PHP Classes

File: counter_report.php

Recommend this page to a friend!
  Classes of David Higgins   CCounter   counter_report.php   Download  
File: counter_report.php
Role: Application script
Content type: text/plain
Description: This is an administrative report for CCounter
Class: CCounter
Simple flat-text file counter
Author: By
Last change:
Date: 22 years ago
Size: 1,900 bytes
 

Contents

Class file image Download
<?

/*******************************************************************

  This is a report page written for the CCounter class

  Written by David Higgins (http://zoulcreations.com)

  Questions, comments or suggestions: higginsd@zoulcreations.com


  This file is to be placed in the same directory as your
  counter.dat file. You may make this page public, but it
  is suggested to keep the page private ... as it displays the
  ip's of all your visitors ...

  This is just an extra additive ... its not necessary for the
  CCounter class to function properly ... nor does it use the
  CCounter class to actually perform its operation ...

*****************************************************************/

// edit the second parameter of the below line ...
define('COUNTER_FILE', 'counter.dat');
?>
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
       <title>Title here!</title>
</head>
<body bgcolor=#000000 text=#FFFFFF>
<center>
<h1>GearWorx Productions Counter Statistics</h1>
<table cellspacing=0 cellpadding=5 border=1>
<tr>
  <td>ID</td>
  <td>Host</td>
  <td>Visits</td>
</tr>
<?
$fp
= fopen('counter.dat', 'r');
$data = fread($fp, filesize('counter.dat'));
$data = explode("\n", $data);
$row = 1;
$total=0;
$unique=0;
$top_int=0;
$top_chr='';
foreach(
$data as $k=>$a) {
 
$unique++;
  if(
is_numeric(strpos($a, '|'))) {
   
$d = explode('|', $a);
   
$total += (int)trim($d[1]);
    if(
$d[1] > $top_int) {
     
$top_int = $d[1];
     
$top_chr = $d[0];
    }
   
?>
<tr bgcolor="<?=$row%2?'#666666':'#333333'?>">
  <td><?=$row?>
<td><?=$d[0]?></td>
  <td><?=$d[1]?></td>
</tr>
<?
    $row
++;
  }
}
?>
</table>
<h4><?=$total?> total visits, from <?=$unique?> unique hosts</h4>
<br>
<?=$top_chr?> really likes visiting your site, with <?=$top_int?> visits.!
</center>
</body>
</html>