Changeset 2f1d6e3f


Ignore:
Timestamp:
May 26, 2009 8:04:20 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
32566a4
Parents:
32dddac
Message:
  • Console:
    • Use CSS for form messages
    • Goodbye nonce spoof message
    • tunnels.jsp improvements
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java

    r32dddac r2f1d6e3f  
    146146            return "";
    147147        if ( (_prevNonce != _curNonce) && (!validPassphrase(_passphrase)) )
    148             return "Invalid nonce, are you being spoofed?";
     148            return "Invalid form submission, probably because you used the 'back' or 'reload' button on your browser. Please resubmit.";
    149149        if ("Stop all".equals(_action))
    150150            return stopAll();
  • apps/routerconsole/java/src/net/i2p/router/web/FormHandler.java

    r32dddac r2f1d6e3f  
    1313 *
    1414 * The form is "processed" after the properties are set and the first output
    15  * property is retrieved - either getNotices() or getErrors().
     15 * property is retrieved - either getAll(), getNotices() or getErrors().
    1616 *
    1717 */
     
    2222    protected String _action;
    2323    protected String _passphrase;
    24     private List _errors;
    25     private List _notices;
     24    private List<String> _errors;
     25    private List<String> _notices;
    2626    private boolean _processed;
    2727    private boolean _valid;
     
    8080   
    8181    /**
     82     * Display everything, wrap it in a div for consistent presentation
     83     *
     84     */
     85    public String getAllMessages() {
     86        validate();
     87        process();
     88        if (_errors.size() <= 0 && _notices.size() <= 0)
     89            return "";
     90        StringBuffer buf = new StringBuffer(512);
     91        buf.append("<div class=\"messages\" id=\"messages\"><p>");
     92        if (_errors.size() > 0) {
     93            buf.append("<span class=\"error\">");
     94            buf.append(render(_errors));
     95            buf.append("</span>");
     96        }
     97        if (_notices.size() > 0) {
     98            buf.append("<span class=\"notice\">");
     99            buf.append(render(_notices));
     100            buf.append("</span>");
     101        }
     102        buf.append("</p></div>");
     103        return buf.toString();
     104    }
     105   
     106    /**
    82107     * Display any error messages (processing the form if it hasn't
    83108     * been yet)
     
    86111    public String getErrors() {
    87112        validate();
     113        process();
    88114        return render(_errors);
    89115    }
     
    96122    public String getNotices() {
    97123        validate();
     124        process();
    98125        return render(_notices);
    99126    }
     
    134161                // ok
    135162            } else {
    136                 addFormError("Invalid nonce, are you being spoofed?");
     163                addFormError("Invalid form submission, probably because you used the 'back' or 'reload' button on your browser. Please resubmit.");
    137164                _valid = false;
    138165            }
     
    140167    }
    141168   
    142     private String render(List source) {
     169    private void process() {
    143170        if (!_processed) {
    144171            if (_valid)
     
    146173            _processed = true;
    147174        }
     175    }
     176   
     177    private String render(List<String> source) {
    148178        if (source.size() <= 0) {
    149179            return "";
    150         } else if (source.size() == 1) {
    151             return (String)source.get(0);
    152180        } else {
    153181            StringBuffer buf = new StringBuffer(512);
     
    155183            for (int i = 0; i < source.size(); i++) {
    156184                buf.append("<li>");
    157                 buf.append((String)source.get(i));
     185                buf.append(source.get(i));
    158186                buf.append("</li>\n");
    159187            }
  • apps/routerconsole/jsp/config.jsp

    r32dddac r2f1d6e3f  
    1919 <jsp:setProperty name="formhandler" property="*" />
    2020 <jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
    21  <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font>
    22  <i><jsp:getProperty name="formhandler" property="notices" /></i>
     21 <jsp:getProperty name="formhandler" property="allMessages" />
    2322
    2423 <form action="config.jsp" method="POST">
     
    117116    <br />
    118117    <input type="radio" name="udpAutoIP" value="hidden" <%=nethelper.getUdpAutoIPChecked(2) %> />
    119     Hidden mode - do not publish IP<i>(prevents participating traffic; change restarts router)</i><br />
     118    Hidden mode - do not publish IP <i>(prevents participating traffic; change restarts router)</i><br />
    120119 </p><p>
    121120 <b>UDP Configuration:</b><br />
  • apps/routerconsole/jsp/configadvanced.jsp

    r32dddac r2f1d6e3f  
    2020 <jsp:setProperty name="formhandler" property="*" />
    2121 <jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
    22  <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font>
    23  <i><jsp:getProperty name="formhandler" property="notices" /></i>
     22 <jsp:getProperty name="formhandler" property="allMessages" />
    2423 
    2524 <form action="configadvanced.jsp" method="POST">
  • apps/routerconsole/jsp/configclients.jsp

    r32dddac r2f1d6e3f  
    2727 <jsp:setProperty name="formhandler" property="nonce" value="<%=request.getParameter("nonce")%>" />
    2828 <jsp:setProperty name="formhandler" property="settings" value="<%=request.getParameterMap()%>" />
    29  <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font>
    30  <i><jsp:getProperty name="formhandler" property="notices" /></i>
     29 <jsp:getProperty name="formhandler" property="allMessages" />
    3130 
    3231 <form action="configclients.jsp" method="POST">
  • apps/routerconsole/jsp/configkeyring.jsp

    r32dddac r2f1d6e3f  
    1717 <jsp:setProperty name="formhandler" property="*" />
    1818 <jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
    19  <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font>
    20  <i><jsp:getProperty name="formhandler" property="notices" /></i>
     19 <jsp:getProperty name="formhandler" property="allMessages" />
    2120 
    2221
  • apps/routerconsole/jsp/configlogging.jsp

    r32dddac r2f1d6e3f  
    1919 <jsp:setProperty name="formhandler" property="*" />
    2020 <jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
    21  <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font>
    22  <i><jsp:getProperty name="formhandler" property="notices" /></i>
     21 <jsp:getProperty name="formhandler" property="allMessages" />
    2322 
    2423 <form action="configlogging.jsp" method="POST">
  • apps/routerconsole/jsp/configpeer.jsp

    r32dddac r2f1d6e3f  
    1717 <jsp:setProperty name="formhandler" property="*" />
    1818 <jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
    19  <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font>
    20  <i><jsp:getProperty name="formhandler" property="notices" /></i>
     19 <jsp:getProperty name="formhandler" property="allMessages" />
    2120 
    2221
  • apps/routerconsole/jsp/configservice.jsp

    r32dddac r2f1d6e3f  
    1717 <jsp:setProperty name="formhandler" property="*" />
    1818 <jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
    19  <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font>
    20  <i><jsp:getProperty name="formhandler" property="notices" /></i>
     19 <jsp:getProperty name="formhandler" property="allMessages" />
    2120 
    2221 <form action="configservice.jsp" method="POST">
  • apps/routerconsole/jsp/configstats.jsp

    r32dddac r2f1d6e3f  
    6262 <jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
    6363 <jsp:setProperty name="formhandler" property="*" />
    64  <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font>
    65  <i><jsp:getProperty name="formhandler" property="notices" /></i>
     64 <jsp:getProperty name="formhandler" property="allMessages" />
    6665
    6766 <jsp:useBean class="net.i2p.router.web.ConfigStatsHelper" id="statshelper" scope="request" />
  • apps/routerconsole/jsp/configtunnels.jsp

    r32dddac r2f1d6e3f  
    2323 <jsp:setProperty name="formhandler" property="nonce" value="<%=request.getParameter("nonce")%>" />
    2424 <jsp:setProperty name="formhandler" property="settings" value="<%=request.getParameterMap()%>" />
    25  <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font>
    26  <i><jsp:getProperty name="formhandler" property="notices" /></i>
     25 <jsp:getProperty name="formhandler" property="allMessages" />
    2726 
    2827 <p><i>
  • apps/routerconsole/jsp/configupdate.jsp

    r32dddac r2f1d6e3f  
    1717 <jsp:setProperty name="formhandler" property="*" />
    1818 <jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
    19  <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font>
    20  <i><jsp:getProperty name="formhandler" property="notices" /></i>
     19 <jsp:getProperty name="formhandler" property="allMessages" />
    2120 
    2221 <jsp:useBean class="net.i2p.router.web.ConfigUpdateHelper" id="updatehelper" scope="request" />
  • apps/routerconsole/jsp/default.css

    r32dddac r2f1d6e3f  
    9090
    9191div.confignav {
     92        padding: 1em;
    9293        background-color: #efefff;
    9394}
    9495
    9596div.configure {
     97        padding: 1em;
    9698        background-color: #ffffc0;
    9799}
     100
     101div.messages {
     102        padding: 1em;
     103        background-color: #fafaff;
     104}
     105
     106div.messages span.error {
     107        color: #d00000;
     108}
     109
     110div.messages span.notice {
     111        font-style: italic;
     112}
  • apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java

    r32dddac r2f1d6e3f  
    271271                        }                       
    272272                        else {
    273                                 message += "Invalid nonce. Are you being spoofed?";
     273                                message = "Invalid form submission, probably because you used the 'back' or 'reload' button on your browser. Please resubmit.";
    274274                        }
    275275                }
  • apps/susidns/src/java/src/i2p/susi/dns/ConfigBean.java

    r32dddac r2f1d6e3f  
    143143                        }                       
    144144                        else {
    145                                 message = "Invalid nonce. Are you being spoofed?";
     145                                message = "Invalid form submission, probably because you used the 'back' or 'reload' button on your browser. Please resubmit.";
    146146                        }
    147147                }
  • apps/susidns/src/java/src/i2p/susi/dns/SubscriptionsBean.java

    r32dddac r2f1d6e3f  
    137137                        }                       
    138138                        else {
    139                                 message = "Invalid nonce. Are you being spoofed?";
     139                                message = "Invalid form submission, probably because you used the 'back' or 'reload' button on your browser. Please resubmit.";
    140140                        }
    141141                }
  • router/java/src/net/i2p/router/tunnel/pool/TunnelPoolManager.java

    r32dddac r2f1d6e3f  
    524524        long processedOut = (outPool != null ? outPool.getLifetimeProcessed() : 0);
    525525       
    526         out.write("<table border=\"1\"><tr><td><b>Direction</b></td><td><b>Expiration</b></td><td><b>Usage</b></td><td align=\"left\">Hops (gateway first)</td></tr>\n");
    527526        int live = 0;
     527        int maxLength = 1;
     528        for (int i = 0; i < tunnels.size(); i++) {
     529            TunnelInfo info = (TunnelInfo)tunnels.get(i);
     530            if (info.getLength() > maxLength)
     531                maxLength = info.getLength();
     532        }
     533        out.write("<table border=\"1\"><tr><th>Direction</th><th>Expiration</th><th>Usage</th><th>Gateway</th>");
     534        if (maxLength > 3) {
     535            out.write("<th align=\"center\" colspan=\"" + (maxLength - 2));
     536            out.write("\">Participants</th>");
     537        }
     538        else if (maxLength == 3) {
     539            out.write("<th>Participant</th>");
     540        }
     541        if (maxLength > 1) {
     542            out.write("<th>Endpoint</th>");
     543        }
     544        out.write("</tr>\n");
    528545        for (int i = 0; i < tunnels.size(); i++) {
    529546            TunnelInfo info = (TunnelInfo)tunnels.get(i);
     
    546563                    String cap = getCapacity(peer);
    547564                    out.write("<td>" + netDbLink(peer) + (id == null ? "" : " " + id) + cap + "</td>");               
     565                }
     566                if (info.getLength() < maxLength && (info.getLength() == 1 || j == info.getLength() - 2)) {
     567                    for (int k = info.getLength(); k < maxLength; k++)
     568                        out.write("<td>&nbsp</td>");
    548569                }
    549570            }
Note: See TracChangeset for help on using the changeset viewer.