function load($A, $P, $T, $F) { $switch = XWB_plugin::pCfg('switch_to_xweibo'); list(, $method) = explode('.', $A); if (!$switch && !in_array($method, $this->whileList)) { $this->_ERHelper('4010005', TRUE, 'load'); } $this->_validate($A, $P, $T, $F); //检测验证 ///处理参数集 $PJDecode = ($tmp = xwb_util_json::decode($P, TRUE)) && is_array($tmp) ? $tmp : array(); if ('null' != strtolower($P) && !$PJDecode) { $this->_ERHelper('4030001', TRUE, 'load'); } if (!XWB_plugin::_chkPath($A)) { $this->_ERHelper('4010001', TRUE, 'load'); } ///分析路由 $Route = XWB_plugin::_parseRoute($A); if (XWB_R_DEF_MOD_FUNC == $Route[3] || '_' == substr($Route[3], 0, 1)) { $this->_ERHelper('4010001', TRUE, 'load'); } ///构建API文件路径 $FilePath = XWB_P_ROOT . DIRECTORY_SEPARATOR . "xplugin_apis" . DIRECTORY_SEPARATOR . $Route[1] . $Route[2] . '.xapi.php'; if (!file_exists($FilePath)) { $this->_ERHelper('4010002', TRUE, 'load'); } ///引用API文件 require_once $FilePath; if (!class_exists($Route[2])) { $this->_ERHelper('4010002', TRUE, 'load'); } ///初始化API类 $apiHandler = new $Route[2](); if (!is_object($apiHandler) || !method_exists($apiHandler, $Route[3])) { $this->_ERHelper('4010002', TRUE, 'load'); } ///调用API方法 $RT = call_user_func_array(array($apiHandler, $Route[3]), $PJDecode); return $RT; }
/** * 获取符合框架目录的一个文件的路径 * @param string $fRoute 文件名 * @param string $type 类型,可选:cls, mod, func, hack * @return sring 文件路径 */ function _getIncFile($fRoute, $type = 'cls') { static $fileMap = array(); $fileId = (string) $fRoute . (string) $type; if (isset($fileMap[$fileId])) { return $fileMap[$fileId]; } if (!XWB_plugin::_chkPath($fRoute)) { trigger_error("file route: [ {$fRoute} - {$type} ] is invalid ", E_USER_ERROR); } $m = XWB_plugin::_parseRoute($fRoute); $fp = $m[1] . $m[2]; $type = strtolower($type); $f = array('cls' => XWB_P_ROOT . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . $fp . '.class.php', 'mod' => XWB_P_ROOT . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . $fp . '.mod.php', 'func' => XWB_P_ROOT . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . $fp . '.function.php', 'hack' => XWB_P_ROOT . DIRECTORY_SEPARATOR . "hack" . DIRECTORY_SEPARATOR . $fp . '.hack.php'); if (!isset($f[$type])) { trigger_error("file type: [ {$type} ] is invalid ", E_USER_ERROR); } if (!file_exists($f[$type])) { trigger_error("file:[ " . $f[$type] . " ] not exists ", E_USER_ERROR); } $fileMap[$fileId] = $f[$type]; return $f[$type]; }