Refactor some URL related functions to use Rhymix constants

This commit is contained in:
Kijin Sung 2016-01-20 15:45:18 +09:00
parent 9ddf2f54f3
commit a8094fe766
3 changed files with 16 additions and 55 deletions

View file

@ -18,18 +18,18 @@ define('RX_TIME', intval(RX_MICROTIME));
/**
* RX_BASEDIR is the SERVER-SIDE absolute path of Rhymix (with trailing slash).
*/
define('RX_BASEDIR', dirname(__DIR__) . '/');
define('RX_BASEDIR', str_replace('\\', '/', dirname(__DIR__)) . '/');
/**
* RX_BASEURL is the CLIENT-SIDE absolute path of Rhymix (with trailing slash, relative to the document root).
*/
if (isset($_SERVER['DOCUMENT_ROOT']) && !strncmp(RX_BASEDIR, $_SERVER['DOCUMENT_ROOT'], strlen($_SERVER['DOCUMENT_ROOT'])))
if (isset($_SERVER['DOCUMENT_ROOT']) && !strncmp(RX_BASEDIR, str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']), strlen($_SERVER['DOCUMENT_ROOT'])))
{
define('RX_BASEURL', rtrim(substr(RX_BASEDIR, strlen($_SERVER['DOCUMENT_ROOT'])), '/') . '/');
}
elseif (isset($_SERVER['PHP_SELF']) && ($len = strlen($_SERVER['PHP_SELF'])) && $len >= 10 && substr($_SERVER['PHP_SELF'], $len - 10) === '/index.php')
{
define('RX_BASEURL', rtrim(substr($_SERVER['PHP_SELF'], 0, $len - 10), '/') . '/');
define('RX_BASEURL', rtrim(str_replace('\\', '/', substr($_SERVER['PHP_SELF'], 0, $len - 10)), '/') . '/');
}
else
{