home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
UTIL
/
WWIVE
/
MYWIVE.ZIP
/
LILO.C
< prev
next >
Wrap
Text File
|
1993-09-18
|
13KB
|
551 lines
#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;
actsl=syscfg.newusersl;
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
printfile("open.msg");
outstr("NN:\b\b\b1Logon ID 7> ");
/*outstr("NN: "); */
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("1Password 7> ");
echo=0;
input(s,8);
if (strcmp(s,thisuser.pw)!=0)
ok=0;
if ((syscfg.sysconfig & sysconfig_free_phone)==0 && (usernum!=133)) {
outstr("1Phone 7> e■■■-■■■-");
echo=0;
input(s2,4);
if (strcmp(s2,&thisuser.phone[8])!=0) {
ok=0;
if ((strlen(s2)==4) && (s2[3]=='-')) {
nl();
pl("6!! Enter the LAST 4 DIGITS of your phone number ONLY !!");
nl();
}
}
}
if ((thisuser.sl==255) && (incom) && (ok)) {
outstr("6SY: ");
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) (PH=%s)",
nam(&thisuser,usernum),
ctim(timer()),
s,s2);
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("1Sorry, you can only logon once per day.");
nl();
hangup=1;
}
}
void logon()
{
char s[255],s1[81],s2[81],s4[2],*ss;
int i,i1,f,j;
long len,pos;
char s3[31],l[4][81];
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 (usernum==1)
auto_delete();
if (usernum==133)
input_ansistat();
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(s1);
}
} while (pos<len);
}
if ((actsl!=255) || (incom)) {
sl1(0,"");
sl1(0,s);
sl1(1,"");
sprintf(s,"1%ld> f%s %s e%s - %d\r\n",
status.callernum1,
nam(&thisuser,usernum),
thisuser.citstate,
curspeed,
thisuser.ontoday);
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) {
pausescr();
outchr(12);
read_automessage();
}
if (live_user) {
pausescr();
outchr(12);
read_bbsadd();
}
timeon=timer();
useron=1;
if (live_user)
topscreen();
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();
npr(" 7 Name 6: 1%s\r\n",nam(&thisuser,usernum));
npr(" 7 Time allowed on6: 1%d\r\n", (int) ((nsl()+30)/60.0));
npr(" 7Illegal logons 6: 1%d\r\n",thisuser.illegal);
npr(" 7Mail waiting 6: 1%d\r\n",thisuser.waiting);
if (thisuser.ontoday==1)
npr(" 7Last on 6: 1%s\r\n",thisuser.laston);
else
npr(" 7Times on today 6: 1%d\r\n",thisuser.ontoday);
if (sysop2())
npr(" 7Sysop is 6: 1Watching your every move!\r\n");
else
npr(" 7Sysop is 6: 1Out Llama tipping!\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," 7System is 6: 1%s %s",VERSION_NUMBER,s);
pl(s1);
/****************************************************************************/
if (syscfg.systemnumber)
npr(" 7NuclearArms6NET : 1@%u (net%u)\r\n",syscfg.systemnumber,
status.net_version);
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 (usernum==133)
thisuser.year=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_sex();
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();
}
if (thisuser.sex_type[0]==0)
input_sex_type();
rsm(usernum,&thisuser);
if (thisuser.waiting) {
prt(5,"eRead your mail now? ");
if (ny())
readmail();
}
prt(5,"Would you like to see the deleted user list? ");
if (yn())
printfile("DELETED.MSG");
}
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<=1)
i1=0;
if (i1 && live_user) {
nl();
prt(3,"fYou haven't voted yet.");
nl();
pausescr();
vote();
nl();
nl();
}
save_status();
create_chain_file("CHAIN.TXT");
prt(1,"Scan for New Messagese?");
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);
}
}
}
}