home *** CD-ROM | disk | FTP | other *** search
/ Chip 1996 December / CHIP_CD_1996_12_PL.iso / software / trial / carbon / terminal / host.ms_ / host.ms
Encoding:
Text File  |  1995-06-18  |  11.2 KB  |  451 lines

  1. ' Host mode script
  2. ' Access levels are:    3 - Sysop
  3. '                       2 - user can access any directory
  4. '                       1 - user can access only current directory
  5. PUSH
  6. SET ECHO ON
  7. SET TEXTWRAP ON
  8. SET HOSTECHO ON
  9. SET INCRLF ON
  10. SET OUTCRLF ON
  11. SET CARRIERDETECT ON
  12.  
  13. SET BAUDRATE 19200
  14. SET DATABITS 8
  15. SET PARITY NONE
  16. SET STOPBITS 1
  17. SET FLOWCONTROL RTS
  18. SET LOCKBAUDRATE ON
  19. SET TERMINAL ANSI
  20.  
  21.  
  22. upload_dir$ = uploaddirectory
  23. default_dir$ = defaultdirectory
  24. file_spec$ = filespec
  25.  
  26.  
  27. cr$ = "^M"
  28. cr2$ = "^M^M"
  29. cr3$ = "^M^M^M"
  30. cr4$ = "^M^M^M^M"
  31. cr5$ = "^M^M^M^M^M"
  32. newpage$ = cr5$+cr5$+cr5$+cr5$+cr5$
  33.  
  34. Header$   = "                   Host Mode"
  35.  
  36. welcome1$ = "                 ***********************************"+cr$
  37. welcome2$ = "                 * Carbon Copy Terminal Host Mode  *"+cr$
  38. welcome3$ = "                 *      Press ENTER to Continue    *"+cr$
  39. welcome4$ = "                 ***********************************"+cr5$
  40.  
  41. continue = 1
  42. max_lines = 20
  43.  
  44.  
  45. WHILE continue=1
  46.     if ChangeDirectory(default_dir$) > 0 then
  47.       mprint "Invalid default directory"
  48.       beep
  49.       sleep 5
  50.       continue = 0
  51.       GOTO force_hangup
  52.     endif
  53.  
  54.     current_dir$ = default_dir$
  55.  
  56.     ONERROR force_hangup
  57.     AUTOANSWER
  58.  
  59.  
  60.     ' Computer answered phone
  61.  
  62.     sleep 5
  63.     IF Connected = 0 Then
  64.      goto force_hangup
  65.     endif
  66.     RPRINT newpage$
  67.     RPRINT welcome1$
  68.     RPRINT welcome2$
  69.     RPRINT welcome3$
  70.     RINPUT welcome4$,temp$
  71.     Rprint cr4$
  72.  
  73.     ' Prompts to enter password
  74.     logon_ok = 0
  75.     set error off
  76.     FOR i = 1 TO 3
  77.         onerror skipsignon
  78.         RINPUT cr$+"Enter FIRST name: ", first$
  79.     RINPUT cr$+"Enter LAST name: ", last$
  80.     SET HOSTECHO OFF
  81.         RINPUT cr$+"Enter PASSWORD: ", password$
  82.         set error off
  83.     SET HOSTECHO ON
  84.     logon_ok = VerifyUser(first$, last$, password$)
  85.         IF logon_ok > 1  THEN
  86.             IF OPENHOST = 1 THEN
  87.                 onerror skipnew
  88.                 rprint cr2$+"              N E W   U S E R"+cr2$
  89.         Rprint cr$+"First Name: "+first$
  90.                 Rprint cr$+"Last Name: "+last$
  91.             RINPUT cr$+"Correct? ", Temp$
  92.                 logon_ok = 0
  93.                 IF upper(Temp$) = "Y" THEN
  94.                     IF Adduser(first$, last$, password$, 1) > 0 THEN
  95.                         RPRINT cr2$+"Unable To Add User At This Time"
  96.                         logon_ok = 1
  97.                     ENDIF
  98.                     EXIT
  99.                 ENDIF
  100.                 skipnew:
  101.         ELSE
  102.             RPRINT cr2$+"Invalid logon attempt!"
  103.             IF i < 3 THEN
  104.              RPRINT cr$+"There are " + String(3 - i) + " attempts left."
  105.         ENDIF
  106.         ENDIF
  107.         ELSE
  108.          IF logon_ok = 1  THEN
  109.             RPRINT cr$+"Invalid logon attempt!"
  110.             IF i < 3 THEN
  111.               RPRINT cr$+"There are " + String(3 - i) + " attempts left." + cr$
  112.             ENDIF
  113.          ELSE
  114.            EXIT
  115.          ENDIF
  116.         ENDIF
  117.         skipsignon:
  118.     NEXT
  119.  
  120.     IF logon_ok > 0 THEN
  121.     RPRINT cr2$+"Unable to validate user!"
  122.         RPRINT cr2$+"Hanging up!"
  123.         goto force_hangup
  124.     else
  125.     continue_commands = 1
  126.     access_level = ExtractUserLevel(first$, last$)
  127.     rprint cr4$
  128.     endif
  129.     WHILE continue_commands = 1
  130.         if Connected = 0 then
  131.             EXIT
  132.     endif
  133.         RPRINT cr2$+"         Host Mode Processor"+cr2$
  134.     RPRINT cr$ + "[F]File Directory    [D]Download    [U]Upload    [C]Chat"
  135.          ' Level 2 or 3
  136.     IF access_level > 1  THEN
  137.         RPRINT cr$ + "[CD]Change Directory [FS]File Specification"
  138.     ENDIF
  139.  
  140.     ' Level 3 only
  141.     IF access_level > 2 then
  142.         RPRINT cr$ + "[AU]Add User         [CU]Change User"
  143.         RPRINT cr$ + "[DU]Delete User      [S]ShutDown"
  144.     ENDIF
  145.  
  146.     RPRINT cr$ + "[G]Goodbye"
  147.  
  148.     ' Wait for command
  149.         RINPUT cr2$+current_dir$ + "> ", tempcommand$
  150.         command$ = upper(tempcommand$)
  151.  
  152.     ' Exit System
  153.     if len(command$) = 1 then
  154.         IF command$ = "G"  THEN
  155.         RPRINT cr$ + "Thanks for calling " + first$ + "!" + cr$
  156.         continue_commands = 0
  157.         SLEEP 2
  158.         ENDIF
  159.  
  160.             ' List Files
  161.         IF command$ = "F" THEN
  162.                 RPRINT cr4$
  163.         RPRINT "Directory listing of: " + current_dir$ + cr2$
  164.         ChangeDirectory(current_dir$)
  165.         filename$ = GetFirstDirEntry(current_dir$, file_spec$)
  166.         WHILE Len(filename$) > 0
  167.             IF Connected = 0 Then
  168.                         EXIT
  169.                 endif
  170.             FOR i = 1 to max_lines
  171.             RPRINT filename$ + cr$
  172.             filename$ = GetNextDirEntry()
  173.                     IF Len(filename$) = 0 THEN
  174.                     EXIT
  175.             ENDIF
  176.             NEXT
  177.             IF LEN(filename$) > 0 THEN
  178.                 Rinput cr$+"List paused.  Press ENTER to continue.",temp$
  179.                 IF "C" = upper(temp$) THEN
  180.                            exit
  181.                         ENDIF
  182.                     rprint cr4$
  183.             ENDIF
  184.         WEND
  185.  
  186.         RINPUT cr$+"End of List.   Press ENTER to Continue",temp$
  187.         rprint cr4$
  188.         ENDIF
  189.  
  190.         ' Download a File
  191.         IF command$ = "D" THEN
  192.             rprint cr4$
  193.         WHILE 1 = 1
  194.             IF Connected = 0 Then
  195.                         EXIT
  196.                     endif
  197.                     RPRINT cr$+Header$+cr3$
  198.             RPRINT cr$+"Available download file transfer protocols:" + cr2$
  199.             RPRINT "[X]..XMODEM Checksum" + cr$
  200.             RPRINT "[C]..XMODEM CRC" + cr$
  201.                     RPRINT "[Y]..YMODEM 1K" + cr$
  202.             RPRINT "[YB].YMODEM Batch" + cr$
  203.             RPRINT "[YG].YMODEM G" + cr$
  204.             RPRINT "[Z]..ZMODEM" + cr$
  205.             RPRINT "[E]..Cancel" + cr$
  206.             RINPUT "Select protocol: ", tempchoice$
  207.             choice$ = upper(tempchoice$)
  208.                     if len(choice$) = 1 then
  209.                 IF choice$ = "E" THEN
  210.                             EXIT
  211.                 ENDIF
  212.                 IF choice$ = "X" THEN
  213.                             set protocol XMODEM
  214.                             EXIT
  215.                 ENDIF
  216.                 IF choice$ = "C" THEN
  217.                             set protocol XMODEMCRC
  218.                             EXIT
  219.                 ENDIF
  220.             IF choice$ = "Y" THEN
  221.                             set protocol YMODEM
  222.                             EXIT
  223.                 ENDIF
  224.                 IF choice$ = "Z" THEN
  225.                             set protocol ZMODEM
  226.                             EXIT
  227.                 ENDIF
  228.             endif
  229.                     if len(choice$) = 2 then
  230.                 IF choice$ = "YB" THEN
  231.                             set protocol YMODEMB
  232.                             EXIT
  233.                 ENDIF
  234.                 IF choice$ = "YG" THEN
  235.                             set protocol YMODEMG
  236.                             EXIT
  237.                 ENDIF
  238.             ENDIF
  239.             rprint cr2$+"Invalid Selection"+cr2$
  240.         WEND
  241.                 IF choice$ = "E" THEN
  242.             rprint "Canceled!"+cr$
  243.                 ELSE
  244.                     ChangeDirectory(current_dir$)
  245.                     RINPUT cr2$+"Enter Filename: ", transfer_file$
  246.                     is_ok = DoesFileExist(transfer_file$)
  247.                     IF is_ok = 1 THEN
  248.                         RPRINT cr$+"File " + transfer_file$ + " was not found." + cr$
  249.                         RPRINT "File transfer canceled!" + cr$
  250.                     ELSE
  251.                         RPRINT cr$+"Downloading " + transfer_file$ + cr$
  252.                         ONERROR snderr
  253.                         SEND transfer_file$
  254.                         sleep 3
  255.                         rprint cr$+"File Transfer Successful"
  256.                         goto sndok
  257.                         snderr:
  258.                         rprint cr2$+"Error Downloading File"
  259.                         rinput cr$+"Hit ENTER to Continue",temp$
  260.                         sndok:
  261.                         set error off
  262.                     ENDIF
  263.                 ENDIF
  264.             ENDIF
  265.     ' Receive a File
  266.         IF command$ = "U" THEN
  267.             rprint cr4$
  268.             WHILE 1 = 1
  269.             IF Connected = 0 Then
  270.                         EXIT
  271.                     endif
  272.                     RPRINT cr$+Header$+cr3$
  273.             RPRINT "Available Upload file transfer protocols:" + cr2$
  274.             RPRINT "[X]..XMODEM Checksum" + cr$
  275.             RPRINT "[C]..XMODEM CRC" + cr$
  276.             RPRINT "[Y]..YMODEM 1K" + cr$
  277.             RPRINT "[YB].YMODEM Batch" + cr$
  278.             RPRINT "[YG].YMODEM G" + cr$
  279.             RPRINT "[Z]..ZMODEM" + cr$
  280.             RPRINT "[E]..Exit" + cr$
  281.             RINPUT "Select protocol: ", tempchoice$
  282.             choice$ = upper(tempchoice$)
  283.                     if len(choice$) = 1 then
  284.                 IF choice$ = "E" THEN
  285.                             EXIT
  286.                 ENDIF
  287.                 IF choice$ = "X" THEN
  288.                 set protocol XMODEM
  289.                 RINPUT cr$+"Enter Filename: ", transfer_file$
  290.                 is_ok = ValidFileName(transfer_file$)
  291.                         EXIT
  292.                 ENDIF
  293.                 IF choice$ = "C" THEN
  294.                         set protocol XMODEMCRC
  295.                 RINPUT cr$+"Enter Filename: ", transfer_file$
  296.                 is_ok = ValidFileName(transfer_file$)
  297.                         EXIT
  298.                 ENDIF
  299.                 IF choice$ = "Y" THEN
  300.                         set protocol YMODEM
  301.                 RINPUT cr$+"Enter Filename: ", transfer_file$
  302.                 is_ok = ValidFileName(transfer_file$)
  303.                         EXIT
  304.                 ENDIF
  305.                 IF choice$ = "Z" THEN
  306.                 set protocol ZMODEM
  307.                 transfer_file$ = ""
  308.                 is_ok = 1
  309.                         EXIT
  310.                 ENDIF
  311.             ENDIF
  312.             if len(choice$) = 2 then
  313.                 IF choice$ = "YB" THEN
  314.                 set protocol YMODEMB
  315.                 transfer_file$ = ""
  316.                 is_ok = 1
  317.                         EXIT
  318.                 ENDIF
  319.                 IF choice$ = "YG" THEN
  320.                         set protocol YMODEMG
  321.                 transfer_file$ = ""
  322.                 is_ok = 1
  323.                         EXIT
  324.                 ENDIF
  325.             ENDIF
  326.             rprint cr2$+"Invalid Selection"+cr2$
  327.         WEND
  328.                 IF choice$ = "E" THEN
  329.                 rprint cr$+"Canceled"+cr$
  330.             ELSE
  331.             IF is_ok = 0 THEN
  332.                         RPRINT "File " + transfer_file$ + " was not valid." + cr$
  333.                         RPRINT "File transfer canceled!" + cr$
  334.                     ELSE
  335.  
  336.                         ChangeDirectory(upload_dir$)
  337.                         ONERROR rcverr
  338.                         RPRINT cr2$+"Uploading " + transfer_file$ +cr$
  339.                         RPRINT cr$+"Start Your File Transfer"+cr$
  340.                         RECEIVE transfer_file$
  341.                         sleep 3
  342.                         RPRINT cr$+"File Transfer Successful"+cr$
  343.                         GOTO rcvok
  344.                         rcverr:
  345.                         Rprint "Error Uploading File - "+transfer_file$+cr$
  346.                         rinput "Hit Enter to Continue",temp$
  347.                         rcvok:
  348.                         ChangeDirectory(current_dir$)
  349.                         set error off
  350.             ENDIF
  351.             ENDIF
  352.         ENDIF
  353.         IF command$ = "S" THEN
  354.                 RPRINT cr$+"Shutdown Initiated"
  355.                 continue = 0
  356.                 continue_commands = 0
  357.         ENDIF
  358.         IF command$ = "C"  THEN 
  359.             rprint cr3$+"Chat Mode Started"+cr$   
  360.             rprint "Enter '*' to Terminate"+cr2$   
  361.             chat
  362.             rprint cr2$+"Chat Mode Terminated"+cr3$        
  363.         ENDIF
  364.  
  365.     ' Change Directory
  366.     ENDIF
  367.     if len(command$) = 2 then
  368.         IF command$ = "CD" THEN
  369.         IF access_level > 1 THEN
  370.             RINPUT cr$+"Enter New Directory: ", new_dir$
  371.                     is_ok = ChangeDirectory(new_dir$)
  372.                     if is_ok = 0 then
  373.                         current_dir$ = new_dir$
  374.             ELSE
  375.                 RPRINT cr2$+"Unable to change to directory!"
  376.             ENDIF
  377.             ENDIF
  378.         ENDIF
  379.  
  380.         IF command$ = "FS" Then
  381.                 RPRINT cr2$+"Current File Specification is "+file_spec$+cr$
  382.             RINPUT cr$+"Enter New File Specification: ", file_spec$
  383.             IF LEN(file_spec$) = 0 THEN
  384.             file_spec$ = filespec
  385.                 ENDIF
  386.         ENDIF
  387.     ' Add a New User
  388.         IF command$ = "AU" THEN
  389.             IF access_level > 2 THEN
  390.                     rprint cr4$
  391.                     RPRINT cr$+Header$+cr$
  392.             RPRINT  "Add a new user." + cr$
  393.             RINPUT cr$+"Enter new user's First name: ", new_first$
  394.             RINPUT cr$+"Enter new user's Last name: ", new_last$
  395.             RINPUT cr$+"Enter new user's Password: ", new_password$
  396.                     RINPUT cr$+"Enter new user's Access level: ", new_level$
  397.                     iLevel = val(new_level$)
  398.                     is_ok = AddUser(new_first$, new_last$, new_password$, iLevel)
  399.             IF is_ok > 0 THEN
  400.             RPRINT cr$+"Unable to add user record!" + cr$
  401.             ELSE
  402.             RPRINT cr$+new_first$+" "+new_last$+" added to datafile." + cr$
  403.             ENDIF
  404.         ENDIF
  405.         ENDIF
  406.  
  407.     ' Change an Existing User
  408.         IF command$ = "CU" THEN
  409.         IF access_level > 2 THEN
  410.                     rprint cr4$
  411.                     RPRINT cr$+Header$+cr$
  412.             RPRINT  "Change an existing user." + cr$
  413.             RINPUT cr$+"Enter user's First name: ", new_first$
  414.             RINPUT cr$+"Enter user's Last name: ", new_last$
  415.             RINPUT cr$+"Enter user's new Password or blank to skip: ", new_password$
  416.                     RINPUT cr$+"Enter new Access Level: ", new_level$
  417.                     iLevel = val(new_level$)
  418.                     is_ok = ChangeUser(new_first$, new_last$, new_password$, iLevel)
  419.             IF is_ok > 0 THEN
  420.             RPRINT cr$+"Unable to change user record!" + cr$
  421.             ELSE
  422.             RPRINT cr$+new_first$+" "+new_last$+ " access level changed."+cr$
  423.             ENDIF
  424.         ENDIF
  425.         ENDIF
  426.  
  427.     ' Delete an Existing User
  428.         IF command$ = "DU" THEN
  429.  
  430.         IF access_level > 2 THEN
  431.                     rprint cr4$
  432.                     RPRINT cr$+Header$+cr$
  433.             RPRINT  "Delete an existing user." + cr$
  434.             RINPUT cr$+"Enter user's First name: ", new_first$
  435.             RINPUT cr$+"Enter user's Last name: ", new_last$
  436.             is_ok = DeleteUser(new_first$, new_last$)
  437.             IF is_ok > 0 THEN
  438.             RPRINT cr$+"Unable to delete user record!" + cr$
  439.             ELSE
  440.             RPRINT cr$+new_first$+" "+new_last$+" deleted." + cr$
  441.             ENDIF
  442.         ENDIF
  443.         ENDIF
  444.         ENDIF
  445.     WEND
  446.     force_hangup:
  447.     HANGUP
  448. WEND
  449. Mprint "Script Terminated"
  450. END
  451.