-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
58 lines (48 loc) · 1.84 KB
/
Copy pathindex.php
File metadata and controls
58 lines (48 loc) · 1.84 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
52
53
54
55
56
57
58
<?php
// Check PHP version
version_compare(PHP_VERSION, '5.2', '<') and exit('TROLL requires PHP 5.2 or newer.');
// Error reporting
error_reporting(E_ALL & ~E_NOTICE);
// Define our base variables
// TODO update paths throughout
// $application = '_framework/app';
// $system = '_framework/sys';
// In dev?
define('IS_DEV', strpos(__FILE__, 'trolldev') === 0);
// TODO replace all window \\ with something that is cross platform
define('APPPATH', dirname(__FILE__) . '/_framework/');
define('BASEPATH', dirname(__FILE__));
define('CACHEPATH', dirname(__FILE__) . '/cache/');
// Define install directory name to be stripped from route processing
define('INSTALLEDIN', (!IS_DEV) ? 'troll' : 'trolldev');
include('./_framework/sys/core/Config.php');
include('./_framework/sys/core/Cache.php');
include('./_framework/sys/core/Route.php');
include('./_framework/sys/core/Request.php');
include('./_framework/sys/core/View.php');
include('./_framework/sys/core/Util.php');
// TODO setup a method in Route that will convert hyphened names to camelcase
Route::run();
// Initialize.
//require SYSPATH.'bootstrap.php';
// TODO move this stuff below into bootstrap
if (!empty(Route::$controller) and file_exists(APPPATH . 'app/controllers/' . ucfirst(Route::$controller) . 'Controller.php')) {
// Load base controller
include(APPPATH . 'app/controllers/BaseController.php');
include(APPPATH . 'app/controllers/' . ucfirst(Route::$controller) . 'Controller.php');
// Check if class exists
if (class_exists(ucfirst(Route::$controller) . 'Controller')) {
$class = ucfirst(Route::$controller) . 'Controller';
$controller = new $class();
if (is_callable(array($controller, Route::$method))) {
$method = Route::$method;
$controller->$method(Route::$params);
} else {
Route::badRequest();
}
} else {
Route::badRequest();
}
} else {
Route::badRequest();
}