30 lines
505 B
PHP
Executable file
30 lines
505 B
PHP
Executable file
#!/usr/bin/php
|
|
<?php
|
|
|
|
require __DIR__.'/base/block.php';
|
|
|
|
$ipv6 = !empty($argv[1]);
|
|
$iface = 'wan';
|
|
|
|
$command = sprintf(
|
|
'wget -O - -q %s "https://api.ipify.org/?format=text" | head -n 1 | cut -c1-50',
|
|
$ipv6 ? '-6' : null
|
|
);
|
|
|
|
$ip = trim(shell_exec($command));
|
|
|
|
if (empty($ip)) {
|
|
die;
|
|
}
|
|
|
|
$fullText = sprintf('[%s] %s', $iface, $ip);
|
|
$shortText = sprintf('%s: %s', $iface, $ip);
|
|
|
|
echo block(
|
|
'ip_'.$iface,
|
|
[
|
|
'full_text' => $fullText,
|
|
'short_text' => $shortText,
|
|
]
|
|
);
|