php统计IP以及在线人数的统计
1.用JS调用文件count.php 在你需要加入统计的的地方加入<script src="count.php"></script> 实际运用中注意修改路径!
2.php环境必须支持putenv()函数,可以统计昨日访问,今日访问,在线人数,您访问的次数。
3 . 在count.php相同目录建立以下文件 count,temp,online,新建文本文档count.txt 然后去掉扩展名就是文件count了;如果是Linux主机请把这三个文件属性设为777.
count.php文件代码:
<?
$file = "count"; // 记数文件名称
$startno = "1000"; // 起始数值
$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
相关文档:
PHPDocument是从你的源代码的注释中生成文档,因此在给你的程序做注释的过程,也就是你编制文档的过程。
从这一点上讲,PHPdoc促使你要养成良好的编程习惯,尽量使用规范,清晰文字为你的程序做注释,同时多多少少也避免了事后编制文档和文档的更新不同步的一些问题。
在phpdocumentor中,注释分为文档性注 ......
生成6 ~ 16位的用户名若干个,主要是文本操作,但是前提是要有一个字符串包。主要包含三个程序。
程序一:负责从字典中随机提取数据,写入一个新文件。(1.php)
<?php
/* 从字典文件中提取随机值 */
$file1 = "./Words.dic";
$file2 = "./common_pass_mini.dic";
$file3 = "./Sys_Month_Date.Dic";
$rfile = "./ ......
批量去除BOM的程序
function
replace_utf8bom(
$str
)
{
$charset
[1] =
substr
(
$str
,0,1);
$charset
[2] =
substr
(
$str
,1,1);
$ch ......
我们常常在网站上看到某篇文章发表于“3天前”,“5个月前”,“4年前”。下面这个函数就提供了计算这个时间差的功能。
<?php
/**
* 时间差计算
*
* @param Timestamp $time
* @return String Time Elapsed
* @author Shelley Shyan
* @copyright http://phparch.cn (Professiona ......