Project

General

Profile

1
<?php
2

    
3
// $Id: save.php,v 1.15 2005/04/25 11:53:12 rdjurovich Exp $
4
/*
5

    
6
 Website Baker Project <http://www.websitebaker.org/>
7
 Copyright (C) 2004-2005, Ryan Djurovich
8

    
9
 Website Baker is free software; you can redistribute it and/or modify
10
 it under the terms of the GNU General Public License as published by
11
 the Free Software Foundation; either version 2 of the License, or
12
 (at your option) any later version.
13

    
14
 Website Baker is distributed in the hope that it will be useful,
15
 but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 GNU General Public License for more details.
18

    
19
 You should have received a copy of the GNU General Public License
20
 along with Website Baker; if not, write to the Free Software
21
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22

    
23
*/
24

    
25
// Start a session
26
if(!defined('SESSION_STARTED')) {
27
	session_name('wb_session_id');
28
	session_start();
29
	define('SESSION_STARTED', true);
30
}
31

    
32
// Function to set error
33
function set_error($message) {
34
	global $_POST;
35
	if(isset($message) AND $message != '') {
36
		// Copy values entered into session so user doesn't have to re-enter everything
37
		if(isset($_POST['website_title'])) {
38
			$_SESSION['wb_url'] = $_POST['wb_url'];
39
			$_SESSION['wb_path'] = $_POST['wb_path'];
40
			$_SESSION['default_timezone'] = $_POST['default_timezone'];
41
			if(!isset($_POST['operating_system'])) {
42
				$_SESSION['operating_system'] = 'linux';
43
			} else {
44
				$_SESSION['operating_system'] = $_POST['operating_system'];
45
			}
46
			if(!isset($_POST['world_writeable'])) {
47
				$_SESSION['world_writeable'] = false;
48
			} else {
49
				$_SESSION['world_writeable'] = true;
50
			}
51
			$_SESSION['database_host'] = $_POST['database_host'];
52
			$_SESSION['database_username'] = $_POST['database_username'];
53
			$_SESSION['database_password'] = $_POST['database_password'];
54
			$_SESSION['database_name'] = $_POST['database_name'];
55
			$_SESSION['table_prefix'] = $_POST['table_prefix'];
56
			if(!isset($_POST['install_tables'])) {
57
				$_SESSION['install_tables'] = false;
58
			} else {
59
				$_SESSION['install_tables'] = true;
60
			}
61
			$_SESSION['website_title'] = $_POST['website_title'];
62
			$_SESSION['admin_username'] = $_POST['admin_username'];
63
			$_SESSION['admin_email'] = $_POST['admin_email'];
64
			$_SESSION['admin_password'] = $_POST['admin_password'];
65
		}
66
		// Set the message
67
		$_SESSION['message'] = $message;
68
		// Specify that session support is enabled
69
		$_SESSION['session_support'] = '<font class="good">Enabled</font>';
70
		// Redirect to first page again and exit
71
		header('Location: index.php?sessions_checked=true');
72
		exit();
73
	}
74
}
75

    
76
// Function to workout what the default permissions are for files created by the webserver
77
function default_file_mode($temp_dir) {
78
	$v = explode(".",PHP_VERSION);
79
	$v = $v[0].$v[1];
80
	if($v > 41 AND is_writable($temp_dir)) {
81
		$filename = $temp_dir.'/test_permissions.txt';
82
		$handle = fopen($filename, 'w');
83
		fwrite($handle, 'This file is to get the default file permissions');
84
		fclose($handle);
85
		$default_file_mode = '0'.substr(sprintf('%o', fileperms($filename)), -3);
86
		unlink($filename);
87
	} else {
88
		$default_file_mode = '0777';
89
	}
90
	return $default_file_mode;
91
}
92

    
93
// Function to workout what the default permissions are for directories created by the webserver
94
function default_dir_mode($temp_dir) {
95
	$v = explode(".",PHP_VERSION);
96
	$v = $v[0].$v[1];
97
	if($v > 41 AND is_writable($temp_dir)) {
98
		$dirname = $temp_dir.'/test_permissions/';
99
		mkdir($dirname);
100
		$default_dir_mode = '0'.substr(sprintf('%o', fileperms($dirname)), -3);
101
		rmdir($dirname);
102
	} else {
103
		$default_dir_mode = '0777';
104
	}
105
	return $default_dir_mode;
106
}
107

    
108
// Begin check to see if form was even submitted
109
	// Set error if no post vars found
110
	if(!isset($_POST['website_title'])) {
111
		set_error('Please fill-in the form below');
112
	}
113
// End check to see if form was even submitted
114

    
115
// Begin path and timezone details code
116
	// Check if user has entered the installation path
117
	if(!isset($_POST['wb_path']) OR $_POST['wb_path'] == '') {
118
		set_error('Please enter an absolute path');
119
	} else {
120
		$wb_path = $_POST['wb_path'];
121
	}
122
	// Check if user has entered the installation url
123
	if(!isset($_POST['wb_url']) OR $_POST['wb_url'] == '') {
124
		set_error('Please enter an absolute URL');
125
	} else {
126
		$wb_url = $_POST['wb_url'];
127
	}
128
	// Remove any slashes at the end of the URL and path
129
	if(substr($wb_url, strlen($wb_url)-1, 1) == "/") {
130
		$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
131
	}
132
	if(substr($wb_path, strlen($wb_path)-1, 1) == "/") {
133
		$wb_path = substr($wb_path, 0, strlen($wb_path)-1);
134
	}
135
	if(substr($wb_url, strlen($wb_url)-1, 1) == "\\") {
136
		$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
137
	}
138
	if(substr($wb_path, strlen($wb_path)-1, 1) == "\\") {
139
		$wb_path = substr($wb_path, 0, strlen($wb_path)-1);
140
	}
141
	if(substr($wb_url, strlen($wb_url)-1, 1) == "/") {
142
		$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
143
	}
144
	if(substr($wb_path, strlen($wb_path)-1, 1) == "/") {
145
		$wb_path = substr($wb_path, 0, strlen($wb_path)-1);
146
	}
147
	if(substr($wb_url, strlen($wb_url)-1, 1) == "\\") {
148
		$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
149
	}
150
	if(substr($wb_path, strlen($wb_path)-1, 1) == "\\") {
151
		$wb_path = substr($wb_path, 0, strlen($wb_path)-1);
152
	}
153
	// Get the default time zone
154
	if(!isset($_POST['default_timezone']) OR !is_numeric($_POST['default_timezone'])) {
155
		set_error('Please select a valid default timezone');
156
	} else {
157
		$default_timezone = $_POST['default_timezone']*60*60;
158
	}
159
// End path and timezone details code
160

    
161
// Begin operating system specific code
162
	// Get operating system
163
	if(!isset($_POST['operating_system']) OR $_POST['operating_system'] != 'linux' AND $_POST['operating_system'] != 'windows') {
164
		set_error('Please select a valid operating system');
165
	} else {
166
		$operating_system = $_POST['operating_system'];
167
	}
168
	// Work-out file permissions
169
	if($operating_system == 'windows') {
170
		$file_mode = '0777';
171
		$dir_mode = '0777';
172
	} elseif(isset($_POST['world_writeable']) AND $_POST['world_writeable'] == 'true') {
173
		$file_mode = '0777';
174
		$dir_mode = '0777';
175
	} else {
176
		$file_mode = default_file_mode('../temp');
177
		$dir_mode = default_dir_mode('../temp');
178
	}
179
// End operating system specific code
180

    
181
// Begin database details code
182
	// Check if user has entered a database host
183
	if(!isset($_POST['database_host']) OR $_POST['database_host'] == '') {
184
		set_error('Please enter a database host name');
185
	} else {
186
		$database_host = $_POST['database_host'];
187
	}
188
	// Check if user has entered a database username
189
	if(!isset($_POST['database_username']) OR $_POST['database_username'] == '') {
190
		set_error('Please enter a database username');
191
	} else {
192
		$database_username = $_POST['database_username'];
193
	}
194
	// Check if user has entered a database password
195
	if(!isset($_POST['database_password'])) {
196
		set_error('Please enter a database password');
197
	} else {
198
		$database_password = $_POST['database_password'];
199
	}
200
	// Check if user has entered a database name
201
	if(!isset($_POST['database_name']) OR $_POST['database_name'] == '') {
202
		set_error('Please enter a database name');
203
	} else {
204
		$database_name = $_POST['database_name'];
205
	}
206
	// Get table prefix
207
	$table_prefix = $_POST['table_prefix'];
208
	// Find out if the user wants to install tables and data
209
	if(isset($_POST['install_tables']) AND $_POST['install_tables'] == 'true') {
210
		$install_tables = true;
211
	} else {
212
		$install_tables = false;
213
	}
214
// End database details code
215

    
216
// Begin website title code
217
	// Get website title
218
	if(!isset($_POST['website_title']) OR $_POST['website_title'] == '') {
219
		set_error('Please enter a website title');
220
	} else {
221
		$website_title = addslashes($_POST['website_title']);
222
	}
223
// End website title code
224

    
225
// Begin admin user details code
226
	// Get admin username
227
	if(!isset($_POST['admin_username']) OR $_POST['admin_username'] == '') {
228
		set_error('Please enter a username for the Administrator account');
229
	} else {
230
		$admin_username = $_POST['admin_username'];
231
	}
232
	// Get admin email and validate it
233
	if(!isset($_POST['admin_email']) OR $_POST['admin_email'] == '') {
234
		set_error('Please enter an email for the Administrator account');
235
	} else {
236
		if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['admin_email'])) {
237
			$admin_email = $_POST['admin_email'];
238
		} else {
239
			set_error('Please enter a valid email address for the Administrator account');
240
		}
241
	}
242
	// Get the two admin passwords entered, and check that they match
243
	if(!isset($_POST['admin_password']) OR $_POST['admin_password'] == '') {
244
		set_error('Please enter a password for the Administrator account');
245
	} else {
246
		$admin_password = $_POST['admin_password'];
247
	}
248
	if(!isset($_POST['admin_repassword']) OR $_POST['admin_repassword'] == '') {
249
		set_error('Please make sure you re-enter the password for the Administrator account');
250
	} else {
251
		$admin_repassword = $_POST['admin_repassword'];
252
	}
253
	if($admin_password != $admin_repassword) {
254
		set_error('Sorry, the two Administrator account passwords you entered do not match');
255
	}
