#native_company# #native_desc#
#native_cta#

Hit Counter

By Azizul Islam
on July 28, 2005

Version: 1

Type: Full Script

Category: Databases

License: GNU General Public License

Description: Unique Hit Counter (IP Based)
Azizul Islam (Bangladesh)
Demo: http://www.samren.org
http://www.samren.org/admin

<?php
if (getenv('HTTP_X_FORWARDED_FOR'))
{
	$domain=getenv('HTTP_X_FORWARDED_FOR');
} 
else 
{
	$domain=getenv('REMOTE_ADDR');
}
//	$domain = GetHostByName($REMOTE_ADDR);
	$d1=date("Ymd");
	$connect = mysql_connect("localhost", "samren", "pass") or die ("Check your server connection.");
	mysql_select_db ("samren");
//Check the IP and Date.
	$results=mysql_query ( "SELECT * FROM hit_counter WHERE iIP='$domain' and dDate='$d1'" );
	$num = mysql_num_rows ($results);
	if ( $num > 0 )
	{
		//echo "The IP  is already assigned.<br>";
		//exit;
	}
	else
	{
		$insert="INSERT INTO hit_counter (iID,iIP,dDate) VALUES ('','$domain','$d1')";
		$results = mysql_query($insert) or die(mysql_error());
	}
//Total visit
	$query="select count(*) from hit_counter";
	$result=mysql_query($query) or die(mysql_error()); 
	$querydata=mysql_fetch_row($result);
	$tot=$querydata[0];
	echo "<strong>Y</strong>ou are visitor no: $tot. <br>";	
//Curdate visitor.
	$query="select count(*) from hit_counter where dDate='$d1'";
	$result=mysql_query($query) or die(mysql_error()); 
	$querydata=mysql_fetch_row($result);
	$tot=$querydata[0];
	echo "<strong>T</strong>oday's total visitors: $tot. <br>";
?>