Project

General

Profile

« Previous | Next » 

Revision 1680

Added by darkviper over 12 years ago

renamed file class.database.php to Database.php
renamed class database into Database
classes SecurityException and SecDirectoryTraversalException added in globalExceptionHandler.php
CoreAutoloader() added in initialize.php
new Constants 'WB_REL' and 'DOCUMENT_ROOT' in initialize.php
class Database is able now to create multiple connections at same time
class ModLanguage added for easy handle of languages from modules

View differences:

initialize.php
49 49
		}
50 50
		$_SERVER['HTTP_REFERER'] = $sTmpReferer;
51 51
	}
52

  
53
$starttime = array_sum(explode(" ",microtime()));
54
if(!defined('DEBUG')){ define('DEBUG', false); }// Include config file
55
if( !defined('ADMIN_DIRECTORY')) { define('ADMIN_DIRECTORY', 'admin'); }
56
if(!preg_match('/xx[a-z0-9_][a-z0-9_\-\.]+/i', 'xx'.ADMIN_DIRECTORY)) {
57
	throw new RuntimeException('Invalid admin-directory: ' . ADMIN_DIRECTORY);
58
}
59

  
60
if( !defined('ADMIN_URL')) { define('ADMIN_URL', WB_URL.'/'.ADMIN_DIRECTORY); }
61
if( !defined('WB_PATH')) { define('WB_PATH', dirname(dirname(__FILE__))); }
62
if( !defined('ADMIN_PATH')) { define('ADMIN_PATH', WB_PATH.'/'.ADMIN_DIRECTORY); }
63

  
64
if (file_exists(WB_PATH.'/framework/class.database.php')) {
65
	// sanitize $_SERVER['HTTP_REFERER']
66
	SanitizeHttpReferer(WB_URL);
52
/* -------------------------------------------------------- */
53
/**
54
 * Autoloader to load classes according to the new WB-2.9 standard
55
 * @param string $sClassName name of the requested class
56
 */
57
	function CoreAutoloader($sClassName) {
58
		$iCount = 0;
59
		$aSearch = array('/^m_/i', '/^a_/i');
60
		$aReplace = array('modules_', ADMIN_DIRECTORY.'_' );
61
		$sClassName = preg_replace($aSearch, $aReplace, $sClassName, 1, $iCount);
62
		if(!$iCount) { $sClassName = 'framework_'.$sClassName; }
63
		$sFileName = WB_PATH.'/'.str_replace('_', '/', $sClassName).'.php';
64
		if(file_exists($sFileName)) {
65
			include($sFileName);
66
		}
67
	}
68
/* -------------------------------------------------------- */
69
	function SetInstallPathConstants() {
70
		if(!defined('DEBUG')){ define('DEBUG', false); }// Include config file
71
		if(!defined('ADMIN_DIRECTORY')){ define('ADMIN_DIRECTORY', 'admin'); }
72
		if(!preg_match('/xx[a-z0-9_][a-z0-9_\-\.]+/i', 'xx'.ADMIN_DIRECTORY)) {
73
			throw new RuntimeException('Invalid admin-directory: ' . ADMIN_DIRECTORY);
74
		}
75
		if(!defined('WB_PATH')){ define('WB_PATH', dirname(dirname(__FILE__))); }
76
		if(!defined('ADMIN_URL')){ define('ADMIN_URL', WB_URL.'/'.ADMIN_DIRECTORY); }
77
		if(!defined('ADMIN_PATH')){ define('ADMIN_PATH', WB_PATH.'/'.ADMIN_DIRECTORY); }
78
		if(!defined('WB_REL')){
79
			$x1 = parse_url(WB_URL);
80
			define('WB_REL', (isset($x1['path']) ? $x1['path'] : ''));
81
		}
82
		if(!defined('DOCUMENT_ROOT')) {
83
			define('DOCUMENT_ROOT', preg_replace('/'.preg_quote(WB_REL, '/').'$/', '', WB_PATH));
84
		}
85
	}
86
/* -------------------------------------------------------- */
87
	$starttime = array_sum(explode(" ",microtime()));
88
	SetInstallPathConstants();
89
	SanitizeHttpReferer(WB_URL); // sanitize $_SERVER['HTTP_REFERER']
90
	spl_autoload_register('CoreAutoloader'); // activate core autoloader
67 91
	date_default_timezone_set('UTC');
68
	require_once(WB_PATH.'/framework/class.database.php');
69

  
70 92
	// Create database class
71
	$database = new database();
72

  
73
    if(version_compare(PHP_VERSION, '5.3.0', '<'))
74
    {
75
        set_magic_quotes_runtime(0); // Disable magic_quotes_runtime
76
    }
93
	$database = new Database();
94
	// disable all kind of magic_quotes
95
	if(get_magic_quotes_gpc() || get_magic_quotes_runtime()) {
96
		@ini_set('magic_quotes_sybase', 0);
97
		@ini_set('magic_quotes_gpc', 0);
98
		@ini_set('magic_quotes_runtime', 0);
99
	}
77 100
	// Get website settings (title, keywords, description, header, and footer)
78 101
	$query_settings = "SELECT name,value FROM ".TABLE_PREFIX."settings";
79 102
	$get_settings = $database->query($query_settings);
......
133 156

  
134 157
	// Get users language
135 158
	if(isset($_GET['lang']) AND $_GET['lang'] != '' AND !is_numeric($_GET['lang']) AND strlen($_GET['lang']) == 2) {
136
	  	define('LANGUAGE', strtoupper($_GET['lang']));
159
		define('LANGUAGE', strtoupper($_GET['lang']));
137 160
		$_SESSION['LANGUAGE']=LANGUAGE;
138 161
	} else {
139 162
		if(isset($_SESSION['LANGUAGE']) AND $_SESSION['LANGUAGE'] != '') {
......
142 165
			define('LANGUAGE', DEFAULT_LANGUAGE);
143 166
		}
144 167
	}
145
	
168

  
146 169
	// Load Language file
147 170
	if(!defined('LANGUAGE_LOADED')) {
148 171
		if(!file_exists(WB_PATH.'/languages/'.LANGUAGE.'.php')) {
......
151 174
			require_once(WB_PATH.'/languages/'.LANGUAGE.'.php');
152 175
		}
153 176
	}
154
	
177

  
155 178
	// Get users timezone
156 179
	if(isset($_SESSION['TIMEZONE'])) {
157 180
		define('TIMEZONE', $_SESSION['TIMEZONE']);
......
175 198
	define('THEME_URL', WB_URL.'/templates/'.DEFAULT_THEME);
176 199
	define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);
177 200

  
178
    // extended wb_settings
201
	// extended wb_settings
179 202
	define('EDIT_ONE_SECTION', false);
180 203

  
181 204
	define('EDITOR_WIDTH', 0);
182

  
183
}

Also available in: Unified diff