tylo Posted April 11, 2005 Share Posted April 11, 2005 StringRegExp is perfect for this kind of problems. I don't think the Random() stuff is really required, as the 'reload' flag is set in the InetGet function. For Autoit 3.1.1.+ Func _GetIP() Local $ip, $tmp = @TempDir & "\~ip.tmp" If InetGet("http://checkip.dyndns.org/", $tmp, 1) Or _ InetGet("http://www.whatismyip.com/", $tmp, 1) Then $ip = FileRead($tmp, FileGetSize($tmp)) FileDelete($tmp) $ip = StringRegExp($ip, "([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", 1) If @error = 0 And @extended = 1 Then Return $ip[0] EndIf SetError(1) Return -1 EndFunc ;==>_GetIP blub Link to comment Share on other sites More sharing options...
Developers Jos Posted April 11, 2005 Developers Share Posted April 11, 2005 StringRegExp is perfect for this kind of problems. I don't think the Random() stuff is really required, as the 'reload' flag is set in the InetGet function. <{POST_SNAPBACK}>Are you sure its not needed when there is a Proxy/Cache server between the pc and the Internet ? 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 11, 2005 Share Posted April 11, 2005 Are you sure its not needed when there is a Proxy/Cache server between the pc and the Internet ?<{POST_SNAPBACK}>Eh.. not really. I guess it must be tested. blub Link to comment Share on other sites More sharing options...
w0uter Posted April 11, 2005 Share Posted April 11, 2005 Eh.. not really. I guess it must be tested. <{POST_SNAPBACK}>or we could be lazy and just let the random in cuz it does not have drawbacks.only possible advantages (and it looks more leet ) 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...
Nutster Posted April 15, 2005 Share Posted April 15, 2005 What about implenting a similar server on autoitscript.com then refering to it? That would remove the problem of external websites unexpectedly updating and ruining the function. David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
Ejoc Posted April 15, 2005 Author Share Posted April 15, 2005 What about implenting a similar server on autoitscript.com then refering to it? That would remove the problem of external websites unexpectedly updating and ruining the function.<{POST_SNAPBACK}>I like that idea, wonder why no one else thought of it... 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...
MSLx Fanboy Posted April 15, 2005 Share Posted April 15, 2005 I'm pretty sure your code works (short of throwing it on a server), but there is an easier way to do it.<?php echo $_SERVER['REMOTE_ADDR']; ?>The Remote Address will ALWAYS have a value, even if its localhost (I haven't tried CMDLine in Unix, but I'm sure it would have localhost). 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 )<{POST_SNAPBACK}> Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
Smed Posted April 15, 2005 Share Posted April 15, 2005 I'm willing to host this temporarilyWhats my IP?a couple of days anyway... If I don't see any drastic trafic changes maybe longer. 601DisengageEnd Program Link to comment Share on other sites More sharing options...
zcoacoaz Posted April 15, 2005 Share Posted April 15, 2005 (edited) http://www.whatismyip.orgFunc _GetIP ( ) InetGet ( "http://www.whatismyip.org", @TempDir & "\ip.txt", 1 ) $ip = FileReadLine ( @TempDir & "\ip.txt" ) FileDelete ( @TempDir & "\ip.txt" ) Return $ip EndFuncEdit: There is also http://www.whatismyip.net and http://www.whatismyip.ca but their answers aren't to the point...Edit: I found more, http://whatismyip.co.uk and http://www.whatismyip.de/ but they aren't to the point either Edited April 15, 2005 by Xenogis [font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font] Link to comment Share on other sites More sharing options...
w0uter Posted April 15, 2005 Share Posted April 15, 2005 (edited) I'm willing to host this temporarilyWhats my IP?a couple of days anyway... If I don't see any drastic trafic changes maybe longer.<{POST_SNAPBACK}>i bet you will get tons of traffic if it was standardly included heres one w/ regexp and your mirror (edit more adresses added)expandcollapse popupFunc _GetIP() Local $ip If InetGet("http://68.216.93.172/whatsmyip.asp?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 = StringRegExp($ip, "([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", 1) If @error = 0 And @extended = 1 Then Return $ip[0] EndIf If InetGet("http://www.whatismyip.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 = StringRegExp($ip, "([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", 1) If @error = 0 And @extended = 1 Then Return $ip[0] EndIf 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 = StringRegExp($ip, "([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", 1) If @error = 0 And @extended = 1 Then Return $ip[0] EndIf If InetGet("http://www.whatismyip.de/?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 = StringRegExp($ip, "([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", 1) If @error = 0 And @extended = 1 Then Return $ip[0] EndIf If InetGet("http://whatismyip.co.uk/?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 = StringRegExp($ip, "([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", 1) If @error = 0 And @extended = 1 Then Return $ip[0] 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 = StringRegExp($ip, "([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", 1) If @error = 0 And @extended = 1 Then Return $ip[0] EndIf If InetGet("http://www.whatismyip.ca/?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 = StringRegExp($ip, "([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", 1) If @error = 0 And @extended = 1 Then Return $ip[0] EndIf SetError(1) Return -1 EndFunc ;==>_GetIP Edited April 15, 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...
Smed Posted April 16, 2005 Share Posted April 16, 2005 i bet you will get tons of traffic if it was standardly included Thats OK, I have oodles of bandwidth to play with, but I did move the URL: Whats My IP? and intentionaly broke the old one. I added Whats My Browser?. Thats already been usefull for me. 601DisengageEnd Program 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