Project

General

Profile

1 1349 Luisehahne
<?php
2
/**
3
 *
4
 * @category        framework
5
 * @package         initialize
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12 1374 Luisehahne
 * @requirements    PHP 5.2.2 and higher
13 1349 Luisehahne
 * @version         $Id$
14
 * @filesource		$HeadURL$
15
 * @lastmodified    $Date$
16
 *
17
 */
18
19 1488 DarkViper
/* -------------------------------------------------------- */
20
// Must include code to stop this file being accessed directly
21 1499 DarkViper
require_once(dirname(__FILE__).'/globalExceptionHandler.php');
22 1487 DarkViper
if(!defined('WB_PATH')) { throw new IllegalFileException(); }
23 1488 DarkViper
/* -------------------------------------------------------- */
24 1349 Luisehahne
//set_include_path(get_include_path() . PATH_SEPARATOR . WB_PATH);
25
26
if (file_exists(WB_PATH.'/framework/class.database.php')) {
27 1596 Luisehahne
	$sTmpReferer = '';
28
	if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != '') {
29
	        $tmp0 = parse_url($_SERVER['HTTP_REFERER']);
30 1598 Luisehahne
       if ($tmp0 !== false) {
31
                $tmp0['host'] = isset($tmp0['host']) ? $tmp0['host'] : '';
32
                $tmp0['path'] = isset($tmp0['path']) ? $tmp0['path'] : '';
33
                $tmp0['fragment'] = isset($tmp0['fragment']) ? '#'.$tmp0['fragment'] : '';
34
                $tmp1 = parse_url(WB_URL);
35
                if ($tmp1 !== false) {
36
                        $tmp1['host'] = isset($tmp1['host']) ? $tmp1['host'] : '';
37
                        $tmp1['path'] = isset($tmp1['path']) ? $tmp1['path'] : '';
38
                        if (strpos($tmp0['host'].$tmp0['path'], $tmp1['host'].$tmp1['path']) !== false) {
39
                                $sTmpReferer = WB_URL.$tmp0['path'].$tmp0['fragment'];
40
                        }
41
                }
42
        }
43 1596 Luisehahne
	}
44
	$_SERVER['HTTP_REFERER'] = $sTmpReferer;
45 1462 DarkViper
	date_default_timezone_set('UTC');
46 1349 Luisehahne
	require_once(WB_PATH.'/framework/class.database.php');
47
48
	// Create database class
49
	$database = new database();
50
51
    if(version_compare(PHP_VERSION, '5.3.0', '<'))
52
    {
53
        set_magic_quotes_runtime(0); // Disable magic_quotes_runtime
54
    }
55
	// Get website settings (title, keywords, description, header, and footer)
56
	$query_settings = "SELECT name,value FROM ".TABLE_PREFIX."settings";
57
	$get_settings = $database->query($query_settings);
58
	if($database->is_error()) { die($database->get_error()); }
59
	if($get_settings->numRows() == 0) { die("Settings not found"); }
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 1510 darkviper
	@define('DO_NOT_TRACK', (isset($_SERVER['HTTP_DNT'])));
70 1349 Luisehahne
	$string_file_mode = STRING_FILE_MODE;
71
	define('OCTAL_FILE_MODE',(int) octdec($string_file_mode));
72
	$string_dir_mode = STRING_DIR_MODE;
73
	define('OCTAL_DIR_MODE',(int) octdec($string_dir_mode));
74 1465 Luisehahne
	$sSecMod = (defined('SECURE_FORM_MODULE') && SECURE_FORM_MODULE != '') ? '.'.SECURE_FORM_MODULE : '';
75 1462 DarkViper
	$sSecMod = WB_PATH.'/framework/SecureForm'.$sSecMod.'.php';
76
	require_once($sSecMod);
