home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 341.img / TCS161S.ZIP / GFILES.PAS < prev    next >
Pascal/Delphi Source File  |  1989-11-28  |  36KB  |  1,374 lines

  1. {$R-,S-,I-,D-,F+,V-,B-,N-,O+ }
  2. {$M 65500,0,0 }
  3.  
  4. unit gfiles;
  5.  
  6. interface
  7.  
  8. uses crt,dos,overlay,
  9.      gentypes,configrt,modem,statret,subs1,subs2,textret,gensubs,
  10.      windows,mainr1,mainr2,overret1,userret,protocol,mainmenu,subs3;
  11.  
  12. procedure gfilesection;
  13.  
  14. implementation
  15.  
  16. procedure gfilesection;
  17. var showit,itsotay,ymodem:boolean;
  18.  
  19. var gfile:file of gfilerec;
  20.     gf:gfilerec;
  21.     gfilea:file of gfilearea;
  22.     gfa:gfilearea;
  23.     curarea:integer;
  24.  
  25. procedure beepbeep (ok:integer);
  26. begin
  27.  delay (500);
  28.  write (^B^M);
  29.  case ok of
  30.   0:write ('Transfer completed.');
  31.   1:write ('Transfer Aborted.');
  32.   2:write ('Transfer Aborted.')
  33.  end;
  34.  writeln (^G^M)
  35. end;
  36.  
  37. procedure parse3 (s:lstr; var a,b,c:integer);
  38. var p:integer;
  39.  
  40.   procedure parse1 (var n:integer);
  41.   var ns:lstr;
  42.   begin
  43.     ns[0]:=#0;
  44.     while (p<=length(s)) and (s[p] in ['0'..'9']) do begin
  45.       ns:=ns+s[p];
  46.       p:=p+1
  47.     end;
  48.     if length(ns)=0
  49.       then n:=0
  50.       else n:=valu(ns);
  51.     if p<length(s) then p:=p+1
  52.   end;
  53.  
  54. begin
  55.   p:=1;
  56.   parse1 (a);
  57.   parse1 (b);
  58.   parse1 (c)
  59. end;
  60.  
  61. function later (d1,t1,d2,t2:sstr):boolean;
  62. var m1,da1,y1,m2,da2,y2:integer;
  63.  
  64.   function latertime (t1,t2:sstr):boolean;
  65.   var n1,n2:integer;
  66.   begin
  67.     latertime:=timeval(t1)>timeval(t2)
  68.   end;
  69.  
  70.  begin
  71.    parse3 (d1,m1,da1,y1);
  72.    parse3 (d2,m2,da2,y2);
  73.    if y1=y2
  74.      then if m1=m2
  75.        then if da1=da2
  76.          then later:=timeval(t1) > timeval(t2)
  77.          else later:=da1>da2
  78.        else later:=m1>m2
  79.      else later:=y1>y2
  80.  end;
  81.  
  82.   function Numgfiles:integer;
  83.   begin
  84.     numgfiles:=filesize(gfile)
  85.   end;
  86.  
  87.   function NumAreas:integer;
  88.   begin
  89.     numareas:=filesize (gfilea)
  90.   end;
  91.  
  92.   procedure Seekgfile (n:integer);
  93.   begin
  94.     seek (gfile,n-1)
  95.   end;
  96.  
  97.   procedure Seekgfilea (n:integer);
  98.   begin
  99.     seek (gfilea,n-1)
  100.   end;
  101.  
  102.   procedure Assigngf (N:Integer);
  103.   begin
  104.     close (gfile);
  105.     assign (gfile,uploaddir+'gfILE'+strr(n));
  106.   end;
  107.  
  108.   function Makearea:boolean;
  109.   var num,n:integer;
  110.       gfatmp:gfilearea;
  111.   begin
  112.     makearea:=false;
  113.     writestr ('Create Area '+strr(numareas+1)+' [y/n]? *');
  114.     writeln;
  115.     if yes then begin
  116.       writestr ('Area Name: *');
  117.       if length(input)=0 then exit;
  118.       gfatmp.Name:=input;
  119.       writestr ('Access Level: *');
  120.       if length(input)=0 then exit;
  121.       gfatmp.Level:=valu(input);
  122.       writestr ('Sponsor [CR/'+unam+']:');
  123.       if length(input)=0 then input:=unam;
  124.       gfatmp.Sponsor:=input;
  125.       gfatmp.UpAble:=True;
  126.       writestr('Able to Upload to area [CR/Yes]: *');
  127.       if length(input)=0 then input:='Y';
  128.       if upcase(input[1])<>'Y' then gfatmp.UpAble:=False;
  129.       writestr('Upload Directory [CR/'+uploaddir+']: *');
  130.       if length(input)=0 then input:=uploaddir;
  131.       gfatmp.gfileDir:=input;
  132.       Seekgfilea (numareas+1);
  133.       write (gfilea,gfatmp);
  134.       gfa:=gfatmp;
  135.       Curarea:=NumAreas+1;
  136.       Assigngf(CurArea);
  137.       rewrite (gfile);
  138.       writeln ('Area created');
  139.       makearea:=true;
  140.       writelog (3,6,gfatmp.Name);
  141.     end
  142.   end;
  143.  
  144.   procedure opengfile;
  145.   var n:integer;
  146.   begin
  147.     n:=ioresult;
  148.     assign (gfilea,uploaddir+'gfiledir');
  149.     reset (gfilea);
  150.     if ioresult<>0 then begin
  151.       close (gfilea);
  152.       n:=ioresult;
  153.       rewrite (gfilea);
  154.       itsotay:=makearea;
  155.     end else itsotay:=true;
  156.   end;
  157.  
  158.   function getfname (path:lstr; name:mstr):lstr;
  159.   var l:lstr;
  160.   begin
  161.     l:=path;
  162.     if length(l)<>0 then
  163.       if not (upcase(l[length(l)]) in [':','\'])
  164.         then l:=l+'\';
  165.     l:=l+name;
  166.     getfname:=l;
  167.   end;
  168.  
  169.   function getapath:lstr;
  170.   var q,r:integer;
  171.       f:file;
  172.       b:boolean;
  173.       p:lstr;
  174.   begin
  175.     getapath:=gfa.gfiledir;
  176.     repeat
  177.       writestr ('Upload Path [CR/'+gfa.gfileDir+']:');
  178.       if hungupon then exit;
  179.       if length(input)=0 then input:=gfa.gfileDir;
  180.       p:=input;
  181.       if input[length(p)]<>'\' then p:=p+'\';
  182.       b:=true;
  183.       assign (f,p+'CON');
  184.       reset (f);
  185.       q:=ioresult;
  186.       close (f);
  187.       r:=ioresult;
  188.       if q<>0 then begin
  189.         writestr ('  Path does not exist.  Create it [y/n]? *');
  190.         b:=yes;
  191.         if b then begin
  192.           mkdir (copy(p,1,length(p)-1));
  193.           q:=ioresult;
  194.           b:=q=0;
  195.           if b then writestr ('Directory created.')
  196.             else writestr ('Unable to create directory.')
  197.         end
  198.       end
  199.     until b;
  200.     getapath:=p;
  201.   end;
  202.  
  203.   procedure fastlistfile (n:integer);
  204.   var q:sstr;
  205.   begin
  206.     seekgfile (n);
  207.     read (gfile,gf);
  208.     writeln;
  209.     ansicolor (urec.promptcolor);
  210.     tab (strr(n)+'.',5);
  211.     ansicolor (urec.regularcolor);
  212.     if break then exit;
  213.     if gf.arcname='' then begin
  214.      if exist(getfname(gf.path,gf.fname)) then
  215.      tab (strlong(gf.filesize),9) else tab ('Offline',9);
  216.     end else tab ('Archived',9);
  217.     if break then exit;
  218.     ansicolor (urec.statcolor);
  219.     tab (gf.gfiledescr,66);
  220.     ansicolor (urec.regularcolor);
  221.     if break then exit;
  222.   end;
  223.  
  224.   function nofiles:boolean;
  225.   begin
  226.     if Numgfiles=0 then begin
  227.       nofiles:=true;
  228.       writestr (^M'Sorry, No G-Files!')
  229.     end else nofiles:=false
  230.   end;
  231.  
  232.   procedure fastlistgfiles;
  233.   var cnt,max,r1,r2,r3:integer;
  234.   begin
  235.     if nofiles then exit;
  236.     writehdr ('General File List');
  237.     max:=Numgfiles;
  238.     thereare (max,'G-File','G-Files');
  239.     parserange (max,r1,r2);
  240.     if r1=0 then exit;
  241.     tab ('No.',5);
  242.     tab ('Bytes',9);
  243.     tab ('Description',66);
  244.     writeln;
  245.     r3:=0;
  246.     for cnt:=r1 to r2 do begin
  247.     r3:=r3+2;
  248.       FASTlistfile (cnt);
  249.       if break then exit
  250.     end;
  251.     writeln;
  252.   end;
  253.  
  254.   function GetgfileNum (t:mstr):integer;
  255.   var n,s:integer;
  256.  
  257.     function SearchforFile (f:sstr):integer;
  258.     var cnt:integer;
  259.     begin
  260.       for cnt:=1 to numgfiles do begin
  261.         seekgfile (cnt);
  262.         read (gfile,gf);
  263.         if match(gf.fname,f) then begin
  264.           searchforfile:=cnt;
  265.           exit
  266.         end
  267.       end;
  268.       searchforfile:=0
  269.     end;
  270.  
  271.   begin
  272.     getgfilenum:=0;
  273.     if length(input)>1 then input:=copy(input,2,255) else
  274.       repeat
  275.         writestr ('File Number to '+t+' [?/List]:');
  276.         if hungupon or (length(input)=0) then exit;
  277.         if input='?' then begin
  278.           fastlistgfiles;
  279.           input:=''
  280.         end
  281.       until input<>'';
  282.     val (input,n,s);
  283.     if s<>0 then begin
  284.       n:=searchforfile(input);
  285.       if n=0 then begin
  286.         writeln ('No such file.');
  287.         exit
  288.       end
  289.     end;
  290.     if (n<1) or (n>numgfiles) then writeln ('Invalid number.')
  291.       else getgfilenum:=n
  292.   end;
  293.  
  294.   procedure addfile (gf:gfileRec);
  295.   begin
  296.     seekgfile (numgfiles+1);
  297.     write (gfile,gf)
  298.   end;
  299.  
  300.   function getfsize (filename:anystr):longint;
  301.   var df:file of byte;
  302.   begin
  303.     gf.filesize:=-1;
  304.     assign (df,filename);
  305.     reset (df);
  306.     if ioresult<>0 then exit;
  307.     getfsize:=filesize(df);
  308.     close(df)
  309.   end;
  310.  
  311.   const beenaborted:boolean=false;
  312.  
  313.   function Aborted:boolean;
  314.   begin
  315.     if beenaborted then begin
  316.       aborted:=true;
  317.       exit
  318.     end;
  319.     aborted:=xpressed or hungupon;
  320.     if xpressed then begin
  321.       beenaborted:=true;
  322.       writeln (^B'[New-Scan Aborted!]')
  323.     end
  324.   end;
  325.  
  326.   procedure NewScan;
  327.   var cnt:integer;
  328.       first:integer;
  329.       newest:boolean;
  330.   label notlater;
  331.   begin
  332.     newest:=false;
  333.     beenaborted:=false;
  334.     first:=0;
  335.     for cnt:=filesize(gfile) downto 1 do begin
  336.       Seekgfile (cnt);
  337.       read (gfile,gf);
  338.       if later (datestr(gf.when),timestr(gf.when),datestr(laston),timestr(laston))
  339.         then first:=cnt
  340.         else goto notlater
  341.     end;
  342.     notlater:
  343.     if first<>0 then begin
  344.       writeln;
  345.       writeln (^M'G-File Area: ['^S+gfa.name+^R']');
  346.       for cnt:=first to filesize(gfile) do begin
  347.         if aborted then exit;
  348.         fastlistfile (cnt);
  349.       end
  350.     end
  351.   end;
  352.  
  353.   procedure SetArea (n:integer);
  354.   var otay:boolean;
  355.   begin
  356.     curarea:=n;
  357.     otay:=false;
  358.     if (n>numareas) or (n<1) then begin
  359.       writeln (^B'Invalid Area!');
  360.       if issysop then if makearea then setarea (curarea)
  361.         else setarea (1)
  362.       else setarea (1);
  363.       exit
  364.     end;
  365.     seekgfilea (n);
  366.     read (gfilea,gfa);
  367.     otay:=(urec.gfLevel>=gfa.Level);
  368.     if not otay then
  369.       if curarea=1 then error ('Access Level too low!','','')
  370.         else begin
  371.           reqlevel (gfa.level);
  372.           setarea (1);
  373.           exit
  374.         end;
  375.     Assigngf(n);
  376.     close (gfile);
  377.     reset (gfile);
  378.     if ioresult<>0 then rewrite (gfile);
  379.     if showit then writeln (^B^M'G-File Area: '^S,gfa.name,^R' ['^S,curarea,^R']');
  380.     if showit=false then writeln;
  381.   end;
  382.  
  383.   procedure newscanall;
  384.   var cnt:integer;
  385.       otay:boolean;
  386.   begin
  387.     writehdr ('New-Scanning - Press [X] to abort.');
  388.     if aborted then exit;
  389.     for cnt:=1 to filesize(gfilea) do begin
  390.       seekgfilea (cnt);
  391.       read (gfilea,gfa);
  392.       otay:=false;
  393.       if urec.gfLevel>=gfa.Level then otay:=true;
  394.       if otay then begin
  395.         if aborted then exit;
  396.         setarea (cnt);
  397.         if aborted then exit;
  398.         newscan;
  399.       end;
  400.       if aborted then exit
  401.     end;
  402.   end;
  403.  
  404.   procedure listareas;
  405.   var cnt,old:integer;
  406.         gfatmp:gfilearea;
  407.   begin
  408.     writehdr ('Area List');
  409.     old:=curarea;
  410.     seekgfileA (1);
  411.     writeln(^M'Num Level   Name');
  412.     for cnt:=1 to NumAreas do begin
  413.       read (gfilea,gfatmp);
  414.       if (urec.level>=gfatmp.Level) then begin
  415.         write (^R,cnt:2,'. ['^S);
  416.          tab(strr(gfatmp.Level),5);
  417.         writeln(^R'] '^S,gfatmp.Name,^R);
  418.         if break then begin
  419.           setarea(old);
  420.           exit;
  421.         end;
  422.       end;
  423.     end;
  424.   end;
  425.  
  426.   function GetAreaNum:integer;
  427.   var areastr:sstr;
  428.       areanum:integer;
  429.   begin
  430.     getareanum:=0;
  431.     if length(input)>1 then areastr:=copy(input,2,255) else
  432.     begin
  433.     repeat
  434.       listareas;
  435.       writestr (^M'Area Number [?/List]:');
  436.       if input='!' then listareas else areastr:=input
  437.     until (input<>'?') or hungupon;
  438.     end;
  439.     if length(areastr)=0 then exit;
  440.     areanum:=valu(areastr);
  441.     if (areanum>0) and (areanum<=NumAreas) then getareanum:=areanum
  442.     else begin
  443.       writestr ('No such Area!');
  444.       if issysop then if makearea then getareanum:=numareas
  445.     end;
  446.   end;
  447.  
  448.   procedure GetArea;
  449.   var areanum:integer;
  450.   begin
  451.     areanum:=getareanum;
  452.     if areanum<>0 then SetArea (areanum);
  453.   end;
  454.  
  455.   procedure yourgfstatus;
  456.   begin
  457. writeln (^B'╒═════════════════╤════════════════╕');
  458.     write ('│ G-File Level    │ '^S);
  459.     tab (strr(urec.gflevel),15);
  460.     writeln (^R'│');
  461.     write ('│ Required Ratio  │ '^S);
  462.     tab (strr(gfratio)+'%',15);
  463.     writeln(^R'│');
  464.     write ('│ G-file U/D Ratio│ '^S);
  465.         tab (strr(percent(urec.gfuploads,urec.gfdownloads)),15);
  466.     writeln (^R'│');
  467.     write ('│ G-File Uploads  │ '^S);
  468.     tab (strr(urec.gfuploads),15);
  469.     writeln (^R'│');
  470.     write ('│ G-File Downloads│ '^S);
  471.     tab (strr(urec.gfdownloads),15);
  472.     writeln (^R'│');
  473.     if useqr then begin
  474.      calcqr;
  475.     write ('│ Quality Rating  │ '^S);
  476.      tab (strr(qr),15);
  477.      writeln (^R'│');
  478.     end;
  479.   writeln ('╘═════════════════╧════════════════╛');
  480.   if percent (urec.gfuploads,urec.gfdownloads)<udratio then begin
  481.       writeln ('Your UL/DL ratio is too low!');
  482.       exit;
  483.       end;
  484.  end;
  485.  
  486.   procedure showgfile (n:integer);
  487.   var f,wipefile:file;
  488.       protop,tran,fn:lstr;
  489.       b:integer;
  490.       ascii,crcmode,ymodem,cool:boolean;
  491.       extrnproto:char;
  492.   begin
  493.     ascii:=false;
  494.     seekgfile (n);
  495.     read (gfile,gf);
  496.     if ulvl<0 then  exit;
  497.     writeln;
  498.     if useqr then begin
  499.      calcqr;
  500.      if (qr<qrlimit) and (ulvl<qrexempt) then begin
  501.      writeln ('Your Quality Rating is '^S+strr(qr)+^R'.');
  502.      writeln ('That exceeds the limit of '^S+strr(qrlimit)+^R'!');
  503.      writeln ('You must get a better QR before you can download.');
  504.      exit;
  505.     end;
  506.     end;
  507.     if (not exist(getfname(gf.path,gf.fname))) and (gf.arcname='') then begin
  508.       writeln('File is [Offline]!');
  509.       writeln;
  510.       exit;
  511.     end;
  512.     if (gf.arcname<>'') and (not exist (getfname(gf.path,gf.fname))) then begin
  513.      writeln;
  514.      writeln ('Extracting file from Archive -- Please hold...');
  515.      if not exist (gf.arcname) then begin
  516.       writeln ('Archive filename '+gf.arcname+' does not exist!');
  517.       exit;
  518.      end;
  519.      extract (gf.fname,gf.arcname,gf.path);
  520.      if not exist (gf.path+gf.fname) then begin
  521.       writeln ('File could not be extracted.    Sorry!');
  522.       writeln ('Leave '+sysopname+' Feedback about this please.');
  523.       exit;
  524.      end;
  525.      if exist (uploaddir+gf.fname) then writeln ('Extracted Successfully.');
  526.     end;
  527.  
  528.     listprotocols(0);
  529.  
  530.     if hungupon then exit;
  531.     writeln;
  532.     writestr (^R+'Protocol [Q/Quit][A/ASCII][CR/'+^S+urec.defproto+^R+': &');
  533.     if length(input)=0 then extrnproto:=urec.defproto else
  534.                 extrnproto:=upcase(input[1]);
  535.     if hungupon then exit;
  536.     if extrnproto='Q' then exit;
  537.  
  538.     fn:=getfname (gf.path,gf.fname);
  539.     ascii:=(extrnproto='A');
  540.  
  541.     if tempsysop then begin
  542.       ulvl:=regularlevel;
  543.       tempsysop:=false;
  544.       writeurec;
  545.       bottomline
  546.     end;
  547.  
  548.     if not ascii then begin
  549.     cool:=findprot('S',extrnproto);
  550.     if not cool then exit;
  551.     writeln; writeln('Start your download now.');
  552.       b:=doext('S',extrnproto,gf.path,gf.fname,baudrate,usecom);
  553.       modeminlock:=false;
  554.       modemoutlock:=false;
  555.       beepbeep (b)
  556.     end;
  557.     if ascii then begin
  558.      writestr ('Press [X] to abort or [CR] to continue: *');
  559.      if upcase(input[1])='X' then exit;
  560.      writeln (^M^R'Title: '^S,gf.gfiledescr,
  561.               ^M^R'Date:  '^S,datestr (gf.when),
  562.               ^M^R'Time:  '^S,timestr (gf.when),^M);
  563.      printfile (getfname(gf.path,gf.Fname));
  564.      urec.gfdownloads:=urec.gfdownloads+1;
  565.      writeln (asciidownload);
  566.      writeln;
  567.     end;
  568.    if ((gf.arcname<>'') and (exist (getfname(gf.path,gf.fname)))) then
  569.    begin
  570.     assign (wipefile,getfname(gf.path,gf.fname));
  571.     erase (wipefile);
  572.    end;
  573.   end;
  574.  
  575.   procedure makeasciigfile (filename:anystr);
  576.   var t:text;
  577.       b:boolean;
  578.       yo:integer;
  579.       fname:lstr;
  580.   begin
  581.    assign (t,filename);
  582.    rewrite (t);
  583.    writeln;
  584.    if (asciigraphics in urec.config) then
  585.    writeln ('──────────────────────────────────────────────────────────') else
  586.    writeln ('----------------------------------------------------------');
  587.    writeln ('[Enter G-File now (Echo''d) - Type /S to Save, /A to Abort]');
  588.    if (asciigraphics in urec.config) then
  589.    writeln ('──────────────────────────────────────────────────────────') else
  590.    writeln ('----------------------------------------------------------');
  591.    writeln;
  592.    repeat
  593.     lastprompt:='Continue...'^M;
  594.     wordwrap:=true;
  595.     getstr (1);
  596.     b:=match(input,'/S') or match(input,'/A');
  597.     if not b then writeln (t,input)
  598.    until b;
  599.    textclose (t);
  600.    if match(input,'/A') then erase (t);
  601.    writelog (3,2,Filename);
  602. end;
  603.  
  604.   procedure uploadgfile;
  605.   var tx,t:text;
  606.       ascii,crcmode,bbb,cool:boolean;
  607.       yo:integer;
  608.       fname,tran,protop,fn:lstr;
  609.       extrnproto:char;
  610.       emmemm:minuterec;
  611.   begin
  612.     writeln;
  613.     crcmode:=false;
  614.     ymodem:=false;
  615.     if gfa.upable=false then begin
  616.      writeln ('Sorry, Uploading is not allowed in this area!');
  617.      writeln;
  618.      exit;
  619.     end;
  620.  
  621.     writehdr('Upload G-Files');
  622.     repeat
  623.      writestr ('Upload Filename: *');
  624.      if length(input)=0 then exit;
  625.     until validfname (input);
  626.     gf.fname:=input;
  627.     fn:=getfname(gfa.gfiledir,gf.fname);
  628.     if not exist(fn) then begin
  629.      writestr ('Description:     &');
  630.      gf.gfiledescr:=input;
  631.      assign (tx,fn);
  632.      listprotocols(1);
  633.     if hungupon then exit;
  634.     writestr (^R+'Protocol [Q/Quit][A/ASCII][CR/'+^S+urec.defproto+^R+'] &');
  635.     if length(input)=0 then extrnproto:=urec.defproto else
  636.                 extrnproto:=upcase(input[1]);
  637.     if hungupon then exit;
  638.     if extrnproto='Q' then exit;
  639.  
  640.     ascii:=(extrnproto='A');
  641.  
  642.     if tempsysop then begin
  643.       ulvl:=regularlevel;
  644.       tempsysop:=false;
  645.       writeurec;
  646.       bottomline
  647.     end;
  648.  
  649.     starttimer (emmemm);
  650.     if not ascii then begin
  651.       ascii:=false;
  652.       yo:=0;
  653.       gf.arcname:='';
  654.       cool:=findprot('R',extrnproto);
  655.       if not cool then exit;
  656.  
  657.       yo:=doext('R',extrnproto,gfa.gfiledir,gf.fname,baudrate,usecom);
  658.  
  659.       modeminlock:=false;
  660.       modemoutlock:=false;
  661.  
  662.       beepbeep (yo);
  663.       case yo of
  664.         0    : writelog (3,2,fn);
  665.         1,2    : begin
  666.                 assign(tx,fn);
  667.                 erase(tx);
  668.               end;
  669.         end;
  670.     end;
  671.  
  672.     if ascii then begin
  673.      assign (t,fn);
  674.      rewrite (t);
  675.      writeln;
  676.      if (asciigraphics in urec.config) then
  677. writeln ('─────────────────────────────────────────────────────────────────') else
  678. writeln ('-----------------------------------------------------------------');
  679. writeln ('Enter G-File now (Echoed)  -  [/S] to Save, [/A] to Abort');
  680.      if (asciigraphics in urec.config) then
  681. writeln ('─────────────────────────────────────────────────────────────────') else
  682. writeln ('-----------------------------------------------------------------');
  683.      writeln;
  684.      repeat
  685.       lastprompt:='Continue...'^M;
  686.       wordwrap:=true;
  687.       getstr (1);
  688.       bbb:=match(input,'/S') or match(input,'/A');
  689.       if not bbb then begin
  690.        writeln (t,input);
  691.       end;
  692.      until bbb;
  693.      textclose (t);
  694.      if match(input,'/A') then erase (t);
  695.      writelog (3,2,fn);
  696.     end
  697.     end else writeln (^M'File exists!'^M);
  698.     stoptimer (emmemm);
  699.     writeln;
  700.     if not exist (fn) then begin
  701.      writeln ('Upload Aborted!');
  702.      exit;
  703.     end else writeln ('Thanks for the upload!');
  704.     gf.when:=now;
  705.     gf.sentby:=unam;
  706.     gf.path:=gfa.gfiledir;
  707.     gf.downloaded:=0;
  708.     gf.specialfile:=false;
  709.     gf.newfile:=true;
  710.     gf.filesize:=getfsize (fn);
  711.     urec.gfuploads:=urec.gfuploads+1;
  712.     seekgfile (numgfiles+1);
  713.     write (gfile,gf);
  714.     if gfilez>32760 then gfilez:=0;
  715.     gfilez:=gfilez+1;
  716.     writeln;
  717.     writelog (3,10,gf.gfiledescr)
  718.  end;
  719.  
  720.   procedure sysopcommands;
  721.   var q:integer;
  722.  
  723.     procedure getstr (prompt:mstr; var ss; len:integer);
  724.     var a:anystr absolute ss;
  725.     begin
  726.       writeln (^B^M'Current ',prompt,' is: '^S,a);
  727.       buflen:=len;
  728.       writestr ('Enter new '+prompt+':');
  729.       if length(input)>0 then a:=input;
  730.     end;
  731.  
  732.     procedure getint (prompt:mstr; var i:integer);
  733.     var q:sstr;
  734.         n:integer;
  735.     begin
  736.       str (i,q);
  737.       getstr (prompt,q,5);
  738.       n:=valu (q);
  739.       if n<>0 then i:=n
  740.     end;
  741.  
  742.     procedure getboo (t:lstr; var b:boolean);
  743.     var s:sstr;
  744.     begin
  745.       s:=yesno (b);
  746.       getstr (t,s,1);
  747.       b:=upcase(s[1])='Y'
  748.     end;
  749.  
  750.     procedure removefile (n:integer);
  751.     var cnt:integer;
  752.     begin
  753.       for cnt:=n to numgfiles-1 do begin
  754.         seekgfile (cnt+1);
  755.         read (gfile,gf);
  756.         seekgfile (cnt);
  757.         write (gfile,gf)
  758.       end;
  759.       seekgfile (numgfiles);
  760.       truncate (gfile)
  761.     end;
  762.  
  763.     procedure addgfile;
  764.     var fn,s,p:anystr;
  765.         found:boolean;
  766.         t:text;
  767.     begin
  768.       found:=false;
  769.       writestr ('Filename: *');
  770.       if length(input)=0 then exit;
  771.       if match(input,'USERS') then begin
  772.        writelog (3,12,unam);
  773.        writeln (^G^M'Too bad, you can''t add the USER file!'^M);
  774.        exit;
  775.       end;
  776.       gf.fname:=input;
  777.       writestr ('Path [CR/'+gfa.gfileDir+']: *');
  778.       if length(input)=0 then input:=gfa.gfiledir;
  779.       gf.path:=input;
  780.       p:=gf.path;
  781.       if exist (forumdir+'SECURITY.DIR') then begin
  782.        assign (t,forumdir+'SECURITY.DIR');
  783.        reset (t);
  784.        repeat
  785.         readln (t,s);
  786.         if s[length(s)]<>'\' then s:=s+'\';
  787.         if match(s,p) then begin
  788.          found:=true;
  789.          writeln;
  790.          writeln (^G'That Directory is protected by the Sysop!');
  791.          writeln;
  792.         end;
  793.        until eof(t) or (found);
  794.        textclose (t);
  795.        if found then exit;
  796.       end;
  797.       writestr ('Archive Filename [CR/None]: *');
  798.       if length(input)<2 then gf.arcname:='' else
  799.       gf.arcname:=input;
  800.       if gf.arcname='' then begin
  801.         fn:=getfname(gf.path,gf.fname);
  802.         if not exist(fn) then begin
  803.           writestr ('File not found!  Enter file now [y/n]? *');
  804.           if yes then makeasciigfile(fn)
  805.         end;
  806.         if not exist(fn) then exit;
  807.       end;
  808.       writestr ('Description:');
  809.       if length(input)=0 then exit;
  810.       gf.gfiledescr:=input;
  811.       writestr ('Sent by [CR/'+unam+']:');
  812.       if length(input)=0 then input:=unam;
  813.       gf.sentby:=input;
  814.       gf.filesize:=getfsize(fn);
  815.       gf.when:=now;
  816.       gf.downloaded:=0;
  817.       gf.specialfile:=false;
  818.       gf.newfile:=false;
  819.       seekgfile (numgfiles+1);
  820.       write (gfile,gf);
  821.       if gfilez>32760 then gfilez:=0;
  822.       gfilez:=gfilez+1;
  823.       if urec.lastgfiles>32760 then urec.lastgfiles:=0;
  824.       urec.lastgfiles:=urec.lastgfiles+1;
  825.       urec.gfuploads:=urec.gfuploads+1;
  826.       writelog (3,11,gf.gfiledescr);
  827.       writeurec
  828.     end;
  829.  
  830.     procedure editgfile;
  831.     var n:integer;
  832.         fn:anystr;
  833.     begin
  834.       n:=getgfilenum('Edit');
  835.       if n=0 then exit;
  836.       seekgfile (n);
  837.       read (gfile,gf);
  838.       getstr ('Filename',gf.fname,12);
  839.       getstr ('Path',gf.path,50);
  840.       getstr ('Archive Filename',gf.arcname,80);
  841.       if gf.arcname='' then begin
  842.        fn:=getfname(gf.path,gf.fname);
  843.        if not exist (fn) then begin
  844.         write (^B^M,fn,' not found!');
  845.         writestr (^M'Create new file '+fn+' [y/n]? *');
  846.         if yes then makeasciigfile(fn);
  847.         if not exist(fn) then exit;
  848.        end else gf.filesize:=getfsize(fn);
  849.       end;
  850.       getstr ('Description',gf.gfiledescr,75);
  851.       getstr ('Uploader',gf.sentby,28);
  852.       getboo ('Special File',gf.specialfile);
  853.       getboo ('New file',gf.newfile);
  854.       seekgfile (n);
  855.       write (gfile,gf);
  856.       writelog (3,3,gf.gfiledescr);
  857.     end;
  858.  
  859.     procedure killgarea;
  860.     var gfatmp:gfilearea;
  861.         cnt,n:integer;
  862.         oldname,newname:sstr;
  863.     begin
  864.       gfatmp:=gfa;
  865.       writestr ('Delete Area #'+strr(curarea)+' ['+gfatmp.Name+']: *');
  866.       if not yes then exit;
  867.       gfilez:=gfilez-numgfiles;
  868.       urec.lastgfiles:=urec.lastgfiles-numgfiles;
  869.       if gfilez<0 then gfilez:=0;
  870.       if urec.lastgfiles<0 then urec.lastgfiles:=0;
  871.       close (gfile);
  872.       oldname:=uploaddir+'gfile'+strr(curarea);
  873.       assign (gfile,oldname);
  874.       erase (gfile);
  875.       for cnt:=curarea to numareas-1 do begin
  876.         newname:=oldname;
  877.         oldname:=uploaddir+'gfile'+strr(cnt+1);
  878.         assign (gfile,oldname);
  879.         rename (gfile,newname);
  880.         n:=ioresult;
  881.         Seekgfilea (cnt+1);
  882.         read (gfilea,gfatmp);
  883.         seekgfilea (cnt);
  884.         write (gfilea,gfatmp);
  885.       end;
  886.       seekgfilea (numareas);
  887.       truncate (gfilea);
  888.       setarea (1)
  889.     end;
  890.  
  891.     procedure modgarea;
  892.     var gfatmp:gfilearea;
  893.     begin
  894.       gfatmp:=gfa;
  895.       getstr ('Area Name',gfatmp.Name,80);
  896.       getint ('Access Level',gfatmp.Level);
  897.       getstr ('Sponsor',gfatmp.Sponsor,30);
  898.       getboo ('Able to Upload here',gfatmp.upable);
  899.       getstr ('Upload Dir',gfatmp.gfileDir,50);
  900.       seekgfilea (curarea);
  901.       write (gfilea,gfatmp);
  902.       gfa:=gfatmp;
  903.     end;
  904.  
  905.     procedure deletegfile;
  906.     var cnt,n,anarky:integer;
  907.         f:file;
  908.         gfn:lstr;
  909.         floyd:userrec;
  910.     begin
  911.       n:=getgfilenum ('Delete');
  912.       if n=0 then exit;
  913.       seekgfile (n);
  914.       read (gfile,gf);
  915.       gfn:=getfname(gf.path,gf.fname);
  916.       gfn:=upstring(gfn);
  917.       writeln;
  918.       writehdr ('Delete G-File');
  919.       writeln (^R'Filename:    '^S,gfn);
  920.       writeln (^R'Size:        '^S,strlong(gf.filesize));
  921.       writeln (^R'Description: '^S,gf.gfiledescr);
  922.       writeln (^R'Uploader:    '^S,gf.sentby);
  923.       writeln (^R);
  924.       writestr ('Delete this [y/n]? *');
  925.       if not yes then exit;
  926.       writestr ('Erase Disk File '+gfn+'? *');
  927.       if yes then begin
  928.         if gf.arcname='' then begin
  929.         assign (f,getfname(gf.path,gf.fname));
  930.         erase (f);
  931.         if ioresult<>0 then writestr ('Couldn''t erase File.')
  932.        end else
  933.        writeln ('G-File is inside Archive; can''t erase it from here.');
  934.       end;
  935.       for cnt:=n+1 to numgfiles do begin
  936.         seekgfile (cnt);
  937.         read (gfile,gf);
  938.         seekgfile (cnt-1);
  939.         write (gfile,gf)
  940.       end;
  941.       seekgfile (numgfiles);
  942.       truncate (gfile);
  943.       if gfilez<0 then gfilez:=0;
  944.       gfilez:=gfilez-1;
  945.       if urec.lastgfiles<0 then urec.lastgfiles:=0;
  946.       urec.lastgfiles:=urec.lastgfiles-1;
  947.       writeurec;
  948.       writestr ('Remove Upload Credits from uploader [y/n]? *');
  949.       if yes then begin
  950.        anarky:=lookupuser (gf.sentby);
  951.        if anarky<>0 then begin
  952.         writeurec;
  953.         seek (ufile,anarky);
  954.         read (ufile,floyd);
  955.         floyd.gfuploads:=floyd.gfuploads-1;
  956.         seek (ufile,anarky);
  957.         write (ufile,floyd);
  958.         readurec
  959.        end;
  960.       end;
  961.       writestr (^M'Deleted.');
  962.       writelog (3,4,gf.gfileDescr)
  963.     end;
  964.  
  965.     procedure SortGArea;
  966.     var temp,mark,cnt,method:integer;
  967.         v1,v2:string[80];
  968.         gftmp:gfileRec;
  969.     begin
  970.       writehdr ('Sort G-Files');
  971.       writeln;
  972.       writeln ('[0]:Quit');
  973.       writeln ('[1]:Description');
  974.       writeln ('[2]:Filename');
  975.       writeln;
  976.       writestr ('Enter method: *');
  977.       method:=valu(input[1]);
  978.       if method=0 then exit;
  979.       mark:=numgfiles-1;
  980.       repeat
  981.         if mark<>0 then begin
  982.           temp:=mark;
  983.           mark:=0;
  984.           for cnt:=1 to temp do begin
  985.             seekgfile (cnt);
  986.             read (gfile,gf);
  987.             read (gfile,gftmp);
  988.             if method=1 then begin
  989.               v1:=upstring(gf.gfiledescr);
  990.               v2:=upstring(gftmp.gfiledescr);
  991.             end else begin
  992.               v1:=upstring(gf.fname);
  993.               v2:=upstring(gftmp.fname);
  994.             end;
  995.             if v1>v2 then begin
  996.               mark:=cnt;
  997.               seekgfile (cnt);
  998.               write (gfile,gftmp);
  999.               write (gfile,gf)
  1000.             end
  1001.           end
  1002.         end
  1003.       until mark=0
  1004.     end;
  1005.  
  1006.     procedure reordergareas;
  1007.     var cura,newa:integer;
  1008.         gfatmp:gfilearea;
  1009.         f1,f2:file;
  1010.         fn1,fn2:sstr;
  1011.     label exit;
  1012.     begin
  1013.       writehdr ('Reorder G-File Areas');
  1014.       writeln (^M'Number of G-File areas: ',numareas:1);
  1015.       for cura:=0 to numareas-2 do begin
  1016.         repeat
  1017.           writestr (^M^J+'New Area #'+strr(cura+1)+' [?/List]-[CR/Quit]:');
  1018.           if length(input)=0 then goto exit;
  1019.           if input='?' then begin
  1020.             listareas;
  1021.             newa:=-1
  1022.           end else begin
  1023.             newa:=valu(input)-1;
  1024.             if (newa<0) or (newa>=numareas) then begin
  1025.               writeln ('Not found!  Please re-enter...');
  1026.               newa:=-1
  1027.             end
  1028.           end
  1029.         until (newa>0);
  1030.         seek (gfilea,cura);
  1031.         read (gfilea,gfa);
  1032.         seek (gfilea,newa);
  1033.         read (gfilea,gfatmp);
  1034.         seek (gfilea,cura);
  1035.         write (gfilea,gfatmp);
  1036.         seek (gfilea,newa);
  1037.         write (gfilea,gfa);
  1038.         fn1:=uploaddir+'gfile';
  1039.         fn2:=fn1+strr(newa+1);
  1040.         fn1:=fn1+strr(cura+1);
  1041.         assign (f1,fn1);
  1042.         assign (f2,fn2);
  1043.         rename (f1,'Temp$$$$.%%%');
  1044.         rename (f2,fn1);
  1045.         rename (f1,fn2)
  1046.       end;
  1047.       exit:
  1048.       setarea (1)
  1049.     end;
  1050.  
  1051.     procedure Movegfile;
  1052.     var an,fn,old:integer;
  1053.         newfilesam,sambam,filesam,wangbang:anystr;
  1054.         darn:file;
  1055.         gftmp:gfileRec;
  1056.     begin
  1057.       fn:=GetgfileNum ('Move');
  1058.       old:=curarea;
  1059.       if fn=0 then exit;
  1060.       input:='';
  1061.       an:=GetAreaNum;
  1062.       if an=0 then exit;
  1063.       Seekgfile (fn);
  1064.       read (gfile,gftmp);
  1065.       if gftmp.arcname<>'' then begin
  1066.        writeln (^M'G-File is inside Archive ',gftmp.arcname,'. Cannot move.'^M);
  1067.        exit;
  1068.       end;
  1069.       removefile (fn);
  1070.       writestr('Physically move the file to correct area? *');
  1071.       write ('Moving...');
  1072.       filesam:=Getfname(gftmp.path,gftmp.fname);
  1073.       sambam:=gftmp.path;
  1074.       setarea(an);
  1075.       if (sambam<>gfa.gfileDir) then if yes then begin
  1076.         gftmp.path:=gfa.gfileDir;
  1077.         newfilesam:=Getfname(gftmp.path,gftmp.fname);
  1078.         exec('Copy',' '+filesam+' '+newfilesam+' >temp');
  1079.         wangbang:=filesam;
  1080.         assign(darn,wangbang);
  1081.         if exist(newfilesam) then erase (darn) else begin
  1082.           gftmp.path:=sambam;
  1083.           writeln('Uh oh... Bad error!');
  1084.         end;
  1085.       end;
  1086.       setarea (An);
  1087.       Addfile (gftmp);
  1088.       setarea (old);
  1089.       writeln (^B'Done.')
  1090.     end;
  1091.  
  1092.   procedure getpathname (fname:lstr; var path:lstr; var name:sstr);
  1093.   var p:integer;
  1094.   begin
  1095.     path:='';
  1096.     repeat
  1097.       p:=pos('\',fname);
  1098.       if p<>0 then begin
  1099.         path:=path+copy(fname,1,p);
  1100.         fname:=copy(fname,p+1,255)
  1101.       end
  1102.     until p=0;
  1103.     name:=fname
  1104.   end;
  1105.  
  1106.   procedure displayfile (var ffinfo:searchrec);
  1107.   var a:integer;
  1108.   begin
  1109.     a:=ffinfo.attr;
  1110.     if (a and 8)=8 then exit;
  1111.     tab (ffinfo.name,13);
  1112.     if (a and 16)=16
  1113.       then write ('Directory')
  1114.       else write (ffinfo.size);
  1115.     if (a and 1)=1 then write (' <read-only>');
  1116.     if (a and 2)=2 then write (' <hidden>');
  1117.     if (a and 4)=4 then write (' <system>');
  1118.     writeln
  1119.   end;
  1120.  
  1121.   procedure getfsize (var g:gfilerec);
  1122.   var df:file of byte;
  1123.   begin
  1124.     g.filesize:=-1;
  1125.     assign (df,getfname(g.path,g.fname));
  1126.     reset (df);
  1127.     if ioresult<>0 then exit;
  1128.     g.filesize:=filesize(df);
  1129.     close(df)
  1130.   end;
  1131.  
  1132.   procedure addresidentgfile (fname:lstr);
  1133.   var g:gfilerec;
  1134.       fn:anystr;
  1135.   begin
  1136.     getpathname (fname,g.path,g.fname);
  1137.     getfsize (g);
  1138.     if g.filesize=-1 then begin
  1139.       writeln ('File can''t be opened!');
  1140.       exit
  1141.     end;
  1142.       buflen:=70;
  1143.       writestr ('Description: &');
  1144.       g.gfiledescr:=input;
  1145.       getfsize (g);
  1146.       g.when:=now;
  1147.       g.sentby:=unam;
  1148.       g.downloaded:=0;
  1149.       g.specialfile:=false;
  1150.       g.newfile:=false;
  1151.       g.arcname:='';
  1152.       seekgfile (numgfiles+1);
  1153.       write (gfile,g);
  1154.       gfilez:=gfilez+1;
  1155.       writeln;
  1156.       writelog (3,11,g.gfiledescr)
  1157.   end;
  1158.  
  1159.   procedure addmultiplegfiles;
  1160.   var spath,pathpart:lstr;
  1161.       dummy:sstr;
  1162.       f:file;
  1163.       ffinfo:searchrec;
  1164.   begin
  1165.     if ulvl<sysoplevel then begin
  1166.       writeln (
  1167.         'Sorry, you may not add resident files without true sysop access!');
  1168.       exit
  1169.     end;
  1170.     writehdr ('Add Resident G-Files By Wildcard');
  1171.     writestr ('Search path/wildcard:');
  1172.     if length(input)=0 then exit;
  1173.     spath:=input;
  1174.     if spath[length(spath)]='\' then dec(spath[0]);
  1175.     assign (f,spath+'\con');
  1176.     reset (f);
  1177.     if ioresult=0 then begin
  1178.       close (f);
  1179.       spath:=spath+'\*.*'
  1180.     end;
  1181.     getpathname (spath,pathpart,dummy);
  1182.     findfirst (spath,$17,ffinfo);
  1183.     if doserror<>0
  1184.       then writeln ('No files found!')
  1185.       else
  1186.         while doserror=0 do begin
  1187.           writeln;
  1188.           displayfile (ffinfo);
  1189.           writestr ('Add this file [Y/N/X]? *');
  1190.           if yes
  1191.             then addresidentgfile (getfname(pathpart,ffinfo.name))
  1192.             else if (length(input)>0) and (upcase(input[1])='X')
  1193.               then exit;
  1194.           findnext (ffinfo)
  1195.         end
  1196.   end;
  1197.  
  1198.   function defaultdrive:byte;
  1199.   var r:registers;
  1200.   begin
  1201.     r.ah:=$19;
  1202.     intr ($21,r);
  1203.     defaultdrive:=r.al+1
  1204.   end;
  1205.  
  1206.   function unsigned (i:integer):real;
  1207.   begin
  1208.     if i>=0
  1209.       then unsigned:=i
  1210.       else unsigned:=65536.0+i
  1211.   end;
  1212.  
  1213.   procedure writefreespace (path:lstr);
  1214.   var drive:byte;
  1215.       r:registers;
  1216.       csize,free,total:real;
  1217.   begin
  1218.     r.ah:=$36;
  1219.     r.dl:=ord(upcase(path[1]))-64;
  1220.     intr ($21,r);
  1221.     if r.ax=-1 then begin
  1222.       writeln ('Invalid drive');
  1223.       exit
  1224.     end;
  1225.     csize:=unsigned(r.ax)*unsigned(r.cx);
  1226.     free:=csize*unsigned(r.bx);
  1227.     total:=csize*unsigned(r.dx);
  1228.     free:=free/1024;
  1229.     total:=total/1024;
  1230.     writeln (free:0:0,'k out of ',total:0:0,'k')
  1231.   end;
  1232.  
  1233.   procedure directory;
  1234.   var r:registers;
  1235.       ffinfo:searchrec;
  1236.       tpath:anystr;
  1237.       b:byte;
  1238.       cnt:integer;
  1239.   begin
  1240.     getdir (defaultdrive,tpath);
  1241.     if tpath[length(tpath)]<>'\' then tpath:=tpath+'\';
  1242.     tpath:=tpath+'*.*';
  1243.     writestr ('Path/Wildcard [CR for '+tpath+']:');
  1244.     writeln (^M);
  1245.     if length(input)<>0 then tpath:=input;
  1246.     writelog (16,10,tpath);
  1247.     findfirst (chr(defaultdrive+64)+':\*.*',8,ffinfo);
  1248.     if doserror<>0
  1249.       then writeln ('No volume label'^M)
  1250.       else writeln ('Volume label: ',ffinfo.name,^M);
  1251.     findfirst (tpath,$17,ffinfo);
  1252.     if doserror<>0 then writeln ('No files found.') else begin
  1253.       cnt:=0;
  1254.       while doserror=0 do begin
  1255.         cnt:=cnt+1;
  1256.         if not break then displayfile (ffinfo);
  1257.         findnext (ffinfo)
  1258.       end;
  1259.       writeln (^B^M'Total Files: ',cnt)
  1260.     end;
  1261.     write ('Free Disk Space: ');
  1262.     writefreespace (tpath)
  1263.   end;
  1264.  
  1265.   begin
  1266.     if not issysop then begin
  1267.       reqlevel (sysoplevel);
  1268.       exit
  1269.     end;
  1270.     repeat
  1271.       q:=menu ('G-File Sysop','SGFILE','QACDUKRMSOW@F');
  1272.       case q of
  1273.         2:addgfile;
  1274.         3:editgfile;
  1275.         4:deletegfile;
  1276.         5:;
  1277.         6:killgarea;
  1278.         7:modgarea;
  1279.         8:movegfile;
  1280.         9:sortgarea;
  1281.         10:reordergareas;
  1282.         11:addmultiplegfiles;
  1283.         12:directory;
  1284.       end
  1285.     until hungupon or (q=1)
  1286.   end;
  1287.  
  1288. var prompt:lstr;
  1289.     n:integer;
  1290.     k:char;
  1291.     q1:mstr;
  1292.     a:arearec;
  1293.     ms:boolean;
  1294.     dammit:boolean;
  1295.     q:integer;
  1296.     x1,x2,x3,zxcv1,zxcv2:integer;
  1297.     y1,y2,y3:real;
  1298. begin
  1299.   dammit:=false;
  1300.   showit:=true;
  1301.   writehdr ('G-Files Section');
  1302.   writeln;
  1303.   itsotay:=false;
  1304.   opengfile;
  1305.   if not itsotay then exit;
  1306.   seekgfilea(1);
  1307.   read (gfilea,gfa);
  1308.   if (urec.gfLevel<gfa.Level) then begin
  1309.     writeln('You don''t have access to the G-Files Section.');
  1310.     exit;
  1311.   end;
  1312.   x1:=urec.nbu;
  1313.   x2:=urec.numon;
  1314.   if x1<1 then x1:=1;
  1315.   if x2<1 then x2:=1;
  1316.   y1:=int(x1);
  1317.   y2:=int(x2);
  1318.   y1:=y1;
  1319.   y2:=y2;
  1320.   y3:=y1/y2;
  1321.   y3:=y3*100;
  1322.   x3:=trunc(y3);
  1323.   write (^R'Required Post/Call Ratio: ['^S);
  1324.   for zxcv1:=1 to 3-(length(strr(gfpcr))) do write (' ');
  1325.   write (strr(gfpcr));
  1326.   writeln ('%'^R']');
  1327.   write (^R'Your Post/Call Ratio:     ['^S);
  1328.   for zxcv2:=1 to 3-(length(strr(x3))) do write (' ');
  1329.   write (strr(x3));
  1330.   writeln ('%'^R']');
  1331.   writeln;
  1332.   write (^R'PCR Status: ['^S);
  1333.   if ulvl>=pcrexempt then write ('Exempt from PCR.') else
  1334.   if (x3<gfpcr) and (ulvl<pcrexempt) then write ('PCR too low!') else
  1335.   if (x3>=gfpcr) and (ulvl<pcrexempt) then write ('Passed PCR check.');
  1336.   writeln (^R']');
  1337.   writeln;
  1338.   if (x3<gfpcr) and (ulvl<pcrexempt) then begin
  1339.    writeln (^B^R'Your Posts-per-Call Ratio is too low!');
  1340.    writeln ('Go post a message or two.');
  1341.    close (gfile);
  1342.    close (gfilea);
  1343.    exit;
  1344.   end;
  1345.   yourgfstatus;
  1346.     setarea(1);
  1347.   repeat
  1348.     prompt:='';
  1349.     q:=menu ('G-Files Command','GFILE','QU%FAYNVDLG');
  1350.     case q of
  1351.       1:begin
  1352.           close(gfile);
  1353.           close(gfilea);
  1354.         end;
  1355.       2:uploadgfile;
  1356.       3:sysopcommands;
  1357.       4:fastlistgfiles;
  1358.       5:getarea;
  1359.       6:yourgfstatus;
  1360.       7:newscanall;
  1361.       8:newscan;
  1362.       9:begin
  1363.           n:=getgfilenum ('Download');
  1364.           if n>0 then showgfile(n);
  1365.         end;
  1366.       10:fastlistgfiles;
  1367.       11:offtcs;
  1368.     end;
  1369.   until hungupon or (q=1);
  1370. end;
  1371.  
  1372. begin
  1373. end.
  1374.