{% else-1 %}
$ip - IP
$ua - User Agent
$device - тип браузера. Возможные значения: Mobile, Opera Mini, Computer, BOT

                        
<?php

if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && filter_var($_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP))

$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];

elseif (isset($_SERVER['REMOTE_ADDR']) && filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP)) $ip = $_SERVER['REMOTE_ADDR'];

else $ip = 'Unknown';

$device = 'Mobile';

if (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])){



$device = 'Opera Mini';

$ua = htmlspecialchars(mysql_escape_string(trim($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])));

}elseif(isset($_SERVER['HTTP_USER_AGENT'])){

$ua = htmlspecialchars(mysql_escape_string(trim($_SERVER['HTTP_USER_AGENT'])));

$sx = strtr('windows ce', NULL, strtolower($ua));

if (!$sx ||

strpos($sx, 'windows') !== false ||

strpos($sx, 'linux') !== false ||

strpos($sx, 'bsd') !== false ||

strpos($sx, 'x11') !== false ||

strpos($sx, 'unix') !== false ||

strpos($sx, 'mac') !== false)

$device = 'Computer';



if(strpos($sx, 'yandex') !== false ||

strpos($sx, 'rambler') !== false ||

strpos($sx, 'mail') !== false ||

strpos($sx, 'google') !== false ||

strpos($sx, 'slurp') !== false ||

strpos($sx, 'msn') !== false ||

strpos($sx, 'teoma') !== false ||

strpos($sx, 'scooter') !== false ||

strpos($sx, 'ia_archiver') !== false ||

strpos($sx, 'lycos') !== false ||

strpos($sx, 'webalta') !== false ||

strpos($sx, 'aport') !== false)

$device = 'BOT';

}else $ua = 'Unknown';

?>
1 32 0
Без комментариев...