32 if (!defined(
'PHP_VERSION_ID')) {
33 $version = explode(
'.', PHP_VERSION);
34 define(
'PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2]));
40 if (PHP_VERSION_ID < 50300) {
43 error_reporting(E_ALL);
46 error_reporting(E_ALL ^ E_DEPRECATED);
49 # Before 5.3.0 we have to set magic quotes runtime off
50 if (PHP_VERSION_ID < 50300) {
51 set_magic_quotes_runtime(0);
57 define(
'SQ_INIT_OB_LEVEL', ob_get_level());
60 define(
'SQ_PHP_CLI', (php_sapi_name() ==
'cli'));
65 if (!defined(
'SQ_SYSTEM_ROOT')) {
66 define(
'SQ_SYSTEM_ROOT', dirname(dirname(dirname(realpath(__FILE__)))));
68 define(
'SQ_INCLUDE_PATH', SQ_SYSTEM_ROOT.
'/core/include');
69 define(
'SQ_CORE_PACKAGE_PATH', SQ_SYSTEM_ROOT.
'/core/assets');
70 define(
'SQ_ATTRIBUTES_PATH', SQ_SYSTEM_ROOT.
'/core/attributes');
71 define(
'SQ_LIB_PATH', SQ_SYSTEM_ROOT.
'/core/lib');
72 define(
'SQ_DATA_PATH', SQ_SYSTEM_ROOT.
'/data');
73 define(
'SQ_CACHE_PATH', SQ_SYSTEM_ROOT.
'/cache');
74 define(
'SQ_PACKAGES_PATH', SQ_SYSTEM_ROOT.
'/packages');
75 define(
'SQ_WEB_PATH', SQ_SYSTEM_ROOT.
'/core/web');
76 define(
'SQ_FUDGE_PATH', SQ_SYSTEM_ROOT.
'/fudge');
77 define(
'SQ_TEMP_PATH', SQ_SYSTEM_ROOT.
'/data/temp');
78 define(
'SQ_LOG_PATH', SQ_SYSTEM_ROOT.
'/data/private/logs');
82 require_once SQ_INCLUDE_PATH.
'/version.inc';
85 require_once SQ_DATA_PATH.
'/private/conf/main.inc';
87 ini_set(
'memory_limit', SQ_CONF_WEB_MEMORY_LIMIT.
'M');
91 if (defined(
'SQ_CONF_TIMEZONE')) {
92 date_default_timezone_set(SQ_CONF_TIMEZONE);
96 if (file_exists(SQ_DATA_PATH.
'/private/conf/licence.inc')) {
97 require_once SQ_DATA_PATH.
'/private/conf/licence.inc';
110 if (strrpos($_SERVER[
'PHP_SELF'],
'index.php/')) {
111 $_SERVER[
'PHP_SELF'] = str_replace(
'index.php/',
'', $_SERVER[
'PHP_SELF']);
115 $_SERVER[
'PHP_SELF'] = htmlspecialchars($_SERVER[
'PHP_SELF']);
118 require_once SQ_FUDGE_PATH.
'/dev/dev.inc';
119 require_once SQ_FUDGE_PATH.
'/general/general.inc';
122 $in_backend = (trim(SQ_CONF_BACKEND_SUFFIX) !=
'') && (basename($_SERVER[
'PHP_SELF']) == SQ_CONF_BACKEND_SUFFIX);
123 define(
'SQ_IN_BACKEND', $in_backend);
126 $in_limbo = (trim(SQ_CONF_LIMBO_SUFFIX) !=
'') && (basename($_SERVER[
'PHP_SELF']) == SQ_CONF_LIMBO_SUFFIX);
127 define(
'SQ_IN_LIMBO', $in_limbo);
130 $in_login = (trim(SQ_CONF_LOGIN_SUFFIX) !=
'') && (basename($_SERVER[
'PHP_SELF']) == SQ_CONF_LOGIN_SUFFIX);
131 define(
'SQ_IN_LOGIN', $in_login);
134 $in_performance = defined(
'SQ_CONF_PERFORMANCE_SUFFIX') && (trim(SQ_CONF_PERFORMANCE_SUFFIX) !=
'') && (basename($_SERVER[
'PHP_SELF']) == SQ_CONF_PERFORMANCE_SUFFIX);
135 define(
'SQ_IN_PERFORMANCE', $in_performance);
138 $in_performance_timing = defined(
'SQ_CONF_PERFORMANCE_TIMING_SUFFIX') && (trim(SQ_CONF_PERFORMANCE_TIMING_SUFFIX) !=
'') && (basename($_SERVER[
'PHP_SELF']) == SQ_CONF_PERFORMANCE_TIMING_SUFFIX);
139 if($in_performance_timing)
140 define(
'SQ_IN_PERFORMANCE_TIMING', $in_performance_timing);
143 $in_performance_result = defined(
'SQ_CONF_PERFORMANCE_RESULT_SUFFIX') && (trim(SQ_CONF_PERFORMANCE_RESULT_SUFFIX) !=
'') && (basename($_SERVER[
'PHP_SELF']) == SQ_CONF_PERFORMANCE_RESULT_SUFFIX);
144 define(
'SQ_IN_PERFORMANCE_RESULT', $in_performance_result);
147 if (!defined(
'SQ_IN_CRON')) {
148 define(
'SQ_IN_CRON', FALSE);
152 if (SQ_IN_BACKEND && substr($_SERVER[
'PHP_SELF'], -1) !=
'/') {
153 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'/'.(($_SERVER[
'QUERY_STRING']) ?
'?'.$_SERVER[
'QUERY_STRING'] :
''));
160 if (!isset($GLOBALS[
'SQ_OUTPUT_TYPE'])) {
161 $GLOBALS[
'SQ_OUTPUT_TYPE'] = (SQ_PHP_CLI) ?
'text' :
'html';
166 $GLOBALS[
'SQ_PURGING_TRASH'] = FALSE;
169 $GLOBALS[
'SQ_REVERT_TO_SYSTEM_VERSION'] = FALSE;
175 define(
'SQ_LINK_TYPE_1', 1);
176 define(
'SQ_LINK_TYPE_2', 2);
177 define(
'SQ_LINK_TYPE_3', 4);
178 define(
'SQ_LINK_NOTICE', 8);
180 define(
'SQ_SC_LINK_ALL', 15);
181 define(
'SQ_SC_LINK_FRONTEND_NAV', 1);
182 define(
'SQ_SC_LINK_BACKEND_NAV', 3);
183 define(
'SQ_SC_LINK_SIGNIFICANT', 7);
184 define(
'SQ_SC_LINK_WEB_PATHS', 7);
190 define(
'SQ_PERMISSION_WORKFLOW', 0);
191 define(
'SQ_PERMISSION_READ', 1);
192 define(
'SQ_PERMISSION_WRITE', 2);
193 define(
'SQ_PERMISSION_ADMIN', 3);
201 define(
'SQ_STATUS_ARCHIVED', 1);
202 define(
'SQ_STATUS_UNDER_CONSTRUCTION', 2);
203 define(
'SQ_STATUS_PENDING_APPROVAL', 4);
204 define(
'SQ_STATUS_APPROVED', 8);
205 define(
'SQ_STATUS_LIVE', 16);
206 define(
'SQ_STATUS_LIVE_APPROVAL', 32);
207 define(
'SQ_STATUS_EDITING', 64);
208 define(
'SQ_STATUS_EDITING_APPROVAL', 128);
209 define(
'SQ_STATUS_EDITING_APPROVED', 256);
211 define(
'SQ_SC_STATUS_NOT_LIVE', 15);
212 define(
'SQ_SC_STATUS_LIVE_EDIT', 48);
213 define(
'SQ_SC_STATUS_CAN_APPROVE', 66);
214 define(
'SQ_SC_STATUS_PENDING', 164);
215 define(
'SQ_SC_STATUS_ALL_APPROVED', 264);
216 define(
'SQ_SC_STATUS_SAFE_EDITING', 448);
217 define(
'SQ_SC_STATUS_ALL', 511);
223 define(
'SQ_SECURITY_PERMISSIONS', 1);
224 define(
'SQ_SECURITY_LOCKING', 2);
225 define(
'SQ_SECURITY_DATA_VALIDATION', 4);
226 define(
'SQ_SECURITY_PASSWORD_VALIDATION', 8);
227 define(
'SQ_SECURITY_LINK_INTEGRITY', 16);
228 define(
'SQ_SECURITY_INTEGRITY', 32);
229 define(
'SQ_SECURITY_STATUS_INTEGRITY', 64);
230 define(
'SQ_SECURITY_TRIGGERS', 128);
232 define(
'SQ_RUN_LEVEL_OPEN', 0);
233 define(
'SQ_RUN_LEVEL_FORCED', 236);
234 define(
'SQ_RUN_LEVEL_SECURE', 255);
238 define(
'SQ_SESSION_SANDBOX_INDEX',
'__SQ_SESSION_SANDBOX');
242 require_once SQ_INCLUDE_PATH.
'/assertions.inc';
246 require_once SQ_INCLUDE_PATH.
'/general.inc';
247 ini_set(
'display_errors', 1);
248 set_error_handler(
'sq_error_handler');
249 set_exception_handler(
'sq_exception_handler');
252 if (!(SQ_IN_BACKEND | SQ_IN_LIMBO | SQ_IN_CRON) & hide_frontend_errors()) {
253 ini_set(
'display_errors', 0);
257 if ((
boolean)SQ_CONF_ERRORS_LOG_TO_SYSLOG === TRUE) {
258 $ident = SQ_CONF_SYSTEM_NAME;
259 if (empty($ident) === TRUE) {
260 $ident = SQ_SYSTEM_LONG_NAME;
262 $consts = get_defined_constants();
263 $facility = $consts[
'LOG_'.strtoupper(SQ_CONF_ERRORS_SYSLOG_FACILITY)];
264 openlog($ident, LOG_ODELAY, $facility);
268 if (get_magic_quotes_gpc()) {
269 stripslashes_array($_GET, TRUE);
270 stripslashes_array($_POST, TRUE);
271 stripslashes_array($_COOKIE, TRUE);
272 stripslashes_array($_REQUEST, TRUE);
273 if (isset($_SERVER[
'QUERY_STRING'])) {
274 $_SERVER[
'QUERY_STRING'] = stripslashes($_SERVER[
'QUERY_STRING']);
279 require_once SQ_INCLUDE_PATH.
'/mysource.inc';
280 $GLOBALS[
'SQ_SYSTEM'] =
new MySource();
281 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_SECURE);
282 $GLOBALS[
'SQ_SYSTEM']->init();