-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.php
68 lines (52 loc) · 1.67 KB
/
init.php
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
<?php
/**
* Created by JetBrains PhpStorm.
* User: emir
* Date: 10/20/12
* Time: 9:28 AM
* To change this template use File | Settings | File Templates.
*/
$coi_start = microtime(true);
error_reporting(E_ALL ^ E_NOTICE);
ini_set('error_reporting', E_ALL);
if (!isset($_SESSION)) session_start();
if (!isset($_SESSION["COI"])) $_SESSION["COI"] = array();
foreach ($_REQUEST as $k => $i)
if (!is_numeric($i)) $_REQUEST[$k] = htmlspecialchars($i, ENT_QUOTES);
foreach ($_POST as $k => $i)
if (!is_numeric($i)) $_POST[$k] = htmlspecialchars($i, ENT_QUOTES);
foreach ($_GET as $k => $i)
if (!is_numeric($i)) $_GET[$k] = htmlspecialchars($i, ENT_QUOTES);
$coiConfig = array();
$serverIP=$_SERVER["SERVER_ADDR"];
$dbConfig=$coiConfig;
if(isset($coiConfig[$serverIP])) $dbConfig=$coiConfig[$serverIP];
if (defined("CONFIG") && is_file(CONFIG))
{
$coiConfig = parse_ini_file(CONFIG, true);
foreach ($coiConfig as $k => $i)
if ($k == strtoupper($k) && (is_scalar($i))) define($k, $i);
$_CONFIG = $coiConfig;
}
$data = array();
function __coiAutoload($class, $root = null)
{
if (is_null($root) && defined("COIROOT")) $root = COIROOT;
if (file_exists($root . '/models/' . $class . '.php'))
{
require_once ($root . '/models/' . $class . '.php');
return true;
}
else
if (strpos($class, 'Controller') !== false)
{
if (file_exists($root . '/controllers/' . $class . '.php'))
{
require_once ($root . '/controllers/' . $class . '.php');
return true;
}
}
return false;
}
spl_autoload_register('__coiAutoload');
include_once "helpers.php";