home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / W / WWIVSOR.ZIP / NEWUSER.C < prev    next >
Text File  |  1995-05-06  |  24KB  |  1,088 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. #include "vars.h"
  16.  
  17. #pragma hdrstop
  18.  
  19. #include <ctype.h>
  20. #include <math.h>
  21. #include <string.h>
  22.  
  23.  
  24. void input_phone(void)
  25. {
  26.   int ok;
  27.  
  28.   do {
  29.     nl();
  30.     ansic(3);
  31.     pl(get_string(527));
  32.     ansic(3);
  33.     pl(get_string(493));
  34.     prt(2,":");
  35.     mpl(12);
  36.     input(thisuser.phone,12);
  37.  
  38.     ok=valid_phone(thisuser.phone);
  39.     if (!ok) {
  40.       nl();
  41.       ansic(6);
  42.       pl(get_string(528));
  43.       ansic(6);
  44.       pl(get_string(529));
  45.     }
  46.   } while ((!ok) && (!hangup));
  47. }
  48.  
  49.  
  50. void input_dataphone(void)
  51. {
  52.   int ok;
  53.  
  54.   do {
  55.     nl();
  56.     ansic(3);
  57.     pl(get_string(540));
  58.     ansic(3);
  59.     pl(get_string(493));
  60.     prt(2,":");
  61.     mpl(12);
  62.     input(thisuser.dataphone,12);
  63.  
  64.     ok=valid_phone(thisuser.dataphone);
  65.  
  66.     if (!ok) {
  67.       nl();
  68.       ansic(6);
  69.       pl(get_string(528));
  70.       ansic(6);
  71.       pl(get_string(529));
  72.     }
  73.   } while ((!ok) && (!hangup));
  74. }
  75.  
  76. void input_language(void)
  77. {
  78.   int i;
  79.   char onx[20],ch,*ss;
  80.  
  81.   if (num_languages>1) {
  82.  
  83.     thisuser.language=255;
  84.  
  85.     do {
  86.       nln(2);
  87.       for (i=0; i<num_languages; i++) {
  88.         npr("%d. %s\r\n",i+1,languages[i].name);
  89.         if (i<9)
  90.           onx[i]='1'+i;
  91.       }
  92.       nl();
  93.       prt(2,get_string(937));
  94.       if (num_languages<10) {
  95.         onx[num_languages]=0;
  96.         ch=onek(onx);
  97.         ch-='1';
  98.       } else {
  99.         for (i=1; i<=num_languages/10; i++)
  100.           odc[i-1]='0'+i;
  101.         odc[i-1]=0;
  102.         ss=mmkey(2);
  103.         ch=atoi(ss)-1;
  104.       }
  105.       if ((ch>=0) && (ch<num_languages)) {
  106.         thisuser.language=languages[ch].num;
  107.       }
  108.     } while (thisuser.language==255);
  109.  
  110.     set_language(thisuser.language);
  111.   }
  112. }
  113.  
  114.  
  115. int check_name(unsigned char *nn)
  116. {
  117.   int ok,f,i;
  118.   unsigned char s[161],s1[161],s2[81];
  119.   long p,l;
  120.  
  121.   ok=1;
  122.   if (nn[strlen(nn)-1]==32)
  123.     ok=0;
  124.   if (nn[0]<65)
  125.     ok=0;
  126.   if (finduser(nn)!=0)
  127.     ok=0;
  128.   if (strchr(nn,'@')!=NULL)
  129.     ok=0;
  130.   if (strchr(nn,'#')!=NULL)
  131.     ok=0;
  132.  
  133.   if (!ok)
  134.     return(ok);
  135.  
  136.   sprintf(s,"%sTRASHCAN.TXT",syscfg.gfilesdir);
  137.   f=sh_open1(s,O_RDONLY | O_BINARY);
  138.  
  139.   if (f<0)
  140.     return(ok);
  141.  
  142.   sh_lseek(f,0L,SEEK_SET);
  143.   l=filelength(f);
  144.   p=0;
  145.   sprintf(s2," %s ",nn);
  146.   while ((p<l) && (ok)) {
  147.     sh_lseek(f,p,SEEK_SET);
  148.     sh_read(f,(void *)s,150);
  149.     i=0;
  150.     while ((i<150) && (s[i])) {
  151.       if (s[i]==13)
  152.         s[i]=0;
  153.       else
  154.         ++i;
  155.     }
  156.     s[150]=0;
  157.     p += (long) (i+2);
  158.     if (s[i-1]==1)
  159.       s[i-1]=0;
  160.     for (i=0; i<strlen(s); i++)
  161.       s[i]=upcase(s[i]);
  162.     sprintf(s1," %s ",s);
  163.     if (strstr(s2,s1)!=NULL)
  164.       ok=0;
  165.   }
  166.   sh_close(f);
  167.   if (!ok) {
  168.     hangup=1;
  169.     hang_it_up();
  170.   }
  171.   return(ok);
  172. }
  173.  
  174.  
  175. void input_name(void)
  176. {
  177.   int ok,count;
  178.  
  179.   count=0;
  180.   do {
  181.     nl();
  182.     ansic(3);
  183.     if (syscfg.sysconfig & sysconfig_no_alias)
  184.       pl(get_string(520));
  185.     else
  186.       pl(get_string(521));
  187.     prt(2,":");
  188.     mpl(30);
  189.     input(thisuser.name,30);
  190.     ok=check_name(thisuser.name);
  191.     if (!ok) {
  192.       nl();
  193.       ansic(6);
  194.       pl(get_string(522));
  195.       ++count;
  196.       if (count==3) {
  197.         hangup=1;
  198.         hang_it_up();
  199.       }
  200.     }
  201.   } while ((!ok) && (!hangup));
  202. }
  203.  
  204.  
  205. void input_realname(void)
  206. {
  207.   if (!(syscfg.sysconfig & sysconfig_no_alias)) {
  208.     do {
  209.       nl();
  210.       ansic(3);
  211.       pl(get_string(523));
  212.       prt(2,":");
  213.       mpl(20);
  214.       inputp(thisuser.realname,20);
  215.  
  216.       if (thisuser.realname[0]==0) {
  217.         nl();
  218.         ansic(6);
  219.         pl(get_string(524));
  220.       }
  221.     } while ((thisuser.realname[0]==0) && (!hangup));
  222.   } else {
  223.     strncpy(thisuser.realname, thisuser.name, sizeof(thisuser.realname)-1);
  224.   }
  225. }
  226.  
  227. void input_callsign(void)
  228. {
  229.   nl();
  230.   ansic(3);
  231.   pl(get_string(525));
  232.   ansic(3);
  233.   pl(get_string(526));
  234.   prt(2,":");
  235.   mpl(6);
  236.   input(thisuser.callsign,6);
  237. }
  238.  
  239.  
  240. int valid_phone(char *phone)
  241. {
  242.   int i;
  243.  
  244.   if (syscfg.sysconfig & sysconfig_free_phone)
  245.     return(1);
  246.  
  247.   if (syscfg.sysconfig & sysconfig_extended_info) {
  248.     if ((!usa_phone_convention(&thisuser)) && thisuser.country[0])
  249.       return(1);
  250.   }
  251.  
  252.   if (strlen(phone)!=12)
  253.     return(0);
  254.   if ((phone[3]!='-') || (phone[7]!='-'))
  255.     return(0);
  256.   for (i=0; i<12; i++) {
  257.     if ((i!=3) && (i!=7)) {
  258.       if ((phone[i]<'0') || (phone[i]>'9')) {
  259.         return(0);
  260.       }
  261.     }
  262.   }
  263.   return(1);
  264. }
  265.  
  266.  
  267. void input_street(void)
  268. {
  269.   do {
  270.     nl();
  271.     ansic(3);
  272.     pl(get_string(530));
  273.     prt(2,":");
  274.     mpl(30);
  275.     inputp(thisuser.street,30);
  276.  
  277.     if (thisuser.street[0]==0) {
  278.       nl();
  279.       ansic(6);
  280.       pl(get_string(531));
  281.     }
  282.   } while ((thisuser.street[0]==0) && (!hangup));
  283. }
  284.  
  285. void input_city(void)
  286. {
  287.   do {
  288.     nl();
  289.     ansic(3);
  290.     pl(get_string(532));
  291.     prt(2,":");
  292.     mpl(30);
  293.     inputp(thisuser.city,30);
  294.  
  295.     if (thisuser.city[0]==0) {
  296.       nl();
  297.       ansic(6);
  298.       pl(get_string(533));
  299.     }
  300.   } while ((thisuser.city[0]==0) && (!hangup));
  301. }
  302.  
  303. void input_state(void)
  304. {
  305.   do {
  306.     nl();
  307.     ansic(3);
  308.     if (strcmp(thisuser.country,"CAN")==0)
  309.       pl(get_string(1521));
  310.     else
  311.       pl(get_string(534));
  312.     prt(2,":");
  313.     mpl(2);
  314.     input(thisuser.state,2);
  315.  
  316.     if (thisuser.state[0]==0) {
  317.       nl();
  318.       ansic(6);
  319.       pl(get_string(535));
  320.     }
  321.   } while ((thisuser.state[0]==0) && (!hangup));
  322. }
  323.  
  324. void input_country(void)
  325. {
  326.   do {
  327.     nl();
  328.     ansic(3);
  329.     pl(get_string(536));
  330.     prt(2,":");
  331.     mpl(3);
  332.     input(thisuser.country,3);
  333.  
  334.     if (thisuser.country[0]==0) {
  335.       nl();
  336.       ansic(6);
  337.       pl(get_string(537));
  338.     }
  339.   } while ((thisuser.country[0]==0) && (!hangup));
  340. }
  341.  
  342.  
  343. void input_zipcode(void)
  344. {
  345.   int len;
  346.  
  347.   do {
  348.     nl();
  349.     ansic(3);
  350.     if (strcmp(thisuser.country,"CAN")==0) {
  351.       pl(get_string(1522));
  352.       len=7;
  353.     } else {
  354.       pl(get_string(538));
  355.       len=10;
  356.     }
  357.     prt(2,":");
  358.     mpl(len);
  359.     input(thisuser.zipcode,len);
  360.  
  361.     if (thisuser.zipcode[0]==0) {
  362.       nl();
  363.       ansic(6);
  364.       pl(get_string(539));
  365.     }
  366.   } while ((thisuser.zipcode[0]==0) && (!hangup));
  367. }
  368.  
  369. void input_sex(void)
  370. {
  371.   nl();
  372.   prt(2,get_string(541));
  373.   thisuser.sex=onek("MF");
  374. }
  375.  
  376. void input_age(userrec *u)
  377. {
  378.   int ok,y,m,d;
  379.   char ag[10];
  380.  
  381.   do {
  382.     nl();
  383.     do {
  384.       nl();
  385.       prt(2,get_string(542));
  386.       mpl(2);
  387.       input(ag,2);
  388.       m=atoi(ag);
  389.     } while ((!hangup) && ((m>12) || (m<1)));
  390.     do {
  391.       nl();
  392.       prt(2,get_string(543));
  393.       mpl(2);
  394.       input(ag,2);
  395.       d=atoi(ag);
  396.     } while ((!hangup) && ((d>31) || (d<1)));
  397.     do {
  398.       nl();
  399.       prt(2,get_string(544));
  400.       mpl(2);
  401.       input(ag,2);
  402.       y=atoi(ag)+1900;
  403.       if (y==1919) {
  404.         nl();
  405.         prt(5,get_string(545));
  406.         if (!yn()) {
  407.           y=0;
  408.         }
  409.       }
  410.     } while ((!hangup) && (y<1905));
  411.     ok=1;
  412.     if (((m==2) || (m==9) || (m==4) || (m==6) || (m==11)) && (d==31))
  413.       ok=0;
  414.     if ((m==2) && (((y%4!=0) && (d==29)) || (d==30)))
  415.       ok=0;
  416.     if (!ok) {
  417.       nl();
  418.       ansic(6);
  419.       pl(get_string(546));
  420.     }
  421.     if (years_old((unsigned char)m, (unsigned char)d, (unsigned char)(y-1900))<5) {
  422.       nl();
  423.       pl(get_string(547));
  424.       ok=0;
  425.     }
  426.   } while ((!ok) && (!hangup));
  427.   u->month=(unsigned char) m;
  428.   u->day=(unsigned char) d;
  429.   u->year=(unsigned char) (y-1900);
  430.   u->age=years_old(u->month,u->day,u->year);
  431.   nl();
  432. }
  433.  
  434. void input_comptype(void)
  435. {
  436.   int i,ok,ct;
  437.   char c[5];
  438.  
  439.   do {
  440.    nl();
  441.    pl(get_string(275));
  442.    nl();
  443.    for (i=0; ctypes[i]; i++)
  444.      npr("%d. %s\r\n",i+1,ctypes[i]);
  445.    nl();
  446.    ansic(3);
  447.    pl(get_string(548));
  448.    ansic(3);
  449.    pl(get_string(549));
  450.    prt(2,":");
  451.    mpl(2);
  452.    input(c,2);
  453.    ct=atoi(c);
  454.  
  455.    ok=1;
  456.    if ((ct<1) || (ct>i))
  457.      ok=0;
  458.  
  459.   } while ((!ok) && (!hangup));
  460.   thisuser.comp_type=ct-1;
  461.   /* if (checkcomp("Ami"))  thisuser.colors[0]=4; Why is this here? */
  462.   if (hangup)
  463.     thisuser.comp_type=0;
  464. }
  465.  
  466. void input_screensize(void)
  467. {
  468.   int ok,x,y;
  469.   char s[5];
  470.  
  471.   do {
  472.     nl();
  473.     ansic(3);
  474.     pl(get_string(550));
  475.     prt(2,":");
  476.     mpl(2);
  477.     input(s,2);
  478.     x=atoi(s);
  479.     if (s[0]==0)
  480.       x=80;
  481.  
  482.     if ((x<32) || (x>80))
  483.       ok=0;
  484.     else
  485.       ok=1;
  486.   } while ((!ok) && (!hangup));
  487.  
  488.   do {
  489.     nl();
  490.     ansic(3);
  491.     pl(get_string(551));
  492.     prt(2,":");
  493.     mpl(2);
  494.     input(s,2);
  495.     y=atoi(s);
  496.     if (s[0]==0)
  497.       y=25;
  498.  
  499.     if ((y<8) || (y>60))
  500.       ok=0;
  501.     else
  502.       ok=1;
  503.   } while ((!ok) && (!hangup));
  504.  
  505.   nl();
  506.   thisuser.screenchars=x;
  507.   thisuser.screenlines=y;
  508.   screenlinest=y;
  509. }
  510.  
  511. void input_pw(void)
  512. {
  513.   int ok;
  514.   char s[81];
  515.  
  516.   do {
  517.     nl();
  518.     ansic(3);
  519.     pl(get_string(552));
  520.     prt(2,":");
  521.     mpl(8);
  522.     input(s,8);
  523.  
  524.     ok=1;
  525.     if (strlen(s)<3)
  526.       ok=0;
  527.   } while ((!ok) && (!hangup));
  528.   if (ok)
  529.     strncpy(thisuser.pw,s,sizeof(thisuser.pw));
  530.   else
  531.     pl(get_string(463));
  532. }
  533.  
  534.  
  535. void input_ansistat(void)
  536. {
  537.   int i,c,c2;
  538.   char ch;
  539.  
  540.   thisuser.sysstatus &= ~(sysstatus_ansi | sysstatus_color);
  541.   nl();
  542.   if (check_ansi()==1) {
  543.     outstr(get_string(553));
  544.   } else {
  545.     outstr(get_string(1244));
  546.     outstr(get_string(1245));
  547.     outstr(get_string(1246));
  548.     outstr(get_string(1247));
  549.     outstr(get_string(1248));
  550.     pl(get_string(1249));
  551.     pl(get_string(554));
  552.     outstr(get_string(555));
  553.   }
  554.   if (yn()) {
  555.     thisuser.sysstatus |= sysstatus_ansi;
  556.     nl();
  557.     prt(5,get_string(556));
  558.     if (yn()) {
  559.       thisuser.sysstatus |= sysstatus_color;
  560.       if (E_C) {
  561.         thisuser.sysstatus |= sysstatus_extra_color;
  562.       }
  563.     } else {
  564.       color_list();
  565.       nl();
  566.       prt(2,get_string(557));
  567.       ch=onek("\r123456789");
  568.       if (ch=='\r')
  569.         ch='7';
  570.       c=ch-'0';
  571.       c2=c << 4;
  572.       for (i=0; i<10; i++) {
  573.        if ((thisuser.bwcolors[i] & 0x70) == 0)
  574.          thisuser.bwcolors[i]=(thisuser.bwcolors[i] & 0x88) | c;
  575.        else
  576.          thisuser.bwcolors[i]=(thisuser.bwcolors[i] & 0x88) | c2;
  577.       }
  578.     }
  579.   }
  580. }
  581.  
  582. int find_new_usernum(userrec *u, unsigned long *qsc)
  583. {
  584.   char s[81];
  585.   int f, nu, un,n;
  586.   userrec tu;
  587.  
  588.   sprintf(s,"%sUSER.LST",syscfg.datadir);
  589.  
  590.   f=-1;
  591.   for (n=0; (f<0) && (n<20); n++) {
  592.     f=sh_open(s,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
  593.     if (f<0) {
  594.       wait1(2);
  595.     }
  596.   }
  597.   if (f<0)
  598.     return(-1);
  599.  
  600.   nu=((int) (filelength(f)/syscfg.userreclen)-1);
  601.   sh_lseek(f, syscfg.userreclen, SEEK_SET);
  602.   un=1;
  603.  
  604.   read_status();
  605.   if (nu == status.users) {
  606.     un=nu+1;
  607.   } else {
  608.  
  609.     while (un<=nu) {
  610.       if (un%25 == 0) {
  611.         f=sh_close(f);
  612.         for (n=0; (f<0) && (n<20); n++) {
  613.           f=sh_open(s,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
  614.           if (f<0) {
  615.             wait1(2);
  616.           }
  617.         }
  618.         if (f<0)
  619.           return(-1);
  620.         sh_lseek(f, ((long) syscfg.userreclen) * ((long) un), SEEK_SET);
  621.         nu=((int) (filelength(f)/syscfg.userreclen)-1);
  622.       }
  623.  
  624.       sh_read(f, (void *)&tu, syscfg.userreclen);
  625.  
  626.       if (tu.inact & inact_deleted) {
  627.         sh_lseek(f, ((long) syscfg.userreclen) * ((long) un), SEEK_SET);
  628.         sh_write(f, (void *)u, syscfg.userreclen);
  629.         sh_close(f);
  630.         write_qscn(un, qsc, 0);
  631.         isr(un, u->name);
  632.         return(un);
  633.       } else
  634.         un++;
  635.     }
  636.   }
  637.  
  638.   if (un <= syscfg.maxusers) {
  639.     sh_lseek(f, ((long) syscfg.userreclen) * ((long) un), SEEK_SET);
  640.     sh_write(f, (void *)u, syscfg.userreclen);
  641.     sh_close(f);
  642.     write_qscn(un, qsc, 0);
  643.     isr(un, u->name);
  644.     return(un);
  645.   } else {
  646.     sh_close(f);
  647.     return(-1);
  648.   }
  649. }
  650.  
  651.  
  652. void newuser(void)
  653. {
  654.   int i, ok;
  655.   char s[255],s1[81],ch;
  656.  
  657.   memset(&thisuser, 0, sizeof(userrec));
  658.   memset(qsc, 0, syscfg.qscn_len);
  659.  
  660.   strncpy(thisuser.firston,date(),sizeof(thisuser.firston));
  661.   strncpy(thisuser.laston,get_string(564),sizeof(thisuser.laston));
  662.   strncpy(&thisuser.macros[0][0],get_string(565),sizeof(thisuser.macros[0]));
  663.   strncpy(&thisuser.macros[1][0],get_string(566),sizeof(thisuser.macros[1]));
  664.   strncpy(&thisuser.macros[2][0],get_string(567),sizeof(thisuser.macros[2]));
  665.  
  666.   thisuser.screenlines=25;
  667.   thisuser.screenchars=80;
  668.   screenlinest=25;
  669.  
  670.   thisuser.sl=syscfg.newusersl;
  671.   thisuser.dsl=syscfg.newuserdsl;
  672.  
  673.   thisuser.ontoday=1;
  674.  
  675.   thisuser.restrict=syscfg.newuser_restrict;
  676.  
  677.   *qsc=999;
  678.   memset(qsc_n,0xff,((max_dirs+31)/32)*4);
  679.   memset(qsc_q,0xff,((max_subs+31)/32)*4);
  680.  
  681.   thisuser.sysstatus=sysstatus_pause_on_page |
  682.                      sysstatus_nscan_file_system |
  683.                      sysstatus_conference;
  684.  
  685.   thisuser.gold=syscfg.newusergold;
  686.  
  687.   thisuser.colors[0]=sysinfo.newuser_colors[0];
  688.   thisuser.colors[1]=sysinfo.newuser_colors[1];
  689.   thisuser.colors[2]=sysinfo.newuser_colors[2];
  690.   thisuser.colors[3]=sysinfo.newuser_colors[3];
  691.   thisuser.colors[4]=sysinfo.newuser_colors[4];
  692.   thisuser.colors[5]=sysinfo.newuser_colors[5];
  693.   thisuser.colors[6]=sysinfo.newuser_colors[6];
  694.   thisuser.colors[7]=sysinfo.newuser_colors[7];
  695.   thisuser.colors[8]=sysinfo.newuser_colors[8];
  696.   thisuser.colors[9]=sysinfo.newuser_colors[9];
  697.  
  698.   thisuser.bwcolors[0]=sysinfo.newuser_bwcolors[0];
  699.   thisuser.bwcolors[1]=sysinfo.newuser_bwcolors[1];
  700.   thisuser.bwcolors[2]=sysinfo.newuser_bwcolors[2];
  701.   thisuser.bwcolors[3]=sysinfo.newuser_bwcolors[3];
  702.   thisuser.bwcolors[4]=sysinfo.newuser_bwcolors[4];
  703.   thisuser.bwcolors[5]=sysinfo.newuser_bwcolors[5];
  704.   thisuser.bwcolors[6]=sysinfo.newuser_bwcolors[6];
  705.   thisuser.bwcolors[7]=sysinfo.newuser_bwcolors[7];
  706.   thisuser.bwcolors[8]=sysinfo.newuser_bwcolors[8];
  707.   thisuser.bwcolors[9]=sysinfo.newuser_bwcolors[9];
  708.  
  709.   reset_act_sl();
  710.  
  711.   for (i=0; i<6; i++) {
  712.     ch=rand() % 36;
  713.     if (ch<10)
  714.       ch+='0';
  715.     else
  716.       ch+='A'-10;
  717.     thisuser.pw[i]=ch;
  718.   }
  719.   thisuser.pw[6]=0;
  720.  
  721.   if (rip_on())
  722.     random_screen("NEWUSER");
  723.  
  724.   input_language();
  725.  
  726.   sprintf(s,get_stringx(1,25),date(),times(),curspeed, instance);
  727.   sl1(0,"");
  728.   sl1(0,s);
  729.   read_status();
  730.   if (status.users>=syscfg.maxusers) {
  731.     nln(2);
  732.     pl(get_string(558));
  733.     pl(get_string(559));
  734.     pl(get_string(560));
  735.     nl();
  736.     hangup=1;
  737.   }
  738.   if (syscfg.closedsystem) {
  739.     nln(2);
  740.     pl(get_string(561));
  741.     pl(get_string(562));
  742.     nl();
  743.     hangup=1;
  744.   }
  745.   if ((syscfg.newuserpw[0]!=0) && (incom)) {
  746.     nln(2);
  747.     ok=0;
  748.     i=0;
  749.     do {
  750.       outstr(get_string(563));
  751.       input(s,20);
  752.       if (strcmp(s,syscfg.newuserpw)==0)
  753.         ok=1;
  754.       else {
  755.         sprintf(s1,get_stringx(1,26),s);
  756.         sl1(0,s1);
  757.       }
  758.     } while ((!ok) && (!hangup) && (i++<4));
  759.     if (!ok)
  760.       hangup=1;
  761.   }
  762.  
  763.   if (!hangup) {
  764.     input_ansistat();
  765.     if (incom) {
  766.       if (printfile("SYSTEM"))
  767.         sl1(0,get_stringx(1,27));
  768.       pausescr();
  769.       if (printfile("NEWUSER"))
  770.         sl1(0,get_stringx(1,28));
  771.     }
  772.     if (syscfg.sysconfig & sysconfig_extended_info)
  773.       input_country();
  774.     input_name();
  775.     input_realname();
  776.     input_phone();
  777.     if (sysinfo.flags & OP_FLAGS_CHECK_DUPE_PHONENUM) {
  778.       if (check_dupes(thisuser.phone)) {
  779.         if (sysinfo.flags & OP_FLAGS_HANGUP_DUPE_PHONENUM) {
  780.           hangup=1;
  781.           hang_it_up();
  782.           return;
  783.         }
  784.       }
  785.     }
  786.     if (syscfg.sysconfig & sysconfig_extended_info) {
  787.       input_street();
  788.       sprintf(s,"%sZIP-CITY\\ZIP1.DAT",syscfg.datadir);
  789.       if (exist(s)) {
  790.         input_zipcode();
  791.         if ((check_zip(thisuser.zipcode,1))==0) {
  792.           thisuser.city[0]=0;
  793.           thisuser.state[0]=0;
  794.           thisuser.zipcode[0]=0;
  795.         }
  796.       }
  797.       if (thisuser.city[0]==0)
  798.         input_city();
  799.       if (thisuser.state[0]==0)
  800.         input_state();
  801.       if (thisuser.zipcode[0]==0)
  802.         input_zipcode();
  803.       input_dataphone();
  804.       if (sysinfo.flags & OP_FLAGS_CHECK_DUPE_PHONENUM) {
  805.         if (check_dupes(thisuser.dataphone)) {
  806.           if (sysinfo.flags & OP_FLAGS_HANGUP_DUPE_PHONENUM) {
  807.             hangup=1;
  808.             hang_it_up();
  809.             return;
  810.           }
  811.         }
  812.       }
  813.     }
  814.     input_callsign();
  815.     input_sex();
  816.     input_age(&thisuser);
  817.     input_comptype();
  818.     input_screensize();
  819.  
  820.     if (numed && (thisuser.sysstatus & sysstatus_ansi)) {
  821.       nl();
  822.       prt(5,get_string(568));
  823.       if (yn())
  824.         select_editor();
  825.       nl();
  826.     }
  827.  
  828.     prt(5,get_string(569));
  829.     if (yn()) {
  830.       nl();
  831.       pl(get_string(570));
  832.       nl();
  833.       i=get_protocol(xf_down);
  834.       if (i)
  835.         thisuser.defprot=i;
  836.     }
  837.     nl();
  838.     outstr(get_string(571)); pl(thisuser.pw);
  839.     nl();
  840.     prt(5,get_string(572));
  841.     if (yn())
  842.       input_pw();
  843.  
  844.     if (sysinfo.flags & OP_FLAGS_SIMPLE_ASV) {
  845.       if ((sysinfo.asv.sl>syscfg.newusersl) &&
  846.           (sysinfo.asv.sl<100)) {
  847.         nl();
  848.         prt(5,get_string(1250));
  849.         if (yn()) {
  850.            nl();
  851.            prt(5,get_string(1251));
  852.            nl();
  853.            mpl(60);
  854.            inputl(thisuser.note,60);
  855.            thisuser.sl=sysinfo.asv.sl;
  856.            thisuser.dsl=sysinfo.asv.dsl;
  857.            thisuser.ar=sysinfo.asv.ar;
  858.            thisuser.dar=sysinfo.asv.dar;
  859.            thisuser.exempt=sysinfo.asv.exempt;
  860.            thisuser.restrict=sysinfo.asv.restrict;
  861.            nl();
  862.            existprint("ASV");
  863.            nl();
  864.            pausescr();
  865.          }
  866.        }
  867.      }
  868.   }
  869.  
  870.   if (!hangup)
  871.     do {
  872.       nln(2);
  873.       outstr(get_string(573)); pl(thisuser.name);
  874.       if (!(syscfg.sysconfig & sysconfig_no_alias)) {
  875.         outstr(get_string(574)); pl(thisuser.realname);
  876.       }
  877.       outstr(get_string(575)); pl(thisuser.callsign);
  878.       outstr(get_string(576)); pl(thisuser.phone);
  879.       outstr(get_string(577)); npr("%c\r\n",thisuser.sex);
  880.       outstr(get_string(578)); npr("%02d/%02d/%02d\r\n",
  881.         (int) thisuser.month, (int) thisuser.day, (int) thisuser.year);
  882.       outstr(get_string(579)); pl(ctypes[thisuser.comp_type]);
  883.       outstr(get_string(580)); npr("%d X %d\r\n",
  884.         thisuser.screenchars, thisuser.screenlines);
  885.       outstr(get_string(581)); pl(thisuser.pw);
  886.       if (syscfg.sysconfig & sysconfig_extended_info) {
  887.         outstr(get_string(582)); pl(thisuser.street);
  888.         outstr(get_string(583)); pl(thisuser.city);
  889.         outstr(get_string(584)); pl(thisuser.state);
  890.         outstr(get_string(585)); pl(thisuser.country);
  891.         outstr(get_string(586)); pl(thisuser.zipcode);
  892.         outstr(get_string(587)); pl(thisuser.dataphone);
  893.       }
  894.       nl();
  895.       pl(get_string(588));
  896.       nln(2);
  897.       if (syscfg.sysconfig & sysconfig_extended_info) {
  898.         prt(2,get_string(589));
  899.         ch=onek("Q123456789ABCDEF");
  900.       } else {
  901.         prt(2,get_string(590));
  902.         ch=onek("Q123456789");
  903.       }
  904.       ok=0;
  905.       switch(ch) {
  906.         case 'Q': ok=1; break;
  907.         case '1': input_name(); break;
  908.         case '2':
  909.           if (!(syscfg.sysconfig & sysconfig_no_alias))
  910.             input_realname();
  911.           break;
  912.         case '3': input_callsign(); break;
  913.         case '4':
  914.           input_phone();
  915.         break;
  916.         case '5': input_sex(); break;
  917.         case '6': input_age(&thisuser); break;
  918.         case '7': input_comptype(); break;
  919.         case '8': input_screensize(); break;
  920.         case '9': input_pw(); break;
  921.         case 'A': input_street(); break;
  922.         case 'B': input_city(); break;
  923.         case 'C': input_state(); break;
  924.         case 'D': input_country(); break;
  925.         case 'E': input_zipcode(); break;
  926.         case 'F': input_dataphone(); break;
  927.       }
  928.     } while ((!ok) && (!hangup));
  929.  
  930.   if (!hangup) {
  931.  
  932.     nl();
  933.     pl(get_string(26));
  934.     nl();
  935.     usernum = find_new_usernum(&thisuser, qsc);
  936.     if (usernum<=0) {
  937.       nl();
  938.       pl(get_string(1523));
  939.       nl();
  940.       hangup=1;
  941.       return;
  942.     }
  943.     ok=0;
  944.     topscreen();
  945.     do {
  946.       nln(2);
  947.       outstr(get_string(591)); pln(usernum);
  948.       outstr(get_string(592)); pl(thisuser.pw);
  949.       nl();
  950.       pl(get_string(593));
  951.       pl(get_string(594));
  952.       pl(get_string(595));
  953.       pl(get_string(596));
  954.       nl();
  955.       outstr(get_string(357));
  956.       echo=0;
  957.       input(s,8);
  958.       if (strcmp(s,thisuser.pw)==0)
  959.         ok=1;
  960.     } while ((!ok) && (!hangup));
  961.     checkit=0;
  962.     if (incom) {
  963.       if (printfile("FEEDBACK"))
  964.         sl1(0,get_stringx(1,29));
  965.       feedback(1);
  966.     }
  967.     if (sysinfo.flags & OP_FLAGS_FORCE_NEWUSER_FEEDBACK) {
  968.       if ((incom) && (!thisuser.emailsent) && (!thisuser.feedbacksent)) {
  969.         existprint("NOFBACK");
  970.         deluser(usernum);
  971.         hangup=1;
  972.         hang_it_up();
  973.         return;
  974.       }
  975.     }
  976.     if ((!hangup) && (syscfg.newuser_c[0])) {
  977.       stuff_in(s,syscfg.newuser_c,create_chain_file(),"","","","");
  978.       write_user(usernum,&thisuser);
  979.       extern_prog(s, sysinfo.spawn_opts[1]);
  980.       read_user(usernum,&thisuser);
  981.     }
  982.     reset_act_sl();
  983.     changedsl();
  984.   }
  985. }
  986.  
  987.  
  988. int check_zip(char *zip, int mode)
  989. {
  990.   int ok;
  991.   char s[81];
  992.   userrec u;
  993.   FILE *zip_file;
  994.   char zip_buf[80];
  995.  
  996.   if (zip[0]==0)
  997.     return(0);
  998.   ok=1;
  999.   sprintf(s,"%sZIP-CITY\\ZIP%c.DAT",syscfg.datadir,zip[0]);
  1000.   if ((zip_file=fsh_open(s,"r"))==NULL) {
  1001.     nl(); ansic(6);
  1002.     outstr(s);
  1003.     pl(get_string(1261));
  1004.     ok=0;
  1005.   }
  1006.   for (;;) {
  1007.     if (fgets(zip_buf,sizeof zip_buf-1,zip_file)==NULL) {
  1008.       nl(); ansic(6);
  1009.       outstr(get_string(1262));
  1010.       outstr(zip);
  1011.       pl(".");
  1012.       fsh_close(zip_file);
  1013.       ok=0;
  1014.       break;
  1015.     }
  1016.     if (strncmp(zip_buf,zip,5)==0) {
  1017.       fsh_close(zip_file);
  1018.       break;
  1019.     }
  1020.   }
  1021.   if (!mode) {
  1022.     (void)sscanf(zip_buf,"%s %s %[ -Z]",&u.zipcode,&u.state,&u.city);
  1023.     properize(u.city);
  1024.     npr("\r\n2%s is in %s, %s.",u.zipcode,u.city,u.state);
  1025.     return(0);
  1026.   }
  1027.   if ((zip_buf) && (ok)) {
  1028.     (void)sscanf(zip_buf,"%s %s %[ -Z]",&u.zipcode,&u.state,&u.city);
  1029.     properize(u.city);
  1030.     npr("\r\n2%s, %s  %s? (y/N): ",u.city,u.state,"USA");
  1031.     if (yn()) {
  1032.       thisuser.city[0]=0;
  1033.       thisuser.state[0]=0;
  1034.       thisuser.country[0]=0;
  1035.       strcpy(thisuser.city,u.city);
  1036.       strcpy(thisuser.state,u.state);
  1037.       strcpy(thisuser.country,"USA");
  1038.     } else {
  1039.       nl(); ansic(6);
  1040.       pl(get_string(1263));
  1041.       ok=0;
  1042.     }
  1043.   }
  1044.   return(ok);
  1045. }
  1046.  
  1047.  
  1048. void properize(char *s)
  1049. {
  1050.   int i;
  1051.  
  1052.   for (i=0;i<strlen(s);i++) {
  1053.     if ((i==0) || ((i>0) && ((s[i-1]==' ') || (s[i-1]=='.')))) {
  1054.       s[i]=toupper(s[i]);
  1055.     } else {
  1056.       s[i]=tolower(s[i]);
  1057.     }
  1058.   }
  1059. }
  1060.  
  1061. int check_dupes(char *phone)
  1062. {
  1063.   int i, dupe=0;
  1064.   char s[81];
  1065.   userrec u;
  1066.  
  1067.   npr(get_string(1524));
  1068.   for (i=0;i<status.users;i++) {
  1069.     if ((i % 10)==0)
  1070.       outstr("3.0");
  1071.     read_user(i,&u);
  1072.     if ((strcmp(phone,u.phone)==0) || (strcmp(phone,u.dataphone)==0)) {
  1073.       if ((i!=usernum) && (strcmp(thisuser.name,u.name)!=0)
  1074.         && (u.inact & inact_deleted)) {
  1075.         sprintf(s,"    %s%s%s",thisuser.name,get_stringx(1,112),phone);
  1076.         sl1(0,s);
  1077.         ssm(1,0,s);
  1078.         sprintf(s,"%s%s",get_stringx(1,113),u.name);
  1079.         sl1(0,s);
  1080.         ssm(1,0,s);
  1081.         dupe=1;
  1082.       }
  1083.     }
  1084.   }
  1085.   return(dupe);
  1086. }
  1087.  
  1088.