Improving the installation process
parent
c532259cef
commit
ba02d0840f
|
|
@ -29,16 +29,8 @@
|
||||||
<fieldset class="install">
|
<fieldset class="install">
|
||||||
<legend class="install">Database Settings</legend>
|
<legend class="install">Database Settings</legend>
|
||||||
<ul>
|
<ul>
|
||||||
<li><label for="login">User:</label>
|
<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.10}</li>
|
<input type="text" name="db_login" id="db_login" value="{db_login}" class="txt"/>{error.9}</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>
|
|
||||||
</ul>
|
</ul>
|
||||||
</fieldset><br />
|
</fieldset><br />
|
||||||
<fieldset class="install">
|
<fieldset class="install">
|
||||||
|
|
|
||||||
|
|
@ -9,44 +9,36 @@ class Install {
|
||||||
var $errors_d = array();
|
var $errors_d = array();
|
||||||
|
|
||||||
function Install(){
|
function Install(){
|
||||||
$this->errors_d[1]="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[2]='The password field cannot be empty';
|
||||||
$this->errors_d[3]="Password does not match the confirm password";
|
$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[4]='The e-mail field cannot be empty';
|
||||||
$this->errors_d[5]="The installation URL 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[6]='Error establishing a database connection';
|
||||||
$this->errors_d[7]="Please add a hostname for the database server";
|
$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[8]="Please name the database";
|
$this->errors_d[10]='The login field cannot be empty';
|
||||||
$this->errors_d[9]="Password does not match the confirm password";
|
|
||||||
$this->errors_d[10]="The login field cannot be empty";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function run() {
|
function run() {
|
||||||
|
|
||||||
if (empty($this->data)) false;
|
if (empty($this->data)) false;
|
||||||
|
|
||||||
$this->create_db();
|
$this->create_db();
|
||||||
|
|
||||||
if (!$this->install_db()) return false;
|
if (!$this->install_db()) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_db(){
|
function create_db(){
|
||||||
|
$link = mysql_connect(DB_Server, DB_User, DB_Password);
|
||||||
|
if(!$link)
|
||||||
|
die('Could not connect: '.mysql_error());
|
||||||
|
|
||||||
|
$sql = 'CREATE DATABASE '.DB_name;
|
||||||
|
|
||||||
$link = mysql_connect($this->data['db_host'], $this->data['db_login'], $this->data['db_password']);
|
if(!mysql_query($sql, $link)){
|
||||||
if (!$link) {
|
|
||||||
die('Could not connect: ' . mysql_error());
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = 'CREATE DATABASE ' . $this->data['db_name'];
|
|
||||||
if (!mysql_query($sql, $link)) {
|
|
||||||
$link = mysql_close($link);
|
$link = mysql_close($link);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_db(){
|
function install_db(){
|
||||||
require_once(Absolute_Path.'config.php');
|
require_once(Absolute_Path.'config.php');
|
||||||
|
|
@ -191,7 +183,6 @@ class Install {
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_form(){
|
function check_form(){
|
||||||
|
|
||||||
$action="";
|
$action="";
|
||||||
|
|
||||||
if (isset($this->data['action'])){
|
if (isset($this->data['action'])){
|
||||||
|
|
@ -207,14 +198,14 @@ class Install {
|
||||||
$sep_err="";
|
$sep_err="";
|
||||||
$this->errors = false;
|
$this->errors = false;
|
||||||
|
|
||||||
if (!$this->data['login']) {
|
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['login']) {
|
||||||
$this->errors =$this->errors.$sep_err."1";
|
$this->errors =$this->errors.$sep_err."1";
|
||||||
$sep_err="|";
|
$sep_err="|";
|
||||||
}
|
}
|
||||||
if (!$this->data['db_login']) {
|
|
||||||
$this->errors =$this->errors.$sep_err."10";
|
|
||||||
$sep_err="|";
|
|
||||||
}
|
|
||||||
if (!$this->data['password']) {
|
if (!$this->data['password']) {
|
||||||
$this->errors=$this->errors.$sep_err."2";
|
$this->errors=$this->errors.$sep_err."2";
|
||||||
$sep_err="|";
|
$sep_err="|";
|
||||||
|
|
@ -227,42 +218,28 @@ class Install {
|
||||||
$this->errors=$this->errors.$sep_err."5";
|
$this->errors=$this->errors.$sep_err."5";
|
||||||
$sep_err="|";
|
$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']) {
|
if ($this->data['password']!=$_POST['password2']) {
|
||||||
$this->errors=$this->errors.$sep_err."3";
|
$this->errors=$this->errors.$sep_err."3";
|
||||||
$sep_err="|";
|
$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']);
|
$off_r= split("," , $this->data['time_offsets']);
|
||||||
$this->data['offset_time'] = $off_r[0];
|
$this->data['offset_time'] = $off_r[0];
|
||||||
$this->data['offset_city'] = $off_r[1];
|
$this->data['offset_city'] = $off_r[1];
|
||||||
unset($this->data['time_offsets']);
|
unset($this->data['time_offsets']);
|
||||||
|
|
||||||
if (!$this->errors) {
|
if(!$this->errors){
|
||||||
|
if($this->run($this->data))
|
||||||
if ($this->run($this->data)) {
|
|
||||||
$this->showForm=false;
|
$this->showForm=false;
|
||||||
} else {
|
else{
|
||||||
$this->errors=$this->errors.$sep_err."6";
|
$this->errors=$this->errors.$sep_err."6";
|
||||||
$sep_err="|";
|
$sep_err="|";
|
||||||
$this->showForm=true;
|
$this->showForm=true;
|
||||||
}
|
}
|
||||||
} else {
|
}else
|
||||||
$this->showForm=true;
|
$this->showForm=true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
16
install.php
16
install.php
|
|
@ -27,24 +27,28 @@ if($install->is_gelato_installed()){
|
||||||
header("location: index.php");
|
header("location: index.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$install->data = $_POST;
|
$install->data = $_POST;
|
||||||
|
|
||||||
$install->check_form();
|
$install->check_form();
|
||||||
$theme = new themes;
|
$theme = new themes;
|
||||||
$theme->set('version',util::version());
|
$theme->set('version',util::version());
|
||||||
$theme->set('showForm',$install->showForm);
|
$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_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_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_name',(!empty($install->data['db_name']))? $install->data['db_name'] : 'gelatocms');
|
||||||
$theme->set('login',isset($install->data['login'])?$install->data['login']:'');
|
$theme->set('login',isset($install->data['login'])?$install->data['login']:'');
|
||||||
$theme->set('email',isset($install->data['email'])?$install->data['email']:'');
|
$theme->set('email',isset($install->data['email'])?$install->data['email']:'');
|
||||||
$theme->set('title',isset($install->data['title'])?$install->data['title']:'');
|
$theme->set('title',isset($install->data['title'])?$install->data['title']:'');
|
||||||
$theme->set('description',isset($install->data['description'])?$install->data['description']:'');
|
$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());
|
$theme->set('themes',util::getThemes());
|
||||||
|
|
||||||
for($c=1;$c<=10;$c++)$errores[$c] = $install->mostrarerror($c);
|
for($c=1;$c<=10;$c++)$errores[$c] = $install->mostrarerror($c);
|
||||||
$theme->set('error',$errores);
|
$theme->set('error',$errores);
|
||||||
|
|
||||||
$theme->display(Absolute_Path.'admin/themes/admin/install.htm');
|
$theme->display(Absolute_Path.'admin/themes/admin/install.htm');
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue