 <?php
header("Content-type: text/html");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Random Date in Past
header("Cache-Control: no-cache");
header("Pragma: no-cache");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Hotlinked Image</title>
    <meta name="description" content="A page to display an image as it was directly linked to by an external site." />
</head>
<body>
<h1>Requested Image</h1>
<?php
if(!isset($_GET["src"]) || empty($_GET["src"])) {
    echo "<p>No image was linked, perhaps you've just navigated to this page on your own?</p>";
}
else {
    echo "<p>As you clicked on a <i>direct</i> link to this image from an external site, this page has been shown. The image you're after is shown below. You may click on it to fully display just the image. You may have to press <i>F5</i> to refresh it once you've clicked on the link.</p>";
    $temp = getimagesize($_SERVER["DOCUMENT_ROOT"] . "/" . strip_tags($_GET["src"]));
    $desiredWidth = 600;
    if($temp[0] > $desiredWidth) {
        $width = $desiredWidth;
        $height = $temp[1] * ($desiredWidth/$temp[0]);
    }
    else {
        $width = $temp[0];
        $height = $temp[1];
    }
    echo "<p><a href=\"/" . strip_tags($_GET["src"]) . "\" title=\"Requested Image\"><img src=\"/" . strip_tags($_GET["src"]) . "\" alt=\"Requested Image\" width=\"" . $width . "\" height=\"" . $height . "\" /></a></p>";
    unset($temp,$desiredWidth,$width,$height);
}
?>
</body>
</html>
