本文整理汇总了PHP中router::get_root_domain方法的典型用法代码示例。如果您正苦于以下问题:PHP router::get_root_domain方法的具体用法?PHP router::get_root_domain怎么用?PHP router::get_root_domain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类router
的用法示例。
在下文中一共展示了router::get_root_domain方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_protocol
/**
* check current protocol and if needed redirect to another!
* @return [type] [description]
*/
private static function check_protocol()
{
// create new url for protocol checker
$newUrl = "";
$currentPath = $_SERVER['REQUEST_URI'];
$mainSite = \lib\utility\option::get('config', 'meta', 'redirectURL');
// if redirect to main site is enable and all thing is okay
// then redirect to the target url
if (\lib\utility\option::get('config', 'meta', 'multiDomain') && \lib\utility\option::get('config', 'meta', 'redirectToMain') && $mainSite && Tld !== 'dev' && parse_url($mainSite, PHP_URL_HOST) != \lib\router::get_root_domain()) {
// as soon as posible we create language detector library
switch (Tld) {
case 'ir':
$newUrl = $mainSite . "/fa";
break;
default:
break;
}
} elseif ($currentPath !== '/' && rtrim($currentPath, '/') !== $currentPath) {
$newUrl = $mainSite . rtrim($currentPath, '/');
} else {
// if want to force using https then redirect to https of current url
if (\lib\utility\option::get('config', 'meta', 'https')) {
if (Protocol === 'http') {
$newUrl = 'https://';
}
} elseif (Protocol === 'https') {
$newUrl = 'http://';
}
if ($newUrl) {
$newUrl .= router::get_root_domain() . '/' . router::get_url();
}
}
// var_dump($newUrl);exit();
// if newUrl is exist and we must to redirect
// then complete url and redirect to this address
if ($newUrl && !\lib\utility::get('force')) {
// redirect to best protocol because we want it!
$redirector = new \lib\redirector($newUrl);
$redirector->redirect();
}
}
示例2: __construct
//.........这里部分代码省略.........
router::set_storage('language', $key);
} else {
// redirect to homepage
$myredirect = new \lib\redirector();
$myredirect->set_domain()->set_url()->redirect();
}
}
}
}
}
}
if (self::$auto_api) {
// automatically allow api, if you wan't to desable it, only set a value
$route = new router\route("/^api([^\\/]*)/", function ($reg) {
router::remove_url($reg->url);
router::set_storage('api', true);
});
}
if (class_exists('\\cls\\route')) {
$router = new \cls\route();
$router->main = $this;
if (method_exists($router, "_before")) {
$router->_before();
}
}
$this->check_router();
/**
* after router
*/
if (class_exists('\\cls\\route')) {
if (method_exists($router, "_after")) {
$router->_after();
}
}
// Define Project Constants *******************************************************************
// declate some constant variable for better use in all part of app
// like dev or com or ir or ...
if (!defined('Tld')) {
define('Tld', router::get_root_domain('tld'));
}
// like .dev or .com
if (!defined('MainTld')) {
define('MainTld', Tld === 'dev' ? '.dev' : '.com');
}
// like ermile
if (!defined('Domain')) {
define('Domain', router::get_root_domain('domain'));
}
// like account
if (!defined('SubDomain')) {
define('SubDomain', router::get_sub_domain());
}
// like 127.0.0.1
if (!defined('ClientIP')) {
define('ClientIP', router::get_clientIP());
}
// like ermile.com
if (!defined('Service')) {
define('Service', Domain . '.' . Tld);
}
// like test
if (!defined('Module')) {
define('Module', router::get_url(0));
}
// like https://ermile.com
router::set_storage('url_site', Protocol . '://' . Domain . '.' . Tld . '/');
if (defined('Account') && constant('Account')) {
// if use ermile set Mainservice for creating all account together
if (is_string(constant('Account')) && constant('Account') !== constant('MainService')) {
$myAccount = constant('Account');
} else {
$myAccount = 'account';
}
} else {
$myAccount = false;
}
// set MyAccount for use in all part of services
if (!defined('AccountService')) {
if (defined('Account') && constant('Account') === constant('MainService')) {
define('AccountService', constant('MainService'));
} else {
define('AccountService', Domain);
}
}
// set MyAccount for use in all part of services
if (!defined('MyAccount')) {
define('MyAccount', $myAccount);
}
router::$base = Protocol . '://';
if (router::$sub_is_fake) {
router::$base .= Service . '/' . (SubDomain ? SubDomain . '/' : null);
} else {
router::$base .= SubDomain . '.' . Service . '/';
}
if (count(explode('.', SubDomain)) > 1) {
die("<p>Saloos only support one subdomain!</p>");
} elseif (SubDomain === 'www') {
header('Location: ' . router::get_storage('url_site'), true, 301);
}
}