77 1349 Luisehahne
	if (!defined("WB_INSTALL_PROCESS")) {
78
		// get CAPTCHA and ASP settings
79
		$table = TABLE_PREFIX.'mod_captcha_control';
80 1462 DarkViper
		if( ($get_settings = $database->query("SELECT * FROM $table LIMIT 1")) ) {
81 1349 Luisehahne
			if($get_settings->numRows() == 0) { die("CAPTCHA-Settings not found"); }
82
			$setting = $get_settings->fetchRow();
83
			if($setting['enabled_captcha'] == '1') define('ENABLED_CAPTCHA', true);
84
			else define('ENABLED_CAPTCHA', false);
85
			if($setting['enabled_asp'] == '1') define('ENABLED_ASP', true);
86
			else define('ENABLED_ASP', false);
87
			define('CAPTCHA_TYPE', $setting['captcha_type']);
88
			define('ASP_SESSION_MIN_AGE', (int)$setting['asp_session_min_age']);
89
			define('ASP_VIEW_MIN_AGE', (int)$setting['asp_view_min_age']);
90
			define('ASP_INPUT_MIN_AGE', (int)$setting['asp_input_min_age']);
91
		}
92
	}
93
94
	// set error-reporting
95
	if(intval(ER_LEVEL) > 0 )
96
	{
97
		error_reporting(ER_LEVEL);
98 1352 Luisehahne
		if( intval(ini_get ( 'display_errors' )) == 0 )
99 1349 Luisehahne
		{
100
			ini_set('display_errors', 1);
101
		}
102
	}
103
	// Start a session
104
	if(!defined('SESSION_STARTED')) {
105
		session_name(APP_NAME.'_session_id');
106
		@session_start();
107
		define('SESSION_STARTED', true);
108
	}
109
	if(defined('ENABLED_ASP') && ENABLED_ASP && !isset($_SESSION['session_started']))
110
		$_SESSION['session_started'] = time();
111
112
	// Get users language
113
	if(isset($_GET['lang']) AND $_GET['lang'] != '' AND !is_numeric($_GET['lang']) AND strlen($_GET['lang']) == 2) {
114
	  	define('LANGUAGE', strtoupper($_GET['lang']));
115
		$_SESSION['LANGUAGE']=LANGUAGE;
116
	} else {
117
		if(isset($_SESSION['LANGUAGE']) AND $_SESSION['LANGUAGE'] != '') {
118
			define('LANGUAGE', $_SESSION['LANGUAGE']);
119
		} else {
120
			define('LANGUAGE', DEFAULT_LANGUAGE);
121
		}
122
	}
123
124
	// Load Language file
125
	if(!defined('LANGUAGE_LOADED')) {
126
		if(!file_exists(WB_PATH.'/languages/'.LANGUAGE.'.php')) {
127
			exit('Error loading language file '.LANGUAGE.', please check configuration');
128
		} else {
129
			require_once(WB_PATH.'/languages/'.LANGUAGE.'.php');
130
		}
131
	}
132
133
	// Get users timezone
134
	if(isset($_SESSION['TIMEZONE'])) {
135
		define('TIMEZONE', $_SESSION['TIMEZONE']);
136
	} else {
137
		define('TIMEZONE', DEFAULT_TIMEZONE);
138
	}
139
	// Get users date format
140
	if(isset($_SESSION['DATE_FORMAT'])) {
141
		define('DATE_FORMAT', $_SESSION['DATE_FORMAT']);
142
	} else {
143
		define('DATE_FORMAT', DEFAULT_DATE_FORMAT);
144
	}
145
	// Get users time format
146
	if(isset($_SESSION['TIME_FORMAT'])) {
147
		define('TIME_FORMAT', $_SESSION['TIME_FORMAT']);
148
	} else {
149
		define('TIME_FORMAT', DEFAULT_TIME_FORMAT);
150
	}
151
152
	// Set Theme dir
153
	define('THEME_URL', WB_URL.'/templates/'.DEFAULT_THEME);
154
	define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);
155
156
    // extended wb_settings
157
	define('EDIT_ONE_SECTION', false);
158
159
	define('EDITOR_WIDTH', 0);
160
161 1598 Luisehahne
}