/** * @params array $params */ public static function factory($pagelet, $params) { $pageletId = BaseModelCommon::getFormatName($pagelet . '_pagelet', 'class'); //if(!DEBUG && !isset($_GET['nojs'])) { //暂时关闭bigpipe if (false) { self::$stack[$pageletId] = $params; echo '<div id="pagelet_' . strtolower($pageletId) . '"></div>'; } else { self::render($pageletId, $params); } }
/** * * 控制器执行 */ public function runCommand() { //请求方法和来源 switch ($_SERVER['REQUEST_METHOD']) { case 'GET': break; case 'POST': if (BaseModelSwitch::check(BaseModelSwitch::SWITCH_POST_REFERER_CHECK) === true) { $forbid = true; if (!empty($_SERVER['HTTP_REFERER'])) { $parseReferer = parse_url($_SERVER['HTTP_REFERER']); if (!empty($parseReferer['host']) && preg_match("/^[\\w-\\.]+\$/", $parseReferer['host'])) { foreach ($_SERVER['SERVER_ACCEPT_REFERER'] as $referer) { if ($referer === $parseReferer['host'] || '.' . $referer === substr($parseReferer['host'], -(strlen($referer) + 1))) { $forbid = false; break; } } } } if ($forbid) { throw new BaseModelException('请求源不允许[' . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '') . ']', 90100, 'controller_trace'); } } break; case 'HEAD': break; default: throw new BaseModelException('请求方法不允许', 90101, 'controller_trace'); } $action = BaseModelCommon::getFormatName(self::$action); if (in_array($action, array('runCommand', 'setView', 'display', 'fetch'), true)) { $controllerName = BaseModelCommon::getFormatName(self::$controller, 'class'); throw new BaseModelException($controllerName . 'Controller类中方法' . $action . '为基类方法不能使用,您现在指向的app-controller为:app/' . Configure::$app . '/controller/', 90102, 'controller_trace'); } if (method_exists($this, $action)) { call_user_func_array(array(&$this, $action), array()); } else { $controllerName = BaseModelCommon::getFormatName(self::$controller, 'class'); throw new BaseModelException($controllerName . 'Controller类中不存在你调用的方法' . $action . ',您现在指向的app-controller为:app/' . Configure::$app . '/controller/', 90103, 'controller_trace'); } }
<?php /** * dagger项目初始化 */ session_start(); ob_start(); //用户配置 require DAGGER_PATH_ROOT . 'config/SysInitConfig.php'; //系统配置 require DAGGER_PATH_ROOT . 'libs/DaggerSysInitConfig.php'; //__autoload函数 require DAGGER_PATH_LIBS . 'basics.php'; //载入数据存储配置 require DAGGER_PATH_CONFIG . 'DBConfig.php'; if (1 === DAGGER_XHPROF && defined('DAGGER_ALARM_XHPROF_API')) { xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); define('DAGGER_XHPROF_ID', uniqid()); } //静态URL解析规则 BaseModelRouter::route(); $class = BaseModelCommon::getFormatName($_GET[DAGGER_CONTROLLER], 'class'); $class .= 'Controller'; $controller = new $class($_GET[DAGGER_CONTROLLER], $_GET[DAGGER_ACTION]); $controller->runCommand(); if (defined('DAGGER_XHPROF') && 1 === DAGGER_XHPROF) { echo '<br /><a href="' . BaseModelDebug::getXhprofUrl() . '" target="_blank" >xhprof</a>'; }