webForumDet fria alternativet

Global.aset

ASPur ASP

3 svar · 188 visningar · startad av Jesper T

Medlem sedan nov. 20017 144 inlägg
Frågan#1

När jag använder global.asa till min "online"-counter så försvinner mina chatrum, beroende på vart jag lägger raden. Eller så funkar inte räknaren. Detta är oberoende av räknare, jag har provat ett tre-fyra stycken, si så där. Hur göra??

Medlem sedan jan. 20013 341 inlägg
#2

vet inte om det hjälper dig, men så här ser min global.asa ut:

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

Sub Application_OnStart
	' Set our user count to 0 when we start the server
	Application("ActiveUsers") = 0
 	Application("active_users")=""

     '###########################################################
     ' set title
     Application("Title") = "ASP Chat"
     ' Create your chat rooms below, do not modify anything else/
     CreateRoom "Data", "Diskutera data"
     CreateRoom "Kärlek", "Kärleksnästet"
     CreateRoom "Allmän", "Allt mellan himmel och jord"
     CreateRoom "Sport", "Sportfånar"
     '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

End Sub

Sub Session_OnStart
	Session("Usname")=""
' Change Session Timeout to 20 minutes (if you need to)
	Session.Timeout = 10
	' Set a Session Start Time
	' This is only important to assure we start a session
	Session("Start") = Now
	' Increase the active visitors count when we start the session
	Application.Lock
		Application("ActiveUsers") = Application("ActiveUsers") + 1
	Application.UnLock
End Sub

Sub Session_OnEnd
	' Decrease the active visitors count when the session ends.
	Application.Lock
		Application("ActiveUsers") = Application("ActiveUsers") - 1
	Application.UnLock
     un=Session("Usname")
     if un<>"" and Application("active_users")<>"" then
	tmp=Application("active_users")
	idx=instr(tmp,un & "*")
	tmp2=left(tmp,idx-1) & right(tmp,len(tmp)-idx-len(un))
	Application("active_users")=tmp2
      end if

    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

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>

har onlineräknare och chat, mina chatrum är iofs nere nu, men det beror inte på global.asa utan lathet :e

Säg till om du vill ha mer beskrivning av hur du ska visa antalet online, chatrum mm, så svarar jag imorrn, när jag inte e så trött :e

------------------
Data-Doktorn
Min egen musik!
Mitt coverband

Medlem sedan nov. 20017 144 inlägg
#3

Jag har samma chat, men hur skriver jag ut användare online?

=application?eller?

/Jesper

Medlem sedan juni 200032 969 inlägg
#4

Enligt aleborgs kod:

Response.Write Application("ActiveUsers")

Mvh,

------------------
Don't panic!

133 ms totalt · 3 externa anrop · v20260731065814-full.25f56b17
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
129 ms — hämta tråd, inlägg och bilagor (db)