echo "Your browser sent a request that could not be understood.";
    exit;
}
if (!isset($_REQUEST['size']) || empty($_REQUEST['size'])) {
    $width = null;
} else {
    $width = $_REQUEST['size'];
}
if (file_exists("var/tokn/" . $_REQUEST['token'])) {
    $token = new ToknFile($_REQUEST['token']);
    if (file_exists("var/stor/" . $token->getReference())) {
        $stor = new Stor(new StorFromFile("var/stor/" . $token->getReference()));
        $thumbnail = new Thumbnail($stor, $width);
        header("Content-Disposition: inline");
        header("Content-Type: " . $stor->getType());
        header("Content-Length: " . $thumbnail->size());
        set_time_limit(0);
        print $thumbnail->raw();
        exit;
    } else {
        header("HTTP/1.1 410 Gone");
        echo "<span style=\"color: red; font-weight: bold; font-size: 24pt;\">410 Gone</span><br />";
        echo "<br />";
        echo "The requested URL is no longer available on this server.";
        exit;
    }
} else {
    header("HTTP/1.1 404 Not Found");
    echo "<span style=\"color: red; font-weight: bold; font-size: 24pt;\">404 Not Found</span><br />";
    echo "<br />";
    echo "The requested URL was not found on the server.";