Improved IP counter // Require ('Common. Inc ');
$ Arr_request = array ();
If (count ($ HTTP_GET_VARS ))
{
While (list ($ key, $ value) = each ($ HTTP_GET_VARS ))
{
$ Arr_request [strtolower ($ key)] = $ value;
}
}
If (count ($ HTTP_POST_VARS ))
{
WHILE (list ($ key, $ value) = each ($ HTTP_POST_VARS ))
{
$ Arr_request [strtolower ($ key)] = $ value;
}
}
$ Link = @ mysql_connect ("localhost", "kong", "kong ");
Mysql_select_db ("mywebdb ");
$ Ip = $ REMOTE_ADDR;
$ Current = getdate (time ());
$ Day = $ current ["mday"];
$ Query = "select * from addcount where day = \" $ day \"";
$ Result = @ mysql_query ($ query );
If (! $ Num = @ mysql_num_rows ($ result ))
$ Num = 1;
While ($ row = @ mysql_fetch_row ($ result ))
{
If (strcmp ($ ip, $ row [1]) = 0)
{
$ I = 1;
$ Id = $ row [0];
$ Click = $ row [3] + 1;
$ Up = "update addcount set click_count = click_count + 1 where id = $ id ";
$ Result2 = @ mysql_query ($ up );
// Break;
}
$ Total + = $ row [3];
}
$ Total ++;
If (! $ I ){
$ Query1 = "insert into addcount (ip, day, click_count) values ('$ IP',' $ Day', 1 )";
Mysql_db_query ("mywebdb", $ query1, $ link );
$ Click = 1;
}
Echo" Counter";
Echo "you are the visitor". $ num ."
";
Echo "today you click". $ click ."
";
Echo "total clicks". $ total. "today
";
/*
Table:
Addcount
Create table addcount (
Id int (6) DEFAULT '0' not null auto_increment,
Ip char (20) not null,
Day int (2) not null,
Click_count int (3) not null,
Primary key (id)
);
*/
?>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.