summaryrefslogtreecommitdiff
path: root/include/setup.php
blob: f5e58f4b3113a96addacf04536e119717ee14f5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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();

?>