home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / W / DEVBBS.ZIP / NEWUSER.C < prev    next >
Text File  |  1992-08-04  |  14KB  |  600 lines

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