External IP in Network Traffic docklet

Hi,

perhaps some of you are using the Network Traffic docklet from Judge as well (see attached picture). It shows the upstream and the downstream speeds as well as the IP. When you're in a network, this is the internal IP which is less interesting than the external IP - e.g. the one you get from sites like http://www.whatismyip.com.

I tried to change the script IP3.vbs in the scripts folder of SysStats, but didn't come to an end. I found this script which was written for samurize and I guess, someone who really know what he's doing can easily change it so the docklet displays the external IP:

Const CheckConnected	  = True



Function getExternalIP ()



dim htmlResult



'Check that Computer is connected to the internet

Connected = IsConnectible("checkip.dyndns.org","","")



if Connected = True OR CheckConnected = False then

htmlResult = ReturnHTML("http://checkip.dyndns.org/")



leftMark = instr(htmlResult, "Address: " ) + 9



if Instr(htmlResult, ",") > 0 Then

rightMark = instr( htmlResult, ",") - 1

else

rightMark = instr( htmlResult, "</body>") - 1

End If



if rightMark > 0 Then



'grabs the IP

getExternalIP = mid( htmlResult, leftMark, rightMark - leftMark + 1)



else

getExternalIP = "ERROR"



end if

Else

getExternalIP = "Offline"

End If



End Function



Private Function ReturnHTML(sURL)

Dim objXMLHTTP,HTML

Set objXMLHTTP = CreateObject("Microsoft.XMLHTTP")

objXMLHTTP.Open "GET", sURL, False

objXMLHTTP.Send

HTML = objXMLHTTP.responseBody

Set objRS = CreateObject("ADODB.Recordset")

objRS.Fields.Append "txt", 200, 45000, &H00000080

objRS.Open

objRS.AddNew

objRS.Fields("txt").AppendChunk HTML

ReturnHTML = objRS("txt").Value

objRS.Close

Set objRS = Nothing

Set objXMLHTTP = Nothing



End Function



' This was done by someone on the forums which I copied, and can I find that post again can I heck

' So who every you are thanks for the cold.

Private Function IsConnectible(sHost,iPings,iTO)

' Works an "all" WSH versions

' sHost is a hostname or IP



' iPings is number of ping attempts

' iTO is timeout in milliseconds

' if values are set to "", then defaults below used



If iPings = "" Then iPings = 2

If iTO = "" Then iTO = 750



Const OpenAsDefault = -2

Const FailIfNotExist = 0

Const ForReading = 1



Set oShell = CreateObject("WScript.Shell")

Set oFSO = CreateObject("Scripting.FileSystemObject")

sTemp = oShell.ExpandEnvironmentStrings("%TEMP%")

sTempFile = sTemp & "runresult.tmp"



oShell.Run "%comspec% /c ping -n " & iPings & " -w " & iTO & " " & sHost & ">" & sTempFile, 0 , True



Set fFile = oFSO.OpenTextFile(sTempFile, ForReading, FailIfNotExist, OpenAsDefault)



sResults = fFile.ReadAll

fFile.Close

oFSO.DeleteFile(sTempFile)



Select Case InStr(sResults,"TTL=")

Case 0 IsConnectible = False

Case Else IsConnectible = True

End Select

End Function

Hope anyone of you can help me beause seeing the external IP may be interesting for many other users...

Regards, Boris

post-71732-1194621020_thumb.jpg

Network Traffic docklet.jpg
Network Traffic docklet.jpg

#479951