template_graph.php 1.08 KB
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2006 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
include("template_defs.php");

#
# 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($guid) ||
    strcmp($guid, "") == 0) {
    USERERROR("You must provide a Template ID.", 1);
}
if (!TBvalid_guid($guid)) {
    PAGEARGERROR("Invalid characters in GUID!");
}

#
# Get the data from the DB.
#
$query_result =
    DBQueryFatal("select image from experiment_template_graphs ".
		 "where parent_guid='$guid'");

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

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

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

#
# No Footer!
# 
?>