Jump to content

Why Would "$_SERVER['REQUEST_URI']" Come up Empty Or Null?


inVINCEable

Recommended Posts

I am checking referrers on a particular site, let's say domain.com/campaigns/2/ is where I am pointing them to. In there I have an index.php file that records the referrer as well as the request URL. Sometimes it is recorded correctly, such as "/campaigns/2/" and other times it comes up null. Either way they are hitting the file there, so what is the explanation as to why it would come up null?

 

Thanks!

 

 

Link to comment
Share on other sites

Sorry, I didn't mean to say it is a DB insert, it just logs the info in a file. Here is the info:

 

 

Here is the php:

 

 

 

 

 

<?php 
//lets log visitor information

$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
$request_method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '';
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
$remote_host = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : '';
$remote_port = isset($_SERVER['REMOTE_PORT']) ? $_SERVER['REMOTE_PORT'] : '';
$request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
$agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';

if(file_exists("info.txt")){ 
$file = fopen("info.txt", "a"); 
$info = "Referer: " . $referer . "\n\n"; 
$info .= "Query: " . $query . "\n\n"; 
$info .= "Request Method: " . $request_method . "\n\n"; 
$info .= "Host: " . $host . "\n\n"; 
$info .= "IP: " . $ip . "\n\n"; 
$info .= "Remote Host: " . $remote_host . "\n\n"; 
$info .= "Remote Port: " . $remote_port . "\n\n"; 
$info .= "Request URL: " . $request_uri . "\n\n"; 
$info .= "Agent: " . $agent . "\n\n"; 
$info .= "-----------------------------------------"; 
fwrite($file, $info); 
} 
else
{
$file = fopen("info.txt", "w"); 
$info = "Referer: " . $referer . "\n\n"; 
$info .= "Query: " . $query . "\n\n"; 
$info .= "Request Method: " . $request_method . "\n\n"; 
$info .= "Host: " . $host . "\n\n"; 
$info .= "IP: " . $ip . "\n\n"; 
$info .= "Remote Host: " . $remote_host . "\n\n"; 
$info .= "Remote Port: " . $remote_port . "\n\n"; 
$info .= "Request URL: " . $request_url . "\n\n"; 
$info .= "Agent: " . $agent . "\n\n"; 
$info .= "-----------------------------------------"; 
fwrite($file, $info); 
}

?>

 

 

And here is the HTML file in its entirety:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Get My Email Guide</title>
</head>

<body>




<?php 
//lets log visitor information

$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
$request_method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '';
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
$remote_host = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : '';
$remote_port = isset($_SERVER['REMOTE_PORT']) ? $_SERVER['REMOTE_PORT'] : '';
$request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
$agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';

if(file_exists("info.txt")){ 
$file = fopen("info.txt", "a"); 
$info = "Referer: " . $referer . "\n\n"; 
$info .= "Query: " . $query . "\n\n"; 
$info .= "Request Method: " . $request_method . "\n\n"; 
$info .= "Host: " . $host . "\n\n"; 
$info .= "IP: " . $ip . "\n\n"; 
$info .= "Remote Host: " . $remote_host . "\n\n"; 
$info .= "Remote Port: " . $remote_port . "\n\n"; 
$info .= "Request URL: " . $request_uri . "\n\n"; 
$info .= "Agent: " . $agent . "\n\n"; 
$info .= "-----------------------------------------"; 
fwrite($file, $info); 
} 
else
{
$file = fopen("info.txt", "w"); 
$info = "Referer: " . $referer . "\n\n"; 
$info .= "Query: " . $query . "\n\n"; 
$info .= "Request Method: " . $request_method . "\n\n"; 
$info .= "Host: " . $host . "\n\n"; 
$info .= "IP: " . $ip . "\n\n"; 
$info .= "Remote Host: " . $remote_host . "\n\n"; 
$info .= "Remote Port: " . $remote_port . "\n\n"; 
$info .= "Request URL: " . $request_url . "\n\n"; 
$info .= "Agent: " . $agent . "\n\n"; 
$info .= "-----------------------------------------"; 
fwrite($file, $info); 
}

?>






<center>*Are You Looking to Go Ahead and Get My Email Guide? </center>

<br />


<br />

<br />

<center>
<ul>
<li>Make Thousands Monthly</li>
<li>Do All Kinds of Things You Couldn't Before</li>

<li>Get Whatever Car You Want!</li>

<li>If you said yes then click the link below!</li>
</ul>
</center>


<center>
<a href="http://www.tracklead.net/click.track?CID=107578&AFID=112392&ADID=241750&SID=fb">
Rags to Riches Story Here!
</a>
</center>



</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.