note 110959 added to function.get-browser

From: Date: Sat, 29 Dec 2012 11:10:35 +0000
Subject: note 110959 added to function.get-browser
Groups: php.notes 
Request: Send a blank email to php-notes+get-192704@lists.php.net to get a copy of this message
You can parse browscap.ini at the following way: if(empty($this -> _ini_file)): if(is_file(DOCUMENT_ROOT.'/'.self::INI_FILE_PATH.'/'.self::INI_FILE_NAME.'.'.self::INI_FILE_SUFFIX)): $this -> _ini_file = parse_ini_file(DOCUMENT_ROOT.'/'.self::INI_FILE_PATH.'/'.self::INI_FILE_NAME.'.'.self::INI_FILE_SUFFIX, true, INI_SCANNER_RAW); ksort($this -> _ini_file); $this -> __updateFile(); else: throw new ExceptionClass(self::FILE_NOT_FOUND.' '.DOCUMENT_ROOT.'/'.self::INI_FILE_PATH.'/'.self::INI_FILE_NAME.'.'.self::INI_FILE_SUFFIX, 404, __FILE__, __LINE__); endif; endif; final private function __parseRequest($_browser) { try { if(isset($_SERVER['HTTP_USER_AGENT'])): foreach($this -> _ini_file as $_key => $_value): $_regex = '^'.str_replace( array('\\','.','?','*','^','$','[',']','|','(',')','+','{','}','%'), array('\\\\','\\.','.','.*','\\^','\\$','\\[','\\]','\\|','\\(','\\)','\\+','\\{','\\}','\\%'), $_key ); if(is_array($_value)): if(preg_match('#'.$_regex.'$#si', $_browser)): $_array = array_merge(array( 'browser_name_regex' => $_regex, 'browser_name_pattern' => $_key), $_value, array( 'http_referer' => $_SERVER['HTTP_REFERER'], 'remote_addr' => $_SERVER['REMOTE_ADDR'], 'remote_host' => $_SERVER['REMOTE_HOST'], 'request_uri' => $_SERVER['REQUEST_URI'] ) ); endif; endif; endforeach; if(array_key_exists('Parent', $_array)): $_array = array_merge($this -> __parseRequest($_array['Parent']), $_array); endif; endif; return $_array; } catch(ExceptionClass $_exception) { $_exception -> getException(); } } ---- Server IP: 69.147.83.199 Probable Submitter: 217.51.30.218 ---- Manual Page -- http://php.net/manual/en/function.get-browser.php Edit -- https://master.php.net/note/edit/110959 Del: integrated -- https://master.php.net/note/delete/110959/integrated Del: useless -- https://master.php.net/note/delete/110959/useless Del: bad code -- https://master.php.net/note/delete/110959/bad+code Del: spam -- https://master.php.net/note/delete/110959/spam Del: non-english -- https://master.php.net/note/delete/110959/non-english Del: in docs -- https://master.php.net/note/delete/110959/in+docs Del: other reasons-- https://master.php.net/note/delete/110959 Reject -- https://master.php.net/note/reject/110959 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#192704) next »