From 132695ceb1d7ab0e4bfbb141e9e9639111dd25b5 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Tue, 1 Mar 2011 23:20:16 +0100 Subject: Start of the refactoring. Commit is quite big because I forgot to use git right from the beginning. Sorry. --- js/js.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 js/js.js (limited to 'js/js.js') diff --git a/js/js.js b/js/js.js new file mode 100644 index 00000000000..c9ab2222e78 --- /dev/null +++ b/js/js.js @@ -0,0 +1,50 @@ +$(document).ready(function() { + + // Hides the user_menu div : + $('#user_menu').hide(); + + // Sets user_menu link behaviour : + $('#user_menu_link').click(function() { + $('#user').toggleClass('userLinkOn'); + $('#user_menu').slideToggle(250); + return false; + }); + + // Sets browser table behaviour : + $('.browser tr').hover( + function() { + $(this).addClass('mouseOver'); + }, + function() { + $(this).removeClass('mouseOver'); + } + ); + + // Sets logs table behaviour : + $('.logs tr').hover( + function() { + $(this).addClass('mouseOver'); + }, + function() { + $(this).removeClass('mouseOver'); + } + ); + + // Sets the file-action buttons behaviour : + $('td.fileaction a').click(function() { + $(this).parent().append($('#file_menu')); + $('#file_menu').slideToggle(250); + return false; + }); + + // Sets the select_all checkbox behaviour : + $('#select_all').click(function() { + + if($(this).attr('checked')) + // Check all + $('.browser input:checkbox').attr('checked', true); + else + // Uncheck all + $('.browser input:checkbox').attr('checked', false); + }); +}); -- cgit v1.2.3 From 61ffa182ee90e1a08538f438fb5528e32b3cf70a Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Wed, 2 Mar 2011 23:06:23 +0100 Subject: Application "files" is able to list the files again, start of splitting css files --- css/styles.css | 21 --------------------- files/css/files.css | 48 +++++++++++++++++++++++++++++++++++++++++++++++ files/index.php | 28 +++++++++++++++++++++++++-- files/js/files.js | 39 ++++++++++++++++++++++++++++++++++++++ files/templates/index.php | 44 ++++++++++++++++++++++++++++++++++++++++++- js/js.js | 38 ------------------------------------- lib/template.php | 2 +- log/index.php | 2 +- 8 files changed, 158 insertions(+), 64 deletions(-) create mode 100644 files/css/files.css create mode 100644 files/js/files.js (limited to 'js/js.js') diff --git a/css/styles.css b/css/styles.css index 771c430c723..4fc5a39b8c0 100644 --- a/css/styles.css +++ b/css/styles.css @@ -571,27 +571,6 @@ p.actions a.delete -/* FILE MENU */ - -#file_menu -{ - display: none; - position: absolute; - background-color: #EEE; -} - -#file_menu ul -{ - list-style-type: none; -} - -#file_menu li a -{ - display: block; - padding: 0.5em 5em 0.5em 2em; - text-decoration: none; -} - /* USER SETTINGS ------------------------------------------------------------ */ diff --git a/files/css/files.css b/files/css/files.css new file mode 100644 index 00000000000..8ab07d45241 --- /dev/null +++ b/files/css/files.css @@ -0,0 +1,48 @@ +/* FILE MENU */ + +#file_menu +{ + display: none; + position: absolute; + background-color: #EEE; +} + +#file_menu ul +{ + list-style-type: none; +} + +#file_menu li a +{ + display: block; + padding: 0.5em 5em 0.5em 2em; + text-decoration: none; +} + +/* FILE TABLE */ + +table td.filesize, table td.date +{ + width: 5em; + padding: 0.5em 1em; + text-align: right; +} + +table td.date +{ + width: 11em; +} + +table td.selection, table th.selection, table td.fileaction +{ + width: 2em; + text-align: center; +} + +table td.filename a +{ + display: block; + background-image: url(../img/file.png); + text-decoration: none; +} + diff --git a/files/index.php b/files/index.php index 538bd87971d..25a9f0297dc 100644 --- a/files/index.php +++ b/files/index.php @@ -22,19 +22,43 @@ */ +// Init owncloud require_once('../lib/base.php'); oc_require( 'template.php' ); + +// Check if we are a user if( !OC_USER::isLoggedIn()){ - header( "Location: ".OC_UTIL::linkto( "index.php" )); + header( "Location: ".OC_HELPER::linkTo( "index.php" )); exit(); } +// Load the files we need +OC_UTIL::addStyle( "files", "files" ); +OC_UTIL::addScript( "files", "files" ); + +// Load the files $dir = isset( $_GET['dir'] ) ? $_GET['dir'] : ''; -$files=OC_FILES::getdirectorycontent( $dir ); +$files = array(); +foreach( OC_FILES::getdirectorycontent( $dir ) as $i ){ + $i["date"] = date( $CONFIG_DATEFORMAT, $i["mtime"] ); + $files[] = $i; +} + +// Make breadcrumb +$breadcrumb = array(); +$pathtohere = "/"; +foreach( explode( "/", $dir ) as $i ){ + if( $i != "" ){ + $pathtohere .= "$i/"; + $breadcrumb[] = array( "dir" => $pathtohere, "name" => $i ); + } +} +// return template $tmpl = new OC_TEMPLATE( "files", "index", "user" ); $tmpl->assign( "files", $files ); +$tmpl->assign( "breadcrumb", $breadcrumb ); $tmpl->printPage(); ?> diff --git a/files/js/files.js b/files/js/files.js new file mode 100644 index 00000000000..9ab573ee92b --- /dev/null +++ b/files/js/files.js @@ -0,0 +1,39 @@ +$(document).ready(function() { + // Sets browser table behaviour : + $('.browser tr').hover( + function() { + $(this).addClass('mouseOver'); + }, + function() { + $(this).removeClass('mouseOver'); + } + ); + + // Sets logs table behaviour : + $('.logs tr').hover( + function() { + $(this).addClass('mouseOver'); + }, + function() { + $(this).removeClass('mouseOver'); + } + ); + + // Sets the file-action buttons behaviour : + $('td.fileaction a').click(function() { + $(this).parent().append($('#file_menu')); + $('#file_menu').slideToggle(250); + return false; + }); + + // Sets the select_all checkbox behaviour : + $('#select_all').click(function() { + + if($(this).attr('checked')) + // Check all + $('.browser input:checkbox').attr('checked', true); + else + // Uncheck all + $('.browser input:checkbox').attr('checked', false); + }); +}); diff --git a/files/templates/index.php b/files/templates/index.php index 9e271bbbcd9..fe7ec903c2a 100644 --- a/files/templates/index.php +++ b/files/templates/index.php @@ -5,4 +5,46 @@ ?>

Files

-# TBD (again) \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + +
NameSizeModified
)" href="" title="">+
+ +
+ +
diff --git a/js/js.js b/js/js.js index c9ab2222e78..244433184f8 100644 --- a/js/js.js +++ b/js/js.js @@ -9,42 +9,4 @@ $(document).ready(function() { $('#user_menu').slideToggle(250); return false; }); - - // Sets browser table behaviour : - $('.browser tr').hover( - function() { - $(this).addClass('mouseOver'); - }, - function() { - $(this).removeClass('mouseOver'); - } - ); - - // Sets logs table behaviour : - $('.logs tr').hover( - function() { - $(this).addClass('mouseOver'); - }, - function() { - $(this).removeClass('mouseOver'); - } - ); - - // Sets the file-action buttons behaviour : - $('td.fileaction a').click(function() { - $(this).parent().append($('#file_menu')); - $('#file_menu').slideToggle(250); - return false; - }); - - // Sets the select_all checkbox behaviour : - $('#select_all').click(function() { - - if($(this).attr('checked')) - // Check all - $('.browser input:checkbox').attr('checked', true); - else - // Uncheck all - $('.browser input:checkbox').attr('checked', false); - }); }); diff --git a/lib/template.php b/lib/template.php index bdb2ebab03b..79899efee49 100644 --- a/lib/template.php +++ b/lib/template.php @@ -41,7 +41,7 @@ function image_path( $app, $file ){ * */ function mimetype_icon( $mimetype ){ - return OC_HELPER::mimetypeIcon( $app, $file ); + return OC_HELPER::mimetypeIcon( $mimetype ); } /** diff --git a/log/index.php b/log/index.php index 58cc1f54021..3cdf3d7c649 100644 --- a/log/index.php +++ b/log/index.php @@ -38,7 +38,7 @@ foreach( $logs as &$i ){ } $tmpl = new OC_TEMPLATE( "log", "index", "user" ); -$tmpl->assign( "log", $logs ); +$tmpl->assign( "logs", $logs ); $tmpl->printPage(); ?> -- cgit v1.2.3 From 3263b80ea94a2d3c8a7d68d8190a93db198e2203 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 17 Apr 2011 00:45:05 +0200 Subject: first-run wizzard wip --- img/task-attention.png | Bin 0 -> 1696 bytes index.php | 7 +++ js/js.js | 18 +++++++ lib/installer.php | 123 +++++++++++++++++++++++++++++++++++++++++++++ templates/error.php | 2 +- templates/installation.php | 52 +++++++++++++++++++ 6 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 img/task-attention.png create mode 100644 lib/installer.php create mode 100644 templates/installation.php (limited to 'js/js.js') diff --git a/img/task-attention.png b/img/task-attention.png new file mode 100644 index 00000000000..35a112e9d53 Binary files /dev/null and b/img/task-attention.png differ diff --git a/index.php b/index.php index b0d48b4acff..b8e1cb24dd5 100644 --- a/index.php +++ b/index.php @@ -29,6 +29,13 @@ require_once( 'template.php' ); $errors=OC_UTIL::checkServer(); if(count($errors)>0){ OC_TEMPLATE::printGuestPage( "", "error", array( "errors" => $errors )); +}elseif(isset($_POST['install']) and $_POST['install']=='true'){ + require_once 'installer.php'; +}elseif (!OC_CONFIG::getValue('installed',false)) { + $hasSQLite=is_callable('sqlite_open'); + $hasMySQL=is_callable('mysql_connect'); + $datadir=OC_CONFIG::getValue('datadir',$SERVERROOT.'/data'); + OC_TEMPLATE::printGuestPage( "", "installation",array('hasSQLite'=>$hasSQLite,'hasMySQL'=>$hasMySQL,'datadir'=>$datadir)); }elseif( OC_USER::isLoggedIn()){ if( isset($_GET["logout"]) and ($_GET["logout"]) ){ OC_USER::logout(); diff --git a/js/js.js b/js/js.js index 244433184f8..86f5885ce62 100644 --- a/js/js.js +++ b/js/js.js @@ -9,4 +9,22 @@ $(document).ready(function() { $('#user_menu').slideToggle(250); return false; }); + + //hide the advanced config + $('#advanced_options').hide(); + $('#use_mysql').hide(); + + // Sets advanced_options link behaviour : + $('#advanced_options_link').click(function() { + $('#advanced').toggleClass('userLinkOn'); + $('#advanced_options').slideToggle(250); + return false; + }); + + $('#mysql').click(function() { + $('#use_mysql').slideDown(250); + }); + $('#sqlite').click(function() { + $('#use_mysql').slideUp(250); + }); }); diff --git a/lib/installer.php b/lib/installer.php new file mode 100644 index 00000000000..a87e7541fc4 --- /dev/null +++ b/lib/installer.php @@ -0,0 +1,123 @@ +0){ + OC_TEMPLATE::printGuestPage( "", "error", array( "errors" => $errors )); + }else{ + header( "Location: $WEBROOT"); + exit(); + } +} + +class OC_INSTALLER{ + public static function install($options){ + $error=array(); + $dbtype=$options['dbtype']; + if(empty($options['login'])){ + $error[]=array('error'=>'username not set'); + }; + if(empty($options['pass'])){ + $error[]=array('error'=>'password not set'); + }; + if(empty($options['directory'])){ + $error[]=array('error'=>'data directory not set'); + }; + if($dbtype=='mysql'){//mysql needs more config options + if(empty($options['dbuser'])){ + $error[]=array('error'=>'database user directory not set'); + }; + if(empty($options['dbpass'])){ + $error[]=array('error'=>'database password directory not set'); + }; + if(empty($options['dbname'])){ + $error[]=array('error'=>'database name directory not set'); + }; + if(empty($options['dbhost'])){ + $error[]=array('error'=>'database host directory not set'); + }; + if(!isset($options['dbtableprefix'])){ + $error[]=array('error'=>'database table prefix directory not set'); + }; + } + if(count($error)==0){ //no errors, good + $username=$options['login']; + $password=$options['pass']; + $datadir=$options['directory']; + + //write the config file + OC_CONFIG::setValue('datadirectory',$datadir); + OC_CONFIG::setValue('dbtype',$dbtype); + if($dbtype=='mysql'){ + $dbuser=$options['dbuser']; + $dbpass=$options['dbpass']; + $dbname=$options['dbname']; + $dbhost=$options['dbhost']; + $dbtableprefix=$options['dbtableprefix']; + OC_CONFIG::setValue('dbname',$dbname); + OC_CONFIG::setValue('dbhost',$dbhost); + OC_CONFIG::setValue('dbtableprefix',$dbtableprefix); + + //check if the database user has admin right + $connection=mysql_connect($dbhost, $dbuser, $dbpass); + if(!$connection) { + $error[]=array('error'=>'mysql username and/or password not valid','you need to enter either an existing account, or the administrative account if you wish to create a new user for ownCloud'); + }else{ + $query="SELECT user FROM mysql.user WHERE user='$dbuser'";//this should be enough to check for admin rights in mysql + if(mysql_query($query,$connection)){ + //use the admin login data for the new database user + self::createDBUser($username,$password); + OC_CONFIG::setValue('dbuser',$username); + OC_CONFIG::setValue('dbpass',$password); + }else{ + OC_CONFIG::setValue('dbuser',$dbuser); + OC_CONFIG::setValue('dbpass',$dbpass); + + //create the database + self::createDatabase($dbname,$dbuser); + } + } + mysql_close($connection); + } + OC_USER::createUser($username,$password); + OC_GROUP::createGroup('admin'); + OC_GROUP::addToGroup($username,'admin'); + OC_CONFIG::setValue('installed',true); + } + return $error; + } + + public static function createDatabase($name,$adminUser,$adminPwd){//TODO refactoring this + $CONFIG_DBHOST=$options['host']; + $CONFIG_DBNAME=$options['name']; + $CONFIG_DBUSER=$options['user']; + $CONFIG_DBPWD=$options['pass']; + $CONFIG_DBTYPE=$options['type']; + //we cant user OC_BD functions here because we need to connect as the administrative user. + $query="CREATE DATABASE IF NOT EXISTS `$name`"; + $result = mysql_query($query,$connection); + if (!$result) { + $entry='DB Error: "'.mysql_error($connection).'"
'; + $entry.='Offending command was: '.$query.'
'; + echo($entry); + } + $query="GRANT ALL PRIVILEGES ON `$name` . * TO '$user'"; + $result = mysql_query($query,$connection); + if (!$result) { + $entry='DB Error: "'.mysql_error($connection).'"
'; + $entry.='Offending command was: '.$query.'
'; + echo($entry); + } + } + + private static function createDBUser($name,$password){ + //we need to create 2 accounts, one for global use and one for local user. if we don't speccify the local one, + // the anonymous user would take precedence when there is one. + $query="CREATE USER 'name'@'localhost' IDENTIFIED BY '$password'"; + $result = mysql_query($query,$connection); + $query="CREATE USER '$name'@'%' IDENTIFIED BY '$password'"; + $result = mysql_query($query,$connection); + } +} + +?> \ No newline at end of file diff --git a/templates/error.php b/templates/error.php index 5b71c1ef751..ae3f029708f 100644 --- a/templates/error.php +++ b/templates/error.php @@ -9,7 +9,7 @@

  • -

    +

  • diff --git a/templates/installation.php b/templates/installation.php new file mode 100644 index 00000000000..6e555e843f2 --- /dev/null +++ b/templates/installation.php @@ -0,0 +1,52 @@ + +
    + " alt="ownCloud" /> +
    + +
    +

    +

    +
    +
    + + MySQL Database +

    +

    +

    + +
    +
    + Advanced ▾ +
    +

    + +

    +

    +

    +
    +

    +

    +

    + + + + + + + + +

    +

    +
    + +
    +
    +
    +

    +
    +
    +
    \ No newline at end of file -- cgit v1.2.3 From 6891e363ea1c130382296a0e4eeef034a08fff70 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Sun, 17 Apr 2011 15:49:54 +0200 Subject: beautiful toggle between cloud and settings --- css/styles.css | 72 ++++++++++++++++++++++++++++++++++++++++----- img/header_background.png | Bin 2953 -> 0 bytes img/header_background2.png | Bin 2402 -> 0 bytes js/js.js | 13 +------- templates/installation.php | 40 +++++++++++-------------- templates/layout.admin.php | 3 +- templates/layout.guest.php | 2 +- templates/layout.user.php | 2 +- templates/login.php | 6 ++-- 9 files changed, 89 insertions(+), 49 deletions(-) delete mode 100644 img/header_background.png delete mode 100644 img/header_background2.png (limited to 'js/js.js') diff --git a/css/styles.css b/css/styles.css index 93829b7ef96..0ee0e14bfb5 100644 --- a/css/styles.css +++ b/css/styles.css @@ -1,6 +1,7 @@ * { margin:0; padding:0; border:0; } body { background-color:#fefefe; background-image:url('../img/body_background.jpg'); background-repeat:repeat-y; background-position:left top; line-height:1.6em; font:normal 80% "Lucida Grande", Arial, Verdana, sans-serif; color:#000; } -#header { height:70px; padding:0.5em 1.5em; background-image:url('../img/header_background.png'); background-repeat:repeat-x; background-position:left top; } +#header { height:70px; padding:0.5em 1.5em; background-image:url('../img/header.png'); background-repeat:repeat-x; background-position:left top; } +#body-settings #header { background-image:url('../img/header-settings.png'); } #owncloud { float:left; margin:0 0 0 2em; } h1 { margin:1em 3em 1em 0; border-bottom:1px solid #666; text-transform:uppercase; font-weight:normal; font-style:italic; color:#666; } p.center { text-align:center; } @@ -21,10 +22,22 @@ legend { padding:0 0.5em; font-size:1.2em; } div.controls { width:91%; margin:1em 1em 1em 2em; padding:0.5em 0; background-color:#f7f7f7; border:1px solid #eee; } -/* LOG IN SCREEN ------------------------------------------------------------ */ -body.login { background-image:none; background-color:#ddd; } -body.login p.info { width:16em; margin:4em auto; padding:1em; background-color:#eee; border:1px solid #ccc; -moz-border-radius:10px; -webkit-border-radius:10px; border-radius:10px; } -#login { margin:0 auto 0 auto; padding:2em 0 0 0; background-image:url('../img/header_background2.png'); background-position:left 0; background-repeat:repeat-x; background-color:#eee; text-align:center; } +/* INSTALLATION ------------------------------------------------------------ +input [type='radio'] { display:block; } +.left { display:block; position:relative; top:2.5em; left:-19em; text-align: right; font-weight:bold; } +input[type='radio'] { padding:10em; vertical-align:middle; } +input+label { font-size:20em; font-weight:bold; vertical-align:middle + */ +legend { font-weight:bold; } +legend abbr { border-bottom:1px dotted #000; } +form a { color:#000; text-decoration:none; } + #login input[type='text'], #login input[type='password'] { display:block; margin:0 auto .5em; } + + +/* LOG IN ------------------------------------------------------------ */ +#body-login { background-image:none; background-color:#ddd; } +#body-login p.info { width:16em; margin:4em auto; padding:1em; background-color:#eee; border:1px solid #ccc; -moz-border-radius:10px; -webkit-border-radius:10px; border-radius:10px; } +#login { margin:0 auto 0 auto; padding:2em 0 0 0; background-image:url('../img/header-login.png'); background-position:left 0; background-repeat:repeat-x; background-color:#eee; text-align:center; } #login form { margin:2.5em auto 0 auto; padding:0 0 1.5em 0; text-align:center; border-bottom:1px solid #fff; } #login h1 { margin:0; padding:2.5em 0 0 0; border:0; text-align:center; text-transform:lowercase; font-size:1.5em; } #login fieldset { background-color:transparent; border:0; } @@ -32,8 +45,53 @@ body.login p.info { width:16em; margin:4em auto; padding:1em; background-color:# #login label { font-size:1.2em; color:#fff; } #login input { width:8em; margin:0.1em; padding:0.2em 0.5em; border:1px solid #ddd; -moz-border-radius:15px; -webkit-border-radius:15px; border-radius:15px; font-size:2em; color:#666; } #login input:hover, #login input:focus { outline:0; } -#login input[type=submit] { width:5em; border:1px solid #ddd; background-color:#fff; font-size:2em; } -#login input[type=submit]:hover, #login input[type=submit]:focus { background-color:#ccc; outline:0; } +#login input[type='submit'] { width:5em; border:1px solid #ddd; background-color:#fff; font-size:2em; } +#login input[type= + + + + ownCloud + + + + + + + + + + +
    + ownCloud +
    + +
    + + +
    +
    + MySQL Database + + + +
    +
    + Advanced ▾ +
    +

    + +

    +

    +
    +
    +
    +

    +
    +
    +
    +

    ownCloud is a personal cloud which runs on your own server.

    + + 'submit']:hover, #login input[type=submit]:focus { background-color:#ccc; outline:0; } /* META NAVIGATION (Settings, Log out) ---------------------------------------------------------------- */ #metanav { float:right; position:relative; top:1.5em; list-style:none; margin:0; padding:0; } diff --git a/img/header_background.png b/img/header_background.png deleted file mode 100644 index d377f65186d..00000000000 Binary files a/img/header_background.png and /dev/null differ diff --git a/img/header_background2.png b/img/header_background2.png deleted file mode 100644 index b0160e02d1f..00000000000 Binary files a/img/header_background2.png and /dev/null differ diff --git a/js/js.js b/js/js.js index 86f5885ce62..06d4478357c 100644 --- a/js/js.js +++ b/js/js.js @@ -1,15 +1,4 @@ -$(document).ready(function() { - - // Hides the user_menu div : - $('#user_menu').hide(); - - // Sets user_menu link behaviour : - $('#user_menu_link').click(function() { - $('#user').toggleClass('userLinkOn'); - $('#user_menu').slideToggle(250); - return false; - }); - +$(document).ready(function() { //hide the advanced config $('#advanced_options').hide(); $('#use_mysql').hide(); diff --git a/templates/installation.php b/templates/installation.php index be4693288b2..cfbe53813e0 100644 --- a/templates/installation.php +++ b/templates/installation.php @@ -1,36 +1,30 @@ -
    " alt="ownCloud" /> -
    +
    -

    -

    + +
    MySQL Database -

    -

    -

    + + +
    Advanced ▾
    -

    + -

    -

    -

    + +
    -

    -

    -

    + + + @@ -39,13 +33,13 @@ -

    -

    + +
    -

    -

    + +
    @@ -53,4 +47,4 @@

    -
    \ No newline at end of file + diff --git a/templates/layout.admin.php b/templates/layout.admin.php index 6f8b4302d3a..6b1e73fd3a4 100644 --- a/templates/layout.admin.php +++ b/templates/layout.admin.php @@ -12,13 +12,12 @@ - + diff --git a/templates/layout.guest.php b/templates/layout.guest.php index dc16a1183c9..c9575530820 100644 --- a/templates/layout.guest.php +++ b/templates/layout.guest.php @@ -12,7 +12,7 @@ - +

    ownCloud is a personal cloud which runs on your own server.

    diff --git a/templates/layout.user.php b/templates/layout.user.php index b03fca93082..4e9190d91ff 100644 --- a/templates/layout.user.php +++ b/templates/layout.user.php @@ -12,7 +12,7 @@ - + -- cgit v1.2.3 From 8dcfd0ee8abc72d5446fb9520c52328ba6cb663a Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Sun, 17 Apr 2011 18:00:10 +0200 Subject: CSS width bugfix & beautiful radio buttons for installation --- css/styles.css | 32 ++++++++++++++++---------------- js/js.js | 6 ++++++ templates/installation.php | 6 +++--- 3 files changed, 25 insertions(+), 19 deletions(-) (limited to 'js/js.js') diff --git a/css/styles.css b/css/styles.css index eace46635e9..9d39151641a 100644 --- a/css/styles.css +++ b/css/styles.css @@ -1,8 +1,6 @@ * { margin:0; padding:0; border:0; } -body { position:absolute; background:#fefefe url('../img/body_background.jpg') repeat-y left top; line-height:1.6em; font:normal 80% "Lucida Grande", Arial, Verdana, sans-serif; color:#000; } -#header { position:fixed; width:100%; height:5.5em; padding:0.5em 1.5em; background:url('../img/header-a.png') repeat-x left top; } -#plugins { position:fixed; } -#main { margin-top:7em; } +body { background:#fefefe url('../img/body_background.jpg') repeat-y left top; font:normal 80%/1.6em "Lucida Grande", Arial, Verdana, sans-serif; color:#000; } +#header { position:fixed; top:0; z-index:100; width:100%; height:5.5em; padding:0.5em 1.5em; background:url('../img/header-a.png') repeat-x left top; } #body-settings #header { background-image:url('../img/header-settings-a.png'); } #owncloud { float:left; margin:0 0 0 2em; } h1 { margin:1em 3em 1em 0; border-bottom:1px solid #666; text-transform:uppercase; font-weight:normal; font-style:italic; color:#666; } @@ -24,16 +22,15 @@ legend { padding:0 0.5em; font-size:1.2em; } div.controls { width:91%; margin:1em 1em 1em 2em; padding:0.5em 0; background-color:#f7f7f7; border:1px solid #eee; } -/* INSTALLATION ------------------------------------------------------------ -input [type='radio'] { display:block; } -.left { display:block; position:relative; top:2.5em; left:-19em; text-align: right; font-weight:bold; } -input[type='radio'] { padding:10em; vertical-align:middle; } -input+label { font-size:20em; font-weight:bold; vertical-align:middle - */ +/* INSTALLATION ------------------------------------------------------------ */ legend { font-weight:bold; } legend abbr { border-bottom:1px dotted #000; } form a { color:#000; text-decoration:none; } - #login input[type='text'], #login input[type='password'] { display:block; margin:0 auto .5em; } +#login input[type='text'], #login input[type='password'] { display:block; margin:0 auto .5em; } +#login input[type='radio'] { display:none; } +#login input[type='radio']+label { margin:1em .1em; padding:0.2em 0.5em; border:1px solid #ddd; -moz-border-radius:15px; -webkit-border-radius:15px; border-radius:15px; font-size:2em; color:#666; background-color:#fff; } +#login input[type='radio']+label:hover, #login input[type='radio']+label:focus { background-color:#ccc; outline:0; } +.left { display:block; position:relative; top:2.5em; left:-19em; text-align: right; font-weight:bold; } /* LOG IN ------------------------------------------------------------ */ @@ -44,12 +41,15 @@ form a { color:#000; text-decoration:none; } #login h1 { margin:0; padding:2.5em 0 0 0; border:0; text-align:center; text-transform:lowercase; font-size:1.5em; } #login fieldset { background-color:transparent; border:0; } #login fieldset p { margin:1em 0 0 0; padding:0; text-align:center; } -#login label { font-size:1.2em; color:#fff; } +#login label { font-size:1.2em; } #login input { width:8em; margin:0.1em; padding:0.2em 0.5em; border:1px solid #ddd; -moz-border-radius:15px; -webkit-border-radius:15px; border-radius:15px; font-size:2em; color:#666; } #login input:hover, #login input:focus { outline:0; } -#login input[type='submit'] { width:5em; border:1px solid #ddd; background-color:#fff; font-size:2em; } +#login input[type='submit'] { width:5em; background-color:#fff; } #login input[type='submit']:hover, #login input[type=submit]:focus { background-color:#ccc; outline:0; } +.prettybutton { margin:0.1em; padding:0.2em 0.5em; border:1px solid #ddd; -moz-border-radius:15px; -webkit-border-radius:15px; border-radius:15px; font-size:2em; color:#666; background-color:#fff; } +.prettybutton:hover, .prettybutton:focus { background-color:#ccc; outline:0; } + /* META NAVIGATION (Settings, Log out) ---------------------------------------------------------------- */ #metanav { float:right; position:relative; top:1.5em; right:2.5em; list-style:none; margin:0; padding:0; } #metanav li { display:inline; } @@ -57,8 +57,8 @@ form a { color:#000; text-decoration:none; } #metanav li a:hover, #metanav li a:focus { background:rgba(0,0,0,.5); -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; outline:0; box-shadow:#555 0 1px 0; -moz-box-shadow:#555 0 1px 0; -webkit-box-shadow:#555 0 1px 0; } #metanav li a img { vertical-align:middle; } -/* PLUGINS MENU ------------------------------------------------------------- */ -#plugins { float:left; width:200px; padding:0; } +/* NAVIGATION ------------------------------------------------------------- */ +#plugins { position:fixed; top:7em; float:left; width:15.7em; padding:0; } #plugins ul { list-style-type:none; border-top:1px solid #ccc; } #plugins a { display:block; padding:0.5em 0.5em 0.5em 3em; background-position:1.5em center; background-repeat:no-repeat; border-bottom:1px solid #ddd; border-top:1px solid #fff; text-decoration:none; font-size:1.2em; color:#666; } #plugins a:hover, #plugins a:focus, #plugins a.selected { background-color:#ccc; border-top:1px solid #ccc; border-bottom:1px solid #ccc; color:#000; outline:0; } @@ -69,7 +69,7 @@ form a { color:#000; text-decoration:none; } #plugins .music { background-image:url('../img/music.png'); } /* CONTENT ------------------------------------------------------------------ */ -#content { margin:0 0 0 230px; } +#content { margin:4em 0 0 16em; } table { width:90%; margin:1em 5em 2em 3em; } table tr.mouseOver td { background-color:#eee; } table th, table td { padding:0; border-bottom:1px solid #ddd; text-align:left; font-style:italic; } diff --git a/js/js.js b/js/js.js index 06d4478357c..2fb67f0ec06 100644 --- a/js/js.js +++ b/js/js.js @@ -2,6 +2,8 @@ $(document).ready(function() { //hide the advanced config $('#advanced_options').hide(); $('#use_mysql').hide(); + $('label.sqlite').css('background-color', '#ddd'); + $('label.mysql').css('background-color', '#fff'); // Sets advanced_options link behaviour : $('#advanced_options_link').click(function() { @@ -12,8 +14,12 @@ $(document).ready(function() { $('#mysql').click(function() { $('#use_mysql').slideDown(250); + $('label.sqlite').css('background-color', '#fff'); + $('label.mysql').css('background-color', '#ddd'); }); $('#sqlite').click(function() { $('#use_mysql').slideUp(250); + $('label.sqlite').css('background-color', '#ddd'); + $('label.mysql').css('background-color', '#fff'); }); }); diff --git a/templates/installation.php b/templates/installation.php index cfbe53813e0..73b9a67743f 100644 --- a/templates/installation.php +++ b/templates/installation.php @@ -19,8 +19,8 @@
    - - + +
    @@ -33,7 +33,7 @@ - +
    -- cgit v1.2.3 From ecd68e0c6e9a1ef4f77f117c9a564f4c99630bab Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Tue, 19 Apr 2011 00:54:36 +0200 Subject: actually know what to put in which login field --- js/js.js | 16 ++++++++++++++++ templates/installation.php | 2 +- templates/login.php | 8 ++++---- 3 files changed, 21 insertions(+), 5 deletions(-) (limited to 'js/js.js') diff --git a/js/js.js b/js/js.js index 2fb67f0ec06..b7d94b5eb6a 100644 --- a/js/js.js +++ b/js/js.js @@ -22,4 +22,20 @@ $(document).ready(function() { $('label.sqlite').css('background-color', '#ddd'); $('label.mysql').css('background-color', '#fff'); }); + + // Hide and show input field values for login form + var textuser = "username"; + var textpassword = "password"; + $("#user").focus(function() { + if($(this).attr("value") == textuser) $(this).attr("value", ""); + }); + $("#user").blur(function() { + if($(this).attr("value") == "") $(this).attr("value", textuser); + }); + $("#password").focus(function() { + if($(this).attr("value") == textpassword) $(this).attr("value", ""); + }); + $("#password").blur(function() { + if($(this).attr("value") == "") $(this).attr("value", textpassword); + }); }); diff --git a/templates/installation.php b/templates/installation.php index 73b9a67743f..725c7f149ef 100644 --- a/templates/installation.php +++ b/templates/installation.php @@ -3,7 +3,7 @@
    - +
    diff --git a/templates/login.php b/templates/login.php index 02ba70be52c..c0defdc2b08 100644 --- a/templates/login.php +++ b/templates/login.php @@ -1,13 +1,13 @@
    - " alt="ownCloud" /> + ownCloud
    - + Login failed! - - + +
    -- cgit v1.2.3 From c7d5e671acdcc73a9740a09249634be051c2968c Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Tue, 19 Apr 2011 01:17:35 +0200 Subject: jQuery-value-hide-foo for the installation form as well --- js/js.js | 34 +++++++++++++++++++--------------- templates/installation.php | 30 +++++++++++++++--------------- 2 files changed, 34 insertions(+), 30 deletions(-) (limited to 'js/js.js') diff --git a/js/js.js b/js/js.js index b7d94b5eb6a..948c3417381 100644 --- a/js/js.js +++ b/js/js.js @@ -23,19 +23,23 @@ $(document).ready(function() { $('label.mysql').css('background-color', '#fff'); }); - // Hide and show input field values for login form - var textuser = "username"; - var textpassword = "password"; - $("#user").focus(function() { - if($(this).attr("value") == textuser) $(this).attr("value", ""); - }); - $("#user").blur(function() { - if($(this).attr("value") == "") $(this).attr("value", textuser); - }); - $("#password").focus(function() { - if($(this).attr("value") == textpassword) $(this).attr("value", ""); - }); - $("#password").blur(function() { - if($(this).attr("value") == "") $(this).attr("value", textpassword); - }); + // Hide and show input field values for login and installation form + var textuser = 'username'; + var textpassword = 'password'; + var textadmin = 'admin username'; + var textdbuser = 'MySQL user'; + var textdbpass = 'password'; + var textdbname = 'database name'; + $('#user').focus(function() { if($(this).attr('value') == textuser) $(this).attr('value', ''); }); + $('#user').blur(function() { if($(this).attr('value') == '') $(this).attr('value', textuser); }); + $('#password').focus(function() { if($(this).attr('value') == textpassword) $(this).attr('value', ''); }); + $('#password').blur(function() { if($(this).attr('value') == '') $(this).attr('value', textpassword); }); + $('#admin').focus(function() { if($(this).attr('value') == textadmin) $(this).attr('value', ''); }); + $('#admin').blur(function() { if($(this).attr('value') == '') $(this).attr('value', textadmin); }); + $('#dbuser').focus(function() { if($(this).attr('value') == textdbuser) $(this).attr('value', ''); }); + $('#dbuser').blur(function() { if($(this).attr('value') == '') $(this).attr('value', textdbuser); }); + $('#dbpass').focus(function() { if($(this).attr('value') == textdbpass) $(this).attr('value', ''); }); + $('#dbpass').blur(function() { if($(this).attr('value') == '') $(this).attr('value', textdbpass); }); + $('#dbname').focus(function() { if($(this).attr('value') == textdbname) $(this).attr('value', ''); }); + $('#dbname').blur(function() { if($(this).attr('value') == '') $(this).attr('value', textdbname); }); }); diff --git a/templates/installation.php b/templates/installation.php index 725c7f149ef..dc6dc5790fc 100644 --- a/templates/installation.php +++ b/templates/installation.php @@ -1,17 +1,17 @@
    - " alt="ownCloud" /> + ownCloud
    - - + +
    MySQL Database - - - + + +
    @@ -22,24 +22,24 @@
    - - - + + + - + - + - - + +
    - - + +
    -- cgit v1.2.3 From 13ddf8100f7b4aace962598a75aadbf228c4aaa7 Mon Sep 17 00:00:00 2001 From: François Kubler Date: Tue, 17 May 2011 22:34:31 +0200 Subject: New installer. * Forms have been revamped (CSS + javascript), * Process has been improved : errors are displayed on the form page, * Some changes in the index.php page so that everything related to installation is in lib/setup.php * Also added a small function in OC_HELPER class to set input values. All these should improve the installation process in terms of ergonomics. Well, I do hope so. --- css/images/no.png | Bin 0 -> 1300 bytes css/styles.css | 182 +++++++++++++++++++++++++++++++++++----- index.php | 66 ++++++++------- js/js.js | 45 ++-------- lib/helper.php | 26 +++++- lib/setup.php | 204 ++++++++++++++++++++++++++------------------- templates/installation.php | 89 +++++++++++--------- templates/login.php | 7 +- 8 files changed, 401 insertions(+), 218 deletions(-) create mode 100644 css/images/no.png (limited to 'js/js.js') diff --git a/css/images/no.png b/css/images/no.png new file mode 100644 index 00000000000..fdc0f421255 Binary files /dev/null and b/css/images/no.png differ diff --git a/css/styles.css b/css/styles.css index 0f4d8c5df80..2790c5c0492 100644 --- a/css/styles.css +++ b/css/styles.css @@ -25,24 +25,169 @@ div.controls { width:91%; margin:1em 1em 1em 2em; padding:0.5em 0; background-co /* LOG IN & INSTALLATION ------------------------------------------------------------ */ #body-login { width:100%; background-image:none; background-color:#ddd; } #body-login p.info { width:16em; margin:4em auto; padding:1em; background-color:#eee; border:1px solid #ccc; -moz-border-radius:10px; -webkit-border-radius:10px; border-radius:10px; } -#login { margin:0 auto 0 auto; padding:2em 0 0 0; background:#eee url('../img/header-login.png') repeat-x left 0; text-align:center; } -#login form { margin:2.5em auto 0 auto; padding:0 0 1.5em 0; text-align:center; border-bottom:1px solid #fff; } -#login form a { color:#000; text-decoration:none; } -#login h1 { margin:0; padding:2.5em 0 0 0; border:0; text-align:center; text-transform:lowercase; font-size:1.5em; } -#login fieldset { background-color:transparent; border:0; } -#login fieldset p { margin:1em 0 0 0; padding:0; text-align:center; } -#login legend { font-weight:bold; margin-left:45%; } -#login legend abbr { border-bottom:1px dotted #000; } -#login label { font-size:1.2em; display:inline; position:relative; top:2em; left:-12em; text-align:right; font-weight:bold; } -#login input { width:8em; margin:0.1em; padding:0.2em 0.5em; border:1px solid #ddd; -moz-border-radius:15px; -webkit-border-radius:15px; border-radius:15px; font-size:2em; color:#666; } -#login input:hover, #login input:focus { outline:0; } -#login input[type='submit'] { width:5em; background-color:#fff; } -#login input[type='submit']:hover, #login input[type=submit]:focus { background-color:#ccc; outline:0; } -#login input[type='text'], #login input[type='password'] { display:block; margin:0 auto .5em; } -#login input[type='radio'] { display:none; } -#login input[type='radio']+label { margin:1em .1em; padding:0.2em 0.5em; border:1px solid #ddd; -moz-border-radius:15px; -webkit-border-radius:15px; border-radius:15px; font-size:2em; color:#666; background-color:#fff; } -#login input[type='radio']+label:hover, #login input[type='radio']+label:focus { background-color:#ccc; outline:0; } -#login #use_mysql { margin-top:1.5em; } + +#login +{ + margin: 0 auto 0 auto; + padding: 2em 0 0 0; + background-image: url(../img/header-login.png); + background-position: left 0; + background-repeat: repeat-x; + background-color: #EEE; + border-bottom: 1px solid #FFF; + text-align: center; +} + +#login_form +{ + width: 20em; + margin: 4em auto; + padding: 0; +} + +#login_form fieldset +{ + background-color: transparent; + border: 0; +} + +#login_form fieldset p +{ + margin: 0.5em 0 0 0; + padding: 0; + text-align: left; +} + +#login_form fieldset p.submit +{ + margin: 2em 0 0 0; + padding: 1em 0 0 0; + border-top: 1px solid #DDD; + text-align: right; +} + +#login_form label +{ + font-size: 1em; + color: #666; +} + +#login_form input +{ + width: 100%; + margin: 0 0 0.5em 0; + padding: 0.5em; + border: 1px solid #DDD; + -moz-border-radius: 15px; + -webkit-border-radius: 15px; + border-radius: 15px; + font-size: 1.5em; + color: #333; + text-align: center; +} + +#login_form input[type=submit] +{ + width: auto; + margin: 1em 0 0 0.5em; + text-align: center; + border: 1px solid #DDD; + background-color: #FFF; + -moz-border-radius: 15px; + -webkit-border-radius: 15px; + border-radius: 15px; + font-size: 1.5em +} + +#login_form input[type=submit]:hover +{ + border: 1px solid #666; + background-color: #666; + color: #FFF; +} + + +#setup_form { + margin: 3em auto; + text-align: left; + width: 720px; +} + +#setup_form #use_mysql { + font-size: 0.9em; + margin: 0 0 0 1em; +} + +#setup_form p.intro { + color: #666; + font-size: 1.3em; + margin: 4em 0 3em 0; + padding: 0; + text-align: center; +} + +#setup_form ul.errors { + background-image: url(images/no.png); + background-position: 1em 1em; + background-repeat: no-repeat; + background-color: #FED7D7; + border: 1px solid #F00; + font-size: 1.2em; + list-style-indent: inside; + margin: 0 0 4em 0; + padding: 1em 1em 1em 5em; +} + +#setup_form fieldset { + margin: 0 0 3em 0; +} + +#setup_form p { + line-height: 1.8em; +} + +#setup_form legend { + font-weight: normal; +} + +#setup_form label { + cursor: pointer; + display: block; + float: left; + margin: 0 0 0.2em 0; + text-align: right; + width: 40%; +} + +#setup_form input[type='text'], +#setup_form input[type='password'] { + font-size: 1em; + margin: 0 0 0 0.5em; + padding: 0.3em; +} + +#setup_form input[type='radio'] { + margin: 0 0 0 1em; +} + +#setup_form input[type='submit'] { + background-color: #DDD; + border: 1px solid #999; + color: #666; + font-size: 1.2em; +} + +#setup_form input[type='submit']:hover { + border-color: #000; + color: #000; +} + +#setup_form p.submit { + padding: 0 0 1em 0; + text-align: center; +} + + .prettybutton { margin:0.1em; padding:0.2em 0.5em; border:1px solid #ddd; -moz-border-radius:15px; -webkit-border-radius:15px; border-radius:15px; font-size:1.5em; text-decoration:none; color:#666; background-color:#fff; } .prettybutton:hover, .prettybutton:focus { background-color:#ccc; outline:0; } @@ -95,7 +240,6 @@ table td.delete { background-image:url('../img/delete.png'); } #fileList tr input[type=checkbox] { display:none; } #fileList tr input[type=checkbox]:checked { display:inline; } #fileList tr:hover input[type=checkbox] { display:inline; } -a.dropArrow{ background-image:url('../img/drop-arrow.png'); width:16px; height:16px; display:block} /* NAVIGATION BAR */ p.nav { margin:1em 0 0 2em; padding:0.8em; line-height:16px; font-weight:bold; } diff --git a/index.php b/index.php index 0fafdc45d22..f4d6f27a3c4 100644 --- a/index.php +++ b/index.php @@ -21,45 +21,55 @@ * */ -$RUNTIME_NOAPPS=true;//no apps, yet +$RUNTIME_NOAPPS = TRUE; //no apps, yet -require_once( 'lib/base.php' ); -require_once( 'appconfig.php' ); -require_once( 'template.php' ); +require_once(dirname(__FILE__).'/lib/base.php'); +require_once('appconfig.php'); +require_once('template.php'); +$not_installed = !OC_CONFIG::getValue('installed', false); +$install_called = (isset($_POST['install']) AND $_POST['install']=='true'); -// check if the server is correctly configured for ownCloud -$errors=OC_UTIL::checkServer(); -if(count($errors)>0){ - OC_TEMPLATE::printGuestPage( "", "error", array( "errors" => $errors )); -}elseif(isset($_POST['install']) and $_POST['install']=='true'){ - require_once 'setup.php'; -}elseif (!OC_CONFIG::getValue('installed',false)) { - $hasSQLite=is_callable('sqlite_open'); - $hasMySQL=is_callable('mysql_connect'); - $datadir=OC_CONFIG::getValue('datadir',$SERVERROOT.'/data'); - OC_TEMPLATE::printGuestPage( "", "installation",array('hasSQLite'=>$hasSQLite,'hasMySQL'=>$hasMySQL,'datadir'=>$datadir)); -}elseif( OC_USER::isLoggedIn()){ - if( isset($_GET["logout"]) and ($_GET["logout"]) ){ +// First step : check if the server is correctly configured for ownCloud : +$errors = OC_UTIL::checkServer(); +if(count($errors) > 0) { + OC_TEMPLATE::printGuestPage("", "error", array("errors" => $errors)); +} + +// Setup required : +elseif($not_installed OR $install_called) { + require_once('setup.php'); +} + +// Someone is logged in : +elseif(OC_USER::isLoggedIn()) { + if(isset($_GET["logout"]) and ($_GET["logout"])) { OC_USER::logout(); - header( "Location: $WEBROOT"); + header("Location: $WEBROOT"); exit(); } - else{ - header( "Location: ".$WEBROOT.'/'.OC_APPCONFIG::getValue( "core", "defaultpage", "files/index.php" )); + else { + header("Location: ".$WEBROOT.'/'.OC_APPCONFIG::getValue("core", "defaultpage", "files/index.php")); exit(); } -}elseif(isset($_POST["user"])){ +} + +// Someone wants to log in : +elseif(isset($_POST["user"])) { OC_APP::loadApps(); - if( OC_USER::login( $_POST["user"], $_POST["password"] )){ - header( "Location: ".$WEBROOT.'/'.OC_APPCONFIG::getValue( "core", "defaultpage", "files/index.php" )); + if(OC_USER::login($_POST["user"], $_POST["password"])) { + header("Location: ".$WEBROOT.'/'.OC_APPCONFIG::getValue("core", "defaultpage", "files/index.php")); exit(); - }else{ - OC_TEMPLATE::printGuestPage( "", "login", array( "error" => true)); } -}else{ + else { + OC_TEMPLATE::printGuestPage("", "login", array("error" => true)); + } +} + +// For all others cases, we display the guest page : +else { OC_APP::loadApps(); - OC_TEMPLATE::printGuestPage( "", "login", array( "error" => false )); + OC_TEMPLATE::printGuestPage("", "login", array("error" => false)); } -?> +?> \ No newline at end of file diff --git a/js/js.js b/js/js.js index 948c3417381..a6470b99bf6 100644 --- a/js/js.js +++ b/js/js.js @@ -1,45 +1,14 @@ $(document).ready(function() { - //hide the advanced config - $('#advanced_options').hide(); - $('#use_mysql').hide(); - $('label.sqlite').css('background-color', '#ddd'); - $('label.mysql').css('background-color', '#fff'); - - // Sets advanced_options link behaviour : - $('#advanced_options_link').click(function() { - $('#advanced').toggleClass('userLinkOn'); - $('#advanced_options').slideToggle(250); - return false; + // Hide the MySQL config div if needed : + if(!$('#mysql').is(':checked')) { + $('#use_mysql').hide(); + } + + $('#sqlite').click(function() { + $('#use_mysql').slideUp(250); }); $('#mysql').click(function() { $('#use_mysql').slideDown(250); - $('label.sqlite').css('background-color', '#fff'); - $('label.mysql').css('background-color', '#ddd'); }); - $('#sqlite').click(function() { - $('#use_mysql').slideUp(250); - $('label.sqlite').css('background-color', '#ddd'); - $('label.mysql').css('background-color', '#fff'); - }); - - // Hide and show input field values for login and installation form - var textuser = 'username'; - var textpassword = 'password'; - var textadmin = 'admin username'; - var textdbuser = 'MySQL user'; - var textdbpass = 'password'; - var textdbname = 'database name'; - $('#user').focus(function() { if($(this).attr('value') == textuser) $(this).attr('value', ''); }); - $('#user').blur(function() { if($(this).attr('value') == '') $(this).attr('value', textuser); }); - $('#password').focus(function() { if($(this).attr('value') == textpassword) $(this).attr('value', ''); }); - $('#password').blur(function() { if($(this).attr('value') == '') $(this).attr('value', textpassword); }); - $('#admin').focus(function() { if($(this).attr('value') == textadmin) $(this).attr('value', ''); }); - $('#admin').blur(function() { if($(this).attr('value') == '') $(this).attr('value', textadmin); }); - $('#dbuser').focus(function() { if($(this).attr('value') == textdbuser) $(this).attr('value', ''); }); - $('#dbuser').blur(function() { if($(this).attr('value') == '') $(this).attr('value', textdbuser); }); - $('#dbpass').focus(function() { if($(this).attr('value') == textdbpass) $(this).attr('value', ''); }); - $('#dbpass').blur(function() { if($(this).attr('value') == '') $(this).attr('value', textdbpass); }); - $('#dbname').focus(function() { if($(this).attr('value') == textdbname) $(this).attr('value', ''); }); - $('#dbname').blur(function() { if($(this).attr('value') == '') $(this).attr('value', textdbname); }); }); diff --git a/lib/helper.php b/lib/helper.php index da566a318ac..c57c83e1ef9 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -60,8 +60,8 @@ class OC_HELPER { global $SERVERROOT; global $WEBROOT; // Check if the app is in the app folder - if( file_exists( "$SERVERROOT/apps/$app/img/$image" )){ - return "$WEBROOT/apps/$app/img/$image"; + if( file_exists( "$SERVERROOT/apps/img/$app/$image" )){ + return "$WEBROOT/apps/img/$app/$image"; } if( !empty( $app )){ return "$WEBROOT/$app/img/$image"; @@ -187,6 +187,28 @@ class OC_HELPER { else return FALSE; } + + /** + * @brief Checks $_REQUEST contains a var for the $s key. If so, returns the html-escaped value of this var; otherwise returns the default value provided by $d. + * @param $s name of the var to escape, if set. + * @param $d default value. + * @returns the print-safe value. + * + */ + + //FIXME: should also check for value validation (i.e. the email is an email). + public static function init_var($s, $d="") { + $r = $d; + if(isset($_REQUEST[$s]) && !empty($_REQUEST[$s])) + $r = stripslashes(htmlspecialchars($_REQUEST[$s])); + + return $r; + } + + public static function init_radio($s, $v, $d) { + if((isset($_REQUEST[$s]) && $_REQUEST[$s]==$v) || $v == $d) + print "checked=\"checked\" "; + } } ?> diff --git a/lib/setup.php b/lib/setup.php index 9b416c8c95e..d80408de988 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -1,145 +1,175 @@ 0){ - OC_TEMPLATE::printGuestPage( "", "error", array( "errors" => $errors )); - }else{ - header( "Location: $WEBROOT"); +$hasSQLite = is_callable('sqlite_open'); +$hasMySQL = is_callable('mysql_connect'); +$datadir = OC_CONFIG::getValue('datadir', $SERVERROOT.'/data'); +$opts = array( + 'hasSQLite' => $hasSQLite, + 'hasMySQL' => $hasMySQL, + 'directory' => $datadir, + 'errors' => array(), +); + +if(isset($_POST['install']) AND $_POST['install']=='true') { + // We have to launch the installation process : + $e = OC_SETUP::install($_POST); + $errors = array('errors' => $e); + + if(count($e) > 0) { + //OC_TEMPLATE::printGuestPage("", "error", array("errors" => $errors)); + $options = array_merge($_POST, $opts, $errors); + OC_TEMPLATE::printGuestPage("", "installation", $options); + } + else { + header("Location: $WEBROOT"); exit(); } } +else { + OC_TEMPLATE::printGuestPage("", "installation", $opts); +} -class OC_SETUP{ - public static function install($options){ - $error=array(); - $dbtype=$options['dbtype']; - if(empty($options['login'])){ - $error[]=array('error'=>'username not set'); - }; - if(empty($options['pass'])){ - $error[]=array('error'=>'password not set'); - }; - if(empty($options['directory'])){ - $error[]=array('error'=>'data directory not set'); - }; - if($dbtype=='mysql'){//mysql needs more config options - if(empty($options['dbuser'])){ - $error[]=array('error'=>'database user not set'); - }; - if(empty($options['dbpass'])){ - $error[]=array('error'=>'database password not set'); - }; - if(empty($options['dbname'])){ - $error[]=array('error'=>'database name not set'); - }; - if(empty($options['dbhost'])){ - $error[]=array('error'=>'database host not set'); - }; - if(!isset($options['dbtableprefix'])){ - $error[]=array('error'=>'database table prefix not set'); - }; +class OC_SETUP { + public static function install($options) { + $error = array(); + $dbtype = $options['dbtype']; + + if(empty($options['adminlogin'])) { + $error[] = 'STEP 1 : admin login is not set.'; + } + if(empty($options['adminpass'])) { + $error[] = 'STEP 1 : admin password is not set.'; + } + if(empty($options['directory'])) { + $error[] = 'STEP 2 : data directory path is not set.'; + } + if($dbtype=='mysql') { //mysql needs more config options + if(empty($options['dbuser'])) { + $error[] = 'STEP 3 : MySQL database user is not set.'; + } + if(empty($options['dbpass'])) { + $error[] = 'STEP 3 : MySQL database password is not set.'; + } + if(empty($options['dbname'])) { + $error[] = 'STEP 3 : MySQL database name is not set.'; + } + if(empty($options['dbhost'])) { + $error[] = 'STEP 3 : MySQL database host is not set.'; + } + if(!isset($options['dbtableprefix'])) { + $error[] = 'STEP 3 : MySQL database table prefix is not set.'; + } } - if(count($error)==0){ //no errors, good - $username=$options['login']; - $password=$options['pass']; - $datadir=$options['directory']; + + if(count($error) == 0) { //no errors, good + $username = htmlspecialchars_decode($options['adminlogin']); + $password = htmlspecialchars_decode($options['adminpass']); + $datadir = htmlspecialchars_decode($options['directory']); //write the config file - OC_CONFIG::setValue('datadirectory',$datadir); - OC_CONFIG::setValue('dbtype',$dbtype); - if($dbtype=='mysql'){ - $dbuser=$options['dbuser']; - $dbpass=$options['dbpass']; - $dbname=$options['dbname']; - $dbhost=$options['dbhost']; - $dbtableprefix=$options['dbtableprefix']; - OC_CONFIG::setValue('dbname',$dbname); - OC_CONFIG::setValue('dbhost',$dbhost); - OC_CONFIG::setValue('dbtableprefix',$dbtableprefix); + OC_CONFIG::setValue('datadirectory', $datadir); + OC_CONFIG::setValue('dbtype', $dbtype); + if($dbtype == 'mysql') { + $dbuser = $options['dbuser']; + $dbpass = $options['dbpass']; + $dbname = $options['dbname']; + $dbhost = $options['dbhost']; + $dbtableprefix = $options['dbtableprefix']; + OC_CONFIG::setValue('dbname', $dbname); + OC_CONFIG::setValue('dbhost', $dbhost); + OC_CONFIG::setValue('dbtableprefix', $dbtableprefix); //check if the database user has admin right - $connection=@mysql_connect($dbhost, $dbuser, $dbpass); + $connection = @mysql_connect($dbhost, $dbuser, $dbpass); if(!$connection) { - $error[]=array('error'=>'mysql username and/or password not valid','hint'=>'you need to enter either an existing account, or the administrative account if you wish to create a new user for ownCloud'); - }else{ - $query="SELECT user FROM mysql.user WHERE user='$dbuser'";//this should be enough to check for admin rights in mysql - if(mysql_query($query,$connection)){ - self::createDBUser($username,$password,$connection); + $error[] = array( + 'error' => 'mysql username and/or password not valid', + 'hint' => 'you need to enter either an existing account, or the administrative account if you wish to create a new user for ownCloud' + ); + } + else { + $query="SELECT user FROM mysql.user WHERE user='$dbuser'"; //this should be enough to check for admin rights in mysql + if(mysql_query($query, $connection)) { + self::createDBUser($username, $password, $connection); //use the admin login data for the new database user - OC_CONFIG::setValue('dbuser',$username); - OC_CONFIG::setValue('dbpassword',$password); + OC_CONFIG::setValue('dbuser', $username); + OC_CONFIG::setValue('dbpassword', $password); //create the database - self::createDatabase($dbname,$username,$connection); - }else{ - OC_CONFIG::setValue('dbuser',$dbuser); - OC_CONFIG::setValue('dbpassword',$dbpass); + self::createDatabase($dbname, $username, $connection); + } + else { + OC_CONFIG::setValue('dbuser', $dbuser); + OC_CONFIG::setValue('dbpassword', $dbpass); //create the database - self::createDatabase($dbname,$dbuser,$connection); + self::createDatabase($dbname, $dbuser, $connection); } + //fill the database if needed $query="SELECT * FROM $dbname.{$dbtableprefix}users"; $result = mysql_query($query,$connection); - if (!$result) { + if(!$result) { OC_DB::createDbFromStructure('db_structure.xml'); } mysql_close($connection); } - }else{ + } + else { //in case of sqlite, we can always fill the database OC_DB::createDbFromStructure('db_structure.xml'); } - if(count($error)==0){ + + if(count($error) == 0) { //create the user and group - OC_USER::createUser($username,$password); + OC_USER::createUser($username, $password); OC_GROUP::createGroup('admin'); - OC_GROUP::addToGroup($username,'admin'); + OC_GROUP::addToGroup($username, 'admin'); //create htaccess files for apache hosts - self::createHtaccess();//TODO detect if apache is used + self::createHtaccess(); //TODO detect if apache is used //and we are done - OC_CONFIG::setValue('installed',true); + OC_CONFIG::setValue('installed', true); } } + return $error; } - public static function createDatabase($name,$user,$connection){ + public static function createDatabase($name,$user,$connection) { //we cant user OC_BD functions here because we need to connect as the administrative user. - $query="CREATE DATABASE IF NOT EXISTS `$name`"; - $result = mysql_query($query,$connection); - if (!$result) { + $query = "CREATE DATABASE IF NOT EXISTS `$name`"; + $result = mysql_query($query, $connection); + if(!$result) { $entry='DB Error: "'.mysql_error($connection).'"
    '; $entry.='Offending command was: '.$query.'
    '; echo($entry); } $query="GRANT ALL PRIVILEGES ON `$name` . * TO '$user'"; - $result = mysql_query($query,$connection);//this query will fail if there aren't the right permissons, ignore the error + $result = mysql_query($query, $connection); //this query will fail if there aren't the right permissons, ignore the error } - private static function createDBUser($name,$password,$connection){ - //we need to create 2 accounts, one for global use and one for local user. if we don't speccify the local one, - // the anonymous user would take precedence when there is one. - $query="CREATE USER '$name'@'localhost' IDENTIFIED BY '$password'"; - $result = mysql_query($query,$connection); - $query="CREATE USER '$name'@'%' IDENTIFIED BY '$password'"; - $result = mysql_query($query,$connection); + private static function createDBUser($name,$password,$connection) { + // we need to create 2 accounts, one for global use and one for local user. if we don't speccify the local one, + // the anonymous user would take precedence when there is one. + $query = "CREATE USER '$name'@'localhost' IDENTIFIED BY '$password'"; + $result = mysql_query($query, $connection); + $query = "CREATE USER '$name'@'%' IDENTIFIED BY '$password'"; + $result = mysql_query($query, $connection); } /** * create .htaccess files for apache hosts */ - private static function createHtaccess(){ + private static function createHtaccess() { global $SERVERROOT; global $WEBROOT; - $content="ErrorDocument 404 /$WEBROOT/templates/404.php\n"; - @file_put_contents($SERVERROOT.'/.htaccess',$content); //supress errors in case we don't have permissions for it + $content = "ErrorDocument 404 /$WEBROOT/templates/404.php\n"; + @file_put_contents($SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it - $content="deny from all"; - file_put_contents(OC_CONFIG::getValue('datadirectory',$SERVERROOT.'/data').'/.htaccess',$content); + $content = "deny from all"; + file_put_contents(OC_CONFIG::getValue('datadirectory', $SERVERROOT.'/data').'/.htaccess', $content); } } diff --git a/templates/installation.php b/templates/installation.php index 5c882e81bf0..9d5eb0c4a54 100644 --- a/templates/installation.php +++ b/templates/installation.php @@ -1,50 +1,59 @@
    ownCloud - - + + +

    + Welcome to ownCloud, your personnal cloud.
    + To finish the installation, please follow the 3 remaining steps below. +

    + + 0): ?> +
      + +
    • + +
    + +
    - - + STEP 1 : Create an admin account. +

    +

    + +
    + STEP 2 : Set where to store the data. +

    +
    +
    + STEP 3 : Configure your database. + + +

    I will use a SQLite database. You have nothing to do !

    + + +

    />

    + + + + - MySQL Database - - - - -
    -
    - Advanced ▾ -
    - - - - -
    - - - - - - - - - - - - - -
    - - - - - +

    I will use a MySQL database.

    + + +

    />

    + +
    +

    +

    +

    +

    +

    +
    -
    -

    -
    + +

    diff --git a/templates/login.php b/templates/login.php index c0defdc2b08..845ae831a40 100644 --- a/templates/login.php +++ b/templates/login.php @@ -1,13 +1,12 @@
    ownCloud -
    - +
    Login failed! - - + +
    -- cgit v1.2.3 From 398d4de0f51ac6326c92e909686258aa605a5b82 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 19 May 2011 21:19:37 +0200 Subject: fix some bugs in the first run dialog, and hide advanced setting initially. --- js/js.js | 16 ++++++++++++++-- templates/installation.php | 25 ++++++++++++++++++------- 2 files changed, 32 insertions(+), 9 deletions(-) (limited to 'js/js.js') diff --git a/js/js.js b/js/js.js index a6470b99bf6..a6765ec62db 100644 --- a/js/js.js +++ b/js/js.js @@ -1,9 +1,14 @@ $(document).ready(function() { // Hide the MySQL config div if needed : - if(!$('#mysql').is(':checked')) { + if(!$('#mysql').is(':checked') && $('#hasSQLite').val()=='true') { $('#use_mysql').hide(); } - + + $('#datadirField').hide(250); + if($('#hasSQLite').val()=='true'){ + $('#databaseField').hide(250); + } + $('#sqlite').click(function() { $('#use_mysql').slideUp(250); }); @@ -11,4 +16,11 @@ $(document).ready(function() { $('#mysql').click(function() { $('#use_mysql').slideDown(250); }); + + $('#showAdvanced').click(function() { + $('#datadirField').slideToggle(250); + if($('#hasSQLite').val()=='true'){ + $('#databaseField').slideToggle(250); + } + }); }); diff --git a/templates/installation.php b/templates/installation.php index 9d5eb0c4a54..880beb9a89e 100644 --- a/templates/installation.php +++ b/templates/installation.php @@ -4,31 +4,41 @@

    Welcome to ownCloud, your personnal cloud.
    - To finish the installation, please follow the 3 remaining steps below. + To finish the installation, please follow the steps below.

    0): ?>
      -
    • +
    • + + +

      + + + +
    - STEP 1 : Create an admin account. + Create an admin account.

    -
    - STEP 2 : Set where to store the data. + Advanced '> + +
    + Set where to store the data.

    -
    - STEP 3 : Configure your database. +
    + Configure your database. +

    I will use a SQLite database. You have nothing to do !

    @@ -38,6 +48,7 @@ +

    I will use a MySQL database.

    -- cgit v1.2.3