diff --git a/admin/themes/admin/install.htm b/admin/themes/admin/install.htm index 3294cfa..32f22d4 100644 --- a/admin/themes/admin/install.htm +++ b/admin/themes/admin/install.htm @@ -29,16 +29,8 @@
Database Settings

diff --git a/classes/install.class.php b/classes/install.class.php index 39743b6..7d33920 100644 --- a/classes/install.class.php +++ b/classes/install.class.php @@ -9,44 +9,36 @@ 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(){ + 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 (!$link) { - die('Could not connect: ' . mysql_error()); - } - - $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; - } + } function install_db(){ require_once(Absolute_Path.'config.php'); @@ -191,7 +183,6 @@ class Install { } function check_form(){ - $action=""; if (isset($this->data['action'])){ @@ -207,14 +198,14 @@ class Install { $sep_err=""; $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"; $sep_err="|"; - } - if (!$this->data['db_login']) { - $this->errors =$this->errors.$sep_err."10"; - $sep_err="|"; - } + } if (!$this->data['password']) { $this->errors=$this->errors.$sep_err."2"; $sep_err="|"; @@ -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; - } } } } } -?> \ No newline at end of file +?> diff --git a/install.php b/install.php index 5f732a6..55569ad 100644 --- a/install.php +++ b/install.php @@ -27,24 +27,28 @@ if($install->is_gelato_installed()){ header("location: index.php"); exit; } -$install->data = $_POST; +$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); $theme->set('error',$errores); $theme->display(Absolute_Path.'admin/themes/admin/install.htm'); -?> +?>