/** Redirect the request to a different server, page or handler
* This only works if NOTHING has been printed yet!!
* @param Array or String $requestData if Array redirects to handler in same application.
* otherwise redirects to the url it assumes is in $requestData
* @param String $information information to be passed as a request parameter
* this will replace eventual information parameter from $requestData
* but not inf the information param is in the funky part of a funky url
* @param String $dir directory to redirect to. If null $thisfunction (->() will be used.
*/
function redirectRequest($requestData, $information=null, $dir=null) {
if (is_array($requestData)) {
if ($information !== null)
$requestData["pntInfo"] = $information;
if ($dir==null) $dir = $this->();
$url = $this->();
$url .= $dir. 'index.php?';
$url .= $this->($requestData);
} else {
if ($information === null) {
$url = $requestData;
} else {
$url = Gen::stripQueryParam($requestData, 'pntInfo');
$url .= (strPos($url, '?') === false) ? '?' : '&';
$url .= "pntInfo=".$this->()->($information);
}
}
if (preg_match('/[\n\r]/', $url)) throw new PntError('Url with Cr or Lf');
header("Location: $url"); /* Redirect browser */
exit;
}
|