source: apps/routerconsole/jsp/summaryframe.jsp

Last change on this file was b8437cd, checked in by zzz <zzz@…>, 3 years ago

Console: Catch ISE in get/setAttribute() (ticket #1529)

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