forked from jfhs/openplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·49 lines (38 loc) · 976 Bytes
/
index.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
<?php
session_start();
define('ROOT', __DIR__);
# autoload
function classLoad( $className ) {
$namespaces = array(
"Lib" => "lib",
"App" => "app",
"Manager" => "managers"
);
foreach ( $namespaces as $ns => $path ) {
if (( 0 === strpos( $className, "{$ns}\\" ) ) || ( 0 === strpos( $className, "\\{$ns}\\"))) {
$pathArr = explode( "\\", $className );
if ($pathArr[0] == '') {
array_shift($pathArr);
}
$pathArr[0] = $path;
$class = implode( DIRECTORY_SEPARATOR, $pathArr );
require_once ROOT . DIRECTORY_SEPARATOR . "{$class}.php";
}
}
}
spl_autoload_register("classLoad");
# /autoload
# i18n
Lib\Lang::init();
function __ ( $word ) {
return isset( Lib\Lang::$translate[$word] )
? Lib\Lang::$translate[$word]
: $word;
}
# /i18n
# app init
$app = strtolower( Lib\Request::get('app', 'index') );
$appClass = "App\\".ucfirst($app);
$appObj = new $appClass;
$appObj->run( $app );
# /app init