-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
40 lines (37 loc) · 968 Bytes
/
index.php
File metadata and controls
40 lines (37 loc) · 968 Bytes
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
<?php
/**
* Default index page
* @author Lazypeople<hfutming@gmail.com>
*/
define('ROOT', dirname(__FILE__));
include_once ROOT.'/src/Epi.php';
include ROOT.'/lib/base.function.php';
include ROOT.'/lib/base.class.php';
include ROOT.'/lib/mail.function.php';
Epi::setPath('base', ROOT.'/src');
Epi::init('api', 'database', 'redis');
$routes = parse_route($_GET['__route__']);
if (!$routes) {
showEndpoints();
}
$mod_file = ROOT.'/mod/'.$routes['mod'].'.class.php';
if (file_exists($mod_file)) {
require $mod_file;
$class_name = ucfirst(strtolower($routes['mod']));
if (class_exists($class_name)) {
$instance = new $class_name;
} else {
showEndpoints();
}
} else {
showEndpoints();
}
// Judge is post
$method = is_post() ? 'post' : 'get';
getApi()->$method($_GET['__route__'], array($instance, $routes['action']), EpiApi::external);
getRoute()->run();
function showEndpoints()
{
echo 'Bad route';
exit();
}