WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Gets the browser and OS from the $_SERVER['http_user_agent'] variable in PHP
Categories : PHP, HTTP, Regexps Update Picture
John Harrison
Date : Jul 08th 2002
Grade : 2 of 5 (graded 3 times)
Viewed : 5839
File : No file for this code example.
Images : No Images for this code example.
Search : More code by John Harrison
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?
###################
# http://www.tececo.com #
# #################
// Browser Detection
        if( eregi("(opera) ([0-9]{1,2}.[0-9]{1,3}){0,1}",$_SERVER['HTTP_USER_AGENT'],$regs) ||
eregi("(opera/)([0-9]{1,2}.[0-9]{1,3}){0,1}",$_SERVER['HTTP_USER_AGENT'],$regs)){$browser
= "Opera $regs[2]";}
        elseif( eregi("(konqueror)/([0-9]{1,2}.[0-9]{1,3})",$_SERVER
['HTTP_USER_AGENT'],$regs) ){$browser = "Konqueror $regs[2]";}
        elseif( eregi("(omniweb/)([0-9]{1,2}.[0-9]{1,3})",$_SERVER['HTTP_USER_AGENT'],$regs) )
{$browser = "OmniWeb $regs[2]";}
        elseif( eregi("(webtv/)([0-9]{1,2}.[0-9]{1,3})",$_SERVER['HTTP_USER_AGENT'],$regs) )
{$browser = "WebTV $regs[2]";}
        elseif( eregi("(lynx)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})",$_SERVER
['HTTP_USER_AGENT'],$regs) ){$browser = "Lynx $regs[2]";}
        elseif( eregi("(links) \(([0-9]{1,2}.[0-9]{1,3})",$_SERVER['HTTP_USER_AGENT'],$regs) )
{$browser = "Links $regs[2]";}
        elseif( eregi("(msie) ([0-9]{1,2}.[0-9]{1,3})",$_SERVER['HTTP_USER_AGENT'],$regs) )
{$browser = "MSIE $regs[2]";}
        elseif( eregi("(netscape6)/(6.[0-9]{1,3})",$_SERVER['HTTP_USER_AGENT'],$regs) )
{$browser = "Netscape $regs[2]";}
        elseif( eregi("mozilla/5",$_SERVER['HTTP_USER_AGENT']) ){$browser = "Netscape";}
        elseif( eregi("(mozilla)/([0-9]{1,2}.[0-9]{1,3})",$_SERVER['HTTP_USER_AGENT'],$regs) )
{$browser = "Netscape $regs[2]";}
        elseif( eregi("w3m",$_SERVER['HTTP_USER_AGENT']) ){$browser = "w3m";}
        else{$browser = "Unknown";}
        
// OS Detection

if(eregi("linux",$_SERVER['HTTP_USER_AGENT'])){$system = "Linux";}
        elseif(eregi("win32",$_SERVER['HTTP_USER_AGENT'])){$system = "Windows";}
        elseif(eregi("Win 9x 4.90",$_SERVER['HTTP_USER_AGENT'])){$system = "Windows Me";}
elseif(eregi("windows 2000",$_SERVER['HTTP_USER_AGENT']) || eregi("(windows nt)( ){0,1}
(5.0)",$_SERVER['HTTP_USER_AGENT']) ){$system = "Windows 2000";}
elseif(eregi("(windows nt)( ){0,1}(5.1)",$_SERVER['HTTP_USER_AGENT']) ){$system = "Windows
XP";}
        elseif( (eregi("(win)([0-9]{2})",$_SERVER['HTTP_USER_AGENT'],$regs)) || (eregi
("(windows) ([0-9]{2})",$_SERVER['HTTP_USER_AGENT'],$regs)) ){$system = "Windows $regs[2]";}
        elseif(eregi("(winnt)([0-9]{1,2}.[0-9]{1,2}){0,1}",$_SERVER['HTTP_USER_AGENT'],$regs) )
{$system = "Windows NT $regs[2]";}
        elseif(eregi("(windows nt)( ){0,1}([0-9]{1,2}.[0-9]{1,2}){0,1}",$_SERVER
['HTTP_USER_AGENT'],$regs) ){$system = "Windows NT $regs[3]";}
        elseif(eregi("mac",$_SERVER['HTTP_USER_AGENT'])){$system = "Macintosh";}
        elseif(eregi("(sunos) ([0-9]{1,2}.[0-9]{1,2}){0,1}",$_SERVER
['HTTP_USER_AGENT'],$regs)){$system = "SunOS $regs[2]";}
        elseif(eregi("(beos) r([0-9]{1,2}.[0-9]{1,2}){0,1}",$_SERVER['HTTP_USER_AGENT'],$regs))
{$system = "BeOS $regs[2]";}
        elseif(eregi("freebsd",$_SERVER['HTTP_USER_AGENT'])){$system = "FreeBSD";}
        elseif(eregi("openbsd",$_SERVER['HTTP_USER_AGENT'])){$system = "OpenBSD";}
        elseif(eregi("irix",$_SERVER['HTTP_USER_AGENT'])){$system = "IRIX";}
        elseif(eregi("os/2",$_SERVER['HTTP_USER_AGENT'])){$system = "OS/2";}
        elseif(eregi("plan9",$_SERVER['HTTP_USER_AGENT'])){$system = "Plan9";}
        elseif(eregi("unix",$_SERVER['HTTP_USER_AGENT']) || eregi("hp-ux",$_SERVER
['HTTP_USER_AGENT']) || eregi("X11",$_SERVER['HTTP_USER_AGENT']) ){$system = "Unix";}
        elseif(eregi("osf",$_SERVER['HTTP_USER_AGENT'])){$system = "OSF";}
        else{$system = "Unknown";}
        
        echo "You are using $browser on a $system system<br>";
?>



PHP Domain Availability Checker
Categories : PHP, Complete Programs, Regexps, HTTP, Sockets
Grab links from a page
Categories : PHP, Regexps, HTTP
Check if a file exists on a remote FTP server with PHP
Categories : PHP, FTP, Regexps
Show Source with Line Numbers
Categories : PHP, Regexps, Filesystem
Avoiding or Detecting high bit characters in a string. Useful when you want to create a valid RSS feed
Categories : PHP, Strings, Unicode, Regexps, Rich Site Summary (RSS)
Simple way to replace a variable value in a .conf (.ini) file using a webbrowser - the first stage of a complete universal configuration editor
Categories : PHP, Regexps, Code Editors, Filesystem
ereg -- Regular expression match
Categories : PHP, PHP Functions, Regexps
Simple Password example
Categories : PHP, Authentication, Security, HTTP
BBCode Formatting String
Categories : PHP, HTML, Regexps, Arrays
Tag content retrieval from websites with preg_match
Categories : PHP, Regexps, Arrays, HTML and PHP
I need a trim function/regexp that will trim all " " from the ends of a string.
Categories : Regexps, PHP, Strings
WebServerSpy checks which kind of Webserver is running, Apache, Netscape, Fasttrack, IIS, HTTP-Header, HTTP 1.0, GET, spy, WWW
Categories : HTTP, Network, Apache, PHP, Web Servers
This script is a contact form between users of a website (kinda like the PM function on the forums)
Categories : PHP, Databases, MySQL, Regexps
PHP4 HTTP Compression Speeds up the Web
Categories : PHP, Zlib, HTML and PHP, HTTP, Network
Form input return conformance
Categories : HTML and PHP, PHP, Regexps