home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
Dloads
/
WWIVMODS
/
PRE412.ZIP
/
TIMEWIN.MOD
< prev
next >
Wrap
Text File
|
1990-08-31
|
16KB
|
446 lines
Spotnick #1 @5468
Sat Aug 25 00:55:48 1990
╔══════════════════════════╗
║ TIME WINDOW MODIFICATION ║
╚════════════╦═════════════╝
╔════════════╩═════════════╗
║ By Spotnick 1@5468 ║
║ And Chris Miller 49@5468 ║
╚══════════════════════════╝
This is a modification to the Time Window Mod made by Bilbo Baggins
The Principal change is that the time of the user who logs when a Time
Window is setted in X minutes,the time of this user will be reduced.
We are working now on a fonction 'day' for the Time Window.
To Use the time Window,all is like the other version,but this one fits
on WWIV 4.11. So what it do ? It reserved the time for a user for 15 min
and only this user can log on,all other will receive a "Network will be
busy for 30 min please call later". The Fonction will be available by
typing " ~ " (tilda) at the main menu,you just have to set the level
you want.
So let's begin now...
-------------------------------------------------------------------------
Put this anywhere in the Top of the BBS.C
/* mod beg */
#include <fcntl.h>
#include <stdio.h>
#include <io.h>
#include <sys\stat.h>
/* mod end */
Add this before the void mainmenu() in BBS.C
/* mod beg */
void timeedit()
{
static char ch,s1[3],s2[3];
static tmod timemod;
static int tfile,t2file,i,j,quitit;
static long currrec;
static char save2[3],save1[3];
quitit = 1;
while ((quitit == 1) && (!hangup)) {
prt(2,"TimeWindow: Q,A,E,D,L,?: ");
ch=onek("Q?AEDL");
switch(ch) {
case 'Q':
quitit=0;
break;
case 'A':
prt(1,"Hour (0-24)? ");
input(save1,2);
nl();
prt(2,"Minute (0-59)? ");
input(save2,2);
nl();
j=(60*(atoi(save1)) + (atoi(save2)));
strcpy(s1, syscfg.datadir);
strcat(s1, "TIMEMOD.DAT");
tfile = open(s1,O_RDWR | O_CREAT | O_APPEND | O_BINARY,S_IREAD | S_IWRITE);
currrec = filelength(tfile) / (long)sizeof(tmod);
/* Check to see if user already signed up for time. */
while ((currrec > 0) && (!hangup))
{
lseek(tfile, (currrec - 1) * (long)sizeof(tmod), SEEK_SET);
currrec--;
read(tfile, (void *)(&timemod), sizeof(tmod));
/* If thisuser.name = timemod.username then exit */
if (!strcmp(thisuser.name,timemod.username)){
prt(2,"You've already reserved a time!");
nl();
close(tfile);
quitit=0;
break;
}
/* If time already taken then exit */
/* j = requested time...i=one of the taken times. */
i = 60*(atoi(timemod.userhour)) + (atoi(timemod.usermin));
if ((j>=i) && (j<=i+15)){
prt(2,"Time span already reserved! Try another time.");
nl();
close(tfile);
quitit=0;
break;
}
}
close(tfile);
if (quitit) {
strcpy(s1, syscfg.datadir);
strcat(s1, "TIMEMOD.DAT");
tfile = open(s1,O_RDWR | O_CREAT | O_APPEND | O_BINARY,S_IREAD | S_IWRITE);
strcpy(timemod.username," ");
strcpy(timemod.username,thisuser.name);
strcpy(timemod.userhour,save1);
strcpy(timemod.usermin,save2);
write(tfile, (void *)(&timemod), sizeof(tmod));
close(tfile);
} else {
quitit=1;
}
break;
case 'E':
quitit = 1;
prt(1,"Hour (0-24)? ");
input(save1,2);
nl();
prt(2,"Minute (0-59)? ");
input(save2,2);
nl();
j=(60*(atoi(save1)) + (atoi(save2)));
strcpy(s1, syscfg.datadir);
strcat(s1, "TIMEMOD.DAT");
tfile = open(s1,O_RDWR | O_CREAT | O_BINARY,S_IREAD | S_IWRITE);
currrec = filelength(tfile) / (long)sizeof(tmod);
/* Check to see if user already signed up for time. */
while ((currrec > 0) && (!hangup))
{
lseek(tfile, (currrec - 1) * (long)sizeof(tmod), SEEK_SET);
currrec--;
read(tfile, (void *)(&timemod), sizeof(tmod));
/* If time already taken then exit */
/* j = requested time...i=one of the taken times. */
i = 60*(atoi(timemod.userhour)) + (atoi(timemod.usermin));
if ((j>=i) && (j<=i+15)){
prt(2,"Time span already reserved! Try another time.");
nl();
quitit=0;
break;
}
}
close(tfile);
strcpy(s1, syscfg.datadir);
strcat(s1, "TIMEMOD.DAT");
tfile = open(s1,O_RDWR | O_CREAT | O_BINARY,S_IREAD | S_IWRITE);
currrec = filelength(tfile) / (long)sizeof(tmod);
/* Find users record and allow editing */
while ((currrec > 0) && (!hangup) && (quitit ==1))
{
lseek(tfile, (currrec - 1) * (long)sizeof(tmod), SEEK_SET);
currrec--;
read(tfile, (void *)(&timemod), sizeof(tmod));
/* If thisuser.name = timemod.username then */
if (!strcmp(thisuser.name,timemod.username)){
lseek(tfile, (currrec) * (long)sizeof(tmod), SEEK_SET);
strcpy(timemod.userhour,save1);
strcpy(timemod.usermin,save2);
write(tfile, (void *)(&timemod), sizeof(tmod));
close(tfile);
nl();
currrec = 0.0;
}
}
close(tfile);
break;
case 'D':
strcpy(s1, syscfg.datadir);
strcat(s1, "TIMEMOD.DAT");
tfile = open(s1,O_RDWR | O_BINARY);
strcpy(s1, syscfg.datadir);
strcat(s1, "TIMEMOD.TMP");
remove(s1);
t2file = open(s1,O_RDWR | O_CREAT | O_APPEND | O_BINARY,S_IREAD | S_IWRITE);
currrec = filelength(tfile) / (long)sizeof(tmod);
/* Check to see if user already signed up for time. */
while ((currrec > 0) && (!hangup))
{
lseek(tfile, (currrec - 1) * (long)sizeof(tmod), SEEK_SET);
currrec--;
read(tfile, (void *)(&timemod), sizeof(tmod));
/* If thisuser.name = timemod.username then exit */
if (strcmp(thisuser.name,timemod.username))
write(t2file, (void *)(&timemod), sizeof(tmod));
}
close(tfile);
close(t2file);
strcpy(s1, syscfg.datadir);
strcat(s1, "TIMEMOD.DAT");
remove(s1);
chdir("DATA");
rename("TIMEMOD.TMP","TIMEMOD.DAT");
chdir("..");
nl();
break;
case 'L':
nl();
prt(7,"User Name Time ");
nl();
prt(3,"------------------------------- ---------");
nl();
strcpy(s1, syscfg.datadir);
strcat(s1, "TIMEMOD.DAT");
tfile = open(s1,O_RDONLY | O_BINARY);
currrec = filelength(tfile) / (long)sizeof(tmod);
strcpy(s2," \r\n");
while ((currrec > 0) && (!hangup))
{
lseek(tfile, (currrec - 1) * (long)sizeof(tmod), SEEK_SET);
currrec--;
read(tfile, (void *)(&timemod), sizeof(tmod));
strcpy(s2,timemod.username);
i = 30 - strlen(s2);
while (i >= 0) {
strcat(s2," ");
i--;
}
strcat(s2," ");
strcat(s2,timemod.userhour);
strcat(s2,":");
strcat(s2,timemod.usermin);
pl(s2);
}
nl();
close(tfile);
break;
case '?':
printmenu(15);
break;
}
}
return;
}
/* mod end */
Put this in void mainmenu() after the case '*' in BBS.C
/* mod beg */
case '~':
if (thisuser.sl>=XX) <=== (Put here the level you want)
timeedit();
break;
/* mod end */
Press F2 and load your BBSULT.C
Put this before void getuser() (DON'T PUT THAT NOW... YOU'LL HAVE THE RIGHT
VERSION AT THE END OF THE FILE if you want the time reduced mod, or put this
one if not)...
/* mod beg */
void timemod()
{
tmod timemod;
struct tm *currtime;
long currrec,secs;
char fname[81];
int tfile,timetmp,holdtime;
time(&secs);
currtime = localtime(&secs);
holdtime = 60*currtime->tm_hour + currtime->tm_min;
strcpy(fname, syscfg.datadir);
strcat(fname, "TIMEMOD.DAT");
tfile = open(fname, (O_RDWR | O_BINARY));
currrec = filelength(tfile) / (long)sizeof(tmod);
while ((currrec > 0) && (!hangup))
{
lseek(tfile, (currrec - 1) * (long)sizeof(tmod), SEEK_SET);
currrec--;
read(tfile, (void *)(&timemod), sizeof(tmod));
timetmp = atoi(timemod.userhour)*60 + atoi(timemod.usermin);
if ( holdtime >= timetmp && (holdtime <= (timetmp+15))) {
if (strcmp(thisuser.name,timemod.username)){
pl("Network will be busy for 30 minutes! Call back later.");
hangup=1;
} else {
close(tfile);
return;
}
}
}
close(tfile);
return;
}
/* mod end */
Now put this in pocedure getuser
if (usernum>0) {
read_user(usernum,&thisuser);
realsl=thisuser.sl;
topscreen();
/* mod beg */
timemod();
/* mod end */
ok=1;
outstr("PW: ");
Now press F2 and load your Vardec.H
Put this at the end of the file
/* mod beg */
/* Time Window's 'tmod' structure */
typedef struct {
char username[31];
char userhour[51];
char usermin[51];
} tmod;
/* mod end */
#define NUM_CTYPES 10
#define VERSION_NUMBER "WWIV v4.11"
#define max_buf 1024
#define VER_VECT 0x6a
#define MSG_COLOR 0
And now here are the mods for the time reduced!
*** Put this at the top of your BBSUTL.C, after the Copyrights:
/* mod beg */
extern float time_next_call;
extern long int wd_holdtime, wd_nextwindow;
#define WINDOWSIZE 15
/* mod end */
*** Put this in the file BBSUTL.C, before the function "getuser()",
at the place of the other function "timemod()" :
/* mod beg */
void timemod()
{
tmod timemod;
struct tm *currtime;
long currrec,secs;
char fname[81];
int tfile,timetmp,holdtime;
int delta=24*60, nextwindow=-1, firstwindow=24*60;
int found=0;
time_next_call = 0;
time(&secs);
currtime = localtime(&secs);
holdtime = 60*currtime->tm_hour + currtime->tm_min;
strcpy(fname, syscfg.datadir);
strcat(fname, "TIMEMOD.DAT");
tfile = open(fname, (O_RDWR | O_BINARY));
currrec = filelength(tfile) / (long)sizeof(tmod);
while (currrec>0 && !hangup)
{
lseek(tfile, (currrec - 1) * (long)sizeof(tmod), SEEK_SET);
currrec--;
read(tfile, (void *)(&timemod), sizeof(tmod));
timetmp = atoi(timemod.userhour)*60 + atoi(timemod.usermin);
if (timetmp < firstwindow)
firstwindow = timetmp;
if ( holdtime>=timetmp && holdtime<=timetmp+WINDOWSIZE && !found) {
if (strcmp(thisuser.name,timemod.username)){
pl("A time window is currently active. Please call back later.");
hangup=1;
} else {
found++;
}
} else {
if ( timetmp-holdtime<delta && timetmp-holdtime>0 &&
strcmp(thisuser.name, timemod.username) &&
!found)
nextwindow = timetmp;
}
}
if (nextwindow==-1 && firstwindow!=24*60)
nextwindow = firstwindow;
if (nextwindow!=-1 && nextwindow < holdtime)
holdtime = holdtime - 24*60;
wd_holdtime = holdtime;
wd_nextwindow = nextwindow; /* quick and dirty, but works. */
close(tfile);
return;
}
/* mod end */
*** Put this in the file BBSUTL.C, in the function "logon()", after
the lines with '.' :
. if ((syscfg.logon_c[0]) && live_user) {
. nl();
. strcpy(s1,syscfg.logon_c);
. strcpy(s2,create_chain_file("CHAIN.TXT"));
. stuff_in(s,s1,s2,"","","","");
. full_external(s,0,1);
. nl();
. nl();
. }
.
. if (live_user) {
. nl();
/* mod beg */
if ( wd_nextwindow!=-1 &&
wd_holdtime*60+(long int) nsl() > wd_nextwindow*60 &&
wd_holdtime < wd_nextwindow) {
wd_nextwindow *= 60;
wd_holdtime *= 60;
time_next_call = nsl() - (wd_nextwindow - wd_holdtime);
thisuser.extratime -= time_next_call;
pl("A time window will soon be active. Your time has been reduced.");
nl();
}
/* mod end */
*** Put this in file BBS.C, in the fonction "main()" (end of
the file), after lines with '.' :
.main_menu_label:
. while (!hangup) {
. if (curdloads)
. dlmainmenu();
. else
. mainmenu();
. }
/* mod beg */
if (time_next_call)
thisuser.extratime += time_next_call;
/* mod end */
*** Put this in the file VARS.H, at the end of the file:
/* mod beg */
#define WINDOWSIZE 15
float time_next_call;
long int wd_holdtime, wd_nextwindow;
/* mod end */
And That's it! All must be fine,if you have any questions about that mod just
send us an E-Mail or call here at The Fortress of Shadow (514) 661-1416 and
we will answer to your questions without problems.
1»2»3»4Spotnick3«2«1«
71@5468
3WWIV net