dolibarr  7.0.0-beta
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 <http://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 $langs->load("users");
30 $langs->load("admin");
31 $langs->load("other");
32 
33 
34 if (!$user->admin) accessforbidden();
35 
36 $upload_dir=$conf->admin->dir_temp;
37 
38 
39 /*
40  * Actions
41  */
42 
43 if (GETPOST('action','aZ09') == 'set_proxy')
44 {
45  if (GETPOST("MAIN_USE_CONNECT_TIMEOUT") && ! is_numeric(GETPOST("MAIN_USE_CONNECT_TIMEOUT")))
46  {
47  setEventMessages($langs->trans("ErrorValueMustBeInteger"), null, 'errors');
48  $error++;
49  }
50  if (GETPOST("MAIN_USE_RESPONSE_TIMEOUT") && ! is_numeric(GETPOST("MAIN_USE_RESPONSE_TIMEOUT")))
51  {
52  setEventMessages($langs->trans("ErrorValueMustBeInteger"), null, 'errors');
53  $error++;
54  }
55 
56  if (! $error)
57  {
58  $result=0;
59  $result+=dolibarr_set_const($db, 'MAIN_USE_CONNECT_TIMEOUT', GETPOST("MAIN_USE_CONNECT_TIMEOUT"), 'chaine',0,'',$conf->entity);
60  $result+=dolibarr_set_const($db, 'MAIN_USE_RESPONSE_TIMEOUT', GETPOST("MAIN_USE_RESPONSE_TIMEOUT"), 'chaine',0,'',$conf->entity);
61  $result+=dolibarr_set_const($db, 'MAIN_PROXY_USE', GETPOST("MAIN_PROXY_USE"), 'chaine',0,'',$conf->entity);
62  $result+=dolibarr_set_const($db, 'MAIN_PROXY_HOST',GETPOST("MAIN_PROXY_HOST"),'chaine',0,'',$conf->entity);
63  $result+=dolibarr_set_const($db, 'MAIN_PROXY_PORT',GETPOST("MAIN_PROXY_PORT"),'chaine',0,'',$conf->entity);
64  $result+=dolibarr_set_const($db, 'MAIN_PROXY_USER',GETPOST("MAIN_PROXY_USER"),'chaine',0,'',$conf->entity);
65  $result+=dolibarr_set_const($db, 'MAIN_PROXY_PASS',GETPOST("MAIN_PROXY_PASS"),'chaine',0,'',$conf->entity);
66  if ($result < 5) dol_print_error($db);
67  }
68 
69  if (! $error)
70  {
71  setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
72  }
73 }
74 
75 
76 /*
77  * View
78  */
79 
80 $form = new Form($db);
81 
82 $wikihelp='EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
83 llxHeader('',$langs->trans("Proxy"), $wikihelp);
84 
85 print load_fiche_titre($langs->trans("SecuritySetup"),'','title_setup');
86 
87 print $langs->trans("ProxyDesc")."<br>\n";
88 print "<br>\n";
89 
90 
91 
92 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
93 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
94 print '<input type="hidden" name="action" value="set_proxy">';
95 
96 
97 $head=security_prepare_head();
98 
99 dol_fiche_head($head, 'proxy', $langs->trans("Security"), -1);
100 
101 
102 if ($conf->use_javascript_ajax)
103 {
104  print "\n".'<script type="text/javascript" language="javascript">';
105  print 'jQuery(document).ready(function () {
106  function initfields()
107  {
108  if (jQuery("#MAIN_PROXY_USE").val()==\'1\')
109  {
110  jQuery(".drag").show();
111  }
112  if (jQuery("#MAIN_PROXY_USE").val()==\'0\')
113  {
114  jQuery(".drag").hide();
115  }
116  }
117  initfields();
118  jQuery("#MAIN_PROXY_USE").change(function() {
119  initfields();
120  });
121  })';
122  print '</script>'."\n";
123 }
124 
125 
126 // Timeout
127 $var=true;
128 
129 print '<table width="100%" class="noborder">';
130 
131 print '<tr class="liste_titre">';
132 print '<td colspan="2">'.$langs->trans("Parameters").'</td>';
133 print '<td width="200">'.$langs->trans("Value").'</td>';
134 print "</tr>\n";
135 
136 
137 print '<tr class="oddeven">';
138 print '<td>'.$langs->trans("ConnectionTimeout").'</td><td align="right">';
139 print '</td>';
140 print '<td class="nowrap">';
141 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).'">';
142 print ' '.strtolower($langs->trans("Seconds"));
143 print '</td>';
144 print '</tr>';
145 
146 
147 print '<tr class="oddeven">';
148 print '<td>'.$langs->trans("ResponseTimeout").'</td><td align="right">';
149 print '</td>';
150 print '<td class="nowrap">';
151 print '<input class="flat" name="MAIN_USE_RESPONSE_TIMEOUT" type="text" size="4" value="'.$conf->global->MAIN_USE_RESPONSE_TIMEOUT.'">';
152 print ' '.strtolower($langs->trans("Seconds"));
153 print '</td>';
154 print '</tr>';
155 
156 
157 print '<tr class="oddeven">';
158 print '<td>'.$langs->trans("MAIN_PROXY_USE").'</td><td align="right">';
159 print '</td>';
160 print '<td class="nowrap">';
161 print $form->selectyesno('MAIN_PROXY_USE',$conf->global->MAIN_PROXY_USE,1);
162 print '</td>';
163 print '</tr>';
164 
165 
166 print '<tr '.$bcdd[$var].'>';
167 print '<td>'.$langs->trans("MAIN_PROXY_HOST").'</td><td align="right">';
168 print '</td>';
169 print '<td class="nowrap">';
170 print '<input class="flat" name="MAIN_PROXY_HOST" type="text" size="16" value="'.$conf->global->MAIN_PROXY_HOST.'">';
171 print '</td>';
172 print '</tr>';
173 
174 
175 print '<tr '.$bcdd[$var].'>';
176 print '<td>'.$langs->trans("MAIN_PROXY_PORT").'</td><td align="right">';
177 print '</td>';
178 print '<td class="nowrap">';
179 print '<input class="flat" name="MAIN_PROXY_PORT" type="text" size="4" value="'.$conf->global->MAIN_PROXY_PORT.'">';
180 print '</td>';
181 print '</tr>';
182 
183 
184 print '<tr '.$bcdd[$var].'>';
185 print '<td>'.$langs->trans("MAIN_PROXY_USER").'</td><td align="right">';
186 print '</td>';
187 print '<td class="nowrap">';
188 print '<input class="flat" name="MAIN_PROXY_USER" type="text" size="16" value="'.$conf->global->MAIN_PROXY_USER.'">';
189 print '</td>';
190 print '</tr>';
191 
192 
193 print '<tr '.$bcdd[$var].'>';
194 print '<td>'.$langs->trans("MAIN_PROXY_PASS").'</td><td align="right">';
195 print '</td>';
196 print '<td class="nowrap">';
197 print '<input class="flat" name="MAIN_PROXY_PASS" type="text" size="16" value="'.$conf->global->MAIN_PROXY_PASS.'">';
198 print '</td>';
199 print '</tr>';
200 
201 print '</table>';
202 
203 dol_fiche_end();
204 
205 print '<div class="center">';
206 print '<input type="submit" class="button" name="button" value="'.$langs->trans("Modify").'">';
207 print '</div>';
208 
209 print '</form>';
210 
211 llxFooter();
212 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
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:485
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
if(GETPOST('button_removefilter_x','alpha')||GETPOST('button_removefilter.x','alpha')||GETPOST('button_removefilter','alpha')) if($action=="save"&&empty($cancel)) if(preg_match('/set_(.*)/', $action, $reg)) if(preg_match('/del_(.*)/', $action, $reg) $wikihelp)
View.
Definition: agenda.php:143
dol_fiche_end($notab=0)
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
security_prepare_head()
Prepare array with list of tabs.
Definition: admin.lib.php:581
print
Draft customers invoices.
Definition: index.php:91