home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HomeWare 14
/
HOMEWARE14.bin
/
bbsutils
/
lsru_21.arj
/
LSRU.PPS
< prev
next >
Wrap
Text File
|
1993-07-14
|
15KB
|
379 lines
;┌──────────────┬────────────────────────────────────────────────────────────┐
;│ │ │
;│ PROGRAM │ LSRU.PPE *** RELEASED TO PUBLIC DOMAIN *** │
;│ │ │
;│ AUTHOR │ MOONCROW │
;│ │ Mooncrow's Aeyrie BBS │
;│ │ NODE#1: (206) 737-0244 [14.4 HST] │
;│ │ NODE#2: (206) 737-8944 [14.4 V32] │
;│ │ NODE#3: (206) 737-8950 [14.4 V32] │
;│ │ NODE#4: (206) PRI-VATE [16.8 D/S] │
;│ │ │
;│ VERSION │ 2.1 │
;│ │ │
;│ DESCRIPTION │ A [PPE] program for PCBOARD 15.0 or higher. │
;│ │ Randomly selects a new logon screen for each new caller. │
;│ │ NOTE: 2.1 is NOT compatible with 1.0 or 1.1 - Reinstall! │
;│ │ │
;│ HOW TO USE │ The intended use for this PPE is for it to be executed in │
;│ │ one of two places. If you are using LSRU only to rotate │
;│ │ your welcome screens, then install this PPE as the first │
;│ │ and only line in your WELCOME. & WELCOMEG. files. │
;│ │ │
;│ │ If you are using LSRU to replace your logon screens, then │
;│ │ do NOT install LSRU in your WELCOME screens. Instead, │
;│ │ install LSRU in PCBTEXT record #259, the prompt that asks │
;│ │ the caller for his FIRST name and also install NULL.PPE in │
;│ │ PCBTEXT record #260, the prompt that asks for the caller's │
;│ │ LAST name. This new installation procedure eliminates │
;│ │ those annoying double echoes of the name prompts. See │
;│ │ LSRU.DOC for more detailed instructions. │
;│ │ │
;│ │ LRSU.CNF (or whatever you choose to call the CNF file) │
;│ │ must be located in the same directory as LSRU.PPE. The │
;│ │ specific format for this CNF file is described in the │
;│ │ sample LSRU.CNF that accompanies this archive. │
;│ │ │
;│ HISTORY │ See the attached LSRU.HIS file for a detailed history. │
;│ │ │
;└──────────────┴────────────────────────────────────────────────────────────┘
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Declare Variable Types │
;└───────────────────────────────────────────────────────────────────────────┘
INTEGER FILE_NUM, INPUT_FLAG, NUM_FILES, POINTER, TEMP
INTEGER HANDLE_POS(1), PWORD_POS(1)
BOOLEAN ERROR_FLAG, GRAPHICS_FLAG
STRING CMDLINE, CONFIG_FILE, ERROR_MSG, LOG_FILE, LOGON_FILE, OPTION
STRING HANDLE, PASSWORD, RETRY_COUNT, TEMP_STRING, CR, CRLF, NAG_FILE
STRING KBDSTUFF_STRING1, KBDSTUFF_STRING2, KBDSTUFF_STRING3, PROMPT_COLOR
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Initialize special variables... just to be on the safe side │
;└───────────────────────────────────────────────────────────────────────────┘
RETRY_COUNT = 0
TEMP = 0
ERROR_FLAG = 0
GRAPHICS_FLAG = (GRAFMODE() = "G" | GRAFMODE() = "R")
CR = CHR(13)
CRLF = CHR(10) + CHR(13)
HANDLE = ""
KBDSTUFF_STRING1 = ""
KBDSTUFF_STRING2 = ""
KBDSTUFF_STRING3 = ""
NAG_FILE = "NAG_USER.ASC"
PROMPT_COLOR = "00h"
PASSWORD = ""
TEMP_STRING = ""
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Verify that a CONFIG file was identified on the command line │
;└───────────────────────────────────────────────────────────────────────────┘
; Store the commandline in CMDLINE var
CMDLINE = TOKENSTR()
TOKENIZE CMDLINE
; If no command line parameters, ABORT!
IF (TOKCOUNT() < 1) THEN
ERROR_MSG = "NO CONFIG FILE SPECIFIED ON LSRU COMMAND LINE"
GOSUB ERROR_HANDLER
HANGUP
ENDIF
; If the specified LSRU config file does not exist, ABORT!
GETTOKEN CONFIG_FILE
IF (!EXIST(PPEPATH() + CONFIG_FILE)) THEN
ERROR_MSG = "LSRU CONFIG FILE NOT FOUND IN PPE DIRECTORY"
GOSUB ERROR_HANDLER
HANGUP
END IF
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Make sure the first CONFIG line is a valid number between 1 and 20 │
;└───────────────────────────────────────────────────────────────────────────┘
FOPEN 1, PPEPATH() + CONFIG_FILE, O_RD, S_DN
FGET 1, NUM_FILES
IF (NUM_FILES < 1) THEN
ERROR_MSG = "LINE 1 OF LSRU CONFIG FILE IS NOT AN INTEGER"
GOSUB ERROR_HANDLER
HANGUP
END IF
IF (NUM_FILES > 20) NUM_FILES = 20
;┌───────────────────────────────────────────────────────────────────────────┐
;│ If the second CONFIG line is "YES", then LSRU will prompt the caller for │
;│ his Handle and Password. A "NO" here means LSRU will only rotate screens │
;└───────────────────────────────────────────────────────────────────────────┘
FGET 1, OPTION
IF ((OPTION <> "YES") & (OPTION <> "yes")) OPTION = "NO"
FCLOSE 1
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Randomly select a logon file from the list in the Config file │
;└───────────────────────────────────────────────────────────────────────────┘
; Pick a random number between 1 and the number in the config file's Line #1
FILE_NUM = 1 + (RANDOM(NUM_FILES - 1))
; Set index pointer to random filename
POINTER = 2+ (5 * FILE_NUM - 4)
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Get the logon filename and cursor position from the Config file │
;└───────────────────────────────────────────────────────────────────────────┘
LOGON_FILE = READLINE(PPEPATH() + CONFIG_FILE, POINTER)
HANDLE_POS(0) = READLINE(PPEPATH() + CONFIG_FILE, POINTER + 1)
HANDLE_POS(1) = READLINE(PPEPATH() + CONFIG_FILE, POINTER + 2)
PWORD_POS(0) = READLINE(PPEPATH() + CONFIG_FILE, POINTER + 3)
PWORD_POS(1) = READLINE(PPEPATH() + CONFIG_FILE, POINTER + 4)
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Make sure the HANDLE & PASSWORD screen coordinates are on the screen! │
;│ [0 <= ROW <= 22] and [0 <= COLUMN <= 67] │
;└───────────────────────────────────────────────────────────────────────────┘
; Check the HANDLE column #
IF ((HANDLE_POS(0) < 0) | (HANDLE_POS(0) > 67)) THEN
ERROR_FLAG = 1
ERROR_MSG = "BAD HANDLE SCREEN COLUMN COORDINATE:" + STRING(HANDLE_POS(0))
GOSUB ERROR_HANDLER
GOTO GET_USER_HANDLE
END IF
; Check the HANDLE row #
IF ((HANDLE_POS(1) < 1) | (HANDLE_POS(1) > 22)) THEN
ERROR_FLAG = 1
ERROR_MSG = "BAD HANDLE SCREEN ROW COORDINATE:" + STRING(HANDLE_POS(1))
GOSUB ERROR_HANDLER
GOTO GET_USER_HANDLE
END IF
; Check the PASSWORD column #
IF ((PWORD_POS(0) < 0) | (PWORD_POS(0) > 67)) THEN
ERROR_FLAG = 1
ERROR_MSG = "BAD PASSWORD SCREEN COLUMN COORDINATE:" + STRING(PWORD_POS(0))
GOSUB ERROR_HANDLER
GOTO GET_USER_HANDLE
END IF
; Check the PASSWORD row #
IF ((PWORD_POS(1) < 0) | (PWORD_POS(1) > 22)) THEN
ERROR_FLAG = 1
ERROR_MSG = "BAD SCREEN ROW COORDINATE:" + STRING(PWORD_POS(1))
GOSUB ERROR_HANDLER
GOTO GET_USER_HANDLE
END IF
;┌───────────────────────────────────────────────────────────────────────────┐
;│ If the logon file exists, display it to the caller, else use default logon│
;└───────────────────────────────────────────────────────────────────────────┘
; If the caller is not in ANSI or RIP graphics mode, tell him how wonderful
; color screens can be and how much hard work goes into creating them.
IF (!GRAPHICS_FLAG) LOGON_FILE = NAG_FILE
IF (EXIST(PPEPATH() + LOGON_FILE)) THEN
DISPFILE PPEPATH() + LOGON_FILE, LANG + SEC + GRAPH
ELSE
ERROR_FLAG = 1
ERROR_MSG = "COULD NOT FIND LOGON FILE - " + LOGON_FILE
GOSUB ERROR_HANDLER
GOTO GET_USER_HANDLE
END IF
;┌───────────────────────────────────────────────────────────────────────────┐
;│ If the second line of the Config file contains "NO, exit to PCBOARD. │
;│ This is MANDATORY if all you want to do is rotate WELCOME screens. │
;└───────────────────────────────────────────────────────────────────────────┘
IF (OPTION = "NO") GOTO EXIT
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Get the caller's handle │
;└───────────────────────────────────────────────────────────────────────────┘
:GET_USER_HANDLE
; Give the caller 3 tries to enter ANY handle longer than 3 characters
IF (RETRY_COUNT = 3) THEN
IF (GRAPHICS_FLAG & EXIST(PPEPATH() + "DENIED.ANS")) THEN
DISPFILE PPEPATH() + "DENIED.ANS", 0
DELAY 182 ; 10 second delay (10*18.2)
ELSE
CLS
FOR TEMP = 1 TO 9
PRINTLN ""
END FOR
PRINTLN SPACE(15) + "@X0CAccess Denied - Excessive Invalid User ID Attempts!@X07"
END IF
HANGUP
END IF
IF (GRAPHICS_FLAG & !ERROR_FLAG) THEN
ANSIPOS HANDLE_POS(0),HANDLE_POS(1)
INPUTSTR "",HANDLE,PROMPT_COLOR,25,MASK_ASCII(),NOCLEAR + UPCASE
ELSE
CLS
INPUTSTR "What is your handle",HANDLE,0Eh,25,MASK_ASCII(),NOCLEAR + UPCASE + LFAFTER + LFBEFORE
END IF
; Make sure caller's handle is at least 3 characters long
IF (LEN(HANDLE) < 3) THEN
HANDLE = ""
RETRY_COUNT = RETRY_COUNT + 1
GOTO GET_USER_HANDLE
END IF
; Trim any leading or trailing "space" characters
TEMP_STRING = TRIM(HANDLE,CHR(32))
HANDLE = TEMP_STRING
TEMP_STRING = ""
; If the caller's Handle does NOT contain a "space", fake the last name
TEMP = INSTR(HANDLE,CHR(32))
IF (TEMP = 0) THEN
KBDSTUFF_STRING1 = HANDLE + " "
ELSE
KBDSTUFF_STRING1 = HANDLE + " "
END IF
TEMP = 0
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Check the USERS file to see if the caller is a registered user. │
;└───────────────────────────────────────────────────────────────────────────┘
TEMP = U_RECNUM(HANDLE)
; Thanks to Mr. Wyzard for pointing out the fact that PCBOARD hiccups during
; the U_RECNUM call if the caller rapidly presses the ENTER key after entering
; a one word handle and immediately aborts the PPE and exits to the prompt for
; the caller's last name. Be sure you add the call to NULL.PPE to record #260
; of your PCBTEXT file.
; A value of -1 means the caller is NOT a registered user, so exit to PCBOARD
IF (TEMP = -1) THEN
CLS
KBDSTUFF_STRING1 = KBDSTUFF_STRING1 + " " + CR
GOTO STUFF_KEYBOARD
END IF
; A value of 0 probably indicates a program error, so abort & hangup
IF (TEMP = 0) THEN
IF (ANSION()) ANSIPOS 0,22
ERROR_MSG = "User record number out of bounds"
GOSUB ERROR_HANDLER
HANGUP
END IF
TEMP = 0
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Ok, the caller is a registered user, so get him to enter his PASSWORD │
;└───────────────────────────────────────────────────────────────────────────┘
IF (GRAPHICS_FLAG & !ERROR_FLAG) THEN
ANSIPOS PWORD_POS(0),PWORD_POS(1)
INPUTSTR "",PASSWORD,PROMPT_COLOR,13,MASK_PWD(),NOCLEAR + ECHODOTS + UPCASE
ELSE
INPUTSTR "What is your password",PASSWORD,0Eh,13,MASK_PWD(),NOCLEAR + ECHODOTS + UPCASE + LFAFTER + LFBEFORE
END IF
; Trim any leading or trailing "space" characters
TEMP_STRING = TRIM(PASSWORD,CHR(32))
PASSWORD = TEMP_STRING
TEMP_STRING = ""
KBDSTUFF_STRING2 = PASSWORD + CR
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Move cursor to the bottom of the screen (Column 0, Row 22) so the next │
;│ prompt won't overwrite the middle of the ANSI logon screen │
;└───────────────────────────────────────────────────────────────────────────┘
IF (ANSION()) ANSIPOS 0,22
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Ok, we have the caller's handle & password, so stuff the keyboard buffer │
;│ and return control to PCBOARD │
;└───────────────────────────────────────────────────────────────────────────┘
:STUFF_KEYBOARD
SHOWOFF
KBDSTUFF KBDSTUFF_STRING1 + KBDSTUFF_STRING2
SHOWON
CLS
GOTO EXIT
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Error Handler │
;└───────────────────────────────────────────────────────────────────────────┘
:ERROR_HANDLER
; Log the error to the CALLER file
LOG_FILE = READLINE(PCBDAT(),30)
FOPEN 2, LOG_FILE, O_RW, S_DW
TEMP_STRING = STRING(DATE()) + " (" + STRING(TIME()) + ") (" + "@NODE@" + ") " + HANDLE
GOSUB PAD_LOG_STRING
FPUT 2, TEMP_STRING
FPUT 2, SPACE(62) + CRLF
TEMP_STRING = "LSRU ERROR: " + ERROR_MSG
GOSUB PAD_LOG_STRING
FPUT 2, TEMP_STRING
FPUT 2, SPACE(62) + CRLF
; If FATAL error occurred, log it, let the caller know and then hangup!
TEMP_STRING = "**************************************************************"
IF (ERROR_FLAG) THEN
FPUT 2, TEMP_STRING
FCLOSE 2
ELSE
CLS
PRINTLN "@X0CFATAL ERROR@X07:" + ERROR_MSG
PRINTLN ""
PRINTLN "@X0EFAIL SAFE TRIPPED... @X0FSHUTTING SYSTEM DOWN...@X07"
PRINTLN ""
PRINTLN "Notify SysOp - If possible!"
FPUT 2, "CALLER OFF ABNORMALLY"
FPUT 2, TEMP_STRING
FCLOSE 2
FCLOSE 1
HANGUP
END IF
RETURN
;┌───────────────────────────────────────────────────────────────────────────┐
;│ PCBOARD CALLER log entries MUST have a fixed line length of 64 bytes │
;└───────────────────────────────────────────────────────────────────────────┘
:PAD_LOG_STRING
IF (LEN(TEMP_STRING) > 62) THEN
TEMP_STRING = LEFT(TEMP_STRING,62) + CRLF
ELSE
TEMP_STRING = TEMP_STRING + SPACE(62-LEN(TEMP_STRING)) + CRLF
END IF
RETURN
;┌───────────────────────────────────────────────────────────────────────────┐
;│ EXITS PPE and returns control to PCBOARD │
;└───────────────────────────────────────────────────────────────────────────┘
:EXIT
END