Skip to content

Latest commit

 

History

History
549 lines (524 loc) · 19.5 KB

file10.pas

File metadata and controls

549 lines (524 loc) · 19.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
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 file10;
interface
uses
crt,dos,
{rcg11172000 no overlay under Linux.}
{overlay,}
myio,
file0, file1, file2, file4, file9,
common;
procedure move;
procedure editfiles;
procedure validatefiles;
implementation
uses
miscx;
procedure move;
var ff:file;
f,f1:ulfrec;
v:verbrec;
s,s1,s2,fl,fn:astr;
x,i:longint;
pl,rn,dbn,oldfileboard:integer;
c:char;
espace,nospace,done,abort,next,ok:boolean;
begin
nl;
print('Move files.');
gfn(fn); abort:=FALSE; next:=FALSE;
nl;
recno(fn,pl,rn);
if (baddlpath) then exit;
if (fn='') or (pos('.',fn)=0) or (rn=0) then
print('No matching files.')
else begin
lastcommandovr:=TRUE;
c:=#0;
while (rn<>0) and (pl<>0) and (rn<=pl) and
(not abort) and (not hangup) do begin
if (rn<>0) and (pl<>0) then begin
seek(ulff,rn); read(ulff,f);
if (c<>'?') then begin
nl;
fileinfo(f,FALSE,abort,next);
nl;
end;
if (next) then c:='N' else begin
prt('Move files (?=help) : '); onek(c,'QMN?'^M);
end;
case c of
^M:c:=#0; {* do nothing *}
'?':begin
nl;
print('<CR>Redisplay entry');
lcmds(10,3,'Move file','Next file');
lcmds(10,3,'Quit','');
nl;
end;
'M':begin
done:=FALSE;
nl;
repeat
prt('Move file (Q=Quit,?=List,#=Move-to base) : ');
input(s,3); dbn:=ccuboards[0][value(s)];
if (s='?') then begin fbaselist; nl; end else
if (s='Q') or ((dbn=0) and (s<>'0')) then done:=TRUE else
if (dbn<0) or (dbn>maxulb) then print('Can''t move it there.')
else begin
oldfileboard:=fileboard;
changefileboard(dbn);
if (fileboard=oldfileboard) then print('Can''t move it there.')
else begin
fileboard:=oldfileboard;
done:=TRUE;
nl;
loaduboard(fileboard);
fl:=memuboard.dlpath+f.filename;
s1:=fexpand(bslash(FALSE,memuboard.dlpath));
loaduboard(dbn);
sprint(#3#5+'Moving file ... to '+memuboard.name+#3#5);
s2:=fexpand(bslash(FALSE,memuboard.dlpath));
ok:=TRUE;
sprint(#3#5+'Orig-path : "'+s1+'" ('+cstrl(freek(exdrv(s1)))+'k free)');
sprint(#3#5+'Dest-path : "'+s2+'" ('+cstrl(freek(exdrv(s2)))+'k free)');
if (s1=s2) then begin
sprint(#3#7+'No move: directory paths are the same.');
espace:=TRUE;
ok:=TRUE;
end else
if (exist(fl)) then begin
espace:=TRUE;
assign(ff,fl);
{$I-}
reset(ff,1); i:=trunc(filesize(ff)/1024.0)+1;
close(ff);
{$I+}
x:=exdrv(memuboard.dlpath); (* uboards[dbn] *)
sprompt(#3#5+'Progress: ');
movefile(ok,nospace,TRUE,fl,
memuboard.dlpath+f.filename);
(* ^^^^^^^^^ uboards[dbn] *)
if (ok) then nl;
if (not ok) then begin
sprompt(#3#7+'Move failed');
if (not nospace) then nl else
sprompt(' - Insuffient space on drive '+chr(x+64)+':');
sprint('!');
end;
end else
print('File does not actually exist.');
if ((espace) and (ok)) or (not exist(fl)) then begin
sprompt(#3#5+'Moving file record ...');
deleteff(rn,pl,FALSE);
oldfileboard:=fileboard; fileboard:=dbn;
close(ulff); fiscan(pl);
if (baddlpath) then exit;
v.descr[1]:=#1#1#0#1#1;
newff(f,v); close(ulff);
fileboard:=oldfileboard;
fiscan(pl);
if (baddlpath) then exit;
sysoplog('Moved "'+sqoutsp(f.filename)+'" from Dir#'+
cstr(fileboard)+' to Dir#'+cstr(dbn));
end;
nl;
c:='N';
dec(rn); dec(lrn);
end;
end;
until ((done) or (hangup));
end;
end;
if (c<>'?') then nrecno(fn,pl,rn);
abort:=FALSE; next:=FALSE;
if (c='Q') then abort:=TRUE;
end;
end;
close(ulff);
end;
end;
procedure creditfile(var u:userrec; un:integer; var f:ulfrec; credit:boolean);
var rfpts:real;
gotpts:longint;
begin
if (not systat.fileptratio) then
gotpts:=0
else begin
rfpts:=(f.blocks/8)/systat.fileptcompbasesize;
gotpts:=round(rfpts*systat.fileptcomp);
if (gotpts<1) then gotpts:=1;
end;
if (credit) then
sprompt(#3#5+'Awarding upload credits: ')
else
sprompt(#3#5+'Taking away upload credits: ');
prompt('1 file, '+cstrl(f.blocks div 8)+'k');
if (credit) then begin
inc(u.uploads);
inc(u.uk,f.blocks div 8);
end else begin
dec(u.uploads);
dec(u.uk,f.blocks div 8);
end;
if (systat.fileptratio) then begin
prompt(', '+cstrl(gotpts)+' file points');
if (credit) then
inc(u.filepoints,gotpts)
else
dec(u.filepoints,gotpts);
end;
print('.');
saveurec(u,un);
if (un=usernum) then showudstats;
end;
procedure editfiles;
var ff:file;
u:userrec;
f,f1:ulfrec;
v:verbrec;
fn,fd,s,sel:astr;
fsize:longint;
pl,rn,i,x:integer;
c,c1:char;
dontshowlist,done,done2,abort,next:boolean;
begin
nl;
print('Edit files.');
gfn(fn); abort:=FALSE; next:=FALSE;
nl;
dontshowlist:=FALSE;
recno(fn,pl,rn);
if (baddlpath) then exit;
if (fn='') or (pos('.',fn)=0) or (rn=0) then
print('No matching files.')
else begin
lastcommandovr:=TRUE;
while (rn<>0) and (not abort) and (not hangup) do begin
if rn<>0 then begin
repeat
seek(ulff,rn); read(ulff,f);
abort:=FALSE; next:=FALSE;
if not dontshowlist then begin
nl;
fileinfo(f,TRUE,abort,next);
end else
dontshowlist:=FALSE;
nl;
abort:=FALSE;
if (next) then c:='N' else begin
prt('Edit files (?=help) : ');
onek(c,'Q?1234567CMRTVWN'^M); nl;
end;
case c of
'?':begin
sprint('1-7:Edit file record');
lcmds(16,3,'Next record','Change Uploader''s file points');
lcmds(16,3,'Verbose edit','Make request file');
lcmds(16,3,'Resume toggle','Toggle validation');
lcmds(16,3,'Withdraw credit','Quit');
dontshowlist:=TRUE;
end;
'1':begin
prt('New filename: '); mpl(12); input(fn,12);
if (fn<>'') then begin
if ((exist(memuboard.dlpath+fn)) and
(exist(memuboard.dlpath+sqoutsp(f.filename)))) then
print('Can''t use that filename.')
else begin
assign(ff,memuboard.dlpath+f.filename);
{$I-} rename(ff,memuboard.dlpath+fn); {$I+}
x:=ioresult;
f.filename:=align(fn);
end;
end;
end;
'2':begin
print('Enter new description');
prt(':'); mpl(60); inputl(s,60);
if s<>'' then f.description:=s;
end;
'3':begin
print('Change file size');
nl;
prt('Use which: [B]ytes [K]Bytes [X]modem-blocks :');
onek(c,'QBKX'^M);
if (c in ['B','K','X']) then begin
prt('New file size in ');
case c of
'B':prt('bytes: ');
'K':prt('Kbytes: ');
'X':prt('Xmodem blocks: ');
end;
mpl(8); input(s,8);
if (s<>'') then begin
val(s,fsize,x);
case c of
'B':f.blocks:=fsize div 128;
'K':f.blocks:=fsize*8;
'X':f.blocks:=fsize;
end;
end;
end;
end;
'4':begin
prt('New user name/# who uploaded it: '); finduser(s,x);
if (x=0) then print('This user does not exist.');
if (x<>0) then begin
f.owner:=x;
loadurec(u,x);
f.stowner:=allcaps(u.name);
end;
end;
'5':begin
prt('New upload file date: '); mpl(8); input(s,8);
if (s<>'') then begin f.date:=s; f.daten:=daynum(s); end;
end;
'6':begin
prt('New number of downloads: '); mpl(5); input(s,5);
if (s<>'') then f.nacc:=value(s);
end;
'7':begin
prt('Enter new amount of file points: '); mpl(5); input(s,5);
if (s<>'') then f.filepoints:=value(s);
end;
'C':begin
loadurec(u,f.owner);
print('Add/Subtract from Uploader''s file points.');
print('Current file points: '+cstr(u.filepoints));
nl;
prt('Change value: '); mpl(6); input(s,6);
if (s<>'') then begin
inc(u.filepoints,value(s));
saveurec(u,f.owner);
end;
end;
'M':with f do
if (isrequest in filestat) then filestat:=filestat-[isrequest]
else filestat:=filestat+[isrequest];
'R':with f do
if (resumelater in filestat) then filestat:=filestat-[resumelater]
else filestat:=filestat+[resumelater];
'T':begin
with f do
if (notval in filestat) then filestat:=filestat-[notval]
else filestat:=filestat+[notval];
loadurec(u,f.owner);
if (not aacs1(u,f.owner,systat.ulvalreq)) then
creditfile(u,f.owner,f,not (notval in f.filestat));
end;
'V':begin
if (f.vpointer=-1) then begin
print('There is no verbose entry for this file.');
if pynq('Create verbose entry? ') then begin
v.descr[1]:='';
f.vpointer:=nfvpointer;
assign(verbf,systat.gfilepath+'verbose.dat');
reset(verbf); seek(verbf,f.vpointer); write(verbf,v);
reset(verbf);
end;
end;
if (f.vpointer<>-1) then begin
dontshowlist:=FALSE;
repeat
if (not dontshowlist) then begin
nl;
verbfileinfo(f.vpointer,TRUE,abort,next);
reset(verbf); seek(verbf,f.vpointer); read(verbf,v);
nl;
end;
dontshowlist:=FALSE;
sel:=^M'Q?DP';
for x:=1 to 4 do begin
sel:=sel+chr(x+48);
if v.descr[x]='' then x:=4;
end;
prt('Verbose edit: (1-'+sel[length(sel)]+',D,P,?,Q) :');
onek(c1,sel); nl;
case c1 of
'?':begin
print('1-'+sel[length(sel)]+':Edit verbose line');
lcmds(20,3,'Delete this entry','Pointer value change');
lcmds(20,3,'Quit','');
nl;
dontshowlist:=TRUE;
end;
'1'..'4':
begin
prt('Enter new line:'); nl;
prt(':'); mpl(50); inputl(s,50);
if (s<>'') then begin
if (s=' ') then
if pynq('Set to NULL string? ') then s:='';
v.descr[ord(c1)-48]:=s;
if (c1=sel[length(sel)]) and (c1<>'4') then
v.descr[ord(c1)-47]:='';
{$I-} seek(verbf,f.vpointer); {$I+}
if (ioresult=0) then write(verbf,v);
end;
end;
'D':if pynq('Are you sure? ') then begin
v.descr[1]:='';
{$I-} seek(verbf,f.vpointer); {$I+}
if (ioresult=0) then write(verbf,v);
f.vpointer:=-1;
c1:='Q';
end;
'P':begin
print('Change pointer value.');
print('Pointer range: 0-'+cstr(filesize(verbf)-1));
print('(-1 makes inactive for this file without deleting any entries)');
nl;
prt('New pointer value: ');
mpl(5); input(s,10);
if (s<>'') then begin
val(s,i,x);
if ((i>=-1) and (i<=filesize(verbf)-1)) then
f.vpointer:=i;
end;
end;
end;
until (c1 in ['Q',' ',^M]) or (hangup) or (f.vpointer=-1);
{$I-} close(verbf); {$I+}
if (ioresult<>0) then print('Errors closing VERBOSE.DAT');
dontshowlist:=FALSE;
end;
end;
'W':begin
loadurec(u,f.owner);
sprint(#3#0+'WARNING: '+#3#5+'If you have already withdrawn credit');
sprint(#3#5+'from this user (or he never got it to begin with),');
sprint(#3#5+'the user will lose even MORE upload credit than');
sprint(#3#5+'they started out with!');
nl;
if pynq('Withdraw credit?? ') then
creditfile(u,f.owner,f,FALSE);
end;
else
next:=TRUE;
end;
seek(ulff,rn); write(ulff,f);
until (c in ['Q',' ']) or (hangup) or (next);
if (c='Q') then abort:=TRUE;
end;
nrecno(fn,pl,rn);
end;
close(ulff);
end;
end;
procedure validatefiles;
var i:integer;
c:char;
abort,next,isglobal,ispoints,isprompt:boolean;
procedure valfiles(b:integer; var abort,next:boolean);
var u:userrec;
f:ulfrec;
s:astr;
lng:longint;
oldboard,pl,rn:integer;
shownalready:boolean;
begin
oldboard:=fileboard;
if (fileboard<>b) then changefileboard(b);
if (fileboard=b) then begin
recno('*.*',pl,rn);
shownalready:=FALSE; abort:=FALSE; next:=FALSE;
while (rn<>0) and (not abort) and (not hangup) do begin
seek(ulff,rn); read(ulff,f);
if (notval in f.filestat) and
(not (resumelater in f.filestat)) then begin
if (not shownalready) then begin
nl;
sprint('Validating '+#3#5+memuboard.name+#3#5+' #'+
cstr(fileboard)); (*+#3#1+' ('+memuboard.dlpath+')');*)
nl;
shownalready:=TRUE;
end;
lng:=f.blocks; lng:=lng*128;
sprint('Filename : '+#3#3+'"'+f.filename+'"');
sprint('Description: '+#3#3+f.description);
sprint('Size/points: '+#3#5+cstrl(lng)+' bytes / '+
cstr(f.filepoints)+' pts');
sprint('UL''d by : '+#3#9+caps(f.stowner)+' #'+cstr(f.owner));
nl;
loadurec(u,f.owner);
if (isprompt) then begin
if (ispoints) then begin
prt('Points for file (<CR>=Skip,Q=Quit) : '); input(s,5);
if (s='Q') then abort:=TRUE;
if ((s<>'') and (s<>'Q')) then begin
f.filepoints:=value(s);
f.filestat:=f.filestat-[notval];
seek(ulff,rn); write(ulff,f);
if (not aacs1(u,f.owner,systat.ulvalreq)) then
creditfile(u,f.owner,f,TRUE);
prt('Points for '+#3#5+caps(f.stowner)+' #'+
cstr(f.owner)+#3#4+' (-999..999) : ');
input(s,5);
if (s<>'') then
if (f.owner=usernum) then
inc(thisuser.filepoints,value(s))
else begin
inc(u.filepoints,value(s));
saveurec(u,f.owner);
end;
end;
nl;
end else begin
repeat
ynq('Validate? (Y/N,V=View,Q=Quit) : '); onek(c,'QNVY');
case c of
'Q':abort:=TRUE;
'V':begin
abort:=FALSE; next:=FALSE;
lfi(sqoutsp(memuboard.dlpath+f.filename),abort,next);
abort:=FALSE; next:=FALSE;
end;
'Y':begin
f.filestat:=f.filestat-[notval];
seek(ulff,rn); write(ulff,f);
if (not aacs1(u,f.owner,systat.ulvalreq)) then
creditfile(u,f.owner,f,TRUE);
end;
end;
until ((c<>'V') or (hangup));
nl;
end;
end else begin
f.filestat:=f.filestat-[notval];
seek(ulff,rn); write(ulff,f);
if (not aacs1(u,f.owner,systat.ulvalreq)) then
creditfile(u,f.owner,f,TRUE);
end;
end;
nrecno('*.*',pl,rn);
wkey(abort,next);
end;
close(ulff);
end;
fileboard:=oldboard;
end;
begin
nl;
print('Validate files -');
nl;
ynq('Prompt for validation? (Y)es, (N)o, (P)oints validation : ');
onek(c,'QNPY');
if (c='Q') then exit;
ispoints:=(c='P');
isprompt:=(c<>'N');
isglobal:=pynq('Search all directories? ');
nl;
abort:=FALSE; next:=FALSE;
if (isglobal) then begin
i:=0;
while (i<=maxulb) and (not abort) and (not hangup) do begin
if (fbaseac(i)) then valfiles(i,abort,next);
inc(i);
wkey(abort,next);
if (next) then abort:=FALSE;
end;
end else
valfiles(fileboard,abort,next);
end;
end.