diff --git a/htroot/env/base.css b/htroot/env/base.css index 72de37701..0a99d779d 100644 --- a/htroot/env/base.css +++ b/htroot/env/base.css @@ -594,6 +594,10 @@ a.deletelink:hover, a.deletelink:focus, div.searchresults:hover a.deletelink, di background:url(grafics/minus.gif) center center no-repeat; } +a.blacklistlink:hover, a.blacklistlink:focus, div.searchresults:hover a.blacklistlink, div.searchresults.hover a.blacklistlink { + background:url(grafics/blkl.gif) center center no-repeat; +} + ul.SubMenu a.MenuItemLink { margin-top:0; } diff --git a/htroot/env/grafics/blkl.gif b/htroot/env/grafics/blkl.gif new file mode 100644 index 000000000..d39a949d4 Binary files /dev/null and b/htroot/env/grafics/blkl.gif differ diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java index e252a61bb..a5a6df4ea 100644 --- a/htroot/yacysearch.java +++ b/htroot/yacysearch.java @@ -30,6 +30,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.IDN; +import java.net.MalformedURLException; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -77,6 +78,8 @@ import net.yacy.kelondro.util.SetTools; import net.yacy.peers.EventChannel; import net.yacy.peers.NewsPool; import net.yacy.peers.graphics.ProfilingGraph; +import net.yacy.repository.Blacklist; +import static net.yacy.repository.BlacklistHelper.addBlacklistEntry; import net.yacy.search.EventTracker; import net.yacy.search.SearchAccessRateConstants; import net.yacy.search.Switchboard; @@ -93,6 +96,7 @@ import net.yacy.search.ranking.RankingProfile; import net.yacy.server.serverObjects; import net.yacy.server.serverSwitch; import net.yacy.server.servletProperties; +import net.yacy.utils.crypt; public class yacysearch { @@ -697,6 +701,24 @@ public class yacysearch { } } + // if a blacklist-button was hit, add host to default blacklist + if (post != null && post.containsKey("blacklisturl")) { + + if (!sb.verifyAuthentication(header)) { + prop.authenticationRequired(); + return prop; + } + + String blacklisturl = crypt.simpleDecode(post.get("blacklisturl", "")); // url + try { + MultiProtocolURL mpurl = new MultiProtocolURL(blacklisturl); + addBlacklistEntry( + Blacklist.defaultBlacklist(sb.listsPath), + mpurl.getHost() + "/.*"); + } catch (MalformedURLException e) { + } + } + // check filters try { Pattern.compile(urlmask); diff --git a/htroot/yacysearchitem.html b/htroot/yacysearchitem.html index 1df8dd953..4b76ae33c 100644 --- a/htroot/yacysearchitem.html +++ b/htroot/yacysearchitem.html @@ -21,6 +21,9 @@ #(/recommend)# + #(blacklist)#:: + + #(/blacklist)# #(/authorized)#
diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java index 18bd88353..812104d46 100644 --- a/htroot/yacysearchitem.java +++ b/htroot/yacysearchitem.java @@ -105,8 +105,8 @@ public class yacysearchitem { final String eventID = post.get("eventID", ""); final boolean adminAuthenticated = sb.verifyAuthentication(header); - final UserDB.Entry user = sb.userDB != null ? sb.userDB.getUser(header) : null; - final boolean authenticated = adminAuthenticated || user != null; + final UserDB.Entry user = sb.userDB != null ? sb.userDB.getUser(header) : null; + final boolean authenticated = adminAuthenticated || user != null; final boolean extendedSearchRights = adminAuthenticated || (user != null && user.hasRight(UserDB.AccessRight.EXTENDED_SEARCH_RIGHT)); @@ -668,7 +668,9 @@ public class yacysearchitem { } /** - * Add action links reserved to authorized users. All parameters must be non null. + * Add action links reserved to authorized users (adminRights). All + * parameters must be non null. + * * @param sb the main Switchboard instance * @param prop properties map to feed * @param theSearch search event @@ -677,41 +679,44 @@ public class yacysearchitem { * @param origQ origin query terms * @param urlhash URL hash of the result item */ - private static void addAuthorizedActions(final Switchboard sb, final serverObjects prop, - final SearchEvent theSearch, final String resultUrlstring, final String resource, final String origQ, - final String urlhash) { - // check if url exists in bookmarks - boolean bookmarkexists = sb.bookmarksDB.getBookmark(urlhash) != null; - prop.put("content_authorized_bookmark", !bookmarkexists); - - final StringBuilder linkBuilder = QueryParams.navurl(RequestHeader.FileType.HTML, theSearch.query.offset / theSearch.query.itemsPerPage(), - theSearch.query, null, false, true); - final int baseUrlLength = linkBuilder.length(); - - String encodedURLString; - try { - encodedURLString = URLEncoder.encode(crypt.simpleEncode(resultUrlstring), StandardCharsets.UTF_8.name()); - } catch (UnsupportedEncodingException e1) { - ConcurrentLog.warn("YACY_SEARCH_ITEM", "UTF-8 encoding is not supported!"); - encodedURLString = crypt.simpleEncode(resultUrlstring); - } - final String bookmarkLink = linkBuilder.append("&bookmarkurl=").append(encodedURLString).toString(); - linkBuilder.setLength(baseUrlLength); + private static void addAuthorizedActions(final Switchboard sb, final serverObjects prop, + final SearchEvent theSearch, final String resultUrlstring, final String resource, final String origQ, + final String urlhash) { + // check if url exists in bookmarks + boolean bookmarkexists = sb.bookmarksDB.getBookmark(urlhash) != null; + prop.put("content_authorized_bookmark", !bookmarkexists); + + final StringBuilder linkBuilder = QueryParams.navurl(RequestHeader.FileType.HTML, theSearch.query.offset / theSearch.query.itemsPerPage(), + theSearch.query, null, false, true); + final int baseUrlLength = linkBuilder.length(); + + String encodedURLString; + try { + encodedURLString = URLEncoder.encode(crypt.simpleEncode(resultUrlstring), StandardCharsets.UTF_8.name()); + } catch (UnsupportedEncodingException e1) { + ConcurrentLog.warn("YACY_SEARCH_ITEM", "UTF-8 encoding is not supported!"); + encodedURLString = crypt.simpleEncode(resultUrlstring); + } + final String bookmarkLink = linkBuilder.append("&bookmarkurl=").append(encodedURLString).toString(); + linkBuilder.setLength(baseUrlLength); - String deleteLink = linkBuilder.append("&deleteref=").append(urlhash).toString(); - linkBuilder.setLength(baseUrlLength); + String deleteLink = linkBuilder.append("&deleteref=").append(urlhash).toString(); + linkBuilder.setLength(baseUrlLength); - String recommendLink = linkBuilder.append("&recommendref=").append(urlhash).toString(); - linkBuilder.setLength(baseUrlLength); + String recommendLink = linkBuilder.append("&recommendref=").append(urlhash).toString(); + linkBuilder.setLength(baseUrlLength); - prop.put("content_authorized_bookmark_bookmarklink", bookmarkLink); - prop.put("content_authorized_recommend_deletelink", deleteLink); - prop.put("content_authorized_recommend_recommendlink", recommendLink); + final String blacklistLink = linkBuilder.append("&blacklisturl=").append(encodedURLString).toString(); + linkBuilder.setLength(baseUrlLength); // cut off - for next new append - prop.put("content_authorized_recommend", (sb.peers.newsPool.getSpecific(NewsPool.OUTGOING_DB, NewsPool.CATEGORY_SURFTIPP_ADD, "url", resultUrlstring) == null) ? "1" : "0"); - prop.put("content_authorized_urlhash", urlhash); - } + prop.put("content_authorized_blacklist_blacklistlink", blacklistLink); + prop.put("content_authorized_bookmark_bookmarklink", bookmarkLink); + prop.put("content_authorized_recommend_deletelink", deleteLink); + prop.put("content_authorized_recommend_recommendlink", recommendLink); + prop.put("content_authorized_recommend", (sb.peers.newsPool.getSpecific(NewsPool.OUTGOING_DB, NewsPool.CATEGORY_SURFTIPP_ADD, "url", resultUrlstring) == null) ? "1" : "0"); + prop.put("content_authorized_blacklist", "1"); + } /** * Process search of image type and feed prop object. All parameters must not be null. diff --git a/source/net/yacy/repository/Blacklist.java b/source/net/yacy/repository/Blacklist.java index a6ad4e039..eda55a691 100644 --- a/source/net/yacy/repository/Blacklist.java +++ b/source/net/yacy/repository/Blacklist.java @@ -451,7 +451,7 @@ public class Blacklist { } /** - * appends aN entry to the backlist source file and updates internal blacklist maps. + * appends an entry to the backlist source file and updates internal blacklist maps. * * @param blacklistSourcefile name of the blacklist file (LISTS/*.black) * @param host host or host pattern