Project

General

Profile

« Previous | Next » 

Revision 95

Added by stefan about 19 years ago

Moved settings from config.php into database.
NOT FULLY WORKING!!!

View differences:

trunk/wb/install/save.php
268 268
$config_content = "" .
269 269
"<?php\n".
270 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 271
"define('DB_TYPE', 'mysql');\n".
278 272
"define('DB_HOST', '$database_host');\n".
279 273
"define('DB_USERNAME', '$database_username');\n".
280 274
"define('DB_PASSWORD', '$database_password');\n".
281 275
"define('DB_NAME', '$database_name');\n".
282
"\n".
283 276
"define('TABLE_PREFIX', '$table_prefix');\n".
284 277
"\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
"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
"define('PAGE_LANGUAGES', false);\n".
299
"define('WYSIWYG_EDITOR', 'htmlarea');\n".
300
"\n".
301
"define('MANAGE_SECTIONS', true);\n".
302
"define('SECTION_BLOCKS', false);\n".
303
"\n".
304
"define('SMART_LOGIN', false);\n".
305
"define('FRONTEND_LOGIN', false);\n".
306
"define('FRONTEND_SIGNUP', '');\n".
307
"\n".
308
"define('SERVER_EMAIL', '".$admin_email."');\n".
309
"\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
"\n".
318
"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 278
"define('WB_PATH', '$wb_path');\n".
325 279
"define('WB_URL', '$wb_url');\n".
326
"\n".
327 280
"define('ADMIN_PATH', '$wb_path/admin');\n".
328 281
"define('ADMIN_URL', '$wb_url/admin');\n".
329 282
"\n".
......
354 307
	set_error('It appears the Absolute path that you entered is incorrect');
