summaryrefslogtreecommitdiff
path: root/include/setup.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/setup.php')
-rw-r--r--include/setup.php74
1 files changed, 74 insertions, 0 deletions
diff --git a/include/setup.php b/include/setup.php
new file mode 100644
index 0000000..f5e58f4
--- /dev/null
+++ b/include/setup.php
@@ -0,0 +1,74 @@
+<?php
+
+mb_regex_encoding("UTF-8");
+mb_internal_encoding("UTF-8");
+
+define("BASEPATH",dirname(dirname(__FILE__)));
+
+function cc_autoload($class_name) {
+
+ if (substr($class_name,strlen($class_name)-9)=='Exception') {
+ return eval("class {$class_name} extends Exception {}");
+ }
+ else if (file_exists(BASEPATH.'/include/'.$class_name.'.class.php')) {
+ include_once($class_name . '.class.php');
+ }
+ else if (file_exists(BASEPATH.'/include/admin/'.$class_name.'.class.php')) {
+ include_once('admin/'.$class_name . '.class.php');
+ }
+ else if (file_exists(BASEPATH.'/include/components/'.$class_name.'.class.php')) {
+ include_once('components/'.$class_name . '.class.php');
+ }
+ else if (file_exists(BASEPATH.'/include/controls/'.$class_name.'.class.php')) {
+ include_once('controls/'.$class_name . '.class.php');
+ }
+ else {
+ return null;
+ }
+
+}
+
+spl_autoload_register('cc_autoload');
+
+function exceptions_error_handler($severity, $message, $filename, $lineno) {
+ $fatal_severities = [
+ E_ERROR,
+ E_PARSE,
+ E_CORE_ERROR,
+ E_COMPILE_ERROR,
+ E_USER_ERROR
+ ];
+ if (!in_array($severity, $fatal_severities)) {
+ return;
+ }
+ throw new ErrorException(severity($severity).': '.$message, 0, $severity, $filename, $lineno);
+}
+
+set_error_handler('exceptions_error_handler', ini_get('error_reporting'));
+
+function severity($code) {
+ $severities = [
+ E_ERROR => 'ERROR',
+ E_WARNING => 'WARNING',
+ E_PARSE => 'PARSING ERROR',
+ E_NOTICE => 'NOTICE',
+ E_CORE_ERROR => 'CORE ERROR',
+ E_CORE_WARNING => 'CORE WARNING',
+ E_COMPILE_ERROR => 'COMPILE ERROR',
+ E_COMPILE_WARNING => 'COMPILE WARNING',
+ E_USER_ERROR => 'USER ERROR',
+ E_USER_WARNING => 'USER WARNING',
+ E_USER_NOTICE => 'USER NOTICE',
+ E_STRICT => 'STRICT NOTICE',
+ E_RECOVERABLE_ERROR => 'RECOVERABLE ERROR',
+ E_DEPRECATED => 'DEPRECATED',
+ E_USER_DEPRECATED => 'USER DEPRECATED'
+ ];
+ return $severities[$code];
+}
+
+Env::get();
+MySession::init();
+//MyLocale::init();
+
+?>