Jump to content

help with HTTP_REFERER


schwza

Recommended Posts

The main code below (searchimage.php) is supposed to read an image from a file, add a little text to it, and then print the image.  I'm not running it directly - I'm using it as the source in an image on another page.  The text I'm trying to add to it is the current url and the referring url. 

 

When I run this using my own webpages, everything works fine.  I have a super simple page called display.php (<img border="1" height="640" width="640" src="http://www.mapincluded.com/searchimage.php?key=parup">), and when I go to www.mapincluded.com/display.php I can see the image and it has printed over it the self page (/searchimage.php) and the referer page (http://www.mapincluded.com/display.php). 

 

The problem comes when I try to display an image in its intended destination, on the preview page for creating a new craigslist post.  For example, at https://post.craigslist.org/bos/H/fee/gbs/x/QG4UveF5CuQEBYd8/j09f6.  The home url displays fine (/searchimage.php), but the referer page is blank.  The body of the craigslist post is exactly the same as display.php, <img border="1" height="640" width="640" src="http://www.mapincluded.com/searchimage.php?key=parup">.  As an added complication, I can't have php in the body of the craigslist post.  I can have an image that uses php, but no direct php.  Incidentally, this does work on an actual craiglist page, just not on the preview of a craigslist page.

 

quick summary: I want to figure out how to get access HTTP_REFERER.  I can do it on my own page but not on a craigslist page.

 

////////////////////// searchimage.php  //////////////////////////
<?php
//PHP's GD class functions can create a variety of output image
//types, this example creates a jpeg.  I borrowed very heavily from this thread: http://www.webhostingtalk.com/showthread.php?threadid=308047 for writing text over an image.

//header("Content-Type: image/jpeg");  <- commented out - do I need this line?

//open up the image you want to put text over


$image = ImageCreateFromGif("startmap450x450.gif"); 

//The numbers are the RGB values of the color you want to use
$black = ImageColorAllocate($image, 0,0,0);

//The canvas's (0,0) position is the upper left corner
//So this is how far down and to the right the text should start

$start_x = 10;
$start_y = 20;
$output = "start is".$_SERVER['PHP_SELF']." ref is".getenv('HTTP_REFERER');
Imagettftext($image, 9, 0, $start_x, $start_y, $black, 'VAG Round.ttf', $output);

//Creates the jpeg image and sends it to the browser
//100 is the jpeg quality percentage

Imagejpeg($image, '', 100);

?>

Link to comment
https://forums.phpfreaks.com/topic/163636-help-with-http_referer/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.