|
|
|
OK guys, this script is a simple file based counter. This is meant for sites that do not run a db and instead, use a file and a cookie. It isn't the best I've seen but it's simple. Consider this as a tutorial. :)
Just create a file called counter.txt and put this where you want to display the counter.
Remember to set the permissions on counter.txt so that your webserver can write to the file.
| <?php
$visitor_ip = $HTTP_COOKIE_VARS["user_ip"];
$counter = "counter.txt";
$counter_file_line = file($counter);
if(!$visitor_ip)
{
setcookie("user_ip", $REMOTE_ADDR, time()+360000);
$counter_file_line[0]++;
$cf = fopen($counter, "w+");
fputs($cf, "$counter_file_line[0]");
fclose($cf);
}
elseif($visitor_ip != $REMOTE_ADDR)
{
$counter_file_line[0]++;
$cf = fopen($counter, "w+");
fputs($cf, "$counter_file_line[0]");
fclose($cf);
}
?> | | |
|
| Introduction to Language Files Categories : PHP, Filesystem, Beginner Guides | | | Creating a Language File Categories : PHP, Beginner Guides, Filesystem | | | A very simple PHP single password cookie based login without usernames. Categories : PHP, Cookies, Security, Beginner Guides | | | PHP based Contact email form with multiple recipients, text file based, supports departments. Categories : PHP, Email, Beginner Guides, Filesystem | | | Convert a File database into MySQL Categories : PHP, Filesystem, Databases, MySQL, Beginner Guides | | | Simple Cookie example Categories : PHP, Beginner Guides, Cookies | | | Simple image counter Categories : PHP, Graphics, Filesystem, Beginner Guides | | | Store, retrieve and delete cookies using JavaScript. Categories : Java Script, Cookies, Beginner Guides, Cookies | | | file class , uploade file , download file already uploaded on another website Categories : PHP, PHP Classes, Filesystem, Web Services | | | Basic Authentication with sessions Categories : PHP, Beginner Guides, Authentication, Form Processing, Sessions | | | PHP4 MYSQL Authentication Script with cookie. Short & Sweet
Categories : Authentication, Apache, Cookies, PHP, MySQL | | | News management class Categories : PHP, PHP Classes, Beginner Guides | | | Authentication script to authenticate users in Active Directory through LDAP. Categories : LDAP, Authentication, Cookies, PHP | | | php jump urls...the best way Categories : PHP, URLs, Filesystem | | | Simple way to replace a variable value in a .conf (.ini) file using a
webbrowser - the first stage of a complete universal configuration editor Categories : PHP, Regexps, Code Editors, Filesystem | |
|
|
|