From 60f8a4c05225b85aabb103be0ce8398ea4043c29 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Thu, 29 Nov 2001 03:59:06 +0000
Subject: [PATCH] New user properties: logontime and curxtrn (re-commited due
 to cvs failure).

---
 exec/fingerservice.js  | 26 +++++++++++++++++++-------
 exec/nodelist-html.js  | 28 ++++++++++++++++++----------
 src/sbbs3/js_user.c    | 16 +++++++++++++++-
 src/sbbs3/logon.cpp    |  1 +
 src/sbbs3/sbbsdefs.h   | 17 ++++++++++-------
 src/sbbs3/userdat.c    | 12 +++++++-----
 src/sbbs3/xtrn_sec.cpp |  1 +
 7 files changed, 71 insertions(+), 30 deletions(-)

diff --git a/exec/fingerservice.js b/exec/fingerservice.js
index cb0f8d691f..877711e456 100644
--- a/exec/fingerservice.js
+++ b/exec/fingerservice.js
@@ -80,11 +80,11 @@ while(request.charAt(0)==' ')	// skip prepended spaces
 
 if(request=="") {	// no specific user requested, give list of active users
 	log("client requested active user list");
-	write(format("%-25.25s %-40.40s %7s Node\r\n"
+	write(format("%-25.25s %-31.31s   Time   %7s Node\r\n"
 		,"User","Action",include_age_gender ? "Age Sex":""));
 	var dashes="----------------------------------------";
-	write(format("%-25.25s %-40.40s %3.3s %3.3s %4.4s\r\n"
-		,dashes,dashes
+	write(format("%-25.25s %-31.31s %8.8s %3.3s %3.3s %4.4s\r\n"
+		,dashes,dashes,dashes
 		,include_age_gender ? dashes : ""
 		,include_age_gender ? dashes : ""
 		,dashes));
@@ -93,11 +93,18 @@ if(request=="") {	// no specific user requested, give list of active users
 		if(system.node_list[n].status!=NODE_INUSE)
 			continue;
 		user.number=system.node_list[n].useron;
-		var action=format(NodeAction[system.node_list[n].action]
-			,system.node_list[n].aux);
-		write(format("%-25.25s %-40.40s %3s %3s %4d\r\n"
+		if(system.node_list[n].action==NODE_XTRN && system.node_list[n].aux)
+			action=format("running %s",user.curxtrn);
+		else
+			action=format(NodeAction[system.node_list[n].action]
+							,system.node_list[n].aux);
+		t=time()-user.logontime;
+		write(format("%-25.25s %-31.31s%3u:%02u:%02u %3s %3s %4d\r\n"
 			,user.alias
 			,action
+			,Math.floor(t/(60*60))
+			,Math.floor(t/60)%60
+			,t%60
 			,include_age_gender ? user.age.toString() : ""
 			,include_age_gender ? user.gender : ""
 			,n+1
@@ -154,7 +161,12 @@ if(request.charAt(0)=='?') {	// Handle "special" requests
 				if(system.node_list[n].status==NODE_INUSE) {
 					user.number=system.node_list[n].useron;
 					write(format("%s (%u %s) ", user.alias, user.age, user.gender));
-					write(format(NodeAction[system.node_list[n].action],system.node_list[n].aux));
+					if(system.node_list[n].action==NODE_XTRN && system.node_list[n].aux)
+						write(format("running %s",user.curxtrn));
+					else
+						write(format(NodeAction[system.node_list[n].action],system.node_list[n].aux));
+					t = time()-user.logontime;
+					write(format(" for %u minutes",Math.floor(t/60)));
 				} else
 					write(format(NodeStatus[system.node_list[n].status],system.node_list[n].aux));
 
diff --git a/exec/nodelist-html.js b/exec/nodelist-html.js
index 99be5882e7..dd8d096295 100644
--- a/exec/nodelist-html.js
+++ b/exec/nodelist-html.js
@@ -40,16 +40,8 @@ writeln(format("<title>%s BBS - Node List</title>",system.name));
 writeln(format("<meta http-equiv=refresh content=%d>",refresh_rate));
 writeln("</head>");
 
-writeln("<font face=Arial,Helvetica,sans-serif>");
 writeln("<body bgcolor=teal text=white link=yellow vlink=lime alink=white>");
-
-// Login Button
-writeln("<form>");
-writeln("<table align=right>");
-writeln("<td><input type=button value='Login' onClick='location=\"telnet://" 
-	+ system.inetaddr + "\";'>"); 
-writeln("</table>");
-writeln("</form>");
+writeln("<font face=Arial,Helvetica,sans-serif>");
 
 // Table
 writeln("<table border=0 width=100%>");
@@ -67,6 +59,7 @@ write(format("<th align=center width=20%>%sUser",font_color));
 write(format("<th align=left>%sAction/Status",font_color));
 write(format("<th align=center width=7%>%sAge",font_color));
 write(format("<th align=center width=10%>%sGender\r\n",font_color));
+write(format("<th align=center width=10%>%sTime\r\n",font_color));
 writeln("</thead>");
 
 writeln("<tbody>");
@@ -77,7 +70,7 @@ for(n=0;n<system.node_list.length;n++) {
 	if(system.node_list[n].status==NODE_INUSE) {
 		user.number=system.node_list[n].useron;
 		if(system.node_list[n].action==NODE_XTRN && system.node_list[n].aux)
-			action=format("running external program (door) #%d",system.node_list[n].aux);
+			action=format("running %s",user.curxtrn);
 		else
 			action=format(NodeAction[system.node_list[n].action]
 				,system.node_list[n].aux);
@@ -92,6 +85,13 @@ for(n=0;n<system.node_list.length;n++) {
 			,user.age
 			,user.gender
 			));
+		t=time()-user.logontime;
+		write(format(
+			"<td align=center>%u:%02u:%02u"
+			,Math.floor(t/(60*60))
+			,Math.floor(t/60)%60
+			,t%60
+			));
 	} else {
 		action=format(NodeStatus[system.node_list[n].status],system.node_list[n].aux);
 		write(format("<td><td>%s",action));
@@ -101,6 +101,14 @@ for(n=0;n<system.node_list.length;n++) {
 writeln("</tbody>");
 writeln("</table>");
 
+// Login Button
+writeln("<form>");
+writeln("<table align=right>");
+writeln("<tr><td><input type=button value='Login' onClick='location=\"telnet://" 
+	+ system.inetaddr + "\";'>"); 
+writeln("</table>");
+writeln("</form>");
+
 writeln("<p><font color=silver><font size=-2>");
 writeln(format("Auto-refresh in %d seconds",refresh_rate));
 write(format("<br>Dynamically generated in %lu milliseconds "
diff --git a/src/sbbs3/js_user.c b/src/sbbs3/js_user.c
index d4a7c4b39a..00c2321fed 100644
--- a/src/sbbs3/js_user.c
+++ b/src/sbbs3/js_user.c
@@ -101,6 +101,7 @@ enum {
 	,USER_PROP_LEECH 	
 	,USER_PROP_CURSUB	
 	,USER_PROP_CURDIR	
+	,USER_PROP_CURXTRN
 	,USER_PROP_FREECDT	
 	,USER_PROP_XEDIT 	
 	,USER_PROP_SHELL 	
@@ -109,6 +110,7 @@ enum {
 	,USER_PROP_CHAT		
 	,USER_PROP_NS_TIME	
 	,USER_PROP_PROT		
+	,USER_PROP_LOGONTIME
 };
 
 static JSBool js_user_get(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
@@ -284,6 +286,10 @@ static JSBool js_user_get(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
 		case USER_PROP_CURDIR:
 			s=user.curdir;
 			break;
+		case USER_PROP_CURXTRN:
+			s=user.curxtrn;
+			break;
+
 		case USER_PROP_FREECDT:
 			val=user.freecdt;
 			break;
@@ -306,12 +312,16 @@ static JSBool js_user_get(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
 			val=user.chat;
 			break;
 		case USER_PROP_NS_TIME:
-			val=user.laston;
+			val=user.ns_time;
 			break;
 		case USER_PROP_PROT:
 			sprintf(tmp,"%c",user.prot);
 			s=tmp;
 			break;
+		case USER_PROP_LOGONTIME:
+			val=user.logontime;
+			break;
+
 		default:	
 			/* This must not set vp in order for child objects to work (stats and security) */
 			return(JS_TRUE);
@@ -407,6 +417,9 @@ static JSBool js_user_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
 		case USER_PROP_CURDIR:	 
 			putuserrec(p->cfg,p->usernumber,U_CURDIR,8,strupr(str));
 			break;
+		case USER_PROP_CURXTRN:	 
+			putuserrec(p->cfg,p->usernumber,U_CURXTRN,8,strupr(str));
+			break;
 		case USER_PROP_XEDIT: 	 
 			putuserrec(p->cfg,p->usernumber,U_XEDIT,8,strupr(str));
 			break;
@@ -520,6 +533,7 @@ static struct JSPropertySpec js_user_properties[] = {
 	{	"gender"			,USER_PROP_SEX		 	,USER_PROP_FLAGS,		NULL,NULL},
 	{	"cursub"			,USER_PROP_CURSUB	 	,USER_PROP_FLAGS,		NULL,NULL},
 	{	"curdir"			,USER_PROP_CURDIR	 	,USER_PROP_FLAGS,		NULL,NULL},
+	{	"curxtrn"			,USER_PROP_CURXTRN	 	,USER_PROP_FLAGS,		NULL,NULL},
 	{	"editor"			,USER_PROP_XEDIT 	 	,USER_PROP_FLAGS,		NULL,NULL},
 	{	"command_shell"		,USER_PROP_SHELL 	 	,USER_PROP_FLAGS,		NULL,NULL},
 	{	"settings"			,USER_PROP_MISC		 	,USER_PROP_FLAGS,		NULL,NULL},
diff --git a/src/sbbs3/logon.cpp b/src/sbbs3/logon.cpp
index c919a20eda..6f8b51f8bc 100644
--- a/src/sbbs3/logon.cpp
+++ b/src/sbbs3/logon.cpp
@@ -194,6 +194,7 @@ bool sbbs_t::logon()
 	logon_ml=useron.level;
 	logontime=time(NULL);
 	starttime=logontime;
+	useron.logontime=logontime;
 	last_ns_time=ns_time=useron.ns_time;
 	// ns_time-=(useron.tlast*60); /* file newscan time == last logon time */
 	delfiles(cfg.temp_dir,ALLFILES);
diff --git a/src/sbbs3/sbbsdefs.h b/src/sbbs3/sbbsdefs.h
index a8a368cbeb..f58b852e61 100644
--- a/src/sbbs3/sbbsdefs.h
+++ b/src/sbbs3/sbbsdefs.h
@@ -462,7 +462,7 @@ typedef enum {						/* Values for xtrn_t.event			*/
 #define LEN_FDESC		58	/* File description 						*/
 #define LEN_FCDT		 9	/* 9 digits for file credit values			*/
 #define LEN_TITLE		70	/* Message title							*/
-#define LEN_MAIN_CMD	40	/* Storage in user.dat for custom commands	*/
+#define LEN_MAIN_CMD	34	/* Storage in user.dat for custom commands	*/
 #define LEN_XFER_CMD	40
 #define LEN_SCAN_CMD	40
 #define LEN_MAIL_CMD	40
@@ -529,8 +529,8 @@ typedef enum {						/* Values for xtrn_t.event			*/
 #define U_LEECH 	U_OLDXEDIT+2 	/* two hex digits - leech attempt count */
 #define U_CURSUB	U_LEECH+2  	/* Current sub (internal code  */
 #define U_CURDIR	U_CURSUB+8 	/* Current dir (internal code  */
-#define U_CMDSET	U_CURDIR+8 	/* unused */
-#define U_MAIN_CMD	U_CMDSET+2+2 	/* unused */
+#define U_CURXTRN	U_CURDIR+8 	/* unused */
+#define U_MAIN_CMD	U_CURXTRN+8+2 	/* unused */
 #define U_XFER_CMD	U_MAIN_CMD+LEN_MAIN_CMD 		/* unused */
 #define U_SCAN_CMD	U_XFER_CMD+LEN_XFER_CMD+2  	/* unused */
 #define U_MAIL_CMD	U_SCAN_CMD+LEN_SCAN_CMD 		/* unused */
@@ -544,8 +544,9 @@ typedef enum {						/* Values for xtrn_t.event			*/
 #define U_CHAT		U_TMPEXT+3 	/* Chat settings */
 #define U_NS_TIME	U_CHAT+8 		/* New-file scan date/time */
 #define U_PROT		U_NS_TIME+8 	/* Default transfer protocol */
-#define U_UNUSED	U_PROT+1
-#define U_LEN		(U_UNUSED+28+2)
+#define U_LOGONTIME	U_PROT+1
+#define U_UNUSED	U_LOGONTIME+8
+#define U_LEN		(U_UNUSED+20+2)
 
 /****************************************************************************/
 /* Offsets into DIR .DAT file for different fields for each file 			*/
@@ -882,7 +883,8 @@ typedef struct {						/* Users information */
 			tmpext[4],					/* QWK Packet extension */
 			comment[LEN_COMMENT+1], 	/* Private comment about user */
 			cursub[9],					/* Current sub-board internal code */
-			curdir[9];					/* Current directory internal code */
+			curdir[9],					/* Current directory internal code */
+			curxtrn[9];					/* Current external program internal code */
 
 	uchar	level,						/* Security level */
 			sex,						/* Sex - M or F */
@@ -908,7 +910,8 @@ typedef struct {						/* Users information */
 			laston, 					/* Last logoff date/time */
 			expire, 					/* Expiration date */
 			pwmod,						/* Password last modified */
-			ns_time;					/* Date/Time of last new file scan */
+			ns_time,					/* Date/Time of last new file scan */
+			logontime;					/* Time of current logon */
 
 } user_t;
 
diff --git a/src/sbbs3/userdat.c b/src/sbbs3/userdat.c
index dbf9aa4011..4a05bccbf3 100644
--- a/src/sbbs3/userdat.c
+++ b/src/sbbs3/userdat.c
@@ -195,6 +195,7 @@ int DLLCALL getuserdat(scfg_t* cfg, user_t *user)
 	user->ns_time=ahtoul(str);
 	if(user->ns_time<0x20000000L)
 		user->ns_time=user->laston;  /* Fix for v2.00->v2.10 */
+	getrec(userdat,U_LOGONTIME,8,str); user->logontime=ahtoul(str);
 
 	getrec(userdat,U_LOGONS,5,str); user->logons=atoi(str);
 	getrec(userdat,U_LTODAY,5,str); user->ltoday=atoi(str);
@@ -235,8 +236,9 @@ int DLLCALL getuserdat(scfg_t* cfg, user_t *user)
 
 	getrec(userdat,U_LEECH,2,str);
 	user->leech=(uchar)ahtoul(str);
-	getrec(userdat,U_CURSUB,8,user->cursub);	/* was useron.cursub (01/19/00) */
-	getrec(userdat,U_CURDIR,8,user->curdir);	/* was useron.curdir (01/19/00) */
+	getrec(userdat,U_CURSUB,8,user->cursub);
+	getrec(userdat,U_CURDIR,8,user->curdir);
+	getrec(userdat,U_CURXTRN,8,user->curxtrn);
 
 	getrec(userdat,U_FREECDT,10,str);
 	user->freecdt=atol(str);
@@ -379,9 +381,8 @@ int DLLCALL putuserdat(scfg_t* cfg, user_t* user)
 
 	putrec(userdat,U_CURSUB,8,user->cursub);
 	putrec(userdat,U_CURDIR,8,user->curdir);
-
-	// putrec(userdat,U_CMDSET,2,ultoa(user->cmdset,str,16)); /* Unused */
-	putrec(userdat,U_CMDSET+2,2,crlf);
+	putrec(userdat,U_CURXTRN,8,user->curxtrn);
+	putrec(userdat,U_CURXTRN+8,2,crlf);
 
 	putrec(userdat,U_XFER_CMD+LEN_XFER_CMD,2,crlf);
 
@@ -403,6 +404,7 @@ int DLLCALL putuserdat(scfg_t* cfg, user_t* user)
 	putrec(userdat,U_TMPEXT,3,user->tmpext);
 	putrec(userdat,U_CHAT,8,ultoa(user->chat,str,16));
 	putrec(userdat,U_NS_TIME,8,ultoa(user->ns_time,str,16));
+	putrec(userdat,U_LOGONTIME,8,ultoa(user->logontime,str,16));
 
 	putrec(userdat,U_UNUSED,29,crlf);
 	putrec(userdat,U_UNUSED+29,2,crlf);
diff --git a/src/sbbs3/xtrn_sec.cpp b/src/sbbs3/xtrn_sec.cpp
index 86c2f88d04..a371ce7e41 100644
--- a/src/sbbs3/xtrn_sec.cpp
+++ b/src/sbbs3/xtrn_sec.cpp
@@ -1416,6 +1416,7 @@ bool sbbs_t::exec_xtrn(uint xtrnnum)
 	thisnode.aux=xtrnnum+1;
 	thisnode.action=NODE_XTRN;
 	putnodedat(cfg.node_num,&thisnode);
+	putuserrec(&cfg,useron.number,U_CURXTRN,8,cfg.xtrn[xtrnnum]->code);
 
 	if(cfg.xtrn[xtrnnum]->misc&REALNAME)
 		strcpy(name,useron.name);
-- 
GitLab