note 107036 deleted from reserved.variables.get by danbrown

From: Date: Tue, 03 Jan 2012 21:48:34 +0000
Subject: note 107036 deleted from reserved.variables.get by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-185289@lists.php.net to get a copy of this message
Note Submitter: tic at tac dot com ---- I think the php_fix_raw_query code posted above has an error when updating the Global variables. I think it should be like this instead <?php function php_fix_raw_query() { $post = ''; // Try globals array if (!$post && isset($_GLOBALS) && isset($_GLOBALS["HTTP_RAW_POST_DATA"])) $post = $_GLOBALS["HTTP_RAW_POST_DATA"]; // Try globals variable if (!$post && isset($HTTP_RAW_POST_DATA)) $post = $HTTP_RAW_POST_DATA; // Try stream if (!$post) { if (!function_exists('file_get_contents')) { $fp = fopen("php://input", "r"); if ($fp) { $post = ''; while (!feof($fp)) $post = fread($fp, 1024); fclose($fp); } } else { $post = "" . file_get_contents("php://input"); } } $raw = !empty($_SERVER['QUERY_STRING']) ? sprintf('%s&%s', $_SERVER['QUERY_STRING'], $post) : $post; $arr = array(); $pairs = explode('&', $raw); foreach ($pairs as $i) { if (!empty($i)) { list($name, $value) = explode('=', $i, 2); if (isset($arr[$name]) ) { if (is_array($arr[$name]) ) { $arr[$name][] = $value; } else { $arr[$name] = array($arr[$name], $value); } } else { $arr[$name] = $value; } } } foreach ( $_POST as $key => $value ) { if (is_array($arr[$key]) ) { $_POST[$key] = $arr[$key]; $_REQUEST[$key] = $arr[$key]; } } foreach ( $_GET as $key => $value ) { if (is_array($arr[$key]) ) { $_GET[$key] = $arr[$key]; $_REQUEST[$key] = $arr[$key]; } } # optionally return result array return $arr; } ?>

« previous php.notes (#185289) next »