Ejoc Posted April 9, 2005 Share Posted April 9, 2005 (edited) It's returning "" for me... It's getting the file correctly, just seems like myipaddress must have changed it's HTML code slightly. I got it working but I'm using a more hard-code version, it's probably an easy fix. *EDIT Ok, I looked into it, and since it's needs to be worked on, I fixed-up the new_GetIP(): ;=============================================================================== ; ; Function Name: new_GetIP() ; Description: Get public IP address of a network/computer. ; Parameter(s): None ; Requirement(s): Internet access. ; Return Value(s): On Success - Returns the public IP Address ; On Failure - -1 and sets @ERROR = 1 ; Proxy Revision by: warmfuzzy ; Original Author(s): Larry/Ezzetabi & Jarvis Stubblefield ; Comments: Reduces likelihood of Proxy Caching problems ;=============================================================================== ; Demo bit local $PublicIP = new_GetIP() MsgBox(0, "IP Address", "Your IP Address is: " & $PublicIP) Exit ; Function replacing _GetIP() in Include\Inet.au3 via #include <Inet.au3> Func new_GetIP() Local $ip If InetGet("http://www.whatismyip.com/?rnd1=" & Random (1,65536) & "&rnd2=" & Random (1,65536), @TempDir & "\~ip.tmp") Then $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp")) FileDelete(@TempDir & "\~ip.tmp") $ip = StringTrimLeft($ip, StringInStr($ip, "<TITLE>Your ip is") + 17) $ip = StringLeft($ip, StringInStr($ip, "WhatIsMyIP.com</TITLE>") - 1) $ip = StringStripWS($ip,8) Return $ip Else SetError(1) Return -1 EndIf EndFunc;Function End >> new_GetIP() Edited April 9, 2005 by Ejoc Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs Link to comment Share on other sites More sharing options...
Developers Jos Posted April 9, 2005 Developers Share Posted April 9, 2005 yes they changed the page.. here's a working version: Func _GetIP() Local $ip If InetGet("http://www.whatismyip.com", @TempDir & "\~ip.tmp") Then $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp")) FileDelete(@TempDir & "\~ip.tmp") $ip = StringTrimLeft($ip, StringInStr($ip, "<TITLE>Your ip is") + 17) $ip = StringLeft($ip, StringInStr($ip, "WhatIsMyIP.com</TITLE>") - 1) Return StringReplace($ip, @TAB, '') Else SetError(1) Return -1 EndIf EndFunc ;==>_GetIP SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
w0uter Posted April 9, 2005 Share Posted April 9, 2005 this one is better: http://www.autoitscript.com/forum/index.php?showtopic=9653 My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Ejoc Posted April 9, 2005 Author Share Posted April 9, 2005 this one is better: http://www.autoitscript.com/forum/index.php?showtopic=9653 <{POST_SNAPBACK}>Thats what I fixed... See post 1 Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs Link to comment Share on other sites More sharing options...
Developers Jos Posted April 9, 2005 Developers Share Posted April 9, 2005 this one is better: http://www.autoitscript.com/forum/index.php?showtopic=9653 <{POST_SNAPBACK}>Define better I just fixed the one submitted to me a while ago which is in the current installer.... No issue with replacing it with a "Better" version..... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
w0uter Posted April 9, 2005 Share Posted April 9, 2005 Define better <{POST_SNAPBACK}>http://dictionary.reference.com/search?q=better My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Developers Jos Posted April 9, 2005 Developers Share Posted April 9, 2005 http://dictionary.reference.com/search?q=better<{POST_SNAPBACK}> ... will update the _getip() UDF as proposed..... tnx SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Ejoc Posted April 10, 2005 Author Share Posted April 10, 2005 They Changed it again... Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs Link to comment Share on other sites More sharing options...
Valik Posted April 10, 2005 Share Posted April 10, 2005 A function which relies on an external site like this probably should not be a standard function in the official distribution. If it can't be done 1st-party, it shouldn't be included so that issues like this are prevented. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 10, 2005 Developers Share Posted April 10, 2005 (edited) They Changed it again...<{POST_SNAPBACK}>Updated version, made it less sensitive for updates:Func _GetIP() Local $ip If InetGet("http://www.whatismyip.com/?rnd1=" & Random (1,65536) & "&rnd2=" & Random (1,65536), @TempDir & "\~ip.tmp") Then $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp")) FileDelete(@TempDir & "\~ip.tmp") $ip = StringTrimLeft($ip, StringInStr($ip, "Your ip is") + 10) $ip = StringLeft($ip, StringInStr($ip, " ") - 1) $ip = StringStripWS($ip, 8) Return $ip Else SetError(1) Return -1 EndIf EndFunc;==>_GetIPA function which relies on an external site like this probably should not be a standard function in the official distribution. If it can't be done 1st-party, it shouldn't be included so that issues like this are prevented.<{POST_SNAPBACK}>We need to keep this in mind for future UDF's.... Edited April 10, 2005 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
tylo Posted April 10, 2005 Share Posted April 10, 2005 http://checkip.dyndns.org/Seems to have a more static and simpler output format... blub Link to comment Share on other sites More sharing options...
w0uter Posted April 10, 2005 Share Posted April 10, 2005 (edited) http://checkip.dyndns.org/Seems to have a more static and simpler output format...<{POST_SNAPBACK}>that one is alot better b/c it downloads fasterFunc _GetIP() Local $ip If InetGet("http://checkip.dyndns.org/?rnd1=" & Random(1, 65536) & "&rnd2=" & Random(1, 65536), @TempDir & "\~ip.tmp") Then $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp")) FileDelete(@TempDir & "\~ip.tmp") $ip = StringTrimLeft($ip, StringInStr($ip, ":") + 1) $ip = StringTrimRight($ip, StringLen($ip) - StringInStr($ip, "/") + 2) Return $ip Else SetError(1) Return -1 EndIf EndFunc;==>_GetIP Edited April 10, 2005 by w0uter My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
layer Posted April 10, 2005 Share Posted April 10, 2005 http://checkip.dyndns.org/Seems to have a more static and simpler output format...<{POST_SNAPBACK}>Nice call FootbaG Link to comment Share on other sites More sharing options...
Developers Jos Posted April 10, 2005 Developers Share Posted April 10, 2005 so what about this way? Func _GetIP() Local $ip, $t_ip If InetGet("http://checkip.dyndns.org/?rnd1=" & Random(1, 65536) & "&rnd2=" & Random(1, 65536), @TempDir & "\~ip.tmp") Then $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp")) FileDelete(@TempDir & "\~ip.tmp") $ip = StringTrimLeft($ip, StringInStr($ip, ":") + 1) $ip = StringTrimRight($ip, StringLen($ip) - StringInStr($ip, "/") + 2) & "x" ConsoleWrite('@@ Debug(26) : $ip = ' & $ip & @lf);### Debug Console $t_ip = StringSplit($ip,'.') If $t_ip[0] = 4 Then Return $ip EndIf EndIf If InetGet("http://www.whatismyip.com/?rnd1=" & Random (1,65536) & "&rnd2=" & Random (1,65536), @TempDir & "\~ip.tmp") Then $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp")) FileDelete(@TempDir & "\~ip.tmp") $ip = StringTrimLeft($ip, StringInStr($ip, "Your ip is") + 10) $ip = StringLeft($ip, StringInStr($ip, " ") - 1) $ip = StringStripWS($ip, 8) If $t_ip[0] = 4 Then Return $ip EndIf EndIf SetError(1) Return -1 EndFunc;==>_GetIP SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
w0uter Posted April 10, 2005 Share Posted April 10, 2005 (edited) @jdeb i think you forgot StringSplit at the whatsmyip.com part and what is that X doing at the StringTrimRight ? also you could use StringIsDigit to check if it actually is an ip an not an ip with a <body> tag atached or something this is what it is suppose to be acording to me (i could be wrong though) Func _GetIP() Local $ip, $t_ip If InetGet("http://checkip.dyndns.org/?rnd1=" & Random(1, 65536) & "&rnd2=" & Random(1, 65536), @TempDir & "\~ip.tmp") Then $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp")) FileDelete(@TempDir & "\~ip.tmp") $ip = StringTrimLeft($ip, StringInStr($ip, ":") + 1) $ip = StringTrimRight($ip, StringLen($ip) - StringInStr($ip, "/") + 2) $t_ip = StringSplit($ip, '.') If $t_ip[0] = 4 And StringIsDigit($t_ip[1]) And StringIsDigit($t_ip[2]) And StringIsDigit($t_ip[3]) And StringIsDigit($t_ip[4]) Then Return $ip EndIf EndIf If InetGet("http://www.whatismyip.com/?rnd1=" & Random(1, 65536) & "&rnd2=" & Random(1, 65536), @TempDir & "\~ip.tmp") Then $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp")) FileDelete(@TempDir & "\~ip.tmp") $ip = StringTrimLeft($ip, StringInStr($ip, "Your ip is") + 10) $ip = StringLeft($ip, StringInStr($ip, " ") - 1) $ip = StringStripWS($ip, 8) $t_ip = StringSplit($ip, '.') If $t_ip[0] = 4 And StringIsDigit($t_ip[1]) And StringIsDigit($t_ip[2]) And StringIsDigit($t_ip[3]) And StringIsDigit($t_ip[4]) Then Return $ip EndIf EndIf SetError(1) Return -1 EndFunc ;==>_GetIP Edited April 10, 2005 by w0uter My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Developers Jos Posted April 10, 2005 Developers Share Posted April 10, 2005 @jdeb i think you forgot StringSplit at the whatsmyip.com partand what is that X doing at the StringTrimRight ?also you could use StringIsDigit to check if it actually is an ipan not an ip with a <body> tag atached or somethingthis is what it is suppose to be acording to me (i could be wrong though)<{POST_SNAPBACK}>sounds good... tnx SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
w0uter Posted April 10, 2005 Share Posted April 10, 2005 sounds good... tnx<{POST_SNAPBACK}>np, just trying to help My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Developers Jos Posted April 10, 2005 Developers Share Posted April 10, 2005 (edited) np, just trying to help <{POST_SNAPBACK}>yea, I sure needed it today... Edited April 10, 2005 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Ejoc Posted April 10, 2005 Author Share Posted April 10, 2005 (edited) Why not have a page hosted by autoit return your IP and make _GetIP() access the autoit page? That way you know it wont change. Edited April 10, 2005 by Ejoc Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs Link to comment Share on other sites More sharing options...
w0uter Posted April 10, 2005 Share Posted April 10, 2005 maby they will exceed there bandwide limit ? if its unlimited yeah why not maby a php script or something. like: <?php $ip = $_SERVER['REMOTE_ADDR']; if($ip != null) { echo $ip; } else { echo 0; } ?> (im not the best w/ php so dont asume that it works ) My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now