本文整理汇总了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);
}
示例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.');
}
}
示例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|';
}