Skip to content

Latest commit

 

History

History
495 lines (442 loc) · 13.5 KB

logon2.pas

File metadata and controls

495 lines (442 loc) · 13.5 KB
 
Nov 18, 2000
Nov 18, 2000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
(*****************************************************************************)
(*> <*)
(*> LOGON2 .PAS - Written by Eric Oman <*)
(*> <*)
(*> Logon functions -- Part 2. <*)
(*> <*)
(*> <*)
(*****************************************************************************)
{$A+,B+,D-,E+,F+,I+,L+,N-,O+,R-,S+,V-}
unit logon2;
interface
uses
crt, dos,
{rcg11172000 no overlay under Linux.}
{overlay,}
mail0, mail1, mail2, mail3, mail4, mail9,
misc2, miscx,
cuser,
doors,
archive1,
menus,
common;
procedure logon;
procedure logoff;
procedure endday;
procedure pver;
implementation
procedure logon;
var ul:text;
vdata:file of vdatar;
lcallf:file of lcallers;
u:userrec;
vd:vdatar;
lcall:lcallers;
lo:array[1..8] of astr;
s:astr;
zz:string[5];
lng:longint;
num,lcts,hilc,vna,callsleft,ct,z,qq,rcode:integer;
c:char;
abort,lastinit:boolean;
datet:string;
h, m, x: Word;
procedure day_desc(dat:astr);
var d:astr;
hs:boolean;
procedure p(s:astr);
begin
sprompt(s);
hs:=TRUE;
end;
begin
hs:=FALSE; d:=copy(date,1,5);
if (d='01/01') then p('Happy New Year') else
if (d='07/04') then p('Happy '+#3#7+'4th '+#3#0+'of '+#3#4+'July'+#3#3) else
if (d='12/24') then p('Happy Christmas Eve') else
if (d='12/25') then p(#3#9+'Merry '+#3#7+'Christmas'+#3#3);
if (not hs) then
begin
if (timer<21600) or (timer>=64800) then p('Good evening') else
if (timer<43200) and (timer>=21600) then p('Good morning') else
p('Good afternoon');
end;
end;
function checkbday:boolean;
var i,j:integer;
begin
i:=85;
repeat
j:=daynum(copy(thisuser.bday,1,6)+tch(cstr(i)));
if (daynum(date)>=j) and (daynum(thisuser.laston)<j) then begin
checkbday:=TRUE;
exit;
end;
inc(i);
until (i>value(copy(date,7,2)));
checkbday:=FALSE;
end;
function bsince:boolean;
begin
bsince:=(not (copy(thisuser.bday,1,5)=copy(date,1,5)));
end;
procedure showbday(s:astr);
begin
nofile:=TRUE;
if (bsince) then printf('bdys'+s); {* birthday occured SINCE laston *}
if (nofile) then printf('bday'+s); {* birthday TODAY *}
end;
procedure findchoptime;
var lng,lng2,lng3:longint;
procedure onlinetime;
var dt:datetimerec;
secs:longint;
begin
secs:=trunc(nsl);
dt.day:=secs div 86400; secs:=secs-(dt.day*86400);
dt.hour:=secs div 3600; secs:=secs-(dt.hour*3600);
dt.min:=secs div 60; secs:=secs-(dt.min*60);
dt.sec:=secs;
sprint(^G);
sprint(#3#8+'** '+#3#5+'System event approaching - online time adjusted to:');
sprint(#3#8+'** '+#3#0+longtim(dt));
sprint(^G);
end;
begin
if (exteventtime<>0) then
begin
lng:=exteventtime;
if (lng<trunc(nsl/60.0)) then
begin
choptime:=(nsl-(lng*60.0))+120.0; onlinetime; exit;
end;
end;
lng:=1; lng2:=trunc(nsl/60);
if (lng2>180) then lng2:=180;
while (lng<=lng2) do
begin
lng3:=lng*60;
if (checkevents(lng3)<>0) then
begin
choptime:=(nsl-(lng*60.0))+60.0; onlinetime; exit;
end;
inc(lng,2);
end;
end;
begin
getdatetime(timeon); mread:=0; extratime:=0.0; freetime:=0.0;
useron:=TRUE; com_flush_rx; logon1st;
if ((thisuser.sl=255) and (not fastlogon) and (spd<>'KB')) then
begin
if pynq('Fast logon? ') then fastlogon:=TRUE;
nl;
end;
lastinit:=FALSE; assign(lcallf,systat.gfilepath+'laston.dat');
{$I-} reset(lcallf); {$I+}
if (ioresult<>0) then
begin
lastinit:=TRUE; rewrite(lcallf); lcall.callernum:=-1;
for z:=0 to 9 do write(lcallf,lcall);
end;
if (systat.lcallinlogon) then
begin
if (cso) then lcts:=10 else lcts:=4;
lcall.callernum:=0; z:=0; hilc:=9;
for z:=0 to 9 do
begin
seek(lcallf,z); read(lcallf,lcall);
if (lcall.callernum=-1) and (hilc=9) then hilc:=z-1;
end;
if (hilc<>-1) then
begin
if (not cso) and (hilc>3) then hilc:=3;
sprint(#3#5+'Last few callers:');
for z:=hilc downto 0 do
begin
seek(lcallf,z); read(lcallf,lcall);
with lcall do
sprint(#3#3+cstr(callernum)+': '+#3#0+name+
#3#2+' #'+#3#4+cstr(number)+#3#3+' from '+#3#0+citystate+#3#3+' at '+#3#4+datet);
end;
end;
nl;
end;
if ((spd<>'KB') or (lastinit)) then
begin
for z:=9 downto 1 do
begin
seek(lcallf,z-1); read(lcallf,lcall);
seek(lcallf,z); write(lcallf,lcall);
end;
with lcall do
begin
callernum:=systat.callernum; name:=caps(thisuser.name);
number:=usernum; citystate:=thisuser.citystate;
datet:=dat;
end;
seek(lcallf,0); write(lcallf,lcall);
end;
close(lcallf);
if ((not fastlogon) and (not hangup)) then
begin
printf('logon'); pausescr; nofile:=FALSE; z:=0;
repeat
inc(z); printf('logon'+cstr(z));
until (z=9) or (nofile) or (hangup);
printf('sl'+cstr(thisuser.sl));
printf('dsl'+cstr(thisuser.dsl));
for c:='A' to 'Z' do
if (c in thisuser.ar) then printf('arlevel'+c);
printf('user'+cstr(usernum));
if (checkbday) then
begin
showbday(cstr(usernum));
if nofile then showbday('');
if nofile then
if bsince then begin
sprint(#3#4+'-------------------------------------------------------------------');
sprint(#3#3+'Happy Birthday, '+caps(thisuser.name)+' !!!');
sprint(#3#3+'You turned '+cstr(ageuser(thisuser.bday))+' on '+
copy(thisuser.bday,1,5)+copy(date,6,3)+'!!');
sprint(#3#3+'(a little late, but it''s the thought that counts!)');
sprint(#3#4+'-------------------------------------------------------------------');
nl;
end else begin
sprint(#3#4+'-------------------------------------------------------------------');
sprint(#3#3+'Happy Birthday, '+caps(thisuser.name)+' !!!');
sprint(#3#3+'You turned '+cstr(ageuser(thisuser.bday))+' today!!');
sprint(#3#4+'-------------------------------------------------------------------');
nl;
end;
end;
if (exist('logon.bat')) then
begin
shelldos(FALSE,process_door('logon.bat @F @L @B @G @T @R'),rcode);
topscr;
end;
nl; cl(5);
if (sysop) then sprint(fstring.sysopin) else sprint(fstring.sysopout);
if (systat.autominlogon) then readamsg;
nl;
end;
if (not wasguestuser) then
begin
if (thisuser.flistopt=0) then thisuser.flistopt:=1;
if (thisuser.bday='00/00/00') then begin
print('Updating system records ...');
cstuff(2,1,thisuser);
nl;
end;
if (thisuser.citystate='') or (thisuser.citystate='Unknown, MI') then
cstuff(4,1,thisuser);
if (thisuser.clsmsg=0) then
begin
nl;
print('Updating user account ... Do you prefer:');
nl;
print(' (1.) A clear-screen before each message');
print(' (2.) Continuous listing of messages, with no screen clearing.');
nl;
prt('Enter selection: '); onek(c,'12');
if (not hangup) then
if (c='1') then thisuser.clsmsg:=1 else thisuser.clsmsg:=2;
end;
if (thisuser.avadjust=0) then
begin
thisuser.avadjust:=1;
thisuser.ac:=thisuser.ac-[avatar];
end;
end;
if (thisuser.computer='Unknown') then
begin
cstuff(5,1,thisuser); nl;
end;
savesystat;
with thisuser do
begin
if ((not fastlogon) and (not hangup)) then begin
if (systat.yourinfoinlogon) then begin pausescr; yourinfo; nl; end;
cl(3); day_desc(dat); sprint(', '+nam+'.');
nl;
sprint(#3#3+'You are caller '+#3#4+'#'+#3#0+cstr(systat.callernum)+',');
if (systat.todayzlog.calls<>0) then
begin
sprompt(#3#3+'the ');
zz:=cstr(systat.todayzlog.calls); zz:=copy(zz,length(zz),1);
z:=value(zz); ct:=systat.todayzlog.calls;
if (ct in [11..13]) then z:=4;
sprompt(#3#0+cstr(systat.todayzlog.calls)+#3#4);
case z of
1:sprompt('st');
2:sprompt('nd');
3:sprompt('rd');
else
sprompt('th');
end;
sprint(#3#3+' caller for today.');
end;
nl;
lmsg:=FALSE;
sprint('Time allowed - '+#3#3+cstr(systat.timeallow[thisuser.sl])+' minutes');
if (waiting<>0) then
begin
sprompt('Mail waiting - '+#3#3+cstr(waiting)+' letter');
if (waiting>1) then print('s') else nl;
end;
if (illegal<>0) then
sprint(^G+#3#8+'Illegal logons - '+cstr(illegal)+' attempts ');
if (loggedon<>0) then
sprint('You have called - '+#3#3+cstr(loggedon)+' times');
if (laston<>date) then
sprint('Last on - '+#3#3+laston)
else
sprint('Calls today - '+#3#3+cstr(ontoday)+' times');
sprompt('Account limits - '+#3#3+cstr(systat.callallow[thisuser.sl])+' call');
if (systat.callallow[thisuser.sl]<>1) then sprompt('s');
sprompt(', using a maximum of '+cstr(systat.timeallow[thisuser.sl])+' minutes, ');
if TRUE {*****} then sprint('per day.') else sprint('per call.');
nl;
if (daynum(laston)<=daynum(systat.tfiledate)) and
(daynum(laston)>0) then
begin
sprint(#3#5+'There may be new text files available.');
end;
vna:=0;
assign(vdata,systat.gfilepath+'voting.dat');
{$I-} reset(vdata); {$I+}
if (ioresult=0) then begin
for num:=1 to 20 do begin
seek(vdata,num-1); read(vdata,vd);
if (vd.numa<>0) then
if (vote[num]=0) then inc(vna);
end;
close(vdata);
if (vna>0) then
begin
sprompt(#3#5+'You have not voted on '+#3#9+cstr(vna)+#3#5+' voting question');
if (vna>1) then sprint('s.') else sprint('.');
if (systat.forcevoting) and (not (rvoting in thisuser.ac)) then begin
nl;
while (not empty) do getkey(c);
pausescr;
misc1.vote;
end;
end;
end;
if (forusr<>0) then
sprint(#3#7+'Your mail is being forwarded to user #'+cstr(forusr));
nl;
topscr;
end;
end;
findchoptime;
with thisuser do
begin
if (smw in ac) then begin rsm; nl; end;
ac:=ac-[smw];
if ((alert in ac) and (sysop)) then chatcall:=TRUE;
if (waiting<>0) then begin
if pynq('Read your mail now? ') then readmail;
nl;
end;
end;
if ((not fastlogon) and (systat.bullinlogon)) then bulletins('');
fastlogon:=FALSE;
end;
procedure logoff;
var ddt,dt:datetimerec;
i,tt,rcode:integer;
begin
if ((useron) and (usernum>0)) then
if (exist('logoff.bat')) then
shelldos(FALSE,process_door('logoff.bat @F @L @B @G @T @R'),rcode);
term_ready(FALSE);
if ((useron) and (usernum>0)) then
begin
purgedir(systat.temppath+'1\');
purgedir(systat.temppath+'2\');
purgedir(systat.temppath+'3\');
slogging:=TRUE;
if (trapping) then
begin
if (hungup) then
begin
writeln(trapfile);
writeln(trapfile,'NO CARRIER');
end;
close(trapfile); trapping:=FALSE;
end;
getdatetime(dt); timediff(ddt,timeon,dt); tt:=trunc((dt2r(ddt)+30)/60);
thisuser.laston:=systat.lastdate; inc(thisuser.loggedon);
(* if not logged in, but logged on *)
if (realsl<>-1) then thisuser.sl:=realsl;
if (realdsl<>-1) then thisuser.dsl:=realdsl;
thisuser.illegal:=0; thisuser.ttimeon:=thisuser.ttimeon+tt;
if (choptime<>0.0) then inc(thisuser.tltoday,trunc(choptime/60.0));
thisuser.tltoday:=trunc(nsl/60.0);
thisuser.lastmsg:=board; thisuser.lastfil:=fileboard;
reset(uf);
if ((usernum>=1) and (usernum<=filesize(uf)-1)) then
begin seek(uf,usernum); write(uf,thisuser); end;
close(uf);
if (spd<>'KB') then inc(systat.todayzlog.active,tt);
inc(systat.todayzlog.fback,ftoday);
inc(systat.todayzlog.privpost,etoday);
savesystat;
for i:=1 to hiubatchv do release(ubatchv[i]); {* release dynamic memory *}
window(1,1,80,25); clrscr;
if (hungup) then sl1(#3#7+'>>*>*>*> Hung Up <*<*<*<<');
sl1(#3#4+'Read: '+#3#3+cstr(mread)+#3#4+' / Time on: '+#3#3+cstr(tt));
end;
end;
procedure endday;
var d,i,tu,fu:integer;
begin
useron:=FALSE;
d:=daynum(date);
if (d<>ldate) then
if (d-ldate)=1 then
inc(ldate)
else begin
writeln('Date corrupted.');
halt(1);
end;
(*****
reset(mailfile);
for i:=0 to filesize(mailfile)-1 do begin
seek(mailfile,i); read(mailfile,mr);
if (old(mr.date,mr.mage) and (mr.destin<>-1)) then begin
fu:=abs(mr.from);
is:=rmail(i);
ssm(fu,is+' never got your letter.');
end;
end;
close(mailfile);
reset(uf);
for board:=1 to numboards do begin
iscan;
cn:=1;
while (cn<=tnum) do begin
if (old(mary[cn].date,mary[cn].mage)) or
(mary[cn].messagestat=deleted) then
deletem(cn)
else
inc(cn);
end;
savebase;
end;
close(uf);
*****)
end;
procedure pver;
var abort,next,aa:boolean;
begin
abort:=FALSE; next:=FALSE;
aa:=allowabort; allowabort:=FALSE;
nl;
printacr(verline(1),abort,next);
printacr(verline(2),abort,next);
nl;
allowabort:=aa;
end;
end.