home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Boldly Go Collection
/
version40.iso
/
TS
/
05B
/
TMHOST05.ZIP
/
TEL-HOST.SCR
< prev
next >
Wrap
Text File
|
1992-02-07
|
31KB
|
1,023 lines
; TO DO LIST/WISH LIST
;
; X Configurable time delays.
; * Additional clearance levels.
; X Standardize keys between modes.
; X Instruction document
; X File list.
; * User log.
; X Auto log off after up/download
; X Movement on screens to show script activity.
; X Make disk cache optional or remove.
; * Multiple try password.
; * Remote control program running using PC Mag PCRemote utility.
; * Time limit for first time callers.
; X Configurable com port for shell to DOS using WABIRD - needs testing
; * Call back option
; * User survey
; X Add local mode to standby menu
; * Use TIME variables for accuracy
; ! Remember. THCONFIG.SCR and the THCONFIG.SBH must be in the
; default script directory. The remaining files can be anywhere.
; === Modified from... =======================
; HOST.SCR by Tsung Hu, 29 Nov, 1991
; ============================================
; █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
; █ Ver 0.5 1992 █
; █ ▀▀▀▀█▀▀▀▀▀ █ █ █
; █ █ █▀▀▀▀ █ █ █ █▀█ █▀▀ ▀▀█▀▀ █
; █ █ █▀▀▀▀ █ ▀▀▀ █▀▀▀█ █ █ ▀▀█ █ █
; █ █ ▀▀▀▀▀ ▀▀▀▀ █ █ ▀▀▀ ▀▀▀ ▀ █
; █ █
; █ Modified Telemate Host Program with Standby mode. █
; █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
;
; Advanced features by: Paul D. Kruschwitz
;
; constant
;
TRUE = 1
FALSE = 0
FOREVER = TRUE
FILEDIR = "\HOST.DIR" ; temp. file for F)ile command
;
; global variable
;
integer local,userlevel,exist,xport,standbymode,timewait,timeidle,i
string username,password,filename,ch,CPORT,FLUSHCOMMAND
integer NEWUSERLEVEL,SYSOPLEVEL,DETECTBAUD,INITIALBAUD,YELLTIME,YELLSOUND
string HOSTDIR,DOWNLOADDIR,UPLOADDIR,RUNPROGRAM
integer OFFAFTER,CP,localmode
localmode=false
local=true
standbymode=false
i=7
integer oldAlarmTime,oldAlarmSound,oldZAuto,oldZRecovery,oldBaud,oldConnection
string oldDirUpload,scriptdir
procedure StoreOptions
query alarmtime,oldAlarmTime
query alarmsound,oldAlarmSound
query dirupload,oldDirUpload
query zautodownload,oldZAuto
query zrecovery,oldZRecovery
query baud,oldBaud
query connection,oldConnection
query maxdosshell,oldmaxdosshell
endproc
procedure RestoreOptions
set alarmtime,oldAlarmTime
set alarmsound,oldAlarmSound
set dirupload,oldDirUpload
set zautodownload,oldZAuto
set zrecovery,oldZRecovery
set baud,oldBaud
set connection,oldConnection
set maxdosshell,oldmaxdosshell
endproc
procedure HostConfig ; read the configuration file
string s,ch,scriptdir ; HCONFIG.SBH from the default script dir
query dirscript,scriptdir
concat SCRIPTDIR,"\"
strpos SCRIPTDIR,"\\",pos
If pos=0
concat SCRIPTDIR,"THCONFIG.SBH"
else
substr SCRIPTDIR,1,pos,SCRIPTDIR
concat SCRIPTDIR,"THCONFIG.SBH"
endif
open SCRIPTDIR
if success
read s
atoi s,NEWUSERLEVEL ; new user level
read s
atoi s,SYSOPLEVEL ; sysop level
read s
atoi s,DETECTBAUD ; detect baud rate
read s
atoi s,INITIALBAUD ; initial baud rate
read s
atoi s,YELLTIME ; yell time
read s
atoi s,YELLSOUND ; yell sound
read HOSTDIR ; directory containing H*.SBH
read DOWNLOADDIR ; download directory
read UPLOADDIR ; upload directory
read s
atoi s,TIMEWAIT ; Active Delay time
read s
atoi s,TIMEIDLE ; Inactive timeout
read s
atoi s,CACHE ; Do you wish to flush cache
read FLUSHCOMMAND ; DOS command to flush cashe
read RUNPROGRAM ; Reads the program or batch to run in shell
close
set alarmtime,YELLTIME ; setup yell alarm
set alarmsound,YELLSOUND
set dirupload,UPLOADDIR ; setup upload directory
set MaxDosShell,True ; Maximum dos shell on shell
else
print "Cannot find HCONFIG.SBH configuration file..."
print
print "Do you want to setup host mode (y/n)? ",
repeat
inputch ch
until success
if ch="y"
print ch
RestoreOptions
query dirscript,scriptdir
concat scriptdir,"\"
strpos scriptdir,"\\",pos
If pos=0
concat scriptdir,"THCONFIG.SCR"
else
substr scriptdir,1,pos,scriptdir
concat scriptdir,"THCONFIG.SCR"
endif
print scriptdir
script scriptdir ; chain to THCONFIG.SCR
else
print "n" ; abort host mode
print "Host mode aborted"
stop
endif
endif
integer cp ; *** Sets up shell to dos parameters ***
string temp
query port,cp ; Stores com port for use with wabird utility
cport="com"
itoa cp,temp ; Changes to string ="#"
concat cport,temp ; Create "com#"
endproc
procedure menu
print
print " Press [S]witch mode. [active<->standby]"
print " [L]ocal mode access"
print " [C]onfigure Host"
print " [Esc] to end script"
print " *[Alt-H] to terminate user."
print " *[C]hat with user. (* = when on-line only.)"
endproc
procedure flushcache ; MOD used to flush PcTool's delayed write cache.
dos FLUSHCOMMAND ; "pc-cache /flush /ok"
endproc
procedure activeflash integer col,row
string fl
fl="ACTIVE " ; Puts 'moving' action on screen
strset fl,"!",i,1 ; to show that script is still
i=i+1 ; functioning.
if i=8
i=1
endif
at col,row
print fl
endproc
procedure HostEnd
clear key ; clear keyboard buffer
clear com ; clear com buffer
print
print "Ending host mode"
put "^(","~", ; send modem init string
print
chdir HOSTDIR
delete FILEDIR ; delete temp file
RestoreOptions
clear text
print
print "TEL-HOST was modified from the original Telemate host script."
print
print "Advanced features were added by: Paul Kruschwitz"
print
print "--- --- --- --- --- --- --- --- --- ---"
print " PLEASE do not re-post changes under the TEL-HOST name"
print " to avoid version confusion."
print "--- --- --- --- --- --- --- --- --- ---"
print
print "All suggestions for improvement are welcome via RIME."
print
print "REMEMBER: Attitude is everything."
stop
endproc
procedure Disconnect ; end session
delay 10
if not local
hangup
endif
set connection,modem
local = FALSE
endproc
procedure Output string s
print s,
if not local
put s,
endif
endproc
procedure InputChar string ch ; input and display locally
repeat
if not local
getch ch
endif
if local or not success
inputch ch
if success
if ch = "^["
HostEnd ; abort by operator
endif
print ch,
endif
endif
until success or not connected
endproc
procedure InputEcho string ch ; input and echo to remote
InputChar ch
if not local
put ch,
endif
if ch = "^M" ; add line feed
Output "^J"
endif
endproc
procedure DotEcho string ch ; input and echo "." to remote
InputChar ch
if not local
if ch="^H" or ch="^M"
put ch,
else
put ".", ; echo with "."
endif
endif
if ch = "^M" ; add line feed
Output "^J"
endif
endproc
procedure Pause ; request a key
string ch
Output "Press [Enter] to continue "
InputEcho ch
Output "^M^J"
if ch<>"^M"
Output "^M^J"
endif
endproc
procedure TypeFile string filename,integer more
string ch ; display a file
integer i
i = 0
open filename
if not success
Output "File not found.^M^J"
else
while success
inputch ch
if success and ch = "^C" ; operator break
clear com
Output "^M^J"
exit
endif
if not local
getch ch
if success and ch = "^C" ; caller break
clear com
Output "^M^J"
exit
endif
endif
read s ; display a line
Output s
Output "^M^J"
i = i+1
if i = 22 and more ; pause if <more> is TRUE
i = 0
Output "-- More --"
InputChar ch
if ch = "^C"
clear com
Output "^M^J"
exit
endif
Output "^M ^M"
endif
endwhile
close
if more
Pause
endif
endif
endproc
procedure inithost
set zautodownload,off
set zrecovery,off
set baud,INITIALBAUD
clear key ; clear keyboard buffer
clear com ; clear com buffer
clear text
print
print "Initializing modem"
put "^)", ; send modem answer string
if connected
print "Carrier signal is high, trying to make it reflect the online status"
put "~AT&C1^M~", ; make carrier signal reflect online status
if connected
print "Carrier signal is still high, host mode may not work correctly"
print "Please check your modem manual for correct DIP switch setting"
else
print "Carrier signal is now correct"
endif
print
endif
put "~ATQ0E0X4^M~", ; disable responds from modem
endproc
procedure InputString string str ; input a string
string ch
str = ""
repeat
InputEcho ch
if ch <> "^M"
if ch = "^H"
if str = ""
Output " "
else
Output " ^H"
endif
endif
concat str,ch
endif
until ch = "^M" or not connected
if str="" or not connected
success = FALSE
else
success = TRUE
endif
endproc
procedure InputFilename string filename,dir
string name
integer pos
InputString name ; input a filename
repeat
strpos name,":",pos ; strip drive part
if pos>0
strdel name,1,pos
endif
until pos=0 or not connected
repeat
strpos name,"\",pos ; strip directory part
if pos>0
strdel name,1,pos
endif
until pos=0 or not connected
if name="" or not connected
success = FALSE
filename = ""
else
success = TRUE
filename = dir
concat filename,"\" ; concat <dir>
strpos filename,"\\",pos
if pos>0
strdel filename,pos,1 ; avoid root directory"
endif
concat filename,name
endif
endproc
procedure InputPassword string password ; input password
password = ""
repeat
DotEcho ch
if ch <> "^M"
if ch = "^H"
if password = ""
Output " "
else
Output " ^H"
endif
endif
concat password,ch
endif
until ch = "^M" or not connected
if password="" or not connected
success = FALSE
else
success = TRUE
endif
endproc
procedure CheckUser string username,password,integer level,valid
integer found,pos1,pos2
string record,name,pass,lev
strpos username,";",pos1 ; record format: "first last;password#level"
strpos username,"#",pos2
if pos1>0 or pos2>0
valid = FALSE
return
endif
strpos password,";",pos1 ; check password for invalid character
strpos password,"#",pos2 ; prevent "#2" etc
if pos1>0 or pos2>0
valid = FALSE
return
endif
chdir HOSTDIR
open "HUSER.SBH" ; passwords in HUSER.SBH
if not success
create "HUSER.SBH"
endif
if not success
Output "System error, please call again later^M^J"
print "SYSOP: Cannot create HUSER.SBH"
Disconnect
alarm "SYSOP: Cannot create HUSER.SBH, disk full ?"
return
endif
found = FALSE
read record
while success and not found
strpos record,";",pos1 ; get fields from the record
strpos record,"#",pos2
if pos1>0 and pos2>0
substr record,1,pos1-1,name
substr record,pos1+1,pos2-pos1-1,pass
if name=username
found = TRUE
if pass=password
valid = TRUE
substr record,pos2+1,1,lev
atoi lev,level
else
valid = FALSE
endif
endif
endif
if not found
read record
endif
endwhile
if not found ; new users
seek -1
write username,";",password,"#",NEWUSERLEVEL
level = 1
valid = TRUE
FileExist "HNEWUSER.SBH",exist
if exist
Output "^M^J"
TypeFile "HNEWUSER.SBH",TRUE
endif
endif
close
endproc
procedure Directory ; display download directory
string cmd
cmd = "DIR >"
concat cmd,FILEDIR ; DIR >\HOST.DIR
dos cmd ; shell to DOS
TypeFile FILEDIR,TRUE ; display \HOST.DIR
endproc
procedure FileTransfer string mode,protocol,filename
print "^M^JPlease start your transfer procedure or press Ctrl-X to abort^M^J"
delay 20
if mode = "r"
if filename="" ; receive batch files
receive protocol
else
receive protocol,filename ; receive single file
endif
else
send protocol,filename ; send multiple files
endif
delay 30 ; Trying to get the message to show up after ...
if success
Output "File transfer completed^M^J"
else
Output "File transfer aborted^M^J"
endif
If OFFAFTER
Output "^M^JAutomatically logging off after download."
disconnect
endif
Pause
if mode="r" and CACHE
flushcache
endif
endproc
procedure beginhost
if not local and DETECTBAUD
waitfor "CONNECT^M","CONNECT 1200","CONNECT 2400","CONNECT 9600","CONNECT 19200",10
if found
switch found
case 1: baudrate = 300
case 2: baudrate = 1200
case 3: baudrate = 2400
case 4: baudrate = 9600
case 5: baudrate = 19200
endswitch
set baud,baudrate
Output "Connected at "
if not local
put baudrate,"^M^J"
endif
print baudrate
endif
endif
Output "^M^J"
delay 5
clear com
clear text
delay 5
chdir HOSTDIR
TypeFile "HWELCOME.SBH",FALSE ; display welcome message
i = 1
len = 0
username = "" ; enter name (at most 3 times)
while i<=3 and len<4 and connected
Output "Please enter your First and Last name: "
InputString username
i = i+1
length username,len ; check the length of name
if len<4
Output "Name too short, please try again^M^J^M^J"
else
Output username
Output " [Y/n]? "
InputString ch
if ch="n"
len=0
endif
endif
endwhile
if len<4 and connected
Output "Goodbye^M^J"
Disconnect
else
i = 1
len = 0
password = "" ; enter password (at most 3 times)
while i<=3 and len<4 and connected
Output "Password: "
InputPassword password
i = i+1
length password,len ; check the length of ot
if len<4
Output "Password too short, please try again^M^J^M^J"
endif
endwhile
if len>=4 ; check password and get user level
CheckUser username,password,userlevel,valid
endif
if (len<4 or not valid) and connected
Output "Invalid password, access denied^M^J^M^J"
Disconnect
else
chdir HOSTDIR ; display notice
FileExist "HNOTICE.SBH",exist
if exist
Output "^M^J"
TypeFile "HNOTICE.SBH",TRUE
endif
endif
endif
endproc
procedure WaitForCall ; wait for connected
integer i,len,valid,exist,baudrate
set connection,modem
local = FALSE
xport = FALSE
i=0
clear text
chdir HOSTDIR
typefile "HACTIVE.SBH",False
print
print
print
if standbymode
print
print " STANDBY MODE HAS BEEN TRIGGERED"
print
print " Host mode active for about 60 seconds ONLY!"
print
print " Press [Esc] to end script"
print
print "|-----------------------------------<Approx. Time Remaining>|"
print "| | | | | | |"
else
menu
endif
clear key ; clear keyboard buffer
clear com ; clear com buffer
while not connected and i<61 ; wait for carrier signal
inputch ch ; sysop commands
if success
switch ch
case "^[": ; abort
HostEnd
case "L": ; local mode
set connection,computer ; this will set connected = 1
local = TRUE
case "C": ; configuration
put"^("
RestoreOptions
script "THCONFIG.SCR" ; chain to THCONFIG.SCR
case "S":
if not standbymode
standbymode=true
put"^("
return
endif
endswitch
endif
if standbymode
print "*",
delay 10
i=i+1
else
Activeflash 30,13
delay 10
endif
endwhile
if i=61 and not connected
Put"^("
delay 15
Return
endif
endproc
procedure ChatMode ; chat mode
integer x
string rch,lch
Output "^M^JChat mode begin:^M^J"
repeat
if not local
getch rch
if success
put rch,
if rch = "^M"
Output "^J"
endif
wherex x
if rch = " " and x > 65
Output "^M^J"
endif
endif
endif
inputch lch
if success and lch<>"^[" ; abort if sysop press [Esc]
Output lch
if lch = "^M"
Output "^J"
endif
wherex x
if lch = " " and x > 65
Output "^M^J"
endif
endif
until lch="^[" or not connected
Output "^M^JChat mode end.^M^J^M^J"
Pause
endproc
procedure DoCommand ; do a command
string SHELLUTIL
ch=""
SHELLUTIL="WABIRD /"
IF NOT LOCAL
WHENIDLE timeidle,"^*"
ENDIF
if xport
If standbymode
output " [Standby ON]^M^J"
else
output " [Standby OFF]^M^J"
endif
Output "Command F,U,D,T,C,X,G,(S,R,Z,M): " ; export mode
else
Output "^M^J^M^J"
chdir HOSTDIR
TypeFile "HMENU.SBH",FALSE ; display menu
If standbymode
output " [Standby ON]^M^J"
else
output " [Standby OFF]^M^J"
endif
Output "Command: "
endif
InputEcho ch
if ch<>"^M"
Output "^M^J"
endif
switch ch
case "F": ; file directory
chdir DOWNLOADDIR
Directory
case "T": ; type a file
Output "Enter filename: "
InputFilename filename,DOWNLOADDIR
if success
chdir DOWNLOADDIR
TypeFile filename,TRUE
endif
case "U": ; upload a file
Output "^M^J"
chdir HOSTDIR
TypeFile "HPROT.SBH",FALSE
Output "Select protocol: "
InputEcho protocol
Output "^M^J"
if local
Output "Function not available in local mode^M^J"
else
switch protocol
case "X","R":
Output "Enter filename: "
InputFilename filename,""
if success
if success
Output "Log off after download [y/N]? "
InputString ch
if ch="Y"
OFFAFTER=TRUE
else
OFFAFTER=FALSE
endif
endif
FileTransfer "r",protocol,filename
endif
case "Z","S","T","M","Y","B","G":
FileTransfer "r",protocol,""
endswitch
endif
case "D": ; download a file
Output "^M^J"
chdir HOSTDIR
TypeFile "HPROT.SBH",FALSE
chdir DOWNLOADDIR
Output "Select protocol: "
InputEcho protocol
Output "^M^J"
if local
Output "Function not available in local mode^M^J"
else
switch protocol
case "X","Y","Z","S","T","M","R","B","G":
Output "Enter filename: "
InputFilename filename,DOWNLOADDIR
if success
Output "Log off after download [y/N]? "
InputString ch
if success
if ch="Y"
OFFAFTER=TRUE
else
OFFAFTER=FALSE
endif
endif
FileTransfer "s",protocol,filename
endif
endswitch
endif
case "C": ; yell
Output "Yelling Sysop, please wait ... ^M^J"
alarm "User is yelling ...^JPress [Enter] to accept, [Esc] to deny"
if success
print "^M^JSYSOP: press [Esc] to terminate chat mode"
ChatMode
else
Output "^M^JSorry, Sysop is not here^M^J"
endif
case "X": ; toggle export mode
xport = not xport
case "G": ; goodbye
chdir HOSTDIR
TypeFile "HGOODBYE.SBH",FALSE
Disconnect
case "S": ; shell to DOS
if userlevel<SYSOPLEVEL
Output "Sorry, this command is for Sysop only^M^J"
else
chdir HOSTDIR
if local ; local mode shell to DOS
Output "Shelling to DOS ... ^M^J"
dos
Output "Return from DOS shell^M^J"
else
Output "Shelling to DOS ... ^M^J"
concat SHELLUTIL,CPORT ; Used to create command line
concat SHELLUTIL,"/dev" ; for WABIRD.
concat SHELLUTIL,CPORT
dos SHELLUTIL ; This is used instead
Output "Returning from DOS shell^M^J" ; of hshell.bat
endif
endif
case "R": ; run remote program
if userlevel<SYSOPLEVEL
Output "Sorry, this command is for Sysop only^M^J"
else
chdir HOSTDIR
if local ; run HLOCAL.BAT if local mode
fileexist "hlocal.bat",exist
if exist
Output "Loading external program ... ^M^J"
dos "hlocal.bat"
flushcache
Output "Return from external program^M^J"
else
Output "SYSOP: Cannot find HLOCAL.BAT^M^J"
endif
else ; run program using wabird.
concat SHELLUTIL,CPORT ; Used to create command line
concat SHELLUTIL,"/dev" ; for WABIRD.
concat SHELLUTIL,CPORT
concat SHELLUTIL,"/prg/c"
concat SHELLUTIL,RUNPROGRAM
dos SHELLUTIL ; This is used instead
dos "wabird /com2 /devcom2 /prg/chremote.bat"
; /c needed for flag on command.com
flushcache
Output "Returning from remote program^M^J"
endif
endif
case "Z": ; shut down host mode
if userlevel<SYSOPLEVEL
Output "Sorry, this command is for Sysop only^M^J"
else
Output "Are you sure [y/N]? "
InputString ch
if ch="y"
Output "Shutting down host mode^M^J"
Disconnect
HostEnd
endif
endif
case "M": ; toggle standby mode
if userlevel<SYSOPLEVEL
Output "Sorry, this command is for Sysop only^M^J"
else
if standbymode
output "Standby Mode Disabled.^M^J"
output "Caution: Modem will now always answer the phone.^M^J"
output " Use the [Z] option to shut down Host.^M^J"
pause
standbymode=false
else
print "Standby Mode Enabled.^M^J"
pause
standbymode=true
endif
endif
endswitch
endproc
procedure Title
integer count
chdir hostdir
count=0
clear text
clear com
chdir HOSTDIR
typefile "HTITLE.SBH",false ; Title page file. Glitz
print
print " Standby mode will become active in 5 seconds..."
print
print " [C]onfigure host mode."
print
print " Press any other key to directly enter Answer mode"
print
print
repeat
delay 10
inputch ch
count=count+1
until success or count=6
if success
if ch="c"
script "THCONFIG.SCR"
else
Return
endif
endif
standbymode=true
endproc
procedure Standby
chdir hostdir
clear text
clear com
clear com
clear text
local=true
chdir HOSTDIR
Typefile "HSTANDBY.SBH",false ; This is the screen to display while
; it is waiting for a call to enable.
menu
done=false
repeat
waitfor "RING",1
if found
ch=""
done = true
else
inputch ch
if success ; ESC to cancel standby
switch ch
case "s":
clear text
clear com
at 5,5
print "Switching to active HOST mode."
print
standbymode=false
return
case "L": ; local mode
set connection,computer ; this will set connected = 1
local = TRUE
localmode=TRUE
return
case "^[":
HostEnd
case "c":
RestoreOptions
script "THCONFIG.SCR" ; chain to THCONFIG.SCR
endswitch
endif
endif
Activeflash 30,15 ; Shows script activity.
until done
clear text
clear com
at 5,5
print "Ring Detected... Waiting ",timewait," seconds for phone to stop ringing."
at 5,8
print "Then the next call within about 60 seconds will be answered by the modem."
delay (timewait*10)
standbymode=true
return
clear com
endproc
;
; begin main program
;
StoreOptions
HostConfig ; read configuration file HCONFIG.SBH
put "^(","~", ; send modem init string
Title
while FOREVER
localmode=false
if standbymode
Standby
endif
if not localmode
inithost ; initialize host
WaitForCall ; wait for a call
endif
if connected
Beginhost
endif
while connected
DoCommand ; do commands
endwhile
whenidle 0,""
if standbymode
put"^("
endif
endwhile