home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / SYSPC22.ZIP / BULLET.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-05-12  |  29.2 KB  |  1,240 lines

  1. overlay procedure bulletinmenu;
  2.  
  3.   procedure makeboard; forward;
  4.  
  5.   function sponsoron:boolean;
  6.   begin
  7.     sponsoron:=match(curboard.sponsor,unam)
  8.   end;
  9.  
  10.   procedure clearorder (var bo:boardorder);
  11.   var cnt:integer;
  12.   begin
  13.     for cnt:=0 to 255 do bo[cnt]:=cnt
  14.   end;
  15.  
  16.   procedure carryout (var bo:boardorder);
  17.   var u:userrec;
  18.       cnt,un:integer;
  19.  
  20.     procedure doone;
  21.     var cnt,q:integer;
  22.         ns,a1,a2:set of byte;
  23.     begin
  24.       fillchar (ns,32,0);
  25.       fillchar (a1,32,0);
  26.       fillchar (a2,32,0);
  27.       for cnt:=0 to 255 do begin
  28.         q:=bo[cnt];
  29.         if q<>cnt then begin
  30.           if q in u.newscanconfig then ns:=ns+[cnt];
  31.           if q in u.access1 then a1:=a1+[cnt];
  32.           if q in u.access2 then a2:=a2+[cnt]
  33.         end
  34.       end;
  35.       u.newscanconfig:=ns;
  36.       u.access1:=a1;
  37.       u.access2:=a2;
  38.       seek (ufile,un);
  39.       write (ufile,u)
  40.     end;
  41.  
  42.   begin
  43.     for cnt:=0 to 255 do if bo[cnt]=cnt then if cnt=255 then exit;
  44.     write (^B'*> Adjusting user access flags...');
  45.     seek (ufile,1);
  46.     for un:=1 to numusers do begin
  47.       if (un mod 10)=0 then write (' ',un);
  48.       read (ufile,u);
  49.       if length(u.handle)>0 then doone
  50.     end;
  51.     writeln ('Done <*');
  52.   end;
  53.  
  54.   procedure switchboards (bnum1,bnum2:integer; var bo:boardorder);
  55.   var bd1,bd2:boardrec;
  56.       n1:integer;
  57.   begin
  58.     seekbdfile (bnum1);
  59.     read (bdfile,bd1);
  60.     seekbdfile (bnum2);
  61.     read (bdfile,bd2);
  62.     seekbdfile (bnum1);
  63.     writebdfile (bd2);
  64.     seekbdfile (bnum2);
  65.     writebdfile (bd1);
  66.     n1:=bo[bnum1];
  67.     bo[bnum1]:=bo[bnum2];
  68.     bo[bnum2]:=n1
  69.   end;
  70.  
  71.   procedure setfirstboard; forward;
  72.  
  73.   procedure seekbfile (n:integer);
  74.   begin
  75.     seek (bfile,n-1); che
  76.   end;
  77.  
  78.   function numbuls:integer;
  79.   begin
  80.     numbuls:=filesize(bfile)
  81.   end;
  82.  
  83.   procedure assignbfile;
  84.   begin
  85.     assign (bfile,boarddir+curboardname+'.BUL')
  86.   end;
  87.  
  88.   procedure formatbfile;
  89.   begin
  90.     assignbfile;
  91.     rewrite (bfile);
  92.     curboardnum:=searchboard(curboardname);
  93.     if curboardnum=-1 then begin
  94.       curboardnum:=filesize(bdfile);
  95.       fillchar (curboard,sizeof(curboard),0);
  96.       writecurboard
  97.     end
  98.   end;
  99.  
  100.   procedure openbfile;
  101.   var b:bulrec;
  102.       i:integer;
  103.   begin
  104.     curboardnum:=searchboard (curboardname);
  105.     if curboardnum=-1 then begin
  106.       makeboard;
  107.       exit
  108.     end;
  109.     close (bfile);
  110.     assignbfile;
  111.     reset (bfile);
  112.     i:=ioresult;
  113.     if ioresult<>0 then formatbfile;
  114.     seekbdfile (curboardnum);
  115.     read (bdfile,curboard);
  116.   end;
  117.  
  118.   function boardexist(n:sstr):boolean;
  119.   begin
  120.     boardexist:=not (searchboard(n)=-1)
  121.   end;
  122.  
  123.   procedure addbul (var b:bulrec);
  124.   begin
  125.     seekbfile (numbuls+1);
  126.     write (bfile,b)
  127.   end;
  128.  
  129.   procedure delbul (bn:integer; deltext:boolean);
  130.   var c,un:integer;
  131.       b:bulrec;
  132.       u:userrec;
  133.   begin
  134.     if (bn<1) or (bn>numbuls) then exit;
  135.     seekbfile (bn);
  136.     read (bfile,b);
  137.     if deltext then deletetext (b.line);
  138.     for c:=bn to numbuls-1 do begin
  139.       seekbfile (c+1);
  140.       read (bfile,b);
  141.       seekbfile (c);
  142.       write (bfile,b)
  143.     end;
  144.     seekbfile (numbuls);
  145.     truncate (bfile)
  146.   end;
  147.  
  148.   procedure delboard (bdn:integer);
  149.   var bd1:boardrec;
  150.       cnt,nbds:integer;
  151.       bo:boardorder;
  152.   begin
  153.     clearorder (bo);
  154.     nbds:=filesize(bdfile)-1;
  155.     if nbds=0 then begin
  156.       close (bdfile);
  157.       rewrite (bdfile);
  158.       exit
  159.     end;
  160.     for cnt:=bdn to nbds-1 do begin
  161.       seekbdfile (cnt+1);
  162.       read (bdfile,bd1);
  163.       seekbdfile (cnt);
  164.       writebdfile (bd1);
  165.       bo[cnt]:=cnt+1
  166.     end;
  167.     seek (bdfile,nbds);
  168.     truncate (bdfile);
  169.     seek (bifile,nbds);
  170.     truncate (bifile);
  171.     carryout (bo)
  172.   end;
  173.  
  174.  
  175.  
  176. var q,curbul:integer;
  177.     b:bulrec;
  178.  
  179.   function queryaccess:accesstype;
  180.   begin
  181.     queryaccess:=getuseraccflag (urec,curboardnum)
  182.   end;
  183.  
  184.   procedure autodelete;
  185.   var cnt:integer;
  186.   begin
  187.     write ('*> Auto-delete active...Wait...');
  188.     for cnt:=6 downto 2 do delbul (cnt,true);
  189.     write (^H^H^H^H^H^H,'Continue <*');
  190.   end;
  191.  
  192.   procedure postbul;
  193.   var l:integer;
  194.       m:message;
  195.       b:bulrec;
  196.   begin
  197.     if ulvl<postlevel then begin
  198.       reqlevel(postlevel);
  199.       exit
  200.     end;
  201.     feed:=false;
  202.     sendtoistru:=true;
  203.     b.ranon:=false;
  204.     if reply=1 then sendtoistru:=false;
  205.     if reply=1 then l:=editor(m,false) else l:=editor(m,true);
  206.     sendtoistru:=false;
  207.     if l>=0 then
  208.       begin
  209.        urec.nbu:=urec.nbu+1;
  210.         writeurec;
  211.         if messages>32760 then messageS:=0;
  212.         messages:=messages+1;
  213.         newposts:=newposts+1;
  214.         b.anon:=m.anon;
  215.         b.title:=m.title;
  216.         b.leftda:=datestr;
  217.         b.leftti:=timestr;
  218.         b.leftby:=unam;
  219.         b.line:=l;
  220.         b.senttol:=senttol;
  221.         If Reply=0 then b.ranon:=false;
  222.         if reply=0 then replyanon:=false;
  223.         b.plevel:=ulvl;
  224.         if reply=1 then begin
  225.         b.title:='R) '+replyt;
  226.         b.senttol:=replyguy;
  227.         if canon then b.senttol:=anonymousstr;
  228.         b.anon:=m.anon;
  229.         b.ranon:=replyanon;
  230.         end;
  231.         addbul (b);
  232.         with curboard do
  233.           if autodel<=numbuls then autodelete
  234.       end
  235.   end;
  236.  
  237.  
  238.  
  239.   function checkcurbul:boolean;
  240.   begin
  241.     if (curbul<1) or (curbul>numbuls) then begin
  242.       checkcurbul:=false;
  243.       curbul:=0
  244.     end else checkcurbul:=true
  245.   end;
  246.  
  247.   procedure getbrec;
  248.   begin
  249.     if checkcurbul then begin
  250.       seekbfile (curbul);
  251.       read (bfile,b); che
  252.     end
  253.   end;
  254.  
  255.   procedure getbnum (txt:mstr);
  256.   var q:boolean;
  257.   begin
  258.     if length(input)>1
  259.       then curbul:=valu(copy(input,2,255))
  260.       else begin
  261.         writestr (^M'Bulletin to '+txt+':');
  262.         curbul:=valu(input)
  263.       end;
  264.     q:=checkcurbul
  265.   end;
  266.  
  267.   procedure readcurbul;
  268.   var q:anystr;
  269.       t:sstr;
  270.       cnt:integer;
  271.   begin
  272.     if checkcurbul then begin
  273.       getbrec;
  274.     write (^B'Bulletin: ['^S,curbul);
  275.     ansireset;
  276.     write ('] of ['^S,numbuls);
  277.     ansireset;
  278.     writeln (']');
  279.     write   ('From : [');
  280.     write (^S);
  281.       if b.anon
  282.         then
  283.           begin
  284.             canon:=true;
  285.             write (anonymousstr);
  286.             ansireset;
  287.             if issysop then writeln ('] (Actually by: '+b.leftby+')') else
  288.             writeln (']');
  289.           end
  290.         else begin
  291.       canon:=false;
  292.       write (^S,b.leftby);
  293.       ansireset;
  294.       writeln (']');
  295.       end;
  296.       write ('To   : ['^S,b.senttol);
  297.       ansireset;
  298.       writeln (']');
  299.       write ('Title: ['^S,b.title);
  300.       ansireset;
  301.       writeln (']');
  302.       if issysop or (not b.anon)
  303.   then begin
  304.         write('When : ['^S,b.leftda);
  305.         ansireset;
  306.         write('] at ['^S,b.leftti);
  307.         ansireset;
  308.         writeln (']');
  309.         end;
  310.       if break then exit;
  311.       printtext (b.line)
  312.     end
  313.   end;
  314.  
  315.     procedure sendbreply;
  316.   begin
  317.     if checkcurbul then begin
  318.       getbrec;
  319.       sendtoistru:=false;
  320.       reply:=1;
  321.       replyt:=b.title;
  322.       replyguy:=b.leftby;
  323.       replyanon:=b.anon;
  324.       postbul;
  325.       reply:=0;
  326.     end;
  327.   end;
  328.  
  329.   procedure killbul(f:integer);
  330.   var un:integer;
  331.       u:userrec;
  332.   begin
  333.     writehdr ('*> Bulletin Deletion <*');
  334.     if f<>1 then getbnum ('delete');
  335.     if not checkcurbul then exit;
  336.     getbrec;
  337.     if (not match(b.leftby,unam)) and (not issysop) and (not sponsoron)
  338.       then begin
  339.         writeln ('You didn''t post that!');
  340.         exit
  341.       end;
  342.     writeln ('Title:   [',b.title,']');
  343.     writeln;
  344.     writestr ('Delete this? *');
  345.     if not yes then exit;
  346.     un:=lookupuser (b.leftby);
  347.     if un<>0 then begin
  348.       writeurec;
  349.       seek (ufile,un);
  350.       read (ufile,u);
  351.       u.nbu:=u.nbu-1;
  352.       seek (ufile,un);
  353.       write (ufile,u);
  354.       readurec
  355.     end;
  356.     delbul (curbul,true);
  357.     writeln ('*> Bulletin deleted. <*');
  358.     writelog (4,5,b.title)
  359.   end;
  360.  
  361.     procedure readbul;
  362.  var r1,r2,max:integer;
  363.  begin
  364.  
  365.   Writeln(^B' '); writeln ('Read messages 1-',numbuls);
  366.   parserange (numbuls,r1,r2);
  367.  
  368.     if (r1>r2) then exit;
  369.     if (r1<1) then exit;
  370.             max:=r1;
  371.  
  372.     repeat
  373.     write(^B);
  374.     if ansi then ansicls;
  375.     if xpressed then begin
  376.                      writeln (^B'*> Read Aborted <*');exit;end;
  377.     if max<1 then max:=1;
  378.     curbul:=max;
  379.     if (curbul>numbuls) then exit;
  380.     readcurbul;
  381.     writeln (^M'Read Command:');
  382.     writestr ('[CR] Next [E]nter [P]revious [R]eply [D]elete [A]gain [Q]uit : *');
  383.     case upcase(input[1]) of
  384.     'R':sendbreply;
  385.     'A':max:=max-1;
  386.     'D':begin
  387.           killbul(1);
  388.           max:=max-1;
  389.         end;
  390.     'P':max:=max-2;
  391.     'Q':exit;
  392.     'E':postbul;
  393.        end;
  394.          max:=max+1;
  395.    until 0=1;
  396.   end;
  397.  
  398.   procedure readnextbul;
  399.   var t:integer;
  400.   begin
  401.     t:=curbul;
  402.     curbul:=curbul+1;
  403.     readcurbul;
  404.     if curbul=0 then curbul:=t
  405.   end;
  406.  
  407.   procedure readnum (n:integer);
  408.   begin
  409.     curbul:=n;
  410.     readcurbul
  411.   end;
  412.  
  413.   function haveaccess (n:integer):boolean;
  414.   var a:accesstype;
  415.   begin
  416.     curboardnum:=n;
  417.     seekbdfile (n);
  418.     read (bdfile,curboard);
  419.     a:=queryaccess;
  420.     if a=bylevel
  421.       then haveaccess:=ulvl>=curboard.level
  422.       else haveaccess:=a=letin
  423.   end;
  424.  
  425.   procedure makeboard;
  426.   begin
  427.     formatbfile;
  428.  
  429.     with curboard do begin
  430.       shortname:=curboardname;
  431.       buflen:=30;
  432.       writestr (^M'%> Board name: &');
  433.       boardname:=input;
  434.       buflen:=30;
  435.       writestr ('%> Sponsor (C/R for '+unam+'):');
  436.       if input='' then input:=unam;
  437.       sponsor:=input;
  438.       writestr ('%> Minimum level for entry:');
  439.       level:=valu(input);
  440.       writestr ('%> Autodelete after:');
  441.       autodel:=valu(input);
  442.       if autodel<10 then begin
  443.         writeln ('Must be at least 10!');
  444.         autodel:=10
  445.       end;
  446.       setallflags (curboardnum,bylevel);
  447.       writecurboard;
  448.       writeln ('%> Board created. <*');
  449.       writelog (4,4,boardname+' ['+shortname+']')
  450.     end
  451.   end;
  452.  
  453.   procedure setactive (nn:sstr);
  454.  
  455.     procedure doswitch;
  456.     begin
  457.       openbfile;
  458.       curbul:=0;
  459.       with curboard do begin
  460.        if ansi and urec.windows then begin
  461.         ansicls;
  462.         windowit (69,6,1,2);
  463.         movexy (4,3);
  464.         writeln ('Area          : '^S,shortname);
  465.         movexy (4,4);
  466.         writeln ('Name          : '^S,boardname);
  467.         movexy (4,5);
  468.         writeln ('Sponsor       : '^S,sponsor);
  469.         movexy (4,6);
  470.         writeln ('Bulletins     : '^S,numbuls);
  471.         movexy (1,9);
  472.         end
  473.         else begin
  474.         write (^M'*> Sub-board: ['^S,boardname);
  475.         ansireset;
  476.         writeln (']');
  477.         write ('*> Sponsor:   ['^S,sponsor);
  478.         ansireset;
  479.         writeln (']');
  480.         write   ('*> Bulletins: ['^S,numbuls);
  481.         ansireset;
  482.         writeln (']',^M)
  483.         end;
  484.       end;
  485.     end;
  486.  
  487.  
  488.     procedure tryswitch;
  489.     var n,s:integer;
  490.  
  491.       procedure denyaccess;
  492.       var b:bulrec;
  493.       begin
  494.         reqlevel (curboard.level);
  495.         setfirstboard
  496.       end;
  497.  
  498.     begin
  499.       curboardname:=nn;
  500.       curboardnum:=searchboard(nn);
  501.       if haveaccess(curboardnum)
  502.         then doswitch
  503.         else denyaccess
  504.     end;
  505.  
  506.   var b:bulrec;
  507.   begin
  508.     curbul:=0;
  509.     close (bfile);
  510.     curboardname:=nn;
  511.     if boardexist(nn) then tryswitch else begin
  512.       writeln ('*> Error : No such board: [',curboardname,']');
  513.       if issysop
  514.         then
  515.           begin
  516.             writestr (^M'%> Create one (Y/N)? *');
  517.             if yes
  518.               then
  519.                 begin
  520.                   makeboard;
  521.                   setactive (curboardname)
  522.                 end
  523.               else setfirstboard
  524.           end
  525.         else setfirstboard
  526.     end
  527.   end;
  528.  
  529.   function validbname (n:sstr):boolean;
  530.   var cnt:integer;
  531.   begin
  532.     validbname:=false;
  533.     if (length(n)=0) or (length(n)>8) then exit;
  534.     for cnt:=1 to length(n) do
  535.       if not (upcase(n[cnt]) in ['0'..'9','A'..'Z']) then exit;
  536.     validbname:=true
  537.   end;
  538.  
  539.   procedure listboards;
  540.   var cnt,oldcurboard:integer;
  541.       printed:boolean;
  542.   begin
  543.     oldcurboard:=curboardnum;
  544.     writeln (^M'[Number]   [Name]                      [Level]'^M);
  545.     if break then exit;
  546.     for cnt:=0 to filesize(bdfile)-1 do
  547.       if haveaccess(cnt) then
  548.         with curboard do begin
  549.           write ('[',shortname:8,'] ');
  550.           tab ('['+boardname,26);
  551.           writeln ('] [',level:5,']');
  552.  
  553.           if break then exit
  554.         end;
  555.     curboardnum:=oldcurboard;
  556.     seekbdfile (curboardnum);
  557.     read (bdfile,curboard)
  558.   end;
  559.  
  560.   procedure activeboard;
  561.   begin
  562.     if length(input)>1
  563.       then input:=copy(input,2,255)
  564.       else begin
  565.         listboards;
  566.         repeat
  567.           writestr (^M^M'Board number [?=List]:');
  568.           if input='?' then listboards
  569.         until (input<>'?') or hungupon;
  570.         end;
  571.     if hungupon or (length(input)=0) then exit;
  572.     if input[1]='*' then input:=copy(input,2,255);
  573.     if validbname(input)
  574.       then setactive (input)
  575.       else
  576.         begin
  577.           writeln (^M'*> Invalid board name! <*');
  578.           setfirstboard
  579.         end
  580.   end;
  581.  
  582.   procedure setfirstboard; { FORWARD }
  583.   begin
  584.     if filesize(bdfile)=0 then exit;
  585.     if not haveaccess(0)
  586.       then error ('*> User can''t access first board','','');
  587.     seek (bdfile,0);
  588.     read (bdfile,curboard);
  589.     curboardname:=curboard.shortname;
  590.     curboardnum:=0;
  591.     curbul:=0;
  592.     openbfile;
  593.     if (urec.windows) and (ansi) then
  594.     with curboard do begin
  595.      ansicls;
  596.         windowit (69,6,1,2);
  597.         movexy (4,3);
  598.         writeln ('Area          : '^S,shortname);
  599.         movexy (4,4);
  600.         writeln ('Name          : '^S,boardname);
  601.         movexy (4,5);
  602.         writeln ('Sponsor       : '^S,sponsor);
  603.         movexy (4,6);
  604.         writeln ('Bulletins     : '^S,numbuls);
  605.         movexy (1,9);
  606.     end;
  607.   end;
  608.  
  609.   procedure listbuls;
  610.   var cnt,bn:integer;
  611.       q:boolean;
  612.   begin
  613.     if length(input)>1 then begin
  614.       curbul:=valu(copy(input,2,255));
  615.       q:=checkcurbul
  616.     end;
  617.     if curbul=0
  618.       then
  619.         begin
  620.           writestr (^M'List titles starting at #*');
  621.           curbul:=valu(input)
  622.         end
  623.       else
  624.         if length(input)>1
  625.           then curbul:=valu(input)
  626.           else curbul:=curbul+10;
  627.     if not checkcurbul then curbul:=1;
  628.     writeln ('Titles:'^M);
  629.     for cnt:=0 to 9 do
  630.       begin
  631.         bn:=curbul+cnt;
  632.         if (bn>0) and (bn<=numbuls) then
  633.           begin
  634.             seekbfile (bn);
  635.             read (bfile,b);
  636.             write (bn,'. ',b.title,' by ');
  637.             if not b.anon then writeln (b.leftby) else writeln (anonymousstr);
  638.             if break then exit
  639.           end
  640.       end
  641.   end;
  642.  
  643.  
  644.  
  645.   procedure editbul;
  646.   var me:message;
  647.   begin
  648.     getbnum ('edit');
  649.     if not checkcurbul then exit;
  650.     getbrec;
  651.     if (not match(b.leftby,unam)) and (not issysop) and (not sponsoron)
  652.       then begin
  653.         writeln ('You didn''t post that!');
  654.         exit
  655.       end;
  656.     reloadtext (b.line,me);
  657.     me.title:=b.title;
  658.     me.anon:=b.anon;
  659.     if reedit (me,true) then begin
  660.       writelog (4,6,b.title);
  661.       deletetext (b.line);
  662.       b.line:=maketext (me);
  663.       if b.line<0 then begin
  664.         write (^M'*> Deleting bulletin...');
  665.         writeln ('Done <*');
  666.         delbul (curbul,false)
  667.       end else begin
  668.         seekbfile (curbul);
  669.         write (bfile,b)
  670.       end
  671.     end
  672.   end;
  673.  
  674.   procedure boardsponsor;
  675.  
  676.     procedure getbgen (txt:mstr; var q);
  677.     var s:lstr absolute q;
  678.     begin
  679.       writeln (^B'Current ',txt,': ',s);
  680.       buflen:=30;
  681.       writestr ('Enter new '+txt+':');
  682.       if length(input)>0 then s:=input
  683.     end;
  684.  
  685.     procedure getbint (txt:mstr; var i:integer);
  686.     var a:anystr;
  687.     begin
  688.       a:=strr(i);
  689.       getbgen (txt,a);
  690.       i:=valu(a);
  691.       writecurboard
  692.     end;
  693.  
  694.     procedure getbstr (txt:mstr; var q);
  695.     begin
  696.       getbgen (txt,q);
  697.       writecurboard
  698.     end;
  699.  
  700.     procedure setacc (ac:accesstype; un:integer);
  701.     var u:userrec;
  702.     begin
  703.       seek (ufile,un);
  704.       read (ufile,u);
  705.       setuseraccflag (u,curboardnum,ac);
  706.       seek (ufile,un);
  707.       write (ufile,u)
  708.     end;
  709.  
  710.     function queryacc (un:integer):accesstype;
  711.     var u:userrec;
  712.     begin
  713.       seek (ufile,un);
  714.       read (ufile,u);
  715.       queryacc:=getuseraccflag (u,curboardnum)
  716.     end;
  717.  
  718.     overlay procedure setnameaccess;
  719.     var un,n:integer;
  720.         ac:accesstype;
  721.         q,unm:mstr;
  722.     begin
  723.       writestr (^M'Change access for user:');
  724.       un:=lookupuser(input);
  725.       if un=0 then begin
  726.         writeln ('No such user!');
  727.         exit
  728.       end;
  729.       unm:=input;
  730.       ac:=queryacc(un);
  731.       writeln (^B^M'Current access: ',accessstr[ac]);
  732.       getacflag (ac,q);
  733.       if ac=invalid then exit;
  734.       if un=unum then writeurec;
  735.       setacc (ac,un);
  736.       if un=unum then readurec;
  737.       case ac of
  738.         letin:n:=1;
  739.         keepout:n:=2;
  740.         bylevel:n:=3
  741.       end;
  742.       writelog (5,n,unm)
  743.     end;
  744.  
  745.     overlay procedure setallaccess;
  746.     var cnt:integer;
  747.         ac:accesstype;
  748.         q:mstr;
  749.     begin
  750.       writehdr ('Set Everyone''s Access');
  751.       getacflag (ac,q);
  752.       if ac=invalid then exit;
  753.       writeurec;
  754.       setallflags (curboardnum,ac);
  755.       readurec;
  756.       writeln ('Done.');
  757.       writelog (5,4,accessstr[ac])
  758.     end;
  759.  
  760.     overlay procedure listaccess;
  761.  
  762.       procedure listacc (all:boolean);
  763.       var cnt:integer;
  764.           a:accesstype;
  765.           u:userrec;
  766.  
  767.         procedure writeuser;
  768.         begin
  769.           if all
  770.             then
  771.               begin
  772.                 tab (u.handle,30);
  773.                 if a=bylevel
  774.                   then writeln ('Level='+strr(u.level))
  775.                   else writeln ('Let in')
  776.               end
  777.             else writeln (u.handle)
  778.         end;
  779.  
  780.       begin
  781.         seek (ufile,1);
  782.         for cnt:=1 to numusers do begin
  783.           read (ufile,u);
  784.           a:=getuseraccflag (u,curboardnum);
  785.           case a of
  786.             letin:writeuser;
  787.             bylevel:if all and (u.level>=curboard.level) then writeuser
  788.           end;
  789.           if break then exit
  790.         end
  791.       end;
  792.  
  793.     begin
  794.       writestr (
  795. 'List A)ll users who have access, or only those with S)pecial access? *');
  796.       if length(input)=0 then exit;
  797.       case upcase(input[1]) of
  798.         'A':listacc (true);
  799.         'S':listacc (false)
  800.       end
  801.     end;
  802.  
  803.     overlay procedure getblevel;
  804.     var b:bulrec;
  805.     begin
  806.       getbint ('level',curboard.level);
  807.       writelog (5,12,strr(curboard.level))
  808.     end;
  809.  
  810.     overlay procedure getautodel;
  811.     var b:bulrec;
  812.     begin
  813.       with curboard do begin
  814.         getbint ('auto-delete',autodel);
  815.         if autodel<10
  816.           then
  817.             begin
  818.               writeln (^B'*> Illegal Setting. Value at 10 <*');
  819.               autodel:=numbuls+1;
  820.               if autodel<10 then autodel:=10;
  821.               writeln (^B'Setting autodelete to ',autodel);
  822.               writecurboard
  823.             end
  824.           else
  825.             if autodel<=numbuls
  826.               then
  827.                 begin
  828.                   writeln (^B'*> Deleting bulletins...');
  829.                   while autodel<=numbuls do delbul (2,true)
  830.                 end
  831.       end;
  832.       writelog (5,11,strr(curboard.autodel))
  833.     end;
  834.  
  835.  
  836.  
  837.     overlay procedure movebulletin;
  838.     var b:bulrec;
  839.         tcb:boardrec;
  840.         tcbn,dbn,bnum:integer;
  841.         tcbname,dbname:sstr;
  842.     begin
  843.       writehdr ('Bulletin Move');
  844.       getbnum ('move');
  845.       if not checkcurbul then exit;
  846.       bnum:=curbul;
  847.       seekbfile (bnum);
  848.       read (bfile,b);
  849.       writestr ('Move "'+b.title+'" posted by '+b.leftby+
  850.         ' to which board? *');
  851.       if length(input)=0 then exit;
  852.       tcbname:=curboardname;
  853.       dbname:=input;
  854.       dbn:=searchboard(dbname);
  855.       if dbn=-1 then begin
  856.         writeln ('No such board!');
  857.         exit
  858.       end;
  859.       write ('*> Moving...');
  860.       delbul (bnum,false);
  861.       close (bfile);
  862.       curboardname:=dbname;
  863.       openbfile;
  864.       addbul (b);
  865.       close (bfile);
  866.       curboardname:=tcbname;
  867.       openbfile;
  868.       writelog (5,13,b.title);
  869.       writeln (^B'Done <*')
  870.     end;
  871.  
  872.  
  873.  
  874.     overlay procedure setsponsor;
  875.     var un:integer;
  876.         b:bulrec;
  877.     begin
  878.       writestr ('%> New sponsor:');
  879.       if length(input)=0 then exit;
  880.       un:=lookupuser (input);
  881.       if un=0
  882.         then writeln ('%> No such user. <%')
  883.         else
  884.           begin
  885.             curboard.sponsor:=input;
  886.             writelog (5,8,input);
  887.             writecurboard
  888.           end
  889.     end;
  890.  
  891.     overlay procedure renameboard;
  892.     var sn:sstr;
  893.         nfp,nbf,nff:lstr;
  894.         qf:file;
  895.         d:integer;
  896.     begin
  897.       getbstr ('board name',curboard.boardname);
  898.       sn:=curboard.shortname;
  899.       getbgen ('access name/number',sn);
  900.       writelog (5,5,curboard.boardname+' ['+sn+']');
  901.       if match(sn,curboard.shortname) then exit;
  902.       if not validbname(sn) then begin
  903.         writeln ('Invalid board name!');
  904.         exit
  905.       end;
  906.       if boardexist(sn) then begin
  907.         writeln ('*> Board already exists <*');
  908.         exit
  909.       end;
  910.       curboard.shortname:=sn;
  911.       writecurboard;
  912.       close (bfile);
  913.       nfp:=boarddir+sn+'.';
  914.       nbf:=nfp+'BUL';
  915.       nff:=nfp+'FIL';
  916.       assign (qf,nbf);
  917.       erase (qf);
  918.       d:=ioresult;
  919.       assign (qf,nff);
  920.       erase (qf);
  921.       d:=ioresult;
  922.       rename (bfile,nbf);
  923.       setfirstboard;
  924.       q:=9
  925.     end;
  926.  
  927.     overlay procedure killboard;
  928.     var cnt:integer;
  929.         f:file;
  930.         fr:filerec;
  931.         bd:boardrec;
  932.     begin
  933.       writestr ('*> Kill board:  Are you sure? *');
  934.       if not yes then exit;
  935.       writelog (5,10,'');
  936.       writeln (^B^M'*> Deleting messages... <*');
  937.       for cnt:=numbuls downto 1 do
  938.         begin
  939.           delbul(cnt,true);
  940.           write (cnt,' ')
  941.         end;
  942.       writeln (^B^M'*> Deleting sub-board files... <*');
  943.       close (bfile);
  944.       assignbfile;
  945.       erase (bfile);
  946.       if ioresult<>0 then writeln (^B'Error erasing board file.');
  947.       writeln (^M'*> Removing sub-board... <*');
  948.       delboard (curboardnum);
  949.       writeln (^B'*> Sub-board erased <*');
  950.       setfirstboard;
  951.       q:=9
  952.     end;
  953.  
  954.     overlay procedure sortboards;
  955.     var cnt,mark,temp:integer;
  956.         bd1,bd2:boardrec;
  957.         bn1,bn2:sstr;
  958.         bo:boardorder;
  959.     begin
  960.       writestr ('Sort sub-boards: Are you sure? *');
  961.       if not yes then exit;
  962.       clearorder (bo);
  963.       mark:=filesize(bdfile)-1;
  964.       repeat
  965.         if mark<>0 then begin
  966.           temp:=mark;
  967.           mark:=0;
  968.           for cnt:=0 to temp-1 do begin
  969.             seek (bifile,cnt);
  970.             read (bifile,bn1);
  971.             read (bifile,bn2);
  972.             if upstring(bn1)>upstring(bn2) then begin
  973.               mark:=cnt;
  974.               switchboards (cnt,cnt+1,bo)
  975.             end
  976.           end
  977.         end
  978.       until mark=0;
  979.       carryout (bo);
  980.       writelog (5,16,'');
  981.       setfirstboard;
  982.       q:=9
  983.     end;
  984.  
  985.     overlay procedure orderboards;
  986.     var numb,curb,newb:integer;
  987.         bo:boardorder;
  988.     label exit;
  989.     begin
  990.       clearorder (bo);
  991.       writehdr ('Re-order sub-boards');
  992.       numb:=filesize (bdfile);
  993.       thereare (numb,'sub-board','sub-boards');
  994.       for curb:=0 to numb-2 do begin
  995.         repeat
  996.           writestr ('New board #'+strr(curb+1)+' [?=List, CR to quit]:');
  997.           if length(input)=0 then goto exit;
  998.           if input='?'
  999.             then
  1000.               begin
  1001.                 listboards;
  1002.                 newb:=-1
  1003.               end
  1004.             else
  1005.               begin
  1006.                 newb:=searchboard(input);
  1007.                 if newb<0 then writeln ('Not found!  Please re-enter...')
  1008.               end
  1009.         until (newb>=0);
  1010.         switchboards (curb,newb,bo)
  1011.       end;
  1012.       exit:
  1013.       carryout (bo);
  1014.       writelog (5,14,'');
  1015.       q:=9;
  1016.       setfirstboard
  1017.     end;
  1018.  
  1019.  
  1020.  
  1021.   begin
  1022.     if (not sponsoron) and (not issysop) then begin
  1023.       writeln ('Nice try, except you aren''t the sponsor.');
  1024.       exit
  1025.     end;
  1026.     writelog (4,3,curboard.boardname+' ['+curboard.shortname+']');
  1027.     repeat
  1028.       q:=menu ('Sponsor','SPONSOR','DLSTMWUEQRKC@BO@VA@H');
  1029.       case q of
  1030.         1:getautodel;
  1031.         2:getblevel;
  1032.         3:setsponsor;
  1033.         4:;
  1034.         5:;
  1035.         6:;
  1036.         7:setnameaccess;
  1037.         8:setallaccess;
  1038.         10:renameboard;
  1039.         11:killboard;
  1040.         12:sortboards;
  1041.         13:movebulletin;
  1042.         14:orderboards;
  1043.         15:listaccess;
  1044.         16:;
  1045.         17:;
  1046.       end
  1047.     until (q=9) or hungupon
  1048.   end;
  1049.  
  1050.   var beenaborted:boolean;
  1051.  
  1052.   function aborted:boolean;
  1053.   begin
  1054.     if beenaborted then begin
  1055.       aborted:=true;
  1056.       exit
  1057.     end;
  1058.     aborted:=xpressed or hungupon;
  1059.     if xpressed then begin
  1060.       beenaborted:=true;
  1061.       writeln (^B'*> NewScan Aborted! <*')
  1062.     end
  1063.   end;
  1064.  
  1065.   procedure newscanboard;
  1066.  
  1067.   var newmsgs:boolean;
  1068.  
  1069.   begin
  1070.     beenaborted:=false;
  1071.     newmsgs:=false;
  1072.     for curbul:=1 to numbuls do begin
  1073.       getbrec;
  1074.   if later (b.leftda,b.leftti,urec.ldmns,urec.ltmns) or
  1075.      later (b.leftda,b.leftti,lastonda,lastonti) then begin
  1076.         readnum (curbul);
  1077.    repeat
  1078.    writeln (^M'NewScan Command:');
  1079.    writestr ('[CR] Next [E]nter [R]eply [D]elete [A]gain [S]kip Area [Q]uit: *');
  1080.     ns:=true;
  1081.     if length(input)=0 then input:=' ';
  1082.     input:=upcase(input[1]);
  1083.     if (input='R') then sendbreply else
  1084.     if (input='D') then killbul(1);
  1085.     if (input='E') then postbul;
  1086.     if (input='A') then readnum (curbul);
  1087.     if (input='S') then exit;
  1088.     if (input='Q') then begin
  1089.     dogit:=true;
  1090.     exit;
  1091.     end;
  1092.       newmsgs:=true;
  1093.       writeln;
  1094.     until input<>'A';
  1095.       end;
  1096.  
  1097.       if aborted then exit
  1098.     end;
  1099.  
  1100.     if (postprompts in urec.config) and newmsgs and (ulvl>=postlevel)
  1101.       then begin
  1102.         writestr (^M'Post now? *');
  1103.         writeln;
  1104.         if yes then postbul
  1105.       end
  1106.   end;
  1107.  
  1108.   procedure newscanall;
  1109.   var cb:integer;
  1110.   begin
  1111.     dogit:=false;
  1112.     beenaborted:=false;
  1113.     writehdr ('*> Newscanning <*');
  1114.     if aborted then exit;
  1115.     for cb:=0 to filesize(bdfile)-1 do begin
  1116.       if aborted then exit;
  1117.       if dogit then exit;
  1118.       if haveaccess(cb) and (not (cb in urec.newscanconfig)) then begin
  1119.         curboardname:=curboard.shortname;
  1120.         openbfile;
  1121.         if aborted then exit;
  1122.         writeln (^B^M'*> Sect: ',curboard.boardname,'...'^M);
  1123.         ns:=true;
  1124.         if aborted then exit;
  1125.         newscanboard
  1126.       end
  1127.     end;
  1128.     writeln (^B^M'*> Newscan complete <*'^G);
  1129.     ns:=false;
  1130.     urec.lastmessages:=messages;
  1131.     urec.ldmns:=datestr;
  1132.     urec.ltmns:=timestr;
  1133.     writeurec;
  1134.     setfirstboard
  1135.   end;
  1136.  
  1137.   procedure noboards;
  1138.   begin
  1139.     writeln ('No sub-boards exist!');
  1140.     if not issysop then exit;
  1141.     writestr ('Create the first sub-board now? *');
  1142.     if not yes then exit;
  1143.     writestr ('Enter its access name/number:');
  1144.     if not validbname(input) then writeln (^B'Invalid board name!') else begin
  1145.       curboardname:=input;
  1146.       makeboard
  1147.     end
  1148.   end;
  1149.  
  1150.   procedure togglenewscan;
  1151.   begin
  1152.     write ('Newscan this board: ');
  1153.     if curboardnum in urec.newscanconfig
  1154.       then
  1155.         begin
  1156.           writeln ('Yes');
  1157.           urec.newscanconfig:=urec.newscanconfig-[curboardnum]
  1158.         end
  1159.       else
  1160.         begin
  1161.           writeln ('No');
  1162.           urec.newscanconfig:=urec.newscanconfig+[curboardnum]
  1163.         end
  1164.   end;
  1165.  
  1166.   procedure nextsubboard;
  1167.   var cb:integer;
  1168.       obn:sstr;
  1169.   begin
  1170.     obn:=curboardname;
  1171.     cb:=curboardnum;
  1172.     while cb<filesize(bdfile) do begin
  1173.       cb:=cb+1;
  1174.       if haveaccess (cb) then begin
  1175.         seek (bifile,cb);
  1176.         read (bifile,obn);
  1177.         setactive (obn);
  1178.         exit
  1179.       end
  1180.     end;
  1181.     writestr ('This is the last sub-board!');
  1182.     setactive (obn)
  1183.   end;
  1184.  
  1185. var boo:boolean;
  1186. label exit;
  1187. begin
  1188.   cursection:=bulletinsysop;
  1189.   openbdfile;
  1190.   if filesize(bdfile)=0 then begin
  1191.     noboards;
  1192.     if filesize(bdfile)=0 then begin
  1193.       closebdfile;
  1194.       goto exit
  1195.     end
  1196.   end;
  1197.   if not haveaccess(0)
  1198.     then
  1199.       begin
  1200.         writeln (^B'You do not have access to the first sub-board!');
  1201.         closebdfile;
  1202.         goto exit
  1203.       end;
  1204.   setfirstboard;
  1205.   repeat
  1206.     boo:=checkcurbul;
  1207.  
  1208.     with curboard do
  1209.       writeln (^M,'[',shortname,']:[',boardname,'] Message ',curbul,' of ',numbuls);
  1210.     if sponsoron or issysop
  1211.       then writeln ('%: Board sponsor commands');
  1212.     ns:=false;
  1213.     q:=menu ('Bulletin','BULLET','PRDFUKT*MQ#_%LNBAVCHES+');
  1214.     case q of
  1215.       1:postbul;
  1216.       2:readbul;
  1217.       3:;
  1218.       4,22:sendmailto (curboard.sponsor,false);
  1219.       5:;
  1220.       6:killbul(0);
  1221.       8,16,17:activeboard;
  1222.       7:listbuls;
  1223.       9:;
  1224.       12:if not hungupon then readnextbul;
  1225.       13:boardsponsor;
  1226.       14:;
  1227.       15:newscanall;
  1228.       18:newscanboard;
  1229.       19:togglenewscan;
  1230.       20:;
  1231.       21:editbul;
  1232.       23:nextsubboard;
  1233.       else if q<0 then readnum (-q)
  1234.     end
  1235.   until (q=10) or hungupon or (filesize(bdfile)=0);
  1236.   exit:
  1237.   close (bfile);
  1238.   closebdfile
  1239. end;
  1240.