dolibarr  16.0.5
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  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
27 require '../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
30 
31 $langs->loadLangs(array("admin", "install", "errors"));
32 
33 if (!$user->admin) {
35 }
36 
37 
38 
39 /*
40  * View
41  */
42 
43 llxHeader();
44 
45 $title = 'InfoPHP';
46 
47 if (isset($title)) {
48  print load_fiche_titre($langs->trans($title), '', 'title_setup');
49 }
50 
51 
52 // Check PHP setup is OK
53 $maxphp = @ini_get('upload_max_filesize'); // In unknown
54 if (preg_match('/k$/i', $maxphp)) {
55  $maxphp = preg_replace('/k$/i', '', $maxphp);
56  $maxphp = $maxphp * 1;
57 }
58 if (preg_match('/m$/i', $maxphp)) {
59  $maxphp = preg_replace('/m$/i', '', $maxphp);
60  $maxphp = $maxphp * 1024;
61 }
62 if (preg_match('/g$/i', $maxphp)) {
63  $maxphp = preg_replace('/g$/i', '', $maxphp);
64  $maxphp = $maxphp * 1024 * 1024;
65 }
66 if (preg_match('/t$/i', $maxphp)) {
67  $maxphp = preg_replace('/t$/i', '', $maxphp);
68  $maxphp = $maxphp * 1024 * 1024 * 1024;
69 }
70 $maxphp2 = @ini_get('post_max_size'); // In unknown
71 if (preg_match('/k$/i', $maxphp2)) {
72  $maxphp2 = preg_replace('/k$/i', '', $maxphp2);
73  $maxphp2 = $maxphp2 * 1;
74 }
75 if (preg_match('/m$/i', $maxphp2)) {
76  $maxphp2 = preg_replace('/m$/i', '', $maxphp2);
77  $maxphp2 = $maxphp2 * 1024;
78 }
79 if (preg_match('/g$/i', $maxphp2)) {
80  $maxphp2 = preg_replace('/g$/i', '', $maxphp2);
81  $maxphp2 = $maxphp2 * 1024 * 1024;
82 }
83 if (preg_match('/t$/i', $maxphp2)) {
84  $maxphp2 = preg_replace('/t$/i', '', $maxphp2);
85  $maxphp2 = $maxphp2 * 1024 * 1024 * 1024;
86 }
87 if ($maxphp > 0 && $maxphp2 > 0 && $maxphp > $maxphp2) {
88  $langs->load("errors");
89  print info_admin($langs->trans("WarningParamUploadMaxFileSizeHigherThanPostMaxSize", @ini_get('upload_max_filesize'), @ini_get('post_max_size')), 0, 0, 0, 'warning');
90  print '<br>';
91 }
92 
93 
94 print '<table class="noborder centpercent">';
95 print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
96 
97 $ErrorPicturePath = "../../theme/eldy/img/error.png";
98 $WarningPicturePath = "../../theme/eldy/img/warning.png";
99 $OkayPicturePath = "../../theme/eldy/img/tick.png";
100 
101 print '<tr><td>'.$langs->trans("Version").'</td><td>';
102 
103 $arrayphpminversionerror = array(5, 5, 0);
104 $arrayphpminversionwarning = array(5, 6, 0);
105 
106 if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) {
107  print '<img src="'.$ErrorPicturePath.'" alt="Error"> '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionerror));
108 } elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0) {
109  print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning));
110 } else {
111  print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.versiontostring(versionphparray());
112 }
113 
114 print '</td></tr>';
115 print '<tr><td>GET and POST support</td><td>';
116 
117 if (!isset($_GET["testget"]) && !isset($_POST["testpost"]) && !isset($_GET["mainmenu"])) { // We must keep $_GET and $_POST here
118  print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("PHPSupportPOSTGETKo");
119  print ' (<a href="'.$_SERVER["PHP_SELF"].'?testget=ok">'.$langs->trans("Recheck").'</a>)';
120 } else {
121  print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupportPOSTGETOk");
122 }
123 
124 print '</td></tr>';
125 print '<tr><td>Sessions support</td><td>';
126 if (!function_exists("session_id")) {
127  print '<img src="'.$ErrorPicturePath.'" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportSessions");
128 } else {
129  print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupportSessions");
130 }
131 print '</td></tr>';
132 
133 print '<tr><td>UTF-8 support</td><td>';
134 if (!function_exists("utf8_encode")) {
135  print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("ErrorPHPDoesNotSupport", "UTF8");
136 } else {
137  print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupport", "UTF8");
138 }
139 print '</td></tr>';
140 
141 print '</table>';
142 
143 print '<br>';
144 
145 $activatedExtensions = array();
146 $loadedExtensions = array_map('strtolower', get_loaded_extensions(false));
147 
148 print '<table class="noborder centpercent">';
149 print '<tr class="liste_titre">';
150 print '<td class="titlefield">'.$langs->trans("Extension").'</td>';
151 print '<td>'.$langs->trans("Test").'</td>';
152 print '</tr>';
153 
154 $functions = ["mb_check_encoding"];
155 $name = "MBString";
156 
157 print "<tr>";
158 print "<td>".$name."</td>";
159 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
160 print "</tr>";
161 
162 $functions = ["json_decode"];
163 $name = "JSON";
164 
165 print "<tr>";
166 print "<td>".$name."</td>";
167 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
168 print "</tr>";
169 
170 $functions = ["imagecreate"];
171 $name = "GD";
172 
173 print "<tr>";
174 print "<td>".$name."</td>";
175 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
176 print "</tr>";
177 
178 $functions = ["curl_init"];
179 $name = "Curl";
180 
181 print "<tr>";
182 print "<td>".$name."</td>";
183 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
184 print "</tr>";
185 
186 $functions = ["easter_date"];
187 $name = "Calendar";
188 
189 print "<tr>";
190 print "<td>".$name."</td>";
191 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
192 print "</tr>";
193 
194 $functions = ["simplexml_load_string"];
195 $name = "Xml";
196 
197 print "<tr>";
198 print "<td>".$name."</td>";
199 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
200 print "</tr>";
201 
202 if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') {
203  $functions = ["locale_get_primary_language", "locale_get_region"];
204  $name = "Intl";
205 
206  print "<tr>";
207  print "<td>".$name."</td>";
208  print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
209  print "</tr>";
210 }
211 
212 $functions = ["imap_open"];
213 $name = "IMAP";
214 
215 print "<tr>";
216 print "<td>".$name."</td>";
217 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
218 print "</tr>";
219 
220 $functions = array();
221 $name = "xDebug";
222 
223 print "<tr>";
224 print "<td>".$name."</td>";
225 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
226 print "</tr>";
227 
228 print '</table>';
229 
230 print '<br>';
231 
232 // Get php_info array
233 $phparray = phpinfo_array();
234 foreach ($phparray as $key => $value) {
235  print '<div class="div-table-responsive-no-min">';
236  print '<table class="noborder">';
237  print '<tr class="liste_titre">';
238  print '<td class="titlefield">'.$key.'</td>';
239  print '<td colspan="2">'.$langs->trans("Value").'</td>';
240  print "</tr>\n";
241 
242  //var_dump($value);
243  foreach ($value as $keyparam => $keyvalue) {
244  if (!is_array($keyvalue)) {
245  print '<tr class="oddeven">';
246  print '<td>'.$keyparam.'</td>';
247  $valtoshow = $keyvalue;
248  if ($keyparam == 'X-ChromePhp-Data') {
249  $valtoshow = dol_trunc($keyvalue, 80);
250  }
251  print '<td colspan="2" class="wordbreak">';
252  if ($keyparam == 'Path') {
253  $valtoshow = implode('; ', explode(';', trim($valtoshow)));
254  }
255  if ($keyparam == 'PATH') {
256  $valtoshow = implode('; ', explode(';', trim($valtoshow)));
257  }
258  if ($keyparam == '_SERVER["PATH"]') {
259  $valtoshow = implode('; ', explode(';', trim($valtoshow)));
260  }
261  print $valtoshow;
262  print '</td>';
263  print '</tr>';
264  } else {
265  print '<tr class="oddeven">';
266  print '<td class="wordbreak">'.$keyparam.'</td>';
267  $i = 0;
268  foreach ($keyvalue as $keyparam2 => $keyvalue2) {
269  print '<td>';
270  $valtoshow = $keyvalue2;
271  if ($keyparam == 'disable_functions') {
272  $valtoshow = implode(', ', explode(',', trim($valtoshow)));
273  }
274  //print $keyparam;
275  print $valtoshow;
276  $i++;
277  print '</td>';
278  }
279  print '</tr>';
280  }
281  }
282  print '</table>';
283  print '</div>';
284  print '<br>';
285 }
286 
287 // End of page
288 llxFooter();
289 $db->close();
290 
291 
301 function getResultColumn($name, array $activated, array $loaded, array $functions)
302 {
303  global $langs;
304 
305  $result = true;
306 
307  //$result = $result && in_array(strtolower($name), $activated);
308  $result = $result && in_array(strtolower($name), $loaded);
309 
310  foreach ($functions as $function) {
311  $result = $result && function_exists($function);
312  }
313 
314  $html = "<td>";
315  if ($result) {
316  if (strtolower($name) == 'xdebug') {
317  $html .= img_warning($langs->trans("ModuleActivated", "xdebug"));
318  } else {
319  $html .= img_picto($langs->trans("Ok"), 'tick');
320  }
321  if (in_array(strtolower($name), $loaded)) {
322  $html .= ' '.$langs->trans("Loaded").' - ';
323  } else {
324  //$html .= ' '.$langs->trans("NotLoaded").' - ';
325  }
326  if (strtolower($name) == 'xdebug') {
327  $html .= ' '.$langs->trans("ModuleActivated", "xdebug");
328  $html .= ' - '.$langs->trans("ModuleActivatedMayExposeInformation");
329  } else {
330  $html .= ' <span class="opacitymedium">'.$langs->trans("PHPSupport", $name).'</span>';
331  }
332  } else {
333  if (strtolower($name) == 'xdebug') {
334  $html .= yn(0).' - ';
335  } else {
336  $html .= img_warning($langs->trans("ModuleActivated", "xdebug"));
337  }
338  if (in_array(strtolower($name), $loaded)) {
339  $html .= ' '.$langs->trans("Loaded").' - ';
340  } else {
341  //$html .= ' '.$langs->trans("NotLoaded").' - ';
342  }
343  $html .= ' '.$langs->trans("ErrorPHPDoesNotSupport", $name);
344  }
345  $html .= "</td>";
346 
347  return $html;
348 }
yn
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
Definition: functions.lib.php:6491
dol_trunc
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.
Definition: functions.lib.php:3805
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
versioncompare
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
Definition: admin.lib.php:66
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4521
phpinfo_array
phpinfo_array()
Return the php_info into an array.
Definition: admin.lib.php:1923
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
getResultColumn
getResultColumn($name, array $activated, array $loaded, array $functions)
Return a result column with a translated result text.
Definition: phpinfo.php:301
versionphparray
versionphparray()
Return version PHP.
Definition: admin.lib.php:128
info_admin
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
Definition: functions.lib.php:4800
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
versiontostring
versiontostring($versionarray)
Renvoi une version en chaine depuis une version en tableau.
Definition: admin.lib.php:36