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

Preparing for merge with sbbs repo.

parent abef8a34
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 605 deletions
# Ignore processed XJS files
*.xjs.ssjs
# Ignore non-example pages
/web/pages/*
!/web/pages/.examples
# Ignore non-example sidebar modules
/web/sidebar/*
!/web/sidebar/.examples
# Ignore non-example components
/web/components/*
!/web/components/.examples
# synchronet-web-v4
A web interface for Synchronet BBS
Documentation is available on [the wiki](https://github.com/echicken/synchronet-web-v4/wiki)
/**
* js-date-format (js-date-format.js)
* v1.0
* (c) Tony Brix (tonybrix.info) - 2014.
* https://github.com/UziTech/js-date-format
*
* MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
Date.prototype.setLocale = function (lang) {
if (lang && lang in Date.locales) {
this.locale = lang;
}
};
Date.prototype.getLocale = function () {
return this.locale || "en";
};
Date.prototype.getMonthName = function (lang) {
var locale = "en";
if (lang && lang in Date.locales) {
locale = lang;
} else if (this.locale && this.locale in Date.locales) {
locale = this.locale;
}
return Date.locales[locale].month_names[this.getMonth()];
};
Date.prototype.getMonthNameShort = function (lang) {
var locale = "en";
if (lang && lang in Date.locales) {
locale = lang;
} else if (this.locale && this.locale in Date.locales) {
locale = this.locale;
}
return Date.locales[locale].month_names_short[this.getMonth()];
};
Date.prototype.getDayName = function (lang) {
var locale = "en";
if (lang && lang in Date.locales) {
locale = lang;
} else if (this.locale && this.locale in Date.locales) {
locale = this.locale;
}
return Date.locales[locale].day_names[this.getDay()];
};
Date.prototype.getDayNameShort = function (lang) {
var locale = "en";
if (lang && lang in Date.locales) {
locale = lang;
} else if (this.locale && this.locale in Date.locales) {
locale = this.locale;
}
return Date.locales[locale].day_names_short[this.getDay()];
};
Date.prototype.getDateSuffix = function (lang) {
var locale = "en";
if (lang && lang in Date.locales) {
locale = lang;
} else if (this.locale && this.locale in Date.locales) {
locale = this.locale;
}
return Date.locales[locale].date_suffix(this.getDate());
};
Date.prototype.getMeridiem = function (isLower, lang) {
var locale = "en";
if (lang && lang in Date.locales) {
locale = lang;
} else if (this.locale && this.locale in Date.locales) {
locale = this.locale;
}
return Date.locales[locale].meridiem(this.getHours(), this.getMinutes(), isLower);
};
Date.prototype.getLastDate = function () {
return (new Date(this.getFullYear(), this.getMonth() + 1, 0)).getDate();
};
/* languages from http://momentjs.com */
Date.locales = {
"en": {
month_names: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
month_names_short: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
day_names: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
day_names_short: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
date_suffix: function (date) {
var day10 = ~~ (date % 100 / 10);
var day1 = date % 10;
if (day10 === 1) {
return "th";
} else if (day1 === 1) {
return "st";
} else if (day1 === 2) {
return "nd";
} else if (day1 === 3) {
return "rd";
} else {
return "th";
}
},
meridiem : function (hour, minute, isLower) {
if (hour < 12) {
return isLower ? "am" : "AM";
} else {
return isLower ? "pm" : "PM";
}
}
}
};
Date.prototype.format = function (formatString) {
var addPadding = function (value, length) {
var negative = ((value < 0) ? "-" : "");
var zeros = "0";
for (var i = 2; i < length; i++) {
zeros += "0";
}
return negative + (zeros + Math.abs(value).toString()).slice(-length);
};
var replacements = {
date: this,
YYYY: function () {
return this.date.getFullYear();
},
YY: function () {
return this.date.getFullYear() % 100;
},
MMMM: function () {
return this.date.getMonthName();
},
MMM: function () {
return this.date.getMonthNameShort();
},
MM: function () {
return addPadding((this.date.getMonth() + 1), 2);
},
M: function () {
return this.date.getMonth() + 1;
},
DDDD: function () {
return this.date.getDayName();
},
DDD: function () {
return this.date.getDayNameShort();
},
DD: function () {
return addPadding(this.date.getDate(), 2);
},
D: function () {
return this.date.getDate();
},
S: function () {
return this.date.getDateSuffix();
},
HH: function () {
return addPadding(this.date.getHours(), 2);
},
H: function () {
return this.date.getHours();
},
hh: function () {
var hour = this.date.getHours();
if (hour > 12) {
hour -= 12;
} else if (hour < 1) {
hour = 12;
}
return addPadding(hour, 2);
},
h: function () {
var hour = this.date.getHours();
if (hour > 12) {
hour -= 12;
} else if (hour < 1) {
hour = 12;
}
return hour;
},
mm: function () {
return addPadding(this.date.getMinutes(), 2);
},
m: function () {
return this.date.getMinutes();
},
ss: function () {
return addPadding(this.date.getSeconds(), 2);
},
s: function () {
return this.date.getSeconds();
},
fff: function () {
return addPadding(this.date.getMilliseconds(), 3);
},
ff: function () {
return addPadding(Math.floor(this.date.getMilliseconds() / 10), 2);
},
f: function () {
return Math.floor(this.date.getMilliseconds() / 100);
},
zzzz: function () {
return addPadding(Math.floor(-this.date.getTimezoneOffset() / 60), 2) + ":" + addPadding(-this.date.getTimezoneOffset() % 60, 2);
},
zzz: function () {
return Math.floor(-this.date.getTimezoneOffset() / 60) + ":" + addPadding(-this.date.getTimezoneOffset() % 60, 2);
},
zz: function () {
return addPadding(Math.floor(-this.date.getTimezoneOffset() / 60), 2);
},
z: function () {
return Math.floor(-this.date.getTimezoneOffset() / 60);
},
tt: function () {
return this.date.getMeridiem(true);
},
TT: function () {
return this.date.getMeridiem(false);
}
};
var formats = new Array();
while (formatString.length > 0) {
if (formatString[0] === "\"") {
var temp = /"[^"]*"/m.exec(formatString);
if (temp === null) {
formats.push(formatString.substring(1));
formatString = "";
} else {
temp = temp[0].substring(1, temp[0].length - 1);
formats.push(temp);
formatString = formatString.substring(temp.length + 2);
}
} else if (formatString[0] === "'") {
var temp = /'[^']*'/m.exec(formatString);
if (temp === null) {
formats.push(formatString.substring(1));
formatString = "";
} else {
temp = temp[0].substring(1, temp[0].length - 1);
formats.push(temp);
formatString = formatString.substring(temp.length + 2);
}
} else if (formatString[0] === "\\") {
if (formatString.length > 1) {
formats.push(formatString.substring(1, 2));
formatString = formatString.substring(2);
} else {
formats.push("\\");
formatString = "";
}
} else {
var foundMatch = false;
for (var i = formatString.length; i > 0; i--) {
if (formatString.substring(0, i) in replacements) {
formats.push(replacements[formatString.substring(0, i)]());
formatString = formatString.substring(i);
foundMatch = true;
break;
}
}
if (!foundMatch) {
formats.push(formatString[0]);
formatString = formatString.substring(1);
}
}
}
return formats.join("");
};
\ No newline at end of file
const named_parameters = {};
if (argv.length > 0) {
argv.forEach(function (e) {
const m = /-?((\w+)(?:=("[^"]+"|[^\s"]+))?)(?:\s+|$)/.exec(e);
named_parameters[m[2]] = (m[3] ? m[3] : null);
});
}
load('http.js');
function download(url, target) {
const http = new HTTPRequest();
try {
const zip = http.Get(url);
} catch (err) {
log(err);
return false;
}
const f = new File(target);
if (!f.open('wb')) return false;
if (!f.write(zip)) return false;
f.close();
return true;
}
function extract(file, target) {
if (!file_isdir(install_dir)) {
if (!mkdir(install_dir)) return false;
}
const zp = system.platform.search(/^win/i) > -1 ? system.exec_dir : '';
return system.exec(zp + 'unzip -uqo ' + file + ' -d ' + target) == 0;
}
function update_sbbs_ini(root_directory, error_directory) {
if (!file_backup(system.ctrl_dir + 'sbbs.ini')) return false;
const f = new File(system.ctrl_dir + 'sbbs.ini');
if (!f.open('r+')) return false;
if (!f.iniSetValue('Web', 'RootDirectory', root_directory)) return false;
if (!f.iniSetValue('Web', 'ErrorDirectory', error_directory)) return false;
f.close();
return true;
}
function update_modopts_ini(modopts) {
if (!file_backup(system.ctrl_dir + 'modopts.ini')) return false;
const f = new File(system.ctrl_dir + 'modopts.ini');
if (!f.open('r+')) return false;
if (!f.iniSetObject('web', modopts)) return false;
f.close();
return true;
}
function get_modopts_ini() {
const f = new File(system.ctrl_dir + 'modopts.ini');
if (!f.open('r')) return false;
const ini = f.iniGetObject('web');
f.close();
return ini;
}
function get_service_ini(section) {
const f = new File(system.ctrl_dir + 'services.ini');
if (!f.open('r')) return false;
const ini = f.iniGetObject(section);
f.close();
return ini;
}
function set_service_ini(section, obj) {
const f = new File(system.ctrl_dir + 'services.ini');
if (!f.open('r+')) return false;
if (!f.iniSetObject(section, obj)) return false;
f.close();
return true;
}
function get_setting(text, value) {
if (typeof named_parameters.defaults != 'undefined') return value;
const i = prompt(text + ' [' + value + ']');
return (i == '' ? value : i);
}
function confirm_setting(text, value) {
if (typeof named_parameters.defaults != 'undefined') {
return value;
} else if (!value) {
return !deny(text + ' [' + value + ']');
} else {
return confirm(text + ' [' + value + ']');
}
}
function copy_dir_contents(src, dest, overwrite) {
src = backslash(fullpath(src));
dest = backslash(fullpath(dest));
const delim = src.substr(-1);
if (!file_isdir(dest)) mkdir(dest);
directory(src + '*').forEach(
function (e) {
e = fullpath(e);
if (file_isdir(e)) {
const path = e.split(delim);
var df = dest + path[path.length - 2];
if (!file_isdir(df)) mkdir(df);
copy_dir_contents(e, df, overwrite);
} else {
var df = dest + file_getname(e);
if (!file_exists(df) || overwrite) {
file_copy(e, dest + file_getname(e));
}
}
}
);
}
// yikes
function remove_dir(dir) {
dir = backslash(fullpath(dir));
directory(dir + '*').forEach(
function (e) {
if (file_isdir(e)) {
remove_dir(e);
} else {
file_remove(e);
}
}
);
rmdir(dir);
}
const url_suffix = named_parameters.release ? named_parameters.release : 'master';
const zip_url = 'https://codeload.github.com/echicken/synchronet-web-v4/zip/' + url_suffix;
const download_target = system.temp_dir + 'webv4.zip';
const extract_dir = fullpath(system.temp_dir);
const temp_dir = fullpath(extract_dir + '/synchronet-web-v4-master');
const install_dir = fullpath(system.exec_dir + '../webv4');
const root_directory = fullpath(install_dir + '/root');
const error_directory = fullpath(root_directory + '/error');
var modopts_web = get_modopts_ini();
if (!modopts_web) {
modopts_web = {
guest : 'Guest',
timeout : 43200,
inactivity : 900,
user_registration : false,
minimum_password_length : 6,
maximum_telegram_length : 800,
web_directory : install_dir,
ftelnet : true,
ftelnet_splash : '../text/synch.ans',
keyboard_navigation : false,
vote_functions : true,
refresh_interval : 60000,
xtrn_blacklist : 'scfg,oneliner',
layout_sidebar_off : false,
layout_sidebar_left : false,
layout_full_width : false,
forum_extended_ascii : false,
max_messages : 0
};
}
var wss = get_service_ini('WS');
if (!wss) {
var wss = {
Port : 1123,
Options : 'NO_HOST_LOOKUP',
Command : 'websocketservice.js'
};
}
var wsss = get_service_ini('WSS');
if (!wsss) {
var wsss = {
Port : 11235,
Options : 'NO_HOST_LOOKUP|TLS',
Command : 'websocketservice.js'
};
}
write('\r\n---\r\n\r\n');
writeln('ecwebv4 installer/updater');
writeln('https://github.com/echicken/synchronet-web-v4');
if (system.version_num < 31700) {
writeln('Synchronet versions earlier than 3.17a are not supported. Exiting.');
exit();
}
write('\r\nIt is strongly recommended that you back up your BBS before proceeding.\r\n');
write('\r\nIf this is a new intallation, you must also shut down your BBS now.\r\n\r\n');
if (typeof named_parameters.defaults == 'undefined' && deny('Proceed with installation/update')) {
writeln('Install/update aborted. Exiting.');
exit();
}
write('\r\n\r\n---\r\n\r\n');
if (!file_exists(download_target) || confirm(download_target + ' present. Overwrite')) {
writeln('Downloading ' + zip_url);
if (!download(zip_url, download_target)) {
writeln('Download of ' + zip_url + ' failed. Exiting.');
exit();
}
}
writeln('Extracting ' + download_target);
if (!extract(download_target, extract_dir)) {
writeln('Extraction of ' + download_target + ' failed. Exiting.');
exit();
}
writeln('Copying files ...');
copy_dir_contents(temp_dir + '/mods', system.mods_dir, true);
copy_dir_contents(temp_dir + '/text', system.text_dir, true);
copy_dir_contents(temp_dir + '/web', install_dir, true);
copy_dir_contents(temp_dir + '/web/pages/.examples', install_dir + '/pages', false);
copy_dir_contents(temp_dir + '/web/pages/.examples', install_dir + '/pages/.examples', true); // These ... probably aren't necessary
copy_dir_contents(temp_dir + '/web/sidebar/.examples', install_dir + '/sidebar', false);
copy_dir_contents(temp_dir + '/web/sidebar/.examples', install_dir + '/sidebar/.examples', true); // These ... probably aren't necessary
copy_dir_contents(temp_dir + '/web/components/.examples', install_dir + '/components', false);
copy_dir_contents(temp_dir + '/web/components/.examples', install_dir + '/components/.examples', true); // These ... probably aren't necessary
writeln('Cleaning up ...');
remove_dir(temp_dir + '/web/pages/.examples');
remove_dir(temp_dir + '/web/sidebar/.examples');
remove_dir(temp_dir);
file_remove(download_target);
write('\r\n---\r\n\r\n');
write('Configuration - press enter to accept default/current value.\r\n\r\n');
modopts_web.guest = get_setting('Guest user alias', modopts_web.guest);
if (!system.matchuser(modopts_web.guest)) {
writeln('Guest user does not exist. Exiting.');
exit();
}
modopts_web.user_registration = confirm_setting('Allow new user registration via the web', modopts_web.user_registration);
modopts_web.ftelnet = confirm_setting('Enable fTelnet', modopts_web.ftelnet);
if (modopts_web.ftelnet) {
modopts_web.ftelnet_splash = get_setting('Path to ftelnet background .ans', modopts_web.ftelnet_splash);
write('\r\nUse of fTelnet requires a WebSocket proxy service.\r\n');
writeln('A websocket proxy server routes traffic between a browser-based');
writeln('application and some other arbitrary server. Here you will configure');
writeln('the ports that your WebSocket and WebSocket Secure proxy services will');
writeln('listen on. Be sure to open these ports in your firewall.');
write('\r\n');
wss.Port = get_setting('WebSocket service port for HTTP clients', wss.Port);
wsss.Port = get_setting('WebSocket secure service port for HTTPS clients', wsss.Port);
writeln('Updating services.ini ...');
if (!file_backup(system.ctrl_dir + 'services.ini')) {
writeln('Failed to back up services.ini. Exiting.');
exit();
}
if(!set_service_ini('WS', wss)) writeln('Failed to configure WS service.');
if (!set_service_ini('WSS', wsss)) writeln('Failed to configure WSS service.');
}
writeln('Updating modopts.ini ...');
if (!update_modopts_ini(modopts_web)) {
writeln('Failed to update modopts.ini. Exiting.');
exit();
}
writeln('Updating sbbs.ini ...');
if (!update_sbbs_ini(root_directory, error_directory)) {
writeln('Failed to update sbbs.ini. Exiting.');
exit();
} else {
write('\r\n---\r\n\r\n');
writeln('Install/update complete.');
writeln('If you shut down your BBS, you can restart it now.');
writeln('For additional configuration and customization steps,');
writeln('visit https://github.com/echicken/synchronet-web-v4');
write('\r\n\r\n---\r\n\r\n');
}

  
   ܰ gj/
synchronet    ߲  
        
  ۱      
   ۲   ۲  ۲ ۰ 
          ۲ 
      ۲  ۱ 
           ۲ 
  ۲۱      
 ߲  ۱  ۲   ܱ  
  ۲   ۱   ۲
            
             
    ۲   ߰ 
 ݰ  bbs software
 



File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment