home *** CD-ROM | disk | FTP | other *** search
/ .net 1999 December / netCD65.iso / pc / Software / VirtualA / 32bit / vasetup.exe / %MYDIR% / INTERNET.EBS < prev    next >
Encoding:
Text File  |  1999-10-06  |  11.5 KB  |  378 lines

  1. 'T:INTERNET.EBS for CIX
  2. ' VA 4.52 release
  3.  
  4. 'Add file to import queue
  5. Declare Function AddToDoList16 Pascal Lib "addons.dll" Alias "AddToDoList" (ByVal szService As String, ByVal szFileName As String, ByVal szMailname As String, ByVal iFlags As Long) As Integer
  6. Declare Function AddToDoList32 Pascal Lib "addons32.dll" Alias "AddToDoList" (ByVal szService As String, ByVal szFileName As String, ByVal szMailname As String, ByVal iFlags As Long) As Long
  7. Declare Function AddFileToMessageBase(topic As String, subject As String, filename As String)
  8. Declare Sub SendYes(t As Tracker)
  9. Declare Sub TrackFailure(s As String)
  10.  
  11. Dim lastprompt As String       'Tracker name of the last prompt encountered
  12. Dim MailID As String           'ID of current mail or deferred command
  13. Public Success As Boolean      'Whether command succeeded
  14. Dim Failure As String           'Reason command failed (CIX error message)
  15. Dim sctrack As Tracker           'Success/Failure tracker
  16. Dim messagescript As String       'File name of CIX script to upload
  17. Dim DownloadFTPid As String       'Deferred FTPDown command ID
  18. Dim SeenFTPFile As Boolean       'There are some FTP files to download
  19. Dim LastArea As String           'Main or Newsnet
  20.  
  21. 'T:EnterFTP (function) (CIX)
  22. Function EnterFTP(id As String, sitename As String, directory As String, bin As Boolean)
  23.     GotoArea "Main"
  24.     On Error Goto EnterFTP_error
  25.     Comms.Send "run internet\r"
  26.     WaitForPrompt "PromptIp"
  27.     Comms.Send "ftp\r"
  28.     WaitForPrompt "PromptFtp"
  29.     Comms.SendLiteral "open " + sitename
  30.     Comms.Send "\r"
  31.     WaitForTimed "):", 1200
  32.     Comms.Send "anonymous\r"
  33.     WaitForTimed "word:", 1200
  34.     Comms.Send Session.LoginName + "@cix.compulink.co.uk\r"
  35.     WaitForPrompt "PromptFtp"
  36.     If bin Then
  37.         Comms.Send "prompt\r"
  38.         WaitForPrompt "PromptFtp"
  39.         Comms.Send "binary\r"
  40.     Else
  41.         Comms.Send "ascii\r"
  42.     End If
  43.     WaitForPrompt "PromptFtp"
  44.     Comms.SendLiteral "cd " + directory
  45.     Comms.Send "\r"
  46.     WaitForPrompt "PromptFtp"
  47.     EnterFTP = True
  48.     Exit Function
  49. EnterFTP_error:
  50.     ReportFailure id, "Error logging in to " + sitename
  51.     Comms.Send "quit\r"
  52.     WaitForMainPrompt
  53.     EnterFTP = False
  54. End Function
  55.  
  56. 'T:SingleIPCommand (subroutine) (CIX)
  57. Sub SingleIPCommand(id As String, comnd As String, param As String, desc As String)
  58.     Dim capname As String
  59.  
  60.     GotoArea "Main"
  61.     Comms.Send "run internet\r"
  62.     WaitForPrompt "PromptIp"
  63.     Comms.SendLiteral comnd + " " + param
  64.     Comms.Send "\r"
  65.     capname = Session.ServicePath + comnd + ".tmp"
  66.     Capture CAPTURE_ON, capname
  67.     TimedWaitForPrompt "PromptIp", 600    'don't know how long this takes
  68.     Capture CAPTURE_OFF
  69.     Comms.Send "quit\r"
  70.     WaitForMainPrompt
  71.     If AddFileToMessageBase("actions/" + comnd, desc + ": " + param, capname) Then
  72.         ReportSuccess id & " : " & desc & " " & param
  73.     Else
  74.         ReportFailure id, Error$
  75.     End If
  76. End Sub
  77.  
  78. 'T:GotFTPFile (subroutine) (CIX)
  79. Sub GotFTPFile(t As Tracker)
  80.     SeenFTPFile = True
  81.     t.reset
  82. End Sub
  83.  
  84. 'T:DoFTPDownload (subroutine) (CIX)
  85. Sub DoFTPDownload(id As String)
  86.     Dim t As Tracker
  87.  
  88.     GotoArea "Main"
  89.     Comms.Send "run internet\r"
  90.     WaitForPrompt "PromptIp"
  91.     Comms.Send "dir\r"
  92.     Set t = CreateTracker("tGotFTPFile", ":", "GotFTPFile")
  93.     SeenFTPFile = False
  94.     WaitFor "ip>"
  95.     t.delete
  96.     If SeenFTPFile Then
  97.         Comms.Send "send *\r"
  98.         WaitFor "\*\*"
  99.         FileDownload PROT_ZMODEM
  100.         WaitFor "ip>"        'Does not appear on a new line after download!
  101.         Comms.Send "erase *\r"
  102.         WaitForPrompt "PromptIp"
  103.     End If
  104.     Comms.Send "quit\r"
  105.     WaitForMainPrompt
  106.     SetLastUpdated "Check for FTP"
  107.     If id="" Then
  108.         ReportSuccess "0 : Checked & Downloaded files from FTP"
  109.     Else
  110.         ReportSuccess id & " : Checked & Downloaded files from FTP"
  111.     End If
  112. End Sub
  113.  
  114. 'T:FTPBatch (subroutine) (CIX)
  115. Sub FTPBatch(id As String, sitename As String, filename As String)
  116.     GotoArea "Main"
  117.     Comms.Send "run internet\r"
  118.     WaitForPrompt "PromptIp"
  119.     Comms.SendLiteral "batchftp " + sitename + " " + filename
  120.     Comms.Send "\r"
  121.     TimedWaitForPrompt "PromptIp", 600     'Don't know how long this takes
  122.     Comms.Send "quit\r"
  123.     WaitForMainPrompt
  124.     ReportSuccess id & " : Batchftp request for " & filename & " at " & sitename
  125.     EatExtraPrompts
  126. End Sub
  127.  
  128. 'T:FTPFile (subroutine) (CIX)
  129. Sub FTPFile(id As String, sitename As String, directory As String, _
  130.             remotefile As String, localfile As String)
  131.  
  132.     If Not EnterFTP(id, sitename, directory, True) Then Exit Sub
  133.     On Error Goto FTPFile_error
  134.     Comms.SendLiteral "cd " + directory
  135.     Comms.Send "\r"
  136.     WaitForPrompt "PromptFtp"
  137.     Comms.SendLiteral "get " + remotefile + " " + localfile
  138.     Comms.Send "\r"
  139.     TimedWaitForPrompt "PromptFtp", 600   'Don't know how long this takes
  140.     Comms.Send "close\r"
  141.     WaitForPrompt "PromptFtp"
  142.     Comms.Send "quit\r"
  143.     WaitForPrompt "PromptIp"
  144.     Comms.SendLiteral "send " + localfile
  145.     Comms.Send "\r"
  146.     WaitFor "\*\*"
  147.     FileDownload PROT_ZMODEM
  148.     WaitFor "ip>"        'Does not appear on a new line after download!
  149.     Comms.Send "quit\r"
  150.     WaitForMainPrompt
  151.     ReportSuccess id & " : FTP for " & directory & "/" & remotefile & " at " & sitename
  152.     EatExtraPrompts
  153.     Exit Sub
  154. FTPFile_error:
  155.     ReportFailure id, Error$
  156.     Comms.Send "quit\r"
  157.     WaitForMainPrompt
  158.     EatExtraPrompts
  159.     Exit Sub
  160. End Sub
  161.  
  162. 'T:FTPFiles (subroutine) (CIX)
  163. Sub FTPFiles(id As String, sitename As String, directory As String, _
  164.              remotefile As String)
  165.     If Not EnterFTP(id, sitename, directory, True) Then Exit Sub
  166.     On Error Goto FTPFiles_error
  167.     Comms.SendLiteral "mget " + remotefile
  168.     Comms.Send "\r"
  169.     TimedWaitForPrompt "PromptFtp", 600   'Don't know how long this takes
  170.     Comms.Send "close\r"
  171.     WaitForPrompt "PromptFtp"
  172.     Comms.Send "quit\r"
  173.     WaitForPrompt "PromptIp"
  174.     Comms.SendLiteral "send " + remotefile
  175.     Comms.Send "\r"
  176.     WaitFor "\*\*"
  177.     FileDownload PROT_ZMODEM
  178.     WaitFor "ip>"        'Does not appear on a new line after download!
  179.     Comms.Send "quit\r"
  180.     WaitForMainPrompt
  181.     ReportSuccess id & " : FTP for " & directory & "/" & remotefile & " at " & sitename
  182.     EatExtraPrompts
  183.     Exit Sub
  184. FTPFiles_error:
  185.     ReportFailure id, Error$
  186.     Comms.Send "quit\r"
  187.     WaitForMainPrompt
  188.     EatExtraPrompts
  189.     Exit Sub
  190. End Sub
  191.  
  192. 'T:FTPDir (subroutine) (CIX)
  193. Sub FTPDir(id As String, sitename As String, directory As String)
  194.     Dim capname As String
  195.  
  196.     If Not EnterFTP(id, sitename, directory, False) Then Exit Sub
  197.     Comms.Send "ls\r"
  198.     capname = Session.ServicePath + "ftpdir.tmp"
  199.     Capture CAPTURE_ON, capname
  200.     TimedWaitForPrompt "PromptFtp", 600   'Don't know how long this takes
  201.     Capture CAPTURE_OFF
  202.     Comms.Send "close\r"
  203.     WaitForPrompt "PromptFtp"
  204.     Comms.Send "quit\r"
  205.     WaitForPrompt "PromptIp"
  206.     Comms.Send "quit\r"
  207.     WaitForMainPrompt
  208.     If AddFileToMessageBase("ftp/"+sitename, "Dir of: " + directory, capname) Then
  209.         ReportSuccess id & " : Dir of " & directory & " at " & sitename
  210.     Else
  211.         ReportFailure id, Error$
  212.     End If
  213.     EatExtraPrompts
  214. End Sub
  215.  
  216. 'T:FTPFullDir (subroutine) (CIX)
  217. Sub FTPFullDir(id As String, sitename As String, directory As String)
  218.     Dim capname As String
  219.     Dim t As Tracker
  220.  
  221.     If Not EnterFTP(id, sitename, directory, False) Then Exit Sub
  222.     Set t = CreateTracker("QueryYes", "ftpdir.tmp\?", "SendYes")
  223.     Comms.Send "ls -lR ftpdir.tmp\r"
  224.     capname = Session.ServicePath + "ftpdir.tmp"
  225.     TimedWaitForPrompt "PromptFtp", 600   'Don't know how long this takes
  226.     t.delete
  227.     Comms.Send "close\r"
  228.     WaitForPrompt "PromptFtp"
  229.     Comms.Send "quit\r"
  230.     WaitForPrompt "PromptIp"
  231.     Comms.Send "send ftpdir.tmp\r"
  232.     WaitFor "\*\*"
  233.     FileDownload PROT_ZMODEM, capname
  234.     WaitFor "ip>"        'Does not appear on a new line after download!
  235.     Comms.Send "quit\r"
  236.     WaitForMainPrompt
  237.     If AddFileToMessageBase("ftp/"+sitename, "Recursive Dir of: "+directory, capname) Then
  238.         ReportSuccess id & " : Recursive Dir of " & directory & " at " & sitename
  239.     Else
  240.         ReportFailure id, Error$
  241.     End If
  242.     EatExtraPrompts
  243. End Sub
  244.  
  245. 'T:Archie (subroutine) (CIX)
  246. Sub Archie(id As String, filename As String)
  247.     Dim capname As String
  248.  
  249.     GotoArea "Main"
  250.     Comms.Send "run internet\r"
  251.     WaitForPrompt "PromptIp"
  252.     TrackFailure "\nNothing was found"
  253.     Comms.SendLiteral "archie " + filename
  254.     Comms.Send "\r"
  255.     capname = Session.ServicePath + "archie.lis"
  256.     TimedWaitForPrompt "PromptIp", 180  ' wait 3 minutes
  257.     If Success Then
  258.         Comms.Send "send archie.lis\r"
  259.         WaitFor "\*\*"
  260.         FileDownload PROT_ZMODEM, capname
  261.         WaitFor "ip>"       'Does not appear on a new line after download!
  262.         Comms.Send "erase archie.lis\r"
  263.         WaitForPrompt "PromptIp"
  264.         If AddFileToMessageBase("actions/archie", "Find File: " + filename, capname) Then
  265.             ReportSuccess id & " : Archie search for " & filename
  266.         Else
  267.             ReportFailure id, Error$
  268.         End If
  269.     Else
  270.         ReportSuccess id & " : Archie search for " & filename & " - nothing was found"
  271.     End If
  272.  
  273.     Comms.Send "quit\r"
  274.     WaitForMainPrompt
  275.     EatExtraPrompts
  276. End Sub
  277.  
  278. 'T:Finger (subroutine) (CIX)
  279. Sub Finger(id As String, address As String)
  280.     SingleIPCommand id, "finger", address, "Finger Person"
  281. End Sub
  282.  
  283. 'T:Ping (subroutine) (CIX)
  284. Sub Ping(id As String, address As String)
  285.     SingleIPCommand id, "ping", address, "Ping Site"
  286. End Sub
  287.  
  288. 'T:Whois (subroutine) (CIX)
  289. Sub Whois(id As String, address As String)
  290.     SingleIPCommand id, "whois", address, "WhoIs"
  291. End Sub
  292.  
  293. 'T:FTPDown (subroutine) (CIX)
  294. Sub FTPDown(id As String)
  295.     DownloadFTPid = id
  296. End Sub
  297.  
  298. 'T:FTPUploadFile (subroutine) (CIX)
  299. Sub FTPUploadFile(id As String, sitename As String, user As String, _
  300.                   password As String, directory As String, localfn As String)
  301.     
  302.     ' Upload to CIX FTP directory
  303.     GotoArea "Main"
  304.     Comms.Send "run internet\r"
  305.     WaitForPrompt "PromptIp"
  306.     Comms.Send "receive\r"
  307.     WaitFor "\*\*"
  308.     FileUpload PROT_ZMODEM, localfn
  309.     WaitFor "ip>"       'Does not appear on a new line after download!
  310.  
  311.     ' defaults
  312.     If user="" Then user = "anonymous"
  313.     If password="" Then password = Session.LoginName + "@cix.compulink.co.uk"
  314.  
  315.     ' Connect to site
  316.     Comms.Send "ftp\r"
  317.     WaitForPrompt "PromptFtp"
  318.     Comms.SendLiteral "open " + sitename
  319.     Comms.Send "\r"
  320.     WaitForTimed "):", 1200
  321.     Comms.Send user+"\r"
  322.     WaitForTimed "word:", 1200
  323.     Comms.Send password+"\r"
  324.     WaitForPrompt "PromptFtp"
  325.     Comms.Send "prompt\r"
  326.     WaitForPrompt "PromptFtp"
  327.     Comms.Send "binary\r"
  328.     WaitForPrompt "PromptFtp"
  329.     Comms.SendLiteral "cd " + directory
  330.     Comms.Send "\r"
  331.     WaitForPrompt "PromptFtp"
  332.     Comms.Send "send " + FileParse$(localfn, 3) + " " + FileParse$(localfn, 3) + "\r"
  333.     WaitForPrompt "PromptFtp"
  334.  
  335.     ' Leave site and erase from directory
  336.     Comms.Send "bye\r"
  337.     WaitForPrompt "PromptIp"
  338.     Comms.Send "erase " + FileParse$(localfn, 3) + "\r"
  339.     WaitForPrompt "PromptIp"
  340.     Comms.Send "quit\r"
  341.     WaitForMainPrompt
  342.     ReportSuccess id & " : FTP Uploaded to " & sitename & " " & directory & "/" & FileParse$(localfn, 3)
  343.     EatExtraPrompts
  344. End Sub
  345.  
  346. 'T:FTPEraseFile (subroutine) (CIX)
  347. Sub FTPEraseFile(id As String, sitename As String, user As String, _
  348.                   password As String, fn As String)
  349.  
  350.     ' defaults
  351.     If user="" Then user = "anonymous"
  352.     If password="" Then password = Session.LoginName + "@cix.compulink.co.uk"
  353.     
  354.     GotoArea "Main"
  355.     Comms.Send "run internet\r"
  356.     WaitForPrompt "PromptIp"
  357.     Comms.Send "ftp\r"
  358.     WaitForPrompt "PromptFtp"
  359.     Comms.SendLiteral "open " + sitename
  360.     Comms.Send "\r"
  361.     WaitForTimed "):", 1200
  362.     Comms.Send user+"\r"
  363.     WaitForTimed "word:", 1200
  364.     Comms.Send password+"\r"
  365.     WaitForPrompt "PromptFtp"
  366.     Comms.SendLiteral "delete " + fn
  367.     Comms.Send "\r"
  368.     WaitForPrompt "PromptFtp"
  369.     Comms.Send "bye\r"
  370.     WaitForPrompt "PromptIp"
  371.     Comms.Send "quit\r"
  372.     WaitForMainPrompt
  373.     ReportSuccess id & " : FTP Erased file " & sitename & " " & fn
  374.     EatExtraPrompts
  375. End Sub
  376.  
  377.  
  378.