Skip to content
Snippets Groups Projects
js_user.c 45.4 KiB
Newer Older
/* Synchronet JavaScript "User" Object */
/* $Id: js_user.c,v 1.119 2020/08/11 03:54:58 rswindell Exp $ */

/****************************************************************************
 * @format.tab-size 4		(Plain Text/Source Code File Header)			*
 * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
 *																			*
 * Copyright Rob Swindell - http://www.synchro.net/copyright.html			*
 *																			*
 * This program is free software; you can redistribute it and/or			*
 * modify it under the terms of the GNU General Public License				*
 * as published by the Free Software Foundation; either version 2			*
 * of the License, or (at your option) any later version.					*
 * See the GNU General Public License for more details: gpl.txt or			*
 * 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				*
 * 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.	*
 ****************************************************************************/

#include "sbbs.h"
rswindell's avatar
rswindell committed
	BOOL		cached;
	client_t*	client;
	int			file;		// for fast read operations, only
/* User Object Properties */
rswindell's avatar
rswindell committed
	 USER_PROP_NUMBER
	,USER_PROP_ALIAS 	
	,USER_PROP_NAME		
	,USER_PROP_HANDLE	
	,USER_PROP_NOTE		
deuce's avatar
deuce committed
	,USER_PROP_IPADDR
	,USER_PROP_COMP		
	,USER_PROP_COMMENT	
	,USER_PROP_NETMAIL	
	,USER_PROP_ADDRESS	
	,USER_PROP_LOCATION	
	,USER_PROP_ZIPCODE
	,USER_PROP_PASS
	,USER_PROP_PHONE  	
	,USER_PROP_BIRTH
	,USER_PROP_BIRTHYEAR
	,USER_PROP_BIRTHMONTH
	,USER_PROP_BIRTHDAY
	,USER_PROP_AGE		/* READ ONLY */
	,USER_PROP_MODEM     
	,USER_PROP_LASTON	
	,USER_PROP_FIRSTON	
	,USER_PROP_EXPIRE    
	,USER_PROP_PWMOD     
	,USER_PROP_LOGONS    
	,USER_PROP_LTODAY    
	,USER_PROP_TIMEON    
	,USER_PROP_TEXTRA  	
	,USER_PROP_TTODAY    
	,USER_PROP_TLAST     
	,USER_PROP_POSTS     
	,USER_PROP_EMAILS    
	,USER_PROP_FBACKS    
	,USER_PROP_ETODAY	
	,USER_PROP_PTODAY
	,USER_PROP_MAIL_WAITING
	,USER_PROP_MAIL_PENDING
	,USER_PROP_ULB       
	,USER_PROP_ULS       
	,USER_PROP_DLB       
	,USER_PROP_DLS       
	,USER_PROP_CDT		
	,USER_PROP_MIN		
	,USER_PROP_LEVEL 	
	,USER_PROP_FLAGS1	
	,USER_PROP_FLAGS2	
	,USER_PROP_FLAGS3	
	,USER_PROP_FLAGS4	
	,USER_PROP_EXEMPT	
	,USER_PROP_REST		
	,USER_PROP_ROWS		
	,USER_PROP_SEX		
	,USER_PROP_MISC		
	,USER_PROP_LEECH 	
	,USER_PROP_CURSUB	
	,USER_PROP_CURDIR	
	,USER_PROP_FREECDT	
	,USER_PROP_XEDIT 	
	,USER_PROP_SHELL 	
	,USER_PROP_QWK		
	,USER_PROP_TMPEXT	
	,USER_PROP_CHAT		
	,USER_PROP_NS_TIME	
	,USER_PROP_PROT		
	,USER_PROP_TIMEPERCALL
	,USER_PROP_TIMEPERDAY
	,USER_PROP_CALLSPERDAY
	,USER_PROP_LINESPERMSG
	,USER_PROP_EMAILPERDAY
	,USER_PROP_POSTSPERDAY
	,USER_PROP_FREECDTPERDAY
