Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

- fixed wrongly applied replacement of "<" and ">" in Blog and simplified the code a bit - added check, whether active blacklist engine is supported by blacklist cleaner

karlchenofhell92b6bc0ad2e8
diff --git a/htroot/BlacklistCleaner_p.html b/htroot/BlacklistCleaner_p.html
index 961693fac..1ee293003 100644
--- a/htroot/BlacklistCleaner_p.html
+++ b/htroot/BlacklistCleaner_p.html
@@ -20,7 +20,12 @@
#{/blacklists}#
</select>
<input type="submit" name="list" value="Check" />
- </div>::#(/disabled)#
+ </div>::
+ <p class="error">The blacklist-cleaner only works for the following blacklist-engines up to now:</p>
+ <ul>#{engines}#
+ <li class="tt" title="#[fullname]#">#[name]#</li>#{/engines}#
+ </ul>::
+ #(/disabled)#
</fieldset>
#(results)#
diff --git a/htroot/BlacklistCleaner_p.java b/htroot/BlacklistCleaner_p.java
index b10917695..276803647 100644
--- a/htroot/BlacklistCleaner_p.java
+++ b/htroot/BlacklistCleaner_p.java
@@ -83,6 +83,8 @@ public class BlacklistCleaner_p {
private static final int ERR_HOST_WRONG_CHARS = 4;
private static final int ERR_DOUBLE_OCCURANCE = 5;
+ public static final Class[] supportedBLEngines = { plasmaSwitchboard.class };
+
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
serverObjects prop = new serverObjects();
@@ -143,15 +145,28 @@ public class BlacklistCleaner_p {
}
private static void putBlacklists(serverObjects prop, String[] lists, String selected) {
- if (lists.length > 0) {
- prop.put("disabled", 0);
- prop.put(DISABLED + "blacklists", lists.length);
- for (int i=0; i<lists.length; i++) {
- prop.put(DISABLED + BLACKLISTS + i + "_name", lists[i]);
- prop.put(DISABLED + BLACKLISTS + i + "_selected", (lists[i].equals(selected)) ? 1 : 0);
+ boolean supported = false;
+ for (int i=0; i<supportedBLEngines.length && !supported; i++)
+ supported |= (plasmaSwitchboard.urlBlacklist.getClass() == supportedBLEngines[i]);
+
+ if (supported) {
+ if (lists.length > 0) {
+ prop.put("disabled", 0);
+ prop.put(DISABLED + "blacklists", lists.length);
+ for (int i=0; i<lists.length; i++) {
+ prop.put(DISABLED + BLACKLISTS + i + "_name", lists[i]);
+ prop.put(DISABLED + BLACKLISTS + i + "_selected", (lists[i].equals(selected)) ? 1 : 0);
+ }
+ } else {
+ prop.put("disabled", 2);
}
} else {
prop.put("disabled", 1);
+ for (int i=0; i<supportedBLEngines.length; i++) {
+ prop.put(DISABLED + "engines_" + i + "_name", supportedBLEngines[i].getSimpleName());
+ prop.put(DISABLED + "engines_" + i + "_fullname", supportedBLEngines[i].getName());
+ }
+ prop.put(DISABLED + "engines", supportedBLEngines.length);
}
}
diff --git a/htroot/Blog.html b/htroot/Blog.html
index ef14602ab..e6dad42a1 100644
--- a/htroot/Blog.html
+++ b/htroot/Blog.html
@@ -55,7 +55,7 @@
<input type="hidden" name="page" value="#[pageid]#" />
<input type="submit" name="submit" value="Submit" />
<input type="submit" name="preview" value="Preview" />
- <input type="submit" name="view" value="Discard" />
+ <input type="submit" name="discard" value="Discard" />
</fieldset>
</form>
::
@@ -98,7 +98,7 @@
<input type="hidden" name="page" value="#[pageid]#" />
<input type="submit" name="submit" value="Submit" />
<input type="submit" name="preview" value="Preview" />
- <input type="submit" name="view" value="Discard" />
+ <input type="submit" name="discard" value="Discard" />
</fieldset>
</form>
::
@@ -108,20 +108,17 @@
::
<!-- 4: Delete Confirmation -->
<h3>Are you sure...</h3>
- <p>... that you want to delete <strong>#[subject]#</strong> by #[author]#?</p>
- <form action="Blog.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
- <fieldset>
+ <p>... that you want to delete <strong>#[subject]#</strong> by <span class="tt">#[author]#</span>?</p>
+ <fieldset><legend>Confirm deletion</legend>
+ <form action="Blog.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<input type="hidden" name="delete" value="sure" />
<input type="hidden" name="page" value="#[pageid]#" />
<input type="submit" value="Yes, delete it." />
- </fieldset>
- </form>
- <br />
- <form action="Blog.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
- <fieldset>
+ </form>
+ <form action="Blog.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<input type="submit" value="No, leave it." />
- </fieldset>
- </form>
+ </form>
+ </fieldset>
::
<!-- 5: XML-Import -->
<h3>XML-Import</h3>
diff --git a/htroot/Blog.java b/htroot/Blog.java
index 92d7cd90f..8f15dde3c 100644
--- a/htroot/Blog.java
+++ b/htroot/Blog.java
@@ -65,6 +65,8 @@ import de.anomic.yacy.yacyNewsRecord;
public class Blog {
+ private static final String DEFAULT_PAGE = "blog_default";
+
private static SimpleDateFormat SimpleFormatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
// TODO: make userdefined date/time-strings (localisation)
@@ -106,7 +108,7 @@ public class Blog {
}
}
- String pagename = post.get("page", "blog_default");
+ String pagename = post.get("page", DEFAULT_PAGE);
final String ip = post.get("CLIENTIP", "127.0.0.1");
String StrAuthor = post.get("author", "");
@@ -137,10 +139,13 @@ public class Blog {
switchboard.blogCommentDB.delete((String) i.next());
}
switchboard.blogDB.delete(pagename);
- pagename = "blog_default";
+ pagename = DEFAULT_PAGE;
}
-
- if (post.containsKey("submit") && (hasRights)) {
+
+ if (post.containsKey("discard"))
+ pagename = DEFAULT_PAGE;
+
+ if (post.containsKey("submit") && (hasRights)) {
// store a new/edited blog-entry
byte[] content;
try {
@@ -153,7 +158,7 @@ public class Blog {
ArrayList comments = null;
//set name for new entry or date for old entry
- if(pagename.equals("blog_default"))
+ if(pagename.equals(DEFAULT_PAGE))
pagename = String.valueOf(System.currentTimeMillis());
else {
page = switchboard.blogDB.read(pagename);
@@ -190,7 +195,7 @@ public class Blog {
prop.put("mode_author", new String(page.author(),"UTF-8"));
prop.put("mode_pageid", page.key());
prop.put("mode_subject", new String(page.subject(), "UTF-8"));
- prop.put("mode_page-code", new String(page.page(), "UTF-8").replaceAll("<","&lt;").replaceAll(">","&gt;"));
+ prop.put("mode_page-code", new String(page.page(), "UTF-8"));
} catch (UnsupportedEncodingException e) {}
}
else {
@@ -211,11 +216,11 @@ public class Blog {
prop.put("mode_subject", post.get("subject",""));
prop.put("mode_date", dateString(new Date()));
prop.putWiki("mode_page", post.get("content", ""));
- prop.put("mode_page-code", post.get("content", "").replaceAll("<","&lt;").replaceAll(">","&gt;"));
+ prop.put("mode_page-code", post.get("content", ""));
}
else prop.put("mode",3); //access denied (no rights)
}
- else if(post.containsKey("delete") && post.get("delete").equals("try")) {
+ else if(post.get("delete", "").equals("try")) {
if(hasRights) {
prop.put("mode",4);
prop.put("mode_pageid",pagename);
@@ -248,7 +253,9 @@ public class Blog {
else {
// show blog-entry/entries
prop.put("mode", 0); //viewing
- if(pagename.equals("blog_default")) {
+ if(pagename.equals(DEFAULT_PAGE)) {
+ // XXX: where are "peername" and "address" used in the template?
+ // XXX: "clientname" is already set to the peername, no need for a new setting
prop.put("peername", yacyCore.seedDB.mySeed.getName());
prop.put("address", address);
//index all entries
@@ -257,29 +264,7 @@ public class Blog {
else {
//only show 1 entry
prop.put("mode_entries",1);
- prop.put("mode_entries_0_pageid", page.key());
- try {
- prop.put("mode_entries_0_subject", new String(page.subject(),"UTF-8"));
- } catch (UnsupportedEncodingException e) {
- prop.put("mode_entries_0_subject", new String(page.subject()));
- }
- try {
- prop.put("mode_entries_0_author", new String(page.author(),"UTF-8"));
- } catch (UnsupportedEncodingException e) {
- prop.put("mode_entries_0_author", new String(page.author()));
- }
- try {
- prop.put("mode_entries_0_comments", new String(page.commentsSize(),"UTF-8"));
- } catch (UnsupportedEncodingException e) {
- prop.put("mode_entries_0_comments", new String(page.commentsSize()));
- }
-
- prop.put("mode_entries_0_date", dateString(page.date()));
- prop.putWiki("mode_entries_0_page", page.page());
- if(hasRights) {
- prop.put("mode_entries_0_admin", 1);
- prop.put("mode_entries_0_admin_pageid",page.key());
- }
+ putBlogEntry(prop, page, address, 0, xml, hasRights);
}
}
@@ -309,45 +294,76 @@ public class Blog {
if(0 < start--)
continue;
entry = switchboard.blogDB.read(pageid);
- prop.put("mode_entries_"+count+"_pageid",entry.key());
- prop.put("mode_entries_"+count+"_address", address);
- if(!xml) {
- prop.put("mode_entries_"+count+"_subject", new String(entry.subject(),"UTF-8"));
- prop.put("mode_entries_"+count+"_author", new String(entry.author(),"UTF-8"));
- prop.putWiki("mode_entries_"+count+"_page", entry.page());
- }
- else {
- prop.put("mode_entries_"+count+"_subject", new String(entry.subject(),"UTF-8"));
- prop.put("mode_entries_"+count+"_author", new String(entry.author(),"UTF-8"));
- prop.putASIS("mode_entries_"+count+"_page", entry.page());
- prop.put("mode_entries_"+count+"_timestamp", entry.timestamp());
- }
- prop.put("mode_entries_"+count+"_date", dateString(entry.date()));
- prop.put("mode_entries_"+count+"_ip", entry.ip());
- if(hasRights) {
- prop.put("mode_entries_"+count+"_admin", 1);
- prop.put("mode_entries_"+count+"_admin_pageid",entry.key());
- }
- else prop.put("mode_entries_"+count+"_admin", 0);
- if(entry.getCommentMode() != 0) {
- prop.put("mode_entries_"+count+"_commentsactive", 1);
- prop.put("mode_entries_"+count+"_commentsactive_pageid",entry.key());
- prop.put("mode_entries_"+count+"_commentsactive_comments", new String(entry.commentsSize(),"UTF-8"));
- prop.put("mode_entries_"+count+"_commentsactive_address", address);
-
- }
- else prop.put("mode_entries_"+count+"_commentsactive", 0);
-
- ++count;
+ putBlogEntry(prop, entry, address, count++, xml, hasRights);
}
prop.put("mode_entries",count);
+
if(i.hasNext()) {
prop.put("mode_moreentries",1); //more entries are availible
prop.put("mode_moreentries_start",nextstart);
prop.put("mode_moreentries_num",num);
+ } else {
+ prop.put("moreentries",0);
}
- else prop.put("moreentries",0);
} catch (IOException e) { }
return prop;
}
+
+ private static serverObjects putBlogEntry(
+ final serverObjects prop,
+ final blogBoard.entry entry,
+ final String address,
+ final int number,
+ final boolean xml,
+ final boolean hasRights) {
+
+ // subject
+ try {
+ prop.put("mode_entries_" + number + "_subject", new String(entry.subject(),"UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ prop.put("mode_entries_" + number + "_subject", new String(entry.subject()));
+ }
+
+ // author
+ try {
+ prop.put("mode_entries_" + number + "_author", new String(entry.author(),"UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ prop.put("mode_entries_" + number + "_author", new String(entry.author()));
+ }
+
+ // comments
+ if(entry.getCommentMode() != 0) {
+ prop.put("mode_entries_" + number + "_commentsactive", 1);
+ prop.put("mode_entries_" + number + "_commentsactive_pageid", entry.key());
+ prop.put("mode_entries_" + number + "_commentsactive_address", address);
+ try {
+ prop.put("mode_entries_" + number + "_commentsactive_comments", new String(entry.commentsSize(),"UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ prop.put("mode_entries_" + number + "_commentsactive_comments", new String(entry.commentsSize()));
+ }
+ } else {
+ prop.put("mode_entries_" + number + "_commentsactive", 0);
+ }
+
+ prop.put("mode_entries_" + number + "_date", dateString(entry.date()));
+ prop.put("mode_entries_" + number + "_pageid", entry.key());
+ prop.put("mode_entries_" + number + "_address", address);
+ prop.put("mode_entries_" + number +" _ip", entry.ip());
+
+ if(xml) {
+ prop.putASIS("mode_entries_" + number + "_page", entry.page());
+ prop.put("mode_entries_" + number + "_timestamp", entry.timestamp());
+ } else {
+ prop.putWiki("mode_entries_" + number + "_page", entry.page());
+ }
+
+ if(hasRights) {
+ prop.put("mode_entries_" + number + "_admin", 1);
+ prop.put("mode_entries_" + number + "_admin_pageid",entry.key());
+ } else {
+ prop.put("mode_entries_" + number + "_admin", 0);
+ }
+
+ return prop;
+ }
}