home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
UTIL
/
WWIVE
/
NEWUSER.C
< prev
next >
Wrap
Text File
|
1992-05-20
|
15KB
|
638 lines
/*****************************************************************************
WWIV Version 4
Copyright (C) 1988-1991 by Wayne Bell
Distribution of the source code for WWIV, in any form, modified or unmodified,
without PRIOR, WRITTEN APPROVAL by the author, is expressly prohibited.
Distribution of compiled versions of WWIV is limited to copies compiled BY
THE AUTHOR. Distribution of any copies of WWIV not compiled by the author
is expressly prohibited.
*****************************************************************************/
#include "vars.h"
#pragma hdrstop
int check_name(char *nn)
{
int ok,f,i;
char s[161],s1[161],s2[81];
long p,l;
ok=1;
if (nn[strlen(nn)-1]==32)
ok=0;
if (nn[0]<65)
ok=0;
if (finduser(nn)!=0)
ok=0;
if (strchr(nn,'@')!=NULL)
ok=0;
if (strchr(nn,'#')!=NULL)
ok=0;
if (!ok)
return(ok);
sprintf(s,"%sTRASHCAN.TXT",syscfg.gfilesdir);
f=open(s,O_RDWR | O_BINARY);
if (f<0)
return(ok);
lseek(f,0L,SEEK_SET);
l=filelength(f);
p=0;
sprintf(s2," %s ",nn);
while ((p<l) && (ok)) {
lseek(f,p,SEEK_SET);
read(f,(void *)s,150);
i=0;
while ((i<150) && (s[i])) {
if (s[i]==13)
s[i]=0;
else
++i;
}
s[150]=0;
p += (long) (i+2);
if (s[i-1]==1)
s[i-1]=0;
for (i=0; i<strlen(s); i++)
s[i]=upcase(s[i]);
sprintf(s1," %s ",s);
if (strstr(s2,s1)!=NULL)
ok=0;
}
close(f);
if (!ok)
hangup=1;
return(ok);
}
void input_name()
{
int ok,count;
count=0;
do {
nl();
if (syscfg.sysconfig & sysconfig_no_alias)
pl("1Enter your full REAL name.");
else
pl("2Enter your full name, or your alias.");
outstr("2:");
input(thisuser.name,30);
ok=check_name(thisuser.name);
if (!ok) {
nl();
pl("7I'm sorry, you can't use that name.");
++count;
if (count==3)
hangup=1;
}
} while ((!ok) && (!hangup));
}
void input_realname()
{
do {
nl();
if (syscfg.sysconfig& sysconfig_no_alias)
pl("3Enter the city and state you live in.");
else
pl("5Enter your real 6FIRST 5and 6LAST 5name.");
outstr(":");
inputl(thisuser.realname,20);
if (thisuser.realname[0]==0) {
nl();
if (syscfg.sysconfig & sysconfig_no_alias)
pl("7Sorry, you must enter your city and state.");
else
pl("7Sorry, you must enter your real name.");
}
} while ((thisuser.realname[0]==0) && (!hangup));
}
void input_callsign()
{
nl();
/* pl("1Enter your amateur radio callsign,");*/
pl("1Enter your zipcode.");
outstr(":");
input(thisuser.callsign,6);
}
void input_phone()
{
int ok,i;
do {
nl();
pl("2Enter your VOICE phone no. in the form:");
pl(" 3###-###-####");
outstr(":");
inputl(thisuser.phone,12);
ok=1;
if ((syscfg.sysconfig & sysconfig_free_phone)==0) {
if (strlen(thisuser.phone)!=12)
ok=0;
if ((thisuser.phone[3]!='-') || (thisuser.phone[7]!='-'))
ok=0;
if ((thisuser.phone[1]!='0') && (thisuser.phone[1]!='1'))
ok=0;
for (i=0; i<12; i++)
if ((i!=3) && (i!=7))
if ((thisuser.phone[i]<'0') || (thisuser.phone[i]>'9'))
ok=0;
}
if (!ok) {
nl();
pl("7Please enter a valid phone number");
pl("7in the correct format.");
}
} while ((!ok) && (!hangup));
}
void input_sex()
{
nl();
outstr("5Gender (M,F) :");
thisuser.sex=onek("MF");
}
void input_age(userrec *u)
{
int a,ok,y,m,d;
char ag[10];
do {
nl();
do {
nl();
outstr("1Month you were born (1-12) : ");
input(ag,2);
m=atoi(ag);
} while ((!hangup) && ((m>12) || (m<1)));
do {
nl();
outstr("1Day of month you were born (1-31) : ");
input(ag,2);
d=atoi(ag);
} while ((!hangup) && ((d>31) || (d<1)));
do {
nl();
outstr("1Year you were born: 19");
input(ag,2);
y=atoi(ag)+1900;
} while ((!hangup) && (y<1905));
ok=1;
if (((m==2) || (m==9) || (m==4) || (m==6) || (m==11)) && (d==31))
ok=0;
if ((m==2) && (y%4!=0) && (d==30))
ok=0;
if (!ok) {
nl();
pl("7There aren't that many days in that month.");
}
} while ((!ok) && (!hangup));
u->month=(unsigned char) m;
u->day=(unsigned char) d;
u->year=(unsigned char) (y-1900);
u->age=years_old(u->month,u->day,u->year);
nl();
}
void input_comptype()
{
int i,ok,ct;
char c[5];
do {
nl();
pl("2Known computer types:");
nl();
for (i=0; ctypes[i]; i++)
npr("%d. %s\r\n",i+1,ctypes[i]);
nl();
pl("3Enter your computer type, or the");
pl("3closest to it (ie, Compaq -> IBM).");
outstr(":");
input(c,2);
ct=atoi(c);
ok=1;
if ((ct<1) || (ct>i))
ok=0;
} while ((!ok) && (!hangup));
thisuser.comp_type=ct-1;
if (checkcomp("Ami"))
thisuser.colors[0]=4;
if (hangup)
thisuser.comp_type=0;
}
void input_screensize()
{
int ok,x,y;
char s[5];
do {
nl();
pl("5How wide is your screen (chars, <CR>=80) ?");
outstr(":");
input(s,2);
x=atoi(s);
if (s[0]==0)
x=80;
if ((x<32) || (x>80))
ok=0;
else
ok=1;
} while ((!ok) && (!hangup));
do {
nl();
pl("7How tall is your screen (lines, <CR>=25) ?");
outstr(":");
input(s,2);
y=atoi(s);
if (s[0]==0)
y=25;
if ((y<4) || (y>60))
ok=0;
else
ok=1;
} while ((!ok) && (!hangup));
thisuser.screenchars=x;
thisuser.screenlines=y;
screenlinest=y;
}
void input_pw()
{
int ok;
char s[81];
do {
nl();
pl("1Please enter a new password, 3-8 chars.");
outstr(":");
input(s,8);
ok=1;
if (strlen(s)<3)
ok=0;
} while ((!ok) && (!hangup));
if (ok)
strcpy(thisuser.pw,s);
else
pl("1Password not changed.");
}
void input_ansistat()
{
int i,c,c2;
char ch;
nl();
outstr("\x1b[0;34;3mTEST\x1b[C");
outstr("\x1b[0;30;45mTEST\x1b[C");
outstr("\x1b[0;1;31;44mTEST\x1b[C");
outstr("\x1b[0;32;7mTEST\x1b[C");
outstr("\x1b[0;1;5;33;46mTEST\x1b[C");
pl("\x1b[0;4mTEST\x1b[0m");
thisuser.sysstatus &= ~(sysstatus_ansi | sysstatus_color);
pl("Is the above line colored, italicized,");
outstr("bold, inversed, or blinking? ");
if (yn())
{
thisuser.sysstatus |= sysstatus_ansi;
nl();
outstr("3Do you want color? ");
if (yn())
thisuser.sysstatus |= sysstatus_color;
else {
color_list();
nl();
outstr("Monochrome base color (<C/R>=7)? ");
ch=onek("\r1234567");
if (ch=='\r')
ch='7';
c=ch-'0';
c2=c << 4;
for (i=0; i<8; i++) {
if ((thisuser.bwcolors[i] & 0x70) == 0)
thisuser.bwcolors[i]=(thisuser.bwcolors[i] & 0x88) | c;
else
thisuser.bwcolors[i]=(thisuser.bwcolors[i] & 0x88) | c2;
}
}
}
}
void newuser()
{
int i,ok;
char s[255],s1[81],ch;
userrec u;
long l1,l2;
sprintf(s,"*** NEW USER %s %s %s",date(),times(),curspeed);
sl1(0,"");
sl1(0,s);
if (status.users>=syscfg.maxusers) {
nl();
nl();
pl("I'm sorry, but the system currently has");
pl("the maximum number of users it can");
pl("handle.");
nl();
hangup=1;
}
if (syscfg.closedsystem) {
nl();
nl();
pl("I'm sorry, but the system is currently");
pl("closed, and not accepting new users.");
nl();
hangup=1;
}
if (syscfg.newuserpw[0]!=0) {
nl();
nl();
ok=0;
i=0;
pl("If you do not know the New User Password");
pl("just hit `Enter' twice and fill out the");
pl("following information and I will call");
pl("you and give you the password");
do {
outstr("New User Password :");
input(s,20);
if (strcmp(s,syscfg.newuserpw)==0)
ok=1;
else {
sprintf(s1,"Wrong newuser password: %s",s);
sl1(0,s1);
}
} while ((!ok) && (!hangup) && (i++<1));
if (!ok)
{
nl();
pl("Fill out the following information");
pl("and I will call you VOICE with the");
pl("New User Password.");
nl();
outstr("Your Alias :");
input(s,20);
sprintf(s1,"Alias: %s",s);
sl1(0,s1);
outstr("Your FULL REAL Name :");
input(s,20);
sprintf(s1,"Real Name: %s",s);
sl1(0,s1);
outstr("Your VOICE phone number ###-###-####:");
input(s,12);
sprintf(s1,"Phone: %s",s);
sl1(0,s1);
outstr("Your Street Address :");
input(s,30);
sprintf(s1,"Address: %s",s);
sl1(0,s1);
outstr("Your city and State :");
input(s,30);
sprintf(s1,"City,State: %s",s);
sl1(0,s1);
outstr("Your Zip Code :");
input(s,30);
sprintf(s1,"Zip Code: %s",s);
sl1(0,s1);
outstr("Best time to call :");
input(s,40);
sprintf(s1,"Call at: %s",s);
sl1(0,s1);
nl();
pl("Thank you for taking time to fill this out");
hangup=1;
}
}
memset(&thisuser, 0, sizeof(userrec));
strcpy(thisuser.firston,date());
strcpy(thisuser.laston,"Never.");
strcpy(&thisuser.macros[0][0],"This is the Ctrl-D Macro");
strcpy(&thisuser.macros[1][0],"This is the Ctrl-F Macro");
strcpy(&thisuser.macros[2][0],"Whatever");
thisuser.screenlines=25;
thisuser.screenchars=80;
screenlinest=25;
thisuser.sl=syscfg.newusersl;
thisuser.dsl=syscfg.newuserdsl;
thisuser.sysopsub=255;
thisuser.ontoday=1;
thisuser.restrict=syscfg.newuser_restrict;
thisuser.qscn=0xFFFFFFFF;
#if MAX_SUBS>32
thisuser.qscn2=0xFFFFFFFF;
#endif
thisuser.nscn1=0xFFFFFFFF;
thisuser.nscn2=0xFFFFFFFF;
thisuser.sysstatus=sysstatus_pause_on_page | sysstatus_nscan_file_system;
thisuser.gold=syscfg.newusergold;
thisuser.colors[0]=7;
thisuser.colors[1]=11;
thisuser.colors[2]=14;
thisuser.colors[3]=5;
thisuser.colors[4]=31;
thisuser.colors[5]=2;
thisuser.colors[6]=140;
thisuser.colors[7]=9;
thisuser.bwcolors[0]=7;
thisuser.bwcolors[1]=15;
thisuser.bwcolors[2]=15;
thisuser.bwcolors[3]=15;
thisuser.bwcolors[4]=112;
thisuser.bwcolors[5]=15;
thisuser.bwcolors[6]=143;
thisuser.bwcolors[7]=7;
reset_act_sl();
for (i=0; i<6; i++) {
ch=rand() % 36;
if (ch<10)
ch+='0';
else
ch+='A'-10;
thisuser.pw[i]=ch;
}
thisuser.pw[6]=0;
if (!hangup) {
if (incom) {
if (printfile("SYSTEM.MSG"))
sl1(0,"#Aborted SYSTEM.MSG");
if (printfile("NEWUSER.MSG"))
sl1(0,"#Aborted NEWUSER.MSG");
}
input_ansistat();
input_name();
input_realname();
input_phone();
input_callsign();
input_sex();
input_age(&thisuser);
input_comptype();
input_screensize();
nl();
npr("1Random password: %s\r\n",thisuser.pw);
nl();
prt(5,"3Do you want a different password (Y/N)? ");
if (yn())
input_pw();
}
if (!hangup)
do {
nl();
nl();
npr("11. Name : %s\r\n",thisuser.name);
if (syscfg.sysconfig & sysconfig_no_alias)
npr("22. City, State : %s\r\n",thisuser.realname);
else
npr("32. Real Name : %s\r\n",thisuser.realname);
npr("53. Zipcode : %s\r\n",thisuser.callsign);
npr("74. Phone No. : %s\r\n",thisuser.phone);
npr("15. Gender : %c\r\n",thisuser.sex);
npr("26. Birthdate : %02d/%02d/%02d\r\n",
(int) thisuser.month, (int) thisuser.day, (int) thisuser.year);
npr("37. Computer type : %s\r\n",ctypes[thisuser.comp_type]);
npr("58. Screen size : %d X %d\r\n",
thisuser.screenchars, thisuser.screenlines);
npr("79. Password : %s\r\n",thisuser.pw);
pl("1Q. No changes.");
nl();
nl();
prt(2,"3Which (1-9,Q) : ");
ch=onek("Q123456789");
ok=0;
switch(ch) {
case 'Q': ok=1; break;
case '1': input_name(); break;
case '2': input_realname(); break;
case '3': input_callsign(); break;
case '4': input_phone(); break;
case '5': input_sex(); break;
case '6': input_age(&thisuser); break;
case '7': input_comptype(); break;
case '8': input_screensize(); break;
case '9': input_pw(); break;
}
} while ((!ok) && (!hangup));
if (!hangup) {
nl();
pl("1Please wait...");
nl();
read_user(0,&u);
l1=number_userrecs();
if (l1==(long) status.users) {
usernum=status.users+1;
} else {
usernum=1;
do {
read_user(usernum,&u);
if ((u.inact & inact_deleted)==0)
++usernum;
} while (((u.inact & inact_deleted)==0) && ((long)usernum<=l1));
}
write_user(usernum,&thisuser);
close_user();
isr(usernum,thisuser.name);
ok=0;
topscreen();
do {
nl();
nl();
npr("1Your user number is %d.\r\n",usernum);
npr("1Your password is '%s'.\r\n",thisuser.pw);
nl();
pl("3Please write down this information, and");
pl("3re-enter your password for verification.");
pl("3You will need to know this password in");
pl("3order to change it to something else.");
nl();
outstr("7PW1: ");
echo=0;
input(s,8);
if (strcmp(s,thisuser.pw)==0)
ok=1;
} while ((!ok) && (!hangup));
changedsl();
/* if (incom) {*/
if (printfile("FEEDBACK"))
sl1(0,"#Aborted FEEDBACK.MSG");
sprintf(s1,"User : %s",thisuser.name);
sl1(0,s1);
pl("Please answer these few questions...");
nl();
pl("1.Where did you get this number from?");
outstr(": ");
input(s,40);
sprintf(s1,"Number from: %s",s);
sl1(0,s1);
pl("2.Were you on this board previously?");
outstr(": ");
input(s,10);
sprintf(s1,"On before: %s",s);
sl1(0,s1);
pl("3.What is your occupation?");
outstr(": ");
input(s,40);
sprintf(s1,"Occupation: %s",s);
sl1(0,s1);
pl("4.Are you a SysOp? Where?");
outstr(": ");
input(s,40);
sprintf(s1,"SysOp: %s",s);
sl1(0,s1);
/* sprintf(irt,"1Validation Feedback7 (%d slots left)",syscfg.maxusers-status.users);
irt_name[0]=0;
email(4,0,4,0);*/
/* }*/
if (syscfg.newuser_c[0]) {
stuff_in(s,syscfg.newuser_c,create_chain_file("CHAIN.TXT"),"","","","");
full_external(s,0,1);
}
}
}