bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode) { char str[256],title[LEN_TITLE+1],top[256]; char msg_id[256]; char touser[64]; char from[64]; char pid[128]; char* editor=NULL; char* msgbuf=NULL; uint16_t xlat; ushort msgattr; int i,storage; long dupechk_hashes; long length; FILE* fp; smbmsg_t msg; uint reason; if(remsg) { sprintf(title,"%.*s",LEN_TITLE,remsg->subj); if(remsg->hdr.attr&MSG_ANONYMOUS) SAFECOPY(from,text[Anonymous]); else SAFECOPY(from,remsg->from); // If user posted this message, reply to the original recipient again if((remsg->from_ext!=NULL && atoi(remsg->from_ext)==useron.number) || stricmp(useron.alias,remsg->from)==0 || stricmp(useron.name,remsg->from)==0) SAFECOPY(touser,remsg->to); else SAFECOPY(touser,from); msgattr=(ushort)(remsg->hdr.attr&MSG_PRIVATE); sprintf(top,text[RegardingByToOn],title,from,remsg->to ,timestr(remsg->hdr.when_written.time) ,smb_zonestr(remsg->hdr.when_written.zone,NULL)); } else { title[0]=0; touser[0]=0; top[0]=0; msgattr=0; } /* Security checks */ if(!can_user_post(&cfg,subnum,&useron,&client,&reason)) { bputs(text[reason]); return false; } bprintf(text[Posting],cfg.grp[cfg.sub[subnum]->grp]->sname,cfg.sub[subnum]->lname); action=NODE_PMSG; nodesync(); if(!(msgattr&MSG_PRIVATE) && (cfg.sub[subnum]->misc&SUB_PONLY || (cfg.sub[subnum]->misc&SUB_PRIV && !noyes(text[PrivatePostQ])))) msgattr|=MSG_PRIVATE; if(sys_status&SS_ABORT) return(false); if( #if 0 /* we *do* support internet posts to specific people July-11-2002 */ !(cfg.sub[subnum]->misc&SUB_INET) && // Prompt for TO: user #endif (cfg.sub[subnum]->misc&SUB_TOUSER || msgattr&MSG_PRIVATE || touser[0])) { if(!touser[0] && !(msgattr&MSG_PRIVATE)) SAFECOPY(touser,"All"); bputs(text[PostTo]); i=LEN_ALIAS; if(cfg.sub[subnum]->misc&SUB_QNET) i=25; if(cfg.sub[subnum]->misc&SUB_FIDO) i=FIDO_NAME_LEN-1; if(cfg.sub[subnum]->misc&(SUB_PNET|SUB_INET)) i=60; getstr(touser,i,K_UPRLWR|K_LINE|K_EDIT|K_AUTODEL); if(stricmp(touser,"ALL") && !(cfg.sub[subnum]->misc&(SUB_PNET|SUB_FIDO|SUB_QNET|SUB_INET|SUB_ANON))) { if(cfg.sub[subnum]->misc&SUB_NAME) { if(!userdatdupe(useron.number,U_NAME,LEN_NAME,touser)) { bputs(text[UnknownUser]); return(false); } } else { if((i=finduser(touser))==0) return(false); username(&cfg,i,touser); } } if(sys_status&SS_ABORT) return(false); } if(!touser[0]) SAFECOPY(touser,"All"); // Default to ALL if(!stricmp(touser,"SYSOP") && !SYSOP) // Change SYSOP to user #1 username(&cfg,1,touser); if(msgattr&MSG_PRIVATE && !stricmp(touser,"ALL")) { bputs(text[NoToUser]); return(false); } if(msgattr&MSG_PRIVATE) wm_mode|=WM_PRIVATE; if(cfg.sub[subnum]->misc&SUB_AONLY || (cfg.sub[subnum]->misc&SUB_ANON && useron.exempt&FLAG('A') && !noyes(text[AnonymousQ]))) msgattr|=MSG_ANONYMOUS; if(cfg.sub[subnum]->mod_ar[0] && chk_ar(cfg.sub[subnum]->mod_ar,&useron,&client)) msgattr|=MSG_MODERATED; if(cfg.sub[subnum]->misc&SUB_SYSPERM && sub_op(subnum)) msgattr|=MSG_PERMANENT; if(msgattr&MSG_PRIVATE) bputs(text[PostingPrivately]); if(msgattr&MSG_ANONYMOUS) bputs(text[PostingAnonymously]); if(cfg.sub[subnum]->misc&SUB_NAME) bputs(text[UsingRealName]); msg_tmp_fname(useron.xedit, str, sizeof(str)); if(!writemsg(str,top,title,wm_mode,subnum,touser,&editor) || (length=(long)flength(str))<1) { /* Bugfix Aug-20-2003: Reject negative length */ bputs(text[Aborted]); return(false); } bputs(text[WritingIndx]); if((i=smb_stack(&smb,SMB_STACK_PUSH))!=SMB_SUCCESS) { errormsg(WHERE,ERR_OPEN,cfg.sub[subnum]->code,i,smb.last_error); return(false); } smb.subnum=subnum; if((i=msgbase_open(&cfg,&smb,&storage,&dupechk_hashes,&xlat))!=SMB_SUCCESS) { errormsg(WHERE,ERR_OPEN,smb.file,i,smb.last_error); smb_stack(&smb,SMB_STACK_POP); return(false); } if((i=smb_locksmbhdr(&smb))!=SMB_SUCCESS) { smb_close(&smb); errormsg(WHERE,ERR_LOCK,smb.file,i,smb.last_error); smb_stack(&smb,SMB_STACK_POP); return(false); } if((i=smb_getstatus(&smb))!=SMB_SUCCESS) { smb_close(&smb); errormsg(WHERE,ERR_READ,smb.file,i,smb.last_error); smb_stack(&smb,SMB_STACK_POP); return(false); } if((msgbuf=(char*)calloc(length+1,sizeof(char))) == NULL) { smb_close(&smb); errormsg(WHERE,ERR_ALLOC,"msgbuf",length+1); smb_stack(&smb,SMB_STACK_POP); return(false); } if((fp=fopen(str,"rb"))==NULL) { free(msgbuf); smb_close(&smb); errormsg(WHERE,ERR_OPEN,str,O_RDONLY|O_BINARY); smb_stack(&smb,SMB_STACK_POP); return(false); } i=fread(msgbuf,1,length,fp); fclose(fp); if(i != length) { free(msgbuf); smb_close(&smb); errormsg(WHERE,ERR_READ,str,length); smb_stack(&smb,SMB_STACK_POP); return(false); } truncsp(msgbuf); /* ToDo: split body/tail */ memset(&msg,0,sizeof(msg)); msg.hdr.attr=msgattr; msg.hdr.when_written.time=msg.hdr.when_imported.time=time32(NULL); msg.hdr.when_written.zone=msg.hdr.when_imported.zone=sys_timezone(&cfg); msg.hdr.number=smb.status.last_msg+1; /* this *should* be the new message number */ if(remsg) { msg.hdr.thread_back=remsg->hdr.number; /* needed for threading backward */ if((msg.hdr.thread_id=remsg->hdr.thread_id) == 0) msg.hdr.thread_id=remsg->hdr.number; /* Add RFC-822 Reply-ID (generate if necessary) */ if(remsg->id!=NULL) smb_hfield_str(&msg,RFC822REPLYID,remsg->id); /* Add FidoNet Reply if original message has FidoNet MSGID */ if(remsg->ftn_msgid!=NULL) smb_hfield_str(&msg,FIDOREPLYID,remsg->ftn_msgid); if((i=smb_updatethread(&smb, remsg, smb.status.last_msg+1))!=SMB_SUCCESS) errormsg(WHERE,"updating thread",smb.file,i,smb.last_error); } smb_hfield_str(&msg,RECIPIENT,touser); SAFECOPY(str,cfg.sub[subnum]->misc&SUB_NAME ? useron.name : useron.alias); smb_hfield_str(&msg,SENDER,str); sprintf(str,"%u",useron.number); smb_hfield_str(&msg,SENDEREXT,str); /* Security logging */ msg_client_hfields(&msg,&client); smb_hfield_str(&msg,SENDERSERVER,startup->host_name); smb_hfield_str(&msg,SUBJECT,title); /* Generate default (RFC822) message-id (always) */ get_msgid(&cfg,subnum,&msg,msg_id,sizeof(msg_id)); smb_hfield_str(&msg,RFC822MSGID,msg_id); /* Generate FTN (FTS-9) MSGID */ if(cfg.sub[subnum]->misc&SUB_FIDO) { ftn_msgid(cfg.sub[subnum],&msg,msg_id,sizeof(msg_id)); smb_hfield_str(&msg,FIDOMSGID,msg_id); } /* Generate FidoNet Program Identifier */ smb_hfield_str(&msg,FIDOPID,msg_program_id(pid)); if(editor!=NULL) smb_hfield_str(&msg,SMB_EDITOR,editor); i=smb_addmsg(&smb,&msg,storage,dupechk_hashes,xlat,(uchar*)msgbuf,NULL); free(msgbuf); if(i==SMB_DUPE_MSG) { attr(cfg.color[clr_err]); bprintf(text[CantPostMsg], smb.last_error); } else if(i!=SMB_SUCCESS) errormsg(WHERE,ERR_WRITE,smb.file,i,smb.last_error); smb_close(&smb); smb_stack(&smb,SMB_STACK_POP); smb_freemsgmem(&msg); if(i!=SMB_SUCCESS) return(false); logon_posts++; user_posted_msg(&cfg, &useron, 1); bprintf(text[Posted],cfg.grp[cfg.sub[subnum]->grp]->sname ,cfg.sub[subnum]->lname); sprintf(str,"%s posted on %s %s" ,useron.alias,cfg.grp[cfg.sub[subnum]->grp]->sname,cfg.sub[subnum]->lname); logline("P+",str); signal_sub_sem(&cfg,subnum); user_event(EVENT_POST); return(true); }
extern "C" int DLLCALL savemsg(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, client_t* client, const char* server, char* msgbuf) { char pid[128]; char msg_id[256]; ushort xlat=XLAT_NONE; int i; int storage=SMB_SELFPACK; long dupechk_hashes=SMB_HASH_SOURCE_DUPE; if(msg==NULL) return(SMB_FAILURE); if(!SMB_IS_OPEN(smb)) { if(smb->subnum==INVALID_SUB) sprintf(smb->file,"%smail",cfg->data_dir); else sprintf(smb->file,"%s%s",cfg->sub[smb->subnum]->data_dir,cfg->sub[smb->subnum]->code); smb->retry_time=cfg->smb_retry_time; if((i=smb_open(smb))!=SMB_SUCCESS) return(i); } /* Lock the msgbase early to preserve our message number (used in MSG-IDs) */ if(!smb->locked && smb_locksmbhdr(smb)!=SMB_SUCCESS) return(SMB_ERR_LOCK); if(filelength(fileno(smb->shd_fp))>0 && (i=smb_getstatus(smb))!=SMB_SUCCESS) { if(smb->locked) smb_unlocksmbhdr(smb); return(i); } if(smb->subnum==INVALID_SUB) { /* e-mail */ /* exception here during recycle: sbbs.dll!savemsg(scfg_t * cfg, smb_t * smb, smbmsg_t * msg, client_t * client, char * msgbuf) Line 473 + 0xf bytes C++ sbbs.dll!js_save_msg(JSContext * cx, JSObject * obj, unsigned int argc, long * argv, long * rval) Line 1519 + 0x25 bytes C js32.dll!js_Invoke(JSContext * cx, unsigned int argc, unsigned int flags) Line 1375 + 0x17 bytes C js32.dll!js_Interpret(JSContext * cx, unsigned char * pc, long * result) Line 3944 + 0xf bytes C js32.dll!js_Execute(JSContext * cx, JSObject * chain, JSObject * script, JSStackFrame * down, unsigned int flags, long * result) Line 1633 + 0x13 bytes C js32.dll!JS_ExecuteScript(JSContext * cx, JSObject * obj, JSObject * script, long * rval) Line 4188 + 0x19 bytes C sbbs.dll!sbbs_t::js_execfile(const char * cmd, const char * startup_dir) Line 686 + 0x27 bytes C++ sbbs.dll!sbbs_t::external(const char * cmdline, long mode, const char * startup_dir) Line 413 + 0x1e bytes C++ sbbs.dll!event_thread(void * arg) Line 2745 + 0x71 bytes C++ apparently the event_thread is sharing an scfg_t* with another thread! */ smb->status.max_crcs=cfg->mail_maxcrcs; smb->status.max_age=cfg->mail_maxage; smb->status.max_msgs=0; /* unlimited */ smb->status.attr=SMB_EMAIL; if(cfg->sys_misc&SM_FASTMAIL) storage=SMB_FASTALLOC; /* duplicate message-IDs must be allowed in mail database */ dupechk_hashes&=~(1<<SMB_HASH_SOURCE_MSG_ID); } else { /* sub-board */ smb->status.max_crcs=cfg->sub[smb->subnum]->maxcrcs; smb->status.max_msgs=cfg->sub[smb->subnum]->maxmsgs; smb->status.max_age=cfg->sub[smb->subnum]->maxage; smb->status.attr=0; if(cfg->sub[smb->subnum]->misc&SUB_HYPER) storage = smb->status.attr = SMB_HYPERALLOC; else if(cfg->sub[smb->subnum]->misc&SUB_FAST) storage = SMB_FASTALLOC; if(cfg->sub[smb->subnum]->misc&SUB_LZH) xlat=XLAT_LZH; /* enforce anonymous/private posts only */ if(cfg->sub[smb->subnum]->misc&SUB_PONLY) msg->hdr.attr|=MSG_PRIVATE; if(cfg->sub[smb->subnum]->misc&SUB_AONLY) msg->hdr.attr|=MSG_ANONYMOUS; } if(msg->hdr.when_imported.time==0) { msg->hdr.when_imported.time=time32(NULL); msg->hdr.when_imported.zone=sys_timezone(cfg); } if(msg->hdr.when_written.time==0) /* Uninitialized */ msg->hdr.when_written = msg->hdr.when_imported; msg->hdr.number=smb->status.last_msg+1; /* needed for MSG-ID generation */ if(smb->status.max_crcs==0) /* no CRC checking means no body text dupe checking */ dupechk_hashes&=~(1<<SMB_HASH_SOURCE_BODY); if(client!=NULL) msg_client_hfields(msg,client); if(server!=NULL) smb_hfield_str(msg,SENDERSERVER,server); /* Generate RFC-822 Message-id */ if(msg->id==NULL) { get_msgid(cfg,smb->subnum,msg,msg_id,sizeof(msg_id)); smb_hfield_str(msg,RFC822MSGID,msg_id); } /* Generate FidoNet MSGID (for FidoNet sub-boards) */ if(smb->subnum!=INVALID_SUB && cfg->sub[smb->subnum]->misc&SUB_FIDO && msg->ftn_msgid==NULL) { ftn_msgid(cfg->sub[smb->subnum],msg,msg_id,sizeof(msg_id)); smb_hfield_str(msg,FIDOMSGID,msg_id); } /* Generate FidoNet Program Identifier */ if(msg->ftn_pid==NULL) smb_hfield_str(msg,FIDOPID,msg_program_id(pid)); if((i=smb_addmsg(smb,msg,storage,dupechk_hashes,xlat,(uchar*)msgbuf,NULL))==SMB_SUCCESS && msg->to!=NULL /* no recipient means no header created at this stage */) signal_sub_sem(cfg,smb->subnum); return(i); }
bool sbbs_t::unpack_rep(char* repfile) { char str[MAX_PATH+1],fname[MAX_PATH+1] ,*AttemptedToUploadREPpacket="Attempted to upload REP packet"; char tmp[512]; char from[26]; char to[26]; char inbox[MAX_PATH+1]; char block[QWK_BLOCK_LEN]; int file; uint i,j,k,lastsub=INVALID_SUB; long l,size,misc; ulong n; ulong ex; node_t node; FILE* rep; DIR* dir; DIRENT* dirent; BOOL twit_list; sprintf(fname,"%stwitlist.cfg",cfg.ctrl_dir); twit_list=fexist(fname); if(repfile!=NULL) strcpy(str,repfile); else sprintf(str,"%s%s.rep",cfg.temp_dir,cfg.sys_id); if(!fexistcase(str)) { bputs(text[QWKReplyNotReceived]); logline("U!",AttemptedToUploadREPpacket); logline(nulstr,"REP file not received"); return(false); } for(k=0;k<cfg.total_fextrs;k++) if(!stricmp(cfg.fextr[k]->ext,useron.tmpext) && chk_ar(cfg.fextr[k]->ar,&useron)) break; if(k>=cfg.total_fextrs) k=0; ex=EX_OUTL|EX_OUTR; if(online!=ON_REMOTE) ex|=EX_OFFLINE; i=external(cmdstr(cfg.fextr[k]->cmd,str,ALLFILES,NULL),ex); if(i) { bputs(text[QWKExtractionFailed]); logline("U!",AttemptedToUploadREPpacket); logline(nulstr,"Extraction failed"); return(false); } sprintf(str,"%s%s.msg",cfg.temp_dir,cfg.sys_id); if(!fexistcase(str)) { bputs(text[QWKReplyNotReceived]); logline("U!",AttemptedToUploadREPpacket); logline(nulstr,"MSG file not received"); return(false); } if((rep=fnopen(&file,str,O_RDONLY))==NULL) { errormsg(WHERE,ERR_OPEN,str,O_RDONLY); return(false); } size=filelength(file); fread(block,QWK_BLOCK_LEN,1,rep); if(strnicmp((char *)block,cfg.sys_id,strlen(cfg.sys_id))) { fclose(rep); bputs(text[QWKReplyNotReceived]); logline("U!",AttemptedToUploadREPpacket); logline(nulstr,"Incorrect BBSID"); return(false); } logline("U+","Uploaded REP packet"); /********************/ /* Process messages */ /********************/ bputs(text[QWKUnpacking]); for(l=QWK_BLOCK_LEN;l<size;l+=i*QWK_BLOCK_LEN) { if(terminated) { bprintf("!Terminated"); break; } lncntr=0; /* defeat pause */ if(fseek(rep,l,SEEK_SET)!=0) { sprintf(str,"%s.msg", cfg.sys_id); errormsg(WHERE,ERR_SEEK,str,l); break; } if(fread(block,1,QWK_BLOCK_LEN,rep)!=QWK_BLOCK_LEN) { sprintf(str,"%s.msg", cfg.sys_id); errormsg(WHERE,ERR_READ,str,ftell(rep)); break; } sprintf(tmp,"%.6s",block+116); i=atoi(tmp); /* i = number of blocks */ if(i<2) { sprintf(str,"%s.msg blocks (read '%s' at offset %ld)", cfg.sys_id, tmp, l); errormsg(WHERE,ERR_CHK,str,i); i=1; continue; } if(atoi(block+1)==0) { /**********/ if(useron.rest&FLAG('E')) { /* E-mail */ bputs(text[R_Email]); /**********/ continue; } sprintf(str,"%25.25s",block+21); truncsp(str); if(!stricmp(str,"NETMAIL")) { /* QWK to FidoNet NetMail */ qwktonetmail(rep,block,NULL,0); continue; } if(strchr(str,'@')) { qwktonetmail(rep,block,str,0); continue; } if(!stricmp(str,"SBBS")) { /* to SBBS, config stuff */ qwkcfgline(block+71,INVALID_SUB); continue; } if(useron.etoday>=cfg.level_emailperday[useron.level] && !(useron.rest&FLAG('Q'))) { bputs(text[TooManyEmailsToday]); continue; } j=atoi(str); if(j && j>lastuser(&cfg)) j=0; if(!j) j=matchuser(&cfg,str,TRUE /* sysop_alias */); if(!j) { bputs(text[UnknownUser]); continue; } if(j==1 && useron.rest&FLAG('S')) { bprintf(text[R_Feedback],cfg.sys_op); continue; } getuserrec(&cfg,j,U_MISC,8,str); misc=ahtoul(str); if(misc&NETMAIL && cfg.sys_misc&SM_FWDTONET) { getuserrec(&cfg,j,U_NETMAIL,LEN_NETMAIL,str); qwktonetmail(rep,block,str,0); continue; } sprintf(smb.file,"%smail",cfg.data_dir); smb.retry_time=cfg.smb_retry_time; if(lastsub!=INVALID_SUB) { smb_close(&smb); lastsub=INVALID_SUB; } smb.subnum=INVALID_SUB; if((k=smb_open(&smb))!=0) { errormsg(WHERE,ERR_OPEN,smb.file,k,smb.last_error); continue; } if(!filelength(fileno(smb.shd_fp))) { smb.status.max_crcs=cfg.mail_maxcrcs; smb.status.max_msgs=0; smb.status.max_age=cfg.mail_maxage; smb.status.attr=SMB_EMAIL; if((k=smb_create(&smb))!=0) { smb_close(&smb); errormsg(WHERE,ERR_CREATE,smb.file,k); continue; } } if((k=smb_locksmbhdr(&smb))!=0) { smb_close(&smb); errormsg(WHERE,ERR_LOCK,smb.file,k); continue; } if((k=smb_getstatus(&smb))!=0) { smb_close(&smb); errormsg(WHERE,ERR_READ,smb.file,k); continue; } smb_unlocksmbhdr(&smb); if(!qwktomsg(rep,block,0,INVALID_SUB,j)) { smb_close(&smb); continue; } smb_close(&smb); if(j==1) { useron.fbacks++; logon_fbacks++; putuserrec(&cfg,useron.number,U_FBACKS,5 ,ultoa(useron.fbacks,tmp,10)); } else { useron.emails++; logon_emails++; putuserrec(&cfg,useron.number,U_EMAILS,5 ,ultoa(useron.emails,tmp,10)); } useron.etoday++; putuserrec(&cfg,useron.number,U_ETODAY,5 ,ultoa(useron.etoday,tmp,10)); bprintf(text[Emailed],username(&cfg,j,tmp),j); sprintf(str,"%s sent e-mail to %s #%d" ,useron.alias,username(&cfg,j,tmp),j); logline("E+",str); if(useron.rest&FLAG('Q')) { sprintf(tmp,"%-25.25s",block+46); truncsp(tmp); } else strcpy(tmp,useron.alias); for(k=1;k<=cfg.sys_nodes;k++) { /* Tell user, if online */ getnodedat(k,&node,0); if(node.useron==j && !(node.misc&NODE_POFF) && (node.status==NODE_INUSE || node.status==NODE_QUIET)) { sprintf(str,text[EmailNodeMsg] ,cfg.node_num,tmp); putnmsg(&cfg,k,str); break; } } if(k>cfg.sys_nodes) { sprintf(str,text[UserSentYouMail],tmp); putsmsg(&cfg,j,str); } } /* end of email */ /**************************/ else { /* message on a sub-board */ /**************************/ n=atol((char *)block+1); /* conference number */ for(j=0;j<usrgrps;j++) { for(k=0;k<usrsubs[j];k++) if(cfg.sub[usrsub[j][k]]->qwkconf==n) break; if(k<usrsubs[j]) break; } if(j>=usrgrps) { if(n<1000) { /* version 1 method, start at 101 */ j=n/100; k=n-(j*100); } else { /* version 2 method, start at 1001 */ j=n/1000; k=n-(j*1000); } j--; /* j is group */ k--; /* k is sub */ if(j>=usrgrps || k>=usrsubs[j] || cfg.sub[usrsub[j][k]]->qwkconf) { bprintf(text[QWKInvalidConferenceN],n); sprintf(str,"%s: Invalid conference number %lu",useron.alias,n); logline("P!",str); continue; } } n=usrsub[j][k]; /* if posting, add to new-scan config for QWKnet nodes automatically */ if(useron.rest&FLAG('Q')) subscan[n].cfg|=SUB_CFG_NSCAN; sprintf(str,"%-25.25s","SBBS"); if(!strnicmp((char *)block+21,str,25)) { /* to SBBS, config stuff */ qwkcfgline((char *)block+71,n); continue; } if(!SYSOP && cfg.sub[n]->misc&SUB_QNET) { /* QWK Netted */ sprintf(str,"%-25.25s","DROP"); /* Drop from new-scan? */ if(!strnicmp((char *)block+71,str,25)) /* don't allow post */ continue; sprintf(str,"%-25.25s","ADD"); /* Add to new-scan? */ if(!strnicmp((char *)block+71,str,25)) /* don't allow post */ continue; } if(useron.rest&FLAG('Q') && !(cfg.sub[n]->misc&SUB_QNET)) { bputs(text[CantPostOnSub]); logline("P!","Attempted to post on non-QWKnet sub"); continue; } if(useron.rest&FLAG('P')) { bputs(text[R_Post]); logline("P!","Post attempted"); continue; } if(useron.ptoday>=cfg.level_postsperday[useron.level] && !(useron.rest&FLAG('Q'))) { bputs(text[TooManyPostsToday]); continue; } if(useron.rest&FLAG('N') && cfg.sub[n]->misc&(SUB_FIDO|SUB_PNET|SUB_QNET|SUB_INET)) { bputs(text[CantPostOnSub]); logline("P!","Networked post attempted"); continue; } if(!chk_ar(cfg.sub[n]->post_ar,&useron)) { bputs(text[CantPostOnSub]); logline("P!","Post attempted"); continue; } if((block[0]=='*' || block[0]=='+') && !(cfg.sub[n]->misc&SUB_PRIV)) { bputs(text[PrivatePostsNotAllowed]); logline("P!","Private post attempt"); continue; } if(block[0]=='*' || block[0]=='+' /* Private post */ || cfg.sub[n]->misc&SUB_PONLY) { sprintf(str,"%-25.25s",nulstr); sprintf(tmp,"%-25.25s","ALL"); if(!strnicmp((char *)block+21,str,25) || !strnicmp((char *)block+21,tmp,25)) { /* to blank */ bputs(text[NoToUser]); /* or all */ continue; } } if(!SYSOP && !(useron.rest&FLAG('Q'))) { sprintf(str,"%-25.25s","SYSOP"); if(!strnicmp((char *)block+21,str,25)) { sprintf(str,"%-25.25s",username(&cfg,1,tmp)); memcpy((char *)block+21,str,25); /* change from sysop */ } /* to user name */ } /* TWIT FILTER */ if(twit_list) { sprintf(fname,"%stwitlist.cfg",cfg.ctrl_dir); sprintf(from,"%25.25s",block+46); /* From user */ truncsp(from); sprintf(to,"%25.25s",block+21); /* To user */ truncsp(to); if(findstr(from,fname) || findstr(to,fname)) { sprintf(str,"Filtering post from %s to %s on %s %s" ,from ,to ,cfg.grp[cfg.sub[n]->grp]->sname,cfg.sub[n]->lname); logline("P!",str); continue; } } if(n!=lastsub) { if(lastsub!=INVALID_SUB) smb_close(&smb); lastsub=INVALID_SUB; sprintf(smb.file,"%s%s",cfg.sub[n]->data_dir,cfg.sub[n]->code); smb.retry_time=cfg.smb_retry_time; smb.subnum=n; if((j=smb_open(&smb))!=0) { errormsg(WHERE,ERR_OPEN,smb.file,j,smb.last_error); continue; } if(!filelength(fileno(smb.shd_fp))) { smb.status.max_crcs=cfg.sub[n]->maxcrcs; smb.status.max_msgs=cfg.sub[n]->maxmsgs; smb.status.max_age=cfg.sub[n]->maxage; smb.status.attr=cfg.sub[n]->misc&SUB_HYPER ? SMB_HYPERALLOC:0; if((j=smb_create(&smb))!=0) { smb_close(&smb); lastsub=INVALID_SUB; errormsg(WHERE,ERR_CREATE,smb.file,j); continue; } } if((j=smb_locksmbhdr(&smb))!=0) { smb_close(&smb); lastsub=INVALID_SUB; errormsg(WHERE,ERR_LOCK,smb.file,j); continue; } if((j=smb_getstatus(&smb))!=0) { smb_close(&smb); lastsub=INVALID_SUB; errormsg(WHERE,ERR_READ,smb.file,j); continue; } smb_unlocksmbhdr(&smb); lastsub=n; } if(!qwktomsg(rep,block,0,n,0)) continue; logon_posts++; user_posted_msg(&cfg, &useron, 1); bprintf(text[Posted],cfg.grp[cfg.sub[n]->grp]->sname ,cfg.sub[n]->lname); sprintf(str,"%s posted on %s %s" ,useron.alias,cfg.grp[cfg.sub[n]->grp]->sname,cfg.sub[n]->lname); signal_sub_sem(&cfg,n); logline("P+",str); if(!(useron.rest&FLAG('Q'))) user_event(EVENT_POST); } /* end of public message */ } update_qwkroute(NULL); /* Write ROUTE.DAT */ if(lastsub!=INVALID_SUB) smb_close(&smb); fclose(rep); if(useron.rest&FLAG('Q')) { /* QWK Net Node */ sprintf(str,"%s%s.msg",cfg.temp_dir,cfg.sys_id); if(fexistcase(str)) remove(str); sprintf(str,"%s%s.rep",cfg.temp_dir,cfg.sys_id); if(fexistcase(str)) remove(str); sprintf(str,"%sATTXREF.DAT",cfg.temp_dir); if(fexistcase(str)) remove(str); dir=opendir(cfg.temp_dir); while(dir!=NULL && (dirent=readdir(dir))!=NULL) { /* Extra files */ // Move files sprintf(str,"%s%s",cfg.temp_dir,dirent->d_name); if(isdir(str)) continue; // Create directory if necessary sprintf(inbox,"%sqnet/%s.in",cfg.data_dir,useron.alias); MKDIR(inbox); sprintf(fname,"%s/%s",inbox,dirent->d_name); mv(str,fname,1); sprintf(str,text[ReceivedFileViaQWK],dirent->d_name,useron.alias); putsmsg(&cfg,1,str); } if(dir!=NULL) closedir(dir); sprintf(str,"%sqnet-rep.now",cfg.data_dir); ftouch(str); } bputs(text[QWKUnpacked]); CRLF; /**********************************************/ /* Hang-up now if that's what the user wanted */ /**********************************************/ autohangup(); return(true); }