security_other.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. // Load Dolibarr environment
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  29. // Load translation files required by the page
  30. $langs->loadLangs(array("users", "admin", "other"));
  31. if (!$user->admin) {
  32. accessforbidden();
  33. }
  34. $action = GETPOST('action', 'aZ09');
  35. /*
  36. * Actions
  37. */
  38. if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
  39. $code = $reg[1];
  40. $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
  41. if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) {
  42. Header("Location: ".$_SERVER["PHP_SELF"]);
  43. exit;
  44. } else {
  45. dol_print_error($db);
  46. }
  47. } elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
  48. $code = $reg[1];
  49. if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
  50. Header("Location: ".$_SERVER["PHP_SELF"]);
  51. exit;
  52. } else {
  53. dol_print_error($db);
  54. }
  55. } elseif ($action == 'updateform') {
  56. $res1 = 1; $res2 = 1; $res3 = 1; $res4 = 1; $res5 = 1;
  57. if (GETPOSTISSET('MAIN_APPLICATION_TITLE')) {
  58. $res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  59. }
  60. if (GETPOSTISSET('MAIN_SESSION_TIMEOUT')) {
  61. $res2 = dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", GETPOST("MAIN_SESSION_TIMEOUT", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
  62. }
  63. if (GETPOSTISSET('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT')) {
  64. $res3 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", GETPOST("MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 'alphanohtml'), 'int', 0, '', $conf->entity);
  65. }
  66. if (GETPOSTISSET('MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS')) {
  67. $res4 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", GETPOST("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 'alphanohtml'), 'int', 0, '', $conf->entity);
  68. }
  69. if (GETPOSTISSET('MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS')) {
  70. $res5 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS", GETPOST("MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS", 'alphanohtml'), 'int', 0, '', $conf->entity);
  71. }
  72. if ($res1 && $res2 && $res3 && $res4 && $res5) {
  73. setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
  74. }
  75. }
  76. /*
  77. * View
  78. */
  79. $form = new Form($db);
  80. $wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
  81. llxHeader('', $langs->trans("Miscellaneous"), $wikihelp);
  82. print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
  83. print '<span class="opacitymedium">'.$langs->trans("MiscellaneousDesc")."</span><br>\n";
  84. print "<br>\n";
  85. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  86. print '<input type="hidden" name="token" value="'.newToken().'">';
  87. print '<input type="hidden" name="action" value="updateform">';
  88. $head = security_prepare_head();
  89. print dol_get_fiche_head($head, 'misc', '', -1);
  90. print '<br>';
  91. // Other Options
  92. print '<table class="noborder centpercent">';
  93. print '<tr class="liste_titre">';
  94. print '<td colspan="3">'.$langs->trans("Parameters").'</td>';
  95. print '<td class="right" width="100">'.$langs->trans("Status").'</td>';
  96. print '</tr>';
  97. // Enable Captcha code
  98. print '<tr class="oddeven">';
  99. print '<td colspan="3">'.$langs->trans("UseCaptchaCode").'</td>';
  100. print '<td class="right">';
  101. if (function_exists("imagecreatefrompng")) {
  102. if (!empty($conf->use_javascript_ajax)) {
  103. print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA');
  104. } else {
  105. if (empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) {
  106. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_SECURITY_ENABLECAPTCHA&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
  107. } else {
  108. print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_SECURITY_ENABLECAPTCHA&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
  109. }
  110. }
  111. } else {
  112. $desc = $form->textwithpicto('', $langs->transnoentities("EnableGDLibraryDesc"), 1, 'warning');
  113. print $desc;
  114. }
  115. print '</td></tr>';
  116. // Enable advanced perms
  117. print '<tr class="oddeven">';
  118. print '<td colspan="3">'.$langs->trans("UseAdvancedPerms").'</td>';
  119. print '<td class="right">';
  120. if (!empty($conf->use_javascript_ajax)) {
  121. print ajax_constantonoff('MAIN_USE_ADVANCED_PERMS');
  122. } else {
  123. if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
  124. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_USE_ADVANCED_PERMS&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
  125. } else {
  126. print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_USE_ADVANCED_PERMS&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
  127. }
  128. }
  129. print "</td></tr>";
  130. print '</table>';
  131. print '<br>';
  132. // Timeout
  133. print '<table width="100%" class="noborder">';
  134. print '<tr class="liste_titre">';
  135. print '<td colspan="2">'.$langs->trans("Parameters").'</td>';
  136. print '<td>'.$langs->trans("Value").'</td>';
  137. print "</tr>\n";
  138. $sessiontimeout = ini_get("session.gc_maxlifetime");
  139. if (empty($conf->global->MAIN_SESSION_TIMEOUT)) {
  140. $conf->global->MAIN_SESSION_TIMEOUT = $sessiontimeout;
  141. }
  142. print '<tr class="oddeven">';
  143. print '<td>'.$langs->trans("SessionTimeOut").'</td><td class="right">';
  144. if (ini_get("session.gc_probability") == 0) {
  145. print $form->textwithpicto('', $langs->trans("SessionsPurgedByExternalSystem", ini_get("session.gc_maxlifetime")));
  146. } else {
  147. print $form->textwithpicto('', $langs->trans("SessionExplanation", ini_get("session.gc_probability"), ini_get("session.gc_divisor"), ini_get("session.gc_maxlifetime")));
  148. }
  149. print '</td>';
  150. print '<td class="nowrap">';
  151. print '<input class="flat right width50" name="MAIN_SESSION_TIMEOUT" type="text" value="'.getDolGlobalInt('MAIN_SESSION_TIMEOUT').'"> '.strtolower($langs->trans("Seconds"));
  152. print '</td>';
  153. print '</tr>';
  154. print '<tr class="oddeven">';
  155. print '<td>'.$langs->trans("MaxNumberOfImagesInGetPost").'</td><td class="right">';
  156. print '</td>';
  157. print '<td class="nowrap">';
  158. print '<input class="flat right width50" name="MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT" type="text" value="'.getDolGlobalInt('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT').'"> '.strtolower($langs->trans("Images"));
  159. print '</td>';
  160. print '</tr>';
  161. print '<tr class="oddeven">';
  162. print '<td>'.$langs->trans("MaxNumberOfPostOnPublicPagesByIP").'</td><td class="right">';
  163. print '</td>';
  164. print '<td class="nowrap">';
  165. print '<input class="flat right width50" name="MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS" type="text" value="'.getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200).'"> '.strtolower($langs->trans("Posts"));
  166. print '</td>';
  167. print '</tr>';
  168. print '<tr class="oddeven">';
  169. print '<td>'.$langs->trans("MaxNumberOfAttachementOnForms").'</td><td class="right">';
  170. print '</td>';
  171. print '<td class="nowrap">';
  172. print '<input class="flat right width50" name="MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS" type="text" value="'.getDolGlobalInt("MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS", 10).'"> '.strtolower($langs->trans("Files"));
  173. print '</td>';
  174. print '</tr>';
  175. /*
  176. if (empty($conf->global->MAIN_APPLICATION_TITLE)) {
  177. $conf->global->MAIN_APPLICATION_TITLE = "";
  178. }
  179. print '<tr class="oddeven">';
  180. print '<td>'.$langs->trans("MAIN_APPLICATION_TITLE").'</td><td class="right">';
  181. print '</td>';
  182. print '<td class="nowrap">';
  183. print '<input class="flat" name="MAIN_APPLICATION_TITLE" type="text" size="20" value="'.dol_escape_htmltag($conf->global->MAIN_APPLICATION_TITLE).'"> ';
  184. print '</td>';
  185. print '</tr>';
  186. */
  187. print '</table>';
  188. print $form->buttonsSaveCancel("Modify", '');
  189. print dol_get_fiche_end();
  190. print '</form>';
  191. // End of page
  192. llxFooter();
  193. $db->close();