; *****************************************************************

8
; ***************************************************************** ; * * ; * CID.PPE V 1.60 (09-01-95) * ; * * ; * Written in PPL 3.10 for PCBoard 15.21 * ; * * ; * Designed By: Gary Meeker * ; * * ; * Began development: 04-06-93 * ; * * ; ***************************************************************** ; ; This .PPE checks the secrity level of a user and if within the specified ; range, checks the Caller ID info for the phone number. If a number is ; found, then it writes it to the file specified. ; ; Usage: ; ; !CID.PPE C:\PCB\PPE\CID.CFG ; ; IF the configuration file is not specified, the CID.CFG in the same directory ; as CID.PPE will be used. ; STRING ConfigFile, CID, Private, Outside, Search(5), NameSearch(5), Text STRING CIDFile, PrivateFile, OutsideFile, NoMatchFile, LockOutFile STRING BadNumFile, PCPNumFile, PCPUserFile, FileName, Label, AreaCode STRING PhoneNumber, Formatted, Filter, Temp, TempFile STRING CID_AC, CID_NUM, TEMP_AC, TEMP_NUM, PF_Sec, OF_Sec, NM_Sec BYTE SecLow, SecHigh, Pos, Offset, NamePos, NameOffset, X, Length BYTE SCount, NCount BOOLEAN LogName, LogNoMatch, LogLockout, LogPCPursuit, Done, CIDTest BOOLEAN AreaCodeFix, AreaCodeFixed, LogFix, Display, NoMatch BOOLEAN SearchHex(5), NameSearchHex(5), SearchHexFlag, NameSearchHexFlag ;Characters to Filter out of Users Record Phone Numbers Filter = " -()+" Display = TRUE ;Parse the command line for possible ConfigFile GETTOKEN ConfigFile ;If not present use PPE info IF (ConfigFile = "") LET ConfigFile = PPEPATH() + PPENAME() + ".CFG" ;Read configuration file

Upload: prentice

Post on 09-Jan-2016

20 views

Category:

Documents


0 download

DESCRIPTION

; *****************************************************************. ; * *. ; * CID.PPE V 1.60 (09-01-95) *. ; * *. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: ; *****************************************************************

; *****************************************************************; * *; * CID.PPE V 1.60 (09-01-95) *; * *; * Written in PPL 3.10 for PCBoard 15.21 *; * *; * Designed By: Gary Meeker *; * *; * Began development: 04-06-93 *; * *; *****************************************************************;; This .PPE checks the secrity level of a user and if within the specified; range, checks the Caller ID info for the phone number. If a number is; found, then it writes it to the file specified.;; Usage:;; !CID.PPE C:\PCB\PPE\CID.CFG;; IF the configuration file is not specified, the CID.CFG in the same directory; as CID.PPE will be used.;

STRING ConfigFile, CID, Private, Outside, Search(5), NameSearch(5), TextSTRING CIDFile, PrivateFile, OutsideFile, NoMatchFile, LockOutFileSTRING BadNumFile, PCPNumFile, PCPUserFile, FileName, Label, AreaCodeSTRING PhoneNumber, Formatted, Filter, Temp, TempFileSTRING CID_AC, CID_NUM, TEMP_AC, TEMP_NUM, PF_Sec, OF_Sec, NM_SecBYTE SecLow, SecHigh, Pos, Offset, NamePos, NameOffset, X, LengthBYTE SCount, NCountBOOLEAN LogName, LogNoMatch, LogLockout, LogPCPursuit, Done, CIDTestBOOLEAN AreaCodeFix, AreaCodeFixed, LogFix, Display, NoMatchBOOLEAN SearchHex(5), NameSearchHex(5), SearchHexFlag, NameSearchHexFlag

;Characters to Filter out of Users Record Phone Numbers

Filter = " -()+"Display = TRUE

;Parse the command line for possible ConfigFile

GETTOKEN ConfigFile

;If not present use PPE info

IF (ConfigFile = "") LET ConfigFile = PPEPATH() + PPENAME() + ".CFG"

;Read configuration file

