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