dolibarr  13.0.2
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  * View
40  */
41 
42 llxHeader();
43 
44 $title = 'InfoPHP';
45 
46 if (isset($title))
47 {
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)) $maxphp = $maxphp * 1;
55 if (preg_match('/m$/i', $maxphp)) $maxphp = $maxphp * 1024;
56 if (preg_match('/g$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024;
57 if (preg_match('/t$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024 * 1024;
58 $maxphp2 = @ini_get('post_max_size'); // In unknown
59 if (preg_match('/k$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1;
60 if (preg_match('/m$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024;
61 if (preg_match('/g$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024;
62 if (preg_match('/t$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024 * 1024;
63 if ($maxphp > 0 && $maxphp2 > 0 && $maxphp > $maxphp2)
64 {
65  $langs->load("errors");
66  print info_admin($langs->trans("WarningParamUploadMaxFileSizeHigherThanPostMaxSize", @ini_get('upload_max_filesize'), @ini_get('post_max_size')), 0, 0, 0, 'warning');
67  print '<br>';
68 }
69 
70 
71 print '<table class="noborder centpercent">';
72 print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
73 
74 $ErrorPicturePath = "../../theme/eldy/img/error.png";
75 $WarningPicturePath = "../../theme/eldy/img/warning.png";
76 $OkayPicturePath = "../../theme/eldy/img/tick.png";
77 
78 print '<tr><td>'.$langs->trans("Version").'</td><td>';
79 
80 $arrayphpminversionerror = array(5, 5, 0);
81 $arrayphpminversionwarning = array(5, 6, 0);
82 
83 if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0)
84 {
85  print '<img src="'.$ErrorPicturePath.'" alt="Error"> '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionerror));
86 } elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0)
87 {
88  print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning));
89 } else {
90  print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.versiontostring(versionphparray());
91 }
92 
93 print '</td></tr>';
94 print '<tr><td>GET and POST support</td><td>';
95 
96 if (!isset($_GET["testget"]) && !isset($_POST["testpost"]) && !isset($_GET["mainmenu"])) // We must keep $_GET and $_POST here
97 {
98  print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("PHPSupportPOSTGETKo");
99  print ' (<a href="'.$_SERVER["PHP_SELF"].'?testget=ok">'.$langs->trans("Recheck").'</a>)';
100 } else {
101  print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupportPOSTGETOk");
102 }
103 
104 print '</td></tr>';
105 print '<tr><td>Sessions support</td><td>';
106 if (!function_exists("session_id"))
107 {
108  print '<img src="'.$ErrorPicturePath.'" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportSessions");
109 } else {
110  print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupportSessions");
111 }
112 print '</td></tr>';
113 
114 print '<tr><td>UTF-8 support</td><td>';
115 if (!function_exists("utf8_encode"))
116 {
117  print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("ErrorPHPDoesNotSupport", "UTF8");
118 } else {
119  print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupport", "UTF8");
120 }
121 print '</td></tr>';
122 
123 print '</table>';
124 
125 print '<br>';
126 
127 $activatedExtensions = array();
128 $loadedExtensions = array_map('strtolower', get_loaded_extensions(false));
129 
130 print '<table class="noborder centpercent">';
131 print '<tr class="liste_titre">';
132 print '<td class="titlefield">'.$langs->trans("Extension").'</td>';
133 print '<td>'.$langs->trans("Test").'</td>';
134 print '</tr>';
135 
136 $functions = ["mb_check_encoding"];
137 $name = "MBString";
138 
139 print "<tr>";
140 print "<td>".$name."</td>";
141 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
142 print "</tr>";
143 
144 $functions = ["json_decode"];
145 $name = "JSON";
146 
147 print "<tr>";
148 print "<td>".$name."</td>";
149 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
150 print "</tr>";
151 
152 $functions = ["imagecreate"];
153 $name = "GD";
154 
155 print "<tr>";
156 print "<td>".$name."</td>";
157 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
158 print "</tr>";
159 
160 $functions = ["curl_init"];
161 $name = "Curl";
162 
163 print "<tr>";
164 print "<td>".$name."</td>";
165 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
166 print "</tr>";
167 
168 if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost')
169 {
170  $functions = ["locale_get_primary_language", "locale_get_region"];
171  $name = "Intl";
172 
173  print "<tr>";
174  print "<td>".$name."</td>";
175  print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
176  print "</tr>";
177 }
178 
179 $functions = ["imap_open"];
180 $name = "IMAP";
181 
182 print "<tr>";
183 print "<td>".$name."</td>";
184 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
185 print "</tr>";
186 
187 $functions = array();
188 $name = "xDebug";
189 
190 print "<tr>";
191 print "<td>".$name."</td>";
192 print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
193 print "</tr>";
194 
195 print '</table>';
196 
197 print '<br>';
198 
199 // Get php_info array
200 $phparray = phpinfo_array();
201 foreach ($phparray as $key => $value)
202 {
203  print '<div class="div-table-responsive-no-min">';
204  print '<table class="noborder">';
205  print '<tr class="liste_titre">';
206  print '<td class="titlefield">'.$key.'</td>';
207  print '<td colspan="2">'.$langs->trans("Value").'</td>';
208  print "</tr>\n";
209 
210  //var_dump($value);
211  foreach ($value as $keyparam => $keyvalue)
212  {
213  if (!is_array($keyvalue))
214  {
215  print '<tr class="oddeven">';
216  print '<td>'.$keyparam.'</td>';
217  $valtoshow = $keyvalue;
218  if ($keyparam == 'X-ChromePhp-Data') $valtoshow = dol_trunc($keyvalue, 80);
219  print '<td colspan="2" class="wordbreak">';
220  if ($keyparam == 'Path') $valtoshow = implode('; ', explode(';', trim($valtoshow)));
221  if ($keyparam == 'PATH') $valtoshow = implode('; ', explode(';', trim($valtoshow)));
222  if ($keyparam == '_SERVER["PATH"]') $valtoshow = implode('; ', explode(';', trim($valtoshow)));
223  print $valtoshow;
224  print '</td>';
225  print '</tr>';
226  } else {
227  print '<tr class="oddeven">';
228  print '<td class="wordbreak">'.$keyparam.'</td>';
229  $i = 0;
230  foreach ($keyvalue as $keyparam2 => $keyvalue2)
231  {
232  print '<td>';
233  $valtoshow = $keyvalue2;
234  if ($keyparam == 'disable_functions') $valtoshow = implode(', ', explode(',', trim($valtoshow)));
235  //print $keyparam;
236  print $valtoshow;
237  $i++;
238  print '</td>';
239  }
240  print '</tr>';
241  }
242  }
243  print '</table>';
244  print '</div>';
245  print '<br>';
246 }
247 
248 // End of page
249 llxFooter();
250 $db->close();
251 
252 
262 function getResultColumn($name, array $activated, array $loaded, array $functions)
263 {
264  global $langs;
265 
266  $result = true;
267 
268  //$result = $result && in_array(strtolower($name), $activated);
269  $result = $result && in_array(strtolower($name), $loaded);
270 
271  foreach ($functions as $function)
272  {
273  $result = $result && function_exists($function);
274  }
275 
276  $html = "<td>";
277  if ($result) {
278  if (strtolower($name) == 'xdebug') $html .= img_warning($langs->trans("ModuleActivated", "xdebug"));
279  else $html .= img_picto($langs->trans("Ok"), 'tick');
280  if (in_array(strtolower($name), $loaded)) {
281  $html .= ' '.$langs->trans("Loaded").' - ';
282  } else {
283  //$html .= ' '.$langs->trans("NotLoaded").' - ';
284  }
285  if (strtolower($name) == 'xdebug') {
286  $html .= ' '.$langs->trans("ModuleActivated", "xdebug");
287  } else {
288  $html .= ' '.$langs->trans("PHPSupport", $name);
289  }
290  } else {
291  if (strtolower($name) == 'xdebug') $html .= yn(0).' - ';
292  else $html .= img_warning($langs->trans("ModuleActivated", "xdebug"));
293  if (in_array(strtolower($name), $loaded)) {
294  $html .= ' '.$langs->trans("Loaded").' - ';
295  } else {
296  //$html .= ' '.$langs->trans("NotLoaded").' - ';
297  }
298  $html .= ' '.$langs->trans("ErrorPHPDoesNotSupport", $name);
299  }
300  $html .= "</td>";
301 
302  return $html;
303 }
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
getResultColumn($name, array $activated, array $loaded, array $functions)
Return a result column with a translated result text.
Definition: phpinfo.php:262
versiontostring($versionarray)
Renvoi une version en chaine depuis une version en tableau.
Definition: admin.lib.php:36
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
llxHeader()
Empty header.
Definition: wrapper.php:45
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
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 ...
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
Definition: admin.lib.php:66
phpinfo_array()
Return the php_info into an array.
Definition: admin.lib.php:1777
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
Definition: index.php:89
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding &#39;...&#39; if string larger than length.
versionphparray()
Return version PHP.
Definition: admin.lib.php:125
llxFooter()
Empty footer.
Definition: wrapper.php:59
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.