From 619c202a7d1bb63a3fa5bc3d261d789bd516b2c0 Mon Sep 17 00:00:00 2001 From: Leander Hutton Date: Sat, 24 Sep 2016 01:01:12 -0400 Subject: [PATCH] Initial commit --- README | 17 +++++++++++++++++ index.php | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100755 README create mode 100755 index.php diff --git a/README b/README new file mode 100755 index 0000000..7fe9ac0 --- /dev/null +++ b/README @@ -0,0 +1,17 @@ +phpIPAddress +leander@one-button.org + +I wrote this to save the IP address of the client that downloads it. +This was mostly done to overcome having a box on on dynamic IP address that I had to access from the outside world. + +It's rather simple, if $save_to_file is set to TRUE the script will save the IP address and hostname to a file. Otherwise it'll just diplsay it in the web browser. +By default this file is called ipaddress.txt and is located in the same directory as the PHP script itself. + +The best way to use this is to have the machine who's IP you're trying to keep track of download the script every few minutes. +You'll need to place the script itself on a webserver that is accessible (and preferably pretty reliable) to the cleint machine. + +Simply add this to your cleint's crontab: + +*/15 * * * * wget -O - -q -t 1 example.com/phpipaddress/index.php >/dev/null 2>&1 + +You can substitute wget for your favorite http client. diff --git a/index.php b/index.php new file mode 100755 index 0000000..7fed916 --- /dev/null +++ b/index.php @@ -0,0 +1,36 @@ + + + + + PHP External IP Address Finder + + +" . "Hostname: " . $hostname . "
" . "Last update: " . $dateandtime; +echo $writeout; + +if ($save_to_file == "TRUE") { + + $ipFileHandler = fopen($filename, 'w') or die("
ERROR CREATING FILE. CHECK DIRECTORY PERMISSIONS
"); + fwrite($ipFileHandler, "IP Address: " . $address . "\n" . "Hostname: " . $hostname . "\n" . "Last update: " . $dateandtime); + fclose($ipFileHandler); +} + +?> + +