⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chat-count.pl

📁 java开发的聊天室
💻 PL
字号:
sub count
{
$vflag=0;
&lockfile("$filehead$countfile");
open(COUNTFILE,"$filehead$countfile");
@line=<COUNTFILE>;
close(COUNTFILE);
open(COUNTFILE,">$filehead$countfile");
foreach (@line)
{
	($vtime,$vcount)=split(/:/,$_);
	if ($vtime eq $daten)
	{
		chop($vcount);
		$vcount=$vcount+1;
		print COUNTFILE "$daten:$vcount\n";
		$vflag=1;
	}
	else {print COUNTFILE "$vtime:$vcount";}
}
close(COUNTFILE);
&unlockfile("$filehead$countfile");
if ($vflag eq 0)
{
	&lockfile("$filehead$countfile");
	open(COUNTFILE,">>$filehead$countfile");
	print COUNTFILE "$daten:1\n";
	close(COUNTFILE);
	&unlockfile("$filehead$countfile");
}

#记录当天访问帐号和次数
$vflag=0;
&lockfile("$filehead$nowuserfile");
open(NOWUSERFILE,"$filehead$nowuserfile");
@line=<NOWUSERFILE>;
close(NOWUSERFILE);
open(NOWUSERFILE,">$filehead$nowuserfile");
foreach (@line)
{
	($vtime,$userid,$vcount)=split(/:/,$_);
	if ($vtime eq $daten) 
	{
		if ($userid eq $username)
		{
			chop($vcount);
			$vcount=$vcount+1;
			print NOWUSERFILE "$daten:$userid:$vcount\n";
			$vflag=1;
		}
		else {	print NOWUSERFILE "$daten:$userid:$vcount";}
	}
	
}
close(NOWUSERFILE);
&unlockfile("$filehead$nowuserfile");
if ($vflag eq 0)
{
	&lockfile("$filehead$nowuserfile");
	open(NOWUSERFILE,">>$filehead$nowuserfile");
	print NOWUSERFILE "$daten:$username:1\n";
	close(NOWUSERFILE);
	&unlockfile("$filehead$nowuserfile");
}


}
sub showcount
{
&send_html;
print "<html><head><title>每天访问人次(供管理员用)</title>";
print "<LINK REL=stylesheet HREF='$cssurl' TYPE='text/css'>";
print "</head><body bgcolor=$funcback text=$funcword><center>";
print "访问人次统计表<br><BR>";
&lockfile("$filehead$countfile");
open(COUNTFILE,"$filehead$countfile");
@line=<COUNTFILE>;
close(COUNTFILE);
&unlockfile("$filehead$countfile");
$tcount=0;
print "<table border=1>";
print "<tr><td align=center>统计时间</td><td align=center colspan=2>前7日访问次数</td></tr>";
@tempcount;
@tempcount1;
$temp1=0;
foreach (@line)
{
	($vtime1,$vcount1)=split(/:/,$_);
	chop($vcount1);
	$tcount=$tcount+$vcount1;
	$tempcount[$temp1]=$vcount1;
	$tempcount1[$temp1]=$vtime1;
	$temp1=$temp1+1;
}
$firstday=$tempcount1[0];
for ($i=0;$i<$temp1;$i++)
{
	for ($j=0;$j<$i;$j++)
	{
		if ($tempcount[$i]>$tempcount[$j])
		{
			$temp2=$tempcount[$j];
			$tempcount[$j]=$tempcount[$i];
			$tempcount[$i]=$temp2;
			$temp3=$tempcount1[$j];
			$tempcount1[$j]=$tempcount1[$i];
			$tempcount1[$i]=$temp3;			
		}
		
	}
}

if ($temp1<7) {$temp10=0;} else {$temp10=$temp1-7;}

for ($i=$temp10;$i<$temp1;$i++)
{
	($vtime,$vcount)=split(/:/,$line[$i]);
	chop($vcount);
	$vwidth=($vcount/$tempcount[0])*400;
	print "<tr><td align=center>$vtime</td><td>$vcount</td><td><img src=$gifhead$linegif width=$vwidth height=10></td></tr>";
}
print "自[$firstday]累计访问人次:$tcount &nbsp;&nbsp;&nbsp;&nbsp;最高记录:[$tempcount1[0]]$tempcount[0]";
print "</table>";

print "<br>当天[$daten]访问人次<br>";
&lockfile("$filehead$nowuserfile");
open(NOWUSERFILE,"$filehead$nowuserfile");
@members=<NOWUSERFILE>;
close(NOWUSERFILE);
&unlockfile("$filehead$nowuserfile");
print "<table border=1>";
$rowcount=10; 			#每行显示人数
for ($i=0;$i<1000;$i++)
{
	print "<tr>";
	for ($j=0;$j<$rowcount;$j++)
	{
		$tempdate=substr($members[$i*$rowcount+$j],0,10);
		if ($tempdate eq $daten) 
		{
			$tempname=substr($members[$i*$rowcount+$j],11,length($members[$i*$rowcount+$j]));
			if ($tempname ne $zhanzhang)
			{
				print "<td>$tempname</td>";
			}
		}
	}
	print "</tr>";
	last if(($i*$rowcount+$j)>($#members));	
}
print "</table>";
print "</center></body></html>";
}
1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -