mirror of
https://github.com/typecho/typecho.git
synced 2025-03-20 01:49:40 +01:00
fix #316
fix #390 fix #430 add constants __TYPECHO_URL_PREFIX__ to custom global url prefix
This commit is contained in:
parent
87a0479324
commit
ed974cd9fe
@ -218,9 +218,13 @@ class Typecho_Request
|
||||
public static function getUrlPrefix()
|
||||
{
|
||||
if (empty(self::$_urlPrefix)) {
|
||||
self::$_urlPrefix = (self::isSecure() ? 'https' : 'http') . '://'
|
||||
. (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'])
|
||||
. (empty($_SERVER['SERVER_PORT']) || in_array($_SERVER['SERVER_PORT'], array(80, 443)) ? '' : ':' . $_SERVER['SERVER_PORT']);
|
||||
if (defined('__TYPECHO_URL_PREFIX__')) {
|
||||
self::$_urlPrefix == __TYPECHO_URL_PREFIX__;
|
||||
} else {
|
||||
self::$_urlPrefix = (self::isSecure() ? 'https' : 'http') . '://'
|
||||
. (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']
|
||||
. (empty($_SERVER['SERVER_PORT']) || in_array($_SERVER['SERVER_PORT'], array(80, 443)) ? '' : ':' . $_SERVER['SERVER_PORT']));
|
||||
}
|
||||
}
|
||||
|
||||
return self::$_urlPrefix;
|
||||
|
@ -372,6 +372,7 @@ class Widget_Options extends Typecho_Widget
|
||||
/** 动态获取根目录 */
|
||||
$this->rootUrl = $this->request->getRequestRoot();
|
||||
if (defined('__TYPECHO_ADMIN__')) {
|
||||
/** 识别在admin目录中的情况 */
|
||||
$adminDir = '/' . trim(defined('__TYPECHO_ADMIN_DIR__') ? __TYPECHO_ADMIN_DIR__ : '/admin/', '/');
|
||||
$this->rootUrl = substr($this->rootUrl, 0, - strlen($adminDir));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user