home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / comm / hostmlnk.zip / HOST.MSL < prev    next >
Text File  |  1993-06-26  |  16KB  |  529 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. upload_dir$ = uploaddirectory
  14. default_dir$ = defaultdirectory
  15. file_spec$ = filespec
  16.  
  17.  
  18. cr$ = "^M"
  19. cr2$ = "^M^M"
  20. cr3$ = "^M^M^M"
  21. cr4$ = "^M^M^M^M"
  22. cr5$ = "^M^M^M^M^M"
  23. newpage$ = cr5$+cr5$+cr5$+cr5$+cr5$
  24.  
  25. Header$   = "                      Host Mode"
  26.  
  27. welcome1$ = "                 ***********************************"+cr$
  28. welcome2$ = "                 *       An Mlink BBS <Private>    *"+cr$
  29. welcome3$ = "                 *       New Features Added!!!!    *"+cr$
  30. welcome4$ = "                 *  - - - - - - - - - - - - - - -  *"+cr$
  31. welcome5$ = "                 *          Now Available:         *"+cr$
  32. welcome6$ = "                 *   Sysop Paging, Message write,  *"+cr$
  33. welcome7$ = "                 *  Password Changing & Chat mode! *"+cr$
  34. welcome8$ = "                 *      Press ENTER to continue    *"+cr$
  35. welcome9$ = "                 ***********************************"+cr5$
  36.  
  37. continue = 1
  38. max_lines = 20
  39.  
  40.  
  41. WHILE continue=1
  42.     if ChangeDirectory(default_dir$) > 0 then
  43.       mprint "Invalid default directory"
  44.       beep
  45.       sleep 5
  46.       continue = 0
  47.       GOTO force_hangup
  48.     endif
  49.  
  50.     current_dir$ = default_dir$
  51.  
  52.     ONERROR force_hangup
  53.     AUTOANSWER
  54.  
  55.  
  56.     ' Computer answered phone
  57.  
  58.     sleep 5
  59.     IF Connected = 0 Then
  60.      goto force_hangup
  61.     endif
  62.     RPRINT newpage$
  63.     RPRINT welcome1$
  64.     RPRINT welcome2$
  65.     RPRINT welcome3$
  66.     RPRINT welcome4$
  67.     RPRINT welcome5$
  68.     RPRINT welcome6$
  69.     RPRINT welcome7$
  70.     RPRINT welcome4$    
  71.     RPRINT welcome8$
  72.     RINPUT welcome9$,temp$
  73.     Rprint cr4$
  74.  
  75.     ' Prompts to enter password
  76.     logon_ok = 0
  77.     set error off
  78.     FOR i = 1 TO 3
  79.         onerror skipsignon
  80.         RINPUT cr$+"Enter FIRST name: ", first$
  81.         RINPUT cr$+"Enter LAST name: ", last$
  82. MPRINT first$+" "+last$+" On Line."
  83.         SET HOSTECHO OFF
  84.         RINPUT cr$+"Enter PASSWORD: ", password$ 
  85.         set error off
  86.         SET HOSTECHO ON
  87.         logon_ok = VerifyUser(first$, last$, password$)
  88.           IF logon_ok > 1  THEN
  89.             IF OPENHOST = 1 THEN
  90.                 onerror skipnew
  91.                    rprint cr2$+"              N E W   U S E R"+cr2$
  92.                 Rprint cr$+"First Name: "+first$
  93.                    Rprint cr$+"Last Name: "+last$
  94.                    RINPUT cr$+"Correct? ", Temp$
  95.                    logon_ok = 0
  96.                    IF upper(Temp$) = "Y" THEN
  97.                      IF Adduser(first$, last$, password$, 1) > 0 THEN
  98.                            RPRINT cr2$+"Unable To Add User At This Time"
  99.                            logon_ok = 1
  100.                      ENDIF
  101.                      EXIT
  102.                 ENDIF
  103.                 skipnew:
  104.               ELSE
  105.                  RPRINT cr2$+"Invalid logon attempt!"
  106.                   IF i < 3 THEN
  107.                      RPRINT cr$+"There are " + String(3 - i) + " attempts left."
  108.                 ENDIF
  109.               ENDIF
  110.         ELSE
  111.          IF logon_ok = 1  THEN
  112.             RPRINT cr$+"Invalid logon attempt!"
  113.             IF i < 3 THEN
  114.               RPRINT cr$+"There are " + String(3 - i) + " attempts left." + cr$
  115.             ENDIF
  116.          ELSE
  117.            EXIT
  118.          ENDIF
  119.         ENDIF
  120.         skipsignon:
  121.     NEXT
  122.  
  123.     IF logon_ok > 0 THEN
  124.         RPRINT cr2$+"Unable to validate user!"
  125.         RPRINT cr2$+"Hanging up!"
  126.         goto force_hangup
  127.     else
  128.         continue_commands = 1
  129.         access_level = ExtractUserLevel(first$, last$)
  130.         rprint cr4$
  131.     endif
  132.     WHILE continue_commands = 1
  133.         if Connected = 0 then
  134.                EXIT
  135.         endif
  136.         RPRINT cr2$+"         Host Mode Processor"+cr2$
  137.         RPRINT cr$ + "[F]File Directory    [D]Download    [U]Upload"
  138.         RPRINT cr$ + "[P]Change Password   [R]Ring Bell for Sysop"
  139.      RPRINT cr$ + "[L]Leave Message for Sysop"
  140.                  ' Level 2 or 3
  141.         IF access_level > 1  THEN
  142.             RPRINT cr$ + "[CD]Change Directory [FS]File Specification"
  143.         ENDIF
  144.  
  145.         ' Level 3 only
  146.         IF access_level > 2 then
  147.             RPRINT cr$ + "[AU]Add User         [CU]Change User"
  148.             RPRINT cr$ + "[DU]Delete User      [S]ShutDown"
  149.         ENDIF
  150.  
  151.         RPRINT cr$ + "[G]Goodbye"
  152.  
  153.         ' Wait for command
  154.         RINPUT cr2$+ "> ", tempcommand$
  155.         command$ = upper(tempcommand$)
  156.  
  157.         ' Exit System
  158.         if len(command$) = 1 then
  159.             IF command$ = "G"  THEN
  160.                 RPRINT cr$ + "Thanks for calling " + first$ + "!" + cr$
  161.                 continue_commands = 0
  162.                 SLEEP 5
  163.             ENDIF
  164.         
  165. '--------------------------------------------------------------------
  166. 'Leave message to Sysop
  167.         IF command$ = "L" THEN
  168.         m9=0
  169.         RPRINT newpage$
  170.         log$=first$+"_msg"
  171.             Is_ok=DoesFileExist(log$)
  172.             If Is_ok=1 THEN 
  173.             RPRINT "Opening Message Log,  Please wait." + cr2$
  174.             ELSE log$=last$+"_msg"
  175.                 Is_ok=DoesFileExist(log$)
  176.                 If Is_ok=1 THEN 
  177.                 RPRINT "Opening Message Log,  Please wait." + cr2$
  178.                 ELSE log$=password$+"_msg"
  179.                     Is_ok=DoesFileExist(log$)
  180.                     If Is_ok=1 THEN 
  181.                     RPRINT "Opening Message Log,  Please wait." + cr2$
  182.                     ELSE m9=1
  183.                     ENDIF    
  184.                 ENDIF            
  185.             ENDIF    
  186.         IF m9=1 THEN
  187.         RPRINT "Unable to access Message log at this time, Sorry."
  188.         ELSE
  189.         OPENLOG log$
  190.         RINPUT "SUBJECT:  ",temp9$
  191.         HOLDLOG
  192.         RPRINT cr2$+"Begin Message"
  193.         RPRINT cr$+"Type [*] when complete" + cr2$
  194.         RESUMELOG
  195.         WAITFOR "*"
  196.         CLEAR
  197.         CLOSELOG
  198.         SLEEP 1
  199.         ENDIF
  200.         ENDIF
  201.  
  202. 'Change Password
  203.         IF command$="P" THEN
  204.         RINPUT cr2$ + "Enter new Password:  ",New_password$  
  205.         ilevel = access_level
  206.         is_ok = ChangeUser(first$,last$,New_password$,ilevel)
  207.             IF is_ok > 0 THEN
  208.             RPRINT cr$+"Unable to Change Password!!"+cr$
  209.             ELSE
  210.             RPRINT cr$ + first$ + " " + last$ + "'s"
  211.             RPRINT "successfully changed." + cr$
  212.             RINPUT "Accept Change?  (Y/N)  ", temp2$
  213.             temp3$=UPPER(temp2$)
  214.                 IF temp3$ = "N" THEN
  215.                 is_ok=ChangeUser(first$,last$,password$,ilevel)
  216.                 ELSE
  217.                 password$=new_password$
  218.                 ENDIF
  219.             ENDIF
  220.         ENDIF
  221.  
  222. 'Page the Sysop
  223.         IF command$="R" THEN
  224.         RPRINT newpage$
  225.         RPrint cr5$+"Paging the Sysop, Please wait."
  226.         FOR x=1 to 30
  227.         SLEEP 1
  228.         BEEP
  229.         NEXT
  230.         RPRINT newpage$ + "The Sysop has been paged. " + cr2$
  231.         RPRINT "If you have not yet received a response, He is not available." + cr4$
  232.         ENDIF
  233.  
  234. 'Chat Mode
  235.         IF command$="C" THEN
  236.         CLEAR
  237.         RPRINT "Begin Chat "  + cr$
  238.         RPRINT "Type BYE to exit chat"+cr2$
  239.         WAITFOR "BYE"
  240.         SLEEP 1
  241.         ENDIF
  242.  
  243. '-----------------------------------------------------------------------            
  244.                     ' List Files
  245.             IF command$ = "F" THEN
  246.                 RPRINT cr4$
  247.                 RPRINT "Directory listing of: " + current_dir$ + cr2$
  248.                 ChangeDirectory(current_dir$)
  249.                    filename$ = GetFirstDirEntry(current_dir$, file_spec$)
  250.                 WHILE Len(filename$) > 0
  251.                     IF Connected = 0 Then
  252.                            EXIT
  253.                     endif
  254.                     FOR i = 1 to max_lines
  255.                         RPRINT filename$ + cr$
  256.                         filename$ = GetNextDirEntry()
  257.                         IF Len(filename$) = 0 THEN
  258.                             EXIT
  259.                         ENDIF
  260.                     NEXT
  261.                     IF LEN(filename$) > 0 THEN
  262.                           Rinput cr$+"List paused.  Press ENTER to continue.",temp$
  263.                           IF "C" = upper(temp$) THEN
  264.                                exit
  265.                             ENDIF
  266.                             rprint cr4$
  267.                     ENDIF
  268.                 WEND
  269.  
  270.                 RINPUT cr$+"End of List.   Press ENTER to Continue",temp$
  271.                 rprint cr4$
  272.             ENDIF
  273.  
  274.             ' Download a File
  275.             IF command$ = "D" THEN
  276.                 rprint cr4$
  277.                 WHILE 1 = 1
  278.                     IF Connected = 0 Then
  279.                            EXIT
  280.                     endif
  281.                     RPRINT cr$+Header$+cr3$
  282.                     RPRINT cr$+"Available download file transfer protocols:" + cr2$
  283.                     RPRINT "[X]..XMODEM Checksum" + cr$
  284.                     RPRINT "[C]..XMODEM CRC" + cr$
  285.                     RPRINT "[Y]..YMODEM 1K" + cr$
  286.                     RPRINT "[YB].YMODEM Batch" + cr$
  287.                     RPRINT "[YG].YMODEM G" + cr$
  288.                     RPRINT "[Z]..ZMODEM" + cr$
  289.                     RPRINT "[E]..Cancel" + cr$
  290.                     RINPUT "Select protocol: ", tempchoice$
  291.                     choice$ = upper(tempchoice$)
  292.                     if len(choice$) = 1 then
  293.                           IF choice$ = "E" THEN
  294.                             EXIT
  295.                         ENDIF
  296.                         IF choice$ = "X" THEN
  297.                             set protocol XMODEM
  298.                             EXIT
  299.                         ENDIF
  300.                         IF choice$ = "C" THEN
  301.                             set protocol XMODEMCRC
  302.                             EXIT
  303.                         ENDIF
  304.                         IF choice$ = "Y" THEN
  305.                             set protocol YMODEM
  306.                             EXIT
  307.                         ENDIF
  308.                         IF choice$ = "Z" THEN
  309.                             set protocol ZMODEM
  310.                             EXIT
  311.                         ENDIF
  312.                     endif
  313.                     if len(choice$) = 2 then
  314.                         IF choice$ = "YB" THEN
  315.                             set protocol YMODEMB
  316.                             EXIT
  317.                         ENDIF
  318.                         IF choice$ = "YG" THEN
  319.                             set protocol YMODEMG
  320.                             EXIT
  321.                         ENDIF
  322.                     ENDIF
  323.                     rprint cr2$+"Invalid Selection"+cr2$
  324.                 WEND
  325.                    IF choice$ = "E" THEN
  326.                     rprint "Canceled!"+cr$
  327.                    ELSE
  328.                        ChangeDirectory(current_dir$)
  329.                       RINPUT cr2$+"Enter Filename: ", transfer_file$
  330.                       is_ok = DoesFileExist(transfer_file$)
  331.                       IF is_ok = 1 THEN
  332.                          RPRINT cr$+"File " + transfer_file$ + " was not found." + cr$
  333.                          RPRINT "File transfer canceled!" + cr$
  334.                       ELSE
  335.                          RPRINT cr$+"Downloading " + transfer_file$ + cr$
  336.                          ONERROR snderr
  337.                         SEND transfer_file$
  338.                         sleep 3
  339.                          rprint cr$+"File Transfer Successful"
  340.                          goto sndok
  341.                          snderr:
  342.                               rprint cr2$+"Error Downloading File"
  343.                            rinput cr$+"Hit ENTER to Continue",temp$
  344.                          sndok:
  345.                          set error off
  346.                        ENDIF
  347.                    ENDIF
  348.             ENDIF
  349.         ' Receive a File
  350.             IF command$ = "U" THEN
  351.                 rprint cr4$
  352.                 WHILE 1 = 1
  353.                     IF Connected = 0 Then
  354.                            EXIT
  355.                     endif
  356.                     RPRINT cr$+Header$+cr3$
  357.                     RPRINT "Available Upload file transfer protocols:" + cr2$
  358.                     RPRINT "[X]..XMODEM Checksum" + cr$
  359.                     RPRINT "[C]..XMODEM CRC" + cr$
  360.                     RPRINT "[Y]..YMODEM 1K" + cr$
  361.                     RPRINT "[YB].YMODEM Batch" + cr$
  362.                     RPRINT "[YG].YMODEM G" + cr$
  363.                     RPRINT "[Z]..ZMODEM" + cr$
  364.                     RPRINT "[E]..Exit" + cr$
  365.                     RINPUT "Select protocol: ", tempchoice$
  366.                     choice$ = upper(tempchoice$)
  367.                     if len(choice$) = 1 then
  368.                           IF choice$ = "E" THEN
  369.                             EXIT
  370.                         ENDIF
  371.                         IF choice$ = "X" THEN
  372.                             set protocol XMODEM
  373.                             RINPUT cr$+"Enter Filename: ", transfer_file$
  374.                             is_ok = ValidFileName(transfer_file$)
  375.                             EXIT
  376.                         ENDIF
  377.                         IF choice$ = "C" THEN
  378.                             set protocol XMODEMCRC
  379.                             RINPUT cr$+"Enter Filename: ", transfer_file$
  380.                             is_ok = ValidFileName(transfer_file$)
  381.                             EXIT
  382.                         ENDIF
  383.                         IF choice$ = "Y" THEN
  384.                             set protocol YMODEM
  385.                             RINPUT cr$+"Enter Filename: ", transfer_file$
  386.                             is_ok = ValidFileName(transfer_file$)
  387.                             EXIT
  388.                         ENDIF
  389.                         IF choice$ = "Z" THEN
  390.                             set protocol ZMODEM
  391.                             transfer_file$ = ""
  392.                             is_ok = 1
  393.                             EXIT
  394.                         ENDIF
  395.                     ENDIF
  396.                     if len(choice$) = 2 then
  397.                         IF choice$ = "YB" THEN
  398.                             set protocol YMODEMB
  399.                             transfer_file$ = ""
  400.                             is_ok = 1
  401.                             EXIT
  402.                         ENDIF
  403.                         IF choice$ = "YG" THEN
  404.                             set protocol YMODEMG
  405.                             transfer_file$ = ""
  406.                             is_ok = 1
  407.                             EXIT
  408.                         ENDIF
  409.                     ENDIF
  410.                     rprint cr2$+"Invalid Selection"+cr2$
  411.                 WEND
  412.                   IF choice$ = "E" THEN
  413.                       rprint cr$+"Canceled"+cr$
  414.                   ELSE
  415.                     IF is_ok = 0 THEN
  416.                         RPRINT "File " + transfer_file$ + " was not valid." + cr$
  417.                         RPRINT "File transfer canceled!" + cr$
  418.                     ELSE
  419.  
  420.                         ChangeDirectory(upload_dir$)
  421.                          ONERROR rcverr
  422.                         RPRINT cr2$+"Uploading " + transfer_file$ +cr$
  423.                         RPRINT cr$+"Start Your File Transfer"+cr$
  424.                         RECEIVE transfer_file$
  425.                         sleep 3
  426.                         RPRINT cr$+"File Transfer Successful"+cr$
  427.                         GOTO rcvok
  428.                         rcverr:
  429.                           Rprint "Error Uploading File - "+transfer_file$+cr$
  430.                           rinput "Hit Enter to Continue",temp$
  431.                         rcvok:
  432.                         ChangeDirectory(current_dir$)
  433.                         set error off
  434.                     ENDIF
  435.                   ENDIF
  436.             ENDIF
  437.             IF command$ = "S" THEN
  438.                 RPRINT cr$+"Shutdown Initiated"
  439.                 continue = 0
  440.                 continue_commands = 0
  441.             ENDIF
  442.  
  443.         ' Change Directory
  444.         ENDIF
  445.         if len(command$) = 2 then
  446.              IF command$ = "CD" THEN
  447.                 IF access_level > 1 THEN
  448.                     RINPUT cr$+"Enter New Directory: ", new_dir$
  449.                     is_ok = ChangeDirectory(new_dir$)
  450.                     if is_ok = 0 then
  451.                         current_dir$ = new_dir$
  452.                     ELSE
  453.                         RPRINT cr2$+"Unable to change to directory!"
  454.                     ENDIF
  455.                 ENDIF
  456.             ENDIF
  457.  
  458.             IF command$ = "FS" Then
  459.                    RPRINT cr2$+"Current File Specification is "+file_spec$+cr$
  460.                    RINPUT cr$+"Enter New File Specification: ", file_spec$
  461.                    IF LEN(file_spec$) = 0 THEN
  462.                       file_spec$ = filespec
  463.                    ENDIF
  464.             ENDIF
  465.         ' Add a New User
  466.             IF command$ = "AU" THEN
  467.                 IF access_level > 2 THEN
  468.                     rprint cr4$
  469.                     RPRINT cr$+Header$+cr$
  470.                     RPRINT  "Add a new user." + cr$
  471.                     RINPUT cr$+"Enter new user's First name: ", new_first$
  472.                     RINPUT cr$+"Enter new user's Last name: ", new_last$
  473.                     RINPUT cr$+"Enter new user's Password: ", new_password$
  474.                     RINPUT cr$+"Enter new user's Access level: ", new_level$
  475.                     iLevel = val(new_level$)
  476.                     is_ok = AddUser(new_first$, new_last$, new_password$, iLevel)
  477.                     IF is_ok > 0 THEN
  478.                         RPRINT cr$+"Unable to add user record!" + cr$
  479.                     ELSE
  480.                         RPRINT cr$+new_first$+" "+new_last$+" added to datafile." + cr$
  481.                     ENDIF
  482.                 ENDIF
  483.             ENDIF
  484.  
  485.         ' Change an Existing User
  486.             IF command$ = "CU" THEN
  487.                 IF access_level > 2 THEN
  488.                     rprint cr4$
  489.                     RPRINT cr$+Header$+cr$
  490.                     RPRINT  "Change an existing user." + cr$
  491.                     RINPUT cr$+"Enter user's First name: ", new_first$
  492.                     RINPUT cr$+"Enter user's Last name: ", new_last$
  493.                     RINPUT cr$+"Enter user's new Password or blank to skip: ", new_password$
  494.                     RINPUT cr$+"Enter new Access Level: ", new_level$
  495.                     iLevel = val(new_level$)
  496.                     is_ok = ChangeUser(new_first$, new_last$, new_password$, iLevel)
  497.                     IF is_ok > 0 THEN
  498.                         RPRINT cr$+"Unable to change user record!" + cr$
  499.                     ELSE
  500.                         RPRINT cr$+new_first$+" "+new_last$+ " access level changed."+cr$
  501.                     ENDIF
  502.                 ENDIF
  503.             ENDIF
  504.  
  505.         ' Delete an Existing User
  506.             IF command$ = "DU" THEN
  507.  
  508.                 IF access_level > 2 THEN
  509.                     rprint cr4$
  510.                     RPRINT cr$+Header$+cr$
  511.                     RPRINT  "Delete an existing user." + cr$
  512.                     RINPUT cr$+"Enter user's First name: ", new_first$
  513.                     RINPUT cr$+"Enter user's Last name: ", new_last$
  514.                     is_ok = DeleteUser(new_first$, new_last$)
  515.                     IF is_ok > 0 THEN
  516.                         RPRINT cr$+"Unable to delete user record!" + cr$
  517.                     ELSE
  518.                         RPRINT cr$+new_first$+" "+new_last$+" deleted." + cr$
  519.                     ENDIF
  520.                 ENDIF
  521.             ENDIF
  522.         ENDIF
  523.     WEND
  524.     force_hangup:
  525.         HANGUP
  526. WEND
  527. Mprint "Script Terminated"
  528. END
  529.