dolibarr  16.0.5
proxy.php
Go to the documentation of this file.
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 
25 require '../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
28 
29 // Load translation files required by the page
30 $langs->loadLangs(array("other", "users", "admin"));
31 
32 if (!$user->admin) {
34 }
35 
36 $upload_dir = $conf->admin->dir_temp;
37 
38 
39 /*
40  * Actions
41  */
42 
43 if (GETPOST('action', 'aZ09') == 'set_proxy') {
44  if (GETPOST("MAIN_USE_CONNECT_TIMEOUT") && !is_numeric(GETPOST("MAIN_USE_CONNECT_TIMEOUT"))) {
45  setEventMessages($langs->trans("ErrorValueMustBeInteger"), null, 'errors');
46  $error++;
47  }
48  if (GETPOST("MAIN_USE_RESPONSE_TIMEOUT") && !is_numeric(GETPOST("MAIN_USE_RESPONSE_TIMEOUT"))) {
49  setEventMessages($langs->trans("ErrorValueMustBeInteger"), null, 'errors');
50  $error++;
51  }
52 
53  if (!$error) {
54  $result = 0;
55  $result += dolibarr_set_const($db, 'MAIN_USE_CONNECT_TIMEOUT', GETPOST("MAIN_USE_CONNECT_TIMEOUT"), 'chaine', 0, '', $conf->entity);
56  $result += dolibarr_set_const($db, 'MAIN_USE_RESPONSE_TIMEOUT', GETPOST("MAIN_USE_RESPONSE_TIMEOUT"), 'chaine', 0, '', $conf->entity);
57  $result += dolibarr_set_const($db, 'MAIN_PROXY_USE', GETPOST("MAIN_PROXY_USE"), 'chaine', 0, '', $conf->entity);
58  $result += dolibarr_set_const($db, 'MAIN_PROXY_HOST', GETPOST("MAIN_PROXY_HOST"), 'chaine', 0, '', $conf->entity);
59  $result += dolibarr_set_const($db, 'MAIN_PROXY_PORT', GETPOST("MAIN_PROXY_PORT"), 'chaine', 0, '', $conf->entity);
60  $result += dolibarr_set_const($db, 'MAIN_PROXY_USER', GETPOST("MAIN_PROXY_USER"), 'chaine', 0, '', $conf->entity);
61  $result += dolibarr_set_const($db, 'MAIN_PROXY_PASS', GETPOST("MAIN_PROXY_PASS"), 'chaine', 0, '', $conf->entity);
62  if ($result < 5) {
63  dol_print_error($db);
64  }
65  }
66 
67  if (!$error) {
68  setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
69  }
70 }
71 
72 
73 /*
74  * View
75  */
76 
77 $form = new Form($db);
78 
79 $wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
80 llxHeader('', $langs->trans("Proxy"), $wikihelp);
81 
82 print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
83 
84 print '<span class="opacitymedium">'.$langs->trans("ProxyDesc")."</span><br>\n";
85 print "<br>\n";
86 
87 
88 
89 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
90 print '<input type="hidden" name="token" value="'.newToken().'">';
91 print '<input type="hidden" name="action" value="set_proxy">';
92 
93 
94 $head = security_prepare_head();
95 
96 print dol_get_fiche_head($head, 'proxy', '', -1);
97 
98 print '<br>';
99 
100 if ($conf->use_javascript_ajax) {
101  print "\n".'<script type="text/javascript">';
102  print 'jQuery(document).ready(function () {
103  function initfields()
104  {
105  if (jQuery("#MAIN_PROXY_USE").val()==\'1\')
106  {
107  jQuery(".drag").show();
108  }
109  if (jQuery("#MAIN_PROXY_USE").val()==\'0\')
110  {
111  jQuery(".drag").hide();
112  }
113  }
114  initfields();
115  jQuery("#MAIN_PROXY_USE").change(function() {
116  initfields();
117  });
118  })';
119  print '</script>'."\n";
120 }
121 
122 
123 // Timeout
124 
125 print '<table width="100%" class="noborder">';
126 
127 print '<tr class="liste_titre">';
128 print '<td colspan="2">'.$langs->trans("Parameters").'</td>';
129 print '<td width="200">'.$langs->trans("Value").'</td>';
130 print "</tr>\n";
131 
132 
133 print '<tr class="oddeven">';
134 print '<td>'.$langs->trans("ConnectionTimeout").'</td><td class="right">';
135 print '</td>';
136 print '<td class="nowrap">';
137 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).'">';
138 print ' '.strtolower($langs->trans("Seconds"));
139 print '</td>';
140 print '</tr>';
141 
142 
143 print '<tr class="oddeven">';
144 print '<td>'.$langs->trans("ResponseTimeout").'</td><td class="right">';
145 print '</td>';
146 print '<td class="nowrap">';
147 print '<input class="flat" name="MAIN_USE_RESPONSE_TIMEOUT" type="text" size="4" value="'.$conf->global->MAIN_USE_RESPONSE_TIMEOUT.'">';
148 print ' '.strtolower($langs->trans("Seconds"));
149 print '</td>';
150 print '</tr>';
151 
152 
153 print '<tr class="oddeven">';
154 print '<td>'.$langs->trans("MAIN_PROXY_USE").'</td><td class="right">';
155 print '</td>';
156 print '<td class="nowrap">';
157 print $form->selectyesno('MAIN_PROXY_USE', (!empty($conf->global->MAIN_PROXY_USE) ? $conf->global->MAIN_PROXY_USE : 0), 1);
158 print '</td>';
159 print '</tr>';
160 
161 
162 print '<tr class="oddeven">';
163 print '<td>'.$langs->trans("MAIN_PROXY_HOST").'</td><td class="right">';
164 print '</td>';
165 print '<td class="nowrap">';
166 print '<input class="flat" name="MAIN_PROXY_HOST" type="text" size="16" value="'.(!empty($conf->global->MAIN_PROXY_HOST) ? $conf->global->MAIN_PROXY_HOST : '').'">';
167 print '</td>';
168 print '</tr>';
169 
170 
171 print '<tr class="oddeven">';
172 print '<td>'.$langs->trans("MAIN_PROXY_PORT").'</td><td class="right">';
173 print '</td>';
174 print '<td class="nowrap">';
175 print '<input class="flat" name="MAIN_PROXY_PORT" type="text" size="4" value="'.(!empty($conf->global->MAIN_PROXY_PORT) ? $conf->global->MAIN_PROXY_PORT : '').'">';
176 print '</td>';
177 print '</tr>';
178 
179 
180 print '<tr class="oddeven">';
181 print '<td>'.$langs->trans("MAIN_PROXY_USER").'</td><td class="right">';
182 print '</td>';
183 print '<td class="nowrap">';
184 print '<input class="flat" name="MAIN_PROXY_USER" type="text" size="16" value="'.(!empty($conf->global->MAIN_PROXY_USER) ? $conf->global->MAIN_PROXY_USER : '').'">';
185 print '</td>';
186 print '</tr>';
187 
188 
189 print '<tr class="oddeven">';
190 print '<td>'.$langs->trans("MAIN_PROXY_PASS").'</td><td class="right">';
191 print '</td>';
192 print '<td class="nowrap">';
193 print '<input class="flat" name="MAIN_PROXY_PASS" type="text" size="16" value="'.(!empty($conf->global->MAIN_PROXY_PASS) ? $conf->global->MAIN_PROXY_PASS : '').'">';
194 print '</td>';
195 print '</tr>';
196 
197 print '</table>';
198 
199 print dol_get_fiche_end();
200 
201 print $form->buttonsSaveCancel("Modify", '');
202 
203 print '</form>';
204 
205 // End of page
206 llxFooter();
207 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
security_prepare_head
security_prepare_head()
Prepare array with list of tabs.
Definition: admin.lib.php:772
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
$wikihelp
if($actionsave) if(!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $wikihelp
View.
Definition: agenda_xcal.php:72
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
dolibarr_set_const
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:627
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59