" Internet Explorer", '/firefox/i' => " Firefox", '/safari/i' => " Safari", '/chrome/i' => " Chrome", '/edg/i' => " Edge", '/opr/i' => " Opera", '/ddg/i' => " DuckDuckGo" ); foreach ($browser_array as $regex => $value) { if (preg_match($regex, $user_browser)) { $browser = $value; } } return $browser; } function getOS($user_os) { $os_platform = "-"; $os_array = array( '/windows/i' => " Windows", '/macintosh|mac os x/i' => " MacOS", '/linux/i' => " Linux", '/ubuntu/i' => " Ubuntu", '/fedora/i' => " Fedora", '/iphone/i' => " iPhone", '/ipad/i' => " iPad", '/android/i' => " Android" ); foreach ($os_array as $regex => $value) { if (preg_match($regex, $user_os)) { $os_platform = $value; } } return $os_platform; } function isMobile() { // Check if the user agent is a mobile device return preg_match('/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|opera mini|palm|phone|pie|tablet|up.browser|up.link|webos|wos)/i', $_SERVER['HTTP_USER_AGENT']); } // Redirect Function function redirect($url = null, $permanent = false) { // Use referer if no URL is provided if (!$url) { $url = $_SERVER['HTTP_REFERER'] ?? 'index.php'; } if (!headers_sent()) { header('Location: ' . $url, true, $permanent ? 301 : 302); exit; } else { // Fallback for headers already sent echo ""; echo ''; exit; } } //Flash Alert Function function flashAlert(string $message, string $type = 'success'): void { $_SESSION['alert_type'] = $type; $_SESSION['alert_message'] = $message; }