#native_company# #native_desc#
#native_cta#

Hits Tracking System

By Mircea Banu
on September 19, 2005

Version: (0.2) hits.php

Type: README

Category: Networking

License: GNU General Public License

Description: This script records information about the visitors on a PHP page (last visit time, IP address, total visits…).

<?php
 include_once "config.php";//just be sore that this is thre right path for the config file

 //last 5 days-------------------------------------------------------------
 $c = 0;
 $days=time()-432000;//5 days ago
 $q=mysql_query("select * from count where date > '$days' order by date desc");
 
 $sum = 0;
 

?>
<h1>Past 5 days: </h1>
<TABLE cellpadding=3 border=1 cellspacing=0 align=center bordercolor="#0066ff">
<TR align=center bgcolor="#ccffff">
        <TD><b>Nr.</b></TD>
        <TD><b>Address:</b></TD>
        <TD><b>IP</b></TD>
        <TD><b>Last time</b></TD>
        <TD><b>How many times</b></TD>
</TR>

<?

$c = 0;
$switch = 0;

while($r=mysql_fetch_object($q)) {

   $c++;
   $ip=$r->ip;
   
   $d = date("d - M - Y",$r->date);

         if($switch == 1) {
                $color="#ffffcc";
                $switch = 0;
         }
         else {
                $color="#00cccc";
                $switch = 1;
         }
         $sum = $sum + $r->total;
 ?>
   <tr align=center bgcolor="<?=$color?>">
        <TD><?=$c?></TD>
        <TD><?=gethostbyaddr($ip)?></TD>
        <TD><?=$ip?></TD>
        <TD><?=$d?></TD>
        <TD><?=$r->total?></TD>
    </tr>
<?

}

?>
</TABLE>
<br>
<b>-total: <?=$c?> hits: <?=$sum?></b>
 <br>
 <br>

 <?
  $q=mysql_query("select * from count order by date desc");
  //all the records ----------------------------------------------------------
 ?>



<h1>All: </h1>
<TABLE cellpadding=3 border=1 cellspacing=0 align=center bordercolor="#0066ff">
<TR align=center bgcolor="#ccffff">
        <TD><b>Nr.</b></TD>
        <TD><b>Address:</b></TD>
        <TD><b>IP</b></TD>
        <TD><b>Last time</b></TD>
        <TD><b>How many times</b></TD>
</TR>
<?

$c = 0;
$switch = 0;
$sum = 0;

while($r=mysql_fetch_object($q)) {

   $c++;
   $ip=$r->ip;

   $d = date("d - M - Y",$r->date);

         if($switch == 1) {
                $color="#ffffcc";
                $switch = 0;
         }
         else {
                $color="#00cccc";
                $switch = 1;
         }
         $sum = $sum + $r->total;
 ?>
   <tr align=center bgcolor="<?=$color?>">
        <TD><?=$c?></TD>
        <TD><?=gethostbyaddr($ip)?></TD>
        <TD><?=$ip?></TD>
        <TD><?=$d?></TD>
        <TD><?=$r->total?></TD>
    </tr>

<?
}

?>
</TABLE>
<br>
<b>-total: <?=$c?> hits: <?=$sum?></b>
 <br>
 <br>
<b>-10 minutes between two recordings;  </b>