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

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4510 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
orbiter 2008-02-25 21:26:49 +00:00
parent c48e25d784
commit 3f321ece7d
8 changed files with 56 additions and 61 deletions

View File

@ -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)#

View File

@ -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>

View File

@ -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)#

View File

@ -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;
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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)) {

View File

@ -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++;
}
}