355 308
}
356 309

  
357
// Include WB functions file
358
require_once(WB_PATH.'/framework/functions.php');
359

  
360 310
// Try connecting to database	
361 311
if(!mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD)) {
362 312
	set_error('Database host name, username and/or password incorrect. MySQL Error:<br />'.mysql_error());
......
368 318
// Close the mysql connection
369 319
mysql_close();
370 320

  
321
// Include WB functions file
322
require_once(WB_PATH.'/framework/functions.php');
323

  
371 324
// Re-connect to the database, this time using in-build database class
372
require_once(WB_PATH.'/framework/class.admin.php');
373
$database = new database();
325
require_once(WB_PATH.'/framework/class.login.php');
326
$database=new database();
374 327

  
375 328
// Check if we should install tables
376 329
if($install_tables == true) {
......
396 349
	$search = "DROP TABLE IF EXISTS `".TABLE_PREFIX."search`";
397 350
	$database->query($search);
398 351
			
352

  
353

  
399 354
	// Try installing tables
400 355
	
401 356
	// Pages table
......
437 392
	$database->query($pages);
438 393
	
439 394
	// 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
	          . ' ';
395
	$settings="CREATE TABLE `".TABLE_PREFIX."settings` ( `setting_id` INT NOT NULL auto_increment,
396
		`name` VARCHAR( 255 ) NOT NULL ,
397
		`value` TEXT NOT NULL ,
398
		PRIMARY KEY ( `setting_id` ) )";
445 399
	$database->query($settings);
400
	$settings_rows=	"INSERT INTO `".TABLE_PREFIX."settings` VALUES ('', 'website_title', '$website_title'),"
401
	." ('', 'website_description', ''),"
402
	." ('', 'website_keywords', ''),"
403
	." ('', 'website_header', ''),"
404
	." ('', 'website_footer', ''),"
405
	." ('', 'wysiwyg_style', 'font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;'),"
406
	." ('', 'rename_files_on_upload', 'php,asp,phpx,aspx'),"
407
	." ('', 'er_level', ''),"
408
	." ('', 'default_language', 'en'),"
409
	." ('', 'app_name', 'wb'),"
410
	." ('', 'default_timezone', '0'),"
411
	." ('', 'default_date_format', 'M d Y'),"
412
	." ('', 'default_time_format', 'g:i A'),"
413
	." ('', 'home_folders', '1'),"
414
	." ('', 'default_template', 'round'),"
415
	." ('', 'multiple_menus', 'false'),"
416
	." ('', 'page_level_limit', '4'),"
417
	." ('', 'intro_page', 'false'),"
418
	." ('', 'page_trash', 'disabled'),"
419
	." ('', 'homepage_redirection', 'false'),"
420
	." ('', 'page_languages', 'false'),"
421
	." ('', 'wysiwyg_editor', 'htmlarea'),"
422
	." ('', 'manage_sections', '1'),"
423
	." ('', 'section_blocks', 'false'),"
424
	." ('', 'smart_login', 'false'),"
425
	." ('', 'frontend_login', 'false'),"
426
	." ('', 'frontend_signup', 'false'),"
427
	." ('', 'server_email', '$admin_email'),"
428
	." ('', 'search', 'public'),"
429
	." ('', 'page_extension', '.php'),"
430
	." ('', 'page_spacer', '-'),"
431
	." ('', 'pages_directory', '/pages'),"
432
	." ('', 'media_directory', '/media'),"
433
	." ('', 'operating_system', '$operating_system'),"
434
	." ('', 'octal_file_mode', '$file_mode'),"
435
	." ('', 'string_file_mode', '$file_mode'),"
436
	." ('', 'octal_dir_mode', '$dir_mode'),"
437
	." ('', 'string_dir_mode', '$dir_mode');";
438
	$database->query($settings_rows);
446 439
	
440
	
447 441
	// Users table
448 442
	$users = 'CREATE TABLE `'.TABLE_PREFIX.'users` ( `user_id` INT NOT NULL auto_increment,'
449 443
	       . ' `group_id` INT NOT NULL ,'
......
493 487
	// Admin user
494 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')";
495 489
	$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
	$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 490
	
512 491
	// Search header
513 492
	$search_header = addslashes('
......
571 550
	// Search template
572 551
	$database->query("INSERT INTO `".TABLE_PREFIX."search` (name) VALUES ('template')");
573 552
	
553
	$wb=new wb();
554
	
574 555
	// Include the pre-installed module install scripts
575 556
	require(WB_PATH.'/modules/wysiwyg/install.php');
576 557
	require(WB_PATH.'/modules/code/install.php');
......
586 567
}
587 568

  
588 569
// Log the user in and go to Website Baker Administration
589
require(WB_PATH.'/framework/class.login.php');
590 570
$thisApp = new Login(
591 571
							array(
592 572
									"MAX_ATTEMPS" => "50",
trunk/wb/admin/index.php
1 1
<?php
2 2

  
3
// $Id: index.php,v 1.2 2005/03/28 11:58:03 rdjurovich Exp $
3
// $Id$
4 4

  
5 5
/*
6 6

  
trunk/wb/admin/interface/timezones.php
1 1
<?php
2 2

  
3
// $Id: timezones.php,v 1.1.1.1 2005/01/30 10:30:19 rdjurovich Exp $
3
// $Id$
4 4

  
5 5
/*
6 6

  
......
31 31

  
32 32
*/
33 33

  
34
// Define that this file is loaded
35
if(!defined('TIMEZONES_LOADED')) {
36
	define('TIMEZONES_LOADED', true);
37
}
38

  
39 34
// Create array
40 35
$TIMEZONES = array();
41 36

  
trunk/wb/admin/settings/save.php
168 168
	$config_filename = $WB_PATH.'/config.php';
169 169
	$config_content = "" .
170 170
	"<?php \n".
171
	"\n".
172
	"define('ER_LEVEL', '$er_level');\n".
173
	$er_level_code.
174
	"\n".
175
	"define('DEFAULT_LANGUAGE', '".str_replace(';', '', $_POST['language'])."');\n".
176
	"\n".
177
	"define('APP_NAME', 'wb');\n".
178
	"\n".
179 171
	"define('DB_TYPE', '".DB_TYPE."');\n".
180 172
	"define('DB_HOST', '".DB_HOST."');\n".
181 173
	"define('DB_USERNAME', '".DB_USERNAME."');\n".
182 174
	"define('DB_PASSWORD', '".DB_PASSWORD."');\n".
183 175
	"define('DB_NAME', '".DB_NAME."');\n".
184
	"\n".
185 176
	"define('TABLE_PREFIX', '".TABLE_PREFIX."');\n".
186 177
	"\n".
187
	"define('DEFAULT_TIMEZONE', '".$timezone_offset."');\n".
188
	"define('DEFAULT_DATE_FORMAT', '".str_replace(';', '', $_POST['date_format'])."');\n".
189
	"define('DEFAULT_TIME_FORMAT', '".str_replace(';', '', $_POST['time_format'])."');\n".
190
	"\n".
191
	"define('HOME_FOLDERS', ".$_POST['home_folders'].");\n".
192
	"\n".
193
	"define('DEFAULT_TEMPLATE', '".$_POST['template']."');\n".
194
	"define('MULTIPLE_MENUS', ".str_replace(';', '', $_POST['multiple_menus']).");\n".
195
	"\n".
196
	"define('INTRO_PAGE', ".str_replace(';', '', $_POST['intro_page']).");\n".
197
	"define('PAGE_TRASH', '".str_replace(';', '', $_POST['page_trash'])."');\n".
198
	"define('PAGE_LEVEL_LIMIT', '".str_replace(';', '', $_POST['page_level_limit'])."');\n".
199
	"define('HOMEPAGE_REDIRECTION', ".str_replace(';', '', $_POST['homepage_redirection']).");\n".
200
	"define('PAGE_LANGUAGES', ".str_replace(';', '', $_POST['page_languages']).");\n".
201
	"\n".
202
	"define('WYSIWYG_EDITOR', '".addslashes($_POST['wysiwyg_editor'])."');\n".
203
	"\n".
204
	"define('MANAGE_SECTIONS', ".str_replace(';', '', $_POST['manage_sections']).");\n".
205
	"define('SECTION_BLOCKS', ".str_replace(';', '', $_POST['section_blocks']).");\n".
206
	"\n".
207
	"define('SMART_LOGIN', ".str_replace(';', '', $_POST['smart_login']).");\n".
208
	"define('FRONTEND_LOGIN', ".str_replace(';', '', $_POST['frontend_login']).");\n".
209
	"define('FRONTEND_SIGNUP', ".str_replace(';', '', $_POST['frontend_signup']).");\n".
210
	"\n".
211
	"define('SERVER_EMAIL', '".$_POST['server_email']."');\n".
212
	"\n".
213
	"define('SEARCH', '".$admin->get_post('search')."');\n".
214
	"\n".
215
	"define('PAGE_EXTENSION', '".str_replace(';', '', $_POST['page_extension'])."');\n".
216
	"define('PAGE_SPACER', '".str_replace(';', '', $_POST['page_spacer'])."');\n".
217
	"\n".
218
	"define('PAGES_DIRECTORY', '".PAGES_DIRECTORY."');\n".
219
	"define('MEDIA_DIRECTORY', '".MEDIA_DIRECTORY."');\n".
220
	"\n".
221
	"define('OPERATING_SYSTEM', '".str_replace(';', '', $_POST['operating_system'])."');\n".
222
	"define('OCTAL_FILE_MODE', ".$file_mode.");\n".
223
	"define('STRING_FILE_MODE', '".$file_mode."');\n".
224
	"define('OCTAL_DIR_MODE', ".$dir_mode.");\n".
225
	"define('STRING_DIR_MODE', '".$dir_mode."');\n".
226
	"\n".
227 178
	"define('WB_PATH', '".$WB_PATH."');\n".
228 179
	"define('WB_URL', '".WB_URL."');\n".
229
	"\n".
230 180
	"define('ADMIN_PATH', '".$ADMIN_PATH."');\n".
231 181
	"define('ADMIN_URL', '".ADMIN_URL."');\n".
232 182
	"\n".
trunk/wb/admin/settings/index.php
44 44
$results = $database->query($query);
45 45
while($setting = $results->fetchRow()) {
46 46
	$setting_name = $setting['name'];
47
	$setting_value = htmlspecialchars($admin->strip_slashes_dummy($setting['value']));
48
	switch($setting_name) {
49
		// Website title
50
		case 'title':
51
			$template->set_var('TITLE', $setting_value);
52
		break;
53
		// Website description
54
		case 'description':
55
			$template->set_var('DESCRIPTION', $setting_value);
56
		break;
57
		// Website keywords
58
		case 'keywords':
59
			$template->set_var('KEYWORDS', $setting_value);
60
		break;
61
		// Website header
62
		case 'header':
63
			$template->set_var('HEADER', $setting_value);
64
		break;
65
		// Website header
66
		case 'header':
67
			$template->set_var('HEADER', $setting_value);
68
		break;
69
		// Website footer
70
		case 'footer':
71
			$template->set_var('FOOTER', $setting_value);
72
		break;
73
		// WYSIWYG style
74
		case 'wysiwyg_style':
75
			$template->set_var('WYSIWYG_STYLE', $setting_value);
76
		break;
77
		case 'rename_files_on_upload':
78
			$template->set_var('RENAME_FILES_ON_UPLOAD', $setting_value);
79
		break;
80
	}
47
	$setting_value = htmlspecialchars($setting['value']);
48
	/*if ($setting_value=='false')
49
		$setting_value=false;
50
	if ($setting_value=='true')
51
		$setting_value=true;*/
52
	echo strtoupper($setting_name).'-'.$setting_value.'-'.($setting_value=="false").'<br />';
53
	$template->set_var(strtoupper($setting_name),$setting_value);
81 54
}
82 55

  
83 56
// Query current settings in the db, then loop through them and print them
trunk/wb/admin/settings/template.html
87 87
<tr>
88 88
	<td class="setting_name">{TEXT_WEBSITE_TITLE}:</td>
89 89
	<td class="setting_value" colspan="2">
90
		<input type="text" name="title" value="{TITLE}" />
90
		<input type="text" name="website_title" value="{WEBSITE_TITLE}" />
91 91
	</td>
92 92
	<script language="javascript" type="text/javascript">
93 93
	document.settings.title.focus();
......
96 96
<tr>
97 97
	<td class="setting_name">{TEXT_WEBSITE_DESCRIPTION}:</td>
98 98
	<td class="setting_value" colspan="2">
99
		<textarea name="description">{DESCRIPTION}</textarea>
99
		<textarea name="website_description">{WEBSITE_DESCRIPTION}</textarea>
100 100
	</td>
101 101
</tr>
102 102
<tr>
103 103
	<td class="setting_name">{TEXT_WEBSITE_KEYWORDS}:</td>
104 104
	<td class="setting_value" colspan="2">
105
		<textarea name="keywords">{KEYWORDS}</textarea>
105
		<textarea name="website_keywords">{WEBSITE_KEYWORDS}</textarea>
106 106
	</td>
107 107
</tr>
108 108
<tr class="advanced">
109 109
	<td class="setting_name">{TEXT_WEBSITE_HEADER}:</td>
110 110
	<td class="setting_value" colspan="2">
111
		<textarea name="header">{HEADER}</textarea>
111
		<textarea name="website_header">{WEBSITE_HEADER}</textarea>
112 112
	</td>
113 113
</tr>
114 114
<tr>
115 115
	<td class="setting_name">{TEXT_WEBSITE_FOOTER}:</td>
116 116
	<td class="setting_value" colspan="2">
117
		<textarea name="footer">{FOOTER}</textarea>
117
		<textarea name="website_footer">{WEBSITE_FOOTER}</textarea>
118 118
	</td>
119 119
</tr>
120 120
<tr>
......
281 281
<tr>
282 282
	<td class="setting_name">{TEXT_LANGUAGE}:</td>
283 283
	<td class="setting_value" colspan="2">
284
		<select name="language">
284
		<select name="default_language">
285 285
			<!-- BEGIN language_list_block -->
286 286
			<option value="{CODE}"{SELECTED}>{NAME} ({CODE})</option>
287 287
			<!-- END language_list_block -->
......
291 291
<tr>
292 292
	<td class="setting_name">{TEXT_TIMEZONE}:</td>
293 293
	<td class="setting_value" colspan="2">
294
		<select name="timezone">
294
		<select name="default_timezone">
295 295
			<option value="0">{TEXT_PLEASE_SELECT}...</option>
296 296
			<!-- BEGIN timezone_list_block -->
297 297
				<option value="{VALUE}" {SELECTED}>{NAME}</option>
......
302 302
<tr>
303 303
	<td class="setting_name">{TEXT_DATE_FORMAT}:</td>
304 304
	<td class="setting_value" colspan="2">
305
		<select name="date_format">
305
		<select name="default_date_format">
306 306
			<option value="M d Y">{TEXT_PLEASE_SELECT}...</option>
307 307
			<!-- BEGIN date_format_list_block -->
308 308
				<option value="{VALUE}" {SELECTED}>{NAME}</option>
......
313 313
<tr>
314 314
	<td class="setting_name">{TEXT_TIME_FORMAT}:</td>
315 315
	<td class="setting_value" colspan="2">
316
		<select name="time_format">
316
		<select name="default_time_format">
317 317
			<option value="g:i A">{TEXT_PLEASE_SELECT}...</option>
318 318
			<!-- BEGIN time_format_list_block -->
319 319
				<option value="{VALUE}" {SELECTED}>{NAME}</option>
......
324 324
<tr>
325 325
	<td class="setting_name">{TEXT_TEMPLATE}:</td>
326 326
	<td class="setting_value" colspan="2">
327
		<select name="template">
327
		<select name="default_template">
328 328
		<!-- BEGIN template_list_block -->
329 329
			<option value="{FILE}"{SELECTED}>{NAME}</option>
330 330
		<!-- END template_list_block -->
trunk/wb/framework/class.admin.php
84 84
		global $MESSAGE;
85 85
		global $TEXT;
86 86
		// Connect to database and get website title
87
		$database = & $this->database;
87
		global $database;
88 88
		$get_title = $database->query("SELECT value FROM ".TABLE_PREFIX."settings WHERE name = 'title'");
89 89
		$title = $get_title->fetchRow();
90 90
		$header_template = new Template(ADMIN_PATH."/interface");
trunk/wb/framework/class.wb.php
31 31

  
32 32
*/
33 33
if (file_exists(WB_PATH.'/framework/class.database.php'))
34
require_once(WB_PATH.'/framework/class.database.php');
34
	require_once(WB_PATH.'/framework/class.database.php');
35 35
		
36 36

  
37 37
class wb
38
{	
38
{
39 39
	// General initialization function 
40 40
	// performed when frontend or backend is loaded.
41 41
	function wb() {
42 42
		// set global database variable
43 43
		global $database;
44 44
		// Create database class
45
		$database = new database();
46
		$this->database = $database;
45
		$this->database = new database();
46
		$database=$this->database;
47 47

  
48 48
		// Start a session
49 49
		if(!defined('SESSION_STARTED')) {
......
51 51
			session_start();
52 52
			define('SESSION_STARTED', true);
53 53
		}
54

  
55
		set_magic_quotes_runtime(0);
54 56
		
57
		// Get website settings (title, keywords, description, header, and footer)
58
		$query_settings = "SELECT name,value FROM ".TABLE_PREFIX."settings";
59
		$get_settings = $database->query($query_settings);
60
		while($setting = $get_settings->fetchRow()) {
61
			$setting_name=strtoupper($setting['name']);
62
			$setting_value=$setting['value'];
63
			if ($setting_value=='false')
64
				$setting_value=false;
65
			if ($setting_value=='true')
66
				$setting_value=true;
67
			define($setting_name,$setting_value);
68
		}
69
		$string_file_mode = STRING_FILE_MODE;
70
		define('OCTAL_FILE_MODE',(int) $string_file_mode);
71
		$string_dir_mode = STRING_DIR_MODE;
72
		define('OCTAL_DIR_MODE',(int) $string_dir_mode);
73
		
55 74
		// Get users language
56 75
		if(isset($_GET['lang']) AND $_GET['lang'] != '' AND !is_numeric($_GET['lang']) AND strlen($_GET['lang']) == 2) {
57 76
		  	define('LANGUAGE', strtoupper($_GET['lang']));
......
77 96
		}
78 97
		
79 98
		// Get users timezone
80
		if(!defined('TIMEZONE')) {
81
			if(isset($_SESSION['TIMEZONE'])) {
82
				define('TIMEZONE', $_SESSION['TIMEZONE']);
83
			} else {
84
				define('TIMEZONE', DEFAULT_TIMEZONE);
85
			}
99
		if(isset($_SESSION['TIMEZONE'])) {
100
			define('TIMEZONE', $_SESSION['TIMEZONE']);
101
		} else {
102
			define('TIMEZONE', DEFAULT_TIMEZONE);
86 103
		}
87 104
		// Get users date format
88
		if(!defined('DATE_FORMAT')) {
89
			if(isset($_SESSION['DATE_FORMAT'])) {
90
				define('DATE_FORMAT', $_SESSION['DATE_FORMAT']);
91
			} else {
92
				define('DATE_FORMAT', DEFAULT_DATE_FORMAT);
93
			}
105
		if(isset($_SESSION['DATE_FORMAT'])) {
106
			define('DATE_FORMAT', $_SESSION['DATE_FORMAT']);
107
		} else {
108
			define('DATE_FORMAT', DEFAULT_DATE_FORMAT);
94 109
		}
95 110
		// Get users time format
96
		if(!defined('TIME_FORMAT')) {
97
			if(isset($_SESSION['TIME_FORMAT'])) {
98
				define('TIME_FORMAT', $_SESSION['TIME_FORMAT']);
99
			} else {
100
				define('TIME_FORMAT', DEFAULT_TIME_FORMAT);
101
			}
111
		if(isset($_SESSION['TIME_FORMAT'])) {
112
			define('TIME_FORMAT', $_SESSION['TIME_FORMAT']);
113
		} else {
114
			define('TIME_FORMAT', DEFAULT_TIME_FORMAT);
102 115
		}
103
		
104
		set_magic_quotes_runtime(0);
105 116
	}
106 117

  
107 118
	// Check whether we should show a page or not (for front-end)
trunk/wb/framework/class.frontend.php
47 47
	// page database row
48 48
	var $page;
49 49
	var $page_id,$page_title,$menu_title,$parent,$root_parent,$level,$visibility;
50
	var $page_description,$page_keywords,$page_link_original,$page_link;
50
	var $page_description,$page_keywords,$page_link;
51 51
	var $page_trail=array();
52 52
	
53 53
	var $page_access_denied;
......
64 64
	
65 65
	function page_select() {
66 66
		global $page_id,$no_intro;
67
		$database=& $this->database;
67
		global $database;
68 68
		// We have no page id and are supposed to show the intro page
69 69
		if((INTRO_PAGE AND !isset($no_intro)) AND (!isset($page_id) OR !is_numeric($page_id))) {
70 70
			// Since we have no page id check if we should go to intro page or default page
......
121 121
	}
122 122

  
123 123
	function get_page_details() {
124
		$database = & $this->database;
124
		global $database;
125 125
	    if($this->page_id != 0) {
126 126
			// Query page details
127 127
			$query_page = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '{$this->page_id}'";
......
142 142
			// Begin code to set details as either variables of constants
143 143
			// Page ID
144 144
			define('PAGE_ID', $this->page['page_id']);
145
			$this->page_id=$this->page['page_id'];
146 145
			// Page Title
147 146
			define('PAGE_TITLE', $this->strip_slashes_dummy($this->page['page_title']));
148 147
			$this->page_title=PAGE_TITLE;
......
180 179
		// End code to set details as either variables of constants
181 180
		}
182 181

  
183
		// Work-out if any possible in-line search boxes should be shown
184
		if(SEARCH == 'public') {
185
			define('SHOW_SEARCH', true);
186
		} elseif(SEARCH == 'private' AND VISIBILITY == 'private') {
187
			define('SHOW_SEARCH', true);
188
		} elseif(SEARCH == 'private' AND $wb->is_authenticated() == true) {
189
			define('SHOW_SEARCH', true);
190
		} else {
191
			define('SHOW_SEARCH', false);
192
		}
193
		// Work-out if menu should be shown
194
		if(!defined('SHOW_MENU')) {
195
			define('SHOW_MENU', true);
196
		}
197
		// Work-out if login menu constants should be set
198
		if(FRONTEND_LOGIN) {
199
			// Set login menu constants
200
			define('LOGIN_URL', WB_URL.'/account/login'.PAGE_EXTENSION);
201
			define('LOGOUT_URL', WB_URL.'/account/logout'.PAGE_EXTENSION);
202
			define('FORGOT_URL', WB_URL.'/account/forgot'.PAGE_EXTENSION);
203
			define('PREFERENCES_URL', WB_URL.'/account/preferences'.PAGE_EXTENSION);
204
			define('SIGNUP_URL', WB_URL.'/account/signup'.PAGE_EXTENSION);
205
		}
206

  
207 182
		// Figure out what template to use
208 183
		if(!defined('TEMPLATE')) {
209 184
			if(isset($this->page['template']) AND $this->page['template'] != '') {
......
219 194
		// Set the template dir
220 195
		define('TEMPLATE_DIR', WB_URL.'/templates/'.TEMPLATE);
221 196

  
222
		// Check if user is allow to view this page
197
		// Check if user is allowed to view this page
223 198
		if(VISIBILITY == 'private' OR VISIBILITY == 'registered') {
224 199
			// Check if the user is authenticated
225 200
			if($this->is_authenticated() == false) {
......
234 209
			// User isnt allowed on this page so tell them
235 210
			$this->page_access_denied=true;
236 211
		}
212
	}
213

  
214
	function get_website_settings() {
215
		global $database;
216

  
217
		// set visibility SQL code
237 218
		// never show no-vis, hidden or deleted pages
238 219
		$this->extra_where_sql = "visibility != 'none' AND visibility != 'hidden' AND visibility != 'deleted'";
239 220
		// Set extra private sql code
......
246 227
			}
247 228
		}
248 229
		$this->extra_where_sql .= $this->sql_where_language;
249
	}
250 230

  
251
	function get_website_settings() {
252
		$database = & $this->database;
253
		// Get website settings (title, keywords, description, header, and footer)
254
		$query_settings = "SELECT name,value FROM ".TABLE_PREFIX."settings";
255
		$get_settings = $database->query($query_settings);
256
		while($setting = $get_settings->fetchRow()) {
257
			switch($setting['name']) {
258
				case 'title':
259
					define('WEBSITE_TITLE', $this->strip_slashes_dummy($setting['value']));
260
					$this->website_title=WEBSITE_TITLE;
261
				break;
262
				case 'description':
263
					if($page_description != '') {
264
						define('WEBSITE_DESCRIPTION', $page_description);
265
					} else {
266
						define('WEBSITE_DESCRIPTION', $this->strip_slashes_dummy($setting['value']));
267
					}
268
					$this->website_description=WEBSITE_DESCRIPTION;
269
				break;
270
				case 'keywords':
271
					if($page_keywords != '') {
272
						define('WEBSITE_KEYWORDS', $this->strip_slashes_dummy($setting['value']).' '.$page_keywords);
273
					} else {
274
						define('WEBSITE_KEYWORDS', $this->strip_slashes_dummy($setting['value']));
275
					}
276
					$this->website_keywords=WEBSITE_KEYWORDS;
277
				break;
278
				case 'header':
279
					define('WEBSITE_HEADER', $this->strip_slashes_dummy($setting['value']));
280
					$this->website_header=WEBSITE_HEADER;
281
				break;
282
				case 'footer':
283
					define('WEBSITE_FOOTER', $this->strip_slashes_dummy($setting['value']));
284
					$this->website_footer=WEBSITE_FOOTER;
285
				break;
286
			}
231
		// Work-out if any possible in-line search boxes should be shown
232
		if(SEARCH == 'public') {
233
			define('SHOW_SEARCH', true);
234
		} elseif(SEARCH == 'private' AND VISIBILITY == 'private') {
235
			define('SHOW_SEARCH', true);
236
		} elseif(SEARCH == 'private' AND $wb->is_authenticated() == true) {
237
			define('SHOW_SEARCH', true);
238
		} else {
239
			define('SHOW_SEARCH', false);
287 240
		}
241
		// Work-out if menu should be shown
242
		if(!defined('SHOW_MENU')) {
243
			define('SHOW_MENU', true);
244
		}
245
		// Work-out if login menu constants should be set
246
		if(FRONTEND_LOGIN) {
247
			// Set login menu constants
248
			define('LOGIN_URL', WB_URL.'/account/login'.PAGE_EXTENSION);
249
			define('LOGOUT_URL', WB_URL.'/account/logout'.PAGE_EXTENSION);
250
			define('FORGOT_URL', WB_URL.'/account/forgot'.PAGE_EXTENSION);
251
			define('PREFERENCES_URL', WB_URL.'/account/preferences'.PAGE_EXTENSION);
252
			define('SIGNUP_URL', WB_URL.'/account/signup'.PAGE_EXTENSION);
253
		}
288 254
	}
289 255
	
290 256
	function page_link($link){
......
297 263
	}
298 264
	
299 265
	function preprocess(&$content) {
300
		$database = & $this->database;
266
		global $database;
301 267
		// Replace [wblink--PAGE_ID--] with real link
302 268
		$pattern = '/\[wblink(.+?)\]/s';
303 269
		preg_match_all($pattern,$content,$ids);
......
360 326
	}
361 327
	
362 328
	function show_menu() {
363
	   $database = & $this->database;
329
	   global $database;
364 330
	   if ($this->menu_recurse==0)
365 331
	       return;
366 332
	   // Check if we should add menu number check to query
......
414 380
		// Get outside objects
415 381
		global $TEXT,$MENU,$HEADING,$MESSAGE;
416 382
		global $globals;
417
		$database = & $this->database;
383
		global $database;
418 384
		$admin = & $this;
419 385
		if ($this->page_access_denied==true) {
420 386
            echo $MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS'];
trunk/wb/framework/class.database.php
74 74
	
75 75
	// Disconnect from the database
76 76
	function disconnect() {
77
		if(isset($this->Database)) {
77
		if($this->connected==true) {
78 78
			mysql_close();
79 79
			return true;
80 80
		} else {

Also available in: Unified diff