title: Automatically get URL of a site displaying my image?
body: <p>I've been trying to get the URL (including GET parameters) of a site that is displaying my image. This is because I want to extract one parameter of the URL.</p>
  
  <p>A friend told me that she knew someone that could achieve this, but I don't know if he was doing it with an image. Also I don't think I can do it with a link because when going to external sites it will appear a warning page saying that you're being redirected outside, so if I put a link to my page and someone clicks, I will get the referrer URL of redirection warning page. I can't assure if my friend was telling the truth about this, but it's very likely that it was true.</p>
  
  <p>All I could get with the image was the IP and other things of the HTTP header, but the referrer part is empty and I thought that the referrer contained the full URL I'm talking about.</p>
  
  <p>This is what I have tried.
  First the img tag in the other site in BBCode:</p>
  
  <pre><code>[img]http://______.com/get_image.php?i=myimage[/img]
  </code></pre>
  
  <p>And in my site this script in PHP, although any language that does the work would be good for me:</p>
  
  <pre><code>&lt;?php
  // Get name of image to be displayed (non-sanitized here for simplicity)
  $filename = $_GET["i"];
  
  // Here I want to get the site where image is being viewed
  if (!empty($_SERVER['HTTP_REFERER'])) {
          $visitor_url = $_SERVER['HTTP_REFERER'];
  } else {
          $visitor_url = "none";
  }
  
  // And write the referrer to a file just to test if it works
  $fp = fopen('referer.txt', 'w');
  fwrite($fp, $visitor_url);
  fclose($fp);
  
  // Eventually display the image
  header('Content-Type: image/png');
  readfile($filename . '.png');
  ?&gt;
  </code></pre>
  
  <p>So my questions are:</p>
  
  <ol>
  <li>Is it possible to get full URL of a site that is displaying my image?</li>
  <li>If not, is there any other method to get the full URL?</li>
  </ol>
  
  <p>Thank you in advance.</p>
  
  <p>Note: I don't have any permision in the other site where I'm posting the image, I'm just an user there. Please tell me if I'm missing something or I have to ask this in another way, I'm new to StackOverflow.</p>