home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
UTIL
/
WWIVE
/
SYSOPF.C
< prev
next >
Wrap
Text File
|
1992-01-14
|
16KB
|
678 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 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()
{
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) {
itoa(i,s,10);
pl(s);
}
}
sprintf(s,"%sNAMES.LST",syscfg.datadir);
i=open(s,O_RDWR | O_BINARY | O_TRUNC);
if (i<0) {
printf("%s NOT FOUND.\n",s);
abort();
}
write(i,(void *) (smallist), (sizeof(smalrec) * status.users));
close(i);
save_status();
close_user();
}
void check_top()
{
FILE *tpusers;
int count,count2,count3,count4,number,true;
char topnames[5][10][30],title[55];
long topk[5][10],cur;
userrec u;
for(count=0;count<=4;count++)
{
for(count2=0;count2<=9;count2++)
{
strcpy(topnames[count][count2],"7>1NOBODY7<");
topk[count][count2]=0;
}
}
number=(int)(filelength(userfile)/sizeof(userrec))-1;
for(count=2;count<=number;count++)
{
read_user(count,&u);
if(!((u.inact) & inact_deleted))
{
for(count2=0;count2<=4;count2++)
{
switch(count2)
{
case 0:
cur=u.uk;
break;
case 1:
cur=u.dk;
break;
case 2:
cur=u.logons;
break;
case 3:
cur=u.msgpost;
break;
case 4:
if(u.dk!=0)
cur=((float) u.uk)/((float) u.dk);
if(cur>=100) cur=99.998;
break;
}
true=0;
for(count3=9;((count3>=0) && (true==0));count3--)
{
if(cur>topk[count2][count3])
{
for(count4=0;(count4<count3);count4++)
{
topk[count2][count4]=topk[count2][count4+1];
strcpy(topnames[count2][count4],topnames[count2][count4+1]);
}
topk[count2][count3]=cur;
if(strcmp(thisuser.name,u.name)==0)
{
strcpy(topnames[count2][count3],"\x1b[1;31m");
strcat(topnames[count2][count3],u.name);
strcat(topnames[count2][count3],"\x1b[1;36m");
}
else
strcpy(topnames[count2][count3],u.name);
true=1;
}
}
}
close_user();
}
}
tpusers=fopen("GFILES\\TEXT\\TOPUSERS.MSG","w"); /* <----*/
fprintf(tpusers,"2The Devil's Doorknob Top Ten User List.\n");/* Put your own name! */
fprintf(tpusers,"\n");
for(count=0;count<=4;count++)
{
switch(count) {
case 0:
strcpy(title,"3Most Upload k\n\n");
break;
case 1:
strcpy(title,"3Most Download k\n\n");
break;
case 2:
strcpy(title,"3Most Logons\n\n");
break;
case 3:
strcpy(title,"3Most Posts\n\n");
break;
case 4:
strcpy(title,"3Best U/D Ratio\n\n");
break;
}
fprintf(tpusers,title);
for(count2=9;count2>=0;count2--)
{
fprintf(tpusers,"1%s",topnames[count][count2]);
for(count3=0;count3<(50-strlen(topnames[count][count2]));count3++)
{
fprintf(tpusers,"7.");
}
if(strchr(topnames[count][count2],'[')!=NULL)
{
for(count4=0;count4<11;count4++)
fprintf(tpusers,"7.");
}
fprintf(tpusers,"3%d",topk[count][count2]);
fprintf(tpusers,"\n");
}
fprintf(tpusers,"\n");
}
fclose(tpusers);
}
void get_status()
{
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()
{
int i;
long l;
outchr(12);
npr("New User Pass : %s\r\n",syscfg.newuserpw);
npr("Board is : %s\r\n",syscfg.closedsystem?"Closed":"Open");
npr("Number Users : %d\r\n",status.users);
npr("Number Calls : %ld\r\n",status.callernum1);
npr("Last Date : %s\r\n",status.date1);
npr("Time : %s\r\n",times());
npr("Active Today : %d\r\n",status.activetoday);
npr("Calls Today : %d\r\n",status.callstoday);
npr("M Posted Today : %d\r\n",status.msgposttoday);
npr("E Sent Today : %d\r\n",status.emailtoday);
npr("F Sent Today : %d\r\n",status.fbacktoday);
npr("Uploads Today : %d\r\n",status.uptoday);
npr("Feedback Waiting: %d\r\n",fwaiting);
i=3;
l=(long) freek(3);
while ((l>0) && ((i+'@')<=cdir[0])) {
npr("%c: Free Space : %ldk\r\n",i+'@',l);
i++;
if ((i+'@')<=cdir[0])
l=(long) freek(i);
}
npr("Sysop : %s7Watching\r\n",sysop2()?"":"6NOT ");
}
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("Name: %s\r\n",nam(&u,un));
npr("RN : %s\r\n",(u.realname));
npr("PH : %s\r\n",(u.phone));
npr("Age : %d %c\r\n", u.age, u.sex);
npr("Comp: %s\r\n",&(ctypes[u.comp_type][0]));
if (u.note[0])
npr("Note: %s\r\n",u.note);
nl();
npr("SL : %d\r\n",u.sl);
if ((u.sl!=255) && (u.sl<actsl)) {
outstr("New ? ");
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,"Delete? ");
if (yn()) {
deluser(un);
nl();
pl("Deleted.");
nl();
} else {
nl();
pl("NOT deleted.");
}
return;
}
}
}
nl();
npr("DSL : %d\r\n",u.dsl);
if ((u.dsl!=255) && (u.dsl<thisuser.dsl)) {
outstr("New ? ");
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)
do {
npr("AR : %s\r\n",s);
prt(2,"Togl? ");
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("DAR : %s\r\n",s1);
prt(2,"Togl? ");
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();
ch1=0;
s[0]=13;
s[1]='?';
strcpy(&(s[2]),restrict_string);
do {
npr(" %s\r\n",s3);
npr("Rstr: %s\r\n",s2);
prt(2,"Togl? ");
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("No Such User.");
nl();
}
}
void print_net_listing(unsigned int ss)
{
int i,i1,i2,abort,f;
char s[161],ch;
net_system_list_rec csne;
ss = ss%10000;
abort=0;
nl();
pla(" 3Node Phone Name Hop Next Grp",&abort);
pla("7══════════════════════════════════════════════════════════════════════════",&abort);
sprintf(s,"%sBBSDATA.NET",syscfg.datadir);
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,"%5d%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()
{
int i;
char s[81];
if (ncn!=NULL)
farfree(ncn);
if (cnn!=NULL)
farfree(cnn);
if (csn!=NULL)
farfree((void far *) csn);
if (con!=NULL)
farfree(con);
ncn=NULL;
cnn=NULL;
csn=NULL;
con=NULL;
read_in_file("MENUS.MSG",(menus),30);
read_in_file("HELP.MSG",(helps),50);
for (i=0; i<30; i++) {
menus1[i].stored_as=0L;
menus1[i].storage_type=255;
menus2[i].stored_as=0L;
menus2[i].storage_type=255;
}
sprintf(s,"%sMENUSANS.MSG",syscfg.gfilesdir);
if (exist(s))
read_in_file("MENUSANS.MSG",(menus1),30);
sprintf(s,"%sMENUS40.MSG",syscfg.gfilesdir);
if (exist(s))
read_in_file("MENUS40.MSG",(menus2),30);
if (csn!=NULL)
farfree((void far *)csn);
if (cnn!=NULL)
farfree(cnn);
if (con!=NULL)
farfree(con);
read_bbs_list_index();
read_contacts();
}
void mailr()
{
int i,abort,a,f,next;
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 {
if (m.tosys!=0) {
outstr("7[1To7] 3 : System #");
itoa(m.tosys,s,10);
pl(s);
} else {
read_user(m.touser,&u);
npr("7[1To7]3 : %s\r\n",nam(&u,m.touser));
}
npr("7[1Title7]3: %s\r\n",m.title);
setorigin(m.fromsys, m.fromuser);
read_message1(&(m.msg),m.anony & 0x0f,1,&next,"EMAIL");
prt(2,"3R,D,Q,<space> : ");
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()
{
char s[81];
int i;
if (!checkpw())
return;
if (!so())
return;
prt(1,"User to change to? ");
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,"#*#*#* Changed to %s",nam(&thisuser,usernum));
topscreen();
sysoplog(s);
} else
pl("3Don't know 'em.");
}
void zlog()
{
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(" 3 Date Calls Active Posts Email Fback U/L %Act T/user",&abort);
pla("7 -------- ----- ------ ----- ----- ----- --- ---- ------",&abort);
while ((i<97) && (!abort) && (!hangup) && (z.date[0]!=0)) {
if (z.calls)
i1=z.active/z.calls;
else
i1=0;
sprintf(s,"1%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()
{
char s[255];
zlogrec z,z1;
int f,i,i1;
double fk;
int nus;
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());
if (1) {
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"),"","","","");
full_external(s,0,1);
}
fk=freek1(syscfg.datadir);
nus=syscfg.maxusers-status.users;
if (fk<512.0) {
sprintf(s,"Only %dk free in data directory.",(int) fk);
ssm(1,0,s);
}
if ((!syscfg.closedsystem) && (nus<15)){
sprintf(s,"Only %d new user slots left.",nus);
ssm(1,0,s);
}
}