Compare commits
12 Commits
cfd00db3ab
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| b7d78e7561 | |||
| d757e632d8 | |||
| 1d759d2e44 | |||
|
|
d8aba80029 | ||
| 6109429b21 | |||
|
9ec952236f
|
|||
|
90be3e54b9
|
|||
|
69c1411c98
|
|||
|
504586a033
|
|||
|
a720d581d5
|
|||
|
e5f6c39224
|
|||
|
6cf4ef1237
|
@@ -8,3 +8,6 @@ RewriteRule ^([^/]+)/?$ /index.php?m=$1 [L]
|
|||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
RewriteCond %{REQUEST_FILENAME} !-d
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?m=$1&t=$2 [L]
|
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?m=$1&t=$2 [L]
|
||||||
|
|
||||||
|
# Hide .git on webserver
|
||||||
|
RedirectMatch 404 /\.git
|
||||||
|
|||||||
12
README.md
12
README.md
@@ -4,18 +4,18 @@ A simple PHP script to tell a visitor's IP address and more information. This fi
|
|||||||
|
|
||||||
## Plain return
|
## Plain return
|
||||||
|
|
||||||
Example: [/][https://ip.nandus.net]
|
Example: [/][https://ip.snapdns.eu]
|
||||||
|
|
||||||
When the script is properly installed, one can visit/curl/wget the website to just receive one's public IP address. This is very useful in combination with other scripts (check out my snap-dyndns packages for example).
|
When the script is properly installed, one can visit/curl/wget the website to just receive one's public IP address. This is very useful in combination with other scripts (check out my snap-dyndns packages for example).
|
||||||
|
|
||||||
```
|
```
|
||||||
max@laptop ~> wget -qO - ip.nandus.net
|
max@laptop ~> curl -Ls ip.snapdns.eu
|
||||||
91.62.68.1
|
91.62.68.1
|
||||||
```
|
```
|
||||||
|
|
||||||
## Detailed return
|
## Detailed return
|
||||||
|
|
||||||
Example: [/myself](https://ip4.nandus.net/myself)
|
Example: [/detailed](https://ip4.snapdns.eu/detailed)
|
||||||
|
|
||||||
Given the location of the script is `ip.example.com`, you can also receive more information about the HTTP headers or the IP's reverse lookup:
|
Given the location of the script is `ip.example.com`, you can also receive more information about the HTTP headers or the IP's reverse lookup:
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ HTTP_CLIENT_IP:
|
|||||||
HTTP_X_FORWARDED:
|
HTTP_X_FORWARDED:
|
||||||
HTTP_FORWARDED_FOR:
|
HTTP_FORWARDED_FOR:
|
||||||
HTTP_FORWARDED:
|
HTTP_FORWARDED:
|
||||||
HTTP_HOST: ip4.nandus.net
|
HTTP_HOST: ip4.snapdns.eu
|
||||||
HTTP_URI:
|
HTTP_URI:
|
||||||
|
|
||||||
HOSTNAME: p5B3E4401.dip0.t-ipconnect.de
|
HOSTNAME: p5B3E4401.dip0.t-ipconnect.de
|
||||||
@@ -38,8 +38,8 @@ Additionally you will be given a whois output of your IP.
|
|||||||
|
|
||||||
## Custom DNS and IP lookup
|
## Custom DNS and IP lookup
|
||||||
|
|
||||||
Example DNS: [/dns/example.com](https://ip.nandus.net/dns/example.com)
|
* Example DNS: [/dns/example.com](https://ip.snapdns.eu/dns/example.com)
|
||||||
Example IP: [/ip/8.8.8.8](https://ip.nandus.net/ip/8.8.8.8)
|
* Example IP: [/ip/8.8.8.8](https://ip.snapdns.eu/ip/8.8.8.8)
|
||||||
|
|
||||||
You can also freely look up any hostname or IP. For domains, this will return a useful list of different DNS records (A, AAAA, NS, MX, TXT, SOA etc).
|
You can also freely look up any hostname or IP. For domains, this will return a useful list of different DNS records (A, AAAA, NS, MX, TXT, SOA etc).
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return (object) array(
|
return (object) array(
|
||||||
'ip4domain' => 'ip4.nandus.net',
|
'ip4domain' => 'ip4.snapdns.eu',
|
||||||
'ip6domain' => 'ip6.nandus.net',
|
'ip6domain' => 'ip6.snapdns.eu',
|
||||||
'detailed_uri' => 'detailed',
|
'detailed_uri' => 'detailed',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
BIN
favicon.png
Normal file
BIN
favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
45
index.php
45
index.php
@@ -20,10 +20,11 @@ if(empty($_GET)) {
|
|||||||
|
|
||||||
if($method === "simple") { // simple
|
if($method === "simple") { // simple
|
||||||
$ip = $_SERVER['REMOTE_ADDR'];
|
$ip = $_SERVER['REMOTE_ADDR'];
|
||||||
echo $ip . "\n";
|
echo $ip;
|
||||||
exit;
|
exit;
|
||||||
} elseif($method === "myself" ) { // detailed info about own IP
|
} elseif($method === "myself" ) { // detailed info about own IP
|
||||||
$ip = $_SERVER['REMOTE_ADDR'];
|
$ip = $_SERVER['REMOTE_ADDR'];
|
||||||
|
print_header();
|
||||||
show_http_headers();
|
show_http_headers();
|
||||||
show_hostname($ip);
|
show_hostname($ip);
|
||||||
show_reverse($hostname);
|
show_reverse($hostname);
|
||||||
@@ -31,12 +32,14 @@ if($method === "simple") { // simple
|
|||||||
show_whois($ip);
|
show_whois($ip);
|
||||||
} elseif($method === "ip" ) { // detailed info an IP
|
} elseif($method === "ip" ) { // detailed info an IP
|
||||||
$ip = $t;
|
$ip = $t;
|
||||||
|
print_header();
|
||||||
show_hostname($ip);
|
show_hostname($ip);
|
||||||
show_reverse($hostname);
|
show_reverse($hostname);
|
||||||
show_ipinfo($ip);
|
show_ipinfo($ip);
|
||||||
show_whois($ip);
|
show_whois($ip);
|
||||||
} elseif($method === "dns" ) { // detailed info a host name
|
} elseif($method === "dns" ) { // detailed info a host name
|
||||||
$hostname = $t;
|
$hostname = $t;
|
||||||
|
print_header();
|
||||||
show_reverse($hostname);
|
show_reverse($hostname);
|
||||||
show_dnsrecords($hostname);
|
show_dnsrecords($hostname);
|
||||||
show_whois($hostname);
|
show_whois($hostname);
|
||||||
@@ -45,7 +48,7 @@ if($method === "simple") { // simple
|
|||||||
header("Location:/".$config->detailed_uri."");
|
header("Location:/".$config->detailed_uri."");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
footer();
|
print_footer();
|
||||||
|
|
||||||
// HTTP HEADERS
|
// HTTP HEADERS
|
||||||
function show_http_headers() {
|
function show_http_headers() {
|
||||||
@@ -92,7 +95,7 @@ function show_whois($target) {
|
|||||||
preg_match('/[a-zA-Z\d\-]+\.[a-zA-Z\d]+$/', $target, $m);
|
preg_match('/[a-zA-Z\d\-]+\.[a-zA-Z\d]+$/', $target, $m);
|
||||||
$target = $m[0];
|
$target = $m[0];
|
||||||
}
|
}
|
||||||
$whois = shell_exec("whois " . $target );
|
$whois = shell_exec("timeout 5 whois " . $target );
|
||||||
echo "<pre>"; print_r($whois); echo "</pre>";
|
echo "<pre>"; print_r($whois); echo "</pre>";
|
||||||
echo "<br />\n";
|
echo "<br />\n";
|
||||||
}
|
}
|
||||||
@@ -111,6 +114,12 @@ function show_dnsrecords($hostname) {
|
|||||||
echo "<strong>" . $value['type'] . "</strong>: ";
|
echo "<strong>" . $value['type'] . "</strong>: ";
|
||||||
echo link_target($value['ipv6']) . "<br />\n";
|
echo link_target($value['ipv6']) . "<br />\n";
|
||||||
}
|
}
|
||||||
|
// CNAME
|
||||||
|
$dnsrecords = dnsrecords($hostname, "DNS_CNAME");
|
||||||
|
foreach($dnsrecords as $key=>$value) {
|
||||||
|
echo "<strong>" . $value['type'] . "</strong>: ";
|
||||||
|
echo link_target($value['target']) . "<br />\n";
|
||||||
|
}
|
||||||
// MX
|
// MX
|
||||||
$dnsrecords = dnsrecords($hostname, "DNS_MX");
|
$dnsrecords = dnsrecords($hostname, "DNS_MX");
|
||||||
foreach($dnsrecords as $key=>$value) {
|
foreach($dnsrecords as $key=>$value) {
|
||||||
@@ -142,7 +151,7 @@ function show_dnsrecords($hostname) {
|
|||||||
echo "" . $value['rname'] . " (rname), ";
|
echo "" . $value['rname'] . " (rname), ";
|
||||||
echo "" . $value['serial'] . " (serial)<br />\n";
|
echo "" . $value['serial'] . " (serial)<br />\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// OTHER
|
// OTHER
|
||||||
$dnsrecords = dnsrecords($hostname, "OTHER");
|
$dnsrecords = dnsrecords($hostname, "OTHER");
|
||||||
if(!empty($dnsrecords)) {
|
if(!empty($dnsrecords)) {
|
||||||
@@ -151,19 +160,32 @@ function show_dnsrecords($hostname) {
|
|||||||
echo "<br />\n";
|
echo "<br />\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// PRINT HEADER
|
||||||
|
function print_header() {
|
||||||
|
print '<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>IP and DNS information</title>
|
||||||
|
<link rel="icon" type="image/png" href="/favicon.png">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
';
|
||||||
|
}
|
||||||
// PRINT FOOTER
|
// PRINT FOOTER
|
||||||
function footer() {
|
function print_footer() {
|
||||||
global $config;
|
global $config;
|
||||||
echo "<br /><hr /><br />\n";
|
echo "<br /><hr /><br />\n";
|
||||||
echo 'Your plain IP address: <a href="//'.$config->ip4domain.'">IPv4</a> | <a href="//'.$config->ip6domain.'">IPv6</a>';
|
echo 'Your plain IP address: <a href="//'.$config->ip4domain.'">IPv4</a> | <a href="//'.$config->ip6domain.'">IPv6</a>';
|
||||||
echo "<br />\n";
|
echo "<br />\n";
|
||||||
echo 'Your detailed IP info: <a href="//'.$config->ip4domain.'/'.$config->detailed_uri.'">IPv4</a> | <a href="//'.$config->ip6domain.'/'.$config->detailed_uri.'">IPv6</a>';
|
echo 'Your detailed IP info: <a href="//'.$config->ip4domain.'/'.$config->detailed_uri.'">IPv4</a> | <a href="//'.$config->ip6domain.'/'.$config->detailed_uri.'">IPv6</a>';
|
||||||
|
echo '</body></html>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// HELPER FUNCTIONS
|
// HELPER FUNCTIONS
|
||||||
function readheader($value) {
|
function readheader($value) {
|
||||||
echo "<strong>" . $value . "</strong>: "; // show desired value
|
echo "<strong>" . $value . "</strong>: "; // show desired value
|
||||||
if(isset($_SERVER[$value])) { // only if desired header has been delivered
|
if(isset($_SERVER[$value])) { // only if desired header has been delivered
|
||||||
echo $_SERVER[$value];
|
echo $_SERVER[$value];
|
||||||
}
|
}
|
||||||
echo "<br />\n";
|
echo "<br />\n";
|
||||||
@@ -173,12 +195,17 @@ function ip2hostname($ip) {
|
|||||||
return $hostname;
|
return $hostname;
|
||||||
}
|
}
|
||||||
function hostname2ip($hostname) {
|
function hostname2ip($hostname) {
|
||||||
$ip = implode(', ', gethostbynamel($hostname));
|
$ipsbyhostname = gethostbynamel($hostname);
|
||||||
|
if($ipsbyhostname === false) {
|
||||||
|
$ip = $hostname;
|
||||||
|
} else {
|
||||||
|
$ip = implode(', ', gethostbynamel($hostname));
|
||||||
|
}
|
||||||
return $ip;
|
return $ip;
|
||||||
}
|
}
|
||||||
function dnsrecords($hostname, $record = "DNS_ALL") {
|
function dnsrecords($hostname, $record = "DNS_ALL") {
|
||||||
if($record === "OTHER") {
|
if($record === "OTHER") {
|
||||||
$dnsrecords = dns_get_record($hostname, DNS_ALL - DNS_A - DNS_AAAA - DNS_MX - DNS_NS - DNS_TXT - DNS_SOA);
|
$dnsrecords = dns_get_record($hostname, DNS_ALL - DNS_A - DNS_AAAA - DNS_MX - DNS_CNAME - DNS_NS - DNS_TXT - DNS_SOA);
|
||||||
} else {
|
} else {
|
||||||
$dnsrecords = dns_get_record($hostname, constant($record));
|
$dnsrecords = dns_get_record($hostname, constant($record));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user