Skip to content

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

added search functionality to ViewFile.html servlet

Michael Peter Christen9644c186a44d
diff --git a/htroot/Crawler_p.java b/htroot/Crawler_p.java
index 37ae0785a..a7209da1e 100644
--- a/htroot/Crawler_p.java
+++ b/htroot/Crawler_p.java
@@ -96,6 +96,11 @@ public class Crawler_p {
prop.put("info", "0");
+ if (post != null) {
+ String c = post.toString();
+ if (c.length() < 1000) Log.logInfo("Crawl Start", c);
+ }
+
if (post != null && post.containsKey("continue")) {
// continue queue
final String queue = post.get("continue", "");
diff --git a/htroot/ViewFile.html b/htroot/ViewFile.html
index a44d67c6d..d72d53d3b 100644
--- a/htroot/ViewFile.html
+++ b/htroot/ViewFile.html
@@ -1,6 +1,59 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<!-- This page is only XHTML 1.0 Transitional and not Strict because iframes are in use -->
<html xmlns="http://www.w3.org/1999/xhtml">
+ <script type="text/javascript">
+//<![CDATA[
+function xmlhttpPost() {
+ var searchform = document.getElementById('searchform');
+ search(searchform.url.value);
+}
+
+function search(query) {
+ var xmlHttpReq = false;
+ var self = this;
+ if (window.XMLHttpRequest) { // Mozilla/Safari
+ self.xmlHttpReq = new XMLHttpRequest();
+ }
+ else if (window.ActiveXObject) { // IE
+ self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ self.xmlHttpReq.open('GET', "/solr/select?q=sku:\"" + query + "\" OR host_s:\"" + query + "\" OR host_dnc_s:\"" + query + "\" OR host_organization_s:\"" + query + "\" OR host_organizationdnc_s:\"" + query + "\" OR host_subdomain_s:\"" + query + "\"&start=0&rows=100&wt=json", true);
+ self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+ self.xmlHttpReq.onreadystatechange = function() {
+ if (self.xmlHttpReq.readyState == 4) {
+ updatepage(self.xmlHttpReq.responseText);
+ }
+ }
+ self.xmlHttpReq.send(null);
+}
+
+function updatepage(str) {
+ var raw = document.getElementById("raw");
+ if (raw != null) raw.innerHTML = str;
+ var rsp = eval("("+str+")");
+ var firstChannel = rsp.channels[0];
+ var totalResults = firstChannel.totalResults.replace(/[,.]/,"");
+ var startIndex = firstChannel.startIndex;
+ var itemsPerPage = firstChannel.itemsPerPage;
+ var navigation = firstChannel.navigation;
+
+ var html = "";
+
+ if (totalResults > 0 && firstChannel.items.length > 0) {
+ var item;
+ html += "<table class=\"networkTable\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" width=\"99%\">";
+ html += "<tr class=\"TableHeader\" valign=\"bottom\">";
+ html += "<td>URL from index (total results = " + totalResults + ")<\/td>";
+ for (var i = 0; i < firstChannel.items.length; i++) {
+ item = firstChannel.items[i];
+ html += "<tr class=\"TableCellLight\"><td align=\"left\"><a href=\"HostBrowser.html?urlstringsearch=&amp;urlstring=" + item.link + "\">" + item.link + "<\/a><\/td>";
+ }
+ html += "<\/table>";
+ }
+ document.getElementById("searchresults").innerHTML = html;
+}
+//]]>
+</script>
<head>
<title>YaCy '#[clientname]#': View URL Content</title>
#%env/templates/metas.template%#
@@ -22,11 +75,15 @@
<h2>View URL Content</h2>
- <form method="get" action="ViewFile.html" accept-charset="ascii">
+ <form method="get" action="ViewFile.html" id="searchform" accept-charset="ascii" onkeyup="xmlhttpPost(); return false;">
<fieldset><legend>Get URL Viewer</legend>
<dl>
- <dt>URL:</dt><dd><input type="text" size="60" name="url" value="#[url]#" />&nbsp;<input type="submit" name="show" value="Show" /></dd>
- <dd>&nbsp;</dd>
+ <dt>URL:</dt>
+ <dd>
+ <input type="text" size="60" name="url" value="#[url]#" />
+ <input type="submit" name="show" value="Show" />
+ <div id="searchresults"></div>
+ </dd>
</dl>
</fieldset>
</form>
diff --git a/source/de/anomic/http/server/HTTPDFileHandler.java b/source/de/anomic/http/server/HTTPDFileHandler.java
index 62d330317..0de649e2c 100644
--- a/source/de/anomic/http/server/HTTPDFileHandler.java
+++ b/source/de/anomic/http/server/HTTPDFileHandler.java
@@ -336,7 +336,7 @@ public final class HTTPDFileHandler {
if (!accessGranted) {
final boolean accessFromLocalhost = Domains.isLocalhost(clientIP) && (refererHost == null || refererHost.isEmpty() || Domains.isLocalhost(refererHost));
accessGranted = accessFromLocalhost && realmValue != null && realmProp.length() > 6 && (adminAccountBase64MD5.equals(realmValue));
- Log.logInfo("HTTPDFileHandler", "access from localhost blocked, clientIP=" + clientIP);
+ if (!accessGranted) Log.logInfo("HTTPDFileHandler", "access blocked, clientIP=" + clientIP);
}
// -5- a password is configured and access comes with matching http-authentify