- added new way to watch images from the image search:

they appear as separate, floating window above the search results,
  not in a new window
- added highslide javascript library for feature mentioned above
- removed dir servlet. This thing was not used as it was supposed to be (as an example applet)
  and was a major problem for intranet-indexing when files are hosted on the same peer.
- added yacy-httpd-internal directory listing. Because YaCy is a search engine,
  directory listings are similar to search result listings. Intranet indexing from the same peer
  will get nice index pages for document collections.
- removed unused test applet

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4494 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent 61a81820e3
commit 6c3cd2b4f2

@ -1,10 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry excluding="env/|htdocsdefault/|proxymsg/|yacy/|env/|yacy/user/" kind="src" path="htroot"/> <classpathentry excluding="env/|htdocsdefault/|proxymsg/|yacy/|env/|yacy/user/" kind="src" path="htroot"/>
<classpathentry kind="src" path="htroot/htdocsdefault"/>
<classpathentry excluding="user/" kind="src" path="htroot/yacy"/> <classpathentry excluding="user/" kind="src" path="htroot/yacy"/>
<classpathentry kind="src" path="htroot/env"/> <classpathentry kind="src" path="htroot/env"/>
<classpathentry kind="src" path="htroot/yacy/user"/>
<classpathentry kind="src" path="source"/> <classpathentry kind="src" path="source"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/tar.jar"/> <classpathentry kind="lib" path="lib/tar.jar"/>

@ -1,36 +0,0 @@
<!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>YaCy '#[clientname]#': test Applet</title>
#%env/templates/metas.template%#
</head>
<body>
#%env/templates/header.template%#
<h2>Test Applet</h2>
#(mode)#
<form action="TestApplet.html" method="POST">
<table>
<tr>
<td>relative Path</td>
<td><input type="text" name="url"></td>
<td>/yacysearch.html</td>
</tr>
<tr>
<td>Parameters</td>
<td><textarea row="10" cols="60" name="arguments"></textarea><td>
<td>search=yacy</td>
</tr>
</table>
<input type="submit" value="test" />
</form>
::
returned Templates:<br />
<textarea rows="10" cols="70">#[templates]#</textarea><br />
returned Template Structure:<br />
<textarea rows="10" cols="70">#[structure]#</textarea><br />
returned Text:<br />
<textarea rows="10" cols="70">#[text]#</textarea><br />
#(/mode)#
#%env/templates/footer.template%#
</body>
</html>

@ -1,99 +0,0 @@
// TestApplet.java
// -----------------------
// (C) 2006 by Alexander Schier
// part of YACY
//
// 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
import de.anomic.http.httpHeader;
import de.anomic.http.httpdFileHandler;
import de.anomic.server.serverByteBuffer;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class TestApplet {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
serverObjects prop = new serverObjects();
if(post== null || !post.containsKey("url")){
prop.put("mode", "0");
return prop;
}
serverObjects args=new serverObjects();
String[] lines=((String)post.get("arguments")).split("\n");
String[] pair;
for(int i=0;i<lines.length;i++){
pair=lines[i].split("=");
if(pair.length==2){
args.putHTML(pair[0], pair[1]);
}
}
prop.put("mode", "1");
//File templatefile=filehandler.getOverlayedFile((String)post.get("url"));
File classfile = httpdFileHandler.getOverlayedClass((String)post.get("url"));
httpHeader header2=new httpHeader();
header2.put(httpHeader.CONNECTION_PROP_CLIENTIP, "127.0.0.1");
header2.put("PATH", post.get("url"));
serverObjects tp=null;
try {
if(classfile==null || !classfile.exists()){
prop.put("mode_templates", "classfile does not exist");
return prop;
}
tp=(serverObjects) httpdFileHandler.invokeServlet(classfile, header2, args);
}
catch (IllegalArgumentException e) {}
catch (IllegalAccessException e) {}
catch (InvocationTargetException e) {}
if(tp==null){
prop.put("templates", "some error occured.");
prop.put("structure", "");
prop.put("text", "");
return prop;
}
Iterator<String> it = tp.keySet().iterator();
StringBuffer tmp = new StringBuffer();
String key = "";
while(it.hasNext()){
key = it.next();
tmp.append(key).append("=").append(tp.get(key)).append("\n");
}
prop.put("mode_templates", tmp.toString());
//FileInputStream fis=null;
//try {
//fis=new FileInputStream(templatefile);
serverByteBuffer o=new serverByteBuffer();
//byte[] structure=httpTemplate.writeTemplate(fis, o, tp, "-UNRESOLVED_PATTERN-".getBytes("UTF-8"));
//prop.put("mode_structure", structure);
prop.put("mode_text", o.toString());
return prop;
//}
//catch (FileNotFoundException e) {}
//catch (UnsupportedEncodingException e) {}
//catch (IOException e) {}
//prop.put("mode_text", "could not finish correctly"); //very informative errormessage
//return prop;
}
}

@ -0,0 +1,77 @@
/* highslide styles for rounded boxes, taken from highslide demo page */
.highslide {
cursor: url(highslide/graphics/zoomin.cur), pointer;
outline: none;
}
.highslide-active-anchor img {
visibility: hidden;
}
.highslide img {
border: 2px solid gray;
}
.highslide:hover img {
border: 2px solid white;
}
.highslide-wrapper {
background: white;
}
.highslide-image {
border: 2px solid white;
}
.highslide-image-blur {
}
.highslide-caption {
display: none;
border: 2px solid white;
border-top: none;
font-family: Verdana, Helvetica;
font-size: 10pt;
padding: 5px;
background-color: white;
}
.highslide-loading {
display: block;
color: black;
font-size: 8pt;
font-family: sans-serif;
font-weight: bold;
text-decoration: none;
padding: 2px;
border: 1px solid black;
background-color: white;
padding-left: 22px;
background-image: url(highslide/graphics/loader.white.gif);
background-repeat: no-repeat;
background-position: 3px 1px;
}
a.highslide-credits,
a.highslide-credits i {
padding: 2px;
color: silver;
text-decoration: none;
font-size: 10px;
}
a.highslide-credits:hover,
a.highslide-credits:hover i {
color: white;
background-color: gray;
}
a.highslide-full-expand {
background: url(highslide/graphics/fullexpand.gif) no-repeat;
display: block;
margin: 0 10px 10px 0;
width: 34px;
height: 34px;
}
/* These must always be last */
.highslide-display-block {
display: block;
}
.highslide-display-none {
display: none;
}

@ -1,263 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>YaCy: Public Files</title>
<link rel="alternate" type="application/rss+xml" title="RSS" href="#[path]#?format=rss" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Language" content="English, Englisch">
<meta name="keywords" content="yacy file share">
<meta name="description" content="YaCy public share zone">
<meta name="copyright" content="Michael Christen">
<link rel="stylesheet" media="all" href="/env/style.css">
<!-- (C), Architecture and Realisation: Michael Peter Christen; Contact: mc <at> anomic.de -->
</head>
<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr><td>
<table class="Heading" border="0" cellspacing="0" cellpadding="0" width="100%">
<tr height="36">
<td width="240">
<a href="http://www.yacy.net">
<img width="52" height="33" border="0" src="/env/grafics/yacy.gif" align="top" alt="YaCy-Logo">
</a>
</td>
<td width="50%" align="center">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr><td height="4"></td></tr>
<tr><td valign="top">
<center>
<font size="4" face="Helvetica, Arial" color="#ffffff">
<b>Public&nbsp;File&nbsp;Directory</b>
</font>
</center>
</td>
</tr>
</table>
</td>
<td width="240" align="right">
<table border="0" cellspacing="0" cellpadding="0">
<tr><td height="4"></td><td></td></tr>
<tr><td valign="top">
<form action="http://#[peerdomain]#.yacy" method="get">
<input type="submit" value="#[peername]#'s Console" class="small">
</form>
</td><td>&nbsp;&nbsp;</td></tr>
</table>
</td>
</tr>
</table>
</td></tr>
<tr><td height="2"></td></tr>
</table>
<!-- BODY -->
<table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td width="10">&nbsp;</td><td>
<!-- steering elements -->
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr height="8"><td></td><td></td></tr>
<tr height="10" valign="top">
<td>Welcome! You are identified and authorized as "<b>#(ident)#Administrator::Uploader::Downloader::not authorized#(/ident)#</b>".</td>
<td align="right">
#(logout)#<!-- adminAuthorization -->
<form action="#" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="logout">
<input type="submit" value="Log-Out Administrator" class="small">&nbsp;(enter&nbsp;empty&nbsp;account)
</form>
::<!-- uploadAuthorization -->
<form action="#" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="logout">
<input type="submit" value="Log-Out 'upload'" class="small">&nbsp;(enter&nbsp;empty&nbsp;account)
</form>
::<!-- downloadAuthorization -->
<form action="#" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="logout">
<input type="submit" value="Log-Out 'download'" class="small">&nbsp;(enter&nbsp;empty&nbsp;account)
</form>
::
#(/logout)#
</td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="6" width="100%">
<tr valign="top">
<td width="50%">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr valign="top" class="TableHeader" height="6"><td class="small">Service</td></tr>
<tr valign="top" class="TableCellLight">
<td class="small">
#(service)#<!-- adminAuthorization, uploadAuthorization -->
<table border="0" cellpadding="0" cellspacing="2" width="100%">
<tr class="TableCellDark">
<td class="small">New Directory:</td>
<td><form action="#" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="newdir">
<input type="text" name="directory" size="10" class="small">&nbsp;
<input type="submit" value="Create" class="small">
</form>
</td>
</tr>
<tr class="TableCellLight">
<td class="small">File Upload:</td>
<td class="small"><form action="#" method="post" enctype="multipart/form-data">
Resource&nbsp;=&nbsp;
<input type="hidden" name="action" value="upload">
<input type="file" name="file" size="10" class="small"><br>
Indexing&nbsp;:&nbsp;<input type="checkbox" name="indexing" checked><br>
<input type="submit" value="Transfer" class="small">
</form>
</td>
</tr>
</table>
::<!-- downloadAuthorization -->
You are granted to view directory listings and do downloads in this directory.<br>
If you want to upload, please log in as user 'upload'
::<!-- not authorized -->
No service available.
#(/service)#
</td>
</tr>
</table>
</td>
<td rowspan="2" width="50%">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr valign="top" class="TableHeader" height="6"><td width="130" class="small">Account</td></tr>
<tr valign="top" class="TableCellLight">
<td width="130" class="small">
#(account)#<!-- adminAuthorization -->
<table border="0" cellpadding="0" cellspacing="2" width="100%">
<tr class="TableCellDark">
<td class="small">upload:</td>
<td><form action="#" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="uploadPassword">
<input type="password" name="password" size="12">&nbsp;
<input type="submit" value="Set Password" class="small">
</form>
</td>
</tr>
<tr class="TableCellLight">
<td class="small">download:</td>
<td><form action="#" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="downloadPassword">
<input type="password" name="password" size="12">&nbsp;
<input type="submit" value="Set Password" class="small">
</form>
</td>
</tr>
</table>
::<!-- uploadAuthorization -->
<form action="#" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="authenticateAdmin">
<input type="submit" value="Log-In as Administrator" class="small">
</form>
::<!-- downloadAuthorization -->
<form action="#" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="authenticateAdmin" class="small">
<input type="submit" value="Log-In as Administrator" class="small">
</form>
<form action="#" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="authenticateUpload" class="small">
<input type="submit" value="Log-In as user 'upload'" class="small">
</form>
:: <!-- not authorized -->
<form action="#" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="authenticateAdmin">
<input type="submit" value="Log-In as Administrator" class="small">
</form>
<form action="#" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="authenticateUpload">
<input type="submit" value="Log-In as user 'upload'" class="small">
</form>
<form action="#" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="authenticateDownload">
<input type="submit" value="Log-In as user 'download'" class="small">
</form>
#(/account)#
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr valign="top" class="TableHeader" height="6"><td class="small">Info</td></tr>
<tr valign="top" class="TableCellLight">
<td class="small">
#(info)#<!-- adminAuthorization -->
Admin and download accounts are necessary to grant their services to clients;
no password is required for the download-account unless you set one.
Files uploaded and indexed here have a special index entry 'yacyshare';
if you want to find files that are indexed in any share zone, add the word 'yacyshare' to the search words.
:: <!-- uploadAuthorization -->
Uploaders are not granted to delete files or directories. If you want to do this, log-in as admin.
:: <!-- downloadAuthorization -->
Download is granted even if no download account has been defined.<br>
If you are an administrator and you wish to block non-authorized downloades, please log in as user 'admin' and set a download password.
:: <!-- not authorized -->
You must log-in to upload or download.
#(/info)#
</td>
</tr>
</table>
</td>
<td></td>
</tr>
</table>
<br>
<!-- directory listing -->
<hr>
<p>
<table border="0" cellpadding="2" cellspacing="1" width="100%">
<tr height="8" class="TableHeader">
<td colspan="7" class="tt">#[path]#</td>
</tr>
#{dirlist}#
<tr height="8" class="TableCell#(dark)#Light::Dark#(/dark)#" valign="top">
#(dir)#<!-- dirlist entry is a file -->
<td class="tt" align="left" width="20"><img src="/env/grafics/fileIconSmall.gif" align="top">
<td class="tt" align="left" width="60">#[date]#</td>
<td class="tt" align="left" width="150"><a href="#[name]#" class="tt">#[name]#</a></td>
<td class="tt" align="right" width="60">#[size]#</td>
<td class="tt" align="left" width="220"><a href="#[yacyhURL]#" class="tt">#[md5s]#</a></td>
<td class="small" align="left">#(descriptionMode)#<img src="#[image]#" alt="#[text]#" border="0" height="32" width="32">::#[text]##(/descriptionMode)#</td>
::<!-- dirlist entry is a directory -->
<td class="tt" align="left" width="20"><img src="/env/grafics/folderIconSmall.gif" align="top" class="small"></td>
<td class="tt" align="left" width="60">#[date]#</td>
<td class="tt" align="left" width="150"><a href="#[name]#/" class="tt">#[name]#</a></td>
<td class="tt" align="right" width="60">&nbsp;</td>
<td class="tt" align="left" colspan="2"><i>Directory</i></td>
#(/dir)#
#(adminAuthorization)#
::
<td class="small" align="center" width="50">
<form action="#" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="delete">
<input type="hidden" name="file" value="#[name]#">
<input type="submit" value="delete" class="small">
</form>
</td>
#(/adminAuthorization)#
</tr>
#{/dirlist}#
</table>
#(emptydir)#::<b>EMPTY</b><br>#(/emptydir)#
#(authenticated)#To inspect this directory you need either an admin, upload or download account. Please log in.::#(/authenticated)#
</p>
<hr>
<p class="small">
Access of this page with the URLs:
<a href="http://#[peeraddress]#/share/" class="tt">http://#[peeraddress]#/share/</a>, or <a href="http://share.#[peerdomain]#.yacy" class="tt">http://share.#[peerdomain]#.yacy</a>
from within the YaCy network.
</p>
</td><td width="20">&nbsp;</td></tr></table>
</body>
</html>

@ -1,353 +0,0 @@
// dir.java
// (C) 2004, 2005 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
// first published 2004 on http://yacy.net
//
// This is a part of YaCy, a peer-to-peer based web search engine
//
// $LastChangedDate$
// $LastChangedRevision$
// $LastChangedBy$
//
// 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.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.Iterator;
import de.anomic.data.userDB;
import de.anomic.http.httpHeader;
import de.anomic.http.httpc;
import de.anomic.http.httpd;
import de.anomic.index.indexURLEntry;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroBitfield;
import de.anomic.plasma.plasmaCondenser;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCodings;
import de.anomic.server.serverCore;
import de.anomic.server.serverDomains;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverMemory;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.server.logging.serverLog;
import de.anomic.server.serverFileUtils.dirlistComparator;
import de.anomic.tools.md5DirFileFilter;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacySeed;
import de.anomic.yacy.yacyURL;
public class dir {
private static SimpleDateFormat SimpleFormatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
public static String dateString(Date date) {
return SimpleFormatter.format(date);
}
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
final plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
// System.out.println("###Header="+ header);
// System.out.println("###post=" + post);
String action = ((post == null) ? "info" : post.get("action", "info"));
// variables for this path
// File htroot = new File(switchboard.getRootPath(), switchboard.getConfig("htRootPath", "htroot"));
final File htroot = switchboard.getConfigPath("htDocsPath", "DATA/HTDOCS");
String path = (String) header.get("PATH", "/");
int pos = path.lastIndexOf("/");
if (pos >= 0) { path = path.substring(0, pos + 1); }
final File dir = new File(htroot, path);
// general settings
prop.putHTML("peername", env.getConfig("peerName", "<nameless>"));
prop.putHTML("peerdomain", env.getConfig("peerName", "<nameless>").toLowerCase());
prop.putHTML("peeraddress", yacyCore.seedDB.mySeed().getPublicAddress());
prop.put("hostname", serverDomains.myPublicIP());
try{
prop.put("hostip", InetAddress.getByName(serverDomains.myPublicIP()));
}catch(UnknownHostException e){
prop.put("hostip", "Unknown Host Exception");
}
prop.put("port", serverCore.getPortNr(env.getConfig("port","8080")));
// generate upload/download authorizations
final String adminAccountBase64MD5 = switchboard.getConfig(httpd.ADMIN_ACCOUNT_B64MD5, "");
final String uploadAccountBase64MD5 = switchboard.getConfig("uploadAccountBase64MD5", "");
final String downloadAccountBase64MD5 = switchboard.getConfig("downloadAccountBase64MD5", "");
userDB.Entry entry = switchboard.userDB.proxyAuth((String)header.get("Authorization", "xxxxxx"));
boolean adminAuthorization, downloadAuthorization, uploadAuthorization;
if(entry == null){
final String authorizationMD5 = de.anomic.server.serverCodings.encodeMD5Hex(((String) header.get("Authorization", "xxxxxx")).trim().substring(6));
// if (logoutAccountBase64.equals(authorization))
adminAuthorization = (adminAccountBase64MD5.length() != 0 && adminAccountBase64MD5.equals(authorizationMD5));
uploadAuthorization = (adminAuthorization ||(uploadAccountBase64MD5.length() != 0 && uploadAccountBase64MD5.equals(authorizationMD5)));
downloadAuthorization = (adminAuthorization || uploadAuthorization || downloadAccountBase64MD5.length() == 0 || downloadAccountBase64MD5.equals(authorizationMD5));
}else{ //userDB
adminAuthorization=entry.hasRight(userDB.Entry.ADMIN_RIGHT);
uploadAuthorization=entry.hasRight(userDB.Entry.UPLOAD_RIGHT);
downloadAuthorization=entry.hasRight(userDB.Entry.DOWNLOAD_RIGHT);
}
// do authentitcate processes by triggering the http authenticate method
if (action.equals("authenticateAdmin") && !adminAuthorization) {
prop.put("AUTHENTICATE", "admin log-in");
return prop;
}
if (action.equals("authenticateUpload") && !uploadAuthorization) {
prop.put("AUTHENTICATE", "upload log-in");
return prop;
}
if (action.equals("authenticateDownload") && !downloadAuthorization) {
prop.put("AUTHENTICATE", "download log-in");
return prop;
}
// work off actions
if (action.equals("logout")) {
if (adminAuthorization) {
prop.put("AUTHENTICATE", "admin log-in");
return prop;
} else if (uploadAuthorization) {
prop.put("AUTHENTICATE", "upload log-in");
return prop;
} else if (downloadAuthorization) {
prop.put("AUTHENTICATE", "download log-in");
return prop;
} else {
action = "";
}
} else if (action.equals("downloadPassword") && adminAuthorization) {
switchboard.setConfig("downloadAccountBase64MD5", (post.get("password", "").length() == 0) ? "" : serverCodings.encodeMD5Hex(kelondroBase64Order.standardCoder.encodeString("download:" + post.get("password", ""))));
} else if (action.equals("uploadPassword") && adminAuthorization) {
switchboard.setConfig("uploadAccountBase64MD5", (post.get("password", "").length() == 0) ? "" : serverCodings.encodeMD5Hex(kelondroBase64Order.standardCoder.encodeString("upload:" + post.get("password", ""))));
} else if (action.equals("upload") && (uploadAuthorization || adminAuthorization)) {
String filename = new File(post.get("file", "dummy")).getName();
pos = filename.lastIndexOf("\\");
if (pos >= 0) { filename = filename.substring(pos + 1); }
final File newfile = new File(dir, filename);
final byte[] binary = (byte[]) post.get("file$file", new byte[0]);
try {
serverFileUtils.write(binary, newfile);
byte[] md5 = serverCodings.encodeMD5Raw(newfile);
String md5s = serverCodings.encodeHex(md5);
// index file info
if (post.get("indexing", "").equals("on")) {
final String urlstring = yacyhURL(yacyCore.seedDB.mySeed(), filename, md5s);
final String phrase = filename.replace('.', ' ').replace('_', ' ').replace('-', ' ');
indexPhrase(switchboard, urlstring, phrase, "", md5);
}
} catch (IOException e) {}
} else if (action.equals("newdir") && (uploadAuthorization || adminAuthorization)) {
final String newdirname = post.get("directory", "EmptyDir");
if (newdirname != null && newdirname.length() > 0) {
final File newdir = new File(dir, newdirname);
newdir.mkdir();
}
} else if (action.equals("delete") && adminAuthorization) {
String filename = post.get("file", "foo");
final File file = new File(dir, filename);
if (file.exists()) {
// delete file(s)
if (file.isDirectory()) {
final String[] content = file.list();
for (int i = 0; i < content.length; i++) (new File(file, content[i])).delete();
file.delete();
} else if (file.isFile()) {
file.delete();
}
// delete index
final String urlstring = yacyhURL(yacyCore.seedDB.mySeed(), filename, "");
final String phrase = filename.replace('.', ' ').replace('_', ' ').replace('-', ' ');
deletePhrase(switchboard, urlstring, phrase, "");
}
}
// if authorized, generate directory tree listing
if ((adminAuthorization) || (uploadAuthorization) || (downloadAuthorization)) {
// generate dir listing
md5DirFileFilter fileFilter = new md5DirFileFilter();
File[] list = dir.listFiles(fileFilter);
if (list == null) list = new File[0];
// sorting the dir list
dirlistComparator comparator = new dirlistComparator();
Arrays.sort(list, comparator);
// tree += "<span class=\"tt\">path&nbsp;=&nbsp;" + path + "</span><br><br>";
if (list != null) {
int filecount = 0, fileIdx = 0;
prop.putHTML("path", path);
boolean dark = false;
for (int i = 0; i < list.length; i++) {
filecount++;
File f = list[i];
String fileName = f.getName();
// changing table row color
prop.put("dirlist_" + fileIdx + "_dark" , dark ? "1" : "0");
dark = !dark;
// last modification date if the entry
prop.put("dirlist_" + fileIdx + "_dir_date" , dateString(new Date(f.lastModified())));
prop.put("dirlist_" + fileIdx + "_dir_rfc822date" , httpc.dateString(new Date(f.lastModified())));
prop.put("dirlist_" + fileIdx + "_dir_timestamp" , Long.toString(f.lastModified()));
// the entry name
prop.putHTML("dirlist_" + fileIdx + "_dir_name" , fileName);
if (f.isDirectory()) {
// the entry is a directory
prop.put("dirlist_" + fileIdx + "_dir" , "1");
prop.putHTML("dirlist_" + fileIdx + "_dir_URL","http://" + yacyCore.seedDB.mySeed().getPublicAddress() + path + fileName + "/");
} else {
// determine if we should display the description string or a preview image
boolean showImage = /* (description.length() == 0) && */ (fileName.endsWith(".jpg") || fileName.endsWith(".gif") || fileName.endsWith(".png") || fileName.endsWith(".ico") || fileName.endsWith(".bmp"));
// the entry is a file
String md5s = serverCodings.encodeMD5Hex(f);
prop.put("dirlist_" + fileIdx + "_dir" , "0");
// the file size
prop.put("dirlist_" + fileIdx + "_dir_size" , serverMemory.bytesToString(f.length()));
prop.put("dirlist_" + fileIdx + "_dir_sizeBytes" , f.length());
// the unique url
prop.putHTML("dirlist_" + fileIdx + "_dir_yacyhURL",yacyhURL(yacyCore.seedDB.mySeed(), fileName, md5s));
prop.putHTML("dirlist_" + fileIdx + "_dir_URL","http://" + yacyCore.seedDB.mySeed().getPublicAddress() + path + fileName);
// the md5 sum of the file
prop.put("dirlist_" + fileIdx + "_dir_md5s",md5s);
// description mode: 0...image preview, 1...description text
prop.put("dirlist_" + fileIdx + "_dir_descriptionMode",showImage?0:1);
if (showImage) {
prop.putHTML("dirlist_" + fileIdx + "_dir_descriptionMode_image",fileName);
}
// always set the description tag (needed by rss and xml)
prop.putHTML("dirlist_" + fileIdx + "_dir_descriptionMode_text", "");
}
prop.put("dirlist_" + fileIdx + "_adminAuthorization",adminAuthorization ? "1" : "0");
prop.putHTML("dirlist_" + fileIdx + "_adminAuthorization_name",fileName);
fileIdx++;
}
prop.put("dirlist",filecount);
prop.put("emptydir", filecount == 0 ? "1" : "0");
}
prop.put("authenticated", "1");
} else {
prop.put("authenticated", "0");
}
if (adminAuthorization) {
prop.put("ident", "0");
prop.put("logout", "0");
prop.put("account", "0");
prop.put("service", "0");
prop.put("info", "0");
} else if (uploadAuthorization) {
prop.put("ident", "1");
prop.put("logout", "1");
prop.put("account", "1");
prop.put("service", "0");
prop.put("info", "1");
} else if (downloadAuthorization) {
prop.put("ident", "2");
prop.put("logout", "2");
prop.put("account", "2");
prop.put("service", "1");
prop.put("info", "2");
} else {
prop.put("ident", "3");
prop.put("logout", "3");
prop.put("account", "3");
prop.put("service", "2");
prop.put("info", "3");
}
// return rewrite properties
return prop;
}
public static String yacyhURL(yacySeed seed, String filename, String md5) {
return "http://share." + seed.getHexHash() + ".yacyh/" + filename + "?md5=" + md5;
}
public static void indexPhrase(plasmaSwitchboard switchboard, String urlstring, String phrase, String descr, byte[] md5) {
try {
final yacyURL url = new yacyURL(urlstring, null);
final plasmaCondenser condenser = new plasmaCondenser(new ByteArrayInputStream(("yacyshare. " + phrase + ". " + descr).getBytes()), "UTF-8");
final indexURLEntry newEntry = new indexURLEntry(
url,
"YaCyShare: " + descr,
yacyCore.seedDB.mySeed().getName(),
"", // tags
"", // ETag
new Date(), // modification
new Date(), // loadtime
new Date(), // freshtime
"AAAAAAAAAAAA", // referrer
md5, // md5
phrase.length(), // size
condenser.RESULT_NUMB_WORDS, // word count
plasmaHTCache.DT_SHARE, // doctype
new kelondroBitfield(4),
"**", // language
0,0,0,0,0,0
);
switchboard.wordIndex.loadedURL.store(newEntry);
switchboard.wordIndex.loadedURL.stack(
newEntry,
"____________", /*initiator*/
yacyCore.seedDB.mySeed().hash, /*executor*/
5 /*process case*/
);
/*final int words =*/ switchboard.wordIndex.addPageIndex(url, new Date(), phrase.length() + descr.length() + 13, null, condenser, "**", plasmaHTCache.DT_SHARE, 0, 0);
} catch (IOException e) {}
}
public static void deletePhrase(plasmaSwitchboard switchboard, String urlstring, String phrase, String descr) {
try {
final String urlhash = (new yacyURL(urlstring, null)).hash();
final Iterator<String> words = plasmaCondenser.getWords(("yacyshare " + phrase + " " + descr).getBytes("UTF-8"), "UTF-8").keySet().iterator();
String word;
while (words.hasNext()) {
word = words.next();
switchboard.wordIndex.removeEntry(plasmaCondenser.word2hash(word), urlhash);
}
switchboard.wordIndex.loadedURL.remove(urlhash);
} catch (Exception e) {
serverLog.logSevere("DIR", "INTERNAL ERROR in dir.deletePhrase", e);
}
}
}

