<?php
/**************************************************************************/
/* Module Gbook MX v2.0 Copyright (c) 2004 by Víctor Simental             */
/* $Revision 30/01/2004 - $Id class.navegador.php - v4.2.0   EPX $        */
/* @URI: http://www.phpwebmasters.com                                     */ 
/* ============================================                           */
/* Based in Gbook MX v4.1.0 Copyright (c) 2003 by                         */
/* Víctor Simental - http://gbookmx.sourceforge.net                       */
/* ============================================                           */
/* GbookMX is Based in the Gbook v1.0 for PHP Nuke Copyright (c) 2003 by  */
/* http://www.PHP-Mania.com.ar                                            */
/* Programed and Design By Víctor Simental and German Cúevas              */
/* vicmx@phpwebmasters.com                                                */
/*                                                                        */
/* This program is free software. You can redistribute it and/or modify   */
/* it under the terms of the GNU General Public License as published by   */
/* the Free Software Foundation; either version 2 of the License.         */
/**************************************************************************/

if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {   
 die ("You can't access this file directly...");
} 
 
class Navegador {
   var $user_agent = "";
   var $navegador = "unknown";
   var $os = "unknown";
      
   # CONSTRUCTOR #
   function Navegador()
   {  $this->user_agent = getenv(HTTP_USER_AGENT);
      $preparens = "";
      $parens = "";
      $i = strpos($this->user_agent,"(");
      if ($i >= 0){
	    $preparens = trim(substr($this->user_agent,0,$i));
		$parens = substr($this->user_agent,$i+1,strlen($this->user_agent));
		$j = strpos($parens,")");
         if($j>=0){
		   $parens = substr($parens,0,$j);
         }
      }
      else
      {
	    $preparens = $this->user_agent;
      }
      $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->os   =  "Unix";
         }
         elseif(preg_match("/Win/i","$token"))
         {  $this->os   =  $token;
         }
         elseif(preg_match("/Mac/i","$token") || preg_match("/PPC/i","$token"))
         {  $this->os   =  $token;
         }
		 elseif(preg_match("/FreeBSD/i","$token"))
         {  $this->os   =  $token;
         }
		 elseif(preg_match("/IRIX/i","$token"))
         {  $this->os   =  $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->navegador =  "ns";
         $leftover=substr($browVer,strlen("Mozilla")+1,strlen($browVer));
      }
      elseif(substr($browVer,0,strlen("Lynx")) == "Lynx")
      {  $this->navegador =  "lynx";
         $leftover=substr($browVer,strlen("Lynx")+1,strlen($browVer));
      }
      elseif(substr($browVer,0,strlen("MSIE")) == "MSIE")
      {  $this->navegador =  "ie";
         $leftover=substr($browVer,strlen("MSIE")+1,strlen($browVer));
      }
      elseif(substr($browVer,0,strlen("Microsoft Internet Explorer")) == "Microsoft Internet Explorer")
      {  $this->navegador =  "ie";
         $leftover=substr($browVer,strlen("Microsoft Internet Explorer")+1,strlen($browVer));
      }
	  //New addition
      elseif(substr($browVer,0,strlen("Opera")) == "Opera")
      {  $this->navegador =  "opera";
         $leftover=substr($browVer,strlen("Opera")+1,strlen($browVer));
      }
	  //New addition
      elseif(substr($browVer,0,strlen("Konqueror")) == "Konqueror")
      {  $this->navegador =  "konqueror";
         $leftover=substr($browVer,strlen("Konqueror")+1,strlen($browVer));
      }
     
   }
}

?>
