教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php无需数据库访问者计数器(txt文本保存数据)

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

发布时间:2016-10-27   编辑:jiaochengji.com
教程集为您提供php无需数据库访问者计数器(txt文本保存数据)等资源,欢迎您收藏本站,我们将为您提供最新的php无需数据库访问者计数器(txt文本保存数据)资源
本款程序是利用php txt实现的网页访问次数统计代码,要记录用户访问了页站页面的次数比较简单实用。


include ("counter.php")
?>

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy8784')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy8784>

<html>
<head>

  <title>访问者计数器</title>

</head>
<body>
<center>
<font color = blue>你是第</font><font color = red> <?= $counter ?> </font><font color = blue>个来访者,</font>
<font color = blue>你的ip:</font><font color = red><?= $ip ?></font>
</center>
</body>
</html>

<?php

 

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy7453')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy7453>

$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<$number;$i ){
  $gra_counter = substr($counter,$i,1);
  $image = $image."<img src = 'images/".$gra_counter.".jpg'>";

 }


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

您可能感兴趣的文章:
php无需数据库访问者计数器(txt文本保存数据)
JDBC接口技术 <转>
php统计网站访问次数的一个简单方法
建立JSP操作以提高数据库访问的效率
BS结构中使用PHP访问ORACLE LOB
php源码该怎么设置数据库
php SQLserver 导入 Mysql
php怎么访问mysql的数组
php和jsp之间有哪些区别
php定时计划任务实例教程

[关闭]
~ ~