From f93729916546aeb7592f39a5da85e7f6eeea3c44 Mon Sep 17 00:00:00 2001 From: Andreas Date: Mon, 23 Oct 2023 15:08:18 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Improved=20os=20detection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/models/UsersModel.php | 41 ++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/app/models/UsersModel.php b/src/app/models/UsersModel.php index 7442799..dde2af7 100644 --- a/src/app/models/UsersModel.php +++ b/src/app/models/UsersModel.php @@ -935,14 +935,24 @@ 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", @@ -950,25 +960,25 @@ protected function get_user_os() "/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; @@ -976,4 +986,5 @@ protected function get_user_os() } return $os_platform; } + }