furan
2004-09-23, 07:28 PM
下載了一個偵測流量程式,如下
<html>
<body>
<?
// Written by HalfaBee 5-Jun-2003
// Bandwidth for the last 24hrs
$fr = file ( '/www/u/username/logs/access_log' );
$fr = array_reverse ( $fr );
$i = 0 ;
$total = 0 ;
foreach( $fr as $s )
{
$fe = explode ( " " , $s );
$tt = str_replace ( '/' , '-' , str_replace ( '[' , '' , $fe [ 3 ] ) ) ;
$time = strtotime ( preg_replace ( '/([0-9][0-9][0-9][0-9]):/' , '1 ' , $tt ) );
$total += $fe [ 9 ];
if( $i ++== 0 )
$endtime = $time - 24 * 3600 ;
if( $time < $endtime )
break;
}
?>
Your total transfer for the last 24Hrs is <? printf ( "%.6fGB" , (float) $total / 1000000000 ) ?>
</body>
</html>
測試時是真的可以成功測得流量(24hr內的流量)
但他好像沒有抓我次網域內的流量
不知道是不是真的如此
是不是有人可以修改成可以偵測次網域的流量
<html>
<body>
<?
// Written by HalfaBee 5-Jun-2003
// Bandwidth for the last 24hrs
$fr = file ( '/www/u/username/logs/access_log' );
$fr = array_reverse ( $fr );
$i = 0 ;
$total = 0 ;
foreach( $fr as $s )
{
$fe = explode ( " " , $s );
$tt = str_replace ( '/' , '-' , str_replace ( '[' , '' , $fe [ 3 ] ) ) ;
$time = strtotime ( preg_replace ( '/([0-9][0-9][0-9][0-9]):/' , '1 ' , $tt ) );
$total += $fe [ 9 ];
if( $i ++== 0 )
$endtime = $time - 24 * 3600 ;
if( $time < $endtime )
break;
}
?>
Your total transfer for the last 24Hrs is <? printf ( "%.6fGB" , (float) $total / 1000000000 ) ?>
</body>
</html>
測試時是真的可以成功測得流量(24hr內的流量)
但他好像沒有抓我次網域內的流量
不知道是不是真的如此
是不是有人可以修改成可以偵測次網域的流量