FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Old version trouble with $_SERVER variables?
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Old version trouble with $_SERVER variables? [message #179825] Mon, 10 December 2012 19:05 Go to next message
C is currently offline  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 #179826 is a reply to message #179825] Mon, 10 December 2012 20:37 Go to previous messageGo to next message
Salvatore is currently offline  Salvatore
Messages: 38
Registered: September 2012
Karma: 0
Member
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.

--
Blah blah bleh...
GCS/CM d(-)@>-- s+:- !a C++$ UBL++++$ L+$ W+++$ w M++ Y++ b++
Re: Old version trouble with $_SERVER variables? [message #179827 is a reply to message #179825] Mon, 10 December 2012 20:55 Go to previous messageGo to next message
M. Strobel is currently offline  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 Go to previous messageGo to next message
The Natural Philosoph is currently offline  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 Go to previous message
Gregor Kofler is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Simple expression parser for PHP.
Next Topic: test,ignore
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 05:05:19 GMT 2024

Total time taken to generate the page: 0.02184 seconds