security_other.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <?php
  2. /* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.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 <http://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. $langs->load("users");
  29. $langs->load("admin");
  30. $langs->load("other");
  31. if (! $user->admin)
  32. accessforbidden();
  33. $action=GETPOST('action','alpha');
  34. /*
  35. * Actions
  36. */
  37. if (preg_match('/set_(.*)/',$action,$reg))
  38. {
  39. $code=$reg[1];
  40. $value=(GETPOST($code) ? GETPOST($code) : 1);
  41. if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
  42. {
  43. Header("Location: ".$_SERVER["PHP_SELF"]);
  44. exit;
  45. }
  46. else
  47. {
  48. dol_print_error($db);
  49. }
  50. }
  51. else if (preg_match('/del_(.*)/',$action,$reg))
  52. {
  53. $code=$reg[1];
  54. if (dolibarr_del_const($db, $code, $conf->entity) > 0)
  55. {
  56. Header("Location: ".$_SERVER["PHP_SELF"]);
  57. exit;
  58. }
  59. else
  60. {
  61. dol_print_error($db);
  62. }
  63. }
  64. else if ($action == 'updateform')
  65. {
  66. $res1=dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", $_POST["MAIN_APPLICATION_TITLE"],'chaine',0,'',$conf->entity);
  67. $res2=dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", $_POST["MAIN_SESSION_TIMEOUT"],'chaine',0,'',$conf->entity);
  68. if ($res1 && $res2) setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
  69. }
  70. /*
  71. * View
  72. */
  73. $form = new Form($db);
  74. $wikihelp='EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
  75. llxHeader('',$langs->trans("Miscellaneous"),$wikihelp);
  76. print load_fiche_titre($langs->trans("SecuritySetup"),'','title_setup');
  77. print $langs->trans("MiscellaneousDesc")."<br>\n";
  78. print "<br>\n";
  79. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  80. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  81. print '<input type="hidden" name="action" value="updateform">';
  82. $head=security_prepare_head();
  83. dol_fiche_head($head, 'misc', $langs->trans("Security"), -1);
  84. // Other Options
  85. $var=true;
  86. print '<table class="noborder" width="100%">';
  87. print '<tr class="liste_titre">';
  88. print '<td colspan="3">'.$langs->trans("Parameters").'</td>';
  89. print '<td align="right" width="100">'.$langs->trans("Status").'</td>';
  90. print '</tr>';
  91. // Enable Captcha code
  92. print '<tr class="oddeven">';
  93. print '<td colspan="3">'.$langs->trans("UseCaptchaCode").'</td>';
  94. print '<td align="right">';
  95. if (function_exists("imagecreatefrompng"))
  96. {
  97. if (! empty($conf->use_javascript_ajax))
  98. {
  99. print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA');
  100. }
  101. else
  102. {
  103. if (empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA))
  104. {
  105. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_SECURITY_ENABLECAPTCHA">'.img_picto($langs->trans("Disabled"),'off').'</a>';
  106. }
  107. else
  108. {
  109. print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_SECURITY_ENABLECAPTCHA">'.img_picto($langs->trans("Enabled"),'on').'</a>';
  110. }
  111. }
  112. }
  113. else
  114. {
  115. $desc = $form->textwithpicto('',$langs->transnoentities("EnableGDLibraryDesc"),1,'warning');
  116. print $desc;
  117. }
  118. print '</td></tr>';
  119. // Enable advanced perms
  120. print '<tr class="oddeven">';
  121. print '<td colspan="3">'.$langs->trans("UseAdvancedPerms").'</td>';
  122. print '<td align="right">';
  123. if (! empty($conf->use_javascript_ajax))
  124. {
  125. print ajax_constantonoff('MAIN_USE_ADVANCED_PERMS');
  126. }
  127. else
  128. {
  129. if (empty($conf->global->MAIN_USE_ADVANCED_PERMS))
  130. {
  131. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_USE_ADVANCED_PERMS">'.img_picto($langs->trans("Disabled"),'off').'</a>';
  132. }
  133. else
  134. {
  135. print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_USE_ADVANCED_PERMS">'.img_picto($langs->trans("Enabled"),'on').'</a>';
  136. }
  137. }
  138. print "</td></tr>";
  139. print '</table>';
  140. print '<br>';
  141. // Timeout
  142. $var=true;
  143. print '<table width="100%" class="noborder">';
  144. print '<tr class="liste_titre">';
  145. print '<td colspan="2">'.$langs->trans("Parameters").'</td>';
  146. print '<td>'.$langs->trans("Value").'</td>';
  147. print "</tr>\n";
  148. $sessiontimeout=ini_get("session.gc_maxlifetime");
  149. if (empty($conf->global->MAIN_SESSION_TIMEOUT)) $conf->global->MAIN_SESSION_TIMEOUT=$sessiontimeout;
  150. print '<tr class="oddeven">';
  151. print '<td>'.$langs->trans("SessionTimeOut").'</td><td align="right">';
  152. print $form->textwithpicto('',$langs->trans("SessionExplanation",ini_get("session.gc_probability"),ini_get("session.gc_divisor")));
  153. print '</td>';
  154. print '<td class="nowrap">';
  155. print '<input class="flat" name="MAIN_SESSION_TIMEOUT" type="text" size="6" value="'.htmlentities($conf->global->MAIN_SESSION_TIMEOUT).'"> '.strtolower($langs->trans("Seconds"));
  156. print '</td>';
  157. print '</tr>';
  158. $sessiontimeout=ini_get("session.gc_maxlifetime");
  159. if (empty($conf->global->MAIN_APPLICATION_TITLE)) $conf->global->MAIN_APPLICATION_TITLE="";
  160. print '<tr class="oddeven">';
  161. print '<td>'.$langs->trans("MAIN_APPLICATION_TITLE").'</td><td align="right">';
  162. print '</td>';
  163. print '<td class="nowrap">';
  164. print '<input class="flat" name="MAIN_APPLICATION_TITLE" type="text" size="20" value="'.htmlentities($conf->global->MAIN_APPLICATION_TITLE).'"> ';
  165. print '</td>';
  166. print '</tr>';
  167. print '</table>';
  168. dol_fiche_end();
  169. print '<div class="center"><input type="submit" class="button" name="button" value="'.$langs->trans("Modify").'"></div>';
  170. print '</form>';
  171. llxFooter();
  172. $db->close();