Sign in to follow this  
Followers 0
autoitxp

Ip notification on site

2 posts in this topic

#1 ·  Posted (edited)

Hi

I wanted to get IP notification on my local server when internet is on connected state but problem is loop sending notification again and again how to just notified when IP got changed . any help ! appreciated Thanks !

Func _WinINet_InternetCheckConnection($lpsz_URL)  
 Local $varResult = DllCall("wininet.dll", "int", "InternetCheckConnection", "str", $lpsz_URL, "uint", 0x00000001, "uint", 0)   
If @error Then Return SetError(-1, 0, "") 
    Return SetError($varResult[0], $varResult[1], $varResult[0])
  EndFunc   ;==>_WinINet_InternetCheckConnection  


  While 1   
Sleep(5000)  
    If _WinINet_InternetCheckConnection("http://www.google.com") = 1 Then   
    InetGet("http://localhost/cgi-bin/script.cgi?action=&$script_name&admin=log&ipadd=" & @IPAddress1, "", 1, 1)    
Else        
MsgBox(64, "", @error)
    EndIf 
WEnd
Edited by autoitxp

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi

Is there any other way then PING to check if google is online this code works gr8 for me over all

Global Const $INTERNET_CONNECTION_MODEM = 0x1
Global Const $INTERNET_CONNECTION_LAN = 0x2
Global Const $INTERNET_CONNECTION_PROXY = 0x4
Global Const $INTERNET_CONNECTION_MODEM_BUSY = 0x8
Global Const $INTERNET_RAS_INSTALLED = 0x10
Global Const $INTERNET_CONNECTION_OFFLINE = 0x20
Global Const $INTERNET_CONNECTION_CONFIGURED = 0x40
Local $s_Error, $c_Connect_1 = True, $c_Connect_2 = False, $c_Connect_3 = True, $ping, $sX, $ret

Local $c_Msg_1 = "No Internet Device Connected"
Local $c_Msg_2 = "Google Offline"
Local $c_Msg_3 = "Google Online"

$handle_wininet = DllOpen('WinInet.dll')
While 1
    Sleep(250)
    Switch $s_Error
        Case 1
            _SendError($c_Msg_1)
            $c_Connect_3 = 1
        Case 2
            _SendError($c_Msg_2)
        Case 3
            _SendError($c_Msg_3)
            ;   Case Else

    EndSwitch


    If $c_Connect_1 = 1 Then
        $ret = DllCall($handle_wininet, "int", "InternetGetConnectedState", "int*", 0, "int", 0)
        If $ret[0] Then
            $sX = ""
            If BitAND($ret[1], $INTERNET_CONNECTION_MODEM) Then $sX &= "MODEM" & @CRLF
            If BitAND($ret[1], $INTERNET_CONNECTION_LAN) Then $sX &= "LAN" & @CRLF
            If BitAND($ret[1], $INTERNET_CONNECTION_PROXY) Then $sX &= "PROXY" & @CRLF
            If BitAND($ret[1], $INTERNET_CONNECTION_MODEM_BUSY) Then $sX &= "MODEM_BUSY" & @CRLF
            If BitAND($ret[1], $INTERNET_RAS_INSTALLED) Then $sX &= "RAS_INSTALLED" & @CRLF
            If BitAND($ret[1], $INTERNET_CONNECTION_OFFLINE) Then $sX &= "OFFLINE" & @CRLF
            If BitAND($ret[1], $INTERNET_CONNECTION_CONFIGURED) Then $sX &= "CONFIGURED" & @CRLF



            $s_Error = 0

            If $c_Connect_3 = 1 Then
                MsgBox(64, "", $sX & ($ret[0] <> 0))
                $c_Connect_2 = True
                ;       $s_Error = 3
            EndIf
        Else

            $s_Error = 1

        EndIf
    EndIf

    If $c_Connect_2 = 1 Then
        $c_Connect_2 = 0
        $ping = Ping('www.google.com')
        If $ping Then
             InetGet("http://localhost/cgi-bin/script.cgi?action=&$script_name&admin=log&ipadd=" & @IPAddress1, "", 1, 1)
            $s_Error = 3
            $c_Connect_3 = 0
        Else
            $s_Error = 2
        EndIf
    EndIf
WEnd


Func _SendError($s_Msg)
    MsgBox(0, "Status", $s_Msg)
EndFunc   ;==>_SendError

Func OnAutoItExit()
    DllClose($handle_wininet)
    MsgBox(64, "", "On Exit")
EndFunc   ;==>OnAutoItExit
Edited by autoitxp

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