澳门新浦京8455comPHP系统流量分析的程序

create table stream (ip text,sTime int,visits int,info
text);?if($day0)$day=0;$mlink=mysql_connect(‘localhost’,’ajax’,’xxxxxxx’);//统计至今首页被浏览的总次数$query=select
SUM(visits) as tvisits from
stream;$result=mysql_db_query(‘ajax’,$query,$mlink);echo ‘span
class=st1浏览首页总累积次数:’;if($row=mysql_fetch_object($result)){echo
$row-tvisits;}$week=array(星期日,星期一,星期二,星期三,星期四,星期五,星期六);for($i=0;$i=$day;$i++){echo
‘p’;$ctime1=time()-24*3600*$i;$ctime2=time()-24*3600*($i-1);echo
‘span class=st4日期:’.date(m月d日,$ctime1).$week[date(w,$ctime1)];echo
/span;$stoday1=mktime(0,0,0,date(m,$ctime1),date(d,$ctime1),date(Y,$ctime1));$stoday2=mktime(0,0,0,date(m,$ctime2),date(d,$ctime2),date(Y,$ctime2));//统计当日首页被浏览的累积次数$query=’select
SUM(visits) as tvisits from stream where sTime=’;$query.=$stoday1.’ and
sTime’.$stoday2;$result=mysql_db_query(‘ajax’,$query,$mlink);echo
‘span
class=st3浏览首页累积次数:’;if($row=mysql_fetch_object($result)){echo
$row-tvisits;}//统计当日拜访ip的数量$query=’select * from stream where
sTime=’.$stoday1;$query.=’ and sTime’.$stoday2.’ order by sTime
DESC’;$result=mysql_db_query(‘ajax’,$query,$mlink);echo
浏览总人数:.mysql_num_rows($result);echo ‘/spanhr size=1’;echo ‘table
border=0 width=100% cellspacing=0 cellpadding=2 class=st3’;echo ‘trtd
nowrap class=st2IP位址/tdtd nowrap class=st2最近时间/tdtd nowrap
class=st2次数/tdtd nowrap class=st2用户资讯/td’;echo
/tr;while($row=mysql_fetch_object($result)){echo ‘tr’;echo ‘td
nowrap’.$row-ip.’/td’;echo ‘td
nowrap’.date(h:i:sa,$row-sTime).’/td’;echo ‘td
nowrap’.$row-visits.’/td’;echo ‘td nowrap’.$row-info.’/td’;echo /tr
;}echo /table;echo ‘hr size=1’;}mysql_close($mlink);?

<?  
//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
“<html><head><title>计数器</title></head>”;
    echo “你是第” .$num.”访问者<BR>”;
    echo “今天你第”.$click.”次点击<BR>”;
    echo “今天总点击”.$total.”次<BR>”;

/*
表:  
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)
);
*/
?>  

You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图