home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* */
- /* XBBS SOURCE CODE copyright (c) 1990 by M. Kimes */
- /* All Rights Reserved */
- /* */
- /* For complete details of the licensing restrictions, please refer */
- /* to the License agreement, which is published in its entirety in */
- /* the in the file LICENSE.XBS. */
- /* */
- /* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
- /* XBBS LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
- /* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
- /* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT M. KIMES */
- /* AT THE ADDRESS LISTED BELOW. IN NO EVENT SHOULD YOU PROCEED TO USE */
- /* THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE XBBS LICENSING */
- /* AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU ARE ABLE TO REACH WITH */
- /* M. KIMES */
- /* */
- /* */
- /* You can contact M. Kimes at the following address: */
- /* */
- /* M. Kimes 1:380/16.0@FidoNet */
- /* 542 Merrick (318)222-3455 data */
- /* Shreveport, LA 71104 */
- /* */
- /* */
- /* Please feel free to contact me at any time to share your comments about */
- /* my software and/or licensing policies. */
- /* */
- /*--------------------------------------------------------------------------*/
- /*======================================================================*/
- /* XBBS Bulletin Board System.....NEW USER module */
- /* Copyright (c) 1989/90 by M. Kimes -- All Rights Reserved */
- /*======================================================================*/
-
- #include "msg.h"
- #include "xext.h"
-
- /* Function prototypes */
-
- void pascal login (void);
- void pascal phonecan (char *);
- void pascal xmain (void);
-
- /* Global variables */
-
- extern word timetoevent;
-
-
-
- void pascal login (void) {
-
- struct _logconfig logconf;
- struct _user check;
- int handlef;
- char exist;
- char *p=NULL;
- struct ffblk f;
- word x=0; /* Once upon a time there was a bug... */
- char text[133]="";
- char name[39];
- char y=0;
- struct date tempdate;
- int register xx;
- char command=0;
-
- /* Read in default new user settings */
-
- gettime(&timeon);
- gettime(&starter);
- readconfig();
- strcpy(messpath,conf.messpath);
- if(conf.nolmrs>4096) conf.nolmrs=4096; /* Ijit-prevention */
- lastread=(word far *)farmalloc(conf.nolmrs * sizeof(word));
- if(lastread==NULL) {
- gprintf(LOGONLY | LOCALONLY,"\nOut of memory for LMRs!\n");
- exit(254);
- }
- for(x=0;x<conf.nolmrs;x++) lastread[x]=0;
- fossil(INIT,0);
- for (x=0;x<10;x++) event[x].secsleft=0;
- memcpy(&mboard,&conf.mboard,sizeof(struct _mboard));
- memcpy(&fboard,&conf.fboard,sizeof(struct _fboard));
- timer_off=0;
- disablesub=1;
- disablejump=1;
-
- timelimit=timetoevent;
-
- /* BEGIN */
-
- cls();
- pauser=0;
-
- if ((handlef=oopen(searchpath("newuser.bbs"),O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
- printm("\nCan't read newuser config file.\n");
- exit(253);
- }
- _read(handlef,&user,sizeof(struct _user));
- _read(handlef,&logconf,sizeof(struct _logconfig));
- cclose(handlef);
-
- gprintf(0,"\nXBBS v%s\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\n",XVERSION);
-
- /* Check system event parameter */
-
- if (timetoevent <= logconf.loglimit) {
- timelimit=240;
- gprintf(0,"\n\nSorry, a system event is scheduled in %u minutes.",timetoevent);
- say_prompt(232);
- fossil(FLUSHOUT,0);
- fossil(DTR,DOWN);
- exit(254);
- }
-
- timelimit=logconf.loglimit;
- if ((baud<logconf.minbaud) and (baud!=0)) {
- readfile("tooslow.xbs",1,0,0);
- fossil (DTR,DOWN);
- say_prompt(231);
- exit(254);
- }
-
- for (xx=0;xx<77;text[xx]='*',text[xx+1]=0,xx++);
- addtolog(text);
-
- readfile ("logo.xbs", 1,1,1);
-
- log1:
-
- if (++y>logconf.nameattempts) {
- say_prompt(233);
- say_prompt(209);
- fossil(FLUSHOUT,0);
- fossil (DTR,DOWN);
- userno=0;
- exit(254);
- }
-
- if (!logconf.name) {
- if (!findfirst("USERINFO.XBS",&f,0)) {
- if ((handlef=oopen("USERINFO.XBS",O_RDONLY | O_TEXT | O_DENYNONE))==-1) {
- fgetsx(name,36,handlef);
- cclose(handlef);
- if (name[strlen(name)-1]=='\n') name[strlen(name)-1]=0;
- goto SkipName;
- }
- }
- }
- say_prompt(234);
- helpnum=501;
- strcpy(name,genin (35,0,0,0,NAME));
- rstrip(name);
- if (stricmp(name,"New User")==0) {
- fossil(DTR,DOWN);
- exit (254);
- }
- if (*name) trashcan(name);
- if (!strchr(name,' ')) {
- say_prompt(210);
- goto log1;
- }
-
- SkipName:
-
- gprintf(LOGONLY,"Online: %s @ %u baud",name,baud);
-
- exist=findfirst(searchpath("users.bbs"),&f,0);
-
- if ((handlef=oopen(searchpath("users.bbs"),O_RDWR | O_APPEND | O_BINARY | O_DENYNONE))==-1) {
- cclose(ccreat("users.bbs",S_IWRITE));
- if ((handlef=oopen(searchpath("users.bbs"),O_RDWR | O_APPEND | O_BINARY | O_DENYNONE))==-1) {
- say_prompt(211);
- fossil (DTR,DOWN);
- exit(253);
- }
- }
-
- say_prompt(236);
- xx=0;
-
- if ((exist==0) and (f.ff_fsize>0)) {
- while (!eof(handlef)) {
- xx++;
- if (!(xx%50)) printm(".");
- if (_read(handlef,&user,sizeof(struct _user))<1) break;
- if ((strcmp(user.name,name)==0) and (!user.deleted)) break;
- if ((strcmp(user.handle,name)==0) and (!user.deleted)) break;
- }
- if (((strcmp(user.name,name)!=0) and (strcmp(user.handle,name)!=0)) or (user.deleted)) {
- cclose(handlef);
- goto NotFound;
- }
- userno=(word)(tell(handlef)/sizeof(struct _user));
- gprintf(LOCALONLY,"\n%cUser # %d",4,userno);
- cclose(handlef);
- }
- else {
- cclose(handlef);
- goto NotFound;
- }
-
- x=0;
-
- enterpass:
-
- if (!logconf.pass) goto SkipPass;
- if (++x>logconf.passattempts) {
- say_prompt(237);
- say_prompt(212);
- fossil(FLUSHOUT,0);
- fossil(DTR,DOWN);
- userno=0;
- exit (254);
- }
- p=NULL;
- say_prompt(237);
- helpnum=502;
- p=genin(11,1,0,0,ALPHANUM);
- rstrip(p);
- if (strcmp(p,user.password)) {
- say_prompt(213);
- gprintf(LOGONLY,"%s%s",say_prompt(255),p);
- goto enterpass;
- }
- SkipPass:
- printm("\n");
- if (strcmp(name,user.name)!=0) {
- gprintf(LOGONLY,"(%s)",user.name);
- }
-
- if (baud) if(baud<conf.ansibaud) user.graphics=0;
-
- if ((user.stat[0])==0) {
- say_prompt(214);
- readfile("Locked.XBS",1,1,1);
- fossil(FLUSHOUT,0);
- fossil(DTR,DOWN);
- say_prompt(215);
- exit (254);
- }
- getdate(&tempdate);
- if ((tempdate.da_mon!=user.lastdate.da_mon) or (tempdate.da_day!=user.lastdate.da_day)) {
- user.callstoday=0;
- user.timetoday=0;
- user.uktoday=0;
- user.dktoday=0;
- }
- if (user.callsperday) {
- if (user.callstoday>=user.callsperday) {
- say_prompt(216);
- fossil(FLUSHOUT,0);
- fossil(DTR,DOWN);
- say_prompt(217);
- exit(254);
- }
- }
- else {
- if (user.timetoday >= user.totaltime) {
- say_prompt(218);
- fossil(FLUSHOUT,0);
- fossil(DTR,DOWN);
- say_prompt(219);
- exit(254);
- }
- }
- if (user.callsperday) {
- timelimit=user.timepercall;
- if ((user.totaltime-user.timetoday)<user.timepercall) {
- timelimit=(user.totaltime-user.timetoday);
- say_prompt(412);
- gprintf(0,"%u minutes, which is all you have left for today.\n",timelimit);
- }
- }
- else timelimit=(user.totaltime-user.timetoday);
-
- getdate(&user.logondate);
- gettime(&user.logontime);
-
- if (timetoevent<timelimit) {
- gprintf(0,say_prompt(413),timetoevent-1);
- timelimit=((timetoevent-1));
- }
-
- load_lastread();
-
- /* This bit of code checks for a filename in homepath/force directory
- consisting of user.id (8 hex digits) + nodenumber logged onto initially
- and reads the file if it finds a match, then deletes the file.
- Can be used for custom welcome screens, etc. */
-
- sprintf(text,"%s\\FORCE\\%08lu.%03hu",conf.homepath,user.id,user.node);
- if(!findfirst(text,&filestat,0)) {
- readfile(text,1,1,1);
- unlink(text);
- }
-
- return;
-
-
- NotFound:
-
- cclose(handlef);
- userno=0;
- if ((handlef=oopen(searchpath("newuser.bbs"),O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
- printm("\nCan't open Newuser config file.\n");
- exit(253);
- }
- _read(handlef,&user,sizeof(struct _user));
- _read(handlef,&logconf,sizeof(logconf));
- cclose(handlef);
-
- printm("\n");
- readfile("notfound.xbs",1,1,1);
- say_prompt(238);
- printm(name);
- say_prompt(220);
- helpnum=503;
- if (*genin(1,0,1,1,YESNO)=='N') {
- say_prompt(221);
- goto log1;
- }
-
- /* NEWUSER LOGIN */
-
- if(!strcmp(name,conf.sysop)) exit(254); /* Sysop should already have account */
-
- {
-
- /* This stuff allows the sysop to bypass the standard logon proc easily
- and substitute his own */
-
- struct ffblk fff;
- char s[133];
- int x;
-
- strcpy(user.name,name);
- userno=0;
- x=findfirst("MYLOGON.XBS",&fff,0);
- sprintf(s,"%sMYLOGON.XBS",conf.menupath);
- if(!findfirst(s,&fff,0) || !x) {
- readfile("MYLOGON.XBS",1,1,1);
- carrchk();
- goto SaveNewUser;
- }
- }
-
- readfile ("newuser.xbs",1,0,1);
- say_prompt(239);
-
-
- NewUser:
-
- strcpy(user.name,name);
-
- userno=0;
- command=0;
-
- AdjustParms:
-
- switch ((int)command) {
- case 0: /* Do all of the below */
- case 9: if ((logconf.graphics) && (conf.ansiavail) && (!baud || baud >= conf.ansibaud)) {
- readfile("graphics.xbs",1,1,1);
- say_prompt(248);
- helpnum=505;
- if(*genin(1,0,1,1,YESNO)=='Y') {
- user.graphics=0;
- user.hiok=1;
- }
- else {
- user.graphics=1;
- user.hiok=0;
- }
- printm("\n");
- usertoggle(GRAPHICS);
- printg("\x1b[0;1;32m");
-
- if (logconf.ansiedit) {
- if (user.graphics && *conf.edansi) {
- readfile("fullscrn.xbs",1,1,1);
- say_prompt(249);
- helpnum=506;
- if(*genin(1,0,1,1,YESNO)=='Y') user.fullscreen=0;
- else user.fullscreen=1;
- printm("\n");
- usertoggle(FULLSCREEN);
- }
- }
- }
- else user.graphics=0;
- if (!user.graphics && logconf.graphics) {
- user.hiok=1;
- readfile("hiascii.xbs",1,1,1);
- say_prompt(470);
- helpnum=577;
- if(*genin(1,0,1,1,YESNO)=='Y') user.hiok=0;
- else user.hiok=1;
- printm("\n");
- usertoggle2(0,17);
- }
- if(command)break;
-
- /*
- if(user.graphics && (baud>1200 || !baud)) {
- alogon();
- goto SaveNewUser;
- }
- */
-
- case 1: if (logconf.city) {
- readfile("city.xbs",1,1,1);
- say_prompt(240);
- city();
- }
- if(command) break;
- case 2: if (logconf.state) {
- readfile("state.xbs",1,1,1);
- say_prompt(241);
- state();
- }
- if(command) break;
- case 3: if (!conf.genstatezip) {
- if (logconf.zipcode) {
- readfile("zip.xbs",1,1,1);
- say_prompt(242);
- zip();
- }
- }
- case 4: if (!logconf.birth) goto SkipBirth;
- goto birthdate2;
- birthdate:
- say_prompt(222);
- birthdate2:
- readfile("birthday.xbs",1,1,1);
- p=NULL;
- say_prompt(243);
- helpnum=504;
- p=genin(8,0,0,0,DATE);
- if (strlen(p)<8) goto birthdate;
- left(text,p,2);
- if ((atoi(text)>12) or (atoi(text)<1)) goto birthdate;
- user.birthdate.da_mon=atoi(text);
- mid(text,p,3,2);
- if ((atoi(text)<1) or (atoi(text)>31)) goto birthdate;
- user.birthdate.da_day=atoi(text);
- right(text,p,4);
- getdate(&tempdate);
- if(atoi(text)<(tempdate.da_year-90) || atoi(text)>(tempdate.da_year-7)) goto birthdate;
- user.birthdate.da_year=atoi(text);
- SkipBirth:
- if(command)break;
- case 5: if (logconf.phone1) {
- readfile("phone1.xbs",1,1,1);
- say_prompt(244);
- phone1();
- phonecan(user.phone1);
- gprintf(LOGONLY,"%s %s",say_prompt(223),user.phone1);
- }
- case 6: if (logconf.phone2) {
- readfile("phone2.xbs",1,1,1);
- say_prompt(245);
- phone2();
- phonecan(user.phone2);
- }
- if(command) break;
- case 7: if (logconf.length) {
- readfile("length.xbs",1,1,1);
- say_prompt(246);
- length();
- }
- if(command)break;
- case 8: if (logconf.width) {
- readfile("width.xbs",1,1,1);
- say_prompt(247);
- width();
- }
- if(command)break;
- case 10: if (logconf.scrnclr) {
- readfile("clearing.xbs",1,1,1);
- say_prompt(250);
- helpnum=507;
- if(*genin(1,0,1,1,YESNO)=='Y') user.scrnclr=0;
- else user.scrnclr=1;
- printm("\n");
- usertoggle(SCRNCLR);
- }
- if(command)break;
- case 11: if (logconf.pagepause) {
- readfile("pausing.xbs",1,1,1);
- say_prompt(252);
- helpnum=508;
- if(*genin(1,0,1,1,YESNO)=='Y') user.more=0;
- else user.more=1;
- printm("\n");
- usertoggle(MORE);
- }
- if(command)break;
- case 12: if (logconf.commflag) {
- readfile("specflag.xbs",1,1,1);
- say_prompt(253);
- helpnum=509;
- if(*genin(1,0,1,1,YESNO)=='Y') user.commodore=0;
- else user.commodore=1;
- printm("\n");
- usertoggle(COMMODORE);
- }
- if(command)break;
- case 13: if (conf.numcomps) comptype();
- if(command)break;
- case 14: strcpy(user.handle,user.name);
- if (logconf.handle) {
- readfile("handle.xbs",1,1,1);
- say_prompt(254);
- strcpy(user.handle,user.name);
- helpnum=510;
- if (*genin(1,0,1,1,YESNO)=='Y') handler();
- }
- if(command) break;
- case 15: if (logconf.pass) {
- readfile("password.xbs",1,1,1);
- password();
- }
- break;
- default: printm("\nDuh....\n");
- break;
- }
-
- say_prompt(475);
- command=0;
- if(logconf.city) {
- gprintf(0,"1. %s\n",user.city);
- }
- if(logconf.state) {
- gprintf(0,"2. %s\n",user.state);
- }
- if(!conf.genstatezip && logconf.zipcode) {
- gprintf(0,"3. %s\n",user.zip);
- }
- if(logconf.birth) {
- gprintf(0,"4. %02u/%02u/%04u\n",user.birthdate.da_mon,user.birthdate.da_day,user.birthdate.da_year);
- }
- if(logconf.phone1) {
- gprintf(0,"5. (%3.3s)%3.3s-%4.4s\n",user.phone1,&user.phone1[3],&user.phone1[6]);
- }
- if(logconf.phone2) {
- gprintf(0,"6. (%3.3s)%3.3s-%4.4s\n",user.phone2,&user.phone2[3],&user.phone2[6]);
- }
- if(logconf.length) {
- gprintf(0,"7. %hu\n",user.length);
- }
- if(logconf.width) {
- gprintf(0,"8. %hu\n",user.width);
- }
- if(logconf.graphics && conf.ansiavail && (!baud || baud>=conf.ansibaud)) {
- printm("9. ");
- user.graphics ? say_prompt(101) : say_prompt(102);
- if(user.graphics && logconf.ansiedit) {
- printm(" ");
- user.fullscreen ? say_prompt(104) : say_prompt(105);
- }
- if(!user.graphics) {
- printm(" ");
- user.hiok ? say_prompt(476) : say_prompt(491);
- }
- }
- if(logconf.scrnclr) {
- printm("10. ");
- user.scrnclr ? say_prompt(107) : say_prompt(108);
- }
- if(logconf.pagepause) {
- printm("11. ");
- user.more ? say_prompt(125) : say_prompt(126);
- }
- if(logconf.commflag) {
- printm("12. ");
- user.commodore ? say_prompt(112) : say_prompt(113);
- }
- if(conf.numcomps) {
- printm("13. ");
- say_prompt(251);
- gprintf(0,"%hu\n",user.comptype);
- }
- if(logconf.handle) {
- gprintf(0,"14. %s\n",user.handle);
- }
- if(logconf.pass) {
-
- int register x;
-
- printm("15. ");
- say_prompt(263);
- for(x=0;x<strlen(user.password);x++) printm("-");
- printm("\n");
- }
- say_prompt(224);
- helpnum=511;
- p=genin(3,0,0,0,NUM);
- if(*p) {
- command=(char)atoi(p);
- goto AdjustParms;
- }
-
- SaveNewUser:
- if ((handlef=oopen(searchpath("users.bbs"),O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
- printm("\nSorry, can't open my userfile.\n");
- exit(253);
- }
- if (!logconf.phone1) goto Nodupe;
-
- say_prompt(225);
- xx=0;
- if ((!exist) && (f.ff_fsize>0)) {
-
- char dupe=0;
-
- while (!eof(handlef)) {
- xx++;
- if ((xx%50)==0) printm(".");
- if (_read(handlef,&check,sizeof(struct _user))<1) goto Nodupe;
- dupe=1;
- if (!strcmp(user.phone1,check.phone1) and (!check.deleted)) break;
- if (logconf.phone2) {
- if (!strcmp(user.phone1,check.phone2) and (!check.deleted)) break;
- if (!strcmp(user.phone2,check.phone1) and (!check.deleted)) break;
- if (!strcmp(user.phone2,check.phone2) and (!check.deleted)) break;
- }
- dupe=0;
- }
- if (dupe) {
- say_prompt(226);
- gprintf(LOGONLY,"%s same as %s",say_prompt(227),check.name);
- readfile ("dupephon.xbs",1,1,1);
- }
- }
- Nodupe:
- printm("\n");
- lseek(handlef,0L,SEEK_END);
- if ((!exist) && (f.ff_fsize>0)) userno=(word)(f.ff_fsize/sizeof(user))+1;
- else userno=1;
- say_prompt(228);
- user.id=conf.nextid++;
- user.node=nodenumber;
- _write(handlef,&user,sizeof(struct _user));
- cclose(handlef);
- saveconfig();
- save_lastread();
-
- if(searchpath("MSGDIRS.XBS")!=NULL) {
-
- int list;
- char line[134];
- char temp[99];
-
- strcpy(temp,messpath);
- if((list=oopen(searchpath("MSGDIRS.XBS"),O_RDONLY | O_BINARY | O_DENYNONE))!=-1) {
- while (!eof(list)) {
- if(!fgetsx(line,134,list))break;
- if(*line==';' || *line=='\n' || *line==' ') continue;
- stripcr(line);
- strcpy(messpath,line);
- save_lastread();
- }
- }
- cclose(list);
- strcpy(messpath,temp);
- }
-
- if (user.callsperday>0) timelimit=user.timepercall;
- else timelimit=user.totaltime;
-
- helpnum=0;
- readfile ("newquest.xbs",1,1,1);
- if ((baud>0) && (baud<conf.ansibaud)) user.graphics=0;
- }
-
-
-
- void pascal phonecan (char *name) {
-
- char check[81];
- char test[11];
- int register x;
- int handle;
-
- strset(check,0);
- strcpy(test,name);
-
- check[0]=test[0]; /* Check for all digits the same */
- for(x=1;x<10;x++) {
- if (toupper(test[x])!=toupper(check[0])) break;
- }
- if (x==10) {
- say_prompt(229);
- say_prompt(230);
- fossil(FLUSHOUT,0);
- fossil(DTR,DOWN);
- carrchk();
- exit(254);
- }
-
- if ((handle=oopen(searchpath("phonecan.ctl"),O_RDONLY | O_TEXT | O_DENYNONE))==-1) return;
-
- while (!eof(handle)) {
- if(!fgetsx(check,(81),handle)) break;
- check[80]=0;
- if (strlen(check)<11)goto skipcheck;
- stripcr(check);
- if (!stricmp(name,check)) {
- badname:
-
- cclose(handle);
- readfile("phonecan.xbs",1,1,1);
- say_prompt(230);
- fossil(FLUSHOUT,0);
- fossil(DTR,DOWN);
- exit(254);
- }
- skipcheck:
- ;
-
- }
- cclose(handle);
- }
-
-