dolibarr 25.0.0-alpha
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 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
29// Load Dolibarr environment
30require '../../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
40
41$langs->loadLangs(array("admin", "install"));
42
43if (!$user->admin) {
45}
46
47
48/*
49 * View
50 */
51
52llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-admin page-system_phpinfo');
53
54$title = 'InfoPHP';
55print load_fiche_titre($langs->trans($title), '', 'title_setup');
56
57
58// Check PHP setup is OK
59$maxphp = @ini_get('upload_max_filesize'); // In unknown
60if (preg_match('/k$/i', $maxphp)) {
61 $maxphp = preg_replace('/k$/i', '', $maxphp);
62 $maxphp *= 1;
63}
64if (preg_match('/m$/i', $maxphp)) {
65 $maxphp = preg_replace('/m$/i', '', $maxphp);
66 $maxphp *= 1024;
67}
68if (preg_match('/g$/i', $maxphp)) {
69 $maxphp = preg_replace('/g$/i', '', $maxphp);
70 $maxphp *= 1024 * 1024;
71}
72if (preg_match('/t$/i', $maxphp)) {
73 $maxphp = preg_replace('/t$/i', '', $maxphp);
74 $maxphp *= 1024 * 1024 * 1024;
75}
76$maxphp2 = @ini_get('post_max_size'); // In unknown
77if (preg_match('/k$/i', $maxphp2)) {
78 $maxphp2 = preg_replace('/k$/i', '', $maxphp2);
79 $maxphp2 *= 1;
80}
81if (preg_match('/m$/i', $maxphp2)) {
82 $maxphp2 = preg_replace('/m$/i', '', $maxphp2);
83 $maxphp2 *= 1024;
84}
85if (preg_match('/g$/i', $maxphp2)) {
86 $maxphp2 = preg_replace('/g$/i', '', $maxphp2);
87 $maxphp2 *= 1024 * 1024;
88}
89if (preg_match('/t$/i', $maxphp2)) {
90 $maxphp2 = preg_replace('/t$/i', '', $maxphp2);
91 $maxphp2 *= 1024 * 1024 * 1024;
92}
93if ($maxphp > 0 && $maxphp2 > 0 && $maxphp > $maxphp2) {
94 $langs->load("errors");
95 print info_admin($langs->trans("WarningParamUploadMaxFileSizeHigherThanPostMaxSize", @ini_get('upload_max_filesize'), @ini_get('post_max_size')), 0, 0, '0', 'warning');
96 print '<br>';
97}
98
99
100// Get php_info array
101$phparray = phpinfo_array();
102
103print '<table class="noborder centpercent">';
104print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Summary").'</td><td></td></tr>';
105
106print '<tr><td>'.$langs->trans("Version").'</td><td>';
107
108$arrayphpminversionerror = array(7, 1, 0);
109$arrayphpminversionwarning = array(7, 1, 0);
110
111if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) {
112 print img_picto('Error', 'error').' '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionerror));
113} elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0) {
114 print img_picto('Warning', 'warning').' '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning));
115} else {
116 print img_picto('Ok', 'tick').' '.versiontostring(versionphparray());
117}
118
119print '</td></tr>';
120print '<tr><td>GET and POST support</td><td>';
121
122if (!isset($_GET["testget"]) && !isset($_POST["testpost"]) && !isset($_GET["mainmenu"])) { // We must keep $_GET and $_POST here. This is a specific test.
123 print img_picto('Warning', 'warning').' '.$langs->trans("PHPSupportPOSTGETKo");
124 print ' (<a href="'.$_SERVER["PHP_SELF"].'?testget=ok">'.$langs->trans("Recheck").'</a>)';
125} else {
126 print img_picto('Ok', 'tick').' '.$langs->trans("PHPSupportPOSTGETOk");
127}
128
129print '</td></tr>';
130print '<tr><td>Sessions support</td><td>';
131if (!function_exists("session_id")) {
132 print img_picto('Error', 'error').' '.$langs->trans("ErrorPHPDoesNotSupportSessions");
133} else {
134 print img_picto('Ok', 'tick').' '.$langs->trans("PHPSupportSessions");
135}
136print '</td></tr>';
137
138foreach (array('Loaded Configuration File', 'Scan this dir for additional .ini files') as $keyparam) {
139 print '<tr><td>'.dolPrintLabel($keyparam).'</td><td>';
140 print dolPrintLabel(empty($phparray['General'][$keyparam]) ? '' : $phparray['General'][$keyparam]);
141 print '</td></tr>';
142}
143
144print '</table>';
145
146print '<br>';
147
148$activatedExtensions = array();
149$loadedExtensions = array_map('strtolower', get_loaded_extensions(false));
150
151print '<table class="noborder centpercent">';
152print '<tr class="liste_titre">';
153print '<td class="titlefield">'.$langs->trans("Extension").'</td>';
154print '<td>'.$langs->trans("Test").'</td>';
155print '</tr>';
156
157if ($db->type == 'mysqli') {
158 $functions = ["mysqli_connect"];
159 $name = "MySQLi";
160
161 print "<tr>";
162 print "<td>".$name."</td>";
163 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
164 print "</tr>";
165}
166
167$functions = ["mb_check_encoding"];
168$name = "MBString";
169
170print "<tr>";
171print "<td>".$name."</td>";
172print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
173print "</tr>";
174
175$functions = ["json_decode"];
176$name = "JSON";
177
178print "<tr>";
179print "<td>".$name."</td>";
180print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
181print "</tr>";
182
183$functions = ["imagecreate"];
184$name = "GD";
185
186print "<tr>";
187print "<td>".$name."</td>";
188print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
189print "</tr>";
190
191$functions = ["curl_init"];
192$name = "Curl";
193
194print "<tr>";
195print "<td>".$name."</td>";
196print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
197print "</tr>";
198
199$functions = ["easter_date"];
200$name = "Calendar";
201
202print "<tr>";
203print "<td>".$name."</td>";
204print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
205print "</tr>";
206
207$functions = ["simplexml_load_string"];
208$name = "Xml";
209
210print "<tr>";
211print "<td>".$name."</td>";
212print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
213print "</tr>";
214
215if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') {
216 $functions = ["locale_get_primary_language", "locale_get_region"];
217 $name = "Intl";
218
219 print "<tr>";
220 print "<td>".$name."</td>";
221 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
222 print "</tr>";
223}
224
225$functions = ["imap_open"];
226$name = "IMAP";
227
228print "<tr>";
229print "<td>".$name."</td>";
230print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
231print "</tr>";
232
233$functions = array();
234$name = "zip";
235
236print "<tr>";
237print "<td>".$name."</td>";
238print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
239print "</tr>";
240
241$functions = array();
242$name = "bz2";
243print "<tr>";
244print "<td>".$name."</td>";
245print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions, $langs->trans("Optional"));
246print "</tr>";
247
248// bcmath is used only by swiftmailer for NTLM authentication that is not implemented by Dolibarr core for the moment, so i comment this.
249/*
250$functions = array();
251$name = "bcmath";
252print "<tr>";
253print "<td>".$name."</td>";
254print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions, $langs->trans("Optional").' (NTLM authentication of Swiftmailer)');
255print "</tr>";
256*/
257
258$functions = array();
259$name = "xDebug";
260print "<tr>";
261print "<td>".$name."</td>";
262print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
263print "</tr>";
264
265print '</table>';
266
267print '<br>';
268
269// Show php_info array
270foreach ($phparray as $key => $value) {
271 print '<div class="div-table-responsive-no-min">';
272 print '<table class="noborder">';
273 print '<tr class="liste_titre">';
274 print '<td class="titlefield">'.$key.'</td>';
275 print '<td colspan="2"></td>';
276 print "</tr>\n";
277
278 //var_dump($value);
279 foreach ($value as $keyparam => $keyvalue) {
280 if (!is_array($keyvalue)) {
281 $keytoshow = $keyparam;
282 $valtoshow = $keyvalue;
283
284 // Hide value of session cookies
285 if (in_array($keyparam, array('HTTP_COOKIE', 'Cookie', "\$_SERVER['HTTP_COOKIE']", 'Authorization'))) {
286 $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
287 }
288 if (preg_match('/'.preg_quote('$_COOKIE[\'DOLSESSID_', '/').'/i', $keyparam)) {
289 $keytoshow = $keyparam;
290 $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
291 }
292 if (preg_match('/'.preg_quote('$_SERVER[\'PHP_AUTH_PW', '/').'/i', $keyparam)) {
293 $keytoshow = $keyparam;
294 $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
295 }
296
297 print '<tr class="oddeven">';
298 print '<td>'.$keytoshow.'</td>';
299 if ($keyparam == 'X-ChromePhp-Data') {
300 $valtoshow = dol_trunc($keyvalue, 80);
301 }
302 print '<td colspan="2" class="wordbreak minwidth100">';
303 if ($keyparam == 'Path') {
304 $valtoshow = implode('; ', explode(';', trim($valtoshow)));
305 }
306 if ($keyparam == 'PATH') {
307 $valtoshow = implode('; ', explode(';', trim($valtoshow)));
308 }
309 if ($keyparam == '_SERVER["PATH"]') {
310 $valtoshow = implode('; ', explode(';', trim($valtoshow)));
311 }
312 print $valtoshow;
313 print '</td>';
314 print '</tr>';
315 } else {
316 print '<tr class="oddeven">';
317 print '<td class="wordbreak">'.$keyparam.'</td>';
318 $i = 0;
319 foreach ($keyvalue as $keyparam2 => $keyvalue2) {
320 print '<td>';
321 $valtoshow = $keyvalue2;
322 if ($keyparam == 'disable_functions') {
323 $valtoshow = implode(', ', explode(',', trim($valtoshow)));
324 }
325 //print $keyparam;
326 print $valtoshow;
327 $i++;
328 print '</td>';
329 }
330 print '</tr>';
331 }
332 }
333 print '</table>';
334 print '</div>';
335 print '<br>';
336}
337
338// End of page
339llxFooter();
340$db->close();
341
342
353function getResultColumn($name, array $activated, array $loaded, array $functions, $optional = '')
354{
355 global $langs;
356
357 $result = true;
358
359 //$result = $result && in_array(strtolower($name), $activated);
360 $result = $result && in_array(strtolower($name), $loaded);
361
362 foreach ($functions as $function) {
363 $result = $result && function_exists($function);
364 }
365
366 $html = "<td>";
367 if ($result) {
368 if (strtolower($name) == 'xdebug') {
369 $html .= img_warning($langs->trans("ModuleActivated", "xdebug"));
370 } else {
371 $html .= img_picto($langs->trans("Ok"), 'tick');
372 }
373 if (in_array(strtolower($name), $loaded)) {
374 $html .= ' '.$langs->trans("Loaded").' - ';
375 } else {
376 //$html .= ' '.$langs->trans("NotLoaded").' - ';
377 }
378 if (strtolower($name) == 'xdebug') {
379 $html .= ' '.$langs->trans("ModuleActivated", "xdebug");
380 $html .= ' - '.$langs->trans("ModuleActivatedMayExposeInformation");
381 } else {
382 $html .= ' <span class="opacitymedium">'.$langs->trans("PHPSupport", $name).'</span>';
383 }
384 } else {
385 if (strtolower($name) == 'xdebug') {
386 $html .= yn(0).' - ';
387 } else {
388 if ($optional) {
389 $html .= img_picto($langs->trans("NotFound"), 'minus');
390 } else {
391 $html .= img_warning($langs->trans("NotFound"));
392 }
393 }
394 if (in_array(strtolower($name), $loaded)) {
395 $html .= ' '.$langs->trans("Loaded").' - ';
396 } else {
397 //$html .= ' '.$langs->trans("NotLoaded").' - ';
398 }
399 $langs->load('errors');
400 $html .= ' '.$langs->trans("ErrorPHPDoesNotSupport", $name);
401 if ($optional) {
402 $html .= ' <span class="opacitymedium">'.$optional.'</span>';
403 }
404 }
405 $html .= "</td>";
406
407 return $html;
408}
getResultColumn($name, array $activated, array $loaded, array $functions, $optional='')
Return a result column with a translated result text.
Definition phpinfo.php:353
versiontostring($versionarray)
Return a version in a string from a version into an array.
Definition admin.lib.php:40
versionphparray()
Return version PHP.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays), to know if a version (a,b,c) is lower than (x,...
Definition admin.lib.php:79
phpinfo_array()
Return the php_info into an array.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
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.