好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > php實現(xiàn)統(tǒng)計IP數(shù)及在線人數(shù)的示例代碼

php實現(xiàn)統(tǒng)計IP數(shù)及在線人數(shù)的示例代碼

熱門標簽:梧州市機器人外呼系統(tǒng)怎么樣 電子地圖標注怎么修改 地圖標注符號樣式有 菏澤語音外呼系統(tǒng)運營商 臨沂crm外呼系統(tǒng)平臺 如何在世界地圖標注 廈門400電話辦理選易號網 公司外呼系統(tǒng)中心 天客通地圖標注

寫在前面的話

很多人有這樣的需求,就是統(tǒng)計網站訪問IP以及在線的人數(shù)。今天我們就看一下具體實現(xiàn)方法。

開啟依賴函數(shù)模塊

實現(xiàn)這個功能,需要依賴putenv()函數(shù)。下面兩種方式均可。

更改php.ini文件方法

找到php.ini文件,搜索putenv關鍵字,刪除即可。

isable_functions = passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv

使用寶塔面板

點擊左側軟件管理,找到php,然后設置->禁用函數(shù)。

刪除putenv,然后重啟php即可。

實現(xiàn)函數(shù)

在count.php同目錄下創(chuàng)建文件:count,temp,online。新建文本文檔count.txt,去掉擴展名即為count了;

linux系統(tǒng)中請設置文件屬性為:777。

文件count.php代碼,用到了php函數(shù)--explode、isset、empty及sprintf等:

?php
$file       = "count"; // 記數(shù)文件名稱
$startno     = "1000";  // 起始數(shù)值
$tempfile     = "temp"; 
$t_now  = time();
$t_array = getdate($t_now);
$day   = $t_array['mday'];
$mon   = $t_array['mon'];
$year  = $t_array['year'];
if (file_exists("$file")) {
    $count_info=file("$file");
    $c_info = explode(",", $count_info[0]);
    $total_c=$c_info[0];
    $yesterday_c=$c_info[1];
    $today_c=$c_info[2];
    $lastday=$c_info[3];
} else {
    $total_c="$startno";
    $yesterday_c="0";
    $today_c="0";
    $lastday="0";
}
 
if ( !isset($HTTP_COOKIE_VARS["countcookie"]) || $HTTP_COOKIE_VARS["countcookie"] != $day) {
    $your_c=1;
    $lockfile=fopen("temp","a");
    flock($lockfile,3);
    putenv('TZ=JST-9');
 
    $t_array2 = getdate($t_now-24*3600);
    $day2=$t_array2['mday'];
    $mon2=$t_array2['mon'];
    $year2=$t_array2['year'];
    $today = "$year-$mon-$day";
    $yesterday = "$year2-$mon2-$day2";
    if ($today != $lastday) {
  
           if ($yesterday != $lastday) $yesterday_c = "0";
               else $yesterday_c = $today_c;
  
        $today_c = 0;
        $lastday = $today;
    }
    $total_c++;
    $today_c++;
    $total_c   = sprintf("%06d", $total_c);
    $today_c   = sprintf("%06d", $today_c);
    $yesterday_c = sprintf("%06d", $yesterday_c);
    setcookie("countcookie","$day",$t_now+43200);
    $fp=fopen("$file","w");
    fputs($fp, "$total_c,$yesterday_c,$today_c,$lastday");
    fclose($fp);
    fclose($lockfile);
}
if ( empty( $your_c ) ) $your_c = 1;
setcookie("yourcount",$your_c+1,$t_now+43200);
$your_c = sprintf("%06d", $your_c);
//////////////////////////開始統(tǒng)計在線
$filename="online";
$onlinetime=600; //同一IP在線時間,單位:秒
$online_id=file($filename);
$total_online=count($online_id);
$ip=getenv("REMOTE_ADDR");
$nowtime=time();
 for($i=0;$i$total_online;$i++){
     $oldip=explode("||",$online_id[$i]);
     $hasonlinetime=$nowtime-$oldip[0];
 if($hasonlinetime$onlinetime and $ip!=$oldip[1]) $nowonline[]=$online_id[$i];
                 }
     $nowonline[]=$nowtime."||".$ip."||";
     $total_online=count($nowonline);
     $fp=fopen($filename,"w");
     rewind($fp);
     for($i=0;$i$total_online;$i++){
     fputs($fp,$nowonline[$i]);
     fputs($fp,"n");
                 }
 fclose($fp);
   if($total_online==0)$total_online=1;
        $total_online = sprintf("%06d", $total_online);
