home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
WWIV2.ZIP
/
SYSOPF.C
< prev
next >
Wrap
Text File
|
1995-12-16
|
14KB
|
620 lines
#include "vars.h"
#pragma hdrstop
void isr1(int un, char *name)
{
int cp,i;
char s[81];
smalrec sr;
cp=0;
while ((cp<status.users) && (strcmp(name,(smallist[cp].name))>0))
++cp;
memmove(&(smallist[cp+1]),&(smallist[cp]),sizeof(smalrec)*(status.users-cp));
strcpy(sr.name,name);
sr.number=un;
smallist[cp]=sr;
++status.users;
}
void reset_files(void)
{
int i,i1;
userrec u;
char s[81];
status.users=0;
read_user(1,&u);
i1=number_userrecs();
for (i=1; i<=i1; i++) {
read_user(i,&u);
if ((u.inact & inact_deleted)==0)
isr1(i,u.name);
if ((i % 10)==0) {
npr("%d\r",i);
}
}
outstr("\r\n\r\n");
sprintf(s,"%sNAMES.LST",syscfg.datadir);
i=open(s,O_RDWR | O_BINARY | O_TRUNC);
if (i<0) {
printf("%s NOT FOUND.\n",s);
exit(noklevel);
}
write(i,(void *) (smallist), (sizeof(smalrec) * status.users));
close(i);
save_status();
close_user();
}
void get_status(void)
{
char s[81];
int statusfile;
sprintf(s,"%sSTATUS.DAT",syscfg.datadir);
statusfile=open(s,O_RDWR | O_BINARY);
if (statusfile>=0) {
read(statusfile,(void *)(&status), sizeof(statusrec));
close(statusfile);
} else
save_status();
}
void prstatus(void)
{
int i;
long l;
outchr(12);
outstr(get_string(298)); pl(syscfg.newuserpw);
outstr(get_string(299)); pl(syscfg.closedsystem?get_string(300):get_string(301));
outstr(get_string(302)); pln(status.users);
outstr(get_string(303)); npr("%ld\r\n",status.callernum1);
outstr(get_string(304)); pl(status.date1);
outstr(get_string(305)); pl(times());
outstr(get_string(306)); pln(status.activetoday);
outstr(get_string(307)); pln(status.callstoday);
outstr(get_string(308)); pln(status.msgposttoday);
outstr(get_string(309)); pln(status.emailtoday);
outstr(get_string(310)); pln(status.fbacktoday);
outstr(get_string(311)); pln(status.uptoday);
outstr(get_string(312)); pln(fwaiting);
i=3;
l=(long) freek(3);
while ((l>0) && ((i+'@')<=cdir[0])) {
npr("%c",i+'@');
outstr(get_string(313));
npr("%ldk\r\n",l);
i++;
if ((i+'@')<=cdir[0])
l=(long) freek(i);
}
outstr(get_string(314));
if (!sysop2())
outstr(get_string(112));
pl(get_string(315));
}
void valuser(int un)
{
userrec u;
char s[81],s1[81],s2[81],s3[81],ar1[20],dar1[20],ch1;
int i,i1,ar2,dar2;
read_user(un,&u);
if ((u.inact & inact_deleted)==0) {
nl();
npr("1Name : %s\r\n",nam(&u,un));
npr("1RN : %s\r\n",u.realname);
npr("Change it? ");
if(yn()) {
prt(0,"New name: ");
inputl(s,sizeof(u.realname)-1);
if (s[0]) {
strcpy(u.realname,s);
write_user(un,&u);
}
}
npr("1Address : %s\r\n",u.street);
npr("Change it? ");
if(yn()) {
prt(0,"New address: ");
inputl(s1,sizeof(u.street)-1);
if (s1[0]) {
strcpy(u.street,s1);
write_user(un,&u);
}
}
npr("1City: %s\r\n",u.city);
npr("Change it? ");
if(yn()) {
prt(0,"New city: ");
inputl(s1,sizeof(u.city)-1);
if (s1[0]) {
strcpy(u.city,s1);
write_user(un,&u);
}
}
npr("1Zip : %s\r\n",u.zipcode);
npr("Change it? ");
if (yn()) {
prt(0,"New zip: ");
input(s1,sizeof(u.zipcode)-1);
if (s1[0]) {
strcpy(u.zipcode,s1);
write_user(un,&u);
}
}
npr("1Phone: %s\r\n",u.phone);
npr("1Age : %d %c (%02d/%02d/%02d)\r\n", u.age, u.sex,u.month, u.day, u.year);
npr("Reset age? ");
if(yn()) {
npr("Enter in current birthdate for comparison: ");
inputl(s,sizeof(u.note)-1);
strcpy(u.note,s);
write_user(un,&u);
u.year=0;
}
npr("1Computer: %s\r\n",ctypes[u.comp_type]);
if (u.note[0]) {
npr("1Note: %s\r\n",u.note);
}
npr("1SL: %d\r\n",u.sl);
if ((u.sl!=255) && (u.sl<actsl)) {
outstr(get_string(316));
input(s,3);
if (s[0]) {
i=atoi(s);
if ((!wfc) && (i>=actsl))
i=-2;
if ((i>=0) && (i<255))
u.sl=i;
if (i==-1) {
nl();
prt(5,get_string(267));
if (yn()) {
deluser(un);
nl();
pl(get_string(56));
nl();
} else {
nl();
pl(get_string(317));
}
return;
}
}
}
npr("1DSL: %d\r\n",u.dsl);
if ((u.dsl!=255) && (u.dsl<thisuser.dsl)) {
outstr(get_string(316));
input(s,3);
if (s[0]) {
i=atoi(s);
if ((!wfc) && (i>=thisuser.dsl))
i=-1;
if ((i>=0) && (i<255))
u.dsl=i;
}
}
strcpy(s3,restrict_string);
ar2=1;
dar2=1;
ar1[0]=13;
dar1[0]=13;
for (i=0; i<=15; i++) {
if (u.ar & (1 << i))
s[i]='A'+i;
else
s[i]=32;
if (thisuser.ar & (1 << i))
ar1[ar2++]='A'+i;
if (u.dar & (1 << i))
s1[i]='A'+i;
else
s1[i]=32;
if (thisuser.dar & (1 << i))
dar1[dar2++]='A'+i;
if (u.restrict & (1 << i))
s2[i]=s3[i];
else
s2[i]=32;
}
s[16]=0;
s1[16]=0;
s2[16]=0;
ar1[ar2]=0;
dar1[dar2]=0;
nl();
ch1=0;
if (ar2>1)
pl("Note: Males get 'A' Ar, females get 'F' Ar.");
do {
npr("1AR: %s\r\n",s);
prt(0,get_string(319));
ch1=onek(ar1);
if (ch1!=13) {
ch1-='A';
if (s[ch1]==32)
s[ch1]=ch1+'A';
else
s[ch1]=32;
u.ar ^= (1 << ch1);
ch1=0;
}
} while ((!hangup) && (ch1!=13));
nl();
ch1=0;
if (dar2>1)
do {
npr("1DAR: %s\r\n",s1);
prt(0,get_string(319));
ch1=onek(dar1);
if (ch1!=13) {
ch1-='A';
if (s1[ch1]==32)
s1[ch1]=ch1+'A';
else
s1[ch1]=32;
u.dar ^= (1 << ch1);
ch1=0;
}
} while ((!hangup) && (ch1!=13));
nl();
npr("Has this user been voice validated? ");
if(yn()) {
strcpy(u.voiced,"YES");
} else {
strcpy(u.voiced,"NO");
}
nl();
ch1=0;
s[0]=13;
s[1]='?';
strcpy(&(s[2]),restrict_string);
do {
npr(" %s\r\n",s3);
npr("1Restr: %s\r\n",s2);
prt(0,get_string(319));
ch1=onek(s);
if ((ch1!=13) && (ch1!=32) && (ch1!='?')) {
i=-1;
for (i1=0; i1<16; i1++)
if (ch1==s[i1+2])
i=i1;
if (i>-1) {
u.restrict ^= (1 << i);
if (s2[i]==32)
s2[i]=s3[i];
else
s2[i]=32;
}
ch1=0;
}
if (ch1=='?') {
ch1=0;
printmenu(10);
}
} while ((!hangup) && (ch1==0));
write_user(un,&u);
close_user();
nl();
} else {
nl();
pl(get_string(321));
nl();
}
}
void print_net_listing(unsigned int ss)
{
int i,i1,i2,abort,f;
char s[161],ch,onx[20],*mmk;
int onxi,odci;
net_system_list_rec csne;
if (net_num_max>1) {
odc[0]=0;
odci=0;
onx[0]='Q';
onx[1]=0;
onxi=1;
nl();
for (i=0; i<net_num_max; i++) {
if (i<9) {
onx[onxi++]=i+'1';
onx[onxi]=0;
} else {
odci=(i+1)/10;
odc[odci-1]=odci+'0';
odc[odci]=0;
}
npr("%d. %s\r\n",i+1,net_networks[i].name);
}
pl(get_string(12));
nl();
prt(2,get_string(13));
if (net_num_max<9) {
ch=onek(onx);
if (ch=='Q')
i=-1;
else
i=ch-'1';
} else {
mmk=mmkey(2);
if (*mmk=='Q')
i=-1;
else
i=atoi(mmk)-1;
}
if ((i>=0) && (i<net_num_max)) {
set_net_num(i);
} else
return;
}
read_bbs_list_index();
ss = ss%10000;
abort=0;
nl();
outstr(net_name);
pl(get_string(322));
nl();
pla(get_string(323),&abort);
pla(get_string(324),&abort);
sprintf(s,"%sBBSDATA.NET",net_data);
f=open(s,O_RDONLY | O_BINARY);
for (i=0; (i<num_sys_list) && (!abort); i++) {
read(f,&csne,sizeof(net_system_list_rec));
if ((csne.forsys!=65535) && ((csne.sysnum%10000)>=ss)) {
if (csne.other & other_net_coord)
ch='&';
else if (csne.other & other_group_coord)
ch='%';
else if (csne.other & other_coordinator)
ch='^';
else
ch=' ';
sprintf(s,"%5u%c %12s %-40s %3d %5d %3d",
csne.sysnum,ch,csne.phone,csne.name,csne.numhops,
csne.forsys, csne.group);
pla(s,&abort);
ss=0;
}
}
close(f);
}
void read_new_stuff(void)
{
int i;
char s[81];
zap_bbs_list();
for (i=0; i<net_num_max; i++) {
zap_call_out_list();
zap_contacts();
}
set_language(0);
}
void mailr(void)
{
int i,abort,a,f,next,tp,nn;
mailrec m;
char c,s[81];
userrec u;
sprintf(s,"%sEMAIL.DAT",syscfg.datadir);
f=open(s,O_BINARY | O_RDWR);
if (f!=-1) {
i=filelength(f)/sizeof(mailrec)-1;
c=' ';
while ((i>=0) && (c!='Q') && (!hangup)) {
lseek(f,((long) (i)) * ((long) sizeof(mailrec)),SEEK_SET);
read(f,(void *)&m,sizeof(mailrec));
if (m.touser!=0) {
do {
read_user(m.touser,&u);
outstr(get_string(325));
pl(nam(&u,m.touser));
tp=80;
if (m.status & status_source_verified)
tp -= 2;
if (m.status & status_new_net) {
tp -= 1;
if (strlen(m.title)<=tp) {
nn=m.title[tp+1];
} else
nn=0;
} else
nn=0;
set_net_num(nn);
outstr(get_string(326)); pl(m.title);
setorigin(m.fromsys, m.fromuser);
read_message1(&(m.msg),m.anony & 0x0f,1,&next,"EMAIL");
prt(2,get_string(327));
if (next)
c=' ';
else
c=onek("QRD ");
if (c=='D') {
delmail(f,i);
if ((!useron) && (m.touser==1) && (m.tosys==0))
--thisuser.waiting;
}
nl();
nl();
} while ((c=='R') && (!hangup));
}
i-=1;
}
close(f);
close_user();
}
}
void chuser(void)
{
char s[81];
int i;
if (!checkpw())
return;
if (!so())
return;
prt(2,get_string(328));
input(s,30);
i=finduser1(s);
if (i>0) {
write_user(usernum,&thisuser);
read_user(i,&thisuser);
usernum=i;
close_user();
actsl=255;
sprintf(s,get_stringx(1,17),nam(&thisuser,usernum));
sysoplog(s);
changedsl();
topscreen();
} else
pl(get_string(8));
}
void zlog(void)
{
zlogrec z;
char s[81];
int abort,f,i,i1;
sprintf(s,"%sZLOG.DAT",syscfg.datadir);
f=open(s,O_RDWR | O_BINARY);
if (f<0)
return;
i=0;
abort=0;
read(f,(void *)&z,sizeof(zlogrec));
pla(get_string(329),&abort);
pla(get_string(330),&abort);
while ((i<97) && (!abort) && (!hangup) && (z.date[0]!=0)) {
if (z.calls)
i1=z.active/z.calls;
else
i1=0;
sprintf(s,"%s %4d %4d %3d %3d %3d %3d %3d %3d",
z.date,z.calls,z.active,z.posts,z.email,z.fback,z.up,10*z.active/144,i1);
pla(s,&abort);
++i;
if (i<97) {
lseek(f,((long) i) * sizeof(zlogrec),SEEK_SET);
read(f,(void *)&z,sizeof(zlogrec));
}
}
close(f);
}
void beginday(void)
{
char s[255];
zlogrec z,z1;
int f,i,i1;
double fk;
int nus;
pl(get_string(331));
strcpy(z.date,status.date1);
z.active=status.activetoday;
z.calls=status.callstoday;
z.posts=status.msgposttoday;
z.email=status.emailtoday;
z.fback=status.fbacktoday;
z.up=status.uptoday;
status.callstoday=0;
status.msgposttoday=0;
status.emailtoday=0;
status.fbacktoday=0;
status.uptoday=0;
status.activetoday=0;
strcpy(status.date3,status.date2);
strcpy(status.date2,status.date1);
strcpy(status.date1,date());
strcpy(status.log2,status.log1);
sl1(3,status.log1);
sl1(2,date());
sprintf(s,"%s%s",syscfg.gfilesdir, status.log2);
unlink(s);
sprintf(s,"%sUSER.LOG",syscfg.gfilesdir);
unlink(s);
save_status();
sprintf(s,"%sZLOG.DAT",syscfg.datadir);
f=open(s,O_RDWR | O_BINARY);
if (f<0) {
f=open(s,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
z1.date[0]=0;
z1.active=0;
z1.calls=0;
z1.posts=0;
z1.email=0;
z1.fback=0;
z1.up=0;
for (i=0; i<97; i++)
write(f,(void *)&z1,sizeof(zlogrec));
} else {
for (i=96; i>=1; i--) {
lseek(f,(long) ((i-1) * sizeof(zlogrec)),SEEK_SET);
read(f,(void *)&z1,sizeof(zlogrec));
lseek(f,(long) (i * sizeof(zlogrec)),SEEK_SET);
write(f,(void *)&z1,sizeof(zlogrec));
}
}
lseek(f,0L,SEEK_SET);
write(f,(void *)&z,sizeof(zlogrec));
close(f);
if (syscfg.beginday_c[0]) {
stuff_in(s,syscfg.beginday_c,create_chain_file("CHAIN.TXT"),"","","","");
do_remote(s,1);
}
fk=freek1(syscfg.datadir);
nus=syscfg.maxusers-status.users;
if (fk<512.0) {
sprintf(s,get_stringx(1,18),(int) fk);
ssm(1,0,s);
}
if ((!syscfg.closedsystem) && (nus<15)){
sprintf(s,get_stringx(1,19),nus);
ssm(1,0,s);
}
}