當前位置: 首頁>>代碼示例>>PHP>>正文


PHP helper::getSiteCode方法代碼示例

本文整理匯總了PHP中helper::getSiteCode方法的典型用法代碼示例。如果您正苦於以下問題:PHP helper::getSiteCode方法的具體用法?PHP helper::getSiteCode怎麽用?PHP helper::getSiteCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在helper的用法示例。


在下文中一共展示了helper::getSiteCode方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setSiteCode

 /**
  * Set the code of current site. 
  * 
  * www.xirang.com => xirang
  * xirang.com     => xirang
  * xirang.com.cn  => xirang
  * xirang.cn      => xirang
  * xirang         => xirang
  * 192.168.1.1    => 192.168.1.1
  *
  * @access protected
  * @return void
  */
 public function setSiteCode()
 {
     return $this->siteCode = helper::getSiteCode($this->server->http_host);
 }
開發者ID:mustafakarali,項目名稱:b2c-1,代碼行數:17,代碼來源:router.class.php

示例2: checkDomain

 /**
  * Check domain and header 301.
  *
  * @access public
  * @return void
  */
 public function checkDomain()
 {
     if (RUN_MODE == 'install' or RUN_MODE == 'upgrade' or RUN_MODE == 'shell' or RUN_MODE == 'admin' or !$this->config->installed) {
         return true;
     }
     $http = (isset($_SERVER['HTTPS']) and strtolower($_SERVER['HTTPS']) != 'off') ? 'https://' : 'http://';
     $httpHost = $this->server->http_host;
     $currentURI = $http . $httpHost . $this->server->request_uri;
     $scheme = isset($this->config->site->scheme) ? $this->config->site->scheme : 'http';
     $mainDomain = isset($this->config->site->domain) ? $this->config->site->domain : '';
     $mainDomain = str_replace(array('http://', 'https://'), '', $mainDomain);
     /* Check main domain and scheme. */
     $redirectURI = $currentURI;
     if (strpos($redirectURI, $scheme . '://') !== 0) {
         $redirectURI = $scheme . substr($redirectURI, strpos($redirectURI, '://'));
     }
     if (!empty($mainDomain) and $httpHost != $mainDomain) {
         $redirectURI = str_replace($httpHost, $mainDomain, $redirectURI);
     }
     if ($redirectURI != $currentURI) {
         header301($redirectURI);
     }
     /* Check domain is allowed. */
     $allowedDomains = isset($this->config->site->allowedDomain) ? $this->config->site->allowedDomain : '';
     $allowedDomains = str_replace(array('http://', 'https://'), '', $allowedDomains);
     if (!empty($allowedDomains)) {
         if (strpos($allowedDomains, $httpHost) !== false) {
             return true;
         }
         if (!empty($mainDomain) and helper::getSiteCode($httpHost) == helper::getSiteCode($mainDomain)) {
             return true;
         }
         die('domain denied.');
     }
 }
開發者ID:wenyinos,項目名稱:chanzhieps,代碼行數:41,代碼來源:model.php

示例3: title

#!/usr/bin/env php
<?php 
include '../../../tests/init.php';
// Include the init file of testing framework.
include '../../router.class.php';
// Include router class.
include '../../helper.class.php';
// Include helper class.
title("testing the logic for site code.");
$router = router::createApp('test', '../../../');
run(helper::getSiteCode('www.xirang.com')) && expect('xirang');
run(helper::getSiteCode('xirang.com')) && expect('xirang');
run(helper::getSiteCode('xirang.com.cn')) && expect('xirang');
run(helper::getSiteCode('www.xirang.cn')) && expect('xirang');
run(helper::getSiteCode('xirang')) && expect('xirang');
run(helper::getSiteCode('192.168.1.1')) && expect('192.168.1.1');
run(helper::getSiteCode('www.xirang.com.cn')) && expect('xirang');
run(appendChanzhiDomain());
run(helper::getSiteCode('xirang.n1.chanzhi.net')) && expect('xirang');
function appendChanzhiDomain()
{
    global $router;
    $router->config->domainPostfix .= '|n1.chanzhi.net|';
}
開發者ID:dyp8848,項目名稱:chanzhieps,代碼行數:24,代碼來源:01_setsitecode.php


注:本文中的helper::getSiteCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。