home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / windows / host2.zip / HOST.XWS < prev    next >
Text File  |  1991-01-03  |  15KB  |  605 lines

  1. /*  SYSTEM HOST SCRIPT
  2.  
  3. Written by Steven Kieffer
  4. 8/25/1990
  5. */
  6.  
  7.  
  8.  
  9.  
  10. STRING login_txt, pass_word, mail, username, userpassword
  11. STRING data_in, char, logtime
  12. INTEGER counter, keychar, bytes, mail_to, sysop
  13.  
  14.  
  15. -- FILES DIRECTORY SET-UP
  16.  
  17. if null(arg(1)) then 
  18.     {
  19.     alarm 
  20.     alert "No host file directory specified, (e.g.  HOST C:\COMM).",OK
  21.     end
  22.     }
  23. menu_txt = arg(1) + "\menu.hst" 
  24. Login_txt = arg(1) + "\login.hst"
  25. pass_word = arg(1) + "\password.hst"
  26. mail = arg(1) + "\mail.hst"
  27. help_txt = arg(1) + "\help.hst"
  28.  
  29.  
  30. clear
  31. linedelim = "^M^J"
  32. packetsize=1024
  33. --MODEM INITIALIZATION
  34.  
  35. label init
  36. if online then bye : wait 2 seconds
  37. TRAP ON
  38. display off
  39. message "Initializing modem..."
  40. GO 
  41. wait 2 seconds : reply modeminit
  42. wait 2 seconds : reply answersetup
  43.  
  44. --WAIT FOR CALLER
  45. label wait
  46. CLS
  47. display on
  48. Print "WAITING FOR CALLER..."
  49. if not null(username) then 
  50.     {
  51.     print : print 
  52.     print "The last caller was, " + username + ", who logged"
  53.     print "in at " + logtime + "."
  54.     }
  55. message "ESC=shutdown host  ENTER=enter system"
  56. while not online
  57.  
  58.         keychar=inkey
  59.         if keychar=27 then goto shutdown
  60.         if keychar=13 then username = "Sysop" : goto start
  61.     if error then goto init
  62. wend
  63.  
  64.  
  65. --LOG ON SEQUENCE
  66.  
  67. label logon
  68. counter=0
  69.  
  70. repeat
  71. username=""
  72. userpassword=""
  73.         counter = counter + 1
  74.     wait 1 second
  75.         if online then reply:reply "^L":reply "^G"
  76.         print "^L" : print "^G"
  77.     if error then goto init
  78.         wait 1 second
  79.         
  80.         if online then reply "What is your name or handle? ";
  81.         print "What is your name or handle? ";
  82.         
  83.         repeat 
  84.                 char = nextchar
  85.                 if error then goto init
  86.                 if not null(char) and char<>"^M" then 
  87.                         {
  88.                         username = username + char
  89.             if char = "^H" then username=left(username,length(username)-2)
  90.                         print char; : if online then reply char;                
  91.                         if error then goto init
  92.                         }
  93.         until char = "^M"
  94.         
  95.         if username is "" then goto bye_bye 
  96.                         
  97.         print : if online then reply
  98.         if online then reply "What is your password? "; 
  99.         print "What is your password? ";
  100.         nextline userpassword,30,30
  101.  
  102. --Check password
  103.  
  104. if error then goto init
  105. username = upcase(username)
  106. userpassword = upcase(userpassword)
  107. if exists(pass_word) then open input pass_word as 1 
  108.     else alert "Could not find PASSWORD.HST file !!!",ok : goto shutdown
  109. repeat
  110.         read line #1,data_in
  111.     data_in = upcase(data_in)
  112.         if slice(data_in,1,";")=username and slice(data_in,2,";")=userpassword then
  113.                 {
  114.                 close #1
  115.                 goto start
  116.                 }
  117.         until eof
  118. close #1       
  119.  
  120. until counter is 3
  121. goto bye_bye
  122.  
  123.  
  124. --Start of host system
  125.  
  126. label start
  127.  
  128. logname = username
  129. logtime = time
  130. if exists(login_txt) then gosub send_login
  131.  
  132. label command
  133. repeat
  134.  
  135. message username + " is online!  ESC=hang-up user.  X=delete mail"
  136.  
  137.         if exists(menu_txt) then
  138.                 {
  139.                 open input menu_txt as 1
  140.                         while not EOF
  141.                         read line #1, data_in
  142.                         if online then reply data_in
  143.                         print data_in
  144.                         wend
  145.                 close #1
  146.                 }
  147.     else alert "Could not find MENU.HST file !!!",ok : goto shutdown
  148.  
  149. --Check for input
  150. while inkey : wend
  151. repeat : until null(nextchar)
  152. keychar=0 : char=""
  153.  
  154.         while keychar=0 and char=""
  155.                 keychar=inkey
  156.                 if keychar then gosub check_cmd
  157.                 if error then goto init
  158.         
  159.                 char=nextchar
  160.                 if error then goto init
  161.                 if not null(char) then gosub check_cmd
  162.                 if error then goto init
  163.         wend
  164.  
  165. until keychar=27
  166.  
  167. goto bye_bye
  168.  
  169. --check command
  170.  
  171. label check_cmd
  172. if keychar <> 0 then char = chr(keychar) : Sysop is true
  173. char=upcase(char)
  174.  
  175. if char = "C" then gosub chat_command
  176. if char = "D" then gosub download_command
  177. if char = "F" then gosub files_command
  178. if char = "G" then goto bye_bye
  179. if char = "H" then gosub help_command
  180. if char = "R" then gosub readmail_command
  181. if char = "P" then gosub postmail_command
  182. if char = "T" then gosub time_command
  183. if char = "U" then gosub upload_command
  184. if char = "X" then gosub clearmail_command
  185.  
  186. return
  187.  
  188.  
  189.  
  190. --SEND LOGIN MESSAGE
  191.  
  192. label send_login
  193.  
  194. if online then reply "^L"
  195. display on
  196. cls
  197.         open input login_txt as #1
  198.                 while not EOF
  199.                 read line #1, data_in
  200.                 if online then reply data_in
  201.                 print data_in
  202.                 wend
  203.         close #1 
  204.  
  205. return
  206.  
  207. --BYE sequence
  208.  
  209. label bye_bye
  210. if online then 
  211.         {
  212.         reply "^G^G"
  213.         reply "GOOD-BYE " + username + " !!!"
  214.         }
  215. print "^G^G"
  216. print "GOOD-BYE " + username + " !!!"
  217.  
  218. wait 1 second
  219. bye : wait 2 seconds
  220. goto init
  221.  
  222. --Shutdown routine
  223.  
  224. label shutdown
  225. cls
  226. print "Shutting down host..."
  227. display off
  228. wait 2 seconds
  229. if online then reply "+++";
  230. wait 2 seconds
  231. reply "ATS0=0" 
  232. wait 1 second : reply
  233. display on
  234. bye : cls : print "Host is shutdown." : alarm : end
  235.  
  236. -- ******COMMAND ROUTINES*******
  237.  
  238.  
  239. --download routine
  240.  
  241. label download_command
  242. if not online then 
  243.         {
  244.         print "You must be online.  Remote function only."
  245.         return
  246.         }
  247.  
  248. cls : if online then reply "^L"
  249. Print "== DOWNLOAD A FILE =="
  250. if online then reply "== DOWNLOAD A FILE =="
  251. print : if online then reply
  252. if online then reply "Select a protocol:"
  253. print "Select a protocol:"
  254. if online then reply
  255. if online then reply "X)modem/CRC  Y)modem/batch  Z)modem  D)art"
  256. print "X)modem/CRC  Y)modem/batch  Z)modem  D)art"
  257.  
  258.         watch 30 seconds for
  259.                 "x"     : protocol "xmodem/crc" : goto download
  260.                 "y"     : protocol "ymodem/batch" : goto download
  261.                 "z"     : protocol "zmodem" : goto download
  262.                 "d"     : protocol "dart" : goto download
  263.         endwatch
  264.  
  265. return
  266.  
  267.  
  268. label download
  269. data_in=""
  270. if online then reply : reply protocol : reply
  271. print : print protocol : print
  272. print "Name of file to download? ";
  273. if online then reply "Name of file to download? "; 
  274. repeat 
  275.                 char = nextchar
  276.                 if error then goto init
  277.                 if not null(char) and char<>"^M" then 
  278.                         {
  279.                         data_in = data_in + char
  280.             if char = "^H" then data_in = left(data_in,length(data_in)-2)
  281.                         print char; : if online then reply char;                
  282.                         if error then goto init
  283.                         }
  284.         until char = "^M"
  285. if online then reply : print
  286. data_in = dirfil + "\" + data_in
  287. if exists(data_in) then
  288.         {
  289.         if online then reply "^GStart your download..."
  290.         print "^GStart your download..."
  291.         send data_in
  292.         }
  293.     else return
  294.  
  295. if online then reply : reply "^G^G^GDownload process completed !!!"
  296. print : print "^G^G^GDownload process completed !!!"
  297. if online then reply : print
  298. return
  299.  
  300. --upload routine
  301.  
  302. label upload_command
  303. if not online then
  304.         {
  305.         print "You must be online.  Remote function only."
  306.         return
  307.         }
  308.  
  309. cls : if online then reply "^L"
  310. print "== UPLOAD A FILE =="
  311. if online then reply"== UPLOAD A FILE =="
  312. print : if online then reply
  313. reply "Select a protocol:"
  314. print "Select a protocol:"
  315. reply : print
  316. reply "X)modem/CRC  Y)modem/batch  Z)modem  D)art"
  317. print "X)modem/CRC  Y)modem/batch  Z)modem  D)art"
  318.  
  319.         watch 30 seconds for
  320.                 "x"     : protocol "xmodem/crc" : goto upload
  321.                 "y"     : protocol "ymodem/batch" : goto upload
  322.                 "z"     : protocol "zmodem" : goto upload
  323.                 "d"     : protocol "dart" : recovery on : recvmode=1 : goto upload
  324.         endwatch
  325.  
  326. return
  327.  
  328. label upload
  329.  
  330. data_in=""
  331. if online then reply : reply protocol : reply
  332. print : print protocol : print
  333. print "Name of file to upload? ";
  334. if online then reply "Name of file to upload? "; 
  335. repeat 
  336.                 char = nextchar
  337.                 if error then goto init
  338.                 if not null(char) and char<>"^M" then 
  339.                         {
  340.                         data_in = data_in + char
  341.             if char = "^H" then data_in = left(data_in,length(data_in)-2)
  342.                         print char; : if online then reply char;                
  343.                         if error then goto init
  344.                         }
  345.         until char = "^M"
  346.  
  347. if online then reply : reply "^GStart your upload..."
  348. print : print "^GStart your upload..."
  349. receive data_in
  350. if error then return
  351.  
  352. if online then reply : reply "^G^G^GUpload process completed !!!"
  353. print : print "^G^G^GUpload process completed !!!"
  354. if online then reply : print
  355. return
  356.  
  357. --Files directory routine
  358.  
  359. label files_command
  360. cls : if online then reply "^L"
  361. if online then reply "Files available for downloading:" : reply
  362. print "Files available for downloading:" : print
  363.  
  364. char = filefind(dirfil + "\*.*")
  365. bytes = filesize(dirfil + "\*.*")
  366. repeat
  367.         print pad(char,16); : if online then reply pad(char,16);
  368.         print bytes : if online then reply bytes
  369.         char = filefind
  370.         bytes = filesize
  371. until null(char)
  372. print : if online then reply
  373. wait 1 second
  374. keychar=1
  375. return
  376.  
  377. --Help routine
  378.  
  379. label help_command
  380. if not exists(help_txt) then return
  381. counter=0
  382. cls : if online then reply "^L"
  383. open input help_txt as #1
  384.         repeat
  385.         counter=counter +1
  386.                 read line #1, data_in
  387.                 if online then reply data_in
  388.                 print data_in
  389.         if counter=20 then
  390.             {
  391.             print "---Press any key to continue---";
  392.             if online then reply "---Press any key to continue---";
  393.                 repeat 
  394.                 keychar=inkey
  395.                 char=nextchar
  396.                 until keychar or not null(char)
  397.             print "^M"; : if online then reply "^M";    
  398.             print "                                 ";
  399.             if online then reply "                               ";
  400.             print "^M"; : if online then reply "^M";
  401.             }
  402.         until EOF
  403. close #1
  404. wait 1 second
  405. print : if online then reply
  406. return
  407.  
  408.         
  409. --Chat routine
  410.  
  411. label chat_command
  412.  
  413.  
  414. if sysop then
  415.     {
  416.     if online then reply "The Sysop would like to chat with you...^G^G"
  417.     print "The Sysop would like to chat with you..."
  418.     }
  419.     else print "Paging the Sysop..." : if online then reply "Paging the Sysop..."
  420.     
  421. sysop is false
  422. counter is 0
  423.  
  424. repeat
  425. counter=counter + 1
  426. alarm : alarm
  427. wait 1 second
  428. until counter=3
  429.  
  430. cls : if online then reply "^L"
  431. message username + " is online.  Press // when done."
  432. if online then reply "== WHEN YOU ARE FINISHED CHATTING, PRESS // TO EXIT =="
  433. print "== WHEN YOU ARE FINISHED CHATTING, PRESS // TO EXIT =="
  434. if online then reply "____________________________________________________________"
  435. print "____________________________________________________________"
  436.  
  437. counter=0
  438. repeat
  439.         char=nextchar
  440.         if error then goto init
  441.         if not null(char) then 
  442.                 {
  443.                 print char;
  444.                 if online then reply char;
  445.                 if error then goto init
  446.         if char="/" then counter=counter+1 else counter=0
  447.                 }
  448.         keychar=inkey
  449.         if keychar then
  450.                 {
  451.                 print chr(keychar);
  452.                 if online then reply chr(keychar);
  453.                 if error then goto init
  454.         if chr(keychar)="/" then counter=counter+1 else counter=0
  455.                 }
  456.         if char = "^M" or chr(keychar) = "^M" then 
  457.         {
  458.         print : if online then reply 
  459.         }
  460. until counter=2
  461. print : if online then reply
  462. return
  463.  
  464. --Time routine
  465.  
  466. label time_command
  467.  
  468. print : if online then reply
  469. print "The current time is: "; : print time
  470. if online then reply "The current time is: "; : reply time
  471. print : if online then reply
  472.  
  473. return
  474.  
  475. --Read Mail routine
  476.  
  477. label readmail_command
  478. cls : if online then reply "^L"
  479.  
  480. if exists(mail) then
  481.     {
  482.     open input mail as #1
  483.         repeat 
  484.         read line #1,data_in
  485.             if data_in="***END***" then
  486.             {
  487.             data_in=""
  488.             if online then reply "Press ENTER to continue.  Press / to exit."
  489.             print "Press ENTER to continue.  Press / to exit."
  490.                 repeat
  491.                 char=nextchar
  492.                 keychar=inkey
  493.                     if intval(char)=47 or keychar=47 then
  494.                     {
  495.                     close #1 : print : if online then reply
  496.                     keychar=1 : return
  497.                      }
  498.                 until char="^M" or keychar=13
  499.             cls : if online then reply "^L"
  500.             }
  501.         if online then reply data_in
  502.         print data_in
  503.         until EOF(1)
  504.     close #1
  505.     return
  506.     }
  507.  
  508. if online then reply "No mail today !!!"
  509. print "No mail today !!!"
  510. return
  511.  
  512.  
  513. --Post mail routine
  514.  
  515. label postmail_command
  516.  
  517. data_in=""
  518. while intval(char) : wend
  519. counter = 0
  520. mail_to is false
  521. cls : if online then reply "^L"
  522. open append mail as #1
  523. if online then reply "== WHEN FINISHED TYPING LETTER, PRESS // TO EXIT =="
  524. print "== WHEN FINISHED TYPING LETTER, PRESS // TO EXIT =="
  525. print : if online then reply
  526. if online then reply "Letter to: ";
  527. print "Letter to: ";
  528.  
  529. repeat
  530.         char=nextchar
  531.     keychar=inkey
  532.         if char = "^M" or keychar = 13 then gosub write_routine
  533.         if not null(char) then 
  534.                 {
  535.                 print char;
  536.                 if online then reply char;
  537.         if char = "/" then counter=counter+1 else counter=0
  538.         data_in = data_in + char
  539.         if char = "^H" then data_in = left(data_in,length(data_in)-2)
  540.                 }
  541.  
  542.         if keychar then
  543.                 {
  544.                 print chr(keychar);
  545.                 if online then reply chr(keychar);
  546.         if chr(keychar)="/" then counter=counter+1 else counter=0
  547.         data_in = data_in + chr(keychar)
  548.         if keychar=8 then data_in = left(data_in,length(data_in)-2)
  549.                 }
  550.  
  551. until counter=2
  552.  
  553. write line #1, ""
  554. write line #1, "______________________________________"
  555. write line #1, "***END***"
  556. close #1
  557.  
  558. print : if online then reply
  559. return
  560.  
  561. --write sub-routine
  562.  
  563. label write_routine
  564.  
  565.         print : if online then reply
  566.         if mail_to then write line #1, data_in ELSE
  567.             {
  568.             write line #1, "TO: " + data_in
  569.             write line #1, "FROM: " + username
  570.             write line #1, "______________________________________"
  571.             write line #1, ""
  572.             print "______________________________________"            
  573.             if online then reply "______________________________________"
  574.             print : if online then reply
  575.             }
  576.         data_in=""
  577.         char="" : keychar=0
  578.         mail_to is true            
  579.         print ">";
  580.         if online then reply ">";
  581. return
  582.  
  583.  
  584. --clear mail routine
  585.  
  586. label clearmail_command
  587. if online then 
  588.     {
  589.     alarm
  590.     print "Privileged SYSOP command!  Must be offline to use."
  591.     return
  592.     }
  593.  
  594. alarm
  595. print "Are you sure you want to erase the mail ? [y/n] ";
  596. input char
  597. if upcase(char) = "Y" then 
  598.     {
  599.     if exists(mail) then delete mail
  600.     print "Mail is deleted !!!"
  601.     return
  602.     }
  603. return
  604.  
  605.