A simple graphic counter. MySQL (the best combination with PHP), GD support, php in LINUX (as the mainstream development language) 4RC1 pass, this is also in use in my system .? Php (as the best combination of MySQL and PHP), GD support, php in LINUX (as the mainstream development language) through 4RC1, this is also in use in my system.
/***
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 0000-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 ),
Prima (the most comprehensive virtual host Management System) ry key (visit_time)
);
***/
Include ("config. inc. php (as the mainstream development language) 3 ");
$ 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 (the best combination with PHP) _ query ($ query, $ dbconnect );
$ Has_count = @ MySQL (the best combination with PHP) _ result ($ result, 0, "tong ");
@ MySQL (the best combination with PHP) _ query ("lock tables hit_count write", $ dbconnect );
$ Query = "select * from hit_count ";
$ Result = @ MySQL (the best combination with PHP) _ query ($ query, $ dbconnect );
If (@ MySQL (the best combination with PHP) _ num_rows ($ result)> 0 ){
$ Cur_count = @ MySQL (the best combination with PHP) _ result ($ result, 0, "hit_count ");
If ($ has_count = 0 ){
$ Cur_count ++;
$ Query = "update hit_count set hit_count = $ cur_count ";
@ MySQL (the best combination with PHP) _ query ($ query, $ dbconnect );
}
@ MySQL (the best combination with PHP) _ query ("unlock tables", $ dbconnect );
}
Else {
$ Cur_count = 1;
$ Query = "insert into hit_count (hit_count) values ($ cur_count )";
@ MySQL (the best combination with PHP) _ query ($ query, $ dbconnect );
@ MySQL (the best combination with PHP) _ 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 (the best combination with PHP) _ 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 );
?>
Middleware (the best combination with PHP), GD support, php in LINUX (as the mainstream development language) 4RC1 passed, which is also in use in my system. ? Php (as the current...