Posted: Sun Jul 21, 2002 1:55 pm
Sorry to spoil the fun guys, but the last two posts had parse errors! The means protokol wins with the code:Care to take a serve protokol?
Code: Select all
<?php
class Counter {
function Counter() { // what is a class without a constructor :-)
}
function checkUniqueVisitor($ip) {
$ip = getenv('REMOTE_ADDR');
$_fp = fopen("ips.txt", 'a+');
fclose("$_fp");
}
function displayCounter($counter, $prefix='', $suffix='') {
if (file_exists($counter)) {
$fp = fopen($counter, 'r');
$num = fread($fp, 100);
$fpsoma = ($num + 1);
fclose($fp);
$fa = fopen($counter, 'w');
fwrite($fa, $fpsoma, 100);
fclose($fa);
echo $prefix.$fpsoma.$suffix;
return TRUE;
} else {
echo ("File not found.");
return FALSE;
}
}
}
$oCounter = new Counter;
$oCounter->displayCounter("counter.txt"); // instantiated object calls the function
?>