Просмотр файла top/top/count.php

Размер файла: 3.89Kb
<?
#----------------------------------------------#
#         MOTOR 16.1 Site Rating               #
#         Mod by Voland                        #
#         WAP-Site  :  http://wapdel.net.ru    #
#----------------------------------------------#
  require_once "../template/regglobals.php";
  include_once "conf.php";
  $data=@file("../local/datatop/data/$id.dat");
  if($data)
    {
      clearstatcache();
      $agent = htmlspecialchars(stripslashes($_SERVER['REMOTE_ADDR']));
      $ugent = htmlspecialchars(stripslashes($_SERVER['HTTP_USER_AGENT']));
      $agent = $agent.'#'.$ugent;
      $time = time();
      $oftime = $time - 600;
      $den = date("d",$time);
      $aron = @file("../local/datatop/online/$id.dat");
      $ton = 0;
      $met = "";
      foreach($aron as $key => $val)
        {
          $artext = @explode("|",$val);
          if($artext[0] > $oftime & $agent != $artext[1] & $artext[1] != "")
            {
              $newar[$ton] = $val;
              $ton = round($ton + 1);
            }
          if($agent == $artext[1] & $artext[0] > $oftime)
            {
              $met = "hit";
            }
        }
      $newar[$ton] = $time."|".$agent."|\r\n";
      $fp = @fopen("../local/datatop/online/$id.dat","a+");
      ftruncate($fp,0);
      fclose($fp);
      foreach($newar as $key => $val)
        {
          $fp = @fopen("../local/datatop/online/$id.dat","a");
          flock($fp,LOCK_EX);
          fputs($fp,$val);
          flock($fp,LOCK_UN);
          fclose($fp);
        }
      $online = round($ton + 1);
      $count = file("../local/datatop/data/$id.dat");
      $count = explode("|",$count[0]);
      if($count[0] != $den)
        {
          $count[1] = 0;
          $count[3] = 0;
          $count[0] = $den;
        }
      if($met != "hit")
        {
          $count[1] = $count[1] + 1;
          $count[2] = $count[2] + 1;
        }
      $count[3] = $count[3] + 1;
      $count[4] = $count[4] + 1;
      $zapis = $count[0].'|'.$count[1].'|'.$count[2].'|'.$count[3].'|'.$count[4];
      $fp = @fopen("../local/datatop/data/$id.dat","a+");
      flock($fp,LOCK_EX);
      ftruncate($fp,0);
      fputs($fp,$zapis);
      fflush($fp);
      flock($fp,LOCK_UN);
      fclose($fp);
      $str = @implode("",@file("../local/datatop/online/$id.dat"));
      $bans = "../local/datatop/online/$id.dat";
      $lines = file("$bans");
      header("Content-type: image/gif");
      $img = @imagecreatefromgif("img/count.gif");
      $color = imagecolorallocate($img,255,0,0);
      $color1 = imagecolorallocate($img,255,255,0);
      $x2 = (imagesx($img) - 5 * strlen($count[1]) - 5);
      $x4 = (imagesx($img) - 5 * strlen($count[3]) - 5);
      $x5 = (imagesx($img) - 5 * strlen($count[4]) - 5);
      $y = 12;
      imagettftext($img,7,0,5,$y + 11,$color,"fonts/$font.ttf","H I T S ");
      imagettftext($img,7,0,5,$y + 19,$color,"fonts/$font.ttf","H O S T S ");
      imagettftext($img,7,0,5,$y + 27,$color,"fonts/$font.ttf","A L L ");
      imagestring($img,1,$x4,$y + 4,$count[3],$color);
      imagestring($img,1,$x2,$y + 12,$count[1],$color);
      imagestring($img,1,$x5,$y + 20,$count[4],$color);
      imagettftext($img,7,0,6,$y + 12,$color1,"fonts/$font.ttf","H I T S ");
      imagettftext($img,7,0,6,$y + 20,$color1,"fonts/$font.ttf","H O S T S ");
      imagettftext($img,7,0,6,$y + 28,$color1,"fonts/$font.ttf","A L L ");
      imagestring($img,1,$x4 + 1,$y + 5,$count[3],$color1);
      imagestring($img,1,$x2 + 1,$y + 13,$count[1],$color1);
      imagestring($img,1,$x5 +1,$y + 21,$count[4],$color1);
      imagegif($img);
      imagedestroy($img);
    }
  else
    {
      header("Content-type: image/gif");
      $img = @imagecreatefromgif("img/count.gif");
      $color = imagecolorallocate($img,255,0,0);
      imagettftext($img,15,0,3,34,$color,"fonts/$font.ttf","BAD");
      imagettftext($img,15,0,53,34,$color,"fonts/$font.ttf","ID!!!");
      imagegif($img);
      imagedestroy($img);
    }
?>