A modification to Simon Steed's mod of Tyler Longren's Logger. It will now only track _NEW_ visitors to your site not every hit on every page as it did befor. You can also use it as a hit counter by grabbing the number of rows from the DB.
By : svonwolf
<? // Hit and visitor counter $connection = mysql_connect($hostName, $userName, $password) or die ("Unable to connect to MySQL server."); $db = mysql_select_db($databaseName) or die ("Unable to select requested database");
$browser = $HTTP_USER_AGENT; $date = date("F jS Y, h:iA");
// Check if the referer is your site if not then add record if (preg_match ("/www.YOUR_DOMAIN.com/i", "$HTTP_REFERER")) { mysql_close($connection); } else {
// If you cant resolve domain use IP address if ($REMOTE_HOST == "") { $host = $REMOTE_ADDR; } else { $host = $REMOTE_HOST; }
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.