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.

248 lines
5.7 KiB

  1. <%@ LANGUAGE = VBScript %>
  2. <% 'Option Explicit %>
  3. <!-- #include file="directives.inc" -->
  4. <!--#include file="iicache.str"-->
  5. <!--#include file="iiaspstr.inc"-->
  6. <%
  7. 'Call this page with a query string of ?sname=machinename
  8. 'example: http://larad01/iis/iicnct.asp?sname=larad01
  9. On Error Resume Next
  10. Dim path, sname, scripttimeout, FileSystem, quote, errd, currentADsObj, lastobj
  11. Dim newid, topid, firstid, currentid, numNewItems
  12. 'This script can take a _long_ time to execute,
  13. 'as we may be dealing with thousands of items
  14. 'to add to our JScript object.
  15. 'save our current script timeout value & set to a much longer value...
  16. scripttimeout = Server.ScriptTimeOut
  17. Server.ScriptTimeOut = 2000
  18. Set FileSystem=CreateObject("Scripting.FileSystemObject")
  19. path=Request.QueryString("sname")
  20. quote=chr(34)
  21. errd=False
  22. if (len(path) <> 0) then
  23. Set currentADsObj=GetObject(path)
  24. if err <> 0 then
  25. errd=True
  26. end if
  27. end if
  28. lastobj = ""
  29. %>
  30. <HTML>
  31. <HEAD>
  32. <SCRIPT LANGUAGE="JavaScript">
  33. var theList=top.title.nodeList;
  34. <%
  35. if errd=0 then
  36. newid=Request.QueryString("Nextid")
  37. firstid=newid
  38. if firstid="" then
  39. firstid=0
  40. end if
  41. currentid=Request.QueryString("currentid")
  42. if currentid="" then
  43. currentid=firstid
  44. newid=newid + 1
  45. end if
  46. numNewItems=0
  47. if (len(path) <> 0) then
  48. %>theList[<%= currentid %>].isCached=true;<%
  49. %>theList[<%= currentid %>].open=true;<%
  50. addObject currentADsObj,currentid,"vdir"
  51. if Instr(currentADsObj.KeyType, "VirtualDir") <> 0 then
  52. addDirs currentADsObj.Path, currentADsObj.ADsPath, currentid, "dir"
  53. end if
  54. end if
  55. Server.ScriptTimeOut = scripttimeout
  56. end if
  57. Sub addObject(Container, parentid, vtype)
  58. On Error Resume Next
  59. Dim thisname, isApp, thisid, thisstate
  60. Dim approot, thisroot
  61. if err.number <> 0 then
  62. errd = true
  63. else
  64. For Each Child In Container
  65. if Instr(Child.KeyType, "VirtualDir") <> 0 then
  66. thisid=newid
  67. thisname=Child.Name
  68. thisstate=2
  69. isApp = False
  70. approot=LCase(Child.AppRoot)
  71. if len(approot) <> 0 then
  72. thisroot = LCase(Child.ADsPath)
  73. approot = Mid(approot,Instr(approot,"w3svc/")+1)
  74. thisroot = Mid(thisroot,Instr(thisroot,"w3svc/")+1)
  75. if Right(approot,1) = "/" then
  76. thisroot = thisroot & "/"
  77. end if
  78. if thisroot=approot then
  79. isApp = True
  80. end if
  81. end if
  82. if UCase(thisname) <> "ROOT" then
  83. SetJscriptObj thisname, Child.ADsPath, parentid, vtype, thisstate, Child.Path, isApp
  84. numNewItems=numNewItems + 1
  85. addObject Child, thisid, "vdir"
  86. addDirs Child.Path, Child.ADsPath, thisid, "dir"
  87. else
  88. addObject Child, parentid, "vdir"
  89. addDirs Child.Path, Child.ADsPath, parentid, "dir"
  90. end if
  91. end if
  92. Next
  93. end if
  94. End Sub
  95. Sub addDirs(path, adspath, parentid, vtype)
  96. Dim thisid, thisname, thisstate, thisadspath, i, f
  97. if Instr(UCase(adspath),"W3SVC") <> 0 then
  98. if path <> "" then
  99. if Left(path,2) <> "\\" then
  100. if FileSystem.FolderExists(path) then
  101. Set f=FileSystem.GetFolder(path)
  102. For Each i In f.SubFolders
  103. thisid=newid
  104. thisstate=2
  105. thisadspath = adspath & "/" & i.Name
  106. SetJscriptObj i.Name,thisadspath, parentid, vtype, thisstate,i,False
  107. numNewItems=numNewItems + 1
  108. if err=0 then
  109. addDirs i, thisadspath, thisid, "dir"
  110. end if
  111. Next
  112. end if
  113. end if
  114. end if
  115. end if
  116. End Sub
  117. Sub SetJscriptObj(caption, path, parentid,vtype,state, fspath,isApp)
  118. %>
  119. theList[<%= newid %>]=theList[<%= parentid %>].addNode(new top.title.listObj(<%= newid %>,"<%= sJSLiteral(caption) %>","<%= sJSLiteral(path) %>","<%= vtype %>",<%= state %>));
  120. theList[<%= parentid %>].isCached=true;
  121. theList[<%= newid %>].isCached=true;
  122. <% if isApp then %>
  123. theList[<%= newid %>].icon = top.title.Global.imagedir + "app";
  124. theList[<%= newid %>].isApp = true;
  125. <% end if %>
  126. theList[<%= newid %>].fspath="<%= replace(fspath,"\","\\") %>";
  127. <%
  128. newid=newid + 1
  129. End Sub
  130. ' we need to insert the whole group into the correct place In the array.
  131. ' since we Set the first entry (machine) to the exisitng place In the array,
  132. ' the Next level In the hierarchy (vservers) will be pointing to the correct
  133. ' parent ids. However, the following level (vdirs, and below) will be pointing
  134. ' to the parent ids as they existed at the bottom of the array, before the
  135. ' move, and will need to be adjusted.
  136. %>
  137. <% if errd=0 then %>
  138. gVars=top.title.Global;
  139. var item=<%= firstid %>;
  140. currentid=<%= currentid %>;
  141. if (currentid !=item){
  142. x=currentid + 1;
  143. //correct the id on the "new" objects
  144. for (var i=item; i < theList.length; i++) {
  145. theList[i].id=x;
  146. if (theList[i].parent !=currentid){
  147. theList[i].parent=theList[i].parent - (item - (currentid + 1));
  148. }
  149. x++;
  150. }
  151. //move the following records "down" the array
  152. for (var i=currentid + 1; i < item;i++){
  153. theList[i].id=theList[i].id + <%= numNewItems %>;
  154. if (theList[i].parent >currentid){
  155. theList[i].parent=theList[i].parent + <%= numNewItems %>;
  156. }
  157. }
  158. }
  159. //and re-sort.
  160. theList[0].sortList();
  161. theList[0].markTerms();
  162. if (theList.length==1){
  163. gVars.selId=0;
  164. theList[0].selected=true;
  165. }
  166. else{
  167. theList[gVars.selId].selected=false;
  168. gVars.selId=<%= currentid %>;
  169. theList[<%= currentid %>].selected=true;
  170. }
  171. top.body.list.location.href="iisrvls.asp"
  172. <% else %>
  173. alert("<%= L_CNCTERR_TEXT %> (<%= err %>)");
  174. <% end if %>
  175. top.body.iisstatus.location="iistat.asp"
  176. </SCRIPT>
  177. <% if err <> 0 then %>
  178. <% Response.write "err: " & err.description %><BR>
  179. <% Response.write "currentcontainer: " & currentADsObj.ADsPath %><BR>
  180. <% Response.write " " & currentADsObj.KeyType %><BR>
  181. <% Response.write "Err Container:" & lastobj %><BR>
  182. <% end if %>
  183. </HEAD>
  184. <BODY>
  185. </BODY>
  186. </HTML>