security_other.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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 = 1; $res2 = 1;
  56. if (GETPOSTISSET('MAIN_APPLICATION_TITLE')) {
  57. $res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  58. }
  59. if (GETPOSTISSET('MAIN_SESSION_TIMEOUT')) {
  60. $res2 = dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", GETPOST("MAIN_SESSION_TIMEOUT", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  61. }
  62. if ($res1 && $res2) {
  63. setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
  64. }
  65. }
  66. /*
  67. * View
  68. */
  69. $form = new Form($db);
  70. $wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
  71. llxHeader('', $langs->trans("Miscellaneous"), $wikihelp);
  72. print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
  73. print '<span class="opacitymedium">'.$langs->trans("MiscellaneousDesc")."</span><br>\n";
  74. print "<br>\n";
  75. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  76. print '<input type="hidden" name="token" value="'.newToken().'">';
  77. print '<input type="hidden" name="action" value="updateform">';
  78. $head = security_prepare_head();
  79. print dol_get_fiche_head($head, 'misc', '', -1);
  80. print '<br>';
  81. // Other Options
  82. print '<table class="noborder centpercent">';
  83. print '<tr class="liste_titre">';
  84. print '<td colspan="3">'.$langs->trans("Parameters").'</td>';
  85. print '<td class="right" width="100">'.$langs->trans("Status").'</td>';
  86. print '</tr>';
  87. // Enable Captcha code
  88. print '<tr class="oddeven">';
  89. print '<td colspan="3">'.$langs->trans("UseCaptchaCode").'</td>';
  90. print '<td class="right">';
  91. if (function_exists("imagecreatefrompng")) {
  92. if (!empty($conf->use_javascript_ajax)) {
  93. print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA');
  94. } else {
  95. if (empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) {
  96. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_SECURITY_ENABLECAPTCHA&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
  97. } else {
  98. print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_SECURITY_ENABLECAPTCHA&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
  99. }
  100. }
  101. } else {
  102. $desc = $form->textwithpicto('', $langs->transnoentities("EnableGDLibraryDesc"), 1, 'warning');
  103. print $desc;
  104. }
  105. print '</td></tr>';
  106. // Enable advanced perms
  107. print '<tr class="oddeven">';
  108. print '<td colspan="3">'.$langs->trans("UseAdvancedPerms").'</td>';
  109. print '<td class="right">';
  110. if (!empty($conf->use_javascript_ajax)) {
  111. print ajax_constantonoff('MAIN_USE_ADVANCED_PERMS');
  112. } else {
  113. if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
  114. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_USE_ADVANCED_PERMS&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
  115. } else {
  116. print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_USE_ADVANCED_PERMS&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
  117. }
  118. }
  119. print "</td></tr>";
  120. print '</table>';
  121. print '<br>';
  122. // Timeout
  123. print '<table width="100%" class="noborder">';
  124. print '<tr class="liste_titre">';
  125. print '<td colspan="2">'.$langs->trans("Parameters").'</td>';
  126. print '<td>'.$langs->trans("Value").'</td>';
  127. print "</tr>\n";
  128. $sessiontimeout = ini_get("session.gc_maxlifetime");
  129. if (empty($conf->global->MAIN_SESSION_TIMEOUT)) {
  130. $conf->global->MAIN_SESSION_TIMEOUT = $sessiontimeout;
  131. }
  132. print '<tr class="oddeven">';
  133. print '<td>'.$langs->trans("SessionTimeOut").'</td><td class="right">';
  134. if (ini_get("session.gc_probability") == 0) {
  135. print $form->textwithpicto('', $langs->trans("SessionsPurgedByExternalSystem", ini_get("session.gc_maxlifetime")));
  136. } else {
  137. print $form->textwithpicto('', $langs->trans("SessionExplanation", ini_get("session.gc_probability"), ini_get("session.gc_divisor"), ini_get("session.gc_maxlifetime")));
  138. }
  139. print '</td>';
  140. print '<td class="nowrap">';
  141. print '<input class="flat right width50" name="MAIN_SESSION_TIMEOUT" type="text" value="'.dol_escape_htmltag($conf->global->MAIN_SESSION_TIMEOUT).'"> '.strtolower($langs->trans("Seconds"));
  142. print '</td>';
  143. print '</tr>';
  144. /*
  145. if (empty($conf->global->MAIN_APPLICATION_TITLE)) {
  146. $conf->global->MAIN_APPLICATION_TITLE = "";
  147. }
  148. print '<tr class="oddeven">';
  149. print '<td>'.$langs->trans("MAIN_APPLICATION_TITLE").'</td><td class="right">';
  150. print '</td>';
  151. print '<td class="nowrap">';
  152. print '<input class="flat" name="MAIN_APPLICATION_TITLE" type="text" size="20" value="'.dol_escape_htmltag($conf->global->MAIN_APPLICATION_TITLE).'"> ';
  153. print '</td>';
  154. print '</tr>';
  155. */
  156. print '</table>';
  157. print dol_get_fiche_end();
  158. print $form->buttonsSaveCancel("Modify", '');
  159. print '</form>';
  160. // End of page
  161. llxFooter();
  162. $db->close();