Skip to content

Commit 742085e

Browse files
committed
add remote ip address on phpwpinfo
1 parent 9569abf commit 742085e

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

phpwpinfo.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,22 @@ public function test_versions() {
155155
} else {
156156
$this->html_table_row('GIT is installed?', 'No', 'Yes', 'No', 'error');
157157
}
158+
159+
$this->html_table_row('Remote IP via $_SERVER["REMOTE_ADDR"]', '', '', $_SERVER["REMOTE_ADDR"], 'info');
160+
161+
if ( isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ) {
162+
$this->html_table_row('Remote IP via $_SERVER["HTTP_X_FORWARDED_FOR"]', '', '', $_SERVER["HTTP_X_FORWARDED_FOR"], 'info');
163+
}
164+
165+
if ( isset($_SERVER["HTTP_X_FORWARDED"]) ) {
166+
$this->html_table_row('Remote IP via $_SERVER["HTTP_X_FORWARDED"]', '', '', $_SERVER["HTTP_X_FORWARDED"], 'info');
167+
}
168+
169+
if ( isset($_SERVER["HTTP_CLIENT_IP"]) ) {
170+
$this->html_table_row('Remote IP via $_SERVER["HTTP_CLIENT_IP"]', '', '', $_SERVER["HTTP_CLIENT_IP"], 'info');
171+
}
172+
173+
$this->html_table_row('Real remote IP via AJAX call', '', '', '... js loading ...', 'warning realip');
158174
}
159175

160176
public function test_php_extensions() {
@@ -449,6 +465,7 @@ public function test_php_config() {
449465
public function return_bytes($val) {
450466
$val = trim($val);
451467
$last = strtolower($val[strlen($val)-1]);
468+
$val = (int) $val;
452469
switch($last) {
453470
// Le modifieur 'G' est disponible depuis PHP 5.1.0
454471
case 'g':
@@ -625,8 +642,16 @@ public function get_footer() {
625642

626643
$output .= '<footer>&copy; <a href="http://beapi.fr">BE API</a> ' . date( 'Y' ) . '</footer>' . "\n";
627644
$output .= '</div>' . "\n";
645+
628646
$output .= '<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>' . "\n";
629647
$output .= '<script src="https://maxcdn.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>' . "\n";
648+
649+
$output .= '<script type="text/javascript">
650+
$.getJSON("//freegeoip.net/json/?callback=?", function(data) {
651+
$(".realip td:last").html(data.ip);
652+
});
653+
</script>' . "\n";
654+
630655
$output .= '</body>' . "\n";
631656
$output .= '</html>' . "\n";
632657

@@ -1147,4 +1172,4 @@ private function _command_exists($command) {
11471172
}
11481173

11491174
// Init render
1150-
phpwpinfo();
1175+
phpwpinfo();

0 commit comments

Comments
 (0)