PDA

View Full Version : counter + old counter


crashed29
01-01-2003, 06:37 PM
I have a site that I just transfered to another hosting company that currently has a counter.

My client wants the counter to start at the point that the old one stopped. So the counter would be something like:
2,000 + new hits.

Does anyone know of a script I could paste onto my page that would work for this?

Thanks!

Mhtml
01-02-2003, 03:19 AM
How or where are you storing the counts?

Nightfire
01-02-2003, 03:29 AM
<?
$COUNT_FILE = "count_data.txt";
if (file_exists($COUNT_FILE)) {
$fp = fopen("$COUNT_FILE", "r+");
flock($fp, 1);
$count = fgets($fp, 4096);
$count += 1;
fseek($fp,0);
fputs($fp, $count);
flock($fp, 3);
fclose($fp);
} else {
echo "Can't find file, check '\$file' var...<BR>";
}

?>

then in count_data.txt put the amount of hits in, ie 3000 and you might need to chmod the file to 777