var start = new Date(); require("file_size.js", "file_size_float"); function header(title) { writeln(""); writeln(""); writeln(""); writeln("" + system.name + " " + title + ""); writeln(""); writeln("

" + system.name + " " + title + "

"); } function root_link() { return "root".link(file_area.web_vpath_prefix); } var sorting_description = { "NAME_AI": "Name ascending", "NAME_DI": "Name descending", "NATURAL": "Date ascending", "DATE_D": "Date descending", "SIZE_A": "Size increasing", "SIZE_D": "Size decreasing" }; // Listing files in a directory function dir_index(dir) { dir = file_area.dir[dir]; header(dir.description); writeln("[" + root_link() + "] / "); var lib = file_area.lib[dir.lib_name]; writeln(lib.description.link(file_area.web_vpath_prefix + lib.vdir + "/") + "
"); writeln("

"); writeln("

"); // Netscape requires this to be in a form 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(""); write(""); write(""); for(var l in list) { var f = list[l]; write(""); write(""); } 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("
"); 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.dir !== undefined) { 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(); } 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(""); writeln("");