IF (EXIST(ConfigFile)) THEN FOPEN 1, ConFigFile, O_RD, S_DN FDEFIN 1 FDGET Temp TOKENIZE REPLACE(Temp, " ", CHR(255)) SCount = 1 WHILE (TRUE) DO Search(SCount) = REPLACE(GETTOKEN(), CHR(255), " ") GETTOKEN SearchHex(SCount) IF (Search(SCount)="") BREAK INC SCount ENDWHILE FDGET Temp TOKENIZE REPLACE(Temp, " ", CHR(255))

Page 2: ; *****************************************************************

NCount = 1 WHILE (TRUE) DO NameSearch(NCount) = REPLACE(GETTOKEN(), CHR(255), " ") GETTOKEN NameSearchHex(NCount) IF (NameSearch(NCount)="") BREAK INC NCount ENDWHILE FDGET Temp TOKENIZE Temp Private = REPLACE(GETTOKEN(), CHR(255), " ") IF (Private="") LET Private = "P" 'usually indicates a PRIVATE number Outside = REPLACE(GETTOKEN(), CHR(255), " ") IF (Outside="") LET Outside = "O" 'usually indicates a OUTSIDE AREA number GETTOKEN SecLow GETTOKEN SecHigh GETTOKEN LogName GETTOKEN LogNoMatch GETTOKEN LogLockout GETTOKEN LogPCPursuit GETTOKEN AreaCode GETTOKEN CIDTest GETTOKEN AreaCodeFix GETTOKEN LogFix FDGET Temp Label = REPLACE(Temp, CHR(255), " ") IF (Label = "") LET Label = "CID: " FDGET CIDFile FDGET Temp TOKENIZE Temp GETTOKEN PrivateFile GETTOKEN PF_Sec FDGET Temp TOKENIZE Temp GETTOKEN OutsideFile GETTOKEN OF_Sec FDGET Temp TOKENIZE Temp GETTOKEN NoMatchFile GETTOKEN NM_Sec FDGET LockoutFile FDGET BadNumFile FDGET PCPNumFile FDGET PCPUserFile FCLOSE 1ELSE PRINTLN "Missing configuration file - ", ConfigFile STOPEND IF

;Delete any existing CIDFile first if one was specified

GOSUB KillFile

;Get the Caller ID string and the Users info

CID = CALLID();CID = "DATE = 0101 TIME = 0103 NMBR = 7709952699 NAME = GARY MEEKER";CID = "DATE = 0101 TIME = 0103 NMBR = 030A37373039393532363939 NAME = 030B47415259204D45454B4552";CID = "DATE = 0101 TIME = 0103 MESG = 030A37373039393532363939 NAME = GARY MEEKER";CID = "DATE = 0101 TIME = 0103 MESG = 030739393532363939 NAME = GARY MEEKER"

IF (CIDTest) THEN

Page 3: ; *****************************************************************

FAPPEND 1, "CID_TEXT", O_RW, S_DN FPUTLN 1, "CIDText:<", CID, ">" FCLOSE 1END IF

GETUSER

;Bail out if no Caller ID info

IF (CID = "") STOP

;If not within the desired Security range we don't show files

IF (CURSEC() < SecLow | CURSEC() > SecHigh) LET Display = FALSE

;Find the postion of the Phone Number in the Caller ID string

FOR X = 1 TO SCount Pos = TOBYTE(Search(X)) ; Get it's numeric value if not string Offset = 0 ; Assume it's numeric, no offset SearchHexFlag = SearchHex(X) ; Assume this is the one we want

IF (Pos = 0) THEN ; If it's not a numeric value Pos = INSTR(CID, Search(X)) ; Look for the string Offset = LEN(Search(X)) ; and how long is our string END IF IF (Pos > 0) BREAK ; OK, we got one. Let's get out of hereNEXT X ; else, let's keep trying

IF (Pos = 0) THEN ; If we never find one, forget it. PRINT "Search Key not Found! (" ; But report what we didn't find FOR X = 1 To SCount PRINT Search(X) NEXT X PRINTLN ")" STOP ; then quitEND IF

;Pull out just the Phone NumberX = Pos + Offset ; Point to the actual data then.IF (SearchHexFlag) THEN ; Are we expecting Hex? GOSUB ReadHex ; Yes, generate Temp from Hex dataELSE Temp = MID(CID, X, 10) ; No, just grab the data thenEND IFTOKENIZE Temp ; Upper Case and find the end if shortPhoneNumber = RTRIM(LEFT(GETTOKEN(), 10), " ") ; just the number please

