static void scan_msgbase(int num) { int i, first = -1; char *headers; if (!changemsgbase(num, MC_QUICK | MC_NOSTAT)) return; getmsgptrs(); if (!(headers = get_headers())) return; for (i = lowest; i <= highest; i++) { if (!headers[i - lowest]) continue; if (!simple_search(i)) headers[i - lowest] = 0; else if (first == -1) first = i; } if (first == -1) return; readmessages(-1, first, headers); free(headers); }
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); }
bool sbbs_t::logon() { char str[256],c; char tmp[512]; int file; uint i,j,mailw; long kmode; ulong totallogons; node_t node; struct tm tm; now=time(NULL); if(localtime_r(&now,&tm)==NULL) return(false); if(!useron.number) return(false); client.user=useron.alias; client_on(client_socket,&client,TRUE /* update */); #ifdef JAVASCRIPT js_create_user_objects(); #endif if(useron.rest&FLAG('Q')) qwklogon=1; if(SYSOP && !(cfg.sys_misc&SM_R_SYSOP)) return(false); if(useron.rest&FLAG('G')) { /* Guest account */ useron.misc=(cfg.new_misc&(~ASK_NSCAN)); useron.rows=0; useron.misc&=~(ANSI|RIP|WIP|NO_EXASCII|COLOR|HTML); useron.misc|=autoterm; if(!(useron.misc&ANSI) && text[AnsiTerminalQ][0] && yesno(text[AnsiTerminalQ])) useron.misc|=ANSI; if(useron.misc&(RIP|WIP|HTML) || (useron.misc&ANSI && text[ColorTerminalQ][0] && yesno(text[ColorTerminalQ]))) useron.misc|=COLOR; if(text[ExAsciiTerminalQ][0] && !yesno(text[ExAsciiTerminalQ])) useron.misc|=NO_EXASCII; for(i=0;i<cfg.total_xedits;i++) if(!stricmp(cfg.xedit[i]->code,cfg.new_xedit) && chk_ar(cfg.xedit[i]->ar,&useron,&client)) break; if(i<cfg.total_xedits) useron.xedit=i+1; else useron.xedit=0; useron.prot=cfg.new_prot; useron.shell=cfg.new_shell; } if(!chk_ar(cfg.node_ar,&useron,&client)) { bputs(text[NoNodeAccess]); sprintf(str,"(%04u) %-25s Insufficient node access" ,useron.number,useron.alias); logline(LOG_NOTICE,"+!",str); return(false); } getnodedat(cfg.node_num,&thisnode,1); if(thisnode.misc&NODE_LOCK) { putnodedat(cfg.node_num,&thisnode); /* must unlock! */ if(!SYSOP && !(useron.exempt&FLAG('N'))) { bputs(text[NodeLocked]); sprintf(str,"(%04u) %-25s Locked node logon attempt" ,useron.number,useron.alias); logline(LOG_NOTICE,"+!",str); return(false); } if(yesno(text[RemoveNodeLockQ])) { getnodedat(cfg.node_num,&thisnode,1); logline("S-","Removed Node Lock"); thisnode.misc&=~NODE_LOCK; } else getnodedat(cfg.node_num,&thisnode,1); } if(useron.exempt&FLAG('H')) console|=CON_NO_INACT; if((useron.exempt&FLAG('Q') && useron.misc&QUIET)) thisnode.status=NODE_QUIET; else thisnode.status=NODE_INUSE; action=thisnode.action=NODE_LOGN; thisnode.connection=node_connection; thisnode.misc&=~(NODE_ANON|NODE_INTR|NODE_MSGW|NODE_POFF|NODE_AOFF); if(useron.chat&CHAT_NOACT) thisnode.misc|=NODE_AOFF; if(useron.chat&CHAT_NOPAGE) thisnode.misc|=NODE_POFF; thisnode.useron=useron.number; putnodedat(cfg.node_num,&thisnode); getusrsubs(); getusrdirs(); if(useron.misc&CURSUB && !(useron.rest&FLAG('G'))) { for(i=0;i<usrgrps;i++) { for(j=0;j<usrsubs[i];j++) { if(!strcmp(cfg.sub[usrsub[i][j]]->code,useron.cursub)) break; } if(j<usrsubs[i]) { curgrp=i; cursub[i]=j; break; } } for(i=0;i<usrlibs;i++) { for(j=0;j<usrdirs[i];j++) if(!strcmp(cfg.dir[usrdir[i][j]]->code,useron.curdir)) break; if(j<usrdirs[i]) { curlib=i; curdir[i]=j; break; } } } if(useron.misc&AUTOTERM) { useron.misc&=~(ANSI|RIP|WIP|HTML); useron.misc|=autoterm; } if(!chk_ar(cfg.shell[useron.shell]->ar,&useron,&client)) { useron.shell=cfg.new_shell; if(!chk_ar(cfg.shell[useron.shell]->ar,&useron,&client)) { for(i=0;i<cfg.total_shells;i++) if(chk_ar(cfg.shell[i]->ar,&useron,&client)) break; if(i==cfg.total_shells) useron.shell=0; } } logon_ml=useron.level; logontime=time(NULL); starttime=logontime; useron.logontime=(time32_t)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); sprintf(str,"%smsgs/n%3.3u.msg",cfg.data_dir,cfg.node_num); remove(str); /* remove any pending node messages */ sprintf(str,"%smsgs/n%3.3u.ixb",cfg.data_dir,cfg.node_num); remove(str); /* remove any pending node message indices */ if(!SYSOP && online==ON_REMOTE && !qwklogon) { rioctl(IOCM|ABORT); /* users can't abort anything */ rioctl(IOCS|ABORT); } CLS; if(useron.rows) rows=useron.rows; unixtodstr(&cfg,(time32_t)logontime,str); if(!strncmp(str,useron.birth,5) && !(useron.rest&FLAG('Q'))) { bputs(text[HappyBirthday]); pause(); CLS; user_event(EVENT_BIRTHDAY); } useron.ltoday++; gettimeleft(); sprintf(str,"%sfile/%04u.dwn",cfg.data_dir,useron.number); batch_add_list(str); if(!qwklogon) { /* QWK Nodes don't go through this */ if(cfg.sys_pwdays && (ulong)logontime>(useron.pwmod+((ulong)cfg.sys_pwdays*24UL*60UL*60UL))) { bprintf(text[TimeToChangePw],cfg.sys_pwdays); c=0; while(c<LEN_PASS) { /* Create random password */ str[c]=sbbs_random(43)+'0'; if(isalnum(str[c])) c++; } str[c]=0; bprintf(text[YourPasswordIs],str); if(cfg.sys_misc&SM_PWEDIT && yesno(text[NewPasswordQ])) while(online) { bputs(text[NewPassword]); getstr(str,LEN_PASS,K_UPPER|K_LINE); truncsp(str); if(chkpass(str,&useron,true)) break; CRLF; } while(online) { if(cfg.sys_misc&SM_PWEDIT) { CRLF; bputs(text[VerifyPassword]); } else bputs(text[NewUserPasswordVerify]); console|=CON_R_ECHOX; getstr(tmp,LEN_PASS*2,K_UPPER); console&=~(CON_R_ECHOX|CON_L_ECHOX); if(strcmp(str,tmp)) { bputs(text[Wrong]); continue; } break; } strcpy(useron.pass,str); useron.pwmod=time32(NULL); putuserrec(&cfg,useron.number,U_PWMOD,8,ultoa((ulong)useron.pwmod,str,16)); bputs(text[PasswordChanged]); pause(); } if(useron.ltoday>cfg.level_callsperday[useron.level] && !(useron.exempt&FLAG('L'))) { bputs(text[NoMoreLogons]); sprintf(str,"(%04u) %-25s Out of logons" ,useron.number,useron.alias); logline(LOG_NOTICE,"+!",str); hangup(); return(false); } if(useron.rest&FLAG('L') && useron.ltoday>1) { bputs(text[R_Logons]); sprintf(str,"(%04u) %-25s Out of logons" ,useron.number,useron.alias); logline(LOG_NOTICE,"+!",str); hangup(); return(false); } kmode=(cfg.uq&UQ_NOEXASC); if(!(cfg.uq&UQ_NOUPRLWR)) kmode|=K_UPRLWR; if(!(useron.rest&FLAG('G'))) { if(!useron.name[0] && ((cfg.uq&UQ_ALIASES && cfg.uq&UQ_REALNAME) || cfg.uq&UQ_COMPANY)) while(online) { if(cfg.uq&UQ_ALIASES && cfg.uq&UQ_REALNAME) bputs(text[EnterYourRealName]); else bputs(text[EnterYourCompany]); getstr(useron.name,LEN_NAME,kmode); if(cfg.uq&UQ_ALIASES && cfg.uq&UQ_REALNAME) { if(trashcan(useron.name,"name") || !useron.name[0] || !strchr(useron.name,' ') || strchr(useron.name,0xff) || (cfg.uq&UQ_DUPREAL && userdatdupe(useron.number,U_NAME,LEN_NAME ,useron.name,0,0))) bputs(text[YouCantUseThatName]); else break; } else break; } if(cfg.uq&UQ_HANDLE && !useron.handle[0]) { sprintf(useron.handle,"%.*s",LEN_HANDLE,useron.alias); while(online) { bputs(text[EnterYourHandle]); if(!getstr(useron.handle,LEN_HANDLE ,K_LINE|K_EDIT|K_AUTODEL|(cfg.uq&UQ_NOEXASC)) || strchr(useron.handle,0xff) || (cfg.uq&UQ_DUPHAND && userdatdupe(useron.number,U_HANDLE,LEN_HANDLE ,useron.handle,0,0)) || trashcan(useron.handle,"name")) bputs(text[YouCantUseThatName]); else break; } } if(cfg.uq&UQ_LOCATION && !useron.location[0]) while(online) { bputs(text[EnterYourCityState]); if(getstr(useron.location,LEN_LOCATION,kmode)) break; } if(cfg.uq&UQ_ADDRESS && !useron.address[0]) while(online) { bputs(text[EnterYourAddress]); if(getstr(useron.address,LEN_ADDRESS,kmode)) break; } if(cfg.uq&UQ_ADDRESS && !useron.zipcode[0]) while(online) { bputs(text[EnterYourZipCode]); if(getstr(useron.zipcode,LEN_ZIPCODE,K_UPPER|(cfg.uq&UQ_NOEXASC))) break; } if(cfg.uq&UQ_PHONE && !useron.phone[0]) { if(text[CallingFromNorthAmericaQ][0]) i=yesno(text[CallingFromNorthAmericaQ]); else i=0; while(online) { bputs(text[EnterYourPhoneNumber]); if(i) { if(gettmplt(useron.phone,cfg.sys_phonefmt ,K_LINE|(cfg.uq&UQ_NOEXASC))<strlen(cfg.sys_phonefmt)) continue; } else { if(getstr(useron.phone,LEN_PHONE ,K_UPPER|(cfg.uq&UQ_NOEXASC))<5) continue; } if(!trashcan(useron.phone,"phone")) break; } } if(!(cfg.uq&UQ_NONETMAIL) && !useron.netmail[0]) { while(online) { bputs(text[EnterNetMailAddress]); if(getstr(useron.netmail,LEN_NETMAIL,K_EDIT|K_AUTODEL|K_LINE) && !trashcan(useron.netmail,"email")) break; } if(useron.netmail[0] && cfg.sys_misc&SM_FWDTONET && !noyes(text[ForwardMailQ])) useron.misc|=NETMAIL; else useron.misc&=~NETMAIL; } if(cfg.new_sif[0]) { sprintf(str,"%suser/%4.4u.dat",cfg.data_dir,useron.number); if(flength(str)<1L) create_sif_dat(cfg.new_sif,str); } } } if(!online) { sprintf(str,"(%04u) %-25s Unsuccessful logon" ,useron.number,useron.alias); logline(LOG_NOTICE,"+!",str); return(false); } SAFECOPY(useron.modem,connection); useron.logons++; putuserdat(&cfg,&useron); getmsgptrs(); sys_status|=SS_USERON; /* moved from further down */ if(useron.rest&FLAG('Q')) { sprintf(str,"(%04u) %-25s QWK Network Connection" ,useron.number,useron.alias); logline("++",str); return(true); } /********************/ /* SUCCESSFUL LOGON */ /********************/ totallogons=logonstats(); sprintf(str,"(%04u) %-25s Logon %lu - %u" ,useron.number,useron.alias,totallogons,useron.ltoday); logline("++",str); if(!qwklogon && cfg.logon_mod[0]) exec_bin(cfg.logon_mod,&main_csi); if(thisnode.status!=NODE_QUIET && (!REALSYSOP || cfg.sys_misc&SM_SYSSTAT)) { sprintf(str,"%slogon.lst",cfg.data_dir); if((file=nopen(str,O_WRONLY|O_CREAT|O_APPEND))==-1) { errormsg(WHERE,ERR_OPEN,str,O_RDWR|O_CREAT|O_APPEND); return(false); } getuserrec(&cfg,useron.number,U_NOTE,LEN_NOTE,useron.note); getuserrec(&cfg,useron.number,U_LOCATION,LEN_LOCATION,useron.location); sprintf(str,text[LastFewCallersFmt],cfg.node_num ,totallogons,useron.alias ,cfg.sys_misc&SM_LISTLOC ? useron.location : useron.note ,tm.tm_hour,tm.tm_min ,connection,useron.ltoday > 999 ? 999 : useron.ltoday); write(file,str,strlen(str)); close(file); } if(cfg.sys_logon[0]) /* execute system logon event */ external(cmdstr(cfg.sys_logon,nulstr,nulstr,NULL),EX_STDOUT); /* EX_SH */ if(qwklogon) return(true); sys_status|=SS_PAUSEON; /* always force pause on during this section */ mailw=getmail(&cfg,useron.number,0); if(!(cfg.sys_misc&SM_NOSYSINFO)) { bprintf(text[SiSysName],cfg.sys_name); //bprintf(text[SiNodeNumberName],cfg.node_num,cfg.node_name); bprintf(text[LiUserNumberName],useron.number,useron.alias); bprintf(text[LiLogonsToday],useron.ltoday ,cfg.level_callsperday[useron.level]); bprintf(text[LiTimeonToday],useron.ttoday ,cfg.level_timeperday[useron.level]+useron.min); bprintf(text[LiMailWaiting],mailw); strcpy(str,text[LiSysopIs]); if(startup->options&BBS_OPT_SYSOP_AVAILABLE || (cfg.sys_chat_ar[0] && chk_ar(cfg.sys_chat_ar,&useron,&client))) strcat(str,text[LiSysopAvailable]); else strcat(str,text[LiSysopNotAvailable]); bprintf("%s\r\n\r\n",str); } if(sys_status&SS_EVENT) bprintf(text[ReducedTime],timestr(event_time)); getnodedat(cfg.node_num,&thisnode,1); thisnode.misc&=~(NODE_AOFF|NODE_POFF); if(useron.chat&CHAT_NOACT) thisnode.misc|=NODE_AOFF; if(useron.chat&CHAT_NOPAGE) thisnode.misc|=NODE_POFF; putnodedat(cfg.node_num,&thisnode); getsmsg(useron.number); /* Moved from further down */ SYNC; c=0; for(i=1;i<=cfg.sys_nodes;i++) if(i!=cfg.node_num) { getnodedat(i,&node,0); if(!(cfg.sys_misc&SM_NONODELIST) && (node.status==NODE_INUSE || ((node.status==NODE_QUIET || node.errors) && SYSOP))) { if(!c) bputs(text[NodeLstHdr]); printnodedat(i,&node); c=1; } if(node.status==NODE_INUSE && i!=cfg.node_num && node.useron==useron.number && !SYSOP && !(useron.exempt&FLAG('G'))) { SAFEPRINTF2(str,"(%04u) %-25s On two nodes at the same time" ,useron.number,useron.alias); logline(LOG_NOTICE,"+!",str); bputs(text[UserOnTwoNodes]); hangup(); return(false); } if(thisnode.status!=NODE_QUIET && (node.status==NODE_INUSE || node.status==NODE_QUIET) && !(node.misc&NODE_AOFF) && node.useron!=useron.number) { sprintf(str,text[NodeLoggedOnAtNbps] ,cfg.node_num ,thisnode.misc&NODE_ANON ? text[UNKNOWN_USER] : useron.alias ,connection); putnmsg(&cfg,i,str); } } if(cfg.sys_exp_warn && useron.expire && useron.expire>now /* Warn user of coming */ && (useron.expire-now)/(1440L*60L)<=cfg.sys_exp_warn) /* expiration */ bprintf(text[AccountWillExpireInNDays],(useron.expire-now)/(1440L*60L)); if(criterrs && SYSOP) bprintf(text[CriticalErrors],criterrs); if((i=getuserxfers(0,useron.number,0))!=0) bprintf(text[UserXferForYou],i,i>1 ? "s" : nulstr); if((i=getuserxfers(useron.number,0,0))!=0) bprintf(text[UnreceivedUserXfer],i,i>1 ? "s" : nulstr); SYNC; sys_status&=~SS_PAUSEON; /* Turn off the pause override flag */ if(online==ON_REMOTE) rioctl(IOSM|ABORT); /* Turn abort ability on */ if(text[ReadYourMailNowQ][0] && mailw) { if(yesno(text[ReadYourMailNowQ])) readmail(useron.number,MAIL_YOUR); } if(usrgrps && useron.misc&ASK_NSCAN && text[NScanAllGrpsQ][0] && yesno(text[NScanAllGrpsQ])) scanallsubs(SCAN_NEW); if(usrgrps && useron.misc&ASK_SSCAN && text[SScanAllGrpsQ][0] && yesno(text[SScanAllGrpsQ])) scanallsubs(SCAN_TOYOU); return(true); }
int changemsgbase(int newb, int flags) { char cbuffer[500]; int basen; int i; struct DayDream_LRP lrpd; int lrpfd; struct stat st; msgbase_t *cb; if (!conference()->conf.CONF_MSGBASES) { current_msgbase = NULL; return 0; } basen = newb; if (basen > conference()->conf.CONF_MSGBASES) basen = 0; /* The MC_QUICK flag is used on non-interactive occasions. */ if (!basen && (flags & MC_QUICK)) return 0; if (!basen) { if (conference()->conf.CONF_MSGBASES == 1) { DDPut(sd[cmbonlymsgsstr]); return 0; } TypeFile("messagebases", TYPE_WARN | TYPE_CONF | TYPE_MAKE); } while (!basen) { DDPut(sd[cmbselectstr]); cbuffer[0] = 0; if (!(Prompt(cbuffer, 3, 0))) return 0; if (!strcasecmp(cbuffer, "?") || (!strcasecmp(cbuffer, "l"))) { TypeFile("messagebases", TYPE_WARN | TYPE_CONF | TYPE_MAKE); } else if (cbuffer[0] == 0) { return 0; } else basen = atoi(cbuffer); } for (i = 0; i < conference()->conf.CONF_MSGBASES; i++) { cb = conference()->msgbases[i]; if (cb->MSGBASE_NUMBER != basen) continue; current_msgbase = cb; getmsgptrs(); if (lrpdatname[0] && (oldlrp != lrp || oldlsp != lsp)) { lrpfd = open(lrpdatname, O_WRONLY | O_CREAT, 0666); if (lrpfd == -1) { DDPut(sd[cmberrlrpstr]); return 0; } fsetperm(lrpfd, 0666); fstat(lrpfd, &st); lrpd.lrp_read = lrp; lrpd.lrp_scan = lsp; lseek(lrpfd, sizeof(struct DayDream_LRP) * user.user_account_id, SEEK_SET); safe_write(lrpfd, &lrpd, sizeof(struct DayDream_LRP)); close(lrpfd); } snprintf(lrpdatname, sizeof lrpdatname, "%s/messages/base%3.3d/msgbase.lrp", conference()->conf.CONF_PATH, cb->MSGBASE_NUMBER); lrpfd = open(lrpdatname, O_RDONLY); lrp = 0; lsp = 0; oldlrp = 0; oldlsp = 0; if (lrpfd != -1) { if ((lseek(lrpfd, sizeof(struct DayDream_LRP) * user.user_account_id, SEEK_SET)) != -1) { if (read(lrpfd, &lrpd, sizeof(struct DayDream_LRP))) { oldlrp = lrp = lrpd.lrp_read; oldlsp = lsp = lrpd.lrp_scan; } } close(lrpfd); } current_msgbase = cb; getmsgptrs(); if ((flags & MC_NOSTAT) == 0) { ddprintf(sd[cmbstat1str], current_msgbase->MSGBASE_NAME, highest - lowest); ddprintf(sd[cmbstat2str], lrp, lsp); ddprintf(sd[cmbstat3str], lowest, highest); } return 1; } DDPut(sd[cmbunkbasestr]); return 0; }
int entermsg(struct DayDream_Message *msg, int reply, char *params) { char ebuf[1024]; int hola; int msgfd; char *s; struct DayDream_Message header; char *lineedmem; int recoff; if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'E' && ((access1 & (1L << SECB_FIDOMESSAGE)) == 0)) { DDPut(sd[emnofidomsgstr]); return 0; } if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'N' && ((access2 & (1L << SECB_SENDNETMAIL)) == 0)) { DDPut(sd[emnonetmsgstr]); return 0; } changenodestatus("Entering a message"); if (msg) { memcpy(&header, msg, sizeof(struct DayDream_Message)); } else { s = (char *) &header; memset(&header, 0, sizeof(struct DayDream_Message)); if (params) strncpy(header.MSG_RECEIVER, params, 25); } if (current_msgbase->MSGBASE_FLAGS & (1L << 0) && current_msgbase->MSGBASE_FLAGS & (1L << 1)) { DDPut(sd[emnomsgsstr]); return 0; } DDPut(sd[emhead1str]); DDPut(current_msgbase->MSGBASE_NAME); ebuf[0] = 0; strlcat(ebuf, sd[emhead2str], sizeof ebuf); hola = 61 - strlen(current_msgbase->MSGBASE_NAME); while (hola) { strlcat(ebuf, "-", sizeof ebuf); hola--; } DDPut(ebuf); ddprintf(sd[emhead3str], highest); DDPut(sd[emhead4str]); if ((current_msgbase->MSGBASE_FLAGS & (1L << 0)) || (header.MSG_FLAGS & (1L << 0))) { DDPut(sd[emprvstr]); header.MSG_FLAGS |= (1L << 0); } else { DDPut(sd[empubstr]); } header.MSG_CREATION = time(0); DDPut(sd[emhead5str]); DDPut(ctime(&header.MSG_CREATION)); DDPut(sd[emhead6str]); if (current_msgbase->MSGBASE_FLAGS & (1L << 2)) { strlcpy(header.MSG_AUTHOR, user.user_handle, sizeof header.MSG_AUTHOR); } else { strlcpy(header.MSG_AUTHOR, user.user_realname, sizeof header.MSG_AUTHOR); } DDPut(header.MSG_AUTHOR); for (;;) { askrec: DDPut(sd[emhead7str]); if (!(Prompt(header.MSG_RECEIVER, 25, 0))) return 0; if (header.MSG_RECEIVER[0] == 0 || (!strcasecmp(header.MSG_RECEIVER, "all")) || (!strcasecmp(header.MSG_RECEIVER, "all users"))) { if (current_msgbase->MSGBASE_FLAGS & (1L << 0)) { DDPut(sd[emhead8str]); HotKey(0); header.MSG_RECEIVER[0] = 0; } else { DDPut(sd[emhead9str]); header.MSG_RECEIVER[0] = 0; break; } } else if (!strcasecmp(header.MSG_RECEIVER, "eall")) { if (current_msgbase->MSGBASE_FLAGS & (1L << 0)) { DDPut(sd[emhead8str]); HotKey(0); header.MSG_RECEIVER[0] = 0; } else if (access1 & (1L << SECB_EALLMESSAGE)) { header.MSG_RECEIVER[0] = -1; DDPut(sd[emhead10str]); break; } else { DDPut(sd[emnopoststr]); HotKey(0); header.MSG_RECEIVER[0] = 0; } } else { if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'L') { struct userbase user; if (!strcasecmp(header.MSG_RECEIVER, "sysop")) { recoff = 0; } else { recoff = findusername(header.MSG_RECEIVER); } if (recoff == -1 || getubentbyid(recoff, &user) == -1) { DDPut(sd[emnouserstr]); HotKey(0); goto askrec; } if (!checkconfaccess(conference()->conf.CONF_NUMBER, &user)) { DDPut(sd[emnoaccessstr]); HotKey(0); } DDPut("[5;12H [5;12H"); if (current_msgbase->MSGBASE_FLAGS & (1L << 2)) { strlcpy(header.MSG_RECEIVER, user.user_handle, sizeof header.MSG_RECEIVER); } else { strlcpy(header.MSG_RECEIVER, user.user_realname, sizeof header.MSG_RECEIVER); } DDPut(header.MSG_RECEIVER); break; } else break; } } DDPut(sd[emsubjectstr]); if (!(Prompt(header.MSG_SUBJECT, 67, 0))) return 0; if (header.MSG_SUBJECT[0] == 0) { DDPut(sd[emabortedstr]); return 0; } DDPut("[11;1H [11;1H"); if (header.MSG_RECEIVER[0] == 0 || header.MSG_RECEIVER[0] == -1 || header.MSG_FLAGS & (1L << 0) || current_msgbase->MSGBASE_FLAGS & (1L << 1)) { } else { DDPut(sd[emisprivatestr]); hola = HotKey(HOT_NOYES); if (hola == 0) return 0; if (hola == 1) header.MSG_FLAGS |= MSG_FLAGS_PRIVATE; } if ((header.MSG_FLAGS & (1L << 0)) == 0 && (access1 & (1L << SECB_PUBLICMESSAGE)) == 0) { DDPut(sd[emnopubstr]); return 0; } if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'N') { if (header.MSG_FN_DEST_NET) { snprintf(ebuf, sizeof ebuf, "%d:%d/%d.%d", header.MSG_FN_DEST_ZONE, header.MSG_FN_DEST_NET, header.MSG_FN_DEST_NODE, header.MSG_FN_DEST_POINT); } else { *ebuf = 0; } DDPut(sd[emnetaddstr]); if (!(Prompt(ebuf, 30, 0))) return 0; if (!str2addr(ebuf, &header.MSG_FN_DEST_ZONE, &header.MSG_FN_DEST_NET, &header.MSG_FN_DEST_NODE, &header.MSG_FN_DEST_POINT)) return 0; if(access2 & (1L << SECB_CRASH)) { DDPut(sd[emnetcrashstr]); if(HotKey(HOT_NOYES) == 1) { header.MSG_FLAGS |= MSG_FLAGS_CRASH; } } DDPut(sd[emnetkillstr]); if(HotKey(HOT_YESNO) == 1) { header.MSG_FLAGS |= MSG_FLAGS_KILL_SENT; } } *header.MSG_ATTACH = 0; if (current_msgbase->MSGBASE_FLAGS & (1L << 5)) { if ((header.MSG_FLAGS & (1L << 0)) && (access2 & (1L << SECB_PVTATTACH))) { *header.MSG_ATTACH = 1; } else if (((header.MSG_FLAGS & (1L << 0)) == 0) && (access2 & (1L << SECB_PUBATTACH))) { *header.MSG_ATTACH = 1; } } if (reply) { if (!askqlines()) { snprintf(ebuf, sizeof ebuf, "%s/daydream%d.msg", DDTMP, node); unlink(ebuf); } DDPut("\n\n"); } /* XXX: size should be replaced by a constant! */ lineedmem = (char *) xmalloc(80 * 500); hola = edfile(lineedmem, 80 * 500, reply, &header); if (hola == 0) { char fabuf[1024]; DDPut(sd[emaborted2str]); free(lineedmem); if (cleantemp() == -1) { DDPut(sd[tempcleanerrstr]); return 0; } snprintf(fabuf, sizeof fabuf, "%s/attachs.%d", DDTMP, node); unlink(fabuf); return 0; } DDPut(sd[emsavingstr]); getmsgptrs(); highest++; header.MSG_NUMBER = highest; if (setmsgptrs() == 0) { free(lineedmem); return 0; } if (*header.MSG_ATTACH) { char fabuf[1024]; FILE *fd; snprintf(fabuf, sizeof fabuf, "%s/attachs.%d", DDTMP, node); if ((fd = fopen(fabuf, "r"))) { char hoobab[1024]; snprintf(hoobab, sizeof hoobab, "%s/messages/base%3.3d/fa%5.5d", conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER); mkdir(hoobab, 0777); setperm(hoobab, 0777); while (fgetsnolf(hoobab, 1024, fd)) { char sr[1024]; char de[1024]; snprintf(sr, sizeof sr, "%s/%s", currnode->MULTI_TEMPORARY, hoobab); snprintf(de, sizeof de, "%s/messages/base%3.3d/fa%5.5d/%s", conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER, hoobab); newrename(sr, de); } fclose(fd); snprintf(hoobab, sizeof hoobab, "%s/messages/base%3.3d/msf%5.5d", conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER); newrename(fabuf, hoobab); } else { *header.MSG_ATTACH = 0; } } if (toupper(current_msgbase->MSGBASE_FN_FLAGS) != 'L') { header.MSG_FN_ORIG_ZONE = current_msgbase->MSGBASE_FN_ZONE; header.MSG_FN_ORIG_NET = current_msgbase->MSGBASE_FN_NET; header.MSG_FN_ORIG_NODE = current_msgbase->MSGBASE_FN_NODE; header.MSG_FN_ORIG_POINT = current_msgbase->MSGBASE_FN_POINT; header.MSG_FLAGS |= (1L << 2); } if ((msgfd = ddmsg_open_base(conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, O_RDWR | O_CREAT, 0666)) == -1) { DDPut(sd[emwriteerrstr]); free(lineedmem); return 0; } fsetperm(msgfd, 0666); lseek(msgfd, 0, SEEK_END); safe_write(msgfd, &header, sizeof(struct DayDream_Message)); ddmsg_close_base(msgfd); if ((msgfd = ddmsg_open_msg(conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER, O_RDWR | O_CREAT | O_TRUNC, 0666)) == -1) { DDPut(sd[emwriteerrstr]); free(lineedmem); return 0; } fsetperm(msgfd, 0666); if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'E') { char ub[128]; int uq; strlcpy(ub, current_msgbase->MSGBASE_FN_TAG, sizeof ub); strupr(ub); snprintf(ebuf, sizeof ebuf, "AREA:%s\n", ub); safe_write(msgfd, ebuf, strlen(ebuf)); if ((uq = getfidounique())) { snprintf(ebuf, sizeof ebuf, "\001MSGID: %d:%d/%d.%d %8.8x\n", current_msgbase->MSGBASE_FN_ZONE, current_msgbase->MSGBASE_FN_NET, current_msgbase->MSGBASE_FN_NODE, current_msgbase->MSGBASE_FN_POINT, uq); safe_write(msgfd, ebuf, strlen(ebuf)); if (header.MSG_ORIGINAL) { if (getreplyid(header.MSG_ORIGINAL, ebuf, sizeof ebuf)) safe_write(msgfd, ebuf, strlen(ebuf)); } } } else if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'N') { snprintf(ebuf, sizeof ebuf, "\001INTL %d:%d/%d %d:%d/%d\n", header.MSG_FN_DEST_ZONE, header.MSG_FN_DEST_NET, header.MSG_FN_DEST_NODE, header.MSG_FN_ORIG_ZONE, header.MSG_FN_ORIG_NET, header.MSG_FN_ORIG_NODE); safe_write(msgfd, ebuf, strlen(ebuf)); if (header.MSG_FN_DEST_POINT) { snprintf(ebuf, sizeof ebuf, "\001TOPT %d\n", header.MSG_FN_DEST_POINT); safe_write(msgfd, ebuf, strlen(ebuf)); } if (header.MSG_FN_ORIG_POINT) { snprintf(ebuf, sizeof ebuf, "\001FMPT %d\n", header.MSG_FN_ORIG_POINT); safe_write(msgfd, ebuf, strlen(ebuf)); } } s = lineedmem; while (hola) { snprintf(ebuf, sizeof ebuf, "%s\n", s); safe_write(msgfd, ebuf, strlen(ebuf)); hola--; s = &s[80]; } // place holder, user auto-sig goes here // snprintf(ebuf, sizeof ebuf, "signature here"); // safe_write(msgfd, ebuf, strlen(ebuf)); if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'E') { snprintf(ebuf, sizeof ebuf, "\n--- DayDream BBS/UNIX (" UNAME ") %s\n * Origin: %s (%d:%d/%d)\nSEEN-BY: %d/%d\n", versionstring, current_msgbase->MSGBASE_FN_ORIGIN, current_msgbase->MSGBASE_FN_ZONE, current_msgbase->MSGBASE_FN_NET, current_msgbase->MSGBASE_FN_NODE, current_msgbase->MSGBASE_FN_NET, current_msgbase->MSGBASE_FN_NODE); safe_write(msgfd, ebuf, strlen(ebuf)); } else if (toupper(current_msgbase->MSGBASE_FN_FLAGS) != 'L') { snprintf(ebuf, sizeof ebuf, "\n--- DayDream BBS/UNIX (" UNAME ") %s\n", versionstring); safe_write(msgfd, ebuf, strlen(ebuf)); } ddmsg_close_msg(msgfd); DDPut(sd[emdonestr]); free(lineedmem); if (header.MSG_FLAGS & (1L << 0)) { user.user_pvtmessages++; clog.cl_pvtmessages++; } else { user.user_pubmessages++; clog.cl_pubmessages++; } return 1; }
int replymessage(struct DayDream_Message *msgd) { char qbuffer[4096]; char input[2048]; char msgin[10]; FILE *msgfd; FILE *quotefd; char *s, *t; int i; int hola; int l = 0; struct DayDream_Message header; s = (char *) &header; for (hola = 0; hola < sizeof(struct DayDream_Message); hola++) { *s++ = 0; } snprintf(qbuffer, sizeof qbuffer, "%s/messages/base%3.3d/msg%5.5d", conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, msgd->MSG_NUMBER); if (!(msgfd = fopen(qbuffer, "r"))) return 0; snprintf(qbuffer, sizeof qbuffer, "%s/daydream%d.mtm", DDTMP, node); unlink(qbuffer); if (!(quotefd = fopen(qbuffer, "w"))) { fclose(msgfd); return 0; } if (current_msgbase->MSGBASE_FLAGS & (1L << 3)) { if (current_msgbase->MSGBASE_FLAGS & (1L << 4)) { s = msgd->MSG_AUTHOR; t = msgin; *t++ = *s++; while (*s) { if (*s == ' ' && *(s + 1)) { s++; *t++ = *s; } s++; } *t++ = '>'; *t = 0; } else { msgin[0] = '>'; msgin[1] = 0; } } else { msgin[0] = 0; } while (fgets(input, 2048, msgfd)) { if (l == 0 && !strncmp("AREA:", input, 5)) continue; l++; if (*input == 1) continue; if (!strncmp("SEEN-BY:", input, 8)) break; stripansi(input); snprintf(qbuffer, sizeof qbuffer, "%s%s", msgin, input); t = qbuffer; for (;;) { if (strlen(t) > 76) { char k; s = &t[75]; for (;;) { if (s == t) { k = t[75]; t[75] = 0; s = &t[75]; break; } else { if (*s == ' ') { k = *s; *s = 0; break; } s--; } } fputs(t, quotefd); fputs("\n", quotefd); *s = k; if (k == ' ') s++; t = s; snprintf(qbuffer, sizeof qbuffer, "%s%s", msgin, t); t = qbuffer; } else { fputs(t, quotefd); break; } } } if (!msgin[0]) { snprintf(qbuffer, sizeof qbuffer, "---[ %s ]", msgd->MSG_AUTHOR); for (i = strlen(qbuffer); i < 75; i++) { strlcat(qbuffer, "-", sizeof qbuffer); } strlcat(qbuffer, "\n\n", sizeof qbuffer); fputs(qbuffer, quotefd); } fclose(msgfd); fclose(quotefd); strlcpy(header.MSG_RECEIVER, msgd->MSG_AUTHOR, sizeof header.MSG_RECEIVER); strlcpy(header.MSG_SUBJECT, msgd->MSG_SUBJECT, sizeof header.MSG_SUBJECT); header.MSG_ORIGINAL = msgd->MSG_NUMBER; if (msgd->MSG_FLAGS & (1L << 0)) header.MSG_FLAGS |= (1L << 0); if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'N') { if (msgd->MSG_FN_ORIG_ZONE) { header.MSG_FN_DEST_ZONE = msgd->MSG_FN_ORIG_ZONE; } else { header.MSG_FN_DEST_ZONE = msgd->MSG_FN_PACKET_ORIG_ZONE; } header.MSG_FN_DEST_NET = msgd->MSG_FN_ORIG_NET; header.MSG_FN_DEST_NODE = msgd->MSG_FN_ORIG_NODE; header.MSG_FN_DEST_POINT = msgd->MSG_FN_ORIG_POINT; } i = entermsg(&header, 1, 0); getmsgptrs(); return i; }