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