Skip to content
Snippets Groups Projects
Commit 4d9d077a authored by rswindell's avatar rswindell
Browse files

Many functional and cosmetic changes.

parent a52627d7
No related branches found
No related tags found
No related merge requests found
// JavaScript HTML Index for Synchronet FTP Server // JavaScript HTML Index for Synchronet FTP Server
// $id$ // $id$
var start=new Date();
var time_stamp=start.valueOf().toString(36);
load("sbbsdefs.js"); // Synchronet constants load("sbbsdefs.js"); // Synchronet constants
/* Utility Functions */ /* Utility Functions */
function writeln(str)
{
write(str + "\r\n");
}
function date(time) function date(time)
{ {
var mon=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; var mon=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
...@@ -27,79 +36,133 @@ function secstr(sec) ...@@ -27,79 +36,133 @@ function secstr(sec)
return(format("%02u:%02u",sec/60,sec%60)); return(format("%02u:%02u",sec/60,sec%60));
} }
var title=system.name /* + " FTP Server" */ ; var title=system.name + " BBS - FTP Server";
writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">');
writeln("<html>");
writeln("<head>");
writeln("<title>");
writeln(title);
if (curdir.name!=undefined) if (curdir.name!=undefined)
title += " - " + curdir.name; write(" - " + curdir.name);
else if(curlib.name!=undefined) else if(curlib.description!=undefined)
title += " - " + curlib.name; write(" - " + curlib.description);
writeln("</title>");
write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">\r\n');
write("<html>\r\n"); /* META TAGS */
write("<head>\r\n"); writeln("<meta name='GENERATOR' content='" + system.version + "'>");
write("<title>"); // The following line is necessary for IBM extended-ASCII in descriptions
write(title); writeln("<meta http-equiv='Content-Type' content='text/html; charset=IBM437'>");
write("</title>\r\n"); // The following lines try to tell the browser NOT to cache the page
write("<META NAME='GENERATOR' content='" + system.version + "'>\r\n"); writeln("<meta http-equiv='Expires' content='0'>");
write("</head>\r\n"); writeln("<meta http-equiv='Cache-Control' content='no-cache'>");
write("<body bgcolor=teal text=white link=yellow vlink=lime alink=white>\r\n"); writeln("<meta http-equiv='Cache-Control' content='max-age=0'>");
write("<font face=Arial,Helvetica,sans-serif>\r\n"); writeln('<META HTTP-EQUIV="Pragma" CONTENT="no-cache">');
write("<H1><I><FONT COLOR=lime>" + title + "</FONT></I></H1>\r\n");
writeln("</head>");
writeln("<body bgcolor=teal text=white link=yellow vlink=lime alink=white>");
writeln("<font face=Arial,Helvetica,sans-serif>");
writeln("<h1><font color=lime>" + title.italics() + "</font></h1>");
var prevdir; var prevdir;
var hdr_font="<font color=silver>"; var hdr_font="<font color=silver>";
var dat_font="<font color=white>"; var dat_font="<font color=white>";
/* User Info */ if(!(user.security.restrictions&UFLAG_G)) { /* !Guest or Anonymous */
write("<table border=0 nowrap>\r\n"); /* Logout button */
write("<tr><th align=right>"+hdr_font+"User:<th align=left>"+dat_font+user.alias); writeln("<table align=right>");
/* Library Info */ writeln("<input type=button value=Logout onclick='location=\"ftp://"
if(curlib.name!=undefined) { + format("%s/%s?$%s",system.inetaddr,html_index_file,time_stamp)
write("<th align=right>"+hdr_font+"Library:<th align=left>"+dat_font+curlib.description); + "\";'>");
prevdir="/"; writeln("</table>");
} else
write("<th align=right>"+hdr_font+"Logons:<th align=left>"+dat_font+user.total_logons); /* User Info */
write("<tr><th align=right>"+hdr_font+"Address:<th align=left width=150>"+dat_font+user.note); writeln("<table nowrap align=left>");
if(curdir.name!=undefined) { writeln("<tr><th align=right>"+hdr_font+"User:<th align=left>"+dat_font+user.alias);
write("<th align=right>"+hdr_font+"Directory:<th align=left>"+dat_font+curdir.description); writeln("<tr><th align=right>"+hdr_font+"Address:<th align=left width=150>"+dat_font+user.ip_address);
if(curdir.misc&DIR_FREE) write("<tr><th align=right>"+hdr_font+"Credits:<th align=left>"+dat_font);
write(hdr_font+" - FREE Downloads</font>"); if(user.security.exemptions&UFLAG_D)
prevdir="/"+curlib.name+"/"; writeln("Exempt");
} else if(curlib.name==undefined) else
write("<th align=right>"+hdr_font+"Last on:<th align=left>"+date(user.laston_date)); writeln(kbytes(user.security.credits+user.security.free_credits));
write("<tr><th align=right>"+hdr_font+"Time left:<th align=left>"+dat_font);
write("<tr><th align=right>"+hdr_font+"Credits:<th align=left>"+dat_font); if(user.security.exemptions&UFLAG_T)
if(user.exemptions&UFLAG_D) writeln("Exempt");
write("Exempt");
else
write(kbytes(user.credits+user.free_credits));
if(curdir.misc!=undefined) {
write("<th align=right>"+hdr_font+"Descriptions:<th align=left>");
if(user.settings&EXTDESC)
write(format("[<a href=%s?ext=off>short</a>]",html_index_file));
else else
write(format("[<a href=%s?ext=on>extended</a>]",html_index_file)); writeln(secstr(user.time_left));
} else if(curlib.name==undefined && user.files_uploaded) { writeln("</table>");
write("<th align=right>"+hdr_font+"Uploaded:<th align=left>"+dat_font);
write(format("%s bytes in %u files",kbytes(user.bytes_uploaded),user.files_uploaded)); /* User Stats */
writeln("<table nowrap>");
writeln("<tr><th align=right>"+hdr_font+"Logons:<th align=left>"+dat_font+user.stats.total_logons);
writeln("<tr><th align=right>"+hdr_font+"Last on:<th align=left>"+date(user.stats.laston_date));
writeln("<tr><th align=right>"+hdr_font+"Uploaded:<th align=left>"+dat_font);
writeln(format("%s bytes in %u files"
,kbytes(user.stats.bytes_uploaded),user.stats.files_uploaded));
writeln("<tr><th align=right>"+hdr_font+"Downloaded:<th align=left>"+dat_font);
writeln(format("%s bytes in %u files",kbytes(user.stats.bytes_downloaded)
,user.stats.files_downloaded));
writeln("</table>");
writeln("<br>");
} else if(curlib.name==undefined) { /* Login */
writeln("<table align=right>");
writeln("<td><input type=button value='New User' onClick='location=\"telnet://"
+ system.inetaddr + "\";'>");
writeln("</table>");
writeln("<form name='login'>");
writeln("<table rules=none cellpadding=3>");
writeln("<tr><th valign=top align=left>"+hdr_font+"Name");
writeln("<td colspan=2><input type=text name='username' size=25 maxlength=25>");
writeln("<tr><th valign=top align=left>"+hdr_font+"Password");
writeln("<td><input type=password name='password' size=8 maxlength=8>");
writeln("<td align=right><input type=button name='LoginButton' value='Login' onClick='login_event();'>");
/* Client-Side Script */
writeln("<SCRIPT language='JavaScript'>");
writeln("<!--");
writeln("function login_event() {");
write("var url='ftp://'");
write("+ escape(document.login.username.value) + ':'");
write("+ escape(document.login.password.value) + '@'");
write(format("+ '%s/%s?$%s'\r\n",system.inetaddr,html_index_file,time_stamp));
// writeln("alert(url);");
writeln("location = url;");
writeln("}");
writeln("// -->");
writeln("</script>");
writeln("</table>");
writeln("</form>");
} }
write("<tr><th align=right>"+hdr_font+"Time left:<th align=left>"+dat_font); if(0) {
if(user.exemptions&UFLAG_T) writeln("<form name=goto>");
write("Exempt"); writeln("<select name=dir>");
else
write(secstr(time_left));
if(prevdir!=undefined) {
write("<th align=right>"+hdr_font+"Navigate:<th align=left>");
write(format("[<a href=%s%s>prev</a>] ",prevdir,html_index_file));
write(format("[<a href=/%s>root</a>] ",html_index_file));
} else if(curlib.name==undefined && user.files_downloaded) {
write("<th align=right>"+hdr_font+"Downloaded:<th align=left>"+dat_font);
write(format("%s bytes in %u files",kbytes(user.bytes_downloaded),user.files_downloaded));
} }
write("\r\n"); /* Virtual Path */
write("</table>\r\n"); writeln("<h3>" + hdr_font + "Path: ");
if(curlib.name==undefined)
writeln(dat_font + "Root");
else
writeln("Root".link(format("/%s?$%s",html_index_file,time_stamp)));
if(curlib.name!=undefined) {
if(curdir.name==undefined)
writeln(" / " + dat_font + curlib.description);
else
writeln(" / " + curlib.description.link(format("/%s/%s?$%s"
,curlib.name,html_index_file,time_stamp)));
}
if(curdir.name!=undefined)
writeln(" / " + dat_font + curdir.description);
if(curdir.settings!=undefined && curdir.settings&DIR_FREE)
write(hdr_font+" - FREE");
writeln("</h3>");
/* Table Attributes */ /* Table Attributes */
var hdr_background="white"; var hdr_background="white";
...@@ -108,40 +171,72 @@ var dat_font="<font size=-1>"; ...@@ -108,40 +171,72 @@ var dat_font="<font size=-1>";
var cell_spacing=""; //"cellspacing=2 cellpadding=2"; var cell_spacing=""; //"cellspacing=2 cellpadding=2";
/* Directory Listing */ /* Directory Listing */
if(dir.length) { if(dir_list.length) {
write("<br><table border=0 " + cell_spacing + " width=50%>\r\n"); writeln("<table " + cell_spacing + " width=33%>");
/* header */ /* header */
write("<thead>"); writeln("<thead>");
write("<tr bgcolor=" + hdr_background + ">"); writeln("<tr bgcolor=" + hdr_background + ">");
write("<th>" + hdr_font + "Directory"); writeln("<th>" + hdr_font + "Directory");
write("<th>" + hdr_font + "Description");
if(curlib.name!=undefined) if(curlib.name!=undefined)
write("<th>" + hdr_font + "Files"); writeln("<th>" + hdr_font + "Files");
write("</thead>"); writeln("</thead>");
/* body */ /* body */
write("\r\n<tbody>\r\n"); writeln("<tbody>");
for(i in dir) { for(i in dir_list) {
write("<tr>\r\n"); writeln("<tr>");
/* filename */ /* filename */
write("<th nowrap align=left>" + dat_font + format("<A HREF=%s", dir[i].link) + ">" writeln("<th nowrap align=left>" + dat_font
+ dir[i].name +"</A>"); + dir_list[i].description.link(dir_list[i].link + "?$" + time_stamp));
write("<td nowrap>" + dat_font + dir[i].description);
if(curlib.name!=undefined) { if(curlib.name!=undefined) {
write("<td align=right><font color=black>" + dat_font + dir[i].size); writeln("<td align=right><font color=black>" + dat_font + dir_list[i].size);
write("<th>" + dat_font + (dir[i].misc&DIR_FREE ? "FREE":"")); writeln("<th>" + dat_font + (dir_list[i].settings&DIR_FREE ? "FREE":""));
} }
} }
write("</table>\r\n"); writeln("</table>");
if(file_list.length)
writeln("<br>");
} }
/* File Listing */ /* File Listing */
if(file.length) { if(file_list.length) {
/* Sort the list? */
switch(ftp_sort) {
case "uploader":
/**
file_list.sort(function(a,b)
{ return(a.uploader-b.uploader); }
);
**/
break;
case "size":
file_list.sort(function(a,b)
{ return(a.size-b.size); }
);
break;
case "credits":
file_list.sort(function(a,b)
{ return(a.credits-b.credits); }
);
break;
case "time":
file_list.sort(function(a,b)
{ return(a.time.valueOf()-b.time.valueOf()); }
);
break;
case "hits":
file_list.sort(function(a,b)
{ return(a.times_downloaded-b.times_downloaded); }
);
break;
}
if(ftp_reverse)
file_list.reverse();
var show_ext_desc; /* show extended descriptions */ var show_ext_desc; /* show extended descriptions */
var total_bytes=0; var total_bytes=0;
...@@ -151,121 +246,155 @@ if(file.length) { ...@@ -151,121 +246,155 @@ if(file.length) {
if (curdir.name==undefined) if (curdir.name==undefined)
show_ext_desc=false; /* aliased files have no ext desc */ show_ext_desc=false; /* aliased files have no ext desc */
else else
show_ext_desc=user.settings&EXTDESC; show_ext_desc=user.settings&USER_EXTDESC;
write("<br><table border=0 nowrap " + cell_spacing + " width=100%>\r\n"); writeln("<table " + cell_spacing + " width=100%>");
/* header */ /* header */
write("<thead>"); writeln("<thead>");
write("<tr bgcolor=" + hdr_background + ">"); writeln("<tr bgcolor=" + hdr_background + ">");
write("<th>" + hdr_font + "File");
if(curdir.misc!=undefined && !(curdir.misc&DIR_FREE)) /* File */
write("<th>" + hdr_font + "Credits"); writeln(format("<th><a href=%s?sort=name%s$%s>%sFile</a>"
,html_index_file
,(ftp_sort=="name" && !ftp_reverse) ? "&reverse":"", time_stamp, hdr_font));
/* Credits or Size */
if(curdir.settings!=undefined && !(curdir.settings&DIR_FREE))
writeln(format("<th><a href=%s?sort=credits%s$%s>%sCredits</a>"
,html_index_file
,(ftp_sort=="credits" && !ftp_reverse) ? "&reverse" : "", time_stamp, hdr_font));
else else
write("<th>" + hdr_font + "Size"); writeln(format("<th><a href=%s?sort=size%s$%s>%sSize</a>"
,html_index_file
,(ftp_sort=="size" && !ftp_reverse) ? "&reverse" : "", time_stamp, hdr_font));
/* Description */
write("<th>" + hdr_font + "Description"); write("<th>" + hdr_font + "Description");
write("<th>" + hdr_font + "Date/Time"); if(curdir.settings!=undefined) {
if(user.settings&USER_EXTDESC)
writeln(format(" [%s]"
,(hdr_font+"short").link(format("%s?ext=off$%s",html_index_file, time_stamp))));
else
writeln(format(" [%s]"
,(hdr_font+"extended").link(format("%s?ext=on$%s",html_index_file, time_stamp))));
}
/* Date/Time */
writeln(format("<th><a href=%s?sort=time%s$%s>%sDate/Time</a>"
,html_index_file
,(ftp_sort=="time" && !ftp_reverse) ? "&reverse" : "", time_stamp, hdr_font));
/* Uploader and Hits (downloads) */
if(curdir.name!=undefined) { /* not valid for aliased files in root */ if(curdir.name!=undefined) { /* not valid for aliased files in root */
write("<th>" + hdr_font + "Uploader"); writeln(format("<th><a href=%s?sort=uploader%s$%s>%sUploader</a>"
write("<th>" + hdr_font + "Hits"); ,html_index_file
,(ftp_sort=="uploader" && !ftp_reverse) ? "&reverse" : "", time_stamp, hdr_font));
writeln(format("<th><a href=%s?sort=hits%s$%s>%sHits</a>"
,html_index_file
,(ftp_sort=="hits" && !ftp_reverse) ? "&reverse" : "", time_stamp, hdr_font));
} }
write("</thead>"); writeln("</thead>");
/* body */ /* body */
write("\r\n<tbody>\r\n"); writeln("<tbody>");
for(i in file) { for(i in file_list) {
total_downloads+=file[i].times_downloaded; total_downloads+=file_list[i].times_downloaded;
if(file[i].time>most_recent) if(file_list[i].time>most_recent)
most_recent=file[i].time; most_recent=file_list[i].time;
write("<TR>\r\n"); writeln("<tr valign=top>");
/* filename */ /* filename */
write("<th valign=top align=left>" + dat_font); if(user.security.restrictions&UFLAG_D
if(curdir.misc!=undefined || (curdir.settings!=undefined
&& !(curdir.misc&DIR_FREE) && !(curdir.settings&DIR_FREE)
&& !(user.exemptions&UFLAG_D) && !(user.security.exemptions&UFLAG_D)
&& file[i].credits > (user.credits+user.free_credits) && file_list[i].credits > (user.security.credits+user.security.free_credits))
) ) {
write(file[i].name); write("<td align=left>" + dat_font);
else writeln(file_list[i].name.link(
write("<A HREF=" + file[i].name + ">" + file[i].name +"</A>"); "javascript:alert('Sorry, you do not have enough credits to download this file.');"));
} else {
write("<th align=left>" + dat_font);
writeln(file_list[i].name.link(file_list[i].link));
}
/* size */ /* size */
write("<TD valign=top align=right>" + dat_font + "<font color=black>"); write("<td align=right>" + dat_font + "<font color=black>");
if(curdir.misc!=undefined && !(curdir.misc&DIR_FREE)) { if(curdir.settings!=undefined && !(curdir.settings&DIR_FREE)) {
if(!file[i].credits) if(!file_list[i].credits)
write("<font color=white><b>FREE"); writeln("<font color=white><b>FREE");
else else
write(kbytes(file[i].credits)); writeln(kbytes(file_list[i].credits));
total_bytes+=file[i].credits; total_bytes+=file_list[i].credits;
} else { } else {
write(kbytes(file[i].size)); writeln(kbytes(file_list[i].size));
total_bytes+=file[i].size; total_bytes+=file_list[i].size;
} }
/* description */ /* description */
write("<TD valign=top>"); write("<td>");
if (show_ext_desc) { if (show_ext_desc) {
if(file[i].misc&FM_EXTDESC) if(file_list[i].settings&FILE_EXTDESC)
write("<PRE>" + file[i].extended_description); writeln("<pre>" + file_list[i].extended_description);
else else
write("<TT>" + file[i].description); writeln("<tt>" + file_list[i].description);
} else } else
write(dat_font + file[i].description); writeln(dat_font + file_list[i].description);
/* date/time */ /* date/time */
write("<TD valign=top align=center nowrap>" + dat_font + "<font color=black>" writeln("<td align=center nowrap>" + dat_font + "<font color=black>"
+ "<TT>"+ date(file[i].time)); + "<tt>"+ date(file_list[i].time));
if(curdir.name!=undefined) { /* not valid for aliased files in root */ if(curdir.name!=undefined) { /* not valid for aliased files in root */
/* uploader */ /* uploader */
var uploader=file[i].uploader; var uploader=file_list[i].uploader;
if (file[i].misc&FM_ANON) if (file_list[i].settings&FILE_ANON)
uploader="Anonymous"; uploader="Anonymous";
else if (uploader == "-> ADDFILES <-") else if (uploader == "-> ADDFILES <-")
uploader="Sysop"; uploader="Sysop";
write("<TD valign=top nowrap>" + dat_font + uploader); writeln("<td nowrap>" + dat_font + uploader);
/* download count */ /* download count */
write("<TD valign=top align=right>" + dat_font + "<font color=black>" writeln("<td align=right>" + dat_font + "<font color=black>"
+ file[i].times_downloaded); + file_list[i].times_downloaded);
} }
write("\r\n");
} }
/* Footer (with totals) */ /* Footer (with totals) */
write("<tfoot>\r\n"); writeln("<tfoot>");
write(format("<TR bgcolor=%s><TH>%s%lu files" + writeln(format("<tr bgcolor=%s><th>%s%lu files" +
"<TH align=right>%s%s<TH>%s-<TH>%s<font color=black><TT>%s" "<th align=right>%s%s<th>%s-<th>%s<font color=black><tt>%s"
,hdr_background ,hdr_background
,hdr_font, file.length ,hdr_font, file_list.length
,hdr_font, kbytes(total_bytes) ,hdr_font, kbytes(total_bytes)
,hdr_font ,hdr_font
,dat_font, date(most_recent) ,dat_font, date(most_recent)
)); ));
if(curdir.name!=undefined) /* not valid for aliased files in root */ if(curdir.name!=undefined) /* not valid for aliased files in root */
write(format("<TH>%s-<TH align=right>%s%lu" writeln(format("<th>%s-<th align=right>%s%lu"
,hdr_font ,hdr_font
,hdr_font, total_downloads ,hdr_font, total_downloads
)); ));
write("</TABLE>\r\n"); writeln("</table>");
} }
if(!file.length && !dir.length) if(!file_list.length && !dir_list.length)
write("<br><b>No Files.</b><br>"); writeln("<br><b>No Files.</b><br>");
/* Footer */ /* Footer */
write("<BR><font size='-2'>Problems? Ask "); write("<br><font size='-2'>Problems? Ask ");
write(format("<a href=mailto:sysop@%s>%s</a>.",system.inetaddr,system.operator)); write(format("<a href=mailto:sysop@%s>%s</a>.",system.inetaddr,system.operator));
write("<BR><font size='-2'>Dynamically generated by "); write("<br><font size='-2'>Dynamically generated ");
write("<A HREF=http://www.synchro.net>" + system.version + "</A>"); write(format("in %lu milliseconds ", new Date().valueOf()-start.valueOf()));
write("<BR>" + Date() + "</font>\r\n"); write("by <a href=http://www.synchro.net>" + system.version + "</a>");
write("</BODY>\r\n"); writeln("<br>" + Date() + "</font>");
write("</HTML>\r\n"); writeln("</body>");
writeln("</html>");
/* End of ftp-html.js */ /* End of ftp-html.js */
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment