Revision: 1859
Author: olavmrk
Date: Fri Oct 16 04:04:24 2009
Log: www/module.php: Add better handling of PATH_INFO and SCRIPT_NAME.
http://code.google.com/p/simplesamlphp/source/detail?r=1859

Modified:
  /trunk/www/module.php

=======================================
--- /trunk/www/module.php       Thu Sep 24 00:36:28 2009
+++ /trunk/www/module.php       Fri Oct 16 04:04:24 2009
@@ -52,11 +52,8 @@

        /* Clear the PATH_INFO option, so that a script can detect whether it 
is  
called
         * 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);
        if ($modEnd === FALSE) {
@@ -87,26 +84,26 @@
        }

        $moduleDir = SimpleSAML_Module::getModuleDir($module) . '/www/';
-       $path = $moduleDir . $url;

        /* Check for '.php/' in the path, the presence of which indicates that  
another php-script
         * should handle the request.
         */
        for ($phpPos = strpos($url, '.php/'); $phpPos !== FALSE; $phpPos =  
strpos($url, '.php/', $phpPos + 1)) {

-               $newPath = substr($url, 0, $phpPos + 4);
-               $paramPath = substr($url, $phpPos + 4);
-
-               if (is_file($moduleDir . $newPath)) {
+               $newURL = substr($url, 0, $phpPos + 4);
+               $param = substr($url, $phpPos + 4);
+
+               if (is_file($moduleDir . $newURL)) {
                        /* $newPath points to a normal file. Point execution to 
that file, and
                         * save the remainder of the path in PATH_INFO.
                         */
-                       $path = $moduleDir . $newPath;
-                       $_SERVER['SCRIPT_NAME'] .= '/' . $module . '/' . 
$newPath;
-                       $_SERVER['PATH_INFO'] = $paramPath;
+                       $url = $newURL;
+                       $_SERVER['PATH_INFO'] = $param;
                        break;
                }
        }
+
+       $path = $moduleDir . $url;

        if ($path[strlen($path)-1] === '/') {
                /* Path ends with a slash - directory reference. Attempt to 
find index  
file
@@ -136,6 +133,7 @@

        if (preg_match('#\.php$#', $path)) {
                /* PHP file - attempt to run it. */
+               $_SERVER['SCRIPT_NAME'] .= '/' . $module . '/' . $url;
                require($path);
                exit();
        }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"simpleSAMLphp commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/simplesamlphp-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to