note 72150 modified in function.getenv by danbrown
| From: | danbrown@php.net | Date: | Sun, 20 Jul 2008 00:16:01 +0000 |
| Subject: | note 72150 modified in function.getenv by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-141829@lists.php.net to get a copy of this message | ||
You need also to know that $_SERVER['SERVER_NAME'] and surely
$_SERVER['PHP_SELF'] are fakeable by sending wrong HTTP headers (hint: "Host:"
will become SERVER_NAME in your PHP scripts). For PHP_SELF you may want to use SCRIPT_NAME instead.
[EDIT by danbrown AT php DOT net: Just keep in mind, PHP_SELF and SCRIPT_NAME are not the exact same
variable, and may differ depending on server and site configuration.]
You may want to use this little code to continue using PHP_SELF:
$_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME']; $PHP_SELF =
$_SERVER['PHP_SELF']
The last one is for people who cannot switch "register_global" off.
There is now "secure" replacement for SERVER_NAME available. Sometimes SERVER_ADDR (which
not fakeable) might be handy but in some situations not. If you need a valid entry in SERVER_NAME
validate it with a regular expressions. See regexlib.com for such expressions.
--was--
You need also to know that $_SERVER['SERVER_NAME'] and surely
$_SERVER['PHP_SELF'] are fakeable by sending wrong HTTP headers (hint: "Host:"
will become SERVER_NAME in your PHP scripts). For PHP_SELF you may want to use SCRIPT_NAME instead.
You may want to use this little code to continue using PHP_SELF:
$_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME']; $PHP_SELF =
$_SERVER['PHP_SELF']
The last one is for people who cannot switch "register_global" off.
There is now "secure" replacement for SERVER_NAME available. Sometimes SERVER_ADDR (which
not fakeable) might be handy but in some situations not. If you need a valid entry in SERVER_NAME
validate it with a regular expressions. See regexlib.com for such expressions.
http://php.net/manual/en/function.getenv.php