-public class MailingList extends Persistent implements Target {
-
- public static enum UserType { Administrator, Moderator, Member }
- public static enum SubscriptionType { All, None, Digest, MimeDigest }
- public static enum Visibility { Members, Public, Nobody }
- public static enum Action { Accept, Hold, Reject }
+ public void banner(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ String basename = request.getServletPath();
+ PrintWriter pw = new PrintWriter(response.getWriter());
+ pw.println("<html>");
+ pw.println(" <body>");
+ String confirm = request.getParameter("confirm");
+ if (confirm != null) {
+ Subscribe sub = (Subscribe)Confirmation.decode(confirm, Long.parseLong(properties.get("secret")), new Date());
+ String email = sub.email;
+ synchronized(this) {
+ String path = this.path.getAbsolutePath() + File.separatorChar + "subscribers" + File.separatorChar + sub.email;
+ if (sub.un) new File(path).delete();
+ else {
+ Log.warn(null, "creating " + path);
+ new FileOutputStream(path).close();
+ }
+ }
+ pw.println(" <b>successfully "+sub.adj+"d " + email + " to " + properties.get("address"));
+ } else {
+ pw.println(" <b>"+properties.get("address")+"</b><br>");
+ pw.println(" <tt><a href="+properties.get("nntp")+">"+properties.get("nntp")+"</a></tt><br>");
+ String action = request.getParameter("action");
+ String email = request.getParameter("email");
+ if (action != null) {
+ Subscribe sub = new Subscribe(email, request.getRequestURL().toString(), action.equals("unsubscribe"));
+ sub.signAndSend(new Address(properties.get("owner")), Long.parseLong(properties.get("secret")), new Date());
+ pw.println("a confirmation email has been sent to " + email + "; click the enclosed link to confirm your request to " + action);
+ } else {
+ pw.println(" <form action='"+basename+"' method=post name=form1>");
+ pw.println(" <input type=text width=100 value='your@email.com' name=email>");
+ pw.println(" <input type=hidden name=frame value=banner>");
+ pw.println(" <select name=action onchange='form1.submit()'>");
+ pw.println(" <option>--choose action--</option>");
+ pw.println(" <option>subscribe</option>");
+ pw.println(" <option>unsubscribe</option>");
+ pw.println(" </select>");
+ pw.println(" </form>");
+ }
+ }
+ pw.println(" </body>");
+ pw.println("</html>");
+ pw.flush();
+ pw.close();
+ }