Skip to content

Instantly share code, notes, and snippets.

@fedek6
Created September 28, 2015 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fedek6/3fcf3742c82f8c570e0b to your computer and use it in GitHub Desktop.
Save fedek6/3fcf3742c82f8c570e0b to your computer and use it in GitHub Desktop.
phpinfo() only for local requests
<?php
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
if ( ! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE) )
{
phpinfo();
} else {
echo 'In Soviet Russia server hack you!';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment