home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
WWIV2.ZIP
/
MISCCMD.C
< prev
next >
Wrap
Text File
|
1995-12-10
|
14KB
|
634 lines
#include "vars.h"
#pragma hdrstop
void read_automessage(void)
{
int i,i1,i2,i3,f,len,ptrbeg[10],ptrend[10];
char s[81],l[6][81],anon,buf[512];
slrec ss;
sprintf(s,"%sAUTO.MSG",syscfg.gfilesdir);
f=open(s,O_RDWR | O_BINARY);
nl();
anon=status.amsganon;
if (f<1) {
pl("2No auto-message.");
} else {
len=read(f,(void *)buf,512);
close(f);
for (i=0; i<10; i++) {
ptrbeg[i]=0;
ptrend[i]=0;
}
i=0;
i1=0;
i2=0;
for(i=0; i<len; i++) {
if (i1) {
if (buf[i]==10) {
ptrbeg[i2]=i+1;
i1=0;
}
} else {
if (buf[i]==13) {
ptrend[i2]=i-1;
if (i2<6) {
for (i3=ptrbeg[i2]; i3<=ptrend[i2]; i3++)
l[i2][i3-ptrbeg[i2]]=buf[i3];
l[i2][ptrend[i2]-ptrbeg[i2]+1]=0;
}
++i2;
i1=1;
}
}
}
ss=syscfg.sl[actsl];
if (anon)
if (ss.ability & ability_read_post_anony) {
sprintf(s,"3<<< 5%s 3>>>",&(l[0][0]));
} else
strcpy(s,"7>1Unknown7<");
else
strcpy(s,&(l[0][0]));
nl();
pl("3┌──────────────────────────────────────∙∙∙∙∙ ∙ ∙ ∙");
npr("3│ 1Auto message by7: 1"); pl(s);
pl("3├──────────────────────────────────────∙∙∙∙∙ ∙ ∙ ∙");
i=1;
while ((ptrend[i]) && (i<6)) {
npr("3│ 5");
pl(&(l[i][0]));
++i;
}
}
pl("3└──────────────────────────────────────∙∙∙∙∙ ∙ ∙ ∙");
nl();
}
void write_automessage1(void)
{
int i,i1,f;
char s[81],l[4][81];
slrec ss;
nl();
pl(get_string(484));
nl();
for (i=0; i<3; i++) {
npr("%d:",i+1);
inputl(&(l[i][0]),39);
strcat(&(l[i][0]),"\r\n");
}
nl();
ss=syscfg.sl[actsl];
if (ss.ability & ability_post_anony) {
prt(5,get_string(485));
if (yn())
i1=anony_sender;
else
i1=0;
} else
i1=0;
prt(5,get_string(438));
if (yn()) {
status.amsganon=i1;
status.amsguser=usernum;
save_status();
sprintf(s,"%sAUTO.MSG",syscfg.gfilesdir);
f=open(s,O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
strcpy(s,nam(&thisuser,usernum));
strcat(s,"\r\n");
write(f,(void *)s,strlen(s));
for (i=0; i<3; i++)
write(f,(void *)&(l[i][0]),strlen(&(l[i][0])));
sysoplog(get_stringx(1,24));
for (i=0; i<3; i++) {
strcpy(s," ");
l[i][strlen(&(l[i][0]))-2]=0;
strcat(s,&(l[i][0]));
sysoplog(s);
}
nl();
pl(get_string(486));
nl();
close(f);
}
}
void write_automessage(void)
{
char ch;
int done,okwrite;
slrec ss;
ss=syscfg.sl[actsl];
if (ss.posts)
okwrite=1;
else
okwrite=0;
if (thisuser.restrict & restrict_automessage)
okwrite=0;
done=0;
do {
nl();
if (okwrite) {
prt(2,get_string(487));
ch=onek("QRWA");
} else {
prt(2,get_string(488));
ch=onek("QRA");
}
switch(ch) {
case 'Q':
done=1;
break;
case 'R':
read_automessage();
break;
case 'W':
write_automessage1();
break;
case 'A':
grab_quotes(NULL, NULL);
if (status.amsguser)
email(status.amsguser,0,0,status.amsganon);
break;
}
} while ((!done) && (!hangup));
}
void bbslist(void)
{
int i,i1,i2,f,done,ok;
char s[150],s1[150],s2[150],ch,ch1,*ss;
char phone[13], name[51], speed[5], type[5];
long l,l1;
done=0;
do {
nl();
prt(2,get_string(489));
ch=onek("QRNA");
switch(ch) {
case 'Q':
done=1;
break;
case 'R':
printfile("BBSLIST.MSG");
break;
case 'N':
print_net_listing(0);
break;
case 'A':
if ((actsl<=10)) {
nl();
nl();
pl(get_string(490));
nl();
break;
}
if (thisuser.restrict & restrict_automessage) {
nl();
nl();
pl(get_string(491));
nl();
break;
}
nl();
pl(get_string(492));
pl(get_string(493));
outstr(":");
mpl(12);
input(phone,12);
if ((phone[3]!='-') || (phone[7]!='-'))
phone[0]=0;
if (strlen(phone)==12) {
ok=1;
sprintf(s1,"%sBBSLIST.MSG",syscfg.gfilesdir);
f=open(s1,O_RDWR | O_CREAT | O_BINARY, S_IREAD | S_IWRITE);
if (f>0) {
lseek(f,0L,SEEK_SET);
l=filelength(f);
if ((ss=malloca(l+500L))==NULL) {
close(f);
return;
}
read(f,ss,(int)l);
l1=0L;
while ((l1<l) && (ok)) {
i=0;
do {
ch=ss[l1++];
s1[i]=ch;
if (ch==13)
s1[i]=0;
++i;
} while ((ch!=10) && (i<120) && (l1<l));
if (strstr(s1,phone)!=NULL)
ok=0;
if (strncmp(s1,phone,12)==0)
ok=0;
}
farfree(ss);
close(f);
}
if (ok) {
pl(get_string(494));
nl();
nl();
pl(get_string(495));
outstr(":");
mpl(50);
inputl(name,50);
nl();
pl(get_string(496));
pl(get_string(497));
outstr(":");
mpl(4);
input(speed,4);
nl();
pl(get_string(498));
outstr(":");
mpl(4);
input(type,4);
sprintf(s,"%12s %-50s [%4s] (%4s)\r\n",
phone, name, speed, type);
nl();
nl();
pl(s);
nl();
prt(5,get_string(499));
if (yn()) {
sprintf(s1,"%sBBSLIST.MSG",syscfg.gfilesdir);
f=open(s1,O_RDWR | O_CREAT | O_BINARY, S_IREAD | S_IWRITE);
if (filelength(f)) {
lseek(f,-1L,SEEK_END);
read(f,((void *)&ch1),1);
if (ch1==26)
lseek(f,-1L,SEEK_END);
}
write(f,(void *)s,strlen(s));
close(f);
nl();
pl(get_string(500));
}
} else {
pl(get_string(501));
nl();
nl();
}
} else {
nl();
pl(get_string(502));
nl();
}
break;
}
} while ((!done) && (!hangup));
}
void kill_old_email(void)
{
int cur,max,i,i1,f,done,done1,forward;
char s[81],s1[81],ch;
long l;
mailrec m;
userrec u;
slrec ss;
prt(5,get_string(503));
forward=(yn());
ss=syscfg.sl[actsl];
sprintf(s,"%sEMAIL.DAT",syscfg.datadir);
f=open(s,O_RDWR | O_BINARY);
if (f==-1) {
nl();
pl(get_string(504));
return;
}
max=(int) (filelength(f) / sizeof(mailrec));
if (forward)
cur=max-1;
else
cur=0;
done=0;
do {
lseek(f,((long) cur) * sizeof(mailrec), SEEK_SET);
read(f,(void *)&m,sizeof(mailrec));
while (((m.fromsys!=0) || (m.fromuser!=usernum) || (m.touser==0)) && (cur<max) && (cur>=0)) {
if (forward)
--cur;
else
++cur;
if ((cur<max) && (cur>=0)) {
lseek(f,((long) cur) * sizeof(mailrec), SEEK_SET);
read(f,(void *)&m,sizeof(mailrec));
}
}
if ((m.fromsys!=0) || (m.fromuser!=usernum) || (m.touser==0) || (cur>=max) || (cur<0))
done=1;
else {
do {
done1=0;
nl();
outstr(get_string(325));
if (m.tosys==0) {
read_user(m.touser,&u);
strcpy(s1,nam(&u,m.touser));
if ((m.anony & (anony_receiver | anony_receiver_pp | anony_receiver_da))
&& ((ss.ability & ability_read_email_anony)==0))
strcpy(s1,get_string(482));
pl(s1);
} else {
npr("#%u @%u\r\n",m.touser, m.tosys);
}
outstr(get_string(326));
pl(m.title);
time(&l);
i=(int) ((l-m.daten)/24.0/3600.0);
outstr(get_string(505));
npr("%d ",i);
pl(get_string(506));
nl();
prt(2,get_string(507));
ch=onek("QRDN");
switch(ch) {
case 'Q':
done1=1;
done=1;
break;
case 'N':
done1=1;
if (forward)
--cur;
else
++cur;
if ((cur>=max) || (cur<0))
done=1;
break;
case 'D':
done1=1;
delmail(f,cur);
nl();
pl(get_string(508));
nl();
sysoplog(get_stringx(1, 100));
break;
case 'R':
nl();
nl();
outstr(get_string(326));
pl(m.title);
setorigin(0,0);
read_message1(&m.msg,(m.anony & 0x0f), 0, &i1,"EMAIL");
break;
}
} while ((!hangup) && (!done1));
}
} while ((!done) && (!hangup));
close(f);
}
void list_users(void)
{
subboardrec s;
userrec u;
int i,nu,abort,ok,num;
char st[81];
if (usub[cursub].subnum==-1) {
nl();
pl(get_string(510));
nl();
return;
}
s=subboards[usub[cursub].subnum];
nl();
pl(get_string(511));
nl();
abort=0;
num=0;
for (i=0; (i<status.users) && (!abort) && (!hangup); i++) {
read_user(smallist[i].number,&u);
ok=1;
if (u.sl<s.readsl)
ok=0;
if (u.age<(s.age&0x7f))
ok=0;
if ((s.ar!=0) && ((u.ar & s.ar)==0))
ok=0;
if (ok) {
pla(nam(&u,smallist[i].number),&abort);
++num;
}
}
if (!abort) {
nl();
npr("%d ",num);
pl(get_string(512));
nl();
}
}
void print_quest(int f, int mapp, int map[21])
{
char s[100];
int i,abort;
votingrec v;
outchr(12);
abort=0;
for (i=1; (i<=mapp) && (abort==0); i++) {
lseek(f,((long) (map[i])) * sizeof(votingrec), SEEK_SET);
read(f,(void *)&v,sizeof(votingrec));
sprintf(s,"%c %2d: %s",
thisuser.votes[map[i]]?' ':'*',i, v.question);
pla(s,&abort);
}
nl();
if (abort)
nl();
}
int print_question(int f, int i, int ii)
{
char s[81],s1[81],s2[81];
int i1,i2,i3,t,t1,abort;
votingrec v;
voting_response vr;
lseek(f,((long) ii)*sizeof(votingrec),SEEK_SET);
read(f,(void *)&v,sizeof(votingrec));
abort=0;
outchr(12);
sprintf(s,"%s%d",get_string(513),i); /*Voting Question # */
pla(s,&abort);
pla(v.question,&abort);
nl();
t=0;
for (i1=0; i1<v.numanswers; i1++) {
vr=v.responses[i1];
t+=vr.numresponses;
}
sprintf(s,"%s: %4.1f%%\r\n",get_string(514),
((double) t) / ((double) status.users) * 100.0);
pla(s,&abort);
nl();
if (t)
t1=t;
else
t1=1;
pla(get_string(515),&abort);
for (i1=0; i1<5; i1++)
odc[i1]=0;
for (i1=0; (i1<v.numanswers) && (!abort); i1++) {
vr=v.responses[i1];
if (((i1+1) % 10)==0)
odc[((i1+1)/10)-1]='0'+((i1+1)/10);
sprintf(s,"%2d: %-60s : %4d %5.1f%%",
i1+1, vr.response, vr.numresponses,
((float)vr.numresponses)/((float)t1)*100.0);
pla(s,&abort);
}
nl();
if (abort)
nl();
return(!abort);
}
void vote_question(int f, int i, int ii)
{
int ok,pqo,i1,i2;
char s[81],*ss;
votingrec v;
voting_response vr;
pqo=print_question(f,i,ii);
ok=pqo;
ok=1;
if (restrict_vote & thisuser.restrict)
ok=0;
if (actsl<=10)
ok=0;
if (!ok)
return;
lseek(f,((long) ii)*sizeof(votingrec),SEEK_SET);
read(f,(void *)&v,sizeof(votingrec));
strcpy(s,get_string(516)); /* Your vote: */
vr=v.responses[thisuser.votes[ii]-1];
if (thisuser.votes[ii])
strcat(s,vr.response);
else
strcat(s,get_string(517)); /* No Comment */
pl(s);
nl();
prt(5,get_string(264)); /* Change it? */
if (!yn())
return;
prt(2,get_string(297)); /* Which */
ss=mmkey(2);
i1=atoi(ss);
if (i1>v.numanswers)
i1=0;
if ((i1==0) && (strcmp(ss,"0")))
return;
if (thisuser.votes[ii]) {
vr=v.responses[thisuser.votes[ii]-1];
--vr.numresponses;
v.responses[thisuser.votes[ii]-1]=vr;
}
thisuser.votes[ii]=i1;
if (i1) {
vr=v.responses[thisuser.votes[ii]-1];
++vr.numresponses;
v.responses[thisuser.votes[ii]-1]=vr;
}
lseek(f,((long) ii)*sizeof(votingrec),SEEK_SET);
write(f,(void *)&v,sizeof(votingrec));
nl();
nl();
}
void vote(void)
{
int i,i1,i2,mod1,mo,f,map[21],mapp,abort,n,done;
char s[81],s1[81],s2[81],sodc[10],*ss;
votingrec v;
sprintf(s,"%sVOTING.DAT",syscfg.datadir);
f=open(s,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
n=(int) (filelength(f) / sizeof(votingrec)) -1;
if (n<20) {
v.question[0]=0;
v.numanswers=0;
for (i=n; i<20; i++)
write(f,(void *)&v,sizeof(votingrec));
}
mapp=0;
for (i=0; i<5; i++)
odc[i]=0;
for (i=0; i<20; i++) {
lseek(f,((long) i) * sizeof(votingrec),SEEK_SET);
read(f,(void *)&v,sizeof(votingrec));
if (v.numanswers) {
map[++mapp]=i;
if ((mapp % 10)==0)
odc[(mapp/10)-1]='0'+(mapp/10);
}
}
strcpy(sodc,odc);
if (mapp==0) {
nl();
nl();
pl(get_string(518)); /*No Voting Questions */
nl();
close(f);
return;
}
print_quest(f,mapp,&map[0]);
done=0;
do {
nl();
nl();
prt(2,get_string(519)); /*Voting #, Q? */
strcpy(odc,sodc);
ss=mmkey(2);
i=atoi(ss);
if ((i>0) && (i<=mapp))
vote_question(f,i,map[i]);
else
if (strcmp(ss,"Q")==0) {
mod1=0;
for (mo=0; mo<20; mo++) {
if (questused[mo])
if (thisuser.votes[mo]==0)
mod1=1;
} if (mod1==1) { prt(1,"You can't quit yet! You didn't vote!\r\n");
}
else
done=1;
}
else
if (strcmp(ss,"?")==0)
print_quest(f,mapp,&map[0]);
} while ((!done) && (!hangup));
close(f);
}