1
0

setselfaddress

This commit is contained in:
Mike Schwörer 2018-02-03 14:43:28 +01:00
parent fe5f066621
commit 0999209e5b
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
3 changed files with 38 additions and 16 deletions

View File

@ -328,4 +328,20 @@ function sendExceptionMail($e)
{
//
}
}
function get_client_ip() {
if (getenv('HTTP_CLIENT_IP')) return getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR')) return getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED')) return getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR')) return getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED')) return getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR')) return getenv('REMOTE_ADDR');
else if (isset($_SERVER['HTTP_CLIENT_IP'])) return $_SERVER['HTTP_CLIENT_IP'];
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) return $_SERVER['HTTP_X_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_X_FORWARDED'])) return $_SERVER['HTTP_X_FORWARDED'];
else if(isset($_SERVER['HTTP_FORWARDED_FOR'])) return $_SERVER['HTTP_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_FORWARDED'])) return $_SERVER['HTTP_FORWARDED'];
else if(isset($_SERVER['REMOTE_ADDR'])) return $_SERVER['REMOTE_ADDR'];
else return 'UNKNOWN';
}

View File

@ -88,6 +88,24 @@ function dumpConsistency($c) {
<!------------------------------------------>
<div class="boxedcontent">
<div class="bc_header">Self IP Addr</div>
<?php
$ippath = __DIR__ . '/../dynamic/self_ip_address.auto.cfg';
$self_ip = file_exists($ippath) ? file_get_contents($ippath) : 'N/A';
$real_ip = get_client_ip();
$me = $real_ip == $self_ip
?>
<div class="bc_data keyvaluelist kvl_200">
<div><span>Registered IP:</span> <span><?php echo $self_ip; ?></span></div>
<div><span>Current IP:</span> <span><?php echo $real_ip; ?></span></div>
</div>
</div>
<!------------------------------------------>
<div class="boxedcontent">
<div class="bc_header">ExtendedGitGraph</div>

View File

@ -1,21 +1,9 @@
<?php
function get_client_ip() {
if (getenv('HTTP_CLIENT_IP')) return getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR')) return getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED')) return getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR')) return getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED')) return getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR')) return getenv('REMOTE_ADDR');
else if (isset($_SERVER['HTTP_CLIENT_IP'])) return $_SERVER['HTTP_CLIENT_IP'];
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) return $_SERVER['HTTP_X_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_X_FORWARDED'])) return $_SERVER['HTTP_X_FORWARDED'];
else if(isset($_SERVER['HTTP_FORWARDED_FOR'])) return $_SERVER['HTTP_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_FORWARDED'])) return $_SERVER['HTTP_FORWARDED'];
else if(isset($_SERVER['REMOTE_ADDR'])) return $_SERVER['REMOTE_ADDR'];
else return 'UNKNOWN';
}
$ip = get_client_ip();
//TODO setSelfAdress
file_put_contents(__DIR__ . '/../dynamic/self_ip_address.auto.cfg', $ip);
system('add-trusted-ip "' . $ip . '"');
echo 'Ok.';