Skip to content

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

added a search history to the new search page the history distinguishes between different users and identifies them by their ip a history is only shown to the user who submitted the search

orbiter3f321ece7deb
diff --git a/htroot/CrawlProfileEditor_p.html b/htroot/CrawlProfileEditor_p.html
index ba36674b8..226857b8d 100644
--- a/htroot/CrawlProfileEditor_p.html
+++ b/htroot/CrawlProfileEditor_p.html
@@ -108,8 +108,8 @@
type="text" value="#[value]#"#(/type)# />::
<strong>#(type)##(checked)#false::true#(/checked)#::#[value]#::#[value]##(/type)#</strong>#(/readonly)#
</dd>#{/entries}#
+ <dt>&nbsp;</dt><dd><input type="submit" name="submit" value="Submit changes" /></dd>
</dl>
- <input type="submit" name="submit" value="Submit changes" />
</fieldset>
</form>
#(/edit)#
diff --git a/htroot/yacy/user/ysearch.html b/htroot/yacy/user/ysearch.html
index 10fdad8f9..f9d5a8c3d 100755
--- a/htroot/yacy/user/ysearch.html
+++ b/htroot/yacy/user/ysearch.html
@@ -142,46 +142,6 @@ var progressbar = new Progressbar(#[results]#, document.getElementById("results"
<div id="sidebar">
<!-- attach the bottomline -->
<!--#include virtual="/yacy/user/ysearchitem.html?bottomline=true&eventID=#[eventID]#" -->
-
- <!--
- <div id="updates" class="boxed">
- <h2 class="title">News</h2>
- <div class="content">
- <ul>
- <li>
- <h3>March 5, 2007</h3>
- <p><a href="#">In posuere eleifend odio quisque semper augue mattis wisi maecenas&#8230;</a></p>
- </li>
- <li>
- <h3>March 3, 2007</h3>
- <p><a href="#">Quisque dictum integer nisl risus, sagittis convallis, rutrum id, congue, and nibh&#8230;</a></p>
- </li>
- <li>
- <h3>February 28, 2007</h3>
- <p><a href="#">Donec leo, vivamus fermentum nibh in augue praesent a lacus at urna congue rutrum&#8230;</a></p>
- </li>
- <li>
- <h3>February 25, 2007</h3>
- <p><a href="#">Nam pede erat, porta eu, lobortis eget, tempus et, tellus. Etiam nequea&#8230;</a></p>
- </li>
- </ul>
- </div>
- </div>
- -->
- <div id="partners" class="boxed">
- <h2 class="title">Recent Searches</h2>
- <div class="content">
- <ul>
- <li><a href="#">Donec Dictum Metus</a></li>
- <li><a href="#">Etiam Rhoncus Volutpat</a></li>
- <li><a href="#">Integer Gravida Nibh</a></li>
- <li><a href="#">Maecenas Luctus Lectus</a></li>
- <li><a href="#">Mauris Vulputate Dolor</a></li>
- <li><a href="#">Nulla Luctus Eleifend</a></li>
- <li><a href="#">Posuere Augue Sit Nisl</a></li>
- </ul>
- </div>
- </div>
</div>
</div>
diff --git a/htroot/yacy/user/ysearchitem.html b/htroot/yacy/user/ysearchitem.html
index e911c3f0d..29ad7765e 100644
--- a/htroot/yacy/user/ysearchitem.html
+++ b/htroot/yacy/user/ysearchitem.html
@@ -9,7 +9,7 @@
::
#{items}#
<div class="thumbcontainer">
- <a href="#[href]#" class="thumblink" onclick="return hs.expand(this)">
+ <a href="#[hrefCache]#" class="thumblink" onclick="return hs.expand(this)">
<img src="/ViewImage.png?maxwidth=96&maxheight=96&code=#[code]#" alt="#[name]#">
</a>
<div class="highslide-caption"><a href="#[href]#">#[name]#<br \><a href="#[source]#">#[sourcedom]#</a></a></div>
@@ -70,6 +70,18 @@ progressbar.step(1);
#(/topwords)#
</div>
</div>
-
#(/navigation)#
+#(history)#::
+ <div id="partners" class="boxed">
+ <h2 class="title">Recent Searches</h2>
+ <div class="content">
+ <ul>
+ #{list}#
+ <li><a href="/yacy/user/ysearch.html?search=#[querystring]#&amp;resource=#[searchdom]#&amp;contentdom=#[contentdom]#">#[querystring]#</a></li>
+ #{/list}#
+ </ul>
+ <p>The search history is only visible for users from host #[host]#</p>
+ </div>
+ </div>
+#(/history)#
diff --git a/htroot/yacy/user/ysearchitem.java b/htroot/yacy/user/ysearchitem.java
index 65202a012..b2fbc7706 100644
--- a/htroot/yacy/user/ysearchitem.java
+++ b/htroot/yacy/user/ysearchitem.java
@@ -28,6 +28,7 @@ import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URLEncoder;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
@@ -189,6 +190,29 @@ public class ysearchitem {
prop.put("navigation_resnav", resnav.toString());
prop.put("navigation", "1");
+ // list search history
+ Iterator<plasmaSearchQuery> i = sb.localSearches.iterator();
+ String client = (String) header.get(httpHeader.CONNECTION_PROP_CLIENTIP);
+ plasmaSearchQuery query;
+ int c = 0;
+ HashSet<String> visibleQueries = new HashSet<String>();
+ while (i.hasNext()) {
+ query = i.next();
+ if (query.resultcount == 0) continue;
+ if (query.offset != 0) continue;
+ if (!query.host.equals(client)) continue; // the search history should only be visible from the user who initiated the search
+ if (visibleQueries.contains(query.queryString)) continue; // avoid doubles
+ visibleQueries.add(query.queryString);
+ prop.put("history_list_" + c + "_querystring", query.queryString);
+ prop.put("history_list_" + c + "_searchdom", query.searchdom());
+ prop.put("history_list_" + c + "_contentdom", query.contentdom());
+ c++;
+ if (c >= 10) break;
+ }
+ prop.put("history_list", c);
+ prop.put("history_host", client);
+ if (c == 0) prop.put("history", 0); else prop.put("history", 1); // switch on if there is anything to see
+
return prop;
}
diff --git a/source/de/anomic/htmlFilter/htmlFilterContentScraper.java b/source/de/anomic/htmlFilter/htmlFilterContentScraper.java
index 18e5b2956..94d56e914 100644
--- a/source/de/anomic/htmlFilter/htmlFilterContentScraper.java
+++ b/source/de/anomic/htmlFilter/htmlFilterContentScraper.java
@@ -240,8 +240,8 @@ public class htmlFilterContentScraper extends htmlFilterAbstractScraper implemen
// System.out.println("ScrapeTag1: tagname=" + tagname + ", opts=" + tagopts.toString() + ", text=" + new String(text));
if ((tagname.equalsIgnoreCase("a")) && (text.length < 2048)) {
String href = tagopts.getProperty("href", "");
- if (href.length() > 0) {
- yacyURL url = absolutePath(href);
+ yacyURL url;
+ if ((href.length() > 0) && ((url = absolutePath(href)) != null)) {
String f = url.getFile();
int p = f.lastIndexOf('.');
String type = (p < 0) ? "" : f.substring(p + 1);
diff --git a/source/de/anomic/http/httpSSI.java b/source/de/anomic/http/httpSSI.java
index f2fa36bc5..4cae78c22 100644
--- a/source/de/anomic/http/httpSSI.java
+++ b/source/de/anomic/http/httpSSI.java
@@ -35,11 +35,11 @@ import de.anomic.server.serverByteBuffer;
public class httpSSI {
- public static void writeSSI(serverByteBuffer in, OutputStream out, String authorization) throws IOException {
- writeSSI(in, 0, out, authorization);
+ public static void writeSSI(serverByteBuffer in, OutputStream out, String authorization, String requesthost) throws IOException {
+ writeSSI(in, 0, out, authorization, requesthost);
}
- public static void writeSSI(serverByteBuffer in, int off, OutputStream out, String authorization) throws IOException {
+ public static void writeSSI(serverByteBuffer in, int off, OutputStream out, String authorization, String requesthost) throws IOException {
int p = in.indexOf("<!--#".getBytes(), off);
if (p >= 0) {
int q = in.indexOf("-->".getBytes(), p + 10);
@@ -48,8 +48,8 @@ public class httpSSI {
} else {
out.write(in.getBytes(off, p - off));
}
- parseSSI(in, p, q + 3 - p, out, authorization);
- writeSSI(in, q + 3, out, authorization);
+ parseSSI(in, p, q + 3 - p, out, authorization, requesthost);
+ writeSSI(in, q + 3, out, authorization, requesthost);
} else /* p < 0 */ {
if (out instanceof httpChunkedOutputStream) {
((httpChunkedOutputStream) out).write(in, off, in.length() - off);
@@ -59,17 +59,17 @@ public class httpSSI {
}
}
- private static void parseSSI(serverByteBuffer in, int off, int len, OutputStream out, String authorization) {
+ private static void parseSSI(serverByteBuffer in, int off, int len, OutputStream out, String authorization, String requesthost) {
if (in.startsWith("<!--#include virtual=\"".getBytes(), off)) {
int q = in.indexOf("\"".getBytes(), off + 22);
if (q > 0) {
String path = in.toString(off + 22, q);
- writeContent(path, out, authorization);
+ writeContent(path, out, authorization, requesthost);
}
}
}
- private static void writeContent(String path, OutputStream out, String authorization) {
+ private static void writeContent(String path, OutputStream out, String authorization, String requesthost) {
// check if there are arguments in path string
String args = "";
int argpos = path.indexOf('?');
@@ -85,7 +85,7 @@ public class httpSSI {
conProp.setProperty(httpHeader.CONNECTION_PROP_PATH, path);
conProp.setProperty(httpHeader.CONNECTION_PROP_ARGS, args);
conProp.setProperty(httpHeader.CONNECTION_PROP_HTTP_VER, httpHeader.HTTP_VERSION_0_9);
- conProp.setProperty(httpHeader.CONNECTION_PROP_CLIENTIP, "127.0.0.1");
+ conProp.setProperty(httpHeader.CONNECTION_PROP_CLIENTIP, requesthost);
header.put(httpHeader.AUTHORIZATION, authorization);
httpdFileHandler.doGet(conProp, header, out);
}
diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.java
index e06f1eed1..52fdd0041 100644
--- a/source/de/anomic/http/httpdFileHandler.java
+++ b/source/de/anomic/http/httpdFileHandler.java
@@ -280,6 +280,7 @@ public final class httpdFileHandler {
path = conProp.getProperty(httpHeader.CONNECTION_PROP_PATH);
String argsString = conProp.getProperty(httpHeader.CONNECTION_PROP_ARGS); // is null if no args were given
String httpVersion = conProp.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER);
+ String clientIP = conProp.getProperty(httpHeader.CONNECTION_PROP_CLIENTIP, "unknown-host");
// check hack attacks in path
if (path.indexOf("..") >= 0) {
@@ -324,7 +325,6 @@ public final class httpdFileHandler {
return;
} else {
// a wrong authentication was given or the userDB user does not have admin access. Ask again
- String clientIP = conProp.getProperty(httpHeader.CONNECTION_PROP_CLIENTIP, "unknown-host");
serverLog.logInfo("HTTPD", "Wrong log-in for account 'admin' in http file handler for path '" + path + "' from host '" + clientIP + "'");
Integer attempts = (Integer) serverCore.bfHost.get(clientIP);
if (attempts == null)
@@ -420,8 +420,7 @@ public final class httpdFileHandler {
// a different language can be desired (by i.e. ConfigBasic.html) than the one stored in the locale.language
String localeSelection = switchboard.getConfig("locale.language","default");
- if (args != null && (args.containsKey("language")))
- {
+ if (args != null && (args.containsKey("language"))) {
// TODO 9.11.06 Bost: a class with information about available languages is needed.
// the indexOf(".") is just a workaround because there from ConfigLanguage.html commes "de.lng" and
// from ConfigBasic.html comes just "de" in the "language" parameter
@@ -634,7 +633,6 @@ public final class httpdFileHandler {
if (tp.containsKey(servletProperties.ACTION_AUTHENTICATE)) {
// handle brute-force protection
if (authorization != null) {
- String clientIP = conProp.getProperty(httpHeader.CONNECTION_PROP_CLIENTIP, "unknown-host");
serverLog.logInfo("HTTPD", "dynamic log-in for account 'admin' in http file handler for path '" + path + "' from host '" + clientIP + "'");
Integer attempts = (Integer) serverCore.bfHost.get(clientIP);
if (attempts == null)
@@ -735,7 +733,7 @@ public final class httpdFileHandler {
httpd.sendRespondHeader(conProp, out, httpVersion, 200, null, mimeType, -1, targetDate, null, tp.getOutgoingHeader(), null, "chunked", nocache);
// send the content in chunked parts, see RFC 2616 section 3.6.1
httpChunkedOutputStream chos = new httpChunkedOutputStream(out);
- httpSSI.writeSSI(o, chos, authorization);
+ httpSSI.writeSSI(o, chos, authorization, clientIP);
//chos.write(result);
chos.finish();
} else {
@@ -749,14 +747,14 @@ public final class httpdFileHandler {
if (zipContent) {
GZIPOutputStream zippedOut = new GZIPOutputStream(o);
- httpSSI.writeSSI(o1, zippedOut, authorization);
+ httpSSI.writeSSI(o1, zippedOut, authorization, clientIP);
//httpTemplate.writeTemplate(fis, zippedOut, tp, "-UNRESOLVED_PATTERN-".getBytes("UTF-8"));
zippedOut.finish();
zippedOut.flush();
zippedOut.close();
zippedOut = null;
} else {
- httpSSI.writeSSI(o1, o, authorization);
+ httpSSI.writeSSI(o1, o, authorization, clientIP);
//httpTemplate.writeTemplate(fis, o, tp, "-UNRESOLVED_PATTERN-".getBytes("UTF-8"));
}
if (method.equals(httpHeader.METHOD_HEAD)) {
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index 9f9802c96..d8dba2738 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -232,6 +232,7 @@ public final class yacyClient {
if (seedStr.length() > yacySeed.maxsize) {
yacyCore.log.logInfo("hello/client: rejected contacting seed; too large (" + seedStr.length() + " > " + yacySeed.maxsize + ")");
} else {
+ //System.out.println("DEBUG yacyClient.publishMySeed seedStr = " + seedStr);
if (yacyCore.peerActions.peerArrival(yacySeed.genRemoteSeed(seedStr, post.get("key", ""), true), (i == 1))) count++;
}
}