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", "errors"));
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
100print '<table class="noborder centpercent">';
101print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td></td></tr>';
102
103print '<tr><td>'.$langs->trans("Version").'</td><td>';
104
105$arrayphpminversionerror = array(7, 1, 0);
106$arrayphpminversionwarning = array(7, 1, 0);
107
108if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) {
109 print img_picto('Error', 'error').' '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionerror));
110} elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0) {
111 print img_picto('Warning', 'warning').' '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning));
112} else {
113 print img_picto('Ok', 'tick').' '.versiontostring(versionphparray());
114}
115
116print '</td></tr>';
117print '<tr><td>GET and POST support</td><td>';
118
119if (!isset($_GET["testget"]) && !isset($_POST["testpost"]) && !isset($_GET["mainmenu"])) { // We must keep $_GET and $_POST here. This is a specific test.
120 print img_picto('Warning', 'warning').' '.$langs->trans("PHPSupportPOSTGETKo");
121 print ' (<a href="'.$_SERVER["PHP_SELF"].'?testget=ok">'.$langs->trans("Recheck").'</a>)';
122} else {
123 print img_picto('Ok', 'tick').' '.$langs->trans("PHPSupportPOSTGETOk");
124}
125
126print '</td></tr>';
127print '<tr><td>Sessions support</td><td>';
128if (!function_exists("session_id")) {
129 print img_picto('Error', 'error').' '.$langs->trans("ErrorPHPDoesNotSupportSessions");
130} else {
131 print img_picto('Ok', 'tick').' '.$langs->trans("PHPSupportSessions");
132}
133print '</td></tr>';
134
135print '<tr><td>UTF-8 support</td><td>';
136if (!function_exists("utf8_encode")) {
137 print img_picto('Warning', 'warning').' '.$langs->trans("ErrorPHPDoesNotSupport", "UTF8");
138} else {
139 print img_picto('Ok', 'tick').' '.$langs->trans("PHPSupport", "UTF8");
140}
141print '</td></tr>';
142
143print '</table>';
144
145print '<br>';
146
147$activatedExtensions = array();
148$loadedExtensions = array_map('strtolower', get_loaded_extensions(false));
149
150print '<table class="noborder centpercent">';
151print '<tr class="liste_titre">';
152print '<td class="titlefield">'.$langs->trans("Extension").'</td>';
153print '<td>'.$langs->trans("Test").'</td>';
154print '</tr>';
155
156if ($db->type == 'mysqli') {
157 $functions = ["mysqli_connect"];
158 $name = "MySQLi";
159
160 print "<tr>";
161 print "<td>".$name."</td>";
162 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
163 print "</tr>";
164}
165
166$functions = ["mb_check_encoding"];
167$name = "MBString";
168
169print "<tr>";
170print "<td>".$name."</td>";
171print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
172print "</tr>";
173
174$functions = ["json_decode"];
175$name = "JSON";
176
177print "<tr>";
178print "<td>".$name."</td>";
179print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
180print "</tr>";
181
182$functions = ["imagecreate"];
183$name = "GD";
184
185print "<tr>";
186print "<td>".$name."</td>";
187print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
188print "</tr>";
189
190$functions = ["curl_init"];
191$name = "Curl";
192
193print "<tr>";
194print "<td>".$name."</td>";
195print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
196print "</tr>";
197
198$functions = ["easter_date"];
199$name = "Calendar";
200
201print "<tr>";
202print "<td>".$name."</td>";
203print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
204print "</tr>";
205
206$functions = ["simplexml_load_string"];
207$name = "Xml";
208
209print "<tr>";
210print "<td>".$name."</td>";
211print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
212print "</tr>";
213
214if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') {
215 $functions = ["locale_get_primary_language", "locale_get_region"];
216 $name = "Intl";
217
218 print "<tr>";
219 print "<td>".$name."</td>";
220 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
221 print "</tr>";
222}
223
224$functions = ["imap_open"];
225$name = "IMAP";
226
227print "<tr>";
228print "<td>".$name."</td>";
229print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
230print "</tr>";
231
232$functions = array();
233$name = "zip";
234
235print "<tr>";
236print "<td>".$name."</td>";
237print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
238print "</tr>";
239
240$functions = array();
241$name = "bz2";
242print "<tr>";
243print "<td>".$name."</td>";
244print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions, $langs->trans("Optional"));
245print "</tr>";
246
247// bcmath is used only by swiftmailer for NTLM authentication that is not implemented by Dolibarr core for the moment, so i comment this.
248/*
249$functions = array();
250$name = "bcmath";
251print "<tr>";
252print "<td>".$name."</td>";
253print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions, $langs->trans("Optional").' (NTLM authentication of Swiftmailer)');
254print "</tr>";
255*/
256
257$functions = array();
258$name = "xDebug";
259print "<tr>";
260print "<td>".$name."</td>";
261print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
262print "</tr>";
263
264print '</table>';
265
266print '<br>';
267
268// Get php_info array
269$phparray = phpinfo_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 $html .= ' '.$langs->trans("ErrorPHPDoesNotSupport", $name);
400 if ($optional) {
401 $html .= ' <span class="opacitymedium">'.$optional.'</span>';
402 }
403 }
404 $html .= "</td>";
405
406 return $html;
407}
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:72
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
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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='', $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.