security_other.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. /* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  4. * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/admin/security_other.php
  21. * \ingroup core
  22. * \brief Security options setup
  23. */
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  28. // Load translation files required by the page
  29. $langs->loadLangs(array("users", "admin", "other"));
  30. if (!$user->admin) {
  31. accessforbidden();
  32. }
  33. $action = GETPOST('action', 'aZ09');
  34. /*
  35. * Actions
  36. */
  37. if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
  38. $code = $reg[1];
  39. $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
  40. if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) {
  41. Header("Location: ".$_SERVER["PHP_SELF"]);
  42. exit;
  43. } else {
  44. dol_print_error($db);
  45. }
  46. } elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
  47. $code = $reg[1];
  48. if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
  49. Header("Location: ".$_SERVER["PHP_SELF"]);
  50. exit;
  51. } else {
  52. dol_print_error($db);
  53. }
  54. } elseif ($action == 'updateform') {
  55. $res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  56. $res2 = dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", GETPOST("MAIN_SESSION_TIMEOUT", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  57. if ($res1 && $res2) {
  58. setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
  59. }
  60. }
  61. /*
  62. * View
  63. */
  64. $form = new Form($db);
  65. $wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
  66. llxHeader('', $langs->trans("Miscellaneous"), $wikihelp);
  67. print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
  68. print '<span class="opacitymedium">'.$langs->trans("MiscellaneousDesc")."</span><br>\n";
  69. print "<br>\n";
  70. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  71. print '<input type="hidden" name="token" value="'.newToken().'">';
  72. print '<input type="hidden" name="action" value="updateform">';
  73. $head = security_prepare_head();
  74. print dol_get_fiche_head($head, 'misc', '', -1);
  75. // Other Options
  76. print '<table class="noborder centpercent">';
  77. print '<tr class="liste_titre">';
  78. print '<td colspan="3">'.$langs->trans("Parameters").'</td>';
  79. print '<td class="right" width="100">'.$langs->trans("Status").'</td>';
  80. print '</tr>';
  81. // Enable Captcha code
  82. print '<tr class="oddeven">';
  83. print '<td colspan="3">'.$langs->trans("UseCaptchaCode").'</td>';
  84. print '<td class="right">';
  85. if (function_exists("imagecreatefrompng")) {
  86. if (!empty($conf->use_javascript_ajax)) {
  87. print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA');
  88. } else {
  89. if (empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) {
  90. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_SECURITY_ENABLECAPTCHA&amp;token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
  91. } else {
  92. print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_SECURITY_ENABLECAPTCHA&amp;token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
  93. }
  94. }
  95. } else {
  96. $desc = $form->textwithpicto('', $langs->transnoentities("EnableGDLibraryDesc"), 1, 'warning');
  97. print $desc;
  98. }
  99. print '</td></tr>';
  100. // Enable advanced perms
  101. print '<tr class="oddeven">';
  102. print '<td colspan="3">'.$langs->trans("UseAdvancedPerms").'</td>';
  103. print '<td class="right">';
  104. if (!empty($conf->use_javascript_ajax)) {
  105. print ajax_constantonoff('MAIN_USE_ADVANCED_PERMS');
  106. } else {
  107. if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
  108. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_USE_ADVANCED_PERMS&amp;token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
  109. } else {
  110. print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_USE_ADVANCED_PERMS&amp;token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
  111. }
  112. }
  113. print "</td></tr>";
  114. print '</table>';
  115. print '<br>';
  116. // Timeout
  117. print '<table width="100%" class="noborder">';
  118. print '<tr class="liste_titre">';
  119. print '<td colspan="2">'.$langs->trans("Parameters").'</td>';
  120. print '<td>'.$langs->trans("Value").'</td>';
  121. print "</tr>\n";
  122. $sessiontimeout = ini_get("session.gc_maxlifetime");
  123. if (empty($conf->global->MAIN_SESSION_TIMEOUT)) {
  124. $conf->global->MAIN_SESSION_TIMEOUT = $sessiontimeout;
  125. }
  126. print '<tr class="oddeven">';
  127. print '<td>'.$langs->trans("SessionTimeOut").'</td><td class="right">';
  128. if (ini_get("session.gc_probability") == 0) {
  129. print $form->textwithpicto('', $langs->trans("SessionsPurgedByExternalSystem", ini_get("session.gc_maxlifetime")));
  130. } else {
  131. print $form->textwithpicto('', $langs->trans("SessionExplanation", ini_get("session.gc_probability"), ini_get("session.gc_divisor"), ini_get("session.gc_maxlifetime")));
  132. }
  133. print '</td>';
  134. print '<td class="nowrap">';
  135. print '<input class="flat" name="MAIN_SESSION_TIMEOUT" type="text" size="6" value="'.htmlentities($conf->global->MAIN_SESSION_TIMEOUT).'"> '.strtolower($langs->trans("Seconds"));
  136. print '</td>';
  137. print '</tr>';
  138. if (empty($conf->global->MAIN_APPLICATION_TITLE)) {
  139. $conf->global->MAIN_APPLICATION_TITLE = "";
  140. }
  141. print '<tr class="oddeven">';
  142. print '<td>'.$langs->trans("MAIN_APPLICATION_TITLE").'</td><td class="right">';
  143. print '</td>';
  144. print '<td class="nowrap">';
  145. print '<input class="flat" name="MAIN_APPLICATION_TITLE" type="text" size="20" value="'.htmlentities($conf->global->MAIN_APPLICATION_TITLE).'"> ';
  146. print '</td>';
  147. print '</tr>';
  148. print '</table>';
  149. print dol_get_fiche_end();
  150. print '<div class="center"><input type="submit" class="button" name="button" value="'.$langs->trans("Modify").'"></div>';
  151. print '</form>';
  152. // End of page
  153. llxFooter();
  154. $db->close();