2.5.2
[phpmyadmin/crack.git] / libraries / defines_php.lib.php3
blob900d875bf493fb56b7c089706b95e2bf41af3244
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=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_MYSQL_CLIENT_API (int) - the version number of the MySQL client
12 * API which php is built against.
13 * PMA_IS_WINDOWS (bool) - mark if phpMyAdmin running on windows
14 * server
15 * PMA_IS_GD2 (bool) - true is GD2 is present
17 // phpMyAdmin release
18 if (!defined('PMA_VERSION')) {
19 define('PMA_VERSION', '2.5.2');
22 // php version
23 if (!defined('PMA_PHP_INT_VERSION')) {
24 if (!ereg('([0-9]{1,2}).([0-9]{1,2}).([0-9]{1,2})', phpversion(), $match)) {
25 $result = ereg('([0-9]{1,2}).([0-9]{1,2})', phpversion(), $match);
27 if (isset($match) && !empty($match[1])) {
28 if (!isset($match[2])) {
29 $match[2] = 0;
31 if (!isset($match[3])) {
32 $match[3] = 0;
34 define('PMA_PHP_INT_VERSION', (int)sprintf('%d%02d%02d', $match[1], $match[2], $match[3]));
35 unset($match);
36 } else {
37 define('PMA_PHP_INT_VERSION', 0);
39 define('PMA_PHP_STR_VERSION', phpversion());
42 // MySQL client API
43 if (!defined('PMA_MYSQL_CLIENT_API')) {
44 if (function_exists('mysql_get_client_info')) {
45 $client_api = mysql_get_client_info();
46 } else {
47 // for compatibility with php <= 4.0.5
48 // expect the worst!
49 $client_api = '3.21.0';
51 $client_api = explode('.', $client_api);
52 define('PMA_MYSQL_CLIENT_API', (int)sprintf('%d%02d%02d', $client_api[0], $client_api[1], intval($client_api[2])));
53 unset($client_api);
56 // Whether the os php is running on is windows or not
57 if (!defined('PMA_IS_WINDOWS')) {
58 if (defined('PHP_OS') && eregi('win', PHP_OS)) {
59 define('PMA_IS_WINDOWS', 1);
60 } else {
61 define('PMA_IS_WINDOWS', 0);
65 function PMA_dl($module) {
66 if (!isset($GLOBALS['PMA_dl_allowed'])) {
67 if (((PMA_PHP_INT_VERSION >= 40000 && !@ini_get('safe_mode') && @ini_get('enable_dl'))
68 || (PMA_PHP_INT_VERSION < 40000 && PMA_PHP_INT_VERSION > 30009 && !@get_cfg_var('safe_mode')))
69 && @function_exists('dl')) {
71 ob_start();
72 phpinfo(INFO_GENERAL); /* Only general info */
73 $a = strip_tags(ob_get_contents());
74 ob_end_clean();
75 /* Get GD version string from phpinfo output */
76 if (ereg('Thread Safety[[:space:]]*enabled', $a)) {
77 if (ereg('Server API[[:space:]]*\(CGI\|CLI\)', $a)) {
78 $GLOBALS['PMA_dl_allowed'] = TRUE;
79 } else {
80 $GLOBALS['PMA_dl_allowed'] = FALSE;
82 } else {
83 $GLOBALS['PMA_dl_allowed'] = TRUE;
85 } else {
86 $GLOBALS['PMA_dl_allowed'] = FALSE;
89 if (PMA_IS_WINDOWS) {
90 $suffix = '.dll';
91 } else {
92 $suffix = '.so';
94 if ($GLOBALS['PMA_dl_allowed']) {
95 return @dl($module . $suffix);
96 } else {
97 return FALSE;
102 // Whether GD2 is present
103 if (!defined('PMA_IS_GD2')) {
104 if ($cfg['GD2Available'] == 'yes') {
105 define('PMA_IS_GD2', 1);
106 } elseif ($cfg['GD2Available'] == 'no') {
107 define('PMA_IS_GD2', 0);
108 } else {
109 if (!@extension_loaded('gd')) {
110 PMA_dl('gd');
112 if (!@function_exists('imagecreatetruecolor')) {
113 define('PMA_IS_GD2', 0);
114 } else {
115 if (@function_exists('gd_info')) {
116 $gd_nfo = gd_info();
117 if (strstr($gd_nfo["GD Version"], '2.')) {
118 define('PMA_IS_GD2', 1);
119 } else {
120 define('PMA_IS_GD2', 0);
122 } else {
123 /* We must do hard way... */
124 ob_start();
125 phpinfo(INFO_MODULES); /* Only modules */
126 $a = strip_tags(ob_get_contents());
127 ob_end_clean();
128 /* Get GD version string from phpinfo output */
129 if (ereg('GD Version[[:space:]]*\(.*\)', $a, $v)) {
130 if (strstr($v, '2.')) {
131 define('PMA_IS_GD2', 1);
132 } else {
133 define('PMA_IS_GD2', 0);
135 } else {
136 define('PMA_IS_GD2', 0);
142 // $__PMA_DEFINES_PHP_LIB__