...

View Full Version : how i can diplay how many guest online



bmwmpower
02-17-2003, 01:51 PM
i want to know how i can display how many guest online and how many member online
example


there are * guest online and there are * member online

my member take session

anyone can help me

Spudhead
02-17-2003, 03:59 PM
Quick answer:

Have a search on google about 4 functions you can put in your global.asa -

Application_onStart
Application_onEnd
Session_onStart
Session_onEnd

Basically, when your application starts, Dim a global counter variable (say, "myUserCounter"). For each session that starts, (or ends) add (or subtract) one from this variable; your current user numbers will then be accessible via 'Application(myUserCounter)'

Any use?

whammy
02-19-2003, 01:48 AM
http://www.w3schools.com/asp/asp_globalasa.asp

bmwmpower
02-22-2003, 11:55 AM
sorry can anyone help me what is the wrong in this code in fiele global.asa


<SCRIPT RUNAT=Server lANGUAGE=VBScript>
ReDim TopicName(0)
ReDim TopicDescription(0)

Sub Application_OnStart

Application("Active")=0
Dim objFS1 , objTextS1 , strLine1, path1
Set objFS1 = Server.CreateObject("Scripting.FileSystemObject")
path1 = Server.MapPath("counter.txt")
Set objTextS1 = objFS1.OpenTextFile(path1,1,0)

Do While objTextS1.AtEndOfStream <> True
strLine1 = objTextS1.ReadLine
strLine1 = Server.HTMLEncode(strLine1)

Loop
objTextS1.Close
Set objTexts1 = Nothing
Set objFs1 = Nothing

Application("logflag") = 0
Application("usercounter") = CInt(strLine1)

'###########################################################
' set title
Application("Title")="ASP Chat"
' Create your chat rooms below, do not modify anything else/
CreateRoom "Egypt", "ASP fiends sharing dope"
CreateRoom "ASP Joint2", "ASP fiends sharing dope"
CreateRoom "ASP Joint3", "ASP fiends sharing dope"
CreateRoom "Room Name", "Room Description"
'###########################################################

Application("TopicNames") = TopicName
Application("TopicDescriptions") = TopicDescription

Dim Users()
Redim Users(1)
Dim UsersGroup()
Redim UsersGroup(1)
Application("Users") = Users
Application("UsersGroup") = UsersGroup

Dim UsersIP()
Redim UsersIP(1)
Dim UsersTimeOn()
Redim UsersTimeOn(1)
Dim UsersIdleOn()
Redim UsersIdleTime(1)
Application("UsersIP") = UsersIP
Application("UsersTimeOn") = UsersTimeOn
Application("UsersIdleTime") = UsersIdleTime


Dim userscnn , usersrs
Set userscnn = Server.CreateObject("ADODB.Connection")

userscnn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("search.mdb") & ";"
Set usersrs = Server.CreateObject("ADODB.Recordset")
usersrs.Open "SELECT User_Name FROM users ORDER BY User_Name ASC", userscnn , 1, 2


Do While Not usersrs.EOF
Application(usersrs("User_Name")) = "offline"
usersrs.MoveNext
Loop

End Sub

Sub Application_OnEnd

End Sub


Sub Session_OnStart

Session.Timeout=5
Session("Start")=Now
Application.Lock
Application("Active")=Application("Active")+1
'this adds 1 to the number of active users when a new user hits
Application.unlock
Application("usercounter") = Application("usercounter") + 1
Session("startchat") = "no"
Session("logoff") = 0
Session("type") = 2

Dim objFS2 , objTextS2 , strLine2
Set objFS2 = Server.CreateObject("Scripting.FileSystemObject")
path2 = Server.MapPath("counter.txt")
Set objTextS2 = objFS2.OpenTextFile(path2,2,0)
objTextS2.WriteLine Application("usercounter")

End Sub
Sub FrontPage_StartSession
On Error Resume Next
if Len(Application("FrontPage_VRoot")) > 0 then Exit Sub

sFile = "global.asa"
sRootPath = Request.ServerVariables("APPL_PHYSICAL_PATH")
if Left(sRootPath,1) = "/" then sSep = "/" else sSep = "\"
if Right(sRootPath,1) <> sSep then sRootPath = sRootPath & sSep
sRootPath = sRootPath & sFile

