Guest User

Untitled

a guest
Jan 23rd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | None | 0 0
  1. <?php
  2.    
  3.    
  4.     $dateiname = "besucherzaehler.txt";
  5.    
  6.     $handle = fopen ($dateiname , "r");
  7.     $inhalt = fread ($handle , filesize ($dateiname));
  8.     fclose ($handle);
  9.    
  10.     $db_link = mysql_connect ("localhost" , "root" , "") or
  11.     die ("Keine Verbindung moeglich");
  12.    
  13.     mysql_select_db("db1") or die ("Datenbank existiert nciht");
  14.    
  15.     $anz1 = "SELECT id FROM besucher ORDER BY id DESC LIMIT 1 ";
  16.    
  17.     $db_erg = mysql_query( $anz1) or die(mysql_error());
  18.    
  19.    
  20.     while ($zeile = mysql_fetch_array( $db_erg, MYSQL_ASSOC))
  21.     {
  22.       $anz1 = $zeile['id'];
  23.     }
  24.    
  25.     $x = 1;
  26.     $x1 = (string) $x;
  27.     $anz = (int) $anz1;
  28.     $fehler = 0;
  29.     while ($x1 <= $anz) {
  30.     $abfrage = "SELECT ip FROM besucher Limit $x , 1";
  31.     if ($abfrage = $_SERVER['REMOTE_ADDR']) {
  32.         $fehler = 1;
  33.     }
  34.     $x = $x + 1;
  35.     $x1 = (string) $x;
  36.     }
  37.    
  38.     $textnr = 5;
  39.    
  40.     if ($fehler <> 1) {
  41.         $inhalt = $inhalt + 1;
  42.         $ip = $_SERVER['REMOTE_ADDR'];
  43.        
  44.         $eintrag = "INSERT INTO besucher (ip) VALUES ('$ip')";
  45.         $eintragen = mysql_query($eintrag) or die(mysql_error());
  46.     }
  47.    
  48.     header ("Content-type: image/png");
  49.    
  50.     $bild = imagecreate (30 , 15);
  51.     imagecolorallocate ($bild , 0 , 0 , 0);
  52.     $textfarbe = ImageColorAllocate ($bild , 0 , 255 , 0);
  53.    
  54.     ImageString ($bild, $textnr, 0, 0, $inhalt , $textfarbe);
  55.    
  56.     ImagePNG ($bild);
  57.    
  58.     $handle = fopen ($dateiname , "w");
  59.     fwrite ($handle, $inhalt);
  60.     fclose ($handle);
  61.     mysql_close($db_link);
  62. ?>
Add Comment
Please, Sign In to add comment