Просмотр файла counter/index.php

Размер файла: 4.14Kb
<?php
/////////////////////////////////////////////////////////////////
//                                                             //
//                     (c) made by Mackler'                    //
//             ----------------------------------              //
//                     ICQ: 531710                             //
//                   email: [email protected]                //
//                 WAPsite: planeta.h2m.ru                     //
//             ----------------------------------              //
//                            '2007'                           //
//                                                             //
/////////////////////////////////////////////////////////////////

Error_Reporting(E_ALL & ~E_NOTICE);
$ip_tek=$REMOTE_ADDR;
$time_tek= date('H').date('i');
$day_tek= date('j');
$a= @fopen("day.dat","r");
$day_last= @fgets($a,10);
@fclose($a);

header ("Content-type:images/png");

//===========================  online ===========================
$aa= @fopen("online.dat","r");
while ( $bb= @fgets($aa, 30))
      { $data[]= $bb;
       }
@fclose($aa);
$n=0;
$m= count($data);
while ( $n < $m )
      { $str= strlen($data[$n]);
        $data_ip[$n]= substr($data[$n], 0, $str-7);
        $data_time[$n]= substr($data[$n], $str-5, 4);
        $n++;
       }
$time_last=$time_tek-5;
for ($n=0; $n<$m; $n++)
    { if ( $time_last <= $data_time[$n] 
           && $ip_tek !== $data_ip[$n]
           && $day_tek == $day_last)
         { $ondat[$n]=$data[$n];
          }
      else {}
     }
$ondat[]=$ip_tek."||".$time_tek."\n";
$online= count($ondat);
$q=@fopen("online.dat","w");
for ($n=0; $n < $online; $n++)
      { @fputs($q,$ondat[$n]);}
@fclose($q);

//========================= hits today ==========================
if ( $day_tek == $day_last )
    { $hit_last = @file("hits.dat");
      $hit = $hit_last[0]+1;
      $fp = @fopen("hits.dat","w");
      @fputs($fp,$hit);
      @fclose($fp);
     }
else { $fp = @fopen("hits.dat","w");
       @fputs($fp,"1");
       @fclose($fp);
       $hit=1;
      }

//==================== hosts today and all=======================
if ( $day_tek == $day_last )
    { $addr=@fopen("host.dat","r");
      while ( $d=@fgets($addr,30))
          { $ip1[] = $d;
           }
      @fclose($addr);
      $i=0;
      $i=count($ip1); $y=0;
      while ($y < $i)
          { if ( $ip1[$y] == $ip_tek."\n")
              { break;
               }
            elseif ( $i == $y+1 )
                { $y++;
                 $addr1=@fopen("host.dat","a");
                 @fputs($addr1,$ip_tek."\n");
                 @fclose($addr1);
                 $i++;
                 $z= @file("allhost.dat");
                 $op=$z[0]+1;
                 $allhost=$op;
                 $addr2=@fopen("allhost.dat","w");
                 @fputs($addr2,$op);
                 @fclose($addr2);
                 break;
                 }
            else {$y++;
                  }
           }
       $host= $i;
      }
else { $fp = @fopen("host.dat","w");
       @fputs($fp,$ip_tek."\n");
       @fclose($fp);
       $host=1;
       $z= @file("allhost.dat");
       $op=$z[0]+1;
       $allhost=$op;
       $addr2=@fopen("allhost.dat","w");
       @fputs($addr2,$op);
       @fclose($addr2);
      }
$qw=@file("allhost.dat");
$allhost=$qw[0];

//===================== image counter ===========================
$image = ImageCreateFromPng("image.png");
$color1=imagecolorallocate($image, 255, 255, 40);
$color2=imagecolorallocate($image, 0, 255, 0);
ImageString ($image,2, 61, 2,"online" , $color2);
ImageString ($image,2, 73, 12,"hits" , $color2);
ImageString ($image,2, 73, 23,"host" , $color2);
ImageString ($image,2, 49, 34,"all host" , $color2);
ImageString ($image,2, 7, 13, $hit, $color1);
ImageString ($image,2, 7, 35, $allhost, $color1);
ImageString ($image,2, 7, 2, $online, $color1);
ImageString ($image,2, 7, 24, $host, $color1);
Imagepng($image);
imagedestroy($image);
//===============================================================
$a= @fopen("day.dat","w");
@fputs($a,$day_tek);
@fclose($a);
?>