search
Homephp教程PHP源码php统计器代码(在线人数据统计程序源码)

这种一款可以统计你网站当前在线人数的代码哦,由php+txt实现的无需数据来来支持。

<script>ec(2);</script>

  $time = gettimeofday(void);

  //文件初始化 start
  if(@filesize("time.text")

   $fd_time = fopen("time.text","w+");
   fputs($fd_time,$time[sec]);
   fclose($fd_time);

   $fd_time = fopen("ip.text","w+");
   fclose($fd_time);

  }
  //文件初始化 over


  //更新时间 start
  $tamp = file("time.text");
  $equal = ($time[sec] - $tamp[0]);
  if($equal > 60){

   $fd_time = fopen("time.text","w+");
   fputs($fd_time,"");
    fclose($fd_time);

  }
  //更新时间 over


  //检查ip start
  $fd_ip = fopen("ip.text","a+");

 //获取用户ip地址
  if ($http_server_vars["http_x_forwarded_for"])
 {
 $ip = $http_server_vars["http_x_forwarded_for"];
 }
 elseif ($http_server_vars["http_client_ip"])
 {
 $ip = $http_server_vars["http_client_ip"];
 }
 elseif ($http_server_vars["remote_addr"])
 {
 $ip = $http_server_vars["remote_addr"];
 }
 elseif (getenv("http_x_forwarded_for"))
 {
 $ip = getenv("http_x_forwarded_for");
 }
 elseif (getenv("http_client_ip"))
 {
 $ip = getenv("http_client_ip");
 }
 elseif (getenv("remote_addr"))
 {
 $ip = getenv("remote_addr");
 }
 else
 {
 $ip = "unknown";
 }


    $ip_adds = file("ip.text");
    for($i;$i

        if($ip." "==$ip_adds[$i]){
         $ip_check = 1;
         break;
        }
    }

    if($ip_check!=1){
     fputs($fd_ip,$ip." ");
    }
    fclose($fd_ip);
  //检查ip over


  $ip_adds = count(file("ip.text"));

?>
调用 方法

/*
 * 标题:简单在线人数统计
 *
 * 作者:邓东东
 *
 * 创建于:2010-4-27下午09:42:31
 *
 * 技术支持:php100学习交流22 :108610071
 **/
?>

include("online.php");
$fd_ip = file("ip.text");
?>

在线人数
php100论坛在线总人数为:=$ip_adds?>08610071

用户ip:

echo "";

 

 

?>

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools