2.5.1
[phpmyadmin/sankalp_k.git] / libraries / defines_php.lib.php3
blob747598dc5562d2bb2c60c3ade10def5dcdc89770
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.1');
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 // Whether GD2 is present
66 if (!defined('PMA_IS_GD2')) {
67 if ($cfg['GD2Available'] == 'yes') {
68 define('PMA_IS_GD2', 1);
69 } elseif ($cfg['GD2Available'] == 'no') {
70 define('PMA_IS_GD2', 0);
71 } else {
72 if (((PMA_PHP_INT_VERSION >= 40000 && !@ini_get('safe_mode') && @ini_get('enable_dl'))
73 || (PMA_PHP_INT_VERSION < 40000 && PMA_PHP_INT_VERSION > 30009 && !@get_cfg_var('safe_mode')))
74 && @function_exists('dl')) {
75 if (PMA_IS_WINDOWS) {
76 $suffix = '.dll';
77 } else {
78 $suffix = '.so';
80 if (!@extension_loaded('gd')) {
81 @dl('gd' . $suffix);
84 if (!@function_exists('imagecreatetruecolor')) {
85 define('PMA_IS_GD2', 0);
86 } else {
87 if (@function_exists('gd_info')) {
88 $gd_nfo = gd_info();
89 if (strstr($gd_nfo["GD Version"], '2.')) {
90 define('PMA_IS_GD2', 1);
91 } else {
92 define('PMA_IS_GD2', 0);
94 } else {
95 /* We must do hard way... */
96 ob_start();
97 phpinfo(8); /* Only modules */
98 $a = ob_get_contents();
99 ob_end_clean();
100 /* Get GD version string from phpinfo output */
101 if (ereg('<tr><td[^>]*>[^>]*GD Version[^<]*</td><td[^>]*>\([^<]*\)</td></tr>', $a, $v)) {
102 if (strstr($v, '2.')) {
103 define('PMA_IS_GD2', 1);
104 } else {
105 define('PMA_IS_GD2', 0);
107 } else {
108 define('PMA_IS_GD2', 0);
114 // $__PMA_DEFINES_PHP_LIB__