程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> PHP綜合 >> PHP系統流量分析的程序

PHP系統流量分析的程序

編輯:PHP綜合
>create table stream (
ip text,
sTime int,
visits int,
info text);
<?
if($day<0)$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 '</span><hr size="1">';
echo '<table border="0" width="100%" cellspacing="0" cellpadding="2" class="st3">';
echo '<tr><td nowrap class="st2">IP位址</td>
<td nowrap class="st2">最近時間</td>
<td nowrap class="st2">次數</td>
<td 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);
?>


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved