home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_03.cab / iiacsshd.asp < prev    next >
Text File  |  1997-11-12  |  12KB  |  493 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_TCPRESTRICT_TEXT="IP Address Access Restrictions"
  11. Const L_BYDEFAULT_TEXT="By default, all computers are:"
  12. Const L_GRANTED_TEXT="Granted access"
  13. Const L_DENIED_TEXT="Denied access"
  14. Const L_EXCEPTBELOW_TEXT="Except those listed below:"
  15. Const L_ACCESS_TEXT="Access"
  16. Const L_IP_TEXT="IP Address"
  17. Const L_SubNET_TEXT="Subnet Mask"
  18. Const L_DOMAIN_TEXT="Domain"
  19. Const L_SELECTITEM_TEXT="Select an item to delete."
  20.  
  21. On Error Resume Next  
  22.  
  23. Dim path, currentobj, ipsecobj
  24.  
  25. path=Session("dpath")
  26. Session("path")=path
  27. Set currentobj=GetObject(path)
  28. Set ipsecobj=currentobj.IPSecurity 
  29.  
  30. Session("SpecObj")="IPSecurity"
  31. Session("SpecProps")="GrantbyDefault,IPDeny,IPGrant,DomainGrant,DomainDeny"
  32.  
  33. function heading(width,thestring)
  34.     Dim i
  35.     width=width - len(thestring)
  36.     for i=width to 0 step -1
  37.         thestring=thestring & " "
  38.     Next
  39.     heading=thestring
  40. end function
  41.  
  42.  %>
  43.  
  44. <!--#include file="iiset.inc"-->
  45.  
  46. <HTML>
  47. <SCRIPT LANGUAGE="JavaScript">
  48.     function SetBool(){
  49.         if (document.userform.rdoGrantbyDefault[0].checked){
  50.             document.userform.GrantbyDefault.value="True"
  51.         }
  52.         else{
  53.             document.userform.GrantbyDefault.value="False"
  54.         }
  55.         loadList();
  56.     }
  57. </SCRIPT>
  58.  
  59. <BODY BGCOLOR="#CCCCCC" LINK="#000000" VLINK="#000000" ALINK="navy" LEFTMARGIN=5 TOPMARGIN=5 onLoad="loadList();loadHelp();">
  60.  
  61. <FORM NAME="userform">
  62.  
  63. <TABLE CELLSPACING=0 CELLPADDING=2>
  64. <TR><TD STYLE="font-face: Helv,Arial; font-size:10pt;"><FONT SIZE=1 FACE="Helv,ARIAL"><B><%= L_TCPRESTRICT_TEXT %></B></FONT></TD></TR>
  65. <TR><TD>
  66. <BLOCKQUOTE>
  67. <TABLE WIDTH="100%" CELLSPACING=0 CELLPADDING=2>
  68.     <TR>
  69.         <TD VALIGN="top" STYLE="font-face: Helv,Arial; font-size:10pt;">
  70.             <FONT SIZE=1 FACE="Helv,ARIAL">
  71.                     <%= L_BYDEFAULT_TEXT %>
  72.             </FONT>
  73.         </TD>
  74.         <TD VALIGN="top" STYLE="font-face: Helv,Arial; font-size:10pt;">
  75.             <TABLE>
  76.                 <TR>
  77.                     <TD>
  78.                         <FONT SIZE=1 FACE="Helv,ARIAL">
  79.                             <IMG SRC="images/smallkey.gif" WIDTH=17 HEIGHT=18 BORDER=0 ALIGN="middle">
  80.                         </FONT>
  81.                     </TD>
  82.                     <TD>
  83.                         <FONT SIZE=1 FACE="Helv,ARIAL">
  84.                         <% if ipsecobj.GrantbyDefault then %>
  85.                             <INPUT TYPE="hidden" NAME="GrantbyDefault" VALUE="True">
  86.                             <INPUT TYPE="radio" NAME="rdoGrantbyDefault" CHECKED OnClick="SetBool();">
  87.                         <% else %>
  88.                             <INPUT TYPE="hidden" NAME="GrantbyDefault" VALUE="False">
  89.                             <INPUT TYPE="radio" NAME="rdoGrantbyDefault" OnClick="SetBool();">
  90.                         <% end if %>
  91.                         </FONT>
  92.                     </TD>
  93.                     <TD>
  94.                         <FONT SIZE=1 FACE="Helv,ARIAL">                    
  95.                             <%= L_GRANTED_TEXT %>
  96.                         </FONT>
  97.                     </TD>
  98.                 </TR>
  99.                 
  100.                 <TR>
  101.                     <TD>
  102.                         <FONT SIZE=1 FACE="Helv,ARIAL">
  103.                             <IMG SRC="images/lock.gif" WIDTH=16 HEIGHT=18 BORDER=0 ALIGN="middle">
  104.                         </FONT>
  105.                     </TD>
  106.                     <TD>
  107.                         <FONT SIZE=1 FACE="Helv,ARIAL">
  108.                         <% if ipsecobj.GrantbyDefault then %>
  109.                             <INPUT TYPE="radio" NAME="rdoGrantbyDefault" OnClick="SetBool();">
  110.                         <% else %>
  111.                             <INPUT TYPE="radio" NAME="rdoGrantbyDefault" CHECKED OnClick="SetBool();">
  112.                         <% end if %>
  113.                         </FONT>
  114.                     </TD>
  115.                     <TD>
  116.                         <FONT SIZE=1 FACE="Helv,ARIAL">                    
  117.                             <%= L_DENIED_TEXT %>
  118.                         </FONT>
  119.                     </TD>
  120.                 </TR>                                
  121.             </TABLE>
  122.         </TD>
  123.     </TR>
  124.     
  125.     <TR>
  126.         <TD STYLE="font-face: Helv,Arial; font-size:10pt;"><FONT SIZE=1 FACE="Helv,ARIAL"><%= L_EXCEPTBELOW_TEXT %></FONT></TD>
  127.     </TR>
  128. </TABLE>
  129. </BLOCKQUOTE>
  130. </TD></TR>
  131. </TABLE>
  132.  
  133. <TABLE BORDER=1 BORDERCOLOR="#CCCCCC" BORDERCOLORDARK="#CCCCCC" BORDERCOLORLIGHT="#CCCCCC">
  134. <TR>
  135. <TD BORDERCOLOR="#CCCCCC" BORDERCOLORDARK="#FFFFFF" BORDERCOLORLIGHT="#000000" STYLE="font-face: Helv,Arial; font-size:10pt;">
  136.     <FONT SIZE=1 FACE="HELV,ARIAL">
  137.     <% if Session("FONTSIZE")="LARGE" then %>
  138.         <%= heading(5,L_ACCESS_TEXT) %>
  139.     <% else %>
  140.         <%= heading(18,L_ACCESS_TEXT) %>
  141.     <% end if %>
  142.     </FONT>
  143. </TD>
  144. <TD BORDERCOLOR="#CCCCCC" BORDERCOLORDARK="#FFFFFF" BORDERCOLORLIGHT="#000000" STYLE="font-face: Helv,Arial; font-size:10pt;">
  145.     <FONT SIZE=1 FACE="HELV,ARIAL">
  146.     <A HREF="javascript:sortList('ip');">
  147.         <% if Session("FONTSIZE")="LARGE" then %>
  148.             <%= heading(28,L_IP_TEXT) %>
  149.         <% else %>
  150.             <%= heading(22,L_IP_TEXT) %>
  151.         <% end if %>
  152.     </A>
  153.     </FONT>    
  154. </TD>
  155. <TD BORDERCOLOR="#CCCCCC" BORDERCOLORDARK="#FFFFFF" BORDERCOLORLIGHT="#000000" STYLE="font-face: Helv,Arial; font-size:10pt;">
  156.     <FONT SIZE=1 FACE="HELV,ARIAL">
  157.     <A HREF="javascript:sortList('subnet');">
  158.         <% if Session("FONTSIZE")="LARGE" then %>
  159.             <%= heading(25,L_SubNET_TEXT) %>
  160.         <% else %>
  161.             <%= heading(17,L_SubNET_TEXT) %>
  162.         <% end if %>
  163.     </A>
  164.     </FONT>
  165. </TD>
  166. <TD BORDERCOLOR="#CCCCCC" BORDERCOLORDARK="#FFFFFF" BORDERCOLORLIGHT="#000000" STYLE="font-face: Helv,Arial; font-size:10pt;">
  167.     <FONT SIZE=1 FACE="HELV,ARIAL">
  168.     <A HREF="javascript:sortList('domain');">
  169.         <% if Session("FONTSIZE")="LARGE" then %>
  170.             <%= heading(43,L_DOMAIN_TEXT) %>
  171.         <% else %>
  172.             <%= heading(32,L_DOMAIN_TEXT) %>        
  173.         <% end if %>
  174.     </A>
  175.     </FONT>
  176. </TD>
  177. </TR>
  178. </TABLE>
  179.  
  180.  
  181. </FORM>
  182.  
  183. <SCRIPT LANGUAGE="JavaScript">
  184.  
  185.     function loadHelp(){
  186.         top.title.Global.helpFileName="iipy_4";
  187.     }
  188.  
  189.     function isNum(txtcntrl) {
  190.         str=txtcntrl.value;
  191.         for (var i=0; i < str.length; i++) {
  192.               var ch=str.substring(i, i + 1);
  193.               if ((ch < "0" || "9" < ch) && ch !=',') {
  194.                    alert("Please enter an integer.");
  195.                 txtcntrl.focus()
  196.             return false;
  197.               }
  198.          }
  199.         return true;
  200.     }
  201.  
  202.     function SetList(){
  203.     }
  204.  
  205.     function disableDefault(dir,fromCntrl, toCntrl){
  206.         if (!dir){
  207.             if (fromCntrl.value !=""){
  208.                 toCntrl.value=fromCntrl.value;
  209.                 fromCntrl.value="";
  210.             }
  211.         }
  212.         else{
  213.             if (toCntrl.value !=""){
  214.                 fromCntrl.value=toCntrl.value;
  215.                 toCntrl.value="";
  216.             }
  217.         }
  218.     }
  219.  
  220.     function enableDefault(chkCntrl){
  221.         chkCntrl.checked=true;
  222.     }
  223.  
  224.  
  225.  
  226.     function loadList(){
  227.         parent.list.location="iiacssls.asp";
  228.     }
  229.  
  230.     function setLastSel(id){
  231.         for (var i=0; i < cachedList.length; i++) {
  232.             if (cachedList[i].id == id){
  233.                 listFunc.sel = i;
  234.                 return;
  235.             }
  236.         }
  237.         
  238.     }    
  239.     
  240.     function sortList(sortby)
  241.         {        
  242.         i=eval(listFunc.sel);
  243.         if ( i != -1)
  244.         {
  245.             lastsel = cachedList[i].id
  246.         }
  247.  
  248.         if (sortby != listFunc.sortby)
  249.             {
  250.             listFunc.sortby = sortby;
  251.             listFunc.sortAsc = true;
  252.             }
  253.         else
  254.             {
  255.             listFunc.sortAsc = !listFunc.sortAsc;
  256.             }
  257.  
  258.         var num = parseFloat(cachedList[sortby]);
  259.         if (isNaN(num))
  260.             {
  261.             cachedList.sort(sortOrder);
  262.             }
  263.         else
  264.             { 
  265.             cachedList.sort(numOrder);
  266.             }
  267.             
  268.         if (!listFunc.sortAsc)
  269.             {
  270.             cachedList.reverse();
  271.             }
  272.         if ( i != -1)
  273.         {            
  274.             setLastSel(lastsel);                
  275.         }
  276.         loadList();
  277.         }
  278.  
  279.     function sortOrder(a,b)
  280.         {
  281.         if (a[listFunc.sortby] < b[listFunc.sortby])
  282.             {
  283.             return -1;
  284.             }
  285.         else
  286.             {
  287.             if (a[listFunc.sortby] > b[listFunc.sortby])
  288.                 {
  289.                 return 1;
  290.                 }
  291.             else
  292.                 {
  293.                 return 0;
  294.                 }
  295.             }
  296.         }
  297.  
  298.     function addItem(){
  299.         i=cachedList.length
  300.         listFunc.noupdate = true;
  301.         if (document.userform.rdoGrantbyDefault[0].checked){
  302.             access=false;
  303.         }
  304.         else{
  305.             access=true;
  306.         }
  307.         cachedList[i]=new listObj(i,access, "", "", "");
  308.         listFunc.sel=i;
  309.         cachedList[i].updated=true;    
  310.         cachedList[i].newitem=true;
  311.         loadList();
  312.     }
  313.  
  314.     function delItem(){
  315.         if (listFunc.sel >= 0){
  316.             listFunc.noupdate = true;        
  317.             sel = eval(listFunc.sel);
  318.             cachedList[sel].deleted = true;
  319.             cachedList[sel].updated = true;
  320.             sel = sel-1;
  321.             
  322.             <% 'run through the list to find the Next non-deleted item %>
  323.             for (var j = sel; j >=0; j--) {
  324.                 if (cachedList[j].deleted){
  325.                 }
  326.                 else{
  327.                     break            
  328.                 }
  329.             }    
  330.             listFunc.sel = j;
  331.             loadList();
  332.         }
  333.         else{
  334.             alert("<%= L_SELECTITEM_TEXT %>");            
  335.         }
  336.     }
  337.  
  338.     function buildListForm(){
  339.         numrows=0;
  340.         for (var i=0; i < cachedList.length; i++) {
  341.             fullstr = cachedList[i].ip + cachedList[i].Subnet+ cachedList[i].domain;
  342.             if ((!cachedList[i].deleted) && (fullstr !="")){
  343.                 numrows=numrows + 1;
  344.             }
  345.         }
  346.         qstr="numrows="+numrows;
  347.         qstr=qstr+"&cols=IPGrant&cols=IPDeny&cols=DomainGrant&cols=DomainDeny"
  348.  
  349.         top.hlist.location.href="iihdn.asp?"+qstr;
  350.         <% 'the list values will be grabbed by the hiddenlistform script... %>
  351.  
  352.  
  353.     }
  354.  
  355.     function SetListVals(){
  356.         listForm=top.hlist.document.hiddenlistform;
  357.         j=0;
  358.         for (var i=0; i < cachedList.length; i++) {
  359.  
  360.             fullstr = cachedList[i].ip + cachedList[i].Subnet+ cachedList[i].domain;
  361.             if ((!cachedList[i].deleted) && (fullstr !="")){
  362.                 ipSubnet=cachedList[i].ip + "," + cachedList[i].Subnet; 
  363.                 if (ipSubnet==","){
  364.                     ipSubnet=""
  365.                 }
  366.                 else{
  367.                 //if there is no subnet, set it to default...
  368.                     if (ipSubnet.indexOf(",") == ipSubnet.length-1){
  369.                         ipSubnet = ipSubnet + "255.255.255.255"
  370.                     }
  371.                 }
  372.                 if (cachedList[i].access){    
  373.                     // this works because on entry, if the user enters a domain, the ip/Subnet will be cleared. 
  374.                     // if they enter an ip the domain will be cleared.
  375.                     // ip/Subnet and domain should be mutually exclusive...
  376.  
  377.                     listForm.elements[j++].value=ipSubnet;
  378.                     listForm.elements[j++].value="";
  379.                     listForm.elements[j++].value=cachedList[i].domain;
  380.                     listForm.elements[j++].value="";
  381.                 }
  382.                 else{
  383.                     listForm.elements[j++].value="";
  384.                     listForm.elements[j++].value=ipSubnet;
  385.                     listForm.elements[j++].value="";
  386.                     listForm.elements[j++].value=cachedList[i].domain;
  387.                 }
  388.             }
  389.             cachedList[i].updated=false; 
  390.         }
  391.     }
  392.  
  393.     function listFuncs(){
  394.         this.sel = -1;
  395.         this.noupdate = false;
  396.         this.addItem=addItem;
  397.         this.delItem=delItem;
  398.         this.writeList=buildListForm;
  399.         this.SetListVals=SetListVals;
  400.         this.mainframe = top.opener.top;        
  401.     }
  402.  
  403.  
  404.  
  405.     function listObj(i,a,ip,s,dmn){
  406.         this.id = i;
  407.         this.access=a;
  408.         this.ip=ip;
  409.         this.Subnet=s;
  410.         this.domain=dmn;
  411.         this.deleted=false;
  412.         this.updated=false;
  413.         this.newitem=false;
  414.     }
  415.  
  416.     cachedList=new Array()
  417.  
  418. <%  
  419.         Dim agrantlist, arraybound, aAccess, i, Nexti
  420.         Dim agrantDomains, adenylist, adenyDomains
  421.         
  422.         agrantlist=ipsecobj.IPGrant
  423.         if IsArray(agrantlist) then
  424.             arraybound=UBound(agrantlist)
  425.             if agrantlist(0) <> "" then
  426.             for i=0 to arraybound
  427.                 aAccess=getIP(agrantlist(i))
  428.                  %>cachedList[<%= i %>]=new listObj(<%= i %>, true, "<%= aAccess(0) %>","<%= aAccess(1) %>","");<%  
  429.             Next
  430.             end if 
  431.         end if
  432.  
  433.         Nexti=UBound(agrantlist)+1
  434.         agrantdomains=ipsecobj.DomainGrant        
  435.         if IsArray(agrantdomains) then        
  436.             arraybound=UBound(agrantdomains)
  437.             if agrantdomains(0) <> "" then
  438.             for i=0 to arraybound
  439.                  %>cachedList[<%= Nexti %>]=new listObj(<%= Nexti %>, true, "","","<%= agrantdomains(i) %>");<%  
  440.                 Nexti=Nexti + 1
  441.             Next
  442.             end if
  443.         end if
  444.  
  445.         adenylist=ipsecobj.IPDeny    
  446.         if IsArray(adenylist) then
  447.             arraybound=UBound(adenylist)
  448.             if adenylist(0) <> "" then                    
  449.             for i=0 to arraybound
  450.                 aAccess=getIP(adenylist(i))
  451.                  %>cachedList[<%= Nexti %>]=new listObj(<%= Nexti %>, false, "<%= aAccess(0) %>","<%= aAccess(1) %>","");<%  
  452.                 Nexti=Nexti + 1
  453.             Next
  454.             end if 
  455.         end if
  456.  
  457.         adenydomains=ipsecobj.DomainDeny
  458.         if IsArray(adenydomains) then
  459.             arraybound=UBound(adenydomains)        
  460.             if adenydomains(0) <> "" then            
  461.             for i=0 to arraybound
  462.                  %>cachedList[<%= Nexti %>]=new listObj(<%= Nexti %>, false, "","","<%= adenydomains(i) %>");<%  
  463.                 Nexti=Nexti + 1
  464.             Next
  465.             end if
  466.         end if
  467.  
  468. function getIP(bindstr)
  469.     
  470.     dim one, ip, sn
  471.  
  472.     one=Instr(bindstr,",")
  473.     if one > 0 then
  474.         ip=Trim(Mid(bindstr,1,(one-1)))
  475.         sn=Trim(Mid(bindstr,(one+1)))
  476.         if sn = "255.255.255.255" then
  477.             sn = ""
  478.         end if 
  479.     else
  480.         ip=bindstr
  481.     end if
  482.     getIP=Array(ip,sn)
  483. end function
  484.  
  485.  %>
  486.  
  487. listFunc=new listFuncs();
  488.  
  489. </SCRIPT>
  490. </BODY>
  491.  
  492. </HTML>
  493. <% end if %>