PageRenderTime 47ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/admin/system/database.php

https://github.com/asterix14/dolibarr
PHP | 137 lines | 89 code | 17 blank | 31 comment | 20 complexity | 9f9277e45f23e5fbd74cff4104ab0adb MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2011 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 2 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 <http://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) accessforbidden();
  27. /*
  28. * View
  29. */
  30. $form=new Form($db);
  31. llxHeader();
  32. print_fiche_titre($langs->trans("DatabaseConfiguration"),'','setup');
  33. // Database
  34. print '<table class="noborder" width="100%">';
  35. print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Database").'</td></tr>'."\n";
  36. print '<tr '.$bc[0].'><td width="300">'.$langs->trans("Version").'</td><td>'.$db->getLabel().' '.$db->getVersion().'</td></tr>'."\n";
  37. print '<tr '.$bc[1].'><td width="300">'.$langs->trans("DatabaseServer").'</td><td>'.$conf->db->host.'</td></tr>'."\n";
  38. print '<tr '.$bc[0].'><td width="300">'.$langs->trans("DatabasePort").'</td><td>'.(empty($conf->db->port)?$langs->trans("Default"):$conf->db->port).'</td></tr>'."\n";
  39. print '<tr '.$bc[1].'><td width="300">'.$langs->trans("DatabaseName").'</td><td>'.$conf->db->name.'</td></tr>'."\n";
  40. print '<tr '.$bc[0].'><td width="300">'.$langs->trans("DriverType").'</td><td>'.$conf->db->type .'</td></tr>'."\n";
  41. print '<tr '.$bc[1].'><td width="300">'.$langs->trans("User").'</td><td>'.$conf->db->user.'</td></tr>'."\n";
  42. print '<tr '.$bc[0].'><td width="300">'.$langs->trans("Password").'</td><td>'.preg_replace('/./i','*',$dolibarr_main_db_pass).'</td></tr>'."\n";
  43. print '<tr '.$bc[1].'><td width="300">'.$langs->trans("DBStoringCharset").'</td><td>'.$db->getDefaultCharacterSetDatabase().'</td></tr>'."\n";
  44. print '<tr '.$bc[0].'><td width="300">'.$langs->trans("DBSortingCharset").'</td><td>'.$db->getDefaultCollationDatabase().'</td></tr>'."\n";
  45. print '</table>';
  46. $base=0;
  47. $sqls = array();
  48. if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli')
  49. {
  50. $sqls[0] = "SHOW VARIABLES"; // TODO Use function getServerParametersValues
  51. $sqls[1] = "SHOW STATUS"; // TODO Use function getServerStatusValues
  52. $base=1;
  53. }
  54. else if ($conf->db->type == 'pgsql')
  55. {
  56. $sqls[0] = "select name,setting from pg_settings";
  57. $base=2;
  58. }
  59. else if ($conf->db->type == 'mssql')
  60. {
  61. //$sqls[0] = "";
  62. //$base=3;
  63. }
  64. if (! $base)
  65. {
  66. print $langs->trans("FeatureNotAvailableWithThisDatabaseDriver");
  67. }
  68. else
  69. {
  70. foreach($sqls as $sql)
  71. {
  72. print '<br>';
  73. print '<table class="noborder" width="100%">';
  74. print '<tr class="liste_titre">';
  75. print '<td width="300">'.$langs->trans("Parameter").'</td>';
  76. print '<td>'.$langs->trans("Value").'</td>';
  77. print '</tr>'."\n";
  78. // arraytest is an array of test to do
  79. $arraytest=array();
  80. if (preg_match('/mysql/i',$db->type))
  81. {
  82. $arraytest=array(
  83. // "character_set_connection"=>'UTF-8',
  84. 'character_set_database'=>'dolibarr_main_db_character_set',
  85. // 'collation_connection'=>"UTF-8",
  86. 'collation_database'=>'dolibarr_main_db_collation'
  87. );
  88. }
  89. $resql = $db->query($sql);
  90. if ($resql)
  91. {
  92. $var=True;
  93. while ($row = $db->fetch_row($resql))
  94. {
  95. $var=!$var;
  96. print '<tr '.$bc[$var].'>';
  97. print '<td>';
  98. print $row[0];
  99. print '</td>';
  100. print '<td>';
  101. $show=0;$text='';
  102. foreach($arraytest as $key => $val)
  103. {
  104. if ($key != $row[0]) continue;
  105. $text='Should be in line with value of param <b>'.$val.'</b> thas is <b>'.${$val}.'</b>';
  106. $show=1;
  107. }
  108. if ($show==0) print $row[1];
  109. if ($show==1) print $form->textwithpicto($row[1],$text);
  110. if ($show==2) print $form->textwithpicto($row[1],$text,1,'warning');
  111. print '</td>';
  112. print '</tr>'."\n";
  113. }
  114. $db->free($resql);
  115. }
  116. print '</table>'."\n";
  117. }
  118. }
  119. llxFooter();
  120. ?>