1
|
<?php
|
2
|
|
3
|
// $Id: save.php 761 2008-03-24 14:54:24Z thorn $
|
4
|
|
5
|
/*
|
6
|
|
7
|
Website Baker Project <http://www.websitebaker.org/>
|
8
|
Copyright (C) 2004-2008, Ryan Djurovich
|
9
|
|
10
|
Website Baker is free software; you can redistribute it and/or modify
|
11
|
it under the terms of the GNU General Public License as published by
|
12
|
the Free Software Foundation; either version 2 of the License, or
|
13
|
(at your option) any later version.
|
14
|
|
15
|
Website Baker is distributed in the hope that it will be useful,
|
16
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18
|
GNU General Public License for more details.
|
19
|
|
20
|
You should have received a copy of the GNU General Public License
|
21
|
along with Website Baker; if not, write to the Free Software
|
22
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23
|
|
24
|
*/
|
25
|
|
26
|
// Start a session
|
27
|
if(!defined('SESSION_STARTED')) {
|
28
|
session_name('wb_session_id');
|
29
|
session_start();
|
30
|
define('SESSION_STARTED', true);
|
31
|
}
|
32
|
// get random-part for session_name()
|
33
|
list($usec,$sec) = explode(' ',microtime());
|
34
|
srand((float)$sec+((float)$usec*100000));
|
35
|
$session_rand = rand(1000,9999);
|
36
|
|
37
|
// Function to set error
|
38
|
function set_error($message, $field_name = '') {
|
39
|
global $_POST;
|
40
|
if(isset($message) AND $message != '') {
|
41
|
// Copy values entered into session so user doesn't have to re-enter everything
|
42
|
if(isset($_POST['website_title'])) {
|
43
|
$_SESSION['wb_url'] = $_POST['wb_url'];
|
44
|
$_SESSION['default_timezone'] = $_POST['default_timezone'];
|
45
|
$_SESSION['default_language'] = $_POST['default_language'];
|
46
|
if(!isset($_POST['operating_system'])) {
|
47
|
$_SESSION['operating_system'] = 'linux';
|
48
|
} else {
|
49
|
$_SESSION['operating_system'] = $_POST['operating_system'];
|
50
|
}
|
51
|
if(!isset($_POST['world_writeable'])) {
|
52
|
$_SESSION['world_writeable'] = false;
|
53
|
} else {
|
54
|
$_SESSION['world_writeable'] = true;
|
55
|
}
|
56
|
$_SESSION['database_host'] = $_POST['database_host'];
|
57
|
$_SESSION['database_username'] = $_POST['database_username'];
|
58
|
$_SESSION['database_password'] = $_POST['database_password'];
|
59
|
$_SESSION['database_name'] = $_POST['database_name'];
|
60
|
$_SESSION['table_prefix'] = $_POST['table_prefix'];
|
61
|
if(!isset($_POST['install_tables'])) {
|
62
|
$_SESSION['install_tables'] = false;
|
63
|
} else {
|
64
|
$_SESSION['install_tables'] = true;
|
65
|
}
|
66
|
$_SESSION['website_title'] = $_POST['website_title'];
|
67
|
$_SESSION['admin_username'] = $_POST['admin_username'];
|
68
|
$_SESSION['admin_email'] = $_POST['admin_email'];
|
69
|
$_SESSION['admin_password'] = $_POST['admin_password'];
|
70
|
$_SESSION['admin_repassword'] = $_POST['admin_repassword'];
|
71
|
}
|
72
|
// Set the message
|
73
|
$_SESSION['message'] = $message;
|
74
|
// Set the element(s) to highlight
|
75
|
if($field_name != '') {
|
76
|
$_SESSION['ERROR_FIELD'] = $field_name;
|
77
|
}
|
78
|
// Specify that session support is enabled
|
79
|
$_SESSION['session_support'] = '<font class="good">Enabled</font>';
|
80
|
// Redirect to first page again and exit
|
81
|
header('Location: index.php?sessions_checked=true');
|
82
|
exit();
|
83
|
}
|
84
|
}
|
85
|
|
86
|
// Dummy class to allow modules' install scripts to call $admin->print_error
|
87
|
class admin_dummy
|
88
|
{
|
89
|
var $error='';
|
90
|
function print_error($message)
|
91
|
{
|
92
|
$this->error=$message;
|
93
|
}
|
94
|
}
|
95
|
|
96
|
// Function to workout what the default permissions are for files created by the webserver
|
97
|
function default_file_mode($temp_dir) {
|
98
|
$v = explode(".",PHP_VERSION);
|
99
|
$v = $v[0].$v[1];
|
100
|
if($v > 41 AND is_writable($temp_dir)) {
|
101
|
$filename = $temp_dir.'/test_permissions.txt';
|
102
|
$handle = fopen($filename, 'w');
|
103
|
fwrite($handle, 'This file is to get the default file permissions');
|
104
|
fclose($handle);
|
105
|
$default_file_mode = '0'.substr(sprintf('%o', fileperms($filename)), -3);
|
106
|
unlink($filename);
|
107
|
} else {
|
108
|
$default_file_mode = '0777';
|
109
|
}
|
110
|
return $default_file_mode;
|
111
|
}
|
112
|
|
113
|
// Function to workout what the default permissions are for directories created by the webserver
|
114
|
function default_dir_mode($temp_dir) {
|
115
|
$v = explode(".",PHP_VERSION);
|
116
|
$v = $v[0].$v[1];
|
117
|
if($v > 41 AND is_writable($temp_dir)) {
|
118
|
$dirname = $temp_dir.'/test_permissions/';
|
119
|
mkdir($dirname);
|
120
|
$default_dir_mode = '0'.substr(sprintf('%o', fileperms($dirname)), -3);
|
121
|
rmdir($dirname);
|
122
|
} else {
|
123
|
$default_dir_mode = '0777';
|
124
|
}
|
125
|
return $default_dir_mode;
|
126
|
}
|
127
|
|
128
|
function add_slashes($input) {
|
129
|
if ( get_magic_quotes_gpc() || ( !is_string($input) ) ) {
|
130
|
return $input;
|
131
|
}
|
132
|
$output = addslashes($input);
|
133
|
return $output;
|
134
|
}
|
135
|
|
136
|
// Begin check to see if form was even submitted
|
137
|
// Set error if no post vars found
|
138
|
if(!isset($_POST['website_title'])) {
|
139
|
set_error('Please fill-in the form below');
|
140
|
}
|
141
|
// End check to see if form was even submitted
|
142
|
|
143
|
// Begin path and timezone details code
|
144
|
|
145
|
// Check if user has entered the installation url
|
146
|
if(!isset($_POST['wb_url']) OR $_POST['wb_url'] == '') {
|
147
|
set_error('Please enter an absolute URL', 'wb_url');
|
148
|
} else {
|
149
|
$wb_url = $_POST['wb_url'];
|
150
|
}
|
151
|
// Remove any slashes at the end of the URL
|
152
|
if(substr($wb_url, strlen($wb_url)-1, 1) == "/") {
|
153
|
$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
|
154
|
}
|
155
|
if(substr($wb_url, strlen($wb_url)-1, 1) == "\\") {
|
156
|
$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
|
157
|
}
|
158
|
if(substr($wb_url, strlen($wb_url)-1, 1) == "/") {
|
159
|
$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
|
160
|
}
|
161
|
if(substr($wb_url, strlen($wb_url)-1, 1) == "\\") {
|
162
|
$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
|
163
|
}
|
164
|
// Get the default time zone
|
165
|
if(!isset($_POST['default_timezone']) OR !is_numeric($_POST['default_timezone'])) {
|
166
|
set_error('Please select a valid default timezone', 'default_timezone');
|
167
|
} else {
|
168
|
$default_timezone = $_POST['default_timezone']*60*60;
|
169
|
}
|
170
|
// End path and timezone details code
|
171
|
|
172
|
// Get the default language
|
173
|
$allowed_languages = array('BG','CA', 'CS', 'DA', 'DE', 'EN', 'ES', 'ET', 'FI', 'FR', 'HR', 'HU', 'IT', 'LV', 'NL', 'PL', 'PT', 'RU','SE', 'TR');
|
174
|
if(!isset($_POST['default_language']) OR !in_array($_POST['default_language'], $allowed_languages)) {
|
175
|
set_error('Please select a valid default backend language','default_language');
|
176
|
} else {
|
177
|
$default_language = $_POST['default_language'];
|
178
|
// make sure the selected language file exists in the language folder
|
179
|
if(!file_exists('../languages/' .$default_language .'.php')) {
|
180
|
set_error('The language file: \'' .$default_language .'.php\' is missing. Upload file to language folder or choose another language','default_language');
|
181
|
}
|
182
|
}
|
183
|
// End default language details code
|
184
|
|
185
|
// Begin operating system specific code
|
186
|
// Get operating system
|
187
|
if(!isset($_POST['operating_system']) OR $_POST['operating_system'] != 'linux' AND $_POST['operating_system'] != 'windows') {
|
188
|
set_error('Please select a valid operating system');
|
189
|
} else {
|
190
|
$operating_system = $_POST['operating_system'];
|
191
|
}
|
192
|
// Work-out file permissions
|
193
|
if($operating_system == 'windows') {
|
194
|
$file_mode = '0777';
|
195
|
$dir_mode = '0777';
|
196
|
} elseif(isset($_POST['world_writeable']) AND $_POST['world_writeable'] == 'true') {
|
197
|
$file_mode = '0777';
|
198
|
$dir_mode = '0777';
|
199
|
} else {
|
200
|
$file_mode = default_file_mode('../temp');
|
201
|
$dir_mode = default_dir_mode('../temp');
|
202
|
}
|
203
|
// End operating system specific code
|
204
|
|
205
|
// Begin database details code
|
206
|
// Check if user has entered a database host
|
207
|
if(!isset($_POST['database_host']) OR $_POST['database_host'] == '') {
|
208
|
set_error('Please enter a database host name', 'database_host');
|
209
|
} else {
|
210
|
$database_host = $_POST['database_host'];
|
211
|
}
|
212
|
// Check if user has entered a database username
|
213
|
if(!isset($_POST['database_username']) OR $_POST['database_username'] == '') {
|
214
|
set_error('Please enter a database username','database_username');
|
215
|
} else {
|
216
|
$database_username = $_POST['database_username'];
|
217
|
}
|
218
|
// Check if user has entered a database password
|
219
|
if(!isset($_POST['database_password'])) {
|
220
|
set_error('Please enter a database password', 'database_password');
|
221
|
} else {
|
222
|
$database_password = $_POST['database_password'];
|
223
|
}
|
224
|
// Check if user has entered a database name
|
225
|
if(!isset($_POST['database_name']) OR $_POST['database_name'] == '') {
|
226
|
set_error('Please enter a database name', 'database_name');
|
227
|
} else {
|
228
|
// make sure only allowed characters are specified
|
229
|
if(preg_match('/[^a-z0-9_]+/i', $_POST['database_name'])) {
|
230
|
// contains invalid characters (only a-z, A-Z, 0-9 and _ allowed to avoid problems with table/field names)
|
231
|
set_error('Only characters a-z, A-Z, 0-9 and _ allowed as database name.', 'database_name');
|
232
|
}
|
233
|
$database_name = $_POST['database_name'];
|
234
|
}
|
235
|
// Get table prefix
|
236
|
if(preg_match('/[^a-z0-9_]+/i', $_POST['table_prefix'])) {
|
237
|
// contains invalid characters (only a-z, A-Z, 0-9 and _ allowed to avoid problems with table/field names)
|
238
|
set_error('Only characters a-z, A-Z, 0-9 and _ allowed as table_prefix.', 'table_prefix');
|
239
|
} else {
|
240
|
$table_prefix = $_POST['table_prefix'];
|
241
|
}
|
242
|
|
243
|
// Find out if the user wants to install tables and data
|
244
|
if(isset($_POST['install_tables']) AND $_POST['install_tables'] == 'true') {
|
245
|
$install_tables = true;
|
246
|
} else {
|
247
|
$install_tables = false;
|
248
|
}
|
249
|
// End database details code
|
250
|
|
251
|
// Begin website title code
|
252
|
// Get website title
|
253
|
if(!isset($_POST['website_title']) OR $_POST['website_title'] == '') {
|
254
|
set_error('Please enter a website title', 'website_title');
|
255
|
} else {
|
256
|
$website_title = add_slashes($_POST['website_title']);
|
257
|
}
|
258
|
// End website title code
|
259
|
|
260
|
// Begin admin user details code
|
261
|
// Get admin username
|
262
|
if(!isset($_POST['admin_username']) OR $_POST['admin_username'] == '') {
|
263
|
set_error('Please enter a username for the Administrator account','admin_username');
|
264
|
} else {
|
265
|
$admin_username = $_POST['admin_username'];
|
266
|
}
|
267
|
// Get admin email and validate it
|
268
|
if(!isset($_POST['admin_email']) OR $_POST['admin_email'] == '') {
|
269
|
set_error('Please enter an email for the Administrator account','admin_email');
|
270
|
} else {
|
271
|
if(eregi("^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$", $_POST['admin_email'])) {
|
272
|
$admin_email = $_POST['admin_email'];
|
273
|
} else {
|
274
|
set_error('Please enter a valid email address for the Administrator account','admin_email');
|
275
|
}
|
276
|
}
|
277
|
// Get the two admin passwords entered, and check that they match
|
278
|
if(!isset($_POST['admin_password']) OR $_POST['admin_password'] == '') {
|
279
|
set_error('Please enter a password for the Administrator account','admin_password');
|
280
|
} else {
|
281
|
$admin_password = $_POST['admin_password'];
|
282
|
}
|
283
|
if(!isset($_POST['admin_repassword']) OR $_POST['admin_repassword'] == '') {
|
284
|
set_error('Please make sure you re-enter the password for the Administrator account','admin_repassword');
|
285
|
} else {
|
286
|
$admin_repassword = $_POST['admin_repassword'];
|
287
|
}
|
288
|
if($admin_password != $admin_repassword) {
|
289
|
set_error('Sorry, the two Administrator account passwords you entered do not match','admin_repassword');
|
290
|
}
|
291
|
// End admin user details code
|
292
|
|
293
|
// Try and write settings to config file
|
294
|
$config_content = "" .
|
295
|
"<?php\n".
|
296
|
"\n".
|
297
|
"define('DB_TYPE', 'mysql');\n".
|
298
|
"define('DB_HOST', '$database_host');\n".
|
299
|
"define('DB_USERNAME', '$database_username');\n".
|
300
|
"define('DB_PASSWORD', '$database_password');\n".
|
301
|
"define('DB_NAME', '$database_name');\n".
|
302
|
"define('TABLE_PREFIX', '$table_prefix');\n".
|
303
|
"\n".
|
304
|
"define('WB_PATH', dirname(__FILE__));\n".
|
305
|
"define('WB_URL', '$wb_url');\n".
|
306
|
"define('ADMIN_PATH', WB_PATH.'/admin');\n".
|
307
|
"define('ADMIN_URL', '$wb_url/admin');\n".
|
308
|
"\n".
|
309
|
"require_once(WB_PATH.'/framework/initialize.php');\n".
|
310
|
"\n".
|
311
|
"?>";
|
312
|
|
313
|
$config_filename = '../config.php';
|
314
|
|
315
|
// Check if the file exists and is writable first.
|
316
|
if(file_exists($config_filename) AND is_writable($config_filename)) {
|
317
|
if(!$handle = fopen($config_filename, 'w')) {
|
318
|
set_error("Cannot open the configuration file ($config_filename)");
|
319
|
} else {
|
320
|
if (fwrite($handle, $config_content) === FALSE) {
|
321
|
set_error("Cannot write to the configuration file ($config_filename)");
|
322
|
}
|
323
|
// Close file
|
324
|
fclose($handle);
|
325
|
}
|
326
|
} else {
|
327
|
set_error("The configuration file $config_filename is not writable. Change its permissions so it is, then re-run step 4.");
|
328
|
}
|
329
|
|
330
|
// Define configuration vars
|
331
|
define('DB_TYPE', 'mysql');
|
332
|
define('DB_HOST', $database_host);
|
333
|
define('DB_USERNAME', $database_username);
|
334
|
define('DB_PASSWORD', $database_password);
|
335
|
define('DB_NAME', $database_name);
|
336
|
define('TABLE_PREFIX', $table_prefix);
|
337
|
define('WB_PATH', str_replace(array('/install','\install'), '',dirname(__FILE__)));
|
338
|
define('WB_URL', $wb_url);
|
339
|
define('ADMIN_PATH', WB_PATH.'/admin');
|
340
|
define('ADMIN_URL', $wb_url.'/admin');
|
341
|
|
342
|
// Check if the user has entered a correct path
|
343
|
if(!file_exists(WB_PATH.'/framework/class.admin.php')) {
|
344
|
set_error('It appears the Absolute path that you entered is incorrect');
|
345
|
}
|
346
|
|
347
|
// Try connecting to database
|
348
|
if(!mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD)) {
|
349
|
set_error('Database host name, username and/or password incorrect. MySQL Error:<br />'.mysql_error());
|
350
|
}
|
351
|
|
352
|
// Try to create the database
|
353
|
mysql_query('CREATE DATABASE '.$database_name);
|
354
|
|
355
|
// Close the mysql connection
|
356
|
mysql_close();
|
357
|
|
358
|
// Include WB functions file
|
359
|
require_once(WB_PATH.'/framework/functions.php');
|
360
|
|
361
|
// Re-connect to the database, this time using in-build database class
|
362
|
require_once(WB_PATH.'/framework/class.login.php');
|
363
|
$database=new database();
|
364
|
|
365
|
// Check if we should install tables
|
366
|
if($install_tables == true) {
|
367
|
|
368
|
// Remove tables if they exist
|
369
|
|
370
|
// Pages table
|
371
|
$pages = "DROP TABLE IF EXISTS `".TABLE_PREFIX."pages`";
|
372
|
$database->query($pages);
|
373
|
// Sections table
|
374
|
$sections = "DROP TABLE IF EXISTS `".TABLE_PREFIX."sections`";
|
375
|
$database->query($sections);
|
376
|
// Settings table
|
377
|
$settings = "DROP TABLE IF EXISTS `".TABLE_PREFIX."settings`";
|
378
|
$database->query($settings);
|
379
|
// Users table
|
380
|
$users = "DROP TABLE IF EXISTS `".TABLE_PREFIX."users`";
|
381
|
$database->query($users);
|
382
|
// Groups table
|
383
|
$groups = "DROP TABLE IF EXISTS `".TABLE_PREFIX."groups`";
|
384
|
$database->query($groups);
|
385
|
// Search table
|
386
|
$search = "DROP TABLE IF EXISTS `".TABLE_PREFIX."search`";
|
387
|
$database->query($search);
|
388
|
// Addons table
|
389
|
$addons = "DROP TABLE IF EXISTS `".TABLE_PREFIX."addons`";
|
390
|
$database->query($addons);
|
391
|
|
392
|
// Try installing tables
|
393
|
|
394
|
// Pages table
|
395
|
$pages = 'CREATE TABLE `'.TABLE_PREFIX.'pages` ( `page_id` INT NOT NULL auto_increment,'
|
396
|
. ' `parent` INT NOT NULL DEFAULT \'0\','
|
397
|
. ' `root_parent` INT NOT NULL DEFAULT \'0\','
|
398
|
. ' `level` INT NOT NULL DEFAULT \'0\','
|
399
|
. ' `link` TEXT NOT NULL,'
|
400
|
. ' `target` VARCHAR( 7 ) NOT NULL DEFAULT \'\' ,'
|
401
|
. ' `page_title` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
402
|
. ' `menu_title` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
403
|
. ' `description` TEXT NOT NULL ,'
|
404
|
. ' `keywords` TEXT NOT NULL ,'
|
405
|
. ' `page_trail` TEXT NOT NULL ,'
|
406
|
. ' `template` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
407
|
. ' `visibility` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
408
|
. ' `position` INT NOT NULL DEFAULT \'0\','
|
409
|
. ' `menu` INT NOT NULL DEFAULT \'0\','
|
410
|
. ' `language` VARCHAR( 5 ) NOT NULL DEFAULT \'\' ,'
|
411
|
. ' `searching` INT NOT NULL DEFAULT \'0\','
|
412
|
. ' `admin_groups` TEXT NOT NULL ,'
|
413
|
. ' `admin_users` TEXT NOT NULL ,'
|
414
|
. ' `viewing_groups` TEXT NOT NULL ,'
|
415
|
. ' `viewing_users` TEXT NOT NULL ,'
|
416
|
. ' `modified_when` INT NOT NULL DEFAULT \'0\','
|
417
|
. ' `modified_by` INT NOT NULL DEFAULT \'0\','
|
418
|
. ' PRIMARY KEY ( `page_id` ) '
|
419
|
. ' )';
|
420
|
$database->query($pages);
|
421
|
|
422
|
// Sections table
|
423
|
$pages = 'CREATE TABLE `'.TABLE_PREFIX.'sections` ( `section_id` INT NOT NULL auto_increment,'
|
424
|
. ' `page_id` INT NOT NULL DEFAULT \'0\','
|
425
|
. ' `position` INT NOT NULL DEFAULT \'0\','
|
426
|
. ' `module` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
427
|
. ' `block` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
428
|
. ' `publ_start` VARCHAR( 255 ) NOT NULL DEFAULT \'0\' ,'
|
429
|
. ' `publ_end` VARCHAR( 255 ) NOT NULL DEFAULT \'0\' ,'
|
430
|
. ' PRIMARY KEY ( `section_id` ) '
|
431
|
. ' )';
|
432
|
$database->query($pages);
|
433
|
|
434
|
require(ADMIN_PATH.'/interface/version.php');
|
435
|
|
436
|
// Settings table
|
437
|
$settings='CREATE TABLE `'.TABLE_PREFIX.'settings` ( `setting_id` INT NOT NULL auto_increment,'
|
438
|
. ' `name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
439
|
. ' `value` TEXT NOT NULL ,'
|
440
|
. ' PRIMARY KEY ( `setting_id` ) '
|
441
|
. ' )';
|
442
|
$database->query($settings);
|
443
|
|
444
|
$settings_rows= "INSERT INTO `".TABLE_PREFIX."settings` "
|
445
|
." (name, value) VALUES "
|
446
|
." ('wb_version', '".VERSION."'),"
|
447
|
." ('website_title', '$website_title'),"
|
448
|
." ('website_description', ''),"
|
449
|
." ('website_keywords', ''),"
|
450
|
." ('website_header', ''),"
|
451
|
." ('website_footer', ''),"
|
452
|
." ('wysiwyg_style', 'font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;'),"
|
453
|
." ('rename_files_on_upload', 'php,asp,phpx,aspx'),"
|
454
|
." ('er_level', ''),"
|
455
|
." ('default_language', '$default_language'),"
|
456
|
." ('app_name', 'wb_$session_rand'),"
|
457
|
." ('default_timezone', '$default_timezone'),"
|
458
|
." ('default_date_format', 'M d Y'),"
|
459
|
." ('default_time_format', 'g:i A'),"
|
460
|
." ('home_folders', 'true'),"
|
461
|
." ('default_template', 'round'),"
|
462
|
." ('default_charset', 'utf-8'),"
|
463
|
." ('multiple_menus', 'false'),"
|
464
|
." ('page_level_limit', '4'),"
|
465
|
." ('intro_page', 'false'),"
|
466
|
." ('page_trash', 'disabled'),"
|
467
|
." ('homepage_redirection', 'false'),"
|
468
|
." ('page_languages', 'false'),"
|
469
|
." ('wysiwyg_editor', 'fckeditor'),"
|
470
|
." ('manage_sections', 'true'),"
|
471
|
." ('section_blocks', 'false'),"
|
472
|
." ('smart_login', 'false'),"
|
473
|
." ('frontend_login', 'false'),"
|
474
|
." ('frontend_signup', 'false'),"
|
475
|
." ('search', 'public'),"
|
476
|
." ('page_extension', '.php'),"
|
477
|
." ('page_spacer', '-'),"
|
478
|
." ('pages_directory', '/pages'),"
|
479
|
." ('media_directory', '/media'),"
|
480
|
." ('operating_system', '$operating_system'),"
|
481
|
." ('string_file_mode', '$file_mode'),"
|
482
|
." ('string_dir_mode', '$dir_mode'),"
|
483
|
." ('wbmailer_routine', 'phpmail'),"
|
484
|
." ('server_email', 'admin@yourdomain.com')," // avoid that mail provider (e.g. mail.com) reject mails like yourname@mail.com
|
485
|
." ('wbmailer_default_sendername', 'WB Mailer'),"
|
486
|
." ('wbmailer_smtp_host', ''),"
|
487
|
." ('wbmailer_smtp_auth', ''),"
|
488
|
." ('wbmailer_smtp_username', ''),"
|
489
|
." ('wbmailer_smtp_password', '')";
|
490
|
$database->query($settings_rows);
|
491
|
|
492
|
// Users table
|
493
|
$users = 'CREATE TABLE `'.TABLE_PREFIX.'users` ( `user_id` INT NOT NULL auto_increment,'
|
494
|
. ' `group_id` INT NOT NULL DEFAULT \'0\','
|
495
|
. ' `groups_id` VARCHAR( 255 ) NOT NULL DEFAULT \'0\','
|
496
|
. ' `active` INT NOT NULL DEFAULT \'0\','
|
497
|
. ' `username` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
498
|
. ' `password` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
499
|
. ' `remember_key` VARCHAR( 255 ) NOT NULL DEFAULT \'\','
|
500
|
. ' `last_reset` INT NOT NULL DEFAULT \'0\','
|
501
|
. ' `display_name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
502
|
. ' `email` TEXT NOT NULL ,'
|
503
|
. ' `timezone` INT NOT NULL DEFAULT \'0\','
|
504
|
. ' `date_format` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
505
|
. ' `time_format` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
506
|
. ' `language` VARCHAR( 5 ) NOT NULL DEFAULT \'' .$default_language .'\' ,'
|
507
|
. ' `home_folder` TEXT NOT NULL ,'
|
508
|
. ' `login_when` INT NOT NULL DEFAULT \'0\','
|
509
|
. ' `login_ip` VARCHAR( 15 ) NOT NULL DEFAULT \'\' ,'
|
510
|
. ' PRIMARY KEY ( `user_id` ) '
|
511
|
. ' )';
|
512
|
$database->query($users);
|
513
|
|
514
|
// Groups table
|
515
|
$groups = 'CREATE TABLE `'.TABLE_PREFIX.'groups` ( `group_id` INT NOT NULL auto_increment,'
|
516
|
. ' `name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
517
|
. ' `system_permissions` TEXT NOT NULL ,'
|
518
|
. ' `module_permissions` TEXT NOT NULL ,'
|
519
|
. ' `template_permissions` TEXT NOT NULL ,'
|
520
|
. ' PRIMARY KEY ( `group_id` ) '
|
521
|
. ' )';
|
522
|
$database->query($groups);
|
523
|
|
524
|
// Search settings table
|
525
|
$search = 'CREATE TABLE `'.TABLE_PREFIX.'search` ( `search_id` INT NOT NULL auto_increment,'
|
526
|
. ' `name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
527
|
. ' `value` TEXT NOT NULL ,'
|
528
|
. ' `extra` TEXT NOT NULL ,'
|
529
|
. ' PRIMARY KEY ( `search_id` ) '
|
530
|
. ' )';
|
531
|
$database->query($search);
|
532
|
|
533
|
// Addons table
|
534
|
$addons = 'CREATE TABLE `'.TABLE_PREFIX.'addons` ( '
|
535
|
.'`addon_id` INT NOT NULL auto_increment ,'
|
536
|
.'`type` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
537
|
.'`directory` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
538
|
.'`name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
539
|
.'`description` TEXT NOT NULL ,'
|
540
|
.'`function` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
541
|
.'`version` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
542
|
.'`platform` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
543
|
.'`author` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
544
|
.'`license` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
|
545
|
.' PRIMARY KEY ( `addon_id` ) '
|
546
|
.' )';
|
547
|
$database->query($addons);
|
548
|
|
549
|
// Insert default data
|
550
|
|
551
|
// Admin group
|
552
|
$full_system_permissions = 'pages,pages_view,pages_add,pages_add_l0,pages_settings,pages_modify,pages_intro,pages_delete,media,media_view,media_upload,media_rename,media_delete,media_create,addons,modules,modules_view,modules_install,modules_uninstall,templates,templates_view,templates_install,templates_uninstall,languages,languages_view,languages_install,languages_uninstall,settings,settings_basic,settings_advanced,access,users,users_view,users_add,users_modify,users_delete,groups,groups_view,groups_add,groups_modify,groups_delete,admintools';
|
553
|
$insert_admin_group = "INSERT INTO `".TABLE_PREFIX."groups` VALUES ('1', 'Administrators', '$full_system_permissions', '', '')";
|
554
|
$database->query($insert_admin_group);
|
555
|
// Admin user
|
556
|
$insert_admin_user = "INSERT INTO `".TABLE_PREFIX."users` (user_id,group_id,groups_id,active,username,password,email,display_name) VALUES ('1','1','1','1','$admin_username','".md5($admin_password)."','$admin_email','Administrator')";
|
557
|
$database->query($insert_admin_user);
|
558
|
|
559
|
// Search header
|
560
|
$search_header = addslashes('
|
561
|
<h1>[TEXT_SEARCH]</h1>
|
562
|
|
563
|
<form name="search" action="[WB_URL]/search/index.php" method="get">
|
564
|
<table cellpadding="3" cellspacing="0" border="0" width="500">
|
565
|
<tr>
|
566
|
<td>
|
567
|
<input type="hidden" name="search_path" value="[SEARCH_PATH]" />
|
568
|
<input type="text" name="string" value="[SEARCH_STRING]" style="width: 100%;" />
|
569
|
</td>
|
570
|
<td width="150">
|
571
|
<input type="submit" value="[TEXT_SEARCH]" style="width: 100%;" />
|
572
|
</td>
|
573
|
</tr>
|
574
|
<tr>
|
575
|
<td colspan="2">
|
576
|
<input type="radio" name="match" id="match_all" value="all"[ALL_CHECKED] />
|
577
|
<label for="match_all">[TEXT_ALL_WORDS]</label>
|
578
|
<input type="radio" name="match" id="match_any" value="any"[ANY_CHECKED] />
|
579
|
<label for="match_any">[TEXT_ANY_WORDS]</label>
|
580
|
<input type="radio" name="match" id="match_exact" value="exact"[EXACT_CHECKED] />
|
581
|
<label for="match_exact">[TEXT_EXACT_MATCH]</label>
|
582
|
</td>
|
583
|
</tr>
|
584
|
</table>
|
585
|
|
586
|
</form>
|
587
|
|
588
|
<hr />
|
589
|
');
|
590
|
$insert_search_header = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'header', '$search_header', '')";
|
591
|
$database->query($insert_search_header);
|
592
|
// Search footer
|
593
|
$search_footer = addslashes('');
|
594
|
$insert_search_footer = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'footer', '$search_footer', '')";
|
595
|
$database->query($insert_search_footer);
|
596
|
// Search results header
|
597
|
$search_results_header = addslashes(''.
|
598
|
'[TEXT_RESULTS_FOR] \'<b>[SEARCH_STRING]</b>\':
|
599
|
<table cellpadding="2" cellspacing="0" border="0" width="100%" style="padding-top: 10px;">');
|
600
|
$insert_search_results_header = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_header', '$search_results_header', '')";
|
601
|
$database->query($insert_search_results_header);
|
602
|
// Search results loop
|
603
|
$search_results_loop = addslashes(''.
|
604
|
'<tr style="background-color: #F0F0F0;">
|
605
|
<td><a href="[LINK]">[TITLE]</a></td>
|
606
|
<td align="right">[TEXT_LAST_UPDATED_BY] [DISPLAY_NAME] ([USERNAME]) [TEXT_ON] [DATE]</td>
|
607
|
</tr>
|
608
|
<tr><td colspan="2" style="text-align: justify; padding-bottom: 5px;">[DESCRIPTION]</td></tr>
|
609
|
<tr><td colspan="2" style="text-align: justify; padding-bottom: 10px;">[EXCERPT]</td></tr>');
|
610
|
|
611
|
$insert_search_results_loop = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_loop', '$search_results_loop', '')";
|
612
|
$database->query($insert_search_results_loop);
|
613
|
// Search results footer
|
614
|
$search_results_footer = addslashes("</table>");
|
615
|
$insert_search_results_footer = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_footer', '$search_results_footer', '')";
|
616
|
$database->query($insert_search_results_footer);
|
617
|
// Search no results
|
618
|
$search_no_results = addslashes('<br />[TEXT_NO_RESULTS]');
|
619
|
$insert_search_no_results = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'no_results', '$search_no_results', '')";
|
620
|
$database->query($insert_search_no_results);
|
621
|
// Search module-order
|
622
|
$search_module_order = addslashes('faqbaker,manual,wysiwyg');
|
623
|
$insert_search_module_order = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'module_order', '$search_module_order', '')";
|
624
|
$database->query($insert_search_module_order);
|
625
|
// Search max lines of excerpt
|
626
|
$search_max_excerpt = addslashes('15');
|
627
|
$insert_search_max_excerpt = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'max_excerpt', '$search_max_excerpt', '')";
|
628
|
$database->query($insert_search_max_excerpt);
|
629
|
// some config-elements
|
630
|
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_enable_old_search', 'true', '')");
|
631
|
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_search_keywords', 'true', '')");
|
632
|
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_search_description', 'true', '')");
|
633
|
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_show_description', 'true', '')");
|
634
|
$database->query("INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'cfg_enable_flush', 'false', '')");
|
635
|
// Search template
|
636
|
$database->query("INSERT INTO `".TABLE_PREFIX."search` (name) VALUES ('template')");
|
637
|
|
638
|
require_once(WB_PATH.'/framework/initialize.php');
|
639
|
|
640
|
// Include the PclZip class file (thanks to
|
641
|
require_once(WB_PATH.'/include/pclzip/pclzip.lib.php');
|
642
|
|
643
|
// Install add-ons
|
644
|
if(file_exists(WB_PATH.'/install/modules')) {
|
645
|
// Unpack pre-packaged modules
|
646
|
|
647
|
}
|
648
|
if(file_exists(WB_PATH.'/install/templates')) {
|
649
|
// Unpack pre-packaged templates
|
650
|
|
651
|
}
|
652
|
if(file_exists(WB_PATH.'/install/languages')) {
|
653
|
// Unpack pre-packaged languages
|
654
|
|
655
|
}
|
656
|
|
657
|
$admin=new admin_dummy();
|
658
|
// Load addons into DB
|
659
|
$dirs['modules'] = WB_PATH.'/modules/';
|
660
|
$dirs['templates'] = WB_PATH.'/templates/';
|
661
|
$dirs['languages'] = WB_PATH.'/languages/';
|
662
|
foreach($dirs AS $type => $dir) {
|
663
|
if($handle = opendir($dir)) {
|
664
|
while(false !== ($file = readdir($handle))) {
|
665
|
if($file != '' AND substr($file, 0, 1) != '.' AND $file != 'admin.php' AND $file != 'index.php') {
|
666
|
// Get addon type
|
667
|
if($type == 'modules') {
|
668
|
load_module($dir.'/'.$file, true);
|
669
|
// Pretty ugly hack to let modules run $admin->set_error
|
670
|
// See dummy class definition admin_dummy above
|
671
|
if ($admin->error!='') {
|
672
|
set_error($admin->error);
|
673
|
}
|
674
|
} elseif($type == 'templates') {
|
675
|
load_template($dir.'/'.$file);
|
676
|
} elseif($type == 'languages') {
|
677
|
load_language($dir.'/'.$file);
|
678
|
}
|
679
|
}
|
680
|
}
|
681
|
closedir($handle);
|
682
|
}
|
683
|
}
|
684
|
|
685
|
// Check if there was a database error
|
686
|
if($database->is_error()) {
|
687
|
set_error($database->get_error());
|
688
|
}
|
689
|
|
690
|
}
|
691
|
|
692
|
// Log the user in and go to Website Baker Administration
|
693
|
$thisApp = new Login(
|
694
|
array(
|
695
|
"MAX_ATTEMPS" => "50",
|
696
|
"WARNING_URL" => ADMIN_URL."/login/warning.html",
|
697
|
"USERNAME_FIELDNAME" => 'admin_username',
|
698
|
"PASSWORD_FIELDNAME" => 'admin_password',
|
699
|
"REMEMBER_ME_OPTION" => SMART_LOGIN,
|
700
|
"MIN_USERNAME_LEN" => "2",
|
701
|
"MIN_PASSWORD_LEN" => "2",
|
702
|
"MAX_USERNAME_LEN" => "30",
|
703
|
"MAX_PASSWORD_LEN" => "30",
|
704
|
'LOGIN_URL' => ADMIN_URL."/login/index.php",
|
705
|
'DEFAULT_URL' => ADMIN_URL."/start/index.php",
|
706
|
'TEMPLATE_DIR' => ADMIN_PATH."/login",
|
707
|
'TEMPLATE_FILE' => "template.html",
|
708
|
'FRONTEND' => false,
|
709
|
'FORGOTTEN_DETAILS_APP' => ADMIN_URL."/login/forgot/index.php",
|
710
|
'USERS_TABLE' => TABLE_PREFIX."users",
|
711
|
'GROUPS_TABLE' => TABLE_PREFIX."groups",
|
712
|
)
|
713
|
);
|
714
|
?>
|