home *** CD-ROM | disk | FTP | other *** search
/ Current Shareware 1994 January / SHAR194.ISO / modem / tmhost24.zip / TMHOST24.SCR < prev   
Text File  |  1993-07-06  |  70KB  |  2,255 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;; HOST.SCR by Tsung Hu, 21 May, 1990
  3. ;; Modified by Richard Bailey Dec 1990
  4. ;; Renamed TMHOST2, see comments throughout file explaining changes.
  5. ;; Modified by Bob Wiatr Aug. 1992 to use with Telemate 3.02 & 3.10                    
  6. ;; Renamed TMHOST21.
  7. ;; Modified by Bob Wiatr April 18, 1993 to use with Telemate 4.0
  8. ;; Renamed TMHOST22
  9.  
  10. #include "SCREENIO.SCR"
  11.  
  12. ;
  13. ; constants
  14. ;          
  15. EchoToLocal = 1                    ; variables set to TRUE
  16. EchoToRemote = 1                   ; for SCREENIO routines
  17. TRUE = 1
  18. FALSE = 0
  19. FOREVER = TRUE
  20. TMLOG = "\TMDIR\TM.USE"
  21. FILEDIR = "\HOST.DIR"           ; temp. file for F)ile command
  22. MENUCOMMAND = " Minutes left. Enter Command  "
  23. XPERTCOMMAND = " Minutes left. Enter Command (? for help)  "
  24. TMHOST = "***TMHOST BBS VER. 2.4 ***"
  25.  
  26. ;
  27. ; global variables
  28. ;
  29. integer access,addmsg,areanum,exist,mail,mins,msgmail,msgread,msgs,ontime
  30. integer reply,savedmsg,timeleft,userlevel,xpert
  31. integer NEWUSERLEVEL,NUSERLEVEL,SYSOPLEVEL,DETECTBAUD,INITIALBAUD,YELLTIME
  32. integer YELLSOUND,LOCAL,COUNT,CLOSESYSTEM,FILELIST
  33.  
  34. string area,ch,filename,logontime,name,now,password,subject,today
  35. string GENBKCOL,HEADERBKCOL,GENTEXTCOL,HEADERTEXTCOL,HILITECOL,MSGBASE
  36. string totalmsgs,username,wdate
  37. string SPECIALTEXTCOL,LOCALBOXCOL,LOCALCOL,TMDIR,HOSTDIR,DOWNLOADDIR
  38. string MSBASE0,MSBASE1,MSBASE2,MSBASE3,MSBASE4,MSBASE5,MSBASE6,MSBASE7
  39. string MSBASE8,MSBASE9  
  40. string area0,area1,area2,area3,area4,area5,area6,area7,area8,area9
  41.  
  42. Procedure CheckDirectory string dir
  43.    integer l,pos
  44.    string ch,firstdir
  45.    strpos dir,";",pos
  46.    if pos>0
  47.       substr dir,1,pos-1,firstdir
  48.       dir = firstdir
  49.    endif
  50.    length dir,l
  51.    if l>0
  52.       substr dir,l,1,ch
  53.       if ch<>"\" and ch<>":"
  54.          concat dir,"\"
  55.       endif
  56.    endif
  57. Endproc
  58.  
  59.  
  60. Procedure HostConfig               ; read the configuration file
  61.    string s,ch                     ; TMHCFG.HST from the current directory
  62.    open "TMHCFG.HST"
  63.      if success
  64.        read s                                                  
  65.        atoi s,NEWUSERLEVEL         ; new user level
  66.        read s
  67.        atoi s,NUSERLEVEL           ; normal user level
  68.        read s
  69.        atoi s,SYSOPLEVEL           ; sysop level
  70.        read s
  71.        atoi s,DETECTBAUD           ; detect baud rate
  72.        read s
  73.        atoi s,INITIALBAUD          ; initial baud rate
  74.        read s
  75.        atoi s,YELLTIME             ; yell time
  76.        read s
  77.        atoi s,YELLSOUND            ; yell sound
  78.        read TMDIR
  79.        read HOSTDIR                ; directory containing H*.HST
  80.        read DOWNLOADDIR            ; download directory
  81.        read s                      ; (upload goes to TM dl DIR)
  82.        atoi s,CLOSESYSTEM          ; Read if system is closed
  83.        read s
  84.        atoi s,FILELIST
  85.        read GENBKCOL               ; general background colour
  86.        read GENTEXTCOL             ; general text colour
  87.        read HILITECOL              ; hilite colour 
  88.        read HEADERBKCOL            ; header background colour
  89.        read HEADERTEXTCOL          ; header text colour 
  90.        read SPECIALTEXTCOL         ; e.g. questionnaire text colour
  91.        read LOCALBOXCOL            ; local box colour e.g. starting Host mode
  92.        read LOCALCOL               ; local text colour
  93.        read s
  94.        atoi s,COUNT                ; number of message areas
  95.        read area0                  ; message areas 
  96.        read MSBASE0                ; and files
  97.        read area1
  98.        read MSBASE1
  99.        read area2 
  100.        read MSBASE2
  101.        read area3 
  102.        read MSBASE3
  103.        read area4 
  104.        read MSBASE4
  105.        read area5
  106.        read MSBASE5 
  107.        read area6 
  108.        read MSBASE6
  109.        read area7
  110.        read MSBASE7
  111.        read area8 
  112.        read MSBASE8 
  113.        read area9 
  114.        read MSBASE9
  115.        read s
  116.        atoi s,ANSILOCAL
  117.        close
  118.                     ; CheckDirectory HOSTDIR
  119.                     ; CheckDirectory DOWNLOADDIR
  120.        set alarmtime,YELLTIME      ; setup yell alarm
  121.        set alarmsound,YELLSOUND
  122.      else
  123.        print "Cannot open TMHCFG.HST in the current directory"
  124.        print
  125.        print "Do you want to setup host mode (y/n)? ",
  126.        repeat
  127.          inputch ch
  128.        until success
  129.          if ch="y"
  130.            print ch
  131.            script "TMHCFG"         ; chain to TMHCFG.SCR
  132.          else
  133.            print "n"               ; abort host mode
  134.            print "Host mode aborted"
  135.            stop
  136.          endif
  137.      endif
  138. Endproc                                         
  139.  
  140. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  141. ;; Function to calculate time difference in minutes between time1 and time2
  142. ;; for calculation of time left for user, ties in <timeleft> and <ontime>
  143. ;; Modification of Difftime function from Toolbox3.scr
  144. ;;
  145.  
  146. Procedure CalcTime string time1,time2,integer minutes
  147.   integer h1,m1,h2,m2     ; <time1> and <time2> in "HH:MM:SS" format
  148.   string hh,mm
  149.   substr time1,1,2,hh              ; get hour part
  150.   substr time1,4,2,mm              ; get minute part
  151.   atoi hh,h1                       ; convert to integer
  152.   atoi mm,m1
  153.   substr time2,1,2,hh              ; get hour,minute and second from <time2>
  154.   substr time2,4,2,mm
  155.   atoi hh,h2
  156.   atoi mm,m2
  157.   if h2<h1                         ; <time2> pass mid-night
  158.     h2 = h2 + 24
  159.   endif
  160.   minutes = (h2-h1)*60 + (m2-m1)
  161. EndProc
  162.  
  163. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  164. ;; New Procedure FULLDATE 
  165. ;; Setup a date string
  166. ;; When full is TRUE, date format e.g. 'Friday December 14, 1990'
  167. ;; When full is FALSE, date format DD-MM-YY e.g. '14-12-90'
  168. ;; Telemate version of date is MM-DD-YY e.g '12-14-90'
  169. ;;
  170.  
  171. Procedure FullDate string strdate,integer full
  172.   string datestr,mm,dd,yy,day,month,year,century
  173.   integer y1,d1,daynum,totaldays,numdays
  174.   date datestr                     ; get date string
  175.   substr datestr,1,2,mm            ; month
  176.   substr datestr,4,2,dd            ; date
  177.   substr datestr,7,2,yy            ; year
  178.   atoi yy,y1
  179.   atoi dd,d1
  180.   if not full
  181.     concat dd,"-"                  ; DD-MM-YY
  182.     concat dd,mm
  183.     concat dd,"-"
  184.     concat dd,yy
  185.     strdate = dd   
  186.   else
  187.     switch mm
  188.       case " 1":
  189.         month = " January "
  190.         numdays = 0
  191.       case " 2":
  192.         month = " February "
  193.         numdays = 31
  194.       case " 3":
  195.         month = " March "
  196.         numdays = 59
  197.       case " 4":
  198.         month = " April "
  199.         numdays = 90
  200.       case " 5":
  201.         month = " May "
  202.         numdays = 120
  203.       case " 6":
  204.         month = " June "
  205.         numdays = 151
  206.       case " 7": 
  207.         month = " July "
  208.         numdays = 181
  209.       case " 8":
  210.         month = " August "
  211.         numdays = 212
  212.       case " 9":
  213.         month = " September "
  214.         numdays = 243
  215.       case "10":
  216.         month = " October "
  217.         numdays = 273
  218.       case "11":
  219.         month = " November "
  220.         numdays = 304
  221.       case "12":
  222.         month = " December "
  223.         numdays = 334
  224.     endswitch
  225.     century = " 19"
  226.     if y1 > 99
  227.       century = " 20"
  228.     endif
  229.     totaldays = (y1-80)*365+1+(y1-80)/4+numdays+d1 
  230.     daynum = totaldays-((totaldays/7)*7)
  231.     switch daynum
  232.       case 0: day = " Monday"
  233.       case 1: day = " Tuesday"
  234.       case 2: day = " Wednesday"
  235.       case 3: day = " Thursday"
  236.       case 4: day = " Friday"
  237.       case 5: day = " Saturday"
  238.       case 6: day = " Sunday"
  239.     endswitch              
  240.     concat day," "
  241.     concat day,month
  242.     concat day,dd
  243.     concat day,","
  244.     concat day,century
  245.     concat day,yy
  246.     strdate = day                  ; DAY MONTH DD, CENTURY YY
  247.   endif                  
  248. Endproc    
  249.  
  250. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  251. ;; New graphic delay routine used in message saving etc.
  252. ;; 
  253.  
  254. Procedure Save
  255.   integer i
  256.   i = 0
  257.   while i < 15
  258.     Echo "."
  259.     delay 3
  260.     i = i+1
  261.   endwhile
  262. Endproc
  263.  
  264. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  265. ;; New procedure LOCALVIEW 
  266. ;; who's online
  267. ;;
  268.  
  269. Procedure LocalView                ; shows user on line locally
  270.   EchoHilite
  271.   EchoColor LOCALBOXCOL
  272.   at 0,0
  273.   print "╔════════════════════════════╡                    ╞════════════════════════════╗"
  274.   print "║ ONLINE:                                                     DATE:            ║"
  275.   print "╚══════════════════════════════════════════════════════════════════════════════╝^M^J"
  276.   EchoColor LOCALCOL
  277.   at 31,0
  278.   print TMHOST
  279.   at 68,1
  280.   print today
  281.   at 10,1
  282.   print username                   ; user online
  283.   EchoNormal
  284. Endproc
  285.  
  286. Procedure HostBegin 
  287.    set zautodownload,off
  288.    set zrecovery,off 
  289.    set usagelog,on
  290.    set baud,INITIALBAUD
  291.    clear key                       ; clear keyboard buffer
  292.    clear com                       ; clear com buffer
  293.    clear text                      ; clear screen
  294.    print
  295.    print
  296.    print "Initializing modem"
  297.    put "ATH0^M~","^)","~ATQ0E0X4^M~",        ; send modem answer string
  298.    delay 5  
  299.    clear text
  300.    EchoColor LOCALBOXCOL
  301.    print "^M^J^M^J^M^J^M^J"
  302.    print "            ┌────────────────────┐ "
  303.    print "        ╒═══╡          Host 2.4  ╞════════════════════╕ "
  304.    print "        │   └────────────────────┘                    │ "
  305.    print "        │           : Waiting for call.....           │ "
  306.    print "        │ ─────────────────────────────────────────── │ "
  307.    print "        │           : Press [   ] to exit Host Mode   │ "
  308.    print "        │             ' ' for configuration           │ "
  309.    print "        │             ' ' for local mode              │ "
  310.    print "        │             ' ' for Offhook local           │ "
  311.    print "        │             [     ] to terminate user       │ "
  312.    print "        ╘═════════════════════════════════════════════╛ "
  313.    print
  314.    EchoColor LOCALCOL
  315.    at 14,6
  316.    print "TELEMATE"
  317.    at 14,8
  318.    print "STATUS"
  319.    at 13,10
  320.    print "OPTIONS"
  321.    at 29,10          ;at 29,10
  322.    print "ESC"
  323.    at 23,11
  324.    print "C"
  325.    at 23,12
  326.    print "L"
  327.    at 23,13
  328.    print "O"
  329.    at 23,14
  330.    print "Alt-H"
  331.    at 44,8
  332.    clear key                       ; clear keyboard buffer
  333.    clear com                       ; clear com buffer     
  334.    
  335.                 ; Do calculations before answering call
  336.  
  337.    FullDate today,FALSE            ; string right way round, not full date
  338.    FullDate wdate,TRUE             ; full date string for welcome
  339.    MSGBASE = MSBASE0               ; message to sysop base
  340.    area = area0
  341.    areanum = 1                     ; message area number (command line)
  342.    access = TRUE 
  343.    usage "Switched to Host mode"
  344. Endproc
  345.  
  346. Procedure HostEnd
  347.   set zautodownload,on
  348.   set zrecovery,on
  349.   clear key                        ; clear keyboard buffer
  350.   clear com                        ; clear com buffer
  351.   clear text
  352.   print
  353.   print "Ending host mode"
  354.   put "^(","~",                    ; send modem init string
  355.   print
  356.   chdir HOSTDIR                    ; change to Host dir
  357.   delete FILEDIR                   ; delete temp file
  358.   chdir TMDIR                      ; change back to Telemate dir
  359.   usage "Terminating Host mode"
  360.   set usagelog,off
  361.   stop
  362. Endproc
  363.  
  364. Procedure Disconnect               ; end session
  365.   delay 10
  366.   if not LOCAL                     ; if remote
  367.     hangup
  368.   endif
  369.   set connection,modem
  370.   LOCAL = FALSE
  371. Endproc
  372.  
  373. Procedure InputChar string ch      ; input and display locally
  374.   repeat                     
  375.   if not LOCAL                   ; get remote characters
  376.      getch ch
  377.     endif
  378.       if LOCAL or not success
  379.         inputch ch
  380.           if success
  381.             if ch = "^["
  382.               HostEnd
  383.             endif
  384.             print ch,
  385.           endif
  386.       endif
  387.    until success or not connected
  388.   Endproc
  389.  
  390. Procedure InputEcho string ch      ; input and echo to remote
  391.   InputChar ch
  392.   if not LOCAL
  393.     put ch,
  394.   endif
  395.   if ch = "^M"                     ; add line feed
  396.     Echo "^J"
  397.   endif
  398. Endproc
  399.  
  400. Procedure DotEcho string ch        ; input and echo "." to remote
  401.   InputChar ch
  402.   if not LOCAL
  403.     if ch="^H" or ch="^M"
  404.       put ch,
  405.     else
  406.       put ".",                     ; echo with "."
  407.     endif
  408.   endif
  409.   if ch = "^M"                     ; add line feed
  410.       Echo "^J"
  411.   endif
  412. Endproc
  413.  
  414. Procedure InputString string str   ; input a string
  415.   string ch
  416.   str = ""
  417.   repeat
  418.     InputEcho ch
  419.     if ch <> "^M"                  ; if return
  420.       if ch = "^H"                 ; if backspace
  421.         if str = ""                ; if string empty
  422.           Echo " "
  423.         else
  424.           Echo " ^H"
  425.         endif
  426.       endif
  427.       concat str,ch
  428.     endif
  429.   until ch = "^M" or not connected
  430.   if str="" or not connected
  431.     success = FALSE
  432.   else
  433.     success = TRUE
  434.   endif
  435. Endproc
  436.  
  437. Procedure InputFilename string filename,dir
  438.   string fname       
  439.   integer pos
  440.   InputString fname                ; input a filename
  441.   repeat
  442.     strpos fname,":",pos           ; strip drive part
  443.       if pos>0                     ; only view file
  444.          strdel fname,1,pos        ; in download dir
  445.       endif
  446.   until pos=0 or not connected
  447.   repeat
  448.     strpos fname,"\",pos           ; strip directory part
  449.       if pos>0
  450.          strdel fname,1,pos
  451.       endif
  452.   until pos=0 or not connected
  453.     if fname="" or not connected
  454.       success = FALSE
  455.       filename = ""
  456.     else
  457.       success = TRUE
  458.       filename = dir
  459.       concat filename,"\"          ; concat <dir>
  460.       strpos filename,"\\",pos
  461.         if pos>0
  462.           strdel filename,pos,1    ; avoid root directory
  463.         endif
  464.       concat filename,fname
  465.     endif
  466. Endproc  
  467.  
  468. Procedure Pause                    ; request a key
  469.   string ch
  470.   Echo "Press [ENTER] to continue "
  471.   InputEcho ch
  472.   Echo "^M^J"
  473.   if ch<>"^M"
  474.     Echo "^M^J"
  475.   endif
  476. Endproc
  477.  
  478. Procedure InputPassword string password
  479.   password = ""
  480.   repeat                           ; input password
  481.     DotEcho ch
  482.       if ch <> "^M"
  483.         if ch = "^H"
  484.           if password = ""
  485.             Echo " "
  486.           else
  487.             Echo " ^H"
  488.           endif
  489.         endif
  490.         concat password,ch
  491.       endif
  492.   until ch = "^M" or not connected
  493.     if password="" or not connected
  494.       success = FALSE
  495.     else
  496.       success = TRUE
  497.     endif
  498. Endproc                                         
  499.  
  500. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  501. ;; Added choice of y/n to [more] in Typefile procedure
  502. ;;
  503.  
  504. Procedure TypeFile string filename,integer more
  505.   string ch                        ; display a file
  506.   integer i
  507.   i = 0
  508.   open filename
  509.   if not success
  510.     Echo "File not found!^M^J"
  511.   else
  512.     while success
  513.       inputch ch
  514.       if success and ch = "^C"     ; operator break
  515.         clear com
  516.         Echo "^M^J"
  517.         exit
  518.       endif
  519.       if not LOCAL
  520.         getch ch
  521.           if success and ch = "^C" ; caller break
  522.             clear com
  523.             Echo "^M^J"
  524.             exit
  525.           endif
  526.       endif
  527.       read s                       ; display a line
  528.       Echo s
  529.       Echo "^M^J"  
  530.       i = i+1
  531.       if i = 22 and more           ; pause if <more> is TRUE
  532.         i = 0
  533.         Echo " More [y/N] "
  534.         InputChar ch
  535.         if ch = "^M" or ch = "N"   ; if no, stop
  536.           clear com
  537.           Echo "^M^J"
  538.           exit
  539.         endif
  540.         Echo "^M                    ^M"
  541.       endif  
  542.     endwhile
  543.     close
  544.     if more
  545.       Pause
  546.     endif
  547.   endif
  548. Endproc            
  549.  
  550. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  551. ;; New Procedure READMAIL
  552. ;; MSGBASE = message area.
  553. ;; At logon a choice is provided to read personal mail from 
  554. ;; messages areas. Checks the 'To    : name' field of message header
  555. ;; and displays appropriate message. An 'R' is placed in the 
  556. ;; 'To   :' string --> 'To  R :' which serves 2 purposes:
  557. ;; 1) The same messages are not displayed at future logons,
  558. ;;    string now changed.
  559. ;; 2) The Sysop can edit out the message once it has been rec'd.
  560. ;;           
  561.  
  562. Procedure ReadMail string MSGBASE
  563.   string toname,s
  564.   integer found,pos,filepos,len,i,more
  565.   savedmsg = FALSE 
  566.   chdir HOSTDIR
  567.   open MSGBASE 
  568.   if not success
  569.     Echo "^M^JSystem Error - no messages available at this time!^M^J"
  570.     print "SYSOP: Cannot find ",MSGBASE," file"
  571.     alarm "SYSOP: Cannot find MESSAGE file, disk full ?"
  572.     return
  573.   endif   
  574.   repeat
  575.   found = FALSE
  576.   read s
  577.   while success and not found      ; locate message 'To:' field
  578.     strpos s,"To     :",pos         
  579.     if pos>0 
  580.       substr s,pos+9,30,toname
  581.       if toname=username           ; username?
  582.         length toname,len          ; length of name
  583.         found = TRUE
  584.         msgread = TRUE       
  585.         tell filepos               ; save file position 
  586.         seek filepos-len-8         ; back to middle of 'To   :' string 
  587.         write "R",                 ; 'R'means message received
  588.       endif                        ; won't be shown on future  
  589.     endif                          ; logons - can be deleted by 
  590.     if not found                   ; Sysop
  591.       read s 
  592.     endif
  593.   endwhile
  594.   if found                       
  595.     i = 0  
  596.     mail = mail+1
  597.     seek filepos-90                ; start of message
  598.     EchoNormal
  599.     Echo "^M^J"
  600.     repeat
  601.       read s                       ; display message
  602.       Echo s
  603.       Echo "^M^J" 
  604.       more = TRUE
  605.       i = i+1
  606.       if i = 22 and more              
  607.         i = 0
  608.         Echo " More [y/N] "        ; pause if long message
  609.         InputChar ch
  610.         if ch = "^C" or ch = "N"
  611.           clear com
  612.           Echo "^M^J"
  613.           exit
  614.         endif
  615.         Echo "^M                    ^M"
  616.       endif  
  617.     until s = " End of Message"   ; end of message
  618.     EchoHilite
  619.     EchoColor SPECIALTEXTCOL
  620.     Echo "Continue [Y/n] "         ; read more mail?
  621.     InputEcho ch
  622.     if ch = "N"
  623.       success = FALSE
  624.     endif
  625.   endif
  626.   until not success
  627.   close
  628.   chdir TMDIR    
  629.   msgmail = TRUE
  630. Endproc  
  631.  
  632. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  633. ;; Changed record length in Checkuser routine, added expert menu
  634. ;; variable TRUE or FALSE for logon 'Menu Mode' and how many 
  635. ;; messages left for user.
  636. ;; Padded with spaces to provide for different password size
  637. ;; when changed by 'Change Password routine'.
  638. ;;
  639.  
  640. Procedure CheckUser string username,password,integer level,xpert,msgs,valid
  641.   integer found,pos1,pos2
  642.   string record,recordname,pass,lev,x,m
  643.   strpos username,";",pos1     ; record format: "first last;password#level
  644.   strpos username,"#",pos2     ;                  %xpert&msgs"
  645.     if pos1>0 or pos2>0 
  646.       valid = FALSE
  647.       return
  648.     endif
  649.   strpos password,";",pos1         ; check password for invalid character
  650.   strpos password,"#",pos2         ;  prevent "#2" etc
  651.     if pos1>0 or pos2>0
  652.       valid = FALSE
  653.       return
  654.     endif
  655.   chdir HOSTDIR
  656.   open "PASSWORD.HST"              ; passwords in PASSWORD.HST
  657.   if not success
  658.      if not success
  659.          create "PASSWORD.HST"
  660.      endif   
  661.        if not success
  662.          Echo "System error, please call again later^M^J"
  663.          print "SYSOP: Cannot create PASSWORD.HST"
  664.          Disconnect
  665.          alarm "SYSOP: Cannot create PASSWORD.HST, disk full ?"
  666.          return
  667.        endif 
  668.   endif    
  669.   found = FALSE
  670.   read record
  671.   while success and not found
  672.     strpos record,";",pos1         ; get fields from the record
  673.     strpos record,"#",pos2
  674.     if pos1>0 and pos2>0
  675.       substr record,1,pos1-1,recordname
  676.       substr record,pos1+1,pos2-pos1-1,pass
  677.       if recordname=username
  678.         found = TRUE
  679.           if pass=password
  680.             valid = TRUE
  681.             substr record,pos2+1,1,lev
  682.             atoi lev,level             ; get userlevel
  683.             substr record,pos2+3,1,x
  684.             atoi x,xpert               ; get menu mode
  685.             substr record,pos2+5,3,m
  686.             atoi m,msgs                ; how many personal messages
  687.           else
  688.             valid = FALSE
  689.           endif
  690.       endif
  691.     endif
  692.     if not found
  693.       read record
  694.     endif
  695.   endwhile
  696.   if not found                     ; new users
  697.     if CLOSESYSTEM
  698.         print "This is a closed board"  
  699.         Disconnect
  700.         return
  701.     else
  702.        open "PASSWORD.HST"            ; else add new user
  703.        seek -1
  704.         write username,";",password,"#",NEWUSERLEVEL,"%",0,"&",0,"                                                                      " 
  705.  
  706.           ; user information record with extra spaces for 'password 
  707.           ; change' length and any further addition of variables 
  708.           ; at a later date. Field length - varies with length of
  709.           ; name or password, however 70 spaces at end
  710.  
  711.        usage "Newuser added to password file"
  712.        level = 1 
  713.        xpert = FALSE
  714.        valid = TRUE
  715.     endif
  716.   endif   
  717.   close
  718.   chdir TMDIR
  719. Endproc                             
  720.  
  721. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  722. ;; New Procedure WRITENEWRECORD
  723. ;; Routine to update PASSWORD.HST file for change of password, menu
  724. ;; mode status or 'add to' or 'take away' number of personal messages.
  725. ;;
  726. ;; ReadMail procedure adds number of messages read at logon,
  727. ;; Entermsg procedure sets addmsg to 1 which is added to msgs.
  728. ;;
  729. ;; rname =  'username' or 'name' for No. of personal messages 
  730. ;; Reads original record and then updates
  731. ;;
  732.  
  733. Procedure WriteNewRecord  string rname
  734.   integer found,filepos,len,pos1,pos2
  735.   string recordname,record,pass,lev,x,m                
  736.   chdir HOSTDIR
  737.   open "PASSWORD.HST"              
  738.   if not success
  739.     Echo "System error, please call again later^M^J"
  740.     print "SYSOP: Cannot locate PASSWORD.HST"
  741.     Disconnect
  742.     alarm "SYSOP: Cannot locate PASSWORD.HST, disk full ?"
  743.     return
  744.   endif
  745.   filepos = 0         
  746.   found = FALSE            
  747.   read record              
  748.   while success and not found      ; locate record
  749.     strpos record,";",pos1
  750.     strpos record,"#",pos2
  751.     if pos1>0 and pos2>0
  752.       substr record,1,pos1-1,recordname  ; locate name
  753.       substr record,pos1+1,pos2-pos1-1,pass
  754.       if recordname=rname               ; is it correct
  755.         found = TRUE                       
  756.         substr record,pos2+1,1,lev      ; get level etc
  757.         substr record,pos2+3,1,x
  758.         substr record,pos2+5,3,m
  759.         atoi m,msgs
  760.         if msgmail
  761.           msgs = msgs - mail
  762.         endif
  763.         if savedmsg  
  764.           msgs = msgs + addmsg
  765.         endif
  766.       endif
  767.     endif 
  768.     length record,len              ; find length of record
  769.     filepos = filepos+len+2        ; add 2 for carriage return
  770.     if not found                   ; and linefeed bytes
  771.       read record
  772.     endif
  773.   endwhile
  774.   if found             
  775.     seek filepos-len-2             ; write over record
  776.     if rname = username            ; logged on user? if another user,
  777.                                    ; keep record update messages
  778.       write rname,";",password,"#",userlevel,"%",xpert,"&",msgs,"                                                  ",
  779.     else
  780.       write rname,";",pass,"#",lev,"%",x,"&",msgs,"                                                   ",
  781.     endif                                            ;
  782.          ; it is important when editing password file 
  783.          ; that field length is kept 'as is'.
  784.          ; spaces are needed in case 'password' is shorter
  785.          ; than original when change of password made.
  786.  
  787.   endif
  788.   close      
  789.   chdir TMDIR    
  790.   msgmail = FALSE
  791. Endproc
  792.  
  793. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  794. ;; New Procedure ENTERMSG
  795. ;; addmsg variable increments number of personal messages 
  796. ;; being left to another user. Number of messages for user is checked
  797. ;; in PASSWORD.HST and updated by WriteNewRecord routine
  798. ;; Messages saved in a a message base file depends on MSBASE variable.
  799. ;; Updates number of messages at head of file.
  800. ;; End of message marker used to detect end of message when reading.
  801. ;; If replying to messages, To 'Name' entry is automatic,
  802. ;; optional same 'Subject'
  803. ;; Save and Kill message commands.
  804. ;; 
  805.  
  806. Procedure EnterMsg                     ; leave message
  807.   integer x,y,num,delpos,filepos       
  808.   integer msgnumber
  809.   string msg,str                       
  810.   filepos = 0                          
  811.   savedmsg = FALSE                     
  812.   clear text
  813.   clear com 
  814.   EchoClearScreen                  ; see screenio.scr
  815.   Echo "^M^J"
  816.   chdir HOSTDIR
  817.   open MSGBASE                     ; open message file
  818.   if not success                   ; e.g Message to Sysop
  819.       create MSGBASE
  820.   endif
  821.   if not success
  822.         Echo "System error, please call again later^M^J"
  823.         print "SYSOP: Cannot create ",MSGBASE," file"
  824.         Disconnect
  825.         alarm "SYSOP: Cannot create MESSAGE file, disk full ?"
  826.         return
  827.       endif  
  828.     read totalmsgs                 ; read number of existing messages
  829.     atoi totalmsgs,num             ; in message file, convert to an
  830.     msgnumber = num                ; integer to write new message No. 
  831.     EchoHilite
  832.     EchoBkColor HEADERBKCOL
  833.     EchoColor HEADERTEXTCOL 
  834.     Echo area                      ; display message base
  835.     Echo "......Press <Ctrl-Z> to End"
  836.     EchoBkColor GENBKCOL
  837.     Echo "^M^JFrom: "
  838.     Echo username
  839.     if MSGBASE = MSBASE0           ; if message to sysop
  840.       name = "Sysop"               ; put To Sysop
  841.       Echo "^M^J"
  842.     else
  843.       str = ""
  844.       Echo "^M^JTo: " 
  845.       EchoNormal 
  846.       if name = ""                 ; enter name of person to
  847.         InputString name           ; send message
  848.       else 
  849.        Echo name
  850.        Echo "^M^J"
  851.       endif
  852.       EchoHilite
  853.       EchoColor HEADERTEXTCOL
  854.     endif
  855.     if subject = ""                ; no subject?
  856.       Echo "Subject: (30 characters max.) " 
  857.       EchoNormal
  858.       InputString subject 
  859.     else  
  860.       Echo "Subject - Press [ENTER] for same or (S) for new subject: "
  861.       EchoNormal                   ; previous subject or new one?
  862.       InputEcho ch 
  863.       if ch = "^M" 
  864.         EchoHilite
  865.         EchoColor HEADERTEXTCOL
  866.         Echo "Subject: "       
  867.         EchoNormal
  868.         Echo subject               ; old subject
  869.       else
  870.         Echo "^M^J"
  871.         EchoHilite
  872.         EchoColor HEADERTEXTCOL
  873.         Echo "Subject: (30 characters max.) "
  874.         EchoNormal
  875.         InputString subject        ; new subject
  876.       endif
  877.       Echo "^M^J"
  878.     endif
  879.     msgnumber = msgnumber + 1      ; next message
  880.     seek filepos                   ; go to head of file
  881.     write msgnumber,"   ",         ; update number of messages
  882.     seek -1                        ; go to end of file 
  883.     tell delpos                    ; save file pointer for K)ill msg
  884.     write "^M^J                                   <-------->                                     " 
  885.     write " Msg#:",msgnumber 
  886.     write " From   : ",username
  887.     write " To     : ",name 
  888.     write " Date   : ",today,"  Time: ",now,"  Subject: ",subject  
  889.     write                          ; write header to file
  890.     tell filepos                   ; save file pointer to 
  891.     repeat                         ; control layout of message
  892.       InputEcho msg                ; get character
  893.       wherex x
  894.       if msg = " " and x>70
  895.         Echo "^M^J" 
  896.         msg = "^M^J "              ; space needed in message for
  897.         filepos = filepos+2        ; placement of linefeed character
  898.       else                         ; in file
  899.         if msg = "^H"              ; if backspace character, go back
  900.           filepos = filepos-1      ; 1 byte and write space
  901.           seek filepos
  902.           msg = " "
  903.         else
  904.           seek filepos             ; else go back and write character
  905.           filepos = filepos+1
  906.         endif
  907.         if msg = "^M"              ; if carriage return
  908.           msg = "^M^J"             ; linefeed in file
  909.           filepos = filepos+1
  910.         endif
  911.       endif
  912.       write msg,
  913.     until msg = "^Z"               ; end message
  914.     seek filepos-1                 ; write over end of file character
  915.     write "^M^J^M^J                                                  " 
  916.                                    ; record area for reply numbers
  917.     write " End of Message"       ; marker for read message routine
  918.     EchoHilite
  919.     EchoColor HEADERTEXTCOL
  920.     repeat     
  921.       Echo "^M^J^M^J S)ave or K)ill Message? "
  922.       InputEcho ch
  923.       if ch = "K"                  ; write over message
  924.         clear com
  925.         num = 0
  926.         seek delpos
  927.         read str
  928.         while success 
  929.           num = num+1
  930.           read str
  931.         endwhile
  932.         seek delpos                ; file position to delete from
  933.         write "^M^J"
  934.         while num>0
  935.         write "............................................................."
  936.           num = num-1              ; file can be edited later
  937.         endwhile
  938.         msgnumber = msgnumber-1    ; reduce message number
  939.         seek 0
  940.         write msgnumber,"   ",     ; spaces required in case of 10 -> 9 etc
  941.         Echo "^M^JMessage Deleted "
  942.         Save
  943.       elseif ch = "S"
  944.         clear com 
  945.         Echo "^M^JMessage Saved "
  946.         Save                 
  947.         If MSGBASE <> MSBASE0      ; if not Message to Sysop
  948.           addmsg = addmsg + 1               
  949.           savedmsg = TRUE          ; variables for WriteNewRecord
  950.         endif
  951.       endif
  952.     until ch = "S" or ch = "K"  
  953.     close 
  954.     chdir TMDIR
  955. Endproc
  956.  
  957. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  958. ;; New Procedure READMSG
  959. ;; S)can message headers, V)iew a selected message or press 
  960. ;; [ENTER] for next message, also can R)eply to message or Q)uit.
  961. ;; Total number of messages in selected message base displayed.
  962. ;; Keep 'Name' and 'Subject' for R)eply.
  963. ;; Number of replies to message shown as 'See Msg: #1, #2, #3 etc'.
  964. ;;
  965.  
  966. Procedure ReadMsg                  ; read messages
  967.   integer num,total,found,len,filepos,n,i,more,pos
  968.   string line1,line2,line3,line4,s,selnum,nextmsg
  969.  
  970.   Procedure ShowMsg                ; show message, used by V)iew
  971.     read s                         ; and [ENTER] for next message
  972.     while success and not found
  973.       strpos s,"Msg#:",pos         ; find message No.
  974.       if pos>0
  975.         substr s,pos+5,4,msgnum
  976.         if msgnum = selnum         ; correct message?
  977.           found = TRUE             
  978.         endif
  979.       endif
  980.       if not found                 ; no read next
  981.         read s
  982.       endif
  983.     endwhile                       
  984.     if found                       
  985.       i = 0            
  986.       name = "" 
  987.       subject = ""             
  988.       repeat
  989.         read s                     ; display message
  990.         strpos s,"From   :",pos 
  991.         if pos>0                   ; who entered message for reply
  992.           substr s,pos+9,30,name 
  993.         endif
  994.         strpos s,"Subject:",pos    ; get existing subject
  995.         if pos>0
  996.           substr s,pos+9,30,subject
  997.         endif
  998.         Echo s
  999.         Echo "^M^J" 
  1000.         more = TRUE
  1001.         i = i+1
  1002.         if i = 22 and more              
  1003.           i = 0
  1004.           Echo " More [y/N] "       ; pause if long message
  1005.           InputChar ch
  1006.           if ch = "^C" or ch = "N"
  1007.             clear com
  1008.             Echo "^M^J"
  1009.             exit
  1010.           endif
  1011.           Echo "^M                    ^M"
  1012.         endif  
  1013.       until s = " End of Message"   ; end of message
  1014.       EchoHilite
  1015.       EchoColor HEADERTEXTCOL
  1016.       Echo "^M^JR)eply ? or [ENTER] to continue "  ; reply to message?
  1017.       InputEcho ch
  1018.       repeat                    
  1019.         if ch = "R"
  1020.           clear com
  1021.           n = total+1              
  1022.           itoa n,nextmsg           ; next message number for reply field
  1023.           tell filepos
  1024.           seek filepos-70          ; start of reply number field
  1025.           read s
  1026.           strpos s, "See Msg:",pos ; check for earlier reply
  1027.           if pos>0                  
  1028.             strpos s,"    ",pos    ; yes locate spaces
  1029.             if pos > 2             ; i.e. after See Msg #
  1030.               length s,len         ; find toal length including spaces
  1031.               strdel s,pos,len-pos+1 ; delete spaces
  1032.               concat s,", "        ; add comma
  1033.               concat s,nextmsg     ; add next reply message number
  1034.               seek filepos-70      ; head of field
  1035.               write s,             
  1036.             endif
  1037.           else                     ; empty string (all spaces)
  1038.             seek filepos-70        ; head of record
  1039.             write "  See Msg: ",n, ; message number of first reply
  1040.           endif
  1041.            reply = TRUE            ; for return to message base
  1042.            addmsg = 0
  1043.            EnterMsg
  1044.            WriteNewRecord name     ; update mail
  1045.         else                       
  1046.           clear com
  1047.           exit
  1048.         endif
  1049.       until ch = "R" or ch = "^M"
  1050.     endif
  1051.   Endproc
  1052.  
  1053.   clear com                        ; main routine
  1054.   clear text
  1055.   EchoClearScreen  
  1056.   reply = FALSE
  1057.   num = 0
  1058.   pos = 0
  1059.   chdir HOSTDIR
  1060.   open MSGBASE 
  1061.   if not success
  1062.     Echo "^M^JSorry no messages available at this time!^M^J"
  1063.     print "SYSOP: Cannot find ",MSGBASE," file"
  1064.     alarm "SYSOP: Cannot find MESSAGE file, disk full ?"
  1065.     return
  1066.   endif            
  1067.   while success 
  1068.     clear text
  1069.     clear com
  1070.     seek 0                         ; go to head of file 
  1071.     read totalmsgs                 ; get total No. of messages
  1072.     atoi totalmsgs,total
  1073.     EchoClearScreen
  1074.     EchoHilite
  1075.     EchoColor HEADERTEXTCOL
  1076.     Echo " Number of Messages : "  ; display number of messages
  1077.     Echo totalmsgs
  1078.     Echo "^M^J S)can   Q)uit   V)iew  or [ENTER] for next msg : "
  1079.     InputEcho ch
  1080.     Echo "^M^J^M^J"        
  1081.     switch ch    
  1082.       case "S":                    ; scan through messages 
  1083.           EchoNormal
  1084.           i = 0 
  1085.           while success
  1086.             read line1             ; start at line 1
  1087.             strpos line1,"Msg#:",pos ; and locate message No. line
  1088.             if pos > 0 
  1089.               read line2
  1090.               read line3 
  1091.               read line4
  1092.               Echo line1           ; show header of message
  1093.               Echo "^M^J"
  1094.               Echo line2 
  1095.               Echo "^M^J"
  1096.               Echo line3
  1097.               Echo "^M^J"
  1098.               Echo line4
  1099.               Echo "^M^J^M^J"
  1100.               i = i + 5
  1101.             endif
  1102.             more = TRUE
  1103.             if i >= 20 and more    ; pause if more messages        
  1104.               i = 0
  1105.               Echo " More [y/N] "
  1106.               InputChar ch
  1107.               if ch = "^C" or ch = "N"
  1108.                 clear com
  1109.                 Echo "^M^J"
  1110.                 exit
  1111.               endif
  1112.               Echo "^M                    ^M"
  1113.             endif  
  1114.           endwhile  
  1115.           Pause 
  1116.       case "Q":                    ; quit message base    
  1117.         close
  1118.         chdir TMDIR  
  1119.         return                       
  1120.       case "^M":                   ; [ENTER] for next message
  1121.         num = num + 1              ; increment to next message
  1122.         if num > total             ; last message? 
  1123.           EchoHilite
  1124.           Echo HEADERTEXTCOL
  1125.           Echo "^M^JThere are no more messages"
  1126.           delay 10
  1127.         else                       ; else show message
  1128.           EchoNormal     
  1129.           found = FALSE 
  1130.           itoa num,selnum          
  1131.           Echo "Msg#: "
  1132.           Echo selnum
  1133.           Echo "^M^J"
  1134.           ShowMsg
  1135.           if reply
  1136.             return
  1137.           endif
  1138.         endif
  1139.       case "V":                    ; view message
  1140.         Echo "^M^JMsg No.? "
  1141.         Inputstring selnum         ; select number of message
  1142.         atoi selnum,num 
  1143.         EchoColor HILITECOL
  1144.         if num > total  or num = 0 ; check validity of selection No.
  1145.           print "^M^JThere are ",totalmsgs," messages only!!!"
  1146.           delay 10
  1147.         else
  1148.           EchoNormal     
  1149.           found = FALSE 
  1150.           Echo "^M^J"
  1151.           seek 6                   ; up to 5 figures (total msgs)
  1152.           ShowMsg                  ; show message
  1153.           if reply
  1154.             return
  1155.           endif
  1156.         endif
  1157.     endswitch
  1158.   endwhile
  1159.   close         
  1160.   chdir TMDIR
  1161. Endproc
  1162.  
  1163.  
  1164. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1165. ;; New Procedure ACCESSMSG
  1166. ;; Allows access to Message Areas, keeps selection 
  1167. ;; Only displays configured message areas.
  1168. ;; Once selected can R)ead, E)nter or Q)uit, ? for help
  1169. ;;                                                     
  1170.  
  1171. Procedure AccessMsg                ; message area listing 
  1172.    string a
  1173.    integer c,n,quit
  1174.    c = 1
  1175.    clear com 
  1176.    clear key
  1177.    clear text
  1178.    EchoClearScreen
  1179.    EchoHilite
  1180.    EchoColor SPECIALTEXTCOL         
  1181.    Echo "^M^J                           ┌───────────────────────┐^M^J"
  1182.    Echo "                           │ Message Area Listings │^M^J" 
  1183.    Echo "                           └───────────────────────┘^M^J"      
  1184.    EchoNormal 
  1185.    while c < COUNT+1               ; only display areas as read
  1186.      switch c                      ; from TMHCFG.HST
  1187.        case 1:   
  1188.          Echo "^M^J                          1.  "
  1189.          Echo area0 
  1190.        case 2:
  1191.          Echo "^M^J                          2.  " 
  1192.          Echo area1 
  1193.        case 3:
  1194.          Echo "^M^J                          3.  "
  1195.          Echo area2 
  1196.        case 4:
  1197.          Echo "^M^J                          4.  "
  1198.          Echo area3
  1199.        case 5:
  1200.          Echo "^M^J                          5.  " 
  1201.          Echo area4   
  1202.        case 6:
  1203.          Echo "^M^J                          6.  "
  1204.          Echo area5 
  1205.        case 7:
  1206.          Echo "^M^J                          7.  "
  1207.          Echo area6
  1208.        case 8:
  1209.          Echo "^M^J                          8.  " 
  1210.          Echo area7
  1211.        case 9:
  1212.          Echo "^M^J                          9.  "
  1213.          Echo area8
  1214.        case 10:
  1215.          Echo "^M^J                          10. "
  1216.          Echo area9 
  1217.      endswitch 
  1218.      c = c+1
  1219.    endwhile
  1220.    n = areanum                     ; save area number 
  1221.    Echo "^M^J^M^JSelect Area Number desired, press [Enter]: "
  1222.    EchoHilite 
  1223.    InputString a 
  1224.    atoi a,areanum
  1225.    if areanum > COUNT
  1226.      Echo "^M^JArea NOT available!!"
  1227.      areanum = n                   ; original areanum
  1228.      delay 10                       
  1229.      return
  1230.    else                            ; once selected
  1231.      switch areanum                ; setup message base and 
  1232.        Case 1:                     ; appropriate file
  1233.          MSGBASE = MSBASE0
  1234.          area = area0
  1235.          areanum = 1               ; command line area number   
  1236.        Case 2:
  1237.          MSGBASE = MSBASE1
  1238.          area = area1
  1239.          areanum = 2                  
  1240.        Case 3: 
  1241.          MSGBASE = MSBASE2
  1242.          area = area2 
  1243.          areanum = 3                  
  1244.        Case 4:
  1245.          MSGBASE = MSBASE3
  1246.          area = area3
  1247.          areanum = 4                  
  1248.        Case 5:
  1249.          MSGBASE = MSBASE4
  1250.          area = area4
  1251.          areanum = 5                  
  1252.        Case 6: 
  1253.          MSGBASE = MSBASE5
  1254.          area = area5 
  1255.          areanum = 6                  
  1256.        Case 7:
  1257.          MSGBASE = MSBASE6
  1258.          area = area6
  1259.          areanum = 7                  
  1260.        Case 8: 
  1261.          MSGBASE = MSBASE7
  1262.          area = area7
  1263.          areanum = 8                  
  1264.        Case 9:
  1265.          MSGBASE = MSBASE8
  1266.          area = area8 
  1267.          areanum = 9                  
  1268.        Case 10:
  1269.          MSGBASE = MSBASE9
  1270.          area = area9
  1271.          areanum = 10                  
  1272.      endswitch   
  1273.      quit = FALSE
  1274.      while not quit
  1275.        EchoClearScreen
  1276.        EchoHilite
  1277.        EchoColor SPECIALTEXTCOL
  1278.        Echo "^M^J^M^JMESSAGE AREA - "
  1279.        Echo area 
  1280.        Echo "^M^JE)nter   R)ead   Q)uit ( ? for commands):" 
  1281.        InputEcho ch
  1282.        switch ch
  1283.          Case "E":                 ; Enter a message
  1284.            name = ""
  1285.            subject = ""
  1286.            addmsg = 0
  1287.            EnterMsg
  1288.            WriteNewRecord name
  1289.          Case "R":                 ; read message  
  1290.            if MSGBASE = MSBASE0    ; message to sysop
  1291.              If userlevel = SYSOPLEVEL  ; read by sysop only
  1292.                ReadMsg
  1293.              else
  1294.                Echo "^M^J^M^JThese are PRIVATE messages!"
  1295.                delay 10 
  1296.              endif
  1297.            else
  1298.              ReadMsg               ; other areas
  1299.            endif                     
  1300.          Case "?":                 ; show available commands
  1301.            EchoNormal
  1302.            Echo "^M^J^M^JE)nter Messages --> S)ave or K)ill"
  1303.            Echo "^M^JR)ead Messages  --> S)can  Q)uit  V)iew  or" 
  1304.            Echo "^M^J                --> [ENTER] for next Message" 
  1305.            Echo "^M^J                --> Msg# and/or R)eply"
  1306.            Echo "^M^JQ)uit           --> Quit message base"
  1307.            Echo "^M^J?               --> This help screen^M^J^M^J"
  1308.            Pause
  1309.          Case "Q":
  1310.            quit = TRUE
  1311.        endswitch        
  1312.      endwhile 
  1313.    endif
  1314. Endproc
  1315.  
  1316. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1317. ;; New Procedure TRASH
  1318. ;; Checks for bad passwords in TRASHCAN.HST
  1319. ;; Sysop edited file - just add passwords not to be accepted
  1320. ;; by system
  1321. ;;
  1322.  
  1323. Procedure Trash                    ; test for bad passwords
  1324.   string s
  1325.   chdir HOSTDIR
  1326.   open "TRASHCAN.HST"              ; trash password file
  1327.   if not success
  1328.     Echo "System error, please call again later^M^J"
  1329.     print "SYSOP: Cannot open TRASHCAN.HST"
  1330.     Disconnect
  1331.     alarm "SYSOP: Cannot open TRASHCAN.HST, disk full ?"
  1332.     return
  1333.   endif
  1334.   while success
  1335.     read s                         ; read word
  1336.     if password = s                ; if password trash, hangup
  1337.       access = FALSE
  1338.     endif  
  1339.   endwhile
  1340.   close 
  1341.   chdir TMDIR
  1342. Endproc
  1343.                                               
  1344. Procedure List                 ; display Filelist
  1345.   string cmd
  1346.   cmd = "type "                           ;"DIR >"
  1347.   clear com
  1348.   clear text
  1349.   concat cmd,DOWNLOADDIR
  1350.   concat cmd,"\files.lst >"
  1351.   concat cmd,FILEDIR                       ; DIR >\HOST.DIR
  1352.   dos "echo One Moment, Loading File List"
  1353.   dos cmd                                  ; shell to DOS
  1354.   TypeFile FILEDIR,TRUE                    ; display \HOST.DIR
  1355.   chdir TMDIR
  1356. Endproc
  1357.                                        
  1358. Procedure Directory                ; display download directory
  1359.   string cmd
  1360.   cmd = "dir "
  1361.   clear com
  1362.   clear text
  1363.   concat cmd,DOWNLOADDIR
  1364.   concat cmd,">"
  1365.   concat cmd,FILEDIR               ; DIR >\HOST.DIR
  1366.   chdir DOWNLOADDIR
  1367.   dos cmd                          ; shell to DOS
  1368.   TypeFile FILEDIR,TRUE            ; display \HOST.DIR
  1369.   chdir TMDIR
  1370. Endproc
  1371.  
  1372. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1373. ;; Addition of Bimodem to Protocol selection.
  1374. ;;
  1375.  
  1376. Procedure Bimod                    ; bimodem transfer
  1377.   clear text
  1378.   clear com 
  1379.   EchoColor GENTEXTCOL
  1380.   Echo "Set-up YOUR end NOW........I am Ready for the transfer.^M^J"
  1381.   Echo "When your end prompts to start my end: press [ENTER]..."
  1382.    InputEcho ""
  1383.    dos "BIMODEM "
  1384.    clear text
  1385.    dos "del Bimodem.Pth"
  1386.    alarm " * Bimodem Transfer(s) Completed * "
  1387.    Echo "^M^J ** Bimodem Transfer Completed ** "
  1388. Endproc
  1389.  
  1390. Procedure FileTransfer string mode,protocol,filename
  1391.   print "^M^JPlease start your transfer procedure or press Ctrl-X to abort^M^J"
  1392.     if mode = "r"
  1393.       if filename=""               ; receive batch files
  1394.         receive protocol
  1395.       else
  1396.         receive protocol,filename  ; receive single file
  1397.       endif
  1398.     else
  1399.       send protocol,filename       ; send multiple files
  1400.     endif       
  1401.     clear com
  1402.     if success
  1403.       Echo "File transfer completed!^M^J"
  1404.     else
  1405.       Echo "File transfer aborted!^M^J"
  1406.     endif
  1407.     Pause
  1408. Endproc
  1409.  
  1410. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1411. ;; New Procedure QUESTIONNAIRE
  1412. ;; Newuser fills out questionnaire, saved to file USER.HST.
  1413. ;; Keep list of users, can be edited if status changes.
  1414. ;;                                                    
  1415.  
  1416. Procedure Questionnaire            ; new users file
  1417.   string address,city,pcode,modemnum,phonenum,datanum,check
  1418.   integer filepos
  1419.   clear com
  1420.   clear text 
  1421.   EchoColor GENTEXTCOL
  1422.   repeat
  1423.   If userlevel < NUSERLEVEL
  1424.     Echo "^M^J You are not found in the user file.^M^J"
  1425.   endif
  1426.   Echo " Would you like to register? [Y/n] : "
  1427.     InputEcho ch
  1428.     if ch = "Y"                          
  1429.       clear com
  1430.       clear text
  1431.       EchoClearScreen
  1432.       EchoHilite
  1433.       EchoColor SPECIALTEXTCOL
  1434.       Echo "^M^J                       ┌────────────────────────────┐^M^J"
  1435.       Echo "                       │ Registration Questionnaire │^M^J" 
  1436.       Echo "                       └────────────────────────────┘^M^J"      
  1437.       chdir HOSTDIR
  1438.       open "USER.HST"              ; user information file
  1439.       if not success
  1440.         create "USER.HST"
  1441.       endif   
  1442.       if not success
  1443.         Echo "System error, please call again later^M^J"
  1444.         print "SYSOP: Cannot create USER.HST"
  1445.         Disconnect
  1446.         alarm "SYSOP: Cannot create USER.HST, disk full ?"
  1447.         return
  1448.       endif
  1449.       seek -1
  1450.       write "**** NEW USER *****"
  1451.       write "NAME:     ",username 
  1452.       tell filepos
  1453.       write "PASSWORD: ",password,"                "
  1454.       write "LEVEL:    ",userlevel
  1455.       repeat
  1456.         Echo "^M^JWhat is your street address ?"
  1457.         Echo "^M^J--->"
  1458.         InputString address
  1459.         Echo address
  1460.         Echo " [y/N] "
  1461.         InputEcho check
  1462.         if check = "N"
  1463.           address = ""
  1464.         endif
  1465.       until check = "Y"
  1466.       write "ADDRESS:  ",address 
  1467.         repeat
  1468.         Echo "^M^J^M^JWhat City are you calling from ? --> "
  1469.         InputString city
  1470.         Echo city
  1471.         Echo " [y/N] "
  1472.         InputEcho check
  1473.         if check = "N"
  1474.           city = ""
  1475.         endif
  1476.       until check = "Y"
  1477.       write "CITY:     ",city
  1478.         repeat
  1479.         Echo "^M^J^M^JWhat is your zip code ? --> "
  1480.         InputString pcode
  1481.         Echo pcode
  1482.         Echo " [y/N] "
  1483.         InputEcho check
  1484.         if check = "N"
  1485.           pcode = ""
  1486.         endif
  1487.       until check = "Y"
  1488.       write "ZIPCODE: ",pcode
  1489.       repeat
  1490.         Echo "^M^J^M^JModem Brand & Speed? --> "
  1491.         InputString modemnum
  1492.         Echo modemnum
  1493.         Echo " [y/N] "
  1494.         InputEcho check
  1495.         if check = "N"
  1496.           modemnum = ""
  1497.         endif
  1498.       until check = "Y" 
  1499.       write "MODEM BRAND & SPEED. ",modemnum
  1500.       repeat
  1501.         Echo "^M^J^M^JVoice phone No. ? --> "
  1502.         InputString phonenum
  1503.         Echo phonenum
  1504.         Echo " [y/N] "
  1505.         InputEcho check
  1506.         if check = "N"
  1507.           phonenum = ""
  1508.         endif
  1509.       until check = "Y"
  1510.       write "PHONE No. ",phonenum
  1511.       repeat
  1512.         Echo "^M^J^M^JData Phone No. or None? --> "
  1513.           InputString datanum
  1514.           Echo datanum
  1515.           Echo " [y/N] "
  1516.           InputEcho check
  1517.           if check = "N"
  1518.             datanum = ""
  1519.           endif
  1520.       until    check = "Y"
  1521.       write "DATA No. ",datanum
  1522.       write "^M^J───────────────────────────────────────────────────────────────────────────────" 
  1523.       repeat
  1524.         Echo "^M^J^M^JPick a password (4 - 16 characters max): "
  1525.         Echo "^M^J--->"
  1526.         InputString password
  1527.         Echo password
  1528.         Echo " [y/N] "
  1529.         InputEcho check
  1530.         if check = "N"
  1531.           password = ""
  1532.         endif
  1533.       until check = "Y" 
  1534.       seek filepos                 ; update password
  1535.       write "PASSWORD: ",password,
  1536.       close
  1537.       chdir TMDIR 
  1538.       clear com
  1539.       clear text
  1540.       Echo "^M^JRegistration information saved " 
  1541.       Save
  1542.       Echo "^M^J^M^JThankyou for filling out the questionnaire.^M^J^M^J"
  1543.       Usage "User filled out Questionnaire......"
  1544.       if userlevel < NUSERLEVEL
  1545.         Echo "If you have provided the correct information, you^M^J"
  1546.         Echo "will be elevated to User STATUS within a day or so.^M^J^M^J^M^J"
  1547.       endif
  1548.       Pause
  1549.     else                                   
  1550.       exit
  1551.     endif
  1552.     Echo "^M^J"
  1553.   until ch = "Y" or ch = "N"       ; repeat until either Y/N   
  1554. Endproc
  1555.  
  1556. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1557. ;; New Procedure WELCOMEUSER
  1558. ;; welcome user after logon, show time, date and No. of personal
  1559. ;; messages.
  1560. ;; choice of reading personal messages at logon
  1561.  
  1562. Procedure WelcomeUser
  1563.   string wname,message 
  1564.   integer len,c,pos
  1565.   c = 1
  1566.   time now
  1567.   strdel now,6,3
  1568.   wname = username
  1569.   length wname,len 
  1570.   strpos wname," ",pos
  1571.   if pos>0                         ; welcome user by
  1572.     strdel wname,pos+1,len-pos     ; first name 
  1573.   endif
  1574.   EchoClearScreen
  1575.   EchoHilite
  1576.   EchoColor SPECIALTEXTCOL
  1577.   Echo "^M^J^M^JHello "
  1578.   EchoColor HILITECOL
  1579.   Echo wname
  1580.   EchoColor SPECIALTEXTCOL
  1581.   Echo "welcome to the "
  1582.   Echo TMHOST
  1583.   print "^M^J^M^JThe time is ",now," on", wdate   ; show time and date
  1584.   put "^M^J^M^JThe time is ",now," on", wdate
  1585.   if msgs = 0                                    ; any mail?
  1586.     Echo "^M^JSorry there is no mail for you today"
  1587.   else 
  1588.     if msgs > 1                    ; yes, show how many
  1589.       message = " messages "
  1590.       print "^M^JYou have ",msgs," personal",message,"to read"
  1591.       put "^M^JYou have ",msgs," personal",message,"to read"
  1592.     else 
  1593.       message = " message "
  1594.       print "^M^JYou have ",msgs," personal",message,"to read"
  1595.       put "^M^JYou have ",msgs," personal",message,"to read"
  1596.     endif
  1597.     Echo "^M^J^M^JRead personal mail [Y/n] "   ; offer choice
  1598.     InputEcho ch                               ; to read mail
  1599.     if ch = "Y"  
  1600.       mail = 0
  1601.       msgread = FALSE 
  1602.       while c < COUNT+1            ; check  all available
  1603.         switch c                   ; message areas
  1604.           case 1:
  1605.             Echo "^M^JMessage area 1 - "
  1606.             Echo area0
  1607.             ReadMail MSBASE0
  1608.           case 2:
  1609.             Echo "^M^JMessage area 2 - "
  1610.             Echo area1
  1611.             ReadMail MSBASE1
  1612.           case 3:
  1613.             Echo "^M^JMessage area 3 - "
  1614.             Echo area2
  1615.             ReadMail MSBASE2
  1616.           case 4:      
  1617.             Echo "^M^JMessage area 4 - "
  1618.             Echo area3
  1619.             ReadMail MSBASE3
  1620.           case 5:
  1621.             Echo "^M^JMessage area 5 - "
  1622.             Echo area4
  1623.             ReadMail MSBASE4
  1624.           case 6:
  1625.             Echo "^M^JMessage area 6 - "
  1626.             Echo area5
  1627.             ReadMail MSBASE5
  1628.           case 7:
  1629.             Echo "^M^JMessage area 7 - "
  1630.             Echo area6
  1631.             ReadMail MSBASE6
  1632.           case 8: 
  1633.             Echo "^M^JMessage area 8 - "
  1634.             Echo area7
  1635.             ReadMail MSBASE7
  1636.           case 9:
  1637.             Echo "^M^JMessage area 9 - "
  1638.             Echo area8
  1639.             ReadMail MSBASE8
  1640.           case 10:
  1641.             Echo "^M^JMessage area 10 - "
  1642.             Echo area9
  1643.             ReadMail MSBASE9
  1644.         endswitch 
  1645.         c = c+1
  1646.       endwhile
  1647.       if msgread
  1648.        Echo "^M^JEnd of personal messages"   
  1649.       endif
  1650.       WriteNewRecord username      ; update record (msgs left)
  1651.     endif                          ; 0 if read all msgs
  1652.   endif
  1653.   Echo "^M^J^M^J"
  1654.   EchoNormal
  1655.   Pause
  1656. Endproc
  1657.  
  1658. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1659. ;; Modified WaitForCall procedure with ANSI variable ANSIREMOTE
  1660. ;; to detect use of Ansi Graphics at logon.
  1661. ;; Beefed up password checking routine, e.g. look for rubbish
  1662. ;; passwords, too may attempts at password.
  1663. ;; Set time on line variable depending on user level.
  1664. ;;
  1665.  
  1666. Procedure WaitForCall              ; wait for connected
  1667.   integer i,len,valid,exist,baudrate
  1668.   set connection,modem
  1669.   LOCAL = FALSE
  1670.   xpert = FALSE
  1671.   while not connected              ; wait for carrier signal
  1672.     inputch ch                     ; sysop commands
  1673.       if success
  1674.         switch ch
  1675.           case "^[":               ; abort
  1676.             HostEnd
  1677.           case "L":                ; local mode
  1678.             set connection,computer  ; this will set connected = 1
  1679.             LOCAL = TRUE
  1680.           case "O":
  1681.             put "~ATH1M0^M~",
  1682.             delay 5
  1683.             set connection,computer  ; this will set connected = 1
  1684.             LOCAL = TRUE
  1685.           case "C":                ; configuration
  1686.             script "TMHCFG"        ; chain to TMHCFG.SCR
  1687.         endswitch
  1688.       endif
  1689.   endwhile
  1690.   if not LOCAL and DETECTBAUD
  1691.     waitfor "CONNECT^M","CONNECT 1200","CONNECT 2400","CONNECT 9600","CONNECT 14400","CONNECT 19200","CONNECT 38400",10
  1692.     if found
  1693.       switch found
  1694.         case 1: baudrate = 1200
  1695.         case 2: baudrate = 2400
  1696.         case 3: baudrate = 9600
  1697.         case 4: baudrate = 14400
  1698.         case 5: baudrate = 19200
  1699.         case 6: baudrate = 38400
  1700.       endswitch
  1701.       set baud,baudrate
  1702.       Echo "Connected at "
  1703.       if not LOCAL
  1704.         put baudrate,"^M^J"
  1705.       endif
  1706.       print baudrate
  1707.     endif
  1708.   endif
  1709.   Echo "^M^J"
  1710.   delay 5
  1711.   clear com
  1712.   clear text
  1713.   delay 5
  1714.   EchoNormal
  1715.   chdir HOSTDIR
  1716.   TypeFile "WELCOME.HST",FALSE     ; display welcome message
  1717.   repeat
  1718.     Echo "Does your Terminal support ANSI Graphics Y/N ?: "
  1719.     InputEcho ch
  1720.     if ch = "Y"
  1721.       ANSIREMOTE = TRUE            ; for ansi display to remote
  1722.     else                           
  1723.       ANSIREMOTE = FALSE
  1724.     endif
  1725.       Echo "^M^J"
  1726.   until ch = "Y" or ch = "N"       ; repeat until either Y/N           
  1727.   chdir TMDIR
  1728.   i = 1
  1729.   len = 0
  1730.   username = ""                    ; enter name (at most 3 times)
  1731.   while i<=3 and len<4 and connected
  1732.     EchoColor GENTEXTCOL
  1733.     Echo "Please enter your First and Last name: "
  1734.     EchoHilite
  1735.     EchoColor HILITECOL
  1736.     InputString username
  1737.     i = i+1
  1738.     length username,len            ; check the length of name
  1739.     if len<4
  1740.       Echo "Name too short, please try again^M^J^M^J"
  1741.     else
  1742.       EchoNormal
  1743.       EchoColor GENTEXTCOL
  1744.       Echo username
  1745.       Echo " [Y/n]? "
  1746.       EchoHilite
  1747.       EchoColor HILITECOL
  1748.       InputString ch
  1749.       if ch="n"
  1750.         len=0
  1751.       endif
  1752.     endif
  1753.   endwhile
  1754.   if len<4 and connected
  1755.     Echo "Goodbye^M^J"
  1756.     Disconnect
  1757.     Usage "User disconnected - name too short"
  1758.   else 
  1759.     i = 1
  1760.     len = 0
  1761.     password = ""                  ; enter password (at most 3 times)
  1762.     while i<=3 and len<4 and connected
  1763.       EchoNormal
  1764.       EchoColor GENTEXTCOL
  1765.       Echo "Password: "
  1766.       EchoHilite
  1767.       EchoColor HILITECOL
  1768.       InputPassword password
  1769.       Trash
  1770.         if not access 
  1771.           Echo "^M^JGarbage Passwords not accepted, access denied!^M^J" 
  1772.           Disconnect
  1773.           Usage "User not accepted - garbage password!"
  1774.           return
  1775.         endif
  1776.       i = i+1
  1777.       length password,len          ; check the length of password
  1778.       if len<4
  1779.         Echo "Password too short, please try again^M^J^M^J"
  1780.       endif 
  1781.     endwhile
  1782.     if len>=4                     ; check password and get user level
  1783.       i = 1
  1784.       while i<=3
  1785.         CheckUser username,password,userlevel,xpert,msgs,valid  
  1786.         if not valid              ; check validity, 3 attempts
  1787.           Echo "Does not match password on file, try again : " 
  1788.           InputPassword password
  1789.         endif 
  1790.         i = i+1
  1791.       endwhile
  1792.     endif
  1793.     if len<4 and connected         ; length wrong, disconnect
  1794.       Echo "Invalid password, access denied^M^J^M^J"
  1795.       Disconnect
  1796.       return  
  1797.       Usage "User disconnected - invalid password"
  1798.     endif
  1799.     if not valid and connected     ; not valid, disconnect
  1800.       Echo "Too many attempts, access denied^M^J^M^J"
  1801.       Disconnect
  1802.       return
  1803.       Usage "User disconnected - Too many attempts at password"
  1804.     else
  1805.       if userlevel = SYSOPLEVEL    ; set logon time
  1806.         ontime = 180
  1807.       elseif userlevel = NUSERLEVEL
  1808.         ontime = 90
  1809.       elseif userlevel < NUSERLEVEL
  1810.         ontime = 20
  1811.         Questionnnaire
  1812.       endif 
  1813.       usage "Logon by:"
  1814.       usage username 
  1815.       time logontime               ; time at user's logon
  1816.       EchoNormal
  1817.       clear com
  1818.       clear text
  1819.       chdir HOSTDIR                ; display notice
  1820.       FileExist "HNOTICE.HST",exist
  1821.       if exist
  1822.         Echo "^M^J"
  1823.         TypeFile "HNOTICE.HST",TRUE
  1824.       endif
  1825.     endif
  1826.   endif 
  1827.   chdir TMDIR
  1828.   WelcomeUser
  1829. Endproc
  1830.  
  1831. Procedure ChatMode                 ; chat mode
  1832.   integer x
  1833.   string rch,lch
  1834.   Echo "^M^JChat mode begin:^M^J"
  1835.   repeat
  1836.     if not LOCAL
  1837.       getch rch
  1838.       if success
  1839.         put rch,
  1840.         if rch = "^M"              ; line feed
  1841.           Echo "^J"
  1842.         endif
  1843.         wherex x
  1844.           if rch = " " and x > 70
  1845.             Echo "^M^J"
  1846.           endif
  1847.       endif
  1848.     endif
  1849.     inputch lch
  1850.     if success and lch<>"^["       ; abort if sysop press [Esc]
  1851.       Echo lch
  1852.       if lch = "^M"
  1853.         Echo "^J"
  1854.       endif
  1855.       wherex x
  1856.       if lch = " " and x > 70
  1857.         Echo "^M^J"
  1858.       endif
  1859.     endif
  1860.   until lch="^[" or not connected
  1861.   Echo "^M^JChat mode end.^M^J^M^J"
  1862.   Pause
  1863. Endproc 
  1864.  
  1865. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1866. ;; New Procedure STATISTICS
  1867. ;; Shows user statistics and enables change of 'Password' or 'Menu Mode'.
  1868. ;;                                
  1869.  
  1870. Procedure Statistics               ; view statistics and 
  1871.   integer len                      ; change password choice
  1872.   clear com
  1873.   clear text 
  1874.   EchoClearScreen
  1875.   EchoColor HILITECOL
  1876.   Echo "^M^J" 
  1877.   Echo username 
  1878.   Echo " - your statistics are:^M^J"
  1879.   EchoColor GENTEXTCOL    
  1880.   Echo "For this call you have "
  1881.   print timeleft,                  ; integers 
  1882.   put timeleft,
  1883.   Echo " minutes remaining.^M^J"
  1884.   Echo "Userlevel: " 
  1885.   if userlevel = 1                 ; show statistics
  1886.     Echo "New User" 
  1887.   elseif userlevel = 2
  1888.     Echo "Normal User"
  1889.   elseif userlevel = 3
  1890.     Echo "Priviledged User"
  1891.   endif
  1892.   Echo "^M^JMenu Mode: "
  1893.   if xpert
  1894.     Echo "Expert (No Menus)"
  1895.   else
  1896.     Echo "Full Menus"
  1897.   endif
  1898.   Echo  "^M^JYour password is: "
  1899.   Echo password 
  1900.   Echo "^M^J^M^J"
  1901.   len = 0
  1902.   EchoNormal
  1903.   EchoHilite        
  1904.   Echo "Change Password ? [y/n] "
  1905.   InputEcho ch
  1906.   if ch = "Y"
  1907.     while len<4  
  1908.       Echo "^M^JNew Password: " 
  1909.       EchoNormal
  1910.       InputPassword password
  1911.       Trash
  1912.       if not access 
  1913.         EchoHilite
  1914.         Echo "^M^JGarbage Passwords not accepted, access denied!^M^J" 
  1915.         Disconnect
  1916.         Usage "User not accepted - garbage password!"
  1917.         return
  1918.       endif
  1919.       length password,len          ; check the length of password
  1920.       if len<4
  1921.         Echo "Password too short, please try again^M^J"
  1922.       else
  1923.         WriteNewRecord username
  1924.         Echo "^M^J^M^JNew Password saved "
  1925.         Save
  1926.         Echo "^M^JWrite it down, it is your new logon password!^M^J^M^J"
  1927.       endif
  1928.     endwhile
  1929.   else
  1930.     EchoNormal
  1931.     Echo "^M^JOriginal Password valid............^M^J^M^J"
  1932.   endif
  1933.   EchoHilite
  1934.   Echo "^M^JIf you have changed your 'Menu Mode' since" 
  1935.   Echo "^M^Jlogging on it can be saved for future logons."
  1936.   Echo "^M^JSave ? [y/n] "
  1937.   EchoNormal
  1938.   InputEcho ch
  1939.   if ch = "Y"
  1940.     WriteNewRecord username        ; update record
  1941.     Echo "^M^JMenu Mode Saved "
  1942.   Save
  1943.   endif 
  1944.   Echo "^M^J^M^J"
  1945.   Pause
  1946. Endproc
  1947.  
  1948. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1949. ;; New Procedure TIMEUP 
  1950. ;; Warns then disconnects user if out of time.
  1951. ;;
  1952.  
  1953. Procedure Timeup                   ; disconnect if over time
  1954.   if timeleft <= 3
  1955.     EchoHilite
  1956.     at 2,20                        ; warning
  1957.     Echo "WARNING - disconnection imminent!"
  1958.     EchoNormal
  1959.   endif
  1960.   if timeleft = 0
  1961.     EchoHilite
  1962.     Echo "^M^JOut of Time.  Connection Terminated^M^J"
  1963.     Disconnect
  1964.     Usage "User disconnected - out of  time"
  1965.   endif  
  1966. Endproc 
  1967.   
  1968. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1969. ;; Modified DoCommand procedure for control of 'Menu mode',
  1970. ;; Ansi menus, calculation of time on, etc.
  1971. ;;
  1972.  
  1973. Procedure DoCommand                ; do a command
  1974.   integer pos
  1975.   clear com
  1976.   clear text
  1977.   time now                         ; current time
  1978.   strdel now,6,3
  1979.   CalcTime logontime,now,mins      ; compare times
  1980.   timeleft = ontime - mins         ; time left online
  1981.   if ANSIREMOTE
  1982.     if xpert                       ; expert mode      
  1983.       Timeup    
  1984.       EchoClearScreen 
  1985.       LocalView
  1986.       EchoColor GENTEXTCOL
  1987.       print "^M^J^M^JCurrent Message Area #",areanum," - ",area
  1988.       put "^M^J^M^JCurrent Message Area #",areanum," - ",area                              
  1989.       print "^M^J",timeleft,XPERTCOMMAND,
  1990.       put "^M^J",timeleft,XPERTCOMMAND,
  1991.     else
  1992.       chdir HOSTDIR
  1993.       TypeFile "MENUANS.HST",FALSE  ; display ansi menu
  1994.       chdir TMDIR
  1995.       Timeup
  1996.       LocalView
  1997.       EchoColor GENTEXTCOL
  1998.       at 0,20
  1999.       print "Current Message Area #",areanum," - ",area
  2000.       put "Current Message Area #",areanum," - ",area                              
  2001.       print timeleft,MENUCOMMAND,
  2002.       put "^M^J",timeleft,MENUCOMMAND,
  2003.     endif
  2004.   else
  2005.     if xpert
  2006.       Timeup
  2007.       LocalView
  2008.       print "^M^J^M^JCurrent Message Area #",areanum," - ",area
  2009.       put "^M^J^M^JCurrent Message Area #",areanum," - ",area                              
  2010.       print "^M^J",timeleft,XPERTCOMMAND,
  2011.       put "^M^J",timeleft,XPERTCOMMAND,
  2012.     else
  2013.       chdir HOSTDIR
  2014.       TypeFile "MENUTXT.HST",FALSE ; display text menu
  2015.       chdir TMDIR
  2016.       Timeup
  2017.       LocalView
  2018.       at 0,20
  2019.       print "Current Message Area #",areanum," - ",area
  2020.       put "Current Message Area #",areanum," - ",area                              
  2021.       print timeleft,MENUCOMMAND,
  2022.       put "^M^J",timeleft,MENUCOMMAND,
  2023.     endif
  2024.   endif
  2025.   if userlevel = SYSOPLEVEL
  2026.     Echo "(H,V) "
  2027.   endif
  2028.   InputEcho ch
  2029.   if ch<>"^M"
  2030.     Echo "^M^J"
  2031.   endif
  2032.   switch ch
  2033.     case "F":                      ; file directory
  2034.       EchoClearScreen
  2035.       chdir DOWNLOADDIR 
  2036.       if FILELIST
  2037.         List
  2038.       else
  2039.         EchoClearScreen
  2040.         chdir DOWNLOADDIR 
  2041.         Directory
  2042.       endif
  2043.     case "T":                      ; type a file
  2044.       clear com
  2045.       EchoClearScreen
  2046.       chdir DOWNLOADDIR
  2047.       Directory
  2048.       EchoColor GENTEXTCOL
  2049.       Echo "^M^JListing of files in host directory...."
  2050.       Echo "^M^JOnly files with extension .TXT should be typed.^M^J^M^J"
  2051.       Echo "Enter filename: " 
  2052.       EchoColor HILITECOL
  2053.       InputFilename filename,DOWNLOADDIR 
  2054.       strpos filename,"TXT",pos 
  2055.       if pos = 0
  2056.         Echo "^M^JFile must have .TXT extension"
  2057.         Delay 20
  2058.       else
  2059.         if success
  2060.           chdir DOWNLOADDIR
  2061.           EchoNormal
  2062.           TypeFile filename,TRUE
  2063.         endif
  2064.       endif
  2065.     case "C":                      ; chat
  2066.       clear com
  2067.       clear text
  2068.       EchoClearScreen
  2069.       Echo "Paging the Sysop, hang on a second!^M^J"
  2070.       alarm "User would like to chat...^JPress [Enter] to accept, [Esc] to deny"
  2071.       if success
  2072.         print "^M^JSYSOP: press [Esc] to terminate chat mode"
  2073.         ChatMode
  2074.       else
  2075.         Echo "^M^JSorry, Sysop is not here^M^J"
  2076.       endif
  2077.     case "U":                      ; upload a file
  2078.       clear com
  2079.       clear text
  2080.       chdir HOSTDIR
  2081.       if ANSIREMOTE 
  2082.         Typefile "PROTOANS.HST",FALSE  ; ansi file
  2083.         EchoColor GENTEXTCOL
  2084.       else
  2085.         TypeFile "PROTOTXT.HST",FALSE
  2086.       endif
  2087.       at 5,20
  2088.       Echo "Select protocol: "   
  2089.       InputEcho protocol
  2090.       Echo "^M^J"
  2091.       if LOCAL
  2092.         Echo "Function not available in local mode^M^J" 
  2093.         delay 10
  2094.       else
  2095.         switch protocol
  2096.           case "I":
  2097.             Bimod
  2098.           case "X","R":
  2099.             Echo "Enter filename: "
  2100.             InputFilename filename,""
  2101.             if success
  2102.               FileTransfer "r",protocol,filename
  2103.             endif
  2104.           case "Z","S","T","M","Y","B","G":
  2105.             FileTransfer "r",protocol,""
  2106.         endswitch
  2107.       endif
  2108.     case "D":                      ; download a file 
  2109.       clear com
  2110.       clear text
  2111.       chdir HOSTDIR
  2112.       if ANSIREMOTE 
  2113.         Typefile "PROTOANS.HST",FALSE 
  2114.         EchoColor GENTEXTCOL
  2115.       else
  2116.         TypeFile "PROTOTXT.HST",FALSE
  2117.       endif
  2118.       chdir DOWNLOADDIR  
  2119.       at 5,20
  2120.       Echo "Select protocol: "   
  2121.       InputEcho protocol
  2122.       Echo "^M^J"
  2123.       if LOCAL
  2124.         Echo "Function not available in local mode^M^J"
  2125.         delay 10
  2126.       else
  2127.         switch protocol
  2128.           case "I":
  2129.             Bimod
  2130.           case "X","Y","Z","S","T","M","R","B","G":
  2131.             Echo "Enter filename: "
  2132.             InputFilename filename,DOWNLOADDIR
  2133.             if success
  2134.               FileTransfer "s",protocol,filename
  2135.             endif
  2136.         endswitch
  2137.       endif
  2138.     case "X":                      ; toggle expert mode
  2139.       xpert = not xpert
  2140.     case "A":                      ; access, change area and
  2141.       AccessMsg                    ; read or enter message.
  2142.     case "E":                      ; enter message in base already selected 
  2143.       name = ""
  2144.       subject = ""
  2145.       addmsg = 0
  2146.       EnterMsg 
  2147.       WriteNewRecord name
  2148.     case "R":                      ; read messages
  2149.       if MSGBASE = MSBASE0         ; message to sysop
  2150.         If userlevel = SYSOPLEVEL  ; read by sysop only
  2151.           ReadMsg
  2152.         else
  2153.           Echo "^M^J^M^JThese are PRIVATE messages!"
  2154.           delay 10 
  2155.         endif
  2156.       else
  2157.         ReadMsg                    ; other areas
  2158.         WriteNewRecord name
  2159.       endif
  2160.     case "M":                      ; or leave message to Sysop
  2161.       areanum = 1
  2162.       area = area0
  2163.       MSGBASE = MSBASE0
  2164.       subject = ""
  2165.       EnterMsg                     ; leave message
  2166.     case "G":                      ; goodbye
  2167.       chdir HOSTDIR
  2168.       if ANSIREMOTE
  2169.         Typefile "BYEANS.HST",FALSE
  2170.         InputEcho ""
  2171.       else
  2172.         TypeFile "BYETXT.HST",FALSE
  2173.         InputEcho ""
  2174.       endif
  2175.       Disconnect
  2176.       Usage "User logged off"
  2177.       chdir TMDIR
  2178.     case "Q":                      
  2179.       Questionnaire
  2180.     case "B":                      ; show bulletins
  2181.       EchoClearScreen
  2182.       EchoNormal
  2183.       chdir HOSTDIR
  2184.       Typefile "BULLETIN.HST",TRUE
  2185.       chdir TMDIR                         
  2186.       Usage "User read bulletins......"
  2187.     case "Y":                      ; user statistics
  2188.       Statistics
  2189.     case "S":                      ; shell to DOS
  2190.       if userlevel<SYSOPLEVEL
  2191.         Echo "Sorry, this command is for Sysop only^M^J"
  2192.         delay 10
  2193.       else
  2194.         chdir HOSTDIR
  2195.         if LOCAL                   ; local mode shell to DOS
  2196.           Echo "Shelling to DOS ... ^M^J"
  2197.           dos
  2198.           Echo "Return from DOS shell^M^J"
  2199.         else
  2200.           fileexist "hshell.bat",exist   ; check for HSHELL.BAT
  2201.           if exist
  2202.             Echo "Shelling to DOS ... ^M^J"
  2203.             dos "hshell.bat"
  2204.             Echo "Return from DOS shell^M^J"
  2205.           else
  2206.             Echo "SYSOP: Cannot find HSHELL.BAT^M^J"
  2207.           endif
  2208.         endif
  2209.       endif
  2210.     case "V":                      ; view log when remote 
  2211.       if userlevel<SYSOPLEVEL
  2212.         Echo "Sorry, this command is for Sysop only^M^J"
  2213.         delay 10
  2214.       else
  2215.         EchoClearScreen
  2216.         EchoNormal
  2217.         dos
  2218.         chdir TMLOG
  2219.         Typefile "TM.USE",TRUE     ; view log
  2220.         dos
  2221.         chdir TMDIR
  2222.       endif
  2223.     case "?":                      ; show help file of available
  2224.       chdir HOSTDIR                ; commands
  2225.       Typefile "HELP.HST",TRUE
  2226.       chdir TMDIR
  2227.     case "H":                      ; shut down host mode
  2228.       if userlevel<SYSOPLEVEL
  2229.         Echo "Sorry, this command is for Sysop only^M^J"
  2230.         delay 10
  2231.       else
  2232.         Echo "Are you sure [y/N]? "
  2233.         InputString ch
  2234.         if ch="y"
  2235.           Echo "Shutting down host mode^M^J"
  2236.           Disconnect
  2237.           HostEnd
  2238.         endif
  2239.       endif
  2240.     endswitch
  2241. Endproc
  2242.  
  2243. ;
  2244. ; begin main program
  2245. ;
  2246. while FOREVER
  2247.   HostConfig                       ; read configuration file TMHCFG.HST
  2248.   HostBegin                        ; initial mode
  2249.   WaitForCall                      ; wait for a call
  2250.   while connected
  2251.     DoCommand                      ; do commands
  2252.   endwhile
  2253. endwhile
  2254.  
  2255.