public function loadBrowscapIni(){
		$sBrowscapIniPath = $this->getBrowscapIniPath();

		//Local file
		if(is_readable($sBrowscapIniPath)){
			$aBrowscap = parse_ini_file($this->getBrowscapIniPath(), true, INI_SCANNER_RAW);
			if($aBrowscap === false)throw new \RuntimeException('Error appends while parsing browscap.ini file "'.$sBrowscapIniPath.'"');
		}
		//Remote file
		else{
			if(($oFileHandle = @fopen($sBrowscapIniPath, 'r')) === false)throw new \InvalidArgumentException('Unable to load browscap.ini file "'.$sBrowscapIniPath.'"');
			$sBrowscapIniContents = '';
			while(($sContent = fgets($oFileHandle)) !== false) {
				$sBrowscapIniContents .= $sContent.PHP_EOL;
			}
			if(!feof($oFileHandle))throw new \RuntimeException('Unable to retrieve contents from browscap.ini file "'.$sBrowscapIniPath.'"');
			fclose($oFileHandle);
			$aBrowscap = parse_ini_string($sBrowscapIniContents, true, INI_SCANNER_RAW);
			if($aBrowscap === false)throw new \RuntimeException('Error appends while parsing browscap.ini file "'.$sBrowscapIniPath.'"');
		}

		$aBrowscapKeys = array_keys($aBrowscap);
		$aBrowscap = array_combine($aBrowscapKeys, array_map(function($aUserAgentInfos, $sUserAgent){
			$aUserAgentInfos = array_map(function($sValue){
				if($sValue === 'true')return 1;
				elseif($sValue === 'false')return '';
				else return $sValue;
			}, $aUserAgentInfos);

			//Define browser name regex
			$aUserAgentInfos['browser_name_regex'] = '^'.str_replace(
				array('\\','.','?','*','^','$','[',']','|','(',')','+','{','}','%'),
				array('\\\\','\\.','.','.*','\\^','\\$','\\[','\\]','\\|','\\(','\\)','\\+','\\{','\\}','\\%'),
				$sUserAgent
			).'$';


			return array_change_key_case($aUserAgentInfos,CASE_LOWER);
		},$aBrowscap,$aBrowscapKeys));

		uksort($aBrowscap,function($sUserAgentA,$sUserAgentB){
			if(($sUserAgentALength = strlen($sUserAgentA)) > ($sUserAgentBLength = strlen($sUserAgentB)))return -1;
			elseif($sUserAgentALength < $sUserAgentBLength)return 1;
			else return strcasecmp($sUserAgentA,$sUserAgentB);
		});
		return $this->setBrowscap($aBrowscap);
	}
public function loadBrowscapIni(){
		$sBrowscapIniPath = $this->getBrowscapIniPath();

		//Local file
		if(is_readable($sBrowscapIniPath)){
			$aBrowscap = parse_ini_file($this->getBrowscapIniPath(), true, INI_SCANNER_RAW);
			if($aBrowscap === false)throw new \RuntimeException('Error appends while parsing browscap.ini file "'.$sBrowscapIniPath.'"');
		}
		//Remote file
		else{
			if(($oFileHandle = @fopen($sBrowscapIniPath, 'r')) === false)throw new \InvalidArgumentException('Unable to load browscap.ini file "'.$sBrowscapIniPath.'"');
			$sBrowscapIniContents = '';
			while(($sContent = fgets($oFileHandle)) !== false) {
				$sBrowscapIniContents .= $sContent.PHP_EOL;
			}
			if(!feof($oFileHandle))throw new \RuntimeException('Unable to retrieve contents from browscap.ini file "'.$sBrowscapIniPath.'"');
			fclose($oFileHandle);
			$aBrowscap = parse_ini_string($sBrowscapIniContents, true, INI_SCANNER_RAW);
			if($aBrowscap === false)throw new \RuntimeException('Error appends while parsing browscap.ini file "'.$sBrowscapIniPath.'"');
		}

		$aBrowscapKeys = array_keys($aBrowscap);
		$aBrowscap = array_combine($aBrowscapKeys, array_map(function($aUserAgentInfos, $sUserAgent){
			$aUserAgentInfos = array_map(function($sValue){
				if($sValue === 'true')return 1;
				elseif($sValue === 'false')return '';
				else return $sValue;
			}, $aUserAgentInfos);

			//Define browser name regex
			$aUserAgentInfos['browser_name_regex'] = '^'.str_replace(
				array('\\','.','?','*','^','$','[',']','|','(',')','+','{','}','%'),
				array('\\\\','\\.','.','.*','\\^','\\$','\\[','\\]','\\|','\\(','\\)','\\+','\\{','\\}','\\%'),
				$sUserAgent
			).'$';


			return array_change_key_case($aUserAgentInfos,CASE_LOWER);
		},$aBrowscap,$aBrowscapKeys));

		uksort($aBrowscap,function($sUserAgentA,$sUserAgentB){
			if(($sUserAgentALength = strlen($sUserAgentA)) > ($sUserAgentBLength = strlen($sUserAgentB)))return -1;
			elseif($sUserAgentALength < $sUserAgentBLength)return 1;
			else return strcasecmp($sUserAgentA,$sUserAgentB);
		});
		return $this->setBrowscap($aBrowscap);
	}
public function loadBrowscapIni ( ) { $ sBrowscapIniPath = $ this -> getBrowscapIniPath ( ) ; //Local file if ( is_readable ( $ sBrowscapIniPath ) ) { $ aBrowscap = parse_ini_file ( $ this -> getBrowscapIniPath ( ) , true , INI_SCANNER_RAW ) ; if ( $ aBrowscap === false ) throw new \ RuntimeException ( 'Error appends while parsing browscap.ini file "' . $ sBrowscapIniPath . '"' ) ; } //Remote file else { if ( ( $ oFileHandle = @ fopen ( $ sBrowscapIniPath , 'r' ) ) === false ) throw new \ InvalidArgumentException ( 'Unable to load browscap.ini file "' . $ sBrowscapIniPath . '"' ) ; $ sBrowscapIniContents = '' ; while ( ( $ sContent = fgets ( $ oFileHandle ) ) !== false ) { $ sBrowscapIniContents .= $ sContent . PHP_EOL ; } if ( ! feof ( $ oFileHandle ) ) throw new \ RuntimeException ( 'Unable to retrieve contents from browscap.ini file "' . $ sBrowscapIniPath . '"' ) ; fclose ( $ oFileHandle ) ; $ aBrowscap = parse_ini_string ( $ sBrowscapIniContents , true , INI_SCANNER_RAW ) ; if ( $ aBrowscap === false ) throw new \ RuntimeException ( 'Error appends while parsing browscap.ini file "' . $ sBrowscapIniPath . '"' ) ; } $ aBrowscapKeys = array_keys ( $ aBrowscap ) ; $ aBrowscap = array_combine ( $ aBrowscapKeys , array_map ( function ( $ aUserAgentInfos , $ sUserAgent ) { $ aUserAgentInfos = array_map ( function ( $ sValue ) { if ( $ sValue === 'true' ) return 1 ; elseif ( $ sValue === 'false' ) return '' ; else return $ sValue ; } , $ aUserAgentInfos ) ; //Define browser name regex $ aUserAgentInfos [ 'browser_name_regex' ] = '^' . str_replace ( array ( '\\' , '.' , '?' , '*' , '^' , '$' , '[' , ']' , '|' , '(' , ')' , '+' , '{' , '}' , '%' ) , array ( '\\\\' , '\\.' , '.' , '.*' , '\\^' , '\\$' , '\\[' , '\\]' , '\\|' , '\\(' , '\\)' , '\\+' , '\\{' , '\\}' , '\\%' ) , $ sUserAgent ) . '$' ; return array_change_key_case ( $ aUserAgentInfos , CASE_LOWER ) ; } , $ aBrowscap , $ aBrowscapKeys ) ) ; uksort ( $ aBrowscap , function ( $ sUserAgentA , $ sUserAgentB ) { if ( ( $ sUserAgentALength = strlen ( $ sUserAgentA ) ) > ( $ sUserAgentBLength = strlen ( $ sUserAgentB ) ) ) return - 1 ; elseif ( $ sUserAgentALength < $ sUserAgentBLength ) return 1 ; else return strcasecmp ( $ sUserAgentA , $ sUserAgentB ) ; } ) ; return $ this -> setBrowscap ( $ aBrowscap ) ; }
Load and parse browscap.ini file
@throws \RuntimeException
@return \Neilime\Browscap\BrowscapService
Load and parse browscap . ini file