怎麼實現不同IP地址的瀏覽次數統計

來源:互聯網
上載者:User
如何?不同IP地址的瀏覽次數統計

// 訪客計數器函數
function counter() {
!empty($_GET['weburl']) || die('weburl不可為空');
$weburl = $_GET['weburl'];

$file = '/usr/local/apache/htdocs/MyTests/counter.txt';
if (! file_exists($file)) {
$num = 1;
$cf = fopen($file, 'w');
fwrite($cf, $weburl.' '.$num);
fclose($cf);
} else {
$cf = fopen($file, 'rw');
$num = fgets($cf);
$num = substr($num, 15);
fclose($cf);

++$num;
$cf = fopen($file, 'w');
fwrite($cf, $num);
fclose($cf);
}
}

?>


訪客計數器



歡迎訪問






您是第位訪客










我想實現一個輸入不同的IP地址並提交後,在“您是第...位訪客”中顯示相應IP訪問了多少次。。。我用一個TXT檔案儲存體IP地址與瀏覽次數,格式如下:
例:
192.168.0.22 5
192.168.5.44 10
......

這個程式應該如何修改? 儲存 PHP HTML 函數 Color

分享到:


------解決方案--------------------
為什麼不存資料庫呢? 寫檔案的不太懂 幫頂下.
------解決方案--------------------
// 訪客計數器函數
function counter() {
!empty($_GET['weburl'])
------解決方案--------------------
die('weburl不可為空');
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.