Skip to content
Snippets Groups Projects
Commit 3689b948 authored by Olav Morken's avatar Olav Morken
Browse files

www/module.php: Add better handling of PATH_INFO and SCRIPT_NAME.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1859 44740490-163a-0410-bde0-09ae8108e29a
parent 436d91fc
No related branches found
No related tags found
No related merge requests found
...@@ -52,11 +52,8 @@ try { ...@@ -52,11 +52,8 @@ try {
/* Clear the PATH_INFO option, so that a script can detect whether it is called /* Clear the PATH_INFO option, so that a script can detect whether it is called
* with anything following the '.php'-ending. * with anything following the '.php'-ending.
*
* Commented out by Andreas on december 3rd 2008. this conflicts with the helper methods
* in Utilities to get URL right.
*/ */
# unset($_SERVER['PATH_INFO']); unset($_SERVER['PATH_INFO']);
$modEnd = strpos($url, '/', 1); $modEnd = strpos($url, '/', 1);
if ($modEnd === FALSE) { if ($modEnd === FALSE) {
...@@ -87,27 +84,27 @@ try { ...@@ -87,27 +84,27 @@ try {
} }
$moduleDir = SimpleSAML_Module::getModuleDir($module) . '/www/'; $moduleDir = SimpleSAML_Module::getModuleDir($module) . '/www/';
$path = $moduleDir . $url;
/* Check for '.php/' in the path, the presence of which indicates that another php-script /* Check for '.php/' in the path, the presence of which indicates that another php-script
* should handle the request. * should handle the request.
*/ */
for ($phpPos = strpos($url, '.php/'); $phpPos !== FALSE; $phpPos = strpos($url, '.php/', $phpPos + 1)) { for ($phpPos = strpos($url, '.php/'); $phpPos !== FALSE; $phpPos = strpos($url, '.php/', $phpPos + 1)) {
$newPath = substr($url, 0, $phpPos + 4); $newURL = substr($url, 0, $phpPos + 4);
$paramPath = substr($url, $phpPos + 4); $param = substr($url, $phpPos + 4);
if (is_file($moduleDir . $newPath)) { if (is_file($moduleDir . $newURL)) {
/* $newPath points to a normal file. Point execution to that file, and /* $newPath points to a normal file. Point execution to that file, and
* save the remainder of the path in PATH_INFO. * save the remainder of the path in PATH_INFO.
*/ */
$path = $moduleDir . $newPath; $url = $newURL;
$_SERVER['SCRIPT_NAME'] .= '/' . $module . '/' . $newPath; $_SERVER['PATH_INFO'] = $param;
$_SERVER['PATH_INFO'] = $paramPath;
break; break;
} }
} }
$path = $moduleDir . $url;
if ($path[strlen($path)-1] === '/') { if ($path[strlen($path)-1] === '/') {
/* Path ends with a slash - directory reference. Attempt to find index file /* Path ends with a slash - directory reference. Attempt to find index file
* in directory. * in directory.
...@@ -136,6 +133,7 @@ try { ...@@ -136,6 +133,7 @@ try {
if (preg_match('#\.php$#', $path)) { if (preg_match('#\.php$#', $path)) {
/* PHP file - attempt to run it. */ /* PHP file - attempt to run it. */
$_SERVER['SCRIPT_NAME'] .= '/' . $module . '/' . $url;
require($path); require($path);
exit(); exit();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment