diff --git a/apps/syndie/java/src/net/i2p/syndie/BlogManager.java b/apps/syndie/java/src/net/i2p/syndie/BlogManager.java index 1773725782615fe3b36d678eb89e28b5e2d12293..3e696c0633fca2d8c09e219ff1a65760a5d5d9b4 100644 --- a/apps/syndie/java/src/net/i2p/syndie/BlogManager.java +++ b/apps/syndie/java/src/net/i2p/syndie/BlogManager.java @@ -241,8 +241,8 @@ public class BlogManager { return (cfg.exists()); } - public String getDefaultProxyHost() { return _context.getProperty("syndie.defaultProxyHost", "localhost"); } - public String getDefaultProxyPort() { return _context.getProperty("syndie.defaultProxyPort", "4444"); } + public String getDefaultProxyHost() { return _context.getProperty("syndie.defaultProxyHost", ""); } + public String getDefaultProxyPort() { return _context.getProperty("syndie.defaultProxyPort", ""); } public boolean authorizeAdmin(String pass) { String admin = getAdminPasswordHash(); @@ -275,8 +275,6 @@ public class BlogManager { out.write("syndie.defaultSelector="+defaultSelector.trim() + "\n"); if (defaultProxyHost != null) out.write("syndie.defaultProxyHost="+defaultProxyHost.trim() + "\n"); - if (defaultProxyHost != null) - out.write("syndie.defaultProxyHost="+defaultProxyHost.trim() + "\n"); if (defaultProxyPort > 0) out.write("syndie.defaultProxyPort="+defaultProxyPort + "\n"); if (opts != null) { @@ -527,8 +525,7 @@ public class BlogManager { return false; } } - - + public String addAddress(User user, String name, String protocol, String location, String schema) { if (!user.getAuthenticated()) return "Not logged in"; boolean ok = validateAddressName(name); @@ -572,7 +569,7 @@ public class BlogManager { } private boolean validateAddressName(String name) { - if ( (name == null) || (name.trim().length() <= 0) || (!name.endsWith(".i2p")) ) return false; + if ( (name == null) || (name.trim().length() <= 0) ) return false; for (int i = 0; i < name.length(); i++) { char c = name.charAt(i); if (!Character.isLetterOrDigit(c) && ('.' != c) && ('-' != c) && ('_' != c) ) @@ -599,7 +596,11 @@ public class BlogManager { private boolean validateAddressSchema(String schema) { if ( (schema == null) || (schema.trim().length() <= 0) ) return false; - return "eep".equals(schema) || "i2p".equals(schema); + if (true) { + return true; + } else { + return "eep".equals(schema) || "i2p".equals(schema); + } } private final SimpleDateFormat _dateFormat = new SimpleDateFormat("yyyy/MM/dd", Locale.UK); diff --git a/apps/syndie/java/src/net/i2p/syndie/sml/HTMLPreviewRenderer.java b/apps/syndie/java/src/net/i2p/syndie/sml/HTMLPreviewRenderer.java index 21274d79cde871abf812ac8fc673c50abb74dbdf..b12db6b690e40b682887aa1e7af98a1e4c7d6da0 100644 --- a/apps/syndie/java/src/net/i2p/syndie/sml/HTMLPreviewRenderer.java +++ b/apps/syndie/java/src/net/i2p/syndie/sml/HTMLPreviewRenderer.java @@ -101,12 +101,12 @@ public class HTMLPreviewRenderer extends HTMLRenderer { if (knownName != null) { _postBodyBuffer.append(' ').append(sanitizeString(knownName)); } else { - _postBodyBuffer.append(" <a href=\"addaddress.jsp?schema="); - _postBodyBuffer.append(sanitizeURL(a.schema)).append("&location="); - _postBodyBuffer.append(sanitizeURL(a.location)).append("&name="); - _postBodyBuffer.append(sanitizeURL(a.protocol)).append("&protocol="); - _postBodyBuffer.append(sanitizeURL(a.name)); - _postBodyBuffer.append("\">").append(sanitizeString(a.name)); + _postBodyBuffer.append(" <a href=\"addresses.jsp?network="); + _postBodyBuffer.append(sanitizeTagParam(a.schema)).append("&location="); + _postBodyBuffer.append(sanitizeTagParam(a.location)).append("&name="); + _postBodyBuffer.append(sanitizeTagParam(a.protocol)).append("&protocol="); + _postBodyBuffer.append(sanitizeTagParam(a.name)); + _postBodyBuffer.append("\">").append(sanitizeString(a.name)).append("</a>"); } } _postBodyBuffer.append("<br />\n"); diff --git a/apps/syndie/java/src/net/i2p/syndie/sml/HTMLRenderer.java b/apps/syndie/java/src/net/i2p/syndie/sml/HTMLRenderer.java index cf9c8543bd4fab0aee261db2a6bd59ac10c1da85..d6066a7d1cb0af474e97a0c55cb8f511eef72a3b 100644 --- a/apps/syndie/java/src/net/i2p/syndie/sml/HTMLRenderer.java +++ b/apps/syndie/java/src/net/i2p/syndie/sml/HTMLRenderer.java @@ -416,11 +416,11 @@ public class HTMLRenderer extends EventReceiverImpl { _bodyBuffer.append(" <i>(").append(sanitizeString(knownName)).append(")</i>"); } else { System.err.println("Receiving address [" + location + "]"); - _bodyBuffer.append("<a href=\"addaddress.jsp?schema="); - _bodyBuffer.append(sanitizeURL(schema)).append("&name="); - _bodyBuffer.append(sanitizeURL(name)).append("&protocol="); - _bodyBuffer.append(sanitizeURL(protocol)).append("&location="); - _bodyBuffer.append(sanitizeURL(location)).append("\">").append(sanitizeString(anchorText)).append("</a>"); + _bodyBuffer.append("<a href=\"addresses.jsp?network="); + _bodyBuffer.append(sanitizeTagParam(schema)).append("&name="); + _bodyBuffer.append(sanitizeTagParam(name)).append("&protocol="); + _bodyBuffer.append(sanitizeTagParam(protocol)).append("&location="); + _bodyBuffer.append(sanitizeTagParam(location)).append("\">").append(sanitizeString(anchorText)).append("</a>"); } } @@ -563,12 +563,12 @@ public class HTMLRenderer extends EventReceiverImpl { if (knownName != null) { _postBodyBuffer.append(' ').append(sanitizeString(knownName)); } else { - _postBodyBuffer.append(" <a href=\"addaddress.jsp?schema="); - _postBodyBuffer.append(sanitizeURL(a.schema)).append("&location="); - _postBodyBuffer.append(sanitizeURL(a.location)).append("&name="); - _postBodyBuffer.append(sanitizeURL(a.name)).append("&protocol="); - _postBodyBuffer.append(sanitizeURL(a.protocol)); - _postBodyBuffer.append("\">").append(sanitizeString(a.name)); + _postBodyBuffer.append(" <a href=\"addresses.jsp?network="); + _postBodyBuffer.append(sanitizeTagParam(a.schema)).append("&location="); + _postBodyBuffer.append(sanitizeTagParam(a.location)).append("&name="); + _postBodyBuffer.append(sanitizeTagParam(a.name)).append("&protocol="); + _postBodyBuffer.append(sanitizeTagParam(a.protocol)); + _postBodyBuffer.append("\">").append(sanitizeString(a.name)).append("</a>"); } } _postBodyBuffer.append("<br />\n"); @@ -624,7 +624,23 @@ public class HTMLRenderer extends EventReceiverImpl { public void receiveHeader(String header, String value) { //System.err.println("Receive header [" + header + "] = [" + value + "]"); - _headers.put(header, value); + if (HEADER_PETNAME.equals(header)) { + StringTokenizer tok = new StringTokenizer(value, "\t\n"); + if (tok.countTokens() != 4) + return; + String name = tok.nextToken(); + String net = tok.nextToken(); + String proto = tok.nextToken(); + String loc = tok.nextToken(); + Address a = new Address(); + a.name = sanitizeString(name, false); + a.schema = sanitizeString(net, false); + a.protocol = sanitizeString(proto, false); + a.location = sanitizeString(loc, false); + _addresses.add(a); + } else { + _headers.put(header, value); + } } public void receiveHeaderEnd() { @@ -637,6 +653,8 @@ public class HTMLRenderer extends EventReceiverImpl { public static final String HEADER_SUBJECT = "Subject"; public static final String HEADER_BGCOLOR = "bgcolor"; public static final String HEADER_IN_REPLY_TO = "InReplyTo"; + public static final String HEADER_STYLE = "Style"; + public static final String HEADER_PETNAME = "PetName"; private void renderSubjectCell() { _preBodyBuffer.append("<tr class=\"syndieEntrySubjectCell\"><td align=\"left\" valign=\"top\" class=\"syndieEntrySubjectCell\" width=\"400\"> "); diff --git a/apps/syndie/java/src/net/i2p/syndie/sml/RSSRenderer.java b/apps/syndie/java/src/net/i2p/syndie/sml/RSSRenderer.java index 64bc6cf3ca819b19d7458adb57e7ab0ece156d03..e31d1b31dfae815d5102119992b55febb6cace28 100644 --- a/apps/syndie/java/src/net/i2p/syndie/sml/RSSRenderer.java +++ b/apps/syndie/java/src/net/i2p/syndie/sml/RSSRenderer.java @@ -250,11 +250,11 @@ public class RSSRenderer extends HTMLRenderer { knownName = _user.getPetNameDB().getNameByLocation(a.location); if (knownName == null) { StringBuffer url = new StringBuffer(128); - url.append("addaddress.jsp?schema="); - url.append(sanitizeURL(a.schema)).append("&location="); - url.append(sanitizeURL(a.location)).append("&name="); - url.append(sanitizeURL(a.name)).append("&protocol="); - url.append(sanitizeURL(a.protocol)); + url.append("addresses.jsp?network="); + url.append(sanitizeTagParam(a.schema)).append("&location="); + url.append(sanitizeTagParam(a.location)).append("&name="); + url.append(sanitizeTagParam(a.name)).append("&protocol="); + url.append(sanitizeTagParam(a.protocol)); out.write(" <enclosure url=\"" + urlPrefix + sanitizeXML(url) + "\" length=\"1\" type=\"text/html\" syndietype=\"address\" />\n"); } } diff --git a/apps/syndie/java/src/net/i2p/syndie/web/PostBean.java b/apps/syndie/java/src/net/i2p/syndie/web/PostBean.java index 59e257d0b76d39b6ac43fc7e06bf97ab3161218c..4bfaa70ee64f6f03d5c87c0467cec41e5d1a85ef 100644 --- a/apps/syndie/java/src/net/i2p/syndie/web/PostBean.java +++ b/apps/syndie/java/src/net/i2p/syndie/web/PostBean.java @@ -15,6 +15,7 @@ public class PostBean { private String _tags; private String _headers; private String _text; + private String _archive; private List _filenames; private List _fileStreams; private List _localFiles; @@ -30,6 +31,7 @@ public class PostBean { _tags = null; _text = null; _headers = null; + _archive = null; _filenames = new ArrayList(); _fileStreams = new ArrayList(); _fileTypes = new ArrayList(); @@ -51,6 +53,7 @@ public class PostBean { public void setTags(String tags) { _tags = tags; } public void setText(String text) { _text = text; } public void setHeaders(String headers) { _headers = headers; } + public void setArchive(String archive) { _archive = archive; } public String getContentType(int id) { if ( (id >= 0) && (id < _fileTypes.size()) ) @@ -81,8 +84,26 @@ public class PostBean { File f = (File)_localFiles.get(i); localStreams.add(new FileInputStream(f)); } - return BlogManager.instance().createBlogEntry(_user, _subject, _tags, _headers, _text, - _filenames, localStreams, _fileTypes); + BlogURI uri = BlogManager.instance().createBlogEntry(_user, _subject, _tags, _headers, _text, + _filenames, localStreams, _fileTypes); + System.err.println("Posted the entry " + uri.toString() + " (archive = " + _archive + ")"); + if ( (uri != null) && (_user.getAllowAccessRemote()) ) { + PetName pn = _user.getPetNameDB().get(_archive); + System.err.println("Archive to petname? " + pn + " (protocol: " + (pn != null ? pn.getProtocol() : "") + ")"); + if ( (pn != null) && ("syndiearchive".equals(pn.getProtocol())) ) { + RemoteArchiveBean r = new RemoteArchiveBean(); + Map params = new HashMap(); + params.put("localentry", new String[] { uri.toString() }); + String proxyHost = BlogManager.instance().getDefaultProxyHost(); + String port = BlogManager.instance().getDefaultProxyPort(); + int proxyPort = 4444; + try { proxyPort = Integer.parseInt(port); } catch (NumberFormatException nfe) {} + System.err.println("Posting the entry " + uri.toString() + " to " + pn.getLocation()); + r.postSelectedEntries(_user, params, proxyHost, proxyPort, pn.getLocation()); + System.err.println("Post status: " + r.getStatus()); + } + } + return uri; } public void renderPreview(Writer out) throws IOException { diff --git a/apps/syndie/java/src/net/i2p/syndie/web/RemoteArchiveBean.java b/apps/syndie/java/src/net/i2p/syndie/web/RemoteArchiveBean.java index b35d098a99fda896568ae1036fb27eed0f76a65f..81c97ce66184ac1c2ab3a4b44af3c21d5c93cfd2 100644 --- a/apps/syndie/java/src/net/i2p/syndie/web/RemoteArchiveBean.java +++ b/apps/syndie/java/src/net/i2p/syndie/web/RemoteArchiveBean.java @@ -264,7 +264,7 @@ public class RemoteArchiveBean { _exportCapable = false; if ( (schema == null) || (schema.trim().length() <= 0) || - (location == null) || (location.trim().length() <= 0) ) { + (location == null) || (location.trim().length() <= 0) ) { _statusMessages.add("Location must be specified"); _fetchIndexInProgress = false; return; @@ -289,11 +289,11 @@ public class RemoteArchiveBean { } _statusMessages.add("Fetching index from " + HTMLRenderer.sanitizeString(_remoteLocation) + - (_proxyHost != null ? " via " + HTMLRenderer.sanitizeString(_proxyHost) + ":" + _proxyPort : "")); + (_proxyHost != null ? " via " + HTMLRenderer.sanitizeString(_proxyHost) + ":" + _proxyPort : "")); File archiveFile = new File(BlogManager.instance().getTempDir(), user.getBlog().toBase64() + "_remoteArchive.txt"); archiveFile.delete(); EepGet eep = new EepGet(I2PAppContext.getGlobalContext(), ((_proxyHost != null) && (_proxyPort > 0)), - _proxyHost, _proxyPort, 0, archiveFile.getAbsolutePath(), location); + _proxyHost, _proxyPort, 0, archiveFile.getAbsolutePath(), location); eep.addStatusListener(new IndexFetcherStatusListener(archiveFile)); eep.fetch(); } @@ -506,12 +506,22 @@ public class RemoteArchiveBean { } public void postSelectedEntries(User user, Map parameters) { + postSelectedEntries(user, parameters, _proxyHost, _proxyPort, _remoteLocation); + } + public void postSelectedEntries(User user, Map parameters, String proxyHost, int proxyPort, String location) { String entries[] = ArchiveViewerBean.getStrings(parameters, "localentry"); if ( (entries == null) || (entries.length <= 0) ) return; List uris = new ArrayList(entries.length); for (int i = 0; i < entries.length; i++) uris.add(new BlogURI(entries[i])); - + if ( (proxyPort > 0) && (proxyHost != null) && (proxyHost.trim().length() > 0) ) { + _proxyPort = proxyPort; + _proxyHost = proxyHost; + } else { + _proxyPort = -1; + _proxyHost = null; + } + _remoteLocation = location; post(uris, user); } diff --git a/apps/syndie/jsp/addaddress.jsp b/apps/syndie/jsp/addaddress.jsp deleted file mode 100644 index 9a63e9774d9664b51ad0346ea9f80c461b5d199f..0000000000000000000000000000000000000000 --- a/apps/syndie/jsp/addaddress.jsp +++ /dev/null @@ -1,51 +0,0 @@ -<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="net.i2p.data.*, net.i2p.syndie.web.*, net.i2p.syndie.sml.*, net.i2p.syndie.*" %> -<% request.setCharacterEncoding("UTF-8"); %> -<jsp:useBean scope="session" class="net.i2p.syndie.User" id="user" /> -<html> -<head> -<title>SyndieMedia</title> -<link href="style.jsp" rel="stylesheet" type="text/css" /> -</head> -<body> -<table border="1" cellpadding="0" cellspacing="0" width="100%"> -<tr><td colspan="5" valign="top" align="left"><jsp:include page="_toplogo.jsp" /></td></tr> -<tr><td valign="top" align="left" rowspan="2"><jsp:include page="_leftnav.jsp" /></td> - <jsp:include page="_topnav.jsp" /> - <td valign="top" align="left" rowspan="2"><jsp:include page="_rightnav.jsp" /></td></tr> -<tr><td valign="top" align="left" colspan="3"><% -String nameStr = request.getParameter("name"); -String protoStr = request.getParameter("proto"); -String locStr = request.getParameter("location"); -String schemaStr = request.getParameter("schema"); -String name = null; -String proto = null; -String location = null; -String schema = null; -try { - name = DataHelper.getUTF8(Base64.decode(nameStr)); - if ( (protoStr != null) && (protoStr.trim().length() > 0) ) - proto = DataHelper.getUTF8(Base64.decode(protoStr)); - location = DataHelper.getUTF8(Base64.decode(locStr)); - schema = DataHelper.getUTF8(Base64.decode(schemaStr)); -} catch (NullPointerException npe) { - // ignore -} - -if ( (name == null) || (location == null) || (schema == null) ) { - out.write("<b>No location specified</b>"); -} else if (user.getAuthenticated() && ("Add".equals(request.getParameter("action"))) ) { - out.write("<b>" + BlogManager.instance().addAddress(user, name, proto, location, schema) + "</b>"); -} else { %>Are you sure you really want to add the -addressbook mapping of <%=HTMLRenderer.sanitizeString(name)%> to -<input type="text" size="20" value="<%=HTMLRenderer.sanitizeString(location)%>" />, applicable within the -schema <%=HTMLRenderer.sanitizeString(schema)%>? -<% if (!user.getAuthenticated()) { %> -<p />If so, add the line -<input type="text" size="20" value="<%=HTMLRenderer.sanitizeString(name)%>=<%=HTMLRenderer.sanitizeString(location)%>" /> -to your <code>userhosts.txt</code>. -<% } else { %><br /> -<a href="addaddress.jsp?name=<%=HTMLRenderer.sanitizeURL(name)%>&location=<%=HTMLRenderer.sanitizeURL(location)%>&schema=<%=HTMLRenderer.sanitizeURL(schema)%>&action=Add">Yes, add it</a>. -<% } -} %></td></tr> -</table> -</body> \ No newline at end of file diff --git a/apps/syndie/jsp/addresses.jsp b/apps/syndie/jsp/addresses.jsp index 08d1d918df18e00ca1ef7574d3f869f17137d9c5..d5e067ddf510d4254c5511fe80961a366f23c30a 100644 --- a/apps/syndie/jsp/addresses.jsp +++ b/apps/syndie/jsp/addresses.jsp @@ -158,17 +158,17 @@ if (!user.getAuthenticated()) { %> <tr><form action="addresses.jsp" method="POST"><td><input type="text" name="name" size="20" value="<%=name%>" /></td> <td><select name="network"> - <option value="i2p" <%="i2p".equals(net) ? " selected=\"true\" " : ""%>>I2P</option> - <option value="syndie" <%="syndie".equals(net) ? " selected=\"true\" " : ""%>>Syndie</option> - <option value="tor" <%="tor".equals(net) ? " selected=\"true\" " : ""%>>Tor</option> - <option value="freenet" <%="freenet".equals(net) ? " selected=\"true\" " : ""%>>Freenet</option> - <option value="internet" <%="internet".equals(net) ? " selected=\"true\" " : ""%>>Internet</option></select></td> + <option value="i2p" <%="i2p".equalsIgnoreCase(net) ? " selected=\"true\" " : ""%>>I2P</option> + <option value="syndie" <%="syndie".equalsIgnoreCase(net) ? " selected=\"true\" " : ""%>>Syndie</option> + <option value="tor" <%="tor".equalsIgnoreCase(net) ? " selected=\"true\" " : ""%>>Tor</option> + <option value="freenet" <%="freenet".equalsIgnoreCase(net) ? " selected=\"true\" " : ""%>>Freenet</option> + <option value="internet" <%="internet".equalsIgnoreCase(net) ? " selected=\"true\" " : ""%>>Internet</option></select></td> <td><select name="protocol"> - <option value="http" <%="http".equals(proto) ? " selected=\"true\" " : ""%>>HTTP</option> - <option value="irc" <%="irc".equals(proto) ? " selected=\"true\" " : ""%>>IRC</option> - <option value="i2phex" <%="i2phex".equals(proto) ? " selected=\"true\" " : ""%>>I2Phex</option> - <option value="syndiearchive" <%="syndiearchive".equals(proto) ? " selected=\"true\" " : ""%>>Syndie archive</option> - <option value="syndieblog" <%="syndieblog".equals(proto) ? " selected=\"true\" " : ""%>>Syndie blog</option></select></td> + <option value="http" <%="http".equalsIgnoreCase(proto) ? " selected=\"true\" " : ""%>>HTTP</option> + <option value="irc" <%="irc".equalsIgnoreCase(proto) ? " selected=\"true\" " : ""%>>IRC</option> + <option value="i2phex" <%="i2phex".equalsIgnoreCase(proto) ? " selected=\"true\" " : ""%>>I2Phex</option> + <option value="syndiearchive" <%="syndiearchive".equalsIgnoreCase(proto) ? " selected=\"true\" " : ""%>>Syndie archive</option> + <option value="syndieblog" <%="syndieblog".equalsIgnoreCase(proto) ? " selected=\"true\" " : ""%>>Syndie blog</option></select></td> <td><input type="text" size="50" name="location" value="<%=loc%>" /></td> <td><input type="checkbox" name="isPublic" /></td> <td><input type="text" name="groups" size="10" /></td> diff --git a/apps/syndie/jsp/admin.jsp b/apps/syndie/jsp/admin.jsp new file mode 100644 index 0000000000000000000000000000000000000000..61b3d77163506143685a53beb4cc079f09063a76 --- /dev/null +++ b/apps/syndie/jsp/admin.jsp @@ -0,0 +1,81 @@ +<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="net.i2p.data.Base64, net.i2p.syndie.web.*, net.i2p.syndie.sml.*, net.i2p.syndie.data.*, net.i2p.syndie.*, org.mortbay.servlet.MultiPartRequest, java.util.*, java.io.*" %> +<% request.setCharacterEncoding("UTF-8"); %> +<jsp:useBean scope="session" class="net.i2p.syndie.User" id="user" /> +<html> +<head> +<title>SyndieMedia admin</title> +<link href="style.jsp" rel="stylesheet" type="text/css" /> +</head> +<body> +<table border="1" cellpadding="0" cellspacing="0" width="100%"> +<tr><td colspan="5" valign="top" align="left"><jsp:include page="_toplogo.jsp" /></td></tr> +<tr><td valign="top" align="left" rowspan="2"><jsp:include page="_leftnav.jsp" /></td> + <jsp:include page="_topnav.jsp" /> + <td valign="top" align="left" rowspan="2"><jsp:include page="_rightnav.jsp" /></td></tr> +<tr><td valign="top" align="left" colspan="3"><% +if (!user.getAuthenticated()) { + %>You must be logged in to configure your Syndie instance!<% +} else { + String action = request.getParameter("action"); + if ( (action != null) && ("Save".equals(action)) ) { + boolean configured = BlogManager.instance().isConfigured(); + String adminPass = request.getParameter("adminpass"); + String regPass = request.getParameter("regpass"); + String remotePass = request.getParameter("remotepass"); + String proxyHost = request.getParameter("proxyhost"); + String proxyPort = request.getParameter("proxyport"); + String selector = request.getParameter("selector"); + if (configured) { + if ( (adminPass != null) && (BlogManager.instance().authorizeAdmin(adminPass)) ) { + int port = -1; + try { port = Integer.parseInt(proxyPort); } catch (NumberFormatException nfe) { port = 4444; } + BlogManager.instance().configure(regPass, remotePass, adminPass, selector, proxyHost, port, null); + %>Configuration updated<% + } else { + %>Invalid admin password. If you lost it, please update your syndie.config.<% + } + } else { + int port = -1; + try { port = Integer.parseInt(proxyPort); } catch (NumberFormatException nfe) { port = 4444; } + BlogManager.instance().configure(regPass, remotePass, adminPass, selector, proxyHost, port, null); + %>Configuration saved<% + } + } else { +%><form action="admin.jsp" method="POST"> +<b>Registration password:</b> <input type="text" name="regpass" size="10" /><br /> +Users must specify this password on the registration form to proceed. If this is +blank, anyone can register.<br /> +<b>Remote password:</b> <input type="text" name="remotepass" size="10" /><br /> +To access remote archives, users must first provide this password on their +metadata page. Remote access is 'dangerous', as it allows the user to instruct +this Syndie instance to establish HTTP connections with arbitrary locations. If +this field is not specified, no one can use remote archives.<br /> +<b>Default remote proxy host:</b> <input type="text" name="proxyhost" size="20" value="localhost" /><br /> +<b>Default remote proxy port:</b> <input type="text" name="proxyport" size="5" value="4444" /><br /> +This is the default HTTP proxy shown on the remote archive page.<br /> +<b>Default blog selector:</b> <input type="text" name="selector" size="40" value="ALL" /><br /> +The selector lets you choose what blog (or blogs) are shown on the front page for +new, unregistered users. Valid values include:<ul> + <li><code>ALL<code>: all blogs</li> + <li><code>blog://$blogHash</code>: all posts in the blog identified by $blogHash</li> + <li><code>blogtag://$blogHash/$tagBase64</code>: all posts in the blog identified by $blogHash + tagged by the tag whose modified base64 encoding is $tagBase64</li> + <li><code>tag://$tagBase64</code>: all posts in any blog tagged by the tag whose + modified base64 encoding is $tagBase64</li> +</ul> +<hr /> +<% if (!BlogManager.instance().isConfigured()) { +long passNum = new Random().nextLong(); %> +<b>Administrative password:</b> <input type="password" name="adminpass" size="10" value="<%=passNum%>" /> <br /> +Since this Syndie instance is not already configured, you can specify a new +administrative password which must be presented whenever you update this configuration. +The default value filled in there is <code><%=passNum%></code><br /> +<% } else { %> +<b>Administrative password:</b> <input type="password" name="adminpass" size="10" value="" /> <br /> +<% } %> +<input type="submit" name="action" value="Save" /> +<% } +} %> +</td></tr> +</table> +</body> diff --git a/apps/syndie/jsp/post.jsp b/apps/syndie/jsp/post.jsp index 3db31c8d5336fa14a8f92812fdf478af1a3d4f19..08020b445f41801ae8ee509d5b332cae71bf08fe 100644 --- a/apps/syndie/jsp/post.jsp +++ b/apps/syndie/jsp/post.jsp @@ -18,8 +18,10 @@ if (!user.getAuthenticated()) { %>You must be logged in to post<% } else { - String confirm = request.getParameter("confirm"); - if ( (confirm != null) && (confirm.equalsIgnoreCase("true")) ) { + String confirm = request.getParameter("action"); + if ( (confirm != null) && (confirm.equalsIgnoreCase("confirm")) ) { + String archive = request.getParameter("archive"); + post.setArchive(archive); BlogURI uri = post.postEntry(); if (uri != null) { %>Blog entry <a href="<%=HTMLRenderer.getPageURL(user.getBlog(), null, uri.getEntryId(), -1, -1, @@ -43,17 +45,34 @@ if (!user.getAuthenticated()) { String entryTags = req.getString("entrytags"); String entryText = req.getString("entrytext"); String entryHeaders = req.getString("entryheaders"); + String style = req.getString("style"); + if ( (style != null) && (style.trim().length() > 0) ) { + if (entryHeaders == null) entryHeaders = HTMLRenderer.HEADER_STYLE + ": " + style; + else entryHeaders = entryHeaders + '\n' + HTMLRenderer.HEADER_STYLE + ": " + style; + } String replyTo = req.getString(ArchiveViewerBean.PARAM_IN_REPLY_TO); if ( (replyTo != null) && (replyTo.trim().length() > 0) ) { byte r[] = Base64.decode(replyTo); if (r != null) { - if (entryHeaders == null) entryHeaders = HTMLRenderer.HEADER_IN_REPLY_TO + ": " + new String(r); - else entryHeaders = entryHeaders + '\n' + HTMLRenderer.HEADER_IN_REPLY_TO + ": " + new String(r); + if (entryHeaders == null) entryHeaders = HTMLRenderer.HEADER_IN_REPLY_TO + ": " + new String(r, "UTF-8"); + else entryHeaders = entryHeaders + '\n' + HTMLRenderer.HEADER_IN_REPLY_TO + ": " + new String(r, "UTF-8"); } else { replyTo = null; } } - + String includeNames = req.getString("includenames"); + if ( (includeNames != null) && (includeNames.trim().length() > 0) ) { + PetNameDB db = user.getPetNameDB(); + if (entryHeaders == null) entryHeaders = ""; + for (Iterator iter = db.getNames().iterator(); iter.hasNext(); ) { + PetName pn = db.get((String)iter.next()); + if ( (pn != null) && (pn.getIsPublic()) ) { + entryHeaders = entryHeaders + '\n' + HTMLRenderer.HEADER_PETNAME + ": " + + pn.getName() + "\t" + pn.getNetwork() + "\t" + pn.getProtocol() + "\t" + pn.getLocation(); + } + } + } + post.setSubject(entrySubject); post.setTags(entryTags); post.setText(entryText); @@ -76,13 +95,39 @@ if (!user.getAuthenticated()) { } post.renderPreview(out); - %><hr />Please <a href="post.jsp?confirm=true">confirm</a> that this is ok. Otherwise, just go back and make changes.<% + %><hr /><form action="post.jsp" method="POST"> +Please confirm that the above is ok<% if (user.getAllowAccessRemote()) { %>, and select what additional archives you +want the post transmitted to. Otherwise, just hit your browser's back arrow and +make changes. +<select name="archive"> +<option name="">-None-</option> +<% +PetNameDB db = user.getPetNameDB(); +TreeSet names = new TreeSet(); +for (Iterator iter = db.getNames().iterator(); iter.hasNext(); ) { + String name = (String)iter.next(); + PetName pn = db.get(name); + if ("syndiearchive".equals(pn.getProtocol())) + names.add(pn.getName()); +} +for (Iterator iter = names.iterator(); iter.hasNext(); ) { + String name = (String)iter.next(); + out.write("<option value=\"" + HTMLRenderer.sanitizeTagParam(name) + "\">" + HTMLRenderer.sanitizeString(name) + "</option>\n"); +} +%> +</select><br /><% } %> +<input type="submit" name="action" value="Confirm" /><% } else { // logged in and not confirmed because they didn't send us anything! // give 'em a new form %><form action="post.jsp" method="POST" enctype="multipart/form-data"> Post subject: <input type="text" size="80" name="entrysubject" value="<%=post.getSubject()%>" /><br /> Post tags: <input type="text" size="20" name="entrytags" value="<%=post.getTags()%>" /><br /> +Post style: <select name="style"> + <option value="default" selected="true">Default</option> + <option value="meta">Meta (hide everything but the metadata)</option> +</select><br /> +Include public names? <input type="checkbox" name="includenames" value="true" /><br /> Post content (in raw SML, no headers):<br /> <textarea rows="6" cols="80" name="entrytext"><%=post.getText()%></textarea><br /> <b>SML cheatsheet:</b><br /><textarea rows="6" cols="80" readonly="true"> @@ -111,7 +156,6 @@ String s = request.getParameter(ArchiveViewerBean.PARAM_IN_REPLY_TO); if ( (s != null) && (s.trim().length() > 0) ) {%> <input type="hidden" name="<%=ArchiveViewerBean.PARAM_IN_REPLY_TO%>" value="<%=request.getParameter(ArchiveViewerBean.PARAM_IN_REPLY_TO)%>" /> <% } %> - Attachment 0: <input type="file" name="entryfile0" /><br /> Attachment 1: <input type="file" name="entryfile1" /><br /> Attachment 2: <input type="file" name="entryfile2" /><br />