home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 189.img / TCS120S.ZIP / FILEXFER.PAS < prev    next >
Pascal/Delphi Source File  |  1989-04-06  |  63KB  |  2,252 lines

  1. {$R-,S-,I-,D-,F+,V-,B-,N-,O+ }
  2. {$M 65500,0,0 }
  3.  
  4. unit filexfer;
  5.  
  6. interface
  7.  
  8. uses crt,dos,
  9.      gentypes,configrt,modem,statret,gensubs,subs1,subs2,windows,
  10.      userret,mainr1,mainr2,overret1,protocol,mainmenu,subs3,textret;
  11.  
  12. procedure udsection;
  13.  
  14. implementation
  15.  
  16. procedure udsection;
  17.  
  18. var ud:udrec;
  19.   { area:arearec; }
  20.     curarea:integer;
  21.     offliney,vcr:boolean;
  22.     validprotos:set of char;
  23.     xtype:char;
  24.  
  25.   procedure beepbeep (ok:integer);
  26.   begin
  27.     delay (500);
  28.     write (^B^M);
  29.     case ok of
  30.       0:write ('Xfer completed!');
  31.       1:write ('Xfer Aborted just before EOF!');
  32.       2:write ('Xfer Aborted!')
  33.     end;
  34.     writeln (^G^M)
  35.   end;
  36.  
  37.   function unsigned (i:integer):real;
  38.   begin
  39.     if i>=0
  40.       then unsigned:=i
  41.       else unsigned:=65536.0+i
  42.   end;
  43.  
  44.   procedure writefreespace (path:lstr);
  45.   var drive:byte;
  46.       r:registers;
  47.       csize,free,total:real;
  48.   begin
  49.     r.ah:=$36;
  50.     r.dl:=ord(upcase(path[1]))-64;
  51.     intr ($21,r);
  52.     if r.ax=-1 then begin
  53.       writeln ('Invalid Drive!');
  54.       exit
  55.     end;
  56.     csize:=unsigned(r.ax)*unsigned(r.cx);
  57.     free:=csize*unsigned(r.bx);
  58.     total:=csize*unsigned(r.dx);
  59.     free:=free/1024;
  60.     total:=total/1024;
  61.     writeln (free:0:0,'k out of ',total:0:0,'k')
  62.   end;
  63.  
  64.   procedure seekafile (n:integer);
  65.   begin
  66.     seek (afile,n-1)
  67.   end;
  68.  
  69.   function numareas:integer;
  70.   begin
  71.     numareas:=filesize (afile)
  72.   end;
  73.  
  74.   procedure seekudfile (n:integer);
  75.   begin
  76.     seek (udfile,n-1)
  77.   end;
  78.  
  79.   function numuds:integer;
  80.   begin
  81.     numuds:=filesize (udfile)
  82.   end;
  83.  
  84.   procedure assignud;
  85.   begin
  86.     close (udfile);
  87.     assign (udfile,'AREA'+strr(curarea))
  88.   end;
  89.  
  90.   function sponsoron:boolean;
  91.   begin
  92.     sponsoron:=match(area.sponsor,unam) or issysop
  93.   end;
  94.  
  95.   function getapath:lstr;
  96.   var q,r:integer;
  97.       f:file;
  98.       b:boolean;
  99.       p:lstr;
  100.   begin
  101.     getapath:=area.xmodemdir;
  102.     if ulvl<sysoplevel then exit;
  103.     repeat
  104.       writestr ('Upload Path [CR/'+area.xmodemdir+']:');
  105.       if hungupon then exit;
  106.       if length(input)=0 then input:=area.xmodemdir;
  107.       p:=input;
  108.       if input[length(p)]<>'\' then p:=p+'\';
  109.       b:=true;
  110.       assign (f,p+'CON');
  111.       reset (f);
  112.       q:=ioresult;
  113.       close (f);
  114.       r:=ioresult;
  115.       if q<>0 then begin
  116.         writestr ('  Path doesn''t exist!  Create it [y/n]? *');
  117.         b:=yes;
  118.         if b then begin
  119.           mkdir (copy(p,1,length(p)-1));
  120.           q:=ioresult;
  121.           b:=q=0;
  122.           if b
  123.             then writestr ('Directory created')
  124.             else writestr ('Unable to create directory')
  125.         end
  126.       end
  127.     until b;
  128.     getapath:=p
  129.   end;
  130.  
  131.   function makearea:boolean;
  132.   var num,n:integer;
  133.       a:arearec;
  134.   begin
  135.     makearea:=false;
  136.     num:=numareas+1;
  137.     n:=numareas;
  138.     writestr ('Create Area '+strr(num)+' [y/n]? *');
  139.     if yes then begin
  140.       writestr ('Area Name: &');
  141.       if length(input)=0 then exit;
  142.       a.name:=input;
  143.       writestr ('Access Level:');
  144.       if length(input)=0 then exit;
  145.       a.level:=valu(input);
  146.       writestr ('Sponsor [CR/'+unam+']:');
  147.       if length(input)=0 then input:=unam;
  148.       a.sponsor:=input;
  149.     { writestr ('Entry Password [CR/None]:');
  150.       if length(input)=0 then a.areapw:='' else
  151.       a.areapw:=input; }
  152.       writestr ('Able to Upload into this area? [CR/Yes]:');
  153.       if (length(input)=0) or (upcase(input[1])='Y') then
  154.       a.upload:=true else a.upload:=false;
  155.       writestr ('Able to Download from this area? [CR/Yes]:');
  156.       if (length(input)=0) or (upcase(input[1])='Y') then
  157.       a.download:=true else a.download:=false;
  158.       a.xmodemdir:=getapath;
  159.       seekafile (num);
  160.       write (afile,a);
  161.       area:=a;
  162.       curarea:=num;
  163.       assignud;
  164.       rewrite (udfile);
  165.       writeln ('Area created');
  166.       makearea:=true;
  167.       writelog (15,4,a.name)
  168.     end
  169.   end;
  170.  
  171.   procedure setarea (n:integer);
  172.  
  173.     procedure nosucharea;
  174.     begin
  175.     { writeln (^B'No such area: ',n,'!'); }
  176.       writeln (^B'No such area!')
  177.     end;
  178.  
  179.   begin
  180.     curarea:=n;
  181.     if (n>numareas) or (n<1) then begin
  182.       nosucharea;
  183.       if issysop
  184.         then if makearea
  185.           then setarea (curarea)
  186.           else setarea (1)
  187.         else setarea (1);
  188.       exit
  189.     end;
  190.     seekafile (n);
  191.     read (afile,area);
  192.     if (urec.udlevel<area.level) and (not issysop)
  193.       then if curarea=1
  194.         then error ('User can''t access first area','','')
  195.         else
  196.           begin
  197.             nosucharea;
  198.             setarea (1);
  199.             exit
  200.           end;
  201.    { if length(area.areapw)>0 then begin
  202.      writeln;
  203.      writestr ('Entry Password:');
  204.      if length(input)=0 then exit;
  205.      if not match(input,area.areapw) then exit;
  206.     end; }
  207.     assignud;
  208.     close (udfile);
  209.     reset (udfile);
  210.     if ioresult<>0 then rewrite (udfile);
  211.     writeln (^B^M'Area: '^S,area.name,^R' ['^S,curarea,^R']');
  212.     { if sponsoron then writeln (^S'%: '^R'Sponsor Commands'); }
  213.     writeln
  214.   end;
  215.  
  216.   procedure listareas;
  217.   var a:arearec;
  218.       cnt,gaybee:integer;
  219.   begin
  220.    if exist (textfiledir+'Filearea.BBS') then
  221.    printfile (textfiledir+'Filearea.BBS') else
  222.    begin
  223.     writehdr ('File Area List');
  224.     seekafile (1);
  225.     writeln ('##. [Level] [Name]'^M);
  226.     for cnt:=1 to numareas do begin
  227.       read (afile,a);
  228.       if a.level<=urec.udlevel
  229.         then begin
  230.         write (^R,cnt:2,'. [');
  231.         write (^S,a.level);
  232.         for gaybee:=1 to (5-(length(strr(a.level)))) do
  233.          write (' ');
  234.         write (^R'] ['^S,a.name,^R']'^M);
  235.         end;
  236.       if break then exit
  237.     end
  238.    end
  239.   end;
  240.  
  241.   function getareanum:integer;
  242.   var areastr:sstr;
  243.       areanum:integer;
  244.   begin
  245.     getareanum:=0;
  246.     if length(input)>1
  247.       then areastr:=copy(input,2,255)
  248.       else begin
  249.         listareas;
  250.         repeat
  251.           writestr (^M'Area Number [?/List]:');
  252.           if input='?' then listareas else areastr:=input
  253.         until (input<>'?') or hungupon;
  254.       end;
  255.     if length(areastr)=0 then exit;
  256.     areanum:=valu(areastr);
  257.     if (areanum>0) and (areanum<=numareas)
  258.       then getareanum:=areanum
  259.       else begin
  260.         writestr ('No such area!');
  261.         if issysop then if makearea then getareanum:=numareas
  262.       end
  263.   end;
  264.  
  265.   procedure getarea;
  266.   var areanum:integer;
  267.   begin
  268.     areanum:=getareanum;
  269.     if areanum<>0 then setarea (areanum)
  270.   end;
  271.  
  272.   function getfname (path:lstr; name:mstr):lstr;
  273.   var l:lstr;
  274.   begin
  275.     l:=path;
  276.     if length(l)<>0
  277.       then if not (l[length(l)] in [':','\'])
  278.         then l:=l+'\';
  279.     l:=l+name;
  280.     getfname:=l
  281.   end;
  282.  
  283.   procedure getpathname (fname:lstr; var path:lstr; var name:sstr);
  284.   var p:integer;
  285.   begin
  286.     path:='';
  287.     repeat
  288.       p:=pos('\',fname);
  289.       if p<>0 then begin
  290.         path:=path+copy(fname,1,p);
  291.         fname:=copy(fname,p+1,255)
  292.       end
  293.     until p=0;
  294.     name:=fname
  295.   end;
  296.  
  297.   procedure listfile (n:integer; extended:boolean);
  298.   var ud:udrec;
  299.       q:sstr;
  300.       a,b,c,ed:string;
  301.   begin
  302.     seekudfile (n);
  303.     read (udfile,ud);
  304.     ansicolor (urec.statcolor);
  305.     tab (strr(n)+'.',4);
  306.     ansicolor (urec.promptcolor);
  307.     tab (ud.filename,14);
  308.     ansicolor (urec.inputcolor);
  309.     if ud.newfile
  310.       then write ('[New]  ')
  311.       else if ud.specialfile
  312.         then write ('[Ask]  ')
  313.         else if ud.points>0
  314.           then tab (strr(ud.points),7)
  315.           else write ('[Free] ');
  316.     ansicolor (urec.regularcolor);
  317.     if exist (getfname(ud.path,ud.filename)) then tab (strlong(ud.filesize),10) else
  318.      write ('[Offline] ');
  319.     ansicolor (urec.statcolor);
  320.     writeln (ud.descrip);
  321.     ansicolor (urec.regularcolor);
  322.     if break or (not extended) then exit;
  323.     write (^R'    ');
  324.     tab (datestr(ud.when),19);
  325.     ansicolor (urec.promptcolor);
  326.     tab (strr(ud.downloaded)+' D/L''s',13);
  327.     ansicolor (urec.inputcolor);
  328.     writeln (ud.sentby);
  329.     a:=copy (ud.extdesc,1,80);
  330.     ansicolor (urec.statcolor);
  331.     writeln (a);
  332.     if length(ud.extdesc)>80 then begin
  333.      b:=copy (ud.extdesc,81,80);
  334.      ansicolor (urec.statcolor);
  335.      writeln (b);
  336.     end;
  337.     if length(ud.extdesc)>160 then begin
  338.      c:=copy (ud.extdesc,161,80);
  339.      ansicolor (urec.statcolor);
  340.      writeln (c);
  341.     end;
  342.     ansicolor (urec.regularcolor);
  343.   end;
  344.  
  345.   function nofiles:boolean;
  346.   begin
  347.     if numuds=0 then begin
  348.       nofiles:=true;
  349.       writestr (^M'Sorry, no files!')
  350.     end else nofiles:=false
  351.   end;
  352.  
  353.   procedure listfiles (extended:boolean);
  354.   var cnt,max,r1,r2:integer;
  355.   const extendedstr:array[false..true] of string[9]=('','Extended ');
  356.   begin
  357.     if nofiles then exit;
  358.     writehdr (extendedstr[extended]+'File List');
  359.     max:=numuds;
  360.     thereare (max,'File','Files');
  361.     parserange (max,r1,r2);
  362.     if r1=0 then exit;
  363.     writeln (^S'#.'^P'  Filename'^U'      Points '^R'Size      '^S'Description'^R);
  364.     if (asciigraphics in urec.config) then
  365.      writeln ('───────────────────────────────────────────────────────────────────────────────')
  366.     else
  367.      writeln ('-------------------------------------------------------------------------------');
  368.     for cnt:=r1 to r2 do begin
  369.       listfile (cnt,extended);
  370.       if break then exit
  371.     end
  372.   end;
  373.  
  374.   function searchforfile (f:sstr):integer;
  375.   var ud:udrec;
  376.       cnt:integer;
  377.   begin
  378.     for cnt:=1 to numuds do begin
  379.       seekudfile (cnt);
  380.       read (udfile,ud);
  381.       if match(ud.filename,f) then begin
  382.         searchforfile:=cnt;
  383.         exit
  384.       end
  385.     end;
  386.     searchforfile:=0
  387.   end;
  388.  
  389.   function getfilenum (t:mstr):integer;
  390.   var n,s:integer;
  391.   begin
  392.     getfilenum:=0;
  393.     if length(input)>1 then input:=copy(input,2,255) else
  394.       repeat
  395.         writestr ('File Name/Number to '+t+' [?/List]:');
  396.         if hungupon or (length(input)=0) then exit;
  397.         if input='?' then begin
  398.           listfiles (false);
  399.           input:=''
  400.         end
  401.       until input<>'';
  402.     val (input,n,s);
  403.     if s<>0 then begin
  404.       n:=searchforfile(input);
  405.       if n=0 then begin
  406.         writeln ('File not found.');
  407.         exit
  408.       end
  409.     end;
  410.     if (n<1) or (n>numuds)
  411.       then writeln ('File number out of range!')
  412.       else getfilenum:=n
  413.   end;
  414.  
  415.   function allowxfer:boolean;
  416.   var cnt:baudratetype;
  417.       k:char;
  418.   begin
  419.     allowxfer:=false;
  420.    { if not carrier then begin
  421.       writeln ('You may only transfer from remote!');
  422.       exit
  423.     end; }
  424.     for cnt:=firstbaud to lastbaud do
  425.       if baudrate=baudarray[cnt]
  426.         then if not (cnt in downloadrates)
  427.           then begin
  428.             writeln ('Sorry, File Transfer is not allowed at ',baudrate,' Baud!');
  429.             exit
  430.           end;
  431.     if parity then begin
  432.       writeln ('Please select NO parity and press [Return]:');
  433.       parity:=false;
  434.       setparam (usecom,baudrate,parity);
  435.       repeat
  436.         k:=getchar;
  437.         if hungupon then exit
  438.       until k in [#13,#141];
  439.       if k=#141 then begin
  440.         parity:=true;
  441.         setparam (usecom,baudrate,parity);
  442.         writeln ('You did not turn off parity.  Transfer aborted.');
  443.         exit
  444.       end
  445.     end;
  446.     allowxfer:=true
  447.   end;
  448.  
  449.   procedure addfile (ud:udrec);
  450.   begin
  451.     seekudfile (numuds+1);
  452.     write (udfile,ud)
  453.   end;
  454.  
  455.   procedure getfsize (var ud:udrec);
  456.   var df:file of byte;
  457.   begin
  458.     ud.filesize:=-1;
  459.     assign (df,getfname(ud.path,ud.filename));
  460.     reset (df);
  461.     if ioresult<>0 then exit;
  462.     ud.filesize:=filesize(df);
  463.     close(df)
  464.   end;
  465.  
  466.   function wildcardmatch (w,f:sstr):boolean;
  467.   var a,b:sstr;
  468.  
  469.     procedure transform (t:sstr; var q:sstr);
  470.     var p:integer;
  471.  
  472.       procedure filluntil (k:char; n:integer);
  473.       begin
  474.         while length(q)<n do q:=q+k
  475.       end;
  476.  
  477.       procedure dopart (mx:integer);
  478.       var k:char;
  479.       begin
  480.         repeat
  481.           if p>length(t)
  482.             then k:='.'
  483.             else k:=t[p];
  484.           p:=p+1;
  485.           case k of
  486.             '.':begin
  487.                   filluntil (' ',mx);
  488.                   exit
  489.                 end;
  490.             '*':filluntil ('?',mx);
  491.             else if length(q)<mx then q:=q+k
  492.           end
  493.         until 0=1
  494.       end;
  495.  
  496.     begin
  497.       p:=1;
  498.       q:='';
  499.       dopart (8);
  500.       dopart (11)
  501.     end;
  502.  
  503.     function theymatch:boolean;
  504.     var cnt:integer;
  505.     begin
  506.       theymatch:=false;
  507.       for cnt:=1 to 11 do
  508.         if (a[cnt]<>'?') and (b[cnt]<>'?') and
  509.            (upcase(a[cnt])<>upcase(b[cnt])) then exit;
  510.       theymatch:=true
  511.     end;
  512.  
  513.   begin
  514.     transform (w,a);
  515.     transform (f,b);
  516.     wildcardmatch:=theymatch
  517.   end;
  518.  
  519.   const beenaborted:boolean=false;
  520.  
  521.   function aborted:boolean;
  522.   begin
  523.     if beenaborted then begin
  524.       aborted:=true;
  525.       exit
  526.     end;
  527.     aborted:=xpressed or hungupon;
  528.     if xpressed then begin
  529.       beenaborted:=true;
  530.       writeln (^B'File New-Scan Aborted!')
  531.     end
  532.   end;
  533.  
  534.   procedure getstring (t:lstr; var m);
  535.   var q:lstr absolute m;
  536.       mm:lstr;
  537.   begin
  538.     writeln ('Old ',t,': ',q);
  539.     writestr ('Enter new '+t+' [CR/no change]:');
  540.     mm:=input;
  541.     if length(mm)<>0 then q:=mm;
  542.     writeln
  543.   end;
  544.  
  545.   procedure getint (t:lstr; var i:integer);
  546.   var s:sstr;
  547.   begin
  548.     s:=strr(i);
  549.     getstring (t,s);
  550.     i:=valu(s)
  551.   end;
  552.  
  553.   procedure getboo (t:lstr; var b:boolean);
  554.   var s:sstr;
  555.   begin
  556.     s:=yesno (b);
  557.     getstring (t,s);
  558.     b:=upcase(s[1])='Y'
  559.   end;
  560.  
  561.   procedure removefile (n:integer);
  562.   var cnt:integer;
  563.   begin
  564.     for cnt:=n to numuds-1 do begin
  565.       seekudfile (cnt+1);
  566.       read (udfile,ud);
  567.       seekudfile (cnt);
  568.       write (udfile,ud)
  569.     end;
  570.     seekudfile (numuds);
  571.     truncate (udfile)
  572.   end;
  573.  
  574.   procedure displayfile (var ffinfo:searchrec);
  575.   var a:integer;
  576.   begin
  577.     a:=ffinfo.attr;
  578.     if (a and 8)=8 then exit;
  579.     tab (ffinfo.name,13);
  580.     if (a and 16)=16
  581.       then write ('Directory')
  582.       else write (ffinfo.size);
  583.     if (a and 1)=1 then write (' <read-only>');
  584.     if (a and 2)=2 then write (' <hidden>');
  585.     if (a and 4)=4 then write (' <system>');
  586.     writeln
  587.   end;
  588.  
  589.   function defaultdrive:byte;
  590.   var r:registers;
  591.   begin
  592.     r.ah:=$19;
  593.     intr ($21,r);
  594.     defaultdrive:=r.al+1
  595.   end;
  596.  
  597.   procedure directory;
  598.   var r:registers;
  599.       ffinfo:searchrec;
  600.       tpath:anystr;
  601.       b:byte;
  602.       cnt:integer;
  603.   begin
  604.     { getdir (defaultdrive,tpath); }
  605.     tpath:=area.xmodemdir;
  606.     if tpath[length(tpath)]<>'\' then tpath:=tpath+'\';
  607.     tpath:=tpath+'*.*';
  608.     writestr ('Path/Wildcard [CR/'+tpath+']:');
  609.     writeln (^M);
  610.     if length(input)<>0 then tpath:=input;
  611.     writelog (16,10,tpath);
  612.     findfirst (chr(defaultdrive+64)+':\*.*',8,ffinfo);
  613.     if doserror<>0
  614.       then writeln ('No volume label'^M)
  615.       else writeln ('Volume label: ',ffinfo.name,^M);
  616.     findfirst (tpath,$17,ffinfo);
  617.     if doserror<>0 then writeln ('No files found.') else begin
  618.       cnt:=0;
  619.       while doserror=0 do begin
  620.         cnt:=cnt+1;
  621.         if not break then displayfile (ffinfo);
  622.         findnext (ffinfo)
  623.       end;
  624.       writeln (^B^M'Total Files: ',cnt)
  625.     end;
  626.     write ('Free Disk Space: ');
  627.     writefreespace (tpath)
  628.   end;
  629.  
  630.   procedure listarchive;
  631.   var n:integer;
  632.       ud:udrec;
  633.       f:file of byte;
  634.       fname:lstr;
  635.       b,p:byte;
  636.       sg:boolean;
  637.       size:longint;
  638.       sussuh:sstr;
  639.       ock:char;
  640.  
  641.     function getsize:longint;
  642.     var x:longint;
  643.         b:array [1..4] of byte absolute x;
  644.         cnt:integer;
  645.     begin
  646.       for cnt:=1 to 4 do read (f,b[cnt]);
  647.       getsize:=x
  648.     end;
  649.  
  650.     procedure badarchive;
  651.     begin
  652.       writeln (^M'That file isn''t an archive!');
  653.       close (f);
  654.       exit
  655.     end;
  656.  
  657.   begin
  658.     if nofiles then exit;
  659.     n:=getfilenum('List');
  660.     if n=0 then exit;
  661.     seekudfile (n);
  662.     read (udfile,ud);
  663.     fname:=getfname(ud.path,ud.filename);
  664.     assign (f,fname);
  665.     reset (f);
  666.     iocode:=ioresult;
  667.     if iocode<>0 then begin
  668.       fileerror ('LISTARCHIVE',fname);
  669.       exit
  670.     end;
  671.     if filesize(f)<32 then begin
  672.       badarchive;
  673.       exit
  674.     end;
  675.     p:=pos ('.',ud.filename);
  676.     sussuh:=copy (ud.filename,p+1,3);
  677.     sussuh:=upstring(sussuh);
  678.     close (f);
  679.     writehdr ('ARC/PAK/ZIP File List');
  680.     writeln;
  681.     writeln (^R'Archive Type [Automatically Detected]:');
  682.     write (^R'-> '^S);
  683.     if sussuh='ARC' then writeln ('PKARC/PKPAK') else
  684.     if sussuh='PAK' then writeln ('PAK') else
  685.     if sussuh='ZIP' then writeln ('PKZIP') else
  686.     if sussuh='ZOO' then writeln ('ZOO');
  687.     if sussuh='ZOO' then begin
  688.      writeln (^R);
  689.      writeln ('TCS does not support ZOO archive viewing. Sorry.');
  690.      exit;
  691.     end;
  692.     if (sussuh<>'ARC') and (sussuh<>'PAK') and (sussuh<>'ZIP')  then begin
  693.      writeln ('None!');
  694.      writeln;
  695.      writeln (^R'This file does not seem to be an archive of the ARC, PAK, or ZIP type.');
  696.      writestr ('Would you care to manually select the archive type [y/n]? *');
  697.      if yes then repeat
  698.       writeln (^R'[1]: PKARC/PKPAK');
  699.       writeln (^R'[2]: PAK');
  700.       writeln (^R'[3]: PKZIP');
  701.       writeln (^R'[Q]: Quit');
  702.       writeln;
  703.       writestr ('Selection:');
  704.       ock:=upcase(input[1]);
  705.       if ock='1' then sussuh:='ARC' else
  706.       if ock='2' then sussuh:='PAK' else
  707.       if ock='3' then sussuh:='ZIP';
  708.      until ock in ['Q','1','2','3'];
  709.     end;
  710.     writeln;
  711.     writeln ('Please hold...');
  712.     writeln;
  713.     if sussuh='ARC' then arcview (fname) else
  714.     if sussuh='PAK' then pakview (fname) else
  715.     if sussuh='ZIP' then zipview (fname);
  716.   end;
  717.  
  718. procedure requestfile;
  719. var t:text;
  720.     me:message;
  721.     m:mailrec;
  722. begin
  723.   if hungupon then exit;
  724.   writestr (^M^J+'Filename to Request: *');
  725.   if length(input)=0 then exit;
  726.   writeln (^M^J+'Enter a Message regarding the File Request:');
  727.   delay (1000);
  728.   titlestr:='File Request: '+input;
  729.   sendstr:='Sysop';
  730.   m.line:=editor (me,false,'File Request: '+input);
  731.   sendstr:='';
  732.   if m.line<0 then exit;
  733.   m.anon:=false;
  734.   m.title:=titlestr;
  735.   m.sentby:=unam;
  736.   m.when:=now;
  737.   addfeedback (m);
  738. end;
  739.  
  740.   function isdsz (var thegog:char):boolean;
  741.   begin
  742.    isdsz:=thegog in ['Z','G','O','1','R','P'];
  743.   end;
  744.  
  745.   function issuperk (var whoasux:char):boolean;
  746.   begin
  747.    issuperk:=whoasux in ['S','E','K','W'];
  748.   end;
  749.  
  750.   procedure download (autoselect:integer);
  751.   var totaltime:sstr;
  752.       num,fsize,actualsize,mins,secs,i,b,dsziactualsize,realtime:integer;
  753.       ud:udrec;
  754.       fname,tcsrulez,protop,tran:lstr;
  755.       ymodem:boolean;
  756.       f:file;
  757.       m:sstr;
  758.       extrnproto:char;
  759.       n:text;
  760.       ok:boolean;
  761.   begin
  762.     if not allowxfer then exit;
  763.     if nofiles then exit;
  764.     if useqr then begin
  765.      calcqr;
  766.      if (qr<qrlimit) and (ulvl<qrexempt) then begin
  767.       writeln ('Your Quality Rating is '^S+strr(qr)+^R'.');
  768.       writeln ('That exceeds the limit of '^S+strr(qrlimit)+^R'!');
  769.       writeln ('You must get a better QR before you can download.');
  770.       exit;
  771.      end;
  772.      end;
  773.     if (area.download=false) then begin
  774.      writeln;
  775.      writeln ('Sorry, downloading is not allowed from this area!');
  776.      writeln;
  777.      exit;
  778.     end;
  779.     if autoselect=0
  780.       then num:=getfilenum('Download')
  781.       else num:=autoselect;
  782.     if num=0 then exit;
  783.     writeln;
  784.     seekudfile (num);
  785.     read (udfile,ud);
  786.     ok:=checkok (ud);
  787.     if not ok then exit;
  788.     ymodem:=false;
  789.     extrnproto:=' ';
  790.     writeln;
  791.     writeln (^S'       - TCS Xfer Protocols -');
  792.     writeln;
  793.     writeln (^R' ['^S'X'^R']-Xmodem            ['^S'Y'^R']-Ymodem ');
  794.     writeln (^R' ['^S'Z'^R']-Zmodem            ['^S'J'^R']-Jmodem');
  795.     writeln (^R' ['^S'L'^R']-Lynx             '^S'*'^R'['^S'G'^R']-Ymodem-G');
  796.     writeln (^R' ['^S'S'^R']-Super8k           ['^S'K'^R']-K9Xmodem');
  797.     writeln (^R' ['^S'R'^R']-Zmodem Recovery   ['^S'P'^R']-PCPursuit Zmodem');
  798.     writeln (^S'*'^R'['^S'O'^R']-Xmodem OvrThrust '^S'*'^R'['^S'1'^R']-Ymodem OvrThrust');
  799.     writeln (^S' * = '^R'Registered DSZ required');
  800.     writeln;
  801.     if hungupon then exit;
  802.     protop:='';
  803.     protop:='Protocol [Q/Quit][CR/';
  804.     if upcase(urec.defproto) in validprotos then
  805.     protop:=protop+upcase(urec.defproto) else
  806.     protop:=protop+'Z';
  807.     protop:=protop+']:';
  808.     writestr (protop);
  809.     if hungupon then exit;
  810.     tran:=input;
  811.     if length(tran)=0 then begin
  812.      if upcase (urec.defproto) in validprotos then
  813.      tran[1]:=urec.defproto else tran[1]:='Z';
  814.     end;
  815.     case upcase(tran[1]) of
  816.      'X' : begin
  817.             ymodem:=false;
  818.             extrnproto:='N';
  819.            end;
  820.      'Y' : begin
  821.             ymodem:=true;
  822.             extrnproto:='N';
  823.            end;
  824.      'Z' : extrnproto:='Z';
  825.      'J' : extrnproto:='J';
  826.      'L' : extrnproto:='L';
  827.      'G' : extrnproto:='G';
  828.      'O' : extrnproto:='O';
  829.      '1' : extrnproto:='1';
  830.      'S' : extrnproto:='S';
  831.      'K' : extrnproto:='K';
  832.      'R' : extrnproto:='R';
  833.      'P' : extrnproto:='P';
  834.      'Q' : exit;
  835.     end;
  836.     fname:=getfname(ud.path,ud.filename);
  837.     assign (f,fname);
  838.     reset (f);
  839.     iocode:=ioresult;
  840.     if iocode<>0 then
  841.       begin
  842.         fileerror ('DOWNLOAD',fname);
  843.         exit
  844.       end;
  845.     fsize:=filesize(f);
  846.     actualsize:=fsize;
  847.     close (f);
  848.     totaltime:=minstr(fsize);
  849.    {if baudrate=9600 then mins:=valu(copy(totaltime,1,pos(':',totaltime)-1 div 8));
  850.     if baudrate=2400 then mins:=valu(copy(totaltime,1,pos(':',totaltime)-1 div 2));
  851.     if baudrate=1200 then mins:=valu(copy(totaltime,1,pos(':',totaltime)-1));
  852.     if baudrate=300 then mins:=valu(copy(totaltime,1,pos(':',totaltime)-1 *4));}
  853.     mins:=valu(copy(totaltime,1,pos(':',totaltime)-1));
  854.     secs:=valu(copy(totaltime,pos(':',totaltime)+1,2));
  855.     realtime:=mins;
  856.     if secs<>0 then realtime:=mins+(secs div 60);
  857.     if mins=0 then mins:=1;
  858.   { mins:=valu(copy(totaltime,1,pos(':',totaltime)-1)); }
  859.     if ((mins>timeleft) and (not sponsoron)) then begin
  860.       writestr ('Sorry, you don''t have enough time left!');
  861.       mins:=-5;
  862.       exit
  863.     end;
  864.     if (mins-5>timetillevent) then begin
  865.       writestr ('Sorry, the timed event is coming up too soon!');
  866.       mins:=-5;
  867.       exit
  868.     end;
  869.     if (ansigraphics in urec.config) then write (#27+'[2J') else write (^L);
  870.     writeln (^B);
  871.     writeln (^R'┌─────────────────────────────────────┐');
  872.     write (^R'│ Filename:       '^S);
  873.     tab (ud.filename,20);
  874.     writeln (^R'│');
  875.     write (^R'│ Uploaded by:    '^S);
  876.     tab (ud.sentby,20);
  877.     writeln (^R'│');
  878.     write (^R'│ Downloaded:     '^S);
  879.     tcsrulez:='';
  880.     tcsrulez:=strr(ud.downloaded)+' time';
  881.     if (ud.downloaded<>1) then tcsrulez:=tcsrulez+'s';
  882.     tab (tcsrulez,20);
  883.     writeln (^R'│');
  884.     if ymodem then fsize:=(fsize+7) div 8;
  885.     if fsize=0 then fsize:=1;
  886.     write (^R'│ Blocks to send: '^S);
  887.     tab (strr(fsize),20);
  888.     writeln (^R'│');
  889.     write (^R'│ Transfer Time:  '^S);
  890.     tab (totaltime,20);
  891.     writeln (^R'│');
  892.     writeln (^R'├─────────────────────────────────────┤');
  893.     writeln (^R'│  Hit ['^S'Ctrl-X'^R'] a few times to Abort  │');
  894.     writeln (^R'└─────────────────────────────────────┘');
  895.     writeln (usr,^M^M'[-File Xfer Status-]');
  896.     writeln (usr,'[User '+unam+' Downloading '+ud.filename+' at ',baudrate,' Baud]');
  897.     writeln (usr,'[User D/L: ',urec.downloads,' downloads, '+streal(urec.downk)+
  898.     ' bytes] [User U/L: ',urec.uploads,' uploads, '+streal(urec.upk)+' bytes]'^M);
  899.     if extrnproto='N' then begin
  900.       b:=protocolxfer (true,false,ymodem,fname);
  901.       beepbeep (b)
  902.     end;
  903.     if extrnproto<>'N' then begin
  904.       b:=doext('S',extrnproto,ud.path,ud.filename,baudrate,usecom);
  905.       if b<>0 then b:=2;
  906.       modeminlock:=false;
  907.       beepbeep (b)
  908.     end;
  909.     if isdsz (extrnproto) then begin
  910.       xtype:=checkdszlog (getfname(ud.path,ud.filename));
  911.       if (upcase(xtype)='Q') and (leechzmodem) then
  912.       begin
  913.        possiblelzm (ud.points);
  914.        b:=2;
  915.       end;
  916.       if (upcase(xtype)='E') or (upcase(xtype)='L') then b:=2;
  917.       end;
  918.     if issuperk (extrnproto) then begin
  919.     { ztype:=checksklog (getfname(ud.path,ud.filename));
  920.       if (upcase(ztype)='R') and (leechzmodem) then
  921.       begin
  922.        possiblelzm (ud.points);
  923.        b:=2;
  924.       end;
  925.       if (upcase(ztype)='E') or (upcase(ztype)='L') then b:=2; }
  926.     end;
  927.       if (b=0) or (b=1) then begin
  928.       writelog (15,1,fname);
  929.       ud.downloaded:=ud.downloaded+1;
  930.       urec.downloads:=urec.downloads+1;
  931.       urec.downk:=urec.downk+ud.filesize;
  932.       seekudfile (num);
  933.       write (udfile,ud);
  934.     { if (ud.points>0) and (not sponsoron) then } begin
  935.        write ('File Pts. you have ');
  936.        if (asciigraphics in urec.config) then write ('─') else write ('-');
  937.        writeln ('> '^S,urec.udpoints,^R);
  938.        urec.udpoints:=urec.udpoints-ud.points;
  939.        write ('Cost of File ');
  940.        if ascii then
  941.        write ('───────') else
  942.        write ('-------');
  943.        writeln ('> '^S,ud.points,^R);
  944.        write ('                      ');
  945.        if (asciigraphics in urec.config) then
  946.        writeln ('───────') else
  947.        writeln ('-------');
  948.        write ('You now have ');
  949.        if (asciigraphics in urec.config) then
  950.        write ('───────') else
  951.        write ('-------');
  952.        writeln ('> '^S,urec.udpoints,^R^M);
  953.       end;
  954.       writeurec
  955.     end;
  956.    if b=2 then begin
  957.  
  958.    end;
  959.   end;
  960.  
  961.   procedure typefile;
  962.   var num:integer;
  963.       ud:udrec;
  964.       fname:lstr;
  965.       f:text;
  966.       k:char;
  967.   begin
  968.     if nofiles then exit;
  969.     num:=getfilenum('type');
  970.     if num=0 then exit;
  971.     writeln;
  972.     seekudfile (num);
  973.     read (udfile,ud);
  974.     if (not sponsoron) and (ud.points>urec.udpoints) then begin
  975.       writeln ('Sorry, that file requires ',ud.points,' points.');
  976.       exit
  977.     end;
  978.     if (ud.newfile) and (not sponsoron) then begin
  979.       writeln ('Sorry, that is a new file and must be validated.');
  980.       exit
  981.     end;
  982.     if (ud.specialfile) and (not sponsoron) then begin
  983.       writeln ('Sorry, downloading that file requires special permission.');
  984.       exit
  985.     end;
  986.     if (length(ud.dlpw)>0) and (filepw) then begin
  987.      writeln;
  988.      writestr ('File Password:');
  989.      if length(input)=0 then exit else
  990.      if not match(input,ud.dlpw) then exit;
  991.     end;
  992.     if tempsysop then begin
  993.       ulvl:=regularlevel;
  994.       tempsysop:=false;
  995.       writeurec;
  996.       bottomline
  997.     end;
  998.     fname:=getfname(ud.path,ud.filename);
  999.     assign (f,fname);
  1000.     reset (f);
  1001.     iocode:=ioresult;
  1002.     if iocode<>0 then
  1003.       begin
  1004.         fileerror ('TYPEFILE',fname);
  1005.         exit
  1006.       end;
  1007.     writeln (^B^M'Filename:       '^S,ud.filename);
  1008.     writeln ('Uploaded by:    '^S,ud.sentby);
  1009.     if (ud.points>0) and (not sponsoron) then begin
  1010.       write (^B^M'NOTE: When the transfer begins, you ',
  1011.                ^M'      will be charged ',ud.points,' point');
  1012.       if ud.points<>1 then write ('s');
  1013.       writeln ('!')
  1014.     end;
  1015.     writeln (^B^M'Press any key to begin the transfer,',
  1016.                ^M'or [Ctrl-X] to abort...'^M);
  1017.     k:=waitforchar;
  1018.     if (k=^X) or (upcase(k)='X') then begin
  1019.       textclose (f);
  1020.       writeln (^B^M'Aborted!');
  1021.       exit
  1022.     end;
  1023.     while not (eof(f) or break) do begin
  1024.       read (f,k);
  1025.       if k=^M then writeln else if k<>^J then write (k)
  1026.     end;
  1027.     textclose (f);
  1028.     if (ud.points>0) and (not sponsoron) then begin
  1029.       urec.udpoints:=urec.udpoints-ud.points;
  1030.       writeln (^B'You now have ',
  1031.                numthings (urec.udpoints,'point','points'),'.')
  1032.     end;
  1033.     writeurec
  1034.   end;
  1035.  
  1036.   function getextdesc:string;
  1037.   var nappa:string[255];
  1038.       a,b,c:string;
  1039.       extdone:boolean;
  1040.       finalcut:integer;
  1041.   begin
  1042.    getextdesc:='';
  1043.    nappa:='';
  1044.    extdone:=false;
  1045.    finalcut:=0;
  1046.    writeln (^P'Extended Description 3 Lines Max - Hit [CR] to end (Wordwrap Active)'^R);
  1047.    writeln (^P'[--------|---------|---------|---------|---------|---------|---------|--------]'^R);
  1048.    repeat
  1049.     buflen:=80;
  1050.     wordwrap:=true;
  1051.     getstr (1);
  1052.     finalcut:=finalcut+1;
  1053.     if finalcut>2 then extdone:=true;
  1054.     if length(input)<1 then extdone:=true else
  1055.     nappa:=nappa+input;
  1056.    until extdone;
  1057.    wordwrap:=false;
  1058.    getextdesc:=nappa;
  1059.   end;
  1060.  
  1061.   procedure upload;
  1062.   var ud:udrec;
  1063.       ok,crcmode,ymodem,extdone:boolean;
  1064.       i,b,granted:integer;
  1065.       fn,protop,tran:lstr;
  1066.       extrnproto,modecode:char;
  1067.       m:minuterec;
  1068.       e1,e2,e3:lstr;
  1069.       h1,h2,m1,m2,s1,s2,ss1,ss2:word;
  1070.       asdf,zxcv:integer;
  1071.   begin
  1072.     if not allowxfer then exit;
  1073.     if timetillevent<30 then begin
  1074.       writestr (
  1075.    'Sorry, uploads are not allowed within one half hour of the timed event!');
  1076.       exit
  1077.     end;
  1078.     if area.upload=false then begin
  1079.      writeln;
  1080.      writeln ('Sorry, uploading is not allowed into this area!');
  1081.      writeln;
  1082.      exit;
  1083.     end;
  1084.     ok:=false;
  1085.     write ('Free Disk Space: ');
  1086.     writefreespace (area.xmodemdir);
  1087.     writeln;
  1088.     repeat
  1089.      writestr ('Upload Filename:');
  1090.      if length(input)=0 then exit;
  1091.      if not validfname(input) then begin
  1092.       writeln ('Invalid filename!');
  1093.       exit
  1094.      end;
  1095.      ud.filename:=input;
  1096.      ud.path:=area.xmodemdir;
  1097.      fn:=getfname(ud.path,ud.filename);
  1098.      if hungupon then exit;
  1099.      if exist(fn) then writeln ('File already exists!') else ok:=true
  1100.     until ok;
  1101.     if filepw then begin
  1102.      writestr ('File Password [CR/None]: &');
  1103.      if length(input)=0 then write ('') else ud.dlpw:=input;
  1104.     end else
  1105.     ud.dlpw:='';
  1106.     writestr ('Description of Upload: &');
  1107.     ud.descrip:=input;
  1108.     ud.extdesc:=getextdesc;
  1109.     crcmode:=false;
  1110.     ymodem:=false;
  1111.     extrnproto:='N';
  1112.     writeln;
  1113.     writeln (^S'       - TCS Xfer Protocols -');
  1114.     writeln;
  1115.     writeln (^R' ['^S'X'^R']-Xmodem            ['^S'Y'^R']-Ymodem ');
  1116.     writeln (^R' ['^S'Z'^R']-Zmodem            ['^S'J'^R']-Jmodem');
  1117.     writeln (^R' ['^S'L'^R']-Lynx             '^S'*'^R'['^S'G'^R']-Ymodem-G');
  1118.     writeln (^R' ['^S'S'^R']-Super8k           ['^S'K'^R']-K9Xmodem');
  1119.     writeln (^R' ['^S'R'^R']-Zmodem Recovery   ['^S'P'^R']-PCPursuit Zmodem');
  1120.     writeln (^S'*'^R'['^S'O'^R']-Xmodem OvrThrust '^S'*'^R'['^S'1'^R']-Ymodem OvrThrust');
  1121.     writeln (^R' ['^S'E'^R']-Lynx Recovery     ');
  1122.     writeln (^S' * = '^R'Registered DSZ required');
  1123.     writeln;
  1124.     if hungupon then exit;
  1125.     protop:='';
  1126.     protop:='Protocol [Q/Quit][CR/';
  1127.     if upcase(urec.defproto) in validprotos then
  1128.     protop:=protop+upcase(urec.defproto) else
  1129.     protop:=protop+'Z';
  1130.     protop:=protop+']:';
  1131.     writestr (protop);
  1132.     if hungupon then exit;
  1133.     tran:=input;
  1134.     if length(tran)=0 then begin
  1135.      if upcase (urec.defproto) in validprotos then
  1136.      tran[1]:=urec.defproto else tran[1]:='Z';
  1137.     end;
  1138.     case upcase(tran[1]) of
  1139.      'X' : ymodem:=false;
  1140.      'Y' : ymodem:=true;
  1141.      'Z' : extrnproto:='Z';
  1142.      'J' : extrnproto:='J';
  1143.      'L' : extrnproto:='L';
  1144.      'G' : extrnproto:='G';
  1145.      'O' : extrnproto:='O';
  1146.      '1' : extrnproto:='1';
  1147.      'S' : extrnproto:='S';
  1148.      'K' : extrnproto:='K';
  1149.      'R' : extrnproto:='R';
  1150.      'P' : extrnproto:='P';
  1151.      'E' : extrnproto:='E';
  1152.      'Q' : exit;
  1153.     end;
  1154.     if extrnproto='N' then crcmode:=true;
  1155.     write (^B^M);
  1156.     ansicolor (urec.statcolor);
  1157.     if extrnproto='Z' then write ('Z');
  1158.     if extrnproto='J' then write ('J');
  1159.     if extrnproto='K' then write ('K9X');
  1160.     if extrnproto='R' then write ('Recovery Z');
  1161.     if extrnproto='P' then write ('PCPursuit Z');
  1162.     if ymodem then write ('Y') else if extrnproto='N' then write ('X');
  1163.     if extrnproto in ['Z','J','W','X','K','N'] then write ('modem') else
  1164.     begin
  1165.      if extrnproto='L' then write ('Lynx');
  1166.      if extrnproto='E' then write ('Lynx Crash Recovery');
  1167.      if extrnproto='G' then write ('Ymodem-G');
  1168.      if extrnproto='O' then write ('Xmodem OverThruster');
  1169.      if extrnproto='1' then write ('Ymodem OverThruster');
  1170.      if extrnproto='S' then write ('Super8k');
  1171.     end;
  1172.     if crcmode then write ('-CRC');
  1173.     writeln (^R' receive ready.  '^M'Hit [Ctrl-X]-[Ctrl-X]-[Enter] a few times to abort');
  1174.     writeln (usr,^M^M'[-File Xfer Status-]');
  1175.     writeln (usr,'[User '+unam+' Uploading '+ud.filename+' at ',baudrate,' Baud]');
  1176.     writeln (usr,'[User D/L: ',urec.downloads,' downloads, '+streal(urec.downk)+
  1177.     ' bytes] [User U/L: ',urec.uploads,' uploads, '+streal(urec.upk)+' bytes]'^M);
  1178.     if tempsysop then begin
  1179.       ulvl:=regularlevel;
  1180.       tempsysop:=false;
  1181.       writeurec;
  1182.       bottomline
  1183.     end;
  1184.     starttimer (m);
  1185.     gettime (h1,m1,s1,ss1);
  1186.     if extrnproto='N' then begin
  1187.       b:=protocolxfer (false,crcmode,ymodem,fn);
  1188.       beepbeep (b)
  1189.     end;
  1190.     if extrnproto<>'N' then begin
  1191.       b:=doext('R',extrnproto,ud.path,ud.filename,baudrate,usecom);
  1192.       modeminlock:=false;
  1193.       modemoutlock:=false;
  1194.       beepbeep (b)
  1195.     end;
  1196.     stoptimer (m);
  1197.     gettime (h2,m2,s2,ss2);
  1198.     if b=0 then begin
  1199.       writelog (15,2,ud.filename);
  1200.       buflen:=40;
  1201.       if ups>32760 then ups:=0;
  1202.       ups:=ups+1;
  1203.       ud.sentby:=unam;
  1204.       ud.when:=now;
  1205.       ud.whenrated:=now;
  1206.       ud.points:=0;
  1207.       ud.downloaded:=0;
  1208.       ud.newfile:=true;
  1209.       ud.specialfile:=false;
  1210.       ud.downloaded:=0;
  1211.       getfsize (ud);
  1212.       addfile (ud);
  1213.       urec.uploads:=urec.uploads+1;
  1214.       urec.upk:=urec.upk+ud.filesize;
  1215.       newuploads:=newuploads+1;
  1216.       writeurec;
  1217.       modecode:=checkdszlog (ud.filename);
  1218.       if useqr then begin
  1219.        calcqr;
  1220.        writeln;
  1221.        writeln (^R'Your Quality Rating is now '^S,qr,^R'.');
  1222.       end;
  1223.      if (ulpercent>0) and (not aborted) then begin
  1224.        asdf:=0;
  1225.        if h1<>h2 then asdf:=asdf+((h1-h2)*60);
  1226.        zxcv:=m2-m1;
  1227.        asdf:=asdf+zxcv;
  1228.        granted:=asdf;
  1229.        granted:=granted*((ulpercent) div 100);
  1230.        writeln ('Granting upload time compensation of '^S,granted,^R' minutes.');
  1231.        urec.timetoday:=urec.timetoday+granted;
  1232.        writeurec;
  1233.       end;
  1234.     end;
  1235.   end;
  1236.  
  1237.   procedure newscan;
  1238.   var cnt,aka:integer;
  1239.       u:udrec;
  1240.       gnuwarez,done:boolean;
  1241.       c:char;
  1242.   begin
  1243.     vcr:=false;
  1244.     gnuwarez:=false;
  1245.     beenaborted:=false;
  1246.     aka:=0;
  1247.     repeat
  1248.     for cnt:=1 to filesize(udfile) do begin
  1249.       if aborted then exit;
  1250.       seekudfile (cnt);
  1251.       read (udfile,u);
  1252.       if (u.whenrated>laston) or (u.when>laston)
  1253.         then begin
  1254.          aka:=aka+1;
  1255.          if aka=1 then begin
  1256.           ansicls;
  1257.           writeln (^R'Newscan Area ['^S,curarea,^R']-['^S,area.name,^R']');
  1258.           writeln;
  1259.          end;
  1260.          listfile (cnt,false);
  1261.          gnuwarez:=true;
  1262.         end;
  1263.        end;
  1264.     if not gnuwarez then done:=true else done:=false;
  1265.     if gnuwarez then begin
  1266.        write (^M^P'Option: ['^S'D'^P']ownload ['^S'A'^P']gain ['^S'+'^P']Add to Batch ['^S'V'^P']iew File ['+
  1267.        ^S'Q'^P']uit ['^S'CR'^P']Continue: ');
  1268.        writestr ('*');
  1269.        c:=upcase(input[1]);
  1270.        if length(input)=0 then done:=true else
  1271.        case c of
  1272.         'D':begin
  1273.              writeln;
  1274.              download (0);
  1275.              writestr (^M'Press [Return]:');
  1276.              aka:=0;
  1277.             end;
  1278.         'A':begin
  1279.              done:=false;
  1280.              aka:=0;
  1281.             end;
  1282.         '+':begin
  1283.              addtobatch (0);
  1284.              aka:=0;
  1285.             end;
  1286.         'V':begin
  1287.              writeln;
  1288.              listarchive;
  1289.              writestr (^M'Press [Return]:');
  1290.              aka:=0;
  1291.             end;
  1292.         'Q':begin
  1293.              vcr:=true;
  1294.              exit;
  1295.             end;
  1296.         'C':done:=true;
  1297.        end;
  1298.       end;
  1299.     until done;
  1300.   end;
  1301.  
  1302.   procedure searchfile;
  1303.   var cnt:integer;
  1304.       searchall:boolean;
  1305.       wildcard:sstr;
  1306.       a:arearec;
  1307.  
  1308.     procedure searcharea;
  1309.     var cnt:integer;
  1310.         u:udrec;
  1311.     begin
  1312.       for cnt:=1 to numuds do begin
  1313.         seekudfile (cnt);
  1314.         read (udfile,u);
  1315.         if wildcardmatch (wildcard,u.filename) then listfile (cnt,false);
  1316.         if xpressed then exit
  1317.       end
  1318.     end;
  1319.  
  1320.   begin
  1321.     writestr (^M'Search all areas [y/n]? *');
  1322.     searchall:=yes;
  1323.     writeln ('Filename to search for (wildcards are ok):');
  1324.     writestr ('-> *');
  1325.     if length(input)=0 then exit;
  1326.     wildcard:=input;
  1327.     if not searchall then begin
  1328.       searcharea;
  1329.       exit
  1330.     end;
  1331.     for cnt:=1 to numareas do begin
  1332.       seekafile (cnt);
  1333.       read (afile,a);
  1334.       if urec.udlevel>=a.level then begin
  1335.         setarea (cnt);
  1336.         searcharea;
  1337.         if xpressed then exit
  1338.       end
  1339.     end
  1340.   end;
  1341.  
  1342.   procedure yourudstatus;
  1343.   var u,d:lstr;
  1344.   begin
  1345.     u:='';
  1346.     d:='';
  1347.     writeln (^B'╒════════════════════════════════════════════╕');
  1348.     write ('│ File Xfer Level: '^S);
  1349.     tab (strr(urec.udlevel),26);
  1350.     writeln (^R'│');
  1351.     write ('│ Transfer Points: '^S);
  1352.     tab (strr(urec.udpoints),26);
  1353.     writeln (^R'│');
  1354.     write ('│ Uploaded:        '^S);
  1355.     u:=strr(urec.uploads)+' times, '+streal(urec.upk)+' bytes';
  1356.     tab (u,26);
  1357.     writeln (^R'│');
  1358.     write ('│ Downloaded:      '^S);
  1359.     d:=strr(urec.downloads)+' times, '+streal(urec.downk)+' bytes';
  1360.     tab (d,26);
  1361.     writeln (^R'│');
  1362.     if useqr then begin
  1363.      calcqr;
  1364.      write (^R'│ Quality Rating:  '^S);
  1365.      tab (strr(qr),26);
  1366.      writeln (^R'│');
  1367.     end;
  1368.     writeln (^B'╘════════════════════════════════════════════╛');
  1369.   end;
  1370.  
  1371.   procedure newscanall;
  1372.   var cnt:integer;
  1373.       a:arearec;
  1374.   begin
  1375.     writehdr ('[New-Scanning - Press (X) to Abort]');
  1376.     beenaborted:=false;
  1377.     if aborted then exit;
  1378.     for cnt:=1 to filesize(afile) do begin
  1379.       seekafile (cnt);
  1380.       read (afile,a);
  1381.       if urec.udlevel>=a.level then begin
  1382.         if aborted then exit;
  1383.         setarea (cnt);
  1384.         if aborted or vcr then exit;
  1385.         newscan
  1386.       end;
  1387.       if aborted then exit
  1388.     end;
  1389.    writeln (^B^M'[Xfer Newscan complete!]'^G);
  1390.   end;
  1391.  
  1392.   procedure addresidentfile (fname:lstr);
  1393.   var ud:udrec;
  1394.       ccr:lstr;
  1395.   begin
  1396.     getpathname (fname,ud.path,ud.filename);
  1397.     getfsize(ud);
  1398.     if ud.filesize=-1 then begin
  1399.      if not offliney then begin
  1400.       writeln ('File can''t be opened!');
  1401.       exit
  1402.      end;
  1403.     end;
  1404.     writestr ('Point Value:');
  1405.     if length(input)=0 then input:='0';
  1406.     ud.points:=valu(input);
  1407.     writestr ('Sent by [CR/'+unam+']: &');
  1408.     if length(input)=0 then input:=unam;
  1409.     ud.sentby:=input;
  1410.     ud.when:=now;
  1411.     ud.whenrated:=now;
  1412.     ud.downloaded:=0;
  1413.     writestr ('Description: &');
  1414.     ud.descrip:=input;
  1415.     ud.extdesc:=getextdesc;
  1416.     if filepw then begin
  1417.      writestr ('File Password [CR/None]: &');
  1418.      if length(input)=0 then ud.dlpw:='' else
  1419.      ud.dlpw:=input;
  1420.     end else
  1421.     ud.dlpw:='';
  1422.     writestr ('Special Request only [Ask]? *');
  1423.     ud.specialfile:=yes;
  1424.     ud.newfile:=false;
  1425.     addfile (ud);
  1426.     ups:=ups+1;
  1427.     urec.uploads:=urec.uploads+1;
  1428.     if ud.filesize>-1 then
  1429.     urec.upk:=urec.upk+ud.filesize;
  1430.     writeurec;
  1431.     writelog (16,8,fname)
  1432.   end;
  1433.  
  1434.   procedure sysopadd;
  1435.   var fn,fnm,fp:lstr;
  1436.   begin
  1437.     if ulvl<sysoplevel then begin
  1438.       writeln
  1439.         ('Sorry, you may not add resident files without true sysop access!');
  1440.       exit
  1441.     end;
  1442.     writehdr ('Add Resident File');
  1443.     writestr ('Filename:');
  1444.     fnm:=input;
  1445.     writestr ('Path of File [CR/'+area.xmodemdir+']:');
  1446.     fp:=input;
  1447.     if length(fp)=0 then fp:=area.xmodemdir;
  1448.     if fp[length(fp)]<>'\' then fp:=fp+'\';
  1449.     fn:=fp+fnm;
  1450.     if exist(fn)
  1451.       then
  1452.         begin
  1453.           writestr ('Confirm: '+fn+' [y/n]:');
  1454.           if yes then addresidentfile (fn)
  1455.         end
  1456.       else begin
  1457.        writeln ('File not found!');
  1458.        if length(fn)=0 then exit;
  1459.        writestr ('Add it as [Offline] (y/n)? *');
  1460.        if yes then begin
  1461.         offliney:=true;
  1462.         addresidentfile (fn);
  1463.         offliney:=false;
  1464.        end else exit;
  1465.      end;
  1466.   end;
  1467.  
  1468.   procedure addmultiplefiles;
  1469.   var spath,pathpart:lstr;
  1470.       dummy:sstr;
  1471.       f:file;
  1472.       ffinfo:searchrec;
  1473.   begin
  1474.     if ulvl<sysoplevel then begin
  1475.       writeln (
  1476.         'Sorry, you may not add resident files without true sysop access!');
  1477.       exit
  1478.     end;
  1479.     writehdr ('Add Resident Files By Wildcard');
  1480.     writestr ('Search path/wildcard:');
  1481.     if length(input)=0 then exit;
  1482.     spath:=input;
  1483.     if spath[length(spath)]='\' then dec(spath[0]);
  1484.     assign (f,spath+'\con');
  1485.     reset (f);
  1486.     if ioresult=0 then begin
  1487.       close (f);
  1488.       spath:=spath+'\*.*'
  1489.     end;
  1490.     getpathname (spath,pathpart,dummy);
  1491.     findfirst (spath,$17,ffinfo);
  1492.     if doserror<>0
  1493.       then writeln ('No files found!')
  1494.       else
  1495.         while doserror=0 do begin
  1496.           writeln;
  1497.           displayfile (ffinfo);
  1498.           writestr ('Add this file [Y/N/X]? *');
  1499.           if yes
  1500.             then addresidentfile (getfname(pathpart,ffinfo.name))
  1501.             else if (length(input)>0) and (upcase(input[1])='X')
  1502.               then exit;
  1503.           findnext (ffinfo)
  1504.         end
  1505.   end;
  1506.  
  1507.   procedure changef;
  1508.   var n,q:integer;
  1509.       ud:udrec;
  1510.  
  1511.     procedure showudrec (var ud:udrec);
  1512.     var a,b,c:string;
  1513.     begin
  1514.       with ud do
  1515.         writeln(^M^J'     Filename: '^S,ud.filename,
  1516.                 ^M^J'         Path: '^S,ud.path,
  1517.                 ^M^J'         Size: '^S,ud.filesize,
  1518.                 ^M^J'       Points: '^S,ud.points,
  1519.                 ^M^J'  Description: '^S,ud.descrip,
  1520.                 ^M^J' # Downloaded: '^S,ud.downloaded,
  1521.                 ^M^J'      Unrated: '^S,yesno(ud.newfile),
  1522.                 ^M^J'  Special Ask: '^S,yesno(ud.specialfile),
  1523.                 ^M^J'      Sent by: '^S,sentby,
  1524.                 ^M^J'      Sent on: '^S,datestr(when),
  1525.                 ^M^J'      Sent at: '^S,timestr(when));
  1526.         if filepw then begin
  1527.          write ('File Password: '^S);
  1528.          if length(ud.dlpw)<1 then writeln ('NONE') else
  1529.          writeln (ud.dlpw);
  1530.         end;
  1531.         writeln ('Extended Desc: '^S);
  1532.     a:=copy (ud.extdesc,1,80);
  1533.     ansicolor (urec.statcolor);
  1534.     writeln (a);
  1535.     if length(ud.extdesc)>80 then begin
  1536.      b:=copy (ud.extdesc,81,80);
  1537.      ansicolor (urec.statcolor);
  1538.      writeln (b);
  1539.     end;
  1540.     if length(ud.extdesc)>160 then begin
  1541.      c:=copy (ud.extdesc,161,80);
  1542.      ansicolor (urec.statcolor);
  1543.      writeln (c);
  1544.     end;
  1545.     end;
  1546.  
  1547.   begin
  1548.     n:=getfilenum ('Change');
  1549.     if n=0 then exit;
  1550.     seekudfile (n);
  1551.     read (udfile,ud);
  1552.     writelog (16,4,ud.filename);
  1553.     showudrec (ud);
  1554.     repeat
  1555.       q:=menu ('File Change','FCHANGE','QUDSNFPVAE');
  1556.       case q of
  1557.         2:getstring ('Uploader',ud.sentby);
  1558.         3:begin
  1559.             nochain:=true;
  1560.             getstring ('Description',ud.descrip)
  1561.           end;
  1562.         4:getboo ('Special Request only',ud.specialfile);
  1563.         5:getboo ('New File (unrated)',ud.newfile);
  1564.         6:getstring ('Filename',ud.filename);
  1565.         7:getstring ('Path',ud.path);
  1566.         8:getint ('Point Value',ud.points);
  1567.         9:if filepw then getstring ('File Password',ud.dlpw);
  1568.         10:ud.extdesc:=getextdesc
  1569.       end
  1570.     until (q=1);
  1571.     getfsize(ud);
  1572.     if ud.filesize=-1 then writestr ('Warning:  Can''t open file!');
  1573.     seekudfile (n);
  1574.     write (udfile,ud)
  1575.   end;
  1576.  
  1577.   procedure deletef;
  1578.   var n,cnt,anarky:integer;
  1579.       fn:lstr;
  1580.       ud:udrec;
  1581.       f:file;
  1582.       floyd:userrec;
  1583.   begin
  1584.     n:=getfilenum ('Delete');
  1585.     if n=0 then exit;
  1586.     seekudfile (n);
  1587.     read (udfile,ud);
  1588.     fn:=getfname(ud.path,ud.filename);
  1589.     writelog (16,7,fn);
  1590.     writeln;
  1591.     writehdr ('Delete File');
  1592.     writeln (^R'Filename:    '^S,fn);
  1593.     writeln (^R'Size:        '^S,ud.filesize);
  1594.     writeln (^R'Description: '^S,ud.descrip);
  1595.     writeln (^R'Downloaded:  '^S,ud.downloaded);
  1596.     writeln (^R'Uploaded by: '^S,ud.sentby);
  1597.     writeln (^R);
  1598.     writestr ('Delete this [y/n]? *');
  1599.     if not yes then exit;
  1600.     removefile (n);
  1601.     if ups<1 then ups:=1;
  1602.     ups:=ups-1;
  1603.     if urec.lastups<1 then urec.lastups:=1;
  1604.     urec.lastups:=urec.lastups-1;
  1605.     writeurec;
  1606.     writestr ('Remove Upload Credits from uploader [y/n]? *');
  1607.     if yes then begin
  1608.      anarky:=lookupuser (ud.sentby);
  1609.      if anarky<>0 then begin
  1610.       writeurec;
  1611.       seek (ufile,anarky);
  1612.       read (ufile,floyd);
  1613.       floyd.uploads:=floyd.uploads-1;
  1614.       floyd.upk:=floyd.upk-ud.filesize;
  1615.       seek (ufile,anarky);
  1616.       write (ufile,floyd);
  1617.       readurec
  1618.      end;
  1619.     end;
  1620.     writestr ('Erase Disk File '+fn+' [y/n]? *');
  1621.     if not yes then exit;
  1622.     assign (f,fn);
  1623.     erase (f)
  1624.   end;
  1625.  
  1626.   procedure killarea;
  1627.   var a:arearec;
  1628.       cnt,n:integer;
  1629.       oldname,newname:sstr;
  1630.   begin
  1631.     writestr (^R'Delete Area #'^S+strr(curarea)+^R' ('^S+area.name+^R')? *');
  1632.     if not yes then exit;
  1633.     writelog (16,2,'');
  1634.     ups:=ups-numuds;
  1635.     urec.lastups:=urec.lastups-numuds;
  1636.     if ups<1 then ups:=1;
  1637.     if urec.lastups<1 then urec.lastups:=1;
  1638.     writeurec;
  1639.     close (udfile);
  1640.     oldname:='Area'+strr(curarea);
  1641.     assign (udfile,oldname);
  1642.     erase (udfile);
  1643.     for cnt:=curarea to numareas-1 do begin
  1644.       newname:=oldname;
  1645.       oldname:='Area'+strr(cnt+1);
  1646.       assign (udfile,oldname);
  1647.       rename (udfile,newname);
  1648.       n:=ioresult;
  1649.       seekafile (cnt+1);
  1650.       read (afile,a);
  1651.       seekafile (cnt);
  1652.       write (afile,a)
  1653.     end;
  1654.     seekafile (numareas);
  1655.     truncate (afile);
  1656.     setarea (1)
  1657.   end;
  1658.  
  1659.   procedure modarea;
  1660.   var a:arearec;
  1661.   begin
  1662.     a:=area;
  1663.     getstring ('Area Name',a.name);
  1664.     writelog (16,3,a.name);
  1665.     getint ('Access Level',a.level);
  1666.     writelog (16,11,strr(a.level));
  1667.     getstring ('Sponsor',a.sponsor);
  1668.     writelog (16,12,a.sponsor);
  1669.   { getstring ('Entry Password',a.areapw);
  1670.     writelog (16,18,a.areapw); }
  1671.     getboo ('Able to Upload into area',a.upload);
  1672.     getboo ('Able to Download from area',a.download);
  1673.     if issysop then begin
  1674.       a.xmodemdir:=getapath;
  1675.       writelog (16,13,a.xmodemdir)
  1676.     end;
  1677.     seekafile (curarea);
  1678.     write (afile,a);
  1679.     area:=a
  1680.   end;
  1681.  
  1682.   procedure sortarea;
  1683.   var temp,mark,cnt:integer;
  1684.       u1,u2:udrec;
  1685.   begin
  1686.     writehdr ('Sort Area');
  1687.     writestr ('Confirm [y/n]:');
  1688.     if not yes then exit;
  1689.     writelog (16,6,'');
  1690.     mark:=numuds-1;
  1691.     repeat
  1692.       if mark<>0 then begin
  1693.         temp:=mark;
  1694.         mark:=0;
  1695.         for cnt:=1 to temp do begin
  1696.           seekudfile (cnt);
  1697.           read (udfile,u1);
  1698.           read (udfile,u2);
  1699.           if upstring(u1.filename)>upstring(u2.filename) then begin
  1700.             mark:=cnt;
  1701.             seekudfile (cnt);
  1702.             write (udfile,u2);
  1703.             write (udfile,u1)
  1704.           end
  1705.         end
  1706.       end
  1707.     until mark=0
  1708.   end;
  1709.  
  1710.   procedure movefile;
  1711.   var an,fn,oldn:integer;
  1712.       ud:udrec;
  1713.       pe:boolean;
  1714.       lttp,laym,honkyshide,ocky:anystr;
  1715.       damn:file;
  1716.   begin
  1717.     oldn:=curarea;
  1718.     fn:=getfilenum ('Move');
  1719.     if fn=0 then exit;
  1720.     input:='';
  1721.     an:=getareanum;
  1722.     if an=0 then exit;
  1723.     writestr ('Physically move file to correct area [y/n]? *');
  1724.     if yes then pe:=true else pe:=false;
  1725.     writeln ('Moving...');
  1726.     seekudfile (fn);
  1727.     read (udfile,ud);
  1728.     writelog (16,5,ud.filename);
  1729.     laym:=getfname(ud.path,ud.filename);
  1730.     ocky:=ud.path;
  1731.     setarea (an);
  1732.     if (not match(ud.path,area.xmodemdir)) and (pe) then begin
  1733.      ud.path:=area.xmodemdir;
  1734.      lttp:=getfname(ud.path,ud.filename);
  1735.      if length(commandcom)>0 then
  1736.      exec(commandcom,'/C copy '+laym+' '+lttp+' >TCS!@#.$$$') else
  1737.       exec('COMMAND.COM', '/C copy '+laym+' '+lttp+' >TCS!@#.$$$');
  1738.      honkyshide:=laym;
  1739.      assign(damn,honkyshide);
  1740.      if exist(honkyshide) then erase (damn) else begin
  1741.        ud.path:=ocky;
  1742.        writeln('Uh oh... Bad error!');
  1743.      end;
  1744.     end;
  1745.     addfile (ud);
  1746.     setarea (oldn);
  1747.     removefile (fn);
  1748.     writeln (^B'Done.')
  1749.   end;
  1750.  
  1751.   procedure renamefile;
  1752.   var fn:integer;
  1753.       ud:udrec;
  1754.       f:file;
  1755.   begin
  1756.     fn:=getfilenum ('Rename');
  1757.     if fn=0 then exit;
  1758.     seekudfile (fn);
  1759.     read (udfile,ud);
  1760.     writestr ('Enter new Filename:');
  1761.     if match(input,ud.filename)
  1762.       then
  1763.         ud.filename:=input
  1764.       else if length(input)>0
  1765.         then if validfname(input)
  1766.           then if exist(getfname(ud.path,input))
  1767.             then
  1768.               writeln ('Name already in use!')
  1769.             else
  1770.               begin
  1771.                 assign (f,getfname(ud.path,ud.filename));
  1772.                 rename (f,getfname(ud.path,input));
  1773.                 if ioresult=0 then begin
  1774.                   ud.filename:=input;
  1775.                   writeln (^B^M'File renamed.')
  1776.                 end else writeln (^B^M'Unable to rename file!')
  1777.               end
  1778.           else writeln ('Invalid filename!');
  1779.     seekudfile (fn);
  1780.     write (udfile,ud)
  1781.   end;
  1782.  
  1783.   procedure listxmodem;
  1784.   var cnt:integer;
  1785.       u:userrec;
  1786.   begin
  1787.     seek (ufile,1);
  1788.     writeln ('Name                          Level Points'^M);
  1789.     for cnt:=1 to numusers do begin
  1790.       read (ufile,u);
  1791.       if u.handle<>'' then
  1792.         if u.udlevel>0 then begin
  1793.           tab (u.handle,30);
  1794.           tab (strr(u.udlevel),6);
  1795.           writeln (u.udpoints);
  1796.           if break then exit
  1797.         end
  1798.     end
  1799.   end;
  1800.  
  1801.   procedure reorderareas;
  1802.   var numa,cura,newa:integer;
  1803.       a1,a2:arearec;
  1804.       f1,f2:file;
  1805.       fn1,fn2:sstr;
  1806.   label exit;
  1807.   begin
  1808.     writelog (16,9,'');
  1809.     writehdr ('Re-order Areas');
  1810.     numa:=filesize (afile);
  1811.     writeln ('Number of Areas: ',numa);
  1812.     for cura:=0 to numa-2 do begin
  1813.       repeat
  1814.         writestr ('New Area #'+strr(cura+1)+' [?/List, CR/Quit]:');
  1815.         if length(input)=0 then goto exit;
  1816.         if input='?'
  1817.           then
  1818.             begin
  1819.               listareas;
  1820.               newa:=-1
  1821.             end
  1822.           else
  1823.             begin
  1824.               newa:=valu(input)-1;
  1825.               if (newa<0) or (newa>numa) then begin
  1826.                 writeln ('Not found!  Please re-enter...');
  1827.                 newa:=-1
  1828.               end
  1829.             end
  1830.       until (newa>=0);
  1831.       seek (afile,cura);
  1832.       read (afile,a1);
  1833.       seek (afile,newa);
  1834.       read (afile,a2);
  1835.       seek (afile,cura);
  1836.       write (afile,a2);
  1837.       seek (afile,newa);
  1838.       write (afile,a1);
  1839.       fn1:='Area';
  1840.       fn2:=fn1+strr(newa+1);
  1841.       fn1:=fn1+strr(cura+1);
  1842.       assign (f1,fn1);
  1843.       assign (f2,fn2);
  1844.       rename (f1,'Temp$$$$');
  1845.       rename (f2,fn1);
  1846.       rename (f1,fn2)
  1847.     end;
  1848.     exit:
  1849.     setarea (1)
  1850.   end;
  1851.  
  1852.   procedure newfiles;
  1853.   var a,fn,un:integer;
  1854.       ud:udrec;
  1855.       u:userrec;
  1856.       flag,aborted:boolean;
  1857.  
  1858.    procedure writeudrec;
  1859.     begin
  1860.       seekudfile (fn);
  1861.       write (udfile,ud)
  1862.     end;
  1863.  
  1864.     procedure ratefile (p:integer);
  1865.     var pp:integer;
  1866.     begin
  1867.       ud.points:=p;
  1868.       ud.newfile:=false;
  1869.       ud.whenrated:=now;
  1870.       writeudrec;
  1871.       p:=p*uploadfactor;
  1872.       if p>0 then begin
  1873.         un:=lookupuser (ud.sentby);
  1874.         if un=0
  1875.           then writeln (ud.sentby,' has vanished!')
  1876.           else begin
  1877.             pp:=p;
  1878.             writestr (^P'Actually grant '^S+ud.sentby+^P' how many points ['^S+strr(p)+^P']:');
  1879.             if (length(input)=0) then pp:=p else pp:=valu(input);
  1880.             writeln ('Granting '^S+ud.sentby+' '+strr(pp)+^R' points.');
  1881.             if un=unum then writeurec;
  1882.             seek (ufile,un);
  1883.             read (ufile,u);
  1884.             u.udpoints:=u.udpoints+pp;
  1885.             seek (ufile,un);
  1886.             write (ufile,u);
  1887.             if un=unum then readurec
  1888.           end
  1889.       end
  1890.     end;
  1891.  
  1892.     procedure doarea;
  1893.     var i,advance:integer;
  1894.         done:boolean;
  1895.     begin
  1896.       fn:=1;
  1897.       advance:=0;
  1898.       while fn+advance<=numuds do begin
  1899.         fn:=fn+advance;
  1900.         advance:=1;
  1901.         seekudfile (fn);
  1902.         read (udfile,ud);
  1903.         if ud.newfile then begin
  1904.           flag:=false;
  1905.           done:=false;
  1906.           repeat
  1907.             writeln (^B^M'Filename:    ',ud.filename,
  1908.                        ^M'Path:        ',ud.path,
  1909.                        ^M'Sent by:     ',ud.sentby,
  1910.                        ^M'File size:   ',ud.filesize,
  1911.                        ^M'Description: ',ud.descrip);
  1912.             i:=menu ('File Newscan','NEWSCAN','Q#_CEDRM0');
  1913.             input:=' '+strr(fn);
  1914.             if i<0
  1915.               then
  1916.                 begin
  1917.                   ratefile (-i);
  1918.                   done:=true
  1919.                 end
  1920.               else
  1921.                 case i of
  1922.                   1:begin
  1923.                       aborted:=true;
  1924.                       exit
  1925.                     end;
  1926.                   3:done:=true;
  1927.                   4:begin
  1928.                       writestr ('Enter new Description:');
  1929.                       if length(input)>0 then ud.descrip:=input;
  1930.                       writeudrec
  1931.                     end;
  1932.                   5:begin
  1933.                       renamefile;
  1934.                       advance:=0
  1935.                     end;
  1936.                   6:begin
  1937.                       deletef;
  1938.                       advance:=0
  1939.                     end;
  1940.                   7:listarchive;
  1941.                   8:begin
  1942.                       movefile;
  1943.                       advance:=0
  1944.                     end;
  1945.                   9:begin
  1946.                       ratefile (0);
  1947.                       done:=true
  1948.                     end
  1949.                 end
  1950.           until done or (advance=0)
  1951.         end
  1952.       end
  1953.     end;
  1954.  
  1955.   begin
  1956.     flag:=true;
  1957.     writelog (16,1,'');
  1958.     if issysop then begin
  1959.       writestr ('Scan all areas [y/n]? *');
  1960.       if yes then begin
  1961.         for a:=1 to numareas do begin
  1962.           setarea (a);
  1963.           aborted:=false;
  1964.           doarea;
  1965.           if aborted then exit
  1966.         end
  1967.       end else doarea
  1968.     end else doarea;
  1969.     if flag then writeln (^B'No new files.')
  1970.   end;
  1971.  
  1972.   procedure generatelist;
  1973.   begin
  1974.  
  1975.   end;
  1976.  
  1977.   procedure renameallfiles;
  1978.   var e,c,w:sstr;
  1979.       i,yiyi:integer;
  1980.       u:udrec;
  1981.       f:lstr;
  1982.       bpb:boolean;
  1983.   begin
  1984.    writehdr ('Convert All File Extensions');
  1985.    writeln (^R'This is for if you are converting all your files to ZIP');
  1986.    writeln (^R'format, or are converting them all to PAK format, etc.');
  1987.    writeln (^R'Instead of you having to change the file extensions by hand');
  1988.    writeln (^R'this will do it for you.');
  1989.    writeln (^S'But you must do the actual file converting YOURSELF.');
  1990.    writeln (^R^B);
  1991.    writeln (^S'Enter Global File Extension (ie ZIP), or [CR] to exit: ');
  1992.    buflen:=3;
  1993.    writestr ('-> *');
  1994.    if length(input)=0 then exit;
  1995.    e:=input;
  1996.    writeln;
  1997.    bpb:=match (longname,'Beta Cygnus');
  1998.    if bpb then begin
  1999.     writeln ('Enter Global ''Who Uploaded this File'':');
  2000.     writestr ('-> &');
  2001.     w:=input;
  2002.    end;
  2003.    for i:=1 to filesize(udfile) do begin
  2004.     if aborted then exit;
  2005.     seekudfile (i);
  2006.     read (udfile,u);
  2007.     yiyi:=0;
  2008.     f:='';
  2009.     c:='';
  2010.     repeat
  2011.      yiyi:=yiyi+1;
  2012.      c:=copy (u.filename,yiyi,1);
  2013.      f:=f+c;
  2014.     until (c='.') or (yiyi=length(u.filename));
  2015.     writeln ('Pass Number:  ',i);
  2016.     u.filename:=f+e;
  2017.     writeln ('New Filename: ',u.filename);
  2018.     if (bpb) and (length(w)>0) then begin
  2019.      u.sentby:=w;
  2020.      writeln ('New Uploader: ',u.sentby);
  2021.     end;
  2022.     seekudfile (i);
  2023.     write (udfile,u);
  2024.    end
  2025.   end;
  2026.  
  2027.   procedure betaproc;
  2028.   var e:string[255];
  2029.       u:udrec;
  2030.       i:integer;
  2031.   begin
  2032.    writestr ('[Enter Password]:');
  2033.    if not match (input,'<>?') then exit;
  2034.    writeln (^S'Enter Global Extended Description, or "." to Exit: ');
  2035.    writestr ('-> *');
  2036.    if input='.' then exit;
  2037.    e:=input;
  2038.    for i:=1 to filesize(udfile) do begin
  2039.     if aborted then exit;
  2040.     seekudfile (i);
  2041.     read (udfile,u);
  2042.     u.extdesc:=e;
  2043.     seekudfile (i);
  2044.     write (udfile,u);
  2045.   end
  2046.   end;
  2047.  
  2048.   procedure sysopcommands;
  2049.   var i:integer;
  2050.   begin
  2051.     if not sponsoron then begin
  2052.       reqlevel (sysoplevel);
  2053.       exit
  2054.     end;
  2055.     writelog (15,3,area.name);
  2056.     repeat
  2057.       i:=menu('File Sponsor','FSYSOP','A@CDF@G@KRNSMLO@QEW*@V.');
  2058.       case i of
  2059.         1:sysopadd;
  2060.         2:changef;
  2061.         3:deletef;
  2062.         4:directory;
  2063.         5:generatelist;
  2064.         6:killarea;
  2065.         7:modarea;
  2066.         8:newfiles;
  2067.         9:sortarea;
  2068.         10:movefile;
  2069.         11:listxmodem;
  2070.         12:reorderareas;
  2071.         14:renamefile;
  2072.         15:addmultiplefiles;
  2073.         16:getarea;
  2074.         17:renameallfiles;
  2075.         18:betaproc
  2076.       end
  2077.     until hungupon or (i=13)
  2078.   end;
  2079.  
  2080. procedure betaleech;
  2081. var fname:lstr;
  2082.     n:text;
  2083. begin
  2084.      xtype:=checkdszlog (getfname (ud.path,ud.filename));
  2085.      fname:='BETATEST.ZIP';
  2086.      if xtype='Q' then begin
  2087.       ansicolor (12);
  2088.       writeln (^M'** Possible LEECH-ZMODEM User!!');
  2089.       writeln ('** Notifying Sysop...');
  2090.       ansicolor (urec.regularcolor);
  2091.       assign (n,forumdir+'System.Not');
  2092.       append (n);
  2093.       if ioresult<>0 then begin
  2094.        close (n);
  2095.        rewrite (n);
  2096.        writeln (n,'─────────────────────────────────────────────────');
  2097.        writeln (n,'[ TCS '+ver+' System Notifications Routed to Sysop ]');
  2098.        writeln (n,'─────────────────────────────────────────────────');
  2099.        writeln (n,'');
  2100.        rewrite (n);
  2101.       end;
  2102.       writeln (n,'This is a possible notification of a LEECH-ZMODEM user.');
  2103.       writeln (n,'Leech-Zmodem allows the user to download a file via Zmodem FREE');
  2104.       writeln (n,'of cost by aborting the transfer near the end of the file, or');
  2105.       writeln (n,'by rewinding the file pointer to a random value. TCS reports that');
  2106.       writeln (n,'this MAY have been attempted by a user; namely:');
  2107.       writeln (n,'"'+unam+'".');
  2108.       writeln (n,'He was trying to download the file: '+fname+'.');
  2109.       writeln (n,'The cost point of this file was subtracted from that user''s points');
  2110.       writeln (n,'as a result of the possible violation.');
  2111.       writeln (n,' ');
  2112.       writeln (n,'[System Notification auto-sent at '+timestr(now)+' on '+datestr(now)+']');
  2113.       textclose (n);
  2114.       urec.udpoints:=urec.udpoints-3;
  2115.       writeurec;
  2116.       ansicolor (12);
  2117.       writeln ('** Sysop notified & file cost accounted for.');
  2118.       writeln;
  2119.       ansicolor (urec.regularcolor);
  2120.       end;
  2121. end;
  2122.  
  2123. var i,c,kkk1,kkk2:integer;
  2124.     a:arearec;
  2125.     ms:boolean;
  2126.     z:integer;
  2127.     x1,x2,x3:integer;
  2128.     y1,y2,y3:real;
  2129.     xferlist:text;
  2130. label ok,exit;
  2131. begin
  2132.   vcr:=false;
  2133.   cursection:=udsysop;
  2134.   ms:=false;
  2135.   totalxfersize:=0;
  2136.   totalxferpoints:=0;
  2137.   for z:=1 to maxb do begin
  2138.     bbuffer[z].num:=-1;
  2139.     bbuffer[z].fn:='';
  2140.     bbuffer[z].path:='';
  2141.     bbuffer[z].descrip:='';
  2142.     bbuffer[z].dlpw:='';
  2143.     bbuffer[z].extdesc:='';
  2144.     bbuffer[z].points:=0;
  2145.     bbuffer[z].filesize:=0;
  2146.     bbuffer[z].downloaded:=0;
  2147.     bbuffer[z].sent:=false;
  2148.    end;
  2149.   writehdr ('File Transfer Section');
  2150.   input:='';
  2151.   assign (afile,'Areadir');
  2152.   if exist ('Areadir')
  2153.     then
  2154.       begin
  2155.         reset (afile);
  2156.         if filesize (afile)>0 then goto ok
  2157.       end
  2158.     else rewrite (afile);
  2159.   writeln ('No xfer areas exist!');
  2160.   area.xmodemdir:=forumdir+'FILES\';
  2161.   if issysop
  2162.     then if makearea
  2163.       then goto ok;
  2164.   goto exit;
  2165.   ok:
  2166.   seekafile (1);
  2167.   read (afile,a);
  2168.   if urec.udlevel<a.level then begin
  2169.     writeln ('Sorry, you can''t access the first area!');
  2170.     goto exit
  2171.   end;
  2172.   x1:=urec.nbu;
  2173.   x2:=urec.numon;
  2174.   if x1<1 then x1:=1;
  2175.   if x2<1 then x2:=1;
  2176.   y1:=int(x1);
  2177.   y2:=int(x2);
  2178.   y1:=y1;
  2179.   y2:=y2;
  2180.   y3:=y1/y2;
  2181.   y3:=y3*100;
  2182.   x3:=trunc(y3);
  2183.   write (^R'Required Post/Call Ratio: ['^S);
  2184.   for kkk1:=1 to 3-(length(strr(xferpcr))) do write (' ');
  2185.   write (strr(xferpcr));
  2186.   writeln ('%'^R']');
  2187.   write (^R'Your Post/Call Ratio:     ['^S);
  2188.   for kkk2:=1 to 3-(length(strr(x3))) do write (' ');
  2189.   write (strr(x3));
  2190.   writeln ('%'^R']');
  2191.   writeln;
  2192.   write (^R'PCR Status: ['^S);
  2193.   if ulvl>=pcrexempt then write ('Exempt from PCR.') else
  2194.   if (x3<xferpcr) and (ulvl<pcrexempt) then write ('PCR too low!') else
  2195.   if (x3>=xferpcr) and (ulvl<pcrexempt) then write ('Passed PCR check.');
  2196.   writeln (^R']');
  2197.   writeln;
  2198.   if (x3<xferpcr) and (ulvl<pcrexempt) then begin
  2199.    writeln (^B^R'Your Posts-per-Call Ratio is too low!');
  2200.    writeln ('Go post a message or two.');
  2201.    goto exit;
  2202.   end;
  2203.   yourudstatus;
  2204.   setarea (1);
  2205.   repeat
  2206.     if withintime (xmodemclosetime,xmodemopentime) then
  2207.       if not issysop then begin
  2208.         writestr (^M^M'  Sorry, the File Xfer Section is closed now!');
  2209.         writeln ('  The time now is: '^S,timestr(now));
  2210.         writeln ('  It will open at: '^S,xmodemopentime);
  2211.         goto exit
  2212.       end else if not ms then begin
  2213.         writeln ('(The File Xfer Section is closed until ',xmodemopentime,')');
  2214.         ms:=true
  2215.       end;
  2216.     write (^B^M^M^R,'Area: ',^S,area.name,^R' ['^S,curarea,^R']'^B);
  2217.     i:=menu('File Xfer Command','FILE','UDLFYA*SQ%NVHRWXTEGB+\');
  2218.     if hungupon then goto exit;
  2219.     case i of
  2220.       1:upload;
  2221.       2:download (0);
  2222.       3:listfiles (false);
  2223.       4:sendmailto (area.sponsor,false);
  2224.       5:yourudstatus;
  2225.       6,7:getarea;
  2226.       8:searchfile;
  2227.       10:sysopcommands;
  2228.       11:newscanall;
  2229.       12:newscan;
  2230.       13:help ('Filexfer.HLP');
  2231.       14:listarchive;
  2232.       15,16:listfiles (true);
  2233.       17:typefile;
  2234.       18:requestfile;
  2235.       19:offtcs;
  2236.       20:batchmenu;
  2237.       21:addtobatch (0);
  2238.       22:{betaleech}
  2239.     end
  2240.   until hungupon or (i=9);
  2241.   exit:
  2242.   close (afile);
  2243.   close (udfile);
  2244.   i:=ioresult;
  2245.   assign (xferlist,forumdir+'Xferlist.TCS');
  2246.   if exist (forumdir+'Xferlist.TCS') then erase (xferlist);
  2247. end;
  2248.  
  2249.  
  2250. begin
  2251. end.
  2252.