diff options
author | andi <andi@splitbrain.org> | 2005-04-29 22:53:20 +0200 |
---|---|---|
committer | andi <andi@splitbrain.org> | 2005-04-29 22:53:20 +0200 |
commit | 6c7843b5addbca9ae2dc1d9d19be8d67663eb8e5 (patch) | |
tree | a9a3f0f481e32f2ce5cb3b256b25b5f482b0b777 /inc/pageutils.php | |
parent | 093ec9e4fcc037744441b83e6ab1a7193c258f96 (diff) | |
download | rpg-6c7843b5addbca9ae2dc1d9d19be8d67663eb8e5.tar.gz rpg-6c7843b5addbca9ae2dc1d9d19be8d67663eb8e5.tar.bz2 |
added internal rewriting
darcs-hash:20050429205320-9977f-6bf54f3b022104a0a9aefa882dfba09a98bc9c2a.gz
Diffstat (limited to 'inc/pageutils.php')
-rw-r--r-- | inc/pageutils.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/inc/pageutils.php b/inc/pageutils.php index 9a255ec2e..724514982 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -6,6 +6,45 @@ * @author Andreas Gohr <andi@splitbrain.org> */ +/** + * Fetch the pageid + * + * Uses either standard $_REQUEST variable or extracts it from + * the full request URI when userewrite is set to 2 + * + * Returns $conf['start'] if no id was found. + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +function getID(){ + global $conf; + + $id = cleanID($_REQUEST['id']); + + //construct page id from request URI + if(empty($id) && $conf['userewrite'] == 2){ + //get the script URL + if($conf['basedir']){ + $script = $conf['basedir'].DOKU_SCRIPT; + }elseif($_SERVER['DOCUMENT_ROOT'] && $_SERVER['SCRIPT_FILENAME']){ + $script = preg_replace ('/^'.preg_quote($_SERVER['DOCUMENT_ROOT'],'/').'/','', + $_SERVER['SCRIPT_FILENAME']); + $script = '/'.$script; + }else{ + $script = $_SERVER['SCRIPT_NAME']; + } + + //remove script URL and Querystring to gain the id + if(preg_match('/^'.preg_quote($script,'/').'(.*)/', + $_SERVER['REQUEST_URI'], $match)){ + $id = preg_replace ('/\?.*/','',$match[1]); + } + $id = cleanID($id); + } + if(empty($id)) $id = $conf['start']; + + return $id; +} /** * Remove unwanted chars from ID |