|
@@ -1,280 +1,294 @@
|
1
|
|
-<?php
|
2
|
|
-if(!defined('entry') || !entry) die('Not a valid page');
|
3
|
|
-require('classes/mysql_connection.class.php');
|
4
|
|
-
|
5
|
|
-class Install {
|
6
|
|
- var $data = null;
|
7
|
|
- var $errors = null;
|
8
|
|
- var $showForm;
|
9
|
|
- var $errors_d = array();
|
10
|
|
-
|
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
|
|
- }
|
21
|
|
-
|
22
|
|
- function run() {
|
23
|
|
-
|
24
|
|
- if (empty($this->data)) false;
|
25
|
|
-
|
26
|
|
- if (!$this->create_config()) return false;
|
27
|
|
-
|
28
|
|
- $this->create_db();
|
29
|
|
-
|
30
|
|
- if (!$this->install_db()) return false;
|
31
|
|
-
|
32
|
|
- return true;
|
33
|
|
- }
|
34
|
|
-
|
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
|
|
- }
|
41
|
|
-
|
42
|
|
- $sql = 'CREATE DATABASE ' . $this->data['db_name'];
|
43
|
|
- if (!mysql_query($sql, $link)) {
|
44
|
|
- $link = mysql_close($link);
|
45
|
|
- return false;
|
46
|
|
- }
|
47
|
|
-
|
48
|
|
- return true;
|
49
|
|
- }
|
50
|
|
-
|
51
|
|
- function install_db(){
|
52
|
|
- require('config.php');
|
53
|
|
- $db = new Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password);
|
54
|
|
- $sqlStr = array();
|
55
|
|
-
|
56
|
|
- $sqlStr[] = "CREATE TABLE `".Table_prefix."data` (
|
57
|
|
- `id_post` int(11) NOT NULL auto_increment,
|
58
|
|
- `title` text NULL,
|
59
|
|
- `url` varchar(250) default NULL,
|
60
|
|
- `description` text NULL,
|
61
|
|
- `type` tinyint(4) NOT NULL default '1',
|
62
|
|
- `date` datetime NOT NULL,
|
63
|
|
- `id_user` int(10) NOT NULL,
|
64
|
|
- PRIMARY KEY (`id_post`)
|
65
|
|
- ) ENGINE = MYISAM ;";
|
66
|
|
-
|
67
|
|
- $sqlStr[] = "CREATE TABLE `".Table_prefix."users` (
|
68
|
|
- `id_user` int(10) unsigned NOT NULL auto_increment,
|
69
|
|
- `name` varchar(100) default NULL,
|
70
|
|
- `login` varchar(100) NOT NULL default '',
|
71
|
|
- `password` varchar(64) NOT NULL default '',
|
72
|
|
- `email` varchar(100) default NULL,
|
73
|
|
- `website` varchar(150) default NULL,
|
74
|
|
- `about` text,
|
75
|
|
- PRIMARY KEY (`id_user`)
|
76
|
|
- ) ENGINE = MYISAM;";
|
77
|
|
-
|
78
|
|
- $sqlStr[] = "CREATE TABLE `".Table_prefix."config` (
|
79
|
|
- `posts_limit` int(3) NOT NULL,
|
80
|
|
- `title` varchar(250) NOT NULL,
|
81
|
|
- `description` text NOT NULL,
|
82
|
|
- `lang` varchar(10) NOT NULL,
|
83
|
|
- `template` varchar(100) NOT NULL,
|
84
|
|
- `url_installation` varchar(250) NOT NULL,
|
85
|
|
- PRIMARY KEY (`title`)
|
86
|
|
- ) ENGINE = MYISAM ;";
|
87
|
|
-
|
88
|
|
-
|
89
|
|
-
|
90
|
|
- $sqlStr[] = "CREATE TABLE `".Table_prefix."options` (
|
91
|
|
- `name` varchar(100) NOT NULL,
|
92
|
|
- `val` varchar(255) NOT NULL,
|
93
|
|
- PRIMARY KEY (`name`)
|
94
|
|
- ) ENGINE = MYISAM ;";
|
95
|
|
-
|
96
|
|
-
|
97
|
|
- $sqlStr[] = "CREATE TABLE `".Table_prefix."comments` (
|
98
|
|
- `id_comment` int(11) NOT NULL auto_increment,
|
99
|
|
- `id_post` int(11) NOT NULL,
|
100
|
|
- `username` varchar(50) NOT NULL,
|
101
|
|
- `email` varchar(100) NOT NULL,
|
102
|
|
- `web` varchar(250) default NULL,
|
103
|
|
- `content` text NOT NULL,
|
104
|
|
- `ip_user` varchar(50) NOT NULL,
|
105
|
|
- `comment_date` datetime NOT NULL,
|
106
|
|
- `spam` tinyint(4) NOT NULL,
|
107
|
|
- PRIMARY KEY (`id_comment`)
|
108
|
|
- ) ENGINE = MYISAM ;";
|
109
|
|
-
|
110
|
|
- $sqlStr[] = "INSERT INTO `".Table_prefix."config` VALUES (". $this->data['posts_limit'] .", '".$this->data['title']."', '".$this->data['description']."', '".$this->data['lang']."', '".$this->data['template']."', '".$this->data['url_installation']."');";
|
111
|
|
- $sqlStr[] = "INSERT INTO `".Table_prefix."users` VALUES ('', '', '".$this->data['login']."', '".md5($this->data['password'])."', '".$this->data['email']."', '".$this->data['website']."', '".$this->data['about']."');";
|
112
|
|
- $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('url_friendly', '1');";
|
113
|
|
- $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('rich_text', '0');";
|
114
|
|
- $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('allow_comments', '0');";
|
115
|
|
- $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('offset_city', '".$this->data['offset_city']."');";
|
116
|
|
- $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('offset_time', '".$this->data['offset_time']."');";
|
117
|
|
- $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('shorten_links', '0');";
|
118
|
|
- foreach($sqlStr as $key => $query){
|
119
|
|
- if(!$db->ejecutarConsulta($query)){
|
120
|
|
- return false;
|
121
|
|
- }
|
122
|
|
- }
|
123
|
|
-
|
124
|
|
- return true;
|
125
|
|
- }
|
126
|
|
-
|
127
|
|
- function inerrors($n) {
|
128
|
|
- if ( strpos($this->errors,$n)===false) {
|
129
|
|
- return false;
|
130
|
|
- } else {
|
131
|
|
- return true;
|
132
|
|
- }
|
133
|
|
- }
|
134
|
|
-
|
135
|
|
- function mostrarerror($n) {
|
136
|
|
- if ($this->inerrors($n)) {
|
137
|
|
- return '<span class="error">'.$this->errors_d[$n].'</span>';
|
138
|
|
- } else {
|
139
|
|
- return "";
|
140
|
|
- }
|
141
|
|
- }
|
142
|
|
-
|
143
|
|
- function is_gelato_installed(){
|
144
|
|
- if (!$this->check_for_config()){
|
145
|
|
- return false;
|
146
|
|
- } else {
|
147
|
|
- if (!$this->is_db_installed()){
|
148
|
|
- return false;
|
149
|
|
- }
|
150
|
|
- */
|
151
|
|
- }
|
152
|
|
-
|
153
|
|
- return true;
|
154
|
|
- }
|
155
|
|
-
|
156
|
|
- function is_db_installed(){
|
157
|
|
-
|
158
|
|
- global $db;
|
159
|
|
-
|
160
|
|
- if (function_exists($db->ejecutarConsulta)){
|
161
|
|
- $sqlStr = "SELECT * FROM `".Table_prefix."config`";
|
162
|
|
- if($db->ejecutarConsulta($sqlStr)) {
|
163
|
|
- return ($db->contarRegistros() > 0);
|
164
|
|
- }
|
165
|
|
- } else {
|
166
|
|
- false;
|
167
|
|
- }
|
168
|
|
-
|
169
|
|
- }
|
170
|
|
- */
|
171
|
|
- function check_for_config(){
|
172
|
|
- if(!file_exists('config.php')) return false;
|
173
|
|
- if(!defined('DB_Server')) return false;
|
174
|
|
- if(!defined('DB_name')) return false;
|
175
|
|
- if(!defined('DB_User')) return false;
|
176
|
|
- if(!defined('DB_Password')) return false;
|
177
|
|
-
|
178
|
|
- return true;
|
179
|
|
- }
|
180
|
|
-
|
181
|
|
- function create_config(){
|
182
|
|
- $config = fopen("config.php", 'w+');
|
183
|
|
- $contents = '<?php
|
184
|
|
-if(!defined(\'entry\') || !entry) die(\'Not a valid page\');
|
185
|
|
-
|
186
|
|
-
|
187
|
|
- gelato CMS - A PHP based tumblelog CMS
|
188
|
|
- development version
|
189
|
|
- http:
|
190
|
|
-
|
191
|
|
- gelato CMS is a free software licensed under the GPL 2.0
|
192
|
|
- Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
|
193
|
|
-
|
194
|
|
- =========================== */
|
195
|
|
-
|
196
|
|
-define(\'DB_Server\', \''. $this->data['db_host'] . '\');
|
197
|
|
-define(\'DB_name\', \''. $this->data['db_name'] . '\');
|
198
|
|
-define(\'DB_User\', \''. $this->data['db_login'] . '\');
|
199
|
|
-define(\'DB_Password\', \''. $this->data['db_password'] . '\');
|
200
|
|
-define(\'Table_prefix\', \'gel_\');
|
201
|
|
-define(\'Absolute_Path\', dirname(__FILE__).DIRECTORY_SEPARATOR);
|
202
|
|
-
|
203
|
|
-?>';
|
204
|
|
-
|
205
|
|
- if (fwrite($config, $contents) === FALSE) {
|
206
|
|
- $this->errors = "Could not write config file to directory";
|
207
|
|
- return false;
|
208
|
|
- }
|
209
|
|
- fclose($config);
|
210
|
|
- return true;
|
211
|
|
- }
|
212
|
|
-
|
213
|
|
- function check_form(){
|
214
|
|
-
|
215
|
|
- $action="";
|
216
|
|
-
|
217
|
|
- if (isset($this->data['action'])){
|
218
|
|
- $action=$this->data['action'];
|
219
|
|
- }
|
220
|
|
-
|
221
|
|
- if (!$this->is_gelato_installed()){
|
222
|
|
-
|
223
|
|
- $this->showForm = true;
|
224
|
|
-
|
225
|
|
-
|
226
|
|
- if ($action=="config") {
|
227
|
|
-
|
228
|
|
- $sep_err="";
|
229
|
|
- $this->errors = false;
|
230
|
|
-
|
231
|
|
- if (!$this->data['login'] || !$this->data['db_login']) {
|
232
|
|
- $this->errors =$this->errors.$sep_err."1";
|
233
|
|
- $sep_err="|";
|
234
|
|
- }
|
235
|
|
- if (!$this->data['password'] || !$this->data['db_password']) {
|
236
|
|
- $this->errors=$this->errors.$sep_err."2";
|
237
|
|
- $sep_err="|";
|
238
|
|
- }
|
239
|
|
- if (!$this->data['email']) {
|
240
|
|
- $this->errors=$this->errors.$sep_err."4";
|
241
|
|
- $sep_err="|";
|
242
|
|
- }
|
243
|
|
- if (!$this->data['url_installation'] ) {
|
244
|
|
- $this->errors=$this->errors.$sep_err."5";
|
245
|
|
- $sep_err="|";
|
246
|
|
- }
|
247
|
|
- if (!$this->data['db_host'] ) {
|
248
|
|
- $this->errors=$this->errors.$sep_err."7";
|
249
|
|
- $sep_err="|";
|
250
|
|
- }
|
251
|
|
- if (!$this->data['db_name'] ) {
|
252
|
|
- $this->errors=$this->errors.$sep_err."8";
|
253
|
|
- $sep_err="|";
|
254
|
|
- }
|
255
|
|
- if ($this->data['password']!=$_POST['password2'] || $_POST['db_password']!=$_POST['db_password2'] ) {
|
256
|
|
- $this->errors=$this->errors.$sep_err."3";
|
257
|
|
- $sep_err="|";
|
258
|
|
- }
|
259
|
|
- $off_r= split("," , $this->data['time_offsets']);
|
260
|
|
- $this->data['offset_time'] = $off_r[0];
|
261
|
|
- $this->data['offset_city'] = $off_r[1];
|
262
|
|
- unset($this->data['time_offsets']);
|
263
|
|
-
|
264
|
|
- if (!$this->errors) {
|
265
|
|
-
|
266
|
|
- if ($this->run($this->data)) {
|
267
|
|
- $this->showForm=false;
|
268
|
|
- } else {
|
269
|
|
- $this->errors=$this->errors.$sep_err."6";
|
270
|
|
- $sep_err="|";
|
271
|
|
- $this->showForm=true;
|
272
|
|
- }
|
273
|
|
- } else {
|
274
|
|
- $this->showForm=true;
|
275
|
|
- }
|
276
|
|
- }
|
277
|
|
- }
|
278
|
|
- }
|
279
|
|
-}
|
|
1
|
+<?php
|
|
2
|
+if(!defined('entry') || !entry) die('Not a valid page');
|
|
3
|
+require('classes/mysql_connection.class.php');
|
|
4
|
+
|
|
5
|
+class Install {
|
|
6
|
+ var $data = null;
|
|
7
|
+ var $errors = null;
|
|
8
|
+ var $showForm;
|
|
9
|
+ var $errors_d = array();
|
|
10
|
+
|
|
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
|
+ }
|
|
21
|
+
|
|
22
|
+ function run() {
|
|
23
|
+
|
|
24
|
+ if (empty($this->data)) false;
|
|
25
|
+
|
|
26
|
+ if (!$this->create_config()) return false;
|
|
27
|
+
|
|
28
|
+ $this->create_db();
|
|
29
|
+
|
|
30
|
+ if (!$this->install_db()) return false;
|
|
31
|
+
|
|
32
|
+ return true;
|
|
33
|
+ }
|
|
34
|
+
|
|
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
|
+ }
|
|
41
|
+
|
|
42
|
+ $sql = 'CREATE DATABASE ' . $this->data['db_name'];
|
|
43
|
+ if (!mysql_query($sql, $link)) {
|
|
44
|
+ $link = mysql_close($link);
|
|
45
|
+ return false;
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ return true;
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ function install_db(){
|
|
52
|
+ require('config.php');
|
|
53
|
+ $db = new Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password);
|
|
54
|
+ $sqlStr = array();
|
|
55
|
+
|
|
56
|
+ $sqlStr[] = "CREATE TABLE `".Table_prefix."data` (
|
|
57
|
+ `id_post` int(11) NOT NULL auto_increment,
|
|
58
|
+ `title` text NULL,
|
|
59
|
+ `url` varchar(250) default NULL,
|
|
60
|
+ `description` text NULL,
|
|
61
|
+ `type` tinyint(4) NOT NULL default '1',
|
|
62
|
+ `date` datetime NOT NULL,
|
|
63
|
+ `id_user` int(10) NOT NULL,
|
|
64
|
+ PRIMARY KEY (`id_post`)
|
|
65
|
+ ) ENGINE = MYISAM ;";
|
|
66
|
+
|
|
67
|
+ $sqlStr[] = "CREATE TABLE `".Table_prefix."users` (
|
|
68
|
+ `id_user` int(10) unsigned NOT NULL auto_increment,
|
|
69
|
+ `name` varchar(100) default NULL,
|
|
70
|
+ `login` varchar(100) NOT NULL default '',
|
|
71
|
+ `password` varchar(64) NOT NULL default '',
|
|
72
|
+ `email` varchar(100) default NULL,
|
|
73
|
+ `website` varchar(150) default NULL,
|
|
74
|
+ `about` text,
|
|
75
|
+ PRIMARY KEY (`id_user`)
|
|
76
|
+ ) ENGINE = MYISAM;";
|
|
77
|
+
|
|
78
|
+ $sqlStr[] = "CREATE TABLE `".Table_prefix."config` (
|
|
79
|
+ `posts_limit` int(3) NOT NULL,
|
|
80
|
+ `title` varchar(250) NOT NULL,
|
|
81
|
+ `description` text NOT NULL,
|
|
82
|
+ `lang` varchar(10) NOT NULL,
|
|
83
|
+ `template` varchar(100) NOT NULL,
|
|
84
|
+ `url_installation` varchar(250) NOT NULL,
|
|
85
|
+ PRIMARY KEY (`title`)
|
|
86
|
+ ) ENGINE = MYISAM ;";
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+ $sqlStr[] = "CREATE TABLE `".Table_prefix."options` (
|
|
91
|
+ `name` varchar(100) NOT NULL,
|
|
92
|
+ `val` varchar(255) NOT NULL,
|
|
93
|
+ PRIMARY KEY (`name`)
|
|
94
|
+ ) ENGINE = MYISAM ;";
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+ $sqlStr[] = "CREATE TABLE `".Table_prefix."comments` (
|
|
98
|
+ `id_comment` int(11) NOT NULL auto_increment,
|
|
99
|
+ `id_post` int(11) NOT NULL,
|
|
100
|
+ `username` varchar(50) NOT NULL,
|
|
101
|
+ `email` varchar(100) NOT NULL,
|
|
102
|
+ `web` varchar(250) default NULL,
|
|
103
|
+ `content` text NOT NULL,
|
|
104
|
+ `ip_user` varchar(50) NOT NULL,
|
|
105
|
+ `comment_date` datetime NOT NULL,
|
|
106
|
+ `spam` tinyint(4) NOT NULL,
|
|
107
|
+ PRIMARY KEY (`id_comment`)
|
|
108
|
+ ) ENGINE = MYISAM ;";
|
|
109
|
+
|
|
110
|
+ $sqlStr[] = "CREATE TABLE `".Table_prefix."feeds` (
|
|
111
|
+ `id_feed` int(11) NOT NULL auto_increment,
|
|
112
|
+ `url` varchar(255) NOT NULL,
|
|
113
|
+ `title` varchar(255) NOT NULL,
|
|
114
|
+ `type` tinyint(4) NOT NULL default '1',
|
|
115
|
+ `updated_at` datetime NOT NULL,
|
|
116
|
+ `error` tinyint(1) NOT NULL default '0',
|
|
117
|
+ `credits` int(1) NOT NULL default '0',
|
|
118
|
+ `site_url` varchar(255) NOT NULL,
|
|
119
|
+ `id_user` int(10) NOT NULL,
|
|
120
|
+ PRIMARY KEY (`id_feed`)
|
|
121
|
+ ) ENGINE=MyISAM ;";
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+ $sqlStr[] = "INSERT INTO `".Table_prefix."config` VALUES (". $this->data['posts_limit'] .", '".$this->data['title']."', '".$this->data['description']."', '".$this->data['lang']."', '".$this->data['template']."', '".$this->data['url_installation']."');";
|
|
125
|
+ $sqlStr[] = "INSERT INTO `".Table_prefix."users` VALUES ('', '', '".$this->data['login']."', '".md5($this->data['password'])."', '".$this->data['email']."', '".$this->data['website']."', '".$this->data['about']."');";
|
|
126
|
+ $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('url_friendly', '1');";
|
|
127
|
+ $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('rich_text', '0');";
|
|
128
|
+ $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('allow_comments', '0');";
|
|
129
|
+ $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('offset_city', '".$this->data['offset_city']."');";
|
|
130
|
+ $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('offset_time', '".$this->data['offset_time']."');";
|
|
131
|
+ $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('shorten_links', '0');";
|
|
132
|
+ $sqlStr[] = "INSERT INTO `".Table_prefix."options` VALUES ('rss_import_frec', '5 minutes');";
|
|
133
|
+
|
|
134
|
+ foreach($sqlStr as $key => $query){
|
|
135
|
+ if(!$db->ejecutarConsulta($query)){
|
|
136
|
+ return false;
|
|
137
|
+ }
|
|
138
|
+ }
|
|
139
|
+
|
|
140
|
+ return true;
|
|
141
|
+ }
|
|
142
|
+
|
|
143
|
+ function inerrors($n) {
|
|
144
|
+ if ( strpos($this->errors,$n)===false) {
|
|
145
|
+ return false;
|
|
146
|
+ } else {
|
|
147
|
+ return true;
|
|
148
|
+ }
|
|
149
|
+ }
|
|
150
|
+
|
|
151
|
+ function mostrarerror($n) {
|
|
152
|
+ if ($this->inerrors($n)) {
|
|
153
|
+ return '<span class="error">'.$this->errors_d[$n].'</span>';
|
|
154
|
+ } else {
|
|
155
|
+ return "";
|
|
156
|
+ }
|
|
157
|
+ }
|
|
158
|
+
|
|
159
|
+ function is_gelato_installed(){
|
|
160
|
+ if (!$this->check_for_config()){
|
|
161
|
+ return false;
|
|
162
|
+ } else {
|
|
163
|
+ if (!$this->is_db_installed()){
|
|
164
|
+ return false;
|
|
165
|
+ }
|
|
166
|
+
|
|
167
|
+ }
|
|
168
|
+
|
|
169
|
+ return true;
|
|
170
|
+ }
|
|
171
|
+
|
|
172
|
+ function is_db_installed(){
|
|
173
|
+ global $db;
|
|
174
|
+ if (function_exists($db->ejecutarConsulta)){
|
|
175
|
+ $sqlStr = "SELECT * FROM `".Table_prefix."config`";
|
|
176
|
+ if($db->ejecutarConsulta($sqlStr)) {
|
|
177
|
+ return ($db->contarRegistros() > 0);
|
|
178
|
+ }
|
|
179
|
+ } else {
|
|
180
|
+ false;
|
|
181
|
+ }
|
|
182
|
+
|
|
183
|
+ }
|
|
184
|
+
|
|
185
|
+ function check_for_config(){
|
|
186
|
+ if(!file_exists('config.php')) return false;
|
|
187
|
+ if(!defined('DB_Server')) return false;
|
|
188
|
+ if(!defined('DB_name')) return false;
|
|
189
|
+ if(!defined('DB_User')) return false;
|
|
190
|
+ if(!defined('DB_Password')) return false;
|
|
191
|
+
|
|
192
|
+ return true;
|
|
193
|
+ }
|
|
194
|
+
|
|
195
|
+ function create_config(){
|
|
196
|
+ $config = fopen("config.php", 'w+');
|
|
197
|
+ $contents = '<?php
|
|
198
|
+if(!defined(\'entry\') || !entry) die(\'Not a valid page\');
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+ gelato CMS - A PHP based tumblelog CMS
|
|
202
|
+ development version
|
|
203
|
+ http:
|
|
204
|
+
|
|
205
|
+ gelato CMS is a free software licensed under the GPL 2.0
|
|
206
|
+ Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
|
|
207
|
+
|
|
208
|
+ =========================== */
|
|
209
|
+
|
|
210
|
+define(\'DB_Server\', \''. $this->data['db_host'] . '\');
|
|
211
|
+define(\'DB_name\', \''. $this->data['db_name'] . '\');
|
|
212
|
+define(\'DB_User\', \''. $this->data['db_login'] . '\');
|
|
213
|
+define(\'DB_Password\', \''. $this->data['db_password'] . '\');
|
|
214
|
+define(\'Table_prefix\', \'gel_\');
|
|
215
|
+define(\'Absolute_Path\', dirname(__FILE__).DIRECTORY_SEPARATOR);
|
|
216
|
+
|
|
217
|
+?>';
|
|
218
|
+
|
|
219
|
+ if (fwrite($config, $contents) === FALSE) {
|
|
220
|
+ $this->errors = "Could not write config file to directory";
|
|
221
|
+ return false;
|
|
222
|
+ }
|
|
223
|
+ fclose($config);
|
|
224
|
+ return true;
|
|
225
|
+ }
|
|
226
|
+
|
|
227
|
+ function check_form(){
|
|
228
|
+
|
|
229
|
+ $action="";
|
|
230
|
+
|
|
231
|
+ if (isset($this->data['action'])){
|
|
232
|
+ $action=$this->data['action'];
|
|
233
|
+ }
|
|
234
|
+
|
|
235
|
+ if (!$this->is_gelato_installed()){
|
|
236
|
+
|
|
237
|
+ $this->showForm = true;
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+ if ($action=="config") {
|
|
241
|
+
|
|
242
|
+ $sep_err="";
|
|
243
|
+ $this->errors = false;
|
|
244
|
+
|
|
245
|
+ if (!$this->data['login'] || !$this->data['db_login']) {
|
|
246
|
+ $this->errors =$this->errors.$sep_err."1";
|
|
247
|
+ $sep_err="|";
|
|
248
|
+ }
|
|
249
|
+ if (!$this->data['password'] || !$this->data['db_password']) {
|
|
250
|
+ $this->errors=$this->errors.$sep_err."2";
|
|
251
|
+ $sep_err="|";
|
|
252
|
+ }
|
|
253
|
+ if (!$this->data['email']) {
|
|
254
|
+ $this->errors=$this->errors.$sep_err."4";
|
|
255
|
+ $sep_err="|";
|
|
256
|
+ }
|
|
257
|
+ if (!$this->data['url_installation'] ) {
|
|
258
|
+ $this->errors=$this->errors.$sep_err."5";
|
|
259
|
+ $sep_err="|";
|
|
260
|
+ }
|
|
261
|
+ if (!$this->data['db_host'] ) {
|
|
262
|
+ $this->errors=$this->errors.$sep_err."7";
|
|
263
|
+ $sep_err="|";
|
|
264
|
+ }
|
|
265
|
+ if (!$this->data['db_name'] ) {
|
|
266
|
+ $this->errors=$this->errors.$sep_err."8";
|
|
267
|
+ $sep_err="|";
|
|
268
|
+ }
|
|
269
|
+ if ($this->data['password']!=$_POST['password2'] || $_POST['db_password']!=$_POST['db_password2'] ) {
|
|
270
|
+ $this->errors=$this->errors.$sep_err."3";
|
|
271
|
+ $sep_err="|";
|
|
272
|
+ }
|
|
273
|
+ $off_r= split("," , $this->data['time_offsets']);
|
|
274
|
+ $this->data['offset_time'] = $off_r[0];
|
|
275
|
+ $this->data['offset_city'] = $off_r[1];
|
|
276
|
+ unset($this->data['time_offsets']);
|
|
277
|
+
|
|
278
|
+ if (!$this->errors) {
|
|
279
|
+
|
|
280
|
+ if ($this->run($this->data)) {
|
|
281
|
+ $this->showForm=false;
|
|
282
|
+ } else {
|
|
283
|
+ $this->errors=$this->errors.$sep_err."6";
|
|
284
|
+ $sep_err="|";
|
|
285
|
+ $this->showForm=true;
|
|
286
|
+ }
|
|
287
|
+ } else {
|
|
288
|
+ $this->showForm=true;
|
|
289
|
+ }
|
|
290
|
+ }
|
|
291
|
+ }
|
|
292
|
+ }
|
|
293
|
+}
|
280
|
294
|
?>
|