<?php
################################
#Free to use under GNUv2.0
#Code: Phillip Ferland 10.22.2007
#Http://randomintervals.com
################################

$ver="v1.0.11";
echo "<title>Vistumbler to PNG Signal Graph $ver Beta - ---RanInt---</title>";

$ssid = $_GET['SSID'];
$mac = $_GET['Mac'];
$man = $_GET['Manuf'];
$auth = $_GET['Auth'];
$encry = $_GET['Encry'];
$radio = $_GET['radio'];
$chan = $_GET['Chn'];
$lat = $_GET['Lat'];
$long = $_GET['Long'];
$BTx = $_GET['BTx'];
$OTx = $_GET['OTx'];
$FA = $_GET['FA'];
$LU = $_GET['LU'];
$NT = $_GET['NT'];
$label = $_GET['Label'];
$sig = $_GET['Sig'];

$X = 20;
$signal = explode("-", $sig);
$count = count($signal);
#FIND OUT IF THE IMG NEEDS TO BE WIDER
if ( 900 < ($count*3))
{
    $Width=900;
    $Height=480;
    $wid=($count*3)+38;
}
else
{
    $wid=900;
    $Height=480;
}
$img = ImageCreateTrueColor($wid, $Height);
$bg = imagecolorallocate($img, 255, 255, 255);
$grid = imagecolorallocate($img,0,0,0);
$color = imagecolorallocate($img, 255, 0, 0);
$tcolor = imagecolorallocate($img, 0, 0, 255);
imagefill($img,0,0,$bg); #PUT HERE SO THAT THE TEXT DOESNT HAVE BLACK FILLINGS (eww)
imagestring($img, 4, 21, 3,  "SSID: ".$ssid."    Channel: ".$chan."    Radio: ".$radio."    Network: ".$NT."    OTx: ".$OTx, $tcolor); #SSID
imagestring($img, 4, 21, 23,  "Mac: ".$mac."    Auth: ".$auth." ".$encry."    BTx: ".$BTx."    Lat: ".$lat."    Long: ".$long, $tcolor); #MAC ADDRESS
imagestring($img, 4, 21, 43, "Manuf: ".$man."    Label: ".$label."    First: ".$FA."    Last: ".$LU, $tcolor); #LAST TIME ACTIVE

imagesetstyle($img, array($bg, $grid));
function imagegrid($image, $w, $h, $s, $color)
{
    for($iw=0; $iw<$w/$s; $iw++)
               {
               imageline($image, ($iw-0)*$s, 60, ($iw-0)*$s, $w, $color);
               }
    for($ih=0; $ih<$h/$s; $ih++)
               {
               imageline($image,  0, $ih*$s, $w, $ih*$s, $color);
               }
}
foreach($signal as $sig)
{
    imageline($img, $X ,459, $X, 459-($sig*4), $color);
    $X++;
    imageline($img, $X ,459, $X, 459-($sig*4), $color);
    $X=$X+2;
}
$date=date('mdyHis');

imagesetstyle($img,array($bg,$grid));
imagegrid($img,$wid,$Height,19.99,$grid);
Print "<img src=\"tmp/$date.png\"><br>";
ImagePNG($img, "tmp/".$date.".png");
Print "You can find your Wifi Graph here -> <a href=\"tmp/$date.png\">$date.png</a>";
ImageDestroy($img);
Print "<br><br><font size=\"1\">Please use Vistumbler to gather the data.<br>You can get it <a href=\"http://techidiots.net/project-pages/vistumbler/\" target=\"_blank\">here</a></font>";
?>