source: apps/susidns/src/jsp/addressbook.jsp @ ce043943

Last change on this file since ce043943 was ce043943, checked in by zzz <zzz@…>, 2 years ago

SusiDNS: Add import feature (ticket #2447)
Box overlap issue remains todo, see ticket #2419

  • Property mode set to 100644
File size: 11.9 KB
Line 
1<%
2/*
3 * Created on Sep 02, 2005
4 *
5 *  This file is part of susidns project, see http://susi.i2p/
6 * 
7 *  Copyright (C) 2005 <susi23@mail.i2p>
8 *
9 *  This program is free software; you can redistribute it and/or modify
10 *  it under the terms of the GNU General Public License as published by
11 *  the Free Software Foundation; either version 2 of the License, or
12 *  (at your option) any later version.
13 *
14 *  This program is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU General Public License for more details.
18 *
19 *  You should have received a copy of the GNU General Public License
20 *  along with this program; if not, write to the Free Software
21 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22 * 
23 * $Revision: 1.3 $
24 */
25
26    // http://www.crazysquirrel.com/computing/general/form-encoding.jspx
27    if (request.getCharacterEncoding() == null)
28        request.setCharacterEncoding("UTF-8");
29
30    response.setHeader("X-Frame-Options", "SAMEORIGIN");
31    response.setHeader("Content-Security-Policy", "default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'");
32    response.setHeader("X-XSS-Protection", "1; mode=block");
33    response.setHeader("X-Content-Type-Options", "nosniff");
34    response.setHeader("Referrer-Policy", "no-referrer");
35    response.setHeader("Accept-Ranges", "none");
36
37%><%@page pageEncoding="UTF-8" contentType="text/html" import="net.i2p.servlet.RequestWrapper"
38%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
39<jsp:useBean id="version" class="i2p.susi.dns.VersionBean" scope="application" />
40<jsp:useBean id="book" class="i2p.susi.dns.NamingServiceBean" scope="session" />
41<jsp:useBean id="intl" class="i2p.susi.dns.Messages" scope="application" />
42<%
43   String importMessages = null;
44   if (intl._t("Import").equals(request.getParameter("action"))) {
45       RequestWrapper wrequest = new RequestWrapper(request);
46       importMessages = book.importFile(wrequest);
47   }
48%>
49<jsp:setProperty name="book" property="*" />
50<jsp:setProperty name="book" property="resetDeletionMarks" value="1"/>
51<c:forEach items="${paramValues.checked}" var="checked">
52<jsp:setProperty name="book" property="markedForDeletion" value="${checked}"/>
53</c:forEach>
54<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
55<html>
56<head>
57<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
58<title>${book.book} <%=intl._t("address book")%> - susidns</title>
59<link rel="stylesheet" type="text/css" href="<%=book.getTheme()%>susidns.css?<%=net.i2p.CoreVersion.VERSION%>">
60<script src="/js/resetScroll.js" type="text/javascript"></script>
61</head>
62<body>
63<div class="page">
64<div id="logo">
65<a href="index"><img src="<%=book.getTheme()%>images/logo.png" alt="" title="<%=intl._t("Overview")%>" border="0"/></a>
66</div>
67<hr>
68<div id="navi">
69<a id="overview" href="index"><%=intl._t("Overview")%></a>&nbsp;
70<a class="abook" href="addressbook?book=private&amp;filter=none"><%=intl._t("Private")%></a>&nbsp;
71<a class="abook" href="addressbook?book=master&amp;filter=none"><%=intl._t("Master")%></a>&nbsp;
72<a class="abook" href="addressbook?book=router&amp;filter=none"><%=intl._t("Router")%></a>&nbsp;
73<a class="abook" href="addressbook?book=published&amp;filter=none"><%=intl._t("Published")%></a>&nbsp;
74<a id="subs" href="subscriptions"><%=intl._t("Subscriptions")%></a>&nbsp;
75<a id="config" href="config"><%=intl._t("Configuration")%></a>
76</div>
77<hr>
78<div class="headline" id="addressbook">
79<h3><%=intl._t("Address book")%>: <%=intl._t(book.getBook())%></h3>
80<h4><%=intl._t("Storage")%>: ${book.displayName}</h4>
81</div>
82
83<div id="messages">${book.messages}<%
84   if (importMessages != null) {
85       %><%=importMessages%><%
86   }
87%></div>
88
89${book.loadBookMessages}
90
91<c:if test="${book.notEmpty}">
92<% if (book.getEntries().length > 0) { /* Don't show if no results. Can't figure out how to do this with c:if */ %>
93<form action="export" method="GET" target="_top">
94<div id="export">
95<input type="hidden" name="book" value="${book.book}">
96<c:if test="${book.search} != null && ${book.search}.length() > 0">
97<input type="hidden" name="search" value="${book.search}">
98</c:if>
99<c:if test="${book.hasFilter}">
100<input type="hidden" name="filter" value="${book.filter}">
101</c:if>
102<input type="submit" class="export" value="<%=intl._t("Export in hosts.txt format")%>" />
103</div>
104</form>
105<% } /* book.getEntries().length() > 0 */ %>
106
107<div id="filter">
108<c:if test="${book.hasFilter}">
109<span><%=intl._t("Current filter")%>: <b>${book.filter}</b>
110<a href="addressbook?filter=none&amp;begin=0&amp;end=49"><%=intl._t("clear filter")%></a></span>
111</c:if>
112<c:if test="${!book.hasFilter}">
113<span><%=intl._t("Filter")%></span>
114</c:if>
115<p>
116<a href="addressbook?filter=a&amp;begin=0&amp;end=49">a</a>
117<a href="addressbook?filter=b&amp;begin=0&amp;end=49">b</a>
118<a href="addressbook?filter=c&amp;begin=0&amp;end=49">c</a>
119<a href="addressbook?filter=d&amp;begin=0&amp;end=49">d</a>
120<a href="addressbook?filter=e&amp;begin=0&amp;end=49">e</a>
121<a href="addressbook?filter=f&amp;begin=0&amp;end=49">f</a>
122<a href="addressbook?filter=g&amp;begin=0&amp;end=49">g</a>
123<a href="addressbook?filter=h&amp;begin=0&amp;end=49">h</a>
124<a href="addressbook?filter=i&amp;begin=0&amp;end=49">i</a>
125<a href="addressbook?filter=j&amp;begin=0&amp;end=49">j</a>
126<a href="addressbook?filter=k&amp;begin=0&amp;end=49">k</a>
127<a href="addressbook?filter=l&amp;begin=0&amp;end=49">l</a>
128<a href="addressbook?filter=m&amp;begin=0&amp;end=49">m</a>
129<a href="addressbook?filter=n&amp;begin=0&amp;end=49">n</a>
130<a href="addressbook?filter=o&amp;begin=0&amp;end=49">o</a>
131<a href="addressbook?filter=p&amp;begin=0&amp;end=49">p</a>
132<a href="addressbook?filter=q&amp;begin=0&amp;end=49">q</a>
133<a href="addressbook?filter=r&amp;begin=0&amp;end=49">r</a>
134<a href="addressbook?filter=s&amp;begin=0&amp;end=49">s</a>
135<a href="addressbook?filter=t&amp;begin=0&amp;end=49">t</a>
136<a href="addressbook?filter=u&amp;begin=0&amp;end=49">u</a>
137<a href="addressbook?filter=v&amp;begin=0&amp;end=49">v</a>
138<a href="addressbook?filter=w&amp;begin=0&amp;end=49">w</a>
139<a href="addressbook?filter=x&amp;begin=0&amp;end=49">x</a>
140<a href="addressbook?filter=y&amp;begin=0&amp;end=49">y</a>
141<a href="addressbook?filter=z&amp;begin=0&amp;end=49">z</a>
142<a href="addressbook?filter=0-9&amp;begin=0&amp;end=49">0-9</a>
143<a href="addressbook?filter=xn--&amp;begin=0&amp;end=49"><%=intl._t("other")%></a>
144<a href="addressbook?filter=none&amp;begin=0&amp;end=49"><%=intl._t("all")%></a>
145</p>
146</div>
147
148<div id="search">
149<form method="POST" action="addressbook">
150<input type="hidden" name="book" value="${book.book}">
151<input type="hidden" name="begin" value="0">
152<input type="hidden" name="end" value="49">
153<div id="booksearch">
154<input class="search" type="text" name="search" value="${book.search}" size="20" >
155<input class="search" type="submit" name="submitsearch" value="<%=intl._t("Search")%>" >
156</div>
157</form>
158</div>
159</c:if>
160
161<%
162    // have to only do this once per page
163    String susiNonce = book.getSerial();
164%>
165<c:if test="${book.notEmpty}">
166<form method="POST" action="addressbook">
167<input type="hidden" name="book" value="${book.book}">
168<input type="hidden" name="serial" value="<%=susiNonce%>">
169<input type="hidden" name="begin" value="0">
170<input type="hidden" name="end" value="49">
171<jsp:setProperty name="book" property="trClass" value="0" />
172<div id="book">
173<table class="book" id="host_list" cellspacing="0" cellpadding="5">
174<tr class="head">
175
176<% if (book.getEntries().length > 0) { /* Don't show if no results. Can't figure out how to do this with c:if */ %>
177<th><%=intl._t("Hostname")%></th>
178<th><%=intl._t("Link (b32)")%></th>
179<th>Helper</th>
180<th>Details</th>
181<th><%=intl._t("Destination")%></th>
182
183<c:if test="${book.validBook}">
184<th title="<%=intl._t("Select hosts for deletion from addressbook")%>"></th>
185</c:if>
186
187</tr>
188<%
189    boolean haveImagegen = book.haveImagegen();
190%>
191<!-- limit iterator, or "Form too large" may result on submit, and is a huge web page if we don't -->
192<c:forEach items="${book.entries}" var="addr" begin="${book.resultBegin}" end="${book.resultEnd}">
193<tr class="list${book.trClass}">
194<td class="names">
195<%
196    if (haveImagegen) {
197%>
198<a href="/imagegen/id?s=256&amp;c=${addr.b32}" target="_blank" title="<%=intl._t("View larger version of identicon for this hostname")%>"><img src="/imagegen/id?s=20&amp;c=${addr.b32}"></a>
199<%
200    }  // haveImagegen
201%>
202<a href="http://${addr.name}/" target="_top">${addr.displayName}</a></td>
203<td class="names"><span class="addrhlpr"><a href="http://${addr.b32}/" target="_blank" title="<%=intl._t("Base 32 address")%>">b32</a></span></td>
204<td class="helper"><a href="http://${addr.name}/?i2paddresshelper=${addr.destination}" target="_blank" title="<%=intl._t("Helper link to share host address with option to add to addressbook")%>">link</a></td>
205<td class="names"><span class="addrhlpr"><a href="details?h=${addr.name}&amp;book=${book.book}" title="<%=intl._t("More information on this entry")%>"><%=intl._t("details")%></a></span></td>
206<td class="destinations"><div class="destaddress" name="dest_${addr.name}" width="200px" tabindex="0" onblur="resetScrollLeft(this)">${addr.destination}</div></td>
207
208<c:if test="${book.validBook}">
209<td class="checkbox"><input type="checkbox" name="checked" value="${addr.name}" title="<%=intl._t("Mark for deletion")%>"></td>
210</c:if>
211
212</tr>
213
214</c:forEach>
215<% } /* book..getEntries().length() > 0 */ %>
216</table>
217</div>
218
219<% if (book.getEntries().length > 0) { /* Don't show if no results. Can't figure out how to do this with c:if */ %>
220<c:if test="${book.validBook}">
221<div id="buttons">
222<p class="buttons">
223<input class="cancel" type="reset" value="<%=intl._t("Cancel")%>" >
224<input class="delete" type="submit" name="action" value="<%=intl._t("Delete Selected")%>" >
225</p>
226</div>
227</c:if>
228<% } /* book..getEntries().length() > 0 */ %>
229</form>
230</c:if><% /* book.notEmpty */ %>
231
232<c:if test="${book.isEmpty}">
233<div id="emptybook">
234<p class="book"><%=intl._t("This address book is empty.")%></p>
235</div>
236</c:if>
237
238<form method="POST" action="addressbook">
239<input type="hidden" name="book" value="${book.book}">
240<input type="hidden" name="serial" value="<%=susiNonce%>">
241<input type="hidden" name="begin" value="0">
242<input type="hidden" name="end" value="49">
243<div id="add">
244<h3><%=intl._t("Add new destination")%></h3>
245<table>
246<tr>
247<td><b><%=intl._t("Hostname")%></b></td>
248<td><input type="text" name="hostname" value="${book.hostname}" size="54"></td>
249</tr>
250<tr>
251<td><b><%=intl._t("Destination")%></b></td>
252<td><textarea name="destination" rows="1" style="height:3em" wrap="off" cols="70" spellcheck="false">${book.destination}</textarea></td>
253</tr>
254</table>
255<p class="buttons">
256<input class="cancel" type="reset" value="<%=intl._t("Cancel")%>" >
257<input class="accept" type="submit" name="action" value="<%=intl._t("Replace")%>" >
258<% if (!book.getBook().equals("published")) { %>
259  <input class="add" type="submit" name="action" value="<%=intl._t("Add Alternate")%>" >
260<% } %>
261<input class="add" type="submit" name="action" value="<%=intl._t("Add")%>" >
262</p>
263</div>
264</form>
265
266<% if (!book.getBook().equals("published")) { %>
267<form method="POST" action="addressbook" enctype="multipart/form-data" accept-charset="UTF-8">
268<input type="hidden" name="book" value="${book.book}">
269<input type="hidden" name="serial" value="<%=susiNonce%>">
270<input type="hidden" name="begin" value="0">
271<input type="hidden" name="end" value="49">
272<div id="import">
273<h3><%=intl._t("Import from hosts.txt file")%></h3>
274<table>
275<tr>
276<td><b><%=intl._t("File")%></b></td>
277<td><input name="file" type="file" accept=".txt" value="" /></td>
278</tr>
279</table>
280<p class="buttons">
281<input class="cancel" type="reset" value="<%=intl._t("Cancel")%>" >
282<input class="download" type="submit" name="action" value="<%=intl._t("Import")%>" >
283</p>
284</div>
285</form>
286<% } %>
287
288<div id="footer">
289<hr>
290<p class="footer">susidns v${version.version} &copy; <a href="${version.url}" target="_top">susi</a> 2005</p>
291</div>
292</div>
293</body>
294</html>
Note: See TracBrowser for help on using the repository browser.