README.md
December 4, 2022 ยท View on GitHub
Description
This is a script to display the number of page views/hits to your site. Very simple, and easy to follow.
More Info
For this code to work correctly, create a counter.dat file. Then input the following:
name:0
You may change name to anything you like, but leave the counter at 0 so your not being lame. You may also add as many users in the dat file as you want.
This returns the number of increasing hits.
| Submitted On | |
| By | Unix Exploits |
| Level | Beginner |
| User Rating | 3.7 (11 globes from 3 users) |
| Compatibility | PHP 3.0, PHP 4.0 |
| Category | Internet/ Browsers/ HTML |
| World | PHP |
| Archive File |
API Declarations
This Open Source :)
Source Code
<?
function incCount($site){
$content = file("counter.dat");
$fp = fopen("counter.dat", "w");
$i = 0;
for(; $i < count($content); $i++) {
$parts = explode(":", trim($content[$i]));
if ($parts[0] == $site) {
$num = $parts[1] + 1;
fwrite($fp, $parts[0].":".$num."\n");
}
else {
fwrite($fp, trim($content[$i])."\n");
}
}
fclose ($fp);
return $num;
}
function getCount($site){
$content = file("counter.dat");
$yes=false;
$i = 0;
for(; $i < count($content); $i++) {
$parts = explode(":", trim($content[$i]));
if ($parts[0] == $site) {
return $parts[1];
}
}
}
?>