home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
UTIL
/
WWIVE
/
MYWIVE.ZIP
/
UEDIT.C
< prev
next >
Wrap
Text File
|
1993-05-31
|
22KB
|
950 lines
#include "vars.h"
#pragma hdrstop
void dellist(int un, userrec *u)
{
int i,i1,i2,f,done,ok;
char s[150],s1[150],s2[150],ch,ch1,*ss;
char reason[50];
long l;
/* userrec u;*/
done=0;
do {
nl();
prt(2,"R:ead, A:dd, Q:uit : ");
ch=onek("QRA");
switch(ch) {
case 'Q':
done=1;
break;
case 'R':
pl("╔══════════════════════════════════════════════════════════════════════════╗");
pl("║ Name Reason For Deletion ║");
pl("╚══════════════════════════════════════════════════════════════════════════╝");
printfile("DELETED.MSG");
break;
case 'A':
nl();
sprintf(s1,"%sDELETED.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);
farfree(ss);
close(f);
}
nl();
pl("Enter reason for deletion :");
outstr(":");
mpl(47);
inputl(reason,47);
nl();
sprintf(s,"* %-20s %-47s *\r\n",nam(u,un), reason);
nl();
nl();
pl(s);
nl();
prt(5,"Is this correct? ");
if (yn()) {
sprintf(s1,"%sDELETED.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 deletion list.");
}
break;
}
} while ((!done) && (!hangup));
}
void deluser(int un)
{
userrec u;
int i,i1,f,n;
mailrec m;
char fn[81];
votingrec v;
voting_response vr;
read_user(un,&u);
if ((u.inact & inact_deleted)==0) {
rsm(un,&u);
dsr(u.name);
u.inact |= inact_deleted;
u.waiting=0;
write_user(un,&u);
sprintf(fn,"%sEMAIL.DAT",syscfg.datadir);
f=open(fn,O_RDWR | O_BINARY, S_IREAD | S_IWRITE);
if (f>0) {
i1=filelength(f)/sizeof(mailrec);
for (i=0; i<i1; i++) {
lseek(f,((long) i) * sizeof(mailrec), SEEK_SET);
read(f,(void *)(&m),sizeof(mailrec));
if (((m.tosys==0) && (m.touser==un)) ||
((m.fromsys==0) && (m.fromuser==un))) {
delmail(f,i);
}
}
}
close(f);
sprintf(fn,"%sVOTING.DAT",syscfg.datadir);
f=open(fn,O_RDWR | O_BINARY, S_IREAD | S_IWRITE);
n=(int) (filelength(f) / sizeof(votingrec)) -1;
for (i=0; i<20; i++)
if (u.votes[i]) {
if (i<=n) {
lseek(f,((long) i) * sizeof(votingrec), SEEK_SET);
read(f,(void *)&v,sizeof(votingrec));
vr=v.responses[u.votes[i]-1];
vr.numresponses--;
v.responses[u.votes[i]-1]=vr;
lseek(f,((long) i) * sizeof(votingrec), SEEK_SET);
write(f,(void *)&v,sizeof(votingrec));
}
u.votes[i]=0;
}
write_user(un,&u);
close(f);
}
}
void print_data(int un, userrec *u, int lng)
{
char s[81],s1[81],s2[81],s3[81],s4[81];
int i;
outchr(12);
if ((u->inact) & inact_deleted) {
pl(">>> DELETED <<<");
nl(); }
npr("1[7A1] fName1: f%-30s 1[7B1] fRN 1: f%s %s\r\n",nam(u,un),(u->realname),u->lastname);
npr("1[7C1] fAdd 1: f%-30s 1[7D1] fCity1: f%s\r\n",u->stretadd,u->citstate);
npr("1[7E1] fZip 1: f%-30ld 1[7F1] fPH 1: f%s\r\n",u->wwiv_regnum,(u->phone));
npr("1[7G1] fAge 1: f%d %c 1(7%02d1/7%02d1/7%02d1)\r\n", u->age, u->sex,u->month, u->day, u->year);
nl();
if (u->forwardsys)
npr("f[eHf] eCompf: e%-30s f[ ] eForwf: #e%d f@e%d\r\n",&(ctypes[u->comp_type][0]),u->forwardusr, u->forwardsys);
else
npr("f[eHf] eCompf: e%-30s f[ ] eForwf: #e%d\r\n",&(ctypes[u->comp_type][0]),u->forwardusr);
if (thisuser.sl==255)
npr("f[eIf] ePW f: e%-30s f[eJf] eLastf: e%s %s\r\n",u->pw,(u->laston),(u->firston));
else
npr("f[eIf] ePW f: e■■■■■■■■■ f[eJf] eLastf: e%s %s\r\n",(u->laston),(u->firston));
if (u->emailnet)
npr("f[eKf] eMsgsf: ePostedf=e%d Ef-emailf=e%d Feedbackf=e%d Waitingf=e%d Net Mailf=e%d\r\n",u->msgpost, u->emailsent,u->feedbacksent, u->waiting, u->emailnet);
else
npr("f[eKf] eMsgsf: ePostedf=e%d Ef-emailf=e%d Feedbackf=e%d Waitingf=e%d\r\n",u->msgpost, u->emailsent,u->feedbacksent, u->waiting);
npr("f[eLf] eLog f: eTotal Logonsf:e%d On Todayf:e%d Illegal Logonsf:e%d\r\n",u->logons,(strcmp(u->laston,date()))?0:u->ontoday,u->illegal);
npr("f[eMf] eUpDnf: eFiles Uploadedf=e%df-e%ldk Files Downloadedf=e%df-e%ldk\r\n",u->uploaded,u->uk,u->downloaded, u->dk);
npr("f[eNf] eBaudf: e%u\r\n", u->lastrate);
nl();
npr("2[cO2] cAss 2: c%-30d 2[cP2] cGold 2: c%d\r\n",u->ass_pts,(int) u->gold);
npr("2[cR2] cSL 2: c%-30d 2[cS2] cDSL 2: c%d\r\n",u->sl,u->dsl);
npr("2[cT2] cSub 2: c%-30d 2[cU2] cExemption 2: c%d\r\n",u->sysopsub,u->exempt);
npr("2[cV2] cUser's Tag2: c%s\r\n",(u->note));
strcpy(s3,restrict_string);
for (i=0; i<=15; i++) {
if (u->ar & (1 << i))
s[i]='A'+i;
else
s[i]=32;
if (u->dar & (1 << i))
s1[i]='A'+i;
else
s1[i]=32;
if (u->restrict & (1 << i))
s2[i]=s3[i];
else
s2[i]=32; }
s[16]=0;
s1[16]=0;
s2[16]=0;
npr("2[cW2] cAR 2: c%-30s",s);
npr(" 2[cX2] cDAR 2: c%s\r\n",s1);
npr("2[cY2] cRest2: c%-13s",s2);
npr(" 2[cZ2] cVoiced2: c%-4s 2[ ] cSP2: c%s\r\n", u->zipcode, u->sex_type);
nl();
if (lng) {
pl("5[7,5]7>5Up7/5Down 1 User {7,5}7>5Search Up7/5Down .7>5Toggle Menu /7>5Search Specs");
pl(" 5:7>5Clear B7-5Date 17>5Delete User 27>5Restore 37>5Go To User");
}
}
#ifdef OLD_SEARCH
int matchuser(int un)
{
userrec u;
int ok;
long l;
unsigned int d;
read_user(un,&u);
ok=1;
if ((u.age>agemax) || (u.age<agemin))
ok=0;
if ((u.sl>slmax) || (u.sl<slmin))
ok=0;
if ((u.dsl>dslmax) || (u.dsl<dslmin))
ok=0;
if (ressex)
if (u.sex!=ressex)
ok=0;
if (arres)
if ((u.ar & arres)==0)
ok=0;
if (darres)
if ((u.dar & darres)==0)
ok=0;
time(&l);
d=(unsigned int)( (l-u.daten)/24.0/3600.0 );
if ((d>daysmax) || (d<daysmin))
ok=0;
return(ok);
}
void changeopt()
{
int done,i,i1;
char s[81],s1[81],s2[81],s3[81],ch;
done=0;
do {
outchr(12);
npr("1. SL : %d to %d\r\n",slmin, slmax);
npr("2. DSL : %d to %d\r\n",dslmin, dslmax);
npr("3. AGE : %d to %d\r\n",agemin, agemax);
npr("4. Last On: %d to %d days ago\r\n",daysmin, daysmax);
if (ressex) {
npr("5. Sex : %c\r\n",ressex);
} else
pl("5. Sex : Inactive");
s[0]=0;
s[1]=0;
s1[0]=0;
s1[1]=0;
for (i=0; i<16; i++) {
if ((1 << i) & arres)
s[0]='A'+i;
if ((1 << i) & darres)
s1[0]='A'+i;
}
if (s[0])
npr("6. AR : %s\r\n",s);
else
pl("6. AR : Inactive");
if (s1[0])
npr("7. DAR : %s\r\n",s1);
else
pl("7. DAR : Inactive");
nl();
prt(2,"Search Options (1-7,Q) : ");
ch=onek("Q1234567");
nl();
switch(ch) {
case 'Q':
done=1;
break;
case '1':
prt(2,"Min SL? ");
input(s,3);
if (s[0])
slmin=atoi(s);
prt(2,"Max SL? ");
input(s,3);
if (s[0])
slmax=atoi(s);
break;
case '2':
prt(2,"Min DSL? ");
input(s,3);
if (s[0])
dslmin=atoi(s);
prt(2,"Max DSL? ");
input(s,3);
if (s[0])
dslmax=atoi(s);
break;
case '3':
prt(2,"Min age? ");
input(s,3);
if (s[0])
agemin=atoi(s);
prt(2,"Max age? ");
input(s,3);
if (s[0])
agemax=atoi(s);
break;
case '4':
prt(2,"Min days since logon? ");
input(s,4);
if (s[0])
daysmin=atoi(s);
prt(2,"Max days since logon? ");
input(s,4);
if (s[0])
daysmax=atoi(s);
break;
case '5':
prt(2,"Sex restrict (spc=none) ? ");
ressex=onek(" MF");
if (ressex==32)
ressex=0;
break;
case '6':
prt(2,"AR restrict (spc=none) ? ");
s[0]=onek("ABCDEFGHIJKLMNOP ");
if (s[0])
arres=1 << (s[0]-'A');
else
arres=0;
break;
case '7':
prt(2,"DAR restrict (spc=none) ? ");
s[0]=onek("ABCDEFGHIJKLMNOP ");
if (s[0])
darres=1 << (s[0]-'A');
else
darres=0;
break;
}
} while ((!done) && (!hangup));
}
#else
/****************************************************************************/
int matchuser(int un)
{
userrec u;
read_user(un,&u);
sp=search_pattern;
return(match_user(&u));
}
int match_user(userrec *u)
{
int ok=1,not=0,done=0,less=0,cpf=0,cpp=0,and=1,gotfcn=0,evalit=0,tmp,tmp1,tmp2;
char fcn[12],parm[12];
long l;
do {
if (*sp==0)
done=1;
else {
if (strchr("()|&!<>",*sp)) {
switch(*sp++) {
case '(':
evalit=2;
break;
case ')':
done=1;
break;
case '|':
and=0;
break;
case '&':
and=1;
break;
case '!':
not=1;
break;
case '<':
less=1;
break;
case '>':
less=0;
break;
}
} else if (*sp=='[') {
gotfcn=1;
sp++;
} else if (*sp==']') {
evalit=1;
++sp;
} else if (*sp!=' ') {
if (gotfcn) {
if (cpp<10)
parm[cpp++]=*sp++;
} else {
if (cpf<10)
fcn[cpf++]=*sp++;
}
} else
++sp;
if (evalit) {
if (evalit==1) {
fcn[cpf]=0;
parm[cpp]=0;
tmp=1;
tmp1=atoi(parm);
if (!strcmp(fcn,"SL")) {
if (less)
tmp=(tmp1>u->sl);
else
tmp=(tmp1<u->sl);
} else if (!strcmp(fcn,"DSL")) {
if (less)
tmp=(tmp1>u->dsl);
else
tmp=(tmp1<u->dsl);
} else if (!strcmp(fcn,"AR")) {
if ((parm[0]>='A') && (parm[0]<='P')) {
tmp1=1 << (parm[0]-'A');
if (u->ar & tmp1)
tmp=1;
else
tmp=0;
} else
tmp=0;
} else if (!strcmp(fcn,"DAR")) {
if ((parm[0]>='A') && (parm[0]<='P')) {
tmp1=1 << (parm[0]-'A');
if (u->dar & tmp1)
tmp=1;
else
tmp=0;
} else
tmp=0;
} else if (!strcmp(fcn,"SEX")) {
tmp=parm[0]==u->sex;
} else if (!strcmp(fcn,"AGE")) {
if (less)
tmp=(tmp1>u->age);
else
tmp=(tmp1<u->age);
} else if (!strcmp(fcn,"LASTON")) {
time(&l);
tmp2=(unsigned int)( (l-u->daten)/24.0/3600.0 );
if (less)
tmp=tmp2<tmp1;
else
tmp=tmp2>tmp1;
} else if (!strcmp(fcn,"AREACODE")) {
tmp=(!strncmp(parm,u->phone,3));
} else if (!strcmp(fcn,"RESTRICT")) {
;
} else if (!strcmp(fcn,"LOGONS")) {
if (less)
tmp=thisuser.logons<tmp1;
else
tmp=thisuser.logons>tmp1;
}
} else
tmp=match_user(u);
if (not)
tmp=!tmp;
if (and)
ok = ok && tmp;
else
ok = ok || tmp;
not=less=cpf=cpp=gotfcn=evalit=0;
and=1;
}
}
} while (!done);
return(ok);
}
/****************************************************************************/
void changeopt()
{
helpl=42;
outchr(12);
pl("Current search string:");
if (search_pattern[0])
pl(search_pattern);
else
pl("-NONE-");
nl();
nl();
prt(5,"Change it? ");
if (yn()) {
pl("Enter new search pattern:");
prt(2,":");
input(search_pattern,75);
}
helpl=0;
}
/****************************************************************************/
#endif
#pragma warn -par
void uedit(int usern, int other)
{
char s[81],s1[81],s2[81],ch,ch1;
int i,i1,i2,i3,l,un,done,nu,done1,full,temp_full,tempu;
userrec u;
nl();
prt(2,"PW: ");
echo=0;
input(s,20);
echo=1;
if (strcmp(s,("REGARD"))==0) {
if (incom)
full=0;
else
full=1;
un=usern;
done=0;
read_user(un,&u);
nu=number_userrecs();
do {
read_user(un,&u);
done1=0;
temp_full=0;
do {
print_data(un,&u, ((full) || (temp_full)));
nl();
prt(2,"Uedit : ");
if ((thisuser.sl==255) || (wfc))
ch=onek("[]{}/,.:123ABCDEFGHIJKLMNOPQRSTUVWXYZ");
else
ch=onek("[]{}/,.:123ABCDEFGHIJKLMNOPQRSTUVWXYZ");
switch(ch) {
case ']':
++un;
if (un>nu)
un=1;
done1=1;
break;
case '[':
--un;
if (un==0)
un=nu;
done1=1;
break;
case '}':
tempu=un;
++un;
if (un>nu)
un=1;
while ((un!=tempu) && (!matchuser(un))) {
++un;
if (un>nu)
un=1;
}
done1=1;
break;
case '{':
tempu=un;
--un;
if (un<1)
un=nu;
while ((un!=tempu) && (!matchuser(un))) {
--un;
if (un<1)
un=nu;
}
done1=1;
break;
case '/':
changeopt();
break;
case ',':
temp_full=(!temp_full);
break;
case '.':
full=(!full);
temp_full=full;
break;
case ':':
u.year=0;
write_user(un,&u);
break;
case '1':
if (((u.inact & inact_deleted)==0) && (actsl>u.sl)) {
prt(5,"Delete? ");
if (yn()) {
prt(5,"Would you like to add this user to the list? ");
if (yn())
dellist(un,&u);
deluser(un);
read_user(un,&u);
}
}
break;
case '2':
if (u.inact & inact_deleted) {
u.inact ^= inact_deleted;
isr(un,u.name);
write_user(un,&u);
}
break;
case '3':
nl();
prt(2,"User name/number: ");
input(s,30);
i=finduser1(s);
if (i>0) {
un=i;
done1=1;
}
break;
case 'A':
nl();
strcpy(s1,u.name);
prt(2,"New Alias? ");
input(s,30);
if (s[0]) {
if (finduser(s)<1) {
dsr(u.name);
strcpy(u.name,s);
isr(un,u.name);
write_user(un,&u);
sprintf(s2,"Changed %s's alias to %s",s1,u.name);
sysoplog(s2);
}
}
break;
case 'B':
nl();
prt(2,"New first name? ");
inputf(s,20);
if (s[0]) {
strcpy(u.realname,s);
write_user(un,&u);
}
nl();
prt(2,"New last name?");
inputf(s,20);
if (s[0]) {
strcpy(u.lastname,s);
write_user(un,&u);
}
break;
case 'C':
nl();
prt(2,"New address? ");
inputf(s,37);
if (s[0]) {
strcpy(u.stretadd,s);
write_user(un,&u);
}
break;
case 'D':
nl();
prt(2,"New city? ");
inputf(s,20);
if (s[0]) {
strcpy(u.citstate,s);
write_user(un,&u);
}
break;
case 'E':
nl();
prt(1,"New zipcode? ");
inputf(s,5);
l=atol(s);
if ((s[0]) && (l>=0))
u.wwiv_regnum = l;
write_user(un,&u);
break;
case 'F':
nl();
prt(2,"New phone number? ");
input(s,12);
if (s[0]) {
strcpy(u.phone,s);
write_user(un,&u);
}
break;
case 'G':
nl();
outstr("Gender (M,F) :");
u.sex=onek("MF");
sprintf(s,"Current birthdate: %02d/%02d/%02d",(int) u.month,
(int) u.day,
(int) u.year);
pl(s);
input_age(&u);
write_user(un,&u);
break;
case 'H':
nl();
pl("Known computer types:");
nl();
for (i=0; ctypes[i]; i++)
npr("%d. %s\r\n",i+1,ctypes[i]);
nl();
prt(2,"Enter new computer type: ");
input(s,2);
i1=atoi(s);
if ((i1>0) && (i1<=i)) {
u.comp_type=i1-1;
if (checkcomp("Ami"))
u.colors[0]=4;
else
u.colors[0]=7;
write_user(un,&u);
}
break;
case 'I':
nl();
prt(5,"Change password? ");
if (yn()) {
nl();
prt(1,"Enter new password :");
input(s,8);
strcpy(u.pw,s);
write_user(un,&u);
}
break;
case 'K':
nl();
prt(1,"Enter Messages Posted :");
input(s,4);
i=atoi(s);
u.msgpost=i;
write_user(un,&u);
break;
case 'L':
nl();
prt(1,"Enter new total logons :");
input(s,4);
i=atoi(s);
u.logons=i;
write_user(un,&u);
break;
case 'M':
nl();
prt(1,"Change Uploads? ");
if (yn()) {
prt(1,"Change Number of Files? ");
if (yn()) {
prt(1, "Enter new number of files : ");
input(s,4);
i=atoi(s);
u.uploaded=i;
write_user(un,&u);
}
npr("Change Amount of k? ");
if(yn()) {
prt(1, "Enter new k : ");
input(s,6);
i=atoi(s);
u.uk=i;
write_user(un,&u);
}
}
npr("Change Downloads? ");
if(yn()) {
npr("Change Number of Files? ");
if(yn()) {
prt(1, "Enter new number of files : ");
input(s,4);
i=atoi(s);
u.downloaded=i;
write_user(un,&u);
}
npr("Change Amount of k? ");
if(yn()) {
prt(1, "Enter new k : ");
input(s,6);
i=atoi(s);
u.dk=i;
write_user(un,&u);
}
}
break;
case 'N':
nl();
prt(1,"Enter New Baud Rate :");
input(s,4);
i=atoi(s);
u.lastrate=i;
write_user(un,&u);
break;
case 'O':
nl();
prt(1,"Enter new ass points :");
input(s,3);
i=atoi(s);
u.ass_pts=i;
write_user(un,&u);
break;
case 'P':
nl();
npr("1Amount of gold in account2?\r\n5[7Current1=2%d5]\r\n", (int) u.gold);
mpl(5);
input(s,5);
i=atoi(s);
if (s[0]) {
u.gold=i;
write_user(un,&u);
}
break;
case 'Q':
done=1;
done1=1;
break;
case 'R':
if (u.sl==255)
break;
if (u.sl>=actsl)
break;
nl();
prt(2,"New SL? ");
input(s,3);
i=atoi(s);
if ((!wfc) && (i>=actsl))
i=-1;
if ((i>=0) && (i<255) && (s[0])) {
u.sl=i;
write_user(un,&u);
if (un==usernum)
actsl=i;
}
break;
case 'S':
if (u.dsl==255)
break;
if (u.dsl>=thisuser.dsl)
break;
nl();
prt(2,"New DSL? ");
input(s,3);
i=atoi(s);
if ((!wfc) && (i>=thisuser.dsl))
i=-1;
if ((i>=0) && (i<255) && (s[0])) {
u.dsl=i;
write_user(un,&u);
}
break;
case 'T':
nl();
prt(2,"New sysop sub? ");
input(s,3);
i=atoi(s);
if ((i>=0) && (i<=255) && (s[0])) {
u.sysopsub=i;
write_user(un,&u);
}
break;
case 'U':
nl();
prt(2,"New Exemption? ");
input(s,3);
i=atoi(s);
if ((i>=0) && (i<=255) && (s[0])) {
u.exempt=i;
write_user(un,&u);
}
break;
case 'V':
nl();
prt(1,"New Tag? ");
inputl(s,39);
strcpy(u.note,s);
write_user(un,&u);
break;
case 'W':
nl();
prt(2,"Toggle which AR? ");
ch1=onek("\rABCDEFGHIJKLMNOP");
if (ch1!=13) {
ch1-='A';
if ((wfc) || (thisuser.ar & (1 << ch1))) {
u.ar ^= (1 << ch1);
write_user(un,&u);
}
}
break;
case 'X':
nl();
prt(2,"Toggle which DAR? ");
ch1=onek("\rABCDEFGHIJKLMNOP");
if (ch1!=13) {
ch1-='A';
if ((wfc) || (thisuser.dar & (1 << ch1))) {
u.dar ^= (1 << ch1);
write_user(un,&u);
}
}
break;
case 'Y':
nl();
npr(" %s\r\n",restrict_string);
do {
prt(2,"Toggle? ");
s[0]=13;
s[1]='?';
strcpy(&(s[2]),restrict_string);
ch1=onek(s);
if (ch1==32)
ch1=13;
if (ch1=='?')
printmenu(10);
if ((ch1!=13) && (ch1!='?')) {
i=-1;
for (i1=0; i1<16; i1++)
if (ch1==s[i1+2])
i=i1;
if (i>-1) {
u.restrict ^= (1 << i);
write_user(un,&u);
}
}
} while ((!hangup) && (ch1=='?'));
break;
case 'Z':
nl();
prt(2,"Has the user been voiced? ");
input(s,6);
if (s[0]) {
strcpy(u.zipcode,s);
write_user(un,&u);
} else {
prt(5,"Delete answer? ");
if (yn()) {
u.zipcode[0]=0;
write_user(un,&u);
}
}
break;
}
} while ((!done1) && (!hangup));
} while ((!done) && (!hangup));
close_user();
if (!wfc)
topscreen();
}
}
#pragma warn +par