I would like to share a php code that I developed that I think is very usefull. It tracks which of my web pages are visited, the IP address and date. It then writes the info to a txt file called track.txt. Below is a php file called track.php
And the code below goes into each of my web pages. In this case the "Columbia Brewing Company" page. I only change the title on each page
I get the output below on a txt file, which tells me the pages that where visited along with the IP address and date. stubby.ca is always the first page
stubby.ca _ 65.50.18.119 _ Feb 16th 03:04:46
Labatt Brewing Company _ 65.50.18.119 _ Feb 16th 03:04:49
Carling Breweries Ltd. _ 65.50.18.119 _ Feb 16th 03:04:51
O'Keefe Brewing Company _ 65.50.18.119 _ Feb 16th 03:04:54
O'Keefe Brewing Company _ 65.50.18.119 _ Feb 16th 03:04:56
stubby.ca _ 65.50.18.119 _ Feb 16th 03:05:13
O'Keefe Brewing Company _ 65.50.18.119 _ Feb 16th 03:05:17
stubby.ca _ 24.77.175.78 _ Feb 16th 03:42:49
stubby.ca _ 24.101.53.42 _ Feb 16th 05:21:03
stubby.ca _ 12.74.202.78 _ Feb 16th 05:36:47
Leonard Whistler
PHP Code:
<?php
$ipaddress = $_SERVER['REMOTE_ADDR'];
$date = date ("M dS H:i:s");
$message = "$page _ $ipaddress _ $date\n";
$File = "track.txt";
$Open = fopen($File, "a+");
if ($Open){
fwrite($Open, "$message");
fclose ($Open);
}
?>
PHP Code:
<?php
$page ='Columbia Brewing Company';
include "track.php";
include "header.php";
include "nav.php";
echo "<h1>$page</h1>";
?>
I get the output below on a txt file, which tells me the pages that where visited along with the IP address and date. stubby.ca is always the first page
stubby.ca _ 65.50.18.119 _ Feb 16th 03:04:46
Labatt Brewing Company _ 65.50.18.119 _ Feb 16th 03:04:49
Carling Breweries Ltd. _ 65.50.18.119 _ Feb 16th 03:04:51
O'Keefe Brewing Company _ 65.50.18.119 _ Feb 16th 03:04:54
O'Keefe Brewing Company _ 65.50.18.119 _ Feb 16th 03:04:56
stubby.ca _ 65.50.18.119 _ Feb 16th 03:05:13
O'Keefe Brewing Company _ 65.50.18.119 _ Feb 16th 03:05:17
stubby.ca _ 24.77.175.78 _ Feb 16th 03:42:49
stubby.ca _ 24.101.53.42 _ Feb 16th 05:21:03
stubby.ca _ 12.74.202.78 _ Feb 16th 05:36:47
Leonard Whistler
Comment