search
Homephp教程PHP源码php无需数据库访问者计数器(txt文本保存数据)

本款程序是利用php+txt实现的网页访问次数统计代码,要记录用户访问了页站页面的次数比较简单实用。

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


include ("counter.php")
?>

 代码如下 复制代码


 

访问者计数器




你是第 = $counter ?> 个来访者,
你的ip:= $ip ?>


 

 代码如下 复制代码

$fp = fopen("counter.txt","r+");
 $counter = fgets($fp,80);
 $counter = doubleval($counter) + 1;
 fseek ($fp,0);
 fputs($fp,$counter);
 fclose($fp);

/*
如果要把这个统计器做成图片的,可以加入下面代码,并且在images目录下做0,9命名的图片就ok了。
*/
 $number = strlen("$counter");
 for($i = 0;$i   $gra_counter = substr($counter,$i,1);
  $image = $image."php无需数据库访问者计数器(txt文本保存数据)";

 }


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";
}

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

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.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools