View file top/in.php

File size: 1.39Kb
<?php
 include "inc/data.php";
 error_reporting(0);
 if (isset($_GET['sid'])) $sid = htmlspecialchars(substr(trim($_GET['sid']),0,5));
 if (nakrutka) 
 {
   $date_data="inc/date.dat";
   $ip_log="inc/data/ip_log_in_".$sid.".dat";
   if (file_exists($ip_log)) $ip_file = file($ip_log);
   $date=date("d-m-Y",time());
   if (file_exists($date_data)) $a_date=file($date_data); else $a_date[]=-1;
   if ($a_date[0]==$date): 
     if (strpos($ip_file[0], "$REMOTE_ADDR")>-1) { Go_Top(); exit;}
     $fu=fopen($ip_log,"a");
     fwrite($fu,"$REMOTE_ADDR"."¤");
     fclose($fu); 
   elseif ($a_date[0] != $date): 
     $fu=fopen($ip_log,"w");
     fwrite($fu,"$REMOTE_ADDR"."¤");
     fclose($fu);
     $fd=fopen($date_data,"w");
     flock($fd,2);
     fputs($fd,$date);
     flock($fd,3);
     fclose($fd);
   endif;
 }
 if (($sid=="") || (!(isset($_GET['sid'])))) $sid="0";
 $IO_data="./inc/data/io_".$sid.".dat";
 if (file_exists($IO_data)) $io = file($IO_data);
 if ($io)
 {
  $record = explode("¤", trim($io[0]));
  $record[0]++;
  $fopt = fopen ($IO_data, "w"); 
  $io_result = $record[0]."¤".$record[1];
  if ($fopt) $result = fwrite($fopt, $io_result);
  fclose($fopt);
 }
 Go_Top();
function Go_Top() { ?>
<script language="javascript">
<!--
  document.location.replace("index.php");
// -->
</script>
<noscript>
<?php header("location: index.php"); ?>
</noscript>
<?php } ?>