[Openfirst-cvscommit] base/config/functions browserid.php,NONE,1.1
Brought to you by:
xtimg
From: <i-...@us...> - 2003-10-01 00:16:25
|
Update of /cvsroot/openfirst/base/config/functions In directory sc8-pr-cvs1:/tmp/cvs-serv2543/config/functions Added Files: browserid.php Log Message: Identifies the client's browser and OS based on browscap.ini. --- NEW FILE: browserid.php --- <?php /* * openFIRST browserid.php * Last Modified: * David Di Biase, April 13, 2003 * * Copyright (C) 2003, * openFIRST Project * Original Author: Greg Inozemtsev <gr...@si...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ //Functions for browser/platform identification function identify_platform($useragent="") { //(This prevents PHP from displaying an error if use of browscap.ini is not enabled) //only report critical errors $err_prev=error_reporting(E_ERROR); //get OS info from browscap.ini $browser=get_browser($useragent); //restore error reporting level error_reporting($err_prev); $return=""; if($browser!=null){ $return=$browser->platform; if ($return==""){ //returns the original user-agent string return $useragent; } } else { //browscap.ini disabled //returns the original user-agent string return $useragent; } //return platform ID return $return; } function identify_browser($useragent="") { //(This prevents PHP from displaying an error if use of browscap.ini is not enabled) //only report critical errors $err_prev=error_reporting(E_ERROR); //get browser info from browscap.ini $browser=get_browser($useragent); //restore error reporting level error_reporting($err_prev); $return=""; if($browser!=null){ //Get browser name $browsername=$browser->browser; if ($browsername==""){ //could not determine browser name, browscap.ini disabled //return the original user-agent string return $useragent; } else { if ($browsername=="IE"){ //Spell 'IE' as 'Internet Explorer' $browsername="Internet Explorer"; } //Get major version $ver=$browser->majorver; //remove # character at beginning of string if (substr($ver,0,1)=="#"){ $ver=substr($ver,1); } $return=$browsername." ".$ver."."; //Get minor version $ver=$browser->minorver; //remove # character at beginning of string if (substr($ver,0,1)=="#"){ $ver=substr($ver,1); } $return.=$ver; //Identify search engine if (isset($browser->crawler)){ if($browser->crawler==1){ $return.=" (Search Engine)"; } } } } else { //browscap.ini disabled //returns the original user-agent string return $useragent; } //return browser ID return $return; } ?> |