<?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'];
}
$browsers = [
'Firefox',
'Opera',
'Chrome',
'MSIE'
];
foreach($browsers AS $browser)
{
if (preg_match('#(' . $browser . ')#ui', $_SERVER['HTTP_USER_AGENT']))
{
$ua = $browser;
}
}