game2006api/webapp/index.php
aozhiwei ba3a85264e 1
2022-02-08 11:36:44 +08:00

44 lines
1.1 KiB
PHP

<?php
require '../config/config.php';
require '../config/routes.php';
require 'bootstrap/init.php';
if (empty($_REQUEST['c']) || empty($_REQUEST['a'])) {
die();
return;
}
function autoload_controller__($classname)
{
require_once "controller/$classname.class.php";
spl_autoload_unregister('autoload_controller__');
}
spl_autoload_register('autoload_controller__');
try{
$c = $_REQUEST['c'];
$a = $_REQUEST['a'];
if (!empty($gOnlyRoutes) && !getXVal($gOnlyRoutes, $c, null)) {
die();
return;
}
if (!empty($gExcludeRoutes) && getXVal($gExcludeRoutes, $c, null)) {
die();
return;
}
$classname = $c .'Controller';
$beginTick = phpcommon\getTickCount();
$obj = eval('return new $classname();');
$method = new ReflectionMethod($classname, $a);
if ($method && $method->isPublic() &&
$a[0] != '_' &&
(!$method->isConstructor() && !$method->isDestructor())) {
$obj->_handlePre();
$method->invoke($obj);
$obj->_handlePost();
}
} catch (Exception $e){
error_log($e);
}