home *** CD-ROM | disk | FTP | other *** search
/ 2 Years of Handheld PC Magazine 1998 to 1999 / HPCMag9899.iso / 2Year / global.asa < prev    next >
Text File  |  2000-03-08  |  4KB  |  107 lines

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