-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile12.pas
More file actions
549 lines (489 loc) · 14.7 KB
/
file12.pas
File metadata and controls
549 lines (489 loc) · 14.7 KB
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
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
{$A+,B-,D-,E-,F+,I-,L-,N-,O+,R-,S+,V-}
unit file12;
interface
uses crt, dos, overlay, common, timefunc, dfFix;
procedure delubatch(n:integer);
procedure listubatchfiles;
procedure removeubatchfiles;
procedure clearubatch;
procedure batchul(bicleanup:boolean; TransferTime:longint);
procedure batchinfo;
implementation
uses file0, file1, file2, file6, file9, execbat, archive1;
procedure delubatch(n:integer);
var
c:integer;
begin
if (n >= 1) and (n <= numubatchfiles) then
begin
if (n <> numubatchfiles) then
for c := n to numubatchfiles - 1 do
BatchULQueue[c]^ := BatchULQueue[c + 1]^;
dispose (BatchUlQueue[numubatchfiles]);
dec(numubatchfiles);
end;
end;
procedure listubatchfiles;
var s,s1:astr;
i,j:integer;
vfo:boolean;
begin
if (numubatchfiles=0) then
print(^M^J'Upload batch queue empty.')
else begin
abort:=FALSE; next:=FALSE;
printacr(^M^J'^4##:Filename.Ext Area Description');
printacr('--------------- ---- -------------------------------------------------------');
i:=1;
while (not abort) and (i <= numubatchfiles) and (not hangup) do
begin
with BatchULQueue[i]^ do
begin
if (section=general.tosysopdir) then
s1:='^7Sysp'
else
s1:=mrn(cstr(section),4);
s := '^3' + mn(i,2) + '^4:^5' + align(FileName) + ' '+s1+' ^3'+
mln(description,55);
printacr(s);
if (VPointer <> 0) then
if (ubatchv[VPointer]^.descr[1]<>'') then
begin
vfo := (filerec(verbf).mode<>fmclosed);
if (not vfo) then
reset(verbf);
if (ioresult=0) then
for j:=1 to MAXEXTDESC do
if ubatchv[VPointer]^.descr[j]='' then
break
else
printacr(' ^4' +
+ ubatchv[VPointer]^.descr[j]);
if (not vfo) then close(verbf);
end;
end;
inc(i);
end;
printacr('^4--------------- ---- -------------------------------------------------------');
end;
end;
procedure removeubatchfiles;
var s:astr;
i:integer;
begin
if (numubatchfiles=0) then
print(^M^J'Upload batch queue empty.')
else
repeat
prt(^M^J'File # to remove (1-'+cstr(numubatchfiles)+') (?=list) : ');
input(s,2);
i:=value(s);
if (s='?') then listubatchfiles;
if ((i>0) and (i<=numubatchfiles)) then
begin
print('"'+stripname(BatchULQueue[i]^.FileName)+'" deleted out of upload queue.');
delubatch(i);
end;
if (numubatchfiles=0) then print('Upload queue now empty.');
until (s<>'?');
end;
procedure clearubatch;
begin
nl;
if pynq('Clear upload queue? ') then
begin
while NumuBatchFiles > 0 do
begin
dispose (BatchULQueue[NumuBatchFiles]);
dec (NumUBatchFiles);
end;
print('^1Upload queue now empty.');
end;
end;
procedure batchul(bicleanup:boolean; TransferTime:longint);
var fi:file of byte;
dirinfo:searchrec;
f:ulfrec;
v:verbrec;
RefundTime,TakeAwayRefundTime:longint;
ConversionTime,TotalConversionTime:longint;
fn,s:astr;
totb,totb1,totfils1:longint;
totpts,p,oldboard,gotpts,dbn,cps:integer;
blks,totfils:word;
OldActivity, i:byte;
c:char;
autologoff,swap,ahangup,next,done,dok,wenttosysop,ok,convt,
fok,nospace:boolean;
procedure UpFile(ubn:integer);
begin
close(DirFile);
initfileboard;
arcstuff(ok,convt,blks,ConversionTime,TRUE,tempdir + 'UP\',fn,f.description);
inc(TotalConversionTime,ConversionTime);
f.blocks := blks;
doffstuff(f, fn, gotpts);
fok:=TRUE;
loadfileboard(fileboard);
if (ok) then
begin
star('Moving file to ^5' + memuboard.name);
movefile(fok, nospace, FALSE, tempdir + 'UP\' + fn, memuboard.ulpath + fn);
if (fok) then
begin
if (v.descr[1] <> '') then
f.vpointer := NewVPointer
else
f.vpointer := -1;
writefv(filesize(DirFile),f,v);
star(fn+' successfully uploaded.'^M^J);
sysoplog('^3Batch uploaded "'+sqoutsp(fn)+'" to ' + memuboard.name);
inc(totfils);
inc(totb, longint(blks) * 128);
inc(totpts,gotpts);
end
else
begin
star('Upload voided: error in processing.');
sysoplog('^3error moving '+sqoutsp(fn)+' to directory');
end;
end
else
begin
star('Upload not received.');
if (f.blocks div 8>general.minresume) then
begin
nl;
dyny:=TRUE;
if pynq('Save file for a later resume? ') then
begin
prompt('^5Progress: ');
movefile(fok,nospace,TRUE,tempdir + 'UP\' + fn,memuboard.ulpath+fn);
if (fok) then
begin
nl;
doffstuff(f,fn,gotpts);
f.filestat:=f.filestat+[resumelater];
if (v.descr[1] <> '') then
f.vpointer := NewVPointer
else
f.vpointer := -1;
writefv(filesize(DirFile),f,v);
s:='file saved for resume';
end
else
begin
star('Upload voided: error in processing.');
sysoplog('^3error moving '+sqoutsp(fn)+' to directory');
end;
end;
end;
if (not (resumelater in f.filestat)) then
begin
s:='file deleted';
kill(tempdir + 'UP\' + fn);
end;
sysoplog('^3errors batch uploading '+sqoutsp(fn)+' - '+s);
end;
if (not ok) and (not bicleanup) then
begin
inc(TakeAwayRefundTime, longint(f.blocks) * 128 div rate);
star('Time refund of ' + FormattedTime(longint(f.blocks) * 128 div rate) + ' will be taken away.');
end
else
if (ubn <> 0) then
delubatch(ubn);
end;
begin
autologoff := FALSE;
oldboard:=fileboard;
(* if ((diskfree(ExtractDriveNumber(memuboard.ulpath)) div 1024) <= general.minspaceforupload) then*)
if ((diskKBfree(ExtractDriveNumber(memuboard.ulpath))) <= general.minspaceforupload) then
begin
nl;
star('Insufficient disk space.');
c:=chr(ExtractDriveNumber(memuboard.ulpath)+64);
if c='@' then
sysoplog('^8--->^3 Upload failure: Main BBS drive full.')
else
sysoplog('^8--->^3 Upload failure: '+c+' Drive full.');
exit;
end;
if not bicleanup then
begin
done:=FALSE;
nl;
if (numubatchfiles=0) then begin
printf('batchul0');
if (nofile) then begin
print('Warning! No upload batch files specified yet.');
print('If you continue, and batch upload files, you will have to');
print('enter file descriptions for each file after the batch upload');
print('is complete.');
end;
end else begin
printf('batchul');
if (nofile) then begin
print('^1If you batch upload files IN ADDITION to the files already');
print('specified in your upload batch queue, you must enter file');
print('descriptions for them after the batch upload is complete.');
end;
end;
reset(xf);
done:=FALSE;
repeat
showprots(TRUE, FALSE, TRUE, FALSE);
s := GetProts(TRUE, FALSE, TRUE, FALSE);
prompt(fstring.protocolp); onek(c, s);
p:=findprot(c, TRUE, FALSE, TRUE, FALSE);
if (p=-99) then
print('Invalid entry.')
else if (p=-5) then
begin
repeat
prt(^M^J'Batch queue [^5L^4]ist batch, [^5R^4]emove a file, [^5C^4]lear, [^5Q^4]uit : ');
onek(c,'QRCL');
case c of
'R':removeubatchfiles;
'C':clearubatch;
'L':listubatchfiles;
end;
until (hangup) or (C='Q');
if (numubatchfiles = 0) then
exit;
end
else
done:=TRUE;
until (done) or (hangup);
if p=-2 then exit;
seek(xf,p); read(xf,protocol); close(xf);
Lasterror := IOResult;
nl;
autologoff := pynq('Autologoff after file transfer ? ');
dok:=TRUE;
lil:=0;
purgedir(tempdir + 'UP\' , FALSE);
nl; nl;
if (useron) then print('Ready to receive batch queue!');
lil:=0;
OldActivity := update_node(1);
swap:=general.swapshell;
general.swapshell:=FALSE;
TransferTime := getpackdatetime;
TimeLock := TRUE;
execwindow(dok,tempdir + 'UP\',FunctionalMCI(protocol.envcmd,'','')+#13#10+
general.protpath + FunctionalMCI(protocol.ulcmd,'',''),-1,i);
TransferTime := getpackdatetime - TransferTime;
general.swapshell:=swap;
update_node(OldActivity);
RefundTime := TransferTime * (General.ULRefund div 100);
freetime := freetime + RefundTime;
TimeLock := FALSE;
lil:=0;
nl;
star('Batch upload transfer complete.'^M^J);
lil:=0;
end
else
begin
RefundTime := 0;
nl;
end;
TotalConversionTime := 0;
TakeAwayRefundTime := 0;
totb := 0; totfils := 0;
totb1 := 0; totfils1 := 0;
totpts := 0;
findfirst(tempdir + 'UP\*.*',anyfile-directory-volumeid,dirinfo);
while (doserror=0) do
begin
inc(totfils1);
inc(totb1,dirinfo.size);
findnext(dirinfo);
end;
abort:=FALSE; next:=FALSE;
if (totfils1 = 0) then
begin
star('No uploads detected!');
exit;
end;
if (TransferTime > 0) then
cps := totb1 div TransferTime
else
cps := 0;
ahangup:=FALSE;
if hangup then
begin
if (Speed > 0) then
begin
Status_screen(100,'Hanging up and taking phone off hook...',FALSE,s);
dophonehangup(FALSE);
dophoneoffhook(FALSE);
Speed := 0;
end;
hangup:=FALSE; ahangup:=TRUE;
end;
if (not ahangup) then
begin
star('Files uploaded : ^5' + cstr(totfils1)+' files.');
star('Amount uploaded : ^5' + cstr(totb1)+' bytes.');
star('Batch upload time: ^5' + FormattedTime(TransferTime));
star('Transfer rate : ^5' + cstr(cps)+' cps');
star('Time refund : ^5' + FormattedTime(RefundTime));
nl;
if AutoLogoff then
CountDown
else
pausescr(FALSE);
end;
InitFileBoard;
for i := NumUBatchFiles downto 1 do { avoids deallocation error }
if exist(tempdir + 'UP\' + sqoutsp(BatchULQueue[i]^.FileName)) then
begin
fn := BatchULQueue[i]^.FileName;
star('Found ' + fn + '.');
if (General.FileDiz) and (DizExists(TempDir + 'UP\' + fn)) then
GetDiz(f, v)
else
begin
f.description := BatchULQueue[i]^.description;
fileboard := BatchULQueue[i]^.Section;
v.descr[1] := '';
if (BatchULQueue[i]^.VPointer <> 0) then
v := ubatchv[BatchULQueue[i]^.VPointer]^;
end;
UpFile(i);
end;
findfirst(tempdir + 'UP\*.*', AnyFile - Directory - volumeid, DirInfo);
while (Doserror = 0) do
begin
fn := DirInfo.name;
star('Found ' + fn + '.');
if (general.searchdup) and (SearchForDups(fn)) then
begin
star('Deleting duplicate file.');
kill(TempDir + 'UP\' + fn);
end
else
begin
WentToSysOp := FALSE;
if (General.FileDiz) and (DizExists(TempDir + 'UP\' + fn)) then
GetDiz(f, v)
else
begin
dodescrs(f, v, WentToSysOp);
if (ahangup) then
begin
f.description:='Not in upload batch queue - hungup after transfer';
f.vpointer:=-1; v.descr[1]:='';
end;
end;
if (not wenttosysop) then
begin
nl;
done := FALSE;
if (ahangup) then
dbn := oldboard
else
repeat
prt('File base (?=List) ['+cstr(cfbase(oldboard))+'] : ');
input(s, 3);
dbn := afbase(value(s));
if (s = '?') then
begin
fbaselist(FALSE);
nl;
end
else
begin
if (s = '') then
dbn := oldboard;
if (not fbaseac(dbn)) or (not aacs(memuboard.ulacs)) or
(exist(memuboard.ulpath + fn)) or
(exist(memuboard.dlpath + fn)) then
begin
print('You cannot put it there.');
dbn := -1;
end;
end;
if (dbn <> -1) and (s <> '?') then
done := TRUE;
until ((done) or (hangup));
fileboard := dbn;
nl;
end
else
fileboard := general.tosysopdir;
UpFile(0);
end;
findnext(DirInfo);
end;
close(DirFile);
fileboard := oldboard;
initfileboard;
close(DirFile);
lil := 0;
dec(RefundTime, TakeAwayRefundTime);
dec(Freetime, TakeAwayRefundTime);
(*
nl;
star('Files uploaded : ' + cstr(totfils1)+' files.');
if (totfils<>totfils1) then
star('Files successful: ' + cstr(totfils)+' files.');
star('File size uploaded: ' + cstr(totb1)+' bytes.');
star('Batch upload time: ' + FormattedTime(TransferTime));
if (TotalConversionTime > 0) then
star('Total convert time: ' + FormattedTime(TotalConversionTime));
star('Transfer rate: ' + cstr(cps) + ' cps'^M^J);
star('Time refund: ' + FormattedTime(RefundTime));
*)
sysoplog('Transfer: '+cstr(totfils1)+' files, '+cstr(totb1)+
' bytes, '+cstr(cps)+ 'cps.');
inc(utoday, totfils);
inc(uktoday, totb div 1024);
if (aacs(general.ulvalreq)) or (general.ValidateAllFiles) then
begin
if (totpts<>0) then
star('File credits: ' + cstr(totpts) + ' pts.');
star('Upload credits: ' + cstr(totfils) + ' files, '+cstr(totb div 1024)+'k.'^M^J);
star('Thanks for the file' + plural(totfils) + ', '+thisuser.name+'!');
inc(thisuser.uploads, totfils);
AdjustBalance(-totpts);
inc(thisuser.uk, totb div 1024);
end
else
begin
print('^5Thanks for the file' + plural(totfils) + ', '+caps(thisuser.name)+'.');
prompt('^5You will receive ');
if (general.uldlratio) then
prompt('file credit')
else
prompt('credits');
print(' as soon as the SysOp validates the file' + plural(totfils) + '!');
end;
nl;
if (choptime <> 0) then begin
choptime := choptime + RefundTime - TakeAwayRefundTime;
freetime := freetime - RefundTime + TakeAwayRefundTime;
star('Sorry, no upload time refund may be given at this time.');
star('You will get your refund after the event.'^M^J);
end;
if (ahangup) then begin
status_screen(100,'Hanging up phone again...',false,s);
dophonehangup(FALSE);
hangup:=TRUE;
end;
saveurec(thisuser, usernum);
end;
procedure batchinfo;
begin
if (numbatchfiles<>0) then
print(^M^J'^9>> ^3You have ^5'+cstr(numbatchfiles)+
'^3 file'+aonoff(numbatchfiles<>1,'s','')+
' left in your download batch queue.');
if (numubatchfiles<>0) then
print(^M^J'^9>> ^3You have ^5'+cstr(numubatchfiles)+
'^3 file'+aonoff(numubatchfiles<>1,'s','')+
' left in your upload batch queue.');
end;
end.