Php > Complete Programs
A Simple hit counter, which also outputs alt tags on images for text
A Simple hit counter, which also outputs alt tags on images for text $fileloc = "/home/mysite/hits.txt"; //| //| Change this to the url directory containing the images, including trailing / //| $imagedir = "http://www.mysite.com/images/"; //| //| If the counter is broken, or there is a problem, it will display nothing unless you set this to 1 //| $debug = 0; if(is_file($fileloc)) { if($hits = file($fileloc) AND $file = fopen($fileloc, "w")) { $hits = trim($hits[0]) + 1; fputs($file, $hits); $length = strlen($hits); fclose($file); $file = fopen($fileloc, "r"); echo "
\n"; for($repeat = 1; $repeat <= $length; $repeat++) { $number = fgetc($file); echo "
\n"; } echo "
\n"; fclose($file); } else { if($debug != 0) { echo "Error: Could not open the file, or file does not contain a valid number"; } } } else { if($debug != 0) { echo "Error: Hit file does not exist, or there has been a disk failure"; } } ?>
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage