home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / W / WWIVSOR.ZIP / MISCCMD.C < prev    next >
Text File  |  1995-05-12  |  25KB  |  1,068 lines

  1. /*****************************************************************************
  2.  
  3.                 WWIV Version 4
  4.                     Copyright (C) 1988-1995 by Wayne Bell
  5.  
  6. Distribution of the source code for WWIV, in any form, modified or unmodified,
  7. without PRIOR, WRITTEN APPROVAL by the author, is expressly prohibited.
  8. Distribution of compiled versions of WWIV is limited to copies compiled BY
  9. THE AUTHOR.  Distribution of any copies of WWIV not compiled by the author
  10. is expressly prohibited.
  11.  
  12.  
  13. *****************************************************************************/
  14.  
  15.  
  16.  
  17. #include "vars.h"
  18.  
  19. #pragma hdrstop
  20.  
  21. #define DOTS 5
  22. #define FRAME 7
  23.  
  24. void read_automessage(void)
  25. {
  26.   int i,i1,i2,i3,f,len,ptrbeg[10],ptrend[10];
  27.   char s[81],l[6][81],anon,buf[512];
  28.   slrec ss;
  29.  
  30.   sprintf(s,"%sAUTO.MSG",syscfg.gfilesdir);
  31.   f=sh_open1(s,O_RDONLY | O_BINARY);
  32.   nl();
  33.   read_status();
  34.   anon=status.amsganon;
  35.   if (f<1) {
  36.     pl(get_string(481));
  37.   } else {
  38.     len=sh_read(f,(void *)buf,512);
  39.     sh_close(f);
  40.     for (i=0; i<10; i++) {
  41.       ptrbeg[i]=0;
  42.       ptrend[i]=0;
  43.     }
  44.     i=0;
  45.     i1=0;
  46.     i2=0;
  47.     for(i=0; i<len; i++) {
  48.       if (i1) {
  49.         if (buf[i]==10) {
  50.           ptrbeg[i2]=i+1;
  51.           i1=0;
  52.         }
  53.       } else {
  54.         if (buf[i]==13) {
  55.           ptrend[i2]=i-1;
  56.           if (i2<6) {
  57.             for (i3=ptrbeg[i2]; i3<=ptrend[i2]; i3++)
  58.               l[i2][i3-ptrbeg[i2]]=buf[i3];
  59.               l[i2][ptrend[i2]-ptrbeg[i2]+1]=0;
  60.           }
  61.           ++i2;
  62.           i1=1;
  63.         }
  64.       }
  65.     }
  66.     ss=syscfg.sl[actsl];
  67.     if (anon)
  68.       if (ss.ability & ability_read_post_anony) {
  69.         sprintf(s,"<<< %s >>>",&(l[0][0]));
  70.       } else
  71.         strcpy(s,get_string(482));
  72.     else
  73.       strcpy(s,&(l[0][0]));
  74.     nl();
  75.     outstr(get_string(483)); pl(s);
  76.     nl();
  77.     i=1;
  78.     while ((ptrend[i]) && (i<6)) {
  79.       pl(&(l[i][0]));
  80.       ++i;
  81.     }
  82.   }
  83.   nl();
  84. }
  85.  
  86. void write_automessage1(void)
  87. {
  88.   int i,i1,f;
  89.   char s[81],l[4][81];
  90.   slrec ss;
  91.  
  92.   nl();
  93.   pl(get_string(484));
  94.   nl();
  95.   for (i=0; i<3; i++) {
  96.     npr("%d:",i+1);
  97.     inputl(&(l[i][0]),39);
  98.     strcat(&(l[i][0]),"\r\n");
  99.   }
  100.   nl();
  101.   ss=syscfg.sl[actsl];
  102.   if (ss.ability & ability_post_anony) {
  103.     prt(5,get_string(485));
  104.     if (yn())
  105.       i1=anony_sender;
  106.     else
  107.       i1=0;
  108.   } else
  109.     i1=0;
  110.   prt(5,get_string(438));
  111.   if (yn()) {
  112.     lock_status();
  113.     status.amsganon=i1;
  114.     status.amsguser=usernum;
  115.     save_status();
  116.     sprintf(s,"%sAUTO.MSG",syscfg.gfilesdir);
  117.     f=sh_open(s,O_RDWR | O_BINARY | O_CREAT | O_TRUNC, S_IREAD | S_IWRITE);
  118.     strcpy(s,nam(&thisuser,usernum));
  119.     strcat(s,"\r\n");
  120.     sh_write(f,(void *)s,strlen(s));
  121.     for (i=0; i<3; i++)
  122.       sh_write(f,(void *)&(l[i][0]),strlen(&(l[i][0])));
  123.     sysoplog(get_stringx(1,24));
  124.     for (i=0; i<3; i++) {
  125.       strcpy(s,"   ");
  126.       l[i][strlen(&(l[i][0]))-2]=0;
  127.       strcat(s,&(l[i][0]));
  128.       sysoplog(s);
  129.     }
  130.     nl();
  131.     pl(get_string(486));
  132.     nl();
  133.     sh_close(f);
  134.   }
  135.  
  136. }
  137.  
  138. void write_automessage(void)
  139. {
  140.   char ch;
  141.   int done,okwrite;
  142.   slrec ss;
  143.  
  144.   ss=syscfg.sl[actsl];
  145.   if (ss.posts)
  146.     okwrite=1;
  147.   else
  148.     okwrite=0;
  149.   if (thisuser.restrict & restrict_automessage)
  150.     okwrite=0;
  151.   done=0;
  152.   do {
  153.     nl();
  154.     if (okwrite) {
  155.       prt(2,get_string(487));
  156.       ch=onek("QRWA");
  157.     } else {
  158.       prt(2,get_string(488));
  159.       ch=onek("QRA");
  160.     }
  161.     switch(ch) {
  162.       case 'Q':
  163.         done=1;
  164.         break;
  165.       case 'R':
  166.         read_automessage();
  167.         break;
  168.       case 'W':
  169.         write_automessage1();
  170.         break;
  171.       case 'A':
  172.         irt[0]=0;
  173.         irt_name[0]=0;
  174.         grab_quotes(NULL, NULL);
  175.         read_status();
  176.         if (status.amsguser)
  177.           email(status.amsguser,0,0,status.amsganon);
  178.         break;
  179.     }
  180.   } while ((!done) && (!hangup));
  181.  
  182. }
  183.  
  184.  
  185. void bbslist(void)
  186. {
  187.   int i,f,done,ok;
  188.   char s[150],s1[150],ch,ch1,*ss;
  189.   char phone[13], name[51], speed[5], type[5];
  190.   long l,l1;
  191.  
  192.   done=0;
  193.   do {
  194.     helpl=0;
  195.     nl();
  196.     prt(2,get_string(489));
  197.     ch=onek("QRNA");
  198.     switch(ch) {
  199.       case 'Q':
  200.         done=1;
  201.         break;
  202.       case 'R':
  203.         printfile("BBSLIST.MSG");
  204.         break;
  205.       case 'N':
  206.         print_net_listing(0);
  207.         break;
  208.       case 'A':
  209.         helpl=25;
  210.         if ((actsl<=10)) {
  211.           nln(2);
  212.           pl(get_string(490));
  213.           nl();
  214.           break;
  215.         }
  216.         if (thisuser.restrict & restrict_automessage) {
  217.           nln(2);
  218.           pl(get_string(491));
  219.           nl();
  220.           break;
  221.         }
  222.         nl();
  223.         pl(get_string(492));
  224.         pl(get_string(493));
  225.         outstr(":");
  226.         mpl(12);
  227.         input(phone,12);
  228.         if ((phone[3]!='-') || (phone[7]!='-'))
  229.           phone[0]=0;
  230.         for (i=0; i<12; i++) {
  231.           if (strchr("0123456789-",phone[i])==0)
  232.             phone[0]=0;
  233.         }
  234.         if (strlen(phone)==12) {
  235.           ok=1;
  236.           sprintf(s1,"%sBBSLIST.MSG",syscfg.gfilesdir);
  237.           f=sh_open1(s1,O_RDONLY | O_BINARY);
  238.           if (f>0) {
  239.             sh_lseek(f,0L,SEEK_SET);
  240.             l=filelength(f);
  241.             if ((ss=malloca(l+500L))==NULL) {
  242.               sh_close(f);
  243.               return;
  244.             }
  245.             sh_read(f,ss,(int)l);
  246.             l1=0L;
  247.             while ((l1<l) && (ok)) {
  248.               i=0;
  249.               do {
  250.                 ch=ss[l1++];
  251.                 s1[i]=ch;
  252.                 if (ch==13)
  253.                   s1[i]=0;
  254.                 ++i;
  255.               } while ((ch!=10) && (i<120) && (l1<l));
  256.               if (strstr(s1,phone)!=NULL)
  257.                 ok=0;
  258.               if (strncmp(s1,phone,12)==0)
  259.                 ok=0;
  260.             }
  261.             bbsfree(ss);
  262.             sh_close(f);
  263.           }
  264.           if (ok) {
  265.             pl(get_string(494));
  266.             nln(2);
  267.             pl(get_string(495));
  268.             outstr(":");
  269.             mpl(50);
  270.             inputl(name,50);
  271.             nl();
  272.             pl(get_string(496));
  273.             pl(get_string(497));
  274.             outstr(":");
  275.             mpl(4);
  276.             input(speed,4);
  277.             nl();
  278.             pl(get_string(498));
  279.             outstr(":");
  280.             mpl(4);
  281.             input(type,4);
  282.             sprintf(s,"%12s  %-50s  [%4s] (%4s)\r\n",
  283.               phone, name, speed, type);
  284.             nln(2);
  285.             pl(s);
  286.             nl();
  287.             prt(5,get_string(499));
  288.             if (yn()) {
  289.               sprintf(s1,"%sBBSLIST.MSG",syscfg.gfilesdir);
  290.               f=sh_open(s1,O_RDWR | O_CREAT | O_BINARY, S_IREAD | S_IWRITE);
  291.               if (filelength(f)) {
  292.                 sh_lseek(f,-1L,SEEK_END);
  293.                 sh_read(f,((void *)&ch1),1);
  294.                 if (ch1==26)
  295.                   sh_lseek(f,-1L,SEEK_END);
  296.               }
  297.               sh_write(f,(void *)s,strlen(s));
  298.               sh_close(f);
  299.               nl();
  300.               pl(get_string(500));
  301.             }
  302.           } else {
  303.             pl(get_string(501));
  304.             nln(2);
  305.           }
  306.         } else {
  307.           nl();
  308.           pl(get_string(502));
  309.           nl();
  310.         }
  311.         break;
  312.     }
  313.   } while ((!done) && (!hangup));
  314. }
  315.  
  316.  
  317. void kill_old_email(void)
  318. {
  319.   int cur,max,i,i1,f,done,done1,forward;
  320.   char s1[81],ch;
  321.   long l;
  322.   mailrec m, m1;
  323.   userrec u;
  324.   slrec ss;
  325.  
  326.   if (rip_on()) {
  327.     cleared = -1;
  328.     setmsgview(0);
  329.     smally = formery;
  330.   }
  331.   prt(5,get_string(503));
  332.   forward=(yn());
  333.   ss=syscfg.sl[actsl];
  334.   f=open_email(0);
  335.   if (f==-1) {
  336.     nl();
  337.     pl(get_string(504));
  338.     return;
  339.   }
  340.   max=(int) (filelength(f) / sizeof(mailrec));
  341.   if (forward)
  342.     cur=max-1;
  343.   else
  344.     cur=0;
  345.   done=0;
  346.   do {
  347.     sh_lseek(f,((long) cur) * sizeof(mailrec), SEEK_SET);
  348.     sh_read(f,(void *)&m,sizeof(mailrec));
  349.     while (((m.fromsys!=0) || (m.fromuser!=usernum) || (m.touser==0)) && (cur<max) && (cur>=0)) {
  350.       if (forward)
  351.         --cur;
  352.       else
  353.         ++cur;
  354.       if ((cur<max) && (cur>=0)) {
  355.         sh_lseek(f,((long) cur) * sizeof(mailrec), SEEK_SET);
  356.         sh_read(f,(void *)&m,sizeof(mailrec));
  357.       }
  358.     }
  359.     if ((m.fromsys!=0) || (m.fromuser!=usernum) || (m.touser==0) || (cur>=max) || (cur<0))
  360.       done=1;
  361.     else {
  362.       f=sh_close(f);
  363.       do {
  364.         done1=0;
  365.         nl();
  366.         if (E_C) {
  367.           outstr(get_string(325));
  368.         } else {
  369.           outstr(get_string(1371));
  370.         }
  371.         if (m.tosys==0) {
  372.           read_user(m.touser,&u);
  373.           strcpy(s1,nam(&u,m.touser));
  374.           if ((m.anony & (anony_receiver | anony_receiver_pp | anony_receiver_da))
  375.               && ((ss.ability & ability_read_email_anony)==0))
  376.             strcpy(s1,get_string(482));
  377.           pl(s1);
  378.         } else {
  379.           npr("#%u @%u\r\n",m.touser, m.tosys);
  380.         }
  381.         if (E_C) {
  382.           outstr(get_string(326));
  383.         } else {
  384.           outstr(get_string(1372));
  385.         }
  386.         pl(m.title);
  387.         time(&l);
  388.         i=(int) ((l-m.daten)/24.0/3600.0);
  389.         if (E_C) {
  390.           outstr(get_string(505));
  391.         } else {
  392.           outstr(get_string(1373));
  393.         }
  394.         npr("%d ",i);
  395.         pl(get_string(506));
  396.         nl();
  397.         prt(2,get_string(507));
  398.         ch=onek("QRDN");
  399.         switch(ch) {
  400.           case 'Q':
  401.             done1=1;
  402.             done=1;
  403.             break;
  404.           case 'N':
  405.             done1=1;
  406.             if (forward)
  407.               --cur;
  408.             else
  409.               ++cur;
  410.             if ((cur>=max) || (cur<0))
  411.               done=1;
  412.             break;
  413.           case 'D':
  414.             done1=1;
  415.             f=open_email(1);
  416.             sh_lseek(f,((long) cur) * sizeof(mailrec), SEEK_SET);
  417.             sh_read(f,(void *)&m1,sizeof(mailrec));
  418.             if (memcmp(&m, &m1, sizeof(mailrec))==0) {
  419.               delmail(f,cur);
  420.               nl();
  421.               pl(get_string(508));
  422.               nl();
  423.               sprintf(s1,get_stringx(1, 100),nam(&u,m1.touser));
  424.               sysoplog(s1);
  425.             } else {
  426.               pl(get_string(1174));
  427.             }
  428.             f=sh_close(f);
  429.             break;
  430.           case 'R':
  431.             nln(2);
  432.             if (E_C) {
  433.               outstr(get_string(326));
  434.             } else {
  435.               outstr(get_string(1372));
  436.             }
  437.             pl(m.title);
  438.             setorigin(0,0);
  439.             read_message1(&m.msg,(m.anony & 0x0f), 0, &i1,"EMAIL");
  440.             break;
  441.         }
  442.       } while ((!hangup) && (!done1));
  443.       f=open_email(0);
  444.       if (f<0)
  445.         break;
  446.     }
  447.   } while ((!done) && (!hangup));
  448.   f=sh_close(f);
  449. }
  450.  
  451.  
  452. void list_users(int mode)
  453. {
  454.   subboardrec s;
  455.   directoryrec d;
  456.   userrec u;
  457.   int i,abort,ok,num, count, color, next=0, ncnm=0;
  458.   char s1[121],s2[121];
  459.  
  460.   if ((usub[cursub].subnum==-1) && (mode==0)) {
  461.     nl();
  462.     pl(get_string(510));
  463.     nl();
  464.     return;
  465.   }
  466.   if ((udir[curdir].subnum==-1) && (mode==1)) {
  467.     nl();
  468.     pl(get_string(32));
  469.     nl();
  470.     return;
  471.   }
  472.   abort=0;
  473.   num=0;
  474.   strcpy(s1,get_string(1175));
  475.   if (mode==0) {
  476.     s=subboards[usub[cursub].subnum];
  477.     npr("\r\n2%s 1%s 2%s.\r\n", s1, subboards[usub[cursub].subnum].name,
  478.         get_string(1628));
  479.   }
  480.   if (mode==1) {
  481.     d=directories[udir[curdir].subnum];
  482.     npr("\r\n2%s 1%s 2%s.\r\n", s1, directories[udir[curdir].subnum].name,
  483.         get_string(1629));
  484.   }
  485.   nl();
  486.   if (okansi()) {
  487.     if (syscfg.sysconfig & sysconfig_extended_info) {
  488.       pla(get_string(1176),&abort);
  489.       sprintf(s1,"%d%s",FRAME,get_string(1177));
  490.       pla(s1,&abort);
  491.     } else {
  492.       pla(get_string(1178),&abort);
  493.       sprintf(s1,"%d%s",FRAME,get_string(1179));
  494.       pla(s1,&abort);
  495.     }
  496.   } else {
  497.     if (syscfg.sysconfig & sysconfig_extended_info) {
  498.       pla(get_string(1180),&abort);
  499.       pla(get_string(1181),&abort);
  500.     } else {
  501.       pla(get_string(1182),&abort);
  502.       pla(get_string(1183),&abort);
  503.     }
  504.   }
  505.   count=0;
  506.   color=3;
  507.   outstr("\r");
  508.   outstr(get_string(1184));
  509.   read_status();
  510.   for (i=0; (i<status.users) && (!abort) && (!hangup); i++) {
  511.     if (ncnm>5) {
  512.       count++;
  513.       npr("%d.",color);
  514.       if (count==DOTS) {
  515.         osan("\r", &abort, &next);
  516.         osan(get_string(1184), &abort, &next);
  517.         color++;
  518.         count=0;
  519.         if (color==4)
  520.           color++;
  521.         if (color==7)
  522.           color=0;
  523.       }
  524.     }
  525.     read_user(smallist[i].number,&u);
  526.     ok=1;
  527.     if (mode==0) {
  528.       if (u.sl<s.readsl)
  529.         ok=0;
  530.       if (u.age < (s.age&0x7f))
  531.         ok=0;
  532.       if ((s.ar!=0) && ((u.ar & s.ar)==0))
  533.         ok=0;
  534.     }
  535.     if (mode==1) {
  536.       if (u.dsl<d.dsl)
  537.         ok=0;
  538.       if (u.age<d.age)
  539.         ok=0;
  540.       if ((d.dar!=0) && ((u.dar & d.dar)==0))
  541.         ok=0;
  542.     }
  543.     if (ok) {
  544.       ncnm=0;
  545.       sprintf(s2,"%s, %s",u.city,u.state);
  546.       if (okansi()) {
  547.         if (syscfg.sysconfig & sysconfig_extended_info) {
  548.           sprintf(s1,"\r%d║7%-4d%d║1%-30.30s%d║2%-30.30s%d║",
  549.             FRAME, smallist[i].number, FRAME, u.name, FRAME, s2, FRAME );
  550.         } else {
  551.           sprintf(s1,"\r%d║7%-4d%d║1%-30.30s%d║",
  552.             FRAME, smallist[i].number, FRAME, u.name, FRAME);
  553.         }
  554.       } else {
  555.         if (syscfg.sysconfig & sysconfig_extended_info) {
  556.           sprintf(s1,"\r:%-4d:%-30s:%-30s:",
  557.             smallist[i].number,u.name,s2);
  558.         } else {
  559.           sprintf(s1,"\r:%-4d:%-30s:",
  560.             smallist[i].number,u.name);
  561.         }
  562.       }
  563.       pla(s1,&abort);
  564.       ++num;
  565.     } else
  566.       ncnm++;
  567.   }
  568.   if (okansi()) {
  569.     if (syscfg.sysconfig & sysconfig_extended_info) {
  570.       sprintf(s1,"\r%d%s",FRAME,get_string(1185));
  571.     } else {
  572.       sprintf(s1,"\r%d%s",FRAME,get_string(1186));
  573.     }
  574.   } else {
  575.     if (syscfg.sysconfig & sysconfig_extended_info) {
  576.       sprintf(s1,"\r%s",get_string(1187));
  577.     } else {
  578.       sprintf(s1,"\r%s",get_string(1188));
  579.     }
  580.   }
  581.   pla(s1,&abort);
  582.   if (abort)
  583.     if (num>0)
  584.       num--;
  585.   npr("1%d 2%s.\r\n",num,(num==1) ? get_string(1630) : get_string(1631));
  586. }
  587.  
  588.  
  589. void print_quest(int mapp, int map[21])
  590. {
  591.   char s[100];
  592.   int i,abort,f;
  593.   votingrec v;
  594.  
  595.   outchr(12);
  596.   abort=0;
  597.   sprintf(s,"%sVOTING.DAT",syscfg.datadir);
  598.   f=sh_open1(s,O_RDONLY | O_BINARY);
  599.   if (f<0)
  600.     return;
  601.  
  602.   for (i=1; (i<=mapp) && (abort==0); i++) {
  603.     sh_lseek(f,((long) (map[i])) * sizeof(votingrec), SEEK_SET);
  604.     sh_read(f,(void *)&v,sizeof(votingrec));
  605.     sprintf(s,"%c %2d: %s",
  606.       thisuser.votes[map[i]]?' ':'*',i, v.question);
  607.     pla(s,&abort);
  608.   }
  609.   f=sh_close(f);
  610.   nl();
  611.   if (abort)
  612.     nl();
  613. }
  614.  
  615.  
  616. int print_question(int i, int ii)
  617. {
  618.   char s[81];
  619.   int i1,t,t1,abort, f;
  620.   votingrec v;
  621.   voting_response vr;
  622.  
  623.   sprintf(s,"%sVOTING.DAT",syscfg.datadir);
  624.   f=sh_open1(s,O_RDONLY | O_BINARY);
  625.   if (f<0)
  626.     return(0);
  627.   sh_lseek(f,((long) ii)*sizeof(votingrec),SEEK_SET);
  628.   sh_read(f,(void *)&v,sizeof(votingrec));
  629.   f=sh_close(f);
  630.   abort=0;
  631.  
  632.   if (!v.numanswers)
  633.     return(0);
  634.  
  635.   outchr(12);
  636.   sprintf(s,"%s%d",get_string(513),i);
  637.   pla(s,&abort);
  638.   pla(v.question,&abort);
  639.   nl();
  640.   t=0;
  641.   for (i1=0; i1<v.numanswers; i1++) {
  642.     vr=v.responses[i1];
  643.     t+=vr.numresponses;
  644.   }
  645.  
  646.   read_status();
  647.   sprintf(s,"%s: %4.1f%%\r\n",get_string(514),
  648.     ((double) t) / ((double) status.users) * 100.0);
  649.   pla(s,&abort);
  650.   nl();
  651.   if (t)
  652.     t1=t;
  653.   else
  654.     t1=1;
  655.   pla(get_string(515),&abort);
  656.   for (i1=0; i1<5; i1++)
  657.     odc[i1]=0;
  658.   for (i1=0; (i1<v.numanswers) && (!abort); i1++) {
  659.     vr=v.responses[i1];
  660.     if (((i1+1) % 10)==0)
  661.       odc[((i1+1)/10)-1]='0'+((i1+1)/10);
  662.     sprintf(s,"%2d: %-60s : %4d  %5.1f%%",
  663.       i1+1, vr.response, vr.numresponses,
  664.       ((float)vr.numresponses)/((float)t1)*100.0);
  665.     pla(s,&abort);
  666.   }
  667.   nl();
  668.   if (abort)
  669.     nl();
  670.   return(!abort);
  671. }
  672.  
  673.  
  674. void vote_question(int i, int ii)
  675. {
  676.   int ok,pqo,i1, f;
  677.   char s[81],*ss, fn[81];
  678.   votingrec v;
  679.  
  680.   sprintf(fn,"%sVOTING.DAT",syscfg.datadir);
  681.  
  682.   pqo=print_question(i,ii);
  683.   ok=pqo;
  684.   ok=1;
  685.   if (restrict_vote & thisuser.restrict)
  686.     ok=0;
  687.   if (actsl<=10)
  688.     ok=0;
  689.   if (!ok)
  690.     return;
  691.  
  692.   f=sh_open1(fn,O_RDONLY| O_BINARY);
  693.   if (f<0)
  694.     return;
  695.   sh_lseek(f,((long) ii)*sizeof(votingrec),SEEK_SET);
  696.   sh_read(f,(void *)&v,sizeof(votingrec));
  697.   f=sh_close(f);
  698.  
  699.   if (!v.numanswers)
  700.     return;
  701.  
  702.   strcpy(s,get_string(516));
  703.   if (thisuser.votes[ii])
  704.     strcat(s,v.responses[thisuser.votes[ii]-1].response);
  705.   else
  706.     strcat(s,get_string(517));
  707.   pl(s);
  708.   nl();
  709.   prt(5,get_string(264));
  710.   if (!yn())
  711.     return;
  712.  
  713.   prt(2,get_string(297));
  714.   ss=mmkey(2);
  715.   i1=atoi(ss);
  716.   if (i1>v.numanswers)
  717.     i1=0;
  718.   if ((i1==0) && (strcmp(ss,"0")))
  719.     return;
  720.  
  721.   f=sh_open1(fn,O_RDWR | O_BINARY);
  722.   if (f<0)
  723.     return;
  724.   sh_lseek(f,((long) ii)*sizeof(votingrec),SEEK_SET);
  725.   sh_read(f,(void *)&v,sizeof(votingrec));
  726.  
  727.   if (!v.numanswers) {
  728.     f=sh_close(f);
  729.     return;
  730.   }
  731.  
  732.   if (thisuser.votes[ii]) {
  733.     v.responses[thisuser.votes[ii]-1].numresponses--;
  734.   }
  735.   thisuser.votes[ii]=i1;
  736.   if (i1) {
  737.     v.responses[thisuser.votes[ii]-1].numresponses++;
  738.   }
  739.   sh_lseek(f,((long) ii)*sizeof(votingrec),SEEK_SET);
  740.   sh_write(f,(void *)&v,sizeof(votingrec));
  741.   f=sh_close(f);
  742.   nln(2);
  743. }
  744.  
  745.  
  746. void vote(void)
  747. {
  748.   int i,f,map[21],mapp,n,done;
  749.   char s[81],sodc[10],*ss;
  750.   votingrec v;
  751.  
  752.   sprintf(s,"%sVOTING.DAT",syscfg.datadir);
  753.   f=sh_open(s,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
  754.   if (f<0)
  755.     return;
  756.   n=(int) (filelength(f) / sizeof(votingrec)) -1;
  757.   if (n<20) {
  758.     v.question[0]=0;
  759.     v.numanswers=0;
  760.     for (i=n; i<20; i++)
  761.       sh_write(f,(void *)&v,sizeof(votingrec));
  762.   }
  763.   mapp=0;
  764.   for (i=0; i<5; i++)
  765.     odc[i]=0;
  766.   for (i=0; i<20; i++) {
  767.     sh_lseek(f,((long) i) * sizeof(votingrec),SEEK_SET);
  768.     sh_read(f,(void *)&v,sizeof(votingrec));
  769.     if (v.numanswers) {
  770.       map[++mapp]=i;
  771.       if ((mapp % 10)==0)
  772.         odc[(mapp/10)-1]='0'+(mapp/10);
  773.     }
  774.   }
  775.   f=sh_close(f);
  776.  
  777.   strcpy(sodc,odc);
  778.   if (mapp==0) {
  779.     nln(2);
  780.     pl(get_string(518));
  781.     nl();
  782.     return;
  783.   }
  784.   print_quest(mapp,&map[0]);
  785.   done=0;
  786.   do {
  787.     nln(2);
  788.     prt(2,get_string(519));
  789.     strcpy(odc,sodc);
  790.     ss=mmkey(2);
  791.     i=atoi(ss);
  792.     if ((i>0) && (i<=mapp))
  793.       vote_question(i,map[i]);
  794.     else
  795.       if (strcmp(ss,"Q")==0)
  796.         done=1;
  797.       else
  798.         if (strcmp(ss,"?")==0)
  799.           print_quest(mapp,&map[0]);
  800.   } while ((!done) && (!hangup));
  801. }
  802.  
  803.  
  804. void time_bank(void)
  805. {
  806.   char s[81],bc[11],c;
  807.   int i,done=0;
  808.   double nsln;
  809.  
  810.   nl();
  811.   if (thisuser.sl<=syscfg.newusersl) {
  812.     ansic(6);
  813.     pl(get_string(981));
  814.     return;
  815.   }
  816.  
  817.   if (thisuser.banktime>syscfg.sl[thisuser.sl].time_per_logon)
  818.     thisuser.banktime=syscfg.sl[thisuser.sl].time_per_logon;
  819.  
  820.   if (menu_on()) {
  821.     rip_timebank();
  822.     return;
  823.   }
  824.  
  825.   if (okansi())
  826.     strcpy(bc,get_string(982));
  827.   else
  828.     strcpy(bc,get_string(983));
  829.  
  830.   do {
  831.     outchr(12);
  832.     sprintf(s,"%c%s%c",bc[0],charstr(25,bc[4]),bc[1]);
  833.     prt(4,s); nl();
  834.     sprintf(s,"%c%-25.25s%c",bc[5],get_string(984),bc[5]);
  835.     prt(4,s); nl();
  836.     sprintf(s,"%c%s%c",bc[7],charstr(25,bc[4]),bc[9]);
  837.     prt(4,s); nl();
  838.     sprintf(s,"%c%-25.25s%c",bc[5],get_string(985),bc[5]);
  839.     prt(4,s); nl();
  840.     sprintf(s,"%c%-25.25s%c",bc[5],get_string(986),bc[5]);
  841.     prt(4,s); nl();
  842.     sprintf(s,"%c%-25.25s%c",bc[5],get_string(987),bc[5]);
  843.     prt(4,s); nl();
  844.     sprintf(s,"%c%s%c",bc[7],charstr(25,bc[4]),bc[9]);
  845.     prt(4,s); nl();
  846.     sprintf(s,"%c%-17.17s%-6d  %c",bc[5],get_string(988),thisuser.banktime,bc[5]);
  847.     prt(4,s); nl();
  848.     sprintf(s,"%c%-17.17s%-6d  %c",bc[5],get_string(1430),(int)(nsl()/60),bc[5]);
  849.     prt(4,s); nl();
  850.     sprintf(s,"%c%s%c",bc[2],charstr(25,bc[4]),bc[3]);
  851.     prt(4,s);
  852.     nln(2);
  853.     prt(1,get_string(989));
  854.     ansic(2);
  855.     c=onek("QDW");
  856.     switch(c) {
  857.       case 'D':
  858.         nl();
  859.         prt(1,get_string(990));
  860.         mpl(3);
  861.         input(s,3);
  862.         i=atoi(s);
  863.         if (i>0) {
  864.           nsln=nsl();
  865.           if ((i+thisuser.banktime)>syscfg.sl[thisuser.sl].time_per_logon)
  866.             i=syscfg.sl[thisuser.sl].time_per_logon-thisuser.banktime;
  867.           if (i>(nsln/60.0))
  868.             i=(nsln/60.0);
  869.           thisuser.banktime+=i;
  870.           thisuser.extratime-=i*60.0;
  871.           tleft(0);
  872.         }
  873.         break;
  874.       case 'W':
  875.         nl();
  876.         if (!thisuser.banktime)
  877.           break;
  878.         prt(1,get_string(991));
  879.         mpl(3);
  880.         input(s,3);
  881.         i=atoi(s);
  882.         if (i>0) {
  883.           nsln=nsl();
  884.           if (i>thisuser.banktime)
  885.             i=thisuser.banktime;
  886.           thisuser.banktime-=i;
  887.           thisuser.extratime+=(i*60.0);
  888.           tleft(0);
  889.         }
  890.         break;
  891.       case 'Q':
  892.         done=1;
  893.         break;
  894.     }
  895.   } while (!done && !hangup);
  896. }
  897.  
  898.  
  899. void remotenotify(char *name, char *desc)
  900. {
  901.   char s[161],s1[81],s2[161];
  902.   int f,i,rnnet,rndest,rnuser;
  903.   long p,l;
  904.  
  905.   sprintf(s1,"%s%s",syscfg.datadir,get_string(1060));
  906.   f=sh_open1(s1,O_RDWR | O_BINARY);
  907.   if (f<0) {
  908.     return;
  909.   }
  910.   sh_lseek(f,0L,SEEK_SET);
  911.   l=filelength(f);
  912.   p=0;
  913.   nl();
  914.   while (p<l) {
  915.     sh_lseek(f,p,SEEK_SET);
  916.     sh_read(f,(void *)s,150);
  917.     i=0;
  918.     while ((i<150) && (s[i])) {
  919.       if (s[i]==13)
  920.         s[i]=0;
  921.       else
  922.         ++i;
  923.     }
  924.     s[150]=0;
  925.  
  926.     p += (long) (i+2);
  927.     strncpy(s2,extractword(1,s,","),sizeof(s2));
  928.     if(strlen(s2) < 17) {
  929.       rnnet=getnetnum(s2);
  930.       strncpy(s2,extractword(2,s,","),sizeof(s2));
  931.       rnuser=atoi(s2);
  932.       strncpy(s2,extractword(3,s,","),sizeof(s2));
  933.       rndest=atoi(s2);
  934.       sprintf(s,"2@%d UPL:1 %s 2DESC:1 %s",
  935.         net_networks[rnnet].sysnum,name,desc);
  936.       if ((rnuser==0) || (rndest==0))
  937.         return;
  938.       if (so()) {
  939.         npr("1SSM:7%s %d@%d %s",net_networks[rnnet].name,rnuser,rndest,s);
  940.         npr("2 (y/N) ");
  941.         if (yn()) {
  942.           set_net_num(rnnet);
  943.           ssm(rnuser,rndest,s);
  944.         }
  945.       } else {
  946.         set_net_num(rnnet);
  947.         ssm(rnuser,rndest,s);
  948.         nl();
  949.       }
  950.     }
  951.   }
  952.   f=sh_close(f);
  953. }
  954.  
  955.  
  956. int remoteupload(char *message)
  957. {
  958.   char s[81],s1[81],s2[81],s3[81],ch,msg[81];
  959.   int i,done,brd,network;
  960.  
  961.   strncpy(msg,stripcolors(message),80);
  962.   if ((strlen(msg)<20) || (msg[0]!='@'))
  963.     return(1);
  964.   strcpy(s1,&msg[1]);
  965.   for (i=0;i<strlen(s1);i++) {
  966.     if (s1[i]==' ') {
  967.       break;
  968.     }
  969.   }
  970.   s1[i]=0;
  971.   itoa(net_networks[net_num].sysnum,s3,10);
  972.   if (strcmp(s1,s3)==NULL)
  973.     return(1);
  974.   for (i=0;i<strlen(msg);i++) {
  975.     if (msg[i]==':') {
  976.       strcpy(s,&msg[++i]);
  977.       break;
  978.     }
  979.   }
  980.   for (i=0;i<strlen(s);i++) {
  981.     if (s[i]==' ') {
  982.       strcpy(s,&s[i+1]);
  983.       break;
  984.     }
  985.   }
  986.   for (i=0;i<strlen(s);i++) {
  987.     if (s[i]=='.') {
  988.       s[i+4]=0;
  989.       break;
  990.     }
  991.   }
  992.   strcpy(s2,stripfn(s));
  993.   done=0;
  994.  
  995.   do {
  996.     nl();
  997.     pl(get_string(1061));
  998.     pl(get_string(1062));
  999.     pl(get_string(1063));
  1000.     pl(get_string(1064));
  1001.     nl();
  1002.     prt(2,get_string(1065));
  1003.     ch=onek(" ADRS\r");
  1004.     switch(ch) {
  1005.       case 'A':
  1006.         if (sysinfo.flags & OP_FLAGS_FAST_SEARCH) {
  1007.           modify_database(s2,1);
  1008.           done=1;
  1009.         }
  1010.         break;
  1011.       case 'R':
  1012.         nl();
  1013.         npr(get_string(1066),s2,s1);
  1014.         if (yn()) {
  1015.           nl();
  1016.           for (brd=0; brd<net_num_max; brd++) {
  1017.             if (net_networks[brd].name != 0) {
  1018.               npr(" 2%d7)1 %s\r\n",
  1019.                 brd+1,net_networks[brd].name);
  1020.             }
  1021.           }
  1022.           nl();
  1023.           npr(get_string(1068));
  1024.           mpl(5);
  1025.           input(s3,5);
  1026.           network=atoi(s3);
  1027.  
  1028.           if ((network-1) < net_num_max) {
  1029. /* Packscan freq.  Others would also go here. */
  1030.             nl();
  1031.             sprintf(s3,"FILEREQ /F:%s /C:1 /A:%s /N:%d",s2,s1,network-1);
  1032.             extern_prog(s3, EFLAG_SHRINK);
  1033.             topscreen();
  1034.             nl();
  1035.             done=1;
  1036.           }
  1037.         } else
  1038.           done=2;
  1039.         break;
  1040.       case 'S':
  1041.         done=2;
  1042.         break;
  1043.       case 13:
  1044.       case ' ':
  1045.       case 'D':
  1046.         done=1;
  1047.         break;
  1048.     }
  1049.   } while (!done);
  1050.   return(done);
  1051. }
  1052.  
  1053.  
  1054. int getnetnum(char *netnam)
  1055. {
  1056.   int i,matched=0;
  1057.  
  1058.   for (i=0; i<net_num_max; i++) {
  1059.     if (stricmp(net_networks[i].name, netnam)==0) {
  1060.       matched=1;
  1061.       break;
  1062.     }
  1063.   }
  1064.   if (!matched)
  1065.     i=atoi(netnam);
  1066.   return(i);
  1067. }
  1068.