source: apps/routerconsole/jsp/summaryframe.jsp @ b02fe53

Last change on this file since b02fe53 was b02fe53, checked in by zzz <zzz@…>, 9 years ago
  • Console:
    • Parameterize download button tags (ticket #425)
    • Clean up summary bar HTML warnings
    • Just display a summary bar link for text browsers
    • Move welcome div from the readme files to index.jsp
    • Require a nonce to change language
  • Property mode set to 100644
File size: 3.3 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 ("restart".equalsIgnoreCase(action) || "shutdown".equalsIgnoreCase(action)) {
36                synchronized(this) {
37                    try {
38                        wait(1000);
39                    } catch(InterruptedException ie) {}
40                }
41            }
42            long timeleft = net.i2p.router.web.ConfigRestartBean.getRestartTimeRemaining();
43            long delay = 60;
44            try { delay = Long.parseLong(d); } catch (NumberFormatException nfe) {}
45            if (delay*1000 < timeleft + 5000)
46                out.print("<meta http-equiv=\"refresh\" content=\"" + d + ";url=/summaryframe.jsp\" >\n");
47            else
48                shutdownSoon = true;
49        }
50    }
51%>
52</head><body style="margin: 0;"><div class="routersummary">
53<%@include file="summarynoframe.jsi" %>
54<%
55    // d and shutdownSoon defined above
56    if (!shutdownSoon) {
57        out.print("<div class=\"refresh\"><form action=\"summaryframe.jsp\" method=\"POST\">\n");
58        if ("0".equals(d)) {
59            out.print("<b>");
60            out.print(intl._("Refresh (s)"));
61            out.print(":</b> <input size=\"3\" type=\"text\" name=\"refresh\" value=\"60\" >\n");
62            out.print("<button type=\"submit\" value=\"Enable\" >");
63            out.print(intl._("Enable"));
64        } else {
65            // this will load in the iframe but subsequent pages will not have the iframe
66            out.print("<input type=\"hidden\" name=\"refresh\" value=\"0\" >\n");
67            out.print("<button type=\"submit\" value=\"Disable\" >");
68            long refreshMS = 60*1000;
69            try {
70                refreshMS = 1000 * Long.parseLong(d);
71            } catch (NumberFormatException nfe) {}
72            String refreshTime = net.i2p.data.DataHelper.formatDuration2(refreshMS);
73            out.print(intl._("Disable {0} Refresh", refreshTime));
74        }
75        out.print("</button></form></div>\n");
76    }
77%>
78</div></body></html>
Note: See TracBrowser for help on using the repository browser.