home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 2 BBS
/
02-BBS.zip
/
easyon1a.zip
/
EASYON.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-12-24
|
16KB
|
524 lines
/* EasyOn.cmd */
/* copyright 1993 by Mark Bernard */
/* ver 1.01 */
/*********************/
/*** Configuration ***/
/*********************/
/*** paths & filenames ***/
UserFile = "c:\max\user.bbs" /* you maximus user.bbs */
LogFile = "c:\bink\bink.log" /* your Binkley log */
OutputFile = "c:\max\misc\phone.bbs" /* usually ...\max\misc\phone.bbs
*/ CmdFile = "c:\max\EasyBBS.cmd" /* ..\max\EasyBBS.cmd */
EasyOnLog = "C:\max\EasyOn.log"
BadList = "c:\max\EasyOn.bad"
/*** Your maximus command-line with switches ***/
MaxString = "maxp -b%2 -p%3 -t%4 -s%1 -n2 -lLine2.log -z\pipe\snoop2"
/* your "usual" string from your spawnbbs.cmd */
/*** Options: 0 = No, 1 = Yes ***/
MoreThanOne = 1 /* If sysop allows more than one user per number */
AutoName = 1
AutoPwd = 1 /* Must also have AutoName = 1, in order to work */
/* User must also have "!" as first character of password */
TurfBlock = 1 /* Logs on using Blockname and BlockPwd,
so that Maximus can display <custom>.bbs */
TurfBad = 1 /* Logs on using BadName and BadPass,
so that Maximus can display <custom>.bbs */
CallidLog = 1 /* Log Numbers in file listed in EasyOnLog (above) */
LogOnly = 0 /* Only LogNumber - then exit, */
/* must also have CallidLog = 1 */
/*** Other ***/
ConnectString = "Connect " /* note the trailing space! */
MdmString = "Mesg =" /* Most frequent */
MdmString2 = "Nmbr =" /* less frequent */
BlockIDString = "P" /* Private */
BlockName = "Call Block"
BlockPwd = "!AnyBlockhead" /* First letter must be "!" */
BadName = "Badlist Name"
BadPwd = "!InBadList" /*First letter must be "!" */
AreaCode = "604" /* local areacode */
/**** End of configuration *****/
/*******************************/
LineCon = 0 /* leave as is... needed in case of empty (new) binkley.log */
LineNum = 1 /* as above */
LineNum2 = 1 /* as above */
PhoneNum = "Unavailable." /* default */
/* Flags - Do Not Alter */
UseString = 0
NotUse = 1
Found = 0
Blocked =0
Found = 0
IsBad = 0
/* Put parameters into MaxString */
arg p.1 p.2 p.3 p.4 p.5 p.6 p.7 p.8 p.9
do i = 1 to 9
Pari = insert("%",i)
do while pos(Pari, MaxString) > 0
ParPos = pos(Pari, MaxString)
MaxString = delstr(MaxString, ParPos, 2)
MaxString = insert(p.i, MaxString, ParPos-1)
end /* do */
end /* do */
if RxFuncquery(SysLoadFuncs) > 0 then
do
call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
call SysLoadFuncs
end /* do */
rc1 = SysFileDelete(OutPutFile)
rc2 = SysFileDelete(CmdFile)
/* Find Number returned by Modem */
/*find last occurence of MdmString in LogFile */
call SysFileSearch MdmString, LogFile,'hit.',N
do i=1 to hit.0; end /* do */
i=(i-1)
LineNum = word(hit.i,1)
LineNum = strip(LineNum,'B')
/*line number of last "MdmString" hit */
call SysFileSearch ConnectString, Logfile, 'con.',N
do j = 1 to con.0; end /* do */
j = (j-1)
LineCon = word(con.j,1)
LineCon = strip(LineCon,'B')
/* Line number of last "Connect" message */
if ((LineCon > LineNum) & ((LineCon-LineNum) < 3)) then
do
UseString = 1
PhoneNum = strip(hit.i, 'B')
end /* do */
/**** check for alternate MdmString2 */
else
do
call SysFileSearch MdmString2, LogFile, 'hit2.', 'N'
do k = 1 to hit2.0; end /* do */
k = (k-1)
LineNum2 = word(hit2.k, 1)
if ((LineCon > LineNum2)&(LineCon-LineNum2 < 3))
then
do
UseString = 2
PhoneNum = strip(hit2.k,'B')
end /* do */
end /* do - else */
/**** can delete this block if there is only one string */
If UseString = 0 then PhoneNum = "Unavailable."
else /* UseString > 0 */
do
if UseString = 2 then MdmString = MdmString2
PhonePos = pos(MdmString, PhoneNum)
/* position of the result code in newstring.*/
PhonePos = PhonePos + length(MdmString)
/* position of string returned by telephone company */
PhoneSize = length(PhoneNum) - PhonePos
/* size of string after return code. Includes blank if any */
PhoneNum = substr(PhoneNum, PhonePos)
PhoneNum = strip(PhoneNum,Both)
/* remove leading and trailing blanks */
PhoneNum = DeGrunge(PhoneNum) /* removes extra stuff from information */
/* received from incompatable caller-id */
PhoneNum = StripArea(PhoneNum)
if datatype(PhoneNum, 'N') = 1 then nop /* PhoneNum not a number */
else do
UseString = 0
If compare(translate(PhoneNum),translate(BlockIDString)) = 0 then do
Blocked = 1 /* Caller is blocking caller-id */
end /* do */
end /* end else do */
/* Log the Call and exit if LogOnly = 1 */
if LogOnly = 1 then do
call LogEntry("Call From: ", PhoneNum)
call lineout CmdFile, MaxString /*Use maxstring with no stuffing*/
call lineout CmdFile /* close file */
exit /* DO NOT PROCEED - LOG ONLY */
end /* Do */
if UseString > 0 then do /* Was a useable number */
TotalSize = stream(UserFile,'C', 'query size')
UserTotal = format((TotalSize/240),6,0) /* Rounded, no decimals */
/* Flags */
LookNext = 1
UserNum = 0
If TurfBad = 1 then IsBad = CheckBad(PhoneNum)
If IsBad = 1 then LookNext = 0
If AutoName = 0 then LookNext = 0
do while LookNext = 1
UserNum = UserNum + 1
if UserNum > UserTotal then do
LookNext = 0
MoreThanOne = 0 /* Looked at all the users phone numbers */
end /* do */
RecordStart = (240*UserNum)-239
UserPhone = charin(Userfile, (RecordStart+93), 15)
UserPhone = CleanPhone(UserPhone)
UserPhone = StripArea(UserPhone)
if UserPhone = PhoneNum then do
Found = 1
UserNumL = UserNum
if UserNum > UserTotal then nop
else do
do while MoreThanOne = 1
UserNum = UserNum + 1
if UserNum > UserTotal then MoreThanOne = 0
RecordStart = (240*UserNum)-239
UserPhone = charin(UserFile, (RecordStart+93), 15)
UserPhone = CleanPhone(UserPhone)
UserPhone = StripArea(UserPhone)
if UserPhone = PhoneNum then
UserNumL = LatestUser(UserNumL, UserNum)
end /* do while */
UserNum = UserNumL
end /* else do */
LookNext = 0
RecordStart = (240*UserNum)-239
UserName = charin(Userfile,RecordStart,32)
UserName = UnPadName(UserName)
UserPwd = charin(UserFile,(RecordStart+112),16)
UserPwd = UnPadName(UserPwd)
end /* do UserPhone = PhoneNum*/
end /* do while LookNext = 1 */
PhoneNum = FormatPhone(PhoneNum)
end /* was a useable number */
else PhoneNum = "Unavailable."
end /* UseString > 0 */
/* output PhoneNum, and BBSStuff */
if Blocked =1 then do
PhoneNum = "Blocked."
if Turfblock = 1 then do
UserName = BlockName
UserPwd = BlockPwd
Found = 1
AutoName = 1
AutoPwd = 1
end /* do */
end /* do */
if IsBad = 1 then do
UserName = BadName
UserPwd = BadPwd
Found = 1
AutoName = 1
AutoPwd = 1
call LogEntry "!!Non-Allowed Number: ", PhoneNum
end /* Do */
else call LogEntry "Call From: ", PhoneNum /* Not in BadList */
if Found = 1 then do /* Found number in UserList */
/* OR Turfing Blocker */
/* OR Turfing caller in BadList */
BBSStuff = ""
if AutoName =1 then do
BBSStuff = '"-j' /* Note quotes!! */
BBSStuff = insert(UserName, BBSStuff, length(BBSStuff))
if AutoPwd = 1 then do
if substr(UserPwd,1,1) = "!" then do
BBSStuff = insert(";Y;", BBSStuff, length(BBSStuff))
BBSStuff = insert(UserPwd, BBSStuff, length(BBSStuff))
end /* do (first character is a "!") */
end /* do AutoPwd = 1 */
BBSStuff = insert('" ', BBSStuff, length(BBSStuff))
end /* do AutoName = 1 */
BBSStuff = insert(BBSStuff, MaxString, wordindex(MaxString,2)-1)
end /* do */
else BBSStuff = MaxString /* found = 0 */
call lineout OutputFile, PhoneNum
call lineout OutputFile /* close file */
call lineout CmdFile, BBSStuff
call lineout CmdFile /* close file */
/* Testing stuff - must use NON-ACTIVE binkley.log */
/*
say Logfile
say BBSStuff
say PhoneNum
*/
exit
LatestUser:
/* compares two users, and returns the one who */
/* signed on most recently */
UNum1 = arg(1)
UNum2 = arg(2)
RecordStart1=(240*UNum1)-239
RecordStart2=(240*UNum2)-239
UDate1 = charin(UserFile, (RecordStart1 + 142), 18)
UDate2 = charin(UserFile, (RecordStart2 + 142), 18)
UYear1 = substr(UDate1, 8, 2)
UYear2 = substr(UDate2, 8, 2)
/* Stupid way of dealing with callers after year 2000 */
If UYear1 < 81 then Uyear1 = Uyear1 + 2000
else Uyear1 = Uyear1 + 1900
If UYear2 < 81 then Uyear2 = Uyear2 + 2000
else Uyear2 = Uyear2 + 1900
select
when UYear2 > UYear1 then UNum1 = UNum2
when UYear2 < UYear1 then nop
otherwise /* the years are equal */
UMonth.1 = substr(UDate1, 4, 3)
UMonth.2 = substr(Udate2, 4, 3)
do i = 1 to 2
select
when UMonth.i = "Jan" then UMonth.i = 1
when UMonth.i = "Feb" then UMonth.i = 2
when UMonth.i = "Mar" then UMonth.i = 3
when UMonth.i = "Apr" then UMonth.i = 4
when UMonth.i = "May" then UMonth.i = 5
when UMonth.i = "Jun" then UMonth.i = 6
when UMonth.i = "Jul" then UMonth.i = 7
when UMonth.i = "Aug" then UMonth.i = 8
when UMonth.i = "Sep" then UMonth.i = 9
when UMonth.i = "Oct" then UMonth.i = 10
when UMonth.i = "Nov" then UMonth.i = 11
when UMonth.i = "Dec" then UMonth.i = 12
otherwise nop
end /* select */
select
when UMonth2 > UMonth1 then UNum1 = UNum2
when UMonth2 < UMonth1 then nop
otherwise
UDay1 = substr(UDate1, 1, 2)
UDay2 = substr(UDate2, 1, 2)
select
when UDay2 > UDay1 then UNum1 = UNum2
when UDay2 < UDay1 then nop
otherwise /* Days are the same */
UHour1 = substr(UDate1, 11, 2)
UHour2 = substr(UDate2, 11, 2)
select
when UHour2 > UHour1 then UNum1 = UNum2
when UHour2 < UHour1 then nop
otherwise
UMin1 = substr(UDate1, 14, 2)
UMin2 = substr(UDate2, 14, 2)
select
when UMin2 > UMin1 then UNum1 = UNum2
when UMin2 < UMin1 then nop
otherwise
USec1 = substr(UDate1, 17, 2)
USec1 = substr(UDate2, 17, 2)
Select
when USec2 > Usec1 then UNum1 = UNum2
when USec2 < USec1 then nop
otherwise nop
end /* select USec */
end /* select UMIn */
end /* select UHour */
end /* select UDay */
end /* select - Month */
end /* select - Year */
return UNum1
LogEntry:
EntryPrefix = arg(1)
Entry = arg(2)
if datatype(Entry, 'N') then Entry = FormatPhone(Entry)
LogDate = date('N')
Entry = insert(EntryPrefix, Entry)
Entry = insert(" EasyOn: ", Entry)
Entry = insert(time('N'), Entry)
dd = word(LogDate, 1)
if length(dd) = 1 then dd = insert("0", dd)
mon = word(LogDate, 2)
yy = word(Logdate, 3)
yy = substr(yy, 3)
Entry = insert(dd, Entry, 0, 3, " ") /* mon */
Entry = insert(mon, Entry, 0, 4, " ") /* dd */
Entry = insert(yy, Entry, 0, 3, " ") /* yy mon dd time*/
Entry = insert("# ", Entry)
if CallidLog = 1 then call lineout EasyOnLog, Entry
return
StripArea:
/* Remove AreaCode if present */
PhNumS = arg(1)
if compare(AreaCode,PhNumS) > length(AreaCode) then
do
PhNumS = delstr(PhNumS,1,length(AreaCode))
end /* do */
return PhNumS
DeGrunge:
/* kludge removing part */
PhNumG = arg(1)
if substr(PhNumG,1,1) = "0" then
do
NumSize = substr(PhNumG, 3, 2)
NumSize = x2d(NumSize) /* hex to decimal */
PhNumG = delstr(PhNumG, 1, 4)
if (datatype(PhNumG,'N') = 1) then /* PhNumG is a number */
do i = 1 to (NumSize*2)
PhNumG = delstr(PhNumG, i, 1)
/* removes every second character, */
/* starting with the first. */
/* PhNumG is now filtered. */
end /* do i = 1 NumSize */
/***** End of Kludge Removing Part */
end /* do if substsr(PhNumG,1,1) = "0") */
return PhNumG
FormatPhone:
PhNumf = arg(1)
/****** Long Disatance Number handling - May require tweaking */
if substr(PhNumf,1,1) = "1" then
/* number in form "1xxxxxxx" */
do
PhNumf = insert("-",PhNumf,1,1)
if substr(PhNumf,4,1) = "1" | substr(PhNumf,4,1) = "0" then
/* Number has "1" or "0" as 4th digit -ie "1-x0xxxxxxxx" */
do
PhNumf = insert("-",PhNumf,5,1) /* After area code */
end /* do */
end /* do if first number is a "1" */
if substr(PhNumf,2,1) = "1" | substr(PhNumf,2,1) = "0" then
/* Number has "1" or "0" as 4th digit -ie "x0xxxxxxxx" */
do
PhNumf = insert("-",PhNumf,3,1) /* After area code */
end /* do if 2nd digit is a "1" or "0" */
PhNumf = insert("-",PhNumf,length(PhNumf)-4,1)
/* end of long distance numbers handling */
return PhNumf
UnPadName:
/* removes trailing blanks from username */
Unpadded = arg(1)
CharSet="ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890~`!@#$%^&*()_-:;',.<>/?=+\|"
LastPos = verify(Translate(Unpadded),CharSet)
if LastPos > 0 then Unpadded = delstr(Unpadded,LastPos)
return Unpadded
CleanPhone:
/* Clean UserPhone */
PhNmC = Arg(1)
PhNmC = strip(PhNmC, Both)
BadPos = Verify(PhNmC,'1234567890','Nomatch')
Do While BadPos > 0 /* strip all non-digits */
PhNmC = delstr(PhNmC, BadPos, 1)
BadPos =Verify(PhNmC,'1234567890','Nomatch')
end /* do */
return PhNmC
CheckBad:
/* Check to see if in BadList */
PhNmb = Arg(1)
FoundBad = 0
RC = SysFileSearch("-",BadList,hitN)
Select
when RC = 2 then LogEntry("Error Checking BadList ","Not enough memory")
when RC = 3 then LogEntry("Error Checking BadList ","error opening file")
otherwise
do t = 1 to hitN.0
BadNum = hitN.t
EndNum = pos(";", BadNum) /* where comment starts */
If EndNum > 0 then BadNum = delstr(BadNum,EndNum)
/* Read in line from BadList */
BadNum = strip(BadNum, Both)
BadNum = CleanPhone(BadNum) /* strip all non-digits */
BadNum = StripArea(BadNum)
if BadNum = PhNmb then do
FoundBad = 1
t = hitN.0
end /* Do */
end /* do t = 1 to hitN.0 */
end /* select */
return FoundBad