@ -1,20 +0,0 @@
<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title><![CDATA[YaCy '#[clientname]#': Public Files #[path]#]]></title>
<link>http://#[peeraddress]##[path]#</link>
<description><![CDATA[Directory Listing of #[path]#]]></description>
<image>
<url>http://#[peeraddress]#/env/grafics/YaCyLogo_60ppi.png</url>
<title>YaCy</title>
<link>http://#[peeraddress]#/</link>
</image>
#{dirlist}#<item>
<title><![CDATA[#(dir)##[name]#::#[name]##(/dir)#]]></title>
<link>#(dir)##[URL]#::#[URL]##(/dir)#</link>
<pubDate>#(dir)##[rfc822date]#::#[rfc822date]##(/dir)#</pubDate>
#(dir)#<guid>#[md5s]#</guid>::#(/dir)#
<category><![CDATA[#(dir)#File::Directory#(/dir)#]]></category>
</item>#{/dirlist}#
</channel>
</rss>

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<share path="#[path]#">
#{dirlist}#
#(dir)#
<file>
<name>#[name]#</name>
<date timestamp="#[timestamp]#">#[date]#</date>
<size bytes="#[sizeBytes]#">#[size]#</size>
<md5>#[md5s]#</md5>
<yacyURL>#[yacyhURL]#</yacyURL>
</file>
::
<directory>
<name>#[name]#</name>
<date timestamp="#[timestamp]#">#[date]#</date>
</directory>
#(/dir)#
#{/dirlist}#
</share>

File diff suppressed because it is too large Load Diff

@ -11,10 +11,13 @@ Released for free under a Creative Commons Attribution 2.5 License
<meta name="keywords" content="" /> <meta name="keywords" content="" />
<meta name="description" content="" /> <meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" /> <link href="default.css" rel="stylesheet" type="text/css" />
<link rel="alternate" type="application/rss+xml" title="Search for #[input_former]#" href="yacysearch.rss?search=#[input_former]#" />
<script type="text/javascript" src="/js/ajax.js"></script> <script type="text/javascript" src="/js/ajax.js"></script>
<script type="text/javascript" src="/js/xml.js"></script> <script type="text/javascript" src="/js/xml.js"></script>
<script type="text/javascript" src="/js/yacysearch.js"></script> <script type="text/javascript" src="/js/yacysearch.js"></script>
<script type="text/javascript" src="/js/highslide.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="env/highslide.css" />
<script type="text/javascript">hs.outlineType = 'rounded-white';</script>
</head> </head>
<body> <body>
<div id="header"> <div id="header">

@ -9,7 +9,10 @@
:: ::
#{items}# #{items}#
<div class="thumbcontainer"> <div class="thumbcontainer">
<a href="#[href]#" class="thumblink"><img src="/ViewImage.png?maxwidth=96&maxheight=96&code=#[code]#" alt="#[name]#"></a> <a href="#[href]#" class="thumblink" onclick="return hs.expand(this)">
<img src="/ViewImage.png?maxwidth=96&maxheight=96&code=#[code]#" alt="#[name]#">
</a>
<div class="highslide-caption">#[name]#</div>
<div class="TableCellDark"><a href="#[href]#">#[name]#</a></div> <div class="TableCellDark"><a href="#[href]#">#[name]#</a></div>
</div> </div>
#{/items}# #{/items}#

@ -4,11 +4,12 @@
<title>YaCy '#[clientname]#': Search Page</title> <title>YaCy '#[clientname]#': Search Page</title>
#%env/templates/metas.template%# #%env/templates/metas.template%#
<link rel="alternate" type="application/rss+xml" title="Search for #[input_former]#" href="yacysearch.rss?search=#[input_former]#" /> <link rel="alternate" type="application/rss+xml" title="Search for #[input_former]#" href="yacysearch.rss?search=#[input_former]#" />
<script type="text/javascript" src="/js/ajax.js"></script> <script type="text/javascript" src="/js/ajax.js"></script>
<script type="text/javascript" src="/js/xml.js"></script> <script type="text/javascript" src="/js/xml.js"></script>
<script type="text/javascript" src="/js/yacysearch.js"></script> <script type="text/javascript" src="/js/yacysearch.js"></script>
<script type="text/javascript" src="/js/highslide.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="env/highslide.css" />
<script type="text/javascript">hs.outlineType = 'rounded-white';</script>
</head> </head>
<body id="yacysearch"#(input)#:: onload="document.getElementById('search').focus()":: onload="document.getElementById('search').focus()"#(/input)#> <body id="yacysearch"#(input)#:: onload="document.getElementById('search').focus()":: onload="document.getElementById('search').focus()"#(/input)#>

@ -22,7 +22,10 @@
:: ::
#{items}# #{items}#
<div class="thumbcontainer"> <div class="thumbcontainer">
<a href="#[href]#" class="thumblink"><img src="/ViewImage.png?maxwidth=96&maxheight=96&code=#[code]#" alt="#[name]#"></a> <a href="#[href]#" class="thumblink" onclick="return hs.expand(this)">
<img src="/ViewImage.png?maxwidth=96&maxheight=96&code=#[code]#" alt="#[name]#">
</a>
<div class="highslide-caption">#[name]#</div>
<div class="TableCellDark"><a href="#[href]#">#[name]#</a></div> <div class="TableCellDark"><a href="#[href]#">#[name]#</a></div>
</div> </div>
#{/items}# #{/items}#

@ -46,6 +46,7 @@
package de.anomic.htmlFilter; package de.anomic.htmlFilter;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.io.Writer; import java.io.Writer;
@ -487,6 +488,19 @@ public class htmlFilterContentScraper extends htmlFilterAbstractScraper implemen
} }
} }
public static htmlFilterContentScraper parseResource(File file) throws IOException {
// load page
byte[] page = serverFileUtils.read(file);
if (page == null) throw new IOException("no content in file " + file.toString());
// scrape content
htmlFilterContentScraper scraper = new htmlFilterContentScraper(new yacyURL("http://localhost", null));
Writer writer = new htmlFilterWriter(null, null, scraper, null, false);
serverFileUtils.copy(new ByteArrayInputStream(page), writer, "UTF-8");
return scraper;
}
public static htmlFilterContentScraper parseResource(yacyURL location) throws IOException { public static htmlFilterContentScraper parseResource(yacyURL location) throws IOException {
// load page // load page
byte[] page = httpc.wget( byte[] page = httpc.wget(

@ -98,6 +98,7 @@ import java.util.logging.Level;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.plasma.plasmaParser; import de.anomic.plasma.plasmaParser;
import de.anomic.plasma.plasmaSwitchboard; import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverByteBuffer; import de.anomic.server.serverByteBuffer;
@ -444,15 +445,62 @@ public final class httpdFileHandler {
break; break;
} }
} }
//no defaultfile, send a dirlisting //no defaultfile, send a dirlisting
if (targetFile == null || !targetFile.exists()) { if (targetFile == null || !targetFile.exists()) {
String dirlistFormat = (args==null)?"html":args.get("format","html"); StringBuffer sb = new StringBuffer();
targetExt = dirlistFormat; // this is needed to set the mime type correctly sb.append("<html>\n<head>\n</head>\n<body>\n<h1>Index of " + path + "</h1>\n <ul>\n");
targetFile = getOverlayedFile("/htdocsdefault/dir." + dirlistFormat); File dir = new File(htDocsPath, path);
targetClass=getOverlayedClass("/htdocsdefault/dir." + dirlistFormat); String[] list = dir.list();
if(! (( targetFile != null && targetFile.exists()) && ( targetClass != null && targetClass.exists())) ){ File f;
httpd.sendRespondError(conProp, out, 3, 500, "dir." + dirlistFormat + " or dir.class not found.", null, null); String size;
long sz;
String headline, author, description;
int images, links;
htmlFilterContentScraper scraper;
for (int i = 0; i < list.length; i++) {
f = new File(dir, list[i]);
if (f.isDirectory()) {
sb.append(" <li><a href=\"" + path + list[i] + "\">" + list[i] + "/</a><br></li>\n");
} else {
if (list[i].endsWith("html") || (list[i].endsWith("htm"))) {
scraper = htmlFilterContentScraper.parseResource(f);
headline = scraper.getTitle();
author = scraper.getAuthor();
description = scraper.getDescription();
images = scraper.getImages().size();
links = scraper.getAnchors().size();
} else {
headline = null;
author = null;
description = null;
images = 0;
links = 0;
}
sz = f.length();
if (sz < 1024) {
size = sz + " bytes";
} else if (sz < 1024 * 1024) {
size = (sz / 1024) + " KB";
} else {
size = (sz / 1024 / 1024) + " MB";
}
sb.append(" <li>");
if ((headline != null) && (headline.length() > 0)) sb.append("<a href=\"" + list[i] + "\"><b>" + headline + "</b></a><br>");
sb.append("<a href=\"" + path + list[i] + "\">" + list[i] + "</a><br>");
if ((author != null) && (author.length() > 0)) sb.append("Author: " + author + "<br>");
if ((description != null) && (description.length() > 0)) sb.append("Description: " + description + "<br>");
sb.append(serverDate.formatShortDay(new Date(f.lastModified())) + ", " + size + ((images > 0) ? ", " + images + " images" : "") + ((links > 0) ? ", " + links + " links" : "") + "<br></li>\n");
}
} }
sb.append(" </ul>\n</body>\n</html>\n");
// write the list to the client
httpd.sendRespondHeader(conProp, out, httpVersion, 200, null, "text/html", sb.length(), new Date(dir.lastModified()), null, new httpHeader(), null, null, true);
if (!method.equals(httpHeader.METHOD_HEAD)) {
out.write(sb.toString().getBytes());
}
return;
} }
} else { } else {
//XXX: you cannot share a .png/.gif file with a name like a class in htroot. //XXX: you cannot share a .png/.gif file with a name like a class in htroot.
@ -460,7 +508,6 @@ public final class httpdFileHandler {
targetFile = new File(htDocsPath, path); targetFile = new File(htDocsPath, path);
targetClass = rewriteClassFile(new File(htDocsPath, path)); targetClass = rewriteClassFile(new File(htDocsPath, path));
} }
} }
//File targetClass = rewriteClassFile(targetFile); //File targetClass = rewriteClassFile(targetFile);
@ -895,7 +942,7 @@ public final class httpdFileHandler {
public static final File getOverlayedFile(String path) { public static final File getOverlayedFile(String path) {
File targetFile; File targetFile;
targetFile = getLocalizedFile(path); targetFile = getLocalizedFile(path);
if (!(targetFile.exists())){ if (!targetFile.exists()) {
targetFile = new File(htDocsPath, path); targetFile = new File(htDocsPath, path);
} }
return targetFile; return targetFile;

@ -283,8 +283,8 @@ public final class yacy {
new File(htDocsPath, "notifier.gif")); new File(htDocsPath, "notifier.gif"));
} catch (IOException e) {} } catch (IOException e) {}
final File htdocsDefaultReadme = new File(htDocsPath, "readme.txt"); final File htdocsReadme = new File(htDocsPath, "readme.txt");
if (!(htdocsDefaultReadme.exists())) try {serverFileUtils.write(( if (!(htdocsReadme.exists())) try {serverFileUtils.write((
"This is your root directory for individual Web Content\r\n" + "This is your root directory for individual Web Content\r\n" +
"\r\n" + "\r\n" +
"Please place your html files into the www subdirectory.\r\n" + "Please place your html files into the www subdirectory.\r\n" +
@ -296,7 +296,7 @@ public final class yacy {
"This directory shares it's content with the applications htroot path, so you\r\n" + "This directory shares it's content with the applications htroot path, so you\r\n" +
"may access your yacy search page with\r\n" + "may access your yacy search page with\r\n" +
"http://<your-peer-name>.yacy/\r\n" + "http://<your-peer-name>.yacy/\r\n" +
"\r\n").getBytes(), htdocsDefaultReadme);} catch (IOException e) { "\r\n").getBytes(), htdocsReadme);} catch (IOException e) {
System.out.println("Error creating htdocs readme: " + e.getMessage()); System.out.println("Error creating htdocs readme: " + e.getMessage());
} }

Loading…
Cancel
Save