VB icon

IP-Zero Counter

Email
Submitted on: 1/1/2015 8:44:00 AM
By: Unix Exploits (from psc cd)  
Level: Beginner
User Rating: By 3 Users
Compatibility: PHP 3.0, PHP 4.0
Views: 1366
 
     This is a script to display the number of page views/hits to your site. Very simple, and easy to follow.
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
// for :IP-Zero Counter
//**************************************
This Open Source :)
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: IP-Zero Counter
// Description:This is a script to display the number of page views/hits to your site. Very simple, and easy to follow.
// By: Unix Exploits (from psc cd)
//
// Inputs:<?echo(incCount("name")." visits"); ?>
//
// Returns:This returns the number of increasing hits.
//
// Assumes: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.
//**************************************

<?
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];
 }
 }
}
?>


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.