Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dateiname = "besucherzaehler.txt";
- $handle = fopen ($dateiname , "r");
- $inhalt = fread ($handle , filesize ($dateiname));
- fclose ($handle);
- $db_link = mysql_connect ("localhost" , "root" , "") or
- die ("Keine Verbindung moeglich");
- mysql_select_db("db1") or die ("Datenbank existiert nciht");
- $anz1 = "SELECT id FROM besucher ORDER BY id DESC LIMIT 1 ";
- $db_erg = mysql_query( $anz1) or die(mysql_error());
- while ($zeile = mysql_fetch_array( $db_erg, MYSQL_ASSOC))
- {
- $anz1 = $zeile['id'];
- }
- $x = 1;
- $x1 = (string) $x;
- $anz = (int) $anz1;
- $fehler = 0;
- while ($x1 <= $anz) {
- $abfrage = "SELECT ip FROM besucher Limit $x , 1";
- if ($abfrage = $_SERVER['REMOTE_ADDR']) {
- $fehler = 1;
- }
- $x = $x + 1;
- $x1 = (string) $x;
- }
- $textnr = 5;
- if ($fehler <> 1) {
- $inhalt = $inhalt + 1;
- $ip = $_SERVER['REMOTE_ADDR'];
- $eintrag = "INSERT INTO besucher (ip) VALUES ('$ip')";
- $eintragen = mysql_query($eintrag) or die(mysql_error());
- }
- header ("Content-type: image/png");
- $bild = imagecreate (30 , 15);
- imagecolorallocate ($bild , 0 , 0 , 0);
- $textfarbe = ImageColorAllocate ($bild , 0 , 255 , 0);
- ImageString ($bild, $textnr, 0, 0, $inhalt , $textfarbe);
- ImagePNG ($bild);
- $handle = fopen ($dateiname , "w");
- fwrite ($handle, $inhalt);
- fclose ($handle);
- mysql_close($db_link);
- ?>
Add Comment
Please, Sign In to add comment