-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.php
More file actions
54 lines (50 loc) · 1.54 KB
/
index.php
File metadata and controls
54 lines (50 loc) · 1.54 KB
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
<?php
$site_path = realpath(__DIR__);
$success = define('__SITE_PATH', $site_path);
if(!$success) {
throw new Exception("Cannot define __SITE_PATH constant!");
}
include __SITE_PATH . '/application/' . 'functions.php';
/**
*
* In-built PHP function serves as a last hope for a class to be loaded.
* Only model classes are required to be initialized on demand
* @param String $classname
* @throws Exception
*/
function __autoload($class_name) {
$class_name = preg_replace_callback("([A-Z])", 'lower', $class_name);
$class_name = substr($class_name, 1);
$file_path = __SITE_PATH . "/model/$class_name.class.php";
if(file_exists($file_path))
include $file_path;
else
throw new Exception("Attempt to load unrecognized class!");
}
/**
* Required application classes
*/
include __SITE_PATH . '/application/' . 'session.class.php';
include __SITE_PATH . '/application/' . 'router.class.php';
include __SITE_PATH . '/application/' . 'template.class.php';
include __SITE_PATH . '/application/' . 'link.class.php';
include __SITE_PATH . '/application/' . 'dynamic.class.php';
include __SITE_PATH . '/application/' . 'db.class.php';
include __SITE_PATH . '/application/' . 'element.class.php';
/**
* Model and Controller base classes
*/
include __SITE_PATH . '/controller/' . 'controller.class.php';
include __SITE_PATH . '/model/' . 'model.class.php';
/**
* Session management
*/
Session::Start();
/**
*
* Router object processes request URI
* and routes application logic to specific controller
* @var Router
*/
$router = new Router();
$router->Route();