Jump to content

Gd Images - Requesting Page's Url


clonetrooper9494
 Share

Recommended Posts

I have an image counter service, and to stop people from stealing users counters(putting the on their pages) I need to check what the requesting pages URL is. So if someones counter is counter.php, and somebody puts this on somepage.html "<img src='counter.php'>", how can I get the value 'somepage.html' to check if it's not some other page like robber.html?Is there any way using PHP to check what page the counter is being requested by?

Link to comment
Share on other sites

There are several ways to do this. Most approaches would check one of the Predefined variables available from the $_SERVER array.http://ca.php.net/manual/en/reserved.variables.server.php*edit*You can use the following php code to print out the $_SERVER array

// array_debug - print out a formatted list of an arrayfunction array_debug($array_name) { 		  echo '<pre>'; 		  ksort($array_name); 		  print_r($array_name); 		  echo '</pre>'; 		} // end func

Link to comment
Share on other sites

It took some work, but I finally got it. Your code doesn't work cuz the page wasn an image. I ended up saying

imagestring($im, 1, 0, 0, print_r($_SERVER,TRUE), $text_color);

with an image 2700 px wide, and it worked! the $_SERVER variable is 'HTTP_REFERER' (or 'http_referer')I looked up 'HTTP_REFERER' at PHP.net and found this...

'HTTP_REFERER'The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
'HTTP_REFERER' will work, but I will have to test it on different browsers though.Thanks for your help jlhaslip!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...