';
if(!isset($_POST['adminpassword']) or empty($_POST['adminpassword']) and $FIRSTRUN) $error.='admin password not set
';
if(!isset($_POST['adminpassword2']) or empty($_POST['adminpassword2']) and $FIRSTRUN) $error.='retype admin password not set
';
if(!isset($_POST['datadirectory']) or empty($_POST['datadirectory'])) $error.='data directory not set
';
if(!isset($_POST['dateformat']) or empty($_POST['dateformat'])) $error.='dteformat not set
';
if(!isset($_POST['dbhost']) or empty($_POST['dbhost'])) $error.='database host not set
';
if(!isset($_POST['dbname']) or empty($_POST['dbname'])) $error.='databasename not set
';
if(!isset($_POST['dbuser']) or empty($_POST['dbuser'])) $error.='database user not set
';
if(!isset($_POST['dbpassword']) or empty($_POST['dbpassword'])) $error.='database password not set
';
if(!isset($_POST['dbpassword2']) or empty($_POST['dbpassword2'])) $error.='retype database password not set
';
if($_POST['dbpassword']<>$_POST['dbpassword2'] ) $error.='database passwords are not the same
';
if($_POST['adminpassword']<>$_POST['adminpassword2'] ) $error.='admin passwords are not the same
';
if(!isset($_POST['adminpassword']) or empty($_POST['adminpassword']) and !$FIRSTRUN){
$_POST['adminpassword']=$CONFIG_ADMINPASSWORD;
}
if(empty($error)) {
//create/fill database
$CONFIG_DBHOST=$_POST['dbhost'];
$CONFIG_DBNAME=$_POST['dbname'];
$CONFIG_DBUSER=$_POST['dbuser'];
$CONFIG_DBPASSWORD=$_POST['dbpassword'];
if(isset($_POST['createdatabase'])){
self::createdatabase($_POST['dbadminuser'],$_POST['dbadminpwd']);
}
if(isset($_POST['filldb'])){
self::filldatabase();
}
//storedata
$config=' ';
$filename=$DOCUMENTROOT.'/config/config.php';
file_put_contents($filename,$config);
header("Location: ".$WEBROOT."/");
}
return($error);
}
}
/**
* Create the database and user
* @param string adminUser
* @param string adminPwd
*
*/
private static function createdatabase($adminUser,$adminPwd){
global $CONFIG_DBHOST;
global $CONFIG_DBNAME;
global $CONFIG_DBUSER;
global $CONFIG_DBPWD;
//we cant user OC_BD functions here because we need to connect as the administrative user.
$connection = @new mysqli($CONFIG_DBHOST, $adminUser, $adminPwd);
if (mysqli_connect_errno()) {
@ob_end_clean();
echo('