Переглянути джерело

Allow $SERVER_NAME$ as a placeholder for the server's name in the application root url. Useful for multiple virtual hosts or test systems using DHCP...

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1438 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 14 роки тому
батько
коміт
1b6206732f
2 змінених файлів з 17 додано та 2 видалено
  1. 16 1
      application/utils.inc.php
  2. 1 1
      core/config.class.inc.php

+ 16 - 1
application/utils.inc.php

@@ -27,6 +27,7 @@ require_once(APPROOT.'/core/config.class.inc.php');
 require_once(APPROOT.'/application/transaction.class.inc.php');
 
 define('ITOP_CONFIG_FILE', APPROOT.'/config-itop.php');
+define('SERVER_NAME_PLACEHOLDER', '$SERVER_NAME$');
 
 class FileUploadException extends Exception
 {
@@ -365,7 +366,21 @@ class utils
      */                   
 	static public function GetAbsoluteUrlAppRoot()
 	{
-		return MetaModel::GetConfig()->Get('app_root_url');
+		$sUrl = MetaModel::GetConfig()->Get('app_root_url');
+		if (strpos($sUrl, SERVER_NAME_PLACEHOLDER) > -1)
+		{
+			if (isset($_SERVER['SERVER_NAME']))
+			{
+				$sServerName = $_SERVER['SERVER_NAME'];
+			}
+			else
+			{
+				// CLI mode ?
+				$sServerName = php_uname('n');
+			}
+			$sUrl = str_replace(SERVER_NAME_PLACEHOLDER, $sServerName, $sUrl);
+		}
+		return $sUrl;
 	}
 
 	static public function GetDefaultUrlAppRoot()

+ 1 - 1
core/config.class.inc.php

@@ -86,7 +86,7 @@ class Config
 	protected $m_aSettings = array(
 		'app_root_url' => array(
 			'type' => 'string',
-			'description' => 'Root URL used for navigating within the application, or from an email to the application',
+			'description' => 'Root URL used for navigating within the application, or from an email to the application (you can put $SERVER_NAME$ as a placeholder for the server\'s name)',
 			'default' => '',
 			'value' => '',
 			'source_of_value' => '',