Skip to content
Snippets Groups Projects
Commit 1ddc052e authored by Michael Long's avatar Michael Long
Browse files

update doorscan to work with current synchronet

parent 99346600
No related branches found
No related tags found
2 merge requests!463MRC mods by Codefenix (2024-10-20),!79update doorscan to work with current synchronet pre/post xtrn modules
Pipeline #1191 passed
...@@ -707,6 +707,8 @@ while(bbs.online) { ...@@ -707,6 +707,8 @@ while(bbs.online) {
} }
stop_mouse(); stop_mouse();
clear_screen(); clear_screen();
// uncomment to use doorscan
/*
if(file_exists("../xtrn/doorscan/doorscan.js")) { if(file_exists("../xtrn/doorscan/doorscan.js")) {
try { try {
load("../xtrn/doorscan/doorscan.js","run",xtrn_area.sec_list[curr_xtrnsec].prog_list[parseInt(x_prog)].code); load("../xtrn/doorscan/doorscan.js","run",xtrn_area.sec_list[curr_xtrnsec].prog_list[parseInt(x_prog)].code);
...@@ -719,6 +721,9 @@ while(bbs.online) { ...@@ -719,6 +721,9 @@ while(bbs.online) {
else { else {
bbs.exec_xtrn(xtrn_area.sec_list[curr_xtrnsec].prog_list[parseInt(x_prog)].number); bbs.exec_xtrn(xtrn_area.sec_list[curr_xtrnsec].prog_list[parseInt(x_prog)].number);
} }
*/
// remove next line if using doorscan
bbs.exec_xtrn(xtrn_area.sec_list[curr_xtrnsec].prog_list[parseInt(x_prog)].number);
start_mouse(); start_mouse();
draw_main(true); draw_main(true);
xtrnsec.draw(); xtrnsec.draw();
......
<!-- HIDDEN:Door Statistics -->
<html>
<head>
<title>Monthly Door Log for <?xjs write(system.name) ?></title>
</head>
<body>
<?xjs
load("/sbbs/xtrn/doorscan/doorscan.js");
var lp=new LogParser();
if (typeof settings.xtrn_blacklist === 'string') {
settings.xtrn_blacklist = settings.xtrn_blacklist.toLowerCase().split(',');
} else {
settings.xtrn_blacklist = [];
}
settings.xtrn_blacklist.push('doorscfg');
settings.xtrn_blacklist.push('doorstat');
settings.xtrn_blacklist.push('doorsta');
var doors = [];
xtrn_area.sec_list.forEach(function (sec) {
if (!sec.can_access || sec.prog_list.length < 1) return;
if (settings.xtrn_blacklist.indexOf(sec.code.toLowerCase()) > -1) return;
sec.prog_list.forEach(function (prog) {
if (!prog.can_access || !prog.can_run) return;
if (settings.xtrn_blacklist.indexOf(prog.code.toLowerCase()) > -1) return;
doors.push(prog.code);
});
});
?>
<div class="well well-sm"><h3>Door Statistics</h3></div>
<div class="list-group" style="margin-top:1em;">
<table class="table table-condensed table-responsive">
<tr>
<th>Door Name</th>
<th>Users</th>
<th>Times Played</th>
<th>Time Spent Playing</th>
<tr>
<?xjs
var alldoors=new Array();
var since=new Date();
since.setMonth(since.getMonth()-1);
doors.forEach(function (door) {
var tr=lp.usersOfSince(door, since);
if(tr.total > 0)
alldoors.push(tr);
});
alldoors=alldoors.sort(function (a,b) {
return(b.total-a.total);
});
for(door in alldoors) {
?>
<tr>
<td><?xjs write(xtrn_area.prog[alldoors[door].prog].name) ?></td>
<td align="center"><?xjs write(alldoors[door].users) ?></td>
<td align="center"><?xjs write(alldoors[door].total) ?></td>
<td align="center"><?xjs write(system.secondstr(alldoors[door].total_duration)) ?></td>
</tr>
<?xjs
}
?>
</table>
</div>
</body>
</html>
...@@ -2,10 +2,7 @@ load("sbbsdefs.js"); ...@@ -2,10 +2,7 @@ load("sbbsdefs.js");
load("text.js"); load("text.js");
load("lockfile.js"); load("lockfile.js");
var doorscan_dir='.'; var doorscan_dir = js.exec_dir;
try { throw barfitty.barf(barf) } catch(e) { doorscan_dir=e.fileName }
doorscan_dir=doorscan_dir.replace(/[\/\\][^\/\\]*$/,'');
doorscan_dir=backslash(doorscan_dir);
function LockedOpen(filename, fmode) function LockedOpen(filename, fmode)
{ {
...@@ -945,6 +942,7 @@ function sysop_config() ...@@ -945,6 +942,7 @@ function sysop_config()
} }
} }
// deprecated, use pre/post instead
function runXtrn(xtrn) function runXtrn(xtrn)
{ {
if(xtrn_area.prog[xtrn]==undefined) if(xtrn_area.prog[xtrn]==undefined)
...@@ -998,6 +996,60 @@ function runXtrn(xtrn) ...@@ -998,6 +996,60 @@ function runXtrn(xtrn)
ucfg.save(); ucfg.save();
} }
function runPre(xtrn)
{
if(xtrn_area.prog[xtrn]==undefined)
throw("Unknown external: "+xtrn);
if(!xtrn_area.prog[xtrn].can_run)
throw("User "+user.name+" is not allowed to run "+xtrn);
var now=new Date();
var dcfg=new DoorConfig(true);
dcfg.door[xtrn].lastRan=now;
dcfg.door[xtrn].runCount++;
dcfg.save();
var ucfg=new UserConfig(user.number, true);
if(ucfg.door[xtrn] == undefined) {
if(ucfg.global == undefined || (!ucfg.global.noAutoScan)) {
ucfg.addxtrn(xtrn);
}
}
if(ucfg.door[xtrn] != undefined)
ucfg.door[xtrn].lastRan=now;
ucfg.save();
if(!(dcfg.door[xtrn]!=undefined && dcfg.door[xtrn].skip != undefined && dcfg.door[xtrn].skip)
|| !(dcfg.skipSection[xtrn_area.prog[xtrn].sec_code]!=undefined && dcfg.skipSection[xtrn_area.prog[xtrn].sec_code])) {
bbs.log_str("DOORSCAN - "+xtrn+" starting @ "+now.toString()+"\r\n");
}
}
function runPost(xtrn)
{
now=new Date();
dcfg=new DoorConfig(true);
if(!(dcfg.door[xtrn]!=undefined && dcfg.door[xtrn].skip != undefined && dcfg.door[xtrn].skip)
&& !(dcfg.skipSection[xtrn_area.prog[xtrn].sec_code]!=undefined && dcfg.skipSection[xtrn_area.prog[xtrn].sec_code])) {
bbs.log_str("DOORSCAN - "+xtrn+" ending @ "+now.toString()+"\r\n");
}
dcfg.door[xtrn].lastExit=now;
dcfg.save();
ucfg=new UserConfig(user.number, true);
if(ucfg.door[xtrn] != undefined) {
ucfg.door[xtrn].lastExit=now;
ucfg.door[xtrn].lastRunCount=dcfg.door[xtrn].runCount;
}
ucfg.save();
}
function doScan() function doScan()
{ {
var dcfg=new DoorConfig(); var dcfg=new DoorConfig();
...@@ -1151,14 +1203,28 @@ function doScan() ...@@ -1151,14 +1203,28 @@ function doScan()
ucfg.save(); ucfg.save();
} }
for(i in argv) {
switch(argv[i].toLowerCase()) { if (argv[0] && argv[0].length) {
switch(argv[0].toLowerCase()) {
case 'scan': case 'scan':
doScan(); doScan();
break; break;
case 'pre':
if(argv[1])
runPre(argv[1].toLowerCase());
else
throw("XTRN code not included on command-line!");
break;
case 'post':
if(argv[1])
runPost(argv[1].toLowerCase());
else
throw("XTRN code not included on command-line!");
break;
case 'run': case 'run':
if(i+1<argc) // deprecated
runXtrn(argv[++i].toLowerCase()); if(argv[1])
runXtrn(argv[1].toLowerCase());
else else
throw("XTRN code not included on command-line!"); throw("XTRN code not included on command-line!");
break; break;
...@@ -1171,5 +1237,7 @@ for(i in argv) { ...@@ -1171,5 +1237,7 @@ for(i in argv) {
case 'rank': case 'rank':
// TODO: Door popularity rankings // TODO: Door popularity rankings
break; break;
default:
break;
} }
} }
This version of doorscan has been updated to work with the new pre/post
xtrn modules, and a file locking issue that would crash webv4 has also been
fixed. A new webv4 module has been added. No other functionality has been added.
Current unfinished status of doorscan:
1. It will scan for door usage and display it on the web page only
2. There is no logon/terminal module to display door usage
3. The bulletin functionality was never implemented
4. The user preferences may not be fully implemented
5. It really ought to be converted to use JSONDB
-----
DoorScan is a utility to notify users of which externals have been ran, how DoorScan is a utility to notify users of which externals have been ran, how
often, and by whom. often, and by whom.
To function properly, doorscan must be used to launch all the monitored doors To function properly, doorscan must be used to launch all the monitored doors
on your BBS. Integrating doorscan into your BBS is done as follows: on your BBS. Integrating doorscan into your BBS is done as follows:
Setting up the login event: 1. Add to modopts.ini under [xtrn_sec]
===========================
The actual scan should be ran during the users login. There are a few eval_before_exec=js.exec("/sbbs/xtrn/doorscan/doorscan.js",{},"pre",prog.code);
different ways of accomplishing this: eval_after_exec=js.exec("/sbbs/xtrn/doorscan/doorscan.js",{},"post",prog.code);
1) As a logon fixed event:
(If you are upgrading from a prior version of doorscan, it should still work but the
preferred method would be to remove the doorscan.js run call from your shell and use
the above hooks)
2. Scan for new doors
The command to scan for new doors is:
/sbbs/exec/jsexec.js /sbbs/xtrn/doorscan/doorscan.js scan
You have many options:
-Run it manually when you add a door
-Add it to crontab (for Linux)
-Run it as a fixed login or daily event. Example:
SCFG -> External Programs -> Fixed Events -> Logon Event SCFG -> External Programs -> Fixed Events -> Logon Event
Set to "*../xtrn/doorscan/doorscan.js scan" Set to "*../xtrn/doorscan/doorscan.js scan"
2) As an External -Add it as an external to be run manually:
SCFG -> External Programs -> Online Programs (Doors) -> Main SCFG -> External Programs -> Online Programs (Doors) -> Main
-> Available Online Programs -> Add -> Available Online Programs -> Add
...@@ -34,26 +61,18 @@ different ways of accomplishing this: ...@@ -34,26 +61,18 @@ different ways of accomplishing this:
BBS Drop File Type None BBS Drop File Type None
Place Drop File In Node Directory Place Drop File In Node Directory
3) In your logon script. 3. Enable the web interface
For logon.js, add the following line where appropriate:
load("../xtrn/doorscan/doorscan.js","scan"); For original web (ie runemaster), copy doorscan.xjs to your web root
Integrating Doorscan Into your Shell For webv4, edit webv4/pages/More/003-doorscan.xjs and remove the HIDDEN from
==================================== the comment:
If your shell uses xtrn_sec.js (as most do) edit xtrn_sec.js and look for the
line "bbs.exec_xtrn(xtrn_area.sec_list[xsec].prog_list[i].code);" <!-- HIDDEN:Door Statistics -->
Comment out that line and replace it with:
//bbs.exec_xtrn(xtrn_area.sec_list[xsec].prog_list[i].code); so it becomes
try {
load("../xtrn/doorscan/doorscan.js","run",xtrn_area.sec_list[xsec].prog_list[i].code); <!-- Door Statistics -->
}
catch(e) {
console.writeln("DOORSCAN ERROR: "+e);
log("Error running "+xtrn_area.sec_list[xsec].prog_list[i].code+" "+e);
}
If your shell does not use xtrn_sec.js, you should be able to figure out how to
modify it to accomlish the same end.
Adding a Door Scan Configuration Item Adding a Door Scan Configuration Item
===================================== =====================================
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment