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

  1. <%@ LANGUAGE=VBScript %>
  2. <% Option Explicit %>
  3. <% Response.Expires = 0 %>
  4.  
  5. <% if Session("FONTSIZE") = "" then %>
  6.     <!--#include file="iito.inc"-->
  7. <% else %>
  8.  
  9. <% 
  10. Const L_ENTERINTEGER_ERRORMESSAGE = "Please enter an integer"
  11. Const L_FILTERS_TEXT = "ISAPI Filters"
  12. Const L_FILTERORDER_TEXT = "Filters installed here are active for this Web site only. Filters are executed In the order listed below."
  13. Const L_FILTER_TEXT = "Filter"
  14. Const L_STATUS_TEXT = "Status"
  15. Const L_EXE_TEXT = "Executable"
  16. Const L_PRIORITY_TEXT = "Priority"
  17. Const L_ACCESSDENIED_TEXT = "Access Denied" 
  18. Const L_HIGH_TEXT = "High"
  19. Const L_MEDIUM_TEXT = "Medium"
  20. Const L_LOW_TEXT = "Low"
  21. Const L_SELECTITEM_TEXT = "Please select a filter to delete."
  22.  
  23. Const L_LOADED_TEXT = "Loaded"
  24. Const L_LOADING_TEXT = "Loading"
  25. Const L_UNLOADED_TEXT = "Unloaded"
  26. Const L_UNLOADING_TEXT = "Unloading"
  27.  
  28.  
  29. On Error Resume Next 
  30.  
  31. Dim path, currentobj
  32.  
  33. path = Session("spath")
  34. Session("path") = Session("spath")
  35. Set currentobj = GetObject(path)
  36. Session("SpecObj")=path & "/Filters"
  37. Session("SpecProps")=""
  38.  
  39. function heading(width,thestring)
  40.     Dim i
  41.     width = width - len(thestring)
  42.     for i = width to 0 step -1
  43.         thestring = thestring & " "
  44.     Next
  45.     heading = thestring
  46. end function
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  %>
  53.  
  54. <!--#include file="iiset.inc"-->
  55.  
  56. <HTML>
  57. <HEAD>
  58.     <TITLE></TITLE>
  59.     <FONT SIZE=1 FACE="Helv,ARIAL">
  60.  
  61. <SCRIPT LANGUAGE="JavaScript">
  62.     top.title.Global.helpFileName="iipy_31";
  63.     top.title.Global.siteProperties = true;
  64.  
  65.     function SetList(){
  66.         self.location.href = "iiapphd.asp"
  67.     }
  68.  
  69.     function isNum(txtcntrl) {
  70.         str = txtcntrl.value;
  71.         for (var i = 0; i < str.length; i++) {
  72.               var ch = str.substring(i, i + 1);
  73.               if ((ch < "0" || "9" < ch) && ch != ',') {
  74.                    alert("Please enter an integer.");
  75.                 txtcntrl.focus()
  76.             return false;
  77.               }
  78.          }
  79.         return true;
  80.     }
  81.     
  82.  
  83.  
  84.     function disableDefault(dir,fromCntrl, toCntrl){
  85.         if (!dir){
  86.             if (fromCntrl.value != ""){
  87.                 toCntrl.value = fromCntrl.value;
  88.                 fromCntrl.value = "";
  89.             }
  90.         }
  91.         else{
  92.             if (toCntrl.value != ""){
  93.                 fromCntrl.value = toCntrl.value;
  94.                 toCntrl.value = "";
  95.             }
  96.         }
  97.     }
  98.  
  99.     function enableDefault(chkCntrl){
  100.         chkCntrl.checked = true;
  101.     }
  102.  
  103. </SCRIPT>
  104. </HEAD>
  105.  
  106. <BODY BGCOLOR="#CCCCCC" TOPMARGIN=5 TEXT="#000000" onLoad="loadList();" LINK="#000000" VLINK="#000000" STYLE="font-face: Helv,Arial; font-size:10pt;">
  107. <FORM NAME="userform" onSubmit="return false"><FONT SIZE=1 FACE="Helv,ARIAL">
  108. <B><%= L_FILTERS_TEXT %></B><P>
  109.  
  110. <%= L_FILTERORDER_TEXT %><P>
  111.  
  112. <TABLE BORDER = 1 BORDERCOLOR="#CCCCCC" BORDERCOLORDARK="#CCCCCC" BORDERCOLORLIGHT="#CCCCCC"  CELLPADDING = 2 CELLSPACING = 0>
  113. <TR>
  114. <TD WIDTH = 50 BORDERCOLOR="#CCCCCC" BORDERCOLORDARK="#FFFFFF" BORDERCOLORLIGHT="#000000"><FONT SIZE=1 FACE='HELV,ARIAL'>
  115.  
  116.         <%= heading(9,L_STATUS_TEXT) %>
  117.  
  118. </TD>
  119. <TD WIDTH = 50 BORDERCOLOR="#CCCCCC" BORDERCOLORDARK="#FFFFFF" BORDERCOLORLIGHT="#000000"><FONT SIZE=1 FACE='HELV,ARIAL'>
  120.  
  121.         <%= heading(9,L_PRIORITY_TEXT) %>
  122.  
  123. </TD>
  124. <TD WIDTH = 100 BORDERCOLOR="#CCCCCC" BORDERCOLORDARK="#FFFFFF" BORDERCOLORLIGHT="#000000" ><FONT SIZE=1 FACE='HELV,ARIAL'>
  125.  
  126.         <%= heading(25,L_FILTER_TEXT) %>
  127.  
  128. </TD>
  129. <TD WIDTH = 250 BORDERCOLOR="#CCCCCC" BORDERCOLORDARK="#FFFFFF" BORDERCOLORLIGHT="#000000"><FONT SIZE=1 FACE='HELV,ARIAL'>
  130.  
  131.         <%= heading(65,L_EXE_TEXT) %>
  132.  
  133. </TD>
  134. </TR>
  135. </TABLE>
  136.  
  137. <SCRIPT LANGUAGE="JavaScript">
  138.  
  139.     function loadList(){
  140.         parent.list.location.href = "iifiltls.asp";
  141.     }
  142.  
  143.  
  144.     function moveItem(dir){
  145.         sel = eval(listFunc.sel);
  146.         if (sel > -1){
  147.             if (!cachedList[sel].deleted){
  148.                 if ((sel + dir >= 0) && (sel + dir < (cachedList.length))){                
  149.                     cachedList[sel].id += dir;
  150.                     cachedList[sel].updated = true;
  151.                     sel += dir;
  152.                     cachedList[sel].id -= dir;
  153.                 
  154.                     listFunc.sel = sel;
  155.                     cachedList.sort(sortOrder);
  156.                     loadList();
  157.                 }
  158.             }
  159.         }
  160.     }
  161.     
  162.     function sortOrder(a,b){
  163.         x=a.id - b.id
  164.         return x
  165.     }
  166.     
  167.  
  168.     function addItem(){
  169.         i = cachedList.length   
  170.         cachedList[i] = new listObj(i,"New Filter", 4, "", "","");
  171.         cachedList[i].newitem = true;
  172.         cachedList[i].updated = true;
  173.         listFunc.sel = i;
  174.         loadList();
  175.     }
  176.  
  177.     function delItem(){
  178.         sel = eval(listFunc.sel);
  179.         if (sel < 0){
  180.             alert("<%= L_SELECTITEM_TEXT %>");
  181.         }
  182.         else{
  183.             cachedList[sel].deleted = true;
  184.             cachedList[sel].updated = true;
  185.             sel = sel-1;
  186.             
  187.             <% 'run through the list to find the Next non-deleted item %>
  188.             for (var j = sel; j >= 0; j--) {
  189.                 if (cachedList[j].deleted){
  190.                 }
  191.                 else{
  192.                     break            
  193.                 }
  194.             }    
  195.             listFunc.sel = j;
  196.             loadList();
  197.         }
  198.     }
  199.     
  200.     function crop(thestring,size)
  201.         {
  202.         <% if Session("FONTSIZE") = "LARGE" then %>
  203.             size = size-10;
  204.         <% end if %>
  205.         if (thestring.length > size)
  206.             {
  207.             thestring = thestring.substring(0,size) + "...";
  208.             }
  209.         return thestring;
  210.         }        
  211.  
  212.     function buildListForm(){
  213.         numrows = 0;
  214.                 
  215.         for (var i = 0; i < cachedList.length; i++) {
  216.             if (!cachedList[i].deleted){        
  217.                 numrows = numrows + 1;
  218.             }
  219.         }
  220.         qstr = "numrows="+numrows;
  221.         qstr = qstr+"&cols=FilterName&cols=FilterPath";
  222.  
  223.         parent.parent.hlist.location.href = "iihdn.asp?"+qstr;
  224.  
  225.         <% 'the list values will be grabbed by the hiddenlistform script... %>
  226.     }
  227.  
  228.     function SetListVals(){
  229.         listForm = parent.parent.hlist.document.hiddenlistform;    
  230.         j = 0;
  231.         for (var i = 0; i < cachedList.length; i++) {
  232.             if (!cachedList[i].deleted){
  233.                 listForm.elements[j++].value = cachedList[i].filter;
  234.                 listForm.elements[j++].value = cachedList[i].filterpath;
  235.                 cachedList[i].updated = false;
  236.             }
  237.         }
  238.     }
  239.  
  240.     function listFuncs(){
  241.         this.sel = -1;
  242.         this.addItem = addItem;
  243.         this.delItem = delItem;
  244.         this.writeList = buildListForm;
  245.         this.SetListVals = SetListVals;
  246.     }
  247.     
  248.     function statMsg(num){
  249.         if (num == 0){
  250.             return "<%= L_LOADED_TEXT %>"
  251.         }
  252.         if (num == 3){
  253.             return "<%= L_LOADING_TEXT %>"        
  254.         }
  255.         if (num == 4){
  256.             return "<%= L_UNLOADED_TEXT %>"        
  257.         }
  258.         if (num == 2){
  259.             return "<%= L_UNLOADING_TEXT %>"        
  260.         }
  261.     }
  262.  
  263.     function listObj(id,f,s,e,en,p){
  264.         this.id = id;
  265.         this.filter = f;
  266.         this.status=s;
  267.         this.displaystatus = statMsg(s); 
  268.         this.filterpath=e;
  269.         this.displayexe = crop(e,35);
  270.         this.enabled = en;
  271.         this.priority = p;    
  272.         this.order = id;
  273.         this.deleted = false;
  274.         this.newitem = false;
  275.         this.updated = false;
  276.         
  277.         this.crop = crop;
  278.     }
  279.  
  280. cachedList = new Array();
  281.  
  282. <% 
  283.  
  284.     Dim filterspath, filtersCollection, loadOrder, i, filtername, fltr, priority
  285.     
  286.     filterspath = path & "/Filters"
  287.     Set filtersCollection = GetObject(filterspath)
  288.     if err = 0 then
  289.     
  290.         'bugbug... hack to get around MMC not setting Filters key type...
  291.         filtersCollection.KeyType = "IIsFilters"
  292.         filtersCollection.SetInfo        
  293.         filtersCollection.GetInfo    
  294.         
  295.         loadOrder = filtersCollection.FilterLoadOrder
  296.  
  297.         i = 0
  298.     
  299.         do while len(loadOrder) > 0 
  300.             if InStr(loadOrder,",") then
  301.                 filtername = Trim(Left(loadOrder,InStr(loadOrder,",")-1))
  302.                 loadOrder = Trim(Mid(loadOrder,InStr(loadOrder,",")+1))
  303.             else
  304.                 filtername = Trim(loadOrder)
  305.                 loadOrder = ""
  306.             end if
  307.  
  308.             if filtername <> "" then
  309.                 Set fltr = GetObject(filterspath & "/" & filtername)
  310.  
  311.                 if err = 0 then                
  312.                     if fltr.NotifyOrderHigh then
  313.                         priority = L_HIGH_TEXT
  314.                     elseif fltr.NotifyOrderMedium then
  315.                         priority = L_MEDIUM_TEXT                    
  316.                     elseif fltr.NotifyOrderLow then
  317.                         priority = L_LOW_TEXT                    
  318.                     else
  319.                         priority = L_LOW_TEXT                    
  320.                     end if
  321.                      %>cachedList[<%= i %>] = new listObj(<%= i %>,"<%= filtername %>","<%= fltr.FilterState %>","<%= replace(fltr.FilterPath,"\","\\") %>","<%= fltr.FilterEnabled %>","<%= priority %>");<%                  
  322.                     i = i+1
  323.                 end if
  324.             end if
  325.         loop
  326.     end if
  327.  %>
  328.  
  329. listFunc = new listFuncs();
  330. </SCRIPT>
  331. </BODY>
  332. </HTML>
  333. <% end if %>