-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.class.php
More file actions
executable file
·61 lines (52 loc) · 1.92 KB
/
base.class.php
File metadata and controls
executable file
·61 lines (52 loc) · 1.92 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
59
60
61
<?php
if (!defined('SP')) define('SP', DIRECTORY_SEPARATOR);
if (!defined('APPPATH')) define('APPPATH', realpath( dirname(dirname(__FILE__)) ) );
if (!defined('BASEPATH')) define('BASEPATH', realpath(dirname(__FILE__)));
if (!defined('THEMEPATH')) define('THEMEPATH', BASEPATH.SP.'web');
if (!defined('SITE_URL')) define('SITE_URL', (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''));
class base {
/**
*
* @var application
*/
public static $app;
/**
*
* @var finder
*/
public static $finder;
public static function loadmodule($classname, $modulename = null) {
$modulepath = $modulename ? BASEPATH.SP.'modules'.SP.$modulename : BASEPATH.SP.'modules';
$classes = self::$finder->find("$classname.php", $modulepath)->files();
if ($classes) foreach($classes as $class) {
require_once "$class";
}
}
public static function loadlib($libname, $init = false) {
$filepath = BASEPATH.SP.'system'.SP.'libs'.SP."$libname.class.php";
if (file_exists($filepath)) {
require_once $filepath;
}
if ($init) {
return new $libname();
}
}
public static function autoload($classname) {
$classes = self::$finder->find("$classname.class.php", BASEPATH.SP)->files();
if ($classes) foreach($classes as $class) {
require_once "$class";
}
}
public static function init() {
ob_start();
self::$finder = self::loadlib('finder', true);
spl_autoload_register(array('base', 'loadlib'));
spl_autoload_register(array('base', 'loadmodule'));
spl_autoload_register(array('base', 'autoload'));
self::$app = self::loadlib('application', true);
self::$app->start();
$contents = ob_get_contents();
ob_end_clean();
echo $contents;
}
}