Quote:
Originally Posted by lenwhistler
I posted a similar question last week. Instead of:
$HTTP_SERVER_VARS['HTTP_REFERER'];
Use:
$_SERVER['HTTP_REFERER'];
|
That is what I am using. Here's my code:
$ip = $_SERVER['REMOTE_ADDR'];
$method = $_SERVER['REQUEST_METHOD'];
$uri_stem = $_SERVER['SCRIPT_NAME'];
$uri_query = $_SERVER['QUERY_STRING'];
$status = "200";
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$cookie = $_SERVER['HTTP_COOKIE'];
if(isset($_SERVER['HTTP_REFERER']))
{$referer = $_SERVER['HTTP_REFERER'];}
else
{$referer = "";}
$host = $_SERVER['HTTP_HOST'];
$accept = $_SERVER['HTTP_ACCEPT'];
$insert = "INSERT INTO stats".
"(ip, method, uri_stem, uri_query, status, user_agent, cookie, referer, host, accept, added)".
" VALUES ('".$ip."', ".
"'".$method."', ".
"'".$uri_stem."', ".
"'".$uri_query."', ".
"200, ".
"'".$user_agent."', ".
"'".$cookie."', ".
"'".$referer."', ".
"'".$host."', ".
"'".$accept."', ".
"NOW())";
echo $insert;
echo "<br>".$referer;
On my development server (localhost), this is what is echoed out to the client:
insert: INSERT INTO stats(ip, method, uri_stem, uri_query, status, user_agent, cookie, referer, host, accept, added) VALUES ('127.0.0.1', 'GET', '/wonderyears/servervar.php', '', 200, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)', '', 'http://localhost/wonderyears/calendar.php', 'localhost', '*/*', NOW())
referrer:
http://localhost/wonderyears/calendar.php
On the production server, this is what is echoed out back to the client:
insert: INSERT INTO stats(ip, method, uri_stem, uri_query, status, user_agent, cookie, referer, host, accept, added) VALUES ('66.214.143.224', 'GET', '/servervar.php', '', 200, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)', '', '', 'mywonderyears.org', 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*', NOW())
referrer:
Notice that referrer has a value on the development server, and is blank on the production server.