Old version trouble with $_SERVER variables? [message #179825] |
Mon, 10 December 2012 19:05 |
C
Messages: 24 Registered: January 2012
Karma: 0
|
Junior Member |
|
|
What is causing the $host, $realhost and $referer variables to be
blank?
<?php
global $host;
$date = date("F jS Y, h:iA");
$host=@gethostbyaddr($_SERVER['REMOTE_ADDR']);
if ($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"] != "")
{$realhost =
@gethostbyaddr($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"]);}
$referer = $_SERVER['$HTTP_REFERER'];
mail("my.address@whatever", "visitor information", "$host at $date
from
$referer.
Forwarded for $realhost");
?>
|
|
|
|
Re: Old version trouble with $_SERVER variables? [message #179827 is a reply to message #179825] |
Mon, 10 December 2012 20:55 |
M. Strobel
Messages: 386 Registered: December 2011
Karma: 0
|
Senior Member |
|
|
Am 10.12.2012 20:05, schrieb C:
> What is causing the $host, $realhost and $referer variables to be
> blank?
>
> <?php
>
> global $host;
>
> $date = date("F jS Y, h:iA");
>
> $host=@gethostbyaddr($_SERVER['REMOTE_ADDR']);
You should not suppress error messages when you are trying to find an error.
/Str.
|
|
|
Re: Old version trouble with $_SERVER variables? [message #179828 is a reply to message #179826] |
Mon, 10 December 2012 21:03 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 10/12/12 20:37, Salvatore wrote:
> On 2012-12-10, C <wrong(dot)address(dot)1(at)gmail(dot)com> wrote:
>> What is causing the $host, $realhost and $referer variables to be
>> blank?
>
> It's possible that the gethostbyaddr() function is failing and no referrer
> is sent.
>
If it is happening across all browsers its more likely that the web
server is failing to invoke PHP with the correct arguments set so that
COULD be a server configuration problem.
I don't know how the linkage is achieved though, so that's the limit of
my Thought.
--
Ineptocracy
(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
|
|
|
Re: Old version trouble with $_SERVER variables? [message #179829 is a reply to message #179825] |
Mon, 10 December 2012 23:41 |
Gregor Kofler
Messages: 69 Registered: September 2010
Karma: 0
|
Member |
|
|
Am 2012-12-10 20:05, C meinte:
> What is causing the $host, $realhost and $referer variables to be
> blank?
>
> <?php
>
> global $host;
>
> $date = date("F jS Y, h:iA");
>
> $host=@gethostbyaddr($_SERVER['REMOTE_ADDR']);
>
> if ($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"] != "")
> {$realhost =
> @gethostbyaddr($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"]);}
$HTTP_SERVER_VARS has been deprecated since ages.
> $referer = $_SERVER['$HTTP_REFERER'];
Shouldn't that be $_SERVER['HTTP_REFERER']?
If gethostbyaddr() was coded with the same rigor, it's highly plausible
that the other variables are "empty", too. Which they aren't. Turn on
your error reporting and fix your bugs.
Gregor
|
|
|