///////////////////////////////////////////////////////
echo "document.write("·總IP訪問:".$total_c."");";
echo "document.write("br>");";
echo "document.write("·昨日訪問:".$yesterday_c."");";
echo "document.write("br>");";
echo "document.write("今日IP:".$today_c."");";
echo "document.write("nbsp;");";
echo "document.write("·您 訪 問:".$your_c."");";
echo "document.write("br>");";
echo "document.write("當前在線:".$total_online."");";
exit;
?>

調用

用JS調用文件count.php

在需要加入統(tǒng)計的的地方,添加:

script src="/php/count.php">/script>

到此這篇關于php實現(xiàn)統(tǒng)計IP數(shù)及在線人數(shù)的示例代碼的文章就介紹到這了,更多相關php 統(tǒng)計IP數(shù)及在線人數(shù)內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • PHP獲取真實IP及IP模擬方法解析
  • php判斷IP地址是否在多個IP段內
  • bt寶塔面板php7.3、php7.4不支持ZipArchive解決方法
  • 通過PHP實現(xiàn)獲取訪問用戶IP
  • PHP Pipeline 實現(xiàn)中間件的示例代碼
  • 原生javascript的ajax請求及后臺PHP響應操作示例
  • php利用ZipArchive類操作文件的實例
  • PHP生成zip壓縮包的常用方法示例
  • php解壓縮zip和rar壓縮包文件的方法
  • PHP基于ip2long實現(xiàn)IP轉換整形

標簽:郴州 貴陽 雞西 白城 綿陽 黃石 瀘州 迪慶

巨人網絡通訊聲明:本文標題《php實現(xiàn)統(tǒng)計IP數(shù)及在線人數(shù)的示例代碼》,本文關鍵詞  php,實現(xiàn),統(tǒng)計,數(shù),及,在線,;如發(fā)現(xiàn)本文內容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內容系統(tǒng)采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《php實現(xiàn)統(tǒng)計IP數(shù)及在線人數(shù)的示例代碼》相關的同類信息!
  • 本頁收集關于php實現(xiàn)統(tǒng)計IP數(shù)及在線人數(shù)的示例代碼的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 大地资源中文在线观看免费版高清| 亚洲 欧美 中文 日韩超碰| 被夫上司侵犯| 真人抽搐一进一出gif动态图| 国内精品久久久久尤物| 恶作剧之吻第一部| 国产成a人片在线观看网站| 久久综合九色综合欧美狠狠| a级无毛片| 99热99在线| 丰满做爰冲田杏梨在线| 巨胸喷奶水www久久久| 特级淫片欧美高清视频zozozo| 图书馆的她| 国产偷自视频在线观看| 且末县| 337P日本粉嫩噜噜噜| 两个人一起差差差的视频| 欧美色穴| 日本大乳奶水奶水免费| 办公室啊啊啊| 男人猛激烈吃奶gif动态图| 隔着校服揉h奶水H| 中国人与黑人xxxx视频| 黄色三节片| 又粗又硬又爽视频| 香港一级爽快片婬片A片免费| 亚洲日本bbw护士| 日本三级香港三级人妇网站| 操女人逼的视频| 免费看无码生交大片| 日本工番口番| 无线乱码一二三区免费看| 黑人粗大长爽久久A片| 操白虎| 日久成瘾糙汉h1vl1| 动漫迷黄www免费观看| 久久精品91佛爷大战美容院| 高潮夹H震蛋按摩椅| 国产清纯白嫩学生无t进| 一色桃子理性狂乱的我|