forked from rainbowsoft/zblogphp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.php
More file actions
50 lines (37 loc) · 1.09 KB
/
Copy pathapi.php
File metadata and controls
50 lines (37 loc) · 1.09 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
<?php
/**
* Z-Blog with PHP.
*
* @author Z-BlogPHP Team
* @version 1.0 2020-07-01
*/
// 标记为 API 运行模式
define('ZBP_IN_API', true);
require 'zb_system/function/c_system_base.php';
$zbp->Load();
if (!$GLOBALS['option']['ZC_API_ENABLE']) {
ApiResponse(null, null, 503, $GLOBALS['lang']['error']['95']);
}
ApiCsrfByLocalLogin();
$mods = array();
// 载入系统和应用的 mod
ApiLoadMods($mods);
$mod = strtolower(GetVars('mod', 'GET'));
$act = strtolower(GetVars('act', 'GET'));
if (empty($act)) {
$act = 'get';
}
if (isset($mods[$mod]) && file_exists($mod_file = $mods[$mod])) {
include_once $mod_file;
$func = 'api_' . $mod . '_' . $act;
if (function_exists($func)) {
$result = call_user_func($func);
ApiResponse(
isset($result['data']) ? $result['data'] : null,
isset($result['error']) ? $result['error'] : null,
isset($result['code']) ? $result['code'] : 200,
isset($result['message']) ? $result['message'] : 'OK'
);
}
}
ApiResponse(null, null, 404, $GLOBALS['lang']['error']['96']);