home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / UTIL / WWIVE / NEWUSER.C < prev    next >
Text File  |  1992-05-20  |  15KB  |  638 lines

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