• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

classes/class.ilBrowser.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00025 
00026   //**************************************************************************\
00027   //* Browser detect functions                                                 *
00028   // This file written by Miles Lott <milosch@phpgroupware.org>               *
00029   // Majority of code borrowed from Sourceforge 2.5                           *
00030   // Copyright 1999-2000 (c) The SourceForge Crew - http://sourceforge.net    *
00031   // Browser detection functions for phpGroupWare developers                  *
00032   // -------------------------------------------------------------------------*
00033   // This library is borrowed from the phpGroupWare API                       *
00034   // http://www.phpgroupware.org/api                                          *
00035   // Modifications made by Sascha Hofmann <sascha.hofmann@uni-koeln.de>       *
00036   //                                                                          *
00037   //**************************************************************************/
00038 
00045 class ilBrowser
00046 {
00047         var $BROWSER_AGENT;
00048         var $BROWSER_VER;
00049         var $BROWSER_PLATFORM;
00050         var $br;
00051         var $p;
00052         var $data;
00053 
00054         function ilBrowser()
00055         {
00056                 $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
00057                 /*
00058                         Determine browser and version
00059                 */
00060                 if(ereg('MSIE ([0-9].[0-9]{1,2})',$HTTP_USER_AGENT,$log_version))
00061                 {
00062                         $this->BROWSER_VER = $log_version[1];
00063                         $this->BROWSER_AGENT = 'IE';
00064                 }
00065                 elseif(ereg('Opera ([0-9].[0-9]{1,2})',$HTTP_USER_AGENT,$log_version) ||
00066                         ereg('Opera/([0-9].[0-9]{1,2})',$HTTP_USER_AGENT,$log_version))
00067                 {
00068                         $this->BROWSER_VER   = $log_version[1];
00069                         $this->BROWSER_AGENT = 'OPERA';
00070                 }
00071                 elseif(ereg('Safari ([0-9/.]*)',$HTTP_USER_AGENT,$log_version) ||
00072                         ereg('Safari/([0-9/.]*)',$HTTP_USER_AGENT,$log_version))
00073                 {
00074                         $this->BROWSER_VER   = $log_version[1];
00075                         $this->BROWSER_AGENT = 'Safari';
00076                 }
00077                 elseif(ereg('Firefox ([0-9/.]*))',$HTTP_USER_AGENT,$log_version) ||
00078                         ereg('Firefox/([0-9/.]*)',$HTTP_USER_AGENT,$log_version))
00079                 {
00080                         $this->BROWSER_VER   = $log_version[1];
00081                         $this->BROWSER_AGENT = 'Firefox';
00082                 }
00083                 elseif(eregi('iCab ([0-9].[0-9a-zA-Z]{1,4})',$HTTP_USER_AGENT,$log_version) ||
00084                         eregi('iCab/([0-9].[0-9a-zA-Z]{1,4})',$HTTP_USER_AGENT,$log_version))
00085                 {
00086                         $this->BROWSER_VER   = $log_version[1];
00087                         $this->BROWSER_AGENT = 'iCab';
00088                 }
00089                 elseif(eregi('Mozilla ([0-9].[0-9a-zA-Z]{1,4})',$HTTP_USER_AGENT,$log_version) ||
00090                         eregi('Mozilla/([0-9].[0-9a-zA-Z]{1,4})',$HTTP_USER_AGENT,$log_version))
00091                 {
00092                         $this->BROWSER_VER   = $log_version[1];
00093                         if (ereg('Gecko',$HTTP_USER_AGENT,$log_version))
00094                         {
00095                                 $this->BROWSER_AGENT = 'Mozilla';
00096                         }
00097                         else
00098                         {
00099                                 $this->BROWSER_AGENT = 'Netscape';
00100                         }
00101                 }
00102                 elseif(ereg('Konqueror/([0-9].[0-9].[0-9]{1,2})',$HTTP_USER_AGENT,$log_version) ||
00103                         ereg('Konqueror/([0-9].[0-9]{1,2})',$HTTP_USER_AGENT,$log_version))
00104                 {
00105                         $this->BROWSER_VER=$log_version[1];
00106                         $this->BROWSER_AGENT='Konqueror';
00107                 }
00108                 else
00109                 {
00110                         $this->BROWSER_VER=0;
00111                         $this->BROWSER_AGENT='OTHER';
00112                 }
00113 
00114                 /*
00115                         Determine platform
00116                 */
00117                 if(strstr($HTTP_USER_AGENT,'Win'))
00118                 {
00119                         $this->BROWSER_PLATFORM='Win';
00120                 }
00121                 elseif(strstr($HTTP_USER_AGENT,'Mac'))
00122                 {
00123                         $this->BROWSER_PLATFORM='Mac';
00124                 }
00125                 elseif(strstr($HTTP_USER_AGENT,'Linux'))
00126                 {
00127                         $this->BROWSER_PLATFORM='Linux';
00128                 }
00129                 elseif(strstr($HTTP_USER_AGENT,'Unix'))
00130                 {
00131                         $this->BROWSER_PLATFORM='Unix';
00132                 }
00133                 elseif(strstr($HTTP_USER_AGENT,'Beos'))
00134                 {
00135                         $this->BROWSER_PLATFORM='Beos';
00136                 }
00137                 else
00138                 {
00139                         $this->BROWSER_PLATFORM='Other';
00140                 }
00141 
00142 /*
00143                 echo "<br>Agent: $HTTP_USER_AGENT";
00144                 echo "<br><b>Browser</b>";
00145                 echo "<br>IE: ".$this->isIE();
00146                 echo "<br>Netscape: ".$this->isNetscape();
00147                 echo "<br>Mozilla: ".$this->isMozilla();
00148                 echo "<br>Firefox: ".$this->isFirefox();
00149                 echo "<br>Safari: ".$this->isSafari();
00150                 echo "<br>Opera: ".$this->isOpera();
00151                 echo "<br><b>OS</b>";
00152                 echo "<br>Mac: ".$this->isMac();
00153                 echo "<br>Windows: ".$this->isWindows();
00154                 echo "<br>Linux: ".$this->isLinux();
00155                 echo "<br>Unix: ".$this->isUnix();
00156                 echo "<br>Beos: ".$this->isBeos();
00157                 echo "<br><b>Summary</b>";
00158                 echo "<br>OS: ".$this->getPlatform();
00159                 echo "<br>Version: ".$this->getVersion(false);
00160                 echo "<br>Agent: ".$this->getAgent();
00161 */
00162 
00163                 // The br and p functions are supposed to return the correct
00164                 // value for tags that do not need to be closed.  This is
00165                 // per the xhmtl spec, so we need to fix this to include
00166                 // all compliant browsers we know of.
00167                 if($this->BROWSER_AGENT == 'IE')
00168                 {
00169                         $this->br = '<br/>';
00170                         $this->p = '<p/>';
00171                 }
00172                 else
00173                 {
00174                         $this->br = '<br>';
00175                         $this->p = '<p>';
00176                 }
00177         }
00178 
00179         function returnArray()
00180         {
00181                 $this->data = array(
00182                         'agent'    => $this->getAgent(),
00183                         'version'  => $this->getVersion(false),
00184                         'platform' => $this->getPlatform()
00185                 );
00186 
00187                 return $this->data;
00188         }
00189 
00190         function getAgent()
00191         {
00192                 return $this->BROWSER_AGENT;
00193         }
00194 
00195         function getVersion($a_as_array = true)
00196         {
00197                 return explode(".", $this->BROWSER_VER);
00198         }
00199 
00200         function getPlatform()
00201         {
00202                 return $this->BROWSER_PLATFORM;
00203         }
00204 
00205         function isLinux()
00206         {
00207                 if($this->getPlatform()=='Linux')
00208                 {
00209                         return true;
00210                 }
00211                 else
00212                 {
00213                         return false;
00214                 }
00215         }
00216 
00217         function isUnix()
00218         {
00219                 if($this->getPlatform()=='Unix')
00220                 {
00221                         return true;
00222                 }
00223                 else
00224                 {
00225                         return false;
00226                 }
00227         }
00228 
00229         function isBeos()
00230         {
00231                 if($this->getPlatform()=='Beos')
00232                 {
00233                         return true;
00234                 }
00235                 else
00236                 {
00237                         return false;
00238                 }
00239         }
00240 
00241         function isMac()
00242         {
00243                 if($this->getPlatform()=='Mac')
00244                 {
00245                         return true;
00246                 }
00247                 else
00248                 {
00249                         return false;
00250                 }
00251         }
00252 
00253         function isWindows()
00254         {
00255                 if($this->getPlatform()=='Win')
00256                 {
00257                         return true;
00258                 }
00259                 else
00260                 {
00261                         return false;
00262                 }
00263         }
00264 
00265         function isIE()
00266         {
00267                 if($this->getAgent()=='IE')
00268                 {
00269                         return true;
00270                 }
00271                 else
00272                 {
00273                         return false;
00274                 }
00275         }
00276 
00280         function isNetscape()
00281         {
00282                 if($this->getAgent()=='Netscape')
00283                 {
00284                         return true;
00285                 }
00286                 else
00287                 {
00288                         return false;
00289                 }
00290         }
00291 
00295         function isMozilla()
00296         {
00297                 if($this->getAgent()=='Mozilla')
00298                 {
00299                         return true;
00300                 }
00301                 else
00302                 {
00303                         return false;
00304                 }
00305         }
00306 
00307         function isOpera()
00308         {
00309                 if($this->getAgent()=='OPERA')
00310                 {
00311                         return true;
00312                 }
00313                 else
00314                 {
00315                         return false;
00316                 }
00317         }
00318 
00319         function isSafari()
00320         {
00321                 if($this->getAgent()=='Safari')
00322                 {
00323                         return true;
00324                 }
00325                 else
00326                 {
00327                         return false;
00328                 }
00329         }
00330 
00331         function isFirefox()
00332         {
00333                 if($this->getAgent()=='Firefox')
00334                 {
00335                         return true;
00336                 }
00337                 else
00338                 {
00339                         return false;
00340                 }
00341         }
00342 
00343 }
00344 
00345 ?>

Generated on Fri Dec 13 2013 09:06:33 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1