|
|
@ -1,7 +1,7 @@ |
|
|
|
<?php |
|
|
|
<?php |
|
|
|
/** |
|
|
|
/** |
|
|
|
* name:API入口文件 |
|
|
|
* name:API入口文件,也可以称之为中间件 |
|
|
|
* update:2020/12 |
|
|
|
* update:2022/03 |
|
|
|
* author:xiaoz<xiaoz93@outlook.com> |
|
|
|
* author:xiaoz<xiaoz93@outlook.com> |
|
|
|
* blog:xiaoz.me |
|
|
|
* blog:xiaoz.me |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -14,60 +14,18 @@ $api = new Api($db); |
|
|
|
|
|
|
|
|
|
|
|
//获取请求方法 |
|
|
|
//获取请求方法 |
|
|
|
$method = $_GET['method']; |
|
|
|
$method = $_GET['method']; |
|
|
|
//对方法进行判断,对应URL路由:/index.php?c=api&method=xxx |
|
|
|
//可变函数变量 |
|
|
|
switch ($method) { |
|
|
|
$var_func = htmlspecialchars(trim($method),ENT_QUOTES); |
|
|
|
case 'add_category': |
|
|
|
//判断函数是否存在,存在则条用可变函数,否则抛出错误 |
|
|
|
add_category($api); |
|
|
|
if ( function_exists($var_func) ) { |
|
|
|
break; |
|
|
|
//调用可变函数 |
|
|
|
case 'edit_category': |
|
|
|
$var_func($api); |
|
|
|
edit_category($api); |
|
|
|
}else{ |
|
|
|
break; |
|
|
|
exit('method not found!'); |
|
|
|
case 'del_category': |
|
|
|
|
|
|
|
del_category($api); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'add_link': |
|
|
|
|
|
|
|
add_link($api); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'edit_link': |
|
|
|
|
|
|
|
edit_link($api); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'del_link': |
|
|
|
|
|
|
|
del_link($api); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'category_list': |
|
|
|
|
|
|
|
category_list($api); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'link_list': |
|
|
|
|
|
|
|
link_list($api); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'get_link_info': |
|
|
|
|
|
|
|
get_link_info($api); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'add_js': |
|
|
|
|
|
|
|
add_js($api); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'upload': |
|
|
|
|
|
|
|
upload($api); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'imp_link': |
|
|
|
|
|
|
|
imp_link($api); |
|
|
|
|
|
|
|
case 'check_weak_password': |
|
|
|
|
|
|
|
check_weak_password($api); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'get_a_link': |
|
|
|
|
|
|
|
get_a_link($api); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'get_sql_update_list': |
|
|
|
|
|
|
|
get_sql_update_list($api); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'exe_sql': |
|
|
|
|
|
|
|
exe_sql($api); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
# code... |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 添加分类目录入口 |
|
|
|
* 添加分类目录入口 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|