game2006api/webapp/index.php
aozhiwei fa714b9436 1
2024-07-25 10:46:54 +08:00

50 lines
1.2 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)
{
$fileName = "controller/$classname.class.php";
if (!file_exists($fileName)) {
if (SERVER_ENV == _ONLINE) {
die();
}
}
require_once $fileName;
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);
}