flower_svr/index.php
2021-06-11 16:09:56 +08:00

54 lines
1.5 KiB
PHP

<?PHP
//处理游戏的ajax请求
header("Access-Control-Allow-Origin: *");
include("include/config.inc.php");
//自动加载类
function __autoload($class){
//判断两个要执行的内容是否正常
if (!preg_match("/^[a-zA-Z0-9_]+$/", $class)) {
echo("要执行的方法里只能包含字母、数字、下画线\r\n");
exit;
}
if(file_exists(WEBPATH_DIR.'ajax_class'.DS.$class.'.class.php')){
require_once(WEBPATH_DIR.'ajax_class'.DS.$class.'.class.php');
if (!class_exists($class, false)) {
echo("找不到对应的类: $class ".__LINE__);
exit;
}
}else{
echo("找不到对应的文件: $class ".__LINE__);
exit;
}
}
$act_a = get_param("a");//要执行的动作
$act_m = get_param("m");//要执行的模块
//判断两个要执行的内容是否正常
if (!preg_match("/^[a-zA-Z0-9_]+$/", $act_a) || !preg_match("/^[a-zA-Z0-9_]+$/", $act_m)) {
echo("要执行的方法里只能包含字母、数字、下画线\r\n");
exit;
}
$act_tmp = 'ajax_'.$act_m;
$act = new $act_tmp();
//是否有这个方法在
if (!method_exists($act, $act_a)) {
echo(__FILE__ . "|" . $act . "找不到对应的方法: " . $act_a . ":" . __LINE__);
exit;
}
//如果获取数据以及解密数据不正确,则不能执行想要的操作的
//echo("[request]".$act."->".$act_a."\r\n");
if($act->get_data()){
$act->{$act_a}();
}else{
echo("执行出错:".$act."->".$act_a."\r\n");
exit;
}
?>