GD Time24
<?php
// print out time and date as png picture.
// to view source call with: gd_time24.php?viewsource=1
// call f.e. with: gd_time24.php?fs=4&trans=1&nd=1
// v0.12 20-Sep-2004, by G. Knauf <efash@gmx.net>
if ($_GET['viewsource']) {
echo highlight_string(file_get_contents($_SERVER['SCRIPT_FILENAME']));
die;
}
extension_loaded('gd') or die ("Error: GD extension not loaded!");
$lt = localtime ();
$time = sprintf ("%02d:%02d:%02d", $lt[2], $lt[1], $lt[0]);
$date = sprintf ("%04d-%02d-%02d", $lt[5] + 1900, $lt[4] + 1, $lt[3]);
if ($_GET['nd'])
$string = $time;
else
$string = $date . ' ' . $time;
$font = $_GET['fs'];
if ($font < 1 || $font > 5)
$font = 3;
$x = ImageFontWidth($font) * strlen($string);
$y = ImageFontHeight($font);
$im = @ImageCreate ($x, $y);
$bg_color = ImageColorAllocate ($im, 0, 0, 0);
$fg_color = ImageColorAllocate ($im, 255, 0, 210);
if ($_GET['trans'])
ImageColorTransparent($im, $bg_color);
ImageString($im, $font, 0, 0, $string, $fg_color);
Header("Content-type: image/png");
ImagePng($im);
ImageDestroy($im);
?>