<?php
if (!defined('NTLCMS')) die('<center><b>Restricted access</b></center>');			

class Browserss {

var $agent = '';
var $name = '';
var $type = '';
var $icon = '';
var $ie = '';

public function Browserss($agent){
$this -> agent = $agent;
$this -> name = $name;
$this -> type = $type;
$this -> icon = $icon;
$this -> ie = $ie;
}
		
public function Browsers(){ 

// определение версии браузера
/*public function _browser_version($agent){
if (preg_match('#Version/([0-9]+(\.[0-9]+)?)#i', $agent, $v))
return $v[1];
}*/
// определение модели телефона
//if ($tel = self :: _phone_model($agent)){
//$this -> name = $tel[0];
//$this -> type = $tel[1];
//$this -> icon = '<img src="'.URL.'/img/browser/onmobile.gif" width = "16" height = "16" alt = "*"/>';
//}
// определение модели устройства
/*static protected function _phone_model($ua){
if (preg_match('#SonyEricsson([0-9a-z]+)#i', $ua, $b)){
return array('SonyEricsson '.$b[1], 'WAP');
}

if (preg_match('#Nokia([0-9a-z]+)#i', $ua, $b)){
return array('Nokia '.$b[1], 'WAP');
}

if (preg_match('#LG-([0-9a-z]+)#i', $ua, $b)){
return array('LG '.$b[1], 'WAP');
}

if (preg_match('#FLY( |\-)([0-9a-z]+)#i', $ua, $b)){
return array('FLY '.$b[2], 'WAP');
}

if (preg_match('#MOT-([0-9a-z]+)#i', $ua, $b)){
return array('Motorola '.$b[1], 'WAP');
}

if (preg_match('#SAMSUNG(-SGH|-GT)?-([0-9a-z]+)#i', $ua, $b)){
return array('Samsung '.$b[2], 'WAP');
}

if (preg_match('#SEC-SGH([0-9a-z]+)#i', $ua, $b)){
return array('Samsung '.$b[1], 'WAP');
}

if (preg_match('#SIE-([0-9a-z]+)#i', $ua, $b)){
return array('Siemens '.$b[1], 'WAP');
}
return false;
}*/

################################################################################
if (preg_match('#^([a-z0-9\-\_ ]+)/([0-9]+\.[0-9]+)#i', $this -> agent, $b)){
$this -> name = $b[1] . (!empty($b[2]) ? ' '.$b[2] : '');
$this -> type = 'PDA';
$this -> icon = '<img src="'.URL.'/img/browser/onmobile.gif" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#MSIE ([0-9]+)#ui', $this -> agent, $bv)){
$this -> name = 'Microsoft Internet Explorer';
$this -> type = 'WEB';
$this -> ie = $bv[1];
$this -> icon = '<img src="'.URL.'/img/browser/msie7.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#America Online Browser#i', $this -> agent)){
$this -> name = 'AOL Explorer';
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/aol.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#(Avant|Advanced) Browser#i', $this -> agent)){
$this -> name = 'Avant Browser';
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/avantbrowser.png" width = "16" height = "16" alt = "*"/>';
}

if (preg_match('#Camino/([0-9]+\.[0-9]+)#i', $this -> agent, $v)){
$this -> name = 'Camino '.$v[1];
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/camino.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#ELinks#i', $this -> agent)){
$this -> name = 'ELinks';
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/elinks.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#Epiphany#i', $this -> agent)){
$this -> name = 'Epiphany';
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/epiphany.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#Flock#i', $this -> agent)){
$this -> name = 'Flock';
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/flock.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#IceWeasel#i', $this -> agent)){
$this -> name = 'GNU IceWeasel';
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/iceweasel.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#IceCat#i', $this -> agent)){
$this -> name = 'GNU IceCat';
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/icecat.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#Microsoft Pocket Internet Explorer#i', $this -> agent)){
$this -> name = 'Internet Explorer Mobile';
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/unknown.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#MSPIE#i', $this -> agent)){
$this -> name = 'Internet Explorer Mobile';
$this -> type = 'PDA';
$this -> icon = '<img src="'.URL.'/img/browser/msie-mobile.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#Windows.+Smartphone#i', $this -> agent)){
$this -> name = 'Internet Explorer Mobile';
$this -> type = 'PDA';
$this -> icon = '<img src="'.URL.'/img/browser/msie-mobile.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#Konqueror#i', $this -> agent)){
$this -> name = 'Konqueror';
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/konqueror.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#Links#i', $this -> agent)){
$this -> name = 'Links';
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/links.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#Lynx#i', $this -> agent)){
$this -> name = 'Lynx';
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/lynx.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#Minimo#i', $this -> agent)){
$this -> name = 'Minimo';
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/minimo.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#(Firebird|Phoenix|Firefox)/([0-9]+\.[0-9]+)#i', $this -> agent, $v)){
$this -> name = 'Mozilla Firefox '.$v[2];
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/firefox.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#NetPositive#i', $this -> agent)){
$this -> name = 'NetPositive';
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/netpositive.png" width = "16" height = "16" alt = "*"/> ';
}
################################################################################
if (preg_match('#Opera/([0-9]+\.[0-9]+)#i', $this -> agent, $v)){
if (preg_match('#Version/([0-9]+(\.[0-9]+)?)#i', $this -> agent, $ver))
$this -> name = 'Opera '.($ver[1] ? $ver[1] : $v[1]);
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/opera-2.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#Opera Mini/([0-9]+\.[0-9]+)#i', $this -> agent, $v)){
$this -> name = 'Opera Mini '.$v[1];
$this -> type = 'WAP';
$this -> icon = '<img src="'.URL.'/img/browser/opera-1.png" width = "16" height = "16" alt = "*"/> ';
}

/*if (preg_match('#Opera Mobi#i', $this -> agent)){
if (preg_match('#Version/([0-9]+(\.[0-9]+)?)#i', $this -> agent, $ver))
if ($tel = self :: _phone_model($this -> agent))
$this -> name = 'Opera Mobile '.($ver[1] ? ' '.$ver[1] : '').' ['.$tel[0].']';
else
$this -> name = 'Opera Mobile '.($ver[1] ? ' '.$ver[1] : '');
$this -> type = 'PDA';
$this -> icon = '<img src="'.URL.'/img/browser/unknown.png" width = "16" height = "16" alt = "*"/> ';
}*/

/*if (preg_match('#(SymbOS|Symbian).+Opera ([0-9]+\.[0-9]+)#i', $this -> agent, $v)){
if ($tel = self :: _phone_model($this -> agent))
$this -> name = 'Opera Mobile '.$v[2].' ['.$tel[0].']';
else
$this -> name = 'Opera Mobile '.$v[2].' [Symbian]';
$this -> type = 'PDA';
$this -> icon = '<img src="'.URL.'/img/browser/unknown.png" width = "16" height = "16" alt = "*"/> ';
}*/

/*if (preg_match('#Windows CE.+Opera ([0-9]+\.[0-9]+)#i', $this -> agent, $v)){
if ($tel = self :: _phone_model($this -> agent))
$this -> name = 'Opera Mobile '.$v[1].' ['.$tel[0].']';
else
$this -> name = 'Opera Mobile '.$v[1].' [Win]';
$this -> type = 'PDA';
$this -> icon = '<img src="'.URL.'/img/browser/unknown.png" width = "16" height = "16" alt = "*"/> ';
}*/

if (preg_match('#PlayStation Portable#i', $this -> agent)){
$this -> name = 'PlayStation Portable';
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/unknown.png" width = "16" height = "16" alt = "*"/>';
}

