public static function run() { ZOL_Registry::set('request', new ZOL_Request()); $request = ZOL_Registry::get('request'); ZOL_Registry::set('response', new ZOL_Response()); $response = ZOL_Registry::get('response'); $controller = $request->getControllerName(); $action = $request->getActionName(); $controller = ZOL_String::toValidVariableName($controller); $action = ZOL_String::toValidVariableName($action); if (empty($controller)) { throw new ZOL_Exception("The controller of '{$controller}' is empty in request!"); } if (empty($action)) { throw new ZOL_Exception("The action of '{$action}' is empty in request!"); } $controller = APP_NAME . '_Page_' . ucfirst($controller); //var_dump($controller); $page = new $controller($request, $response); self::$_page = $page; self::$_url = empty($_SERVER['SCRIPT_URL']) ? '' : $_SERVER['SCRIPT_URL']; self::$_cacheKey = self::getCacheKey(); if ($page->isCache() && ($html = self::getCache())) { die($html); } if ($page->validate($request, $response)) { $actionMap = $page->getActionMapping(); if (empty($actionMap)) { $action = 'do' . ucfirst($action); if (method_exists($page, $action)) { $page->{$action}($request, $response); } else { throw new ZOL_Exception("The function of '{$action}' does not exist in class '{$controller}'!"); } } else { foreach ($actionMap[$action] as $methodName) { $methodName = 'do' . ucfirst($methodName); if (method_exists($page, $methodName)) { $page->{$methodName}($request, $response); } else { throw new ZOL_Exception(' the function dose not exist:' . $methodName); } } } } self::$_html = $response->display(); $page->isCache() && self::setCache(); }
} function api_json_convert_encoding_g2u(&$value, &$key) { $value = mb_convert_encoding($value, "UTF-8", "GBK"); } function api_json_convert_encoding_u2g(&$value, &$key) { $value = mb_convert_encoding($value, "GBK", "UTF-8"); } //define('ZOL_API_ISFW', true);#应用ZOL框架的项目 //define('ZOL_API_STOPLOG', true);#应用ZOL框架的项目 //require_once('/www/zdata/Api.php'); #API require_once PRODUCTION_ROOT . '/init.php'; ZOL::setNameSpace(PRODUCTION_ROOT . '/Libs'); #注册类库 ZOL::setNameSpace(PRODUCTION_ROOT . '/Modules'); #注册缓存模块 ZOL::setNameSpace(APP_PATH); #注册应用 ZOL::setNameSpace(PRODUCTION_ROOT . '/Db'); #注册数据库链接类 ZOL::setNameSpace(PRODUCTION_ROOT . '/DAL'); #注册DAL实例 ZOL::setNameSpace(PRODUCTION_ROOT . '/Helper'); #注册Helper实例 ZOL::setNameSpace(PRODUCTION_ROOT . '/App/Pro'); #注册 ZOL::setNameSpace(PRODUCTION_ROOT . '/App/Pro/Plugin'); #注册 ZOL_Controller_Front::run();