dolibarr 21.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 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
34$langs->loadLangs(array("admin", "install", "errors"));
35
36if (!$user->admin) {
38}
39
40
41/*
42 * View
43 */
44
45llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-admin page-system_phpinfo');
46
47$title = 'InfoPHP';
48
49if (isset($title)) {
50 print load_fiche_titre($langs->trans($title), '', 'title_setup');
51}
52
53
54// Check PHP setup is OK
55$maxphp = @ini_get('upload_max_filesize'); // In unknown
56if (preg_match('/k$/i', $maxphp)) {
57 $maxphp = preg_replace('/k$/i', '', $maxphp);
58 $maxphp *= 1;
59}
60if (preg_match('/m$/i', $maxphp)) {
61 $maxphp = preg_replace('/m$/i', '', $maxphp);
62 $maxphp *= 1024;
63}
64if (preg_match('/g$/i', $maxphp)) {
65 $maxphp = preg_replace('/g$/i', '', $maxphp);
66 $maxphp *= 1024 * 1024;
67}
68if (preg_match('/t$/i', $maxphp)) {
69 $maxphp = preg_replace('/t$/i', '', $maxphp);
70 $maxphp *= 1024 * 1024 * 1024;
71}
72$maxphp2 = @ini_get('post_max_size'); // In unknown
73if (preg_match('/k$/i', $maxphp2)) {
74 $maxphp2 = preg_replace('/k$/i', '', $maxphp2);
75 $maxphp2 *= 1;
76}
77if (preg_match('/m$/i', $maxphp2)) {
78 $maxphp2 = preg_replace('/m$/i', '', $maxphp2);
79 $maxphp2 *= 1024;
80}
81if (preg_match('/g$/i', $maxphp2)) {
82 $maxphp2 = preg_replace('/g$/i', '', $maxphp2);
83 $maxphp2 *= 1024 * 1024;
84}
85if (preg_match('/t$/i', $maxphp2)) {
86 $maxphp2 = preg_replace('/t$/i', '', $maxphp2);
87 $maxphp2 *= 1024 * 1024 * 1024;
88}
89if ($maxphp > 0 && $maxphp2 > 0 && $maxphp > $maxphp2) {
90 $langs->load("errors");
91 print info_admin($langs->trans("WarningParamUploadMaxFileSizeHigherThanPostMaxSize", @ini_get('upload_max_filesize'), @ini_get('post_max_size')), 0, 0, '0', 'warning');
92 print '<br>';
93}
94
95
96print '<table class="noborder centpercent">';
97print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td></td></tr>';
98
99$ErrorPicturePath = "../../theme/eldy/img/error.png";
100$WarningPicturePath = "../../theme/eldy/img/warning.png";
101$OkayPicturePath = "../../theme/eldy/img/tick.png";
102
103print '<tr><td>'.$langs->trans("Version").'</td><td>';
104
105$arrayphpminversionerror = array(5, 5, 0);
106$arrayphpminversionwarning = array(5, 6, 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
156$functions = ["mb_check_encoding"];
157$name = "MBString";
158
159print "<tr>";
160print "<td>".$name."</td>";
161print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
162print "</tr>";
163
164$functions = ["json_decode"];
165$name = "JSON";
166
167print "<tr>";
168print "<td>".$name."</td>";
169print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
170print "</tr>";
171
172$functions = ["imagecreate"];
173$name = "GD";
174
175print "<tr>";
176print "<td>".$name."</td>";
177print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
178print "</tr>";
179
180$functions = ["curl_init"];
181$name = "Curl";
182
183print "<tr>";
184print "<td>".$name."</td>";
185print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
186print "</tr>";
187
188$functions = ["easter_date"];
189$name = "Calendar";
190
191print "<tr>";
192print "<td>".$name."</td>";
193print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
194print "</tr>";
195
196$functions = ["simplexml_load_string"];
197$name = "Xml";
198
199print "<tr>";
200print "<td>".$name."</td>";
201print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
202print "</tr>";
203
204if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') {
205 $functions = ["locale_get_primary_language", "locale_get_region"];
206 $name = "Intl";
207
208 print "<tr>";
209 print "<td>".$name."</td>";
210 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
211 print "</tr>";
212}
213
214$functions = ["imap_open"];
215$name = "IMAP";
216
217print "<tr>";
218print "<td>".$name."</td>";
219print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
220print "</tr>";
221
222$functions = array();
223$name = "zip";
224
225print "<tr>";
226print "<td>".$name."</td>";
227print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
228print "</tr>";
229
230$functions = array();
231$name = "xDebug";
232
233print "<tr>";
234print "<td>".$name."</td>";
235print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
236print "</tr>";
237
238print '</table>';
239
240print '<br>';
241
242// Get php_info array
243$phparray = phpinfo_array();
244foreach ($phparray as $key => $value) {
245 print '<div class="div-table-responsive-no-min">';
246 print '<table class="noborder">';
247 print '<tr class="liste_titre">';
248 print '<td class="titlefield">'.$key.'</td>';
249 print '<td colspan="2"></td>';
250 print "</tr>\n";
251
252 //var_dump($value);
253 foreach ($value as $keyparam => $keyvalue) {
254 if (!is_array($keyvalue)) {
255 $keytoshow = $keyparam;
256 $valtoshow = $keyvalue;
257
258 // Hide value of session cookies
259 if (in_array($keyparam, array('HTTP_COOKIE', 'Cookie', "\$_SERVER['HTTP_COOKIE']", 'Authorization'))) {
260 $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
261 }
262 if (preg_match('/'.preg_quote('$_COOKIE[\'DOLSESSID_', '/').'/i', $keyparam)) {
263 $keytoshow = $keyparam;
264 $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
265 }
266 if (preg_match('/'.preg_quote('$_SERVER[\'PHP_AUTH_PW', '/').'/i', $keyparam)) {
267 $keytoshow = $keyparam;
268 $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
269 }
270
271 print '<tr class="oddeven">';
272 print '<td>'.$keytoshow.'</td>';
273 if ($keyparam == 'X-ChromePhp-Data') {
274 $valtoshow = dol_trunc($keyvalue, 80);
275 }
276 print '<td colspan="2" class="wordbreak">';
277 if ($keyparam == 'Path') {
278 $valtoshow = implode('; ', explode(';', trim($valtoshow)));
279 }
280 if ($keyparam == 'PATH') {
281 $valtoshow = implode('; ', explode(';', trim($valtoshow)));
282 }
283 if ($keyparam == '_SERVER["PATH"]') {
284 $valtoshow = implode('; ', explode(';', trim($valtoshow)));
285 }
286 print $valtoshow;
287 print '</td>';
288 print '</tr>';
289 } else {
290 print '<tr class="oddeven">';
291 print '<td class="wordbreak">'.$keyparam.'</td>';
292 $i = 0;
293 foreach ($keyvalue as $keyparam2 => $keyvalue2) {
294 print '<td>';
295 $valtoshow = $keyvalue2;
296 if ($keyparam == 'disable_functions') {
297 $valtoshow = implode(', ', explode(',', trim($valtoshow)));
298 }
299 //print $keyparam;
300 print $valtoshow;
301 $i++;
302 print '</td>';
303 }
304 print '</tr>';
305 }
306 }
307 print '</table>';
308 print '</div>';
309 print '<br>';
310}
311
312// End of page
313llxFooter();
314$db->close();
315
316
326function getResultColumn($name, array $activated, array $loaded, array $functions)
327{
328 global $langs;
329
330 $result = true;
331
332 //$result = $result && in_array(strtolower($name), $activated);
333 $result = $result && in_array(strtolower($name), $loaded);
334
335 foreach ($functions as $function) {
336 $result = $result && function_exists($function);
337 }
338
339 $html = "<td>";
340 if ($result) {
341 if (strtolower($name) == 'xdebug') {
342 $html .= img_warning($langs->trans("ModuleActivated", "xdebug"));
343 } else {
344 $html .= img_picto($langs->trans("Ok"), 'tick');
345 }
346 if (in_array(strtolower($name), $loaded)) {
347 $html .= ' '.$langs->trans("Loaded").' - ';
348 } else {
349 //$html .= ' '.$langs->trans("NotLoaded").' - ';
350 }
351 if (strtolower($name) == 'xdebug') {
352 $html .= ' '.$langs->trans("ModuleActivated", "xdebug");
353 $html .= ' - '.$langs->trans("ModuleActivatedMayExposeInformation");
354 } else {
355 $html .= ' <span class="opacitymedium">'.$langs->trans("PHPSupport", $name).'</span>';
356 }
357 } else {
358 if (strtolower($name) == 'xdebug') {
359 $html .= yn(0).' - ';
360 } else {
361 $html .= img_warning($langs->trans("ModuleActivated", "xdebug"));
362 }
363 if (in_array(strtolower($name), $loaded)) {
364 $html .= ' '.$langs->trans("Loaded").' - ';
365 } else {
366 //$html .= ' '.$langs->trans("NotLoaded").' - ';
367 }
368 $html .= ' '.$langs->trans("ErrorPHPDoesNotSupport", $name);
369 }
370 $html .= "</td>";
371
372 return $html;
373}
getResultColumn($name, array $activated, array $loaded, array $functions)
Return a result column with a translated result text.
Definition phpinfo.php:326
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:70
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.