dolibarr 24.0.0-beta
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';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
33
42$langs->loadLangs(array("admin", "install", "errors"));
43
44if (!$user->admin) {
46}
47
48
49/*
50 * View
51 */
52
53llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-admin page-system_phpinfo');
54
55$title = 'InfoPHP';
56print load_fiche_titre($langs->trans($title), '', 'title_setup');
57
58
59// Check PHP setup is OK
60$maxphp = @ini_get('upload_max_filesize'); // In unknown
61if (preg_match('/k$/i', $maxphp)) {
62 $maxphp = preg_replace('/k$/i', '', $maxphp);
63 $maxphp *= 1;
64}
65if (preg_match('/m$/i', $maxphp)) {
66 $maxphp = preg_replace('/m$/i', '', $maxphp);
67 $maxphp *= 1024;
68}
69if (preg_match('/g$/i', $maxphp)) {
70 $maxphp = preg_replace('/g$/i', '', $maxphp);
71 $maxphp *= 1024 * 1024;
72}
73if (preg_match('/t$/i', $maxphp)) {
74 $maxphp = preg_replace('/t$/i', '', $maxphp);
75 $maxphp *= 1024 * 1024 * 1024;
76}
77$maxphp2 = @ini_get('post_max_size'); // In unknown
78if (preg_match('/k$/i', $maxphp2)) {
79 $maxphp2 = preg_replace('/k$/i', '', $maxphp2);
80 $maxphp2 *= 1;
81}
82if (preg_match('/m$/i', $maxphp2)) {
83 $maxphp2 = preg_replace('/m$/i', '', $maxphp2);
84 $maxphp2 *= 1024;
85}
86if (preg_match('/g$/i', $maxphp2)) {
87 $maxphp2 = preg_replace('/g$/i', '', $maxphp2);
88 $maxphp2 *= 1024 * 1024;
89}
90if (preg_match('/t$/i', $maxphp2)) {
91 $maxphp2 = preg_replace('/t$/i', '', $maxphp2);
92 $maxphp2 *= 1024 * 1024 * 1024;
93}
94if ($maxphp > 0 && $maxphp2 > 0 && $maxphp > $maxphp2) {
95 $langs->load("errors");
96 print info_admin($langs->trans("WarningParamUploadMaxFileSizeHigherThanPostMaxSize", @ini_get('upload_max_filesize'), @ini_get('post_max_size')), 0, 0, '0', 'warning');
97 print '<br>';
98}
99
100
101print '<table class="noborder centpercent">';
102print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td></td></tr>';
103
104print '<tr><td>'.$langs->trans("Version").'</td><td>';
105
106$arrayphpminversionerror = array(7, 1, 0);
107$arrayphpminversionwarning = array(7, 1, 0);
108
109if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) {
110 print img_picto('Error', 'error').' '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionerror));
111} elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0) {
112 print img_picto('Warning', 'warning').' '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning));
113} else {
114 print img_picto('Ok', 'tick').' '.versiontostring(versionphparray());
115}
116
117print '</td></tr>';
118print '<tr><td>GET and POST support</td><td>';
119
120if (!isset($_GET["testget"]) && !isset($_POST["testpost"]) && !isset($_GET["mainmenu"])) { // We must keep $_GET and $_POST here. This is a specific test.
121 print img_picto('Warning', 'warning').' '.$langs->trans("PHPSupportPOSTGETKo");
122 print ' (<a href="'.$_SERVER["PHP_SELF"].'?testget=ok">'.$langs->trans("Recheck").'</a>)';
123} else {
124 print img_picto('Ok', 'tick').' '.$langs->trans("PHPSupportPOSTGETOk");
125}
126
127print '</td></tr>';
128print '<tr><td>Sessions support</td><td>';
129if (!function_exists("session_id")) {
130 print img_picto('Error', 'error').' '.$langs->trans("ErrorPHPDoesNotSupportSessions");
131} else {
132 print img_picto('Ok', 'tick').' '.$langs->trans("PHPSupportSessions");
133}
134print '</td></tr>';
135
136print '<tr><td>UTF-8 support</td><td>';
137if (!function_exists("utf8_encode")) {
138 print img_picto('Warning', 'warning').' '.$langs->trans("ErrorPHPDoesNotSupport", "UTF8");
139} else {
140 print img_picto('Ok', 'tick').' '.$langs->trans("PHPSupport", "UTF8");
141}
142print '</td></tr>';
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
157$functions = ["mb_check_encoding"];
158$name = "MBString";
159
160print "<tr>";
161print "<td>".$name."</td>";
162print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
163print "</tr>";
164
165$functions = ["json_decode"];
166$name = "JSON";
167
168print "<tr>";
169print "<td>".$name."</td>";
170print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
171print "</tr>";
172
173$functions = ["imagecreate"];
174$name = "GD";
175
176print "<tr>";
177print "<td>".$name."</td>";
178print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
179print "</tr>";
180
181$functions = ["curl_init"];
182$name = "Curl";
183
184print "<tr>";
185print "<td>".$name."</td>";
186print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
187print "</tr>";
188
189$functions = ["easter_date"];
190$name = "Calendar";
191
192print "<tr>";
193print "<td>".$name."</td>";
194print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
195print "</tr>";
196
197$functions = ["simplexml_load_string"];
198$name = "Xml";
199
200print "<tr>";
201print "<td>".$name."</td>";
202print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
203print "</tr>";
204
205if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') {
206 $functions = ["locale_get_primary_language", "locale_get_region"];
207 $name = "Intl";
208
209 print "<tr>";
210 print "<td>".$name."</td>";
211 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
212 print "</tr>";
213}
214
215$functions = ["imap_open"];
216$name = "IMAP";
217
218print "<tr>";
219print "<td>".$name."</td>";
220print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
221print "</tr>";
222
223$functions = array();
224$name = "zip";
225
226print "<tr>";
227print "<td>".$name."</td>";
228print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
229print "</tr>";
230
231$functions = array();
232$name = "bz2";
233print "<tr>";
234print "<td>".$name."</td>";
235print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions, $langs->trans("Optional"));
236print "</tr>";
237
238// bcmath is used only by swiftmailer for NTLM authentication that is not implemented by Dolibarr core for the moment, so i comment this.
239/*
240$functions = array();
241$name = "bcmath";
242print "<tr>";
243print "<td>".$name."</td>";
244print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions, $langs->trans("Optional").' (NTLM authentication of Swiftmailer)');
245print "</tr>";
246*/
247
248$functions = array();
249$name = "xDebug";
250print "<tr>";
251print "<td>".$name."</td>";
252print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
253print "</tr>";
254
255print '</table>';
256
257print '<br>';
258
259// Get php_info array
260$phparray = phpinfo_array();
261foreach ($phparray as $key => $value) {
262 print '<div class="div-table-responsive-no-min">';
263 print '<table class="noborder">';
264 print '<tr class="liste_titre">';
265 print '<td class="titlefield">'.$key.'</td>';
266 print '<td colspan="2"></td>';
267 print "</tr>\n";
268
269 //var_dump($value);
270 foreach ($value as $keyparam => $keyvalue) {
271 if (!is_array($keyvalue)) {
272 $keytoshow = $keyparam;
273 $valtoshow = $keyvalue;
274
275 // Hide value of session cookies
276 if (in_array($keyparam, array('HTTP_COOKIE', 'Cookie', "\$_SERVER['HTTP_COOKIE']", 'Authorization'))) {
277 $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
278 }
279 if (preg_match('/'.preg_quote('$_COOKIE[\'DOLSESSID_', '/').'/i', $keyparam)) {
280 $keytoshow = $keyparam;
281 $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
282 }
283 if (preg_match('/'.preg_quote('$_SERVER[\'PHP_AUTH_PW', '/').'/i', $keyparam)) {
284 $keytoshow = $keyparam;
285 $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
286 }
287
288 print '<tr class="oddeven">';
289 print '<td>'.$keytoshow.'</td>';
290 if ($keyparam == 'X-ChromePhp-Data') {
291 $valtoshow = dol_trunc($keyvalue, 80);
292 }
293 print '<td colspan="2" class="wordbreak minwidth100">';
294 if ($keyparam == 'Path') {
295 $valtoshow = implode('; ', explode(';', trim($valtoshow)));
296 }
297 if ($keyparam == 'PATH') {
298 $valtoshow = implode('; ', explode(';', trim($valtoshow)));
299 }
300 if ($keyparam == '_SERVER["PATH"]') {
301 $valtoshow = implode('; ', explode(';', trim($valtoshow)));
302 }
303 print $valtoshow;
304 print '</td>';
305 print '</tr>';
306 } else {
307 print '<tr class="oddeven">';
308 print '<td class="wordbreak">'.$keyparam.'</td>';
309 $i = 0;
310 foreach ($keyvalue as $keyparam2 => $keyvalue2) {
311 print '<td>';
312 $valtoshow = $keyvalue2;
313 if ($keyparam == 'disable_functions') {
314 $valtoshow = implode(', ', explode(',', trim($valtoshow)));
315 }
316 //print $keyparam;
317 print $valtoshow;
318 $i++;
319 print '</td>';
320 }
321 print '</tr>';
322 }
323 }
324 print '</table>';
325 print '</div>';
326 print '<br>';
327}
328
329// End of page
330llxFooter();
331$db->close();
332
333
344function getResultColumn($name, array $activated, array $loaded, array $functions, $optional = '')
345{
346 global $langs;
347
348 $result = true;
349
350 //$result = $result && in_array(strtolower($name), $activated);
351 $result = $result && in_array(strtolower($name), $loaded);
352
353 foreach ($functions as $function) {
354 $result = $result && function_exists($function);
355 }
356
357 $html = "<td>";
358 if ($result) {
359 if (strtolower($name) == 'xdebug') {
360 $html .= img_warning($langs->trans("ModuleActivated", "xdebug"));
361 } else {
362 $html .= img_picto($langs->trans("Ok"), 'tick');
363 }
364 if (in_array(strtolower($name), $loaded)) {
365 $html .= ' '.$langs->trans("Loaded").' - ';
366 } else {
367 //$html .= ' '.$langs->trans("NotLoaded").' - ';
368 }
369 if (strtolower($name) == 'xdebug') {
370 $html .= ' '.$langs->trans("ModuleActivated", "xdebug");
371 $html .= ' - '.$langs->trans("ModuleActivatedMayExposeInformation");
372 } else {
373 $html .= ' <span class="opacitymedium">'.$langs->trans("PHPSupport", $name).'</span>';
374 }
375 } else {
376 if (strtolower($name) == 'xdebug') {
377 $html .= yn(0).' - ';
378 } else {
379 if ($optional) {
380 $html .= img_picto($langs->trans("NotFound"), 'minus');
381 } else {
382 $html .= img_warning($langs->trans("NotFound"));
383 }
384 }
385 if (in_array(strtolower($name), $loaded)) {
386 $html .= ' '.$langs->trans("Loaded").' - ';
387 } else {
388 //$html .= ' '.$langs->trans("NotLoaded").' - ';
389 }
390 $html .= ' '.$langs->trans("ErrorPHPDoesNotSupport", $name);
391 if ($optional) {
392 $html .= ' <span class="opacitymedium">'.$optional.'</span>';
393 }
394 }
395 $html .= "</td>";
396
397 return $html;
398}
getResultColumn($name, array $activated, array $loaded, array $functions, $optional='')
Return a result column with a translated result text.
Definition phpinfo.php:344
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.