home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
WWIV2.ZIP
/
NEWUSER.C
< prev
next >
Wrap
Text File
|
1995-12-17
|
17KB
|
797 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(void)
{
int ok,count;
count=0;
do {
nl();
ansic(3);
if (syscfg.sysconfig & sysconfig_no_alias)
pl(get_string(520));
else
pl(get_string(521));
prt(2,":");
mpl(30);
input(thisuser.name,30);
ok=check_name(thisuser.name);
if (!ok) {
nl();
ansic(6);
pl(get_string(522));
++count;
if (count==3)
hangup=1;
}
} while ((!ok) && (!hangup));
}
void input_realname(void)
{
do {
nl();
ansic(3);
pl(get_string(523));
prt(2,":");
mpl(20);
inputl(thisuser.realname,20);
if (thisuser.realname[0]==0) {
nl();
ansic(6);
pl(get_string(524));
}
} while ((thisuser.realname[0]==0) && (!hangup));
}
void input_callsign(void)
{
nl();
ansic(3);
pl(get_string(525));
ansic(3);
pl(get_string(526));
prt(2,":");
mpl(6);
input(thisuser.callsign,6);
}
int valid_phone(char *phone)
{
int i;
if ((syscfg.sysconfig & sysconfig_free_phone)==0) {
if (strlen(phone)!=12)
return(0);
if ((phone[3]!='-') || (phone[7]!='-'))
return(0);
if ((phone[1]!='0') && (phone[1]!='1'))
return(0);
for (i=0; i<12; i++) {
if ((i!=3) && (i!=7)) {
if ((phone[i]<'0') || (phone[i]>'9')) {
return(0);
}
}
}
}
return(1);
}
void input_phone(void)
{
int ok,i;
do {
nl();
ansic(3);
pl(get_string(527));
ansic(3);
pl(get_string(493));
prt(2,":");
mpl(12);
input(thisuser.phone,12);
ok=valid_phone(thisuser.phone);
if (!ok) {
nl();
ansic(6);
pl(get_string(528));
ansic(6);
pl(get_string(529));
}
} while ((!ok) && (!hangup));
}
void input_street(void)
{
do {
nl();
ansic(3);
pl(get_string(530));
prt(2,":");
mpl(30);
inputl(thisuser.street,30);
if (thisuser.street[0]==0) {
nl();
ansic(6);
pl(get_string(531));
}
} while ((thisuser.street[0]==0) && (!hangup));
}
void input_city(void)
{
do {
nl();
ansic(3);
pl(get_string(532));
prt(2,":");
mpl(30);
inputl(thisuser.city,30);
if (thisuser.city[0]==0) {
nl();
ansic(6);
pl(get_string(533));
}
} while ((thisuser.city[0]==0) && (!hangup));
}
void input_state(void)
{
do {
nl();
ansic(3);
pl(get_string(534));
prt(2,":");
mpl(2);
input(thisuser.state,2);
if (thisuser.state[0]==0) {
nl();
ansic(6);
pl(get_string(535));
}
} while ((thisuser.state[0]==0) && (!hangup));
}
void input_country(void)
{
do {
nl();
ansic(3);
pl(get_string(536));
prt(2,":");
mpl(3);
input(thisuser.country,3);
if (thisuser.country[0]==0) {
nl();
ansic(6);
pl(get_string(537));
}
} while ((thisuser.country[0]==0) && (!hangup));
}
void input_zipcode(void)
{
do {
nl();
ansic(3);
pl(get_string(538));
prt(2,":");
mpl(10);
input(thisuser.zipcode,10);
if (thisuser.zipcode[0]==0) {
nl();
ansic(6);
pl(get_string(539));
}
} while ((thisuser.zipcode[0]==0) && (!hangup));
}
void input_dataphone(void)
{
int ok,i;
do {
nl();
pl("2You will be asked to enter your work number, this will");
pl("2used for verification purposes only, and will not be used");
pl("2afterwards for any other reason. If you have no work number");
pl("2enter in your data number, if you don't have a data number");
pl("2enter in your voice number again.");
ansic(3);
pl("3Please enter you 1WORK 3number in the form:");
ansic(3);
pl(get_string(493));
prt(2,":");
mpl(12);
input(thisuser.dataphone,12);
ok=valid_phone(thisuser.dataphone);
if (!ok) {
nl();
ansic(6);
pl(get_string(528));
ansic(6);
pl(get_string(529));
}
} while ((!ok) && (!hangup));
}
void input_sex(void)
{
nl();
prt(2,get_string(541));
thisuser.sex=onek("MF");
}
void input_age(userrec *u)
{
int a,ok,y,m,d;
char ag[10];
do {
nl();
do {
nl();
prt(2,get_string(542));
mpl(2);
input(ag,2);
m=atoi(ag);
} while ((!hangup) && ((m>12) || (m<1)));
do {
nl();
prt(2,get_string(543));
mpl(2);
input(ag,2);
d=atoi(ag);
} while ((!hangup) && ((d>31) || (d<1)));
do {
nl();
prt(2,get_string(544));
mpl(2);
input(ag,2);
y=atoi(ag)+1900;
if (y==1919) {
nl();
prt(5,get_string(545));
if (!yn()) {
y=0;
}
}
} 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==29)) || (d==30)))
ok=0;
if (!ok) {
nl();
ansic(6);
pl(get_string(546));
}
if (years_old((unsigned char)m, (unsigned char)d, (unsigned char)(y-1900))<5) {
nl();
pl(get_string(547));
ok=0;
}
} 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(void)
{
int i,ok,ct;
char c[5];
do {
nl();
pl(get_string(275));
nl();
for (i=0; ctypes[i]; i++)
npr("%d. %s\r\n",i+1,ctypes[i]);
nl();
ansic(3);
pl(get_string(548));
ansic(3);
pl(get_string(549));
prt(2,":");
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(void)
{
int ok,x,y;
char s[5];
do {
nl();
ansic(3);
pl(get_string(550));
prt(2,":");
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();
ansic(3);
pl(get_string(551));
prt(2,":");
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(void)
{
int ok;
char s[81];
do {
nl();
ansic(3);
pl(get_string(552));
prt(2,":");
mpl(8);
input(s,8);
ok=1;
if (strlen(s)<3)
ok=0;
} while ((!ok) && (!hangup));
if (ok)
strcpy(thisuser.pw,s);
else
pl(get_string(463));
}
void input_ansistat(void)
{
int i,c,c2;
char ch;
thisuser.sysstatus &= ~(sysstatus_ansi | sysstatus_color);
nl();
if (check_ansi()==1) {
outstr(get_string(553));
} else {
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");
pl(get_string(554));
outstr(get_string(555));
}
if (yn()) {
thisuser.sysstatus |= sysstatus_ansi;
nl();
prt(5,get_string(556));
if (yn())
thisuser.sysstatus |= sysstatus_color;
else {
color_list();
nl();
prt(2,get_string(557));
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_ptag()
{
pl("Would you like to enter a personal tagline? ");
if(yn())
{
nl();
pl("eYou may now enter your new tag");
prt(2,":");
inputl(thisuser.ptag,40);
}
}
void input_sexp()
{
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(void)
{
int i,ok;
char s[255],s1[81],ch;
userrec u;
long l1,l2;
sprintf(s,get_stringx(1,25),date(),times(),curspeed);
sl1(0,"");
sl1(0,s);
if (status.users>=syscfg.maxusers) {
nl();
nl();
pl(get_string(558));
pl(get_string(559));
pl(get_string(560));
nl();
hangup=1;
}
if (syscfg.closedsystem) {
nl();
nl();
pl(get_string(561));
pl(get_string(562));
nl();
hangup=1;
}
if ((syscfg.newuserpw[0]!=0) && (incom)) {
nl();
nl();
ok=0;
i=0;
do {
outstr(get_string(563));
input(s,20);
if (strcmp(s,syscfg.newuserpw)==0)
ok=1;
else {
sprintf(s1,get_stringx(1,26),s);
sl1(0,s1);
}
} while ((!ok) && (!hangup) && (i++<4));
if (!ok)
hangup=1;
}
memset(&thisuser, 0, sizeof(userrec));
memset(qsc, 0, syscfg.qscn_len);
strcpy(thisuser.firston,date());
strcpy(thisuser.laston,get_string(564));
strcpy(&thisuser.macros[0][0],get_string(565));
strcpy(&thisuser.macros[1][0],get_string(566));
strcpy(&thisuser.macros[2][0],get_string(567));
thisuser.screenlines=25;
thisuser.screenchars=80;
screenlinest=25;
thisuser.sl=syscfg.newusersl;
thisuser.dsl=syscfg.newuserdsl;
thisuser.ontoday=1;
thisuser.restrict=syscfg.newuser_restrict;
*qsc=999;
memset(qsc_n,0xff,((max_dirs+31)/32)*4);
memset(qsc_q,0xff,((max_subs+31)/32)*4);
thisuser.sysstatus=sysstatus_pause_on_page | sysstatus_nscan_file_system;
thisuser.gold=syscfg.newusergold;
thisuser.colors[0]=15;
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.colors[8]=1;
thisuser.colors[9]=3;
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;
thisuser.bwcolors[8]=7;
thisuser.bwcolors[9]=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,get_stringx(1,27));
if (printfile("NEWUSER.MSG"))
sl1(0,get_stringx(1,28));
}
input_ansistat();
input_name();
input_realname();
input_phone();
if (syscfg.sysconfig & sysconfig_extended_info) {
input_street();
input_city();
input_state();
input_country();
input_zipcode();
input_dataphone();
}
input_callsign();
input_sex();
input_age(&thisuser);
input_comptype();
input_screensize();
if (numed && (thisuser.sysstatus & sysstatus_ansi)) {
nl();
prt(5,get_string(568));
if (yn())
select_editor();
}
prt(5,get_string(569));
if (yn()) {
nl();
pl(get_string(570));
nl();
i=get_protocol(xf_down);
if (i)
thisuser.defprot=i;
}
/* input_ptag();
input_sexp();*/
nl();
outstr(get_string(571)); pl(thisuser.pw);
nl();
prt(5,get_string(572));
if (yn())
input_pw();
}
if (!hangup)
do {
nl();
nl();
outstr(get_string(573)); pl(thisuser.name);
outstr(get_string(574)); pl(thisuser.realname);
outstr(get_string(575)); pl(thisuser.callsign);
outstr(get_string(576)); pl(thisuser.phone);
outstr(get_string(577)); npr("%c\r\n",thisuser.sex);
outstr(get_string(578)); npr("%02d/%02d/%02d\r\n",
(int) thisuser.month, (int) thisuser.day, (int) thisuser.year);
outstr(get_string(579)); pl(ctypes[thisuser.comp_type]);
outstr(get_string(580)); npr("%d X %d\r\n",
thisuser.screenchars, thisuser.screenlines);
outstr(get_string(581)); pl(thisuser.pw);
if (syscfg.sysconfig & sysconfig_extended_info) {
outstr(get_string(582)); pl(thisuser.street);
outstr(get_string(583)); pl(thisuser.city);
outstr(get_string(584)); pl(thisuser.state);
outstr(get_string(585)); pl(thisuser.country);
outstr(get_string(586)); pl(thisuser.zipcode);
outstr(get_string(587)); pl(thisuser.dataphone);
}
nl();
pl(get_string(588));
nl();
nl();
if (syscfg.sysconfig & sysconfig_extended_info) {
prt(2,get_string(589));
ch=onek("Q123456789ABCDEF");
} else {
prt(2,get_string(590));
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;
case 'A': input_street(); break;
case 'B': input_city(); break;
case 'C': input_state(); break;
case 'D': input_country(); break;
case 'E': input_zipcode(); break;
case 'F': input_dataphone(); break;
}
} while ((!ok) && (!hangup));
if (!hangup) {
nl();
pl(get_string(26));
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();
write_qscn(usernum, qsc, 0);
isr(usernum,thisuser.name);
ok=0;
topscreen();
do {
nl();
nl();
outstr(get_string(591)); pln(usernum);
outstr(get_string(592)); pl(thisuser.pw);
nl();
pl(get_string(593));
pl(get_string(594));
pl(get_string(595));
pl(get_string(596));
nl();
outstr(get_string(357));
echo=0;
input(s,8);
if (strcmp(s,thisuser.pw)==0)
ok=1;
} while ((!ok) && (!hangup));
changedsl();
checkit=0;
if (incom) {
if (printfile("FEEDBACK"))
sl1(0,get_stringx(1,29));
sprintf(irt,get_stringx(1,30),syscfg.maxusers-status.users);
irt_name[0]=0;
grab_quotes(NULL, NULL);
email(71,0,71,0);
}
if (syscfg.newuser_c[0]) {
stuff_in(s,syscfg.newuser_c,create_chain_file("CHAIN.TXT"),"","","","");
full_external(s,0,1);
}
}
}