if (preg_match('#Safari#i', $this -> agent)){
$this -> name = 'Safari';
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/safari.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#SeaMonkey#i', $this -> agent)){
$this -> name = 'SeaMonkey';
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/seamonkey.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#Shiira#i', $this -> agent)){
$this -> name = 'Shiira';
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/shiira.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#w3m#i', $this -> agent)){
$this -> name = 'w3m';
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/w3m.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#Chrome/([0-9]+\.[0-9]+)#i', $this -> agent, $v)){

$this -> name = 'Google Chrome '.$v[1];
$this -> type = 'WEB';
$this -> icon = '<img src="'.URL.'/img/browser/chrome.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#SONY/COM#i', $this -> agent)){
$this -> name = 'Sony mylo';
$this -> type = 'PDA';
$this -> icon = '<img src="'.URL.'/img/browser/unknown.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#Nitro#i', $this -> agent)){
$this -> name = 'Nintendo DS';
$this -> type = 'PDA';
$this -> icon = '<img src="'.URL.'/img/browser/unknown.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#^Openwave#i', $this -> agent)){
$this -> name = 'Openwave';
$this -> type = 'PDA';
$this -> icon = '<img src="'.URL.'/img/browser/openwave.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#UCWEB/([0-9]+\.[0-9]+)#i', $this -> agent, $match)){
$this -> name = 'UCWEB '.$match[1];
$this -> type = 'WAP';
$this -> icon = '<img src="'.URL.'/img/browser/ucweb.png" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#BOLT/([0-9]+\.[0-9]+)#i', $this -> agent, $match)){
$this -> name = 'BOLT '.$match[1];
$this -> type = 'WAP';
$this -> icon = '<img src="'.URL.'/img/browser/bolt.png" width = "16" height = "16" alt = "*"/> ';
}

################################################################################

/*if (preg_match('#Opera Mini/([0-9]+\.[0-9]+)#i', $this -> agent, $v)){
if ($tel = self :: _phone_model($this -> agent)){
$this -> name = 'Opera Mini '.$v[1].' ('.$tel[0].')';
$this -> type = version_compare($v[1], 4, '>=') ? 'PDA' : $tel[1];
$this -> icon = '<img src="'.URL.'/img/browser/onmobile.gif" width = "16" height = "16" alt = "*"/>';
}
} */

if (preg_match('#iPhone#i', $this -> agent)){
$this -> name = 'iPhone';
$this -> type = preg_match('#Opera Mini#i', $this -> agent) ? 'PDA' : 'ITOUCH';
$this -> icon = '<img src="'.URL.'/img/browser/onmobile.gif" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#iPod#i', $this -> agent)){
$this -> name = 'iPod';
$this -> type = preg_match('#Opera Mini#i', $this -> agent) ? 'PDA' : 'ITOUCH';
$this -> icon = '<img src="'.URL.'/img/browser/onmobile.gif" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#iPad#i', $this -> agent)){
$this -> name = 'iPad';
$this -> type = preg_match('#Opera Mini#i', $this -> agent) ? 'PDA' : 'ITOUCH';
$this -> icon = '<img src="'.URL.'/img/browser/onmobile.gif" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#Bada#i', $this -> agent)){
$this -> name = 'Samsung Bada';
$this -> type = preg_match('#Opera Mini#i', $this -> agent) ? 'PDA' : 'ITOUCH';
$this -> icon = '<img src="'.URL.'/img/browser/onmobile.gif" width = "16" height = "16" alt = "*"/> ';
}

if (preg_match('#Android#i', $this -> agent)){
if (preg_match('#Opera Mini#i', $this -> agent)){
$this -> name = 'Opera Mini (Android)';
$this -> type = 'PDA';
$this -> icon = '<img src="'.URL.'/img/browser/onmobile.gif" width = "16" height = "16" alt = "*"/> ';
} else {
$this -> name = 'Android';
$this -> type = 'ITOUCH';
$this -> icon = '<img src="'.URL.'/img/browser/onmobile.gif" width = "16" height = "16" alt = "*"/> ';
}
}

if (preg_match('#Windows Phone#i', $this -> agent)){

if (preg_match('#Opera Mini#i', $this -> agent)){
$this -> name = 'Opera Mini (Windows Phone)';
$this -> type = 'PDA';
$this -> icon = '<img src="'.URL.'/img/browser/onmobile.gif" width = "16" height = "16" alt = "*"/> ';
} else {
$this -> name = 'Windows Phone 7';
$this -> type = 'ITOUCH';
$this -> icon = '<img src="'.URL.'/img/browser/onmobile.gif" width = "16" height = "16" alt = "*"/> ';
}
}
return $this -> icon . $this -> name;
}

}

//$oss = new Browser() or die('Error init Operatings class!');
//$oss = new Browser($_SERVER['HTTP_USER_AGENT']);
//$oss -> Browsers()

?>