This snippet is composed of two files !
-----------------------------------------------
The name of the first file (is a batch file): publicip.sh
The file content:
# Retrieve the public IP address of the machine on which it is executed scritp
res=$(curl -s http://checkip.amazonaws.com/)
# Generates the date of execution of the script
gendate=$(date)
# Written in an IP address file
echo "$res - $gendate" > publicip.txt
-----------------------------------------------
The name of the second file is: index.php
The file content:
<?php
exec("sh publicip.sh");
$file='publicip.txt';
$content = @fread(fopen($file, "r"), filesize($file));
if(!empty($content))
{
echo '<p class="text-center"><strong>'.$content.'</strong><p class="text-center">';
exec("rm publicip.txt");
}else{
echo '<p class="red text-center">The file <strong>'.$file.'</strong> is not readable or not exist<p class="text-center">';
echo '<p class="text-center">Check the access right and bash script</p>';
}
?>
-----------------------------------------------
This snippet consists of two files and lets you view a web page your public IP address. Personally, I use this snippet on my Synology. I use the script checkip at Amazon services.
Download the complete app (with full html and css (+bootstrap)) for a better look) on my personnal gitlab :
http://212.47.248.107/Alain/GetPublicIP
Download the complete app (with full html and css (+bootstrap)) for a better look) on my personnal gitlab :
http://212.47.248.107/Alain/GetPublicIP
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.