Subversion Repositories oidplus

Rev

Rev 1267 | Rev 1317 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1267 Rev 1287
Line 2123... Line 2123...
2123
                if (!is_null($target)) {
2123
                if (!is_null($target)) {
2124
                        $basedir = realpath(__DIR__.'/../../');
2124
                        $basedir = realpath(__DIR__.'/../../');
2125
                        $target = realpath($target);
2125
                        $target = realpath($target);
2126
                        if ($target === false) return false;
2126
                        if ($target === false) return false;
2127
                        $tmp = substr($target, strlen($basedir)+1);
2127
                        $tmp = substr($target, strlen($basedir)+1);
2128
                        $res .= str_replace(DIRECTORY_SEPARATOR,'/',$tmp); // remove OS specific path delimiters introduced by realpath()
2128
                        $res .= str_replace(DIRECTORY_SEPARATOR,'/',$tmp); // replace OS specific path delimiters introduced by realpath()
2129
                        if (is_dir($target)) $res .= '/';
2129
                        if (is_dir($target)) $res .= '/';
2130
                }
2130
                }
2131
 
2131
 
2132
                return $res;
2132
                return $res;
2133
        }
2133
        }
2134
 
2134
 
2135
        /**
2135
        /**
-
 
2136
         * Note: canonicalURL() is different than webpath(),
-
 
2137
         * because it does additional things like re-ordering of arguments
2136
         * @param string|null $goto
2138
         * @param string|null $goto
2137
         * @return false|string
2139
         * @return false|string
2138
         * @throws OIDplusException
2140
         * @throws OIDplusException
2139
         */
2141
         */
2140
        public static function canonicalURL(string $goto=null) {
2142
        public static function canonicalURL(string $goto=null) {
Line 2144... Line 2146...
2144
                // Second part: Directory
2146
                // Second part: Directory
2145
                $basedir = realpath(__DIR__.'/../../');
2147
                $basedir = realpath(__DIR__.'/../../');
2146
                $target = realpath('.');
2148
                $target = realpath('.');
2147
                if ($target === false) return false;
2149
                if ($target === false) return false;
2148
                $tmp = substr($target, strlen($basedir)+1);
2150
                $tmp = substr($target, strlen($basedir)+1);
2149
                $res = str_replace(DIRECTORY_SEPARATOR,'/',$tmp); // remove OS specific path delimiters introduced by realpath()
2151
                $res = str_replace(DIRECTORY_SEPARATOR,'/',$tmp); // replace OS specific path delimiters introduced by realpath()
2150
                if (is_dir($target) && ($res != '')) $res .= '/';
2152
                if (is_dir($target) && ($res != '')) $res .= '/';
2151
 
2153
 
2152
                // Third part: File name
2154
                // Third part: File name
2153
                $tmp = explode('/',$_SERVER['SCRIPT_NAME']);
2155
                $tmp = $_SERVER['SCRIPT_NAME'];
-
 
2156
                $tmp = rtrim($tmp, 'index.php');
-
 
2157
                $tmp = explode('/',$tmp);
2154
                $tmp = end($tmp);
2158
                $tmp = end($tmp);
2155
 
2159
 
2156
                // Fourth part: Query string (ordered)
2160
                // Fourth part: Query string (ordered)
2157
                $url = [];
2161
                $url = [];
2158
                parse_str($_SERVER['QUERY_STRING'], $url);
2162
                parse_str($_SERVER['QUERY_STRING'], $url);