瀏覽代碼

For the setup: try to make the URL detection work even if the actual PHP file is not part of the URL (i.e when index.php is implicitely added when browsing a folder)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1347 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 14 年之前
父節點
當前提交
b1b0f2c0bc
共有 1 個文件被更改,包括 12 次插入1 次删除
  1. 12 1
      application/utils.inc.php

+ 12 - 1
application/utils.inc.php

@@ -419,7 +419,18 @@ class utils
 		}
 		else
 		{
-			throw new Exception("Failed to determine application root path $sAbsoluteUrl ($sCurrentRelativePath) APPROOT:'$sAppRoot'");
+			// Second attempt without index.php at the end...
+			$sCurrentRelativePath = str_replace('index.php', '', $sCurrentRelativePath);
+			$sAppRootPos = strpos($sAbsoluteUrl, $sCurrentRelativePath);
+			if ($sAppRootPos !== false)
+			{
+				$sAppRootUrl = substr($sAbsoluteUrl, 0, $sAppRootPos); // remove the current page and path
+			}
+			else
+			{
+				// No luck...
+				throw new Exception("Failed to determine application root path $sAbsoluteUrl ($sCurrentRelativePath) APPROOT:'$sAppRoot'");
+			}			
 		}
 		return $sAppRootUrl;
 	}