mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 17:14:36 +01:00
Rename - converted to a class
This commit is contained in:
parent
2811576045
commit
c6b810baf3
@ -1,157 +0,0 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare API - Browser detect functions *
|
||||
* This file written by Miles Lott <milosch@phpgroupware.org> *
|
||||
* Majority of code borrowed from Sourceforge 2.5 *
|
||||
* Copyright 1999-2000 (c) The SourceForge Crew - http://sourceforge.net *
|
||||
* Browser detection functions for phpGroupWare developers *
|
||||
* -------------------------------------------------------------------------*
|
||||
* This library is part of the phpGroupWare API *
|
||||
* http://www.phpgroupware.org/api *
|
||||
* ------------------------------------------------------------------------ *
|
||||
* This library is free software; you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as published by *
|
||||
* the Free Software Foundation; either version 2.1 of the License, *
|
||||
* or any later version. *
|
||||
* This library 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 Lesser General Public License for more details. *
|
||||
* You should have received a copy of the GNU Lesser General Public License *
|
||||
* along with this library; if not, write to the Free Software Foundation, *
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
||||
\**************************************************************************/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
// Where do we need to put this? - Milosch
|
||||
|
||||
unset ($BROWSER_AGENT);
|
||||
unset ($BROWSER_VER);
|
||||
unset ($BROWSER_PLATFORM);
|
||||
|
||||
function browser_get_agent ()
|
||||
{
|
||||
global $BROWSER_AGENT;
|
||||
return $BROWSER_AGENT;
|
||||
}
|
||||
|
||||
function browser_get_version()
|
||||
{
|
||||
global $BROWSER_VER;
|
||||
return $BROWSER_VER;
|
||||
}
|
||||
|
||||
function browser_get_platform()
|
||||
{
|
||||
global $BROWSER_PLATFORM;
|
||||
return $BROWSER_PLATFORM;
|
||||
}
|
||||
|
||||
function browser_is_mac()
|
||||
{
|
||||
if (browser_get_platform()=='Mac')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function browser_is_windows()
|
||||
{
|
||||
if (browser_get_platform()=='Win')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function browser_is_ie()
|
||||
{
|
||||
if (browser_get_agent()=='IE')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function browser_is_netscape()
|
||||
{
|
||||
if (browser_get_agent()=='MOZILLA')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Determine browser and version
|
||||
*/
|
||||
if (ereg( 'MSIE ([0-9].[0-9]{1,2})',$HTTP_USER_AGENT,$log_version))
|
||||
{
|
||||
$BROWSER_VER=$log_version[1];
|
||||
$BROWSER_AGENT='IE';
|
||||
}
|
||||
elseif (ereg( 'Opera ([0-9].[0-9]{1,2})',$HTTP_USER_AGENT,$log_version))
|
||||
{
|
||||
$BROWSER_VER=$log_version[1];
|
||||
$BROWSER_AGENT='OPERA';
|
||||
}
|
||||
elseif (ereg( 'Mozilla/([0-9].[0-9]{1,2})',$HTTP_USER_AGENT,$log_version))
|
||||
{
|
||||
$BROWSER_VER=$log_version[1];
|
||||
$BROWSER_AGENT='MOZILLA';
|
||||
}
|
||||
else
|
||||
{
|
||||
$BROWSER_VER=0;
|
||||
$BROWSER_AGENT='OTHER';
|
||||
}
|
||||
|
||||
/*
|
||||
Determine platform
|
||||
*/
|
||||
if (strstr($HTTP_USER_AGENT,'Win'))
|
||||
{
|
||||
$BROWSER_PLATFORM='Win';
|
||||
}
|
||||
else if (strstr($HTTP_USER_AGENT,'Mac'))
|
||||
{
|
||||
$BROWSER_PLATFORM='Mac';
|
||||
}
|
||||
else if (strstr($HTTP_USER_AGENT,'Linux'))
|
||||
{
|
||||
$BROWSER_PLATFORM='Linux';
|
||||
}
|
||||
else if (strstr($HTTP_USER_AGENT,'Unix'))
|
||||
{
|
||||
$BROWSER_PLATFORM='Unix';
|
||||
}
|
||||
else
|
||||
{
|
||||
$BROWSER_PLATFORM='Other';
|
||||
}
|
||||
|
||||
/*
|
||||
echo "\n\nAgent: $HTTP_USER_AGENT";
|
||||
echo "\nIE: ".browser_is_ie();
|
||||
echo "\nMac: ".browser_is_mac();
|
||||
echo "\nWindows: ".browser_is_windows();
|
||||
echo "\nPlatform: ".browser_get_platform();
|
||||
echo "\nVersion: ".browser_get_version();
|
||||
echo "\nAgent: ".browser_get_agent();
|
||||
*/
|
||||
?>
|
158
phpgwapi/inc/class.browser.inc.php
Normal file
158
phpgwapi/inc/class.browser.inc.php
Normal file
@ -0,0 +1,158 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare API - Browser detect functions *
|
||||
* This file written by Miles Lott <milosch@phpgroupware.org> *
|
||||
* Majority of code borrowed from Sourceforge 2.5 *
|
||||
* Copyright 1999-2000 (c) The SourceForge Crew - http://sourceforge.net *
|
||||
* Browser detection functions for phpGroupWare developers *
|
||||
* -------------------------------------------------------------------------*
|
||||
* This library is part of the phpGroupWare API *
|
||||
* http://www.phpgroupware.org/api *
|
||||
* ------------------------------------------------------------------------ *
|
||||
* This library is free software; you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as published by *
|
||||
* the Free Software Foundation; either version 2.1 of the License, *
|
||||
* or any later version. *
|
||||
* This library 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 Lesser General Public License for more details. *
|
||||
* You should have received a copy of the GNU Lesser General Public License *
|
||||
* along with this library; if not, write to the Free Software Foundation, *
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
||||
\**************************************************************************/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
class browser
|
||||
{
|
||||
var $BROWSER_AGENT;
|
||||
var $BROWSER_VER;
|
||||
var $BROWSER_PLATFORM;
|
||||
|
||||
function browser ()
|
||||
{
|
||||
global $HTTP_USER_AGENT,$log_version;
|
||||
/*
|
||||
Determine browser and version
|
||||
*/
|
||||
if (ereg( 'MSIE ([0-9].[0-9]{1,2})',$HTTP_USER_AGENT,$log_version))
|
||||
{
|
||||
$this->BROWSER_VER=$log_version[1];
|
||||
$this->BROWSER_AGENT='IE';
|
||||
}
|
||||
elseif (ereg( 'Opera ([0-9].[0-9]{1,2})',$HTTP_USER_AGENT,$log_version))
|
||||
{
|
||||
$this->BROWSER_VER=$log_version[1];
|
||||
$this->BROWSER_AGENT='OPERA';
|
||||
}
|
||||
elseif (ereg( 'Mozilla/([0-9].[0-9]{1,2})',$HTTP_USER_AGENT,$log_version))
|
||||
{
|
||||
$this->BROWSER_VER=$log_version[1];
|
||||
$this->BROWSER_AGENT='MOZILLA';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->BROWSER_VER=0;
|
||||
$this->BROWSER_AGENT='OTHER';
|
||||
}
|
||||
|
||||
/*
|
||||
Determine platform
|
||||
*/
|
||||
if (strstr($HTTP_USER_AGENT,'Win'))
|
||||
{
|
||||
$this->BROWSER_PLATFORM='Win';
|
||||
}
|
||||
else if (strstr($HTTP_USER_AGENT,'Mac'))
|
||||
{
|
||||
$this->BROWSER_PLATFORM='Mac';
|
||||
}
|
||||
else if (strstr($HTTP_USER_AGENT,'Linux'))
|
||||
{
|
||||
$this->BROWSER_PLATFORM='Linux';
|
||||
}
|
||||
else if (strstr($HTTP_USER_AGENT,'Unix'))
|
||||
{
|
||||
$this->BROWSER_PLATFORM='Unix';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->BROWSER_PLATFORM='Other';
|
||||
}
|
||||
|
||||
/*
|
||||
echo "\n\nAgent: $HTTP_USER_AGENT";
|
||||
echo "\nIE: ".browser_is_ie();
|
||||
echo "\nMac: ".browser_is_mac();
|
||||
echo "\nWindows: ".browser_is_windows();
|
||||
echo "\nPlatform: ".browser_get_platform();
|
||||
echo "\nVersion: ".browser_get_version();
|
||||
echo "\nAgent: ".browser_get_agent();
|
||||
*/
|
||||
}
|
||||
|
||||
function get_agent ()
|
||||
{
|
||||
return $this->BROWSER_AGENT;
|
||||
}
|
||||
|
||||
function get_version()
|
||||
{
|
||||
return $this->BROWSER_VER;
|
||||
}
|
||||
|
||||
function get_platform()
|
||||
{
|
||||
return $this->BROWSER_PLATFORM;
|
||||
}
|
||||
|
||||
function is_mac()
|
||||
{
|
||||
if ($this->get_platform()=='Mac')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function is_windows()
|
||||
{
|
||||
if ($this->get_platform()=='Win')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function is_ie()
|
||||
{
|
||||
if ($this->get_agent()=='IE')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function is_netscape()
|
||||
{
|
||||
if ($this->get_agent()=='MOZILLA')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user