proxy.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <?php
  2. /* Copyright (C) 2011-2013 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/admin/proxy.php
  20. * \ingroup core
  21. * \brief Page setup proxy to use for external web access
  22. */
  23. require '../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  26. // Load translation files required by the page
  27. $langs->loadLangs(array("other", "users", "admin"));
  28. if (!$user->admin) {
  29. accessforbidden();
  30. }
  31. $upload_dir = $conf->admin->dir_temp;
  32. /*
  33. * Actions
  34. */
  35. if (GETPOST('action', 'aZ09') == 'set_proxy') {
  36. if (GETPOST("MAIN_USE_CONNECT_TIMEOUT") && !is_numeric(GETPOST("MAIN_USE_CONNECT_TIMEOUT"))) {
  37. setEventMessages($langs->trans("ErrorValueMustBeInteger"), null, 'errors');
  38. $error++;
  39. }
  40. if (GETPOST("MAIN_USE_RESPONSE_TIMEOUT") && !is_numeric(GETPOST("MAIN_USE_RESPONSE_TIMEOUT"))) {
  41. setEventMessages($langs->trans("ErrorValueMustBeInteger"), null, 'errors');
  42. $error++;
  43. }
  44. if (!$error) {
  45. $result = 0;
  46. $result += dolibarr_set_const($db, 'MAIN_USE_CONNECT_TIMEOUT', GETPOST("MAIN_USE_CONNECT_TIMEOUT"), 'chaine', 0, '', $conf->entity);
  47. $result += dolibarr_set_const($db, 'MAIN_USE_RESPONSE_TIMEOUT', GETPOST("MAIN_USE_RESPONSE_TIMEOUT"), 'chaine', 0, '', $conf->entity);
  48. $result += dolibarr_set_const($db, 'MAIN_PROXY_USE', GETPOST("MAIN_PROXY_USE"), 'chaine', 0, '', $conf->entity);
  49. $result += dolibarr_set_const($db, 'MAIN_PROXY_HOST', GETPOST("MAIN_PROXY_HOST"), 'chaine', 0, '', $conf->entity);
  50. $result += dolibarr_set_const($db, 'MAIN_PROXY_PORT', GETPOST("MAIN_PROXY_PORT"), 'chaine', 0, '', $conf->entity);
  51. $result += dolibarr_set_const($db, 'MAIN_PROXY_USER', GETPOST("MAIN_PROXY_USER"), 'chaine', 0, '', $conf->entity);
  52. $result += dolibarr_set_const($db, 'MAIN_PROXY_PASS', GETPOST("MAIN_PROXY_PASS"), 'chaine', 0, '', $conf->entity);
  53. if ($result < 5) {
  54. dol_print_error($db);
  55. }
  56. }
  57. if (!$error) {
  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("Proxy"), $wikihelp);
  67. print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
  68. print '<span class="opacitymedium">'.$langs->trans("ProxyDesc")."</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="set_proxy">';
  73. $head = security_prepare_head();
  74. print dol_get_fiche_head($head, 'proxy', '', -1);
  75. if ($conf->use_javascript_ajax) {
  76. print "\n".'<script type="text/javascript" language="javascript">';
  77. print 'jQuery(document).ready(function () {
  78. function initfields()
  79. {
  80. if (jQuery("#MAIN_PROXY_USE").val()==\'1\')
  81. {
  82. jQuery(".drag").show();
  83. }
  84. if (jQuery("#MAIN_PROXY_USE").val()==\'0\')
  85. {
  86. jQuery(".drag").hide();
  87. }
  88. }
  89. initfields();
  90. jQuery("#MAIN_PROXY_USE").change(function() {
  91. initfields();
  92. });
  93. })';
  94. print '</script>'."\n";
  95. }
  96. // Timeout
  97. print '<table width="100%" class="noborder">';
  98. print '<tr class="liste_titre">';
  99. print '<td colspan="2">'.$langs->trans("Parameters").'</td>';
  100. print '<td width="200">'.$langs->trans("Value").'</td>';
  101. print "</tr>\n";
  102. print '<tr class="oddeven">';
  103. print '<td>'.$langs->trans("ConnectionTimeout").'</td><td class="right">';
  104. print '</td>';
  105. print '<td class="nowrap">';
  106. print '<input class="flat" name="MAIN_USE_CONNECT_TIMEOUT" type="text" size="4" value="'.(GETPOSTISSET("MAIN_USE_CONNECT_TIMEOUT") ? GETPOST("MAIN_USE_CONNECT_TIMEOUT") : $conf->global->MAIN_USE_CONNECT_TIMEOUT).'">';
  107. print ' '.strtolower($langs->trans("Seconds"));
  108. print '</td>';
  109. print '</tr>';
  110. print '<tr class="oddeven">';
  111. print '<td>'.$langs->trans("ResponseTimeout").'</td><td class="right">';
  112. print '</td>';
  113. print '<td class="nowrap">';
  114. print '<input class="flat" name="MAIN_USE_RESPONSE_TIMEOUT" type="text" size="4" value="'.$conf->global->MAIN_USE_RESPONSE_TIMEOUT.'">';
  115. print ' '.strtolower($langs->trans("Seconds"));
  116. print '</td>';
  117. print '</tr>';
  118. print '<tr class="oddeven">';
  119. print '<td>'.$langs->trans("MAIN_PROXY_USE").'</td><td class="right">';
  120. print '</td>';
  121. print '<td class="nowrap">';
  122. print $form->selectyesno('MAIN_PROXY_USE', (!empty($conf->global->MAIN_PROXY_USE) ? $conf->global->MAIN_PROXY_USE : 0), 1);
  123. print '</td>';
  124. print '</tr>';
  125. print '<tr class="oddeven">';
  126. print '<td>'.$langs->trans("MAIN_PROXY_HOST").'</td><td class="right">';
  127. print '</td>';
  128. print '<td class="nowrap">';
  129. print '<input class="flat" name="MAIN_PROXY_HOST" type="text" size="16" value="'.(!empty($conf->global->MAIN_PROXY_HOST) ? $conf->global->MAIN_PROXY_HOST : '').'">';
  130. print '</td>';
  131. print '</tr>';
  132. print '<tr class="oddeven">';
  133. print '<td>'.$langs->trans("MAIN_PROXY_PORT").'</td><td class="right">';
  134. print '</td>';
  135. print '<td class="nowrap">';
  136. print '<input class="flat" name="MAIN_PROXY_PORT" type="text" size="4" value="'.(!empty($conf->global->MAIN_PROXY_PORT) ? $conf->global->MAIN_PROXY_PORT : '').'">';
  137. print '</td>';
  138. print '</tr>';
  139. print '<tr class="oddeven">';
  140. print '<td>'.$langs->trans("MAIN_PROXY_USER").'</td><td class="right">';
  141. print '</td>';
  142. print '<td class="nowrap">';
  143. print '<input class="flat" name="MAIN_PROXY_USER" type="text" size="16" value="'.(!empty($conf->global->MAIN_PROXY_USER) ? $conf->global->MAIN_PROXY_USER : '').'">';
  144. print '</td>';
  145. print '</tr>';
  146. print '<tr class="oddeven">';
  147. print '<td>'.$langs->trans("MAIN_PROXY_PASS").'</td><td class="right">';
  148. print '</td>';
  149. print '<td class="nowrap">';
  150. print '<input class="flat" name="MAIN_PROXY_PASS" type="text" size="16" value="'.(!empty($conf->global->MAIN_PROXY_PASS) ? $conf->global->MAIN_PROXY_PASS : '').'">';
  151. print '</td>';
  152. print '</tr>';
  153. print '</table>';
  154. print dol_get_fiche_end();
  155. print '<div class="center">';
  156. print '<input type="submit" class="button" name="button" value="'.$langs->trans("Modify").'">';
  157. print '</div>';
  158. print '</form>';
  159. // End of page
  160. llxFooter();
  161. $db->close();