dolibarr 20.0.0
phpinfo.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
7 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
28// Load Dolibarr environment
29require '../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
32
33$langs->loadLangs(array("admin", "install", "errors"));
34
35if (!$user->admin) {
37}
38
39
40/*
41 * View
42 */
43
44llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-admin page-system_phpinfo');
45
46$title = 'InfoPHP';
47
48if (isset($title)) {
49 print load_fiche_titre($langs->trans($title), '', 'title_setup');
50}
51
52
53// Check PHP setup is OK
54$maxphp = @ini_get('upload_max_filesize'); // In unknown
55if (preg_match('/k$/i', $maxphp)) {
56 $maxphp = preg_replace('/k$/i', '', $maxphp);
57 $maxphp *= 1;
58}
59if (preg_match('/m$/i', $maxphp)) {
60 $maxphp = preg_replace('/m$/i', '', $maxphp);
61 $maxphp *= 1024;
62}
63if (preg_match('/g$/i', $maxphp)) {
64 $maxphp = preg_replace('/g$/i', '', $maxphp);
65 $maxphp *= 1024 * 1024;
66}
67if (preg_match('/t$/i', $maxphp)) {
68 $maxphp = preg_replace('/t$/i', '', $maxphp);
69 $maxphp *= 1024 * 1024 * 1024;
70}
71$maxphp2 = @ini_get('post_max_size'); // In unknown
72if (preg_match('/k$/i', $maxphp2)) {
73 $maxphp2 = preg_replace('/k$/i', '', $maxphp2);
74 $maxphp2 *= 1;
75}
76if (preg_match('/m$/i', $maxphp2)) {
77 $maxphp2 = preg_replace('/m$/i', '', $maxphp2);
78 $maxphp2 *= 1024;
79}
80if (preg_match('/g$/i', $maxphp2)) {
81 $maxphp2 = preg_replace('/g$/i', '', $maxphp2);
82 $maxphp2 *= 1024 * 1024;
83}
84if (preg_match('/t$/i', $maxphp2)) {
85 $maxphp2 = preg_replace('/t$/i', '', $maxphp2);
86 $maxphp2 *= 1024 * 1024 * 1024;
87}
88if ($maxphp > 0 && $maxphp2 > 0 && $maxphp > $maxphp2) {
89 $langs->load("errors");
90 print info_admin($langs->trans("WarningParamUploadMaxFileSizeHigherThanPostMaxSize", @ini_get('upload_max_filesize'), @ini_get('post_max_size')), 0, 0, 0, 'warning');
91 print '<br>';
92}
93
94
95print '<table class="noborder centpercent">';
96print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
97
98$ErrorPicturePath = "../../theme/eldy/img/error.png";
99$WarningPicturePath = "../../theme/eldy/img/warning.png";
100$OkayPicturePath = "../../theme/eldy/img/tick.png";
101
102print '<tr><td>'.$langs->trans("Version").'</td><td>';
103
104$arrayphpminversionerror = array(5, 5, 0);
105$arrayphpminversionwarning = array(5, 6, 0);
106
107if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) {
108 print img_picto('Error', 'error').' '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionerror));
109} elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0) {
110 print img_picto('Warning', 'warning').' '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning));
111} else {
112 print img_picto('Ok', 'tick').' '.versiontostring(versionphparray());
113}
114
115print '</td></tr>';
116print '<tr><td>GET and POST support</td><td>';
117
118if (!isset($_GET["testget"]) && !isset($_POST["testpost"]) && !isset($_GET["mainmenu"])) { // We must keep $_GET and $_POST here. This is a specific test.
119 print img_picto('Warning', 'warning').' '.$langs->trans("PHPSupportPOSTGETKo");
120 print ' (<a href="'.$_SERVER["PHP_SELF"].'?testget=ok">'.$langs->trans("Recheck").'</a>)';
121} else {
122 print img_picto('Ok', 'tick').' '.$langs->trans("PHPSupportPOSTGETOk");
123}
124
125print '</td></tr>';
126print '<tr><td>Sessions support</td><td>';
127if (!function_exists("session_id")) {
128 print img_picto('Error', 'error').' '.$langs->trans("ErrorPHPDoesNotSupportSessions");
129} else {
130 print img_picto('Ok', 'tick').' '.$langs->trans("PHPSupportSessions");
131}
132print '</td></tr>';
133
134print '<tr><td>UTF-8 support</td><td>';
135if (!function_exists("utf8_encode")) {
136 print img_picto('Warning', 'warning').' '.$langs->trans("ErrorPHPDoesNotSupport", "UTF8");
137} else {
138 print img_picto('Ok', 'tick').' '.$langs->trans("PHPSupport", "UTF8");
139}
140print '</td></tr>';
141
142print '</table>';
143
144print '<br>';
145
146$activatedExtensions = array();
147$loadedExtensions = array_map('strtolower', get_loaded_extensions(false));
148
149print '<table class="noborder centpercent">';
150print '<tr class="liste_titre">';
151print '<td class="titlefield">'.$langs->trans("Extension").'</td>';
152print '<td>'.$langs->trans("Test").'</td>';
153print '</tr>';
154
155$functions = ["mb_check_encoding"];
156$name = "MBString";
157
158print "<tr>";
159print "<td>".$name."</td>";
160print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
161print "</tr>";
162
163$functions = ["json_decode"];
164$name = "JSON";
165
166print "<tr>";
167print "<td>".$name."</td>";
168print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
169print "</tr>";
170
171$functions = ["imagecreate"];
172$name = "GD";
173
174print "<tr>";
175print "<td>".$name."</td>";
176print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
177print "</tr>";
178
179$functions = ["curl_init"];
180$name = "Curl";
181
182print "<tr>";
183print "<td>".$name."</td>";
184print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
185print "</tr>";
186
187$functions = ["easter_date"];
188$name = "Calendar";
189
190print "<tr>";
191print "<td>".$name."</td>";
192print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
193print "</tr>";
194
195$functions = ["simplexml_load_string"];
196$name = "Xml";
197
198print "<tr>";
199print "<td>".$name."</td>";
200print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
201print "</tr>";
202
203if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') {
204 $functions = ["locale_get_primary_language", "locale_get_region"];
205 $name = "Intl";
206
207 print "<tr>";
208 print "<td>".$name."</td>";
209 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
210 print "</tr>";
211}
212
213$functions = ["imap_open"];
214$name = "IMAP";
215
216print "<tr>";
217print "<td>".$name."</td>";
218print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
219print "</tr>";
220
221$functions = array();
222$name = "zip";
223
224print "<tr>";
225print "<td>".$name."</td>";
226print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
227print "</tr>";
228
229$functions = array();
230$name = "xDebug";
231
232print "<tr>";
233print "<td>".$name."</td>";
234print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
235print "</tr>";
236
237print '</table>';
238
239print '<br>';
240
241// Get php_info array
242$phparray = phpinfo_array();
243foreach ($phparray as $key => $value) {
244 print '<div class="div-table-responsive-no-min">';
245 print '<table class="noborder">';
246 print '<tr class="liste_titre">';
247 print '<td class="titlefield">'.$key.'</td>';
248 print '<td colspan="2">'.$langs->trans("Value").'</td>';
249 print "</tr>\n";
250
251 //var_dump($value);
252 foreach ($value as $keyparam => $keyvalue) {
253 if (!is_array($keyvalue)) {
254 $keytoshow = $keyparam;
255 $valtoshow = $keyvalue;
256
257 // Hide value of session cookies
258 if (in_array($keyparam, array('HTTP_COOKIE', 'Cookie', "\$_SERVER['HTTP_COOKIE']", 'Authorization'))) {
259 $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
260 }
261 if (preg_match('/'.preg_quote('$_COOKIE[\'DOLSESSID_', '/').'/i', $keyparam)) {
262 $keytoshow = $keyparam;
263 $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
264 }
265 if (preg_match('/'.preg_quote('$_SERVER[\'PHP_AUTH_PW', '/').'/i', $keyparam)) {
266 $keytoshow = $keyparam;
267 $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
268 }
269
270 print '<tr class="oddeven">';
271 print '<td>'.$keytoshow.'</td>';
272 if ($keyparam == 'X-ChromePhp-Data') {
273 $valtoshow = dol_trunc($keyvalue, 80);
274 }
275 print '<td colspan="2" class="wordbreak">';
276 if ($keyparam == 'Path') {
277 $valtoshow = implode('; ', explode(';', trim($valtoshow)));
278 }
279 if ($keyparam == 'PATH') {
280 $valtoshow = implode('; ', explode(';', trim($valtoshow)));
281 }
282 if ($keyparam == '_SERVER["PATH"]') {
283 $valtoshow = implode('; ', explode(';', trim($valtoshow)));
284 }
285 print $valtoshow;
286 print '</td>';
287 print '</tr>';
288 } else {
289 print '<tr class="oddeven">';
290 print '<td class="wordbreak">'.$keyparam.'</td>';
291 $i = 0;
292 foreach ($keyvalue as $keyparam2 => $keyvalue2) {
293 print '<td>';
294 $valtoshow = $keyvalue2;
295 if ($keyparam == 'disable_functions') {
296 $valtoshow = implode(', ', explode(',', trim($valtoshow)));
297 }
298 //print $keyparam;
299 print $valtoshow;
300 $i++;
301 print '</td>';
302 }
303 print '</tr>';
304 }
305 }
306 print '</table>';
307 print '</div>';
308 print '<br>';
309}
310
311// End of page
312llxFooter();
313$db->close();
314
315
325function getResultColumn($name, array $activated, array $loaded, array $functions)
326{
327 global $langs;
328
329 $result = true;
330
331 //$result = $result && in_array(strtolower($name), $activated);
332 $result = $result && in_array(strtolower($name), $loaded);
333
334 foreach ($functions as $function) {
335 $result = $result && function_exists($function);
336 }
337
338 $html = "<td>";
339 if ($result) {
340 if (strtolower($name) == 'xdebug') {
341 $html .= img_warning($langs->trans("ModuleActivated", "xdebug"));
342 } else {
343 $html .= img_picto($langs->trans("Ok"), 'tick');
344 }
345 if (in_array(strtolower($name), $loaded)) {
346 $html .= ' '.$langs->trans("Loaded").' - ';
347 } else {
348 //$html .= ' '.$langs->trans("NotLoaded").' - ';
349 }
350 if (strtolower($name) == 'xdebug') {
351 $html .= ' '.$langs->trans("ModuleActivated", "xdebug");
352 $html .= ' - '.$langs->trans("ModuleActivatedMayExposeInformation");
353 } else {
354 $html .= ' <span class="opacitymedium">'.$langs->trans("PHPSupport", $name).'</span>';
355 }
356 } else {
357 if (strtolower($name) == 'xdebug') {
358 $html .= yn(0).' - ';
359 } else {
360 $html .= img_warning($langs->trans("ModuleActivated", "xdebug"));
361 }
362 if (in_array(strtolower($name), $loaded)) {
363 $html .= ' '.$langs->trans("Loaded").' - ';
364 } else {
365 //$html .= ' '.$langs->trans("NotLoaded").' - ';
366 }
367 $html .= ' '.$langs->trans("ErrorPHPDoesNotSupport", $name);
368 }
369 $html .= "</td>";
370
371 return $html;
372}
getResultColumn($name, array $activated, array $loaded, array $functions)
Return a result column with a translated result text.
Definition phpinfo.php:325
versiontostring($versionarray)
Renvoi une version en chaine depuis une version en tableau.
Definition admin.lib.php:38
versionphparray()
Return version PHP.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
Definition admin.lib.php:68
phpinfo_array()
Return the php_info into an array.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.