' discover the VRoot for the current page;
' walk back up VPath until we match VRoot
Vroot = Request.ServerVariables("PATH_INFO")
iCount = 0
do while Len(Vroot) > 1
idx = InStrRev(Vroot, "/")
if idx > 0 then
Vroot = Left(Vroot,idx)
else
' error; assume root web
Vroot = "/"
end if
if Server.MapPath(Vroot & sFile) = sRootPath then exit do
if Right(Vroot,1) = "/" then Vroot = Left(Vroot,Len(Vroot)-1)
iCount = iCount + 1
if iCount > 100 then
' error; assume root web
Vroot = "/"
exit do
end if
loop
' map all URL= attributes in _ConnectionString variables
Application.Lock
if Len(Application("FrontPage_VRoot")) = 0 then
Application("FrontPage_VRoot") = Vroot
UrlVarArray = Application("FrontPage_UrlVars")
for i = 0 to UBound(UrlVarArray)
if Len(UrlVarArray(i)) > 0 then FrontPage_MapUrl(UrlVarArray(i))
next
end if
Application.Unlock
End Sub
Sub FrontPage_MapUrl(AppVarName)
' convert URL attribute in conn string to absolute file location
strVal = Application(AppVarName)
strKey = "URL="
idxStart = InStr(strVal, strKey)
If idxStart = 0 Then Exit Sub
strBefore = Left(strVal, idxStart - 1)
idxStart = idxStart + Len(strKey)
idxEnd = InStr(idxStart, strVal, ";")
If idxEnd = 0 Then
strAfter = ""
strURL = Mid(strVal, idxStart)
Else
strAfter = ";" & Mid(strVal, idxEnd + 1)
strURL = Mid(strVal, idxStart, idxEnd - idxStart)
End If
strOut = strBefore & Server.MapPath(Application("FrontPage_VRoot") & strURL) & strAfter
Application(AppVarName) = strOut

End Sub

Sub Session_OnEnd

Topic = Session("Topic")
Name = Session("Name")

Users = Application("Users")
UsersIP = Application("UsersIP")
UsersTimeOn = Application("UsersTimeOn")
UsersIdleTime = Application("UsersIdleTime")

Match = 1
If IsArray(Users) Then
UsersGroup = Application("UsersGroup")
NumOfUsers = UBound(Users)
If NumOfUsers = 1 Then
Set Application("Users") = Nothing
Set Application("UsersGroup") = Nothing

Set Application("UsersIP") = Nothing
Set Application("UsersIdleTime") = Nothing
Set Application("UsersTimeOn") = Nothing
Else
ReDim UpdatedUsers(1)
ReDim UpdatedUsersGroup(1)

ReDim UpdatedUsersIP(1)
ReDim UpdatedUsersTimeOn(1)
ReDim UpdatedUsersIdleTime(1)
For I = 1 To NumOfUsers
If Name <> Users(I) Then
ReDim Preserve UpdatedUsers(Match)
ReDim Preserve UpdatedUsersGroup(Match)
UpdatedUsers(Match) = Users(I)
UpdatedUsersGroup(Match) = UsersGroup(I)


ReDim Preserve UpdatedUsersIP(Match)
ReDim Preserve UpdatedUsersTimeOn(Match)
ReDim Preserve UpdatedUsersIdleTime(Match)
UpdatedUsersIP(Match) = UsersIP(I)
UpdatedUsersTimeOn(Match) = UsersTimeOn(I)
UpdatedUsersIdleTime(Match) = UsersIdleTime(I)

Match = Match + 1
End If
Next
Application("Users") = UpdatedUsers
Application("UsersGroup") = UpdatedUsersGroup

Application("UsersIP") = UpdatedUsersIP
Application("UsersTimeOn") = UpdatedUsersTimeOn
Application("UsersIdleTime") = UpdatedUsersIdleTime

End If
End If


Set fileObject = Server.CreateObject("Scripting.FileSystemObject")
textFile = Application("filebase") & Replace(Topic, "+", "_") & ".txt"
'If fileObject.FileExists(textfile) Then
Set inStream = fileObject.OpenTextFile(textFile,1,TRUE,FALSE)
file = inStream.ReadAll
Set inStream = Nothing

file = file & "<FONT SIZE=2 FACE='Vedana,Arial' Color=#808080><b>***[" & Name & " has exited (" & Now & ")]***</b></FONT><br>"
Set outStream = fileObject.CreateTextFile(textFile,True)
outStream.WriteLine(file)
outStream.Close
Set outStream = Nothing
'End If

Session("Enter") = True

Application.Lock
Application("Active")=Application("Active")-1
'this subtracts 1 from the number of active users when a new user leaves
Application.unlock
Application(Session("temp")) = "offline"
End Sub

Sub CreateRoom(Name, Description)
nLen = UBound(TopicName)+1
ReDim Preserve TopicName(nLen)
TopicName(nLen) = Name
ReDim Preserve TopicDescription(nLen)
TopicDescription(nLen) = Description

End Sub

</SCRIPT>

oracleguy
02-22-2003, 10:21 PM
Well considering the length of the file, could you perhaps tell us what error you are getting and on what line? Or what isn't working?

bmwmpower
02-23-2003, 11:23 AM
the problem in the Application("Active") not work i mean that the no. of guest online increase and not decrease
and the Sequence of the code



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum