source: apps/routerconsole/jsp/summaryframe.jsp @ 6b811b3

Last change on this file since 6b811b3 was 6b811b3, checked in by zzz <zzz@…>, 9 years ago

replace more equalsIgnoreCase() calls

  • Property mode set to 100644
File size: 3.4 KB
Line 
1<%@page contentType="text/html"%>
2<%@page pageEncoding="UTF-8"%>
3<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4<%
5/*
6 * All links in the summary bar must have target="_top"
7 * so they don't load in the iframe
8 */
9%>
10<html><head>
11<%@include file="css.jsi" %>
12<title>Summary Bar</title>
13<%
14    // try hard to avoid an error page in the iframe after shutdown
15    String action = request.getParameter("action");
16    String d = request.getParameter("refresh");
17    // Normal browsers send value, IE sends button label
18    boolean allowIFrame = intl.allowIFrame(request.getHeader("User-Agent"));
19    boolean shutdownSoon = (!allowIFrame) ||
20                           "shutdownImmediate".equals(action) || "restartImmediate".equals(action) ||
21                           "Shutdown immediately".equals(action) || "Restart immediately".equals(action);
22    if (!shutdownSoon) {
23        if (d == null || "".equals(d)) {
24            d = intl.getRefresh();
25        } else {
26            d = net.i2p.data.DataHelper.stripHTML(d);  // XSS
27            intl.setRefresh(d);
28        }
29        // we probably don't get here if d == "0" since caught in summary.jsi, but just
30        // to be sure...
31        if (!"0".equals(d)) {
32            // doesn't work for restart or shutdown with no expl. tunnels,
33            // since the call to ConfigRestartBean.renderStatus() hasn't happened yet...
34            // So we delay slightly
35            if (action != null &&
36                ("restart".equals(action.toLowerCase(java.util.Locale.US)) || "shutdown".equals(action.toLowerCase(java.util.Locale.US)))) {
37                synchronized(this) {
38                    try {
39                        wait(1000);
40                    } catch(InterruptedException ie) {}
41                }
42            }
43            long timeleft = net.i2p.router.web.ConfigRestartBean.getRestartTimeRemaining();
44            long delay = 60;
45            try { delay = Long.parseLong(d); } catch (NumberFormatException nfe) {}
46            if (delay*1000 < timeleft + 5000)
47                out.print("<meta http-equiv=\"refresh\" content=\"" + d + ";url=/summaryframe.jsp\" >\n");
48            else
49                shutdownSoon = true;
50        }
51    }
52%>
53</head><body style="margin: 0;"><div class="routersummary">
54<%@include file="summarynoframe.jsi" %>
55<%
56    // d and shutdownSoon defined above
57    if (!shutdownSoon) {
58        out.print("<div class=\"refresh\"><form action=\"summaryframe.jsp\" method=\"POST\">\n");
59        if ("0".equals(d)) {
60            out.print("<b>");
61            out.print(intl._("Refresh (s)"));
62            out.print(":</b> <input size=\"3\" type=\"text\" name=\"refresh\" value=\"60\" >\n");
63            out.print("<button type=\"submit\" value=\"Enable\" >");
64            out.print(intl._("Enable"));
65        } else {
66            // this will load in the iframe but subsequent pages will not have the iframe
67            out.print("<input type=\"hidden\" name=\"refresh\" value=\"0\" >\n");
68            out.print("<button type=\"submit\" value=\"Disable\" >");
69            long refreshMS = 60*1000;
70            try {
71                refreshMS = 1000 * Long.parseLong(d);
72            } catch (NumberFormatException nfe) {}
73            String refreshTime = net.i2p.data.DataHelper.formatDuration2(refreshMS);
74            out.print(intl._("Disable {0} Refresh", refreshTime));
75        }
76        out.print("</button></form></div>\n");
77    }
78%>
79</div></body></html>
Note: See TracBrowser for help on using the repository browser.