256
// End admin user details code
257

    
258
// Try and write settings to config file
259
$config_content = "" .
260
"<?php\n".
261
"\n".
262
"define('ER_LEVEL', '');\n".
263
"\n".
264
"define('DEFAULT_LANGUAGE', 'EN');\n".
265
"\n".
266
"define('APP_NAME', 'wb');\n".
267
"\n".
268
"define('DB_TYPE', 'mysql');\n".
269
"define('DB_HOST', '$database_host');\n".
270
"define('DB_USERNAME', '$database_username');\n".
271
"define('DB_PASSWORD', '$database_password');\n".
272
"define('DB_NAME', '$database_name');\n".
273
"\n".
274
"define('TABLE_PREFIX', '$table_prefix');\n".
275
"\n".
276
"define('DEFAULT_TIMEZONE', '$default_timezone');\n".
277
"define('DEFAULT_DATE_FORMAT', 'M d Y');\n".
278
"define('DEFAULT_TIME_FORMAT', 'g:i A');\n".
279
"\n".
280
"define('HOME_FOLDERS', true);\n".
281
"\n".
282
"define('DEFAULT_TEMPLATE', 'round');\n".
283
"define('MULTIPLE_MENUS', false);\n".
284
"\n".
285
"define('PAGE_LEVEL_LIMIT', '4');\n".
286
"define('INTRO_PAGE', false);\n".
287
"define('PAGE_TRASH', 'disabled');\n".
288
"define('HOMEPAGE_REDIRECTION', false);\n".
289
"define('PAGE_LANGUAGES', false);\n".
290
"\n".
291
"define('WYSIWYG_STYLE', 'font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;');\n".
292
"\n".
293
"define('MANAGE_SECTIONS', true);\n".
294
"define('SECTION_BLOCKS', false);\n".
295
"\n".
296
"define('SMART_LOGIN', false);\n".
297
"define('FRONTEND_LOGIN', false);\n".
298
"define('FRONTEND_SIGNUP', '');\n".
299
"\n".
300
"define('SERVER_EMAIL', '".$admin_email."');\n".
301
"\n".
302
"define('SEARCH', 'public');\n".
303
"\n".
304
"define('PAGE_EXTENSION', '.php');\n".
305
"define('PAGE_SPACER', '-');\n".
306
"\n".
307
"define('PAGES_DIRECTORY', '/pages');\n".
308
"define('MEDIA_DIRECTORY', '/media');\n".
309
"\n".
310
"define('OPERATING_SYSTEM', '$operating_system');\n".
311
"define('OCTAL_FILE_MODE', $file_mode);\n".
312
"define('STRING_FILE_MODE', '$file_mode');\n".
313
"define('OCTAL_DIR_MODE', $dir_mode);\n".
314
"define('STRING_DIR_MODE', '$dir_mode');\n".
315
"\n".
316
"define('WB_PATH', '$wb_path');\n".
317
"define('WB_URL', '$wb_url');\n".
318
"\n".
319
"define('ADMIN_PATH', '$wb_path/admin');\n".
320
"define('ADMIN_URL', '$wb_url/admin');\n".
321
"\n".
322
"?>";
323

    
324
$config_filename = '../config.php';
325

    
326
// Check if the file exists and is writable first.
327
if(file_exists($config_filename) AND is_writable($config_filename)) {
328
	if(!$handle = fopen($config_filename, 'w')) {
329
		set_error("Cannot open the configuration file ($config_filename)");
330
	} else {
331
		if (fwrite($handle, $config_content) === FALSE) {
332
			set_error("Cannot write to the configuration file ($config_filename)");
333
		}
334
		// Close file
335
		fclose($handle);
336
	}
337
} else {
338
	set_error("The configuration file $config_filename is not writable. Change its permissions so it is, then re-run step 4.");
339
}
340

    
341
// Include configuration file
342
require('../config.php');
343

    
344
// Check if the user has entered a correct path
345
if(!file_exists(WB_PATH.'/framework/class.admin.php')) {
346
	set_error('It appears the Absolute path that you entered is incorrect');
347
}
348

    
349
// Include WB functions file
350
if(!defined('FUNCTIONS_FILE_LOADED')) {
351
	require(WB_PATH.'/framework/functions.php');
352
}
353

    
354
// Try connecting to database	
355
if(!mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD)) {
356
	set_error('Database host name, username and/or password incorrect. MySQL Error:<br />'.mysql_error());
357
}
358

    
359
// Try to create the database
360
mysql_query('CREATE DATABASE '.$database_name);
361

    
362
// Close the mysql connection
363
mysql_close();
364

    
365
// Re-connect to the database, this time using in-build database class
366
require(WB_PATH.'/framework/class.admin.php');
367
$database = new database();
368

    
369
// Check if we should install tables
370
if($install_tables == true) {
371
	
372
	// Remove tables if they exist
373

    
374
	// Pages table
375
	$pages = "DROP TABLE IF EXISTS `".TABLE_PREFIX."pages`";
376
	$database->query($pages);
377
	// Sections table
378
	$sections = "DROP TABLE IF EXISTS `".TABLE_PREFIX."sections`";
379
	$database->query($sections);
380
	// Settings table
381
	$settings = "DROP TABLE IF EXISTS `".TABLE_PREFIX."settings`";
382
	$database->query($settings);
383
	// Users table
384
	$users = "DROP TABLE IF EXISTS `".TABLE_PREFIX."users`";
385
	$database->query($users);
386
	// Groups table
387
	$groups = "DROP TABLE IF EXISTS `".TABLE_PREFIX."groups`";
388
	$database->query($groups);
389
	// Search table
390
	$search = "DROP TABLE IF EXISTS `".TABLE_PREFIX."search`";
391
	$database->query($search);
392
			
393
	// Try installing tables
394
	
395
	// Pages table
396
	$pages = 'CREATE TABLE `'.TABLE_PREFIX.'pages` ( `page_id` INT NOT NULL auto_increment,'
397
	       . ' `parent` INT NOT NULL ,'
398
	       . ' `root_parent` INT NOT NULL ,'
399
	       . ' `level` INT NOT NULL ,'
400
	       . ' `link` TEXT NOT NULL ,'
401
	       . ' `target` VARCHAR( 7 ) NOT NULL ,'
402
	       . ' `page_title` VARCHAR( 255 ) NOT NULL ,'
403
	       . ' `menu_title` VARCHAR( 255 ) NOT NULL ,'
404
	       . ' `description` TEXT NOT NULL ,'
405
	       . ' `keywords` TEXT NOT NULL ,'
406
	       . ' `page_trail` TEXT NOT NULL ,'
407
	       . ' `template` VARCHAR( 255 ) NOT NULL ,'
408
	       . ' `visibility` VARCHAR( 255 ) NOT NULL ,'
409
	       . ' `position` INT NOT NULL ,'
410
	       . ' `menu` INT NOT NULL ,'
411
	       . ' `language` VARCHAR( 5 ) NOT NULL ,'
412
	       . ' `searching` INT NOT NULL ,'
413
	       . ' `admin_groups` TEXT NOT NULL ,'
414
	       . ' `admin_users` TEXT NOT NULL ,'
415
	       . ' `viewing_groups` TEXT NOT NULL ,'
416
	       . ' `viewing_users` TEXT NOT NULL ,'
417
	       . ' `modified_when` INT NOT NULL ,'
418
	       . ' `modified_by` INT NOT NULL ,'
419
	       . ' PRIMARY KEY ( `page_id` ) )'
420
	       . ' ';
421
	$database->query($pages);
422
	
423
	// Sections table
424
	$pages = 'CREATE TABLE `'.TABLE_PREFIX.'sections` ( `section_id` INT NOT NULL auto_increment,'
425
	       . ' `page_id` INT NOT NULL ,'
426
	       . ' `position` INT NOT NULL ,'
427
	       . ' `module` VARCHAR( 255 ) NOT NULL ,'
428
	       . ' `block` VARCHAR( 255 ) NOT NULL ,'
429
	       . ' PRIMARY KEY ( `section_id` ) )'
430
	       . ' ';
431
	$database->query($pages);
432
	
433
	// Settings table
434
	$settings = 'CREATE TABLE `'.TABLE_PREFIX.'settings` ( `setting_id` INT NOT NULL auto_increment,'
435
	          . ' `name` VARCHAR( 255 ) NOT NULL ,'
436
	          . ' `value` TEXT NOT NULL ,'
437
	          . ' PRIMARY KEY ( `setting_id` ) )'
438
	          . ' ';
439
	$database->query($settings);
440
	
441
	// Users table
442
	$users = 'CREATE TABLE `'.TABLE_PREFIX.'users` ( `user_id` INT NOT NULL auto_increment,'
443
	       . ' `group_id` INT NOT NULL ,'
444
	       . ' `active` INT NOT NULL ,'
445
	       . ' `username` VARCHAR( 255 ) NOT NULL ,'
446
	       . ' `password` VARCHAR( 255 ) NOT NULL ,'
447
	       . ' `remember_key` VARCHAR( 255 ) NOT NULL ,'
448
	       . ' `last_reset` INT NOT NULL ,'
449
	       . ' `display_name` VARCHAR( 255 ) NOT NULL ,'
450
	       . ' `email` TEXT NOT NULL ,'
451
	       . ' `timezone` INT NOT NULL ,'
452
	       . ' `date_format` VARCHAR( 255 ) NOT NULL ,'
453
	       . ' `time_format` VARCHAR( 255 ) NOT NULL ,'
454
	       . ' `language` VARCHAR( 5 ) NOT NULL ,'
455
	       . ' `home_folder` TEXT NOT NULL ,'
456
	       . ' `login_when` INT NOT NULL ,'
457
	       . ' `login_ip` VARCHAR( 15 ) NOT NULL ,'
458
	       . ' PRIMARY KEY ( `user_id` ) )'
459
	       . ' ';
460
	$database->query($users);
461
	
462
	// Groups table
463
	$groups = 'CREATE TABLE `'.TABLE_PREFIX.'groups` ( `group_id` INT NOT NULL auto_increment,'
464
	        . ' `name` VARCHAR( 255 ) NOT NULL ,'
465
	        . ' `system_permissions` TEXT NOT NULL ,'
466
	        . ' `module_permissions` TEXT NOT NULL ,'
467
	        . ' `template_permissions` TEXT NOT NULL ,'
468
	        . ' PRIMARY KEY ( `group_id` ) )'
469
	        . ' ';
470
	$database->query($groups);
471
	
472
	// Search settings table
473
	$search = 'CREATE TABLE `'.TABLE_PREFIX.'search` ( `search_id` INT NOT NULL auto_increment,'
474
	        . ' `name` VARCHAR( 255 ) NOT NULL ,'
475
	        . ' `value` TEXT NOT NULL ,'
476
	        . ' `extra` TEXT NOT NULL ,'
477
	        . ' PRIMARY KEY ( `search_id` ) )'
478
	        . ' ';
479
	$database->query($search);
480
	
481
	// Insert default data
482
	
483
	// Admin group
484
	$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';
485
	$insert_admin_group = "INSERT INTO `".TABLE_PREFIX."groups` VALUES ('1', 'Administrators', '$full_system_permissions', '', '')";
486
	$database->query($insert_admin_group);
487
	// Admin user
488
	$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')";
489
	$database->query($insert_admin_user);
490
	// Default settings
491
	$insert_website_title = "INSERT INTO `".TABLE_PREFIX."settings` VALUES ('', 'title', '".$website_title."')";
492
	$database->query($insert_website_title);
493
	$insert_website_description = "INSERT INTO `".TABLE_PREFIX."settings` VALUES ('', 'description', '')";
494
	$database->query($insert_website_description);
495
	$insert_website_keywords = "INSERT INTO `".TABLE_PREFIX."settings` VALUES ('', 'keywords', '')";
496
	$database->query($insert_website_keywords);
497
	$insert_website_header = "INSERT INTO `".TABLE_PREFIX."settings` VALUES ('', 'header', '')";
498
	$database->query($insert_website_header);
499
	$insert_website_footer = "INSERT INTO `".TABLE_PREFIX."settings` VALUES ('', 'footer', '')";
500
	$database->query($insert_website_footer);
501
	// Search header
502
	$search_header = addslashes('
503
<h1>Search</h1>
504

    
505
<form name="search" action="[WB_URL]/search/index[PAGE_EXTENSION]" method="post">
506
<table cellpadding="3" cellspacing="0" border="0" width="500">
507
<tr>
508
<td>
509
	<input type="text" name="string" value="[SEARCH_STRING]" style="width: 100%;" />
510
</td>
511
<td width="150">
512
	<input type="submit" value="[TEXT_SEARCH]" style="width: 100%;" />
513
</td>
514
</tr>
515
<tr>
516
<td colspan="2">
517
	<input type="radio" name="match" id="match_all" value="all"[ALL_CHECKED] />
518
	<a href="javascript: toggle_radio(\'match_all\');">[TEXT_ALL_WORDS]</a>
519
	<input type="radio" name="match" id="match_any" value="any"[ANY_CHECKED] />
520
	<a href="javascript: toggle_radio(\'match_any\');">[TEXT_ANY_WORDS]</a>
521
	<input type="radio" name="match" id="match_exact" value="exact"[EXACT_CHECKED] />
522
	<a href="javascript: toggle_radio(\'match_exact\');">[TEXT_EXACT_MATCH]</a>
523
</td>
524
</tr>
525
</table>
526

    
527
</form>
528

    
529
<hr />
530
	');
531
	$insert_search_header = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'header', '$search_header', '')";
532
	$database->query($insert_search_header);
533
	// Search footer
534
	$search_footer = addslashes('');
535
	$insert_search_footer = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'footer', '$search_footer', '')";
536
	$database->query($insert_search_footer);
537
	// Search results header
538
	$search_results_header = addslashes(''.
539
'[TEXT_RESULTS_FOR] \'<b>[SEARCH_STRING]</b>\':
540
<table cellpadding="2" cellspacing="0" border="0" width="100%" style="padding-top: 10px;">');
541
	$insert_search_results_header = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_header', '$search_results_header', '')";
542
	$database->query($insert_search_results_header);
543
	// Search results loop
544
	$search_results_loop = addslashes(''.
545
'<tr style="background-color: #F0F0F0;">
546
<td><a href="[LINK]">[TITLE]</a></td>
547
<td align="right">[TEXT_LAST_UPDATED_BY] [DISPLAY_NAME] ([USERNAME]) [TEXT_ON] [DATE]</td>
548
</tr>
549
<tr><td colspan="2" style="text-align: justify; padding-bottom: 10px;">[DESCRIPTION]</td></tr>');
550
	$insert_search_results_loop = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_loop', '$search_results_loop', '')";
551
	$database->query($insert_search_results_loop);
552
	// Search results footer
553
	$search_results_footer = addslashes("</table>");
554
	$insert_search_results_footer = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'results_footer', '$search_results_footer', '')";
555
	$database->query($insert_search_results_footer);
556
	// Search no results
557
	$search_no_results = addslashes('<br />No results found');
558
	$insert_search_no_results = "INSERT INTO `".TABLE_PREFIX."search` VALUES ('', 'no_results', '$search_no_results', '')";
559
	$database->query($insert_search_no_results);
560
	// Search template
561
	$database->query("INSERT INTO `".TABLE_PREFIX."search` (name) VALUES ('template')");
562
	
563
	// Include the pre-installed module install scripts
564
	require(WB_PATH.'/modules/wysiwyg/install.php');
565
	require(WB_PATH.'/modules/code/install.php');
566
	require(WB_PATH.'/modules/news/install.php');
567
	require(WB_PATH.'/modules/form/install.php');
568
	require(WB_PATH.'/modules/wrapper/install.php');
569
	
570
	// Check if there was a database error
571
	if($database->is_error()) {
572
		set_error($database->get_error());
573
	}
574
	
575
}
576

    
577
// Log the user in and go to Website Baker Administration
578
require(WB_PATH.'/framework/class.login.php');
579
$thisApp = new Login(
580
							array(
581
									"MAX_ATTEMPS" => "50",
582
									"WARNING_URL" => ADMIN_URL."/login/warning.html",
583
									"USERNAME_FIELDNAME" => 'admin_username',
584
									"PASSWORD_FIELDNAME" => 'admin_password',
585
									"REMEMBER_ME_OPTION" => SMART_LOGIN,
586
									"MIN_USERNAME_LEN" => "2",
587
									"MIN_PASSWORD_LEN" => "2",
588
									"MAX_USERNAME_LEN" => "30",
589
									"MAX_PASSWORD_LEN" => "30",
590
									'LOGIN_URL' => ADMIN_URL."/login/index.php",
591
									'DEFAULT_URL' => ADMIN_URL."/start/index.php",
592
									'TEMPLATE_DIR' => ADMIN_PATH."/login",
593
									'TEMPLATE_FILE' => "template.html",
594
									'FRONTEND' => false,
595
									'FORGOTTEN_DETAILS_APP' => ADMIN_URL."/login/forgot/index.php",
596
									'USERS_TABLE' => TABLE_PREFIX."users",
597
									'GROUPS_TABLE' => TABLE_PREFIX."groups",
598
							)
599
					);
600

    
601
?>
(2-2/3)