<?php
error_reporting( E_ERROR );
//error_reporting( E_ALL );
// load configuration
$config = parse_ini_file("config.ini", true);
$sysconfig = $config['System'];
// include path for zend framework
if ($sysconfig['zendfw_path'] != "") {
set_include_path(get_include_path() . PATH_SEPARATOR . $sysconfig['zendfw_path']);
}
// set locale for date/time formatting
$loc = setlocale(LC_ALL, 'de_DE.UTF8', 'de_DE', 'de', 'ge');
// includes
require_once 'library/tools.php';
// set the width and height of the new image in pixels
$image_width = $sysconfig['image_width'];
$image_height = $sysconfig['image_height'];
// create simple black image
$im = ImageCreateTrueColor($image_width, $image_height);
$backgroundcol = ImageColorAllocate($im, 0, 0, 0);
ImageFillToBorder($im, 0, 0, $backgroundcol, $backgroundcol);
// copy (resized) background image on background
$bgimagefile = 'resources/background.jpg';
$bg = @ImageCreateFromJpeg ($bgimagefile); /* Hintergrundbild darstellen */
if ($bg) {
imagecopyresampled($im, $bg, 0, 0, 0, 0, $image_width, $image_height, imagesx($bg), imagesy($bg));
}
$style = array();
$style['textcolor'] = ImageColorAllocate ($im, 255, 255, 255);
$style['textcolor_rt'] = ImageColorAllocate ($im, 255, 0, 0);
$style['textcolor_gn'] = ImageColorAllocate ($im, 0, 255, 0);
$style['font'] = 'resources/calibri.ttf';
$style['fontb'] = 'resources/calibrib.ttf';
$opt = array(
'width' => 450,
'align' => ALIGN_LEFT
);
imagettftextboxopt($im, 72, 0, 20, 25, $style['textcolor'], $style['font'], strftime("%H:%M"), $opt);
//$fp = fsockopen("213.239.204.105",80,&$errno,&$errstr,2);
$fp = fsockopen("213.239.204.105",80);
if(!$fp)
{
imagettftextboxopt($im, 16, 0, 350, 80, $style['textcolor_rt'], $style['fontb'], 'offline', $opt);
}
else
{
imagettftextboxopt($im, 16, 0, 350, 80, $style['textcolor_gn'], $style['fontb'], 'online', $opt);
}
fclose($fp);
// set the HTTP header type to jpeg
header("Content-type: image/jpeg");
// send the new PNG image to the browser
ImageJpeg($im);
// destroy the reference pointer to the image in memory to free up resources
ImageDestroy($im);
?>