static void js_getuserdat(scfg_t* scfg, private_t* p)
	if(p->user->number != 0 && !p->cached) {
		if(p->file < 1)
			p->file = openuserdat(scfg, /* for_modify: */FALSE);
		if(fgetuserdat(scfg, p->user, p->file)==0)
static JSBool js_user_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
    jsint       tiny;
	JSString*	js_str;
deuce's avatar
deuce committed
	jsrefcount	rc;
	scfg_t*			scfg;

	scfg=JS_GetRuntimePrivate(JS_GetRuntime(cx));
	if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL)
		return(JS_TRUE);
    JS_IdToValue(cx, id, &idval);
    tiny = JSVAL_TO_INT(idval);
rswindell's avatar
rswindell committed
		case USER_PROP_NUMBER:
rswindell's avatar
rswindell committed
			break;
			break;
		case USER_PROP_HANDLE:
deuce's avatar
deuce committed
		case USER_PROP_IPADDR:
			s=p->user->ipaddr;
			break;
			break;
		case USER_PROP_COMMENT:
			break;
		case USER_PROP_NETMAIL:
			s=usermailaddr(scfg, tmp
				,scfg->inetmail_misc&NMAIL_ALIAS ? p->user->alias : p->user->name);
			break;
		case USER_PROP_LOCATION:
			break;
		case USER_PROP_ZIPCODE:
		case USER_PROP_BIRTHYEAR:
			val = getbirthyear(p->user->birth);
			break;
		case USER_PROP_BIRTHMONTH:
			val = getbirthmonth(scfg, p->user->birth);
			break;
		case USER_PROP_BIRTHDAY:
			val = getbirthday(scfg, p->user->birth);
			break;
			val=getage(scfg,p->user->birth);
			break;
		case USER_PROP_LASTON:
			break;
		case USER_PROP_FIRSTON:
			break;
		case USER_PROP_EXPIRE:
			break;
		case USER_PROP_LOGONS:
			break;
		case USER_PROP_LTODAY:
			break;
		case USER_PROP_TIMEON:
			break;
		case USER_PROP_TEXTRA:
			break;
		case USER_PROP_TTODAY:
			break;
		case USER_PROP_EMAILS: 
			break;
		case USER_PROP_FBACKS: 
			break;
		case USER_PROP_ETODAY:	
			break;
		case USER_PROP_PTODAY:
			break;
		case USER_PROP_FLAGS1:
			break;
		case USER_PROP_FLAGS2:
			break;
		case USER_PROP_FLAGS3:
			break;
		case USER_PROP_FLAGS4:
			break;
		case USER_PROP_EXEMPT:
			sprintf(tmp,"%c",p->user->sex);
		case USER_PROP_MISC:
			break;
		case USER_PROP_CURSUB:
			break;
		case USER_PROP_CURDIR:
			if(p->user->xedit>0 && p->user->xedit<=scfg->total_xedits)
				s=scfg->xedit[p->user->xedit-1]->code;
			s=scfg->shell[p->user->shell]->code;
			break;
		case USER_PROP_TMPEXT:
			break;
		case USER_PROP_NS_TIME:
			sprintf(tmp,"%c",p->user->prot);
			val=scfg->level_timepercall[p->user->level];
			val=scfg->level_timeperday[p->user->level];
			val=scfg->level_callsperday[p->user->level];
			val=scfg->level_linespermsg[p->user->level];
			val=scfg->level_postsperday[p->user->level];
			val=scfg->level_emailperday[p->user->level];
			val=scfg->level_freecdtperday[p->user->level];
			val=getmail(scfg,p->user->number,/* sent? */FALSE, /* SPAM: */FALSE);
			val=getmail(scfg,p->user->number,/* sent? */TRUE, /* SPAM: */FALSE);
		case USER_PROP_CACHED:
			*vp = BOOLEAN_TO_JSVAL(p->cached);
			return(JS_TRUE);	/* intentional early return */

			*vp = BOOLEAN_TO_JSVAL(p->user->level >= SYSOP_LEVEL);
			return(JS_TRUE);	/* intentional early return */

		default:	
			/* This must not set vp in order for child objects to work (stats and security) */
	if(s!=NULL) {
		if((js_str=JS_NewStringCopyZ(cx, s))==NULL)
			return(JS_FALSE);
		*vp = STRING_TO_JSVAL(js_str);
		*vp=DOUBLE_TO_JSVAL((double)val);
static JSBool js_user_set(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
rswindell's avatar
rswindell committed
	ulong		usermisc;
    jsint       tiny;
deuce's avatar
deuce committed
	jsrefcount	rc;
	scfg_t*			scfg;

	scfg=JS_GetRuntimePrivate(JS_GetRuntime(cx));
	if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL)
		return(JS_TRUE);
deuce's avatar
deuce committed
	JSVALUE_TO_MSTRING(cx, *vp, str, NULL);
	HANDLE_PENDING(cx, str);
deuce's avatar
deuce committed
	if(str==NULL)
    JS_IdToValue(cx, id, &idval);
    tiny = JSVAL_TO_INT(idval);
	switch(tiny) {
rswindell's avatar
rswindell committed
		case USER_PROP_NUMBER:
deuce's avatar
deuce committed
			if(!JS_ValueToInt32(cx, *vp, &usernumber)) {
				free(str);
				p->user->number=(ushort)usernumber;
rswindell's avatar
rswindell committed
			break;
			SAFECOPY(p->user->alias,str);
rswindell's avatar
rswindell committed
			/* update USER.DAT */
			putuserrec(scfg,p->user->number,U_ALIAS,LEN_ALIAS,str);
rswindell's avatar
rswindell committed

			/* update NAME.DAT */
			getuserrec(scfg,p->user->number,U_MISC,8,tmp);
rswindell's avatar
rswindell committed
			usermisc=ahtoul(tmp);
			if(!(usermisc&DELETED))
				putusername(scfg,p->user->number,str);
			putuserrec(scfg,p->user->number,U_NAME,LEN_NAME,str);
			break;
		case USER_PROP_HANDLE:
			SAFECOPY(p->user->handle,str);
			putuserrec(scfg,p->user->number,U_HANDLE,LEN_HANDLE,str);
			putuserrec(scfg,p->user->number,U_NOTE,LEN_NOTE,str);
deuce's avatar
deuce committed
		case USER_PROP_IPADDR:		 
			SAFECOPY(p->user->ipaddr,str);
			putuserrec(scfg,p->user->number,U_IPADDR,LEN_IPADDR,str);
			break;
		case USER_PROP_COMP:
			SAFECOPY(p->user->comp,str);
			putuserrec(scfg,p->user->number,U_COMP,LEN_COMP,str);
			break;
		case USER_PROP_COMMENT:	 
			SAFECOPY(p->user->comment,str);
			putuserrec(scfg,p->user->number,U_COMMENT,LEN_COMMENT,str);
			break;
		case USER_PROP_NETMAIL:	 
			SAFECOPY(p->user->netmail,str);
			putuserrec(scfg,p->user->number,U_NETMAIL,LEN_NETMAIL,str);
			break;
		case USER_PROP_ADDRESS:	 
			SAFECOPY(p->user->address,str);
			putuserrec(scfg,p->user->number,U_ADDRESS,LEN_ADDRESS,str);
			break;
		case USER_PROP_LOCATION:	 
			SAFECOPY(p->user->location,str);
			putuserrec(scfg,p->user->number,U_LOCATION,LEN_LOCATION,str);
			break;
		case USER_PROP_ZIPCODE:	 
			SAFECOPY(p->user->zipcode,str);
			putuserrec(scfg,p->user->number,U_ZIPCODE,LEN_ZIPCODE,str);
			SAFECOPY(p->user->phone,str);
			putuserrec(scfg,p->user->number,U_PHONE,LEN_PHONE,str);
			SAFECOPY(p->user->birth,str);
			putuserrec(scfg,p->user->number,U_BIRTH,LEN_BIRTH,str);
		case USER_PROP_BIRTHYEAR:
			SAFEPRINTF(tmp, "%04u", atoi(str));
			putuserrec(scfg,p->user->number, U_BIRTH, 4, tmp);
			break;
		case USER_PROP_BIRTHMONTH:
			SAFEPRINTF(tmp, "%02u", atoi(str));
			putuserrec(scfg,p->user->number, U_BIRTH + 4, 2, tmp);
			break;
		case USER_PROP_BIRTHDAY:
			SAFEPRINTF(tmp, "%02u", atoi(str));
			putuserrec(scfg,p->user->number, U_BIRTH + 6, 2, tmp);
			break;
			SAFECOPY(p->user->modem,str);
			putuserrec(scfg,p->user->number,U_MODEM,LEN_MODEM,str);
		case USER_PROP_ROWS:	
			p->user->rows=atoi(str);
			putuserrec(scfg,p->user->number,U_ROWS,0,str);	/* base 10 */
			p->user->sex=toupper(str[0]);
			putuserrec(scfg,p->user->number,U_SEX,0,strupr(str));	/* single char */
			break;
		case USER_PROP_CURSUB:	 
			SAFECOPY(p->user->cursub,str);
			putuserrec(scfg,p->user->number,U_CURSUB,0,str);
			break;
		case USER_PROP_CURDIR:	 
			SAFECOPY(p->user->curdir,str);
			putuserrec(scfg,p->user->number,U_CURDIR,0,str);
			SAFECOPY(p->user->curxtrn,str);
			putuserrec(scfg,p->user->number,U_CURXTRN,0,str);
			putuserrec(scfg,p->user->number,U_XEDIT,0,str);
			putuserrec(scfg,p->user->number,U_SHELL,0,str);
			if(!JS_ValueToECMAUint32(cx,*vp,&val)) {
deuce's avatar
deuce committed
				free(str);
			putuserrec(scfg,p->user->number,U_MISC,0,ultoa(p->user->misc=val,tmp,16));
			if(!JS_ValueToECMAUint32(cx,*vp,&val)) {
deuce's avatar
deuce committed
				free(str);
			putuserrec(scfg,p->user->number,U_QWK,0,ultoa(p->user->qwk=val,tmp,16));
			if(!JS_ValueToECMAUint32(cx,*vp,&val)) {
deuce's avatar
deuce committed
				free(str);
			putuserrec(scfg,p->user->number,U_CHAT,0,ultoa(p->user->chat=val,tmp,16));
			break;
		case USER_PROP_TMPEXT:	 
			SAFECOPY(p->user->tmpext,str);
			putuserrec(scfg,p->user->number,U_TMPEXT,0,str);
			break;
		case USER_PROP_NS_TIME:	 
			if(!JS_ValueToECMAUint32(cx,*vp,&val)) {
deuce's avatar
deuce committed
				free(str);
			putuserrec(scfg,p->user->number,U_NS_TIME,0,ultoa((ulong)(p->user->ns_time=val),tmp,16));
			p->user->prot=toupper(str[0]);
			putuserrec(scfg,p->user->number,U_PROT,0,strupr(str)); /* single char */
		case USER_PROP_LOGONTIME:	 
			if(!JS_ValueToECMAUint32(cx,*vp,&val)) {
deuce's avatar
deuce committed
				free(str);
			putuserrec(scfg,p->user->number,U_LOGONTIME,0,ultoa(p->user->logontime=val,tmp,16));
			
		/* security properties*/
		case USER_PROP_PASS:	
			putuserrec(scfg,p->user->number,U_PASS,LEN_PASS,strupr(str));
			if(!JS_ValueToECMAUint32(cx,*vp,&val)) {
deuce's avatar
deuce committed
				free(str);
			putuserrec(scfg,p->user->number,U_PWMOD,0,ultoa(p->user->pwmod=val,tmp,16));
			putuserrec(scfg,p->user->number,U_LEVEL,0,str);
			break;
		case USER_PROP_FLAGS1:
				val=str_to_bits(p->user->flags1 << 1, str) >> 1;
				if(!JS_ValueToECMAUint32(cx,*vp,&val)) {
deuce's avatar
deuce committed
					free(str);
			putuserrec(scfg,p->user->number,U_FLAGS1,0,ultoa(p->user->flags1=val,tmp,16));
			break;
		case USER_PROP_FLAGS2:
				val=str_to_bits(p->user->flags2 << 1, str) >> 1;
				if(!JS_ValueToECMAUint32(cx,*vp,&val)) {
deuce's avatar
deuce committed
					free(str);
			putuserrec(scfg,p->user->number,U_FLAGS2,0,ultoa(p->user->flags2=val,tmp,16));
			break;
		case USER_PROP_FLAGS3:
				val=str_to_bits(p->user->flags3 << 1, str) >> 1;
				if(!JS_ValueToECMAUint32(cx,*vp,&val)) {
deuce's avatar
deuce committed
					free(str);
			putuserrec(scfg,p->user->number,U_FLAGS3,0,ultoa(p->user->flags3=val,tmp,16));
			break;
		case USER_PROP_FLAGS4:
				val=str_to_bits(p->user->flags4 << 1, str) >> 1;
				if(!JS_ValueToECMAUint32(cx,*vp,&val)) {
deuce's avatar
deuce committed
					free(str);
			putuserrec(scfg,p->user->number,U_FLAGS4,0,ultoa(p->user->flags4=val,tmp,16));
			break;
		case USER_PROP_EXEMPT:
				val=str_to_bits(p->user->exempt << 1, str) >> 1;
				if(!JS_ValueToECMAUint32(cx,*vp,&val)) {
deuce's avatar
deuce committed
					free(str);
			putuserrec(scfg,p->user->number,U_EXEMPT,0,ultoa(p->user->exempt=val,tmp,16));
				val=str_to_bits(p->user->rest << 1, str) >> 1;
				if(!JS_ValueToECMAUint32(cx,*vp,&val)) {
deuce's avatar
deuce committed
					free(str);
			putuserrec(scfg,p->user->number,U_REST,0,ultoa(p->user->rest=val,tmp,16));
			p->user->cdt=strtoul(str,NULL,0);
			putuserrec(scfg,p->user->number,U_CDT,0,str);
			break;
		case USER_PROP_FREECDT:
			p->user->freecdt=strtoul(str,NULL,0);
			putuserrec(scfg,p->user->number,U_FREECDT,0,str);
			p->user->min=strtoul(str,NULL,0);
			putuserrec(scfg,p->user->number,U_MIN,0,str);
			break;
		case USER_PROP_TEXTRA:  
			p->user->textra=(ushort)strtoul(str,NULL,0);
			putuserrec(scfg,p->user->number,U_TEXTRA,0,str);
			break;
		case USER_PROP_EXPIRE:  
			if(!JS_ValueToECMAUint32(cx,*vp,&val)) {
deuce's avatar
deuce committed
				free(str);
			putuserrec(scfg,p->user->number,U_EXPIRE,0,ultoa(p->user->expire=val,tmp,16));

		case USER_PROP_CACHED:
			JS_ValueToBoolean(cx, *vp, &p->cached);
deuce's avatar
deuce committed
			free(str);
			return(JS_TRUE);	/* intentional early return */

deuce's avatar
deuce committed
	free(str);
	if(!(p->user->rest&FLAG('G')))
		p->cached=FALSE;
#define USER_PROP_FLAGS JSPROP_ENUMERATE
static jsSyncPropertySpec js_user_properties[] = {
/*		 name				,tinyid					,flags,					ver	*/

	{	"number"			,USER_PROP_NUMBER		,USER_PROP_FLAGS,		310},
	{	"alias"				,USER_PROP_ALIAS 		,USER_PROP_FLAGS,		310},
	{	"name"				,USER_PROP_NAME		 	,USER_PROP_FLAGS,		310},
	{	"handle"			,USER_PROP_HANDLE	 	,USER_PROP_FLAGS,		310},
deuce's avatar
deuce committed
	{	"ip_address"		,USER_PROP_IPADDR	 	,USER_PROP_FLAGS,		310},
	{	"note"				,USER_PROP_NOTE		 	,USER_PROP_FLAGS,		310},
	{	"host_name"			,USER_PROP_COMP		 	,USER_PROP_FLAGS,		310},
	{	"computer"			,USER_PROP_COMP		 	,USER_PROP_FLAGS,		310},
	{	"comment"			,USER_PROP_COMMENT	 	,USER_PROP_FLAGS,		310},
	{	"netmail"			,USER_PROP_NETMAIL	 	,USER_PROP_FLAGS,		310},
	{	"email"				,USER_PROP_EMAIL	 	,USER_PROP_FLAGS|JSPROP_READONLY,		310},
	{	"address"			,USER_PROP_ADDRESS	 	,USER_PROP_FLAGS,		310},
	{	"location"			,USER_PROP_LOCATION	 	,USER_PROP_FLAGS,		310},
	{	"zipcode"			,USER_PROP_ZIPCODE	 	,USER_PROP_FLAGS,		310},
	{	"phone"				,USER_PROP_PHONE  	 	,USER_PROP_FLAGS,		310},
	{	"birthdate"			,USER_PROP_BIRTH  	 	,USER_PROP_FLAGS,		310},
	{	"birthyear"			,USER_PROP_BIRTHYEAR   	,USER_PROP_FLAGS,		31802},
	{	"birthmonth"		,USER_PROP_BIRTHMONTH  	,USER_PROP_FLAGS,		31802},
	{	"birthday"			,USER_PROP_BIRTHDAY  	,USER_PROP_FLAGS,		31802},
	{	"age"				,USER_PROP_AGE			,USER_PROP_FLAGS|JSPROP_READONLY,		310},
	{	"connection"		,USER_PROP_MODEM      	,USER_PROP_FLAGS,		310},
	{	"modem"				,USER_PROP_MODEM      	,USER_PROP_FLAGS,		310},
	{	"screen_rows"		,USER_PROP_ROWS		 	,USER_PROP_FLAGS,		310},
	{	"gender"			,USER_PROP_SEX		 	,USER_PROP_FLAGS,		310},
	{	"cursub"			,USER_PROP_CURSUB	 	,USER_PROP_FLAGS,		310},
	{	"curdir"			,USER_PROP_CURDIR	 	,USER_PROP_FLAGS,		310},
	{	"curxtrn"			,USER_PROP_CURXTRN	 	,USER_PROP_FLAGS,		310},
	{	"editor"			,USER_PROP_XEDIT 	 	,USER_PROP_FLAGS,		310},
	{	"command_shell"		,USER_PROP_SHELL 	 	,USER_PROP_FLAGS,		310},
	{	"settings"			,USER_PROP_MISC		 	,USER_PROP_FLAGS,		310},
	{	"qwk_settings"		,USER_PROP_QWK		 	,USER_PROP_FLAGS,		310},
	{	"chat_settings"		,USER_PROP_CHAT		 	,USER_PROP_FLAGS,		310},
	{	"temp_file_ext"		,USER_PROP_TMPEXT	 	,USER_PROP_FLAGS,		310},
	{	"new_file_time"		,USER_PROP_NS_TIME	 	,USER_PROP_FLAGS,		311},
	{	"newscan_date"		,USER_PROP_NS_TIME	 	,0, /* Alias */			310},
	{	"download_protocol"	,USER_PROP_PROT		 	,USER_PROP_FLAGS,		310},
	{	"logontime"			,USER_PROP_LOGONTIME 	,USER_PROP_FLAGS,		310},
rswindell's avatar
rswindell committed
	{	"cached"			,USER_PROP_CACHED		,USER_PROP_FLAGS,		314},
	{	"is_sysop"			,USER_PROP_IS_SYSOP		,JSPROP_ENUMERATE|JSPROP_READONLY,	315},
static char* user_prop_desc[] = {

	 "record number (1-based)"
	,"alias/name"
	,"real name"
	,"chat handle"
	,"IP address last logged on from"
deuce's avatar
deuce committed
	,"Sysop note (AKA ip_address on 3.16 and before)"
	,"host name last logged on from"
	,"AKA host_name"
	,"sysop's comment"
	,"external e-mail address"
	,"local Internet e-mail address	- <small>READ ONLY</small>"
	,"street address"
	,"location (e.g. city, state)"
	,"zip/postal code"
	,"phone number"
	,"birth date in 'YYYYMMDD' format or legacy format: 'MM/DD/YY' or 'DD/MM/YY', depending on system configuration"
	,"birth year"
	,"birth month (1-12)"
	,"birth day of month (1-31)"
	,"calculated age in years - <small>READ ONLY</small>"
	,"connection type (protocol)"
	,"AKA connection"
	,"terminal rows (lines)"
	,"gender type (e.g. M or F)"
	,"current/last message sub-board (internal code)"
	,"current/last file directory (internal code)"
	,"current/last external program (internal code) run"
	,"external message editor (internal code) or <i>blank</i> if none"
	,"command shell (internal code)"
	,"settings bitfield - see <tt>USER_*</tt> in <tt>sbbsdefs.js</tt> for bit definitions"
	,"QWK packet settings bitfield - see <tt>QWK_*</tt> in <tt>sbbsdefs.js</tt> for bit definitions"
	,"chat settings bitfield - see <tt>CHAT_*</tt> in <tt>sbbsdefs.js</tt> for bit definitions"
	,"temporary file type (extension)"
	,"new file scan date/time (time_t format)"
	,"file transfer protocol (command key)"
	,"logon time (time_t format)"
	,"record is currently cached in memory"
	,"user has a System Operator's security level"
static jsSyncPropertySpec js_user_security_properties[] = {
/*		 name				,tinyid					,flags,				ver	*/

	{	"password"			,USER_PROP_PASS		 	,USER_PROP_FLAGS,	310 },
	{	"password_date"		,USER_PROP_PWMOD      	,USER_PROP_FLAGS,	310 },
	{	"level"				,USER_PROP_LEVEL 	 	,USER_PROP_FLAGS,	310 },
	{	"flags1"			,USER_PROP_FLAGS1	 	,USER_PROP_FLAGS,	310 },
	{	"flags2"			,USER_PROP_FLAGS2	 	,USER_PROP_FLAGS,	310 },
	{	"flags3"			,USER_PROP_FLAGS3	 	,USER_PROP_FLAGS,	310 },
	{	"flags4"			,USER_PROP_FLAGS4	 	,USER_PROP_FLAGS,	310 },
	{	"exemptions"		,USER_PROP_EXEMPT	 	,USER_PROP_FLAGS,	310 },
	{	"restrictions"		,USER_PROP_REST		 	,USER_PROP_FLAGS,	310 },
	{	"credits"			,USER_PROP_CDT		 	,USER_PROP_FLAGS,	310 },
	{	"free_credits"		,USER_PROP_FREECDT	 	,USER_PROP_FLAGS,	310 },
	{	"minutes"			,USER_PROP_MIN		 	,USER_PROP_FLAGS,	310 },
	{	"extra_time"		,USER_PROP_TEXTRA  	 	,USER_PROP_FLAGS,	310 },
	{	"expiration_date"	,USER_PROP_EXPIRE     	,USER_PROP_FLAGS,	310 },
static char* user_security_prop_desc[] = {

	 "password"
	,"date password last modified (time_t format)"
	,"security level (0-99)"
	,"flag set #1 (bitfield) can use +/-[A-?] notation"
	,"flag set #2 (bitfield) can use +/-[A-?] notation"
	,"flag set #3 (bitfield) can use +/-[A-?] notation"
	,"flag set #4 (bitfield) can use +/-[A-?] notation"
	,"exemption flags (bitfield) can use +/-[A-?] notation"
	,"restriction flags (bitfield) can use +/-[A-?] notation"
	,"credits"
	,"free credits (for today only)"
	,"extra minutes (time bank)"
	,"extra minutes (for today only)"
	,"expiration date/time (time_t format)"
#undef  USER_PROP_FLAGS
#define USER_PROP_FLAGS JSPROP_ENUMERATE|JSPROP_READONLY

/* user.limits: These should be READ ONLY by nature */
static jsSyncPropertySpec js_user_limits_properties[] = {
/*		 name					,tinyid					,flags,				ver	*/

	{	"time_per_logon"		,USER_PROP_TIMEPERCALL	,USER_PROP_FLAGS,	311 },
	{	"time_per_day"			,USER_PROP_TIMEPERDAY	,USER_PROP_FLAGS,	311 },
	{	"logons_per_day"		,USER_PROP_CALLSPERDAY	,USER_PROP_FLAGS,	311 },
	{	"lines_per_message"		,USER_PROP_LINESPERMSG	,USER_PROP_FLAGS,	311 },
	{	"email_per_day"			,USER_PROP_EMAILPERDAY	,USER_PROP_FLAGS,	311 },
	{	"posts_per_day"			,USER_PROP_POSTSPERDAY	,USER_PROP_FLAGS,	311 },
	{	"free_credits_per_day"	,USER_PROP_FREECDTPERDAY,USER_PROP_FLAGS,	311 },
static char* user_limits_prop_desc[] = {

	 "time (in minutes) per logon"
	,"time (in minutes) per day"
	,"logons per day"
	,"lines per message (post or email)"
	,"email sent per day"
	,"messages posted per day"
	,"free credits given per day"
	,NULL
};
#endif

#undef  USER_PROP_FLAGS
#define USER_PROP_FLAGS JSPROP_ENUMERATE|JSPROP_READONLY

/* user.stats: These should be READ ONLY by nature */
static jsSyncPropertySpec js_user_stats_properties[] = {
/*		 name				,tinyid					,flags,					ver	*/

	{	"laston_date"		,USER_PROP_LASTON	 	,USER_PROP_FLAGS,		310 },
	{	"firston_date"		,USER_PROP_FIRSTON	 	,USER_PROP_FLAGS,		310 },
	{	"total_logons"		,USER_PROP_LOGONS     	,USER_PROP_FLAGS,		310 },
	{	"logons_today"		,USER_PROP_LTODAY     	,USER_PROP_FLAGS,		310 },
	{	"total_timeon"		,USER_PROP_TIMEON     	,USER_PROP_FLAGS,		310 },
	{	"timeon_today"		,USER_PROP_TTODAY     	,USER_PROP_FLAGS,		310 },
	{	"timeon_last_logon"	,USER_PROP_TLAST      	,USER_PROP_FLAGS,		310 },
	{	"total_posts"		,USER_PROP_POSTS      	,USER_PROP_FLAGS,		310 },
	{	"total_emails"		,USER_PROP_EMAILS     	,USER_PROP_FLAGS,		310 },
	{	"total_feedbacks"	,USER_PROP_FBACKS     	,USER_PROP_FLAGS,		310 },
	{	"email_today"		,USER_PROP_ETODAY	 	,USER_PROP_FLAGS,		310 },
	{	"posts_today"		,USER_PROP_PTODAY	 	,USER_PROP_FLAGS,		310 },
	{	"bytes_uploaded"	,USER_PROP_ULB        	,USER_PROP_FLAGS,		310 },
	{	"files_uploaded"	,USER_PROP_ULS        	,USER_PROP_FLAGS,		310 },
	{	"bytes_downloaded"	,USER_PROP_DLB        	,USER_PROP_FLAGS,		310 },
	{	"files_downloaded"	,USER_PROP_DLS        	,USER_PROP_FLAGS,		310 },
	{	"leech_attempts"	,USER_PROP_LEECH 	 	,USER_PROP_FLAGS,		310 },
	{	"mail_waiting"		,USER_PROP_MAIL_WAITING	,USER_PROP_FLAGS,		312	},
	{	"mail_pending"		,USER_PROP_MAIL_PENDING	,USER_PROP_FLAGS,		312	},
static char* user_stats_prop_desc[] = {

	 "date of previous logon (time_t format)"
	,"date of first logon (time_t format)"
	,"total number of logons"
	,"total logons today"
	,"total time used (in minutes)"
	,"time used today"
	,"time used last session"
	,"total messages posted"
	,"total e-mails sent"
	,"total feedback messages sent"
	,"e-mail sent today"
	,"messages posted today"
	,"total bytes uploaded"
	,"total files uploaded"
	,"total bytes downloaded"
	,"total files downloaded"
	,"suspected leech downloads"
rswindell's avatar
rswindell committed
	,"number of e-mail messages currently waiting"
	,"number of e-mail messages sent, currently pending deletion"
static void js_user_finalize(JSContext *cx, JSObject *obj)
{
	private_t* p = (private_t*)JS_GetPrivate(cx,obj);
	if(p!=NULL) {
		if(p->file > 0)
			closeuserdat(p->file);
js_chk_ar(JSContext *cx, uintN argc, jsval *arglist)