var start = new Date(); require("file_size.js", "file_size_float"); function header(title) { writeln(""); writeln(""); writeln(""); writeln("
"); writeln("
"); var fb = new FileBase(dir.code); if(!fb.open()) { write("Error " + fb.error + " opening directory: " + dir.code); return; } var sort = http_request.query["sort"]; if(sort !== undefined) sort = parseInt(sort[0], 10); var list = fb.get_list(FileBase.DETAIL.NORM, true, sort); fb.close(); if(!list) { write("file list is null"); return; } writeln("Name"); write(" | Size"); write(" | Date"); write(" | Description"); writeln(" |
---|---|---|---|
" + f.name.link(f.name)); write(" | " + file_size_float(f.size, 1, 0)); write(" | " + strftime("%b-%d-%y", f.time).bold()); write(" | " + utf8_encode(f.desc || "")); writeln(" |
" + list.length + " files");
}
// Listing the directories of a library
function lib_index(lib)
{
header(file_area.lib[lib].description);
writeln("[" + root_link() + "] / ");
writeln(file_area.lib[lib].description + "
");
writeln("
");
for(var d in file_area.dir) {
var dir = file_area.dir[d];
if(dir.lib_name != lib)
continue;
if(!dir.can_access)
continue;
write(dir.name.link(dir.vdir + "/") + "
");
}
}
// Listing all libraries
function root_index()
{
header("File Areas");
for(var l in file_area.lib_list) {
var lib = file_area.lib_list[l];
write(lib.description.link(lib.vdir + "/")+ "
");
}
}
if(http_request.virtual_path[http_request.virtual_path.length - 1] != '/') {
http_reply.status = "301 Moved";
http_reply.header.Location = http_request.virtual_path + '/';
exit();
}
if(http_request.dir !== undefined) {
dir_index(http_request.dir);
} else if (http_request.lib !== undefined) {
lib_index(http_request.lib);
} else {
root_index();
}
var now = new Date();
write("
Dynamically generated ");
write(format("in %lu milliseconds ", now.valueOf()-start.valueOf()));
write("by " + server.version + "");
writeln("
" + now);
writeln("