showthumb.php3 981 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");

#
# This script generates the contents of an image. No headers or footers,
# just spit back an image. The thumbs are public, so no checking is done.
# To obfuscate, do not use pid/eid, but rather use the resource index. 
#

#
# Verify page arguments.
# 
if (!isset($idx) ||
    strcmp($idx, "") == 0) {
    USERERROR("You must provide an ID.", 1);
}

#
# Get the thumb from the DB. 
#
$query_result =
    DBQueryFatal("select thumbnail from experiment_resources ".
		 "where idx='$idx'");
29 30 31 32 33 34 35 36 37 38

if ($query_result && mysql_num_rows($query_result)) {
    $row  = mysql_fetch_array($query_result);
    $data = $row[thumbnail];

    if (strlen($data)) {
	header("Content-type: image/png");
	echo "$data";
	return;
    }
39
}
40 41 42 43

# No Data. Spit back a stub image.
header("Content-type: image/gif");
readfile("coming-soon-thumb.gif");
44 45 46 47 48

#
# No Footer!
# 
?>