IF (LEN(PhoneNumber) = 7) LET PhoneNumber = AreaCode + PhoneNumber

Formatted = LEFT(PhoneNumber, 3) + "-" + MID(PhoneNumber, 4, 3) + "-" + RIGHT(PhoneNumber, 4)

;Write the number as AAA-EEE-NNNN to the desired file if specifed

IF ((CIDFile <> "") & (LEN(PhoneNumber) = 10)) THEN ;Verify all digits and a full 10 of them at that

FOR Pos = 1 TO 10 IF (INSTR(MASK_NUM(), MID(PhoneNumber, Pos, 1)) = 0) GOTO SkipCID NEXT Pos

FCREATE 1, CIDFile, O_WR, S_DB ; Generate the file FPUTLN 1, Formatted

Page 4: ; *****************************************************************

FCLOSE 1

:SkipCID

END IF

IF (LogName) THEN FOR X = 1 TO NCount NamePos = TOBYTE(NameSearch(X)) ; Ditto to the Name Search NameOffset = 0 NameSearchHexFlag = NameSearchHex(X)

IF (NamePos = 0) THEN NamePos = INSTR(CID, NameSearch(X)) NameOffset = LEN(NameSearch(X)) END IF IF (NamePos > 0) BREAK NEXT X

;Log the Name if present

IF (NamePos<>0) THEN ; Pull out just the Name X = NamePos + NameOffset ; Point to the actual data then. IF (NameSearchHexFlag) THEN ; Are we expecting Hex? GOSUB ReadHex ; Yes, generate Temp from Hex data ELSE Temp = MID(CID, X, 60) ; No, just grab the data then END IF

LOG Label + TRIM(Temp, " "), 0 ; And log it END IFEND IF

;If it's PRIVATE then show the file if specified

IF (LEFT(PhoneNumber, 1) = Private) THEN Temp = PF_Sec : TempFile = PrivateFile : GOSUB ShowFile

;If it's OUTSIDE AREA then show the file if specified

ELSEIF (LEFT(PhoneNumber, 1) = Outside) THEN Temp = OF_Sec : TempFile = OutsideFile : GOSUB ShowFile

;If it's not Home/Voice or Business/Data then show the file if specified; but nevermind if we didn't get an actual phone number.

ELSEIF ((LEN(PhoneNumber = 10)) & U_RECNUM(U_NAME()) > 0) THEN IF (AreaCodeFix) THEN CID_AC = LEFT(PhoneNumber, 3) CID_NUM = RIGHT(PhoneNumber, 7) END IF

NoMatch = TRUE ; Assume they don't match

;Get HVPhone number and strip out other characters.

Temp = U_HVPHONE : Text = "Home/Voice" GOSUB DoFilter ; Sets Done if area code changed IF (Done) LET U_HVPHONE = Temp ; Change it

;Get BDPhone number and strip out other characters.

Temp = U_BDPHONE : Text = "Bus/Data"

Page 5: ; *****************************************************************

GOSUB DoFilter ; Sets Done if area code changed IF (Done) LET U_BDPHONE = Temp ; Change it

IF (NoMatch) THEN IF (LogNoMatch) LOG "Caller ID: Not Home: "+U_HVPHONE+" or Bus: "+U_BDPHONE, 0 Temp = NM_Sec : TempFile = NoMatchFile : GOSUB ShowFile END IF IF (AreaCodeFixed) PUTUSER ; Write record if phone number changedEND IF

;If the number matches an entry in the BadNumFile then display the LockoutFile

FileName = BadNumFileText = FormattedGOSUB ScanFile ' Check for Text in Filename, return Done TRUE if foundIF (Done) THEN IF (LogLockout) LOG "CallerID: Caller Locked out!", 0 IF (EXIST(LockoutFile)) DISPFILE LockoutFile, LANG+SEC+GRAPH STOPEND IF

