1
|
<?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
|
* @requirements PHP 5.2.2 and higher
|
13
|
* @version $Id: initialize.php 1617 2012-02-22 11:24:12Z darkviper $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/framework/initialize.php $
|
15
|
* @lastmodified $Date: 2012-02-22 12:24:12 +0100 (Wed, 22 Feb 2012) $
|
16
|
*
|
17
|
*/
|
18
|
|
19
|
/* -------------------------------------------------------- */
|
20
|
// Must include code to stop this file being accessed directly
|
21
|
require_once(dirname(__FILE__).'/globalExceptionHandler.php');
|
22
|
if(!defined('WB_PATH')) { throw new IllegalFileException(); }
|
23
|
/* -------------------------------------------------------- */
|
24
|
/**
|
25
|
* sanitize $_SERVER['HTTP_REFERER']
|
26
|
* @param string $sWbUrl qualified startup URL of current application
|
27
|
*/
|
28
|
function SanitizeHttpReferer($sWbUrl = WB_URL) {
|
29
|
$sTmpReferer = '';
|
30
|
if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != '') {
|
31
|
$aRefUrl = parse_url($_SERVER['HTTP_REFERER']);
|
32
|
if ($aRefUrl !== false) {
|
33
|
$aRefUrl['host'] = isset($aRefUrl['host']) ? $aRefUrl['host'] : '';
|
34
|
$aRefUrl['path'] = isset($aRefUrl['path']) ? $aRefUrl['path'] : '';
|
35
|
$aRefUrl['fragment'] = isset($aRefUrl['fragment']) ? '#'.$aRefUrl['fragment'] : '';
|
36
|
$aWbUrl = parse_url(WB_URL);
|
37
|
if ($aWbUrl !== false) {
|
38
|
$aWbUrl['host'] = isset($aWbUrl['host']) ? $aWbUrl['host'] : '';
|
39
|
$aWbUrl['path'] = isset($aWbUrl['path']) ? $aWbUrl['path'] : '';
|
40
|
if (strpos($aRefUrl['host'].$aRefUrl['path'],
|
41
|
$aWbUrl['host'].$aWbUrl['path']) !== false) {
|
42
|
$aRefUrl['path'] = preg_replace('#^'.$aWbUrl['path'].'#i', '', $aRefUrl['path']);
|
43
|
$sTmpReferer = WB_URL.$aRefUrl['path'].$aRefUrl['fragment'];
|
44
|
}
|
45
|
unset($aWbUrl);
|
46
|
}
|
47
|
unset($aRefUrl);
|
48
|
}
|
49
|
}
|
50
|
$_SERVER['HTTP_REFERER'] = $sTmpReferer;
|
51
|
}
|
52
|
|
53
|
|
54
|
if (file_exists(WB_PATH.'/framework/class.database.php')) {
|
55
|
// sanitize $_SERVER['HTTP_REFERER']
|
56
|
SanitizeHttpReferer(WB_URL);
|
57
|
date_default_timezone_set('UTC');
|
58
|
require_once(WB_PATH.'/framework/class.database.php');
|
59
|
|
60
|
// Create database class
|
61
|
$database = new database();
|
62
|
|
63
|
if(version_compare(PHP_VERSION, '5.3.0', '<'))
|
64
|
{
|
65
|
set_magic_quotes_runtime(0); // Disable magic_quotes_runtime
|
66
|
}
|
67
|
// Get website settings (title, keywords, description, header, and footer)
|
68
|
$query_settings = "SELECT name,value FROM ".TABLE_PREFIX."settings";
|
69
|
$get_settings = $database->query($query_settings);
|
70
|
if($database->is_error()) { die($database->get_error()); }
|
71
|
if($get_settings->numRows() == 0) { die("Settings not found"); }
|
72
|
while($setting = $get_settings->fetchRow()) {
|
73
|
$setting_name=strtoupper($setting['name']);
|
74
|
$setting_value=$setting['value'];
|
75
|
if ($setting_value=='false')
|
76
|
$setting_value=false;
|
77
|
if ($setting_value=='true')
|
78
|
$setting_value=true;
|
79
|
@define($setting_name,$setting_value);
|
80
|
}
|
81
|
@define('DO_NOT_TRACK', (isset($_SERVER['HTTP_DNT'])));
|
82
|
$string_file_mode = STRING_FILE_MODE;
|
83
|
define('OCTAL_FILE_MODE',(int) octdec($string_file_mode));
|
84
|
$string_dir_mode = STRING_DIR_MODE;
|
85
|
define('OCTAL_DIR_MODE',(int) octdec($string_dir_mode));
|
86
|
$sSecMod = (defined('SECURE_FORM_MODULE') && SECURE_FORM_MODULE != '') ? '.'.SECURE_FORM_MODULE : '';
|
87
|
$sSecMod = WB_PATH.'/framework/SecureForm'.$sSecMod.'.php';
|
88
|
require_once($sSecMod);
|
89
|
if (!defined("WB_INSTALL_PROCESS")) {
|
90
|
// get CAPTCHA and ASP settings
|
91
|
$table = TABLE_PREFIX.'mod_captcha_control';
|
92
|
if( ($get_settings = $database->query("SELECT * FROM $table LIMIT 1")) ) {
|
93
|
if($get_settings->numRows() == 0) { die("CAPTCHA-Settings not found"); }
|
94
|
$setting = $get_settings->fetchRow();
|
95
|
if($setting['enabled_captcha'] == '1') define('ENABLED_CAPTCHA', true);
|
96
|
else define('ENABLED_CAPTCHA', false);
|
97
|
if($setting['enabled_asp'] == '1') define('ENABLED_ASP', true);
|
98
|
else define('ENABLED_ASP', false);
|
99
|
define('CAPTCHA_TYPE', $setting['captcha_type']);
|
100
|
define('ASP_SESSION_MIN_AGE', (int)$setting['asp_session_min_age']);
|
101
|
define('ASP_VIEW_MIN_AGE', (int)$setting['asp_view_min_age']);
|
102
|
define('ASP_INPUT_MIN_AGE', (int)$setting['asp_input_min_age']);
|
103
|
}
|
104
|
}
|
105
|
|
106
|
// set error-reporting
|
107
|
if(intval(ER_LEVEL) > 0 )
|
108
|
{
|
109
|
error_reporting(ER_LEVEL);
|
110
|
if( intval(ini_get ( 'display_errors' )) == 0 )
|
111
|
{
|
112
|
ini_set('display_errors', 1);
|
113
|
}
|
114
|
}
|
115
|
// Start a session
|
116
|
if(!defined('SESSION_STARTED')) {
|
117
|
session_name(APP_NAME.'_session_id');
|
118
|
@session_start();
|
119
|
define('SESSION_STARTED', true);
|
120
|
}
|
121
|
if(defined('ENABLED_ASP') && ENABLED_ASP && !isset($_SESSION['session_started']))
|
122
|
$_SESSION['session_started'] = time();
|
123
|
|
124
|
// Get users language
|
125
|
if(isset($_GET['lang']) AND $_GET['lang'] != '' AND !is_numeric($_GET['lang']) AND strlen($_GET['lang']) == 2) {
|
126
|
define('LANGUAGE', strtoupper($_GET['lang']));
|
127
|
$_SESSION['LANGUAGE']=LANGUAGE;
|
128
|
} else {
|
129
|
if(isset($_SESSION['LANGUAGE']) AND $_SESSION['LANGUAGE'] != '') {
|
130
|
define('LANGUAGE', $_SESSION['LANGUAGE']);
|
131
|
} else {
|
132
|
define('LANGUAGE', DEFAULT_LANGUAGE);
|
133
|
}
|
134
|
}
|
135
|
|
136
|
// Load Language file
|
137
|
if(!defined('LANGUAGE_LOADED')) {
|
138
|
if(!file_exists(WB_PATH.'/languages/'.LANGUAGE.'.php')) {
|
139
|
exit('Error loading language file '.LANGUAGE.', please check configuration');
|
140
|
} else {
|
141
|
require_once(WB_PATH.'/languages/'.LANGUAGE.'.php');
|
142
|
}
|
143
|
}
|
144
|
|
145
|
// Get users timezone
|
146
|
if(isset($_SESSION['TIMEZONE'])) {
|
147
|
define('TIMEZONE', $_SESSION['TIMEZONE']);
|
148
|
} else {
|
149
|
define('TIMEZONE', DEFAULT_TIMEZONE);
|
150
|
}
|
151
|
// Get users date format
|
152
|
if(isset($_SESSION['DATE_FORMAT'])) {
|
153
|
define('DATE_FORMAT', $_SESSION['DATE_FORMAT']);
|
154
|
} else {
|
155
|
define('DATE_FORMAT', DEFAULT_DATE_FORMAT);
|
156
|
}
|
157
|
// Get users time format
|
158
|
if(isset($_SESSION['TIME_FORMAT'])) {
|
159
|
define('TIME_FORMAT', $_SESSION['TIME_FORMAT']);
|
160
|
} else {
|
161
|
define('TIME_FORMAT', DEFAULT_TIME_FORMAT);
|
162
|
}
|
163
|
|
164
|
// Set Theme dir
|
165
|
define('THEME_URL', WB_URL.'/templates/'.DEFAULT_THEME);
|
166
|
define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);
|
167
|
|
168
|
// extended wb_settings
|
169
|
define('EDIT_ONE_SECTION', false);
|
170
|
|
171
|
define('EDITOR_WIDTH', 0);
|
172
|
|
173
|
}
|