public static function router() { // System Classes Config::init(); Autoloder::load(); Request::setRequest(); // Router Data Config::$controller = Request::$request['post']['controller']; Config::$action = Request::$request['post']['action']; Config::$route = self::$controller . '/' . self::$action; Config::$session = []; Config::$is_ajax = false; if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') { Config::$is_ajax = true; } // Current User Session Config::locateUserSession(); // API Mode if (!Request::$request['post']) { //Default API Mode Config::$mobile_mode = 'default'; } else { Config::$mobile_mode = Request::$request['post']['mobile']; } return true; }
public function before($context) { $partnerConfig = null; $context->response->skipAction = false; $hzdomain = (isset($_SERVER["HTTP_HOST"])) ? strtolower($_SERVER["HTTP_HOST"]) : HZ_DOMAINNAME; $hzdomain = ($context->request->sdomain != '' && $context->request->sdomain != 'www.haodf.com') ? $context->request->sdomain : $hzdomain; $hzdomain = str_replace(URL_PREFIX, '', $hzdomain); $partnerConfig = PartnerClient::getInstance()->getByDomain($hzdomain); //设置 版式 $homePageName = trim($partnerConfig->homePageName); $request = new Request(); if($homePageName == 'index.2.php') $request->setRequest('partnerTpl', 'yaolan'); else if($homePageName == 'index.3.php') $request->setRequest('partnerTpl', 'pclady'); else if($hzdomain == 'haodf.picchealth.com') $request->setRequest('partnerTpl', 'picc'); else $request->setRequest('partnerTpl', 'index'); //设置省市 $homeParam = trim($partnerConfig->homeParam); $homeParam = ($homeParam != '') ? str_replace('prov=', '', $homeParam) : "beijing,shanghai,guangdong,hubei,sichuan"; $context->request->defaultProvs = $homeParam; //设置宽窄 $imageUrl = 'http://i1.hdfimg.com/partner'; $kuanCss = "$imageUrl/css/950.css"; $zhaiCss = "$imageUrl/css/778.css"; $cssLink = ($partnerConfig->windowType == 1) ? $kuanCss : $zhaiCss; $cssDefineAry = array('haodf.health.sohu.com'=>"$imageUrl/sohu/950.css", 'qq.health.haodf.com'=>"$imageUrl/sohu/950.css", 'wenda.health.msn.com.cn'=>"https://wenda.health.msn.com.cn/partner/css/950.css", 'qqhealth.haodf.com'=>"$imageUrl/sohu/950.css"); $cssLink = array_key_exists($hzdomain, $cssDefineAry) ? $cssDefineAry[$hzdomain] : $cssLink; $context->response->cssLink = $cssLink; //设置charset $charset = ($partnerConfig != null && $partnerConfig->isNull() == false) ? $partnerConfig->charset : 'gb2312'; $charset = (strpos($hzdomain, 'haodf.0-6.com') !== false) ? 'gb2312' : $charset; $charset = ($charset == '') ? 'gb2312' : $charset; $context->response->charset = $charset; $context->response->isPeople = (strpos($hzdomain, 'haodf.health.people.com.cn') !== false); if ($partnerConfig->isNull()) { header('Location: http://www.haodf.com/404.html'); } if (false == $partnerConfig->isNull() && $partnerConfig->isOpenCase()) { $context->response->isThreadOpen = true; } else { $context->response->isThreadOpen = false; } if (false == $partnerConfig->isNull() && $partnerConfig->isOpenDisease()) { $context->response->isDiseaseOpen = true; } else { $context->response->isDiseaseOpen = false; } $isSohu = (strpos($hzdomain, 'haodf.health.sohu.com') !== false); $isQQ = ((strpos($hzdomain, 'qq.health.haodf.com') !== false) || (strpos($hzdomain, 'qqhealth.haodf.com') !== false)); $isPicc = ((strpos($hzdomain, 'haodf.picchealth.com') !== false)); $context->request->isSohu = $isSohu; $context->request->isQQ = $isQQ; $context->request->isPicc = $isPicc; $context->response->isSohu = $isSohu; $context->response->isQQ = $isQQ; $context->response->isPicc = $isPicc; $context->response->partnerConfig = $partnerConfig; $context->request->partnerConfig = $partnerConfig; }
private static function refreshDebugCookie($key, $value, $expire = 0) { /*{{{*/ $request = new Request(); $cookie = new HdfCookie(); if ($expire == 0) { $cookie->set($key, $value, 0 - time()); } else { $cookie->set($key, $value, $expire); } $request->setRequest($key, $value); }