Documentation TYPO3 par Ameos

defines.lib.php

00001 <?php
00002 /* $Id: defines.lib.php,v 2.6.2.1 2004/02/02 20:24:48 lem9 Exp $ */
00003 // vim: expandtab sw=4 ts=4 sts=4:
00004 
00020 // phpMyAdmin release
00021 if (!defined('PMA_VERSION')) {
00022     define('PMA_VERSION', '2.5.6-rc1');
00023 }
00024 
00025 // php version
00026 if (!defined('PMA_PHP_INT_VERSION')) {
00027     if (!preg_match('@([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})@', phpversion(), $match)) {
00028         $result = preg_match('@([0-9]{1,2}).([0-9]{1,2})@', phpversion(), $match);
00029     }
00030     if (isset($match) && !empty($match[1])) {
00031         if (!isset($match[2])) {
00032             $match[2] = 0;
00033         }
00034         if (!isset($match[3])) {
00035             $match[3] = 0;
00036         }
00037         define('PMA_PHP_INT_VERSION', (int)sprintf('%d%02d%02d', $match[1], $match[2], $match[3]));
00038         unset($match);
00039     } else {
00040         define('PMA_PHP_INT_VERSION', 0);
00041     }
00042     define('PMA_PHP_STR_VERSION', phpversion());
00043 }
00044 
00045 // MySQL client API
00046 if (!defined('PMA_MYSQL_CLIENT_API')) {
00047     $client_api = explode('.', mysql_get_client_info());
00048     define('PMA_MYSQL_CLIENT_API', (int)sprintf('%d%02d%02d', $client_api[0], $client_api[1], intval($client_api[2])));
00049     unset($client_api);
00050 }
00051 
00052 // Whether the os php is running on is windows or not
00053 if (!defined('PMA_IS_WINDOWS')) {
00054     if (defined('PHP_OS') && stristr(PHP_OS, 'win')) {
00055         define('PMA_IS_WINDOWS', 1);
00056     } else {
00057         define('PMA_IS_WINDOWS', 0);
00058     }
00059 }
00060 
00061 function PMA_dl($module) {
00062     if (!isset($GLOBALS['PMA_dl_allowed'])) {
00063         if (!@ini_get('safe_mode') && @ini_get('enable_dl') && @function_exists('dl')) {
00064             ob_start();
00065             phpinfo(INFO_GENERAL); /* Only general info */
00066             $a = strip_tags(ob_get_contents());
00067             ob_end_clean();
00068             /* Get GD version string from phpinfo output */
00069             if (preg_match('@Thread Safety[[:space:]]*enabled@', $a)) {
00070                 if (preg_match('@Server API[[:space:]]*\(CGI\|CLI\)@', $a)) {
00071                     $GLOBALS['PMA_dl_allowed'] = TRUE;
00072                 } else {
00073                     $GLOBALS['PMA_dl_allowed'] = FALSE;
00074                 }
00075             } else {
00076                 $GLOBALS['PMA_dl_allowed'] = TRUE;
00077             }
00078         } else {
00079             $GLOBALS['PMA_dl_allowed'] = FALSE;
00080         }
00081     }
00082     if (PMA_IS_WINDOWS) {
00083         $suffix = '.dll';
00084     } else {
00085         $suffix = '.so';
00086     }
00087     if ($GLOBALS['PMA_dl_allowed']) {
00088         return @dl($module . $suffix);
00089     } else {
00090         return FALSE;
00091     }
00092 }
00093 
00094 // Whether GD2 is present
00095 if (!defined('PMA_IS_GD2')) {
00096     if ($cfg['GD2Available'] == 'yes') {
00097         define('PMA_IS_GD2', 1);
00098     } elseif ($cfg['GD2Available'] == 'no') {
00099         define('PMA_IS_GD2', 0);
00100     } else {
00101         if (!@extension_loaded('gd')) {
00102             PMA_dl('gd');
00103         }
00104         if (!@function_exists('imagecreatetruecolor')) {
00105             define('PMA_IS_GD2', 0);
00106         } else {
00107             if (@function_exists('gd_info')) {
00108                 $gd_nfo = gd_info();
00109                 if (strstr($gd_nfo["GD Version"], '2.')) {
00110                     define('PMA_IS_GD2', 1);
00111                 } else {
00112                     define('PMA_IS_GD2', 0);
00113                 }
00114             } else {
00115                 /* We must do hard way... */
00116                 ob_start();
00117                 phpinfo(INFO_MODULES); /* Only modules */
00118                 $a = strip_tags(ob_get_contents());
00119                 ob_end_clean();
00120                 /* Get GD version string from phpinfo output */
00121                 if (preg_match('@GD Version[[:space:]]*\(.*\)@', $a, $v)) {
00122                     if (strstr($v, '2.')) {
00123                         define('PMA_IS_GD2', 1);
00124                     } else {
00125                         define('PMA_IS_GD2', 0);
00126                     }
00127                 } else {
00128                     define('PMA_IS_GD2', 0);
00129                 }
00130             }
00131         }
00132     }
00133 }
00134 
00135 // Determines platform (OS), browser and version of the user
00136 // Based on a phpBuilder article:
00137 //   see http://www.phpbuilder.net/columns/tim20000821.php
00138 if (!defined('PMA_USR_OS')) {
00139     if (!empty($_SERVER['HTTP_USER_AGENT'])) {
00140         $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
00141     } else if (!isset($HTTP_USER_AGENT)) {
00142         $HTTP_USER_AGENT = '';
00143     }
00144 
00145     // 1. Platform
00146     if (strstr($HTTP_USER_AGENT, 'Win')) {
00147         define('PMA_USR_OS', 'Win');
00148     } else if (strstr($HTTP_USER_AGENT, 'Mac')) {
00149         define('PMA_USR_OS', 'Mac');
00150     } else if (strstr($HTTP_USER_AGENT, 'Linux')) {
00151         define('PMA_USR_OS', 'Linux');
00152     } else if (strstr($HTTP_USER_AGENT, 'Unix')) {
00153         define('PMA_USR_OS', 'Unix');
00154     } else if (strstr($HTTP_USER_AGENT, 'OS/2')) {
00155         define('PMA_USR_OS', 'OS/2');
00156     } else {
00157         define('PMA_USR_OS', 'Other');
00158     }
00159 
00160     // 2. browser and version
00161     // (must check everything else before Mozilla)
00162 
00163     if (preg_match('@Opera(/| )([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
00164         define('PMA_USR_BROWSER_VER', $log_version[2]);
00165         define('PMA_USR_BROWSER_AGENT', 'OPERA');
00166     } else if (preg_match('@MSIE ([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
00167         define('PMA_USR_BROWSER_VER', $log_version[1]);
00168         define('PMA_USR_BROWSER_AGENT', 'IE');
00169     } else if (preg_match('@OmniWeb/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
00170         define('PMA_USR_BROWSER_VER', $log_version[1]);
00171         define('PMA_USR_BROWSER_AGENT', 'OMNIWEB');
00172     //} else if (ereg('Konqueror/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
00173     // Konqueror 2.2.2 says Konqueror/2.2.2
00174     // Konqueror 3.0.3 says Konqueror/3
00175     } else if (preg_match('@(Konqueror/)(.*)(;)@', $HTTP_USER_AGENT, $log_version)) {
00176         define('PMA_USR_BROWSER_VER', $log_version[2]);
00177         define('PMA_USR_BROWSER_AGENT', 'KONQUEROR');
00178     } else if (preg_match('@Mozilla/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)
00179                && preg_match('@Safari/([0-9]*)@', $HTTP_USER_AGENT, $log_version2)) {
00180         define('PMA_USR_BROWSER_VER', $log_version[1] . '.' . $log_version2[1]);
00181         define('PMA_USR_BROWSER_AGENT', 'SAFARI');
00182     } else if (preg_match('@Mozilla/([0-9].[0-9]{1,2})@', $HTTP_USER_AGENT, $log_version)) {
00183         define('PMA_USR_BROWSER_VER', $log_version[1]);
00184         define('PMA_USR_BROWSER_AGENT', 'MOZILLA');
00185     } else {
00186         define('PMA_USR_BROWSER_VER', 0);
00187         define('PMA_USR_BROWSER_AGENT', 'OTHER');
00188     }
00189 }
00190 
00191 ?>


Généré par L'expert TYPO3 avec  doxygen 1.4.6