home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
UTIL
/
WWIVE
/
MYWIVE.ZIP
/
MISCCMD.C
< prev
next >
Wrap
Text File
|
1993-05-19
|
16KB
|
683 lines
#include "vars.h"
#pragma hdrstop
void read_automessage()
{
int i,i1,i2,i3,f,len,ptrbeg[10],ptrend[10];
char s[81],l[10][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("1No Auto-Post! Write One!");
} 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<10) {
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,"NoBoDy #xxx");
else
strcpy(s,&(l[0][0]));
nl();
npr("7[3══── 1Auto Post Entered By5:1 %s 3──══7]\r\n",s);
nl();
i=1;
while ((ptrend[i]) && (i<10)) {
pl(&(l[i][0]));
++i;
}
}
nl();
}
void write_automessage1()
{
int i,i1,f;
char s[81],l[10][81];
slrec ss;
nl();
pl("fWrite Auto-Poste! f9 Linese: 3Ctrl-P Colors Work Heree!");
s[0]=0;
nl();
for (i=0; i<9; i++) {
outchr(i+'1');
outchr('>');
inli(&(l[i][0]),s,77,1);
strcat(&(l[i][0]),"\r\n");
}
nl();
ss=syscfg.sl[actsl];
if (ss.ability & ability_post_anony) {
prt(5,"eAnonymous!? [Y/N]: ");
if (yn())
i1=anony_sender;
else
i1=0;
} else
i1=0;
prt(5,"eIs This Ok? [Y/N]: ");
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<10; i++)
write(f,(void *)&(l[i][0]),strlen(&(l[i][0])));
sysoplog("-+*+- Changed Auto-Post!");
for (i=0; i<10; i++) {
strcpy(s," ");
l[i][strlen(&(l[i][0]))-2]=0;
strcat(s,&(l[i][0]));
sysoplog(s);
}
nl();
pl("eAuto-Post 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(3,"fAuto-Post7! e[fReade/fWritee/fEmaile/fQuite]7: ");
ch=onek("QRWE");
} else {
prt(2,"Auto-Post! [Read/Email/Quit]: ");
ch=onek("QRE");
}
switch(ch) {
case 'Q':
done=1;
break;
case 'R':
read_automessage();
break;
case 'W':
write_automessage1();
break;
case 'E':
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(2,"7[1BBS list7]f: 1R7:1ead7, 1A7:1dd7, 1N7:1et7, 1Q7:1uit 7: ");
ch=onek("QRNA");
switch(ch) {
case 'Q':
done=1;
break;
case 'R':
pl("7╔════════════════════════════════════════════════════════════════════════════╗");
pl("7║3 Number 2BBS Name 7Baud 1Type7 ║");
pl("7╚════════════════════════════════════════════════════════════════════════════╝");
printfile("BBSLIST.MSG");
break;
case 'N':
print_net_listing(0);
break;
case 'A':
if ((actsl<=1)) {
nl();
nl();
pl("7You must be a validated user to add to the BBS list.");
nl();
break;
}
if (thisuser.restrict & restrict_automessage) {
nl();
nl();
pl("fYou can not add to the BBS list.");
nl();
break;
}
nl();
pl("1Please enter phone number:");
pl(" 7■■■-■■■-■■■■");
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("1Number not yet in BBS list.");
nl();
nl();
pl("fEnter BBS name and comments (incl. V.32/HST) :");
outstr(":");
mpl(47);
inputl(name,47);
nl();
pl("eEnter maximum speed of the BBS:");
pl("eie, 300,1200,2400,9600,14.4,19.2");
outstr(":");
mpl(4);
input(speed,4);
nl();
pl("1Enter BBS type (ie, WWIV):");
outstr(":");
mpl(4);
input(type,4);
sprintf(s,"1*f%12s 2%-47s 7[1%4s7] (1%4s7)1*\r\n",
phone, name, speed, type);
nl();
nl();
pl(s);
nl();
prt(5,"eIs 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("fAdded 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 donate()
{
int i,i1,i2,f,done,ok;
char s[150],s1[150],s2[150],ch,ch1,*ss;
char amount[5];
long l,l1;
done=0;
printfile("DONATE.MSG");
do {
nl();
prt(2,"Donations [I]:nfo, [L]:ist, [D]:onate, [Q]:uit > ");
ch=onek("QILD");
switch(ch) {
case 'Q':
done=1;
break;
case 'I':
printfile("DINFO.MSG");
break;
case 'L':
pl("╔══════════════════════════════════════════╗");
pl("║ Name Amount ║");
pl("╚══════════════════════════════════════════╝");
printfile("DONATES.MSG");
break;
case 'D':
if ((actsl<=1)) {
nl();
nl();
pl("You must be a validated user to add to the Donations list.");
nl();
break;
}
nl();
npr("Hello %s ",thisuser.name);
nl();
pl("Enter the amount you wish to donate");
pl("In the form ##.##");
outstr(":");
mpl(5);
input(amount,5);
sprintf(s,"%-34s $%5s\r\n",thisuser.name, amount);
nl();
nl();
pl(s);
nl();
prt(5,"Is this correct? ");
if (yn()) {
sprintf(s1,"%sDONATES.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("Added to Donations list.");
}
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(5,"eList 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,"7>1UNKNOWN7<");
npr("1To 7: 1%s\r\n",s1);
} else {
npr("1To 7: 1User %d, system %d\r\n", m.touser, m.tosys);
}
npr("1Title7: 1%s\r\n",m.title);
time(&l);
i=(int) ((l-m.daten)/24.0/3600.0);
npr("1Sent 7: 1%d days ago\r\n",i);
nl();
prt(2,"fRe:feade, fDe:feletee, fNe:fexte, fQe:fuit e: ");
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("1Title7: 1%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 subf:");
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("f%d 7users.\r\n",num);
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,"e%c 1%2d7: 1%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);
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,"eUsers voting: 5%4.1f%%\r\n",
((double) t) / ((double) status.users) * 100.0);
pla(s,&abort);
nl();
if (t)
t1=t;
else
t1=1;
pla(" d0: 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<=1)
ok=0;
if (!ok)
return;
lseek(f,((long) ii)*sizeof(votingrec),SEEK_SET);
read(f,(void *)&v,sizeof(votingrec));
strcpy(s,"1Your vote7:1 ");
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,"eChange it? ");
if (!yn())
return;
prt(2,"fWhich? ");
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,loop;
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("6No voting questions currently.");
nl();
close(f);
return;
}
print_quest(f,mapp,&map[0]);
done=0;
do {
nl();
nl();
prt(2,"1Voting Boothe: 7[1A7]1utovotee,1Numbere,1Qe,1? 7: ");
strcpy(odc,sodc);
ss=mmkey(2);
i=atoi(ss);
if ((i>0) && (i<=mapp))
vote_question(f,i,map[i]);
else
if (strcmp(ss,"A")==0) {
for (loop=1; loop <= mapp; loop++)
if ((!thisuser.votes[ map[loop] ]) && (!hangup))
vote_question(f,loop,map[loop]);
nl();
prt(1,"AutoVote Complete.");
done=1; }
else
if (strcmp(ss,"Q")==0)
done=1;
else
if (strcmp(ss,"?")==0)
print_quest(f,mapp,&map[0]);
} while ((!done) && (!hangup));
close(f);
pl("1Now updating the Voting Results!");
voteprint();
}