Home > php教程 > PHP源码 > body text

php无需数据库访问者计数器(txt文本保存数据)

WBOY
Release: 2016-06-08 17:26:24
Original
1808 people have browsed it

本款程序是利用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";
}

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template