Scripts

Browser / os functie

Heb hem even aangepast. Dit is beter ;) Met dank aan PrisonerOfPain. Op vragen door: $var = user_agent();

browser-os-functie
[code]<?
function useragent ()
{
        $Browsers = array
                (
                        'MSIE 5.5' => 'Internet Explorer 5.5',
                        'MSIE 6.0' => 'Internet Explorer 6.0',
                        'Konqueror' => 'Konqueror',
                        'Netscape' => 'Netscape',
                        'MSIE' => 'Internet Explorer',
                        'Firefox' => 'Mozilla Firefox',
                        'Safari' => 'Safari'
                );

        $OperatingSystems = array
                (
                        'Win98' => 'Microsoft Windows 98',
                        'Windows NT 5.0' => 'Microsoft Windows 2000',
                        'Win95' => 'Microsoft Windows 95',
                        'Windows NT 5.1' => 'Microsoft Windows XP',
                        'Linux' => 'Linux',
                );

        $Res['Browser'] = _find (&$Browsers, $_SERVER['HTTP_USER_AGENT']);
        $Res['OS'] = _find (&$OperatingSystems, $_SERVER['HTTP_USER_AGENT']);
        return $Res;
}

function _find (&$Array, $Haystack)
{
        foreach ($Array as $Key => $Value)
        {
                if (strstr ($Haystack, $Key) !== false)
                {
                        return $Value;
                }
        }
}

list ($Browser, $OS) = useragent();
print_r(user_agent());
?>[/code]

Reacties

0
Nog geen reacties.