Schweinelangsam, und GD muss mit GIF-Support kompiliert sein...
PHP-Code:
<?php
// Dein Status-GIF
$status_gif = 'http://status.com/status.gif';
// PHP braucht Schreibrechte (777) im Verzeichnis
$temp_file = realpath('temp.gif');
$img_buffer = null;
$red = 180;
$green = 24;
$green_file = realpath('green.txt');
$red_file = realpath('red.txt');
$green_count = 0;
$redf_count = 0;
if (is_file($green_file)) {
list($green_count) = file($green_file);
}
if (is_file($red_count)) {
list($red_count) = file($red_file);
}
$fh = fopen($status_gif, 'rb');
if (is_resource($fh)) {
while($buff = fread($fh, 256)){
$img_buffer .= $buff;
}
fclose($fh);
$fh = fopen($temp_file, 'wb');
if (is_resource($fh)) {
fwrite($fh, $img_buffer);
fclose($fh);
$img = imagecreatefromgif($temp_file);
if (is_resource($img)) {
$col = imagecolorat($img, 0, 0);
imagedestroy($img);
if ($col == $green) {
f_write($green_file, ++$green_count);
} elseif ($col == $red) {
f_write($red_file, ++$red_count);
} else {
// Punkt hat andere Farbe
}
}
}
}
function f_write($file, $val){
$fh = fopen($file, 'w');
if (is_resource($fh)) {
fwrite($fh, $val);
fclose($fh);
}
}
?>
~