home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / phptriad / phptriad2-2-1.exe / htdocs / phpmyadmin / libraries / defines.lib.php < prev    next >
PHP Script  |  2002-01-06  |  5KB  |  129 lines

  1. <?php
  2. /* $Id: defines.lib.php,v 1.17 2002/01/06 19:04:02 lem9 Exp $ */
  3.  
  4.  
  5. /**
  6.  * DEFINES VARIABLES & CONSTANTS
  7.  * Overview:
  8.  *    PMA_VERSION              (string) - phpMyAdmin version string
  9.  *    PMA_PHP_INT_VERSION      (int)    - eg: 30017 instead of 3.0.17 or
  10.  *                                        40006 instead of 4.0.6RC3
  11.  *    PMA_IS_WINDOWS           (bool)   - mark if phpMyAdmin running on windows
  12.  *                                        server
  13.  *    PMA_MYSQL_INT_VERSION    (int)    - eg: 32339 instead of 3.23.39
  14.  *    PMA_USR_OS               (string) - the plateform (os) of the user
  15.  *    PMA_USR_BROWSER_AGENT    (string) - the browser of the user
  16.  *    PMA_USR_BROWSER_VER      (double) - the version of this browser
  17.  */
  18. // phpMyAdmin release
  19. if (!defined('PMA_VERSION')) {
  20.     define('PMA_VERSION', '2.2.3');
  21. }
  22.  
  23. // php version
  24. if (!defined('PMA_PHP_INT_VERSION')) {
  25.     if (!ereg('([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})', phpversion(), $match)) {
  26.         $result = ereg('([0-9]{1,2}).([0-9]{1,2})', phpversion(), $match);
  27.     }
  28.     if (isset($match) && !empty($match[1])) {
  29.         if (!isset($match[2])) {
  30.             $match[2] = 0;
  31.         }
  32.         if (!isset($match[3])) {
  33.             $match[3] = 0;
  34.         }
  35.         define('PMA_PHP_INT_VERSION', (int)sprintf('%d%02d%02d', $match[1], $match[2], $match[3]));
  36.         unset($match);
  37.     } else {
  38.         define('PMA_PHP_INT_VERSION', 0);
  39.     }
  40. }
  41.  
  42. // Whether the os php is running on is windows or not
  43. if (!defined('PMA_IS_WINDOWS')) {
  44.     if (defined('PHP_OS') && eregi('win', PHP_OS)) {
  45.         define('PMA_IS_WINDOWS', 1);
  46.     } else {
  47.         define('PMA_IS_WINDOWS', 0);
  48.     }
  49. }
  50.  
  51. // MySQL Version
  52. if (!defined('PMA_MYSQL_INT_VERSION') && isset($userlink)) {
  53.     if (!empty($server)) {
  54.         $result = mysql_query('SELECT VERSION() AS version');
  55.         if ($result != FALSE && @mysql_num_rows($result) > 0) {
  56.             $row   = mysql_fetch_array($result);
  57.             $match = explode('.', $row['version']);
  58.         } else {
  59.             $result = @mysql_query('SHOW VARIABLES LIKE \'version\'');
  60.             if ($result != FALSE && @mysql_num_rows($result) > 0){
  61.                 $row   = mysql_fetch_row($result);
  62.                 $match = explode('.', $row[1]);
  63.             }
  64.         }
  65.     } // end server id is defined case
  66.  
  67.     if (!isset($match) || !isset($match[0])) {
  68.         $match[0] = 3;
  69.     }
  70.     if (!isset($match[1])) {
  71.         $match[1] = 21;
  72.     }
  73.     if (!isset($match[2])) {
  74.         $match[2] = 0;
  75.     }
  76.  
  77.     define('PMA_MYSQL_INT_VERSION', (int)sprintf('%d%02d%02d', $match[0], $match[1], intval($match[2])));
  78.     unset($match);
  79. }
  80.  
  81.  
  82. // Determines platform (OS), browser and version of the user
  83. // Based on a phpBuilder article:
  84. //   see http://www.phpbuilder.net/columns/tim20000821.php
  85. if (!defined('PMA_USR_OS')) {
  86.     // loic1 - 2001/25/11: use the new globals arrays defined with
  87.     // php 4.1+
  88.     if (!empty($_SERVER['HTTP_USER_AGENT'])) {
  89.         $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
  90.     } else if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) {
  91.         $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
  92.     }
  93.     // 1. Platform
  94.     if (strstr($HTTP_USER_AGENT, 'Win')) {
  95.         define('PMA_USR_OS', 'Win');
  96.     } else if (strstr($HTTP_USER_AGENT, 'Mac')) {
  97.         define('PMA_USR_OS', 'Mac');
  98.     } else if (strstr($HTTP_USER_AGENT, 'Linux')) {
  99.         define('PMA_USR_OS', 'Linux');
  100.     } else if (strstr($HTTP_USER_AGENT, 'Unix')) {
  101.         define('PMA_USR_OS', 'Unix');
  102.     } else if (strstr($HTTP_USER_AGENT, 'OS/2')) {
  103.         define('PMA_USR_OS', 'OS/2');
  104.     } else {
  105.         define('PMA_USR_OS', 'Other');
  106.     }
  107.     // 2. browser and version
  108.     if (ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
  109.         define('PMA_USR_BROWSER_VER', $log_version[1]);
  110.         define('PMA_USR_BROWSER_AGENT', 'IE');
  111.     } else if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
  112.         define('PMA_USR_BROWSER_VER', $log_version[2]);
  113.         define('PMA_USR_BROWSER_AGENT', 'OPERA');
  114.     } else if (ereg('OmniWeb/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
  115.         define('PMA_USR_BROWSER_VER', $log_version[1]);
  116.         define('PMA_USR_BROWSER_AGENT', 'OMNIWEB');
  117.     } else if (ereg('Mozilla/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
  118.         define('PMA_USR_BROWSER_VER', $log_version[1]);
  119.         define('PMA_USR_BROWSER_AGENT', 'MOZILLA');
  120.     } else if (ereg('Konqueror/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
  121.         define('PMA_USR_BROWSER_VER', $log_version[1]);
  122.         define('PMA_USR_BROWSER_AGENT', 'KONQUEROR');
  123.     } else {
  124.         define('PMA_USR_BROWSER_VER', 0);
  125.         define('PMA_USR_BROWSER_AGENT', 'OTHER');
  126.     }
  127. } // $__PMA_DEFINES_LIB__
  128. ?>
  129.