FileName = PCPNumFileGOSUB ScanFile ' Check for Text in Filename, return Done TRUE if foundIF (Done) THEN FileName = PCPUserFile Text = U_NAME() GOSUB ScanFile ' Check for Text in Filename, return Done TRUE if found Temp = "user added." IF (!Done) GOSUB AddtoFileEND IF

FileName = PCPUserFileText = U_Name()GOSUB ScanFile ' Check for Text in Filename, return Done TRUE if foundIF (Done) THEN FileName = PCPNumFile Text = Formatted GOSUB ScanFile ' Check for Text in Filename, return Done TRUE if found Temp = "number to ignore: " + Text IF (!Done) GOSUB AddtoFileEND IF

END

:ShowFile IF (TempFile <> "") THEN GOSUB CheckSec ' Sets Done = True if file to be displayed IF (EXIST(TempFile) & Done) DISPFILE TempFile, LANG+SEC+GRAPH END IFRETURN

:CheckSec Done = Display IF (Temp = "") RETURN ' Nothing specified use Display Done = FALSE ' Assume False Temp = REPLACE(Temp, ",", ";") ' Convert for Parsing TOKENIZE Temp ' Tokenize the list Text = "-" ' Initialize for WHILE loop WHILE (Text <> "" & !Done) DO GETTOKEN Text ' Get a Security Level or Range IF (Text<>"") THEN X = INSTR(Text, "-") ' Is it a Range? IF (X>0) THEN ' Yes

Page 6: ; *****************************************************************

IF (CURSEC() => LEFT(Text, X-1) & CURSEC() <= MID(Text, X+1, LEN(Text)-X)) LET Done = TRUE ELSE ' No IF (CURSEC() = Text) LET Done = TRUE END IF END IF END WHILERETURN

:ReadHex Temp = "" ' Start with nothing X = X + 2 ' Set pointer Length = S2I(MID(CID, X, 2), 16) ' Read the length in hex WHILE (Length > 0) DO ' Check the entire length X = X + 2 ' Bump the pointer Temp = Temp + CHR(S2I(MID(CID, X, 2), 16)) ' Convert a character DEC Length ' Count it END WHILE ' Keep it up until doneRETURN

:ScanFile Done = False ' Assume we don't find it IF (EXIST(FileName)) THEN ' Make sure the file is there FOPEN 1, FileName, O_RD, S_DN ' OK, so open it FDEFIN 1 ' WHILE (!Done) DO FDGET Temp IF (Temp="") BREAK ' Done with file if blank Done = (Temp=Text) END WHILE FCLOSE 1 END IFRETURN

:AddtoFile FAPPEND 1, FileName, O_RW, S_DN FPUTLN 1, Text FCLOSE 1 IF (LogPCPursuit) LOG "CallerID: New PCP "+ Temp, 0 GOSUB KillFile STOPRETURN

:KillFile IF (EXIST(CIDFile)) DELETE CIDFileRETURN

:DoFilter Done = FALSE FOR X = 1 TO LEN(Filter) Temp = STRIP(Temp, MID(Filter, X, 1)) ; Strip out any unwanted characters NEXT X IF (Temp = "") THEN Temp = "0000000000" ; If nothing left then make it all Zeros ELSEIF (LEFT(Temp, 1) = "1") THEN Temp = MID(Temp, 2, LEN(Temp)-1) ; If it starts with a 1, strip it off END IF IF (AreaCodeFix) THEN IF (LEN(Temp) = 7) THEN Temp = "000" + Temp ; Use the 000 for area code if the User did END IF ; not provide one Temp_AC = LEFT(Temp, 3) ; Get the Area Code Temp_NUM = RIGHT(Temp, 7) ; and the Phone Number

Page 7: ; *****************************************************************

IF ((Temp_AC <> CID_AC) & (Temp_NUM = CID_NUM)) THEN ; Area code changed? Temp = Formatted ; Yes, change it to what Caller ID supplied AreaCodeFixed = TRUE ; We need to write User record Done = TRUE ; We fixed one! NoMatch = FALSE ; It matches now! IF (LogFix) LOG "CallerID: " + Text + " Phone changed to " + Temp, 0 END IF END IF IF (RIGHT(PhoneNumber, LEN(Temp)) = Temp) LET NoMatch = FALSERETURN