Project

General

Profile

1 4 ryan
<?php
2
3 40 stefan
// $Id$
4 4 ryan
5
/*
6
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2005, 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 5 stefan
*/
25 4 ryan
26 5 stefan
// Start a session
27
if(!defined('SESSION_STARTED')) {
28
	session_name('wb_session_id');
29
	session_start();
30
	define('SESSION_STARTED', true);
31
}
32 4 ryan
33 5 stefan
// Function to set error
34
function set_error($message) {
35
	global $_POST;
36
	if(isset($message) AND $message != '') {
37
		// Copy values entered into session so user doesn't have to re-enter everything
38
		if(isset($_POST['website_title'])) {
39
			$_SESSION['wb_url'] = $_POST['wb_url'];
40
			$_SESSION['wb_path'] = $_POST['wb_path'];
41
			$_SESSION['default_timezone'] = $_POST['default_timezone'];
42
			if(!isset($_POST['operating_system'])) {
43
				$_SESSION['operating_system'] = 'linux';
44
			} else {
45
				$_SESSION['operating_system'] = $_POST['operating_system'];
46
			}
47
			if(!isset($_POST['world_writeable'])) {
48
				$_SESSION['world_writeable'] = false;
49
			} else {
50
				$_SESSION['world_writeable'] = true;
51
			}
52
			$_SESSION['database_host'] = $_POST['database_host'];
53
			$_SESSION['database_username'] = $_POST['database_username'];
54
			$_SESSION['database_password'] = $_POST['database_password'];
55
			$_SESSION['database_name'] = $_POST['database_name'];
56
			$_SESSION['table_prefix'] = $_POST['table_prefix'];
57
			if(!isset($_POST['install_tables'])) {
58
				$_SESSION['install_tables'] = false;
59
			} else {
60
				$_SESSION['install_tables'] = true;
61
			}
62
			$_SESSION['website_title'] = $_POST['website_title'];
63
			$_SESSION['admin_username'] = $_POST['admin_username'];
64
			$_SESSION['admin_email'] = $_POST['admin_email'];
65
			$_SESSION['admin_password'] = $_POST['admin_password'];
66
		}
67
		// Set the message
68
		$_SESSION['message'] = $message;
69
		// Specify that session support is enabled
70
		$_SESSION['session_support'] = '<font class="good">Enabled</font>';
71
		// Redirect to first page again and exit
72
		header('Location: index.php?sessions_checked=true');
73
		exit();
74
	}
75
}
76
77
// Function to workout what the default permissions are for files created by the webserver
78
function default_file_mode($temp_dir) {
79 4 ryan
	$v = explode(".",PHP_VERSION);
80
	$v = $v[0].$v[1];
81 5 stefan
	if($v > 41 AND is_writable($temp_dir)) {
82 4 ryan
		$filename = $temp_dir.'/test_permissions.txt';
83
		$handle = fopen($filename, 'w');
84
		fwrite($handle, 'This file is to get the default file permissions');
85
		fclose($handle);
86
		$default_file_mode = '0'.substr(sprintf('%o', fileperms($filename)), -3);
87
		unlink($filename);
88
	} else {
89
		$default_file_mode = '0777';
90
	}
91
	return $default_file_mode;
92
}
93
94 5 stefan
// Function to workout what the default permissions are for directories created by the webserver
95 4 ryan
function default_dir_mode($temp_dir) {
96
	$v = explode(".",PHP_VERSION);
97
	$v = $v[0].$v[1];
98
	if($v > 41 AND is_writable($temp_dir)) {
99
		$dirname = $temp_dir.'/test_permissions/';
100
		mkdir($dirname);
101
		$default_dir_mode = '0'.substr(sprintf('%o', fileperms($dirname)), -3);
102
		rmdir($dirname);
103
	} else {
104
		$default_dir_mode = '0777';
105
	}
106
	return $default_dir_mode;
107 5 stefan
}
108
109 70 stefan
function add_slashes($input) {
110
		if ( get_magic_quotes_gpc() || ( !is_string($input) ) ) {
111
			return $input;
112
		}
113
		$output = addslashes($input);
114
		return $output;
115
	}
