Category Archives: bbcode

Automatically get URL of a site displaying my image?

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.

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.

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.

This is what I have tried. First the img tag in the other site in BBCode:


And in my site this script in PHP, although any language that does the work would be good for me:

// 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);

// Eventually display the image
header('Content-Type: image/png');
readfile($filename . '.png');

So my questions are:

  1. Is it possible to get full URL of a site that is displaying my image?
  2. If not, is there any other method to get the full URL?

Thank you in advance.

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.