Add config parameter to define base URL (#625)

This commit is contained in:
Mitchell Hewes 2017-01-22 03:11:03 +11:00 committed by Frédéric Guillot
parent 86d981fa90
commit 9b670a9909
3 changed files with 16 additions and 8 deletions

View File

@ -24,6 +24,7 @@ defined('DB_PASSWORD') or define('DB_PASSWORD', '');
defined('DEBUG_MODE') or define('DEBUG_MODE', false); defined('DEBUG_MODE') or define('DEBUG_MODE', false);
defined('DEBUG_FILENAME') or define('DEBUG_FILENAME', DATA_DIRECTORY.DIRECTORY_SEPARATOR.'debug.log'); defined('DEBUG_FILENAME') or define('DEBUG_FILENAME', DATA_DIRECTORY.DIRECTORY_SEPARATOR.'debug.log');
defined('BASE_URL') or define('BASE_URL', '');
defined('THEME_DIRECTORY') or define('THEME_DIRECTORY', 'themes'); defined('THEME_DIRECTORY') or define('THEME_DIRECTORY', 'themes');
defined('THEME_URL_PATH') or define('THEME_URL_PATH', 'themes'); defined('THEME_URL_PATH') or define('THEME_URL_PATH', 'themes');
defined('SESSION_SAVE_PATH') or define('SESSION_SAVE_PATH', ''); defined('SESSION_SAVE_PATH') or define('SESSION_SAVE_PATH', '');

View File

@ -44,17 +44,21 @@ function parse_app_version($refnames, $commithash)
function get_current_base_url() function get_current_base_url()
{ {
if(BASE_URL) {
$url = BASE_URL;
return rtrim($url, '/') . '/';
} else {
$url = is_secure_connection() ? 'https://' : 'http://'; $url = is_secure_connection() ? 'https://' : 'http://';
$url .= $_SERVER['HTTP_HOST']; $url .= $_SERVER['HTTP_HOST'];
if (strpos($_SERVER['HTTP_HOST'], ':') === false) { if (strpos($_SERVER['HTTP_HOST'], ':') === false) {
$url .= $_SERVER['SERVER_PORT'] == 80 || $_SERVER['SERVER_PORT'] == 443 ? '' : ':'.$_SERVER['SERVER_PORT']; $url .= $_SERVER['SERVER_PORT'] == 80 || $_SERVER['SERVER_PORT'] == 443 ? '' : ':'.$_SERVER['SERVER_PORT'];
} }
$url .= str_replace('\\', '/', dirname($_SERVER['PHP_SELF'])) !== '/' ? str_replace('\\', '/', dirname($_SERVER['PHP_SELF'])).'/' : '/'; $url .= str_replace('\\', '/', dirname($_SERVER['PHP_SELF'])) !== '/' ? str_replace('\\', '/', dirname($_SERVER['PHP_SELF'])).'/' : '/';
return $url; return $url;
} }
}
function is_secure_connection() function is_secure_connection()
{ {

View File

@ -6,6 +6,9 @@ define('HTTP_TIMEOUT', '20');
// HTTP_MAX_RESPONSE_SIZE => Maximum accepted size of the response body in MB (default 2MB) // HTTP_MAX_RESPONSE_SIZE => Maximum accepted size of the response body in MB (default 2MB)
define('HTTP_MAX_RESPONSE_SIZE', 2097152); define('HTTP_MAX_RESPONSE_SIZE', 2097152);
// BASE_URL => URL that clients should access this instance of miniflux from
define('BASE_URL', '');
// DATA_DIRECTORY => default is data (writable directory) // DATA_DIRECTORY => default is data (writable directory)
define('DATA_DIRECTORY', 'data'); define('DATA_DIRECTORY', 'data');