Файл: vkollektive2014/core/ip.php
Строк: 80
<?
if (empty($_SESSION['user_brow'])){
if (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])) {
$agent = $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'];
} elseif (isset($_SERVER['HTTP_USER_AGENT'])) {
$agent = $_SERVER['HTTP_USER_AGENT'];
} else {
$agent = 'Неизвестный браузер';
}
$agent = preg_replace('|http://|i','', $agent);
$agent = strtok($agent,'( ');
$_SESSION['user_brow'] = substr($agent,0,22);
}
$agent = check($_SESSION['user_brow']);
if (preg_match("/^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$/", $_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
elseif (preg_match("/^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$/", $_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
else
{
$ip = preg_replace("/[^0-9.]/", "", $_SERVER['REMOTE_ADDR']);
}
$ip = htmlspecialchars(stripslashes($ip));
function GetUserAgent()
{
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$agent = check($_SERVER['HTTP_USER_AGENT']);
if (stripos($agent, 'Avant Browser') !== false) {
return 'Avant Browser';
} elseif (stripos($agent, 'Acoo Browser') !== false) {
return 'Acoo Browser';
} elseif (stripos($agent, 'MyIE2') !== false) {
return 'MyIE2';
} elseif (preg_match('|Iron/([0-9a-z.]*)|i', $agent, $pocket)) {
return 'SRWare Iron ' . subtok($pocket[1], '.', 0, 2);
} elseif (preg_match('|Chrome/([0-9a-z.]*)|i', $agent, $pocket)) {
return 'Chrome ' . subtok($pocket[1], '.', 0, 3);
} elseif (preg_match('#(Maxthon|NetCaptor)( [0-9a-z.]*)?#i', $agent, $pocket)) {
return $pocket[1] . $pocket[2];
} elseif (stripos($agent, 'Safari') !== false && preg_match('|Version/([0-9]{1,2}.[0-9]{1,2})|i', $agent, $pocket)) {
return 'Safari ' . subtok($pocket[1], '.', 0, 3);
} elseif (preg_match('#(NetFront|K-Meleon|Netscape|Galeon|Epiphany|Konqueror|Safari|Opera Mini|Opera Mobile)/([0-9a-z.]*)#i', $agent, $pocket)) {
return $pocket[1] . ' ' . subtok($pocket[2], '.', 0, 2);
} elseif (stripos($agent, 'Opera') !== false && preg_match('|Version/([0-9]{1,2}.[0-9]{1,2})|i', $agent, $pocket)) {
return 'Opera ' . $pocket[1];
} elseif (preg_match('|Opera[/ ]([0-9a-z.]*)|i', $agent, $pocket)) {
return 'Opera ' . subtok($pocket[1], '.', 0, 2);
} elseif (preg_match('|Orca/([ 0-9a-z.]*)|i', $agent, $pocket)) {
return 'Orca ' . subtok($pocket[1], '.', 0, 2);
} elseif (preg_match('#(SeaMonkey|Firefox|GranParadiso|Minefield|Shiretoko)/([0-9a-z.]*)#i', $agent, $pocket)) {
return $pocket[1] . ' ' . subtok($pocket[2], '.', 0, 3);
} elseif (preg_match('|rv:([0-9a-z.]*)|i', $agent, $pocket) && strpos($agent, 'Mozilla/') !== false) {
return 'Mozilla ' . subtok($pocket[1], '.', 0, 2);
} elseif (preg_match('|Lynx/([0-9a-z.]*)|i', $agent, $pocket)) {
return 'Lynx ' . subtok($pocket[1], '.', 0, 2);
} elseif (preg_match('|MSIE ([0-9a-z.]*)|i', $agent, $pocket)) {
return 'IE ' . subtok($pocket[1], '.', 0, 2);
} else {
$agent = preg_replace('|http://|i', '', $agent);
$agent = strtok($agent, '( ');
$agent = substr($agent, 0, 22);
$agent = subtok($agent, '.', 0, 2);
if (!empty($agent)) {
return $agent;
}
}
}
return 'Unknown';
}
?>