diff options
-rw-r--r-- | _test/cases/inc/pageutils_getid.test.php | 3 | ||||
-rw-r--r-- | inc/pageutils.php | 8 |
2 files changed, 10 insertions, 1 deletions
diff --git a/_test/cases/inc/pageutils_getid.test.php b/_test/cases/inc/pageutils_getid.test.php index aa97e4930..8233ffb42 100644 --- a/_test/cases/inc/pageutils_getid.test.php +++ b/_test/cases/inc/pageutils_getid.test.php @@ -57,6 +57,9 @@ class init_getID_test extends UnitTestCase { $_SERVER['SCRIPT_FILENAME'] = '/usr/share/dokuwiki/doku.php'; $_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php'; $_SERVER['REQUEST_URI'] = '/dokuwiki/doku.php/wiki:dokuwiki'; + $_SERVER['PATH_INFO'] = '/wiki:dokuwiki'; + $_SERVER['PATH_TRANSLATED'] = '/var/www/wiki:dokuwiki'; + $_SERVER['PHP_SELF'] = '/dokuwiki/doku.php/wiki:dokuwiki'; $this->assertEqual(getID(), 'wiki:dokuwiki'); } diff --git a/inc/pageutils.php b/inc/pageutils.php index 872191d12..c10272af3 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -23,6 +23,8 @@ function getID($param='id',$clean=true){ $id = isset($_REQUEST[$param]) ? $_REQUEST[$param] : null; + $request = $_SERVER['REQUEST_URI']; + //construct page id from request URI if(empty($id) && $conf['userewrite'] == 2){ //get the script URL @@ -32,6 +34,10 @@ function getID($param='id',$clean=true){ $relpath = 'lib/exe/'; } $script = $conf['basedir'].$relpath.basename($_SERVER['SCRIPT_FILENAME']); + + }elseif($_SERVER['DOCUMENT_ROOT'] && $_SERVER['PATH_TRANSLATED']){ + $request = preg_replace ('/^'.preg_quote($_SERVER['DOCUMENT_ROOT'],'/').'/','', + $_SERVER['PATH_TRANSLATED']); }elseif($_SERVER['DOCUMENT_ROOT'] && $_SERVER['SCRIPT_FILENAME']){ $script = preg_replace ('/^'.preg_quote($_SERVER['DOCUMENT_ROOT'],'/').'/','', $_SERVER['SCRIPT_FILENAME']); @@ -42,7 +48,7 @@ function getID($param='id',$clean=true){ //clean script and request (fixes a windows problem) $script = preg_replace('/\/\/+/','/',$script); - $request = preg_replace('/\/\/+/','/',$_SERVER['REQUEST_URI']); + $request = preg_replace('/\/\/+/','/',$request); //remove script URL and Querystring to gain the id if(preg_match('/^'.preg_quote($script,'/').'(.*)/',$request, $match)){ |