<?PHP
Header ("Content-type: image/jpeg");
// Create either from JPG or draw the face
$Image = $HTTP_GET_VARS["img"];
$im = "";
// ADJUST the textures directory here !!!
if (! empty ($Image))
$im = ImageCreateFromJPEG ($DOCUMENT_ROOT."/textures/".$Image.".jpg");
if ($im == "")
{
$im = ImageCreate (512,256);
$UseImage = false;
}
else
$UseImage = true;
$VrDiff = intval ($HTTP_GET_VARS["vr"]);
$Roman = ($HTTP_GET_VARS["typ"] & 0x01) == 0x01;
$cNumber = MyImageColor ($im, 0xd0, 0x10, 0x10, $HTTP_GET_VARS["nc"]);
if (! $UseImage)
{
$cClock = MyImageColor ($im, 0xff, 0xff, 0xE0, $HTTP_GET_VARS["cc"]);
ImageFill ($im, 1, 1, $cClock);
}
$sTime = (gmstrftime ("%H")-2+$VrDiff) % 24; // VRT24
$mTime = intval(gmstrftime ("%M"));
$sTime += $mTime / 60;
$sy= ImageSY ($im);
$sx= ImageSX ($im);
if ($Roman)
{
$aRoman = array (' ','I','II','III','IV','V','VI','VII','VIII','IX','X'
,'XI','XII','XII','XIII','XV','XVI','XVII','XVIII','XIX','XX'
,'XXI','XXII','XXIII','XIV');
$tsize = $sy/4+7;
$offy = $tsize*1.9;
$offx = $sx/35;
$text = sprintf ("%s:%s", $aRoman[$sTime], $aRoman[$mTime]);
}
else
{
$tsize = $sx/4;
$offy = $sy/1.3;
$offx = $sx/20-20;
$text = sprintf ("%02d:%02d", $sTime, $mTime);
}
$font = $HTTP_GET_VARS["fnt"];
if (empty ($font))
$font = "verdana";
// ADJUST the font directory here !!!
ImageTTFText ($im, $tsize, 0, $offx, $offy, $cnumber, $DOCUMENT_ROOT."/fonts/".$font.".ttf", $text);
ImageJPEG ($im, "", 90);
ImageDestroy ($im);
// END MAIN =============
function MyImageColor ($im, $r, $g, $b, $hex="")
{
if (!empty ($hex))
{
$r = hexdec (substr ($hex, 0, 2));
$g = hexdec (substr ($hex, 2, 2));
$b = hexdec (substr ($hex, 4, 2));
}
ImageColorAllocate ($im, $r, $g, $b);
return (ImageColorClosest ($im, $r, $g, $b));
}
?>