Skip to content
Snippets Groups Projects
Commit 22e8d2e3 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Remove dynamic HTML index support from FTP server

The days of browsers rendering HTML served-up via FTP are over, so remove this feature. This also removes all JavaScript support from the FTP server and that is a bit odd as it was one of the first Synchronet components for which I added JS support.

Removing this feature was pretty painless; much easier than adding it was. The main motivation was less cruft to port to the file base in the works. There should be no more references to 00index.html anywhere at this point. Bye bye cool feature, we'll miss you.
parent 791b6b33
No related branches found
No related tags found
No related merge requests found
...@@ -235,8 +235,6 @@ Options = ALLOW_POP3 | USE_SUBMISSION_PORT | TLS_SUBMISSION | TLS_POP3 ...@@ -235,8 +235,6 @@ Options = ALLOW_POP3 | USE_SUBMISSION_PORT | TLS_SUBMISSION | TLS_POP3
; Dynamically generated index files ; Dynamically generated index files
IndexFileName = 00index IndexFileName = 00index
HtmlIndexFile = 00index.html
HtmlIndexScript = ftp-html.js
; Supported options (separated with |): ; Supported options (separated with |):
; DEBUG_RX ; DEBUG_RX
; DEBUG_DATA ; DEBUG_DATA
...@@ -246,13 +244,11 @@ Options = ALLOW_POP3 | USE_SUBMISSION_PORT | TLS_SUBMISSION | TLS_POP3 ...@@ -246,13 +244,11 @@ Options = ALLOW_POP3 | USE_SUBMISSION_PORT | TLS_SUBMISSION | TLS_POP3
; NO_LOCAL_FSYS ; NO_LOCAL_FSYS
; DIR_FILES ; DIR_FILES
; KEEP_TEMP_FILES ; KEEP_TEMP_FILES
; HTML_INDEX_FILE
; LOOKUP_PASV_IP ; LOOKUP_PASV_IP
; NO_HOST_LOOKUP ; NO_HOST_LOOKUP
; NO_RECYCLE ; NO_RECYCLE
; NO_JAVASCRIPT
; MUTE ; MUTE
Options = INDEX_FILE | HTML_INDEX_FILE | ALLOW_QWK Options = INDEX_FILE | ALLOW_QWK
[Web] Web (HTTP) Server [Web] Web (HTTP) Server
AutoStart = true AutoStart = true
......
// JavaScript HTML Index for Synchronet FTP Server
// $Id: ftp-html.js,v 1.23 2015/04/14 01:45:31 rswindell Exp $
load("sbbsdefs.js"); // Synchronet constants
var start=new Date();
var time_stamp = '';
var time_stamp_only = '';
var new_time_stamp='$'+start.valueOf().toString(36); // Used to defeat caching browsers
if (!(user.security.restrictions&UFLAG_G)) {
time_stamp=new_time_stamp;
time_stamp_only = '%3F' + time_stamp;
}
/* Utility Functions */
function writeln(str)
{
write(str + "\r\n");
}
function kbytes(nbytes)
{
return(Math.round(nbytes/1024)+"k");
}
function secstr(sec)
{
return(format("%02u:%02u",sec/60,sec%60));
}
var title = system.name + " - FTP Server";
var font_face = "<font face=Arial,Helvetica,sans-serif>";
var font_size = 2; // Change base font size here
if(client.socket.local_port!=21)
port=":" + client.socket.local_port;
else
port="";
writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">');
writeln("<html>");
writeln("<head>");
writeln("<title>");
writeln(title);
if (ftp.curdir.name!=undefined)
write(" - " + ftp.curdir.name);
else if(ftp.curlib.description!=undefined)
write(" - " + ftp.curlib.description);
writeln("</title>");
/* META TAGS */
writeln("<meta name='GENERATOR' content='" + system.version + "'>");
// The following line is necessary for IBM extended-ASCII in descriptions
writeln("<meta http-equiv='Content-Type' content='text/html; charset=IBM437'>");
writeln("</head>");
writeln("<body bgcolor=#aaaaaa text=black link=white vlink=#334455 alink=red>");
writeln(font_face);
/* Go To Select Box */
writeln("<table width=100%>");
writeln("<td>");
writeln("<h1>" + font_face + "<font color=white>" + title.italics() + "</font></h1>");
writeln("<td align=right>");
writeln("<form>"); // Netscape requires this to be in a form <sigh>
writeln(format(
"<select " +
"onChange='if(selectedIndex>0) location=options[selectedIndex].value + \"%s\";'>"
,time_stamp_only));
writeln("<option>Go To...</option>");
writeln(format("<option value=/%s>Root</option>",html_index_file));
for(l in file_area.lib_list) {
writeln(format("<optgroup label=%s>",file_area.lib_list[l].name));
writeln(format("<option value=%s>[%s]"
,file_area.lib_list[l].link
,file_area.lib_list[l].name));
for(d in file_area.lib_list[l].dir_list) {
writeln(format("<option value=%s>%s"
,file_area.lib_list[l].dir_list[d].link
,file_area.lib_list[l].dir_list[d].name));
}
writeln("</optgroup>");
}
writeln("</select>");
writeln("</form>");
writeln("</table>");
var prevdir;
var hdr_font="<font color=black>";
var dat_font="<font color=#112233>";
if(!(user.security.restrictions&UFLAG_G)) { /* !Guest or Anonymous */
if(system.matchuser("Guest")) {
/* Logout button */
writeln("<table align=right>");
writeln("<form>");
writeln("<input type=button value=Logout onclick='location=\"ftp://"
+ format("%s/%s%s",system.host_name + port,html_index_file,time_stamp_only)
+ "\";'>");
writeln("</form>");
writeln("</table>");
writeln("<br><br>");
}
/* User Info */
writeln("<table border=0 nowrap align=left>");
writeln(font_face);
writeln("<tr><th bgcolor=#888888 align=right>"+hdr_font+"User:<th bgcolor=#888888 align=left>"+dat_font+user.alias);
writeln("<tr><th bgcolor=#888888 align=right>"+hdr_font+"Address:<th bgcolor=#888888 align=left width=150>"+dat_font+user.ip_address);
write("<tr><th bgcolor=#888888 align=right>"+hdr_font+"Credits:<th bgcolor=#888888 align=left>"+dat_font);
if(user.security.exemptions&UFLAG_D)
writeln("Exempt");
else
writeln(kbytes(user.security.credits+user.security.free_credits));
write("<tr><th bgcolor=#888888 align=right>"+hdr_font+"Time left:<th bgcolor=#888888 align=left>"+dat_font);
if(user.security.exemptions&UFLAG_T)
writeln("Exempt");
else
writeln(secstr(ftp.time_left));
writeln("</table>");
/* User Stats */
writeln("<table border=0 nowrap>");
writeln(font_face);
writeln("<tr><th align=right bgcolor=#888888>"+hdr_font+"Logons:<th bgcolor=#888888 align=left>"+dat_font+user.stats.total_logons);
writeln("<tr><th bgcolor=#888888 align=right>"+hdr_font+"Last on:<th bgcolor=#888888 align=left>"+strftime("%B %d, %Y %H:%M" ,user.stats.laston_date));
writeln("<tr><th bgcolor=#888888 align=right>"+hdr_font+"Uploaded:<th bgcolor=#888888 align=left>"+dat_font);
writeln(format("%s bytes in %u files"
,kbytes(user.stats.bytes_uploaded),user.stats.files_uploaded));
writeln("<tr><th bgcolor=#888888 align=right>"+hdr_font+"Downloaded:<th bgcolor=#888888 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(ftp.curlib.name==undefined) { /* Login */
writeln("<table align=right>");
writeln("<td><input type=button value='New User' onClick='location=\"telnet://"
+ system.host_name + port + "\";'>");
writeln("</table>");
writeln("<form name='login'>");
writeln("<table border=1 frame=box rules=none cellpadding=3>");
writeln(font_face);
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=10 maxlength=25>");
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%%3F%s'\r\n"
,system.host_name + port,html_index_file,new_time_stamp));
// writeln("alert(url);");
writeln("location = url;");
writeln("}");
writeln("// -->");
writeln("</script>");
writeln("</table>");
writeln("</form>");
}
/* Virtual Path */
writeln("<h3>" + hdr_font + "Path: ");
if(ftp.curlib.name==undefined)
writeln(dat_font + "Root");
else
writeln("Root".link(format("/%s%s",html_index_file,time_stamp_only)));
if(ftp.curlib.name!=undefined) {
if(ftp.curdir.name==undefined)
writeln(" / " + dat_font + ftp.curlib.description);
else
writeln(" / " + ftp.curlib.description.link(format("/%s/%s%s"
,ftp.curlib.name,html_index_file,time_stamp_only)));
}
if(ftp.curdir.name!=undefined)
writeln(" / " + dat_font + ftp.curdir.description);
if(ftp.curdir.settings!=undefined && ftp.curdir.settings&DIR_FREE)
write(hdr_font+" - FREE");
writeln("</h3>");
/* Table Attributes */
var hdr_background="#8899aa";
var hdr_font=format("<font size=%d color=black>",font_size-1);
var dat_font=format("<font size=%d>",font_size);
var cell_spacing=""; //"cellspacing=2 cellpadding=2";
/* Directory Listing */
if(ftp.dir_list.length) {
writeln("<table " + cell_spacing + " width=33%>");
writeln(font_face);
/* header */
writeln("<thead>");
writeln("<tr bgcolor=" + hdr_background + ">");
writeln("<th>" + hdr_font + "Directory");
if(ftp.curlib.name!=undefined)
writeln("<th>" + hdr_font + "Files");
writeln("</thead>");
/* body */
writeln("<tbody>");
for(i in ftp.dir_list) {
writeln("<tr>");
/* filename */
writeln("<th nowrap align=left>" + dat_font
+ ftp.dir_list[i].description.link(ftp.dir_list[i].link + time_stamp_only));
if(ftp.curlib.name!=undefined) {
writeln("<td align=right><font color=black>" + dat_font + ftp.dir_list[i].size);
writeln("<th>" + dat_font + (ftp.dir_list[i].settings&DIR_FREE ? "FREE":""));
}
}
writeln("</table>");
if(ftp.file_list.length)
writeln("<br>");
}
/* File Listing */
if(ftp.file_list.length) {
/* Sort the list? */
switch(ftp.sort) {
case "uploader":
ftp.file_list.sort(function(a,b)
{ if(a.uploader>b.uploader)
return(1);
if(a.uploader<b.uploader)
return(-1);
return(0); }
);
break;
case "size":
ftp.file_list.sort(function(a,b)
{ return(a.size-b.size); }
);
break;
case "credits":
ftp.file_list.sort(function(a,b)
{ return(a.credits-b.credits); }
);
break;
case "time":
ftp.file_list.sort(function(a,b)
{ return(a.time.valueOf()-b.time.valueOf()); }
);
break;
case "hits":
ftp.file_list.sort(function(a,b)
{ return(a.times_downloaded-b.times_downloaded); }
);
break;
}
if(ftp.reverse)
ftp.file_list.reverse();
var show_ext_desc; /* show extended descriptions */
var total_bytes=0;
var total_downloads=0;
var most_recent=0;
if (ftp.curdir.name==undefined)
show_ext_desc=false; /* aliased files have no ext desc */
else
show_ext_desc=ftp.extended_descriptions;
writeln("<table " + cell_spacing + " width=100%>");
writeln(font_face);
/* header */
writeln("<thead>");
writeln("<tr bgcolor=" + hdr_background + ">");
/* File */
writeln(format("<th><a href=%s%%3Fsort=name%s%s>%sFile</a>"
,html_index_file
,(ftp.sort=="name" && !ftp.reverse) ? "&reverse":"", time_stamp, hdr_font));
/* Credits or Size */
if(ftp.curdir.settings!=undefined && !(ftp.curdir.settings&DIR_FREE))
writeln(format("<th><a href=%s%%3Fsort=credits%s%s>%sCredits</a>"
,html_index_file
,(ftp.sort=="credits" && !ftp.reverse) ? "&reverse" : "", time_stamp, hdr_font));
else
writeln(format("<th><a href=%s%%3Fsort=size%s%s>%sSize</a>"
,html_index_file
,(ftp.sort=="size" && !ftp.reverse) ? "&reverse" : "", time_stamp, hdr_font));
/* Description */
write("<th>" + hdr_font + "Description");
if(ftp.extended_descriptions)
writeln(format(" [%s]"
,(hdr_font+"short").link(format("%s%%3Fext=off%s",html_index_file, time_stamp))));
else
writeln(format(" [%s]"
,(hdr_font+"extended").link(format("%s%%3Fext=on%s",html_index_file, time_stamp))));
/* Date/Time */
writeln(format("<th><a href=%s%%3Fsort=time%s%s>%sDate/Time</a>"
,html_index_file
,(ftp.sort=="time" && !ftp.reverse) ? "&reverse" : "", time_stamp, hdr_font));
/* Uploader and Hits (downloads) */
if(ftp.curdir.name!=undefined) { /* not valid for aliased files in root */
writeln(format("<th><a href=%s%%3Fsort=uploader%s%s>%sUploader</a>"
,html_index_file
,(ftp.sort=="uploader" && !ftp.reverse) ? "&reverse" : "", time_stamp, hdr_font));
writeln(format("<th><a href=%s%%3Fsort=hits%s%s>%sHits</a>"
,html_index_file
,(ftp.sort=="hits" && !ftp.reverse) ? "&reverse" : "", time_stamp, hdr_font));
}
writeln("</thead>");
/* body */
writeln("<tbody>");
for(i in ftp.file_list) {
total_downloads+=ftp.file_list[i].times_downloaded;
if(ftp.file_list[i].time>most_recent)
most_recent=ftp.file_list[i].time;
writeln("<tr valign=top>");
/* filename */
if(user.security.restrictions&UFLAG_D
|| (ftp.curdir.settings!=undefined
&& !(ftp.curdir.settings&DIR_FREE)
&& !(user.security.exemptions&UFLAG_D)
&& ftp.file_list[i].credits > (user.security.credits+user.security.free_credits))
) {
write("<td align=left>" + dat_font);
writeln(ftp.file_list[i].name.link(
"javascript:alert('Sorry, you do not have enough credits to download this file.');"));
} else {
write("<th align=left>" + dat_font);
writeln(ftp.file_list[i].name.link(ftp.file_list[i].link));
}
/* size */
write("<td align=right>" + dat_font + "<font color=black>");
if(ftp.curdir.settings!=undefined && !(ftp.curdir.settings&DIR_FREE)) {
if(!ftp.file_list[i].credits)
writeln("<font color=white><b>FREE");
else
writeln(kbytes(ftp.file_list[i].credits));
total_bytes+=ftp.file_list[i].credits;
} else {
writeln(kbytes(ftp.file_list[i].size));
total_bytes+=ftp.file_list[i].size;
}
/* description */
write("<td>" + dat_font);
if (show_ext_desc) {
if(ftp.file_list[i].settings&FILE_EXTDESC)
writeln("<pre>" + ftp.file_list[i].extended_description);
else
writeln("<tt>" + ftp.file_list[i].description);
} else
writeln(dat_font + ftp.file_list[i].description);
/* date/time */
writeln("<td align=center nowrap>" + dat_font + "<font color=black>"
+ "<tt>"+ strftime("%b %d, %Y %H:%M" ,ftp.file_list[i].time));
if(ftp.curdir.name!=undefined) { /* not valid for aliased files in root */
/* uploader */
var uploader=ftp.file_list[i].uploader;
if(ftp.file_list[i].settings&FILE_ANON)
uploader="Anonymous";
else {
if(uploader == "-> ADDFILES <-")
uploader=system.operator;
if(!(user.security.restrictions&UFLAG_G)) /* ! Guest/Anonymous */
uploader=uploader.link("mailto:" + uploader + "@" + system.inetaddr);
}
writeln("<td nowrap>" + dat_font + uploader);
/* download count */
writeln("<td align=right>" + dat_font + "<font color=black>"
+ ftp.file_list[i].times_downloaded);
}
}
/* Footer (with totals) */
writeln("<tfoot>");
writeln(format("<tr bgcolor=%s><th>%s%lu files" +
"<th align=right>%s%s<th>%s-<th>%s<font color=black><tt>%s"
,hdr_background
,hdr_font, ftp.file_list.length
,hdr_font, kbytes(total_bytes)
,hdr_font
,dat_font, strftime("%b %d, %Y %H:%M" ,most_recent)
));
if(ftp.curdir.name!=undefined) /* not valid for aliased files in root */
writeln(format("<th>%s-<th align=right>%s%lu"
,hdr_font
,hdr_font, total_downloads
));
writeln("</table>");
}
if(!ftp.file_list.length && !ftp.dir_list.length)
writeln("<br><b>No Files.</b><br>");
/* Footer */
write(format("<br><font size=%d color=black>Problems? Ask ",font_size-1));
write(format("<a href=mailto:sysop@%s>%s</a>.",system.inetaddr,system.operator));
write(format("<br><font size=%d>Dynamically generated ",font_size-1));
write(format("in %lu milliseconds ", new Date().valueOf()-start.valueOf()));
write("by <a href=http://www.synchro.net>" + server.version + "</a>");
writeln("<br>" + Date() + "</font>");
writeln("</body>");
writeln("</html>");
/* End of ftp-html.js */
// JavaScript HTML Index for Synchronet FTP Server
// $Id: ftp-web-html.js,v 1.11 2015/04/14 01:42:29 rswindell Exp $
load("sbbsdefs.js"); // Synchronet constants
var start=new Date();
var time_stamp = '';
var time_stamp_only = '';
var new_time_stamp='$'+start.valueOf().toString(36); // Used to defeat caching browsers
if (!(user.security.restrictions&UFLAG_G)) {
time_stamp=new_time_stamp;
time_stamp_only = '%3F' + time_stamp;
}
/* Utility Functions */
function writeln(str)
{
write(str + "\r\n");
}
function kbytes(nbytes)
{
return(Math.round(nbytes/1024)+"k");
}
function secstr(sec)
{
return(format("%02u:%02u",sec/60,sec%60));
}
var title = system.name + " - FTP Server";
if(client.socket.local_port!=21)
port=":" + client.socket.local_port;
else
port="";
var http_port = 80;
var file = new File(file_cfgname(system.ctrl_dir, "sbbs.ini"));
if(file.open("r")) {
http_port = file.iniGetValue("web","port",80);
file.close();
}
writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">');
writeln("<html>");
writeln("<head>");
writeln("<title>");
writeln(title);
if (ftp.curdir.name!=undefined)
write(" - " + ftp.curdir.name);
else if(ftp.curlib.description!=undefined)
write(" - " + ftp.curlib.description);
writeln("</title>");
/* META TAGS */
writeln("<meta name='GENERATOR' content='" + system.version + "'>");
// The following line is necessary for IBM extended-ASCII in descriptions
writeln("<meta http-equiv='Content-Type' content='text/html; charset=IBM437'>");
writeln('<link rel="stylesheet" type="text/css" href="http://' + format("%s:%u",system.host_name, http_port) + '/default.css">');
writeln("</head>");
writeln('<body style="background-image: url(http://' + format("%s:%u",system.host_name, http_port) +'/images/default/bg_grad.jpg)";>');
//writeln(font_face);
writeln('<table class="welcome_main" width="95%"><tr><td>');
/* Go To Select Box */
writeln("<table width=100%>");
writeln("<td>");
writeln('<h1 class="ftp_title">' + title + '</h1>');
writeln("<td align=right>");
writeln("<form>"); // Netscape requires this to be in a form <sigh>
writeln(format(
"<select " +
"onChange='if(selectedIndex>0) location=options[selectedIndex].value + \"%s\";'>"
,time_stamp_only));
writeln("<option>Go To...</option>");
writeln(format("<option value=/%s>Root</option>",html_index_file));
for(l in file_area.lib_list) {
writeln(format("<optgroup label=%s>",file_area.lib_list[l].name));
writeln(format("<option value=%s>[%s]"
,file_area.lib_list[l].link
,file_area.lib_list[l].name));
for(d in file_area.lib_list[l].dir_list) {
writeln(format("<option value=%s>%s"
,file_area.lib_list[l].dir_list[d].link
,file_area.lib_list[l].dir_list[d].name));
}
writeln("</optgroup>");
}
writeln("</select>");
writeln("</form>");
writeln("</table>");
var prevdir;
var hdr_font="<font color=silver>";
var dat_font="<font color=#CCCCCC>";
if(!(user.security.restrictions&UFLAG_G)) { /* !Guest or Anonymous */
if(system.matchuser("Guest")) {
/* Logout button */
writeln("<table align=right>");
writeln("<form>");
writeln("<input type=button value=Logout onclick='location=\"ftp://"
+ format("%s/%s%s",system.host_name + port,html_index_file,time_stamp_only)
+ "\";'>");
writeln("</form>");
writeln("</table><br /><br />");
}
writeln("<table nowrap class=\"ftp_stats\"><tr><td>");
/* User Info */
writeln("<table nowrap align=left>");
writeln("<tr><th class=\"ftp_stats\" align=right>" + hdr_font
+ "User:<th class=\"ftp_stats\" align=left>" +dat_font+ user.alias);
writeln("<tr><th class=\"ftp_stats\" align=right>"+ hdr_font
+ "Address:<th class=\"ftp_stats\" align=left width=150>"+dat_font+user.ip_address);
write("<tr><th class=\"ftp_stats\" align=right>" + hdr_font
+ "Credits:<th class=\"ftp_stats\" align=left>"+dat_font);
if(user.security.exemptions&UFLAG_D)
writeln("Exempt");
else
writeln(kbytes(user.security.credits+user.security.free_credits));
write("<tr><th class=\"ftp_stats\" align=right>" + hdr_font
+ "Time left:<th class=\"ftp_stats\" align=left>"+dat_font);
if(user.security.exemptions&UFLAG_T)
writeln("Exempt");
else
writeln(secstr(ftp.time_left));
writeln("</table>");
/* User Stats */
writeln("<table nowrap>");
writeln("<tr><th class=\"ftp_stats\" align=right>" + hdr_font
+ "Logons:<th class=\"ftp_stats\" align=left>" + dat_font + user.stats.total_logons);
writeln("<tr><th class=\"ftp_stats\" align=right>" + hdr_font
+ "Last on:<th class=\"ftp_stats\" align=left>"+ dat_font
+ strftime("%B %d, %Y, %H:%M" ,user.stats.laston_date));
writeln("<tr><th class=\"ftp_stats\" align=right>" + hdr_font
+ "Uploaded:<th class=\"ftp_stats\" align=left>"+dat_font);
writeln(format("%s bytes in %u files"
,kbytes(user.stats.bytes_uploaded),user.stats.files_uploaded));
writeln("<tr><th class=\"ftp_stats\" align=right>" + hdr_font
+ "Downloaded:<th class=\"ftp_stats\" align=left>"+dat_font);
writeln(format("%s bytes in %u files",kbytes(user.stats.bytes_downloaded)
,user.stats.files_downloaded));
writeln("</table>");
writeln("</tr></td></table>");
writeln("<br>");
} else if(ftp.curlib.name==undefined) { /* Login */
writeln("<table align=right>");
writeln("<td><input type=button value='New User' onClick='location=\"telnet://"
+ system.host_name + port + "\";'>");
writeln("</table>");
writeln("<form name='login'>");
writeln("<table border=1 frame=box 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=10 maxlength=25>");
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%%3F%s'\r\n"
,system.host_name + port,html_index_file,new_time_stamp));
// writeln("alert(url);");
writeln("location = url;");
writeln("}");
writeln("// -->");
writeln("</script>");
writeln("</table>");
writeln("</form>");
}
/* Virtual Path */
writeln('<table align="center" width="100%" border="0" cellspacing="0" cellpadding="0">');
writeln('<tr>');
writeln('<td style="background-image: url(http://' + format("%s:%u",system.host_name, http_port) + '/images/default/tnav_bg.gif); background-repeat: repeat-x; text-align: left;" width="1%"><img src="http://' + format("%s:%u"
,system.host_name
,http_port)
+ '/images/default/tnav_left.gif" width="5" height="32" alt="" /></td>');
writeln('<td style="background-image: url(http://'
+ format("%s:%u",system.host_name, http_port)
+ '/images/default/tnav_bg.gif); background-repeat: repeat-x;">');
if(ftp.curlib.name==undefined)
writeln('<span class="tlink">FTP Server Root</span>');
else
writeln('<a class="tlink" href="' + format("/%s%s",html_index_file,time_stamp_only)
+ '">FTP Server Root</a>');
if(ftp.curlib.name!=undefined) {
if(ftp.curdir.name==undefined)
writeln('<span class="tlink">' + ftp.curlib.description + '</span>');
else
writeln('<a class="tlink" href="' + format("/%s/%s%s",ftp.curlib.name,html_index_file,time_stamp_only) + '">'
+ ftp.curlib.description + '</a>');
}
if(ftp.curdir.name!=undefined)
writeln('<span class="tlink">' + ftp.curdir.description + '</span>');
if(ftp.curdir.settings!=undefined && ftp.curdir.settings&DIR_FREE)
write(" - FREE");
writeln('</td>');
writeln('<td style="background-image: url(http://' + format("%s:%u",system.host_name, http_port) + '/images/default/tnav_bg.gif); background-repeat: repeat-x; text-align: right;" width="1%"><img src="http://' + format("%s:%u",system.host_name, http_port)
+ '/images/default/tnav_right.gif" width="5" height="32" alt="" /></td>');
writeln('</tr>');
writeln('</table>');
writeln('<br />');
/* Directory Listing */
if(ftp.dir_list.length) {
writeln('<table class="ftp_dirlist" cellspacing="2" width="33%">');
/* header */
writeln("<thead>");
writeln('<tr class="ftp_dirlist_hdr">');
writeln('<th class="ftp_dirlist_hdr">Directory</th>');
if(ftp.curlib.name!=undefined)
writeln('<th class="ftp_dirlist_hdr">Files</th>');
writeln("</thead>");
/* body */
writeln("<tbody>");
for(i in ftp.dir_list) {
writeln("<tr>");
/* filename */
writeln('<th class="ftp_dirlist" nowrap align="left"><a class="ftp_dirlist" href="'
+ ftp.dir_list[i].link + time_stamp_only + '">' + ftp.dir_list[i].description + '</a></th>');
if(ftp.curlib.name!=undefined) {
writeln('<td class="ftp_dirlist" align="right">' + ftp.dir_list[i].size);
writeln((ftp.dir_list[i].settings&DIR_FREE ? "FREE</th>":"</th>"));
}
}
writeln('</tr><tr><th class="ftp_dirlist_hdr">&nbsp;</th>');
if(ftp.curlib.name!=undefined)
writeln('<th class="ftp_dirlist_hdr_rt">-</th></tr></tbody></table>');
else
writeln('</table>');
if(ftp.file_list.length)
writeln("<br>");
}
/* File Listing */
if(ftp.file_list.length) {
/* Sort the list? */
switch(ftp.sort) {
case "uploader":
ftp.file_list.sort(function(a,b)
{ if(a.uploader>b.uploader)
return(1);
if(a.uploader<b.uploader)
return(-1);
return(0); }
);
break;
case "size":
ftp.file_list.sort(function(a,b)
{ return(a.size-b.size); }
);
break;
case "credits":
ftp.file_list.sort(function(a,b)
{ return(a.credits-b.credits); }
);
break;
case "time":
ftp.file_list.sort(function(a,b)
{ return(a.time.valueOf()-b.time.valueOf()); }
);
break;
case "hits":
ftp.file_list.sort(function(a,b)
{ return(a.times_downloaded-b.times_downloaded); }
);
break;
}
if(ftp.reverse)
ftp.file_list.reverse();
var show_ext_desc; /* show extended descriptions */
var total_bytes=0;
var total_downloads=0;
var most_recent=0;
if (ftp.curdir.name==undefined)
show_ext_desc=false; /* aliased files have no ext desc */
else
show_ext_desc=ftp.extended_descriptions;
writeln('<table class="ftp_dirlist" cellspacing="2" width="100%">');
/* header */
writeln("<thead>");
writeln('<tr>');
/* File */
writeln(format('<th class="ftp_dirlist_hdr"><a class="ftp_dirlist_hdr" href=%s%%3Fsort=name%s%s>File</a>'
,html_index_file
,(ftp.sort=="name" && !ftp.reverse) ? '&reverse':'', time_stamp) + '</th>');
/* Credits or Size */
if(ftp.curdir.settings!=undefined && !(ftp.curdir.settings&DIR_FREE))
writeln(format('<th class="ftp_dirlist_hdr"><a class="ftp_dirlist_hdr" href=%s%%3Fsort=credits%s%s>Credits</a>'
,html_index_file
,(ftp.sort=="credits" && !ftp.reverse) ? '&reverse' : '', time_stamp) + '</th>');
else
writeln(format('<th class="ftp_dirlist_hdr"><a class="ftp_dirlist_hdr" href=%s%%3Fsort=size%s%s>Size</a>'
,html_index_file
,(ftp.sort=="size" && !ftp.reverse) ? '&reverse' : '', time_stamp) + '</th>');
/* Description */
write('<th class="ftp_dirlist_hdr">Description');
if(ftp.extended_descriptions)
writeln(' [<a class="ftp_dirlist_hdr" href="'
+ format("%s%%3Fext=off%s",html_index_file, time_stamp) + '">short</a>]</th>');
else
writeln(' [<a class="ftp_dirlist_hdr" href="'
+ format("%s%%3Fext=on%s",html_index_file, time_stamp) + '">extended</a>]</th>');
/* Date/Time */
writeln(format('<th class="ftp_dirlist_hdr"><a class="ftp_dirlist_hdr" href=%s%%3Fsort=time%s%s>Date/Time</a>'
,html_index_file
,(ftp.sort=="time" && !ftp.reverse) ? '&reverse' : '', time_stamp) + '</th>');
/* Uploader and Hits (downloads) */
if(ftp.curdir.name!=undefined) { /* not valid for aliased files in root */
writeln(format('<th class="ftp_dirlist_hdr"><a class="ftp_dirlist_hdr" href=%s%%3Fsort=uploader%s%s>Uploader</a>'
,html_index_file
,(ftp.sort=="uploader" && !ftp.reverse) ? '&reverse' : '', time_stamp) + '</th>');
writeln(format('<th class="ftp_dirlist_hdr"><a class="ftp_dirlist_hdr" href=%s%%3Fsort=hits%s%s>Hits</a>'
,html_index_file
,(ftp.sort=="hits" && !ftp.reverse) ? '&reverse' : '', time_stamp) + '</th>');
}
writeln("</thead>");
/* body */
writeln("<tbody>");
for(i in ftp.file_list) {
total_downloads+=ftp.file_list[i].times_downloaded;
if(ftp.file_list[i].time>most_recent)
most_recent=ftp.file_list[i].time;
writeln("<tr valign=top>");
/* filename */
if(user.security.restrictions&UFLAG_D
|| (ftp.curdir.settings!=undefined
&& !(ftp.curdir.settings&DIR_FREE)
&& !(user.security.exemptions&UFLAG_D)
&& ftp.file_list[i].credits > (user.security.credits+user.security.free_credits))
) {
write('<td class="ftp_dirlist" align="left">');
writeln('<a class="ftp_dirlist" href="javascript:alert(\"Sorry, you do not have enough credits to download this file.\"); ">'
+ ftp.file_list[i].name + '</a><td>');
} else {
write('<th class="ftp_dirlist" align=left>');
writeln('<a class="ftp_dirlist" href="' + ftp.file_list[i].link + '">'
+ ftp.file_list[i].name + "</a></th>");
}
/* size */
write('<td class="ftp_dirlist" align="right">');
if(ftp.curdir.settings!=undefined && !(ftp.curdir.settings&DIR_FREE)) {
if(!ftp.file_list[i].credits)
writeln('FREE</td>');
else
writeln(kbytes(ftp.file_list[i].credits)+ "</td>");
total_bytes+=ftp.file_list[i].credits;
} else {
writeln(kbytes(ftp.file_list[i].size) + "</td>");
total_bytes+=ftp.file_list[i].size;
}
/* description */
write("<td>");
if (show_ext_desc) {
if(ftp.file_list[i].settings&FILE_EXTDESC)
writeln("<pre class=\"ftp_desc\">" + ftp.file_list[i].extended_description + "</pre></td>");
else
writeln("<tt class=\"ftp_dirlist\">" + ftp.file_list[i].description + "</tt></td>");
} else
writeln(ftp.file_list[i].description + "</td>");
/* date/time */
writeln('<td align="left" class="ftp_dirlist" nowrap="nowrap">'
+ strftime("%b %d, %Y %H:%M" ,ftp.file_list[i].time) + "</td>");
if(ftp.curdir.name!=undefined) { /* not valid for aliased files in root */
/* uploader */
var uploader=ftp.file_list[i].uploader;
if(ftp.file_list[i].settings&FILE_ANON)
uploader="Anonymous";
else {
if(uploader == "-> ADDFILES <-")
uploader=system.operator;
if(!(user.security.restrictions&UFLAG_G)) /* ! Guest/Anonymous */
uploader=uploader.link("mailto:" + uploader + "@" + system.inetaddr);
}
writeln('<td class="ftp_dirlist" nowrap="nowrap">' + uploader + '</td>');
/* download count */
writeln('<td class="ftp_dirlist" align=right>'
+ ftp.file_list[i].times_downloaded + '</td>');
}
}
/* Footer (with totals) */
writeln("<tfoot>");
writeln(format('<tr><th class="ftp_dirlist_ftr">%lu files</th><th class="ftp_dirlist_ftr" align="right">%s</th><th class="ftp_dirlist_ftr">-</th><th class="ftp_dirlist_ftr">%s'
,ftp.file_list.length
,kbytes(total_bytes)
,strftime("%b %d, %Y %H:%M" ,most_recent)
));
if(ftp.curdir.name!=undefined) /* not valid for aliased files in root */
writeln(format('<th class="ftp_dirlist_ftr">-</th><th class="ftp_dirlist_ftr" align=right>%lu'
,total_downloads
) + '</th>');
writeln('</tr></tfoot></table>');
}
if(!ftp.file_list.length && !ftp.dir_list.length)
writeln("<br><b>No Files.</b><br>");
/* Footer */
write(format('<div class="ftp_ftr"><br>Problems? Ask '));
write(format("<a href=mailto:sysop@%s>%s</a>.",system.inetaddr,system.operator));
write(format("<br>Dynamically generated "));
write(format("in %lu milliseconds ", new Date().valueOf()-start.valueOf()));
write("by <a href=http://www.synchro.net>" + server.version + "</a>");
writeln("<br>" + Date() + "</font>");
writeln('</div></td></tr></table><br>');
writeln("</body>");
writeln("</html>");
/* End of ftp-html.js */
/* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */ /* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */
/* $Id: FtpCfgDlgUnit.cpp,v 1.13 2016/05/27 08:55:02 rswindell Exp $ */
/**************************************************************************** /****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
...@@ -15,21 +13,9 @@ ...@@ -15,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or * * See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html * * http://www.fsf.org/copyleft/gpl.html *
* * * *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see * * For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html * * http://www.synchro.net/source.html *
* * * *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. * * Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/ ****************************************************************************/
...@@ -85,8 +71,6 @@ void __fastcall TFtpCfgDlg::FormShow(TObject *Sender) ...@@ -85,8 +71,6 @@ void __fastcall TFtpCfgDlg::FormShow(TObject *Sender)
PasvPortHighEdit->Text=AnsiString((int)MainForm->ftp_startup.pasv_port_high); PasvPortHighEdit->Text=AnsiString((int)MainForm->ftp_startup.pasv_port_high);
IndexFileNameEdit->Text=AnsiString(MainForm->ftp_startup.index_file_name); IndexFileNameEdit->Text=AnsiString(MainForm->ftp_startup.index_file_name);
HtmlFileNameEdit->Text=AnsiString(MainForm->ftp_startup.html_index_file);
HtmlJavaScriptEdit->Text=AnsiString(MainForm->ftp_startup.html_index_script);
AnswerSoundEdit->Text=AnsiString(MainForm->ftp_startup.answer_sound); AnswerSoundEdit->Text=AnsiString(MainForm->ftp_startup.answer_sound);
HangupSoundEdit->Text=AnsiString(MainForm->ftp_startup.hangup_sound); HangupSoundEdit->Text=AnsiString(MainForm->ftp_startup.hangup_sound);
HackAttemptSoundEdit->Text=AnsiString(MainForm->ftp_startup.hack_sound); HackAttemptSoundEdit->Text=AnsiString(MainForm->ftp_startup.hack_sound);
...@@ -102,9 +86,6 @@ void __fastcall TFtpCfgDlg::FormShow(TObject *Sender) ...@@ -102,9 +86,6 @@ void __fastcall TFtpCfgDlg::FormShow(TObject *Sender)
=!(MainForm->ftp_startup.options&FTP_OPT_NO_HOST_LOOKUP); =!(MainForm->ftp_startup.options&FTP_OPT_NO_HOST_LOOKUP);
AutoIndexCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_INDEX_FILE; AutoIndexCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_INDEX_FILE;
AutoIndexCheckBoxClick(Sender); AutoIndexCheckBoxClick(Sender);
HtmlIndexCheckBox->Checked
=MainForm->ftp_startup.options&FTP_OPT_HTML_INDEX_FILE;
HtmlIndexCheckBoxClick(Sender);
PasvIpLookupCheckBoxClick(Sender); PasvIpLookupCheckBoxClick(Sender);
PageControl->ActivePage=GeneralTabSheet; PageControl->ActivePage=GeneralTabSheet;
...@@ -149,10 +130,6 @@ void __fastcall TFtpCfgDlg::OKBtnClick(TObject *Sender) ...@@ -149,10 +130,6 @@ void __fastcall TFtpCfgDlg::OKBtnClick(TObject *Sender)
SAFECOPY(MainForm->ftp_startup.index_file_name SAFECOPY(MainForm->ftp_startup.index_file_name
,IndexFileNameEdit->Text.c_str()); ,IndexFileNameEdit->Text.c_str());
SAFECOPY(MainForm->ftp_startup.html_index_file
,HtmlFileNameEdit->Text.c_str());
SAFECOPY(MainForm->ftp_startup.html_index_script
,HtmlJavaScriptEdit->Text.c_str());
SAFECOPY(MainForm->ftp_startup.answer_sound SAFECOPY(MainForm->ftp_startup.answer_sound
,AnswerSoundEdit->Text.c_str()); ,AnswerSoundEdit->Text.c_str());
...@@ -193,10 +170,6 @@ void __fastcall TFtpCfgDlg::OKBtnClick(TObject *Sender) ...@@ -193,10 +170,6 @@ void __fastcall TFtpCfgDlg::OKBtnClick(TObject *Sender)
MainForm->ftp_startup.options|=FTP_OPT_INDEX_FILE; MainForm->ftp_startup.options|=FTP_OPT_INDEX_FILE;
else else
MainForm->ftp_startup.options&=~FTP_OPT_INDEX_FILE; MainForm->ftp_startup.options&=~FTP_OPT_INDEX_FILE;
if(HtmlIndexCheckBox->Checked==true)
MainForm->ftp_startup.options|=FTP_OPT_HTML_INDEX_FILE;
else
MainForm->ftp_startup.options&=~FTP_OPT_HTML_INDEX_FILE;
if(PasvIpLookupCheckBox->Checked==true) if(PasvIpLookupCheckBox->Checked==true)
MainForm->ftp_startup.options|=FTP_OPT_LOOKUP_PASV_IP; MainForm->ftp_startup.options|=FTP_OPT_LOOKUP_PASV_IP;
else else
...@@ -241,24 +214,6 @@ void __fastcall TFtpCfgDlg::AutoIndexCheckBoxClick(TObject *Sender) ...@@ -241,24 +214,6 @@ void __fastcall TFtpCfgDlg::AutoIndexCheckBoxClick(TObject *Sender)
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TFtpCfgDlg::HtmlJavaScriptButtonClick(TObject *Sender)
{
OpenDialog->FileName=HtmlJavaScriptEdit->Text;
if(OpenDialog->Execute()==true) {
HtmlJavaScriptEdit->Text=OpenDialog->FileName;
}
}
//---------------------------------------------------------------------------
void __fastcall TFtpCfgDlg::HtmlIndexCheckBoxClick(TObject *Sender)
{
HtmlFileNameEdit->Enabled=HtmlIndexCheckBox->Checked;
HtmlJavaScriptEdit->Enabled=HtmlIndexCheckBox->Checked;
HtmlJavaScriptLabel->Enabled=HtmlIndexCheckBox->Checked;
}
//---------------------------------------------------------------------------
void __fastcall TFtpCfgDlg::PasvIpLookupCheckBoxClick(TObject *Sender) void __fastcall TFtpCfgDlg::PasvIpLookupCheckBoxClick(TObject *Sender)
{ {
PasvIPv4AddrEdit->Enabled = !PasvIpLookupCheckBox->Checked; PasvIPv4AddrEdit->Enabled = !PasvIpLookupCheckBox->Checked;
......
...@@ -255,14 +255,6 @@ object FtpCfgDlg: TFtpCfgDlg ...@@ -255,14 +255,6 @@ object FtpCfgDlg: TFtpCfgDlg
object IndexTabSheet: TTabSheet object IndexTabSheet: TTabSheet
Caption = 'Index' Caption = 'Index'
ImageIndex = 3 ImageIndex = 3
object HtmlJavaScriptLabel: TLabel
Left = 7
Top = 62
Width = 65
Height = 20
AutoSize = False
Caption = 'JavaScript'
end
object AutoIndexCheckBox: TCheckBox object AutoIndexCheckBox: TCheckBox
Left = 7 Left = 7
Top = 10 Top = 10
...@@ -285,38 +277,6 @@ object FtpCfgDlg: TFtpCfgDlg ...@@ -285,38 +277,6 @@ object FtpCfgDlg: TFtpCfgDlg
ShowHint = True ShowHint = True
TabOrder = 1 TabOrder = 1
end end
object HtmlIndexCheckBox: TCheckBox
Left = 7
Top = 36
Width = 78
Height = 19
Hint = 'Automatically generate HTML index files for file descriptions'
Caption = 'HTML'
ParentShowHint = False
ShowHint = True
TabOrder = 2
OnClick = HtmlIndexCheckBoxClick
end
object HtmlFileNameEdit: TEdit
Left = 85
Top = 36
Width = 156
Height = 21
Hint = 'Name of HTML index file (default=00index.html)'
ParentShowHint = False
ShowHint = True
TabOrder = 3
end
object HtmlJavaScriptEdit: TEdit
Left = 85
Top = 62
Width = 156
Height = 21
Hint = 'JavaScript filename to execute to generate HTML index file'
ParentShowHint = False
ShowHint = True
TabOrder = 4
end
end end
object LogTabSheet: TTabSheet object LogTabSheet: TTabSheet
Caption = 'Log' Caption = 'Log'
......
/* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */ /* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */
/* $Id: FtpCfgDlgUnit.h,v 1.8 2018/07/24 01:11:28 rswindell Exp $ */
/**************************************************************************** /****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
...@@ -15,21 +13,9 @@ ...@@ -15,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or * * See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html * * http://www.fsf.org/copyleft/gpl.html *
* * * *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see * * For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html * * http://www.synchro.net/source.html *
* * * *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. * * Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/ ****************************************************************************/
...@@ -87,10 +73,6 @@ __published: ...@@ -87,10 +73,6 @@ __published:
TTabSheet *IndexTabSheet; TTabSheet *IndexTabSheet;
TCheckBox *AutoIndexCheckBox; TCheckBox *AutoIndexCheckBox;
TEdit *IndexFileNameEdit; TEdit *IndexFileNameEdit;
TCheckBox *HtmlIndexCheckBox;
TEdit *HtmlFileNameEdit;
TLabel *HtmlJavaScriptLabel;
TEdit *HtmlJavaScriptEdit;
TLabel *QwkTimeoutLabel; TLabel *QwkTimeoutLabel;
TEdit *QwkTimeoutEdit; TEdit *QwkTimeoutEdit;
TLabel *HackAttemptSoundLabel; TLabel *HackAttemptSoundLabel;
...@@ -109,8 +91,6 @@ __published: ...@@ -109,8 +91,6 @@ __published:
void __fastcall AnswerSoundButtonClick(TObject *Sender); void __fastcall AnswerSoundButtonClick(TObject *Sender);
void __fastcall HangupSoundButtonClick(TObject *Sender); void __fastcall HangupSoundButtonClick(TObject *Sender);
void __fastcall AutoIndexCheckBoxClick(TObject *Sender); void __fastcall AutoIndexCheckBoxClick(TObject *Sender);
void __fastcall HtmlJavaScriptButtonClick(TObject *Sender);
void __fastcall HtmlIndexCheckBoxClick(TObject *Sender);
void __fastcall HackAttemptSoundButtonClick(TObject *Sender); void __fastcall HackAttemptSoundButtonClick(TObject *Sender);
void __fastcall PasvIpLookupCheckBoxClick(TObject *Sender); void __fastcall PasvIpLookupCheckBoxClick(TObject *Sender);
private: private:
......
...@@ -866,11 +866,9 @@ __fastcall TMainForm::TMainForm(TComponent* Owner) ...@@ -866,11 +866,9 @@ __fastcall TMainForm::TMainForm(TComponent* Owner)
ftp_startup.client_on=client_on; ftp_startup.client_on=client_on;
ftp_startup.socket_open=socket_open; ftp_startup.socket_open=socket_open;
ftp_startup.options ftp_startup.options
=FTP_OPT_INDEX_FILE|FTP_OPT_HTML_INDEX_FILE|FTP_OPT_ALLOW_QWK; =FTP_OPT_INDEX_FILE | FTP_OPT_ALLOW_QWK;
ftp_startup.max_clients=10; ftp_startup.max_clients=10;
strcpy(ftp_startup.index_file_name,"00index"); strcpy(ftp_startup.index_file_name,"00index");
strcpy(ftp_startup.html_index_file,"00index.html");
strcpy(ftp_startup.html_index_script,"ftp-html.js");
ftp_startup.login_attempt_list=&login_attempt_list; ftp_startup.login_attempt_list=&login_attempt_list;
memset(&web_startup,0,sizeof(web_startup)); memset(&web_startup,0,sizeof(web_startup));
...@@ -3038,7 +3036,6 @@ void __fastcall TMainForm::PropertiesExecute(TObject *Sender) ...@@ -3038,7 +3036,6 @@ void __fastcall TMainForm::PropertiesExecute(TObject *Sender)
/* Copy global settings, if appropriate (not unique) */ /* Copy global settings, if appropriate (not unique) */
if(memcmp(&bbs_startup.js,&js,sizeof(js))==0) bbs_startup.js=global.js; if(memcmp(&bbs_startup.js,&js,sizeof(js))==0) bbs_startup.js=global.js;
if(memcmp(&ftp_startup.js,&js,sizeof(js))==0) ftp_startup.js=global.js;
if(memcmp(&web_startup.js,&js,sizeof(js))==0) web_startup.js=global.js; if(memcmp(&web_startup.js,&js,sizeof(js))==0) web_startup.js=global.js;
if(memcmp(&mail_startup.js,&js,sizeof(js))==0) mail_startup.js=global.js; if(memcmp(&mail_startup.js,&js,sizeof(js))==0) mail_startup.js=global.js;
if(memcmp(&services_startup.js,&js,sizeof(js))==0) services_startup.js=global.js; if(memcmp(&services_startup.js,&js,sizeof(js))==0) services_startup.js=global.js;
......
...@@ -36,8 +36,6 @@ ...@@ -36,8 +36,6 @@
#include "text.h" /* TOTAL_TEXT */ #include "text.h" /* TOTAL_TEXT */
#include "ftpsrvr.h" #include "ftpsrvr.h"
#include "telnet.h" #include "telnet.h"
#include "js_rtpool.h"
#include "js_request.h"
#include "multisock.h" #include "multisock.h"
#include "ssl.h" #include "ssl.h"
#include "cryptlib.h" #include "cryptlib.h"
...@@ -433,692 +431,6 @@ int getdir(char* p, user_t* user, client_t* client) ...@@ -433,692 +431,6 @@ int getdir(char* p, user_t* user, client_t* client)
return(dir); return(dir);
} }
/*********************************/
/* JavaScript Data and Functions */
/*********************************/
#ifdef JAVASCRIPT
js_server_props_t js_server_props;
static JSBool
js_write(JSContext *cx, uintN argc, jsval *arglist)
{
jsval *argv=JS_ARGV(cx, arglist);
uintN i;
JSString* str=NULL;
FILE* fp;
jsrefcount rc;
char *p = NULL;
size_t len;
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((fp=(FILE*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
for (i = 0; i < argc; i++) {
str = JS_ValueToString(cx, argv[i]);
if (!str)
return JS_FALSE;
JSSTRING_TO_MSTRING(cx, str, p, &len);
HANDLE_PENDING(cx, p);
rc=JS_SUSPENDREQUEST(cx);
if(p) {
fwrite(p, len, 1, fp);
free(p);
}
JS_RESUMEREQUEST(cx, rc);
}
if(str==NULL)
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
else
JS_SET_RVAL(cx, arglist, STRING_TO_JSVAL(str));
return(JS_TRUE);
}
static JSBool
js_writeln(JSContext *cx, uintN argc, jsval *arglist)
{
FILE* fp;
jsrefcount rc;
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((fp=(FILE*)JS_GetContextPrivate(cx))==NULL)
return(JS_FALSE);
js_write(cx,argc,arglist);
rc=JS_SUSPENDREQUEST(cx);
fprintf(fp,"\r\n");
JS_RESUMEREQUEST(cx, rc);
return(JS_TRUE);
}
static JSFunctionSpec js_global_functions[] = {
{"write", js_write, 1}, /* write to HTML file */
{"writeln", js_writeln, 1}, /* write to HTML file */
{"print", js_writeln, 1}, /* alias for writeln */
{0}
};
static void
js_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
{
char line[64];
char file[MAX_PATH+1];
char* warning;
FILE* fp;
int log_level;
fp=(FILE*)JS_GetContextPrivate(cx);
if(report==NULL) {
lprintf(LOG_ERR,"!JavaScript: %s", message);
if(fp!=NULL)
fprintf(fp,"!JavaScript: %s", message);
return;
}
if(report->filename)
sprintf(file," %s",report->filename);
else
file[0]=0;
if(report->lineno)
sprintf(line," line %u",report->lineno);
else
line[0]=0;
if(JSREPORT_IS_WARNING(report->flags)) {
if(JSREPORT_IS_STRICT(report->flags))
warning="strict warning";
else
warning="warning";
log_level=LOG_WARNING;
} else {
log_level=LOG_ERR;
warning="";
}
lprintf(log_level,"!JavaScript %s%s%s: %s",warning,file,line,message);
if(fp!=NULL)
fprintf(fp,"!JavaScript %s%s%s: %s",warning,file,line,message);
}
static JSContext*
js_initcx(JSRuntime* runtime, SOCKET sock, JSObject** glob, JSObject** ftp, js_callback_t* cb)
{
JSContext* js_cx;
BOOL success=FALSE;
BOOL rooted=FALSE;
if((js_cx = JS_NewContext(runtime, JAVASCRIPT_CONTEXT_STACK))==NULL)
return(NULL);
JS_BEGINREQUEST(js_cx);
lprintf(LOG_DEBUG,"%04d JavaScript: Context created",sock);
JS_SetErrorReporter(js_cx, js_ErrorReporter);
memset(cb, 0, sizeof(js_callback_t));
/* ToDo: call js_CreateCommonObjects() instead */
do {
lprintf(LOG_DEBUG,"%04d JavaScript: Initializing Global object",sock);
if(!js_CreateGlobalObject(js_cx, &scfg, NULL, &startup->js, glob))
break;
rooted=TRUE;
if(!JS_DefineFunctions(js_cx, *glob, js_global_functions))
break;
/* Internal JS Object */
if(js_CreateInternalJsObject(js_cx, *glob, cb, &startup->js)==NULL)
break;
lprintf(LOG_DEBUG,"%04d JavaScript: Initializing System object",sock);
if(js_CreateSystemObject(js_cx, *glob, &scfg, uptime, server_host_name(), SOCKLIB_DESC)==NULL)
break;
if((*ftp=JS_DefineObject(js_cx, *glob, "ftp", NULL
,NULL,JSPROP_ENUMERATE|JSPROP_READONLY))==NULL)
break;
if(js_CreateServerObject(js_cx,*glob,&js_server_props)==NULL)
break;
success=TRUE;
} while(0);
if(!success) {
if(rooted)
JS_RemoveObjectRoot(js_cx, glob);
JS_ENDREQUEST(js_cx);
JS_DestroyContext(js_cx);
return(NULL);
}
return(js_cx);
}
BOOL js_add_file(JSContext* js_cx, JSObject* array,
char* name, char* desc, char* ext_desc,
off_t size, ulong credits,
time_t time, time_t uploaded, time_t last_downloaded,
ulong times_downloaded, ulong misc,
char* uploader, char* link)
{
JSObject* file;
JSString* js_str;
jsval val;
jsuint index;
if(uploaded == 0)
uploaded = time;
if((file=JS_NewObject(js_cx, NULL, NULL, NULL))==NULL)
return(FALSE);
if((js_str=JS_NewStringCopyZ(js_cx, name))==NULL)
return(FALSE);
val=STRING_TO_JSVAL(js_str);
if(!JS_SetProperty(js_cx, file, "name", &val))
return(FALSE);
if((js_str=JS_NewStringCopyZ(js_cx, desc))==NULL)
return(FALSE);
val=STRING_TO_JSVAL(js_str);
if(!JS_SetProperty(js_cx, file, "description", &val))
return(FALSE);
if((js_str=JS_NewStringCopyZ(js_cx, ext_desc))==NULL)
return(FALSE);
val=STRING_TO_JSVAL(js_str);
if(!JS_SetProperty(js_cx, file, "extended_description", &val))
return(FALSE);
val=INT_TO_JSVAL(size);
if(!JS_SetProperty(js_cx, file, "size", &val))
return(FALSE);
val=INT_TO_JSVAL(credits);
if(!JS_SetProperty(js_cx, file, "credits", &val))
return(FALSE);
val=DOUBLE_TO_JSVAL((double)time);
if(!JS_SetProperty(js_cx, file, "time", &val))
return(FALSE);
val=INT_TO_JSVAL((int32)uploaded);
if(!JS_SetProperty(js_cx, file, "uploaded", &val))
return(FALSE);
val=INT_TO_JSVAL((int32)last_downloaded);
if(!JS_SetProperty(js_cx, file, "last_downloaded", &val))
return(FALSE);
val=INT_TO_JSVAL(times_downloaded);
if(!JS_SetProperty(js_cx, file, "times_downloaded", &val))
return(FALSE);
if((js_str=JS_NewStringCopyZ(js_cx, uploader))==NULL)
return(FALSE);
val=STRING_TO_JSVAL(js_str);
if(!JS_SetProperty(js_cx, file, "uploader", &val))
return(FALSE);
val=INT_TO_JSVAL(misc);
if(!JS_SetProperty(js_cx, file, "settings", &val))
return(FALSE);
if((js_str=JS_NewStringCopyZ(js_cx, link))==NULL)
return(FALSE);
val=STRING_TO_JSVAL(js_str);
if(!JS_SetProperty(js_cx, file, "link", &val))
return(FALSE);
if(!JS_GetArrayLength(js_cx, array, &index))
return(FALSE);
val=OBJECT_TO_JSVAL(file);
return(JS_SetElement(js_cx, array, index, &val));
}
BOOL js_generate_index(JSContext* js_cx, JSObject* parent,
SOCKET sock, FILE* fp, int lib, int dir, user_t* user, client_t* client)
{
char str[256];
char path[MAX_PATH+1];
char spath[MAX_PATH+1]; /* script path */
char vpath[MAX_PATH+1]; /* virtual path */
char aliasfile[MAX_PATH+1];
char extdesc[513];
char* p;
char* tp;
char* np;
char* dp;
char aliasline[512];
BOOL alias_dir;
BOOL success=FALSE;
FILE* alias_fp;
uint i;
file_t f;
glob_t g;
jsval val;
jsval rval;
JSObject* lib_obj=NULL;
JSObject* dir_obj=NULL;
JSObject* file_array=NULL;
JSObject* dir_array=NULL;
JSObject* js_script=NULL;
JSString* js_str;
long double start=xp_timer();
jsrefcount rc;
lprintf(LOG_DEBUG,"%04d <%s> JavaScript: Generating HTML Index for %s"
,sock, user->alias, genvpath(lib,dir,str));
JS_SetContextPrivate(js_cx, fp);
do { /* pseudo try/catch */
if((file_array=JS_NewArrayObject(js_cx, 0, NULL))==NULL) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript FAILED to create file_array",sock, user->alias);
break;
}
/* file[] */
val=OBJECT_TO_JSVAL(file_array);
if(!JS_SetProperty(js_cx, parent, "file_list", &val)) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript FAILED to set file property",sock, user->alias);
break;
}
if((dir_array=JS_NewArrayObject(js_cx, 0, NULL))==NULL) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript FAILED to create dir_array",sock, user->alias);
break;
}
/* dir[] */
val=OBJECT_TO_JSVAL(dir_array);
if(!JS_SetProperty(js_cx, parent, "dir_list", &val)) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript FAILED to set dir property",sock, user->alias);
break;
}
rc=JS_SUSPENDREQUEST(js_cx);
if(strcspn(startup->html_index_script,"/\\")==strlen(startup->html_index_script)) {
sprintf(spath,"%s%s",scfg.mods_dir,startup->html_index_script);
if(scfg.mods_dir[0]==0 || !fexist(spath))
sprintf(spath,"%s%s",scfg.exec_dir,startup->html_index_script);
} else
sprintf(spath,"%.*s",(int)sizeof(spath)-4,startup->html_index_script);
/* Add extension if not specified */
if(!strchr(spath,'.'))
strcat(spath,".js");
if(!fexist(spath)) {
JS_RESUMEREQUEST(js_cx, rc);
lprintf(LOG_ERR,"%04d <%s> !HTML JavaScript (%s) doesn't exist",sock,user->alias, spath);
break;
}
JS_RESUMEREQUEST(js_cx, rc);
if((js_str=JS_NewStringCopyZ(js_cx, startup->html_index_file))==NULL)
break;
val=STRING_TO_JSVAL(js_str);
if(!JS_SetProperty(js_cx, parent, "html_index_file", &val)) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript FAILED to set html_index_file property",sock, user->alias);
break;
}
/* curlib */
if((lib_obj=JS_NewObject(js_cx, NULL, 0, NULL))==NULL) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript FAILED to create lib_obj",sock, user->alias);
break;
}
val=OBJECT_TO_JSVAL(lib_obj);
if(!JS_SetProperty(js_cx, parent, "curlib", &val)) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript FAILED to set curlib property",sock, user->alias);
break;
}
/* curdir */
if((dir_obj=JS_NewObject(js_cx, NULL, 0, NULL))==NULL) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript FAILED to create dir_obj",sock, user->alias);
break;
}
val=OBJECT_TO_JSVAL(dir_obj);
if(!JS_SetProperty(js_cx, parent, "curdir", &val)) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript FAILED to set curdir property",sock, user->alias);
break;
}
SAFECOPY(vpath,"/");
if(lib>=0) { /* root */
strcat(vpath,scfg.lib[lib]->sname);
strcat(vpath,"/");
if((js_str=JS_NewStringCopyZ(js_cx, scfg.lib[lib]->sname))==NULL)
break;
val=STRING_TO_JSVAL(js_str);
if(!JS_SetProperty(js_cx, lib_obj, "name", &val)) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript FAILED to set curlib.name property",sock, user->alias);
break;
}
if((js_str=JS_NewStringCopyZ(js_cx, scfg.lib[lib]->lname))==NULL)
break;
val=STRING_TO_JSVAL(js_str);
if(!JS_SetProperty(js_cx, lib_obj, "description", &val)) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript FAILED to set curlib.desc property",sock, user->alias);
break;
}
}
if(dir>=0) { /* 1st level */
strcat(vpath,scfg.dir[dir]->code_suffix);
strcat(vpath,"/");
if((js_str=JS_NewStringCopyZ(js_cx, scfg.dir[dir]->code))==NULL)
break;
val=STRING_TO_JSVAL(js_str);
if(!JS_SetProperty(js_cx, dir_obj, "code", &val)) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript FAILED to set curdir.code property",sock, user->alias);
break;
}
if((js_str=JS_NewStringCopyZ(js_cx, scfg.dir[dir]->sname))==NULL)
break;
val=STRING_TO_JSVAL(js_str);
if(!JS_SetProperty(js_cx, dir_obj, "name", &val)) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript FAILED to set curdir.name property",sock, user->alias);
break;
}
if((js_str=JS_NewStringCopyZ(js_cx, scfg.dir[dir]->lname))==NULL)
break;
val=STRING_TO_JSVAL(js_str);
if(!JS_SetProperty(js_cx, dir_obj, "description", &val)) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript FAILED to set curdir.desc property",sock, user->alias);
break;
}
val=INT_TO_JSVAL(scfg.dir[dir]->misc);
if(!JS_SetProperty(js_cx, dir_obj, "settings", &val)) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript FAILED to set curdir.misc property",sock, user->alias);
break;
}
}
if((js_str=JS_NewStringCopyZ(js_cx, vpath))==NULL)
break;
val=STRING_TO_JSVAL(js_str);
if(!JS_SetProperty(js_cx, parent, "path", &val)) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript FAILED to set curdir property",sock, user->alias);
break;
}
if(lib<0) { /* root dir */
rc=JS_SUSPENDREQUEST(js_cx);
/* File Aliases */
sprintf(path,"%sftpalias.cfg",scfg.ctrl_dir);
if((alias_fp=fopen(path,"r"))!=NULL) {
while(!feof(alias_fp)) {
if(!fgets(aliasline,sizeof(aliasline),alias_fp))
break;
p=aliasline; /* alias pointer */
SKIP_WHITESPACE(p);
if(*p==';') /* comment */
continue;
tp=p; /* terminator pointer */
FIND_WHITESPACE(tp);
if(*tp) *tp=0;
np=tp+1; /* filename pointer */
SKIP_WHITESPACE(np);
tp=np; /* terminator pointer */
FIND_WHITESPACE(tp);
if(*tp) *tp=0;
dp=tp+1; /* description pointer */
SKIP_WHITESPACE(dp);
truncsp(dp);
if(stricmp(dp,BBS_HIDDEN_ALIAS)==0)
continue;
alias_dir=FALSE;
/* Virtual Path? */
if(!strnicmp(np,BBS_VIRTUAL_PATH,strlen(BBS_VIRTUAL_PATH))) {
if((dir=getdir(np+strlen(BBS_VIRTUAL_PATH),user,client))<0)
continue; /* No access or invalid virtual path */
tp=strrchr(np,'/');
if(tp==NULL)
continue;
tp++;
if(*tp) {
SAFEPRINTF2(aliasfile,"%s%s",scfg.dir[dir]->path,tp);
np=aliasfile;
}
else
alias_dir=TRUE;
}
if(!alias_dir && !fexist(np))
continue;
if(alias_dir) {
if(!chk_ar(&scfg,scfg.dir[dir]->ar,user,client))
continue;
SAFEPRINTF2(vpath,"/%s/%s",p,startup->html_index_file);
} else
SAFECOPY(vpath,p);
JS_RESUMEREQUEST(js_cx, rc);
js_add_file(js_cx
,alias_dir ? dir_array : file_array
,p /* filename */
,dp /* description */
,NULL /* extdesc */
,flength(np) /* size */
,0 /* credits */
,fdate(np) /* time */
,0 /* uploaded */
,0 /* last downloaded */
,0 /* times downloaded */
,0 /* misc */
,scfg.sys_id /* uploader */
,vpath /* link */
);
rc=JS_SUSPENDREQUEST(js_cx);
}
fclose(alias_fp);
}
JS_RESUMEREQUEST(js_cx, rc);
/* QWK Packet */
if(startup->options&FTP_OPT_ALLOW_QWK /* && fexist(qwkfile) */) {
sprintf(str,"%s.qwk",scfg.sys_id);
SAFEPRINTF(vpath,"/%s",str);
js_add_file(js_cx
,file_array
,str /* filename */
,"QWK Message Packet" /* description */
,NULL /* extdesc */
,10240 /* size */
,0 /* credits */
,time(NULL) /* time */
,0 /* uploaded */
,0 /* last downloaded */
,0 /* times downloaded */
,0 /* misc */
,scfg.sys_id /* uploader */
,str /* link */
);
}
/* Library Folders */
for(i=0;i<scfg.total_libs;i++) {
if(!chk_ar(&scfg,scfg.lib[i]->ar,user,client))
continue;
SAFEPRINTF2(vpath,"/%s/%s",scfg.lib[i]->sname,startup->html_index_file);
js_add_file(js_cx
,dir_array
,scfg.lib[i]->sname /* filename */
,scfg.lib[i]->lname /* description */
,NULL /* extdesc */
,0,0,0,0,0,0,0 /* unused */
,scfg.sys_id /* uploader */
,vpath /* link */
);
}
} else if(dir<0) {
/* Directories */
for(i=0;i<scfg.total_dirs;i++) {
if(scfg.dir[i]->lib!=lib)
continue;
if(/* i!=scfg.sysop_dir && i!=scfg.upload_dir && */
!chk_ar(&scfg,scfg.dir[i]->ar,user,client))
continue;
SAFEPRINTF3(vpath,"/%s/%s/%s"
,scfg.lib[scfg.dir[i]->lib]->sname
,scfg.dir[i]->code_suffix
,startup->html_index_file);
js_add_file(js_cx
,dir_array
,scfg.dir[i]->sname /* filename */
,scfg.dir[i]->lname /* description */
,NULL /* extdesc */
,getfiles(&scfg,i) /* size */
,0,0,0,0,0 /* unused */
,scfg.dir[i]->misc /* misc */
,scfg.sys_id /* uploader */
,vpath /* link */
);
}
} else if(chk_ar(&scfg,scfg.dir[dir]->ar,user,client)){
SAFEPRINTF(path,"%s*",scfg.dir[dir]->path);
rc=JS_SUSPENDREQUEST(js_cx);
time_t start = time(NULL);
glob(path, GLOB_MARK, NULL, &g);
for(i=0;i<(int)g.gl_pathc;i++) {
if(*lastchar(g.gl_pathv[i]) == '/') /* is directory */
continue;
#ifdef _WIN32
GetShortPathName(g.gl_pathv[i], str, sizeof(str));
#else
SAFECOPY(str,g.gl_pathv[i]);
#endif
memset(&f, 0, sizeof(f));
padfname(getfname(str),f.name);
f.dir=dir;
BOOL filedat;
if((filedat=getfileixb(&scfg,&f))==FALSE
&& !(startup->options&FTP_OPT_DIR_FILES)
&& !(scfg.dir[dir]->misc&DIR_FILES))
continue;
if(filedat) {
if(!getfiledat(&scfg,&f))
continue;
} else {
f.size = f.cdt;
f.date = f.dateuled;
if(!filedat || (scfg.dir[dir]->misc&DIR_FCHK)) {
struct stat st;
if(stat(g.gl_pathv[i], &st) != 0)
continue;
f.cdt = st.st_size;
f.size = st.st_size;
f.date = (time32_t)st.st_mtime;
}
}
if(f.misc&FM_EXTDESC) {
extdesc[0]=0;
getextdesc(&scfg, dir, f.datoffset, extdesc);
/* Remove Ctrl-A Codes and Ex-ASCII code */
remove_ctrl_a(extdesc,extdesc);
}
SAFEPRINTF3(vpath,"/%s/%s/%s"
,scfg.lib[scfg.dir[dir]->lib]->sname
,scfg.dir[dir]->code_suffix
,getfname(g.gl_pathv[i]));
JS_RESUMEREQUEST(js_cx, rc);
js_add_file(js_cx
,file_array
,getfname(g.gl_pathv[i]) /* filename */
,f.desc /* description */
,f.misc&FM_EXTDESC ? extdesc : NULL
,f.size /* size */
,f.cdt /* credits */
,f.date /* time */
,f.dateuled /* uploaded */
,f.datedled /* last downloaded */
,f.timesdled /* times downloaded */
,f.misc /* misc */
,f.uler /* uploader */
,getfname(g.gl_pathv[i]) /* link */
);
rc=JS_SUSPENDREQUEST(js_cx);
}
lprintf(LOG_INFO, "%04d <%s> JavaScript array of /%s/%s (%lu files) created in %ld seconds"
,sock, user->alias, scfg.lib[lib]->sname, scfg.dir[dir]->code_suffix
,(ulong)g.gl_pathc,(long)time(NULL) - start);
globfree(&g);
JS_RESUMEREQUEST(js_cx, rc);
}
/* RUN SCRIPT */
JS_ClearPendingException(js_cx);
if((js_script=JS_CompileFile(js_cx, parent, spath))==NULL) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript FAILED to compile script (%s)",sock, user->alias, spath);
break;
}
js_PrepareToExecute(js_cx, parent, spath, /* startup_dir: */NULL, parent);
if((success=JS_ExecuteScript(js_cx, parent, js_script, &rval))!=TRUE) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript FAILED to execute script (%s)",sock, user->alias, spath);
break;
}
lprintf(LOG_DEBUG,"%04d <%s> JavaScript: Done executing script: %s (%.2Lf seconds)"
,sock, user->alias, spath, xp_timer()-start);
} while(0);
JS_DeleteProperty(js_cx, parent, "path");
JS_DeleteProperty(js_cx, parent, "sort");
JS_DeleteProperty(js_cx, parent, "reverse");
JS_DeleteProperty(js_cx, parent, "file_list");
JS_DeleteProperty(js_cx, parent, "dir_list");
JS_DeleteProperty(js_cx, parent, "curlib");
JS_DeleteProperty(js_cx, parent, "curdir");
JS_DeleteProperty(js_cx, parent, "html_index_file");
return(success);
}
#endif /* ifdef JAVASCRIPT */
void recverror(SOCKET socket, int rd, int line) void recverror(SOCKET socket, int rd, int line)
{ {
if(rd==0) if(rd==0)
...@@ -2934,7 +2246,6 @@ static void ctrl_thread(void* arg) ...@@ -2934,7 +2246,6 @@ static void ctrl_thread(void* arg)
char path[MAX_PATH+1]; char path[MAX_PATH+1];
char local_dir[MAX_PATH+1]; char local_dir[MAX_PATH+1];
char ren_from[MAX_PATH+1]=""; char ren_from[MAX_PATH+1]="";
char html_index_ext[MAX_PATH+1];
WORD port; WORD port;
uint32_t ip_addr; uint32_t ip_addr;
socklen_t addr_len; socklen_t addr_len;
...@@ -2997,15 +2308,6 @@ static void ctrl_thread(void* arg) ...@@ -2997,15 +2308,6 @@ static void ctrl_thread(void* arg)
client_t client; client_t client;
struct tm tm; struct tm tm;
struct tm cur_tm; struct tm cur_tm;
#ifdef JAVASCRIPT
jsval js_val;
JSRuntime* js_runtime=NULL;
JSContext* js_cx=NULL;
JSObject* js_glob;
JSObject* js_ftp;
JSString* js_str;
js_callback_t js_callback;
#endif
login_attempt_t attempted; login_attempt_t attempted;
CRYPT_SESSION sess = -1; CRYPT_SESSION sess = -1;
BOOL got_pbsz = FALSE; BOOL got_pbsz = FALSE;
...@@ -3374,27 +2676,6 @@ static void ctrl_thread(void* arg) ...@@ -3374,27 +2676,6 @@ static void ctrl_thread(void* arg)
timeleft=(long)gettimeleft(&scfg,&user,logintime); timeleft=(long)gettimeleft(&scfg,&user,logintime);
ftp_printfile(sock,sess,"hello",230); ftp_printfile(sock,sess,"hello",230);
#ifdef JAVASCRIPT
#ifdef JS_CX_PER_SESSION
if(js_cx!=NULL) {
if(js_CreateUserClass(js_cx, js_glob, &scfg)==NULL)
lprintf(LOG_ERR,"%04d !JavaScript ERROR creating user class",sock);
if(js_CreateUserObject(js_cx, js_glob, &scfg, "user", user.number, &client)==NULL)
lprintf(LOG_ERR,"%04d !JavaScript ERROR creating user object",sock);
if(js_CreateClientObject(js_cx, js_glob, "client", &client, sock, -1)==NULL)
lprintf(LOG_ERR,"%04d !JavaScript ERROR creating client object",sock);
if(js_CreateFileAreaObject(js_cx, js_glob, &scfg, &user
,startup->html_index_file)==NULL)
lprintf(LOG_ERR,"%04d !JavaScript ERROR creating file area object",sock);
}
#endif
#endif
if(sysop) if(sysop)
sockprintf(sock,sess,"230-Sysop access granted."); sockprintf(sock,sess,"230-Sysop access granted.");
sockprintf(sock,sess,"230-%s logged in.",user.alias); sockprintf(sock,sess,"230-%s logged in.",user.alias);
...@@ -4408,16 +3689,6 @@ static void ctrl_thread(void* arg) ...@@ -4408,16 +3689,6 @@ static void ctrl_thread(void* arg)
send_mlsx_entry(fp, sock, sess, mlsx_feats, "file", "r", UINT64_MAX, 0, str, NULL, 0, cmd[3] == 'T' ? mls_path : startup->index_file_name); send_mlsx_entry(fp, sock, sess, mlsx_feats, "file", "r", UINT64_MAX, 0, str, NULL, 0, cmd[3] == 'T' ? mls_path : startup->index_file_name);
l++; l++;
} }
/* HTML Index File */
if(startup->options&FTP_OPT_INDEX_FILE && startup->html_index_file[0]
&& (cmd[3] == 'D' || strcmp(startup->html_index_file, mls_fname) == 0)) {
if (cmd[3] == 'T')
sockprintf(sock,sess, "250- Listing %s", startup->html_index_file);
get_owner_name(NULL, str);
send_mlsx_entry(fp, sock, sess, mlsx_feats, "file", "r", UINT64_MAX, 0, str, NULL, 0, cmd[3] == 'T' ? mls_path : startup->html_index_file);
l++;
}
if(lib<0) { /* Root dir */ if(lib<0) { /* Root dir */
if (cmd[3] == 'T' && !*mls_fname) { if (cmd[3] == 'T' && !*mls_fname) {
sockprintf(sock,sess, "250- Listing root"); sockprintf(sock,sess, "250- Listing root");
...@@ -4503,25 +3774,6 @@ static void ctrl_thread(void* arg) ...@@ -4503,25 +3774,6 @@ static void ctrl_thread(void* arg)
lprintf(LOG_WARNING,"%04d <%s> !Missing aliased file: %s",sock, user.alias, np); lprintf(LOG_WARNING,"%04d <%s> !Missing aliased file: %s",sock, user.alias, np);
continue; continue;
} }
if(cmd[3] == 'D' || strcmp(startup->html_index_file, mls_fname) == 0) {
if (cmd[3] == 'T')
sockprintf(sock,sess, "250- Listing %s", p);
get_unique(aliaspath, uniq);
if (cmd[3] == 'D') {
if (alias_dir==TRUE)
send_mlsx_entry(fp, sock, sess, mlsx_feats, "dir", "el", UINT64_MAX, 0, NULL, uniq, 0, p);
else
send_mlsx_entry(fp, sock, sess, mlsx_feats, "file", "r", (uint64_t)flength(np), fdate(np), NULL, uniq, 0, p);
}
else {
if (alias_dir==TRUE)
send_mlsx_entry(fp, sock, sess, mlsx_feats, "dir", "el", UINT64_MAX, 0, NULL, uniq, 0, aliaspath[0] ? aliaspath : mls_path);
else
send_mlsx_entry(fp, sock, sess, mlsx_feats, "file", "r", (uint64_t)flength(np), fdate(np), NULL, uniq, 0, mls_path);
}
l++;
}
} }
fclose(alias_fp); fclose(alias_fp);
...@@ -4722,21 +3974,6 @@ static void ctrl_thread(void* arg) ...@@ -4722,21 +3974,6 @@ static void ctrl_thread(void* arg)
else else
fprintf(fp,"%s\r\n",startup->index_file_name); fprintf(fp,"%s\r\n",startup->index_file_name);
} }
/* HTML Index File */
if(startup->options&FTP_OPT_HTML_INDEX_FILE && startup->html_index_file[0]
&& wildmatchi(startup->html_index_file, filespec, FALSE)) {
if(detail)
fprintf(fp,"-r--r--r-- 1 %-*s %-8s %9ld %s %2d %02d:%02d %s\r\n"
,NAME_LEN
,scfg.sys_id
,lib<0 ? scfg.sys_id : dir<0
? scfg.lib[lib]->sname : scfg.dir[dir]->code_suffix
,512L
,ftp_mon[cur_tm.tm_mon],cur_tm.tm_mday,cur_tm.tm_hour,cur_tm.tm_min
,startup->html_index_file);
else
fprintf(fp,"%s\r\n",startup->html_index_file);
}
if(lib<0) { /* Root dir */ if(lib<0) { /* Root dir */
lprintf(LOG_INFO,"%04d <%s> %slisting: root in %s mode", sock, user.alias, detail ? "detailed ":"", mode); lprintf(LOG_INFO,"%04d <%s> %slisting: root in %s mode", sock, user.alias, detail ? "detailed ":"", mode);
...@@ -5054,8 +4291,6 @@ static void ctrl_thread(void* arg) ...@@ -5054,8 +4291,6 @@ static void ctrl_thread(void* arg)
p=tp+1; p=tp+1;
} }
sprintf(html_index_ext,"%s?",startup->html_index_file);
sprintf(str,"%s.qwk",scfg.sys_id); sprintf(str,"%s.qwk",scfg.sys_id);
if(lib<0 && startup->options&FTP_OPT_ALLOW_QWK if(lib<0 && startup->options&FTP_OPT_ALLOW_QWK
&& !stricmp(p,str) && !delecmd) { && !stricmp(p,str) && !delecmd) {
...@@ -5141,9 +4376,7 @@ static void ctrl_thread(void* arg) ...@@ -5141,9 +4376,7 @@ static void ctrl_thread(void* arg)
delfile=TRUE; delfile=TRUE;
fprintf(fp,"%-*s File/Folder Descriptions\r\n" fprintf(fp,"%-*s File/Folder Descriptions\r\n"
,INDEX_FNAME_LEN,startup->index_file_name); ,INDEX_FNAME_LEN,startup->index_file_name);
if(startup->options&FTP_OPT_HTML_INDEX_FILE)
fprintf(fp,"%-*s File/Folder Descriptions (HTML)\r\n"
,INDEX_FNAME_LEN,startup->html_index_file);
if(lib<0) { if(lib<0) {
/* File Aliases */ /* File Aliases */
...@@ -5236,132 +4469,6 @@ static void ctrl_thread(void* arg) ...@@ -5236,132 +4469,6 @@ static void ctrl_thread(void* arg)
} }
fclose(fp); fclose(fp);
} }
/* HTML Index File */
} else if(startup->options&FTP_OPT_HTML_INDEX_FILE
&& (!stricmp(p,startup->html_index_file)
|| !strnicmp(p,html_index_ext,strlen(html_index_ext)))
&& !delecmd) {
success=TRUE;
if(getsize) {
sockprintf(sock,sess, "550 Size not available for dynamically generated files");
continue;
}
else if(getdate)
file_date=time(NULL);
else {
#ifdef JAVASCRIPT
if(startup->options&FTP_OPT_NO_JAVASCRIPT) {
lprintf(LOG_ERR,"%04d <%s> !JavaScript disabled, cannot generate %s",sock, user.alias, fname);
sockprintf(sock,sess, "451 JavaScript disabled");
filepos=0;
continue;
}
if(js_runtime == NULL) {
lprintf(LOG_DEBUG,"%04d <%s> JavaScript: Creating runtime: %lu bytes"
,sock, user.alias,startup->js.max_bytes);
if((js_runtime = jsrt_GetNew(startup->js.max_bytes, 1000, __FILE__, __LINE__))==NULL) {
lprintf(LOG_ERR,"%04d <%s> !ERROR creating JavaScript runtime",sock, user.alias);
sockprintf(sock,sess,"451 Error creating JavaScript runtime");
filepos=0;
continue;
}
}
if(js_cx==NULL) { /* Context not yet created, create it now */
/* js_initcx() starts a request */
if(((js_cx=js_initcx(js_runtime, sock,&js_glob,&js_ftp,&js_callback))==NULL)) {
lprintf(LOG_ERR,"%04d <%s> !ERROR initializing JavaScript context",sock, user.alias);
sockprintf(sock,sess,"451 Error initializing JavaScript context");
filepos=0;
continue;
}
if(js_CreateUserClass(js_cx, js_glob, &scfg)==NULL)
lprintf(LOG_ERR,"%04d <%s> !JavaScript ERROR creating user class",sock, user.alias);
if(js_CreateFileClass(js_cx, js_glob)==NULL)
lprintf(LOG_ERR,"%04d <%s> !JavaScript ERROR creating file class",sock, user.alias);
if(js_CreateUserObject(js_cx, js_glob, &scfg, "user", &user, &client, /* global_user: */TRUE)==NULL)
lprintf(LOG_ERR,"%04d <%s> !JavaScript ERROR creating user object",sock, user.alias);
if(js_CreateClientObject(js_cx, js_glob, "client", &client, sock, -1)==NULL)
lprintf(LOG_ERR,"%04d <%s> !JavaScript ERROR creating client object",sock, user.alias);
if(js_CreateFileAreaObject(js_cx, js_glob, &scfg, &user, &client
,startup->html_index_file)==NULL)
lprintf(LOG_ERR,"%04d <%s> !JavaScript ERROR creating file area object",sock, user.alias);
}
else
JS_BEGINREQUEST(js_cx);
if((js_str=JS_NewStringCopyZ(js_cx, "name"))!=NULL) {
js_val=STRING_TO_JSVAL(js_str);
JS_SetProperty(js_cx, js_ftp, "sort", &js_val);
}
js_val=BOOLEAN_TO_JSVAL(FALSE);
JS_SetProperty(js_cx, js_ftp, "reverse", &js_val);
if(!strnicmp(p,html_index_ext,strlen(html_index_ext))) {
p+=strlen(html_index_ext);
tp=strrchr(p,'$');
if(tp!=NULL)
*tp=0;
if(!strnicmp(p,"ext=",4)) {
p+=4;
if(!strcmp(p,"on"))
user.misc|=EXTDESC;
else
user.misc&=~EXTDESC;
if(!(user.rest&FLAG('G')))
putuserrec(&scfg,user.number,U_MISC,8,ultoa(user.misc,str,16));
}
else if(!strnicmp(p,"sort=",5)) {
p+=5;
tp=strchr(p,'&');
if(tp!=NULL) {
*tp=0;
tp++;
if(!stricmp(tp,"reverse")) {
js_val=BOOLEAN_TO_JSVAL(TRUE);
JS_SetProperty(js_cx, js_ftp, "reverse", &js_val);
}
}
if((js_str=JS_NewStringCopyZ(js_cx, p))!=NULL) {
js_val=STRING_TO_JSVAL(js_str);
JS_SetProperty(js_cx, js_ftp, "sort", &js_val);
}
}
}
js_val=BOOLEAN_TO_JSVAL(INT_TO_BOOL(user.misc&EXTDESC));
JS_SetProperty(js_cx, js_ftp, "extended_descriptions", &js_val);
JS_ENDREQUEST(js_cx);
#endif
if((fp=fopen(ftp_tmpfname(fname,"html",sock),"w+b"))==NULL) {
lprintf(LOG_ERR,"%04d <%s> !ERROR %d (%s) line %d opening %s"
,sock, user.alias, errno, strerror(errno), __LINE__, fname);
sockprintf(sock,sess, "451 Insufficient system storage");
filepos=0;
continue;
}
lprintf(LOG_INFO,"%04d <%s> downloading %s for %s in %s mode"
,sock, user.alias, startup->html_index_file, genvpath(lib,dir,str)
,mode);
credits=FALSE;
tmpfile=TRUE;
delfile=TRUE;
#ifdef JAVASCRIPT
JS_BEGINREQUEST(js_cx);
js_val=INT_TO_JSVAL(timeleft);
if(!JS_SetProperty(js_cx, js_ftp, "time_left", &js_val))
lprintf(LOG_ERR,"%04d <%s> !JavaScript ERROR setting user.time_left",sock, user.alias);
js_generate_index(js_cx, js_ftp, sock, fp, lib, dir, &user, &client);
JS_ENDREQUEST(js_cx);
#endif
fclose(fp);
}
} else if(dir>=0) { } else if(dir>=0) {
if(!chk_ar(&scfg,scfg.dir[dir]->ar,&user,&client)) { if(!chk_ar(&scfg,scfg.dir[dir]->ar,&user,&client)) {
...@@ -5617,8 +4724,6 @@ static void ctrl_thread(void* arg) ...@@ -5617,8 +4724,6 @@ static void ctrl_thread(void* arg)
if((!append && filepos==0 && fexist(fname)) if((!append && filepos==0 && fexist(fname))
|| (startup->options&FTP_OPT_INDEX_FILE || (startup->options&FTP_OPT_INDEX_FILE
&& !stricmp(p,startup->index_file_name)) && !stricmp(p,startup->index_file_name))
|| (startup->options&FTP_OPT_HTML_INDEX_FILE
&& !stricmp(p,startup->html_index_file))
) { ) {
lprintf(LOG_WARNING,"%04d <%s> attempted to overwrite existing file: %s" lprintf(LOG_WARNING,"%04d <%s> attempted to overwrite existing file: %s"
,sock,user.alias,fname); ,sock,user.alias,fname);
...@@ -5867,22 +4972,6 @@ static void ctrl_thread(void* arg) ...@@ -5867,22 +4972,6 @@ static void ctrl_thread(void* arg)
PlaySound(startup->hangup_sound, NULL, SND_ASYNC|SND_FILENAME); PlaySound(startup->hangup_sound, NULL, SND_ASYNC|SND_FILENAME);
#endif #endif
#ifdef JAVASCRIPT
if(js_cx!=NULL) {
lprintf(LOG_DEBUG,"%04d JavaScript: Destroying context",sock);
JS_BEGINREQUEST(js_cx);
JS_RemoveObjectRoot(js_cx, &js_glob);
JS_ENDREQUEST(js_cx);
JS_DestroyContext(js_cx); /* Free Context */
}
if(js_runtime!=NULL) {
lprintf(LOG_DEBUG,"%04d JavaScript: Destroying runtime",sock);
jsrt_Release(js_runtime);
}
#endif
/* status(STATUS_WFC); server thread should control status display */ /* status(STATUS_WFC); server thread should control status display */
if(pasv_sock!=INVALID_SOCKET) if(pasv_sock!=INVALID_SOCKET)
...@@ -6020,13 +5109,6 @@ void DLLCALL ftp_server(void* arg) ...@@ -6020,13 +5109,6 @@ void DLLCALL ftp_server(void* arg)
return; return;
} }
ZERO_VAR(js_server_props);
SAFEPRINTF3(js_server_props.version,"%s %s%c", FTP_SERVER, VERSION, REVISION);
js_server_props.version_detail=ftp_ver();
js_server_props.clients=&active_clients.value;
js_server_props.options=&startup->options;
js_server_props.interfaces=&startup->interfaces;
uptime=0; uptime=0;
served=0; served=0;
startup->recycle_now=FALSE; startup->recycle_now=FALSE;
...@@ -6043,13 +5125,6 @@ void DLLCALL ftp_server(void* arg) ...@@ -6043,13 +5125,6 @@ void DLLCALL ftp_server(void* arg)
if(startup->max_inactivity==0) startup->max_inactivity=FTP_DEFAULT_MAX_INACTIVITY; /* seconds */ if(startup->max_inactivity==0) startup->max_inactivity=FTP_DEFAULT_MAX_INACTIVITY; /* seconds */
if(startup->sem_chk_freq==0) startup->sem_chk_freq=DEFAULT_SEM_CHK_FREQ; /* seconds */ if(startup->sem_chk_freq==0) startup->sem_chk_freq=DEFAULT_SEM_CHK_FREQ; /* seconds */
if(startup->index_file_name[0]==0) SAFECOPY(startup->index_file_name,"00index"); if(startup->index_file_name[0]==0) SAFECOPY(startup->index_file_name,"00index");
if(startup->html_index_file[0]==0) SAFECOPY(startup->html_index_file,"00index.html");
if(startup->html_index_script[0]==0) SAFECOPY(startup->html_index_script,"ftp-html.js");
if(startup->options&FTP_OPT_HTML_INDEX_FILE)
startup->options&=~FTP_OPT_NO_JAVASCRIPT;
else
startup->options|=FTP_OPT_NO_JAVASCRIPT;
if(startup->js.max_bytes==0) startup->js.max_bytes=JAVASCRIPT_MAX_BYTES;
protected_uint32_adjust(&thread_count,1); protected_uint32_adjust(&thread_count,1);
thread_up(FALSE /* setuid */); thread_up(FALSE /* setuid */);
......
/* Synchronet FTP server */ /* Synchronet FTP server */
/* $Id: ftpsrvr.h,v 1.58 2019/03/22 21:28:27 rswindell Exp $ */
/**************************************************************************** /****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
...@@ -15,21 +13,9 @@ ...@@ -15,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or * * See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html * * http://www.fsf.org/copyleft/gpl.html *
* * * *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see * * For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html * * http://www.synchro.net/source.html *
* * * *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. * * Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/ ****************************************************************************/
...@@ -79,8 +65,6 @@ typedef struct { ...@@ -79,8 +65,6 @@ typedef struct {
/* Paths */ /* Paths */
char ctrl_dir[128]; char ctrl_dir[128];
char index_file_name[64]; char index_file_name[64];
char html_index_file[64];
char html_index_script[64];
char temp_dir[128]; char temp_dir[128];
char answer_sound[128]; char answer_sound[128];
char hangup_sound[128]; char hangup_sound[128];
...@@ -95,9 +79,6 @@ typedef struct { ...@@ -95,9 +79,6 @@ typedef struct {
uint bind_retry_count; /* Number of times to retry bind() calls */ uint bind_retry_count; /* Number of times to retry bind() calls */
uint bind_retry_delay; /* Time to wait between each bind() retry */ uint bind_retry_delay; /* Time to wait between each bind() retry */
/* JavaScript operating parameters */
js_startup_t js;
/* Login Attempt parameters */ /* Login Attempt parameters */
struct login_attempt_settings login_attempt; struct login_attempt_settings login_attempt;
link_list_t* login_attempt_list; link_list_t* login_attempt_list;
...@@ -123,11 +104,9 @@ static struct init_field ftp_init_fields[] = { ...@@ -123,11 +104,9 @@ static struct init_field ftp_init_fields[] = {
#define FTP_OPT_NO_LOCAL_FSYS (1<<5) #define FTP_OPT_NO_LOCAL_FSYS (1<<5)
#define FTP_OPT_DIR_FILES (1<<6) /* Allow access to files in dir but not in database */ #define FTP_OPT_DIR_FILES (1<<6) /* Allow access to files in dir but not in database */
#define FTP_OPT_KEEP_TEMP_FILES (1<<7) /* Don't delete temp files (for debugging) */ #define FTP_OPT_KEEP_TEMP_FILES (1<<7) /* Don't delete temp files (for debugging) */
#define FTP_OPT_HTML_INDEX_FILE (1<<8) /* Auto-generate HTML index files */
#define FTP_OPT_LOOKUP_PASV_IP (1<<9) /* resolve public IP address for PASV response */ #define FTP_OPT_LOOKUP_PASV_IP (1<<9) /* resolve public IP address for PASV response */
#define FTP_OPT_NO_HOST_LOOKUP (1<<11) #define FTP_OPT_NO_HOST_LOOKUP (1<<11)
#define FTP_OPT_NO_RECYCLE (1<<27) /* Disable recycling of server */ #define FTP_OPT_NO_RECYCLE (1<<27) /* Disable recycling of server */
#define FTP_OPT_NO_JAVASCRIPT (1<<29) /* JavaScript disabled */
#define FTP_OPT_MUTE (1<<31) #define FTP_OPT_MUTE (1<<31)
/* ftp_startup_t.options bits that require re-init/recycle when changed */ /* ftp_startup_t.options bits that require re-init/recycle when changed */
...@@ -144,11 +123,9 @@ static ini_bitdesc_t ftp_options[] = { ...@@ -144,11 +123,9 @@ static ini_bitdesc_t ftp_options[] = {
{ FTP_OPT_NO_LOCAL_FSYS ,"NO_LOCAL_FSYS" }, { FTP_OPT_NO_LOCAL_FSYS ,"NO_LOCAL_FSYS" },
{ FTP_OPT_DIR_FILES ,"DIR_FILES" }, { FTP_OPT_DIR_FILES ,"DIR_FILES" },
{ FTP_OPT_KEEP_TEMP_FILES ,"KEEP_TEMP_FILES" }, { FTP_OPT_KEEP_TEMP_FILES ,"KEEP_TEMP_FILES" },
{ FTP_OPT_HTML_INDEX_FILE ,"HTML_INDEX_FILE" },
{ FTP_OPT_LOOKUP_PASV_IP ,"LOOKUP_PASV_IP" }, { FTP_OPT_LOOKUP_PASV_IP ,"LOOKUP_PASV_IP" },
{ FTP_OPT_NO_HOST_LOOKUP ,"NO_HOST_LOOKUP" }, { FTP_OPT_NO_HOST_LOOKUP ,"NO_HOST_LOOKUP" },
{ FTP_OPT_NO_RECYCLE ,"NO_RECYCLE" }, { FTP_OPT_NO_RECYCLE ,"NO_RECYCLE" },
{ FTP_OPT_NO_JAVASCRIPT ,"NO_JAVASCRIPT" },
{ FTP_OPT_MUTE ,"MUTE" }, { FTP_OPT_MUTE ,"MUTE" },
/* terminator */ /* terminator */
{ 0 ,NULL } { 0 ,NULL }
......
...@@ -434,19 +434,11 @@ void sbbs_read_ini( ...@@ -434,19 +434,11 @@ void sbbs_read_ini(
ftp->pasv_port_high ftp->pasv_port_high
=iniGetShortInt(list,section,"PasvPortHigh",0xffff); =iniGetShortInt(list,section,"PasvPortHigh",0xffff);
/* JavaScript Operating Parameters */
sbbs_get_js_settings(list, section, &ftp->js, &global->js);
SAFECOPY(ftp->host_name SAFECOPY(ftp->host_name
,iniGetString(list,section,strHostName,global->host_name,value)); ,iniGetString(list,section,strHostName,global->host_name,value));
SAFECOPY(ftp->index_file_name SAFECOPY(ftp->index_file_name
,iniGetString(list,section,"IndexFileName","00index",value)); ,iniGetString(list,section,"IndexFileName","00index",value));
SAFECOPY(ftp->html_index_file
,iniGetString(list,section,"HtmlIndexFile","00index.html",value));
SAFECOPY(ftp->html_index_script
,iniGetString(list,section,"HtmlIndexScript","ftp-html.js",value));
SAFECOPY(ftp->answer_sound SAFECOPY(ftp->answer_sound
,iniGetString(list,section,strAnswerSound,nulstr,value)); ,iniGetString(list,section,strAnswerSound,nulstr,value));
...@@ -462,7 +454,7 @@ void sbbs_read_ini( ...@@ -462,7 +454,7 @@ void sbbs_read_ini(
=iniGetLogLevel(list,section,strLogLevel,global->log_level); =iniGetLogLevel(list,section,strLogLevel,global->log_level);
ftp->options ftp->options
=iniGetBitField(list,section,strOptions,ftp_options =iniGetBitField(list,section,strOptions,ftp_options
,FTP_OPT_INDEX_FILE|FTP_OPT_HTML_INDEX_FILE|FTP_OPT_ALLOW_QWK); ,FTP_OPT_INDEX_FILE | FTP_OPT_ALLOW_QWK);
ftp->bind_retry_count=iniGetInteger(list,section,strBindRetryCount,global->bind_retry_count); ftp->bind_retry_count=iniGetInteger(list,section,strBindRetryCount,global->bind_retry_count);
ftp->bind_retry_delay=iniGetInteger(list,section,strBindRetryDelay,global->bind_retry_delay); ftp->bind_retry_delay=iniGetInteger(list,section,strBindRetryDelay,global->bind_retry_delay);
...@@ -921,10 +913,6 @@ BOOL sbbs_write_ini( ...@@ -921,10 +913,6 @@ BOOL sbbs_write_ini(
else if(!iniSetLogLevel(lp,section,strLogLevel,ftp->log_level,&style)) else if(!iniSetLogLevel(lp,section,strLogLevel,ftp->log_level,&style))
break; break;
/* JavaScript Operating Parameters */
if(!sbbs_set_js_settings(lp,section,&ftp->js,&global->js,&style))
break;
if(strcmp(ftp->host_name,global->host_name)==0 if(strcmp(ftp->host_name,global->host_name)==0
|| (bbs != NULL && strcmp(bbs->host_name,cfg->sys_inetaddr)==0)) || (bbs != NULL && strcmp(bbs->host_name,cfg->sys_inetaddr)==0))
iniRemoveKey(lp,section,strHostName); iniRemoveKey(lp,section,strHostName);
...@@ -938,10 +926,6 @@ BOOL sbbs_write_ini( ...@@ -938,10 +926,6 @@ BOOL sbbs_write_ini(
if(!iniSetString(lp,section,"IndexFileName",ftp->index_file_name,&style)) if(!iniSetString(lp,section,"IndexFileName",ftp->index_file_name,&style))
break; break;
if(!iniSetString(lp,section,"HtmlIndexFile",ftp->html_index_file,&style))
break;
if(!iniSetString(lp,section,"HtmlIndexScript",ftp->html_index_script,&style))
break;
if(!iniSetString(lp,section,strAnswerSound,ftp->answer_sound,&style)) if(!iniSetString(lp,section,strAnswerSound,ftp->answer_sound,&style))
break; break;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
template.ftp_url += host; template.ftp_url += host;
if(ftp_port!=21) if(ftp_port!=21)
template.ftp_url += ftp_port; template.ftp_url += ftp_port;
template.ftpidx ="/00index.html?$" + new Date().valueOf().toString(36); template.ftpidx ="/";
template.ftpqwk = "/" + system.qwk_id.toLowerCase() + ".qwk"; template.ftpqwk = "/" + system.qwk_id.toLowerCase() + ".qwk";
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment