home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / subs / global.asa next >
Text File  |  2003-10-07  |  3KB  |  91 lines

  1. <SCRIPT LANGUAGE=VBScript RUNAT=Server>
  2. Sub Application_OnStart
  3.     '==FrontPage Generated - startspan==
  4.     Dim FrontPage_UrlVars(1)
  5.     '--Project Data Connection
  6.         Application("Request_ConnectionString") = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=URL=fpdb/request.mdb"
  7.         FrontPage_UrlVars(0) = "Request_ConnectionString"
  8.         Application("Request_ConnectionTimeout") = 15
  9.         Application("Request_CommandTimeout") = 30
  10.         Application("Request_CursorLocation") = 3
  11.         Application("Request_RuntimeUserName") = ""
  12.         Application("Request_RuntimePassword") = ""
  13.     '--
  14.     Application("FrontPage_UrlVars") = FrontPage_UrlVars
  15.     '==FrontPage Generated - endspan==
  16. End Sub
  17. Sub Session_OnStart
  18.     FrontPage_StartSession '==FrontPage Generated==
  19. End Sub
  20. Sub FrontPage_StartSession
  21.     On Error Resume Next
  22.     if Len(Application("FrontPage_VRoot")) > 0 then Exit Sub
  23.     ' discover the VRoot for the current page;
  24.     ' walk back up VPath until we find global.asa
  25.     Vroot = Request.ServerVariables("PATH_INFO")
  26.     strG1 = "global.asa"
  27.     strG2 = "Global.asa"
  28.     iCount = 0
  29.     do while Len(Vroot) > 1
  30.         idx = InStrRev(Vroot, "/")
  31.         if idx > 0 then
  32.             Vroot = Left(Vroot,idx)
  33.         else
  34.             ' error; assume root web
  35.             Vroot = "/"
  36.         end if
  37.         if FrontPage_FileExists(Server.MapPath(Vroot & strG1)) then exit do
  38.         if FrontPage_FileExists(Server.MapPath(Vroot & strG2)) then exit do
  39.         if Right(Vroot,1) = "/" then Vroot = Left(Vroot,Len(Vroot)-1)
  40.         iCount = iCount + 1
  41.         if iCount > 100 then
  42.             ' error; assume root web
  43.             Vroot = "/"
  44.             exit do
  45.         end if
  46.     loop
  47.     ' map all URL= attributes in _ConnectionString variables
  48.     Application.Lock
  49.     if Len(Application("FrontPage_VRoot")) = 0 then
  50.         Application("FrontPage_VRoot") = Vroot
  51.         UrlVarArray = Application("FrontPage_UrlVars")
  52.         for i = 0 to UBound(UrlVarArray)
  53.             if Len(UrlVarArray(i)) > 0 then FrontPage_MapUrl(UrlVarArray(i))
  54.         next
  55.     end if
  56.     Application.Unlock
  57. End Sub
  58. Sub FrontPage_MapUrl(AppVarName)
  59.     ' convert URL attribute in conn string to absolute file location
  60.     strVal = Application(AppVarName)
  61.     strKey = "URL="
  62.     idxStart = InStr(strVal, strKey)
  63.     If idxStart = 0 Then Exit Sub
  64.     strBefore = Left(strVal, idxStart - 1)
  65.     idxStart = idxStart + Len(strKey)
  66.     idxEnd = InStr(idxStart, strVal, ";")
  67.     If idxEnd = 0 Then
  68.         strAfter = ""
  69.         strURL = Mid(strVal, idxStart)
  70.     Else
  71.         strAfter = ";" & Mid(strVal, idxEnd + 1)
  72.         strURL = Mid(strVal, idxStart, idxEnd - idxStart)
  73.     End If
  74.     strOut = strBefore & Server.MapPath(Application("FrontPage_VRoot") & strURL) & strAfter
  75.     Application(AppVarName) = strOut
  76. End Sub
  77. Function FrontPage_FileExists(fspath)
  78.     On Error Resume Next
  79.     FrontPage_FileExists = False
  80.     set fs = CreateObject("Scripting.FileSystemObject")
  81.     Err.Clear
  82.     set istream = fs.OpenTextFile(fspath)
  83.     if Err.Number = 0 then
  84.         FrontPage_FileExists = True
  85.         istream.Close
  86.     end if
  87.     set istream = Nothing
  88.     set fs = Nothing
  89. End Function
  90. </SCRIPT>
  91.