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 >
Wrap
Text File
|
1993-07-19
|
14KB
|
614 lines
#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("Enter your full REAL name.");
else
pl("1Enter your alias.");
outstr(":");
mpl(18);
input(thisuser.name,18);
ok=check_name(thisuser.name);
if (!ok) {
nl();
pl("fI'm sorry, that name is already in use.");
++count;
if (count==3)
hangup=1;
}
} while ((!ok) && (!hangup));
}
void input_realname()
{
do {
nl();
if (syscfg.sysconfig& sysconfig_no_alias)
pl("1Enter the city and state you live in.");
else
pl("1Enter your real fFIRST 1name.");
outstr(":");
mpl(20);
inputf(thisuser.realname,20);
if (thisuser.realname[0]==0) {
nl();
if (syscfg.sysconfig & sysconfig_no_alias)
pl("fSorry, you must enter your city and state.");
else
pl("fSorry, you must enter your real FIRST name.");
}
} while ((thisuser.realname[0]==0) && (!hangup));
}
void input_lastname()
{
do {
nl();
pl("1Enter your real fLAST 1name.");
outstr(":");
mpl(20);
inputf(thisuser.lastname,20);
if (thisuser.lastname[0]==0) {
nl();
pl("fSorry, you must enter your real LAST name.");
}
} while ((thisuser.lastname[0]==0) && (!hangup));
}
void input_address()
{
do {
nl();
pl("1Enter your street address.");
outstr(":");
mpl(37);
inputf(thisuser.stretadd,37);
if (thisuser.stretadd[0]==0) {
nl();
pl("fSorry, you must enter your Street Address.");
}
} while ((thisuser.stretadd[0]==0) && (!hangup));
}
void input_citystate()
{
do {
nl();
pl("1Enter your City and State.");
outstr(":");
mpl(37);
inputf(thisuser.citstate,37);
if (thisuser.citstate[0]==0) {
nl();
pl("fSorry, you must enter your city and state.");
}
} while ((thisuser.citstate[0]==0) && (!hangup));
}
void input_callsign()
{
char s[81];
long l;
do {
nl();
pl("1Enter your zipcode");
outstr(":");
mpl(5);
input(s,5);
l=atol(s);
if ((s[0]) && (l>=0))
thisuser.wwiv_regnum = l;
if (s[0]==0) {
nl();
pl("fSorry, you must enter your zipcode.");
}
} while ((s[0]==0) && (!hangup));
}
void input_phone()
{
int ok,i;
do {
nl();
pl("1Enter your fVOICE 1phone no. in the form:");
pl(" e■■■-■■■-■■■■");
outstr(":");
mpl(12);
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("fPlease enter a valid phone number");
pl("fin the correct format.");
}
} while ((!ok) && (!hangup));
}
void input_sex()
{
nl();
outstr("1Your gender (M,F) :");
mpl(1);
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) : ");
mpl(2);
input(ag,2);
m=atoi(ag);
} while ((!hangup) && ((m>12) || (m<1)));
do {
nl();
outstr("1Day of month you were born (1-31) : ");
mpl(2);
input(ag,2);
d=atoi(ag);
} while ((!hangup) && ((d>31) || (d<1)));
do {
nl();
outstr("1Year you were born: 19");
mpl(2);
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("fThere 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("1Known computer types:");
nl();
for (i=0; ctypes[i]; i++)
npr("%d. %s\r\n",i+1,ctypes[i]);
nl();
pl("1Enter your computer type, or the");
pl("1closest to it (ie, Compaq -> IBM).");
outstr(":");
mpl(2);
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("1How wide is your screen (chars, <CR>=80) ?");
outstr(":");
mpl(2);
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("1How tall is your screen (lines, <CR>=25) ?");
outstr(":");
mpl(2);
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(":");
mpl(8);
input(s,8);
ok=1;
if (strlen(s)<3)
ok=0;
} while ((!ok) && (!hangup));
if (ok)
strcpy(thisuser.pw,s);
else
pl("fPassword 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("1Is the above line colored, italicized,");
prt(1,"bold, inversed, or blinking? ");
if (yn())
{
thisuser.sysstatus |= sysstatus_ansi;
nl();
outstr("Do 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 input_sex_type()
{
char s4[2];
int j;
do {
npr("Please enter your sexual preference - Nobody will see it -\r\n");
npr("1. Straight\r\n2. Gay\r\n3. Bi-Sexual\r\n4. Still under personal debate\r\n");
outstr(": ");
input(s4,1);
strcpy(thisuser.sex_type,s4);
j=atoi(s4);
} while((j==0) || (j>4));
}
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) && (incom)) {
nl();
nl();
ok=0;
i=0;
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++<4));
if (!ok)
hangup=1;
}
memset(&thisuser, 0, sizeof(userrec));
strcpy(thisuser.firston,date());
strcpy(thisuser.laston,"Never.");
strcpy(&thisuser.macros[0][0],"I love Gilgamesh!!!!");
strcpy(&thisuser.macros[1][0],"The Devil's Doorknob Rules!");
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");
}
if (!hangup)
input_ansistat();
if (!hangup)
input_name();
input_realname();
input_lastname();
input_phone();
input_address();
input_citystate();
input_callsign();
input_sex();
input_age(&thisuser);
input_sex_type();
input_comptype();
input_screensize();
nl();
npr("1Random password: %s\r\n",thisuser.pw);
nl();
prt(5,"1Do 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("12. City, State : %s\r\n",thisuser.realname);
else
npr("12. Real Name : %s %s\r\n",thisuser.realname,thisuser.lastname);
npr("13. Address : %s\r\n",thisuser.stretadd);
npr("14. City, State : %s\r\n",thisuser.citstate);
npr("15. Zipcode : %ld\r\n",thisuser.wwiv_regnum);
npr("16. Phone No. : %s\r\n",thisuser.phone);
npr("17. Gender : %c\r\n",thisuser.sex);
npr("18. Birthdate : %02d/%02d/%02d\r\n",
(int) thisuser.month, (int) thisuser.day, (int) thisuser.year);
npr("19. Computer type : %s\r\n",ctypes[thisuser.comp_type]);
npr("10. Screen size : %d X %d\r\n",
thisuser.screenchars, thisuser.screenlines);
npr("1A. Password : %s\r\n",thisuser.pw);
pl("1Q. No changes.");
nl();
nl();
prt(2,"1Which (1-0,A,Q) : ");
ch=onek("AQ1234567890");
ok=0;
switch(ch) {
case 'Q': ok=1; break;
case 'A': input_pw(); break;
case '1': input_name(); break;
case '2': input_realname();input_lastname(); break;
case '3': input_address(); break;
case '4': input_citystate(); break;
case '5': input_callsign(); break;
case '6': input_phone(); break;
case '7': input_sex(); break;
case '8': input_age(&thisuser); break;
case '9': input_comptype(); break;
case '0': input_screensize(); break;
}
} while ((!ok) && (!hangup));
if (!hangup) {
nl();
pl("ePlease 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("1Please write down this information, and");
pl("1re-enter your password for verification.");
pl("1You will need to know this password in");
pl("1order to change it to something else.");
nl();
outstr("1PW: ");
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(irt,"Validation Feedback (%d slots left)",syscfg.maxusers-status.users);
irt_name[0]=0;
email(2,0,2,0);
}
/*if (syscfg.newuser_c[0]) {
stuff_in(s,syscfg.newuser_c,create_chain_file("CHAIN.TXT"),"","","","");
full_external(s,0,1);
}*/
}
}