![]() |
|
[PHP]Get OS and Browser - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: PHP (https://sinister.li/Forum-PHP) +--- Thread: [PHP]Get OS and Browser (/Thread-PHP-Get-OS-and-Browser) |
[PHP]Get OS and Browser - 1234hotmaster - 07-21-2011 Operating System Function: PHP Code: function GetOS() {
$oses = array ( 'iPhone' => '(iPhone)', 'Windows 3.11' => 'Win16','Windows 95' => '(Windows 95)|(Win95)|(Windows_95)','Windows 98' => '(Windows 98)|(Win98)',
'Windows 2000' => '(Windows NT 5.0)|(Windows 2000)','Windows XP' => '(Windows NT 5.1)|(Windows XP)','Windows 2003' => '(Windows NT 5.2)',
'Windows Vista' => '(Windows NT 6.0)|(Windows Vista)','Windows 7' => '(Windows NT 6.1)|(Windows 7)','Windows NT 4.0' => '(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)',
'Windows ME' => 'Windows ME','Open BSD'=>'OpenBSD','Sun OS'=>'SunOS','Linux'=>'(Linux)|(X11)','Safari' => '(Safari)',
'Macintosh'=>'(Mac_PowerPC)|(Macintosh)','QNX'=>'QNX','BeOS'=>'BeOS','OS/2'=>'OS/2',
'Search Bot'=>'(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp/cat)|(msnbot)|(ia_archiver)');
foreach($oses as $os=>$pattern){if(eregi($pattern, $_SERVER['HTTP_USER_AGENT'])) {return $os;} } return 'Unknown';
}
Usage: PHP Code: <?php echo "Your Current OS is".GetOS(); ?>Browser Function: PHP Code: function GetBrowser() {
$browsers = array('Opera' => 'Opera','Mozilla Firefox'=> '(Firebird)|(Firefox)','Galeon' => 'Galeon','Mozilla'=>'Gecko','MyIE'=>'MyIE',
'Lynx' => 'Lynx','Netscape' => '(Mozilla/4\.75)|(Netscape6)|(Mozilla/4\.08)|(Mozilla/4\.5)|(Mozilla/4\.6)|(Mozilla/4\.79)',
'Konqueror'=>'Konqueror','SearchBot' => '(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp/cat)|(msnbot)|(ia_archiver)',
'Internet Explorer 8' => '(MSIE 8\.[0-9]+)','Internet Explorer 7' => '(MSIE 7\.[0-9]+)','Internet Explorer 6' => '(MSIE 6\.[0-9]+)',
'Internet Explorer 5' => '(MSIE 5\.[0-9]+)','Internet Explorer 4' => '(MSIE 4\.[0-9]+)');
foreach($browsers as $browser=>$pattern) { if(eregi($pattern, $_SERVER['HTTP_USER_AGENT'])) {return $browser; } } return 'Unknown';
}
Usage: PHP Code: <?php echo "Your Browser is ".GetBrowser(); ?>Credits to a guy i really don't remember
[PHP]Get OS and Browser - 1234hotmaster - 07-21-2011 Operating System Function: PHP Code: function GetOS() {
$oses = array ( 'iPhone' => '(iPhone)', 'Windows 3.11' => 'Win16','Windows 95' => '(Windows 95)|(Win95)|(Windows_95)','Windows 98' => '(Windows 98)|(Win98)',
'Windows 2000' => '(Windows NT 5.0)|(Windows 2000)','Windows XP' => '(Windows NT 5.1)|(Windows XP)','Windows 2003' => '(Windows NT 5.2)',
'Windows Vista' => '(Windows NT 6.0)|(Windows Vista)','Windows 7' => '(Windows NT 6.1)|(Windows 7)','Windows NT 4.0' => '(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)',
'Windows ME' => 'Windows ME','Open BSD'=>'OpenBSD','Sun OS'=>'SunOS','Linux'=>'(Linux)|(X11)','Safari' => '(Safari)',
'Macintosh'=>'(Mac_PowerPC)|(Macintosh)','QNX'=>'QNX','BeOS'=>'BeOS','OS/2'=>'OS/2',
'Search Bot'=>'(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp/cat)|(msnbot)|(ia_archiver)');
foreach($oses as $os=>$pattern){if(eregi($pattern, $_SERVER['HTTP_USER_AGENT'])) {return $os;} } return 'Unknown';
}
Usage: PHP Code: <?php echo "Your Current OS is".GetOS(); ?>Browser Function: PHP Code: function GetBrowser() {
$browsers = array('Opera' => 'Opera','Mozilla Firefox'=> '(Firebird)|(Firefox)','Galeon' => 'Galeon','Mozilla'=>'Gecko','MyIE'=>'MyIE',
'Lynx' => 'Lynx','Netscape' => '(Mozilla/4\.75)|(Netscape6)|(Mozilla/4\.08)|(Mozilla/4\.5)|(Mozilla/4\.6)|(Mozilla/4\.79)',
'Konqueror'=>'Konqueror','SearchBot' => '(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp/cat)|(msnbot)|(ia_archiver)',
'Internet Explorer 8' => '(MSIE 8\.[0-9]+)','Internet Explorer 7' => '(MSIE 7\.[0-9]+)','Internet Explorer 6' => '(MSIE 6\.[0-9]+)',
'Internet Explorer 5' => '(MSIE 5\.[0-9]+)','Internet Explorer 4' => '(MSIE 4\.[0-9]+)');
foreach($browsers as $browser=>$pattern) { if(eregi($pattern, $_SERVER['HTTP_USER_AGENT'])) {return $browser; } } return 'Unknown';
}
Usage: PHP Code: <?php echo "Your Browser is ".GetBrowser(); ?>Credits to a guy i really don't remember
RE: [PHP]Get OS and Browser - White Charisma - 07-22-2011 lol, thanks dude, but change the colours, i can hardly read it D: RE: [PHP]Get OS and Browser - White Charisma - 07-22-2011 lol, thanks dude, but change the colours, i can hardly read it D: RE: [PHP]Get OS and Browser - 1234hotmaster - 07-22-2011 sorry its [php] tag i can't do anything
RE: [PHP]Get OS and Browser - 1234hotmaster - 07-22-2011 sorry its [php] tag i can't do anything
RE: [PHP]Get OS and Browser - White Charisma - 07-22-2011 Bleh ill blame sage then ;P RE: [PHP]Get OS and Browser - White Charisma - 07-22-2011 Bleh ill blame sage then ;P RE: [PHP]Get OS and Browser - FreeBobby - 09-25-2011 Wow thanks, I didn't know those tips !
|