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