$_SERVER['REMOTE_ADDR'],
'host' => (isset($_SERVER['REMOTE_ADDR']) ? gethostbyaddr($_SERVER['REMOTE_ADDR']) : ""),
'port' => $_SERVER['REMOTE_PORT'],
'ua' => $_SERVER['HTTP_USER_AGENT'],
'lang' => $_SERVER['HTTP_ACCEPT_LANGUAGE'],
'mime' => $_SERVER['HTTP_ACCEPT'],
'encoding' => $_SERVER['HTTP_ACCEPT_ENCODING'],
'charset' => $_SERVER['HTTP_ACCEPT_CHARSET'],
'connection' => $_SERVER['HTTP_CONNECTION'],
'cache' => $_SERVER['HTTP_CACHE_CONTROL'],
'cookie' => $_SERVER['HTTP_COOKIE'],
'referer' => $_SERVER['HTTP_REFERER'],
'real_ip' => $_SERVER['HTTP_X_REAL_IP'],
'fwd_ip' => $_SERVER['HTTP_X_FORWARDED_FOR'],
'fwd_host' => (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? gethostbyaddr($_SERVER['HTTP_X_FORWARDED_FOR']) : ""),
'dnt' => $_SERVER['HTTP_DNT']
);
// Check request (ex. ifconfig.php?q=ip)
$query=trim(preg_replace('/ +/', ' ', preg_replace('/[^A-Za-z0-9 ]/', ' ', urldecode(html_entity_decode(strip_tags($_GET['q']))))));
// Return single value on request & die
if (isset($query) && !empty($user[$query]) && array_key_exists($query, $user)) {
die($user[$query]."\n");
}
// Return full output in one of supported formats (html, text, xml, json. default: html)
elseif (isset($query) && ($query=="text")) {
header('Content-Type: text/plain');
foreach($user as $key => $value) {
echo $key.": ".$value."\n";
}
die();
} elseif (isset($query) && ($query=="xml")) {
header('Content-Type: text/xml');
// Function for SimpleXML creation
function array_to_xml(array $arr, SimpleXMLElement $xml)
{
foreach ($arr as $k => $v) {
is_array($v)
? array_to_xml($v, $xml->addChild($k))
: $xml->addChild($k, $v);
}
return $xml;
}
echo array_to_xml($user, new SimpleXMLElement('
'.$key.': '.$value.'
'."\n"; } ?>Copyright © 2014 Sergey Briskin.
Get Source code on GitHub