note 56978 deleted from function.override-function by philip

From: Date: Thu, 03 Sep 2015 02:28:27 +0000
Subject: note 56978 deleted from function.override-function by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-203593@lists.php.net to get a copy of this message
Note Submitter: rojaro at gmail dot com ---- Since Apache 1 & 2 use diffrent methods (Unicode vs. UTF8) on Win32 platforms to encode urls, i've implemented the following workaround to get around this "bug" (which is actually known behaviour and wont get fixed). This workaround is really usefull when writing PHP scripts which have to work on all platforms (Windows, Linux, BSD etc.), must process URLs and must work under both Apache versions. <?php $httpd = explode(' ', $_SERVER['SERVER_SOFTWARE']); if(substr($httpd[0], 0, 6)=='Apache' && substr($httpd[0], 7, 1)==2 && $httpd[1]=='(Win32)') { if(isset($_SERVER['REQUEST_URI'])) $_SERVER['REQUEST_URI'] = str_replace('%2F', '/', rawurlencode(utf8_decode(rawurldecode($_SERVER['REQUEST_URI'])))); if(isset($_SERVER['REDIRECT_URL'])) $_SERVER['REDIRECT_URL'] = str_replace('%2F', '/', rawurlencode(utf8_decode(rawurldecode($_SERVER['REDIRECT_URL'])))); override_function('urlencode', '$url', 'return str_replace("%2F", "/", rawurlencode(utf8_encode($url)));'); } ?>

« previous php.notes (#203593) next »