dolibarr 20.0.0
database.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
5 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
6 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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// Load Dolibarr environment
28require '../../main.inc.php';
29
30$langs->load("admin");
31
32if (!$user->admin) {
34}
35
36
37
38/*
39 * View
40 */
41
42$form = new Form($db);
43
44llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-admin page-system_database');
45
46print load_fiche_titre($langs->trans("InfoDatabase"), '', 'title_setup');
47
48// Database
49print '<div class="div-table-responsive-no-min">';
50print '<table class="noborder centpercent">';
51print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Database").'</td></tr>'."\n";
52print '<tr class="oddeven"><td width="300">'.$langs->trans("Version").'</td><td>'.$db::LABEL.' '.$db->getVersion().'</td></tr>'."\n";
53print '<tr class="oddeven"><td width="300">'.$langs->trans("DatabaseServer").'</td><td>'.$conf->db->host.'</td></tr>'."\n";
54print '<tr class="oddeven"><td width="300">'.$langs->trans("DatabasePort").'</td><td>'.(empty($conf->db->port) ? $langs->trans("Default") : $conf->db->port).'</td></tr>'."\n";
55print '<tr class="oddeven"><td width="300">'.$langs->trans("DatabaseName").'</td><td>'.$conf->db->name.'</td></tr>'."\n";
56print '<tr class="oddeven"><td width="300">'.$langs->trans("DriverType").'</td><td>'.$conf->db->type.($db->getDriverInfo() ? ' ('.$db->getDriverInfo().')' : '').'</td></tr>'."\n";
57// @phan-suppress-next-line PhanTypeSuspiciousStringExpression (user is defined in the stdClass)
58print '<tr class="oddeven"><td width="300">'.$langs->trans("User").'</td><td>'.$conf->db->user.'</td></tr>'."\n";
59print '<tr class="oddeven"><td width="300">'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $dolibarr_main_db_pass).'</td></tr>'."\n";
60print '<tr class="oddeven"><td width="300">'.$langs->trans("DBStoringCharset").'</td><td>'.$db->getDefaultCharacterSetDatabase().'</td></tr>'."\n";
61print '<tr class="oddeven"><td width="300">'.$langs->trans("DBSortingCharset").'</td><td>'.$db->getDefaultCollationDatabase().'</td></tr>'."\n";
62print '</table>';
63print '</div>';
64
65// Tables
66print '<br>';
67print '<div class="div-table-responsive-no-min">';
68print '<table class="noborder centpercent">';
69print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Tables").'</td></tr>'."\n";
70print '<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";
71print '</table>';
72print '</div>';
73
74$listofvars = $db->getServerParametersValues();
75$listofstatus = $db->getServerStatusValues();
76$arraylist = array('listofvars', 'listofstatus');
77
78if (!count($listofvars) && !count($listofstatus)) {
79 print $langs->trans("FeatureNotAvailableWithThisDatabaseDriver");
80} else {
81 foreach ($arraylist as $listname) {
82 print '<br>';
83 print '<div class="div-table-responsive-no-min">';
84 print '<table class="noborder centpercent">';
85 print '<tr class="liste_titre">';
86 print '<td width="300">'.$langs->trans("Parameters").'</td>';
87 print '<td>'.$langs->trans("Value").'</td>';
88 print '</tr>'."\n";
89
90 // arraytest is an array of test to do
91 $arraytest = array();
92 if (preg_match('/mysql/i', $db->type)) {
93 $arraytest = array(
94 'character_set_database' => array('var' => 'dolibarr_main_db_character_set', 'valifempty' => 'utf8'),
95 'collation_database' => array('var' => 'dolibarr_main_db_collation', 'valifempty' => 'utf8_unicode_ci')
96 );
97 }
98
99 $listtouse = array();
100 if ($listname == 'listofvars') {
101 $listtouse = $listofvars;
102 }
103 if ($listname == 'listofstatus') {
104 $listtouse = $listofstatus;
105 }
106
107 foreach ($listtouse as $param => $paramval) {
108 print '<tr class="oddeven">';
109 print '<td>';
110 print $param;
111 print '</td>';
112 print '<td class="wordbreak">';
113 $show = 0;
114 $text = '';
115 foreach ($arraytest as $key => $val) {
116 if ($key != $param) {
117 continue;
118 }
119 $tmpvar = $val['var'];
120 $val2 = ${$tmpvar};
121 $text = 'Should be in line with value of param <b>'.$val['var'].'</b> thas is <b>'.($val2 ? $val2 : "'' (=".$val['valifempty'].")").'</b>';
122 $show = 1;
123 }
124 if ($show == 0) {
125 print $paramval;
126 }
127 if ($show == 1) {
128 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
129 print $form->textwithpicto($paramval, $text);
130 }
131 if ($show == 2) {
132 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
133 print $form->textwithpicto($paramval, $text, 1, 'warning');
134 }
135 print '</td>';
136 print '</tr>'."\n";
137 }
138 print '</table>'."\n";
139 print '</div>';
140 }
141}
142
143// End of page
144llxFooter();
145$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it'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.