void sbbs_t::change_user(void) { uint i; char str[256]; char tmp[128]; if(!chksyspass()) return; bputs(text[ChUserPrompt]); if(!getstr(str,LEN_ALIAS,K_UPPER)) return; if((i=finduser(str))==0) return; if(online==ON_REMOTE) { getuserrec(&cfg,i,U_LEVEL,2,str); if(atoi(str)>logon_ml) { getuserrec(&cfg,i,U_PASS,8,tmp); bputs(text[ChUserPwPrompt]); console|=CON_R_ECHOX; getstr(str,8,K_UPPER); console&=~(CON_R_ECHOX|CON_L_ECHOX); if(strcmp(str,tmp)) return; } } putmsgptrs(); putuserrec(&cfg,useron.number,U_CURSUB,0 ,cfg.sub[usrsub[curgrp][cursub[curgrp]]]->code); putuserrec(&cfg,useron.number,U_CURDIR,0 ,cfg.dir[usrdir[curlib][curdir[curlib]]]->code); useron.number=i; getuserdat(&cfg,&useron); getnodedat(cfg.node_num,&thisnode,1); thisnode.useron=useron.number; putnodedat(cfg.node_num,&thisnode); getmsgptrs(); if(REALSYSOP) sys_status&=~SS_TMPSYSOP; else sys_status|=SS_TMPSYSOP; sprintf(str,"Changed into %s #%u",useron.alias,useron.number); logline("S+",str); }
void sbbs_t::logout() { char str[256]; char tmp[512]; int i,j; ushort ttoday; node_t node; struct tm tm; now=time(NULL); if(localtime_r(&now,&tm)==NULL) return; if(!useron.number) { /* Not logged in, so do nothing */ if(!online) { sprintf(str,"%s T:%3u sec\r\n" ,hhmmtostr(&cfg,&tm,tmp) ,(uint)(now-answertime)); logline("@-",str); } return; } strcpy(lastuseron,useron.alias); /* for use with WFC status display */ if(useron.rest&FLAG('G')) { /* Reset guest's msg scan cfg */ putuserrec(&cfg,useron.number,U_NAME,LEN_NAME,nulstr); batdn_total=0; } batch_create_list(); if(sys_status&SS_USERON && thisnode.status!=NODE_QUIET && !(useron.rest&FLAG('Q'))) for(i=1;i<=cfg.sys_nodes;i++) if(i!=cfg.node_num) { getnodedat(i,&node,0); if((node.status==NODE_INUSE || node.status==NODE_QUIET) && !(node.misc&NODE_AOFF) && node.useron!=useron.number) { sprintf(str,text[NodeLoggedOff],cfg.node_num ,thisnode.misc&NODE_ANON ? text[UNKNOWN_USER] : useron.alias); putnmsg(&cfg,i,str); } } if(!online) { /* NOT re-login */ #if 0 /* too soon, handled in node_thread */ getnodedat(cfg.node_num,&thisnode,1); thisnode.status=NODE_WFC; thisnode.misc&=~(NODE_INTR|NODE_MSGW|NODE_NMSG |NODE_UDAT|NODE_POFF|NODE_AOFF|NODE_EXT); putnodedat(cfg.node_num,&thisnode); #endif #if 0 /* beep? */ if(sys_status&SS_SYSALERT) { mswait(500); offhook(); CLS; lputs("\r\n\r\nAlerting Sysop..."); while(!lkbrd(1)) { sbbs_beep(1000,200); nosound(); mswait(200); } lkbrd(0); } #endif sys_status&=~SS_SYSALERT; if(cfg.sys_logout[0]) /* execute system logout event */ external(cmdstr(cfg.sys_logout,nulstr,nulstr,NULL),EX_OUTL|EX_OFFLINE); } if(cfg.logout_mod[0]) exec_bin(cfg.logout_mod,&main_csi); backout(); sprintf(str,"%smsgs/%4.4u.msg",cfg.data_dir,useron.number); if(!flength(str)) /* remove any 0 byte message files */ remove(str); delfiles(cfg.temp_dir,ALLFILES); putmsgptrs(); if(!REALSYSOP) logofflist(); useron.laston=(time32_t)now; ttoday=useron.ttoday-useron.textra; /* billable time used prev calls */ if(ttoday>=cfg.level_timeperday[useron.level]) i=0; else i=cfg.level_timeperday[useron.level]-ttoday; if(i>cfg.level_timepercall[useron.level]) /* i=amount of time without min */ i=cfg.level_timepercall[useron.level]; j=(int)(now-starttime)/60; /* j=billable time online in min */ if(i<0) i=0; if(j<0) j=0; if(useron.min && j>i) { j-=i; /* j=time to deduct from min */ sprintf(str,"Minute Adjustment: %d",-j); logline(">>",str); if(useron.min>(ulong)j) useron.min-=j; else useron.min=0L; putuserrec(&cfg,useron.number,U_MIN,10,ultoa(useron.min,str,10)); } if(timeleft>0 && starttime-logontime>0) /* extra time */ useron.textra+=(ushort)((starttime-logontime)/60); putuserrec(&cfg,useron.number,U_TEXTRA,5,ultoa(useron.textra,str,10)); putuserrec(&cfg,useron.number,U_NS_TIME,8,ultoa((ulong)last_ns_time,str,16)); logoutuserdat(&cfg, &useron, now, logontime); getusrsubs(); getusrdirs(); if(usrgrps>0) putuserrec(&cfg,useron.number,U_CURSUB,0,cfg.sub[usrsub[curgrp][cursub[curgrp]]]->code); if(usrlibs>0) putuserrec(&cfg,useron.number,U_CURDIR,0,cfg.dir[usrdir[curlib][curdir[curlib]]]->code); hhmmtostr(&cfg,&tm,str); strcat(str," "); if(sys_status&SS_USERON) sprintf(tmp,"T:%3u R:%3lu P:%3lu E:%3lu F:%3lu " "U:%3luk %lu D:%3luk %lu" ,(uint)(now-logontime)/60,posts_read,logon_posts ,logon_emails,logon_fbacks,logon_ulb/1024UL,logon_uls ,logon_dlb/1024UL,logon_dls); else sprintf(tmp,"T:%3u sec",(uint)(now-answertime)); strcat(str,tmp); strcat(str,"\r\n"); logline("@-",str); sys_status&=~SS_USERON; answertime=now; // Incase we're relogging on }