|
@@ -9,44 +9,36 @@ class Install {
|
9
|
9
|
var $errors_d = array();
|
10
|
10
|
|
11
|
11
|
function Install(){
|
12
|
|
- $this->errors_d[1]="The login field cannot be empty";
|
13
|
|
- $this->errors_d[2]="The password field cannot be empty";
|
14
|
|
- $this->errors_d[3]="Password does not match the confirm password";
|
15
|
|
- $this->errors_d[4]="The e-mail field cannot be empty";
|
16
|
|
- $this->errors_d[5]="The installation URL field cannot be empty";
|
17
|
|
- $this->errors_d[6]="Error establishing a database connection";
|
18
|
|
- $this->errors_d[7]="Please add a hostname for the database server";
|
19
|
|
- $this->errors_d[8]="Please name the database";
|
20
|
|
- $this->errors_d[9]="Password does not match the confirm password";
|
21
|
|
- $this->errors_d[10]="The login field cannot be empty";
|
|
12
|
+ $this->errors_d[1]='The login field cannot be empty';
|
|
13
|
+ $this->errors_d[2]='The password field cannot be empty';
|
|
14
|
+ $this->errors_d[3]='Password does not match the confirm password';
|
|
15
|
+ $this->errors_d[4]='The e-mail field cannot be empty';
|
|
16
|
+ $this->errors_d[5]='The installation URL field cannot be empty';
|
|
17
|
+ $this->errors_d[6]='Error establishing a database connection';
|
|
18
|
+ $this->errors_d[9]='For security reasons this field is required. It is the same information that in the config.php file';
|
|
19
|
+ $this->errors_d[10]='The login field cannot be empty';
|
22
|
20
|
}
|
23
|
21
|
|
24
|
22
|
function run() {
|
25
|
|
-
|
26
|
23
|
if (empty($this->data)) false;
|
27
|
|
-
|
28
|
24
|
$this->create_db();
|
29
|
|
-
|
30
|
25
|
if (!$this->install_db()) return false;
|
31
|
|
-
|
32
|
26
|
return true;
|
33
|
27
|
}
|
34
|
28
|
|
35
|
|
- function create_db(){
|
36
|
|
-
|
37
|
|
- $link = mysql_connect($this->data['db_host'], $this->data['db_login'], $this->data['db_password']);
|
38
|
|
- if (!$link) {
|
39
|
|
- die('Could not connect: ' . mysql_error());
|
40
|
|
- }
|
|
29
|
+ function create_db(){
|
|
30
|
+ $link = mysql_connect(DB_Server, DB_User, DB_Password);
|
|
31
|
+ if(!$link)
|
|
32
|
+ die('Could not connect: '.mysql_error());
|
|
33
|
+
|
|
34
|
+ $sql = 'CREATE DATABASE '.DB_name;
|
41
|
35
|
|
42
|
|
- $sql = 'CREATE DATABASE ' . $this->data['db_name'];
|
43
|
|
- if (!mysql_query($sql, $link)) {
|
|
36
|
+ if(!mysql_query($sql, $link)){
|
44
|
37
|
$link = mysql_close($link);
|
45
|
38
|
return false;
|
46
|
|
- }
|
47
|
|
-
|
|
39
|
+ }
|
48
|
40
|
return true;
|
49
|
|
- }
|
|
41
|
+ }
|
50
|
42
|
|
51
|
43
|
function install_db(){
|
52
|
44
|
require_once(Absolute_Path.'config.php');
|
|
@@ -191,7 +183,6 @@ class Install {
|
191
|
183
|
}
|
192
|
184
|
|
193
|
185
|
function check_form(){
|
194
|
|
-
|
195
|
186
|
$action="";
|
196
|
187
|
|
197
|
188
|
if (isset($this->data['action'])){
|
|
@@ -207,14 +198,14 @@ class Install {
|
207
|
198
|
$sep_err="";
|
208
|
199
|
$this->errors = false;
|
209
|
200
|
|
210
|
|
- if (!$this->data['login']) {
|
211
|
|
- $this->errors =$this->errors.$sep_err."1";
|
|
201
|
+ if (!isset($this->data['db_login']) or $this->data['db_login']!=DB_User) {
|
|
202
|
+ $this->errors =$this->errors.$sep_err."9"; //7,8
|
212
|
203
|
$sep_err="|";
|
213
|
|
- }
|
214
|
|
- if (!$this->data['db_login']) {
|
215
|
|
- $this->errors =$this->errors.$sep_err."10";
|
|
204
|
+ }
|
|
205
|
+ if (!$this->data['login']) {
|
|
206
|
+ $this->errors =$this->errors.$sep_err."1";
|
216
|
207
|
$sep_err="|";
|
217
|
|
- }
|
|
208
|
+ }
|
218
|
209
|
if (!$this->data['password']) {
|
219
|
210
|
$this->errors=$this->errors.$sep_err."2";
|
220
|
211
|
$sep_err="|";
|
|
@@ -227,42 +218,28 @@ class Install {
|
227
|
218
|
$this->errors=$this->errors.$sep_err."5";
|
228
|
219
|
$sep_err="|";
|
229
|
220
|
}
|
230
|
|
- if (!$this->data['db_host'] ) {
|
231
|
|
- $this->errors=$this->errors.$sep_err."7";
|
232
|
|
- $sep_err="|";
|
233
|
|
- }
|
234
|
|
- if (!$this->data['db_name'] ) {
|
235
|
|
- $this->errors=$this->errors.$sep_err."8";
|
236
|
|
- $sep_err="|";
|
237
|
|
- }
|
238
|
221
|
if ($this->data['password']!=$_POST['password2']) {
|
239
|
222
|
$this->errors=$this->errors.$sep_err."3";
|
240
|
223
|
$sep_err="|";
|
241
|
224
|
}
|
242
|
|
- if ( $_POST['db_password']!=$_POST['db_password2']) {
|
243
|
|
- $this->errors=$this->errors.$sep_err."9";
|
244
|
|
- $sep_err="|";
|
245
|
|
- }
|
246
|
225
|
|
247
|
226
|
$off_r= split("," , $this->data['time_offsets']);
|
248
|
227
|
$this->data['offset_time'] = $off_r[0];
|
249
|
228
|
$this->data['offset_city'] = $off_r[1];
|
250
|
229
|
unset($this->data['time_offsets']);
|
251
|
230
|
|
252
|
|
- if (!$this->errors) {
|
253
|
|
-
|
254
|
|
- if ($this->run($this->data)) {
|
|
231
|
+ if(!$this->errors){
|
|
232
|
+ if($this->run($this->data))
|
255
|
233
|
$this->showForm=false;
|
256
|
|
- } else {
|
|
234
|
+ else{
|
257
|
235
|
$this->errors=$this->errors.$sep_err."6";
|
258
|
236
|
$sep_err="|";
|
259
|
237
|
$this->showForm=true;
|
260
|
238
|
}
|
261
|
|
- } else {
|
|
239
|
+ }else
|
262
|
240
|
$this->showForm=true;
|
263
|
|
- }
|
264
|
241
|
}
|
265
|
242
|
}
|
266
|
243
|
}
|
267
|
244
|
}
|
268
|
|
-?>
|
|
245
|
+?>
|