debugbar.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /* Copyright (C) 2005-2019 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  4. * Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  5. * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
  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/debugbar.php
  22. * \ingroup debugbar
  23. * \brief Setup page for debugbar module
  24. */
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  27. global $conf;
  28. if (!$user->admin) {
  29. accessforbidden();
  30. }
  31. // Load translation files required by the page
  32. $langs->loadLangs(array("admin", "other"));
  33. $error = 0;
  34. $action = GETPOST('action', 'aZ09');
  35. /*
  36. * Actions
  37. */
  38. // Set modes
  39. if ($action == 'set') {
  40. $db->begin();
  41. $result1 = dolibarr_set_const($db, "DEBUGBAR_LOGS_LINES_NUMBER", GETPOST('DEBUGBAR_LOGS_LINES_NUMBER', 'int'), 'chaine', 0, '', 0);
  42. $result2 = dolibarr_set_const($db, "DEBUGBAR_USE_LOG_FILE", GETPOST('DEBUGBAR_USE_LOG_FILE', 'int'), 'chaine', 0, '', 0);
  43. if ($result1 < 0 || $result2 < 0) {
  44. $error++;
  45. }
  46. if (!$error) {
  47. $db->commit();
  48. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  49. } else {
  50. $db->rollback();
  51. setEventMessages($error, null, 'errors');
  52. }
  53. }
  54. /*
  55. * View
  56. */
  57. llxHeader();
  58. $form = new Form($db);
  59. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  60. print load_fiche_titre($langs->trans("DebugBarSetup"), $linkback, 'title_setup');
  61. if (!function_exists('mb_check_encoding')) {
  62. $langs->load("errors");
  63. print info_admin($langs->trans("ErrorPHPNeedModule", 'mbstring'), 0, 0, 'error');
  64. }
  65. print '<br>';
  66. // Level
  67. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  68. print '<input type="hidden" name="token" value="'.newToken().'">';
  69. print '<input type="hidden" name="action" value="set">';
  70. print '<table class="noborder centpercent">';
  71. print '<tr class="liste_titre">';
  72. print '<td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td>';
  73. print '<td class="right"><input type="submit" class="button button-edit" '.$option.' value="'.$langs->trans("Modify").'"></td>';
  74. print "</tr>\n";
  75. print '<tr class="oddeven"><td class="nowrap">'.$langs->trans("DEBUGBAR_USE_LOG_FILE").'</td>';
  76. print '<td>';
  77. print $form->selectyesno('DEBUGBAR_USE_LOG_FILE', $conf->global->DEBUGBAR_USE_LOG_FILE, 1);
  78. print '</td><td>';
  79. print '<span class="opacitymedium"> '.$langs->trans("UsingLogFileShowAllRecordOfSubrequestButIsSlower").'</span>';
  80. print '</td></tr>';
  81. print '<tr class="oddeven"><td class="nowrap">'.$langs->trans("DEBUGBAR_LOGS_LINES_NUMBER").'</td>';
  82. print '<td><input type="text" class="flat width75" name="DEBUGBAR_LOGS_LINES_NUMBER" value="'.(empty($conf->global->DEBUGBAR_LOGS_LINES_NUMBER) ? 250 : $conf->global->DEBUGBAR_LOGS_LINES_NUMBER).'">'; // This slow seriously output
  83. print '</td><td>';
  84. print '<span class="opacitymedium">'.$langs->trans("WarningValueHigherSlowsDramaticalyOutput").'</span>';
  85. print '</td></tr>';
  86. print '</table>';
  87. print "</form>\n";
  88. // End of page
  89. llxFooter();
  90. $db->close();