home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_03.cab / iicache.asp < prev    next >
Text File  |  1997-11-12  |  6KB  |  251 lines

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