From af2408d59bbe5e59c6c6b3a8125e6b512a887663 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 27 Jan 2009 21:45:06 +0100 Subject: Work around IIS bug for redirects FS#1576 Ignore-this: 37b33f575e4c0b31e4af93185bf74f0f When IIS is running PHP in CGI mode it will not send cookie headers on 302 redirections. This is a known bug (KB176113). This patch will detect affected servers. Instead of a 302 redirect a Refresh: header is issued. This is supported by all known browsers should have the same effect as a real redirect. darcs-hash:20090127204506-7ad00-ce474f3b0db003e86e09d5e9a9bd7c96887ac01c.gz --- inc/common.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 606f107b7..817e416b0 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1454,4 +1454,25 @@ function is_mem_available($mem,$bytes=1048576){ return true; } +/** + * Send a HTTP redirect to the browser + * + * Works arround Microsoft IIS cookie sending bug. Exits the script. + * + * @link http://support.microsoft.com/kb/q176113/ + * @author Andreas Gohr + */ +function send_redirect($url){ + // check if running on IIS < 6 with CGI-PHP + if( isset($_SERVER['SERVER_SOFTWARE']) && isset($_SERVER['GATEWAY_INTERFACE']) && + (strpos($_SERVER['GATEWAY_INTERFACE'],'CGI') !== false) && + (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) && + $matches[1] < 6 ){ + header('Refresh: 0;url='.$url); + }else{ + header('Location: '.$url); + } + exit; +} + //Setup VIM: ex: et ts=2 enc=utf-8 : -- cgit v1.2.3