dolibarr/htdocs/admin/system/database.php

140 lines
5.1 KiB
PHP
Raw Normal View History

<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
2003-08-28 23:37:29 +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
2003-08-28 23:37:29 +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/>.
2003-08-28 23:37:29 +02:00
*/
/**
2008-12-20 19:37:30 +01:00
* \file htdocs/admin/system/database.php
2011-01-10 20:16:21 +01:00
* \brief Page with system information of database
2008-12-20 19:37:30 +01:00
*/
2022-09-07 20:08:59 +02:00
// Load Dolibarr environment
require '../../main.inc.php';
$langs->load("admin");
2004-09-03 22:59:00 +02:00
2021-02-26 22:04:03 +01:00
if (!$user->admin) {
accessforbidden();
}
2008-12-20 19:37:30 +01:00
/*
* View
2008-12-20 19:37:30 +01:00
*/
$form = new Form($db);
2008-12-20 19:37:30 +01:00
2003-08-28 23:37:29 +02:00
llxHeader();
print load_fiche_titre($langs->trans("InfoDatabase"), '', 'title_setup');
// Database
2017-01-17 20:04:41 +01:00
print '<div class="div-table-responsive-no-min">';
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">';
2011-02-07 14:55:53 +01:00
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Database").'</td></tr>'."\n";
2020-12-21 01:40:15 +01:00
print '<tr class="oddeven"><td width="300">'.$langs->trans("Version").'</td><td>'.$db::LABEL.' '.$db->getVersion().'</td></tr>'."\n";
print '<tr class="oddeven"><td width="300">'.$langs->trans("DatabaseServer").'</td><td>'.$conf->db->host.'</td></tr>'."\n";
print '<tr class="oddeven"><td width="300">'.$langs->trans("DatabasePort").'</td><td>'.(empty($conf->db->port) ? $langs->trans("Default") : $conf->db->port).'</td></tr>'."\n";
print '<tr class="oddeven"><td width="300">'.$langs->trans("DatabaseName").'</td><td>'.$conf->db->name.'</td></tr>'."\n";
print '<tr class="oddeven"><td width="300">'.$langs->trans("DriverType").'</td><td>'.$conf->db->type.($db->getDriverInfo() ? ' ('.$db->getDriverInfo().')' : '').'</td></tr>'."\n";
print '<tr class="oddeven"><td width="300">'.$langs->trans("User").'</td><td>'.$conf->db->user.'</td></tr>'."\n";
print '<tr class="oddeven"><td width="300">'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $dolibarr_main_db_pass).'</td></tr>'."\n";
print '<tr class="oddeven"><td width="300">'.$langs->trans("DBStoringCharset").'</td><td>'.$db->getDefaultCharacterSetDatabase().'</td></tr>'."\n";
print '<tr class="oddeven"><td width="300">'.$langs->trans("DBSortingCharset").'</td><td>'.$db->getDefaultCollationDatabase().'</td></tr>'."\n";
print '</table>';
2017-01-17 20:04:41 +01:00
print '</div>';
// Tables
2012-09-09 16:32:03 +02:00
print '<br>';
2017-01-17 20:04:41 +01:00
print '<div class="div-table-responsive-no-min">';
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">';
2012-09-09 16:32:03 +02:00
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Tables").'</td></tr>'."\n";
2022-09-11 15:17:10 +02:00
print '<tr class="oddeven"><td class=""><a href="'.DOL_URL_ROOT.'/admin/system/database-tables.php?mainmenu=home">'.img_picto('', 'list', 'class="pictofixedwidth"').$langs->trans("List").'</a></td></tr>'."\n";
2012-09-09 16:32:03 +02:00
print '</table>';
2017-01-17 20:04:41 +01:00
print '</div>';
$listofvars = $db->getServerParametersValues();
$listofstatus = $db->getServerStatusValues();
$arraylist = array('listofvars', 'listofstatus');
2003-08-28 23:37:29 +02:00
2021-02-26 22:04:03 +01:00
if (!count($listofvars) && !count($listofstatus)) {
2008-12-20 19:37:30 +01:00
print $langs->trans("FeatureNotAvailableWithThisDatabaseDriver");
2020-05-21 09:35:30 +02:00
} else {
2021-02-26 22:04:03 +01:00
foreach ($arraylist as $listname) {
2008-12-20 19:37:30 +01:00
print '<br>';
print '<div class="div-table-responsive-no-min">';
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">';
2008-12-20 19:37:30 +01:00
print '<tr class="liste_titre">';
print '<td width="300">'.$langs->trans("Parameters").'</td>';
2008-12-20 19:37:30 +01:00
print '<td>'.$langs->trans("Value").'</td>';
2011-02-07 14:55:53 +01:00
print '</tr>'."\n";
2014-07-08 01:02:30 +02:00
2008-12-20 19:37:30 +01:00
// arraytest is an array of test to do
$arraytest = array();
2021-02-26 22:04:03 +01:00
if (preg_match('/mysql/i', $db->type)) {
$arraytest = array(
'character_set_database'=>array('var'=>'dolibarr_main_db_character_set', 'valifempty'=>'utf8'),
'collation_database'=>array('var'=>'dolibarr_main_db_collation', 'valifempty'=>'utf8_unicode_ci')
2008-12-20 19:37:30 +01:00
);
}
2014-07-08 01:02:30 +02:00
$listtouse = array();
2021-02-26 22:04:03 +01:00
if ($listname == 'listofvars') {
$listtouse = $listofvars;
}
if ($listname == 'listofstatus') {
$listtouse = $listofstatus;
}
2021-02-26 22:04:03 +01:00
foreach ($listtouse as $param => $paramval) {
2017-04-12 17:44:01 +02:00
print '<tr class="oddeven">';
print '<td>';
print $param;
print '</td>';
2020-12-21 01:40:15 +01:00
print '<td class="wordbreak">';
$show = 0; $text = '';
2021-02-26 22:04:03 +01:00
foreach ($arraytest as $key => $val) {
if ($key != $param) {
continue;
}
$val2 = ${$val['var']};
$text = 'Should be in line with value of param <b>'.$val['var'].'</b> thas is <b>'.($val2 ? $val2 : "'' (=".$val['valifempty'].")").'</b>';
$show = 1;
2008-12-20 19:37:30 +01:00
}
2021-02-26 22:04:03 +01:00
if ($show == 0) {
print $paramval;
}
if ($show == 1) {
print $form->textwithpicto($paramval, $text);
}
if ($show == 2) {
print $form->textwithpicto($paramval, $text, 1, 'warning');
}
print '</td>';
print '</tr>'."\n";
2008-12-20 19:37:30 +01:00
}
2011-02-07 14:55:53 +01:00
print '</table>'."\n";
2017-01-17 20:04:41 +01:00
print '</div>';
}
2003-08-28 23:37:29 +02:00
}
2018-07-28 14:29:28 +02:00
// End of page
llxFooter();
2014-07-08 01:02:30 +02:00
$db->close();