Get url of site that is hotlinking an image

Discussion in 'PHP' started by lbalance, Jul 18, 2007.

  1. #1
    How might I go about getting the URL of a website that is looking at an image?

    I want to make my own pagerank images but want it to pick up the site thats linking in instead of passing it as an argument.

    A good example would be iWebtools pagerank images. All you would do is place this code on your page and it picks up what URL its coming from:
    <a href="http://www.iwebtool.com/webmasters/pagerank_button/" target="_blank"><img alt="PageRank Button" src="http://www.iwebtool.com/images/pagerank_numimage.png" border="0"></a>
    Code (markup):
    So far I have a PHP script that gets me the number, then I convert it to an image with PHP. Then I have an .htaccess entry to allow me to link to an image, when in fact its redirected to the PHP file.

    I've tried HTTP_REFERER and other $_SERVER settings but nothing worked.

    Suggestions?
     
    lbalance, Jul 18, 2007 IP
  2. jmhyer123

    jmhyer123 Peon

    Messages:
    542
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Why don't you use GD library to dynamically generate the image that it's linked to and that way you could use the script to store the site that's linking to it in a text file or DB.

    Also it wouldn't be the referer, it would be either $REMOTE_ADDR or $REMOTE_HOST or somethign along those lines...
     
    jmhyer123, Jul 18, 2007 IP
  3. lbalance

    lbalance Peon

    Messages:
    381
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #3
    im using the PHP script to dynamically create the image. after getting the pagerank number, i pass it to the PHP script for making images, starting with
    header("Content-type: image/gif");
     
    lbalance, Jul 18, 2007 IP
  4. lbalance

    lbalance Peon

    Messages:
    381
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #4
    upon further testing, http_referer is the answer.

    i had a syntax error somewhere else.
     
    lbalance, Jul 18, 2007 IP