• Main Page
  • Related Pages
  • Modules
  • 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 
00044 class ilBrowser
00045 {
00046         var $BROWSER_AGENT;
00047         var $BROWSER_VER;
00048         var $BROWSER_PLATFORM;
00049         var $br;
00050         var $p;
00051         var $data;
00052 
00053         function ilBrowser()
00054         {
00055                 $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
00056                 /*
00057                         Determine browser and version
00058                 */
00059                 if(ereg('MSIE ([0-9].[0-9]{1,2})',$HTTP_USER_AGENT,$log_version))
00060                 {
00061                         $this->BROWSER_VER = $log_version[1];
00062                         $this->BROWSER_AGENT = 'IE';
00063                 }
00064                 elseif(ereg('Opera ([0-9].[0-9]{1,2})',$HTTP_USER_AGENT,$log_version) ||
00065                         ereg('Opera/([0-9].[0-9]{1,2})',$HTTP_USER_AGENT,$log_version))
00066                 {
00067                         $this->BROWSER_VER   = $log_version[1];
00068                         $this->BROWSER_AGENT = 'OPERA';
00069                 }
00070                 elseif(ereg('Safari ([0-9/.]*)',$HTTP_USER_AGENT,$log_version) ||
00071                         ereg('Safari/([0-9/.]*)',$HTTP_USER_AGENT,$log_version))
00072                 {
00073                         $this->BROWSER_VER   = $log_version[1];
00074                         $this->BROWSER_AGENT = 'Safari';
00075                 }
00076                 elseif(ereg('Firefox ([0-9/.]*)',$HTTP_USER_AGENT,$log_version) ||
00077                         ereg('Firefox/([0-9/.]*)',$HTTP_USER_AGENT,$log_version))
00078                 {
00079                         $this->BROWSER_VER   = $log_version[1];
00080                         $this->BROWSER_AGENT = 'Firefox';
00081                 }
00082                 elseif(eregi('iCab ([0-9].[0-9a-zA-Z]{1,4})',$HTTP_USER_AGENT,$log_version) ||
00083                         eregi('iCab/([0-9].[0-9a-zA-Z]{1,4})',$HTTP_USER_AGENT,$log_version))
00084                 {
00085                         $this->BROWSER_VER   = $log_version[1];
00086                         $this->BROWSER_AGENT = 'iCab';
00087                 }
00088                 elseif(eregi('Mozilla ([0-9].[0-9a-zA-Z]{1,4})',$HTTP_USER_AGENT,$log_version) ||
00089                         eregi('Mozilla/([0-9].[0-9a-zA-Z]{1,4})',$HTTP_USER_AGENT,$log_version))
00090                 {
00091                         $this->BROWSER_VER   = $log_version[1];
00092                         if (ereg('Gecko',$HTTP_USER_AGENT,$log_version))
00093                         {
00094                                 $this->BROWSER_AGENT = 'Mozilla';
00095                         }
00096                         else
00097                         {
00098                                 $this->BROWSER_AGENT = 'Netscape';
00099                         }
00100                 }
00101                 elseif(ereg('Konqueror/([0-9].[0-9].[0-9]{1,2})',$HTTP_USER_AGENT,$log_version) ||
00102                         ereg('Konqueror/([0-9].[0-9]{1,2})',$HTTP_USER_AGENT,$log_version))
00103                 {
00104                         $this->BROWSER_VER=$log_version[1];
00105                         $this->BROWSER_AGENT='Konqueror';
00106                 }
00107                 else
00108                 {
00109                         $this->BROWSER_VER=0;
00110                         $this->BROWSER_AGENT='OTHER';
00111                 }
00112 
00113                 /*
00114                         Determine platform
00115                 */
00116                 if(strstr($HTTP_USER_AGENT,'Win'))
00117                 {
00118                         $this->BROWSER_PLATFORM='Win';
00119                 }
00120                 elseif(strstr($HTTP_USER_AGENT,'Mac'))
00121                 {
00122                         $this->BROWSER_PLATFORM='Mac';
00123                 }
00124                 elseif(strstr($HTTP_USER_AGENT,'Linux'))
00125                 {
00126                         $this->BROWSER_PLATFORM='Linux';
00127                 }
00128                 elseif(strstr($HTTP_USER_AGENT,'Unix'))
00129                 {
00130                         $this->BROWSER_PLATFORM='Unix';
00131                 }
00132                 elseif(strstr($HTTP_USER_AGENT,'Beos'))
00133                 {
00134                         $this->BROWSER_PLATFORM='Beos';
00135                 }
00136                 else
00137                 {
00138                         $this->BROWSER_PLATFORM='Other';
00139                 }
00140 
00141 /*
00142                 echo "<br>Agent: $HTTP_USER_AGENT";
00143                 echo "<br><b>Browser</b>";
00144                 echo "<br>IE: ".$this->isIE();
00145                 echo "<br>Netscape: ".$this->isNetscape();
00146                 echo "<br>Mozilla: ".$this->isMozilla();
00147                 echo "<br>Firefox: ".$this->isFirefox();
00148                 echo "<br>Safari: ".$this->isSafari();
00149                 echo "<br>Opera: ".$this->isOpera();
00150                 echo "<br><b>OS</b>";
00151                 echo "<br>Mac: ".$this->isMac();
00152                 echo "<br>Windows: ".$this->isWindows();
00153                 echo "<br>Linux: ".$this->isLinux();
00154                 echo "<br>Unix: ".$this->isUnix();
00155                 echo "<br>Beos: ".$this->isBeos();
00156                 echo "<br><b>Summary</b>";
00157                 echo "<br>OS: ".$this->getPlatform();
00158                 echo "<br>Version: ".$this->getVersion(false);
00159                 echo "<br>Agent: ".$this->getAgent();
00160 */
00161 
00162                 // The br and p functions are supposed to return the correct
00163                 // value for tags that do not need to be closed.  This is
00164                 // per the xhmtl spec, so we need to fix this to include
00165                 // all compliant browsers we know of.
00166                 if($this->BROWSER_AGENT == 'IE')
00167                 {
00168                         $this->br = '<br/>';
00169                         $this->p = '<p/>';
00170                 }
00171                 else
00172                 {
00173                         $this->br = '<br>';
00174                         $this->p = '<p>';
00175                 }
00176         }
00177 
00178         function returnArray()
00179         {
00180                 $this->data = array(
00181                         'agent'    => $this->getAgent(),
00182                         'version'  => $this->getVersion(false),
00183                         'platform' => $this->getPlatform()
00184                 );
00185 
00186                 return $this->data;
00187         }
00188 
00189         function getAgent()
00190         {
00191                 return $this->BROWSER_AGENT;
00192         }
00193 
00194         function getVersion($a_as_array = true)
00195         {
00196                 return explode(".", $this->BROWSER_VER);
00197         }
00198 
00199         function getPlatform()
00200         {
00201                 return $this->BROWSER_PLATFORM;
00202         }
00203 
00204         function isLinux()
00205         {
00206                 if($this->getPlatform()=='Linux')
00207                 {
00208                         return true;
00209                 }
00210                 else
00211                 {
00212                         return false;
00213                 }
00214         }
00215 
00216         function isUnix()
00217         {
00218                 if($this->getPlatform()=='Unix')
00219                 {
00220                         return true;
00221                 }
00222                 else
00223                 {
00224                         return false;
00225                 }
00226         }
00227 
00228         function isBeos()
00229         {
00230                 if($this->getPlatform()=='Beos')
00231                 {
00232                         return true;
00233                 }
00234                 else
00235                 {
00236                         return false;
00237                 }
00238         }
00239 
00240         function isMac()
00241         {
00242                 if($this->getPlatform()=='Mac')
00243                 {
00244                         return true;
00245                 }
00246                 else
00247                 {
00248                         return false;
00249                 }
00250         }
00251 
00252         function isWindows()
00253         {
00254                 if($this->getPlatform()=='Win')
00255                 {
00256                         return true;
00257                 }
00258                 else
00259                 {
00260                         return false;
00261                 }
00262         }
00263 
00264         function isIE()
00265         {
00266                 if($this->getAgent()=='IE')
00267                 {
00268                         return true;
00269                 }
00270                 else
00271                 {
00272                         return false;
00273                 }
00274         }
00275 
00279         function isNetscape()
00280         {
00281                 if($this->getAgent()=='Netscape')
00282                 {
00283                         return true;
00284                 }
00285                 else
00286                 {
00287                         return false;
00288                 }
00289         }
00290 
00294         function isMozilla()
00295         {
00296                 if($this->getAgent()=='Mozilla')
00297                 {
00298                         return true;
00299                 }
00300                 else
00301                 {
00302                         return false;
00303                 }
00304         }
00305 
00306         function isOpera()
00307         {
00308                 if($this->getAgent()=='OPERA')
00309                 {
00310                         return true;
00311                 }
00312                 else
00313                 {
00314                         return false;
00315                 }
00316         }
00317 
00318         function isSafari()
00319         {
00320                 if($this->getAgent()=='Safari')
00321                 {
00322                         return true;
00323                 }
00324                 else
00325                 {
00326                         return false;
00327                 }
00328         }
00329 
00330         function isFirefox()
00331         {
00332                 if($this->getAgent()=='Firefox')
00333                 {
00334                         return true;
00335                 }
00336                 else
00337                 {
00338                         return false;
00339                 }
00340         }
00341 
00342 }
00343 
00344 ?>

Generated on Fri Dec 13 2013 17:56:47 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1