to globa..asa'er
Hejjeg kører med 2 global.asa'er på mit webhotel, og det er så vidt jeg forstår ikke nogen god ide. Den ene som ligger i roden af www mappen ) viser blandt andet hvor mange som er online. Den anden ligger sammen med et ASP chatroom som jeg har downloadet og bruger på hjemmesiden.
Kan jeg "smelte" de to sammen så alt virker som det skal?
Tager jeg ganske enkelt koden fra den første og ligger ind i den anden?
de to filer se således ud:
den fra roden af www
[<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
' viser at vi starter fra 0 - kan ændres for evt snyd(!) ;o)
Application("ActiveUsers") = 0
End Sub
Sub Session_OnStart
' så er timeout'en på en session 10 minutter - kan ændres...
Session.Timeout = 10
Session("Start") = Now
Application.Lock
Application("ActiveUsers") = Application("ActiveUsers") + 1
Application.UnLock
End Sub
Sub Session_OnEnd
Application.Lock
Application("ActiveUsers") = Application("ActiveUsers") - 1
Application.UnLock
End Sub
</SCRIPT>]
Den som kom med chatten:
[' The BrowserType Session Object is declared before the RUNAT=Server script,
' so that we can use the RST("userAgent")=bc.browser code.
<OBJECT RUNAT=Server SCOPE=Session ID=BC PROGID="MSWC.BrowserType">
</OBJECT>
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
'==FrontPage Generated - startspan==
Dim FrontPage_UrlVars(2)
'--Project Data Connection
Application("reklamer_ConnectionString") = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=URL=databases/reklamer.mdb"
FrontPage_UrlVars(0) = "reklamer_ConnectionString"
Application("reklamer_ConnectionTimeout") = 15
Application("reklamer_CommandTimeout") = 30
Application("reklamer_CursorLocation") = 3
Application("reklamer_RuntimeUserName") = ""
Application("reklamer_RuntimePassword") = ""
'--Project Data Connection
Application("conquermarks_ConnectionString") = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=URL=databases/cmarks.mdb"
FrontPage_UrlVars(1) = "conquermarks_ConnectionString"
Application("conquermarks_ConnectionTimeout") = 15
Application("conquermarks_CommandTimeout") = 30
Application("conquermarks_CursorLocation") = 3
Application("conquermarks_RuntimeUserName") = ""
Application("conquermarks_RuntimePassword") = ""
'--
Application("FrontPage_UrlVars") = FrontPage_UrlVars
'==FrontPage Generated - endspan==
Application("activeUsers") = 0
End Sub
Sub FrontPage_StartSession
On Error Resume Next
if Len(Application("FrontPage_VRoot")) > 0 then Exit Sub
' discover the VRoot for the current page;
' walk back up VPath until we find global.asa
Vroot = Request.ServerVariables("PATH_INFO")
strG1 = "global.asa"
strG2 = "Global.asa"
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 FrontPage_FileExists(Server.MapPath(Vroot & strG1)) then exit do
if FrontPage_FileExists(Server.MapPath(Vroot & strG2)) 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
Function FrontPage_FileExists(fspath)
On Error Resume Next
FrontPage_FileExists = False
set fs = CreateObject("Scripting.FileSystemObject")
Err.Clear
set istream = fs.OpenTextFile(fspath)
if Err.Number = 0 then
FrontPage_FileExists = True
istream.Close
end if
set istream = Nothing
set fs = Nothing
End Function
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_OnStart
FrontPage_StartSession '==FrontPage Generated==
Session.Timeout = 15
Application.Lock
Application("activeUsers") = Application("activeUsers") + 1
Application.UnLock
Session("FontLister_Version") = "3.4.9"
Session("FontLister_ReleaseDate") = "May 10, 1999"
Session("FontSelector_Version") = "1.3"
Session("HTML_Font_Colorizer_Version") = "2.04"
Session("HTML_Font_Colorizer_ReleaseDate") = "June 19, 1998"
Session("FillOut_Manager_Version") = "1.02"
Session("DB") = "DBQ="&Request.ServerVariables("APPL_PHYSICAL_PATH")&"\databases\reklamer.mdb;" &_
"DefaultDir="&Request.ServerVariables("APPL_PHYSICAL_PATH")&"databases\;" &_
"Driver={Microsoft Access Driver (*.mdb)};" &_
"DriverId=25;FIL=MS Access;" &_
"ImplicitCommitSync=Yes;" &_
"MaxBufferSize=512;" &_
"MaxScanRows=8;" &_
"PageTimeout=5;" &_
"SafeTransactions=0;" &_
"Threads=3;UID=admin;" &_
"UserCommitSync=Yes;"
Session("meningerDB") = "DBQ="&Request.ServerVariables("APPL_PHYSICAL_PATH")&"\databases\meninger.mdb;" &_
"DefaultDir="&Request.ServerVariables("APPL_PHYSICAL_PATH")&"databases\;" &_
"Driver={Microsoft Access Driver (*.mdb)};" &_
"DriverId=25;FIL=MS Access;" &_
"ImplicitCommitSync=Yes;" &_
"MaxBufferSize=512;" &_
"MaxScanRows=8;" &_
"PageTimeout=5;" &_
"SafeTransactions=0;" &_
"Threads=3;UID=admin;" &_
"UserCommitSync=Yes;"
' Set cMarks = Server.CreateObject("ADODB.Connection")
' Set Session("cMarks") = cMarks
End Sub
Sub Session_onEnd()
Application.Lock
Application("activeUsers") = Application("activeUsers") - 1
Application.UnLock
' Session("cMarks").Close
' Set Session("cMarks") = nothing
' If ( Session("chatUserID") <> "" ) Then
' Application("onlineUser_" & Session("chatUserID"))
' End If
Dim chatname
chatname = Session("chatname")
If (Len(chatname) > 0) Then
Dim x
Application.Lock
' add a leaving message to chatroom
For x = NUMBER_OF_MESSAGES To 2 Step - 1
Application("chatline_" & x) = Application("chatline_" & x-1)
Next
Application("chatline_1") = "<span class=""LoggedOut""><img src=""images/bp.gif"" height=""9"" width=""9""> " & chatname & " decided to leave us at " & now & "</span>"
' update online users by removing this user and
' rearranging other users below him/her
For x = 1 To 10
If (chatname = Application("onlineUser_" & x)) Then
Dim y
Application("onlineUser_" & x) = ""
For y = x To 9
Application("onlineUser_" & y) = Application("onlineUser_" & y+1)
Next
Application("onlineUser_10") = ""
' are you able to _break_ in ASP?
End If
Next
Application.UnLock
' invalidate session
Session("chatname") = ""
End If
End Sub
</SCRIPT>
<OBJECT RUNAT=Server SCOPE=Session ID=MyInfo PROGID="MSWC.MyInfo">
</OBJECT>]
Hilsen jan
