*) first step of removing embedded html from dir class

- dir list generation uses templates now

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2349 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 19 years ago
parent 279b1d969d
commit 8283df2d77

@ -30,7 +30,8 @@
<b>Public&nbsp;File&nbsp;Directory</b>
</font>
</center>
</td></tr>
</td>
</tr>
</table>
</td>
<td width="240" align="right">
@ -59,21 +60,25 @@
<tr height="8"><td></td><td></td></tr>
<tr height="10" valign="top">
<td>Welcome! You are identified and authorized as "<b>#[ident]#</b>".</td>
<td align="right">#[logout]#</td></tr>
<td align="right">#[logout]#</td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="6" width="100%">
<tr valign="top"><td width="50%">
<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]#</td></tr>
</table>
</td><td rowspan="2" width="50%">
</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]#</td></tr>
</table>
</td></tr>
</td>
</tr>
<tr valign="top">
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
@ -89,8 +94,45 @@
<!-- directory listing -->
<hr>
<p>#[dir]#</p>
<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]#" 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

@ -67,6 +67,7 @@ import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCodings;
import de.anomic.server.serverCore;
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;
@ -88,7 +89,7 @@ public class dir {
// System.out.println("###Header="+ header);
// System.out.println("###post=" + post);
String action = ((post == null) ? "info" : post.get("action", "info"));
String tree = "";
// variables for this path
// File htroot = new File(switchboard.getRootPath(), switchboard.getConfig("htRootPath", "htroot"));
final File htroot = new File(switchboard.getRootPath(), switchboard.getConfig("htDocsPath", "DATA/HTDOCS"));
@ -156,14 +157,11 @@ public class dir {
} else {
action = "";
}
}
if (action.equals("downloadPassword") && adminAuthorization) {
} else if (action.equals("downloadPassword") && adminAuthorization) {
switchboard.setConfig("downloadAccountBase64MD5", (post.get("password", "").length() == 0) ? "" : serverCodings.encodeMD5Hex(kelondroBase64Order.standardCoder.encodeString("download:" + post.get("password", ""))));
}
if (action.equals("uploadPassword") && adminAuthorization) {
} else if (action.equals("uploadPassword") && adminAuthorization) {
switchboard.setConfig("uploadAccountBase64MD5", (post.get("password", "").length() == 0) ? "" : serverCodings.encodeMD5Hex(kelondroBase64Order.standardCoder.encodeString("upload:" + post.get("password", ""))));
}
if (action.equals("upload") && (uploadAuthorization || adminAuthorization)) {
} else if (action.equals("upload") && (uploadAuthorization || adminAuthorization)) {
String filename = new File(post.get("file", "dummy")).getName();
String description = post.get("description", "");
pos = filename.lastIndexOf("\\");
@ -183,15 +181,13 @@ public class dir {
indexPhrase(switchboard, urlstring, phrase, description);
}
} catch (IOException e) {}
}
if (action.equals("newdir") && (uploadAuthorization || adminAuthorization)) {
} 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();
}
}
if (action.equals("delete") && adminAuthorization) {
} else if (action.equals("delete") && adminAuthorization) {
String filename = post.get("file", "foo");
final File file = new File(dir, filename);
if (file.exists()) {
@ -231,16 +227,16 @@ public class dir {
String md5s, description;
Date d;
// tree += "<span class=\"tt\">path&nbsp;=&nbsp;" + path + "</span><br><br>";
if (list == null)
tree += "This directory is empty.<br>";
else {
int filecount = 0;
tree += "<table border=\"0\" cellpadding=\"2\" cellspacing=\"1\" width=\"100%\">" +
"<tr height=\"8\" class=\"TableHeader\"><td colspan=\"7\" class=tt>" + path + "</td></tr>";
if (list != null) {
int filecount = 0, fileIdx = 0;
prop.put("path", path);
boolean dark = false;
for (int i = 0; i < list.length; i++) {
if (!((list[i].startsWith("dir.")) || (list[i].endsWith(".md5")))) {
tree += "<tr height=\"8\" class=\"TableCell" + ((dark) ? "Dark" : "Light") + "\" valign=\"top\">";
prop.put("dirlist_" + fileIdx + "_dark" , dark?1:0);
dark = !dark;
filecount++;
f = new File(dir, list[i]);
@ -267,37 +263,45 @@ public class dir {
}
d = new Date(f.lastModified());
if (f.isDirectory()) {
tree += "<td class=\"tt\" align=\"left\" width=\"20\"><img src=\"/env/grafics/folderIconSmall.gif\" align=\"top\" class=\"small\"></td>";
tree += "<td class=\"tt\" align=\"left\" width=\"60\">" + dateString(d) + "</td>";
tree += "<td class=\"tt\" align=\"left\" width=\"150\"><a href=\"" /*+ path*/ + list[i] + "/\" class=\"tt\">" + list[i] + "</a></td>";
tree += "<td class=\"tt\" align=\"right\" width=\"60\">" + formatLong(0, 10) + "</td>";
tree += "<td class=\"tt\" align=\"left\" colspan=\"2\"><i>Directory</i></td>";
prop.put("dirlist_" + fileIdx + "_dir" , 1);
prop.put("dirlist_" + fileIdx + "_dir_date" , dateString(d));
prop.put("dirlist_" + fileIdx + "_dir_name" , list[i]);
} else {
tree += "<td class=\"tt\" align=\"left\" width=\"20\"><img src=\"/env/grafics/fileIconSmall.gif\" align=\"top\">";
tree += "<td class=\"tt\" align=\"left\" width=\"60\">" + dateString(d) + "&nbsp;";
tree += "<td class=\"tt\" align=\"left\" width=\"150\"><a href=\"" /*+ path*/ + list[i] + "\" class=\"tt\">" + list[i] + "</a></td>";
tree += "<td class=\"tt\" align=\"right\" width=\"60\">" + formatLong(f.length(), 10) + "</td>";
tree += "<td class=\"tt\" align=\"left\" width=\"220\"><a href=\"" + yacyhURL(yacyCore.seedDB.mySeed, f.getName(), md5s) + "\" class=\"tt\">" + md5s + "</a></td>";
tree += "<td class=\"small\" align=\"left\">" + (((description.length() == 0) && ((list[i].endsWith(".jpg")) || (list[i].endsWith(".gif")) || (list[i].endsWith(".png")))) ? ("<img src=\"" + list[i] + "\" border=\"0\" height=\"32\" width=\"32\"") : description) + "</td>";
prop.put("dirlist_" + fileIdx + "_dir" , 0);
prop.put("dirlist_" + fileIdx + "_dir_date" , dateString(d));
prop.put("dirlist_" + fileIdx + "_dir_name" , list[i]);
prop.put("dirlist_" + fileIdx + "_dir_size" , serverMemory.bytesToString(f.length()).replaceAll(" ", "&nbsp;"));
prop.put("dirlist_" + fileIdx + "_dir_yacyhURL",yacyhURL(yacyCore.seedDB.mySeed, f.getName(), md5s));
prop.put("dirlist_" + fileIdx + "_dir_md5s",md5s);
boolean showImage = (description.length() == 0) && (list[i].endsWith(".jpg") || list[i].endsWith(".gif") || list[i].endsWith(".png"));
prop.put("dirlist_" + fileIdx + "_dir_descriptionMode",showImage?0:1);
if (showImage) {
prop.put("dirlist_" + fileIdx + "_dir_descriptionMode_image",list[i]);
} else {
prop.put("dirlist_" + fileIdx + "_dir_descriptionMode_text",description);
}
}
prop.put("dirlist_" + fileIdx + "_adminAuthorization",adminAuthorization?1:0);
if (adminAuthorization) {
tree += "<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=\"" + list[i] + "\">" +
"<input type=\"submit\" value=\"delete\" class=\"small\"></form></td>";
prop.put("dirlist_" + fileIdx + "_adminAuthorization_name",list[i]);
}
// if (adminAuthorization) tree += "</form> "; else tree += "<br>";
tree += "</tr>" + serverCore.crlfString;
fileIdx++;
}
}
tree += "</table>";
if (filecount == 0) {
tree += "<b>EMPTY</b><br>";
}
prop.put("dirlist",filecount);
prop.put("emptydir", filecount == 0 ? 1:0);
}
prop.put("authenticated",1);
} else {
prop.put("authenticated",0);
}
String ident = "";
String account = "";
String service = "";
@ -401,7 +405,6 @@ public class dir {
}
} else {
ident = "not authorized";
tree = "To inspect this directory you need either an admin, upload or download account. Please log in.";
account = "<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\">" +
@ -419,7 +422,6 @@ public class dir {
info = "You must log-in to upload or download.";
}
prop.put("dir", tree);
prop.put("ident", ident);
prop.put("account", account);
prop.put("service", service);

Loading…
Cancel
Save