note 16111 added to language.variables.external
| From: | ari dot kuorikoski at finebyte dot com | Date: | Tue, 16 Oct 2001 20:07:56 +0000 |
| Subject: | note 16111 added to language.variables.external | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-19010@lists.php.net to get a copy of this message | ||
I realized that many of PHP projects shared in the web are written track_vars set off and in my
configuration I allways turn them on. So here is a little script that switches the $HTTP_POST_VARS,
$HTTP_GET_VARS and $HTTP_POST_FILES to a form that they would be used when track_vars was set off:
<?php
/* Ari Kuorikoski
ari.kuorikoski@finebyte.com
http://www.finebyte.com
*/
/*==================================================
Transform $HTTP_GET_VARS["index"] = "value"
to $index = "value"
==================================================*/
if (!empty($HTTP_POST_VARS)) {
while (list($key, $value) = each ($HTTP_POST_VARS)) {
$a = $key;
$$a = $value;
}
}
/*==================================================
Transform $HTTP_GET_VARS["index"] = "value"
to $index = "value"
==================================================*/
if (!empty($HTTP_GET_VARS)) {
while (list($key, $value) = each ($HTTP_GET_VARS)) {
$a = $key;
$$a = $value;
}
}
/*==================================================
Transform $HTTP_SESSION_VARS["index"] = "value"
to $index = "value"
==================================================*/
if (!empty($HTTP_SESSION_VARS)) {
while (list($key, $value) = each ($HTTP_SESSION_VARS)) {
$a = $key;
$$a = $value;
}
}
/*==================================================
Transform $HTTP_POST_FILES["index"]["index2"] = "value"
to $index_index2 = "value"
==================================================*/
if (!empty($HTTP_POST_FILES)) {
while (list($key, $value) = each ($HTTP_POST_FILES)) {
if (!is_array($value)){
$a = $key;
$$a = $value;
}
else {
while (list ($aKey, $aValue) = each($value)) {
if ($aKey != 'tmp_name') {
$b = $key ."_".$aKey;
$$b = $aValue;
}
else {
// temporary filename
$b = $key;
$$b = $aValue;
}
}
}
}
}
/*==================================================
Transform $HTTP_SESSION_VARS["index"] = "value"
to $index = "value"
==================================================*/
if (!empty($HTTP_SESSION_VARS)) {
while (list($key, $value) = each ($HTTP_SESSION_VARS)) {
$a = $key;
$$a = $value;
}
}
/*==================================================
Transform $HTTP_ENV_VARS["index"] = "value"
to $index = "value"
==================================================*/
if (!empty($HTTP_ENV_VARS)) {
while (list($key, $value) = each ($HTTP_ENV_VARS)) {
$a = $key;
$$a = $value;
}
}
/*==================================================
Transform $HTTP_COOKIE_VARS["index"] = "value"
to $index = "value"
==================================================*/
if (!empty($HTTP_COOKIE_VARS)) {
while (list($key, $value) = each ($HTTP_COOKIE_VARS)) {
$a = $key;
$$a = $value;
}
}
/*==================================================
Transform $HTTP_SERVER_VARS["index"] = "value"
to $index = "value"
==================================================*/
if (!empty($HTTP_SERVER_VARS)) {
while (list($key, $value) = each ($HTTP_SERVER_VARS)) {
$a = $key;
$$a = $value;
}
}
?>
--
http://www.php.net/manual/en/language.variables.external.php
http://master.php.net/manage/user-notes.php?action=edit+16111
http://master.php.net/manage/user-notes.php?action=delete+16111
http://master.php.net/manage/user-notes.php?action=reject+16111