home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
UTIL
/
WWIVE
/
MISCCMD.C
< prev
next >
Wrap
Text File
|
1992-06-16
|
15KB
|
642 lines
/*****************************************************************************
WWIV Version 4
Copyright (C) 1988-1991 by Wayne Bell
Distribution of the source code for WWIV, in any form, modified or unmodified,
without PRIOR, WRITTEN APPROVAL by the author, is expressly prohibited.
Distribution of compiled versions of WWIV is limited to copies compiled BY
THE AUTHOR. Distribution of any copies of WWIV not compiled by the author
is expressly prohibited.
*****************************************************************************/
#include "vars.h"
#pragma hdrstop
void read_automessage()
{
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("6No 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,"<<< %s >>>",&(l[0][0]));
} else
strcpy(s,"1>7UNKNOWN1<");
else
strcpy(s,&(l[0][0]));
nl();
npr("1Auto message by3:7 %s\r\n",s);
pl("7═══════════════");
nl();
i=1;
while ((ptrend[i]) && (i<6)) {
pl(&(l[i][0]));
++i;
}
}
nl();
}
void write_automessage1()
{
int i,i1,f;
char s[81],l[4][81];
slrec ss;
nl();
pl("1Enter auto-message7,1 3 lines7:");
nl();
for (i=0; i<3; i++) {
npr("7[1%d7]3:5",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(7,"Anonymous? ");
if (yn())
i1=anony_sender;
else
i1=0;
} else
i1=0;
prt(1,"Is this OK? ");
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("Changed Auto-message");
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("6Auto-message saved.");
nl();
close(f);
}
}
void write_automessage()
{
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(1,"A-msg:7 R1:ead,7 W1:rite,7 A1:uto-reply,7 Q1:uit : ");
ch=onek("QRWA");
} else {
prt(1,"A-msg:7 R1:ead,7 A1:uto-reply,7 Q1:uit : ");
ch=onek("QRA");
}
switch(ch) {
case 'Q':
done=1;
break;
case 'R':
read_automessage();
break;
case 'W':
write_automessage1();
break;
case 'A':
if (status.amsguser)
email(status.amsguser,0,0,status.amsganon);
break;
}
} while ((!done) && (!hangup));
}
void bbslist()
{
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(1,"BBS list:7 R1:ead,7 A1:dd,7 N1:et,7 Q1:uit : ");
ch=onek("QRNA");
switch(ch) {
case 'Q':
done=1;
break;
case 'R':
pl("7╔════════════════════════════════════════════════════════════════════════════╗");
pl("7║3 Number 2BBS Name 7Baud 1Type7 ║");
pl("7╚════════════════════════════════════════════════════════════════════════════╝");
pl("7══════════════════════════════════════════════════════════════════════════════");
printfile("BBSLIST.MSG");
pl("7══════════════════════════════════════════════════════════════════════════════");
break;
case 'N':
print_net_listing(0);
break;
case 'A':
if ((actsl<=10)) {
nl();
nl();
pl("6You must be a validated user to add to the BBS list.");
nl();
break;
}
if (thisuser.restrict & restrict_automessage) {
nl();
nl();
pl("3You can not add to the BBS list.");
nl();
break;
}
nl();
pl("1Please enter phone number:");
pl("2 ###-###-####");
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("3Number not yet in BBS list.");
nl();
nl();
pl("5Enter BBS name and comments (incl. V.32/HST) :");
outstr(":");
mpl(47);
inputl(name,47);
nl();
pl("7Enter maximum speed of the BBS:");
pl("1ie, 300,1200,2400,9600,14.4,19.2");
outstr(":");
mpl(4);
input(speed,4);
nl();
pl("2Enter BBS type (ie, WWIV):");
outstr(":");
mpl(4);
input(type,4);
sprintf(s,"1*3%12s 2%-47s 7[1%4s7] (1%4s7)1*\r\n",
phone, name, speed, type);
nl();
nl();
pl(s);
nl();
prt(5,"3Is this correct? ");
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("5Added to BBS list.");
}
} else {
pl("6It's already in the BBS list.");
nl();
nl();
}
} else {
nl();
pl("6Please enter number in correct format.");
nl();
}
break;
}
} while ((!done) && (!hangup));
}
void kill_old_email()
{
int cur,max,i,i1,f,done,done1,forward;
char s[81],s1[81],ch;
long l;
mailrec m;
userrec u;
slrec ss;
prt(1,"List mail starting at most recent? ");
forward=(yn());
ss=syscfg.sl[actsl];
sprintf(s,"%sEMAIL.DAT",syscfg.datadir);
f=open(s,O_RDWR | O_BINARY);
if (f==-1) {
nl();
pl("6No mail.");
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();
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,"1>7UNKNOWN1<");
npr("7[1To7]1 :3 %s\r\n",s1);
} else {
npr("7[1To7]1 :3 User %d, system %d\r\n", m.touser, m.tosys);
}
npr("7[1Title7]1:3 %s\r\n",m.title);
time(&l);
i=(int) ((l-m.daten)/24.0/3600.0);
npr("7[1Sent7]1 :3 %d days ago\r\n",i);
nl();
prt(7,"R1:ead,7 D1:elete,7 N1:ext,7 Q1:uit : ");
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("6Mail deleted.");
nl();
sysoplog("Deleted mail.");
break;
case 'R':
nl();
nl();
npr("7[1Title7]1:3 %s\r\n",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()
{
subboardrec s;
userrec u;
int i,nu,abort,ok,num;
char st[81];
if (usub[cursub].subnum==-1) {
nl();
pl("No sub!");
nl();
return;
}
s=subboards[usub[cursub].subnum];
nl();
pl("1Users with access to current sub:");
pl("7═════════════════════════════════");
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)
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("1%d users.\r\n",num);
pl("7══════════");
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,"1%c2 %2d3:5 %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,"c│ 7Voting question 1#%-2d c│",i);
pl("c╒═══════════════════════════════════════════════════════════════════════════╕");
pla(s,&abort);
/* pla(v.question,&abort);*/
npr("c│ 1%-73s c│\r\n",v.question);
pl("c╘═══════════════════════════════════════════════════════════════════════════╛");
nl();
t=0;
for (i1=0; i1<v.numanswers; i1++) {
vr=v.responses[i1];
t+=vr.numresponses;
}
sprintf(s,"7Users voting1:3 %4.1f%%\r\n",
((double) t) / ((double) status.users) * 100.0);
pla(s,&abort);
nl();
if (t)
t1=t;
else
t1=1;
pla("1 0: No Comment",&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,"1%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,"3Your vote:7 ");
vr=v.responses[thisuser.votes[ii]-1];
if (thisuser.votes[ii])
strcat(s,vr.response);
else
strcat(s,"1No Comment");
pl(s);
nl();
prt(5,"Change it? ");
if (!yn())
return;
prt(3,"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()
{
int i,i1,i2,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("7No voting questions currently.");
nl();
close(f);
return;
}
print_quest(f,mapp,&map[0]);
done=0;
do {
nl();
nl();
prt(1,"Voting:7 Number,Q,? 3: ");
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)
done=1;
else
if (strcmp(ss,"?")==0)
print_quest(f,mapp,&map[0]);
} while ((!done) && (!hangup));
close(f);
}