From 30c4854288cc2f34a8a1a3afc25641c1f49acaa0 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Mon, 10 Nov 2008 13:00:59 +0000 Subject: [PATCH] Module: Add support for running scripts which depends on PATH_INFO from modules. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@981 44740490-163a-0410-bde0-09ae8108e29a --- www/module.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/www/module.php b/www/module.php index e07a87110..c75ec081a 100644 --- a/www/module.php +++ b/www/module.php @@ -50,6 +50,11 @@ try { $url = $_SERVER['PATH_INFO']; assert('substr($url, 0, 1) === "/"'); + /* Clear the PATH_INFO option, so that a script can detect whether it is called + * with anything following the '.php'-ending. + */ + unset($_SERVER['PATH_INFO']); + $modEnd = strpos($url, '/', 1); if ($modEnd === FALSE) { /* The path must always be on the form /module/. */ @@ -80,6 +85,24 @@ try { $path = SimpleSAML_Module::getModuleDir($module) . '/www/' . $url; + /* Check for '.php/' in the path, the presence of which indicates that another php-script + * should handle the request. + */ + for ($phpPos = strpos($path, '.php/'); $phpPos !== FALSE; $phpPos = strpos($path, '.php/', $phpPos + 1)) { + + $newPath = substr($path, 0, $phpPos + 4); + $paramPath = substr($path, $phpPos + 4); + + if (is_file($newPath)) { + /* $newPath points to a normal file. Point execution to that file, and + * save the remainder of the path in PATH_INFO. + */ + $path = $newPath; + $_SERVER['PATH_INFO'] = $paramPath; + break; + } + } + if ($path[strlen($path)-1] === '/') { /* Path ends with a slash - directory reference. Attempt to find index file * in directory. -- GitLab