phpinfo.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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. /**
  22. * \file htdocs/admin/system/phpinfo.php
  23. * \brief Page des infos systeme de php
  24. */
  25. // Load Dolibarr environment
  26. require '../../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  29. $langs->loadLangs(array("admin", "install", "errors"));
  30. if (!$user->admin) {
  31. accessforbidden();
  32. }
  33. /*
  34. * View
  35. */
  36. llxHeader();
  37. $title = 'InfoPHP';
  38. if (isset($title)) {
  39. print load_fiche_titre($langs->trans($title), '', 'title_setup');
  40. }
  41. // Check PHP setup is OK
  42. $maxphp = @ini_get('upload_max_filesize'); // In unknown
  43. if (preg_match('/k$/i', $maxphp)) {
  44. $maxphp = preg_replace('/k$/i', '', $maxphp);
  45. $maxphp = $maxphp * 1;
  46. }
  47. if (preg_match('/m$/i', $maxphp)) {
  48. $maxphp = preg_replace('/m$/i', '', $maxphp);
  49. $maxphp = $maxphp * 1024;
  50. }
  51. if (preg_match('/g$/i', $maxphp)) {
  52. $maxphp = preg_replace('/g$/i', '', $maxphp);
  53. $maxphp = $maxphp * 1024 * 1024;
  54. }
  55. if (preg_match('/t$/i', $maxphp)) {
  56. $maxphp = preg_replace('/t$/i', '', $maxphp);
  57. $maxphp = $maxphp * 1024 * 1024 * 1024;
  58. }
  59. $maxphp2 = @ini_get('post_max_size'); // In unknown
  60. if (preg_match('/k$/i', $maxphp2)) {
  61. $maxphp2 = preg_replace('/k$/i', '', $maxphp2);
  62. $maxphp2 = $maxphp2 * 1;
  63. }
  64. if (preg_match('/m$/i', $maxphp2)) {
  65. $maxphp2 = preg_replace('/m$/i', '', $maxphp2);
  66. $maxphp2 = $maxphp2 * 1024;
  67. }
  68. if (preg_match('/g$/i', $maxphp2)) {
  69. $maxphp2 = preg_replace('/g$/i', '', $maxphp2);
  70. $maxphp2 = $maxphp2 * 1024 * 1024;
  71. }
  72. if (preg_match('/t$/i', $maxphp2)) {
  73. $maxphp2 = preg_replace('/t$/i', '', $maxphp2);
  74. $maxphp2 = $maxphp2 * 1024 * 1024 * 1024;
  75. }
  76. if ($maxphp > 0 && $maxphp2 > 0 && $maxphp > $maxphp2) {
  77. $langs->load("errors");
  78. print info_admin($langs->trans("WarningParamUploadMaxFileSizeHigherThanPostMaxSize", @ini_get('upload_max_filesize'), @ini_get('post_max_size')), 0, 0, 0, 'warning');
  79. print '<br>';
  80. }
  81. print '<table class="noborder centpercent">';
  82. print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
  83. $ErrorPicturePath = "../../theme/eldy/img/error.png";
  84. $WarningPicturePath = "../../theme/eldy/img/warning.png";
  85. $OkayPicturePath = "../../theme/eldy/img/tick.png";
  86. print '<tr><td>'.$langs->trans("Version").'</td><td>';
  87. $arrayphpminversionerror = array(5, 5, 0);
  88. $arrayphpminversionwarning = array(5, 6, 0);
  89. if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) {
  90. print '<img src="'.$ErrorPicturePath.'" alt="Error"> '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionerror));
  91. } elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0) {
  92. print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning));
  93. } else {
  94. print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.versiontostring(versionphparray());
  95. }
  96. print '</td></tr>';
  97. print '<tr><td>GET and POST support</td><td>';
  98. if (!isset($_GET["testget"]) && !isset($_POST["testpost"]) && !isset($_GET["mainmenu"])) { // We must keep $_GET and $_POST here
  99. print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("PHPSupportPOSTGETKo");
  100. print ' (<a href="'.$_SERVER["PHP_SELF"].'?testget=ok">'.$langs->trans("Recheck").'</a>)';
  101. } else {
  102. print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupportPOSTGETOk");
  103. }
  104. print '</td></tr>';
  105. print '<tr><td>Sessions support</td><td>';
  106. if (!function_exists("session_id")) {
  107. print '<img src="'.$ErrorPicturePath.'" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportSessions");
  108. } else {
  109. print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupportSessions");
  110. }
  111. print '</td></tr>';
  112. print '<tr><td>UTF-8 support</td><td>';
  113. if (!function_exists("utf8_encode")) {
  114. print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("ErrorPHPDoesNotSupport", "UTF8");
  115. } else {
  116. print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupport", "UTF8");
  117. }
  118. print '</td></tr>';
  119. print '</table>';
  120. print '<br>';
  121. $activatedExtensions = array();
  122. $loadedExtensions = array_map('strtolower', get_loaded_extensions(false));
  123. print '<table class="noborder centpercent">';
  124. print '<tr class="liste_titre">';
  125. print '<td class="titlefield">'.$langs->trans("Extension").'</td>';
  126. print '<td>'.$langs->trans("Test").'</td>';
  127. print '</tr>';
  128. $functions = ["mb_check_encoding"];
  129. $name = "MBString";
  130. print "<tr>";
  131. print "<td>".$name."</td>";
  132. print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
  133. print "</tr>";
  134. $functions = ["json_decode"];
  135. $name = "JSON";
  136. print "<tr>";
  137. print "<td>".$name."</td>";
  138. print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
  139. print "</tr>";
  140. $functions = ["imagecreate"];
  141. $name = "GD";
  142. print "<tr>";
  143. print "<td>".$name."</td>";
  144. print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
  145. print "</tr>";
  146. $functions = ["curl_init"];
  147. $name = "Curl";
  148. print "<tr>";
  149. print "<td>".$name."</td>";
  150. print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
  151. print "</tr>";
  152. $functions = ["easter_date"];
  153. $name = "Calendar";
  154. print "<tr>";
  155. print "<td>".$name."</td>";
  156. print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
  157. print "</tr>";
  158. $functions = ["simplexml_load_string"];
  159. $name = "Xml";
  160. print "<tr>";
  161. print "<td>".$name."</td>";
  162. print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
  163. print "</tr>";
  164. if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') {
  165. $functions = ["locale_get_primary_language", "locale_get_region"];
  166. $name = "Intl";
  167. print "<tr>";
  168. print "<td>".$name."</td>";
  169. print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
  170. print "</tr>";
  171. }
  172. $functions = ["imap_open"];
  173. $name = "IMAP";
  174. print "<tr>";
  175. print "<td>".$name."</td>";
  176. print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
  177. print "</tr>";
  178. $functions = array();
  179. $name = "zip";
  180. print "<tr>";
  181. print "<td>".$name."</td>";
  182. print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
  183. print "</tr>";
  184. $functions = array();
  185. $name = "xDebug";
  186. print "<tr>";
  187. print "<td>".$name."</td>";
  188. print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
  189. print "</tr>";
  190. print '</table>';
  191. print '<br>';
  192. // Get php_info array
  193. $phparray = phpinfo_array();
  194. foreach ($phparray as $key => $value) {
  195. print '<div class="div-table-responsive-no-min">';
  196. print '<table class="noborder">';
  197. print '<tr class="liste_titre">';
  198. print '<td class="titlefield">'.$key.'</td>';
  199. print '<td colspan="2">'.$langs->trans("Value").'</td>';
  200. print "</tr>\n";
  201. //var_dump($value);
  202. foreach ($value as $keyparam => $keyvalue) {
  203. if (!is_array($keyvalue)) {
  204. $keytoshow = $keyparam;
  205. $valtoshow = $keyvalue;
  206. // Hide value of session cookies
  207. if (in_array($keyparam, array('HTTP_COOKIE', 'Cookie', "\$_SERVER['HTTP_COOKIE']", 'Authorization'))) {
  208. $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
  209. }
  210. if (preg_match('/'.preg_quote('$_COOKIE[\'DOLSESSID_', '/').'/i', $keyparam)) {
  211. $keytoshow = $keyparam;
  212. $valtoshow = '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
  213. }
  214. print '<tr class="oddeven">';
  215. print '<td>'.$keytoshow.'</td>';
  216. if ($keyparam == 'X-ChromePhp-Data') {
  217. $valtoshow = dol_trunc($keyvalue, 80);
  218. }
  219. print '<td colspan="2" class="wordbreak">';
  220. if ($keyparam == 'Path') {
  221. $valtoshow = implode('; ', explode(';', trim($valtoshow)));
  222. }
  223. if ($keyparam == 'PATH') {
  224. $valtoshow = implode('; ', explode(';', trim($valtoshow)));
  225. }
  226. if ($keyparam == '_SERVER["PATH"]') {
  227. $valtoshow = implode('; ', explode(';', trim($valtoshow)));
  228. }
  229. print $valtoshow;
  230. print '</td>';
  231. print '</tr>';
  232. } else {
  233. print '<tr class="oddeven">';
  234. print '<td class="wordbreak">'.$keyparam.'</td>';
  235. $i = 0;
  236. foreach ($keyvalue as $keyparam2 => $keyvalue2) {
  237. print '<td>';
  238. $valtoshow = $keyvalue2;
  239. if ($keyparam == 'disable_functions') {
  240. $valtoshow = implode(', ', explode(',', trim($valtoshow)));
  241. }
  242. //print $keyparam;
  243. print $valtoshow;
  244. $i++;
  245. print '</td>';
  246. }
  247. print '</tr>';
  248. }
  249. }
  250. print '</table>';
  251. print '</div>';
  252. print '<br>';
  253. }
  254. // End of page
  255. llxFooter();
  256. $db->close();
  257. /**
  258. * Return a result column with a translated result text
  259. *
  260. * @param string $name The name of the PHP extension
  261. * @param array $activated A list with all activated PHP extensions. Deprecated.
  262. * @param array $loaded A list with all loaded PHP extensions
  263. * @param array $functions A list with all PHP functions to check
  264. * @return string
  265. */
  266. function getResultColumn($name, array $activated, array $loaded, array $functions)
  267. {
  268. global $langs;
  269. $result = true;
  270. //$result = $result && in_array(strtolower($name), $activated);
  271. $result = $result && in_array(strtolower($name), $loaded);
  272. foreach ($functions as $function) {
  273. $result = $result && function_exists($function);
  274. }
  275. $html = "<td>";
  276. if ($result) {
  277. if (strtolower($name) == 'xdebug') {
  278. $html .= img_warning($langs->trans("ModuleActivated", "xdebug"));
  279. } else {
  280. $html .= img_picto($langs->trans("Ok"), 'tick');
  281. }
  282. if (in_array(strtolower($name), $loaded)) {
  283. $html .= ' '.$langs->trans("Loaded").' - ';
  284. } else {
  285. //$html .= ' '.$langs->trans("NotLoaded").' - ';
  286. }
  287. if (strtolower($name) == 'xdebug') {
  288. $html .= ' '.$langs->trans("ModuleActivated", "xdebug");
  289. $html .= ' - '.$langs->trans("ModuleActivatedMayExposeInformation");
  290. } else {
  291. $html .= ' <span class="opacitymedium">'.$langs->trans("PHPSupport", $name).'</span>';
  292. }
  293. } else {
  294. if (strtolower($name) == 'xdebug') {
  295. $html .= yn(0).' - ';
  296. } else {
  297. $html .= img_warning($langs->trans("ModuleActivated", "xdebug"));
  298. }
  299. if (in_array(strtolower($name), $loaded)) {
  300. $html .= ' '.$langs->trans("Loaded").' - ';
  301. } else {
  302. //$html .= ' '.$langs->trans("NotLoaded").' - ';
  303. }
  304. $html .= ' '.$langs->trans("ErrorPHPDoesNotSupport", $name);
  305. }
  306. $html .= "</td>";
  307. return $html;
  308. }