Sign in to follow this  
Followers 0

External IP address UDF

6 posts in this topic

Posted

;By Igor Ferreira Cemim
;igor.cemim at yahoo.com.br
;http://www.autoitscript.com/forum/index.php?showuser=46021

;Search a valid IP address on a given URL.
Func searchIP($URL = "http://www.ip-adress.com/")
  InetGet($URL, @TempDir & "\IP.dat", 1)

  ;Regular expression by:
  ;http://www.geekzilla.co.uk/view0CBFD9A7-621D-4B0C-9554-91FD48AADC77.htm
  $re = "\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
  $file = FileOpen(@TempDir & "\IP.dat", 0)

  While 1
    $line = StringLower(FileReadLine($file))
    If @error = -1 Then
      FileClose($file)
      FileDelete(@TempDir & "\IP.dat")
      ExitLoop
    EndIf

    $webIP = StringRegExpReplace($line, "[a-z]", "")
    $IP = StringRegExp($webIP, $re, 2)

    If (IsArray($IP)) Then
      FileClose($file)
      FileDelete(@TempDir & "\IP.dat")
      Return $IP[0]
    EndIf
  WEnd
EndFunc

;Get external IP from What Is My IP Address automation page.
Func getExternalIP()
  InetGet("http://www.whatismyip.com/automation/n09230945.asp", @TempDir & "\IP.dat", 1)
  $IP = FileReadLine(@TempDir & "\IP.dat", 1)
  FileDelete(@TempDir & "\IP.dat")

  Return $IP
EndFunc

Need more comments?! :)

Share this post


Link to post
Share on other sites



Posted

Awesome topic, five stars from me! :)

Share this post


Link to post
Share on other sites

Posted

Liar :)

Share this post


Link to post
Share on other sites

Posted (edited)

Whaaat? I thought all topics got awesome when YOU posted in them! :)

(HA got you now, there's no way you can deny that!)

Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites

Posted

Good idea, nice code. Thanks for sharing.

Share this post


Link to post
Share on other sites

Posted (edited)

The getExternalIP is already done. _GetIP

But the other func is good :)

Edited by ProgAndy

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.