Skip to content

Commit

Permalink
🔧 Improved os detection
Browse files Browse the repository at this point in the history
  • Loading branch information
anditv21 committed Oct 23, 2023
1 parent e4a05c0 commit f937299
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions src/app/models/UsersModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -935,45 +935,56 @@ protected function get_user_Browser() {
}




protected function get_user_os()
{
global $user_agent;
$user_agent = $_SERVER["HTTP_USER_AGENT"];
$os_platform = "Unknown";

$os_array = [
"/android/i" => "Android",
"/blackberry/i" => "BlackBerry",
"/chrome/i" => "Chrome OS",
"/ubuntu/i" => "Ubuntu",
"/macintosh|mac os x/i" => "Mac OS X",
"/mac_powerpc/i" => "Mac OS 9",
"/iphone/i" => "iPhone",
"/ipod/i" => "iPod",
"/ipad/i" => "iPad",
"/linux/i" => "Linux",
"/huawei/i" => "Huawei Mobile",
"/windows nt 10/i" => "Windows 10",
"/windows nt 6.3/i" => "Windows 8.1",
"/windows nt 6.2/i" => "Windows 8",
"/windows nt 6.1/i" => "Windows 7",
"/windows nt 6.0/i" => "Windows Vista",
"/windows nt 5.2/i" => "Windows Server 2003/XP x64",
"/windows nt 5.1/i" => "Windows XP",
"/windows xp/i" => "Windows XP",
"/windows nt 5.0/i" => "Windows 2000",
"/windows me/i" => "Windows ME",
"/win98/i" => "Windows 98",
"/win95/i" => "Windows 95",
"/win16/i" => "Windows 3.11",
"/macintosh|mac os x/i" => "Mac OS X",
"/mac_powerpc/i" => "Mac OS 9",
"/linux/i" => "Linux",
"/kalilinux/i" => "Wannabe Hacker",
"/ubuntu/i" => "Ubuntu",
"/iphone/i" => "iPhone",
"/ipod/i" => "iPod",
"/ipad/i" => "iPad",
"/android/i" => "Android",
"/blackberry/i" => "BlackBerry",
"/webos/i" => "Mobile",
"/Windows Phone/i" => "Windows Phone",
"/centos/i" => "CentOS",
"/debian/i" => "Debian",
"/fedora/i" => "Fedora",
"/redhat/i" => "Red Hat",
"/suse/i" => "openSUSE",
"/mint/i" => "Linux Mint",
"/kali/i" => "Kali Linux",
"/elementary/i" => "Elementary OS",
"/zorin/i" => "Zorin OS",
"/huawei/i" => "Huawei",
"/deepin/i" => "Deepin",
"/manjaro/i" => "Manjaro",
];

foreach ($os_array as $regex => $value) {
if (preg_match($regex, $user_agent)) {
$os_platform = $value;
}
}
return $os_platform;
}

}

0 comments on commit f937299

Please sign in to comment.