1 |
1349
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category framework
|
5 |
|
|
* @package initialize
|
6 |
1694
|
Luisehahne
|
* @author Ryan Djurovich, WebsiteBaker Project
|
7 |
|
|
* @copyright 2009-2012, WebsiteBaker Org. e.V.
|
8 |
1349
|
Luisehahne
|
* @link http://www.websitebaker2.org/
|
9 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
10 |
|
|
* @platform WebsiteBaker 2.8.x
|
11 |
1374
|
Luisehahne
|
* @requirements PHP 5.2.2 and higher
|
12 |
1349
|
Luisehahne
|
* @version $Id$
|
13 |
|
|
* @filesource $HeadURL$
|
14 |
|
|
* @lastmodified $Date$
|
15 |
|
|
*
|
16 |
|
|
*/
|
17 |
|
|
|
18 |
1488
|
DarkViper
|
/* -------------------------------------------------------- */
|
19 |
|
|
// Must include code to stop this file being accessed directly
|
20 |
1499
|
DarkViper
|
require_once(dirname(__FILE__).'/globalExceptionHandler.php');
|
21 |
1637
|
darkviper
|
if(!defined('WB_URL')) { throw new IllegalFileException(); }
|
22 |
1488
|
DarkViper
|
/* -------------------------------------------------------- */
|
23 |
1617
|
darkviper
|
/**
|
24 |
|
|
* sanitize $_SERVER['HTTP_REFERER']
|
25 |
|
|
* @param string $sWbUrl qualified startup URL of current application
|
26 |
|
|
*/
|
27 |
|
|
function SanitizeHttpReferer($sWbUrl = WB_URL) {
|
28 |
|
|
$sTmpReferer = '';
|
29 |
|
|
if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != '') {
|
30 |
|
|
$aRefUrl = parse_url($_SERVER['HTTP_REFERER']);
|
31 |
|
|
if ($aRefUrl !== false) {
|
32 |
|
|
$aRefUrl['host'] = isset($aRefUrl['host']) ? $aRefUrl['host'] : '';
|
33 |
|
|
$aRefUrl['path'] = isset($aRefUrl['path']) ? $aRefUrl['path'] : '';
|
34 |
|
|
$aRefUrl['fragment'] = isset($aRefUrl['fragment']) ? '#'.$aRefUrl['fragment'] : '';
|
35 |
|
|
$aWbUrl = parse_url(WB_URL);
|
36 |
|
|
if ($aWbUrl !== false) {
|
37 |
|
|
$aWbUrl['host'] = isset($aWbUrl['host']) ? $aWbUrl['host'] : '';
|
38 |
|
|
$aWbUrl['path'] = isset($aWbUrl['path']) ? $aWbUrl['path'] : '';
|
39 |
|
|
if (strpos($aRefUrl['host'].$aRefUrl['path'],
|
40 |
|
|
$aWbUrl['host'].$aWbUrl['path']) !== false) {
|
41 |
|
|
$aRefUrl['path'] = preg_replace('#^'.$aWbUrl['path'].'#i', '', $aRefUrl['path']);
|
42 |
|
|
$sTmpReferer = WB_URL.$aRefUrl['path'].$aRefUrl['fragment'];
|
43 |
|
|
}
|
44 |
|
|
unset($aWbUrl);
|
45 |
|
|
}
|
46 |
|
|
unset($aRefUrl);
|
47 |
|
|
}
|
48 |
|
|
}
|
49 |
|
|
$_SERVER['HTTP_REFERER'] = $sTmpReferer;
|
50 |
|
|
}
|
51 |
1680
|
darkviper
|
/* -------------------------------------------------------- */
|
52 |
|
|
function SetInstallPathConstants() {
|
53 |
|
|
if(!defined('DEBUG')){ define('DEBUG', false); }// Include config file
|
54 |
|
|
if(!defined('ADMIN_DIRECTORY')){ define('ADMIN_DIRECTORY', 'admin'); }
|
55 |
|
|
if(!preg_match('/xx[a-z0-9_][a-z0-9_\-\.]+/i', 'xx'.ADMIN_DIRECTORY)) {
|
56 |
|
|
throw new RuntimeException('Invalid admin-directory: ' . ADMIN_DIRECTORY);
|
57 |
|
|
}
|
58 |
|
|
if(!defined('WB_PATH')){ define('WB_PATH', dirname(dirname(__FILE__))); }
|
59 |
|
|
if(!defined('ADMIN_URL')){ define('ADMIN_URL', WB_URL.'/'.ADMIN_DIRECTORY); }
|
60 |
|
|
if(!defined('ADMIN_PATH')){ define('ADMIN_PATH', WB_PATH.'/'.ADMIN_DIRECTORY); }
|
61 |
|
|
if(!defined('WB_REL')){
|
62 |
|
|
$x1 = parse_url(WB_URL);
|
63 |
|
|
define('WB_REL', (isset($x1['path']) ? $x1['path'] : ''));
|
64 |
|
|
}
|
65 |
|
|
if(!defined('DOCUMENT_ROOT')) {
|
66 |
|
|
define('DOCUMENT_ROOT', preg_replace('/'.preg_quote(WB_REL, '/').'$/', '', WB_PATH));
|
67 |
|
|
}
|
68 |
|
|
}
|
69 |
|
|
/* -------------------------------------------------------- */
|
70 |
|
|
$starttime = array_sum(explode(" ",microtime()));
|
71 |
1694
|
Luisehahne
|
$iPhpDeclaredClasses = sizeof(get_declared_classes());
|
72 |
1680
|
darkviper
|
SetInstallPathConstants();
|
73 |
|
|
SanitizeHttpReferer(WB_URL); // sanitize $_SERVER['HTTP_REFERER']
|
74 |
1687
|
darkviper
|
if(!class_exists('WbAutoloader', false)){ include(dirname(__FILE__).'/WbAutoloader.php'); }
|
75 |
|
|
WbAutoloader::doRegister(array(ADMIN_DIRECTORY=>'a', 'modules'=>'m'));
|
76 |
|
|
require_once dirname(dirname(__FILE__)).'/include/Twig/Autoloader.php';
|
77 |
|
|
Twig_Autoloader::register();
|
78 |
1462
|
DarkViper
|
date_default_timezone_set('UTC');
|
79 |
1349
|
Luisehahne
|
// Create database class
|
80 |
1682
|
darkviper
|
$sSqlUrl = DB_TYPE.'://'.DB_USERNAME.':'.DB_PASSWORD.'@'.DB_HOST.'/'.DB_NAME;
|
81 |
1686
|
darkviper
|
$database = WbDatabase::getInstance();
|
82 |
1683
|
darkviper
|
$database->doConnect($sSqlUrl);
|
83 |
1680
|
darkviper
|
// disable all kind of magic_quotes
|
84 |
|
|
if(get_magic_quotes_gpc() || get_magic_quotes_runtime()) {
|
85 |
|
|
@ini_set('magic_quotes_sybase', 0);
|
86 |
|
|
@ini_set('magic_quotes_gpc', 0);
|
87 |
|
|
@ini_set('magic_quotes_runtime', 0);
|
88 |
|
|
}
|
89 |
1349
|
Luisehahne
|
// Get website settings (title, keywords, description, header, and footer)
|
90 |
|
|
$query_settings = "SELECT name,value FROM ".TABLE_PREFIX."settings";
|
91 |
|
|
$get_settings = $database->query($query_settings);
|
92 |
|
|
if($database->is_error()) { die($database->get_error()); }
|
93 |
|
|
if($get_settings->numRows() == 0) { die("Settings not found"); }
|
94 |
|
|
while($setting = $get_settings->fetchRow()) {
|
95 |
|
|
$setting_name=strtoupper($setting['name']);
|
96 |
|
|
$setting_value=$setting['value'];
|
97 |
1694
|
Luisehahne
|
// if ($setting_value=='') {$setting_value=false;}
|
98 |
|
|
if ($setting_value=='false'){$setting_value=false;}
|
99 |
|
|
if ($setting_value=='true'){$setting_value=true;}
|
100 |
1349
|
Luisehahne
|
@define($setting_name,$setting_value);
|
101 |
|
|
}
|
102 |
1510
|
darkviper
|
@define('DO_NOT_TRACK', (isset($_SERVER['HTTP_DNT'])));
|
103 |
1349
|
Luisehahne
|
$string_file_mode = STRING_FILE_MODE;
|
104 |
|
|
define('OCTAL_FILE_MODE',(int) octdec($string_file_mode));
|
105 |
|
|
$string_dir_mode = STRING_DIR_MODE;
|
106 |
|
|
define('OCTAL_DIR_MODE',(int) octdec($string_dir_mode));
|
107 |
1465
|
Luisehahne
|
$sSecMod = (defined('SECURE_FORM_MODULE') && SECURE_FORM_MODULE != '') ? '.'.SECURE_FORM_MODULE : '';
|
108 |
1462
|
DarkViper
|
$sSecMod = WB_PATH.'/framework/SecureForm'.$sSecMod.'.php';
|
109 |
|
|
require_once($sSecMod);
|
110 |
1349
|
Luisehahne
|
if (!defined("WB_INSTALL_PROCESS")) {
|
111 |
|
|
// get CAPTCHA and ASP settings
|
112 |
|
|
$table = TABLE_PREFIX.'mod_captcha_control';
|
113 |
1462
|
DarkViper
|
if( ($get_settings = $database->query("SELECT * FROM $table LIMIT 1")) ) {
|
114 |
1349
|
Luisehahne
|
if($get_settings->numRows() == 0) { die("CAPTCHA-Settings not found"); }
|
115 |
|
|
$setting = $get_settings->fetchRow();
|
116 |
|
|
if($setting['enabled_captcha'] == '1') define('ENABLED_CAPTCHA', true);
|
117 |
|
|
else define('ENABLED_CAPTCHA', false);
|
118 |
|
|
if($setting['enabled_asp'] == '1') define('ENABLED_ASP', true);
|
119 |
|
|
else define('ENABLED_ASP', false);
|
120 |
|
|
define('CAPTCHA_TYPE', $setting['captcha_type']);
|
121 |
|
|
define('ASP_SESSION_MIN_AGE', (int)$setting['asp_session_min_age']);
|
122 |
|
|
define('ASP_VIEW_MIN_AGE', (int)$setting['asp_view_min_age']);
|
123 |
|
|
define('ASP_INPUT_MIN_AGE', (int)$setting['asp_input_min_age']);
|
124 |
|
|
}
|
125 |
|
|
}
|
126 |
|
|
|
127 |
|
|
// set error-reporting
|
128 |
|
|
if(intval(ER_LEVEL) > 0 )
|
129 |
|
|
{
|
130 |
|
|
error_reporting(ER_LEVEL);
|
131 |
1352
|
Luisehahne
|
if( intval(ini_get ( 'display_errors' )) == 0 )
|
132 |
1349
|
Luisehahne
|
{
|
133 |
|
|
ini_set('display_errors', 1);
|
134 |
|
|
}
|
135 |
|
|
}
|
136 |
|
|
// Start a session
|
137 |
|
|
if(!defined('SESSION_STARTED')) {
|
138 |
|
|
session_name(APP_NAME.'_session_id');
|
139 |
|
|
@session_start();
|
140 |
|
|
define('SESSION_STARTED', true);
|
141 |
|
|
}
|
142 |
|
|
if(defined('ENABLED_ASP') && ENABLED_ASP && !isset($_SESSION['session_started']))
|
143 |
|
|
$_SESSION['session_started'] = time();
|
144 |
|
|
|
145 |
|
|
// Get users language
|
146 |
|
|
if(isset($_GET['lang']) AND $_GET['lang'] != '' AND !is_numeric($_GET['lang']) AND strlen($_GET['lang']) == 2) {
|
147 |
1680
|
darkviper
|
define('LANGUAGE', strtoupper($_GET['lang']));
|
148 |
1349
|
Luisehahne
|
$_SESSION['LANGUAGE']=LANGUAGE;
|
149 |
|
|
} else {
|
150 |
|
|
if(isset($_SESSION['LANGUAGE']) AND $_SESSION['LANGUAGE'] != '') {
|
151 |
|
|
define('LANGUAGE', $_SESSION['LANGUAGE']);
|
152 |
|
|
} else {
|
153 |
|
|
define('LANGUAGE', DEFAULT_LANGUAGE);
|
154 |
|
|
}
|
155 |
|
|
}
|
156 |
1680
|
darkviper
|
|
157 |
1349
|
Luisehahne
|
// Load Language file
|
158 |
|
|
if(!defined('LANGUAGE_LOADED')) {
|
159 |
|
|
if(!file_exists(WB_PATH.'/languages/'.LANGUAGE.'.php')) {
|
160 |
|
|
exit('Error loading language file '.LANGUAGE.', please check configuration');
|
161 |
|
|
} else {
|
162 |
|
|
require_once(WB_PATH.'/languages/'.LANGUAGE.'.php');
|
163 |
|
|
}
|
164 |
|
|
}
|
165 |
1680
|
darkviper
|
|
166 |
1349
|
Luisehahne
|
// Get users timezone
|
167 |
|
|
if(isset($_SESSION['TIMEZONE'])) {
|
168 |
|
|
define('TIMEZONE', $_SESSION['TIMEZONE']);
|
169 |
|
|
} else {
|
170 |
|
|
define('TIMEZONE', DEFAULT_TIMEZONE);
|
171 |
|
|
}
|
172 |
|
|
// Get users date format
|
173 |
|
|
if(isset($_SESSION['DATE_FORMAT'])) {
|
174 |
|
|
define('DATE_FORMAT', $_SESSION['DATE_FORMAT']);
|
175 |
|
|
} else {
|
176 |
|
|
define('DATE_FORMAT', DEFAULT_DATE_FORMAT);
|
177 |
|
|
}
|
178 |
|
|
// Get users time format
|
179 |
|
|
if(isset($_SESSION['TIME_FORMAT'])) {
|
180 |
|
|
define('TIME_FORMAT', $_SESSION['TIME_FORMAT']);
|
181 |
|
|
} else {
|
182 |
|
|
define('TIME_FORMAT', DEFAULT_TIME_FORMAT);
|
183 |
|
|
}
|
184 |
|
|
|
185 |
|
|
// Set Theme dir
|
186 |
|
|
define('THEME_URL', WB_URL.'/templates/'.DEFAULT_THEME);
|
187 |
|
|
define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);
|
188 |
|
|
|
189 |
1680
|
darkviper
|
// extended wb_settings
|
190 |
1349
|
Luisehahne
|
define('EDIT_ONE_SECTION', false);
|
191 |
|
|
|
192 |
|
|
define('EDITOR_WIDTH', 0);
|