116 40 stefan
117 5 stefan
// Begin check to see if form was even submitted
118 40 stefan
// Set error if no post vars found
119
if(!isset($_POST['website_title'])) {
120
	set_error('Please fill-in the form below');
121
}
122 4 ryan
// End check to see if form was even submitted
123 5 stefan
124 4 ryan
// Begin path and timezone details code
125 40 stefan
// Check if user has entered the installation path
126
if(!isset($_POST['wb_path']) OR $_POST['wb_path'] == '') {
127
	set_error('Please enter an absolute path');
128
} else {
129
	$wb_path = $_POST['wb_path'];
130
}
131
// Check if user has entered the installation url
132
if(!isset($_POST['wb_url']) OR $_POST['wb_url'] == '') {
133
	set_error('Please enter an absolute URL');
134
} else {
135
	$wb_url = $_POST['wb_url'];
136
}
137
// Remove any slashes at the end of the URL and path
138
if(substr($wb_url, strlen($wb_url)-1, 1) == "/") {
139
	$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
140
}
141
if(substr($wb_path, strlen($wb_path)-1, 1) == "/") {
142
	$wb_path = substr($wb_path, 0, strlen($wb_path)-1);
143
}
144
if(substr($wb_url, strlen($wb_url)-1, 1) == "\\") {
145
	$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
146
}
147
if(substr($wb_path, strlen($wb_path)-1, 1) == "\\") {
148
	$wb_path = substr($wb_path, 0, strlen($wb_path)-1);
149
}
150
if(substr($wb_url, strlen($wb_url)-1, 1) == "/") {
151
	$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
152
}
153
if(substr($wb_path, strlen($wb_path)-1, 1) == "/") {
154
	$wb_path = substr($wb_path, 0, strlen($wb_path)-1);
155
}
156
if(substr($wb_url, strlen($wb_url)-1, 1) == "\\") {
157
	$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
158
}
159
if(substr($wb_path, strlen($wb_path)-1, 1) == "\\") {
160
	$wb_path = substr($wb_path, 0, strlen($wb_path)-1);
161
}
162
// Get the default time zone
163
if(!isset($_POST['default_timezone']) OR !is_numeric($_POST['default_timezone'])) {
164
	set_error('Please select a valid default timezone');
165
} else {
166
	$default_timezone = $_POST['default_timezone']*60*60;
167
}
168 5 stefan
// End path and timezone details code
169
170
// Begin operating system specific code
171 40 stefan
// Get operating system
172
if(!isset($_POST['operating_system']) OR $_POST['operating_system'] != 'linux' AND $_POST['operating_system'] != 'windows') {
173
	set_error('Please select a valid operating system');
174
} else {
175
	$operating_system = $_POST['operating_system'];
176
}
177
// Work-out file permissions
178
if($operating_system == 'windows') {
179
	$file_mode = '0777';
180
	$dir_mode = '0777';
181
} elseif(isset($_POST['world_writeable']) AND $_POST['world_writeable'] == 'true') {
182
	$file_mode = '0777';
183
	$dir_mode = '0777';
184
} else {
185
	$file_mode = default_file_mode('../temp');
186
	$dir_mode = default_dir_mode('../temp');
187
}
188 5 stefan
// End operating system specific code
189
190 4 ryan
// Begin database details code
191 40 stefan
// Check if user has entered a database host
192
if(!isset($_POST['database_host']) OR $_POST['database_host'] == '') {
193
	set_error('Please enter a database host name');
194
} else {
195
	$database_host = $_POST['database_host'];
196
}
197
// Check if user has entered a database username
198
if(!isset($_POST['database_username']) OR $_POST['database_username'] == '') {
199
	set_error('Please enter a database username');
200
} else {
201
	$database_username = $_POST['database_username'];
202
}
203
// Check if user has entered a database password
204
if(!isset($_POST['database_password'])) {
205
	set_error('Please enter a database password');
206
} else {
207
	$database_password = $_POST['database_password'];
208
}
209
// Check if user has entered a database name
210
if(!isset($_POST['database_name']) OR $_POST['database_name'] == '') {
211
	set_error('Please enter a database name');
212
} else {
213
	$database_name = $_POST['database_name'];
214
}
215
// Get table prefix
216
$table_prefix = $_POST['table_prefix'];
217
// Find out if the user wants to install tables and data
218
if(isset($_POST['install_tables']) AND $_POST['install_tables'] == 'true') {
219
	$install_tables = true;
220
} else {
221
	$install_tables = false;
222
}
223 4 ryan
// End database details code
224 5 stefan
225
// Begin website title code
226 40 stefan
// Get website title
227
if(!isset($_POST['website_title']) OR $_POST['website_title'] == '') {
228
	set_error('Please enter a website title');
229
} else {
230 70 stefan
	$website_title = add_slashes($_POST['website_title']);
231 40 stefan
}
232 5 stefan
// End website title code
233
234
// Begin admin user details code
235 40 stefan
// Get admin username
236
if(!isset($_POST['admin_username']) OR $_POST['admin_username'] == '') {
237
	set_error('Please enter a username for the Administrator account');
238
} else {
239
	$admin_username = $_POST['admin_username'];
240
}
241
// Get admin email and validate it
242
if(!isset($_POST['admin_email']) OR $_POST['admin_email'] == '') {
243
	set_error('Please enter an email for the Administrator account');
244
} else {
245
	if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['admin_email'])) {
246
		$admin_email = $_POST['admin_email'];
247 5 stefan
	} else {
248 40 stefan
		set_error('Please enter a valid email address for the Administrator account');
249 5 stefan
	}
