Jump to content
Sign in to follow this  
Jujo

Dynamic IP address updater

Recommended Posts

Jujo

Today I made a simple program that updates IP address using AutoIt and PHP. PHP keeps track of IPs, and AutoIt submits it.

Note: You need hosting account with PHP support

Heres AutoIt code:

#Include <Constants.au3>
#Include <IE.au3>
#NoTrayIcon

HotKeySet("{ESC}", "die")
HotKeySet("{^F5}", "refresh")
$wait = InputBox("Updater", "Waiting time: ", "21600", "", "", "", "", "", 10)
$port = InputBox("Updater", "Port to submit: ", "1004", "", "", "", "", "", 10)

If $wait = 0 Or $wait = "" Then
    $wait = 21600
EndIf
If $port = 0 Or $port = "" Then
    $port = 1004
EndIf

$wait = $wait * 1000
refresh()
While 1
    Sleep($wait)
    refresh()
WEnd

Func refresh()
    $object = _IECreate("URL/update.php?port=" & $port, 0, 1)
    _IEQuit($object)
EndFunc
Func die()
    Exit
EndFunc

You have to change URL to some URL where is your update.php script located.

Here is update.php script source:

<?
$myFile = "data.txt";
$fh = fopen($myFile, 'w') or die("ERROR FILE 1");
$stringData = $_SERVER['REMOTE_ADDR'].':'.$_GET['port'];
fwrite($fh, $stringData);
fclose($fh);
?>

And, for reading, you just need to load data.txt file in your browser. Save this PHP file as update.php and create empty file called data.txt

I also recommend you to password protect the whole folder, but thats your choise ^_^

Edited by Jujo

Share this post


Link to post
Share on other sites
avery

Today I made a simple program that updates IP address using AutoIt and PHP. PHP keeps track of IPs, and AutoIt submits it.

Note: You need hosting account with PHP support

Heres AutoIt code:

#Include <Constants.au3>
#Include <IE.au3>
#NoTrayIcon

HotKeySet("{ESC}", "die")
HotKeySet("{^F5}", "refresh")
$wait = InputBox("Updater", "Waiting time: ", "21600", "", "", "", "", "", 10)
$port = InputBox("Updater", "Port to submit: ", "1004", "", "", "", "", "", 10)

If $wait = 0 Or $wait = "" Then
    $wait = 21600
EndIf
If $port = 0 Or $port = "" Then
    $port = 1004
EndIf

$wait = $wait * 1000
refresh()
While 1
    Sleep($wait)
    refresh()
WEnd

Func refresh()
    $object = _IECreate("URL/update.php?port=" & $port, 0, 1)
    _IEQuit($object)
EndFunc
Func die()
    Exit
EndFunc

You have to change URL to some URL where is your update.php script located.

Here is update.php script source:

<?
$myFile = "data.txt";
$fh = fopen($myFile, 'w') or die("ERROR FILE 1");
$stringData = $_SERVER['REMOTE_ADDR'].':'.$_GET['port'];
fwrite($fh, $stringData);
fclose($fh);
?>

And, for reading, you just need to load data.txt file in your browser. Save this PHP file as update.php and create empty file called data.txt

I also recommend you to password protect the whole folder, but thats your choise :party:

Can I use this with DynDNS? I always wanted to have that updated for me :)

www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.