/** @return array requestdata
* all components from '/$thisfunction (->()/$alias' up to one slash before the ? are interpreted
* as pntType/id/key/value/key/value etc.
* For normal urls while an alias is passed, this method returns the script name as parameter key,
* so one should not use the script name as the name of a parameter in the query string
* since phpPeanuts 2.1 no longer includes params from $_POST
* if Funky Urls are used, either the server root must be equal to the phpPeanuts base folder,
* or $this->baseUrl must be set (for example from classes/scriptMakeSettings.php)
* or $this->() must be overridden to properly initialize $this->baseUrl
*/
function getFunkyRequestData($alias=null, $uriParam=null) {
$uri = $uriParam ? $uriParam : $this->('REQUEST_URI');
if ($uriParam || $alias ) {
$requestData = array();
$pAndQ = explode('?', $uri);
$p = $pAndQ[0];
if (isSet($pAndQ[1]))
parse_str($pAndQ[1], $requestData); //!adds slashes if magic_quotes_gpc
} else { //no uriParam and normal urls or POST
$requestData = $_GET;
$p = $uri;
}
if (!$alias) return $requestData;
//funky urls, find the funky piece of the request uri
$pos = strPos($p, $alias);
if ($pos === false) return $requestData; //can not find the start of the funky piece
$funkyPiece = substr($p,$pos+strLen($alias));
if (strLen($funkyPiece) == 0) return $requestData; // funky piece is empty
//parse the funky piece of the request uri
$funkyData = array();
$kvArr = explode("/",$funkyPiece);
$funkyData['pntType'] = urlDecode($kvArr[0]);
if (isSet($kvArr[1]))
$funkyData['id'] = urlDecode($kvArr[1]);
if (count($kvArr) > 2)
for ($i=2; $i < count($kvArr)-1; $i += 2)
$funkyData[urlDecode($kvArr[$i])] = urlDecode($kvArr[$i+1]);
//printDebug($funkyData);
//ErrorHandlers normal query string must override funkyData
return array_merge($funkyData, $requestData);
}
|