added new cybertag-tracking feature that was inspired by itgrl

from the forum discussion in
http://forum.yacy-websuche.de/viewtopic.php?p=12612#p12612

The feature will provide two basic entities:
- you can integrate image links which point to your yacy installation anywhere in the web.
  the image can be loaded with
  <img src="http://<yourpeer>:<yourport>/cytag.png?icon=invisible&nick=<yournickname_or_community_id>&tag=<anything>">
  This will place a invisible 1-pixel image. If you change the icon=invisible to icon=redpill, you will see a red pill
  Use this, to track your activity in the web.
- you can view your tracks at
  http://localhost:8080/Tracks.html
- There is a public api to your tracks at
  http://localhost:8080/api/tracks_p.json
  which needs authentication


git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5581 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent 03a16f6c20
commit 01b97ef3f8

@ -1,49 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="env/|htdocsdefault/|proxymsg/|yacy/|env/|yacy/user/|yacy/user/|yacy/ui/|processing/domaingraph/applet/|processing/domaingraph/|api/|api/bookmarks/posts/|api/bookmarks/|api/util/|api/bookmarks/xbel/|api/bookmarks/tags/" kind="src" path="htroot"/>
<classpathentry excluding="user/|user/|ui/" kind="src" path="htroot/yacy"/>
<classpathentry kind="src" path="htroot/env"/>
<classpathentry kind="src" path="source"/>
<classpathentry kind="src" path="htroot/yacy/ui"/>
<classpathentry excluding="bookmarks/posts/|bookmarks/|util/|bookmarks/xbel/|bookmarks/tags/" kind="src" path="htroot/api"/>
<classpathentry kind="src" path="htroot/api/bookmarks/posts"/>
<classpathentry excluding="posts/|xbel/|tags/" kind="src" path="htroot/api/bookmarks"/>
<classpathentry kind="src" path="htroot/api/util"/>
<classpathentry kind="src" path="htroot/api/bookmarks/xbel"/>
<classpathentry kind="src" path="htroot/api/bookmarks/tags"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/tar.jar"/>
<classpathentry kind="lib" path="libx/bzip2.jar"/>
<classpathentry kind="lib" path="libx/commons-discovery.jar"/>
<classpathentry kind="lib" path="libx/commons-jxpath-1.1.jar"/>
<classpathentry kind="lib" path="libx/jakarta-oro-2.0.7.jar"/>
<classpathentry kind="lib" path="libx/jaxrpc.jar"/>
<classpathentry kind="lib" path="libx/jmimemagic-0.1.0.jar"/>
<classpathentry kind="lib" path="libx/jrpm-head.jar"/>
<classpathentry kind="lib" path="libx/jrpm-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="libx/jsch-0.1.21.jar"/>
<classpathentry kind="lib" path="libx/log4j-1.2.9.jar"/>
<classpathentry kind="lib" path="libx/odf_utils_05_11_29.jar"/>
<classpathentry kind="lib" path="libx/sbbi-upnplib-1.0.3.jar"/>
<classpathentry kind="lib" path="libx/tm-extractors-1.0.jar"/>
<classpathentry kind="lib" path="libx/wsdl4j.jar"/>
<classpathentry kind="lib" path="libx/xerces.jar"/>
<classpathentry kind="lib" path="libx/poi-3.0-alpha2-20060616.jar"/>
<classpathentry kind="lib" path="libx/poi-scratchpad-3.0-alpha2-20060616.jar"/>
<classpathentry kind="lib" path="libx/inetlib.jar"/>
<classpathentry kind="lib" path="libx/gnumail.jar"/>
<classpathentry kind="lib" path="libx/activation.jar"/>
<classpathentry kind="lib" path="libx/webcat-0.1-swf.jar"/>
<classpathentry kind="lib" path="libx/J7Zip-modified.jar"/>
<classpathentry kind="lib" path="libx/PDFBox-0.7.3.jar"/>
<classpathentry kind="lib" path="libx/FontBox-0.1.0-dev.jar"/>
<classpathentry kind="lib" path="libx/bcprov-jdk14-139.jar"/>
<classpathentry kind="lib" path="libx/bcmail-jdk14-139.jar"/>
<classpathentry kind="lib" path="libx/commons-codec-1.3.jar"/>
<classpathentry kind="lib" path="lib/commons-httpclient-3.1.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/commons-io-1.4.jar"/>
<classpathentry kind="lib" path="lib/commons-fileupload-1.2.1.jar"/>
<classpathentry kind="lib" path="lib/servlet-api.jar"/>
<classpathentry kind="output" path="gen"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="env/|htdocsdefault/|proxymsg/|yacy/|env/|yacy/user/|yacy/user/|yacy/ui/|processing/domaingraph/applet/|processing/domaingraph/|api/|api/bookmarks/posts/|api/bookmarks/|api/util/|api/bookmarks/xbel/|api/bookmarks/tags/" kind="src" path="htroot"/>
<classpathentry excluding="user/|user/|ui/" kind="src" path="htroot/yacy"/>
<classpathentry kind="src" path="htroot/env"/>
<classpathentry kind="src" path="source"/>
<classpathentry kind="src" path="htroot/yacy/ui"/>
<classpathentry excluding="bookmarks/posts/|bookmarks/|util/|bookmarks/xbel/|bookmarks/tags/" kind="src" path="htroot/api"/>
<classpathentry kind="src" path="htroot/api/bookmarks/posts"/>
<classpathentry excluding="posts/|xbel/|tags/" kind="src" path="htroot/api/bookmarks"/>
<classpathentry kind="src" path="htroot/api/util"/>
<classpathentry kind="src" path="htroot/api/bookmarks/xbel"/>
<classpathentry kind="src" path="htroot/api/bookmarks/tags"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/tar.jar"/>
<classpathentry kind="lib" path="libx/bzip2.jar"/>
<classpathentry kind="lib" path="libx/commons-discovery.jar"/>
<classpathentry kind="lib" path="libx/commons-jxpath-1.1.jar"/>
<classpathentry kind="lib" path="libx/jakarta-oro-2.0.7.jar"/>
<classpathentry kind="lib" path="libx/jaxrpc.jar"/>
<classpathentry kind="lib" path="libx/jmimemagic-0.1.0.jar"/>
<classpathentry kind="lib" path="libx/jrpm-head.jar"/>
<classpathentry kind="lib" path="libx/jrpm-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="libx/jsch-0.1.21.jar"/>
<classpathentry kind="lib" path="libx/log4j-1.2.9.jar"/>
<classpathentry kind="lib" path="libx/odf_utils_05_11_29.jar"/>
<classpathentry kind="lib" path="libx/sbbi-upnplib-1.0.3.jar"/>
<classpathentry kind="lib" path="libx/tm-extractors-1.0.jar"/>
<classpathentry kind="lib" path="libx/wsdl4j.jar"/>
<classpathentry kind="lib" path="libx/xerces.jar"/>
<classpathentry kind="lib" path="libx/poi-3.0-alpha2-20060616.jar"/>
<classpathentry kind="lib" path="libx/poi-scratchpad-3.0-alpha2-20060616.jar"/>
<classpathentry kind="lib" path="libx/inetlib.jar"/>
<classpathentry kind="lib" path="libx/gnumail.jar"/>
<classpathentry kind="lib" path="libx/activation.jar"/>
<classpathentry kind="lib" path="libx/webcat-0.1-swf.jar"/>
<classpathentry kind="lib" path="libx/J7Zip-modified.jar"/>
<classpathentry kind="lib" path="libx/PDFBox-0.7.3.jar"/>
<classpathentry kind="lib" path="libx/FontBox-0.1.0-dev.jar"/>
<classpathentry kind="lib" path="libx/bcprov-jdk14-139.jar"/>
<classpathentry kind="lib" path="libx/bcmail-jdk14-139.jar"/>
<classpathentry kind="lib" path="libx/commons-codec-1.3.jar"/>
<classpathentry kind="lib" path="lib/commons-httpclient-3.1.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/commons-io-1.4.jar"/>
<classpathentry kind="lib" path="lib/commons-fileupload-1.2.1.jar"/>
<classpathentry kind="lib" path="lib/servlet-api.jar"/>
<classpathentry kind="output" path="gen"/>
</classpath>

@ -184,7 +184,7 @@
<pathelement location="${build}" />
<pathelement location="${htroot}" />
<!-- libs needed for the yacy thread/object-pools -->
<!-- standard libs -->
<pathelement location="${lib}/tar.jar" />
<pathelement location="${lib}/commons-fileupload-1.2.1.jar" />
<pathelement location="${lib}/commons-httpclient-3.1.jar" />

@ -25,7 +25,7 @@
Your YaCy Peer needs some basic information to operate properly
</p>
<form action="ConfigBasic.html" method="post" enctype="multipart/form-data">
<form action="ConfigBasic.html" method="get">
<ol>
<li>
<img src="/env/grafics/ok.png" height="16" width="16" alt="ok" />&nbsp;Select a language for the interface:<br />
@ -53,7 +53,8 @@
<tr>
<td><label for="usecaseFreeworld">join and support the global network 'freeworld', search the web with an uncensored user-owned search network</label></td>
<td><label for="usecasePortal">your YaCy installation behaves independently from other peers and you define your own web index by starting your own web crawl. This can be used to search your own web pages or to define a topic-oriented search portal.</label></td>
<td><label for="usecaseIntranet">create a search portal for your intranet web pages, or pages that are placed at DATA/HTDOCS/repository and can be accessed at <a href="http://localhost:#[port]#/repository/">http://localhost:#[port]#/repository</a></label></td>
<td><label for="usecaseIntranet">create a search portal for your intranet web pages, or pages that are placed at DATA/HTDOCS/repository and can be accessed at <a href="http://localhost:#[port]#/repository/">http://localhost:#[port]#/repository</a></label>
<input type="file" name="repository" size="10" value="/DATA/HTROOT/repositry"></td>
</tr>
</table>
</fieldset>

@ -0,0 +1,67 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CyTag Trails</title>
#%env/templates/metas.template%#
<script language="Javascript">
function search() {
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', "api/trail_p.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 rsp = eval("("+str+")");
var trails = rsp.trails;
var html = "";
var item;
html += "<table class=\"networkTable\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\">";
html += "<tr class=\"TableHeader\" valign=\"bottom\">";
html += "<td>time</td>";
html += "<td>trail</td>";
html += "<td>nick</td>";
html += "<td>tag</td>";
html += "<td>icon</td>";
html += "<td>ip</td>";
html += "<td>agent</td></tr>";
for (var i = 0; i < trails.length; i++) {
item = trails[i];
if (item.time == null) break;
html += "<tr class=\"TableCellLight\"><td>"+ item.time + "</td>";
html += "<td>" + item.trail + "</td>";
html += "<td>" + item.nick + "</td>";
html += "<td>" + item.tag + "</td>";
html += "<td>" + item.icon + "</td>";
html += "<td>" + item.ip + "</td>";
html += "<td>" + item.agent + "</td></tr>";
}
html += "</table>";
document.getElementById("trails").innerHTML = html;
}
</script>
</head>
<body>
#%env/templates/header.template%#
<script type="text/javascript">
search();
</script>
<div id="trails"></div>
#%env/templates/footer.template%#
</body>
</html>

@ -0,0 +1,13 @@
import de.anomic.http.httpRequestHeader;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.server.servletProperties;
//dummy class
public class Trails {
public static servletProperties respond(final httpRequestHeader requestHeader, final serverObjects post, final serverSwitch<?> env) {
final servletProperties prop = new servletProperties();
return prop;
}
}

@ -0,0 +1,47 @@
// trail_p.java
// (C) 2009 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
// first published 06.02.2009 on http://www.yacy.net
//
// This is a part of YaCy.
// The Software shall be used for Good, not Evil.
//
// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
// $LastChangedRevision: 1986 $
// $LastChangedBy: orbiter $
//
// LICENSE
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import de.anomic.http.httpRequestHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class trail_p {
public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
int c = 0;
for (String t: sb.trail) {
prop.put("trails_" + c++ + "_trail", t); // don't put in putHTML or putXML in, this is wrong!
}
prop.put("trails", c);
return prop;
}
}

@ -0,0 +1,8 @@
{
"trails": [
#{trails}#
#[trail]#,
#{/trails}#
{}
]
}

@ -0,0 +1,89 @@
// cytag.java
// (C) 2009 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
// first published 06.02.2009 on http://www.yacy.net
//
// This is a part of YaCy.
// The Software shall be used for Good, not Evil.
//
// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
// $LastChangedRevision: 1986 $
// $LastChangedBy: orbiter $
//
// LICENSE
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import de.anomic.htmlFilter.htmlFilterCharacterCoding;
import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.order.DateFormatter;
import de.anomic.kelondro.util.FileUtils;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.ymage.ymageImageParser;
public class cytag {
public static Image respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard)env;
// harvest request information
StringBuilder connect = new StringBuilder();
connect.append('{');
addJSON(connect, "time", DateFormatter.formatShortMilliSecond(new Date()));
addJSON(connect, "trail", header.get("Referer", ""));
addJSON(connect, "nick", (post == null) ? "" : post.get("nick", ""));
addJSON(connect, "tag", (post == null) ? "" : post.get("tag", ""));
addJSON(connect, "icon", (post == null) ? "" : post.get("icon", ""));
addJSON(connect, "ip", header.get("CLIENTIP", ""));
addJSON(connect, "agent", header.get("User-Agent", ""));
connect.append('}');
sb.trail.add(connect.toString());
//Log.logInfo("CYTAG", "catched trail - " + connect.toString());
String defaultimage = "redpillmini.png";
if (post != null && post.get("icon", "").equals("invisible")) defaultimage = "invisible.png";
File iconfile = new File(sb.getRootPath(), "/htroot/env/grafics/" + defaultimage);
byte[] imgb = null;
try {
imgb = FileUtils.read(iconfile);
} catch (final IOException e) {
return null;
}
if (imgb == null) return null;
// read image
final Image image = ymageImageParser.parse("cytag.png", imgb);
return image;
}
private static final void addJSON(StringBuilder sb, String k, String v) {
if (sb.length() > 2) sb.append(',');
sb.append('\"');
sb.append(k);
sb.append("\":\"");
sb.append(htmlFilterCharacterCoding.unicode2xml(v, true));
sb.append('\"');
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 423 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 B

@ -133,5 +133,6 @@
::
#%env/templates/embeddedfooter.template%#
#(/display)#
<img src="cytag.png?icon=invisible&nick=yacyh_#[clientid]#&tag=search">
</body>
</html>

@ -277,14 +277,14 @@ public class httpHeader extends TreeMap<String, String> implements Map<String, S
}
// a convenience method to access the map with fail-over defaults
public Object get(final Object key, final Object dflt) {
final Object result = get(key);
public String get(final String key, final String dflt) {
final String result = get(key);
if (result == null) return dflt;
return result;
}
// return multiple results
public Object getSingle(final Object key, final int count) {
public String getSingle(final String key, final int count) {
if (count == 0) return get(key, null);
return get("*" + key + "-" + count, null);
}

@ -106,7 +106,7 @@ public final class httpd implements serverHandler, Cloneable {
//TODO: Load this from a file
private static final HashSet<String> disallowZippedContentEncoding = new HashSet<String>(Arrays.asList(new String[]{
".gz", ".tgz", ".jpg", ".jpeg", ".gif", ".zip", ".rar", ".bz2", ".lha", ".jar", ".rpm", ".arc", ".arj", ".wmv", ".png", ".ico", ".bmp"
".gz", ".tgz", ".jpg", ".jpeg", ".png", ".mp3", ".mov", ".avi", ".gif", ".zip", ".rar", ".bz2", ".lha", ".jar", ".rpm", ".arc", ".arj", ".wmv", ".ico", ".bmp"
}));
// static objects

@ -787,6 +787,7 @@ public final class httpdFileHandler {
templatePatterns.put(servletProperties.PEER_STAT_VERSION, switchboard.getConfig("version", ""));
templatePatterns.put(servletProperties.PEER_STAT_UPTIME, ((System.currentTimeMillis() - serverCore.startupTime) / 1000) / 60); // uptime in minutes
templatePatterns.putHTML(servletProperties.PEER_STAT_CLIENTNAME, switchboard.getConfig("peerName", "anomic"));
templatePatterns.putHTML(servletProperties.PEER_STAT_CLIENTID, ((plasmaSwitchboard) switchboard).webIndex.seedDB.myID());
templatePatterns.put(servletProperties.PEER_STAT_MYTIME, DateFormatter.formatShortSecond());
//System.out.println("respond props: " + ((tp == null) ? "null" : tp.toString())); // debug
} catch (final InvocationTargetException e) {
@ -972,8 +973,8 @@ public final class httpdFileHandler {
// write the file to the client
targetDate = new Date(targetFile.lastModified());
final long contentLength = (zipContent)?-1:targetFile.length()-rangeStartOffset;
final String contentEncoding = (zipContent)?"gzip":null;
final String transferEncoding = (!httpVersion.equals(httpHeader.HTTP_VERSION_1_1))?null:(zipContent)?"chunked":null;
final String contentEncoding = (zipContent) ? "gzip" : null;
final String transferEncoding = (httpVersion.equals(httpHeader.HTTP_VERSION_1_1) && zipContent) ? "chunked" : null;
if (!httpVersion.equals(httpHeader.HTTP_VERSION_1_1) && zipContent) forceConnectionClose(conProp);
httpd.sendRespondHeader(conProp, out, httpVersion, statusCode, null, mimeType, contentLength, targetDate, null, header, contentEncoding, transferEncoding, nocache);
@ -1026,7 +1027,7 @@ public final class httpdFileHandler {
} catch (final Exception e) {
try {
// doing some errorhandling ...
e.printStackTrace();
//e.printStackTrace();
int httpStatusCode = 400;
final String httpStatusText = null;
final StringBuilder errorMessage = new StringBuilder(2000);

@ -323,6 +323,11 @@ public final class DateFormatter {
return format(FORMAT_SHORT_SECOND, date);
}
public static String formatShortMilliSecond(final Date date) {
return format(FORMAT_SHORT_MILSEC, date);
}
/**
* Identical to {@link #formatShortDay(Date, TimeZone)}, but for short second format.
*/

@ -236,6 +236,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
public URLLicense licensedURLs;
public Timer moreMemory;
public List<Pattern> networkWhitelist, networkBlacklist;
public List<String> trail;
public serverProcessor<indexingQueueEntry> indexingDocumentProcessor;
public serverProcessor<indexingQueueEntry> indexingCondensementProcessor;
@ -270,6 +271,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
// remote proxy configuration
httpRemoteProxyConfig.init(this);
this.trail = new ArrayList<String>();
// load values from configs
this.plasmaPath = getConfigPath(plasmaSwitchboardConstants.PLASMA_PATH, plasmaSwitchboardConstants.PLASMA_PATH_DEFAULT);
this.log.logConfig("Plasma DB Path: " + this.plasmaPath.toString());

@ -645,9 +645,6 @@ public final class serverCore extends serverAbstractBusyThread implements server
this.in.close();
this.out.close();
// sleep for a while
//try {Thread.sleep(500);} catch (final InterruptedException e) {}
// close everything
this.controlSocket.close();

@ -34,6 +34,7 @@ public class servletProperties extends serverObjects {
public static final String PEER_STAT_UPTIME = "uptime";
public static final String PEER_STAT_MYTIME = "mytime";
public static final String PEER_STAT_CLIENTNAME = "clientname";
public static final String PEER_STAT_CLIENTID = "clientid";
private String prefix="";

Loading…
Cancel
Save