|
|
|
/******************************************
** Description : BrowserDetector
** File Name : browserDetector.php3
** Author : epsilon7 for PHyX8 studios
** Author Email : epsilon7@asphyxia.com
** Created : Thursday, May 11, 2000
** Last Modified : Wednesday, July 12, 2000
** Modified By : epsilon7
*'
INFO:
Returns Browser information
based on HTTP_USER_AGENT
Ported from The Webmonkey JavaScript Source
##BrowserDetector()
##Parses User-Agent string into useful info.
##Source: Webmonkey Code Library
##(http://www.hotwired.com/webmonkey/javascript/code_library/)
##Author: Rich Blaylock
##Author Email: blaylock@wired.com
Usage:
include("browserDetector.php3");
$bd = new BrowserDetector;
Variables:
$bd->BROWSER // Netscape, MSIE, Opera
$bd->PLATFORM // Win95, Unix, Windows 98, Mac, PPC, etc.
$bd->VERSION // MajorVersion.MinorVersion
$bd->MAJORVER // Major Version (before . in version string)
$bd->MINORVER // Minor Version (after . in version string)
'****************************************/
class BrowserDetector
{ var $UA = "";
var $BROWSER = "Unknown";
var $PLATFORM = "Unknown";
var $VERSION = "";
var $MAJORVER = "";
var $MINORVER = "";
/* START CONSTRUCTOR */
function BrowserDetector()
{ $this->UA = getenv(HTTP_USER_AGENT);
$preparens = "";
$parens = "";
$i = strpos($this->UA,"(");
if ($i >= 0)
{ $preparens = trim(substr($this->UA,0,$i));
$parens = substr($this->UA,$i+1,strlen($this->UA));
$j = strpos($parens,")");
if($j>=0)
{ $parens = substr($parens,0,$j);
}
}
else
{ $preparens = $this->UA;
}
$browVer = $preparens;
$token = trim(strtok($parens,";"));
while($token)
{ if($token=="compatible")
{
}
elseif(preg_match("/MSIE/i","$token"))
{ $browVer = $token;
}
elseif(preg_match("/Opera/i","$token"))
{ $browVer = $token;
}
elseif(preg_match("/X11/i","$token") || preg_match("/SunOS/i","$token") || preg_match
("/Linux/i","$token"))
{ $this->PLATFORM = "Unix";
}
elseif(preg_match("/Win/i","$token"))
{ $this->PLATFORM = $token;
}
elseif(preg_match("/Mac/i","$token") || preg_match("/PPC/i","$token"))
{ $this->PLATFORM = $token;
}
$token = strtok(";");
}
$msieIndex = strpos($browVer,"MSIE");
if($msieIndex >= 0)
{ $browVer = substr($browVer,$msieIndex,strlen($browVer));
}
$leftover = "";
if(substr($browVer,0,strlen("Mozilla")) == "Mozilla")
{ $this->BROWSER = "Netscape";
$leftover=substr($browVer,strlen("Mozilla")+1,strlen($browVer));
}
elseif(substr($browVer,0,strlen("Lynx")) == "Lynx")
{ $this->BROWSER = "Lynx";
$leftover=substr($browVer,strlen("Lynx")+1,strlen($browVer));
}
elseif(substr($browVer,0,strlen("MSIE")) == "MSIE")
{ $this->BROWSER = "IE";
$leftover=substr($browVer,strlen("MSIE")+1,strlen($browVer));
}
elseif(substr($browVer,0,strlen("Microsoft Internet Explorer")) == "Microsoft Internet
Explorer")
{ $this->BROWSER = "IE";
$leftover=substr($browVer,strlen("Microsoft Internet Explorer")+1,strlen($browVer));
}
elseif(substr($browVer,0,strlen("Opera")) == "Opera")
{ $this->BROWSER = "Opera";
$leftover=substr($browVer,strlen("Opera")+1,strlen($browVer));
}
$leftover = trim($leftover);
$i=strpos($leftover," ");
if($i > 0)
{ $this->VERSION = substr($leftover,0,$i);
}
else
{ $this->VERSION = $leftover;
}
$j = strpos($this->VERSION,".");
if($j >= 0)
{ $this->MAJORVER = substr($this->VERSION,0,$j);
$this->MINORVER = substr($this->VERSION,$j+1,strlen($this->VERSION));
}
else
{ $this->MAJORVER = $this->VERSION;
}
}
}
/******************************************
** Some Test Results
Testing : Mozilla/4.73 [en] (Win98; U)
Browser : Netscape
Platform : Win98
Version : 4.73
Major Version : 4
Minor Version : 73
Testing : Opera/4.0 (Windows 98;US) Beta 3 [en]
Browser : Opera
Platform : Windows 98
Version : 4.0
Major Version : 4
Minor Version : 0
Testing : Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)
Browser : IE
Platform : Windows 98
Version : 5.0
Major Version : 5
Minor Version : 0
'****************************************/ |
|
| A simple class with some HTML output functions that would come in handy for consistent page layout etc. Categories : PHP, PHP Classes, HTML and PHP, HTML, Navigation | | | Automatic generation of HTML code for a table. OO interface. Can define colspan, rowspan, table style, cell style, and data style. Simple, but
effective. Categories : PHP, PHP Classes, HTML, HTML and PHP | | | class formHTML build your HTML Forms from PHP Categories : PHP, PHP Classes, HTML and PHP, HTML | | | Form is a utility class for generating html forms. It provides form initialization and regex based data validation (both server and client side) with a convenient interface. This version obsoletes version 1.0a Categories : HTML, PHP, PHP Classes, Regexps | | | Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | | | file class , uploade file , download file already uploaded on another website Categories : PHP, PHP Classes, Filesystem, Web Services | | | Authorize.net AIM Interface Class v1.0.0 Categories : PHP, PHP Classes, Ecommerce, Payment Gateways | | | crop and resize image class using gd library function Categories : PHP, PHP Classes, GD image library, Graphics | | | Excel class in PHP Categories : PHP, PHP Classes, Excel | | | News management class Categories : PHP, PHP Classes, Beginner Guides | | | Expose - PHP template engine, supports server and client-sided caching,a plugin system, multiple languages, template script language is based on PHP itself. Categories : PHP, PHP Classes, Templates, Complete Programs | | | Simple Template Class/Example Categories : PHP, Templates, PHP Classes | | | Parses HTTP_USER_AGENT so that you can customize your site to different browsers Categories : HTML, PHP, Complete Programs | | | RSS parser.
Parses RSS into an array. Quick and nasty but does the job.
No checking is done for correct Tags, only correct XML.
PHP4 needed to display result (uses print_r). Categories : PHP, XML, PHP Classes, Rich Site Summary (RSS) | | | FormWizard reads a mysql table and generates automatically
a html formular in a html-table Categories : PHP, MySQL, HTML | |
| | | | Wolli Burg wrote :784
This doesn`t seem to work with opera 6.01 ?
as opera it shows IE as browser
| |
|
|
|