What is a GD library?
Here is the latest
http://www.pic767flyingclub.com/767picfc.php?vatsim=810161
<?php
/-------------------------------------------
// Script by Fred Clausen (c)
// ba747heavy@charter.net
// Script is free for non-commercial use
// Script originally created for 767 PIC FC
//
// Removal of code and or modifictation
// of this script is strictly prohibited
//-----------------------------------------/
// Argument list:
// ?image_type=type <-- Specify the type of image, valid entries are 'jpg', 'png', 'gif'.
Please note that is for the input image name, ie the image that the dynamic image is
based on. The output image format is based on the next entry
// &output_type=type <-- Same arguments as image_type
// &vatsim=id <-- Your VATSIM ID
// Time to make sure that the server can do what we want it to do
// If this test fails, the whole schebang quits with no errors
if(function_exists("imagecreate"))
{
$error = false;
$img_dir_script = "";
$imgname_script = "";
$output_type_script = "";
$image_type_script = "";
$vatsim_script = "";
$im = "";
$green = imagecolorallocate($im, 97, 192, 102);
$img_dir_script = './images/';
$imgname_script = "statuspic767.png"; // Argument passed value for the image name
// Font dir
$font = "./font/handgotb.ttf";
if(isset($_GET['image_type']))
$image_type_script =$_GET['image_type']; // Argument passed value for the
input image type
else
$image_type_script = "png";
if(isset($_GET['output_type']))
$output_type_script = $_GET['output_type']; // Argument passed value for
the putput image type
else
$output_type_script = "png";
if(isset($_GET['vatsim'])) // Argument passed value for the users VATSIM ID
number
$vatsim_script = $_GET['vatsim'];
else
$vatsim = "0";
// Going to load the image into memory, and make sure that an error hadn't
already occured[removed error, will leave check for it]
if (!$error)
{
switch($image_type_script)
{
case 'png': // If the input type is a png
$im = @imagecreatefrompng
($img_dir_script.$imgname_script); / Attempt to open /
break;
case 'jpg': // If the input type is jpg
$im = @imagecreatefromjpeg
($img_dir_script.$imgname_script); / Attempt to open /
break;
case 'gif': // If the input type is gif
$im = @imagecreatefromgif
($img_dir_script.$imgname_script); / Attempt to open /
break;
}
}
// Test to see if the image loaded properly above, and or an error condidtion
existed
// If an error existed, create an image displaying an error
if (!$im || $error) / See if it failed /
{
$im = imagecreate (300, 75); / Create a blank image /
$bgc = imagecolorallocate ($im, 255, 255, 255);
$tc = imagecolorallocate ($im, 0, 0, 0);
imagefilledrectangle ($im, 0, 0, 300, 75, $bgc);
/ Output an errmsg /
imagestring ($im, 1, 5, 5, "Error: Image is not able to be loaded", $tc);
}
else
{
// output and format all the vatsim stuff, which will be stored in an
array
$output = get_vatsim_stuff();
// imagettftext($im, 12, 0, 0, 0, $green, $font, $output);
// Need to fix fonts...
// $font_here = imageloadfont($font);
$green = imagecolorallocate($im, 97, 192, 102);
#imagefttext($im, 10, 0, 0, 0, $green, $font, $output, array());
}
// Time to output the final result
switch($output_type_script)
{
case 'gif':
header("Content-type: image/gif");
imageGIF($im);
break;
case 'jpg':
header("Content-type: image/jpeg");
imageJPEG($im);
break;
case 'png':
header("Content-type: image/png");
imagePNG($im);
break;
}
imagedestory($im); // Remove the image from the server cache and clear up any
diskspace
}
function get_vatsim_stuff()
{
// read the vatsim data file into an array so I can parse it
$url = file("http://www.vatsim.net/data/satnet-data.txt");
// now we need to loop through the array and see if we
// have a match for the ID number
$clients = false;
$output_string = "";
foreach ($url as $line_num => $line) {
// See if we are in the clients section of the file
if(!clients)
if(chop($line) == "!CLIENTS:")
$clients = true;
else
// regex that creates a match to a 8 character callsign(way too
much I think)
// and also matches the UID # provided by the values being
passed.
if(preg_match("*{1,8}:$vatsim_script:", $line))
{
$array_vatsim = preg_split(":", $line);
// The string to output
$output_string = "Online " . $array_vatsim[0] . " " .
$array_vatsim[2];
}
}
if(!clients)
$output_string = "NOT ONLINE";
return $output_string;
}
?>