Skip to content

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

*) blacklists can be exported as XML or plain text now *) blacklist import via file upload works now

low012cf69557ea22d
diff --git a/htroot/BlacklistImpExp_p.html b/htroot/BlacklistImpExp_p.html
index 00c853d6c..2a9e1f74a 100644
--- a/htroot/BlacklistImpExp_p.html
+++ b/htroot/BlacklistImpExp_p.html
@@ -38,15 +38,52 @@
</form>
<!-- blacklist import from file -->
- <form action="sharedBlacklist_p.html" method="get">
+ <form action="sharedBlacklist_p.html" method="post" enctype="multipart/form-data">
<fieldset>
- <legend>file:</legend>
+ <legend>plain text file:</legend>
+ Upload a regular text file which contains one blacklist entry per line.<br /><br />
<input type="hidden" name="currentBlacklist" value="#[currentBlacklist]#" />
- <input type="text" name="file" />
+ <input type="file" name="file" />
<input type="submit" value="Load new blacklist items" />
</fieldset>
</form>
</fieldset>::#(/disabled)#
+
+ <fieldset class="exportListItems">
+ <legend>Export blacklist items to...</legend>
+
+ <form action="xml/blacklists_p.xml" method="get">
+ <fieldset>
+ <legend>XML file:</legend>
+ Here you can export a blacklist as an XML file. This file will contain additional
+ information about which cases a blacklist is activated for.<br /><br />
+ <select name="listname">
+ <option value="">all</option>
+ #{blackListNames}#
+ <option value="#[blackListName]#">#[blackListName]#</option>
+ #{/blackListNames}#
+ </select>
+ <input type="submit" value="Export list as XML" />
+ </fieldset>
+ </form>
+
+ <form action="yacy/list.html" method="get">
+ <fieldset>
+ <legend>plain text file:</legend>
+ Here you can export a blacklist as a regular text file with one blacklist entry per line.
+ This file will not contain any additional information.<br /><br />
+ <select name="listname">
+ <option value="">all</option>
+ #{blackListNames}#
+ <option value="#[blackListName]#">#[blackListName]#</option>
+ #{/blackListNames}#
+ </select>
+ <input type="hidden" name="col" value="black" />
+ <input type="submit" value="Export list as text" />
+ </fieldset>
+ </form>
+
+ </fieldset>
#%env/templates/footer.template%#
</body>
</html>
diff --git a/htroot/BlacklistImpExp_p.java b/htroot/BlacklistImpExp_p.java
index e51964444..d3a5f3133 100644
--- a/htroot/BlacklistImpExp_p.java
+++ b/htroot/BlacklistImpExp_p.java
@@ -42,7 +42,7 @@ import de.anomic.yacy.yacySeed;
import java.util.List;
public class BlacklistImpExp_p {
- private final static String DISABLED = "disabled_";
+ private final static String DISABLED = "disabled_";
public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
@@ -63,7 +63,6 @@ public class BlacklistImpExp_p {
blacklistToUse = dirlist.get(0);
}
-
// List known hosts for BlackList retrieval
if (sb.webIndex.seedDB != null && sb.webIndex.seedDB.sizeConnected() > 0) { // no nullpointer error
int peerCount = 0;
@@ -87,9 +86,18 @@ public class BlacklistImpExp_p {
prop.put(DISABLED + "otherHosts", peerCount);
}
-
prop.putXML(DISABLED + "currentBlacklist", (blacklistToUse==null) ? "" : blacklistToUse);
prop.put("disabled", (blacklistToUse == null) ? "1" : "0");
+
+ int count = 0;
+ for (String element : dirlist) {
+ if (element.endsWith(".black")) {
+ prop.putHTML("blackListNames_" + count + "_blackListName", element);
+ count++;
+ }
+ }
+ prop.put("blackListNames", count);
+
return prop;
}
}
diff --git a/htroot/sharedBlacklist_p.java b/htroot/sharedBlacklist_p.java
index 684a160fd..eaf3baf9b 100644
--- a/htroot/sharedBlacklist_p.java
+++ b/htroot/sharedBlacklist_p.java
@@ -31,6 +31,7 @@
import java.io.File;
import java.io.FileWriter;
+import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
@@ -47,6 +48,9 @@ import de.anomic.server.serverSwitch;
import de.anomic.tools.nxTools;
import de.anomic.yacy.yacySeed;
import de.anomic.yacy.yacyURL;
+import java.util.LinkedList;
+import java.util.logging.Level;
+import java.util.logging.Logger;
public class sharedBlacklist_p {
@@ -72,7 +76,7 @@ public class sharedBlacklist_p {
prop.putHTML("currentBlacklist", selectedBlacklistName);
prop.putHTML("page_target", selectedBlacklistName);
-
+
if (post != null) {
// initialize the list manager
@@ -167,12 +171,14 @@ public class sharedBlacklist_p {
final String sourceFileName = post.get("file");
prop.putHTML("page_source", sourceFileName);
- final File sourceFile = new File(listManager.listsPath, sourceFileName);
- if (!sourceFile.exists() || !sourceFile.canRead() || !sourceFile.isFile()) {
- prop.put("status", STATUS_FILE_ERROR);
- prop.put("page", "1");
- } else {
- otherBlacklist = listManager.getListArray(sourceFile);
+ final String fileString = post.get("file$file");
+
+ if (fileString != null) {
+ try {
+ otherBlacklist = nxTools.strings(fileString.getBytes("UTF-8"), "UTF-8");
+ } catch (IOException ex) {
+ Logger.getLogger(sharedBlacklist_p.class.getName()).log(Level.SEVERE, null, ex);
+ }
}
} else if (post.containsKey("add")) {
diff --git a/htroot/xml/blacklists.java b/htroot/xml/blacklists.java
index 34f26adc2..5ad1c9133 100644
--- a/htroot/xml/blacklists.java
+++ b/htroot/xml/blacklists.java
@@ -31,7 +31,7 @@ public class blacklists {
public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final serverObjects prop = new serverObjects();
-
+
listManager.listsPath = new File(listManager.switchboard.getRootPath(),listManager.switchboard.getConfig("listManager.listsPath", "DATA/LISTS"));
final List<String> dirlist = listManager.getDirListing(listManager.listsPath);
int blacklistCount=0;