dolibarr/htdocs/admin/system/phpinfo.php

426 lines
12 KiB
PHP
Raw Normal View History

<?php
2012-08-02 10:07:55 +02:00
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
2012-09-21 00:13:20 +02:00
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
2018-10-27 14:43:12 +02:00
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
2020-04-08 11:46:45 +02:00
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
2002-04-30 12:51:35 +02:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
2002-04-30 12:51:35 +02:00
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2002-04-30 12:51:35 +02:00
*/
/**
2009-01-18 18:35:29 +01:00
* \file htdocs/admin/system/phpinfo.php
* \brief Page des infos systeme de php
2009-01-18 18:35:29 +01:00
*/
require '../../main.inc.php';
2013-06-05 16:24:32 +02:00
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$langs->load("admin");
2020-01-15 10:02:18 +01:00
$langs->load("install");
$langs->load("errors");
if (!$user->admin)
2012-08-02 10:07:55 +02:00
accessforbidden();
2009-01-18 18:35:29 +01:00
/*
* View
*/
llxHeader();
$title = 'InfoPHP';
2009-01-18 18:35:29 +01:00
2012-09-30 21:26:58 +02:00
if (isset($title))
{
print load_fiche_titre($langs->trans($title), '', 'title_setup');
2012-09-30 21:26:58 +02:00
}
2009-01-18 18:35:29 +01:00
// Check PHP setup is OK
$maxphp = @ini_get('upload_max_filesize'); // In unknown
if (preg_match('/k$/i', $maxphp)) $maxphp = $maxphp * 1;
if (preg_match('/m$/i', $maxphp)) $maxphp = $maxphp * 1024;
if (preg_match('/g$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024;
if (preg_match('/t$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024 * 1024;
$maxphp2 = @ini_get('post_max_size'); // In unknown
if (preg_match('/k$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1;
if (preg_match('/m$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024;
if (preg_match('/g$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024;
if (preg_match('/t$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024 * 1024;
if ($maxphp > 0 && $maxphp2 > 0 && $maxphp > $maxphp2)
{
$langs->load("errors");
print info_admin($langs->trans("WarningParamUploadMaxFileSizeHigherThanPostMaxSize", @ini_get('upload_max_filesize'), @ini_get('post_max_size')), 0, 0, 0, 'warning');
print '<br>';
}
2020-04-08 11:46:45 +02:00
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">';
2013-06-05 16:24:32 +02:00
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
2020-01-15 10:02:18 +01:00
$ErrorPicturePath = "../../theme/eldy/img/error.png";
$WarningPicturePath = "../../theme/eldy/img/warning.png";
$OkayPicturePath = "../../theme/eldy/img/tick.png";
2020-01-15 10:02:18 +01:00
print '<tr><td width="220">'.$langs->trans("Version").'</td><td>';
$arrayphpminversionerror = array(5, 5, 0);
$arrayphpminversionwarning = array(5, 6, 0);
2020-04-08 11:46:45 +02:00
2020-01-15 10:21:36 +01:00
if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0)
2020-01-15 10:02:18 +01:00
{
2020-04-08 11:46:45 +02:00
print '<img src="'.$ErrorPicturePath.'" alt="Error"> '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionerror));
2020-05-21 09:35:30 +02:00
} elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0)
2020-01-15 10:02:18 +01:00
{
2020-04-08 11:46:45 +02:00
print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning));
2020-05-21 09:35:30 +02:00
} else {
2020-04-08 11:46:45 +02:00
print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.versiontostring(versionphparray());
2020-01-15 10:02:18 +01:00
}
print '</td></tr>';
print '<tr><td>GET and POST support</td><td>';
if (!isset($_GET["testget"]) && !isset($_POST["testpost"]) && !isset($_GET["mainmenu"]))
2020-01-15 10:02:18 +01:00
{
2020-04-08 11:46:45 +02:00
print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("PHPSupportPOSTGETKo");
print ' (<a href="'.$_SERVER["PHP_SELF"].'?testget=ok">'.$langs->trans("Recheck").'</a>)';
2020-05-21 09:35:30 +02:00
} else {
2020-04-08 11:46:45 +02:00
print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupportPOSTGETOk");
2020-01-15 10:02:18 +01:00
}
print '</td></tr>';
print '<tr><td>Sessions support</td><td>';
if (!function_exists("session_id"))
2020-01-15 10:02:18 +01:00
{
2020-04-08 11:46:45 +02:00
print '<img src="'.$ErrorPicturePath.'" alt="Error"> '.$langs->trans("ErrorPHPDoesNotSupportSessions");
2020-05-21 09:35:30 +02:00
} else {
2020-04-08 11:46:45 +02:00
print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupportSessions");
2020-01-15 10:02:18 +01:00
}
print '</td></tr>';
2020-09-08 02:59:49 +02:00
2020-04-08 11:46:45 +02:00
print '<tr><td>UTF-8 support</td><td>';
2020-01-15 10:02:18 +01:00
if (!function_exists("utf8_encode"))
2020-01-15 10:02:18 +01:00
{
2020-09-08 02:59:49 +02:00
print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("ErrorPHPDoesNotSupport", "UTF8");
2020-05-21 09:35:30 +02:00
} else {
2020-09-08 02:59:49 +02:00
print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupport", "UTF8");
2020-01-15 10:02:18 +01:00
}
print '</td></tr>';
2020-09-08 02:59:49 +02:00
print '<tr><td>MBString support</td><td>';
if (!function_exists("mb_check_encoding"))
{
print '<img src="'.$WarningPicturePath.'" alt="Warning"> '.$langs->trans("ErrorPHPDoesNotSupport", "mbstring");
} else {
print '<img src="'.$OkayPicturePath.'" alt="Ok"> '.$langs->trans("PHPSupport", "mbstring");
}
print '</td></tr>';
2020-04-08 11:46:45 +02:00
print '</table>';
2020-01-15 10:02:18 +01:00
2020-04-08 11:46:45 +02:00
print '<br>';
2020-01-15 10:02:18 +01:00
2020-04-08 11:46:45 +02:00
$activatedExtensions = array_map('strtolower', getActivatedExtensions());
$loadedExtensions = array_map('strtolower', get_loaded_extensions(false));
2020-04-08 11:46:45 +02:00
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width="200">'.$langs->trans("Extension").'</td>';
//print '<td align="center">'.$langs->trans("EnabledInSetup").'</td>';
2020-04-08 11:46:45 +02:00
print '<td align="center">'.$langs->trans("Loaded").'</td>';
print '<td align="center">'.$langs->trans("FunctionTest").'</td>';
print '<td>'.$langs->trans("Result").'</td>';
print '</tr>';
$functions = ["imagecreate"];
$name = "GD";
print "<tr>";
print "<td>".$name."</td>";
//print getTableColumn($name, $activatedExtensions);
2020-04-08 11:46:45 +02:00
print getTableColumn($name, $loadedExtensions);
print getTableColumnFunction($functions);
print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
print "</tr>";
$functions = ["curl_init"];
$name = "Curl";
print "<tr>";
print "<td>".$name."</td>";
//print getTableColumn($name, $activatedExtensions);
2020-04-08 11:46:45 +02:00
print getTableColumn($name, $loadedExtensions);
print getTableColumnFunction($functions);
print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
print "</tr>";
2020-01-15 10:02:18 +01:00
if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost')
{
2020-04-08 11:46:45 +02:00
$functions = ["locale_get_primary_language", "locale_get_region"];
$name = "Intl";
2020-01-15 10:02:18 +01:00
2020-04-08 11:46:45 +02:00
print "<tr>";
print "<td>".$name."</td>";
//print getTableColumn($name, $activatedExtensions);
2020-04-08 11:46:45 +02:00
print getTableColumn($name, $loadedExtensions);
print getTableColumnFunction($functions);
print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
2020-01-16 01:11:39 +01:00
2020-04-08 11:46:45 +02:00
print "</tr>";
2020-01-16 01:11:39 +01:00
}
2020-04-08 11:46:45 +02:00
$functions = array();
$name = "xDebug";
print "<tr>";
print "<td>".$name."</td>";
//print getTableColumn($name, $activatedExtensions);
2020-04-08 11:46:45 +02:00
print getTableColumn($name, $loadedExtensions);
print getTableColumnFunction($functions);
print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions);
print "</tr>";
2020-01-15 10:02:18 +01:00
print '</table>';
2020-01-15 12:56:36 +01:00
print '<br>';
2012-09-30 21:26:58 +02:00
// Get php_info array
$phparray = phpinfo_array();
foreach ($phparray as $key => $value)
{
2020-04-08 11:46:45 +02:00
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder">';
2012-09-30 21:26:58 +02:00
print '<tr class="liste_titre">';
print '<td width="220px">'.$key.'</td>';
print '<td colspan="2">'.$langs->trans("Value").'</td>';
print "</tr>\n";
2012-09-21 00:13:20 +02:00
//var_dump($value);
foreach ($value as $keyparam => $keyvalue)
2012-09-21 00:13:20 +02:00
{
if (!is_array($keyvalue))
2012-09-21 00:13:20 +02:00
{
2017-04-13 15:59:51 +02:00
print '<tr class="oddeven">';
2012-09-30 21:26:58 +02:00
print '<td>'.$keyparam.'</td>';
$valtoshow = $keyvalue;
if ($keyparam == 'X-ChromePhp-Data') $valtoshow = dol_trunc($keyvalue, 80);
print '<td colspan="2">';
if ($keyparam == 'Path') $valtoshow = implode('; ', explode(';', trim($valtoshow)));
if ($keyparam == 'PATH') $valtoshow = implode('; ', explode(';', trim($valtoshow)));
if ($keyparam == '_SERVER["PATH"]') $valtoshow = implode('; ', explode(';', trim($valtoshow)));
print $valtoshow;
print '</td>';
2012-09-21 00:13:20 +02:00
print '</tr>';
2020-05-21 09:35:30 +02:00
} else {
2017-04-13 15:59:51 +02:00
print '<tr class="oddeven">';
2012-09-21 00:13:20 +02:00
print '<td>'.$keyparam.'</td>';
$i = 0;
foreach ($keyvalue as $keyparam2 => $keyvalue2)
2012-09-21 00:13:20 +02:00
{
print '<td>';
$valtoshow = $keyvalue2;
if ($keyparam == 'disable_functions') $valtoshow = implode(', ', explode(',', trim($valtoshow)));
//print $keyparam;
2012-09-30 21:26:58 +02:00
print $valtoshow;
2012-09-21 00:13:20 +02:00
$i++;
print '</td>';
}
print '</tr>';
}
}
2017-01-17 20:04:41 +01:00
print '</table>';
print '</div>';
print '<br>';
}
2012-09-30 21:26:58 +02:00
2018-07-28 14:29:28 +02:00
// End of page
2011-08-27 21:15:14 +02:00
llxFooter();
2012-08-02 10:07:55 +02:00
$db->close();
2020-04-08 11:46:45 +02:00
/**
* Return all list with all activated, but possible not loaded PHP extensions
*
* @return array
*/
function getActivatedExtensions()
{
$file = getConfigFilePath();
$handle = fopen(GetConfigFilePath(), "r");
$content = fread($handle, filesize($file));
fclose($handle);
$configLines = explode("\r", $content);
$extensions = array();
$lastLine = "";
foreach ($configLines as $line)
2020-04-08 11:46:45 +02:00
{
$line = trim($line);
// ignore comment lines
if (substr($line, 0, 1) === ";")
2020-04-08 11:46:45 +02:00
{
continue;
}
// extension
if (substr($line, 0, 9) === "extension" && substr($line, 0, 10) !== "extension_")
2020-04-08 11:46:45 +02:00
{
$value = trim(end(explode("=", $line)));
$extensions[] = $value === "gd2" ? "gd" : $value;
}
// zend_extension
if (substr($line, 0, 14) === "zend_extension")
2020-04-08 11:46:45 +02:00
{
$extensions[] = str_replace("[", "", str_replace("]", "", $lastLine));
}
$lastLine = $line;
}
return array_unique($extensions);
}
/**
* Return the path to the current used php config file
*
* @return string
*/
function getConfigFilePath()
{
$phparray = phpinfo_array();
foreach ($phparray as $value)
2020-04-08 11:46:45 +02:00
{
foreach ($value as $keyparam => $keyvalue)
2020-04-08 11:46:45 +02:00
{
if (strtolower($keyparam) !== "loaded configuration file")
2020-04-08 11:46:45 +02:00
{
continue;
}
return $keyvalue;
}
}
return "";
}
/**
* Return a table column with a indicator (okay or warning), based on the given name and list
*
* @param string $name The name to check inside the given list
2020-04-08 12:11:06 +02:00
* @param array $list A list that should contains the given name
2020-04-08 11:46:45 +02:00
*
* @return string
*/
function getTableColumn($name, array $list)
{
2020-05-29 09:50:38 +02:00
global $langs;
$name = strtolower($name);
2020-04-08 11:46:45 +02:00
$html = "<td align='center'>";
if (in_array($name, $list))
2020-04-08 11:46:45 +02:00
{
2020-05-29 09:50:38 +02:00
if ($name == 'xdebug') $html .= '<img src="../../theme/eldy/img/warning.png" title="'.$langs->trans("ModuleActivated", "xdebug").'">';
else $html .= '<img src="../../theme/eldy/img/tick.png" title="Ok">';
2020-05-21 09:35:30 +02:00
} else {
2020-05-29 09:50:38 +02:00
if ($name == 'xdebug') $html .= yn(0);
else $html .= '<img src="../../theme/eldy/img/warning.png" title="Warning">';
2020-04-08 11:46:45 +02:00
}
$html .= "</td>";
return $html;
}
/**
* Return a table column with a indicator (okay or warning), based on the given functions to check
*
* @param array $functions A list with functions to check
*
* @return string
*/
function getTableColumnFunction(array $functions)
{
if (count($functions) < 1)
2020-04-08 11:46:45 +02:00
{
return "<td align='center'>-</td>";
}
$result = true;
$html = "<td align='center'>";
foreach ($functions as $function)
2020-04-08 11:46:45 +02:00
{
$result = $result && function_exists($function);
}
if ($result)
2020-04-08 11:46:45 +02:00
{
$html .= '<img src="../../theme/eldy/img/tick.png" alt="Ok">';
2020-05-21 09:35:30 +02:00
} else {
2020-04-08 11:46:45 +02:00
$html .= '<img src="../../theme/eldy/img/warning.png" alt="Warning">';
}
$html .= "</td>";
return $html;
}
/**
* Return a result column with a translated result text
*
* @param string $name The name of the PHP extension
* @param array $activated A list with all activated PHP extensions
* @param array $loaded A list with all loaded PHP extensions
* @param array $functions A list with all PHP functions to check
*
2020-04-12 16:26:19 +02:00
* @return string
2020-04-08 11:46:45 +02:00
*/
function getResultColumn($name, array $activated, array $loaded, array $functions)
{
global $langs;
$result = true;
//$result = $result && in_array(strtolower($name), $activated);
2020-04-08 11:46:45 +02:00
$result = $result && in_array(strtolower($name), $loaded);
foreach ($functions as $function)
2020-04-08 11:46:45 +02:00
{
$result = $result && function_exists($function);
}
$html = "<td>";
$html .= $result ? $langs->trans("PHPSupport".$name) : $langs->trans("ErrorPHPDoesNotSupport".$name);
$html .= "</td>";
2020-04-08 11:46:45 +02:00
return $html;
}