dsaba Posted June 1, 2008 Share Posted June 1, 2008 Many of you may be familiar with the free statistics websites out there that will let you place a small image on your webpage or a small piece of javascript code that outputs an image..etc.. It will then collect stats about your site..etc.. Well, what stumps me is how this javascript or php dynamic image is able to pickup referer information. I've tried making a dynamic php image that spits out referer information, but it will only spit out the last page from where it was loaded which is of course the current page and not the "referer referer" if you know what I'm getting at... How can I get this referer info with javascript or php dynamic image? Here's an example of a php dynamic image that I can't get around this problem: As you can see it tells you that the referer is the page from which is was loaded at which is this very thread. Here's the code I used: <?php $ref = trim(@$_SERVER['HTTP_REFERER']); if (empty($ref)) { $ref = 'no referer'; } $im = imagecreatetruecolor(round(strlen($ref)*6.5), 30); $white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 0, 0, 0); imagefill($im, 0, 0, $white); //fill image with white imagecolortransparent($im, $white); //make white color transparent imagestring($im, 2, 5, 5, $ref, $black); //write string in black color //display image header("Content-Type: image/gif"); imagegif($im); imagedestroy($im); ?> Thanks for looking. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.