Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

267 lines
7.3 KiB

  1. <%@ LANGUAGE = VBScript %>
  2. <% Option Explicit %>
  3. <!-- #include file="directives.inc" -->
  4. <!--#include file="iicache.str"-->
  5. <!--#include file="iiaspstr.inc"-->
  6. <%
  7. ' Copyright (c) 1998 Microsoft Corporation
  8. '
  9. ' Module Name:
  10. ' iicache2.asp
  11. ' Abstract:
  12. ' Loads new nodes into the cached tree list.
  13. ' Author:
  14. ' Taylor Weiss (taylorw) 8-Oct-1998
  15. ' Revision History:
  16. ' 8-Oct-1998 taylorw created
  17. '
  18. ' Query String:
  19. '
  20. ' sname - ADsPath of the node in the tree being expanded. This may
  21. ' be a site node, in which case is does not contain the
  22. ' immediate parent of the nodes we want to cache.
  23. '
  24. ' fspath - The file system path of the object. Since the folder may
  25. ' not exist in the metabase, we need this to enumerate
  26. ' physical directories.
  27. '
  28. On Error Resume Next
  29. Const MD_PATH_NOT_FOUND = &H80070003
  30. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  31. ' Global Variables
  32. '
  33. Dim strRootADsPath, strRootFsPath
  34. Dim objRoot, bRootExists
  35. Dim bIsWeb
  36. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  37. ' Script setup
  38. strRootADsPath = Request.QueryString("sname")
  39. strRootFsPath = Request.QueryString("fspath")
  40. ' Get the ads container object that will be the parent of the new nodes.
  41. set objRoot = GetObject( strRootADsPath )
  42. if InStr( objRoot.Class, "Server" ) <> 0 then
  43. strRootADsPath = strRootADsPath & "/ROOT"
  44. set objRoot = GetObject( strRootADsPath )
  45. end if
  46. if err.Number = MD_PATH_NOT_FOUND then
  47. bRootExists = False
  48. err.Clear
  49. else
  50. ' If we got some other error, or we get errors here then something
  51. ' really odd happened.
  52. bRootExists = True
  53. if strRootFsPath = "" then
  54. strRootFsPath = objRoot.Path
  55. end if
  56. end if
  57. if InStr( UCase(strRootADsPath), "W3SVC" ) <> 0 then
  58. bIsWeb = True
  59. else
  60. bIsWeb = False
  61. end if
  62. %>
  63. <HTML>
  64. <HEAD>
  65. </HEAD>
  66. <BODY>
  67. <SCRIPT LANGUAGE="JavaScript">
  68. var theList = top.title.nodeList;
  69. var gVars = top.title.Global;
  70. var intNewId = theList.length;
  71. var intRootId = gVars.selId;
  72. var intCurrentId = intNewId; // changes as we add items
  73. <%
  74. if err.Number = 0 then
  75. ' Mark the parent item as cached. Note: if we fail farther down stream
  76. ' we won't have any way to recache this node until the user refreshes.
  77. %>
  78. theList[intRootId].isCached = true;
  79. theList[intRootId].open = true;
  80. <%
  81. if bRootExists then
  82. addVirtualChildren()
  83. end if
  84. if bIsWeb then
  85. addPhysicalChildren()
  86. end if
  87. ' We are finished adding the new nodes, now we need to reorder the list.
  88. %>
  89. // intNewId = The index of the first item we added.
  90. // intRootId = The index of the parent item
  91. // intCurrentId = One past the index of the last item
  92. // Reset the id's of old list items past the parent item to reflect
  93. // their new positions once the list is sorted.
  94. var intNumNewItems = intCurrentId - intNewId;
  95. if( intNumNewItems > 0 )
  96. {
  97. for( var i = intRootId + 1; i < intNewId; i++ )
  98. {
  99. theList[i].id += intNumNewItems;
  100. if( theList[i].parent > intRootId )
  101. {
  102. theList[i].parent += intNumNewItems;
  103. }
  104. }
  105. }
  106. theList[0].sortList();
  107. theList[0].markTerms();
  108. top.body.list.location.href="iisrvls.asp";
  109. top.body.iisstatus.location="iistat.asp";
  110. <%
  111. end if
  112. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  113. ' Helper Functions
  114. sub addVirtualChildren()
  115. On Error Resume Next
  116. dim objChildNode, strChildName, bIsApplication
  117. for each objChildNode in objRoot
  118. if InStr(UCase(objChildNode.Class), "VIRTUALDIR") <> 0 then
  119. %>
  120. theList[intCurrentId] = theList[intRootId].addNode(
  121. new top.title.listObj( (intCurrentId - intNewId) + intRootId + 1,
  122. "<%= sJSLiteral(objChildNode.Name) %>",
  123. "<%= sJSLiteral(objChildNode.ADsPath) %>",
  124. "vdir",
  125. 2 // state
  126. )
  127. );
  128. theList[intCurrentId].fspath = "<%= sJSLiteral(objChildNode.Path) %>";
  129. <%
  130. if bIsWeb then
  131. if isApplication(objChildNode) then
  132. %>
  133. theList[intCurrentId].icon = top.title.Global.imagedir + "app";
  134. theList[intCurrentId].isApp = true;
  135. <%
  136. end if
  137. end if
  138. %>
  139. intCurrentId++;
  140. <%
  141. end if
  142. next
  143. end sub
  144. function isApplication( objWebNode )
  145. ' On Error Resume Next
  146. dim bReturn, strAppRoot, strADsPath
  147. bReturn = False
  148. strAppRoot = UCase(objWebNode.AppRoot)
  149. if strAppRoot <> "" then
  150. ' The AppRoot is inherited, if there is really an application
  151. ' defined at this node, the paths will point to the same node.
  152. strADsPath = UCase(objWebNode.ADsPath)
  153. strAppRoot = Mid(strAppRoot,Instr(strAppRoot,"W3SVC/")+1)
  154. strADsPath = Mid(strADsPath,Instr(strADsPath,"W3SVC/")+1)
  155. if strADsPath = strAppRoot then
  156. bReturn = True
  157. end if
  158. end if
  159. isApplication = bReturn
  160. end function
  161. sub addPhysicalChildren()
  162. On Error Resume Next 'Needed if GetObject(objChildFolder) fails
  163. dim objFileSystem, objChildFolder, objRootFolder, objChildNode
  164. set objFileSystem = CreateObject("Scripting.FileSystemObject")
  165. if objFileSystem.FolderExists( strRootFsPath ) then
  166. set objRootFolder = objFileSystem.GetFolder( strRootFsPath )
  167. for each objChildFolder in objRootFolder.SubFolders
  168. 'Check for existence of objChildFolder in metabase
  169. Set objChildNode = GetObject(objRoot.ADsPath & "/" & objChildFolder.Name)
  170. If err.Number <> 0 Then 'Is not a virtual dir in metabase
  171. err.Clear
  172. %>
  173. theList[intCurrentId] = theList[intRootId].addNode(
  174. new top.title.listObj( (intCurrentId - intNewId) + intRootId + 1,
  175. "<%= sJSLiteral(objChildFolder.Name) %>",
  176. "<%= sJSLiteral(strRootADsPath & "/" & objChildFolder.Name) %>",
  177. "dir",
  178. 2 // state
  179. )
  180. );
  181. theList[intCurrentId].fspath = "<%= sJSLiteral(objChildFolder.Path) %>";
  182. intCurrentId++;
  183. <%
  184. Else
  185. If InStr(UCase(objChildNode.Class), "WEBDIR") <> 0 Then 'Is a dir in metabase
  186. %>
  187. theList[intCurrentId] = theList[intRootId].addNode(
  188. new top.title.listObj( (intCurrentId - intNewId) + intRootId + 1,
  189. "<%= sJSLiteral(objChildFolder.Name) %>",
  190. "<%= sJSLiteral(strRootADsPath & "/" & objChildFolder.Name) %>",
  191. "dir",
  192. 2 // state
  193. )
  194. );
  195. theList[intCurrentId].fspath = "<%= sJSLiteral(objChildFolder.Path) %>";
  196. intCurrentId++;
  197. <%
  198. End If
  199. End If
  200. next
  201. end if
  202. end sub
  203. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  204. ' Report Errors
  205. if err.Number <> 0 then
  206. %>
  207. // Dump some debugging information
  208. alert("<%= L_CNCTERR_TEXT %> (<%= Hex(err.Number) %>): <%= err.Description%>");
  209. document.write( "Client Variables for the selected node <P>");
  210. document.write( "id = " + theList[intRootId].id + "<BR>");
  211. document.write( "title = " + theList[intRootId].title + "<BR>");
  212. document.write( "path = " + theList[intRootId].path + "<BR>");
  213. document.write( "keytype = " + theList[intRootId].keytype + "<BR>");
  214. document.write( "fspath = " + theList[intRootId].fspath + "<BR>");
  215. document.write( "stype = " + theList[intRootId].stype + "<BR>");
  216. document.write( "Server Variables<P>");
  217. document.write( "strRootADsPath = " + "<%= strRootADsPath %>" + "<BR>");
  218. //document.write( "strRootFsPath = " + "<%= strRootFsPath %>" + "<BR>");
  219. document.write( "objRoot.Name = " + "<%= objRoot.Name %>" + "<BR>");
  220. document.write( "objRoot.ADsPath = " + "<%= objRoot.ADsPath %>" + "<BR>");
  221. document.write( "bRootExists = " + "<%= bRootExists %>" + "<BR>");
  222. <%
  223. end if
  224. %>
  225. </SCRIPT>
  226. </BODY>
  227. </HTML>