* 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.tags/v3.0
@@ -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; } |
@@ -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)); | |||
} | |||
?> | |||
?> |
@@ -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); }); | |||
}); |
@@ -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\" "; | |||
} | |||
} | |||
?> |
@@ -1,145 +1,175 @@ | |||
<?php | |||
if(isset($_POST['install']) and $_POST['install']=='true'){ | |||
$errors=OC_SETUP::install($_POST); | |||
if(count($errors)>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).'"<br />'; | |||
$entry.='Offending command was: '.$query.'<br />'; | |||
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); | |||
} | |||
} | |||
@@ -1,50 +1,59 @@ | |||
<div id="login"> | |||
<img src="<?php echo image_path('', 'owncloud-logo-medium-white.png'); ?>" alt="ownCloud" /> | |||
<form action="#" method="post"> | |||
<input type='hidden' name='install' value='true'/> | |||
<form action="index.php" method="post" id="setup_form"> | |||
<input type="hidden" name="install" value="true" /> | |||
<p class="intro"> | |||
Welcome to <strong>ownCloud</strong>, your personnal cloud.<br /> | |||
To finish the installation, please follow the 3 remaining steps below. | |||
</p> | |||
<?php if(count($_['errors']) > 0): ?> | |||
<ul class="errors"> | |||
<?php foreach($_['errors'] as $err): ?> | |||
<li><?php print $err; ?></li> | |||
<?php endforeach; ?> | |||
</ul> | |||
<?php endif; ?> | |||
<fieldset> | |||
<input type="text" name="login" id="admin" value="admin username" /> | |||
<input type="password" name="pass" id="password" value="password" /> | |||
<legend><strong>STEP 1</strong> : Create an <strong>admin account.</strong></legend> | |||
<p><label for="adminlogin">Login :</label><input type="text" name="adminlogin" id="adminlogin" value="<?php print OC_HELPER::init_var('adminlogin'); ?>" /></p> | |||
<p><label for="adminpass">Password :</label><input type="password" name="adminpass" id="adminpass" value="<?php print OC_HELPER::init_var('adminpass'); ?>" /></p> | |||
</fieldset> | |||
<fieldset> | |||
<legend><strong>STEP 2</strong> : Set where to store the data.</legend> | |||
<p><label for="directory">Data directory :</label><input type="text" name="directory" id="directory" value="<?php print OC_HELPER::init_var('directory', $_['directory']); ?>" /></p> | |||
</fieldset> | |||
<fieldset> | |||
<legend><strong>STEP 3</strong> : Configure your database.</legend> | |||
<?php if($_['hasSQLite']): ?> | |||
<?php if(!$_['hasMySQL']): ?> | |||
<p>I will use a SQLite database. You have nothing to do !</p> | |||
<input type="hidden" id="dbtype" name="dbtype" value="sqlite" /> | |||
<?php else: ?> | |||
<p><label class="sqlite" for="sqlite">SQLite </label><input type="radio" name="dbtype" value='sqlite' id="sqlite" <?php OC_HELPER::init_radio('dbtype', 'sqlite', 'sqlite'); ?>/></p> | |||
<?php endif; ?> | |||
<?php endif; ?> | |||
<?php if($_['hasMySQL']): ?> | |||
<?php if(!$_['hasSQLite']): ?> | |||
<legend><abbr title="to use SQLite instead, install it on your server">MySQL</abbr> Database</legend> | |||
<input type="text" name="dbuser" id="dbuser" value="MySQL user" /> | |||
<input type="password" name="dbpass" id="dbpass" value="password" /> | |||
<input type="text" name="dbname" id="dbname" value="database name" /> | |||
<?php endif;?> | |||
</fieldset> | |||
<fieldset id="advanced"> | |||
<legend><a id="advanced_options_link" href="">Advanced ▾</a></legend> | |||
<div id="advanced_options"> | |||
<label>Data directory</label><input type="text" name="directory" value="<?php echo($_['datadir']);?>" /> | |||
<?php if($_['hasMySQL'] and $_['hasSQLite']): ?> | |||
<input type="radio" name="dbtype" value='sqlite' id="sqlite" checked="checked" /><label class="sqlite" for="sqlite">SQLite</label> | |||
<input type="radio" name="dbtype" value='mysql' id="mysql"><label class="mysql" for="mysql">MySQL</label> | |||
<div id="use_mysql"> | |||
<input type="text" name="dbuser" id="dbuser" value="MySQL user" /> | |||
<input type="password" name="dbpass" id="dbpass" value="password" /> | |||
<input type="text" name="dbname" id="dbname" value="database name" /> | |||
<?php endif;?> | |||
<?php if($_['hasMySQL'] and !$_['hasSQLite']): ?> | |||
<input type="hidden" name="dbtype" value="mysql" /> | |||
<?php endif;?> | |||
<?php if(!$_['hasMySQL'] and $_['hasSQLite']): ?> | |||
<input type="hidden" name="dbtype" value="sqlite" /> | |||
<?php endif;?> | |||
<?php if($_['hasMySQL'] and $_['hasSQLite']): ?> | |||
<label>Database host</label><input type="text" name="dbhost" id="dbhost" value="localhost" /> | |||
<label>Table prefix</label><input type="text" name="dbtableprefix" id="dbtableprefix" value="oc_" /> | |||
</div> | |||
<?php endif;?> | |||
<?php if($_['hasMySQL'] and !$_['hasSQLite']): ?> | |||
<label>Database host</label><input type="text" name="dbhost" id="dbhost" value="localhost" /> | |||
<label>Table prefix</label><input type="text" name="dbtableprefix" id="dbtableprefix" value="oc_" /> | |||
<?php endif;?> | |||
<p>I will use a MySQL database.</p> | |||
<input type="hidden" id="dbtype" name="dbtype" value="mysql" /> | |||
<?php else: ?> | |||
<p><label class="mysql" for="mysql">MySQL </label><input type="radio" name="dbtype" value='mysql' id="mysql" <?php OC_HELPER::init_radio('dbtype', 'mysql', 'sqlite'); ?>/></p> | |||
<?php endif; ?> | |||
<div id="use_mysql"> | |||
<p><label for="dbhost">Host :</label><input type="text" name="dbhost" id="dbhost" value="<?php print OC_HELPER::init_var('dbhost', 'localhost'); ?>" /></p> | |||
<p><label for="dbname">Database name :</label><input type="text" name="dbname" id="dbname" value="<?php print OC_HELPER::init_var('dbname'); ?>" /></p> | |||
<p><label for="dbtableprefix">Table prefix :</label><input type="text" name="dbtableprefix" id="dbtableprefix" value="<?php print OC_HELPER::init_var('dbtableprefix', 'oc_'); ?>" /></p> | |||
<p><label for="dbuser">MySQL user login :</label><input type="text" name="dbuser" id="dbuser" value="<?php print OC_HELPER::init_var('dbuser'); ?>" /></p> | |||
<p><label for="dbpass">MySQL user password :</label><input type="password" name="dbpass" id="dbpass" value="<?php print OC_HELPER::init_var('dbpass'); ?>" /></p> | |||
</div> | |||
<?php endif; ?> | |||
</fieldset> | |||
<fieldset> | |||
<p class="submit"><input type="submit" value="Create" /></p> | |||
</fieldset> | |||
<p class="submit"><input type="submit" value="Finish setup" /></p> | |||
</form> | |||
</div> |
@@ -1,13 +1,12 @@ | |||
<div id="login"> | |||
<img src="<?php echo image_path('', 'owncloud-logo-medium-white.png'); ?>" alt="ownCloud" /> | |||
<form action="index.php" method="post"> | |||
<!-- <h1>Sign in :</h1> --> | |||
<form action="index.php" method="post" id="login_form"> | |||
<fieldset> | |||
<?php if($_['error']): ?> | |||
Login failed! | |||
<?php endif; ?> | |||
<input type="text" name="user" id="user" value="username" /> | |||
<input type="password" name="password" id="password" value="password" /> | |||
<input type="text" name="user" id="user" value="" /> | |||
<input type="password" name="password" id="password" value="" /> | |||
<input type="submit" value="Log in" /> | |||
</fieldset> | |||
</form> |