/**
*
* 计数器(v1.1.0)
*
* Version : 1.1.0
* Author : 村长
* PHP : >4.3
*
*/
class Counter
{
var $CountFolder;
var $countType;
var $showtype;
var $imgArray;
function Counter()
{
$this->countType = 0;
$this->showtype = "GetCountByDay";
$this->imgArray = array();
$this->MakeCounter();
}
function MakeCounter()
{
$this->CountFolder = "log/".date("Ymd");
if(!is_dir($this->CountFolder))
{
mkdir($this->CountFolder,0777);
}
$this->_DoCount();
}
//Save data file
function _DoCount()
{
$file = date("Ymd").ip2long($_SERVER['REMOTE_ADDR']).".txt";
if(!file_exists($this->CountFolder."/".$file))
{
$fp = @fopen($this->CountFolder."/".$file,"wb+");
//这里可以保存其他需要的日志记录
@fputs($fp,$_SERVER['REMOTE_ADDR']);
@fclose($fp);
}
}
//获得指定时间的统计数据
//默认为1天 0 为取所有
function GetCountByDay($day=1)
{
//今日的时间戳
$today = strtotime(date("Y-m-d"));
$all = 0;
for($i=$day;$i>=0;$i--)
{
$tsp = $today-(86400*$i);
$folder = "log/".date("Ymd",$tsp)."/*.txt";
$ta = glob("$folder");
$all= $all+ count($ta);
}
return $all;
}
function GetCountUseImg($day=1)
{
$allnumber = $this->GetCountByDay($day);
for($i=0;$istrlen($allnumber);$i++)
{
$idx = substr($allnumber,$i,1);
$returnVal.= sprintf("",$this->imgArray[$idx]);
}
return $returnVal;
}
function SetStyle($style='',$ext="gif")
{
$imgprefix ="img/";
$folder = $imgprefix.$style;
foreach(range(0,9) as $num)
{
$this->imgArray[$num] = $folder."/".$num.".$ext";
}
if(is_dir($folder))
{
$this->showtype = "GetCountUseImg";
}
else
{
$this->showtype = "GetCountByDay";
}
}
function Show($day=0)
{
return $this->{$this->showtype}($day);
}
}
//实例计数器对象
$counter = new Counter();
//采用 sports98 样式显示,告知默认扩展名为png格式
$counter->SetStyle("sports98","png");
echo "
今日访问:".$counter->Show(0);
//采用S1样式显示,默认扩展名为 gif
$counter->SetStyle("s1");
echo "
近3日访问:".$counter->Show(2);
//----只显示文字的计数器
$counter->SetStyle("-");
echo "
近3日访问:".$counter->Show(2);
?>

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境

Atom编辑器mac版下载
最流行的的开源编辑器

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)