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