database.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/admin/system/database.php
  22. * \brief Page with system information of database
  23. */
  24. require '../../main.inc.php';
  25. $langs->load("admin");
  26. if (!$user->admin) {
  27. accessforbidden();
  28. }
  29. /*
  30. * View
  31. */
  32. $form = new Form($db);
  33. llxHeader();
  34. print load_fiche_titre($langs->trans("InfoDatabase"), '', 'title_setup');
  35. // Database
  36. print '<div class="div-table-responsive-no-min">';
  37. print '<table class="noborder centpercent">';
  38. print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Database").'</td></tr>'."\n";
  39. print '<tr class="oddeven"><td width="300">'.$langs->trans("Version").'</td><td>'.$db::LABEL.' '.$db->getVersion().'</td></tr>'."\n";
  40. print '<tr class="oddeven"><td width="300">'.$langs->trans("DatabaseServer").'</td><td>'.$conf->db->host.'</td></tr>'."\n";
  41. 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";
  42. print '<tr class="oddeven"><td width="300">'.$langs->trans("DatabaseName").'</td><td>'.$conf->db->name.'</td></tr>'."\n";
  43. print '<tr class="oddeven"><td width="300">'.$langs->trans("DriverType").'</td><td>'.$conf->db->type.($db->getDriverInfo() ? ' ('.$db->getDriverInfo().')' : '').'</td></tr>'."\n";
  44. print '<tr class="oddeven"><td width="300">'.$langs->trans("User").'</td><td>'.$conf->db->user.'</td></tr>'."\n";
  45. print '<tr class="oddeven"><td width="300">'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $dolibarr_main_db_pass).'</td></tr>'."\n";
  46. print '<tr class="oddeven"><td width="300">'.$langs->trans("DBStoringCharset").'</td><td>'.$db->getDefaultCharacterSetDatabase().'</td></tr>'."\n";
  47. print '<tr class="oddeven"><td width="300">'.$langs->trans("DBSortingCharset").'</td><td>'.$db->getDefaultCollationDatabase().'</td></tr>'."\n";
  48. print '</table>';
  49. print '</div>';
  50. // Tables
  51. print '<br>';
  52. print '<div class="div-table-responsive-no-min">';
  53. print '<table class="noborder centpercent">';
  54. print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Tables").'</td></tr>'."\n";
  55. print '<tr class="oddeven"><td width="300"><a href="'.DOL_URL_ROOT.'/admin/system/database-tables.php?mainmenu=home">'.$langs->trans("List").'</a></td></tr>'."\n";
  56. print '</table>';
  57. print '</div>';
  58. $listofvars = $db->getServerParametersValues();
  59. $listofstatus = $db->getServerStatusValues();
  60. $arraylist = array('listofvars', 'listofstatus');
  61. if (!count($listofvars) && !count($listofstatus)) {
  62. print $langs->trans("FeatureNotAvailableWithThisDatabaseDriver");
  63. } else {
  64. foreach ($arraylist as $listname) {
  65. print '<br>';
  66. print '<div class="div-table-responsive-no-min">';
  67. print '<table class="noborder centpercent">';
  68. print '<tr class="liste_titre">';
  69. print '<td width="300">'.$langs->trans("Parameters").'</td>';
  70. print '<td>'.$langs->trans("Value").'</td>';
  71. print '</tr>'."\n";
  72. // arraytest is an array of test to do
  73. $arraytest = array();
  74. if (preg_match('/mysql/i', $db->type)) {
  75. $arraytest = array(
  76. 'character_set_database'=>array('var'=>'dolibarr_main_db_character_set', 'valifempty'=>'utf8'),
  77. 'collation_database'=>array('var'=>'dolibarr_main_db_collation', 'valifempty'=>'utf8_unicode_ci')
  78. );
  79. }
  80. $listtouse = array();
  81. if ($listname == 'listofvars') {
  82. $listtouse = $listofvars;
  83. }
  84. if ($listname == 'listofstatus') {
  85. $listtouse = $listofstatus;
  86. }
  87. foreach ($listtouse as $param => $paramval) {
  88. print '<tr class="oddeven">';
  89. print '<td>';
  90. print $param;
  91. print '</td>';
  92. print '<td class="wordbreak">';
  93. $show = 0; $text = '';
  94. foreach ($arraytest as $key => $val) {
  95. if ($key != $param) {
  96. continue;
  97. }
  98. $val2 = ${$val['var']};
  99. $text = 'Should be in line with value of param <b>'.$val['var'].'</b> thas is <b>'.($val2 ? $val2 : "'' (=".$val['valifempty'].")").'</b>';
  100. $show = 1;
  101. }
  102. if ($show == 0) {
  103. print $paramval;
  104. }
  105. if ($show == 1) {
  106. print $form->textwithpicto($paramval, $text);
  107. }
  108. if ($show == 2) {
  109. print $form->textwithpicto($paramval, $text, 1, 'warning');
  110. }
  111. print '</td>';
  112. print '</tr>'."\n";
  113. }
  114. print '</table>'."\n";
  115. print '</div>';
  116. }
  117. }
  118. // End of page
  119. llxFooter();
  120. $db->close();