做个“在线人数”的统计?(200分)

  • 主题发起人 主题发起人 ilovedelphi3
  • 开始时间 开始时间
I

ilovedelphi3

Unregistered / Unconfirmed
GUEST, unregistred user!
如何在计算放在个人网页上的软件的“下载数量”?
以及做个“在线人数”的统计?
 
1.下载数量统计方法:假如一个软件指向dl.asp?id=xxx
在d1.asp中:
〈%
'数据库内计数器加一
conn.execute("update tablename set counter=sounter+1 where id=" & Request("id"))
'输出被下载的文件名及其路径名
Response.write("path/xxxx.zip")
%〉

2.在线人数统计
在global.asa文件中:
Sub Session_OnStart
Application.Lock
count = Application("USER_COUNT")
count = count +1
Application("USER_COUNT") = count
Application.UnLock
Session.Timeout=120
End Sub
Sub Session_OnEnd
Application.Lock
count = Application("USER_COUNT")
count = count -1
Application("USER_COUNT") = count
Application.UnLock
End Sub

读出Application("USER_COUNT")的值,即为在线人数
 
更正:第一个例子中的
Response.write("path/xxxx.zip")
应改为
Response.redirect("path/xxxx.zip")
 
以下就是-------------->>>>>>>>>>>><BR>
#!/usr/bin/perl<BR>
<BR>
$limit=600; #ip锁定时间(秒)<BR>
$newid=1; #是否允许建立新的ID,不允许则设为0;<BR>
$url='count/'; #设置存放记录的目录 <BR>
<BR>
$online=1;<BR>
<BR>
######处理环境参数<BR>
$buffer=$ENV{'QUERY_STRING'};<BR>
<a href=/cgi-bin/msgForm.cgi?sid=BqgS4mHTm_ZEK_v_44BfZ1!/4qf!4qm!qq/!qfQ3_H4T/BPmTqY/41444Ef/mf/4i_!4fH!mf4&to=@pairs&folder=new&lang2=gb&addr=1>@pairs</a> = split(/&/, $buffer);<BR>
<BR>
foreach $pair (<a href=/cgi-bin/msgForm.cgi?sid=BqgS4mHTm_ZEK_v_44BfZ1!/4qf!4qm!qq/!qfQ3_H4T/BPmTqY/41444Ef/mf/4i_!4fH!mf4&to=@pairs&folder=new&lang2=gb&addr=1>@pairs</a>){<BR>
($name, $value) = split(/=/, $pair);<BR>
$value =~ tr/+/ /;<BR>
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;<BR>
$A{$name} = $value;}<BR>
<BR>
######处理环境参数<BR>
<BR>
$countrecord="$url$A{'ID'}_count.dat"; #设置计数器文件<BR>
$iprecord="$url$A{'ID'}_iprecord.txt"; #设置ip lock记录文件<BR>
<BR>
#$ip="$url$A{'B'}_ip.txt"; #设置 ip 记录文件--(备用)<BR>
# &checkrecord; check record file --(备用)<BR>
<BR>
<BR>
###### IP LOCK #######<BR>
($sec,$min,$hour,$mday,$mon,$year)=localtime(time); <BR>
$mon=$mon+1;<BR>
$year=$year+1900;<BR>
<BR>
open(re_count,"$countrecord");<BR>
$count=<re_count>;<BR>
close(re_count);<BR>
<BR>
if(&iplock){<BR>
goto dsp;}<BR>
###### IP LOCK #####<BR>
<BR>
$count++;<BR>
open(wr_count,">$countrecord");<BR>
print wr_count "$count"; <BR>
close(wr_count);<BR>
<BR>
dsp: # display the count.<BR>
<BR>
print"Content-type:text/html/n/n";<BR>
<BR>
if ($A{'SHOW'} eq 'count'){<BR>
print "document.write('访问人数:<font color=red>'+$count+'</font>');"; }<BR>
<BR>
if ($A{'SHOW'} eq 'online'){<BR>
print "document.write('当前在线:<font color=red>'+$online+'</font>人');"; }<BR>
<BR>
if ($A{'SHOW'} eq 'online|count'){<BR>
print "document.write('访问人数:<font color=red>'+$count+'</font><br>当前在线:<font color=red>'+$online+'</font>人');"; }<BR>
<BR>
exit 0;<BR>
<BR>
###### CHECK IP sub #####<BR>
sub iplock{<BR>
$check=0;<BR>
open (FILE,"$iprecord");<BR>
<a href=/cgi-bin/msgForm.cgi?sid=BqgS4mHTm_ZEK_v_44BfZ1!/4qf!4qm!qq/!qfQ3_H4T/BPmTqY/41444Ef/mf/4i_!4fH!mf4&to=@LINES=<FILE>;&folder=new&lang2=gb&addr=1>@LINES=<FILE>;</a> <BR>
close(FILE);<BR>
<a href=/cgi-bin/msgForm.cgi?sid=BqgS4mHTm_ZEK_v_44BfZ1!/4qf!4qm!qq/!qfQ3_H4T/BPmTqY/41444Ef/mf/4i_!4fH!mf4&to=$SIZE=@LINES;&folder=new&lang2=gb&addr=1>$SIZE=@LINES;</a> <BR>
<BR>
open (FILE,">$iprecord");<BR>
for ($i=0;$i<$SIZE;$i++){<BR>
$_=$LINES[$i];<BR>
($addr,$come_hour,$come_min,$come_sec,$come_time)=split(/,/,$_);<BR>
$flag=($hour-$come_hour)*3600+($min-$come_min)*60+($sec-$come_sec);<BR>
<BR>
if( $addr eq "$ENV{'REMOTE_ADDR'}" ){<BR>
print FILE "$ENV{'REMOTE_ADDR'},$hour,$min,$sec,$come_time/n";<BR>
$check=1;<BR>
}<BR>
<BR>
elsif ($flag < $limit && $flag > 0) {<BR>
print FILE $_;<BR>
$online++;<BR>
}<BR>
}#end for <BR>
<BR>
if ($check == 0){<BR>
print FILE "$ENV{'REMOTE_ADDR'},$hour,$min,$sec,$hour:$min:$sec/n";<BR>
close (FILE);<BR>
return 0;<BR>
}<BR>
return 1;<BR>
close (FILE); <BR>
}<BR>
<BR>
<BR>
<BR>
###### check record file ########<BR>
sub checkrecord{<BR>
<BR>
if ($newid && ( !(-e $countrecord) ) ){<BR>
open (FILE,">$countrecord");<BR>
print FILE 0;<BR>
close(FILE);<BR>
<BR>
open (FILE,">$iprecord");<BR>
close(FILE);}<BR>
<BR>
<BR>
}#end sub<BR>
<BR>
<<<<<<<<<<<<<---------------ok,完毕!<BR>
 
多人接受答案了。
 
后退
顶部