Merge branch '0.0.9-alpha' of github.com:NuSkooler/enigma-bbs into user-interruptions
This commit is contained in:
commit
d9238ee6a5
Binary file not shown.
|
@ -127,14 +127,16 @@
|
|||
mainMenuSystemStats: {
|
||||
mci: {
|
||||
BN1: { width: 17 }
|
||||
VL2: { width: 17 }
|
||||
VN2: { width: 17 }
|
||||
OS3: { width: 33 }
|
||||
SC4: { width: 33 }
|
||||
DT5: { width: 33 }
|
||||
CT6: { width: 33 }
|
||||
AN7: { width: 6 }
|
||||
ND8: { width: 6 }
|
||||
TC9: { width: 6 }
|
||||
TT11: { width: 6 }
|
||||
PT12: { width: 6 }
|
||||
TP13: { width: 6 }
|
||||
NV14: { width: 17 }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
26
core/bbs.js
26
core/bbs.js
|
@ -11,6 +11,8 @@ const logger = require('./logger.js');
|
|||
const database = require('./database.js');
|
||||
const resolvePath = require('./misc_util.js').resolvePath;
|
||||
const UserProps = require('./user_property.js');
|
||||
const SysProps = require('./system_property.js');
|
||||
const SysLogKeys = require('./system_log.js');
|
||||
|
||||
// deps
|
||||
const async = require('async');
|
||||
|
@ -19,6 +21,7 @@ const _ = require('lodash');
|
|||
const mkdirs = require('fs-extra').mkdirs;
|
||||
const fs = require('graceful-fs');
|
||||
const paths = require('path');
|
||||
const moment = require('moment');
|
||||
|
||||
// our main entry point
|
||||
exports.main = main;
|
||||
|
@ -246,13 +249,13 @@ function initialize(cb) {
|
|||
|
||||
if(err) {
|
||||
propLoadOpts.names.concat('username').forEach(v => {
|
||||
StatLog.setNonPeristentSystemStat(`sysop_${v}`, 'N/A');
|
||||
StatLog.setNonPersistentSystemStat(`sysop_${v}`, 'N/A');
|
||||
});
|
||||
} else {
|
||||
opProps.username = opUserName;
|
||||
|
||||
_.each(opProps, (v, k) => {
|
||||
StatLog.setNonPeristentSystemStat(`sysop_${k}`, v);
|
||||
StatLog.setNonPersistentSystemStat(`sysop_${k}`, v);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -260,17 +263,24 @@ function initialize(cb) {
|
|||
}
|
||||
);
|
||||
},
|
||||
function initFileAreaStats(callback) {
|
||||
const getAreaStats = require('./file_base_area.js').getAreaStats;
|
||||
getAreaStats( (err, stats) => {
|
||||
if(!err) {
|
||||
function initCallsToday(callback) {
|
||||
const StatLog = require('./stat_log.js');
|
||||
StatLog.setNonPeristentSystemStat('file_base_area_stats', stats);
|
||||
}
|
||||
const filter = {
|
||||
logName : SysLogKeys.UserLoginHistory,
|
||||
resultType : 'count',
|
||||
date : moment(),
|
||||
};
|
||||
|
||||
StatLog.findSystemLogEntries(filter, (err, callsToday) => {
|
||||
if(!err) {
|
||||
StatLog.setNonPersistentSystemStat(SysProps.LoginsToday, callsToday);
|
||||
}
|
||||
return callback(null);
|
||||
});
|
||||
},
|
||||
function initMessageStats(callback) {
|
||||
return require('./message_area.js').startup(callback);
|
||||
},
|
||||
function initMCI(callback) {
|
||||
return require('./predefined_mci.js').init(callback);
|
||||
},
|
||||
|
|
|
@ -969,7 +969,7 @@ function getDefaultConfig() {
|
|||
|
||||
statLog : {
|
||||
systemEvents : {
|
||||
loginHistoryMax: -1 // forever
|
||||
loginHistoryMax: -1, // set to -1 for forever
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -73,7 +73,7 @@ function getISOTimestampString(ts) {
|
|||
}
|
||||
ts = moment(ts);
|
||||
}
|
||||
return ts.utc().format('YYYY-MM-DDTHH:mm:ss.SSS[Z]');
|
||||
return ts.format('YYYY-MM-DDTHH:mm:ss.SSSZ');
|
||||
}
|
||||
|
||||
function sanatizeString(s) {
|
||||
|
@ -189,14 +189,6 @@ const DB_INIT_TABLE = {
|
|||
);`
|
||||
);
|
||||
|
||||
dbs.user.run(
|
||||
`CREATE TABLE IF NOT EXISTS user_login_history (
|
||||
user_id INTEGER NOT NULL,
|
||||
user_name VARCHAR NOT NULL,
|
||||
timestamp DATETIME NOT NULL
|
||||
);`
|
||||
);
|
||||
|
||||
return cb(null);
|
||||
},
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@ const Log = require('./logger.js').log;
|
|||
const getConnectionByUserId = require('./client_connections.js').getConnectionByUserId;
|
||||
const webServerPackageName = require('./servers/content/web.js').moduleInfo.packageName;
|
||||
const Events = require('./events.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
const SysProps = require('./system_menu_method.js');
|
||||
|
||||
// deps
|
||||
const hashids = require('hashids');
|
||||
|
@ -470,10 +472,11 @@ class FileAreaWebAccess {
|
|||
});
|
||||
},
|
||||
function updateStats(user, callback) {
|
||||
StatLog.incrementUserStat(user, 'dl_total_count', 1);
|
||||
StatLog.incrementUserStat(user, 'dl_total_bytes', dlBytes);
|
||||
StatLog.incrementSystemStat('dl_total_count', 1);
|
||||
StatLog.incrementSystemStat('dl_total_bytes', dlBytes);
|
||||
StatLog.incrementUserStat(user, UserProps.FileDlTotalCount, 1);
|
||||
StatLog.incrementUserStat(user, UserProps.FileDlTotalBytes, dlBytes);
|
||||
|
||||
StatLog.incrementSystemStat(SysProps.FileDlTotalCount, 1);
|
||||
StatLog.incrementSystemStat(SysProps.FileDlTotalBytes, dlBytes);
|
||||
|
||||
return callback(null, user);
|
||||
},
|
||||
|
|
|
@ -15,6 +15,7 @@ const stringFormat = require('./string_format.js');
|
|||
const wordWrapText = require('./word_wrap.js').wordWrapText;
|
||||
const StatLog = require('./stat_log.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
const SysProps = require('./system_property.js');
|
||||
|
||||
// deps
|
||||
const _ = require('lodash');
|
||||
|
@ -56,7 +57,25 @@ const WellKnownAreaTags = exports.WellKnownAreaTags = {
|
|||
};
|
||||
|
||||
function startup(cb) {
|
||||
return cleanUpTempSessionItems(cb);
|
||||
async.series(
|
||||
[
|
||||
(callback) => {
|
||||
return cleanUpTempSessionItems(callback);
|
||||
},
|
||||
(callback) => {
|
||||
getAreaStats( (err, stats) => {
|
||||
if(!err) {
|
||||
StatLog.setNonPersistentSystemStat(SysProps.FileBaseAreaStats, stats);
|
||||
}
|
||||
|
||||
return callback(null);
|
||||
});
|
||||
}
|
||||
],
|
||||
err => {
|
||||
return cb(err);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function isInternalArea(areaTag) {
|
||||
|
@ -1012,7 +1031,7 @@ function getAreaStats(cb) {
|
|||
function updateAreaStatsScheduledEvent(args, cb) {
|
||||
getAreaStats( (err, stats) => {
|
||||
if(!err) {
|
||||
StatLog.setNonPeristentSystemStat('file_base_area_stats', stats);
|
||||
StatLog.setNonPersistentSystemStat(SysProps.FileBaseAreaStats, stats);
|
||||
}
|
||||
|
||||
return cb(err);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
const MenuModule = require('./menu_module.js').MenuModule;
|
||||
const { getSortedAvailableFileAreas } = require('./file_base_area.js');
|
||||
const StatLog = require('./stat_log.js');
|
||||
const SysProps = require('./system_property.js');
|
||||
|
||||
// deps
|
||||
const async = require('async');
|
||||
|
@ -52,7 +53,7 @@ exports.getModule = class FileAreaSelectModule extends MenuModule {
|
|||
async.waterfall(
|
||||
[
|
||||
function mergeAreaStats(callback) {
|
||||
const areaStats = StatLog.getSystemStat('file_base_area_stats') || { areas : {} };
|
||||
const areaStats = StatLog.getSystemStat(SysProps.FileBaseAreaStats) || { areas : {} };
|
||||
|
||||
// we could use 'sort' alone, but area/conf sorting has some special properties; user can still override
|
||||
const availAreas = getSortedAvailableFileAreas(self.client);
|
||||
|
|
|
@ -11,6 +11,8 @@ const StatLog = require('./stat_log.js');
|
|||
const FileEntry = require('./file_entry.js');
|
||||
const Log = require('./logger.js').log;
|
||||
const Events = require('./events.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
const SysProps = require('./system_property.js');
|
||||
|
||||
// deps
|
||||
const async = require('async');
|
||||
|
@ -479,10 +481,11 @@ exports.getModule = class TransferFileModule extends MenuModule {
|
|||
});
|
||||
}, () => {
|
||||
// All stats/meta currently updated via fire & forget - if this is ever a issue, we can wait for callbacks
|
||||
StatLog.incrementUserStat(this.client.user, 'dl_total_count', downloadCount);
|
||||
StatLog.incrementUserStat(this.client.user, 'dl_total_bytes', downloadBytes);
|
||||
StatLog.incrementSystemStat('dl_total_count', downloadCount);
|
||||
StatLog.incrementSystemStat('dl_total_bytes', downloadBytes);
|
||||
StatLog.incrementUserStat(this.client.user, UserProps.FileDlTotalCount, downloadCount);
|
||||
StatLog.incrementUserStat(this.client.user, UserProps.FileDlTotalBytes, downloadBytes);
|
||||
|
||||
StatLog.incrementSystemStat(SysProps.FileDlTotalCount, downloadCount);
|
||||
StatLog.incrementSystemStat(SysProps.FileDlTotalBytes, downloadBytes);
|
||||
|
||||
fileIds.forEach(fileId => {
|
||||
FileEntry.incrementAndPersistMetaValue(fileId, 'dl_count', 1);
|
||||
|
@ -509,10 +512,11 @@ exports.getModule = class TransferFileModule extends MenuModule {
|
|||
return next(null);
|
||||
});
|
||||
}, () => {
|
||||
StatLog.incrementUserStat(this.client.user, 'ul_total_count', uploadCount);
|
||||
StatLog.incrementUserStat(this.client.user, 'ul_total_bytes', uploadBytes);
|
||||
StatLog.incrementSystemStat('ul_total_count', uploadCount);
|
||||
StatLog.incrementSystemStat('ul_total_bytes', uploadBytes);
|
||||
StatLog.incrementUserStat(this.client.user, UserProps.FileUlTotalCount, uploadCount);
|
||||
StatLog.incrementUserStat(this.client.user, UserProps.FileUlTotalBytes, uploadBytes);
|
||||
|
||||
StatLog.incrementSystemStat(SysProps.FileUlTotalCount, uploadCount);
|
||||
StatLog.incrementSystemStat(SysProps.FileUlTotalBytes, uploadBytes);
|
||||
|
||||
return cb(null);
|
||||
});
|
||||
|
|
|
@ -25,6 +25,7 @@ const Config = require('./config.js').get;
|
|||
const { getAddressedToInfo } = require('./mail_util.js');
|
||||
const Events = require('./events.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
const SysProps = require('./system_property.js');
|
||||
|
||||
// deps
|
||||
const async = require('async');
|
||||
|
@ -470,7 +471,7 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
|
|||
);
|
||||
}
|
||||
|
||||
updateUserStats(cb) {
|
||||
updateUserAndSystemStats(cb) {
|
||||
if(Message.isPrivateAreaTag(this.message.areaTag)) {
|
||||
Events.emit(Events.getSystemEvents().UserSendMail, { user : this.client.user });
|
||||
if(cb) {
|
||||
|
@ -480,6 +481,9 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
|
|||
}
|
||||
|
||||
Events.emit(Events.getSystemEvents().UserPostMessage, { user : this.client.user, areaTag : this.message.areaTag });
|
||||
|
||||
StatLog.incrementNonPersistentSystemStat(SysProps.MessageTotalCount, 1);
|
||||
StatLog.incrementNonPersistentSystemStat(SysProps.MessagesToday, 1);
|
||||
return StatLog.incrementUserStat(this.client.user, UserProps.MessagePostCount, 1, cb);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ const User = require('./user.js');
|
|||
const sysDb = require('./database.js').dbs.system;
|
||||
const { Errors } = require('./enig_error.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
const SysLogKeys = require('./system_log.js');
|
||||
|
||||
// deps
|
||||
const moment = require('moment');
|
||||
|
@ -91,7 +92,7 @@ exports.getModule = class LastCallersModule extends MenuModule {
|
|||
}
|
||||
|
||||
StatLog.getSystemLogEntries(
|
||||
'user_login_history',
|
||||
SysLogKeys.UserLoginHistory,
|
||||
StatLog.Order.TimestampDesc,
|
||||
200, // max items to fetch - we need more than max displayed for filtering/etc.
|
||||
(err, loginHistory) => {
|
||||
|
|
|
@ -239,7 +239,10 @@ module.exports = class Message {
|
|||
filter.toUserName
|
||||
filter.fromUserName
|
||||
filter.replyToMesageId
|
||||
filter.newerThanTimestamp
|
||||
|
||||
filter.newerThanTimestamp - may not be used with |date|
|
||||
filter.date - moment object - may not be used with |newerThanTimestamp|
|
||||
|
||||
filter.newerThanMessageId
|
||||
filter.areaTag - note if you want by conf, send in all areas for a conf
|
||||
*filter.metaTuples - {category, name, value}
|
||||
|
@ -356,7 +359,10 @@ module.exports = class Message {
|
|||
});
|
||||
|
||||
if(_.isString(filter.newerThanTimestamp) && filter.newerThanTimestamp.length > 0) {
|
||||
// :TODO: should be using "localtime" here?
|
||||
appendWhereClause(`DATETIME(m.modified_timestamp) > DATETIME("${filter.newerThanTimestamp}", "+1 seconds")`);
|
||||
} else if(moment.isMoment(filter.date)) {
|
||||
appendWhereClause(`DATE(m.modified_timestamp, "localtime") = DATE("${filter.date.format('YYYY-MM-DD')}")`);
|
||||
}
|
||||
|
||||
if(_.isNumber(filter.newerThanMessageId)) {
|
||||
|
|
|
@ -9,12 +9,17 @@ const Log = require('./logger.js').log;
|
|||
const msgNetRecord = require('./msg_network.js').recordMessage;
|
||||
const sortAreasOrConfs = require('./conf_area_util.js').sortAreasOrConfs;
|
||||
const UserProps = require('./user_property.js');
|
||||
const StatLog = require('./stat_log.js');
|
||||
const SysProps = require('./system_property.js');
|
||||
|
||||
// deps
|
||||
const async = require('async');
|
||||
const _ = require('lodash');
|
||||
const assert = require('assert');
|
||||
const moment = require('moment');
|
||||
|
||||
exports.startup = startup;
|
||||
exports.shutdown = shutdown;
|
||||
exports.getAvailableMessageConferences = getAvailableMessageConferences;
|
||||
exports.getSortedAvailMessageConferences = getSortedAvailMessageConferences;
|
||||
exports.getAvailableMessageAreasByConfTag = getAvailableMessageAreasByConfTag;
|
||||
|
@ -35,6 +40,37 @@ exports.updateMessageAreaLastReadId = updateMessageAreaLastReadId;
|
|||
exports.persistMessage = persistMessage;
|
||||
exports.trimMessageAreasScheduledEvent = trimMessageAreasScheduledEvent;
|
||||
|
||||
function startup(cb) {
|
||||
// by default, private messages are NOT included
|
||||
async.series(
|
||||
[
|
||||
(callback) => {
|
||||
Message.findMessages( { resultType : 'count' }, (err, count) => {
|
||||
if(count) {
|
||||
StatLog.setNonPersistentSystemStat(SysProps.MessageTotalCount, count);
|
||||
}
|
||||
return callback(err);
|
||||
});
|
||||
},
|
||||
(callback) => {
|
||||
Message.findMessages( { resultType : 'count', date : moment() }, (err, count) => {
|
||||
if(count) {
|
||||
StatLog.setNonPersistentSystemStat(SysProps.MessagesToday, count);
|
||||
}
|
||||
return callback(err);
|
||||
});
|
||||
}
|
||||
],
|
||||
err => {
|
||||
return cb(err);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function shutdown(cb) {
|
||||
return cb(null);
|
||||
}
|
||||
|
||||
function getAvailableMessageConferences(client, options) {
|
||||
options = options || { includeSystemInternal : false };
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ exports.getModule = class AreaPostFSEModule extends FullScreenEditorModule {
|
|||
return persistMessage(msg, callback);
|
||||
},
|
||||
function updateStats(callback) {
|
||||
self.updateUserStats(callback);
|
||||
self.updateUserAndSystemStats(callback);
|
||||
}
|
||||
],
|
||||
function complete(err) {
|
||||
|
|
|
@ -14,6 +14,8 @@ const FileBaseFilters = require('./file_base_filter.js');
|
|||
const { formatByteSize } = require('./string_util.js');
|
||||
const ANSI = require('./ansi_term.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
const SysProps = require('./system_property.js');
|
||||
const SysLogKeys = require('./system_log.js');
|
||||
|
||||
// deps
|
||||
const packageJson = require('../package.json');
|
||||
|
@ -29,12 +31,12 @@ function init(cb) {
|
|||
}
|
||||
|
||||
function setNextRandomRumor(cb) {
|
||||
StatLog.getSystemLogEntries('system_rumorz', StatLog.Order.Random, 1, (err, entry) => {
|
||||
StatLog.getSystemLogEntries(SysLogKeys.UserAddedRumorz, StatLog.Order.Random, 1, (err, entry) => {
|
||||
if(entry) {
|
||||
entry = entry[0];
|
||||
}
|
||||
const randRumor = entry && entry.log_value ? entry.log_value : '';
|
||||
StatLog.setNonPeristentSystemStat('random_rumor', randRumor);
|
||||
StatLog.setNonPersistentSystemStat(SysProps.NextRandomRumor, randRumor);
|
||||
if(cb) {
|
||||
return cb(null);
|
||||
}
|
||||
|
@ -67,12 +69,12 @@ const PREDEFINED_MCI_GENERATORS = {
|
|||
VN : function version() { return packageJson.version; },
|
||||
|
||||
// +op info
|
||||
SN : function opUserName() { return StatLog.getSystemStat('sysop_username'); },
|
||||
SR : function opRealName() { return StatLog.getSystemStat('sysop_real_name'); },
|
||||
SL : function opLocation() { return StatLog.getSystemStat('sysop_location'); },
|
||||
SA : function opAffils() { return StatLog.getSystemStat('sysop_affiliation'); },
|
||||
SS : function opSex() { return StatLog.getSystemStat('sysop_sex'); },
|
||||
SE : function opEmail() { return StatLog.getSystemStat('sysop_email_address'); },
|
||||
SN : function opUserName() { return StatLog.getSystemStat(SysProps.SysOpUsername); },
|
||||
SR : function opRealName() { return StatLog.getSystemStat(SysProps.SysOpRealName); },
|
||||
SL : function opLocation() { return StatLog.getSystemStat(SysProps.SysOpLocation); },
|
||||
SA : function opAffils() { return StatLog.getSystemStat(SysProps.SysOpAffiliations); },
|
||||
SS : function opSex() { return StatLog.getSystemStat(SysProps.SysOpSex); },
|
||||
SE : function opEmail() { return StatLog.getSystemStat(SysProps.SysOpEmailAddress); },
|
||||
// :TODO: op age, web, ?????
|
||||
|
||||
//
|
||||
|
@ -153,13 +155,14 @@ const PREDEFINED_MCI_GENERATORS = {
|
|||
//
|
||||
// Date/Time
|
||||
//
|
||||
// :TODO: change to CD for 'Current Date'
|
||||
DT : function date(client) { return moment().format(client.currentTheme.helpers.getDateFormat()); },
|
||||
CT : function time(client) { return moment().format(client.currentTheme.helpers.getTimeFormat()) ;},
|
||||
|
||||
//
|
||||
// OS/System Info
|
||||
//
|
||||
// https://github.com/nodejs/node-v0.x-archive/issues/25769
|
||||
//
|
||||
OS : function operatingSystem() {
|
||||
return {
|
||||
linux : 'Linux',
|
||||
|
@ -167,6 +170,9 @@ const PREDEFINED_MCI_GENERATORS = {
|
|||
win32 : 'Windows',
|
||||
sunos : 'SunOS',
|
||||
freebsd : 'FreeBSD',
|
||||
android : 'Android',
|
||||
openbsd : 'OpenBSD',
|
||||
aix : 'IBM AIX',
|
||||
}[os.platform()] || os.type();
|
||||
},
|
||||
|
||||
|
@ -189,7 +195,10 @@ const PREDEFINED_MCI_GENERATORS = {
|
|||
|
||||
AN : function activeNodes() { return clientConnections.getActiveConnections().length.toString(); },
|
||||
|
||||
TC : function totalCalls() { return StatLog.getSystemStat('login_count').toLocaleString(); },
|
||||
TC : function totalCalls() { return StatLog.getSystemStat(SysProps.LoginCount).toLocaleString(); },
|
||||
TT : function totalCallsToday() {
|
||||
return StatLog.getSystemStat(SysProps.LoginsToday).toLocaleString();
|
||||
},
|
||||
|
||||
RR : function randomRumor() {
|
||||
// start the process of picking another random one
|
||||
|
@ -203,34 +212,35 @@ const PREDEFINED_MCI_GENERATORS = {
|
|||
//
|
||||
// :TODO: DD - Today's # of downloads (iNiQUiTY)
|
||||
//
|
||||
SD : function systemNumDownloads() { return sysStatAsString('dl_total_count', 0); },
|
||||
SD : function systemNumDownloads() { return sysStatAsString(SysProps.FileDlTotalCount, 0); },
|
||||
SO : function systemByteDownload() {
|
||||
const byteSize = StatLog.getSystemStatNum('dl_total_bytes');
|
||||
const byteSize = StatLog.getSystemStatNum(SysProps.FileDlTotalBytes);
|
||||
return formatByteSize(byteSize, true); // true=withAbbr
|
||||
},
|
||||
SU : function systemNumUploads() { return sysStatAsString('ul_total_count', 0); },
|
||||
SU : function systemNumUploads() { return sysStatAsString(SysProps.FileUlTotalCount, 0); },
|
||||
SP : function systemByteUpload() {
|
||||
const byteSize = StatLog.getSystemStatNum('ul_total_bytes');
|
||||
const byteSize = StatLog.getSystemStatNum(SysProps.FileUlTotalBytes);
|
||||
return formatByteSize(byteSize, true); // true=withAbbr
|
||||
},
|
||||
TF : function totalFilesOnSystem() {
|
||||
const areaStats = StatLog.getSystemStat('file_base_area_stats');
|
||||
const areaStats = StatLog.getSystemStat(SysProps.FileBaseAreaStats);
|
||||
return _.get(areaStats, 'totalFiles', 0).toLocaleString();
|
||||
},
|
||||
TB : function totalBytesOnSystem() {
|
||||
const areaStats = StatLog.getSystemStat('file_base_area_stats');
|
||||
const areaStats = StatLog.getSystemStat(SysProps.FileBaseAreaStats);
|
||||
const totalBytes = parseInt(_.get(areaStats, 'totalBytes', 0));
|
||||
return formatByteSize(totalBytes, true); // true=withAbbr
|
||||
},
|
||||
PT : function messagesPostedToday() { // Obv/2
|
||||
return sysStatAsString(SysProps.MessagesToday, 0);
|
||||
},
|
||||
TP : function totalMessagesOnSystem() { // Obv/2
|
||||
return sysStatAsString(SysProps.MessageTotalCount, 0);
|
||||
},
|
||||
|
||||
// :TODO: PT - Messages posted *today* (Obv/2)
|
||||
// -> Include FTN/etc.
|
||||
// :TODO: NT - New users today (Obv/2)
|
||||
// :TODO: CT - Calls *today* (Obv/2)
|
||||
// :TODO: FT - Files uploaded/added *today* (Obv/2)
|
||||
// :TODO: DD - Files downloaded *today* (iNiQUiTY)
|
||||
// :TODO: TP - total message/posts on the system (Obv/2)
|
||||
// -> Include FTN/etc.
|
||||
// :TODO: LC - name of last caller to system (Obv/2)
|
||||
// :TODO: TZ - Average *system* post/call ratio (iNiQUiTY)
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ const theme = require('./theme.js');
|
|||
const resetScreen = require('./ansi_term.js').resetScreen;
|
||||
const StatLog = require('./stat_log.js');
|
||||
const renderStringLength = require('./string_util.js').renderStringLength;
|
||||
const SystemLogKeys = require('./system_log.js');
|
||||
|
||||
// deps
|
||||
const async = require('async');
|
||||
|
@ -20,8 +21,6 @@ exports.moduleInfo = {
|
|||
packageName : 'codes.l33t.enigma.rumorz',
|
||||
};
|
||||
|
||||
const STATLOG_KEY_RUMORZ = 'system_rumorz';
|
||||
|
||||
const FormIds = {
|
||||
View : 0,
|
||||
Add : 1,
|
||||
|
@ -52,10 +51,16 @@ exports.getModule = class RumorzModule extends MenuModule {
|
|||
if(_.isString(formData.value.rumor) && renderStringLength(formData.value.rumor) > 0) {
|
||||
const rumor = formData.value.rumor.trim(); // remove any trailing ws
|
||||
|
||||
StatLog.appendSystemLogEntry(STATLOG_KEY_RUMORZ, rumor, StatLog.KeepDays.Forever, StatLog.KeepType.Forever, () => {
|
||||
StatLog.appendSystemLogEntry(
|
||||
SystemLogKeys.UserAddedRumorz,
|
||||
rumor,
|
||||
StatLog.KeepDays.Forever,
|
||||
StatLog.KeepType.Forever,
|
||||
() => {
|
||||
this.clearAddForm();
|
||||
return this.displayViewScreen(true, cb); // true=cls
|
||||
});
|
||||
}
|
||||
);
|
||||
} else {
|
||||
// empty message - treat as if cancel was hit
|
||||
return this.displayViewScreen(true, cb); // true=cls
|
||||
|
@ -149,7 +154,7 @@ exports.getModule = class RumorzModule extends MenuModule {
|
|||
function fetchEntries(callback) {
|
||||
const entriesView = self.viewControllers.view.getView(MciCodeIds.ViewForm.Entries);
|
||||
|
||||
StatLog.getSystemLogEntries(STATLOG_KEY_RUMORZ, StatLog.Order.Timestamp, (err, entries) => {
|
||||
StatLog.getSystemLogEntries(SystemLogKeys.UserAddedRumorz, StatLog.Order.Timestamp, (err, entries) => {
|
||||
return callback(err, entriesView, entries);
|
||||
});
|
||||
},
|
||||
|
@ -158,7 +163,7 @@ exports.getModule = class RumorzModule extends MenuModule {
|
|||
return {
|
||||
text : e.log_value, // standard
|
||||
rumor : e.log_value,
|
||||
}
|
||||
};
|
||||
}));
|
||||
|
||||
entriesView.redraw();
|
||||
|
|
|
@ -21,6 +21,8 @@ const copyFileWithCollisionHandling = require('../file_util.js').copyFileWit
|
|||
const getAreaStorageDirectoryByTag = require('../file_base_area.js').getAreaStorageDirectoryByTag;
|
||||
const isValidStorageTag = require('../file_base_area.js').isValidStorageTag;
|
||||
const User = require('../user.js');
|
||||
const StatLog = require('../stat_log.js');
|
||||
const SysProps = require('../system_property.js');
|
||||
|
||||
// deps
|
||||
const moment = require('moment');
|
||||
|
@ -1261,12 +1263,12 @@ function FTNMessageScanTossModule() {
|
|||
}
|
||||
}
|
||||
|
||||
// we do this after such that error cases can be preseved above
|
||||
// we do this after such that error cases can be preserved above
|
||||
if(lookupName !== message.toUserName) {
|
||||
message.toUserName = localUserName;
|
||||
}
|
||||
|
||||
// set the meta information - used elsehwere for retrieval
|
||||
// set the meta information - used elsewhere for retrieval
|
||||
message.meta.System[Message.SystemMetaNames.LocalToUserID] = localToUserId;
|
||||
return callback(null);
|
||||
});
|
||||
|
@ -1277,6 +1279,10 @@ function FTNMessageScanTossModule() {
|
|||
|
||||
// save to disc
|
||||
message.persist(err => {
|
||||
if(!message.isPrivate()) {
|
||||
StatLog.incrementNonPersistentSystemStat(SysProps.MessageTotalCount, 1);
|
||||
StatLog.incrementNonPersistentSystemStat(SysProps.MessagesToday, 1);
|
||||
}
|
||||
return callback(err);
|
||||
});
|
||||
}
|
||||
|
|
111
core/stat_log.js
111
core/stat_log.js
|
@ -5,9 +5,11 @@ const sysDb = require('./database.js').dbs.system;
|
|||
const {
|
||||
getISOTimestampString
|
||||
} = require('./database.js');
|
||||
const Errors = require('./enig_error.js');
|
||||
|
||||
// deps
|
||||
const _ = require('lodash');
|
||||
const moment = require('moment');
|
||||
|
||||
/*
|
||||
System Event Log & Stats
|
||||
|
@ -70,11 +72,23 @@ class StatLog {
|
|||
};
|
||||
}
|
||||
|
||||
// :TODO: fix spelling :)
|
||||
setNonPeristentSystemStat(statName, statValue) {
|
||||
setNonPersistentSystemStat(statName, statValue) {
|
||||
this.systemStats[statName] = statValue;
|
||||
}
|
||||
|
||||
incrementNonPersistentSystemStat(statName, incrementBy) {
|
||||
incrementBy = incrementBy || 1;
|
||||
|
||||
let newValue = parseInt(this.systemStats[statName]);
|
||||
if(!isNaN(newValue)) {
|
||||
newValue += incrementBy;
|
||||
} else {
|
||||
newValue = incrementBy;
|
||||
}
|
||||
this.setNonPersistentSystemStat(statName, newValue);
|
||||
return newValue;
|
||||
}
|
||||
|
||||
setSystemStat(statName, statValue, cb) {
|
||||
// live stats
|
||||
this.systemStats[statName] = statValue;
|
||||
|
@ -100,19 +114,7 @@ class StatLog {
|
|||
}
|
||||
|
||||
incrementSystemStat(statName, incrementBy, cb) {
|
||||
incrementBy = incrementBy || 1;
|
||||
|
||||
let newValue = parseInt(this.systemStats[statName]);
|
||||
if(newValue) {
|
||||
if(!_.isNumber(newValue)) {
|
||||
return cb(new Error(`Value for ${statName} is not a number!`));
|
||||
}
|
||||
|
||||
newValue += incrementBy;
|
||||
} else {
|
||||
newValue = incrementBy;
|
||||
}
|
||||
|
||||
const newValue = this.incrementNonPersistentSystemStat(statName, incrementBy);
|
||||
return this.setSystemStat(statName, newValue, cb);
|
||||
}
|
||||
|
||||
|
@ -217,13 +219,45 @@ class StatLog {
|
|||
);
|
||||
}
|
||||
|
||||
getSystemLogEntries(logName, order, limit, cb) {
|
||||
let sql =
|
||||
`SELECT timestamp, log_value
|
||||
FROM system_event_log
|
||||
WHERE log_name = ?`;
|
||||
/*
|
||||
Find System Log entries by |filter|:
|
||||
|
||||
switch(order) {
|
||||
filter.logName (required)
|
||||
filter.resultType = (obj) | count
|
||||
where obj contains timestamp and log_value
|
||||
filter.limit
|
||||
filter.date - exact date to filter against
|
||||
filter.order = (timestamp) | timestamp_asc | timestamp_desc | random
|
||||
*/
|
||||
findSystemLogEntries(filter, cb) {
|
||||
filter = filter || {};
|
||||
if(!_.isString(filter.logName)) {
|
||||
return cb(Errors.MissingParam('filter.logName is required'));
|
||||
}
|
||||
|
||||
filter.resultType = filter.resultType || 'obj';
|
||||
filter.order = filter.order || 'timestamp';
|
||||
|
||||
let sql;
|
||||
if('count' === filter.resultType) {
|
||||
sql =
|
||||
`SELECT COUNT() AS count
|
||||
FROM system_event_log`;
|
||||
} else {
|
||||
sql =
|
||||
`SELECT timestamp, log_value
|
||||
FROM system_event_log`;
|
||||
}
|
||||
|
||||
sql += ' WHERE log_name = ?';
|
||||
|
||||
if(filter.date) {
|
||||
filter.date = moment(filter.date);
|
||||
sql += ` AND DATE(timestamp, "localtime") = DATE("${filter.date.format('YYYY-MM-DD')}")`;
|
||||
}
|
||||
|
||||
if('count' !== filter.resultType) {
|
||||
switch(filter.order) {
|
||||
case 'timestamp' :
|
||||
case 'timestamp_asc' :
|
||||
sql += ' ORDER BY timestamp ASC';
|
||||
|
@ -235,8 +269,28 @@ class StatLog {
|
|||
|
||||
case 'random' :
|
||||
sql += ' ORDER BY RANDOM()';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(_.isNumber(filter.limit) && 0 !== filter.limit) {
|
||||
sql += ` LIMIT ${filter.limit}`;
|
||||
}
|
||||
|
||||
sql += ';';
|
||||
|
||||
if('count' === filter.resultType) {
|
||||
sysDb.get(sql, [ filter.logName ], (err, row) => {
|
||||
return cb(err, row ? row.count : 0);
|
||||
});
|
||||
} else {
|
||||
sysDb.all(sql, [ filter.logName ], (err, rows) => {
|
||||
return cb(err, rows);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
getSystemLogEntries(logName, order, limit, cb) {
|
||||
if(!cb && _.isFunction(limit)) {
|
||||
cb = limit;
|
||||
limit = 0;
|
||||
|
@ -244,15 +298,12 @@ class StatLog {
|
|||
limit = limit || 0;
|
||||
}
|
||||
|
||||
if(0 !== limit) {
|
||||
sql += ` LIMIT ${limit}`;
|
||||
}
|
||||
|
||||
sql += ';';
|
||||
|
||||
sysDb.all(sql, [ logName ], (err, rows) => {
|
||||
return cb(err, rows);
|
||||
});
|
||||
const filter = {
|
||||
logName,
|
||||
order,
|
||||
limit,
|
||||
};
|
||||
return this.findSystemLogEntries(filter, cb);
|
||||
}
|
||||
|
||||
appendUserLogEntry(user, logName, logValue, keepDays, cb) {
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
/* jslint node: true */
|
||||
'use strict';
|
||||
|
||||
//
|
||||
// Common SYSTEM/global log keys
|
||||
//
|
||||
module.exports = {
|
||||
UserAddedRumorz : 'system_rumorz',
|
||||
UserLoginHistory : 'user_login_history',
|
||||
};
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/* jslint node: true */
|
||||
'use strict';
|
||||
|
||||
//
|
||||
// Common SYSTEM/global properties/stats used throughout the system.
|
||||
//
|
||||
// This IS NOT a full list. Custom modules & the like can create
|
||||
// their own!
|
||||
//
|
||||
module.exports = {
|
||||
LoginCount : 'login_count',
|
||||
LoginsToday : 'logins_today', // non-persistent
|
||||
|
||||
FileBaseAreaStats : 'file_base_area_stats', // object - see file_base_area.js::getAreaStats
|
||||
FileUlTotalCount : 'ul_total_count',
|
||||
FileUlTotalBytes : 'ul_total_bytes',
|
||||
FileDlTotalCount : 'dl_total_count',
|
||||
FileDlTotalBytes : 'dl_total_bytes',
|
||||
|
||||
MessageTotalCount : 'message_post_total_count', // total non-private messages on the system; non-persistent
|
||||
MessagesToday : 'message_post_today', // non-private messages posted/imported today; non-persistent
|
||||
|
||||
// begin +op non-persistent...
|
||||
SysOpUsername : 'sysop_username',
|
||||
SysOpRealName : 'sysop_real_name',
|
||||
SysOpLocation : 'sysop_location',
|
||||
SysOpAffiliations : 'sysop_affiliation',
|
||||
SysOpSex : 'sysop_sex',
|
||||
SysOpEmailAddress : 'sysop_email_address',
|
||||
// end +op non-persistent
|
||||
|
||||
NextRandomRumor : 'random_rumor',
|
||||
};
|
|
@ -473,7 +473,9 @@ module.exports = class User {
|
|||
return this.removeProperty(name, next);
|
||||
},
|
||||
err => {
|
||||
if(cb) {
|
||||
return cb(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ const {
|
|||
ErrorReasons
|
||||
} = require('./enig_error.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
const SysProps = require('./system_property.js');
|
||||
const SystemLogKeys = require('./system_log.js');
|
||||
|
||||
// deps
|
||||
const async = require('async');
|
||||
|
@ -86,7 +88,8 @@ function userLogin(client, username, password, cb) {
|
|||
return callback(null);
|
||||
},
|
||||
function updateSystemLoginCount(callback) {
|
||||
return StatLog.incrementSystemStat('login_count', 1, callback); // :TODO: create system_property.js
|
||||
StatLog.incrementNonPersistentSystemStat(SysProps.LoginsToday, 1);
|
||||
return StatLog.incrementSystemStat(SysProps.LoginCount, 1, callback);
|
||||
},
|
||||
function recordLastLogin(callback) {
|
||||
return StatLog.setUserStat(user, UserProps.LastLoginTs, StatLog.now, callback);
|
||||
|
@ -102,7 +105,7 @@ function userLogin(client, username, password, cb) {
|
|||
});
|
||||
|
||||
return StatLog.appendSystemLogEntry(
|
||||
'user_login_history',
|
||||
SystemLogKeys.UserLoginHistory,
|
||||
historyItem,
|
||||
loginHistoryMax,
|
||||
StatLog.KeepType.Max,
|
||||
|
|
|
@ -65,12 +65,15 @@ for a full listing. Many codes attempt to pay homage to Oblivion/2, iNiQUiTY, et
|
|||
| `SC` | System CPU model |
|
||||
| `NV` | System underlying Node.js version |
|
||||
| `AN` | Current active node count |
|
||||
| `TC` | Total login/calls to system |
|
||||
| `TC` | Total login/calls to the system *ever* |
|
||||
| `TT` | Total login/calls to the system *today* |
|
||||
| `RR` | Displays a random rumor |
|
||||
| `SD` | Total downloads, system wide |
|
||||
| `SO` | Total downloaded amount, system wide (formatted to appropriate bytes/megs/etc.) |
|
||||
| `SU` | Total uploads, system wide |
|
||||
| `SP` | Total uploaded amount, system wide (formatted to appropriate bytes/megs/etc.) |
|
||||
| `TP` | Total messages posted/imported to the system *currently* |
|
||||
| `PT` | Total messages posted/imported to the system *today* |
|
||||
|
||||
Some additional special case codes also exist:
|
||||
|
||||
|
|
|
@ -3,9 +3,10 @@ layout: page
|
|||
title: ACS
|
||||
---
|
||||
## File Base ACS
|
||||
[ACS Codes](/docs/configuration/acs.md) may be used to control acess to File Base areas by specifying an `acs` string in a file area's definition. If no `acs` is supplied in a file area definition, the following defaults apply to an area:
|
||||
* `read` (list, download, etc.): `GM[users]`
|
||||
* `write` (upload): `GM[sysops]`
|
||||
[ACS Codes](/docs/configuration/acs.md) may be used to control access to File Base areas by specifying an `acs` string in a file area's definition. If no `acs` is supplied in a file area definition, the following defaults apply to an area:
|
||||
* `read` : `GM[users]`: List/view the area and it's contents.
|
||||
* `write` : `GM[sysops]`: Upload.
|
||||
* `download` : `GM[users]`: Download.
|
||||
|
||||
To override read and/or write ACS, supply a valid `acs` member.
|
||||
|
||||
|
@ -18,8 +19,13 @@ areas: {
|
|||
desc: Oldschool PC/DOS
|
||||
storageTags: [ "retro_pc", "retro_pc_bbs" ]
|
||||
acs: {
|
||||
write: GM[users]
|
||||
// only users of the "l33t" group or those who have
|
||||
// uploaded 10+ files can download from here...
|
||||
download: GM[l33t]|UP10
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## See Also
|
||||
[Access Condition System (ACS)](/docs/configuration/acs.md)
|
||||
|
|
|
@ -2,18 +2,21 @@
|
|||
layout: page
|
||||
title: About File Areas
|
||||
---
|
||||
## A Different Approach
|
||||
ENiGMA½ has strayed away from the old familure setup here and instead takes a more modern approach:
|
||||
* [Gazelle](https://whatcd.github.io/Gazelle/) inspired system for searching & browsing files
|
||||
* No File Conferences (just areas!)
|
||||
* File Areas are still around but should generally be used less. Instead, files can have one or more tags. Think things like `dos.retro`, `pc.warez`, `games`, etc.
|
||||
* Temporary web (http:// or https://) download links in additional to standard X/Y/Z protocol support
|
||||
* Users can star rate files & search/filter by ratings
|
||||
* Concept of user defined filters
|
||||
## About File Areas
|
||||
|
||||
## Other bells and whistles
|
||||
* A given area can span one to many physical storage locations
|
||||
* Upload processor can extract and use `FILE_ID.DIZ`/`DESC.SDI`, for standard descriptions as well as `README.TXT`, `*.NFO`, and so on for longer descriptions
|
||||
* Upload processor also attempts release year estimation by scanning prementioned description file(s)
|
||||
* Fast indexed Full Text Search (FTS)
|
||||
* Duplicates validated by SHA-256
|
||||
### A Different Approach
|
||||
ENiGMA½ has strayed away from the old familiar setup here and instead takes a more modern approach:
|
||||
* [Gazelle](https://whatcd.github.io/Gazelle/) inspired system for searching & browsing files.
|
||||
* No conferences (just areas!)
|
||||
* File areas are still around but should *generally* be used less. Instead, files can have one or more tags. Think things like `dos.retro`, `pc.warez`, `games`, etc.
|
||||
|
||||
### Other bells and whistles
|
||||
* Temporary web (http:// or https://) download links in additional to standard X/Y/Z protocol support. Batch downloads of many files can be downloaded as a single ZIP archive.
|
||||
* Users can rate files & search/filter by ratings.
|
||||
* Users can also create and save their own filters for later use such as "Latest Artscene Releases" or "C64 SIDs".
|
||||
* A given area can span one to many physical storage locations.
|
||||
* Upload processor can extract and use `FILE_ID.DIZ`/`DESC.SDI`, for standard descriptions as well as `README.TXT`, `*.NFO`, and so on for longer descriptions. The processor also attempts release year estimation by scanning aforementioned description file(s).
|
||||
* Fast indexed [Full Text Search (FTS)](https://sqlite.org/fts3.html) across descriptions and filenames.
|
||||
* Duplicates are checked for by cryptographically secure [SHA-256](https://en.wikipedia.org/wiki/SHA-2) hashes.
|
||||
* Support for many archive and file formats. External utilities can easily be added to the configuration to extend for additional formats.
|
||||
* Much, much more!
|
||||
|
|
|
@ -2,7 +2,24 @@
|
|||
layout: page
|
||||
title: Uploads
|
||||
---
|
||||
## Uploads
|
||||
The default ACS for file areas areas in ENiGMA½ is to allow read (viewing of the area), and downloads for users while only permitting SysOps to write (upload). See [File Base ACS](acs.md) for more information.
|
||||
|
||||
Note that `storageTags` may contain *1:n* storage tag references.
|
||||
To allow uploads to a particular area, change the ACS level for `write`. For example:
|
||||
```hjson
|
||||
uploads: {
|
||||
name: Uploads
|
||||
desc: User Uploads
|
||||
storageTags: [
|
||||
"uploads"
|
||||
]
|
||||
acs: {
|
||||
write: GM[users]
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
:information_source: Remember that uploads in a particular area are stored **using the first storage tag defined in that area.**
|
||||
|
||||
:information_source: Any ACS checks are allowed. See [ACS](/docs/acs.md)
|
||||
|
||||
**Uploads in a particular area are stored in the first storage tag defined in an area.**
|
||||
|
|
Loading…
Reference in New Issue