home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / php.exe / Counter.php < prev    next >
Encoding:
PHP Script  |  2001-07-02  |  2.4 KB  |  77 lines

  1. //**************************************
  2.     //     
  3.     // Name: A cool Counter
  4.     // Description:This is a simple counter 
  5.     //     that doesn't need any editing. If you wa
  6.     //     nt the better version, which is free, go
  7.     //     to http://ddkresource.cjb.com
  8.     // By: Driss Kaitouni
  9.     //
  10.     //This code is copyrighted and has    // limited warranties.Please see http://
  11.     //     www.Planet-Source-Code.com/xq/ASP/txtCod
  12.     //     eId.352/lngWId.8/qx/vb/scripts/ShowCode.
  13.     //     htm    //for details.    //**************************************
  14.     //     
  15.     
  16.     <?php
  17.     $img = "";
  18.     $animated_img = "";
  19.     $padding = 4;
  20.     $width = 16;
  21.     $height = 22;
  22.     $fpt = "acount.txt";
  23.     $lock_ip =0;
  24.     $ip_lock_timeout =30;
  25.     $fpt_ip = "ip.txt";
  26.     function checkIP($rem_addr) {
  27.     global $fpt_ip,$ip_lock_timeout;
  28.     $ip_array = file($fpt_ip);
  29.     $reload_dat = fopen($fpt_ip,"w");
  30.     $this_time = time();
  31.     for ($i=0; $i<sizeof($ip_array); $i++) {
  32.     list($ip_addr,$time_stamp) = split("\|",$ip_array[$i]);
  33.     if ($this_time < ($time_stamp+60*$ip_lock_timeout)) {
  34.     if ($ip_addr == $rem_addr) {
  35.     $found=1;
  36.     } else {
  37.     fwrite($reload_dat,"$ip_addr|$time_stamp");
  38.     }
  39.     }
  40.     }
  41.     fwrite($reload_dat,"$rem_addr|$this_time\n");
  42.     fclose($reload_dat);
  43.     return ($found==1) ? 1 : 0;
  44.     }
  45.     if (!file_exists($fpt)) {
  46.     $count_dat = fopen($fpt,"w+");
  47.     $digits = 0;
  48.     fwrite($count_dat,$digits);
  49.     fclose($count_dat);
  50.     }
  51.     else {
  52.     $line = file($fpt);
  53.     $digits = $line[0];
  54.     if ($lock_ip==0 || ($lock_ip==1 && checkIP($REMOTE_ADDR)==0)) {
  55.     $count_dat = fopen($fpt,"r+");
  56.     $digits++;
  57.     fwrite($count_dat,$digits);
  58.     fclose($count_dat);
  59.     }
  60.     }
  61.     $digits = sprintf ("%0".$padding."d",$digits);
  62.     $ani_digits = sprintf ("%0".$padding."d",$digits+1);
  63.     echo "<table cellpadding=0 cellspacing=0 border=0><tr align=center>\n";
  64.     $length_digits = strlen($digits);
  65.     for ($i=0; $i < $length_digits; $i++) {
  66.     if (substr("$digits",$i,1) == substr("$ani_digits",$i,1)) {
  67.     $digit_pos = substr("$digits",$i,1);
  68.     echo ("<td><img src=$img$digit_pos.gif width=$width height=$height></td>\n");
  69.     } else {
  70.     $digit_pos = substr("$ani_digits",$i,1);
  71.     echo ("<td><img src=$animated_img$digit_pos.gif width=$width height=$height></td>\n");
  72.     }
  73.     }
  74.     echo "</tr></table>\n";
  75.     ?>
  76.  
  77.