home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / SYSPC22.ZIP / MAINMENU.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-02-14  |  26.3 KB  |  1,093 lines

  1.  
  2. overlay procedure editusers;
  3. var eunum:integer;
  4.  
  5.   procedure elistusers;
  6.   var cnt,f,l:integer;
  7.       u:userrec;
  8.   begin
  9.     parserange (numusers,f,l);
  10.     seek (ufile,f);
  11.     for cnt:=f to l do begin
  12.       read (ufile,u);
  13.       tab (strr(cnt)+'. ',5);
  14.       if break then exit;
  15.       tab (u.handle,31);
  16.       if break then exit;
  17.       writestr (strr(u.level));
  18.       if break then exit
  19.     end
  20.   end;
  21.  
  22. begin
  23.   repeat
  24.     writestr (^M'User to edit [?=list]:');
  25.     if input='?'
  26.       then elistusers
  27.       else if (length(input)=0) or (match(input,'Q'))
  28.         then exit
  29.         else begin
  30.           eunum:=lookupuser (input);
  31.           if eunum=0
  32.             then writestr ('User not found!')
  33.             else edituser (eunum)
  34.         end
  35.   until hungupon
  36. end;
  37.  
  38. overlay procedure summonsysop;
  39. var tf:text;
  40.     k:char;
  41. begin
  42.   chatmode:=not chatmode;
  43.   bottomline;
  44.   if chatmode
  45.     then
  46.       if sysopisavail
  47.         then
  48.           begin
  49.             writestr ('Enter a short reason: &');
  50.             chatreason:=input;
  51.             if length(input)=0 then begin
  52.               chatmode:=false;
  53.               exit
  54.             end;
  55.             writelog (1,3,chatreason);
  56.             splitscreen (4);
  57.             top;
  58.             clrscr;
  59.             writeln (usr,unam,' wants to chat!  His reason:');
  60.             write (usr,chatreason);
  61.             bottom;
  62.             assign (tf,'Summon');
  63.             reset (tf);
  64.             if ioresult=0
  65.               then
  66.                 while (not (eof(tf) or hungupon)) and chatmode do
  67.                   begin
  68.                     read (tf,k);
  69.                     nobreak:=true;
  70.                     if ord(k)=7 then summonbeep else writechar (k);
  71.                     if keyhit then begin
  72.                       k:=bioskey;
  73.                       clearbreak;
  74.                       chat (false)
  75.                     end
  76.                   end;
  77.             if chatmode
  78.               then writestr (^M'Use [C] again to turn off page.')
  79.               else unsplit
  80.           end
  81.         else
  82.           begin
  83.             writeln ('*> Sysop is not available <*');
  84.             chatmode:=false;
  85.             if chatnum=3 then writeln (^M'*> Don''t Push It!!! One more time and you will be logged off <*');
  86.             if chatnum>=4 then begin
  87.             writeln (^M'*> Some people NEVER learn <*');
  88.             disconnect;
  89.             end;
  90.             writelog (1,2,'')
  91.           end
  92.     else writestr ('Page off.  Use [C] to turn it back on.');
  93.   chatnum:=chatnum+1;
  94.   clearbreak
  95. end;
  96.  
  97. overlay procedure offtheforum;
  98. var q,n:integer;
  99.     tn:file of integer;
  100.     m:message;
  101. begin
  102.   writestr ('Hang up now? *');
  103.   if yes then begin
  104.     writestr ('Leave message to next user? *');
  105.     if yes then begin
  106.       q:=editor(m,false);
  107.       if q>=0 then begin
  108.         if tonext>=0 then deletetext (tonext);
  109.         tonext:=q;
  110.         writestatus
  111.       end
  112.     end;
  113.     printfile (textfiledir+'GoodBye');
  114.     disconnect
  115.   end
  116. end;
  117.  
  118. overlay procedure listusers;
  119. var cnt:integer;
  120.     u:userrec;
  121. begin
  122.   writeln (^B'[Name]                             [Level]  [Calls]  [Posts]  [Last Login]'^M);
  123.   if break then exit;
  124.   for cnt:=1 to numusers do
  125.     begin
  126.       seek (ufile,cnt);
  127.       read (ufile,u); che;
  128.       if length(u.handle)>0 then begin
  129.         tab (u.handle,35);
  130.         if break then exit;
  131.      {   if u.level>31 and ulvl<31 then
  132.          writestr ('31')
  133.         else  }
  134.         tab (strr(u.level),9);
  135.         if break then exit;
  136.         tab (strr(u.numon),9);
  137.         if break then exit;
  138.         tab (strr(u.nbu),9);
  139.         if break then exit;
  140.         writeln (u.londa);
  141.       end
  142.     end
  143. end;
  144.  
  145. overlay procedure editnews;
  146. var nn,numnews:integer;
  147.     nf:file of newsrec;
  148.  
  149.   procedure getnn (txt:mstr);
  150.   begin
  151.     writestr ('News number to '+txt+':');
  152.     nn:=valu(input);
  153.     if (nn<1) or (nn>numnews) then nn:=0
  154.   end;
  155.  
  156.   procedure delnews;
  157.   var cnt:integer;
  158.       r:newsrec;
  159.   begin
  160.     if nn=0 then getnn ('delete');
  161.     if nn<>0 then begin
  162.       seek (nf,nn-1);
  163.       read (nf,r); che;
  164.       deletetext (r.where);
  165.       numnews:=filesize(nf)-1;
  166.       for cnt:=nn to numnews do
  167.         begin
  168.           seek (nf,cnt);
  169.           read (nf,r);
  170.           seek (nf,cnt-1);
  171.           write (nf,r)
  172.         end;
  173.       seek (nf,numnews);
  174.       truncate (nf)
  175.     end
  176.   end;
  177.  
  178.   procedure listnews;
  179.   var cnt:integer;
  180.       r:newsrec;
  181.       sector:integer;
  182.       q:buffer;
  183.       l:anystr;
  184.       k:char;
  185.   begin
  186.     clearbreak;
  187.     for cnt:=1 to numnews do begin
  188.       seek (nf,cnt-1);
  189.       read (nf,r);
  190.       write (strr(cnt)+'. ');
  191.       writeln (r.title);
  192.       if break then exit
  193.     end;
  194.     writeln
  195.   end;
  196.  
  197.   procedure viewnews;
  198.   var r:newsrec;
  199.   begin
  200.     if nn=0 then getnn ('view');
  201.     if nn<>0 then begin
  202.       seek (nf,nn-1);
  203.       read (nf,r); che;
  204.       writeln ('Title: ',r.title);
  205.       writeln ('Level: ',r.Level);
  206.       writeln ('Date : ',r.date,' at ',r.time);
  207.       writeln;
  208.       printtext (r.where)
  209.     end
  210.   end;
  211.  
  212.   procedure adddnews;
  213.   begin
  214.     close (nf);
  215.     addnews;
  216.     assign (nf,'News');
  217.     reset (nf)
  218.   end;
  219.  
  220. var q:integer;
  221. begin
  222.   assign (nf,'News');
  223.   reset (nf);
  224.   if ioresult<>0 then writestr ('No news!  Use [A] to add some!') else begin
  225.     repeat
  226.       numnews:=filesize(nf);
  227.       write (^B^M'News entries: ',numnews);
  228.       q:=menu ('News edit','NEWS','ADLVQ');
  229.       nn:=valu(copy(input,2,255));
  230.       if (nn<1) or (nn>numnews) then nn:=0;
  231.       case q of
  232.         1:adddnews;
  233.         2:delnews;
  234.         3:listnews;
  235.         4:viewnews
  236.       end;
  237.       if numnews=0 then begin
  238.         close (nf);
  239.         erase (nf);
  240.         writestr ('No more news!  Use [A] to add some.');
  241.         q:=5
  242.       end
  243.     until (q=5) or hungupon
  244.   end;
  245.   close (nf)
  246. end;
  247.  
  248. overlay procedure yourstatus;
  249. begin
  250.   writehdr (' *> Your Status <* ');
  251.   writeln;
  252.   writeln (' *> Name:   '^S,unam,
  253.          ^M' *> Level:  '^S,ulvl,
  254.          ^M' *> Calls:  '^S,urec.numon,
  255.          ^M' *> Posted: '^S,urec.nbu,
  256.        ^M^M' *> G-File Transfers <* ',
  257.        ^M^M' *> Uploads:     '^S,urec.gfup,
  258.          ^M' *> Downloads:   '^S,urec.gfdown,
  259.        ^M^M' *> Transfer Section <* ',
  260.        ^M^M' *> Uploads:     '^S,urec.uploads,
  261.          ^M' *> Downloads:   '^S,urec.downloads,
  262.        ^M^M' *> Total time on: '^S,urec.totaltime:0:0,
  263.          ^M' *> Time left:     '^S,timeleft)
  264. end;
  265.  
  266. overlay procedure delerrlog;
  267. var e:text;
  268.     i:integer;
  269. begin
  270.   writestr ('Delete error log:  Confirm:');
  271.   if not yes then exit;
  272.   assign (e,'errlog');
  273.   reset (e);
  274.   i:=ioresult;
  275.   if ioresult=1
  276.     then writeln (^M'No error log!')
  277.     else begin
  278.       textclose (e);
  279.       erase (e);
  280.       writestr ('Error log deleted.');
  281.       if ioresult>1
  282.         then writeln ('I/O error ',i,' deleting error log!');
  283.       writelog (2,2,'')
  284.     end
  285. end;
  286.  
  287. overlay procedure feedback;
  288. var m:mailrec;
  289.     me:message;
  290. begin
  291.   writestr ('Leave feedback? *');
  292.   if not yes then exit;
  293.   sendtoistru:=false;
  294.   feed:=true;
  295.   m.line:=editor(me,true);
  296.   if m.line<0 then exit;
  297.   m.title:=me.title;
  298.   m.sentby:=unam;
  299.   m.anon:=false;
  300.   m.sentda:=datestr;
  301.   m.sentti:=timestr;
  302.   addfeedback (m);feed:=false;sendtoistru:=true;
  303.   writestr ('Feedback sent.')
  304. end;
  305.  
  306. overlay procedure settime;
  307. var n1,n2,n3,t:integer;
  308.     r:regs;
  309. begin
  310.   writestr ('Current time: '+timestr);
  311.   writestr ('Current date: '+datestr);
  312.   writestr ('Enter new time:');
  313.   if length(input)<>0
  314.     then begin
  315.       t:=timeleft;
  316.       n3:=timeval(input);
  317.       n1:=n3 div 60;
  318.       n2:=n3 mod 60;
  319.       r.ch:=n1;
  320.       r.cl:=n2;
  321.       r.dh:=0;
  322.       r.dl:=0;
  323.       r.ah:=$2d;
  324.       intr ($21,r);
  325.       if r.al=$ff then writestr ('Invalid time!');
  326.       settimeleft (t)
  327.     end;
  328.   writestr ('Enter new date:');
  329.   if length(input)<>0
  330.     then begin
  331.       parse3 (input,n1,n2,n3);
  332.       if n3<100 then n3:=n3+1900;
  333.       r.dh:=n1;
  334.       r.dl:=n2;
  335.       r.cx:=n3;
  336.       r.ah:=$2b;
  337.       intr ($21,r);
  338.       if r.al=$ff then writestr ('Invalid date!')
  339.     end;
  340.   writelog (2,4,'')
  341. end;
  342.  
  343. overlay procedure changepwd;
  344. var t:sstr;
  345. begin
  346.   writehdr ('Password Change');
  347.   dots:=true;
  348.   buflen:=15;
  349.   write ('Enter new password: ');
  350.   if getpassword
  351.     then begin
  352.       writeurec;
  353.       writestr ('Password changed.');
  354.       writelog (1,1,'')
  355.     end else
  356.       writestr ('No change.')
  357. end;
  358.  
  359.  
  360.  
  361. overlay procedure makeuser;
  362. var u:userrec;
  363.     un,ln:integer;
  364. begin
  365.   writehdr ('Add a user');
  366.   writestr ('Name:');
  367.   if length(input)=0 then exit;
  368.   if lookupuser(input)<>0 then begin
  369.     writestr ('Sorry!  Already exists!');
  370.     exit
  371.   end;
  372.   u.handle:=input;
  373.   writestr ('Password:');
  374.   u.password:=input;
  375.   writestr ('Level:');
  376.   if length(input)=0 then exit;
  377.   u.level:=valu(input);
  378.   un:=adduser(u);
  379.   if un=-1 then begin
  380.     writestr ('Sorry, no room for new users!');
  381.     exit
  382.   end;
  383.   ln:=u.level;
  384.   if ln<1 then ln:=1;
  385.   if ln>100 then ln:=100;
  386.   u.timetoday:=usertime[ln];
  387.   seek (ufile,un);
  388.   write (ufile,u);
  389.   writestr ('User added as #'+strr(un)+'.');
  390.   writelog (2,8,u.handle)
  391. end;
  392.  
  393. overlay procedure infoformhunt;
  394. begin
  395.   nosys:=false;
  396.   writestr ('User to search for [CR=all users]:');
  397.   writeln (^M);
  398.   showinfoforms (input)
  399. end;
  400.  
  401. overlay procedure viewsyslog;
  402. var n:integer;
  403.     l:logrec;
  404.  
  405.   function lookupsyslogdat (m,s:integer):integer;
  406.   var cnt:integer;
  407.   begin
  408.     for cnt:=1 to numsyslogdat do with syslogdat[cnt] do
  409.       if (menu=m) and (subcommand=s) then begin
  410.         lookupsyslogdat:=cnt;
  411.         exit
  412.       end;
  413.     lookupsyslogdat:=0
  414.   end;
  415.  
  416.   function firstentry:boolean;
  417.   begin
  418.     firstentry:=(l.menu=0) and (l.subcommand in [1..2])
  419.   end;
  420.  
  421.   procedure backup;
  422.   begin
  423.     while n<>0 do begin
  424.       n:=n-1;
  425.       seek (logfile,n);
  426.       read (logfile,l);
  427.       if firstentry then exit
  428.     end;
  429.     n:=-1
  430.   end;
  431.  
  432.   procedure showentry (includedate:boolean);
  433.   var q:lstr;
  434.       p:integer;
  435.   begin
  436.     q:=syslogdat[lookupsyslogdat(l.menu,l.subcommand)].text;
  437.     p:=pos('%',q);
  438.     if p<>0 then q:=copy(q,1,p-1)+l.param+copy(q,p+1,255);
  439.     if includedate then q:=q+' on '+l.date;
  440.     q:=q+' at '+l.time;
  441.     writeln (q)
  442.   end;
  443.  
  444. var b:boolean;
  445. begin
  446.   writehdr ('View system log');
  447.   writeln ('Press space to advance to the previous caller, X to abort.');
  448.   writeln;
  449.   writelog (2,6,'');
  450.   n:=filesize(logfile);
  451.   repeat
  452.     clearbreak;
  453.     writeln (^M);
  454.     backup;
  455.     if n=-1 then exit;
  456.     seek (logfile,n);
  457.     read (logfile,l);
  458.     showentry (true);
  459.     b:=false;
  460.     while not (eof(logfile) or break or xpressed or b) do begin
  461.       read (logfile,l);
  462.       b:=firstentry;
  463.       if not b then showentry (false);
  464.     end
  465.   until xpressed
  466. end;
  467.  
  468. overlay procedure delsyslog;
  469. begin
  470.   writestr ('Delete system log: Confirm:');
  471.   if not yes then exit;
  472.   close (logfile);
  473.   rewrite (logfile);
  474.   writeln (^M'System log deleted.');
  475.   writelog (2,7,unam)
  476. end;
  477.  
  478. overlay procedure nvote;
  479.  begin
  480.    if vote and (ulvl>=forvote) then newvote else
  481.    writeln (^M^M);
  482.  end;
  483.  
  484. overlay procedure showsystemstatus;
  485. var totalused,totalidle,totalup,totaldown,totalmins,callsday,
  486.     total_disk,total_free,file_sizes:real;
  487.     total_files:integer;
  488.  
  489.   Procedure FileSZ;
  490.   var cnt,cnt2,cnt3,cnt4,curarea:integer;
  491.       ar,area:arearec;
  492.       ud:udrec;
  493.       Inscan,showit,fast:boolean;
  494.       Drv:array[1..15] of boolean;
  495.  
  496.   procedure assignud;
  497.   begin
  498.     close (udfile);
  499.     assign (udfile,'AREA'+strr(curarea))
  500.   end;
  501.  
  502.   const beenaborted:boolean=false;
  503.  
  504.   function aborted:boolean;
  505.   begin
  506.     if beenaborted then begin
  507.       aborted:=true;
  508.       exit
  509.     end;
  510.     aborted:=xpressed or hungupon;
  511.     if xpressed then begin
  512.       beenaborted:=true;
  513.       writeln (^B'File Calculation aborted..')
  514.     end
  515.   end;
  516.  
  517.   procedure setarea (n:integer);
  518.   begin
  519.     curarea:=n;
  520.     seek(afile,n-1);
  521.     read (afile,area);
  522.     assignud;
  523.     close (udfile);
  524.     reset (udfile);
  525.     if ioresult<>0 then rewrite (udfile);
  526.   end;
  527.  
  528.   Procedure CheckDrive(dv:char);
  529.   var n:byte;
  530.       Temp_Disk,Temp_Free:real;
  531.  
  532.     procedure WriteFreeSpace (dr:byte);
  533.     var r:regs;
  534.         csize:real;
  535.  
  536.       function unsigned (i:integer):real;
  537.       begin
  538.         if i>=0 then unsigned:=i else unsigned:=65536.0+i
  539.       end;
  540.  
  541.     begin
  542.       r.ah:=$36;
  543.       r.dl:=dr;
  544.       intr ($21,r);
  545.       if r.ax=-1 then exit;
  546.       csize:=unsigned(r.ax)*unsigned(r.cx);
  547.       Temp_Free:=(csize*unsigned(r.bx))/1000;
  548.       Temp_Disk:=(csize*unsigned(r.dx))/1000;
  549.     end;
  550.  
  551.   begin
  552.     if (ord(dv)<65) or (ord(dv)>79) then exit;
  553.     n:=ord(dv)-64;
  554.     writefreespace(n);
  555.     if not Drv[n] then begin
  556.       Drv[n]:=true;
  557.       Total_Disk:=Total_Disk+Temp_Disk;
  558.       Total_Free:=Total_Free+Temp_Free;
  559.     end;
  560.   end;
  561.  
  562.   function getfname (path:lstr; name:mstr):lstr;
  563.   var l:lstr;
  564.   begin
  565.     l:=path;
  566.     if length(l)<>0 then if not (upcase(l[length(l)]) in [':','\'])
  567.       then l:=l+'\';
  568.     l:=l+name;
  569.     getfname:=l
  570.   end;
  571.  
  572.   begin
  573.     total_files:=0;
  574.     file_sizes:=0;
  575.     total_disk:=0;
  576.     Total_Free:=0;
  577.     for cnt:=1 to 15 do Drv[Cnt]:=false;
  578.     assign (afile,'AreaDir');
  579.     if exist ('Areadir') then begin
  580.       reset (afile);
  581.       if filesize (afile)<0 then exit
  582.     end else rewrite (afile);
  583.     cnt:=1;
  584.     while (cnt<=filesize(afile)) do begin
  585.       seek (afile,cnt-1);
  586.       read (afile,ar);
  587.       CheckDrive(upcase(ar.xmodemdir[1]));
  588.       setarea (cnt);
  589.       if urec.udlevel >= ar.level then
  590.       write ('*> Area [',cnt,']  [',ar.name,'] <*          ')
  591.       else write ('*> Area: [Restricted] <*');
  592.       for cnt2:=filesize(udfile) downto 1 do begin
  593.         Seek (udfile,cnt2-1);
  594.         read (udfile,ud);
  595.         CheckDrive(upcase(ud.path[1]));
  596.         if aborted then begin
  597.           Total_Files:=0;
  598.           File_Sizes:=0;
  599.           Total_Disk:=0;
  600.           Total_Free:=0;
  601.           exit;
  602.         end;
  603.         if exist(getfname(ud.path,ud.filename)) then begin
  604.           Total_Files:=Total_Files+1;
  605.           File_Sizes:=File_Sizes+ud.filesize;
  606.         end;
  607.       end;
  608.       cnt3:=0;
  609.       delay(1000);
  610.       write (^H^H^H^H^H^H^H^H^H^H^H^H^H^H);
  611.       cnt4:=14;
  612.       for cnt3:=1 to length(ar.name) do write (^H);
  613.       for cnt3:=1 to length(ar.name) do cnt4:=cnt4+1;
  614.       write (^H^H^H^H);
  615.       cnt4:=cnt4+4;
  616.       if cnt<10 then write (^H) else write (^H^H);
  617.       if cnt<10 then cnt4:=cnt4+1 else cnt4:=cnt4+2;
  618.       write (^H^H^H^H^H^H^H^H^H);
  619.       cnt4:=cnt4+9;
  620.       for cnt3:=1 to cnt4 do write (' ');
  621.       for cnt3:=1 to cnt4 do write (^H);
  622.       cnt:=cnt+1;
  623.     end;
  624.     File_Sizes:=File_Sizes/1000;
  625.     write(usr,'*> Drives Online: ');
  626.     for cnt:=1 to 15 do if Drv[cnt] then write (usr,chr(cnt+64),' ');
  627.   end;
  628.  
  629.   procedure percent (prompt:mstr; top,bot:real);
  630.   var p:real;
  631.   begin
  632.     write (prompt);
  633.     if bot<1 then begin
  634.       writeln (' Not Available');
  635.       exit
  636.     end;
  637.     p:=round(10000*top/bot)/100;
  638.     writeln (p:6:2,'%')
  639.   end;
  640.  
  641.  
  642. begin
  643.   totalused:=numminsused.total+elapsedtime(numminsused);
  644.   totalidle:=numminsidle.total;
  645.   totalup:=totalidle+numminsused.total;
  646.   totalmins:=1440.0*(numdaysup-1.0)+timer;
  647.   totaldown:=totalmins-totalup;
  648.   callsday:=round(10*numcallers/numdaysup)/10;
  649.   writeln('*> Calculating <*');
  650.   writeln;
  651.   FileSZ;
  652.   writehdr('           *> System Statistics <*');
  653.   writeln(^B^B^B);
  654.   writeln ('*> Time & date        --->  '^S,timestr,', ',datestr,
  655.        ^M^J'*> Calls today        --->  '^S,callstoday,
  656.        ^M^J'*> Total callers      --->  '^S,numcallers:0:0,
  657.        ^M^J'*> Total days up      --->  '^S,numdaysup,
  658.        ^M^J'*> Calls per day      --->  '^S,callsday:0:1,
  659.        ^M^J'*> Total mins in use  --->  '^S,numminsused.total:0:0,
  660.        ^M^J'*> Total mins idle    --->  '^S,totalidle:0:0,
  661.        ^M^J'*> Mins file xfer     --->  '^S,numminsxfer.total:0:0,
  662.        ^M^J'*> Total mins up      --->  '^S,totalup:0:0,
  663.        ^M^J'*> Total mins down    --->  '^S,totaldown:0:0);
  664.   percent ('*> Pct used           --->  '^S,totalused,totalmins);
  665.   percent ('*> Pct dead           --->  '^S,totalidle,totalmins);
  666.   percent ('*> Pct up             --->  '^S,totalup,totalmins);
  667.   percent ('*> Pct down           --->  '^S,totaldown,totalmins);
  668.   writeln ('*> Files Online       --->  '^S,total_files,
  669.        ^M^J'*> Files Storage      --->  '^S,File_Sizes/1000:0:3,' megs',
  670.        ^M^J'*> Total Storage      --->  '^S,Total_Disk/1000:0:3,' megs',
  671.        ^M^J'*> Upload Space       --->  '^S,Total_Free/1000:0:3,' megs');
  672.   percent ('*> Pct Space Unused   --->  '^S,total_free,total_disk);
  673.   percent ('*> Pct Space Used     --->  '^S,(total_disk-Total_Free),Total_disk);
  674.   percent ('*> Pct Storage Online --->  '^S,file_sizes,total_disk);
  675. end;
  676.  
  677. overlay procedure newuselist;
  678. var n:integer;
  679.     u:userrec;
  680.  
  681.   procedure showuser;
  682.  
  683.   begin
  684.     writeln (^B^M'Name:   '^S,u.handle,
  685.                ^M'Voting  ',
  686.                ^M'   Yes: ',^S,u.votey,
  687.                ^M'    No: ',^S,u.voten);
  688.     writestr  (^M'Edit user? *');
  689.     if yes then edituser (n)
  690.   end;
  691.  
  692. begin
  693.   for n:=1 to numusers do begin
  694.     seek (ufile,n);
  695.     read (ufile,u);
  696.     if (u.level<=level2nd) and (length(u.handle)>0) then showuser;
  697.   end;
  698. end;
  699.  
  700. overlay procedure showallforms;
  701. begin
  702. end;
  703.  
  704. overlay procedure showallsysops;
  705. var n:integer;
  706.     u:userrec;
  707.     q:set of configtype;
  708.     s:configtype;
  709.  
  710.   procedure showuser;
  711.   const sectionnames:array [udsysop..databasesysop] of string[20]=
  712.          ('File transfer','Bulletin section','Voting booths',
  713.           'E-mail section','Doors','Main menu','Databases');
  714.   begin
  715.     writeln (^B^M'Name:  '^S,u.handle,
  716.                ^M'Level: '^S,u.level,^M);
  717.     for s:=udsysop to databasesysop do
  718.       if s in u.config then
  719.         writeln ('Sysop of the ',sectionnames[s]);
  720.     writestr (^M'Edit user? *');
  721.     if yes then edituser (n)
  722.   end;
  723.  
  724. begin
  725.   q:=[];
  726.   for s:=udsysop to databasesysop do q:=q+[s];
  727.   for n:=1 to numusers do begin
  728.     seek (ufile,n);
  729.     read (ufile,u);
  730.     if (u.level>=sysoplevel) or (q*u.config<>[]) then showuser
  731.   end
  732. end;
  733.  
  734.  
  735. overlay procedure readerrlog;
  736. begin
  737.   if exist ('Errlog')
  738.     then printfile ('Errlog')
  739.     else writestr ('No error file!')
  740. end;
  741.  
  742. overlay procedure setlastcall;
  743.  
  744.   function digit (k:char):boolean;
  745.   begin
  746.     digit:=ord(k) in [48..57]
  747.   end;
  748.  
  749.   function validtime (inp:sstr):boolean;
  750.   var c,s,l:integer;
  751.       d1,d2,d3,d4:char;
  752.       ap,m:char;
  753.   begin
  754.     validtime:=false;
  755.     l:=length(inp);
  756.     if (l<7) or (l>8) then exit;
  757.     c:=pos(':',inp);
  758.     if c<>l-5 then exit;
  759.     s:=pos(' ',inp);
  760.     if s<>l-2 then exit;
  761.     d2:=inp[c-1];
  762.     if l=7
  763.       then d1:='0'
  764.       else d1:=inp[1];
  765.     d3:=inp[c+1];
  766.     d4:=inp[c+2];
  767.     ap:=upcase(inp[s+1]);
  768.     m:=upcase(inp[s+2]);
  769.     if d1='1' then if d2>'2' then d2:='!';
  770.     if (d1>='0') and (d1<='1') and digit(d2) and (d3>='0') and (d3<='5')
  771.        and digit(d4) and ((ap='A') or (ap='P')) and (m='M')
  772.          then validtime:=true
  773.   end;
  774.  
  775.   function validdate (inp:sstr):boolean;
  776.   var k,l:char;
  777.  
  778.     function gchar:char;
  779.     begin
  780.       if length(inp)=0 then begin
  781.         gchar:='?';
  782.         exit
  783.       end;
  784.       gchar:=inp[1];
  785.       delete (inp,1,1)
  786.     end;
  787.  
  788.   begin
  789.     validdate:=false;
  790.     k:=gchar;
  791.     l:=gchar;
  792.     if not digit(k) then exit;
  793.     if l='/'
  794.       then if k='0'
  795.         then exit
  796.         else
  797.       else begin
  798.         if k>'1' then exit;
  799.         if not digit(l) then exit;
  800.         if (l>'2') and (k='1') then exit;
  801.         l:=gchar;
  802.         if l<>'/' then exit
  803.       end;
  804.     k:=gchar;
  805.     l:=gchar;
  806.     if l='/'
  807.       then if k='0'
  808.         then exit
  809.         else
  810.       else begin
  811.         if k>'3' then exit;
  812.         if not digit(l) then exit;
  813.         if (k='3') and (l>'1') then exit;
  814.         l:=gchar;
  815.         if l<>'/' then exit
  816.       end;
  817.     if digit(gchar) and digit(gchar) then validdate:=true
  818.   end;
  819.  
  820. begin
  821.   writeln (^M'Your last call was: '^S,lastonda,' at ',lastonti);
  822.   writestr (^M'Enter new date (mm/dd/yy):');
  823.   if validdate (input)
  824.     then
  825.     begin
  826.     urec.ldmns:=input;
  827.     urec.londa:=input;
  828.     end
  829.     else writestr ('Invalid date!');
  830.   writestr (^M'Enter new time (hh:mm am/pm):');
  831.   if validtime(input)
  832.     then
  833.     begin
  834.     urec.ltmns:=input;
  835.     urec.lonti:=input;
  836.     end
  837.     else writestr ('Invalid time!');
  838.     writeurec;
  839. end;
  840.  
  841. overlay procedure removeallforms;
  842. var cnt,ndel:integer;
  843.     u:userrec;
  844.     f:integer;
  845. begin
  846.   writestr ('Erase ALL info-forms:  Are you sure? *');
  847.   if not yes then exit;
  848.   writeurec;
  849.   writestr (^M'Erasing... please stand by...');
  850.   ndel:=0;
  851.   for cnt:=1 to numusers do begin
  852.     if (cnt mod 10)=0 then write (cnt,', ');
  853.     seek (ufile,cnt);
  854.     read (ufile,u);
  855.     for f:=1 to 9 do
  856.     if u.infoform[f]>=0 then begin
  857.       deletetext (u.infoform[f]);
  858.       u.infoform[f]:=-1;
  859.       seek (ufile,cnt);
  860.       write (ufile,u);
  861.       ndel:=ndel+1
  862.     end;
  863.       end;
  864.   writeln ('done.');
  865.   writestr (^M'All '+strr(ndel)+' forms erased.');
  866.   readurec
  867. end;
  868.  
  869. overlay procedure readfeedback;
  870. var ffile:file of mailrec;
  871.     m:mailrec;
  872.     me:message;
  873.     cur:integer;
  874.  
  875.   function nummessages:integer;
  876.   begin
  877.     nummessages:=filesize(ffile)
  878.   end;
  879.  
  880.   function checkcur:boolean;
  881.   begin
  882.     if length(input)>1 then cur:=valu(copy(input,2,255));
  883.     if (cur<1) or (cur>nummessages) then begin
  884.       writestr (^M'Message out of range!');
  885.       cur:=0;
  886.       checkcur:=true
  887.     end else begin
  888.       checkcur:=false;
  889.       seek (ffile,cur-1);
  890.       read (ffile,m)
  891.     end
  892.   end;
  893.  
  894.   procedure readnum (n:integer);
  895.   begin
  896.     cur:=n;
  897.     input:='';
  898.     if checkcur then exit;
  899.     writeln (^B^M'Message: '^S,cur,
  900.                ^M'Title:   '^S,m.title,
  901.                ^M'Sent by: '^S,m.sentby,
  902.                ^M'Sent on: '^S,m.sentda,' at '^S,m.sentti,^M);
  903.     if break then exit;
  904.     printtext (m.line)
  905.   end;
  906.  
  907.   procedure writecurmsg;
  908.   begin
  909.     if (cur<1) or (cur>nummessages) then cur:=0;
  910.     write (^B^M'Current msg: '^S);
  911.     if cur=0 then write ('None') else begin
  912.       seek (ffile,cur-1);
  913.       read (ffile,m);
  914.       write (m.title,' by ',m.sentby)
  915.     end
  916.   end;
  917.  
  918.   procedure delfeedback;
  919.   var cnt:integer;
  920.   begin
  921.     if checkcur then exit;
  922.     deletetext (m.line);
  923.     for cnt:=cur to nummessages-1 do begin
  924.       seek (ffile,cnt);
  925.       read (ffile,m);
  926.       seek (ffile,cnt-1);
  927.       write (ffile,m)
  928.     end;
  929.     seek (ffile,nummessages-1);
  930.     truncate (ffile);
  931.     cur:=cur-1
  932.   end;
  933.  
  934.   procedure editusr;
  935.   var n:integer;
  936.   begin
  937.     if checkcur then exit;
  938.     n:=lookupuser (m.sentby);
  939.     if n=0
  940.       then writestr ('User disappeared!')
  941.       else edituser (n)
  942.   end;
  943.  
  944.  
  945. procedure infoform;
  946. begin
  947.  
  948.   writeln (^M);
  949.   showinfoforms (m.sentby)
  950. end;
  951.  
  952.  
  953.   procedure nextfeedback;
  954.   begin
  955.     cur:=cur+1;
  956.     if cur>nummessages then begin
  957.       writestr (^M'Sorry, no more feedback!');
  958.       cur:=0;
  959.       exit
  960.     end;
  961.     readnum (cur)
  962.   end;
  963.  
  964.   procedure readagain;
  965.   begin
  966.     if checkcur then exit;
  967.     readnum (cur)
  968.   end;
  969.  
  970.   procedure replyfeedback;
  971.   begin
  972.     if checkcur then exit;
  973.     sendmailto (m.sentby,false)
  974.   end;
  975.  
  976.   procedure listfeedback;
  977.   var cnt:integer;
  978.   begin
  979.     if nummessages=0 then exit;
  980.     thereare (nummessages,'piece of feedback','pieces of feedback');
  981.     if break then exit;
  982.     writeln (^M'Num Title                          Left by'^M);
  983.     seek (ffile,0);
  984.     for cnt:=1 to nummessages do begin
  985.       read (ffile,m);
  986.       tab (strr(cnt),4);
  987.       if break then exit;
  988.       tab (m.title,31);
  989.       writeln (m.sentby);
  990.       if break then exit
  991.     end
  992.   end;
  993.  
  994. var q:integer;
  995. label exit;
  996. begin
  997.   assign (ffile,'Feedback');
  998.   reset (ffile);
  999.   if ioresult<>0 then rewrite (ffile);
  1000.   cur:=0;
  1001.   repeat
  1002.     if nummessages=0 then begin
  1003.       writestr ('Sorry, no feedback!');
  1004.       goto exit
  1005.     end;
  1006.     writecurmsg;
  1007.     q:=menu ('Feedback','FEED','Q#DEIR_AL');
  1008.     if q<0
  1009.       then readnum (-q)
  1010.       else case q of
  1011.         3:delfeedback;
  1012.         4:editusr;
  1013.         5:infoform;
  1014.         6:replyfeedback;
  1015.         7:nextfeedback;
  1016.         8:readagain;
  1017.         9:listfeedback;
  1018.       end
  1019.   until (q=1) or hungupon;
  1020.   exit:
  1021.   close (ffile)
  1022. end;
  1023.  
  1024. procedure mainsysopcommands;
  1025. var q:integer;
  1026. begin
  1027.   repeat
  1028.     q:=menu ('Sysop','SYSOP','QTEANDUCIJSKVMFRL');
  1029.     case q of
  1030.       2:;
  1031.       3:readerrlog;
  1032.       4:addnews;
  1033.       5:editnews;
  1034.       6:delerrlog;
  1035.       7:editusers;
  1036.       8:settime;
  1037.       9:infoformhunt;
  1038.       10:showallforms;
  1039.       11:viewsyslog;
  1040.       12:delsyslog;
  1041.       13:showallsysops;
  1042.       14:makeuser;
  1043.       15:readfeedback;
  1044.       16:removeallforms;
  1045.       17:newuselist;
  1046.     end
  1047.   until (q=1) or (q=2) or hungupon
  1048. end;
  1049.  
  1050. procedure mainmenu;
  1051. var q:integer;
  1052. begin
  1053.   repeat
  1054.     if fromdoor then doors;
  1055.     cursection:=mainsysop;
  1056.     q:=menu ('Main','MAIN','OKCDEFTIAR&UMNZP__SG_V+XY-_____%@');
  1057.     writeln;
  1058.     case q of
  1059.       1:printfile ('otherbbs');                          {aboutthisbbs;}
  1060.       2:configure;                                       {bulletinmenu;}
  1061.       3:summonsysop;
  1062.       4:datamenu;
  1063.       5:emailmenu;
  1064.       6:feedback;
  1065.       7:genfiles;                                        {offtheforum;}
  1066.       8:question(0);                                     {mainhelp;}
  1067.       9:aboutthisbbs;
  1068.       10:if gambling then mycommand;
  1069.       11:nvote;                                          {configure;}
  1070.       12:listusers;
  1071.       13:bulletinmenu;                                   {otherbbs;}
  1072.       14:printnews;
  1073.       15:doors;
  1074.       16:showlastcallers;                                {doors;}
  1075.       17:;
  1076.       18:;
  1077.       19:showsystemstatus;
  1078.       20:offtheforum;                                    {udsection;}
  1079.       21:;
  1080.       22:votingbooth (false);
  1081.       23:changepwd;                                      {showlastcallers;}
  1082.       24:udsection;                                      {transfername;}
  1083.       25:yourstatus;
  1084.       26:setlastcall;
  1085.       27:;                                               {changepwd;}
  1086.       28:;
  1087.       29:;
  1088.       30:;                                               {Showadd;}
  1089.       31:;                                               {Donation;}
  1090.       32:mainsysopcommands;
  1091.     end
  1092.   until hungupon
  1093. end;