/***
hit_count表只一個字段hit_count
page_visit_record表是用來控制一個IP一天內只產生一個計數器跳動
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),
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,