From 13ddf8100f7b4aace962598a75aadbf228c4aaa7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Kubler?= Date: Tue, 17 May 2011 22:34:31 +0200 Subject: [PATCH] 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 diff --git a/css/images/no.png b/css/images/no.png new file mode 100644 index 0000000000000000000000000000000000000000..fdc0f42125585d0c99e64deddc1e1aaade72a873 GIT binary patch literal 1300 zcmV+v1?&2WP)&uCmh7IUW$e1Bi^=t@X|ra$4UydFj$C zpLTT(KF*NG!5>bW7QNrlaHb6EymNSw!khCRuM}8|h=2%o=FFc@UAa>K*|~FrPX(_L ziPkM$`hEGNNe!bwmv`&5#%ayyHFp>+a^xo;`%Q9Ef02DWaAZsu~+fl7viu zKbZpuD7kx=Km%2}n*fEK}~QmAyA>AQFHVoM8JYrOXaL4b3v z;C#{Y<={Pi?d^=q<%mRZ`7t-(L&+~08JTa42<1C>vSi&lve|3_+LkQQOpn(VE_k8!5`=7zbD&7STZ+%%2G>0P(=!>eVdUwTmzeQA(k;rswcsu5aDS zV0Sma=W@(hx|Ar25D}i4HH&}Zn0sf>B3gsi+)I*EK{;Fs;n@kWAOP(3>tre`nYCyU zaU9dr*~uTh_pA|-=ix{- zyju(m6&Ex6;6d)+zRk^!4$yiegS-?_wP_QzD^_rH)hbd00|;;%zIy;~9`)WlvNpGg zd|3_eOaO+8ig3>1lcWGNV`>7J(o#~H3<~%gP7T8wN4>ZI+s6Q(hYCxQV!7WujwR?U0@)aK=Yd%!jLF@aadLZ1o-STFKT1T}sPj4@6< z5W|fGmOl{Yw|Cf1)N#+r}oYO0000< KMNUMnLSTYk#a43w literal 0 HcmV?d00001 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! - - + +
-- 2.39.5