From: skodak Date: Tue, 1 Aug 2006 18:02:42 +0000 (+0000) Subject: improved redirect() - faster and more standards compliant X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9e72ebd6782398505a7c51695ecf8166cb703279;p=moodle.git improved redirect() - faster and more standards compliant --- diff --git a/lib/weblib.php b/lib/weblib.php index 0d4fb1bca5..c248e74166 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -4301,12 +4301,17 @@ function redirect($url, $message='', $delay='0') { $encodedurl = htmlentities($url); $tmpstr = clean_text(''); //clean encoded URL $encodedurl = substr($tmpstr, 9, strlen($tmpstr)-13); - $url = addslashes(html_entity_decode($encodedurl)); + $url = html_entity_decode($encodedurl); + $surl = addslashes($url); /// when no message and header printed yet, try to redirect if (empty($message) and !defined('HEADER_PRINTED')) { + //try header redirection first + @header('HTTP/1.x 303 See Other'); //302 might not work for POST requests, 303 is ignored by obsolete clients + @header('Location: '.$url); + //another way for older browsers and already sent headers (eg trailing whitespace in config.php) echo ''; - echo ''; // To cope with Mozilla bug + echo ''; // To cope with Mozilla bug die; } @@ -4326,7 +4331,7 @@ function redirect($url, $message='', $delay='0') {