<? 
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) and preg_match('|^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$|',$_SERVER['HTTP_X_FORWARDED_FOR']))
{
	$ip = trim(htmlspecialchars(mysql_real_escape_string($_SERVER['HTTP_X_FORWARDED_FOR'])));
}
elseif(isset($_SERVER['HTTP_CLIENT_IP']) and preg_match('|^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$|',$_SERVER['HTTP_CLIENT_IP']))
{
	$ip = trim(htmlspecialchars(mysql_real_escape_string($_SERVER['HTTP_CLIENT_IP'])));
}
elseif(isset($_SERVER['REMOTE_ADDR']) and preg_match('|^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$|',$_SERVER['REMOTE_ADDR']))
{
	$ip = trim(htmlspecialchars(mysql_real_escape_string($_SERVER['REMOTE_ADDR'])));
}
else
{
	$ip = 'Скрыт';
}

/* Определение UA посетителя */
if (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']))
{
	$ua = trim(stripcslashes(htmlspecialchars(mysql_real_escape_string($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']))));
}
elseif (isset($_SERVER['HTTP_USER_AGENT']))
{
	$ua = trim(stripcslashes(htmlspecialchars(mysql_real_escape_string($_SERVER['HTTP_USER_AGENT']))));
}
else
{
	$ua = 'Скрыт';
}
$ua=strtok($ua, '/');
$ua=strtok($ua, ' ');

?>