home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
WWIV2.ZIP
/
UEDIT.C
< prev
next >
Wrap
Text File
|
1995-12-10
|
21KB
|
931 lines
#include "vars.h"
#pragma hdrstop
static unsigned long *u_qsc;
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, int cls)
{
char s[81],s1[81],s2[81],s3[81],s4[81];
int i;
if (cls)
outchr(12);
if ((u->inact) & inact_deleted) {
pl(">>> DELETED <<<");
nl(); }
npr("[A] Name: %-30s ",nam(u,un));
npr("[B] RN : %s\r\n",(u->realname));
npr("[C] Add : %-30s ",u->street);
npr("[D] City: %s,%s\r\n",u->city,u->state);
npr("[E] Zip : %-30s ",u->zipcode);
npr("[F] PH : %s\r\n",(u->phone));
npr("[G] Age : %d %c (%02d/%02d/%02d)", u->age, u->sex,u->month, u->day, u->year);
npr(" [H] Comp: %s\r\n",&(ctypes[u->comp_type][0]));
if (u->forwardsys)
npr("[-] Forw: #%d @%-25d",u->forwardusr, u->forwardsys);
else
npr("[-] Forw: #%-30d",u->forwardusr);
if (thisuser.sl==255)
npr("[I] PW : %s\r\n",u->pw);
else
npr("[I] PW : ■■■■■■■■■\r\n");
npr("[J] Last: %s %s",(u->laston),(u->firston));
npr(" [ ] Work #: %s\r\n",(u->dataphone));
if (u->emailnet)
npr("[K] Msgs: Posts=%d Mail=%d Feedback=%d Waiting=%d Net Mail=%d\r\n",u->msgpost, u->emailsent,u->feedbacksent, u->waiting, u->emailnet);
else
npr("[K] Msgs: Posts=%d Mail=%d Feedback=%d Waiting=%d\r\n",u->msgpost, u->emailsent,u->feedbacksent, u->waiting);
npr("[L] Log : Logons:%d Today:%d Illegal:%d\r\n",u->logons,(strcmp(u->laston,date()))?0:u->ontoday,u->illegal);
npr("[M] UpDn: Up=%d-%ldk Down=%d-%ldk\r\n",u->uploaded,u->uk,u->downloaded, u->dk);
npr("[N] Baud: %-30u ", u->lastrate);
npr("[O] Ass : %d\r\n",u->ass_pts);
npr("[R] SL : %-30d ",u->sl);
npr("[P] Gold: %d\r\n",(int) u->gold);
npr("[S] DSL : %-30d ",u->dsl);
npr("[-] Rank: %s\r\n",u->rank);
npr("[T] Sub : %-30d [U] Exemption :",*u_qsc);
pln(u->exempt);
if (lng) {
npr("[V] User's Tag: %s\r\n",(u->ptag));
npr("[5] Note1: %s\r\n",u->note);
npr("[6] Note2: %s\r\n",u->note2);
npr("[7] Note3: %s\r\n",u->note3);
npr("[8] Ass Msg: %s\r\n",u->assmsg);
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("[W] AR : %-30s",s);
npr(" [X] DAR : %s\r\n",s1);
npr("[Y] Rest: %-30s ",s2);
npr("[Z] Voiced: %s\r\n",u->voiced);
npr("[-] SP: %-13s",u->sex_type);
npr("[-] IQ: %-12s",u->iq);
npr("[9] LM: %s\r\n",u->logyeah);
}
}
/****************************************************************************/
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],ts[40];
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=u->logons<tmp1;
else
tmp=u->logons>tmp1;
} else if (!strcmp(fcn,"REALNAME")) {
strcpy(ts,u->realname);
strupr(ts);
tmp=(strstr(ts,parm)!=NULL);
} else if (!strcmp(fcn,"BAUD")) {
if (less)
tmp=u->lastrate<(unsigned short)tmp1;
else
tmp=u->lastrate>(unsigned short)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(void)
{
helpl=42;
outchr(12);
pl(get_string(262));
if (search_pattern[0])
pl(search_pattern);
else
pl(get_string(263));
nl();
nl();
prt(5,get_string(264));
if (yn()) {
pl(get_string(265));
prt(2,":");
input(search_pattern,75);
}
helpl=0;
}
/****************************************************************************/
void uedit(int usern, int other)
{
char s[81],s1[81],s2[81],ch,ch1;
int i,i1,i2,i3,un,done,nu,done1,full,temp_full,tempu,cls=1,done2;
userrec u;
long l;
u_qsc=(unsigned long *)farmalloc(syscfg.qscn_len);
if (incom)
full=0;
else
full=1;
if (other&1)
full=0;
if (other&2)
cls=0;
un=usern;
done=0;
read_user(un,&u);
nu=number_userrecs();
do {
read_user(un,&u);
read_qscn(un,u_qsc,0);
done1=0;
temp_full=0;
do {
print_data(un,&u, ((full) || (temp_full)), cls);
nl();
prt(2,get_string(266));
if ((thisuser.sl==255) || (wfc))
ch=onek("[]{}/,.:123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ%?");
else
ch=onek("[]{}/,.:123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ%?");
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 ':':
do {
done2=0;
nl();
pl(get_string(288));
pl(get_string(289));
pl(get_string(290));
pl(get_string(291));
pl(get_string(292));
pl(get_string(293));
pl(get_string(294));
pl(get_string(295));
pl(get_string(296));
pl(get_string(12));
outstr(get_string(297));
ch1=onek("Q12345678");
switch(ch1) {
case '1': u.realname[0]=0; break;
case '2': u.year=0; break;
case '3': u.street[0]=0; break;
case '4': u.city[0]=0; break;
case '5': u.state[0]=0; break;
case '6': u.country[0]=0; break;
case '7': u.zipcode[0]=0; break;
case '8': u.dataphone[0]=0; break;
case 'Q': done2=1; break;
}
} while (!done2);
write_user(un,&u);
break;
case '1':
if (((u.inact & inact_deleted)==0) && (actsl>u.sl)) {
prt(5,get_string(267));
if (yn()) {
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,get_string(268));
input(s,sizeof(u.name)-1);
i=finduser1(s);
if (i>0) {
un=i;
done1=1;
}
break;
case 'A':
nl();
prt(2,get_string(69));
input(s,sizeof(u.name)-1);
if (s[0]) {
if (finduser(s)<1) {
dsr(u.name);
strcpy(u.name,s);
isr(un,u.name);
write_user(un,&u);
}
}
break;
case 'B':
nl();
prt(2,get_string(269));
inputl(s,sizeof(u.realname)-1);
if (s[0]) {
strcpy(u.realname,s);
write_user(un,&u);
}
break;
case 'C':
nl();
prt(2,get_string(282));
inputl(s1,sizeof(u.street)-1);
if (s1[0]) {
strcpy(u.street,s1);
write_user(un,&u);
}
break;
case 'D':
nl();
prt(2,get_string(283));
inputl(s1,sizeof(u.city)-1);
if (s1[0]) {
strcpy(u.city,s1);
write_user(un,&u);
}
break;
case 'E':
nl();
prt(2,get_string(286));
input(s1,sizeof(u.zipcode)-1);
if (s1[0]) {
strcpy(u.zipcode,s1);
write_user(un,&u);
}
break;
case 'F':
nl();
prt(2,get_string(272));
input(s,sizeof(u.phone)-1);
if (s[0]) {
strcpy(u.phone,s);
write_user(un,&u);
}
break;
case 'G':
nl();
outstr(get_string(274));
npr("%02d/%02d/%02d\r\n",(int) u.month, (int) u.day, (int) u.year);
input_age(&u);
write_user(un,&u);
prt(5,"Change Sex?");
if(yn()){
nl();
prt(3,"M or F (>");
u.sex=onek("MF");
write_user(un,&u);
}
break;
case 'H':
nl();
pl(get_string(275));
nl();
for (i=0; ctypes[i]; i++)
npr("%d. %s\r\n",i+1,ctypes[i]);
nl();
prt(2,get_string(276));
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 'J':
nl();
prt(5,"Reset laston date? ");
if (yn()) {
nl();
strcpy(xdate,date());
strcpy(u.laston,xdate);
i=1;
u.ontoday=i;
time(&l);
u.daten=l;
pl("3Date reset.");
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,get_string(76));
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,get_string(153));
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':
if (u_qsc) {
nl();
prt(2,get_string(278));
input(s,3);
i=atoi(s);
if ((i>=0) && (i<=999) && (s[0])) {
*u_qsc=i;
write_qscn(un,u_qsc,0);
}
}
break;
case 'U':
nl();
prt(2,get_string(277));
input(s,3);
i=atoi(s);
if ((i>=0) && (i<=255) && (s[0])) {
u.exempt=i;
write_user(un,&u);
}
break;
case '5':
nl();
prt(2,get_string(273));
inputl(s,sizeof(u.note)-1);
strcpy(u.note,s);
write_user(un,&u);
break;
case 'V':
nl();
prt(2,get_string(273));
inputl(s,sizeof(u.ptag)-1);
strcpy(u.ptag,s);
write_user(un,&u);
break;
case '6':
nl();
prt(2,get_string(273));
inputl(s,sizeof(u.note2)-1);
strcpy(u.note2,s);
write_user(un,&u);
break;
case '7':
nl();
prt(2,get_string(273));
inputl(s,sizeof(u.note3)-1);
strcpy(u.note3,s);
write_user(un,&u);
break;
case '8':
nl();
prt(2,get_string(273));
inputl(s,sizeof(u.assmsg)-1);
strcpy(u.assmsg,s);
write_user(un,&u);
break;
case '9':
nl();
prt(1,"New log yeah:");
input(s,1);
strcpy(u.logyeah,s);
write_user(un,&u);
break;
case 'W':
nl();
prt(2,get_string(280));
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,get_string(281));
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,get_string(279));
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.voiced,s);
write_user(un,&u);
}
break;
case '?':
printmenu(6);
getkey();
break;
case '4':
nl();
prt(2,get_string(270));
input(s,sizeof(u.callsign)-1);
if (s[0]) {
strcpy(u.callsign,s);
write_user(un,&u);
} else {
prt(5,get_string(271));
if (yn()) {
u.callsign[0]=0;
write_user(un,&u);
}
}
break;
case '%':
prt(2,get_string(284));
input(s1,sizeof(u.state)-1);
if (s1[0]) {
strcpy(u.state,s1);
write_user(un,&u);
}
prt(2,get_string(285));
input(s1,sizeof(u.country)-1);
if (s1[0]) {
strcpy(u.country,s1);
write_user(un,&u);
}
prt(2,get_string(287));
input(s1,sizeof(u.dataphone)-1);
if (s1[0]){
strcpy(u.dataphone,s1);
write_user(un,&u);
}
break;
}
} while ((!done1) && (!hangup));
} while ((!done) && (!hangup));
close_user();
if (u_qsc)
farfree(u_qsc);
u_qsc=NULL;
if (!wfc)
topscreen();
}