Project

General

Profile

1
<?php
2

    
3
// $Id: initialize.php 143 2005-09-18 23:49:44Z ryan $
4

    
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
*/
25
 
26
if (file_exists(WB_PATH.'/framework/class.database.php'))
27
{
28
	require_once(WB_PATH.'/framework/class.database.php');
29
		
30
	// Create database class
31
	$database = new database();
32
	
33
	set_magic_quotes_runtime(0);
34
	
35
	// Get website settings (title, keywords, description, header, and footer)
36
	$query_settings = "SELECT name,value FROM ".TABLE_PREFIX."settings";
37
	$get_settings = $database->query($query_settings);
38
	while($setting = $get_settings->fetchRow()) {
39
		$setting_name=strtoupper($setting['name']);
40
		$setting_value=$setting['value'];
41
		if ($setting_value=='false')
42
			$setting_value=false;
43
		if ($setting_value=='true')
44
			$setting_value=true;
45
		define($setting_name,$setting_value);
46
	}
47
	$string_file_mode = STRING_FILE_MODE;
48
	define('OCTAL_FILE_MODE',(int) $string_file_mode);
49
	$string_dir_mode = STRING_DIR_MODE;
50
	define('OCTAL_DIR_MODE',(int) $string_dir_mode);
51
	
52
	// Start a session
53
	if(!defined('SESSION_STARTED')) {
54
		session_name(APP_NAME.'_session_id');
55
		session_start();
56
		define('SESSION_STARTED', true);
57
	}
58
	
59
	// Get users language
60
	if(isset($_GET['lang']) AND $_GET['lang'] != '' AND !is_numeric($_GET['lang']) AND strlen($_GET['lang']) == 2) {
61
	  	define('LANGUAGE', strtoupper($_GET['lang']));
62
		$_SESSION['LANGUAGE']=LANGUAGE;
63
	} else {
64
		if(isset($_SESSION['LANGUAGE']) AND $_SESSION['LANGUAGE'] != '') {
65
			define('LANGUAGE', $_SESSION['LANGUAGE']);
66
		} else {
67
			define('LANGUAGE', DEFAULT_LANGUAGE);
68
		}
69
	}
70
	
71
	// Load Language file
72
	if(!defined('LANGUAGE_LOADED')) {
73
		if(!file_exists(WB_PATH.'/languages/'.LANGUAGE.'.php')) {
74
			exit('Error loading language file '.LANGUAGE.', please check configuration');
75
		} else {
76
			require_once(WB_PATH.'/languages/'.LANGUAGE.'.php');
77
		}
78
	}
79
	
80
	// Get users timezone
81
	if(isset($_SESSION['TIMEZONE'])) {
82
		define('TIMEZONE', $_SESSION['TIMEZONE']);
83
	} else {
84
		define('TIMEZONE', DEFAULT_TIMEZONE);
85
	}
86
	// Get users date format
87
	if(isset($_SESSION['DATE_FORMAT'])) {
88
		define('DATE_FORMAT', $_SESSION['DATE_FORMAT']);
89
	} else {
90
		define('DATE_FORMAT', DEFAULT_DATE_FORMAT);
91
	}
92
	// Get users time format
93
	if(isset($_SESSION['TIME_FORMAT'])) {
94
		define('TIME_FORMAT', $_SESSION['TIME_FORMAT']);
95
	} else {
96
		define('TIME_FORMAT', DEFAULT_TIME_FORMAT);
97
	}
98
		
99
}
100

    
101
?>
(11-11/11)