I'm setting up a support system and need to get some data from the client when it opens the service these data are: IP Operating System in this format (Windows 10 64x for ex) Browser used (Google Chrome Version 99)
The ip I can get normally. what is missing is the rest and the closest I got was this here;
$ip = $_SERVER['REMOTE_ADDR'];
$u_agent = $_SERVER['HTTP_USER_AGENT'];
$bname = 'Unknown';
$platform = 'Unknown';
$version= "";
if (preg_match('/linux/i', $u_agent)) {
$platform = 'Linux';
}
elseif (preg_match('/macintosh|mac os x/i', $u_agent)) {
$platform = 'Mac';
}
elseif (preg_match('/windows|win32/i', $u_agent)) {
$platform = 'Windows';
}
if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent))
{
$bname = 'Internet Explorer';
$ub = "MSIE";
}
elseif(preg_match('/Firefox/i',$u_agent))
{
$bname = 'Mozilla Firefox';
$ub = "Firefox";
}
elseif(preg_match('/Chrome/i',$u_agent))
{
$bname = 'Google Chrome';
$ub = "Chrome";
}
elseif(preg_match('/AppleWebKit/i',$u_agent))
{
$bname = 'AppleWebKit';
$ub = "Opera";
}
elseif(preg_match('/Safari/i',$u_agent))
{
$bname = 'Apple Safari';
$ub = "Safari";
}
elseif(preg_match('/Netscape/i',$u_agent))
{
$bname = 'Netscape';
$ub = "Netscape";
}
$known = array('Version', $ub, 'other');
$pattern = '#(?<browser>' . join('|', $known) .')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
if (!preg_match_all($pattern, $u_agent, $matches)) {
}
$i = count($matches['browser']);
if ($i != 1) {
if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){
$version= $matches['version'][0];
}
else {
$version= $matches['version'][1];
}
}
else {
$version= $matches['version'][0];
}
// check if we have a number
if ($version==null || $version=="") {$version="?";}
$Browser = array(
'userAgent' => $u_agent,
'name' => $bname,
'version' => $version,
'platform' => $platform,
'pattern' => $pattern
);
$navegador = "Navegador: " . $Browser['name'] . " " . $Browser['version'];
$so = "SO: " . $Browser['platform'];
echo $navegador . "<br> $so";
and this returns
Browser: Google Chrome 60.0.3112.90 OS: Windows
So it's only necessary to bring in what system windows is in case if it is windows or what linux or other operating system it is and if available if it is 32 or 64x
Could anyone guide me with changing this function to display at least the OS version?