-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.inc.php
46 lines (36 loc) · 953 Bytes
/
init.inc.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
<?php
set_include_path(get_include_path().PATH_SEPARATOR.dirname(__FILE__));
require_once 'config.inc.php';
require_once 'helpers/global.php';
require_once 'lib/utils.php';
session_start();
/* global helpers */
function config($name){
global $config;
$r = $config;
$path = explode('.',$name);
foreach($path as $i){
$r = $r[$i];
}
return $r;
}
/* magic functions */
function __autorun(){
$path = pathinfo($_SERVER['SCRIPT_NAME']);
$class_name = ucfirst($path['filename']).'Controller';
// We need to create instance after class is defined
include(basename($_SERVER['SCRIPT_NAME']));
if(class_exists($class_name))
new $class_name;
exit();
}
function __autoload($class_name){
if(!@include_once("models/$class_name.php"))
@include_once("lib/$class_name.class.php");
}
spl_autoload_register('__autoload');
if($config['db'])
DBRecord::connect();
/* autorun page controller */
__autorun();
?>