1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
<?php /* * Gallery - a web based photo album viewer and editor * Copyright (C) 2000-2008 Bharat Mediratta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ /** * This script is useful to gather information about a specific PHP * environment. The output is an array that can be appended to the * GdFunctionalityMatrix.inc in the gd module's phpunit tests. This is used * by the phpunit tests to test the GdToolkit functionality in different PHP * environments in a single installation. * * @version $Revision: 17580 $ * @package Gd * @subpackage PHPUnit * * @author Ernesto Baschny <ernst@baschny.de> */ if (!defined('G2_SUPPORT')) { return; }
/* * Gets a lot of information about our GD installation and return it as a * giant string, which can be eval'ed to an array. */ function getGdLibraryInfo() { if (! extension_loaded('gd')) { return ''; }
/* Get GD version from phpinfo or gd_info */ if (function_exists('gd_info')) { $gdInfo = gd_info(); $matchString = $gdInfo['GD Version']; $matcherVersion = '/([\d\.]+)(\s+or\s+higher)?/i'; $matcherBundled = '/bundled/i'; } else { ob_start(); phpinfo(8); $matchString = ob_get_contents(); $matcherVersion = '/\bgd\s+version\b[^\d\n\r]+?([\d\.]+)(\s+or\s+higher)?/i'; $matcherBundled = '/\bgd\s+version\b[^\d\n\r]+?bundled/i'; ob_end_clean(); } if (preg_match($matcherVersion, $matchString, $matches)) { $gdVersion = $matches[1]; } else { $gdVersion = 0; } if (isset($matches[2])) { $gdVersion = sprintf('>%s', $gdVersion); } $isGdBundled = 0; if (preg_match($matcherBundled, $matchString)) { $isGdBundled = 1; }
/* Find out supported mime types */ $mimeChecks = array( array( 'mimeType' => 'image/gif', 'value' => defined('IMG_GIF') ? IMG_GIF : '', 'functions' => array('imageCreateFromGif', 'imageGif') ), array( 'mimeType' => 'image/jpeg', 'value' => defined('IMG_JPEG') ? IMG_JPEG : '', 'functions' => array('imageCreateFromJpeg', 'imageJpeg') ), array( 'mimeType' => 'image/png', 'value' => defined('IMG_PNG') ? IMG_PNG : '', 'functions' => array('imageCreateFromPng', 'imagePng') ), array( 'mimeType' => 'image/vnd.wap.wbmp', 'value' => defined('IMG_WBMP') ? IMG_WBMP : '', 'functions' => array('imageCreateFromWbmp', 'imageWbmp') ), array( 'mimeType' => 'image/x-xpixmap', 'value' => defined('IMG_XPM') ? IMG_XPM : '', 'functions' => array('imageCreateFromXpm', 'imageXpm') ), array( 'mimeType' => 'image/x-xbitmap', 'value' => defined('IMG_XBM') ? IMG_XBM : '', 'functions' => array('imageCreateFromXbm', 'imageXbm') ), ); $mimeTypes = array(); foreach ($mimeChecks as $check) { $ok = true; foreach ($check['functions'] as $fct) { if (! function_exists($fct)) { $ok = false; } } if ($ok && ! ($check['value'] & imageTypes())) { $ok = false; } if ($ok) { $mimeTypes[] = $check['mimeType']; } }
$out = ''; $out .= '$gdEnvironments[] = array(' . "\n"; $name = sprintf('%s|%s%s|%s', phpversion(), $gdVersion, ($isGdBundled ? '-bundled' : '-external'), PHP_OS );
$out .= "\t" . sprintf('\'name\' => \'%s\',', $name) . "\n"; $out .= "\t" . sprintf('\'phpVersion\' => \'%s\',', phpversion()) . "\n"; $out .= "\t" . sprintf('\'gdVersion\' => \'%s\',', $gdVersion) . "\n"; $out .= "\t" . sprintf('\'gdBundled\' => %s,', $isGdBundled) . "\n";
$imageTypes = 0; if (function_exists('imageTypes')) { $imageTypes = imageTypes(); } $out .= "\t" . sprintf('\'imageTypes\' => %s,', $imageTypes) . "\n";
if (function_exists('gd_info')) { $gdInfo = gd_info(); $out .= "\t" . '\'gd_info\' => array(' . "\n"; foreach ($gdInfo as $field => $value) { $out .= "\t\t" . sprintf('\'%s\' => \'%s\',', $field, $value) . "\n"; } $out .= "\t" . '),' . "\n"; }
/* Check which constants are defined */ $constants = get_defined_constants(); $out .= "\t" . '\'constants\' => array(' . "\n"; foreach ($constants as $constant => $value) { if (! preg_match('/^(IMAGE|IMG|GD|PHP)/', $constant)) { continue; } if (! is_int($value)) { $value = sprintf('\'%s\'', $value); } $out .= "\t\t" . sprintf('\'%s\' => %s,', $constant, $value) . "\n"; } $out .= "\t" . '),' . "\n";
$out .= "\t" . '\'mimeTypes\' => array(' . "\n"; foreach ($mimeTypes as $mimeType) { $out .= "\t\t" . sprintf('\'%s\',', $mimeType) . "\n"; } $out .= "\t" . '),' . "\n";
ob_start(); phpinfo(8); $phpinfo = ob_get_contents(); ob_end_clean(); $phpinfo = htmlspecialchars($phpinfo); $phpinfo = preg_replace('/\'/', '\\\'', $phpinfo); $out .= "\t" . sprintf('\'phpinfo(8)\' => \'%s\',', $phpinfo) . "\n";
/* Functions defined in this GD module */ $functions = get_extension_funcs('gd'); $out .= "\t" . '\'functions\' => array(' . "\n"; foreach ($functions as $fct) { $out .= "\t\t" . sprintf('\'%s\' => true,', $fct) . "\n"; }
$otherFunctions = array( 'getimagesize', 'image_type_to_extension', 'image_type_to_mime_type', 'iptcembed', 'iptcparse', ); foreach ($otherFunctions as $fct) { if (! function_exists($fct)) { continue; } $out .= "\t\t" . sprintf('\'%s\' => true,', $fct) . "\n"; } $out .= "\t" . '),' . "\n"; $out .= ');' . "\n"; return $out; }
$gdInfo = getGdLibraryInfo();
?> <html> <head> <title>Gallery Support | GD Library Info</title> <link rel="stylesheet" type="text/css" href="<?php print $baseUrl ?>support.css"/> </head> <body> <div id="content"> <div id="title"> <a href="../../">Gallery</a> » <a href="<?php generateUrl('index.php') ?>">Support</a> » GD Library Info </div> <?php if ($gdInfo == ''): ?> <h2>No GD library found.</h2> <?php else: ?> <h2>This information might be useful for the GD module developers:</h2> <pre style="padding-left: 20px"><?php echo $gdInfo; ?></pre> <?php endif; ?> </div> </body> </html>
|