home *** CD-ROM | disk | FTP | other *** search
Wrap
'T:INTERNET.EBS for CIX ' VA 4.52 release 'Add file to import queue 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 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 Declare Function AddFileToMessageBase(topic As String, subject As String, filename As String) Declare Sub SendYes(t As Tracker) Declare Sub TrackFailure(s As String) Dim lastprompt As String 'Tracker name of the last prompt encountered Dim MailID As String 'ID of current mail or deferred command Public Success As Boolean 'Whether command succeeded Dim Failure As String 'Reason command failed (CIX error message) Dim sctrack As Tracker 'Success/Failure tracker Dim messagescript As String 'File name of CIX script to upload Dim DownloadFTPid As String 'Deferred FTPDown command ID Dim SeenFTPFile As Boolean 'There are some FTP files to download Dim LastArea As String 'Main or Newsnet 'T:EnterFTP (function) (CIX) Function EnterFTP(id As String, sitename As String, directory As String, bin As Boolean) GotoArea "Main" On Error Goto EnterFTP_error Comms.Send "run internet\r" WaitForPrompt "PromptIp" Comms.Send "ftp\r" WaitForPrompt "PromptFtp" Comms.SendLiteral "open " + sitename Comms.Send "\r" WaitForTimed "):", 1200 Comms.Send "anonymous\r" WaitForTimed "word:", 1200 Comms.Send Session.LoginName + "@cix.compulink.co.uk\r" WaitForPrompt "PromptFtp" If bin Then Comms.Send "prompt\r" WaitForPrompt "PromptFtp" Comms.Send "binary\r" Else Comms.Send "ascii\r" End If WaitForPrompt "PromptFtp" Comms.SendLiteral "cd " + directory Comms.Send "\r" WaitForPrompt "PromptFtp" EnterFTP = True Exit Function EnterFTP_error: ReportFailure id, "Error logging in to " + sitename Comms.Send "quit\r" WaitForMainPrompt EnterFTP = False End Function 'T:SingleIPCommand (subroutine) (CIX) Sub SingleIPCommand(id As String, comnd As String, param As String, desc As String) Dim capname As String GotoArea "Main" Comms.Send "run internet\r" WaitForPrompt "PromptIp" Comms.SendLiteral comnd + " " + param Comms.Send "\r" capname = Session.ServicePath + comnd + ".tmp" Capture CAPTURE_ON, capname TimedWaitForPrompt "PromptIp", 600 'don't know how long this takes Capture CAPTURE_OFF Comms.Send "quit\r" WaitForMainPrompt If AddFileToMessageBase("actions/" + comnd, desc + ": " + param, capname) Then ReportSuccess id & " : " & desc & " " & param Else ReportFailure id, Error$ End If End Sub 'T:GotFTPFile (subroutine) (CIX) Sub GotFTPFile(t As Tracker) SeenFTPFile = True t.reset End Sub 'T:DoFTPDownload (subroutine) (CIX) Sub DoFTPDownload(id As String) Dim t As Tracker GotoArea "Main" Comms.Send "run internet\r" WaitForPrompt "PromptIp" Comms.Send "dir\r" Set t = CreateTracker("tGotFTPFile", ":", "GotFTPFile") SeenFTPFile = False WaitFor "ip>" t.delete If SeenFTPFile Then Comms.Send "send *\r" WaitFor "\*\*" FileDownload PROT_ZMODEM WaitFor "ip>" 'Does not appear on a new line after download! Comms.Send "erase *\r" WaitForPrompt "PromptIp" End If Comms.Send "quit\r" WaitForMainPrompt SetLastUpdated "Check for FTP" If id="" Then ReportSuccess "0 : Checked & Downloaded files from FTP" Else ReportSuccess id & " : Checked & Downloaded files from FTP" End If End Sub 'T:FTPBatch (subroutine) (CIX) Sub FTPBatch(id As String, sitename As String, filename As String) GotoArea "Main" Comms.Send "run internet\r" WaitForPrompt "PromptIp" Comms.SendLiteral "batchftp " + sitename + " " + filename Comms.Send "\r" TimedWaitForPrompt "PromptIp", 600 'Don't know how long this takes Comms.Send "quit\r" WaitForMainPrompt ReportSuccess id & " : Batchftp request for " & filename & " at " & sitename EatExtraPrompts End Sub 'T:FTPFile (subroutine) (CIX) Sub FTPFile(id As String, sitename As String, directory As String, _ remotefile As String, localfile As String) If Not EnterFTP(id, sitename, directory, True) Then Exit Sub On Error Goto FTPFile_error Comms.SendLiteral "cd " + directory Comms.Send "\r" WaitForPrompt "PromptFtp" Comms.SendLiteral "get " + remotefile + " " + localfile Comms.Send "\r" TimedWaitForPrompt "PromptFtp", 600 'Don't know how long this takes Comms.Send "close\r" WaitForPrompt "PromptFtp" Comms.Send "quit\r" WaitForPrompt "PromptIp" Comms.SendLiteral "send " + localfile Comms.Send "\r" WaitFor "\*\*" FileDownload PROT_ZMODEM WaitFor "ip>" 'Does not appear on a new line after download! Comms.Send "quit\r" WaitForMainPrompt ReportSuccess id & " : FTP for " & directory & "/" & remotefile & " at " & sitename EatExtraPrompts Exit Sub FTPFile_error: ReportFailure id, Error$ Comms.Send "quit\r" WaitForMainPrompt EatExtraPrompts Exit Sub End Sub 'T:FTPFiles (subroutine) (CIX) Sub FTPFiles(id As String, sitename As String, directory As String, _ remotefile As String) If Not EnterFTP(id, sitename, directory, True) Then Exit Sub On Error Goto FTPFiles_error Comms.SendLiteral "mget " + remotefile Comms.Send "\r" TimedWaitForPrompt "PromptFtp", 600 'Don't know how long this takes Comms.Send "close\r" WaitForPrompt "PromptFtp" Comms.Send "quit\r" WaitForPrompt "PromptIp" Comms.SendLiteral "send " + remotefile Comms.Send "\r" WaitFor "\*\*" FileDownload PROT_ZMODEM WaitFor "ip>" 'Does not appear on a new line after download! Comms.Send "quit\r" WaitForMainPrompt ReportSuccess id & " : FTP for " & directory & "/" & remotefile & " at " & sitename EatExtraPrompts Exit Sub FTPFiles_error: ReportFailure id, Error$ Comms.Send "quit\r" WaitForMainPrompt EatExtraPrompts Exit Sub End Sub 'T:FTPDir (subroutine) (CIX) Sub FTPDir(id As String, sitename As String, directory As String) Dim capname As String If Not EnterFTP(id, sitename, directory, False) Then Exit Sub Comms.Send "ls\r" capname = Session.ServicePath + "ftpdir.tmp" Capture CAPTURE_ON, capname TimedWaitForPrompt "PromptFtp", 600 'Don't know how long this takes Capture CAPTURE_OFF Comms.Send "close\r" WaitForPrompt "PromptFtp" Comms.Send "quit\r" WaitForPrompt "PromptIp" Comms.Send "quit\r" WaitForMainPrompt If AddFileToMessageBase("ftp/"+sitename, "Dir of: " + directory, capname) Then ReportSuccess id & " : Dir of " & directory & " at " & sitename Else ReportFailure id, Error$ End If EatExtraPrompts End Sub 'T:FTPFullDir (subroutine) (CIX) Sub FTPFullDir(id As String, sitename As String, directory As String) Dim capname As String Dim t As Tracker If Not EnterFTP(id, sitename, directory, False) Then Exit Sub Set t = CreateTracker("QueryYes", "ftpdir.tmp\?", "SendYes") Comms.Send "ls -lR ftpdir.tmp\r" capname = Session.ServicePath + "ftpdir.tmp" TimedWaitForPrompt "PromptFtp", 600 'Don't know how long this takes t.delete Comms.Send "close\r" WaitForPrompt "PromptFtp" Comms.Send "quit\r" WaitForPrompt "PromptIp" Comms.Send "send ftpdir.tmp\r" WaitFor "\*\*" FileDownload PROT_ZMODEM, capname WaitFor "ip>" 'Does not appear on a new line after download! Comms.Send "quit\r" WaitForMainPrompt If AddFileToMessageBase("ftp/"+sitename, "Recursive Dir of: "+directory, capname) Then ReportSuccess id & " : Recursive Dir of " & directory & " at " & sitename Else ReportFailure id, Error$ End If EatExtraPrompts End Sub 'T:Archie (subroutine) (CIX) Sub Archie(id As String, filename As String) Dim capname As String GotoArea "Main" Comms.Send "run internet\r" WaitForPrompt "PromptIp" TrackFailure "\nNothing was found" Comms.SendLiteral "archie " + filename Comms.Send "\r" capname = Session.ServicePath + "archie.lis" TimedWaitForPrompt "PromptIp", 180 ' wait 3 minutes If Success Then Comms.Send "send archie.lis\r" WaitFor "\*\*" FileDownload PROT_ZMODEM, capname WaitFor "ip>" 'Does not appear on a new line after download! Comms.Send "erase archie.lis\r" WaitForPrompt "PromptIp" If AddFileToMessageBase("actions/archie", "Find File: " + filename, capname) Then ReportSuccess id & " : Archie search for " & filename Else ReportFailure id, Error$ End If Else ReportSuccess id & " : Archie search for " & filename & " - nothing was found" End If Comms.Send "quit\r" WaitForMainPrompt EatExtraPrompts End Sub 'T:Finger (subroutine) (CIX) Sub Finger(id As String, address As String) SingleIPCommand id, "finger", address, "Finger Person" End Sub 'T:Ping (subroutine) (CIX) Sub Ping(id As String, address As String) SingleIPCommand id, "ping", address, "Ping Site" End Sub 'T:Whois (subroutine) (CIX) Sub Whois(id As String, address As String) SingleIPCommand id, "whois", address, "WhoIs" End Sub 'T:FTPDown (subroutine) (CIX) Sub FTPDown(id As String) DownloadFTPid = id End Sub 'T:FTPUploadFile (subroutine) (CIX) Sub FTPUploadFile(id As String, sitename As String, user As String, _ password As String, directory As String, localfn As String) ' Upload to CIX FTP directory GotoArea "Main" Comms.Send "run internet\r" WaitForPrompt "PromptIp" Comms.Send "receive\r" WaitFor "\*\*" FileUpload PROT_ZMODEM, localfn WaitFor "ip>" 'Does not appear on a new line after download! ' defaults If user="" Then user = "anonymous" If password="" Then password = Session.LoginName + "@cix.compulink.co.uk" ' Connect to site Comms.Send "ftp\r" WaitForPrompt "PromptFtp" Comms.SendLiteral "open " + sitename Comms.Send "\r" WaitForTimed "):", 1200 Comms.Send user+"\r" WaitForTimed "word:", 1200 Comms.Send password+"\r" WaitForPrompt "PromptFtp" Comms.Send "prompt\r" WaitForPrompt "PromptFtp" Comms.Send "binary\r" WaitForPrompt "PromptFtp" Comms.SendLiteral "cd " + directory Comms.Send "\r" WaitForPrompt "PromptFtp" Comms.Send "send " + FileParse$(localfn, 3) + " " + FileParse$(localfn, 3) + "\r" WaitForPrompt "PromptFtp" ' Leave site and erase from directory Comms.Send "bye\r" WaitForPrompt "PromptIp" Comms.Send "erase " + FileParse$(localfn, 3) + "\r" WaitForPrompt "PromptIp" Comms.Send "quit\r" WaitForMainPrompt ReportSuccess id & " : FTP Uploaded to " & sitename & " " & directory & "/" & FileParse$(localfn, 3) EatExtraPrompts End Sub 'T:FTPEraseFile (subroutine) (CIX) Sub FTPEraseFile(id As String, sitename As String, user As String, _ password As String, fn As String) ' defaults If user="" Then user = "anonymous" If password="" Then password = Session.LoginName + "@cix.compulink.co.uk" GotoArea "Main" Comms.Send "run internet\r" WaitForPrompt "PromptIp" Comms.Send "ftp\r" WaitForPrompt "PromptFtp" Comms.SendLiteral "open " + sitename Comms.Send "\r" WaitForTimed "):", 1200 Comms.Send user+"\r" WaitForTimed "word:", 1200 Comms.Send password+"\r" WaitForPrompt "PromptFtp" Comms.SendLiteral "delete " + fn Comms.Send "\r" WaitForPrompt "PromptFtp" Comms.Send "bye\r" WaitForPrompt "PromptIp" Comms.Send "quit\r" WaitForMainPrompt ReportSuccess id & " : FTP Erased file " & sitename & " " & fn EatExtraPrompts End Sub