Improving the installation process
parent
c532259cef
commit
ba02d0840f
|
|
@ -29,16 +29,8 @@
|
|||
<fieldset class="install">
|
||||
<legend class="install">Database Settings</legend>
|
||||
<ul>
|
||||
<li><label for="login">User:</label>
|
||||
<input type="text" name="db_login" id="db_login" value="{db_login}" class="txt"/>{error.10}</li>
|
||||
<li><label for="password">Password:</label>
|
||||
<input type="password" name="db_password" id="db_password" value="" class="txt"/></li>
|
||||
<li><label for="password2">Re-type password:</label>
|
||||
<input type="password" name="db_password2" id="db_password2" value="" class="txt"/>{error.9}</li>
|
||||
<li><label for="email">Database Host:</label>
|
||||
<input type="text" name="db_host" id="db_host" value="{db_host}" class="txt"/>{error.7}</li>
|
||||
<li><label for="email">Database Name:</label>
|
||||
<input type="text" name="db_name" id="db_name" value="{db_name}" class="txt"/>{error.8}</li>
|
||||
<li><label for="login">Are you the admin? please write the database name User</label>
|
||||
<input type="text" name="db_login" id="db_login" value="{db_login}" class="txt"/>{error.9}</li>
|
||||
</ul>
|
||||
</fieldset><br />
|
||||
<fieldset class="install">
|
||||
|
|
|
|||
|
|
@ -9,42 +9,34 @@ class Install {
|
|||
var $errors_d = array();
|
||||
|
||||
function Install(){
|
||||
$this->errors_d[1]="The login field cannot be empty";
|
||||
$this->errors_d[2]="The password field cannot be empty";
|
||||
$this->errors_d[3]="Password does not match the confirm password";
|
||||
$this->errors_d[4]="The e-mail field cannot be empty";
|
||||
$this->errors_d[5]="The installation URL field cannot be empty";
|
||||
$this->errors_d[6]="Error establishing a database connection";
|
||||
$this->errors_d[7]="Please add a hostname for the database server";
|
||||
$this->errors_d[8]="Please name the database";
|
||||
$this->errors_d[9]="Password does not match the confirm password";
|
||||
$this->errors_d[10]="The login field cannot be empty";
|
||||
$this->errors_d[1]='The login field cannot be empty';
|
||||
$this->errors_d[2]='The password field cannot be empty';
|
||||
$this->errors_d[3]='Password does not match the confirm password';
|
||||
$this->errors_d[4]='The e-mail field cannot be empty';
|
||||
$this->errors_d[5]='The installation URL field cannot be empty';
|
||||
$this->errors_d[6]='Error establishing a database connection';
|
||||
$this->errors_d[9]='For security reasons this field is required. It is the same information that in the config.php file';
|
||||
$this->errors_d[10]='The login field cannot be empty';
|
||||
}
|
||||
|
||||
function run() {
|
||||
|
||||
if (empty($this->data)) false;
|
||||
|
||||
$this->create_db();
|
||||
|
||||
if (!$this->install_db()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function create_db(){
|
||||
$link = mysql_connect(DB_Server, DB_User, DB_Password);
|
||||
if(!$link)
|
||||
die('Could not connect: '.mysql_error());
|
||||
|
||||
$link = mysql_connect($this->data['db_host'], $this->data['db_login'], $this->data['db_password']);
|
||||
if (!$link) {
|
||||
die('Could not connect: ' . mysql_error());
|
||||
}
|
||||
$sql = 'CREATE DATABASE '.DB_name;
|
||||
|
||||
$sql = 'CREATE DATABASE ' . $this->data['db_name'];
|
||||
if (!mysql_query($sql, $link)) {
|
||||
if(!mysql_query($sql, $link)){
|
||||
$link = mysql_close($link);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -191,7 +183,6 @@ class Install {
|
|||
}
|
||||
|
||||
function check_form(){
|
||||
|
||||
$action="";
|
||||
|
||||
if (isset($this->data['action'])){
|
||||
|
|
@ -207,12 +198,12 @@ class Install {
|
|||
$sep_err="";
|
||||
$this->errors = false;
|
||||
|
||||
if (!$this->data['login']) {
|
||||
$this->errors =$this->errors.$sep_err."1";
|
||||
if (!isset($this->data['db_login']) or $this->data['db_login']!=DB_User) {
|
||||
$this->errors =$this->errors.$sep_err."9"; //7,8
|
||||
$sep_err="|";
|
||||
}
|
||||
if (!$this->data['db_login']) {
|
||||
$this->errors =$this->errors.$sep_err."10";
|
||||
if (!$this->data['login']) {
|
||||
$this->errors =$this->errors.$sep_err."1";
|
||||
$sep_err="|";
|
||||
}
|
||||
if (!$this->data['password']) {
|
||||
|
|
@ -227,42 +218,28 @@ class Install {
|
|||
$this->errors=$this->errors.$sep_err."5";
|
||||
$sep_err="|";
|
||||
}
|
||||
if (!$this->data['db_host'] ) {
|
||||
$this->errors=$this->errors.$sep_err."7";
|
||||
$sep_err="|";
|
||||
}
|
||||
if (!$this->data['db_name'] ) {
|
||||
$this->errors=$this->errors.$sep_err."8";
|
||||
$sep_err="|";
|
||||
}
|
||||
if ($this->data['password']!=$_POST['password2']) {
|
||||
$this->errors=$this->errors.$sep_err."3";
|
||||
$sep_err="|";
|
||||
}
|
||||
if ( $_POST['db_password']!=$_POST['db_password2']) {
|
||||
$this->errors=$this->errors.$sep_err."9";
|
||||
$sep_err="|";
|
||||
}
|
||||
|
||||
$off_r= split("," , $this->data['time_offsets']);
|
||||
$this->data['offset_time'] = $off_r[0];
|
||||
$this->data['offset_city'] = $off_r[1];
|
||||
unset($this->data['time_offsets']);
|
||||
|
||||
if (!$this->errors) {
|
||||
|
||||
if ($this->run($this->data)) {
|
||||
if(!$this->errors){
|
||||
if($this->run($this->data))
|
||||
$this->showForm=false;
|
||||
} else {
|
||||
else{
|
||||
$this->errors=$this->errors.$sep_err."6";
|
||||
$sep_err="|";
|
||||
$this->showForm=true;
|
||||
}
|
||||
} else {
|
||||
}else
|
||||
$this->showForm=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
10
install.php
10
install.php
|
|
@ -28,19 +28,23 @@ if($install->is_gelato_installed()){
|
|||
exit;
|
||||
}
|
||||
$install->data = $_POST;
|
||||
|
||||
$install->check_form();
|
||||
$theme = new themes;
|
||||
$theme->set('version',util::version());
|
||||
$theme->set('showForm',$install->showForm);
|
||||
|
||||
#db_password
|
||||
#db_password2
|
||||
$theme->set('db_login',isset($install->data['db_login'])? $install->data['db_login'] : '');
|
||||
$theme->set('db_host',(!empty($install->data['db_host']))? $install->data['db_host'] : 'localhost');
|
||||
$theme->set('db_name',(!empty($install->data['db_name']))? $install->data['db_name'] : 'gelatocms');
|
||||
#$theme->set('db_host',(!empty($install->data['db_host']))? $install->data['db_host'] : 'localhost');
|
||||
#$theme->set('db_name',(!empty($install->data['db_name']))? $install->data['db_name'] : 'gelatocms');
|
||||
$theme->set('login',isset($install->data['login'])?$install->data['login']:'');
|
||||
$theme->set('email',isset($install->data['email'])?$install->data['email']:'');
|
||||
$theme->set('title',isset($install->data['title'])?$install->data['title']:'');
|
||||
$theme->set('description',isset($install->data['description'])?$install->data['description']:'');
|
||||
$theme->set('url_installation',isset($_SERVER['SCRIPT_URI'])?substr($_SERVER["SCRIPT_URI"], 0, -12):'');
|
||||
|
||||
$theme->set('url_installation',(isset($install->data['url_installation']) and $install->data['url_installation'])?$install->data['url_installation']:(isset($_SERVER['SCRIPT_URI'])?substr($_SERVER["SCRIPT_URI"], 0, -12):''));
|
||||
$theme->set('themes',util::getThemes());
|
||||
|
||||
for($c=1;$c<=10;$c++)$errores[$c] = $install->mostrarerror($c);
|
||||
|
|
|
|||
Loading…
Reference in New Issue