proxy.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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 <http://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. $langs->load("users");
  27. $langs->load("admin");
  28. $langs->load("other");
  29. if (!$user->admin) accessforbidden();
  30. $upload_dir=$conf->admin->dir_temp;
  31. /*
  32. * Actions
  33. */
  34. if (GETPOST('action','aZ09') == 'set_proxy')
  35. {
  36. if (GETPOST("MAIN_USE_CONNECT_TIMEOUT") && ! is_numeric(GETPOST("MAIN_USE_CONNECT_TIMEOUT")))
  37. {
  38. setEventMessages($langs->trans("ErrorValueMustBeInteger"), null, 'errors');
  39. $error++;
  40. }
  41. if (GETPOST("MAIN_USE_RESPONSE_TIMEOUT") && ! is_numeric(GETPOST("MAIN_USE_RESPONSE_TIMEOUT")))
  42. {
  43. setEventMessages($langs->trans("ErrorValueMustBeInteger"), null, 'errors');
  44. $error++;
  45. }
  46. if (! $error)
  47. {
  48. $result=0;
  49. $result+=dolibarr_set_const($db, 'MAIN_USE_CONNECT_TIMEOUT', GETPOST("MAIN_USE_CONNECT_TIMEOUT"), 'chaine',0,'',$conf->entity);
  50. $result+=dolibarr_set_const($db, 'MAIN_USE_RESPONSE_TIMEOUT', GETPOST("MAIN_USE_RESPONSE_TIMEOUT"), 'chaine',0,'',$conf->entity);
  51. $result+=dolibarr_set_const($db, 'MAIN_PROXY_USE', GETPOST("MAIN_PROXY_USE"), 'chaine',0,'',$conf->entity);
  52. $result+=dolibarr_set_const($db, 'MAIN_PROXY_HOST',GETPOST("MAIN_PROXY_HOST"),'chaine',0,'',$conf->entity);
  53. $result+=dolibarr_set_const($db, 'MAIN_PROXY_PORT',GETPOST("MAIN_PROXY_PORT"),'chaine',0,'',$conf->entity);
  54. $result+=dolibarr_set_const($db, 'MAIN_PROXY_USER',GETPOST("MAIN_PROXY_USER"),'chaine',0,'',$conf->entity);
  55. $result+=dolibarr_set_const($db, 'MAIN_PROXY_PASS',GETPOST("MAIN_PROXY_PASS"),'chaine',0,'',$conf->entity);
  56. if ($result < 5) dol_print_error($db);
  57. }
  58. if (! $error)
  59. {
  60. setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
  61. }
  62. }
  63. /*
  64. * View
  65. */
  66. $form = new Form($db);
  67. $wikihelp='EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
  68. llxHeader('',$langs->trans("Proxy"), $wikihelp);
  69. print load_fiche_titre($langs->trans("SecuritySetup"),'','title_setup');
  70. print $langs->trans("ProxyDesc")."<br>\n";
  71. print "<br>\n";
  72. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  73. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  74. print '<input type="hidden" name="action" value="set_proxy">';
  75. $head=security_prepare_head();
  76. dol_fiche_head($head, 'proxy', $langs->trans("Security"), -1);
  77. if ($conf->use_javascript_ajax)
  78. {
  79. print "\n".'<script type="text/javascript" language="javascript">';
  80. print 'jQuery(document).ready(function () {
  81. function initfields()
  82. {
  83. if (jQuery("#MAIN_PROXY_USE").val()==\'1\')
  84. {
  85. jQuery(".drag").show();
  86. }
  87. if (jQuery("#MAIN_PROXY_USE").val()==\'0\')
  88. {
  89. jQuery(".drag").hide();
  90. }
  91. }
  92. initfields();
  93. jQuery("#MAIN_PROXY_USE").change(function() {
  94. initfields();
  95. });
  96. })';
  97. print '</script>'."\n";
  98. }
  99. // Timeout
  100. $var=true;
  101. print '<table width="100%" class="noborder">';
  102. print '<tr class="liste_titre">';
  103. print '<td colspan="2">'.$langs->trans("Parameters").'</td>';
  104. print '<td width="200">'.$langs->trans("Value").'</td>';
  105. print "</tr>\n";
  106. print '<tr class="oddeven">';
  107. print '<td>'.$langs->trans("ConnectionTimeout").'</td><td align="right">';
  108. print '</td>';
  109. print '<td class="nowrap">';
  110. print '<input class="flat" name="MAIN_USE_CONNECT_TIMEOUT" type="text" size="4" value="'.(isset($_POST["MAIN_USE_CONNECT_TIMEOUT"])?GETPOST("MAIN_USE_CONNECT_TIMEOUT"):$conf->global->MAIN_USE_CONNECT_TIMEOUT).'">';
  111. print ' '.strtolower($langs->trans("Seconds"));
  112. print '</td>';
  113. print '</tr>';
  114. print '<tr class="oddeven">';
  115. print '<td>'.$langs->trans("ResponseTimeout").'</td><td align="right">';
  116. print '</td>';
  117. print '<td class="nowrap">';
  118. print '<input class="flat" name="MAIN_USE_RESPONSE_TIMEOUT" type="text" size="4" value="'.$conf->global->MAIN_USE_RESPONSE_TIMEOUT.'">';
  119. print ' '.strtolower($langs->trans("Seconds"));
  120. print '</td>';
  121. print '</tr>';
  122. print '<tr class="oddeven">';
  123. print '<td>'.$langs->trans("MAIN_PROXY_USE").'</td><td align="right">';
  124. print '</td>';
  125. print '<td class="nowrap">';
  126. print $form->selectyesno('MAIN_PROXY_USE',$conf->global->MAIN_PROXY_USE,1);
  127. print '</td>';
  128. print '</tr>';
  129. print '<tr '.$bcdd[$var].'>';
  130. print '<td>'.$langs->trans("MAIN_PROXY_HOST").'</td><td align="right">';
  131. print '</td>';
  132. print '<td class="nowrap">';
  133. print '<input class="flat" name="MAIN_PROXY_HOST" type="text" size="16" value="'.$conf->global->MAIN_PROXY_HOST.'">';
  134. print '</td>';
  135. print '</tr>';
  136. print '<tr '.$bcdd[$var].'>';
  137. print '<td>'.$langs->trans("MAIN_PROXY_PORT").'</td><td align="right">';
  138. print '</td>';
  139. print '<td class="nowrap">';
  140. print '<input class="flat" name="MAIN_PROXY_PORT" type="text" size="4" value="'.$conf->global->MAIN_PROXY_PORT.'">';
  141. print '</td>';
  142. print '</tr>';
  143. print '<tr '.$bcdd[$var].'>';
  144. print '<td>'.$langs->trans("MAIN_PROXY_USER").'</td><td align="right">';
  145. print '</td>';
  146. print '<td class="nowrap">';
  147. print '<input class="flat" name="MAIN_PROXY_USER" type="text" size="16" value="'.$conf->global->MAIN_PROXY_USER.'">';
  148. print '</td>';
  149. print '</tr>';
  150. print '<tr '.$bcdd[$var].'>';
  151. print '<td>'.$langs->trans("MAIN_PROXY_PASS").'</td><td align="right">';
  152. print '</td>';
  153. print '<td class="nowrap">';
  154. print '<input class="flat" name="MAIN_PROXY_PASS" type="text" size="16" value="'.$conf->global->MAIN_PROXY_PASS.'">';
  155. print '</td>';
  156. print '</tr>';
  157. print '</table>';
  158. dol_fiche_end();
  159. print '<div class="center">';
  160. print '<input type="submit" class="button" name="button" value="'.$langs->trans("Modify").'">';
  161. print '</div>';
  162. print '</form>';
  163. llxFooter();
  164. $db->close();