Simple graphic counters require MYSQL and GD support /***
Only one hit_count field in the hit_count table
The page_visit_record table is used to control one IP address to generate only one counter in a day.
Create table page_visit_record (
Visit_time datetime DEFAULT '2017-00-00 00:00:00 'not null,
Remote_addr char (15) not null,
Visit_page char (60) not null,
KEY visit_time (visit_time, visit_page ),
Primary key (visit_time)
);
***/
Include ("config. inc. php3 ");
$ Query = "select count (*) as tong from page_visit_record where remote_addr = '$ REMOTE_ADDR' and date_format (visit_time, '% Y-% m-% d') = curdate () ";
$ Result = @ mysql_query ($ query, $ dbconnect );
$ Has_count = @ mysql_result ($ result, 0, "tong ");
@ Mysql_query ("lock tables hit_count write", $ dbconnect );
$ Query = "select * from hit_count ";
$ Result = @ mysql_query ($ query, $ dbconnect );
If (@ mysql_num_rows ($ result)> 0 ){
$ Cur_count = @ mysql_result ($ result, 0, "hit_count ");
If ($ has_count = 0 ){
$ Cur_count ++;
$ Query = "update hit_count set hit_count = '$ cur_count '";
@ Mysql_query ($ query, $ dbconnect );
}
@ Mysql_query ("unlock tables", $ dbconnect );
}
Else {
$ Cur_count = 1;
$ Query = "insert into hit_count (hit_count) values ('$ cur_count ')";
@ Mysql_query ($ query, $ dbconnect );
@ Mysql_query ("unlock tables", $ dbconnect );
}
While (strlen ($ cur_count) <8)
$ Cur_count = "0 $ cur_count ";
$ Visit_time = date ("Y-m-d H: I: s ");
$ Query = "insert into page_visit_record (visit_time, remote_addr, visit_page) values ('$ visit_time', '$ REMOTE_ADDR', '$ page ')";
@ Mysql_query ($ query, $ dbconnect );
Header ("Content-type: image/gif ");
$ Im = imagecreate (56,16 );
$ Black = ImageColorAllocate ($ im, 0, 0 );
$ Blue = ImageColorAllocate ($ im, 255 );
$ White = ImageColorAllocate ($ im, 255,255,255 );
$ Yellow = ImageColorAllocate ($ im, 255,255, 0 );
Imagerectangle ($ im, 0, 0, 54, 14, $ blue );
// Imagestring ($ im, 2, 4, 1, $ cur_count, $ yellow );
Imagestring ($ im, 2, 4, 1, $ cur_count, $ yellow );
ImageGif ($ im );
ImageDestroy ($ im );
?>