250 40 stefan
}
251
// Get the two admin passwords entered, and check that they match
252
if(!isset($_POST['admin_password']) OR $_POST['admin_password'] == '') {
253
	set_error('Please enter a password for the Administrator account');
254
} else {
255
	$admin_password = $_POST['admin_password'];
256
}
257
if(!isset($_POST['admin_repassword']) OR $_POST['admin_repassword'] == '') {
258
	set_error('Please make sure you re-enter the password for the Administrator account');
259
} else {
260
	$admin_repassword = $_POST['admin_repassword'];
261
}
262
if($admin_password != $admin_repassword) {
263
	set_error('Sorry, the two Administrator account passwords you entered do not match');
264
}
265 5 stefan
// End admin user details code
266
267 4 ryan
// Try and write settings to config file
268
$config_content = "" .
269
"<?php\n".
270
"\n".
271
"define('ER_LEVEL', '');\n".
272
"\n".
273
"define('DEFAULT_LANGUAGE', 'EN');\n".
274
"\n".
275
"define('APP_NAME', 'wb');\n".
276
"\n".
277
"define('DB_TYPE', 'mysql');\n".
278
"define('DB_HOST', '$database_host');\n".
279
"define('DB_USERNAME', '$database_username');\n".
280
"define('DB_PASSWORD', '$database_password');\n".
281
"define('DB_NAME', '$database_name');\n".
282
"\n".
283
"define('TABLE_PREFIX', '$table_prefix');\n".
284
"\n".
285
"define('DEFAULT_TIMEZONE', '$default_timezone');\n".
286
"define('DEFAULT_DATE_FORMAT', 'M d Y');\n".
287
"define('DEFAULT_TIME_FORMAT', 'g:i A');\n".
288
"\n".
289 5 stefan
"define('HOME_FOLDERS', true);\n".
290
"\n".
291
"define('DEFAULT_TEMPLATE', 'round');\n".
292
"define('MULTIPLE_MENUS', false);\n".
293
"\n".
294
"define('PAGE_LEVEL_LIMIT', '4');\n".
295
"define('INTRO_PAGE', false);\n".
296
"define('PAGE_TRASH', 'disabled');\n".
297
"define('HOMEPAGE_REDIRECTION', false);\n".
298 4 ryan
"define('PAGE_LANGUAGES', false);\n".
299 70 stefan
"define('WYSIWYG_EDITOR', 'htmlarea');\n".
300 4 ryan
"\n".
301 5 stefan
"define('MANAGE_SECTIONS', true);\n".
302
"define('SECTION_BLOCKS', false);\n".
303
"\n".
304 4 ryan
"define('SMART_LOGIN', false);\n".
305
"define('FRONTEND_LOGIN', false);\n".
306
"define('FRONTEND_SIGNUP', '');\n".
307
"\n".
308 5 stefan
"define('SERVER_EMAIL', '".$admin_email."');\n".
309 4 ryan
"\n".
310
"define('SEARCH', 'public');\n".
311
"\n".
312
"define('PAGE_EXTENSION', '.php');\n".
313
"define('PAGE_SPACER', '-');\n".
314
"\n".
315
"define('PAGES_DIRECTORY', '/pages');\n".
316
"define('MEDIA_DIRECTORY', '/media');\n".
317 5 stefan
"\n".
318 4 ryan
"define('OPERATING_SYSTEM', '$operating_system');\n".
319
"define('OCTAL_FILE_MODE', $file_mode);\n".
320
"define('STRING_FILE_MODE', '$file_mode');\n".
321
"define('OCTAL_DIR_MODE', $dir_mode);\n".
322
"define('STRING_DIR_MODE', '$dir_mode');\n".
323
"\n".
324
"define('WB_PATH', '$wb_path');\n".
325
"define('WB_URL', '$wb_url');\n".
326
"\n".
327
"define('ADMIN_PATH', '$wb_path/admin');\n".
328
"define('ADMIN_URL', '$wb_url/admin');\n".
329
"\n".
330
"?>";
331
332
$config_filename = '../config.php';
333
334
// Check if the file exists and is writable first.
335
if(file_exists($config_filename) AND is_writable($config_filename)) {
336
	if(!$handle = fopen($config_filename, 'w')) {
337
		set_error("Cannot open the configuration file ($config_filename)");
338
	} else {
339
		if (fwrite($handle, $config_content) === FALSE) {
340
			set_error("Cannot write to the configuration file ($config_filename)");
341
		}
342
		// Close file
343
		fclose($handle);
344
	}
345
} else {
346
	set_error("The configuration file $config_filename is not writable. Change its permissions so it is, then re-run step 4.");
347 5 stefan
}
348 4 ryan
349
// Include configuration file
350 5 stefan
require('../config.php');
351 4 ryan
352 5 stefan
// Check if the user has entered a correct path
353
if(!file_exists(WB_PATH.'/framework/class.admin.php')) {
354
	set_error('It appears the Absolute path that you entered is incorrect');
355
}
356
357
// Include WB functions file
358
require_once(WB_PATH.'/framework/functions.php');
359
360 4 ryan
// Try connecting to database
361 5 stefan
if(!mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD)) {
362
	set_error('Database host name, username and/or password incorrect. MySQL Error:<br />'.mysql_error());
363
}
364
365 4 ryan
// Try to create the database
366 5 stefan
mysql_query('CREATE DATABASE '.$database_name);
367
368
// Close the mysql connection
369
mysql_close();
370
371
// Re-connect to the database, this time using in-build database class
372 40 stefan
require_once(WB_PATH.'/framework/class.admin.php');
373 4 ryan
$database = new database();
374
375
// Check if we should install tables
376
if($install_tables == true) {
377
378
	// Remove tables if they exist
379
380
	// Pages table
381
	$pages = "DROP TABLE IF EXISTS `".TABLE_PREFIX."pages`";
382
	$database->query($pages);
383
	// Sections table
384
	$sections = "DROP TABLE IF EXISTS `".TABLE_PREFIX."sections`";
385
	$database->query($sections);
386
	// Settings table
387
	$settings = "DROP TABLE IF EXISTS `".TABLE_PREFIX."settings`";
388
	$database->query($settings);
389
	// Users table
390
	$users = "DROP TABLE IF EXISTS `".TABLE_PREFIX."users`";
391
	$database->query($users);
392
	// Groups table
393
	$groups = "DROP TABLE IF EXISTS `".TABLE_PREFIX."groups`";
394
	$database->query($groups);
395
	// Search table
396
	$search = "DROP TABLE IF EXISTS `".TABLE_PREFIX."search`";
397
	$database->query($search);
398
399
	// Try installing tables
400
401
	// Pages table
402
	$pages = 'CREATE TABLE `'.TABLE_PREFIX.'pages` ( `page_id` INT NOT NULL auto_increment,'
403
	       . ' `parent` INT NOT NULL ,'
404
	       . ' `root_parent` INT NOT NULL ,'
405
	       . ' `level` INT NOT NULL ,'
406
	       . ' `link` TEXT NOT NULL ,'
407
	       . ' `target` VARCHAR( 7 ) NOT NULL ,'
408
	       . ' `page_title` VARCHAR( 255 ) NOT NULL ,'
409
	       . ' `menu_title` VARCHAR( 255 ) NOT NULL ,'
410
	       . ' `description` TEXT NOT NULL ,'
411 5 stefan
	       . ' `keywords` TEXT NOT NULL ,'
412 4 ryan
	       . ' `page_trail` TEXT NOT NULL ,'
413
	       . ' `template` VARCHAR( 255 ) NOT NULL ,'
414
	       . ' `visibility` VARCHAR( 255 ) NOT NULL ,'
415 5 stefan
	       . ' `position` INT NOT NULL ,'
416
	       . ' `menu` INT NOT NULL ,'
417 4 ryan
	       . ' `language` VARCHAR( 5 ) NOT NULL ,'
418
	       . ' `searching` INT NOT NULL ,'
419
	       . ' `admin_groups` TEXT NOT NULL ,'
420
	       . ' `admin_users` TEXT NOT NULL ,'
421
	       . ' `viewing_groups` TEXT NOT NULL ,'
422
	       . ' `viewing_users` TEXT NOT NULL ,'
423
	       . ' `modified_when` INT NOT NULL ,'
424
	       . ' `modified_by` INT NOT NULL ,'
425
	       . ' PRIMARY KEY ( `page_id` ) )'
426
	       . ' ';
427
	$database->query($pages);
428
429
	// Sections table
430
	$pages = 'CREATE TABLE `'.TABLE_PREFIX.'sections` ( `section_id` INT NOT NULL auto_increment,'
431
	       . ' `page_id` INT NOT NULL ,'
432
	       . ' `position` INT NOT NULL ,'
433 5 stefan
	       . ' `module` VARCHAR( 255 ) NOT NULL ,'
434 4 ryan
	       . ' `block` VARCHAR( 255 ) NOT NULL ,'
435
	       . ' PRIMARY KEY ( `section_id` ) )'
436
	       . ' ';
437
	$database->query($pages);
438
439
	// Settings table
440
	$settings = 'CREATE TABLE `'.TABLE_PREFIX.'settings` ( `setting_id` INT NOT NULL auto_increment,'
441
	          . ' `name` VARCHAR( 255 ) NOT NULL ,'
442
	          . ' `value` TEXT NOT NULL ,'
443
	          . ' PRIMARY KEY ( `setting_id` ) )'
444
	          . ' ';
445
	$database->query($settings);
446
447
	// Users table
448
	$users = 'CREATE TABLE `'.TABLE_PREFIX.'users` ( `user_id` INT NOT NULL auto_increment,'
449
	       . ' `group_id` INT NOT NULL ,'
450
	       . ' `active` INT NOT NULL ,'
451
	       . ' `username` VARCHAR( 255 ) NOT NULL ,'
452
	       . ' `password` VARCHAR( 255 ) NOT NULL ,'
453
	       . ' `remember_key` VARCHAR( 255 ) NOT NULL ,'
454
	       . ' `last_reset` INT NOT NULL ,'
455
	       . ' `display_name` VARCHAR( 255 ) NOT NULL ,'
456
	       . ' `email` TEXT NOT NULL ,'
457
	       . ' `timezone` INT NOT NULL ,'
458
	       . ' `date_format` VARCHAR( 255 ) NOT NULL ,'
459
	       . ' `time_format` VARCHAR( 255 ) NOT NULL ,'
460 5 stefan
	       . ' `language` VARCHAR( 5 ) NOT NULL ,'
461 4 ryan
	       . ' `home_folder` TEXT NOT NULL ,'
462
	       . ' `login_when` INT NOT NULL ,'
463
	       . ' `login_ip` VARCHAR( 15 ) NOT NULL ,'
464
	       . ' PRIMARY KEY ( `user_id` ) )'
465
	       . ' ';
466
	$database->query($users);
467
468
	// Groups table
469
	$groups = 'CREATE TABLE `'.TABLE_PREFIX.'groups` ( `group_id` INT NOT NULL auto_increment,'
470
	        . ' `name` VARCHAR( 255 ) NOT NULL ,'
471
	        . ' `system_permissions` TEXT NOT NULL ,'
472
	        . ' `module_permissions` TEXT NOT NULL ,'
473
	        . ' `template_permissions` TEXT NOT NULL ,'
474
	        . ' PRIMARY KEY ( `group_id` ) )'
475
	        . ' ';
476
	$database->query($groups);
477
478
	// Search settings table
479
	$search = 'CREATE TABLE `'.TABLE_PREFIX.'search` ( `search_id` INT NOT NULL auto_increment,'
480
	        . ' `name` VARCHAR( 255 ) NOT NULL ,'
481
	        . ' `value` TEXT NOT NULL ,'
482
	        . ' `extra` TEXT NOT NULL ,'
483
	        . ' PRIMARY KEY ( `search_id` ) )'
484
	        . ' ';
485
	$database->query($search);
486
487
	// Insert default data
488
489
	// Admin group
490
	$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';
491
	$insert_admin_group = "INSERT INTO `".TABLE_PREFIX."groups` VALUES ('1', 'Administrators', '$full_system_permissions', '', '')";
492
	$database->query($insert_admin_group);
493
	// Admin user
494
	$insert_admin_user = "INSERT INTO `".TABLE_PREFIX."users` (user_id,group_id,active,username,password,email,display_name) VALUES ('1','1','1','$admin_username','".md5($admin_password)."','$admin_email','Administrator')";
495
	$database->query($insert_admin_user);
496
	// Default settings
497
	$insert_website_title = "INSERT INTO `".TABLE_PREFIX."settings` VALUES ('', 'title', '".$website_title."')";
498
	$database->query($insert_website_title);
499
	$insert_website_description = "INSERT INTO `".TABLE_PREFIX."settings` VALUES ('', 'description', '')";
500
	$database->query($insert_website_description);
501
	$insert_website_keywords = "INSERT INTO `".TABLE_PREFIX."settings` VALUES ('', 'keywords', '')";
502
	$database->query($insert_website_keywords);
503
	$insert_website_header = "INSERT INTO `".TABLE_PREFIX."settings` VALUES ('', 'header', '')";
504
	$database->query($insert_website_header);
505
	$insert_website_footer = "INSERT INTO `".TABLE_PREFIX."settings` VALUES ('', 'footer', '')";
506
	$database->query($insert_website_footer);
507 61 stefan
	$insert_wysiwyg_style = "INSERT INTO `".TABLE_PREFIX."settings` VALUES ('', 'wysiwyg_style', 'font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;')";
508
	$database->query($insert_wysiwyg_style);
509
	$insert_rename_files_on_upload = "INSERT INTO `".TABLE_PREFIX."settings` VALUES ('', 'rename_files_on_upload', 'php,asp,phpx,aspx')";
510
	$database->query($insert_rename_files_on_upload);
511
512 4 ryan
	// Search header
513 41 stefan
	$search_header = addslashes('
514 4 ryan
<h1>Search</h1>
515
516
<form name="search" action="[WB_URL]/search/index[PAGE_EXTENSION]" method="post">
517
<table cellpadding="3" cellspacing="0" border="0" width="500">
518
<tr>
519
<td>
520 40 stefan
<input type="text" name="string" value="[SEARCH_STRING]" style="width: 100%;" />
521 4 ryan
</td>
522
<td width="150">
523 40 stefan
<input type="submit" value="[TEXT_SEARCH]" style="width: 100%;" />
524 4 ryan
</td>
525
</tr>
526
<tr>
527
<td colspan="2">
528 40 stefan
<input type="radio" name="match" id="match_all" value="all"[ALL_CHECKED] />
529
<a href="javascript: toggle_radio(\'match_all\');">[TEXT_ALL_WORDS]</a>
530
<input type="radio" name="match" id="match_any" value="any"[ANY_CHECKED] />
531
<a href="javascript: toggle_radio(\'match_any\');">[TEXT_ANY_WORDS]</a>
532
<input type="radio" name="match" id="match_exact" value="exact"[EXACT_CHECKED] />
533
<a href="javascript: toggle_radio(\'match_exact\');">[TEXT_EXACT_MATCH]</a>
534 4 ryan
</td>
535
</tr>
536
</table>
537
538
</form>
539
540
<hr />
541
	');
542
	$insert_search_header = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'header', '$search_header', '')";
543
	$database->query($insert_search_header);
544
	// Search footer
545 41 stefan
	$search_footer = addslashes('');
546 4 ryan
	$insert_search_footer = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'footer', '$search_footer', '')";
547
	$database->query($insert_search_footer);
548 5 stefan
	// Search results header
549 41 stefan
	$search_results_header = addslashes(''.
550 5 stefan
'[TEXT_RESULTS_FOR] \'<b>[SEARCH_STRING]</b>\':
551 4 ryan
<table cellpadding="2" cellspacing="0" border="0" width="100%" style="padding-top: 10px;">');
552
	$insert_search_results_header = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_header', '$search_results_header', '')";
553
	$database->query($insert_search_results_header);
554
	// Search results loop
555 41 stefan
	$search_results_loop = addslashes(''.
556 5 stefan
'<tr style="background-color: #F0F0F0;">
557
<td><a href="[LINK]">[TITLE]</a></td>
558
<td align="right">[TEXT_LAST_UPDATED_BY] [DISPLAY_NAME] ([USERNAME]) [TEXT_ON] [DATE]</td>
559
</tr>
560 4 ryan
<tr><td colspan="2" style="text-align: justify; padding-bottom: 10px;">[DESCRIPTION]</td></tr>');
561 40 stefan
$insert_search_results_loop = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_loop', '$search_results_loop', '')";
562
$database->query($insert_search_results_loop);
563
// Search results footer
564 41 stefan
$search_results_footer = addslashes("</table>");
565 40 stefan
$insert_search_results_footer = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_footer', '$search_results_footer', '')";
566
$database->query($insert_search_results_footer);
567
// Search no results
568 41 stefan
$search_no_results = addslashes('<br />No results found');
569 4 ryan
	$insert_search_no_results = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'no_results', '$search_no_results', '')";
570
	$database->query($insert_search_no_results);
571
	// Search template
572 5 stefan
	$database->query("INSERT INTO `".TABLE_PREFIX."search` (name) VALUES ('template')");
573 4 ryan
574
	// Include the pre-installed module install scripts
575
	require(WB_PATH.'/modules/wysiwyg/install.php');
576
	require(WB_PATH.'/modules/code/install.php');
577
	require(WB_PATH.'/modules/news/install.php');
578
	require(WB_PATH.'/modules/form/install.php');
579
	require(WB_PATH.'/modules/wrapper/install.php');
580
581 5 stefan
	// Check if there was a database error
582 4 ryan
	if($database->is_error()) {
583
		set_error($database->get_error());
584 5 stefan
	}
585 4 ryan
586
}
587
588 5 stefan
// Log the user in and go to Website Baker Administration
589
require(WB_PATH.'/framework/class.login.php');
590
$thisApp = new Login(
591
							array(
592
									"MAX_ATTEMPS" => "50",
593
									"WARNING_URL" => ADMIN_URL."/login/warning.html",
594
									"USERNAME_FIELDNAME" => 'admin_username',
595
									"PASSWORD_FIELDNAME" => 'admin_password',
596
									"REMEMBER_ME_OPTION" => SMART_LOGIN,
597
									"MIN_USERNAME_LEN" => "2",
598
									"MIN_PASSWORD_LEN" => "2",
599
									"MAX_USERNAME_LEN" => "30",
600
									"MAX_PASSWORD_LEN" => "30",
601
									'LOGIN_URL' => ADMIN_URL."/login/index.php",
602
									'DEFAULT_URL' => ADMIN_URL."/start/index.php",
603
									'TEMPLATE_DIR' => ADMIN_PATH."/login",
604
									'TEMPLATE_FILE' => "template.html",
605
									'FRONTEND' => false,
606
									'FORGOTTEN_DETAILS_APP' => ADMIN_URL."/login/forgot/index.php",
607
									'USERS_TABLE' => TABLE_PREFIX."users",
608
									'GROUPS_TABLE' => TABLE_PREFIX."groups",
609
							)
610
					);
611 4 ryan
612 5 stefan
?>