home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / apps / global.asa < prev    next >
Text File  |  2007-05-18  |  4KB  |  103 lines

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