| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 420 人关注过本帖
标题:[求助]如何编写论坛在线人数
只看楼主 加入收藏
charshen
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-4-18
收藏
 问题点数:0 回复次数:1 
[求助]如何编写论坛在线人数

如何编写论坛在线人数,和显示用户是否在线的方法。谢谢了!

搜索更多相关主题的帖子: 编写 
2006-04-18 16:48
zfjyyzycl
Rank: 2
等 级:论坛游民
帖 子:239
专家分:10
注 册:2006-4-15
收藏
得分:0 

这样调用
<td width="13%" style="font-size: 12px; color: #304618; font-family: 宋体">在线人数:</td>
<td width="13%" style="font-size: 12px; color: #304618; font-family: 宋体"> <img src="OnlineCount.asp"></td>

如果该文件的名称是:OnlineCount.asp的话

<%@ Language=JavaScript %>
<%
var strCountData="1234567890";
var theTime=new Date();

function GetOnline()
{
if (typeof(Application("GuestOnline"))=="undefined")
Application("GuestOnline")="0";
}

function CheckGuest()
{
file://Check Me
if (typeof(Session("test"))=="undefined")
Session("test")="guest";
var strUserName=String(Session("test"));
var strGuestOnline=String(Application("GuestOnline"));
var GuestArray=strGuestOnline.split("\n");
var i;
var iGuestNum;
if (typeof(Session("GuestNum"))=="undefined")
{
for (i=0;i<GuestArray.length;i++)
{
if (GuestArray[i]=="0") break;
}
Session("GuestNum")=i;
}

iGuestNum=Session("GuestNum")*1;
if (iGuestNum>10000)iGuestNum=10000;

var strFormatTime=theTime.getTime();
strFormatTime="0000000000000000000"+strFormatTime;
strFormatTime=strFormatTime.substr(strFormatTime.length-16,16);

GuestArray[iGuestNum]=strFormatTime+strUserName;

strGuestOnline=GuestArray.join("\n");
Application("GuestOnline")=strGuestOnline;

return 1;
}

function GetNumber()
{
file://Count Guests on line
var strFormatTime=theTime.getTime()-5*60*1000;
strFormatTime="0000000000000000000"+strFormatTime;
strFormatTime=strFormatTime.substr(strFormatTime.length-16,16);

var strGuestOnline=String(Application("GuestOnline"));
var GuestArray=strGuestOnline.split("\n");

var iGuestCounter=0;
var i;
for (i=0;i<GuestArray.length;i++)
{
if (GuestArray[i].substr(0,16)> strFormatTime)
iGuestCounter++;
else if (GuestArray[i].length>0)
GuestArray[i]="0";
}
strGuestOnline=GuestArray.join("\n");
Application("GuestOnline")=strGuestOnline;
strCountData=iGuestCounter;
return strCountData;
}

function OutPut()
{
var i;
strCountData=""+strCountData;

var strDigits= new Array(
"0","0x3c","0x66","0x66","0x66","0x66","0x66","0x66","0x66","0x66","0x3c", file://0
"1","0x30","0x38","0x30","0x30","0x30","0x30","0x30","0x30","0x30","0x30", file://1
"2","0x3c","0x66","0x60","0x60","0x30","0x18","0x0c","0x06","0x06","0x7e", file://2
"3","0x3c","0x66","0x60","0x60","0x38","0x60","0x60","0x60","0x66","0x3c", file://3
"4","0x30","0x30","0x38","0x38","0x34","0x34","0x32","0x7e","0x30","0x78", file://4
"5","0x7e","0x06","0x06","0x06","0x3e","0x60","0x60","0x60","0x66","0x3c", file://5
"6","0x38","0x0c","0x06","0x06","0x3e","0x66","0x66","0x66","0x66","0x3c", file://6
"7","0x7e","0x66","0x60","0x60","0x30","0x30","0x18","0x18","0x0c","0x0c", file://7
"8","0x3c","0x66","0x66","0x66","0x3c","0x66","0x66","0x66","0x66","0x3c", file://8
"9","0x3c","0x66","0x66","0x66","0x66","0x7c","0x60","0x60","0x30","0x1c"); file://9

var iCharCount=strCountData.length;
var iCharWidth=8;
var iCharHeight=10;
var theBit;
var theNum;
Response.ContentType ="image/x-xbitmap";
Response.Expires =0;

Response.Write ("#define counter_width "+ iCharWidth*iCharCount+"\r\n"); file://图形宽
Response.Write ("#define counter_height "+ iCharHeight+"\r\n"); file://图形高
Response.Write ("static unsigned char counter_bits[]={\r\n");

for (iRow=0;iRow<iCharHeight;iRow++)
for (i=0;i<iCharCount;i++)
{
theBit=strCountData.charAt(i);
for (k=0;k<strDigits.length;k+=(iCharHeight+1))
{
if (strDigits[k]==theBit)break;
}
if (k>=strDigits.length)k=0;
theOffset=k+1;

Response.Write (strDigits[theOffset+iRow]);
Response.Write (",");
}

Response.Write ("};\r\n");

}

GetOnline();
CheckGuest();
GetNumber();
OutPut();
%>

2006-04-18 23:00
快速回复:[求助]如何编写论坛在线人数
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028761 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved