proxy.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. print '<br>';
  76. if ($conf->use_javascript_ajax) {
  77. print "\n".'<script type="text/javascript">';
  78. print 'jQuery(document).ready(function () {
  79. function initfields()
  80. {
  81. if (jQuery("#MAIN_PROXY_USE").val()==\'1\')
  82. {
  83. jQuery(".drag").show();
  84. }
  85. if (jQuery("#MAIN_PROXY_USE").val()==\'0\')
  86. {
  87. jQuery(".drag").hide();
  88. }
  89. }
  90. initfields();
  91. jQuery("#MAIN_PROXY_USE").change(function() {
  92. initfields();
  93. });
  94. })';
  95. print '</script>'."\n";
  96. }
  97. // Timeout
  98. print '<table width="100%" class="noborder">';
  99. print '<tr class="liste_titre">';
  100. print '<td colspan="2">'.$langs->trans("Parameters").'</td>';
  101. print '<td width="200">'.$langs->trans("Value").'</td>';
  102. print "</tr>\n";
  103. print '<tr class="oddeven">';
  104. print '<td>'.$langs->trans("ConnectionTimeout").'</td><td class="right">';
  105. print '</td>';
  106. print '<td class="nowrap">';
  107. 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).'">';
  108. print ' '.strtolower($langs->trans("Seconds"));
  109. print '</td>';
  110. print '</tr>';
  111. print '<tr class="oddeven">';
  112. print '<td>'.$langs->trans("ResponseTimeout").'</td><td class="right">';
  113. print '</td>';
  114. print '<td class="nowrap">';
  115. print '<input class="flat" name="MAIN_USE_RESPONSE_TIMEOUT" type="text" size="4" value="'.$conf->global->MAIN_USE_RESPONSE_TIMEOUT.'">';
  116. print ' '.strtolower($langs->trans("Seconds"));
  117. print '</td>';
  118. print '</tr>';
  119. print '<tr class="oddeven">';
  120. print '<td>'.$langs->trans("MAIN_PROXY_USE").'</td><td class="right">';
  121. print '</td>';
  122. print '<td class="nowrap">';
  123. print $form->selectyesno('MAIN_PROXY_USE', (!empty($conf->global->MAIN_PROXY_USE) ? $conf->global->MAIN_PROXY_USE : 0), 1);
  124. print '</td>';
  125. print '</tr>';
  126. print '<tr class="oddeven">';
  127. print '<td>'.$langs->trans("MAIN_PROXY_HOST").'</td><td class="right">';
  128. print '</td>';
  129. print '<td class="nowrap">';
  130. print '<input class="flat" name="MAIN_PROXY_HOST" type="text" size="16" value="'.(!empty($conf->global->MAIN_PROXY_HOST) ? $conf->global->MAIN_PROXY_HOST : '').'">';
  131. print '</td>';
  132. print '</tr>';
  133. print '<tr class="oddeven">';
  134. print '<td>'.$langs->trans("MAIN_PROXY_PORT").'</td><td class="right">';
  135. print '</td>';
  136. print '<td class="nowrap">';
  137. print '<input class="flat" name="MAIN_PROXY_PORT" type="text" size="4" value="'.(!empty($conf->global->MAIN_PROXY_PORT) ? $conf->global->MAIN_PROXY_PORT : '').'">';
  138. print '</td>';
  139. print '</tr>';
  140. print '<tr class="oddeven">';
  141. print '<td>'.$langs->trans("MAIN_PROXY_USER").'</td><td class="right">';
  142. print '</td>';
  143. print '<td class="nowrap">';
  144. print '<input class="flat" name="MAIN_PROXY_USER" type="text" size="16" value="'.(!empty($conf->global->MAIN_PROXY_USER) ? $conf->global->MAIN_PROXY_USER : '').'">';
  145. print '</td>';
  146. print '</tr>';
  147. print '<tr class="oddeven">';
  148. print '<td>'.$langs->trans("MAIN_PROXY_PASS").'</td><td class="right">';
  149. print '</td>';
  150. print '<td class="nowrap">';
  151. print '<input class="flat" name="MAIN_PROXY_PASS" type="text" size="16" value="'.(!empty($conf->global->MAIN_PROXY_PASS) ? $conf->global->MAIN_PROXY_PASS : '').'">';
  152. print '</td>';
  153. print '</tr>';
  154. print '</table>';
  155. print dol_get_fiche_end();
  156. print $form->buttonsSaveCancel("Modify", '');
  157. print '</form>';
  158. // End of page
  159. llxFooter();
  160. $db->close();