/** * 组装绝对网址链接 * * @param string $pattern 路径模式 get/test/abc-{zh|en}/blog/{year}-([1-9]\d*):language:year:id * 其中请求方法get是可选的 如 /test/abc-{zh|en}/blog/{year}-([1-9]\d*):language:year:id * @param string $parameters 参数 array('language'=>'en','year'=>'2014','id'=4025 * @param bool $forceHttps 是否强制使用https协议, false时将使用请求时的协议。 * * @return string http://www.host.com/.../test/abc-en/blog/2014-4025 */ public function toAbsURL($pattern, $parameters = null, $forceHttps = false) { $uri = $this->toURL($pattern, $parameters); $uri = $this->app->request()->getUriPrefix() . $uri; $forceHttps and $uri = 'https' . strstr($uri, ':'); return $uri; }
private function show($errorInfo, $tpl) { $errorInfo['goto_index'] = $this->app->FRONT_ROOT_URL . '/index.php'; if ($this->app->request()->isAjax()) { ob_clean(); //清除之前输出的内容 echo json_encode(notice(false, $errorInfo)); } elseif (isset($_SERVER['REMOTE_ADDR'])) { //载入显示模板 if (file_exists($tpl)) { require $tpl; } else { $this->printError($errorInfo, '<br/>', '糟糕,连错误页显示模板也不存在!'); } } else { $this->printError($errorInfo, PHP_EOL); } }
/** * 构造方法 * * @param Monkey\App $app */ public function __construct($app) { $this->app = $app; if ('HEAD' == $app->request()->getMethod()) { $this->setHttpHeaderOnly(true); } $this->charset = $app->CHARSET; $app->shutdown()->register(array($this, 'send')); if (substr($this->app->request()->header()->getContentType(), -4) == 'json') { $this->setJson(); } if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], 'gzip') !== false && !ini_get('zlib.output_compression') && extension_loaded("zlib") && function_exists('gzencode')) { ob_start("ob_gzhandler"); } else { ob_start(); } }