| |
<?php
// Variablen Konfiguration // ==================================== $count=1; // Default Counter Stand $ip=getenv("REMOTE_ADDR"); // Aktuelle IP Adresse von Besucher $counterfile="counter.txt"; // Speicherort $anzahl = 5; // Anzahl der Counter Stellen $reloadsperre = FALSE; // Reload ein (TRUE) oder aus (FALSE); $error_img = "fehler.png"; // Fehler Grafik Datei
// Fehler Funktion // ==================================== function error_image() { global $error_img; $size = GetImageSize($error_img); $src_img = ImageCreateFromPNG($error_img); $c_img = ImageCreate($size[0], $size[1]); ImageCopy($c_img,$src_img, 0, 0, 0, 0, $size[0], $size[1]); imagedestroy($src_img); Header("Content-type: image/png"); ImagePNG($c_img); //error image wird ausgegeben imagedestroy($c_img); exit; }
// Falls Counterdatei nicht existiert // dann anlegen // ==================================== if (!file_exists($counterfile)) { if ($datei=fopen($counterfile,"w")) { fputs($datei,"$count:$ip"); fclose($datei); } else { error_image(); }
} else { // Counter lesen // ==================================== if (list($line) = file($counterfile)) { list($count,$old_ip)=split(":",$line); if ($ip != $old_ip OR $reloadsperre == FALSE) { $count++ ; // Counter aktualisieren // ===================== if ($datei=fopen($counterfile,"w")) { fputs($datei,"$count:$ip"); fclose($datei); } else { error_image(); } } } else { error_image(); } }
// Counterstand mit nullen auffuellen // ==================================== $count = str_pad($count, $anzahl, "0", STR_PAD_LEFT);
// Groesse einer Counter Grafik laden // ==================================== $counter_size = GetImageSize("0.png");
// Counter Zielbild erstellen // ==================================== $c_im = ImageCreate(($anzahl*$counter_size[0]), $counter_size[1]);
// Einzelne Counter Zahlen erstellen // ==================================== for($i=0;$i<$anzahl;$i++) { $src_im = ImageCreateFromPNG("$count[$i].png"); ImageCopy($c_im, //Ziel-Bild $src_im, //Quell-Bild ($counter_size[0]*$i), //Ziel-Bild x koordinate 0, //Ziel-Bild y koordinate 0, //Quell-Bild x koordinate 0, //Quell-Bild y koordinate $counter_size[0], //Quell-Bild x (w) breite $counter_size[1]); //Quell-Bild y (h) hoehe imagedestroy($src_im); }
// Counter ausgeben // ==================================== Header("Content-type: image/png"); ImagePNG($c_im); //counter png wird ausgegeben imagedestroy($c_im);
?>
© Henrik Teichmann
|
|