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

  1. <%@ LANGUAGE=VBScript %>
  2. <%'Option Explicit %>
  3. <% Response.Expires = 0 %>
  4.  
  5. <% 
  6. Const L_CERR_TEXT ="Custom Errors"
  7. Const L_CUSTOMERR_TEXT="Custom Error Messages can be a text stream or a pointer to a file (such as an HTML document or an Active Server Page)"
  8. Const L_ERROR_TEXT="HTTP Error"
  9. Const L_OUTPUTTYPE_TEXT="Type"
  10. Const L_TEXTORFILE_TEXT="Contents"
  11. Const L_ACCESSDENIED_TEXT="Access Denied" %>
  12.  
  13. <% 
  14. function heading(width,thestring)
  15.     width=width - Len(thestring)
  16.     for i=width to 0 step -1
  17.         thestring=thestring & " "
  18.     Next
  19.     heading=thestring
  20. end function
  21.  %>
  22.  
  23. <HTML>
  24. <HEAD>
  25.     <TITLE></TITLE>
  26. </HEAD>
  27.  
  28. <BODY BGCOLOR="#CCCCCC" LINK="#000000" VLINK="#000000" TOPMARGIN=10 TEXT="#000000" >
  29. <FORM NAME="userform">
  30. <FONT SIZE=1 FACE="Helv,ARIAL">
  31. <B><%= L_CERR_TEXT %></B>
  32. <P>
  33. <TABLE WIDTH=490 BORDER=0>
  34.     <TR>
  35.         <TD COLSPAN=3 STYLE="font-face: Helv,Arial; font-size:10pt;">
  36.             <FONT SIZE=1 FACE="Helv,ARIAL">
  37.                 <%= L_CUSTOMERR_TEXT %>
  38.                 <BR> 
  39.             </FONT>
  40.         </TD>
  41.     </TR>
  42. </TABLE>
  43.  
  44. <TABLE BORDER=1 BORDERCOLOR="#CCCCCC" BORDERCOLORDARK="#CCCCCC" BORDERCOLORLIGHT="#CCCCCC" CELLPADDING=2 CELLSPACING=0>
  45. <TR>
  46. <TD BORDERCOLOR="#CCCCCC" BORDERCOLORDARK="#FFFFFF" BORDERCOLORLIGHT="#000000" STYLE="font-face: Helv,Arial; font-size:10pt;"><FONT SIZE=1 FACE="HELV,ARIAL">
  47.     <A HREF="javascript:sortList('error');">
  48.     <% if Session("FONTSIZE")="LARGE" then %>
  49.         <%= heading(12,L_ERROR_TEXT) %>
  50.     <% else %>
  51.         <%= heading(20,L_ERROR_TEXT) %>
  52.     <% end if %>
  53.     </A>
  54.     </FONT>
  55. </TD>
  56. <TD BORDERCOLOR="#CCCCCC" BORDERCOLORDARK="#FFFFFF" BORDERCOLORLIGHT="#000000" STYLE="font-face: Helv,Arial; font-size:10pt;"><FONT SIZE=1 FACE="HELV,ARIAL">
  57.     <A HREF="javascript:sortList('outType');">
  58.         <% if Session("FONTSIZE")="LARGE" then %>
  59.             <%= heading(26,L_OUTPUTTYPE_TEXT) %>
  60.         <% else %>
  61.             <%= heading(18,L_OUTPUTTYPE_TEXT) %>
  62.         <% end if %>        
  63.     </A>
  64.     </FONT>
  65. </TD>
  66. <TD BORDERCOLOR="#CCCCCC" BORDERCOLORDARK="#FFFFFF" BORDERCOLORLIGHT="#000000" STYLE="font-face: Helv,Arial; font-size:10pt;"><FONT SIZE=1 FACE="HELV,ARIAL">
  67.     <A HREF="javascript:sortList('msgPath');">
  68.         <% if Session("FONTSIZE")="LARGE" then %>    
  69.             <%= heading(90,L_TEXTORFILE_TEXT) %>
  70.         <% else %>
  71.             <%= heading(99,L_TEXTORFILE_TEXT) %>        
  72.         <% end if %>
  73.     </A>
  74.     </FONT>
  75. </TD>
  76. </TR>
  77. </TABLE>
  78.  
  79. </FORM>
  80.  
  81. <FORM name="hiddenform">
  82.     <INPUT TYPE="hidden" NAME="index" VALUE=-1>
  83. </FORM>
  84. </BODY>
  85. <SCRIPT LANGUAGE="JavaScript">
  86.     top.title.Global.helpFileName="iipy_13";
  87.  
  88.     function loadList(){
  89.  
  90.     <% if Session("IsIE") then %>
  91.         parent.list.location.href = "iierrls.asp";
  92.     <% else %>
  93.         parent.frames[2].location.href="iierrls.asp";
  94.     <% end if %>
  95.     }
  96.  
  97.     function addItem(){
  98.     }
  99.  
  100.     function delItem(){
  101.     }
  102.  
  103.     function setLastSel(id){
  104.         for (var i=0; i < cachedList.length; i++) {
  105.             if (cachedList[i].id == id){
  106.                 document.hiddenform.index.value = i;
  107.                 return;
  108.             }
  109.         }
  110.         
  111.     }
  112.     
  113.     function sortList(sortby)
  114.         {
  115.         i=eval(document.hiddenform.index.value);
  116.  
  117.         if ( i != -1)
  118.         {
  119.             lastsel = cachedList[i].id
  120.         }
  121.         
  122.         if (sortby != listFunc.sortby)
  123.             {
  124.             listFunc.sortby = sortby;
  125.             listFunc.sortAsc = true;
  126.             }
  127.         else
  128.             {
  129.             listFunc.sortAsc = !listFunc.sortAsc;
  130.             }
  131.  
  132.         var num = parseFloat(cachedList[sortby]);
  133.         if (isNaN(num))
  134.             {
  135.             cachedList.sort(sortOrder);
  136.             }
  137.         else
  138.             { 
  139.             cachedList.sort(numOrder);
  140.             }
  141.             
  142.         if (!listFunc.sortAsc)
  143.             {
  144.             cachedList.reverse();
  145.             }
  146.             
  147.         if ( i != -1)            
  148.         {
  149.             setLastSel(lastsel);
  150.         }
  151.         
  152.         loadList();
  153.         }
  154.  
  155.     function sortOrder(a,b)
  156.         {
  157.         if (a[listFunc.sortby] < b[listFunc.sortby])
  158.             {
  159.             return -1;
  160.             }
  161.         else
  162.             {
  163.             if (a[listFunc.sortby] > b[listFunc.sortby])
  164.                 {
  165.                 return 1;
  166.                 }
  167.             else
  168.                 {
  169.                 return 0;
  170.                 }
  171.             }
  172.         }
  173.  
  174.     
  175.     function crop(thestring,size)
  176.         {
  177.         <% if Session("FONTSIZE") = "LARGE" then %>
  178.             size = size-10;
  179.         <% end if %>
  180.         if (thestring.length > size)
  181.             {
  182.             thestring = thestring.substring(0,size) + "...";
  183.             }
  184.         return thestring;
  185.         }    
  186.  
  187.     function buildListForm(){
  188.         numrows=0;
  189.         for (var i=0; i < cachedList.length; i++) {
  190.             if (cachedList[i].outType !=""){
  191.                 numrows=numrows + 1;
  192.             }
  193.         }
  194.  
  195.         qstr="numrows="+numrows;
  196.         qstr=qstr+"&cols=HttpErrors";
  197.  
  198.         parent.parent.hlist.location.href="iihdn.asp?"+qstr;
  199.  
  200.         <% 'the list values will be grabbed by the hiddenlistform script... %>
  201.     }
  202.  
  203.     function SetListVals(){
  204.  
  205.         listForm = parent.parent.hlist.document.hiddenlistform;    
  206.         j=0;
  207.         for (var i=0; i < cachedList.length; i++) {
  208.             if (cachedList[i].outType !=""){
  209.                 if (cachedList[i].Subcode == 0){
  210.                     sc = "*";
  211.                 }
  212.                 else{
  213.                     sc = cachedList[i].Subcode;
  214.                 }
  215.                 listForm.elements[j++].value=cachedList[i].error+","+sc+","+cachedList[i].outType+","+cachedList[i].msgPath;
  216.             }
  217.             cachedList[i].updated=false; 
  218.         }
  219.     }
  220.  
  221.     function listFuncs(){
  222.         this.addItem=addItem;
  223.         this.delItem=delItem;
  224.         this.writeList=buildListForm;
  225.         this.SetListVals=SetListVals;
  226.     }
  227.  
  228.     function listObj(i,e,s,o,p,d,t){
  229.         this.id = i;
  230.         this.error=e;
  231.         this.Subcode=s;
  232.         this.outType=o;
  233.         this.msgPath=p;
  234.         this.msgDefault=d;
  235.         this.types=t;
  236.         this.deleted=false;
  237.         this.newitem=false;
  238.         this.updated=false;
  239.  
  240.  
  241.         //lookup from Custom_Error_Desc
  242.         if (s !=0){
  243.             this.errcode=e +":" + s;
  244.         }
  245.         else{
  246.             this.errcode=e
  247.         }
  248.         
  249.         this.displayPath = crop(this.msgPath,50);
  250.     }
  251.  
  252.     cachedList=new Array()
  253.  
  254. <%  
  255.     On Error Resume Next 
  256.     
  257.     Dim path, currentobj, infoobj, i, ErrItem, thisErr
  258.     Dim aErrs, aErrDescs
  259.     
  260.     path=Session("dpath")
  261.     Session("path")=path
  262.     Session("SpecObj")=""
  263.     Session("SpecProps")=""
  264.     Set currentobj=GetObject(path)
  265.     Set infoobj=GetObject("IIS://localhost/w3svc/info")
  266.  
  267.     aErrs=currentobj.GetEx("HttpErrors")
  268.     aErrDescs=infoobj.GetEx("CustomErrorDescriptions")
  269.  
  270.     if err <> 0 then
  271.          %>cachedList[0]=new listObj("","","","","","");<% 
  272.     else
  273.         i = 0
  274.         For Each ErrItem in aErrDescs
  275.             thisErr=getError(ErrItem,aErrs)
  276.              %>cachedList[<%= i %>]=new listObj(<%= i %>, "<%= thisErr(0) %>","<%= thisErr(1) %>","<%= thisErr(2) %>","<%= thisErr(3) %>","<%= thisErr(4) %>", <%= thisErr(5) %>);<%   
  277.              i = i+1
  278.         Next
  279.         Response.write "loadList();"
  280.     end if
  281.  
  282.  
  283. function getError(errstr,aErrs)
  284.     'bug bug
  285.     On Error Resume Next
  286.     Dim i, one, two, three, four, five, error
  287.     Dim Subcode, errtext, Subcodetext, default, path, otype, thistype
  288.     Dim CErr, aCErr
  289.  
  290.     one=Instr(errstr,",")
  291.     two=Instr((one+1),errstr,",")
  292.     three=Instr((two+1),errstr,",")
  293.     four=Instr((three+1),errstr,",")
  294.     five=Instr((four+1),errstr,",")
  295.         
  296.     otype=0
  297.     error=Mid(errstr,1,(one-1))
  298.     subcode=Mid(errstr,(one+1),((two-one)-1))
  299.     errtext=Mid(errstr,(two+1), (three-two)-1)
  300.     subcodetext=Mid(errstr,(three+1), (four-three)-1)
  301.     otype=Mid(errstr,(four+1))
  302.     path=errtext & " " & Subcodetext
  303.  
  304.     default=path
  305.     thistype=""
  306.     
  307.     if aErrs(0) <> "" then
  308.  
  309.     For Each CErr in aErrs
  310.         aCErr=getCustomErr(CErr)
  311.         if ((error=aCErr(0)) and (subcode=replace(aCErr(1),"*","0"))) then
  312.             thistype=aCErr(2)
  313.             path=aCErr(3)
  314.             exit for
  315.         end if
  316.         i = i + 1
  317.     Next
  318.     end if
  319.     
  320.     getError=Array(error, subcode, thistype,path,default,otype)
  321.     
  322. end function
  323.  
  324. function getCustomErr(errstr)
  325.     Dim one, two, three, code, Subcode, src, path
  326.         
  327.     one=Instr(errstr,",")
  328.     two=Instr((one+1),errstr,",")
  329.     three=Instr((two+1),errstr,",")
  330.     
  331.     code=Mid(errstr,1,(one-1))
  332.     Subcode=Mid(errstr,(one+1),((two-one)-1))
  333.     src=Mid(errstr,(two+1), (three-two)-1)
  334.     path=Mid(errstr,(three+1))
  335.  
  336.     path=replace(path,"\","\\")
  337.  
  338.     getCustomErr=Array(code, Subcode, src, path)
  339. end function
  340.  
  341.  %>
  342.  
  343. listFunc=new listFuncs();
  344.  
  345.  
  346. </SCRIPT>
  347.  
  348. </HTML>
  349.