PHP Classes
elePHPant
Icontem

File: testIPTracker.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of L  >  IPTracker  >  testIPTracker.php  >  Download  
File: testIPTracker.php
Role: Example script
Content type: text/plain
Description: example
Class: IPTracker
Class for storing visitor data in a db or textfile
Author: By
Last change: Changed to make it compliant to anyDB the db abstraction layer(http://www.phpclasses.org/anydb)
Date: 12 years ago
Size: 814 bytes
 

Contents

Class file image Download
<?php

$type
= 'file';
//$type = 'db';

// determine the tracker type
if ($type == 'file') {
    require_once
'IPTrackerFile.php';
   
$tracker = new IPTrackerFile('ip.log');
} else {
    require_once
'IPTrackerDB.php';
    require_once
'../anyDB/anyDB.php';
   
$db = anyDB::getLayer('MYSQL', '', 'mysql');

   
$tracker = new IPTrackerDB($db, 'localhost', 'php', '', '');
}

// the tracker type
echo $tracker->getIdentifier() . '<p>';

// track the current visitor
$tracker->track();

// status data
echo 'my ip: ' . $tracker->getIP() . '<br>';
echo
'entries : ' . $tracker->count . '<p>';

// get the last entry
$last = $tracker->get($tracker->count);
echo
'latest entry:<br>';
echo
date('Y-m-d H.i.s', $last['time']) . ' | ' . $last['ip'] . ' | ' . $last['host'] . ' | ' .$last['referer'];


?>