diff --git a/htroot/Surftips.java b/htroot/Surftips.java index 8479051aa..2f06ec89e 100644 --- a/htroot/Surftips.java +++ b/htroot/Surftips.java @@ -57,6 +57,7 @@ public class Surftips { boolean showScore = ((post != null) && (post.containsKey("score"))); + // access control boolean publicPage = sb.getConfigBool("publicSurftips", true); boolean authorizedAccess = sb.verifyAuthentication(header, false); if ((post != null) && (post.containsKey("publicPage"))) { diff --git a/htroot/index.html b/htroot/index.html index 46006cd36..e1bf157fa 100644 --- a/htroot/index.html +++ b/htroot/index.html @@ -111,7 +111,20 @@ #(/searchoptions)#

This peer holds #[links]# URLs of #[total-links]# in the known network.

- + #(searchoptions)#:: +

+

+

+ #(/searchoptions)# #(display)# #%env/templates/simplefooter.template%# :: diff --git a/htroot/index.java b/htroot/index.java index 887dd605f..a4d5ea884 100644 --- a/htroot/index.java +++ b/htroot/index.java @@ -49,6 +49,18 @@ public class index { final plasmaSwitchboard sb = (plasmaSwitchboard) env; final serverObjects prop = new serverObjects(); + // access control + boolean publicPage = sb.getConfigBool("publicSearchpage", true); + boolean authorizedAccess = sb.verifyAuthentication(header, false); + if ((post != null) && (post.containsKey("publicPage"))) { + if (!authorizedAccess) { + prop.put("AUTHENTICATE", "admin log-in"); // force log-in + return prop; + } + publicPage = post.get("publicPage", "0").equals("1"); + sb.setConfig("publicSearchpage", publicPage); + } + boolean global = (post == null) ? true : post.get("resource", "global").equals("global"); final boolean authenticated = sb.adminAuthenticated(header) >= 2; final int display = ((post == null) || (!authenticated)) ? 0 : post.getInt("display", 0); diff --git a/htroot/yacysearch.html b/htroot/yacysearch.html index bc1c259b4..6b07cc723 100644 --- a/htroot/yacysearch.html +++ b/htroot/yacysearch.html @@ -117,6 +117,8 @@ document.getElementById("Enter").value = "search again - catch up more links";

No Results. "#[wrong_regex]#" is no valid regular expression. Please go back to the previous page and make sure to enter a valid regular expressions for URL mask and Prefer mask.

::

#[linkcount]# results from #[orderedcount]# ordered links from #[filteredcount]# filtered links of a total number of #[totalcount]# known.

+ :: +

Searching the web with this peer is disabled for unauthorized users. Please log in as administrator to use the search function

#(/num-results)# diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java index 943dea596..fdd747edd 100644 --- a/htroot/yacysearch.java +++ b/htroot/yacysearch.java @@ -90,6 +90,8 @@ public class yacysearch { public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) { final plasmaSwitchboard sb = (plasmaSwitchboard) env; + boolean searchAllowed = sb.getConfigBool("publicSearchpage", true) || sb.verifyAuthentication(header, false); + boolean authenticated = sb.adminAuthenticated(header) >= 2; int display = (post == null) ? 0 : post.getInt("display", 0); if ((display == 1) && (!authenticated)) display = 0; @@ -101,7 +103,7 @@ public class yacysearch { final String referer = (String) header.get("Referer"); String querystring = (post == null) ? "" : post.get("search", "").trim(); - if ((post == null) || (env == null) || (querystring.length() == 0)) { + if ((post == null) || (env == null) || (querystring.length() == 0) || (!searchAllowed)) { // save referrer // System.out.println("HEADER=" + header.toString()); @@ -145,10 +147,11 @@ public class yacysearch { prop.put("input_contentdomCheckApp", 0); prop.put("type", 0); prop.put("type_excluded", 0); - prop.put("type_num-results", 0); prop.put("type_combine", 0); prop.put("type_resultbottomline", 0); prop.put("type_results", ""); + prop.put("num-results", (searchAllowed) ? 0 : 6); + return prop; } diff --git a/yacy.init b/yacy.init index 3589eca36..f625ae232 100644 --- a/yacy.init +++ b/yacy.init @@ -852,8 +852,10 @@ currentSkin= # table-types: RAM = 0, TREE = 1, FLEX = 2; tableTypeForPreNURL=0 -# flag to show surftips on Surftips.html page for non-administrator users +# flag to show if pages shall be usable for non-admin users +# this can be applied to the Surftips.html and yacysearch.html page publicSurftips = true +publicSearchpage = true # a Java Properties file containig a list of SOAP services that should deployed # additionally to the default services. E.g.