home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / UTIL / WWIVE / MYWIVE.ZIP / NEWUSER.C < prev    next >
Text File  |  1993-07-19  |  14KB  |  614 lines

  1. #include "vars.h"
  2. #pragma hdrstop
  3.  
  4. int check_name(char *nn)
  5. {
  6.   int ok,f,i;
  7.   char s[161],s1[161],s2[81];
  8.   long p,l;
  9.  
  10.   ok=1;
  11.   if (nn[strlen(nn)-1]==32)
  12.     ok=0;
  13.   if (nn[0]<65)
  14.     ok=0;
  15.   if (finduser(nn)!=0)
  16.     ok=0;
  17.   if (strchr(nn,'@')!=NULL)
  18.     ok=0;
  19.   if (strchr(nn,'#')!=NULL)
  20.     ok=0;
  21.   if (!ok)
  22.     return(ok);
  23.   sprintf(s,"%sTRASHCAN.TXT",syscfg.gfilesdir);
  24.   f=open(s,O_RDWR | O_BINARY);
  25.   if (f<0)
  26.     return(ok);
  27.   lseek(f,0L,SEEK_SET);
  28.   l=filelength(f);
  29.   p=0;
  30.   sprintf(s2," %s ",nn);
  31.   while ((p<l) && (ok)) {
  32.     lseek(f,p,SEEK_SET);
  33.     read(f,(void *)s,150);
  34.     i=0;
  35.     while ((i<150) && (s[i])) {
  36.       if (s[i]==13)
  37.     s[i]=0;
  38.       else
  39.     ++i;
  40.     }
  41.     s[150]=0;
  42.     p += (long) (i+2);
  43.     if (s[i-1]==1)
  44.       s[i-1]=0;
  45.     for (i=0; i<strlen(s); i++)
  46.       s[i]=upcase(s[i]);
  47.     sprintf(s1," %s ",s);
  48.     if (strstr(s2,s1)!=NULL)
  49.       ok=0;
  50.   }
  51.   close(f);
  52.   if (!ok)
  53.     hangup=1;
  54.   return(ok);
  55. }
  56.  
  57. void input_name()
  58. {
  59.   int ok,count;
  60.  
  61.   count=0;
  62.   do {
  63.     nl();
  64.     if (syscfg.sysconfig & sysconfig_no_alias)
  65.       pl("Enter your full REAL name.");
  66.     else
  67.       pl("1Enter your alias.");
  68.     outstr(":");
  69.     mpl(18);
  70.     input(thisuser.name,18);
  71.     ok=check_name(thisuser.name);
  72.     if (!ok) {
  73.       nl();
  74.       pl("fI'm sorry, that name is already in use.");
  75.       ++count;
  76.       if (count==3)
  77.         hangup=1;
  78.     }
  79.   } while ((!ok) && (!hangup));
  80. }
  81.  
  82. void input_realname()
  83. {
  84.   do {
  85.     nl();
  86.     if (syscfg.sysconfig& sysconfig_no_alias)
  87.       pl("1Enter the city and state you live in.");
  88.     else
  89.       pl("1Enter your real fFIRST 1name.");
  90.     outstr(":");
  91.     mpl(20);
  92.     inputf(thisuser.realname,20);
  93.  
  94.     if (thisuser.realname[0]==0) {
  95.       nl();
  96.       if (syscfg.sysconfig & sysconfig_no_alias)
  97.     pl("fSorry, you must enter your city and state.");
  98.       else
  99.     pl("fSorry, you must enter your real FIRST name.");
  100.     }
  101.   } while ((thisuser.realname[0]==0) && (!hangup));
  102. }
  103.  
  104. void input_lastname()
  105. {
  106.   do {
  107.     nl();
  108.     pl("1Enter your real fLAST 1name.");
  109.     outstr(":");
  110.     mpl(20);
  111.     inputf(thisuser.lastname,20);
  112.     if (thisuser.lastname[0]==0) {
  113.       nl();
  114.       pl("fSorry, you must enter your real LAST name.");
  115.     }
  116.   } while ((thisuser.lastname[0]==0) && (!hangup));
  117. }
  118.  
  119. void input_address()
  120. {
  121.   do {
  122.     nl();
  123.     pl("1Enter your street address.");
  124.     outstr(":");
  125.     mpl(37);
  126.     inputf(thisuser.stretadd,37);
  127.     if (thisuser.stretadd[0]==0) {
  128.       nl();
  129.       pl("fSorry, you must enter your Street Address.");
  130.     }
  131.   } while ((thisuser.stretadd[0]==0) && (!hangup));
  132. }
  133.  
  134. void input_citystate()
  135. {
  136.   do {
  137.     nl();
  138.     pl("1Enter your City and State.");
  139.     outstr(":");
  140.     mpl(37);
  141.     inputf(thisuser.citstate,37);
  142.     if (thisuser.citstate[0]==0) {
  143.       nl();
  144.       pl("fSorry, you must enter your city and state.");
  145.     }
  146.   } while ((thisuser.citstate[0]==0) && (!hangup));
  147. }
  148.  
  149. void input_callsign()
  150. {
  151.   char s[81];
  152.   long l;
  153.   
  154.   do {
  155.   nl();
  156.   pl("1Enter your zipcode");
  157.   outstr(":");
  158.   mpl(5);
  159.   input(s,5);
  160.   l=atol(s);
  161.   if ((s[0]) && (l>=0))
  162.     thisuser.wwiv_regnum = l;
  163.   if (s[0]==0) {
  164.     nl();
  165.     pl("fSorry, you must enter your zipcode.");
  166.    }
  167.   } while ((s[0]==0) && (!hangup));
  168. }
  169.  
  170. void input_phone()
  171. {
  172.   int ok,i;
  173.  
  174.   do {
  175.     nl();
  176.     pl("1Enter your fVOICE 1phone no. in the form:");
  177.     pl(" e■■■-■■■-■■■■");
  178.     outstr(":");
  179.     mpl(12);
  180.     inputl(thisuser.phone,12);
  181.     ok=1;
  182.     if ((syscfg.sysconfig & sysconfig_free_phone)==0) {
  183.       if (strlen(thisuser.phone)!=12)
  184.         ok=0;
  185.       if ((thisuser.phone[3]!='-') || (thisuser.phone[7]!='-'))
  186.         ok=0;
  187.       if ((thisuser.phone[1]!='0') && (thisuser.phone[1]!='1'))
  188.         ok=0;
  189.       for (i=0; i<12; i++)
  190.         if ((i!=3) && (i!=7))
  191.           if ((thisuser.phone[i]<'0') || (thisuser.phone[i]>'9'))
  192.             ok=0;
  193.     }
  194.     if (!ok) {
  195.       nl();
  196.       pl("fPlease enter a valid phone number");
  197.       pl("fin the correct format.");
  198.     }
  199.   } while ((!ok) && (!hangup));
  200. }
  201.  
  202. void input_sex()
  203. {
  204.   nl();
  205.   outstr("1Your gender (M,F) :");
  206.   mpl(1);
  207.   thisuser.sex=onek("MF");
  208. }
  209.  
  210. void input_age(userrec *u)
  211. {
  212.   int a,ok,y,m,d;
  213.   char ag[10];
  214.  
  215.   do {
  216.     nl();
  217.     do {
  218.       nl();
  219.       outstr("1Month you were born (1-12) : ");
  220.       mpl(2);
  221.       input(ag,2);
  222.       m=atoi(ag);
  223.     } while ((!hangup) && ((m>12) || (m<1)));
  224.     do {
  225.       nl();
  226.       outstr("1Day of month you were born (1-31) : ");
  227.       mpl(2);
  228.       input(ag,2);
  229.       d=atoi(ag);
  230.     } while ((!hangup) && ((d>31) || (d<1)));
  231.     do {
  232.       nl();
  233.       outstr("1Year you were born: 19");
  234.       mpl(2);
  235.       input(ag,2);
  236.       y=atoi(ag)+1900;
  237.     } while ((!hangup) && (y<1905));
  238.     ok=1;
  239.     if (((m==2) || (m==9) || (m==4) || (m==6) || (m==11)) && (d==31))
  240.       ok=0;
  241.     if ((m==2) && (y%4!=0) && (d==30))
  242.       ok=0;
  243.     if (!ok) {
  244.       nl();
  245.       pl("fThere aren't that many days in that month.");
  246.     }
  247.   } while ((!ok) && (!hangup));
  248.   u->month=(unsigned char) m;
  249.   u->day=(unsigned char) d;
  250.   u->year=(unsigned char) (y-1900);
  251.   u->age=years_old(u->month,u->day,u->year);
  252.   nl();
  253. }
  254.  
  255. void input_comptype()
  256. {
  257.   int i,ok,ct;
  258.   char c[5];
  259.  
  260.   do {
  261.    nl();
  262.    pl("1Known computer types:");
  263.    nl();
  264.    for (i=0; ctypes[i]; i++)
  265.      npr("%d. %s\r\n",i+1,ctypes[i]);
  266.    nl();
  267.    pl("1Enter your computer type, or the");
  268.    pl("1closest to it (ie, Compaq -> IBM).");
  269.    outstr(":");
  270.    mpl(2);
  271.    input(c,2);
  272.    ct=atoi(c);
  273.    ok=1;
  274.    if ((ct<1) || (ct>i))
  275.      ok=0;
  276.   } while ((!ok) && (!hangup));
  277.   thisuser.comp_type=ct-1;
  278.   if (checkcomp("Ami"))
  279.     thisuser.colors[0]=4;
  280.   if (hangup)
  281.     thisuser.comp_type=0;
  282. }
  283.  
  284. void input_screensize()
  285. {
  286.   int ok,x,y;
  287.   char s[5];
  288.  
  289.   do {
  290.     nl();
  291.     pl("1How wide is your screen (chars, <CR>=80) ?");
  292.     outstr(":");
  293.     mpl(2);
  294.     input(s,2);
  295.     x=atoi(s);
  296.     if (s[0]==0)
  297.       x=80;
  298.     if ((x<32) || (x>80))
  299.       ok=0;
  300.     else
  301.       ok=1;
  302.   } while ((!ok) && (!hangup));
  303.   do {
  304.     nl();
  305.     pl("1How tall is your screen (lines, <CR>=25) ?");
  306.     outstr(":");
  307.     mpl(2);
  308.     input(s,2);
  309.     y=atoi(s);
  310.     if (s[0]==0)
  311.       y=25;
  312.     if ((y<4) || (y>60))
  313.       ok=0;
  314.     else
  315.       ok=1;
  316.   } while ((!ok) && (!hangup));
  317.   thisuser.screenchars=x;
  318.   thisuser.screenlines=y;
  319.   screenlinest=y;
  320. }
  321.  
  322. void input_pw()
  323. {
  324.   int ok;
  325.   char s[81];
  326.  
  327.   do {
  328.     nl();
  329.     pl("1Please enter a new password, 3-8 chars.");
  330.     outstr(":");
  331.     mpl(8);
  332.     input(s,8);
  333.     ok=1;
  334.     if (strlen(s)<3)
  335.       ok=0;
  336.   } while ((!ok) && (!hangup));
  337.   if (ok)
  338.     strcpy(thisuser.pw,s);
  339.   else
  340.     pl("fPassword not changed.");
  341. }
  342.  
  343. void input_ansistat()
  344. {
  345.   int i,c,c2;
  346.   char ch;
  347.  
  348.   nl();
  349.   outstr("\x1b[0;34;3mTEST\x1b[C");
  350.   outstr("\x1b[0;30;45mTEST\x1b[C");
  351.   outstr("\x1b[0;1;31;44mTEST\x1b[C");
  352.   outstr("\x1b[0;32;7mTEST\x1b[C");
  353.   outstr("\x1b[0;1;5;33;46mTEST\x1b[C");
  354.   pl("\x1b[0;4mTEST\x1b[0m");
  355.   thisuser.sysstatus &= ~(sysstatus_ansi | sysstatus_color);
  356.   pl("1Is the above line colored, italicized,");
  357.   prt(1,"bold, inversed, or blinking? ");
  358.   if (yn())
  359.     {
  360.     thisuser.sysstatus |= sysstatus_ansi;
  361.     nl();
  362.     outstr("Do you want color? ");
  363.     if (yn())
  364.       thisuser.sysstatus |= sysstatus_color;
  365.     else {
  366.       color_list();
  367.       nl();
  368.       outstr("Monochrome base color (<C/R>=7)? ");
  369.       ch=onek("\r1234567");
  370.       if (ch=='\r')
  371.         ch='7';
  372.       c=ch-'0';
  373.       c2=c << 4;
  374.       for (i=0; i<8; i++) {
  375.        if ((thisuser.bwcolors[i] & 0x70) == 0)
  376.      thisuser.bwcolors[i]=(thisuser.bwcolors[i] & 0x88) | c;
  377.        else
  378.      thisuser.bwcolors[i]=(thisuser.bwcolors[i] & 0x88) | c2;
  379.       }
  380.     }
  381.    }
  382. }
  383.  
  384. void input_sex_type()
  385. {
  386.   char s4[2];
  387.   int j;
  388.  
  389.   do {
  390.     npr("Please enter your sexual preference - Nobody will see it -\r\n");
  391.     npr("1. Straight\r\n2. Gay\r\n3. Bi-Sexual\r\n4. Still under personal debate\r\n");
  392.     outstr(": ");
  393.     input(s4,1);
  394.     strcpy(thisuser.sex_type,s4);
  395.     j=atoi(s4);
  396.    } while((j==0) || (j>4));
  397. }
  398.  
  399. void newuser()
  400. {
  401.   int i,ok;
  402.   char s[255],s1[81],ch;
  403.   userrec u;
  404.   long l1,l2;
  405.  
  406.   sprintf(s,"*** NEW USER %s   %s    %s",date(),times(),curspeed);
  407.   sl1(0,"");
  408.   sl1(0,s);
  409.   if (status.users>=syscfg.maxusers) {
  410.     nl();
  411.     nl();
  412.     pl("I'm sorry, but the system currently has");
  413.     pl("the maximum number of users it can");
  414.     pl("handle.");
  415.     nl();
  416.     hangup=1;
  417.   }
  418.   if (syscfg.closedsystem) {
  419.     nl();
  420.     nl();
  421.     pl("I'm sorry, but the system is currently");
  422.     pl("closed, and not accepting new users.");
  423.     nl();
  424.     hangup=1;
  425.   }
  426.   if ((syscfg.newuserpw[0]!=0) && (incom)) {
  427.     nl();
  428.     nl();
  429.     ok=0;
  430.     i=0;
  431.     do {
  432.       outstr("New User Password :");
  433.       input(s,20);
  434.       if (strcmp(s,syscfg.newuserpw)==0)
  435.         ok=1;
  436.       else {
  437.         sprintf(s1,"Wrong newuser password: %s",s);
  438.         sl1(0,s1);
  439.       }
  440.     } while ((!ok) && (!hangup) && (i++<4));
  441.     if (!ok)
  442.       hangup=1;
  443.   }
  444.   memset(&thisuser, 0, sizeof(userrec));
  445.   strcpy(thisuser.firston,date());
  446.   strcpy(thisuser.laston,"Never.");
  447.   strcpy(&thisuser.macros[0][0],"I love Gilgamesh!!!!");
  448.   strcpy(&thisuser.macros[1][0],"The Devil's Doorknob Rules!");
  449.   strcpy(&thisuser.macros[2][0],"Whatever");
  450.   thisuser.screenlines=25;
  451.   thisuser.screenchars=80;
  452.   screenlinest=25;
  453.   thisuser.sl=syscfg.newusersl;
  454.   thisuser.dsl=syscfg.newuserdsl;
  455.   thisuser.sysopsub=255;
  456.   thisuser.ontoday=1;
  457.   thisuser.restrict=syscfg.newuser_restrict;
  458.   thisuser.qscn=0xFFFFFFFF;
  459. #if MAX_SUBS>32
  460.   thisuser.qscn2=0xFFFFFFFF;
  461. #endif
  462.   thisuser.nscn1=0xFFFFFFFF;
  463.   thisuser.nscn2=0xFFFFFFFF;
  464.   thisuser.sysstatus=sysstatus_pause_on_page | sysstatus_nscan_file_system;
  465.   thisuser.gold=syscfg.newusergold;
  466.   thisuser.colors[0]=7;
  467.   thisuser.colors[1]=11;
  468.   thisuser.colors[2]=14;
  469.   thisuser.colors[3]=5;
  470.   thisuser.colors[4]=31;
  471.   thisuser.colors[5]=2;
  472.   thisuser.colors[6]=140;
  473.   thisuser.colors[7]=9;
  474.   thisuser.bwcolors[0]=7;
  475.   thisuser.bwcolors[1]=15;
  476.   thisuser.bwcolors[2]=15;
  477.   thisuser.bwcolors[3]=15;
  478.   thisuser.bwcolors[4]=112;
  479.   thisuser.bwcolors[5]=15;
  480.   thisuser.bwcolors[6]=143;
  481.   thisuser.bwcolors[7]=7;
  482.   reset_act_sl();
  483.   for (i=0; i<6; i++) {
  484.     ch=rand() % 36;
  485.     if (ch<10)
  486.       ch+='0';
  487.     else
  488.       ch+='A'-10;
  489.     thisuser.pw[i]=ch;
  490.   }
  491.   thisuser.pw[6]=0;
  492.   if (!hangup) {
  493.     if (incom) {
  494.       if (printfile("SYSTEM.MSG"))
  495.     sl1(0,"#Aborted SYSTEM.MSG");
  496.       if (printfile("NEWUSER.MSG"))
  497.     sl1(0,"#Aborted NEWUSER.MSG");
  498.     }
  499.     if (!hangup)
  500.     input_ansistat();
  501.     if (!hangup)
  502.     input_name();
  503.     input_realname();
  504.     input_lastname();
  505.     input_phone();
  506.     input_address();
  507.     input_citystate();
  508.     input_callsign();
  509.     input_sex();
  510.     input_age(&thisuser);
  511.     input_sex_type();
  512.     input_comptype();
  513.     input_screensize();
  514.     nl();
  515.     npr("1Random password: %s\r\n",thisuser.pw);
  516.     nl();
  517.     prt(5,"1Do you want a different password (Y/N)? ");
  518.     if (yn())
  519.       input_pw();
  520.   }
  521.   if (!hangup)
  522.     do {
  523.       nl();
  524.       nl();
  525.       npr("11. Name          : %s\r\n",thisuser.name);
  526.       if (syscfg.sysconfig & sysconfig_no_alias)
  527.     npr("12. City, State   : %s\r\n",thisuser.realname);
  528.       else
  529.     npr("12. Real Name     : %s %s\r\n",thisuser.realname,thisuser.lastname);
  530.       npr("13. Address       : %s\r\n",thisuser.stretadd);
  531.       npr("14. City, State   : %s\r\n",thisuser.citstate);
  532.       npr("15. Zipcode       : %ld\r\n",thisuser.wwiv_regnum);
  533.       npr("16. Phone No.     : %s\r\n",thisuser.phone);
  534.       npr("17. Gender        : %c\r\n",thisuser.sex);
  535.       npr("18. Birthdate     : %02d/%02d/%02d\r\n",
  536.     (int) thisuser.month, (int) thisuser.day, (int) thisuser.year);
  537.       npr("19. Computer type : %s\r\n",ctypes[thisuser.comp_type]);
  538.       npr("10. Screen size   : %d X %d\r\n",
  539.     thisuser.screenchars, thisuser.screenlines);
  540.       npr("1A. Password      : %s\r\n",thisuser.pw);
  541.       pl("1Q. No changes.");
  542.       nl();
  543.       nl();
  544.       prt(2,"1Which (1-0,A,Q) : ");
  545.       ch=onek("AQ1234567890");
  546.       ok=0;
  547.       switch(ch) {
  548.     case 'Q': ok=1; break;
  549.     case 'A': input_pw(); break;
  550.     case '1': input_name(); break;
  551.     case '2': input_realname();input_lastname(); break;
  552.     case '3': input_address(); break;
  553.     case '4': input_citystate(); break;
  554.     case '5': input_callsign(); break;
  555.     case '6': input_phone(); break;
  556.     case '7': input_sex(); break;
  557.     case '8': input_age(&thisuser); break;
  558.     case '9': input_comptype(); break;
  559.     case '0': input_screensize(); break;
  560.       }
  561.     } while ((!ok) && (!hangup));
  562.   if (!hangup) {
  563.     nl();
  564.     pl("ePlease wait...");
  565.     nl();
  566.     read_user(0,&u);
  567.     l1=number_userrecs();
  568.     if (l1==(long) status.users) {
  569.       usernum=status.users+1;
  570.     } else {
  571.       usernum=1;
  572.       do {
  573.         read_user(usernum,&u);
  574.         if ((u.inact & inact_deleted)==0)
  575.           ++usernum;
  576.       } while (((u.inact & inact_deleted)==0) && ((long)usernum<=l1));
  577.     }
  578.     write_user(usernum,&thisuser);
  579.     close_user();
  580.     isr(usernum,thisuser.name);
  581.     ok=0;
  582.     topscreen();
  583.     do {
  584.       nl();
  585.       nl();
  586.       npr("1Your user number is %d.\r\n",usernum);
  587.       npr("1Your password is '%s'.\r\n",thisuser.pw);
  588.       nl();
  589.       pl("1Please write down this information, and");
  590.       pl("1re-enter your password for verification.");
  591.       pl("1You will need to know this password in");
  592.       pl("1order to change it to something else.");
  593.       nl();
  594.       outstr("1PW: ");
  595.       echo=0;
  596.       input(s,8);
  597.       if (strcmp(s,thisuser.pw)==0)
  598.         ok=1;
  599.     } while ((!ok) && (!hangup));
  600.     changedsl();
  601.     if (incom) {
  602.       if (printfile("FEEDBACK"))
  603.         sl1(0,"#Aborted FEEDBACK.MSG");
  604.       sprintf(irt,"Validation Feedback (%d slots left)",syscfg.maxusers-status.users);
  605.       irt_name[0]=0;
  606.       email(2,0,2,0);
  607.     }
  608.     /*if (syscfg.newuser_c[0]) {
  609.       stuff_in(s,syscfg.newuser_c,create_chain_file("CHAIN.TXT"),"","","","");
  610.       full_external(s,0,1);
  611.     }*/
  612.   }
  613. }
  614.