home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
UTIL
/
WWIVE
/
OLDDEV.ARJ
/
LILO.C
< prev
next >
Wrap
Text File
|
1992-06-15
|
14KB
|
586 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
int check_ansi()
{
long l;
char ch;
while (comhit())
get1c();
pr1("\x1b[6n");
l=timer1()+36;
if (modem_flag & flag_ec)
l += 18;
while ((timer1()<l) && (!hangup)) {
checkhangup();
ch=get1c();
if (ch=='\x1b')
return(1);
if (ch=='N')
return(-1);
}
return(0);
}
void getuser()
{
char s[81],s2[81],s3[81],*ss;
int ok,count,net_only,ans;
long l;
FILE *f;
thisuser.sysstatus &= (~sysstatus_ansi);
net_only=1;
if (syscfg.netlowtime!= syscfg.nethightime) {
if (syscfg.nethightime>syscfg.netlowtime) {
if ((timer()<=(syscfg.netlowtime*60.0)) || (timer()>=(syscfg.nethightime*60.0)))
net_only=0;
} else {
if ((timer()<=(syscfg.netlowtime*60.0)) && (timer()>=(syscfg.nethightime*60.0)))
net_only=0;
}
} else
net_only=0;
count=0;
ok=0;
checkit=1;
okmacro=0;
if ((!net_only) && (incom)) {
sprintf(s,"%sWELCOME.ANS",syscfg.gfilesdir);
if (exist(s)) {
nl();
#ifdef OLD
outstr("Can you support ANSI graphics? ");
thisuser.sysstatus=0;
ans=yn();
#else
ans=check_ansi();
#endif
if (ans>0)
printfile("welcome.ans");
else if (ans==0)
printfile("welcome.msg");
} else
printfile("welcome.msg");
}
makeansi(0x07, s, 1);
outs(s);
do {
nl();
if (net_only) {
pl("This time is reserved for net-mail ONLY.");
pl("Please try calling back again later.");
} else
pl("1Enter number or name or 'NEW'");
outstr("NN: "); /* DON'T change the NN: prompt. */
input(s,30);
usernum=finduser(s);
if ((net_only) && (usernum!=-2))
usernum=0;
if (usernum>0) {
read_user(usernum,&thisuser);
actsl = syscfg.newusersl;
topscreen();
ok=1;
outstr("1PW: ");
echo=0;
input(s,8);
if (strcmp(s,thisuser.pw)!=0)
ok=0;
if ((syscfg.sysconfig & sysconfig_free_phone)==0) {
outstr("7PH: ■■■-■■■-");
echo=0;
input(s2,4);
if (strcmp(s2,&thisuser.phone[8])!=0) {
ok=0;
if ((strlen(s2)==4) && (s2[3]=='-')) {
nl();
pl("!! Enter the LAST 4 DIGITS of your phone number ONLY !!");
nl();
}
}
}
if ((thisuser.sl==255) && (incom) && (ok)) {
outstr("6SY:7 ");
echo=0;
input(s,20);
if (strcmp(s,syscfg.systempw)!=0)
ok=0;
}
echo=1;
if (ok) {
reset_act_sl();
changedsl();
} else {
++thisuser.illegal;
write_user(usernum,&thisuser);
close_user();
nl();
pl("\7ILLEGAL LOGON\7");
nl();
sprintf(s3,"### ILLEGAL LOGON for %s (%s) (PW=%s)",
nam(&thisuser,usernum),
ctim(timer()),
s);
sl1(0,s3);
usernum=0;
}
} else
if (usernum==-1) {
newuser();
ok=1;
} else
if (usernum==0) {
if (net_only)
nl();
else
pl("6Unknown user.");
} else
if ((usernum==-2) || (usernum==-3) || (usernum==-4)) {
if (incom) {
save_status();
time(&l);
s2[0]=0;
switch(usernum) {
case -2:
sprintf(s2,"NETWORK /B%u /T%ld /F%u",modem_speed,l,modem_flag);
run_external1(s2);
break;
case -3:
sprintf(s2,"REMOTE /B%u /F%u",modem_speed,modem_flag);
run_external1(s2);
break;
case -4:
s[8]=0;
if (s[0]) {
sprintf(s2,"%s /B%u /F%u",s,modem_speed,modem_flag);
sprintf(s3,"%sREMOTES.DAT",syscfg.datadir);
f=fopen(s3,"r");
if (f) {
ok=0;
while ((!ok) && (fgets(s3,80,f))) {
ss=strchr(s3,'\n');
if (ss)
*ss=0;
if (stricmp(s3,s)==0)
ok=1;
}
fclose(f);
if (ok) {
run_external1(s2);
}
}
}
break;
}
get_status();
hangup=1;
dtr(0);
global_xx=0;
wait(1.0);
dtr(1);
wait(0.1);
cleanup_net();
imodem(0);
}
hangup=1;
}
} while ((!hangup) && (!ok) && (++count<3));
if (count==3)
hangup=1;
checkit=0;
okmacro=1;
if ((!hangup) && (usernum>0) && (thisuser.restrict & restrict_logon) &&
(strcmp(date(),thisuser.laston)==0) && (thisuser.ontoday>0)) {
nl();
pl("Sorry, you can only logon once per day.");
nl();
hangup=1;
}
}
void logon()
{
char s[255],s1[81],s2[81],*ss;
int i,i1,f;
long len,pos;
if (usernum<1) {
hangup=1;
return;
}
if (live_user) {
ansic(0);
outchr(12);
}
if (strcmp(date(),status.date1)!=0) {
if (live_user) {
nl();
pl("6Now doing daily maintenance.");
nl();
}
beginday();
}
if (incom && live_user) {
i=printfile("LOGON");
if ((!i) && (!(thisuser.sysstatus & sysstatus_pause_on_page)))
pausescr();
}
strcpy(xdate,date());
if (strcmp(xdate,thisuser.laston)==0)
++thisuser.ontoday;
else {
thisuser.ontoday=1;
thisuser.timeontoday=0.0;
thisuser.extratime=0.0;
thisuser.posttoday=0;
thisuser.etoday=0;
thisuser.fsenttoday1=0;
}
++thisuser.logons;
cursub=0;
msgreadlogon=0;
if (udir[0].subnum==0)
curdir=1;
else
curdir=0;
curdloads=0;
if (actsl!=255) {
++status.callernum1;
++status.callstoday;
}
sprintf(s,"%ld: %s %s %s %s - %d",
status.callernum1,
nam(&thisuser,usernum),
times(),
date(),
curspeed,
thisuser.ontoday);
sprintf(s2,"%sLASTON.TXT",syscfg.gfilesdir);
ss=get_file(s2,&len);
pos=0;
if (ss!=NULL) {
if (!cs())
for (i=0; i<4; i++)
copy_line(s1,ss,&pos,len);
i=1;
do {
copy_line(s1,ss,&pos,len);
if ((s1[0]) && live_user) {
if (i) {
i=0;
nl();
nl();
pl("7Last few callers: ");
nl();
pl("5╔═══════════════════════════════════════╗");
pl("5║7Call # 3Alias 7Baud 2#5║");
pl("5╠═══════════════════════════════════════╣");
}
pl(s1);
}
} while (pos<len);
}
if ((actsl!=255) || (incom)) {
sl1(0,"");
sl1(0,s);
sl1(1,"");
sprintf(s,"5║7[1%4ld7]5:3 %-21s 5%4s7 -2 %2d5║\r\n",
status.callernum1,
nam(&thisuser,usernum),
curspeed,
thisuser.ontoday);
pl("5╚═══════════════════════════════════════╝");
sprintf(s1,"%sUSER.LOG",syscfg.gfilesdir);
f=open(s1,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
lseek(f,0L,SEEK_END);
i=strlen(s);
if (actsl!=255) {
write(f,(void *)s,i);
close(f);
f=open(s2,O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
pos=0;
copy_line(s1,ss,&pos,len);
for (i=1; i<8; i++) {
copy_line(s1,ss,&pos,len);
strcat(s1,"\r\n");
write(f,(void *)s1,strlen(s1));
}
write(f,(void *)s,strlen(s));
close(f);
} else
close(f);
}
if (ss!=NULL)
farfree(ss);
if (live_user)
read_automessage();
timeon=timer();
useron=1;
if (live_user)
topscreen();
if (actsl>10)
{
prt(2,"Updating The Devil's Doorknob Top Ten User List!");
check_top();
}
nl();
if ((syscfg.logon_c[0]) && live_user) {
nl();
stuff_in(s,syscfg.logon_c,create_chain_file("CHAIN.TXT"),"","","","");
full_external(s,0,1);
nl();
nl();
}
if (live_user) {
nl();
pl("3 ┌─────────┐");
pl("3 │ 5Stats 3│");
pl("3 ┌──────────────────────┴─────────┴────────────────────────┐");
npr("3 │1Name3:7 %-22s3 1Caller number 3: 7%-4ld 3│\r\n",nam(&thisuser,usernum),status.callernum1);
npr("3 │1Time allowed on3:7 %-12d 1Post/Call Ratio3: 7%-5.3f3│\r\n", (int) ((nsl()+30)/60.0),post_ratio(),syscfg.post_call_ratio);
npr("3 │1Illegal logons3 :6 %-12d 1Mail Waiting 3: 6%-3d 3│\r\n",thisuser.illegal,thisuser.waiting);
npr("3 │1Last on 3 :7 %-12s 1Times on today 3: 7%-3d 3│\r\n",thisuser.laston,thisuser.ontoday);
if (sysop2())
npr("3 │1Sysop is 3 :7 Watching your every move! 3│\r\n");
else
npr("3 │1Sysop is 3 :7 Out Llama tipping! 3│\r\n");
/****************************************************************************/
/*
* Do NOT remove or modify this part of the code. If the registration number
* (or an indicator that it is unregistered) is not printed out, it will
* be plainly obvious that this is a 'pirated' version of the source code.
*/
if (syscfg.wwiv_reg_number)
sprintf(s,"(Reg #%ld)",syscfg.wwiv_reg_number);
else
strcpy(s,"(Unregistered)");
sprintf(s1," 3 │1System is 3 :7 %s %s 3 │",VERSION_NUMBER,s);
pl(s1);
/****************************************************************************/
if (syscfg.systemnumber)
npr("3 │5≡7BamaNet5≡1 Node3 :7 @%u (net%2u) 3 │\r\n",syscfg.systemnumber,
status.net_version);
pl("3 └─────────────────────────────────────────────────────────┘");
nl();
if (thisuser.forwardusr) {
if (thisuser.forwardsys) {
if (!next_system(thisuser.forwardsys)) {
thisuser.forwardusr=0;
thisuser.forwardsys=0;
strcpy(s1,"Forwarded to unknown system; forwarding reset.");
} else {
sprintf(s1,"Forwarding mail to #%u @%u.",
thisuser.forwardusr,thisuser.forwardsys);
}
} else {
sprintf(s1,"Forwarding mail to user #%u.",thisuser.forwardusr);
}
pl(s1);
nl();
}
fsenttoday=0;
if (thisuser.year) {
s[0]=years_old(thisuser.month,thisuser.day,thisuser.year);
if (thisuser.age!=s[0]) {
thisuser.age=s[0];
topscreen();
}
} else {
nl();
pl("Please enter the following information:");
do {
nl();
input_age(&thisuser);
sprintf(s,"%02d/%02d/%02d",(int) thisuser.month,
(int) thisuser.day,
(int) thisuser.year);
nl();
npr("Birthdate: %s. Correct? ",s);
if (!yn())
thisuser.year=0;
} while ((!hangup) && (thisuser.year==0));
topscreen();
nl();
}
rsm(usernum,&thisuser);
if (thisuser.waiting) {
nl();
prt(5,"Read your mail now? ");
if (ny())
readmail();
}
}
nscandate=thisuser.daten;
batchtime=0.0;
numbatchdl=numbatch=0;
i1=0;
for (i=0; i<20; i++) {
if (questused[i])
if (thisuser.votes[i]==0)
i1=1;
}
if (restrict_vote & thisuser.restrict)
i1=0;
if (actsl<=10)
i1=0;
if (i1 && live_user) {
nl();
prt(6,"You bama! You haven't voted yet!");
nl();
nl();
pausescr();
vote();
}
save_status();
create_chain_file("CHAIN.TXT");
nl();
prt(7,"View top ten users5?");
if (yn())
printfile("TOPUSERS.MSG");
nl();
prt(1,"Scan for new messages3?");
if (ny())
nscan(0);
}
void logoff()
{
long l;
int f,r,w,t,i;
char s[81];
mailrec m;
shortmsgrec sm;
double ton;
dtr(0);
hangup=1;
if (usernum<1)
return;
thisuser.lastrate=modem_speed;
strcpy(thisuser.laston,xdate);
thisuser.illegal=0;
if ((timer()-timeon)<-30.0)
timeon-=24.0*3600.0;
ton=timer()-timeon;
thisuser.timeon += ton;
thisuser.timeontoday += (ton-extratimecall);
status.activetoday += (int) (ton/60.0);
save_status();
time(&l);
thisuser.daten=l;
close_user();
write_user(usernum,&thisuser);
close_user();
sprintf(s,"Read: %u Time on: %u",msgreadlogon,
(int)((timer()-timeon)/60.0));
if ((incom) || (actsl!=255))
sl1(0,s);
if (mailcheck) {
sprintf(s,"%sEMAIL.DAT",syscfg.datadir);
f=open(s,O_BINARY | O_RDWR);
if (f!=-1) {
t=(int) (filelength(f)/sizeof(mailrec));
r=0;
w=0;
while (r<t) {
lseek(f,(long)(sizeof(mailrec)) * (long)(r),SEEK_SET);
read(f,(void *)&m,sizeof(mailrec));
if ((m.tosys!=0) || (m.touser!=0)) {
if (r!=w) {
lseek(f,(long)(sizeof(mailrec)) * (long)(w),SEEK_SET);
write(f,(void *)&m,sizeof(mailrec));
}
++w;
}
++r;
}
chsize(f,(long)(sizeof(mailrec)) * (long)(w));
close(f);
}
}
if (smwcheck) {
sprintf(s,"%sSMW.DAT",syscfg.datadir);
f=open(s,O_BINARY | O_RDWR);
if (f!=-1) {
t=(int) (filelength(f)/sizeof(shortmsgrec));
r=0;
w=0;
while (r<t) {
lseek(f,(long)(sizeof(shortmsgrec)) * (long)(r),SEEK_SET);
read(f,(void *)&sm,sizeof(shortmsgrec));
if ((sm.tosys!=0) || (sm.touser!=0)) {
if (r!=w) {
lseek(f,(long)(sizeof(shortmsgrec)) * (long)(w),SEEK_SET);
write(f,(void *)&sm,sizeof(shortmsgrec));
}
++w;
}
++r;
}
chsize(f,(long)(sizeof(shortmsgrec)) * (long)(w));
close(f);
}
}
remove_from_temp("*.*", syscfg.tempdir, 0);
remove_from_temp("*.*", syscfg.batchdir, 0);
if (numbatch && (numbatch != numbatchdl)) {
for (i=0; i<numbatch; i++) {
if (!batch[i].sending) {
didnt_upload(i);
}
}
}
}