From 92b6bc0ad2e879bf1362cff963e1bc05093a7339 Mon Sep 17 00:00:00 2001 From: karlchenofhell Date: Wed, 28 Feb 2007 00:04:32 +0000 Subject: [PATCH] - 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 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3417 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/BlacklistCleaner_p.html | 7 +- htroot/BlacklistCleaner_p.java | 27 +++++-- htroot/Blog.html | 21 +++-- htroot/Blog.java | 142 ++++++++++++++++++--------------- 4 files changed, 115 insertions(+), 82 deletions(-) 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}# - ::#(/disabled)# + :: +

The blacklist-cleaner only works for the following blacklist-engines up to now:

+ :: + #(/disabled)# #(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 0) { + prop.put("disabled", 0); + prop.put(DISABLED + "blacklists", lists.length); + for (int i=0; i - + :: @@ -98,7 +98,7 @@ - + :: @@ -108,20 +108,17 @@ ::

Are you sure...

-

... that you want to delete #[subject]# by #[author]#?

-
-
+

... that you want to delete #[subject]# by #[author]#?

+
Confirm deletion + -
- -
-
-
+ +
-
- + +
::

XML-Import

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("<","<").replaceAll(">",">")); + 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("<","<").replaceAll(">",">")); + 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; + } }