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

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
parent 9cd5b0e4
No related branches found
No related tags found
No related merge requests found
...@@ -50,6 +50,11 @@ try { ...@@ -50,6 +50,11 @@ try {
$url = $_SERVER['PATH_INFO']; $url = $_SERVER['PATH_INFO'];
assert('substr($url, 0, 1) === "/"'); 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); $modEnd = strpos($url, '/', 1);
if ($modEnd === FALSE) { if ($modEnd === FALSE) {
/* The path must always be on the form /module/. */ /* The path must always be on the form /module/. */
...@@ -80,6 +85,24 @@ try { ...@@ -80,6 +85,24 @@ try {
$path = SimpleSAML_Module::getModuleDir($module) . '/www/' . $url; $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] === '/') { 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.
......
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