note 108435 added to function.parse-str
| From: | BenjaminGarcia | Date: | Thu, 26 Apr 2012 09:18:13 +0000 |
| Subject: | note 108435 added to function.parse-str | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-187357@lists.php.net to get a copy of this message | ||
function like parse_str, but doesn't convert spaces and dots to underscores in $_GET AND $_POST
/**
* GET and POST input containing dots, etc.
*/
function getRealREQUEST() {
$vars = array();
$input = $_SERVER['REDIRECT_QUERY_STRING'];
if(!empty($input)){
$pairs = explode("&", $input);
foreach ($pairs as $pair) {
$nv = explode("=", $pair);
$name = urldecode($nv[0]);
$nameSanitize = preg_replace('/([^\[]*)\[.*$/','$1',$name);
$nameMatched = str_replace('.','_',$nameSanitize);
$nameMatched = str_replace(' ','_',$nameMatched);
$vars[$nameSanitize] = $_REQUEST[$nameMatched];
}
}
$input = file_get_contents("php://input");
if(!empty($input)){
$pairs = explode("&", $input);
foreach ($pairs as $pair) {
$nv = explode("=", $pair);
$name = urldecode($nv[0]);
$nameSanitize = preg_replace('/([^\[]*)\[.*$/','$1',$name);
$nameMatched = str_replace('.','_',$nameSanitize);
$nameMatched = str_replace(' ','_',$nameMatched);
$vars[$nameSanitize] = $_REQUEST[$nameMatched];
}
}
return $vars;
}
----
Server IP: 148.206.80.9
Probable Submitter: 189.247.124.69
----
Manual Page -- http://www.php.net/manual/en/function.parse-str.php
Edit -- https://master.php.net/note/edit/108435
Del: integrated -- https://master.php.net/note/delete/108435/integrated
Del: useless -- https://master.php.net/note/delete/108435/useless
Del: bad code -- https://master.php.net/note/delete/108435/bad+code
Del: spam -- https://master.php.net/note/delete/108435/spam
Del: non-english -- https://master.php.net/note/delete/108435/non-english
Del: in docs -- https://master.php.net/note/delete/108435/in+docs
Del: other reasons-- https://master.php.net/note/delete/108435
Reject -- https://master.php.net/note/reject/108435
Search -- https://master.php.net/manage/user-notes.php