$value) { $clean[$key] = $value; } //explode the vars delimited by tilde $clean = explode('~', $cleanGet["mapId"]); //Pull in variables $mapId = $clean["0"]; $call = $clean["1"]; //Get DB data $db1 = GetMapCodeLVL1($mapId); //--------------DO LEVEL ONE LOOKUP------------------// if ($db1["DoCallLookup"] != "1") { if ($db1["MapCode"] != "") { //evaluate if the code is remapped to another code $db2 = GetMapCodeLVL1($db1["MapCode"]); //get the mapped map code $output = $db2["Content"]; //get the remapped content } elseif ($db1["Content"] != "") { $output = outputStringCleaner($db1["Content"]); //output the static content } else { //no map code (db validity) header('Location: reference.php'); //no content, redirect to reference.php(error page) } } //--------------DO LEVEL TWO LOOKUP------------------// else { $db2 = GetMapCodeLVL2($mapId, LCCallToNumber($call), LCCallToNumber($call)); //get the call number overlay map $mapTemplate = $db2["Library"] . $db2["Floor"]; //Get the name of the map template if ($mapTemplate != "") { //ERROR HANDLING: Check for a null template (DB validity) //do the image merge function $output = displayOverlayImage($mapTemplate, $db2["X"], $db2["Y"], $db2["Width"], $db2["Height"]); //set the image var for output $output = ''; } } //##################### Functions ############################# function GetMapCodeLVL1($MapId) { // Collects data from "mapsCall" table $query = "SELECT * FROM maps WHERE Code = '"; $query .= $MapId; $query .= "'"; // puts into the $info array $info = GetMySQLData($query); return $info; } function GetMapCodeLVL2($MapId, $call) { // Collects data from "mapsCall" table $query = "SELECT * FROM mapscall WHERE mapId = '"; $query .= $MapId; $query .= "' AND Start <='"; $query .= $call; $query .= "' AND End >='"; $query .= $call . "'"; // puts into the $info array $info = GetMySQLData($query); return $info; } //Gets or creates the call number map image function displayOverlayImage($mapTemplate, $dst_x, $dst_y, $src_w, $src_h) { // Create image instances $img = 'maps/templates/'.$mapTemplate.'.gif'; //template $imgOutput = 'maps/' . $mapTemplate.$dst_x.$dst_y.$src_w.$src_h . '.gif'; //merged file //Check for a cached file if (file_exists($imgOutput)) { return $imgOutput; } else { //Create the image memory streams $dest = imagecreatefromgif($img); //get the template image $src = imagecreatefromgif('maps/templates/overlay.gif'); //get the overlay //merge the images imagecopymerge($dest, $src, $dst_x, $dst_y, 0, 0, $src_w, $src_h, 90); // Output and free from memory $image = imagegif($dest,$imgOutput); imagedestroy($dest) or die (‘failed imageDestroy(1)’); imagedestroy($src) or die (‘failed imageDestroy(2)’); return $imgOutput; } } //##################### Display Code ############################# ob_start("callback"); ?>