dolibarr 21.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 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
107$ErrorPicturePath = "../../theme/eldy/img/error.png";
108$WarningPicturePath = "../../theme/eldy/img/warning.png";
109$OkayPicturePath = "../../theme/eldy/img/tick.png";
110
111print '<tr><td>'.$langs->trans("Version").'</td><td>';
112
113$arrayphpminversionerror = array(5, 5, 0);
114$arrayphpminversionwarning = array(5, 6, 0);
115
116if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) {
117 print img_picto('Error', 'error').' '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionerror));
118} elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0) {
119 print img_picto('Warning', 'warning').' '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning));
120} else {
121 print img_picto('Ok', 'tick').' '.versiontostring(versionphparray());
122}
123
124print '</td></tr>';
125print '<tr><td>GET and POST support</td><td>';
126
127if (!isset($_GET["testget"]) && !isset($_POST["testpost"]) && !isset($_GET["mainmenu"])) { // We must keep $_GET and $_POST here. This is a specific test.
128 print img_picto('Warning', 'warning').' '.$langs->trans("PHPSupportPOSTGETKo");
129 print ' (<a href="'.$_SERVER["PHP_SELF"].'?testget=ok">'.$langs->trans("Recheck").'</a>)';
130} else {
131 print img_picto('Ok', 'tick').' '.$langs->trans("PHPSupportPOSTGETOk");
132}
133
134print '</td></tr>';
135print '<tr><td>Sessions support</td><td>';
136if (!function_exists("session_id")) {
137 print img_picto('Error', 'error').' '.$langs->trans("ErrorPHPDoesNotSupportSessions");
138} else {
139 print img_picto('Ok', 'tick').' '.$langs->trans("PHPSupportSessions");
140}
141print '</td></tr>';
142
143print '<tr><td>UTF-8 support</td><td>';
144if (!function_exists("utf8_encode")) {
145 print img_picto('Warning', 'warning').' '.$langs->trans("ErrorPHPDoesNotSupport", "UTF8");
146} else {
147 print img_picto('Ok', 'tick').' '.$langs->trans("PHPSupport", "UTF8");
148}
149print '</td></tr>';
150
151print '</table>';
152
153print '<br>';
154
155$activatedExtensions = array();
156$loadedExtensions = array_map('strtolower', get_loaded_extensions(false));
157
158print '<table class="noborder centpercent">';
159print '<tr class="liste_titre">';
160print '<td class="titlefield">'.$langs->trans("Extension").'</td>';
161print '<td>'.$langs->trans("Test").'</td>';
162print '</tr>';
163
164$functions = ["mb_check_encoding"];
165$name = "MBString";
166
167print "<tr>";
168print "<td>".$name."</td>";
169print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
170print "</tr>";
171
172$functions = ["json_decode"];
173$name = "JSON";
174
175print "<tr>";
176print "<td>".$name."</td>";
177print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
178print "</tr>";
179
180$functions = ["imagecreate"];
181$name = "GD";
182
183print "<tr>";
184print "<td>".$name."</td>";
185print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
186print "</tr>";
187
188$functions = ["curl_init"];
189$name = "Curl";
190
191print "<tr>";
192print "<td>".$name."</td>";
193print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
194print "</tr>";
195
196$functions = ["easter_date"];
197$name = "Calendar";
198
199print "<tr>";
200print "<td>".$name."</td>";
201print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
202print "</tr>";
203
204$functions = ["simplexml_load_string"];
205$name = "Xml";
206
207print "<tr>";
208print "<td>".$name."</td>";
209print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
210print "</tr>";
211
212if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') {
213 $functions = ["locale_get_primary_language", "locale_get_region"];
214 $name = "Intl";
215
216 print "<tr>";
217 print "<td>".$name."</td>";
218 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
219 print "</tr>";
220}
221
222$functions = ["imap_open"];
223$name = "IMAP";
224
225print "<tr>";
226print "<td>".$name."</td>";
227print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
228print "</tr>";
229
230$functions = array();
231$name = "zip";
232
233print "<tr>";
234print "<td>".$name."</td>";
235print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
236print "</tr>";
237
238$functions = array();
239$name = "xDebug";
240
241print "<tr>";
242print "<td>".$name."</td>";
243print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
244print "</tr>";
245
246print '</table>';
247
248print '<br>';
249
250// Get php_info array
251$phparray = phpinfo_array();
252foreach ($phparray as $key => $value) {
253 print '<div class="div-table-responsive-no-min">';
254 print '<table class="noborder">';
255 print '<tr class="liste_titre">';
256 print '<td class="titlefield">'.$key.'</td>';
257 print '<td colspan="2"></td>';
258 print "</tr>\n";
259
260 //var_dump($value);
261 foreach ($value as $keyparam => $keyvalue) {
262 if (!is_array($keyvalue)) {
263 $keytoshow = $keyparam;
264 $valtoshow = $keyvalue;
265
266 // Hide value of session cookies
267 if (in_array($keyparam, array('HTTP_COOKIE', 'Cookie', "\$_SERVER['HTTP_COOKIE']", 'Authorization'))) {
268 $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
269 }
270 if (preg_match('/'.preg_quote('$_COOKIE[\'DOLSESSID_', '/').'/i', $keyparam)) {
271 $keytoshow = $keyparam;
272 $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
273 }
274 if (preg_match('/'.preg_quote('$_SERVER[\'PHP_AUTH_PW', '/').'/i', $keyparam)) {
275 $keytoshow = $keyparam;
276 $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
277 }
278
279 print '<tr class="oddeven">';
280 print '<td>'.$keytoshow.'</td>';
281 if ($keyparam == 'X-ChromePhp-Data') {
282 $valtoshow = dol_trunc($keyvalue, 80);
283 }
284 print '<td colspan="2" class="wordbreak">';
285 if ($keyparam == 'Path') {
286 $valtoshow = implode('; ', explode(';', trim($valtoshow)));
287 }
288 if ($keyparam == 'PATH') {
289 $valtoshow = implode('; ', explode(';', trim($valtoshow)));
290 }
291 if ($keyparam == '_SERVER["PATH"]') {
292 $valtoshow = implode('; ', explode(';', trim($valtoshow)));
293 }
294 print $valtoshow;
295 print '</td>';
296 print '</tr>';
297 } else {
298 print '<tr class="oddeven">';
299 print '<td class="wordbreak">'.$keyparam.'</td>';
300 $i = 0;
301 foreach ($keyvalue as $keyparam2 => $keyvalue2) {
302 print '<td>';
303 $valtoshow = $keyvalue2;
304 if ($keyparam == 'disable_functions') {
305 $valtoshow = implode(', ', explode(',', trim($valtoshow)));
306 }
307 //print $keyparam;
308 print $valtoshow;
309 $i++;
310 print '</td>';
311 }
312 print '</tr>';
313 }
314 }
315 print '</table>';
316 print '</div>';
317 print '<br>';
318}
319
320// End of page
321llxFooter();
322$db->close();
323
324
334function getResultColumn($name, array $activated, array $loaded, array $functions)
335{
336 global $langs;
337
338 $result = true;
339
340 //$result = $result && in_array(strtolower($name), $activated);
341 $result = $result && in_array(strtolower($name), $loaded);
342
343 foreach ($functions as $function) {
344 $result = $result && function_exists($function);
345 }
346
347 $html = "<td>";
348 if ($result) {
349 if (strtolower($name) == 'xdebug') {
350 $html .= img_warning($langs->trans("ModuleActivated", "xdebug"));
351 } else {
352 $html .= img_picto($langs->trans("Ok"), 'tick');
353 }
354 if (in_array(strtolower($name), $loaded)) {
355 $html .= ' '.$langs->trans("Loaded").' - ';
356 } else {
357 //$html .= ' '.$langs->trans("NotLoaded").' - ';
358 }
359 if (strtolower($name) == 'xdebug') {
360 $html .= ' '.$langs->trans("ModuleActivated", "xdebug");
361 $html .= ' - '.$langs->trans("ModuleActivatedMayExposeInformation");
362 } else {
363 $html .= ' <span class="opacitymedium">'.$langs->trans("PHPSupport", $name).'</span>';
364 }
365 } else {
366 if (strtolower($name) == 'xdebug') {
367 $html .= yn(0).' - ';
368 } else {
369 $html .= img_warning($langs->trans("ModuleActivated", "xdebug"));
370 }
371 if (in_array(strtolower($name), $loaded)) {
372 $html .= ' '.$langs->trans("Loaded").' - ';
373 } else {
374 //$html .= ' '.$langs->trans("NotLoaded").' - ';
375 }
376 $html .= ' '.$langs->trans("ErrorPHPDoesNotSupport", $name);
377 }
378 $html .= "</td>";
379
380 return $html;
381}
getResultColumn($name, array $activated, array $loaded, array $functions)
Return a result column with a translated result text.
Definition phpinfo.php:334
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).
Definition admin.lib.php:69
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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
llxFooter()
Footer empty.
Definition document.php:107
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, $format=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.