Home

Add

Edit

Without Linenumbers

Code in Textfield

Download

  1. '#Define TSNE_PINGICMP
    
  2. #INCLUDE Once "TSNEX_V3.bi"
    
  3. #INCLUDE Once "TSNE_V3.bi"
    
  4. 
    
  5. 
    
  6. Function Replace(Byval V_Data As String, Byval V_Expression As String, Byval V_ReplaceBy As String) As String
    
  7. If Len(V_Data) < Len(V_Expression) Then Return V_Data
    
  8. Dim D As String = V_Data
    
  9. Dim SL As Uinteger = Len(V_Expression)
    
  10. Dim X As Uinteger = 0
    
  11. Do
    
  12.     X += 1
    
  13.     If X > Len(D) - SL + 1 Then Exit Do
    
  14.     If Mid(D, X, SL) = V_Expression Then
    
  15.         D = Mid(D, 1, X - 1) & V_ReplaceBy & Mid(D, X + SL)
    
  16.         X -= (SL - 1)
    
  17.         If X < 0 Then X = 0
    
  18.     End If
    
  19. Loop
    
  20. Return D
    
  21. End Function
    
  22. 
    
  23. 
    
  24. 
    
  25. Dim T As String
    
  26. Dim xpos As Integer
    
  27. Dim thostd() As String
    
  28. Dim thostc As Uinteger
    
  29. Dim thostx As Uinteger
    
  30. Dim tinterval As Uinteger
    
  31. Dim tapp As String
    
  32. Dim tmsg As String
    
  33. Dim tmailhost As String
    
  34. Dim tmailport As Ushort
    
  35. Dim tmailuser As String
    
  36. Dim tmailpass As String
    
  37. Dim tmailfrom As String
    
  38. Dim tmailto As String
    
  39. Dim tmailsubject As String
    
  40. Dim tmailmsg As String
    
  41. Open "config.c4n" For Input As #1
    
  42. Do Until Eof(1)
    
  43.     Line Input #1, t
    
  44.     xpos = Instr(1, t, "=")
    
  45.     If xpos > 0 Then
    
  46.         Select Case Lcase(Left(t, xpos - 1))
    
  47.             Case "host"
    
  48.                 T = Trim(Mid(t, xpos + 1))
    
  49.                 If t <> "" Then
    
  50.                     thostc += 1
    
  51.                     Redim Preserve thostd(thostc) As String
    
  52.                     thostd(thostc) = t
    
  53.                 End If
    
  54.             Case "interval": tinterval = Cuint(Trim(Mid(t, xpos + 1)))
    
  55.             Case "app": tapp = Trim(Mid(t, xpos + 1))
    
  56.             Case "mailhost": tmailhost = Trim(Mid(t, xpos + 1))
    
  57.             Case "mailport": tmailport = Cushort(Trim(Mid(t, xpos + 1)))
    
  58.             Case "mailuser": tmailuser = Trim(Mid(t, xpos + 1))
    
  59.             Case "mailpass": tmailpass = Trim(Mid(t, xpos + 1))
    
  60.             Case "mailfrom": tmailfrom = Trim(Mid(t, xpos + 1))
    
  61.             Case "mailto": tmailto = Trim(Mid(t, xpos + 1))
    
  62.             Case "mailsubject": tmailsubject = Trim(Mid(t, xpos + 1))
    
  63.             Case "mailmsg": tmailmsg = Trim(Mid(t, xpos + 1))
    
  64.             Case "msg": tmsg = Trim(Mid(t, xpos + 1))
    
  65.         End Select
    
  66.     End If
    
  67. Loop
    
  68. Close #1
    
  69. 
    
  70. 
    
  71. If thostc <= 0 Then
    
  72.     Screenres 400, 100, 32
    
  73.     Windowtitle "PING CONFIG-ERROR!"
    
  74.     Cls()
    
  75.     Print "keine host's in 'config.c4n'!"
    
  76.     Print "press any key to exit!"
    
  77.     Sleep
    
  78.     Screen 0
    
  79.     End -1
    
  80. End If
    
  81. If tinterval = 0 Then tinterval = 60
    
  82. 
    
  83. Dim TRunTime As Double
    
  84. Dim RV As Integer
    
  85. Dim xtot As Double
    
  86. Dim TERR As String
    
  87. Dim TCheck As Integer
    
  88. Do
    
  89.     Select Case Inkey()
    
  90.         Case Chr(27): Exit Do
    
  91.         Case " ": Screen 0
    
  92.     End Select
    
  93.     If xtot <= Timer() Then If thostx <= thostc Then thostx += 1
    
  94.     If thostx <= thostc Then
    
  95.         RV = TSNE_Ping(thostd(thostx), TRunTime)
    
  96.         If RV <> TSNE_Const_NoError Then
    
  97.             If TERR = "" Then
    
  98.                 Beep
    
  99.                 Screenres 400, 100, 32
    
  100.                 Windowtitle "PING ERROR!"
    
  101.                 Cls()
    
  102.                 Print "PING TIMEOUT!"
    
  103.                 Print ""
    
  104.                 Print "HOST:" & thostd(thostx)
    
  105.                 Print ""
    
  106.                 If tmsg <> "" Then
    
  107.                     Print tmsg
    
  108.                     Print ""
    
  109.                 End If
    
  110.                 Print "press any key to resume!"
    
  111.             End If
    
  112.             If tmailmsg <> "" Then TERR += Replace(tmailmsg, "$IP$", thostd(thostx)) & Chr(13, 10)
    
  113.             If tapp <> "" Then Shell tapp
    
  114.         End If
    
  115.     End If
    
  116.     If thostx = thostc Then
    
  117.         If TERR <> "" Then RV = TSNEX_SMTP_SendMail(tmailhost, tmailport, tmailuser, tmailpass, tmailfrom, tmailto, tmailsubject, TErr)
    
  118.         TERR = ""
    
  119.         thostx = 0
    
  120.         xtot = Timer() + tinterval
    
  121.     End If
    
  122.     Sleep 100, 1
    
  123. Loop
    
  124. End 0
    
  125. 
    
  126.