dolibarr 21.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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Load Dolibarr environment
27require '../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
30
39// Load translation files required by the page
40$langs->loadLangs(array("other", "users", "admin"));
41
42if (!$user->admin) {
44}
45
46$upload_dir = $conf->admin->dir_temp;
47
48
49/*
50 * Actions
51 */
52$error = 0;
53
54if (GETPOST('action', 'aZ09') == 'set_proxy') {
55 if (GETPOST("MAIN_USE_CONNECT_TIMEOUT") && !is_numeric(GETPOST("MAIN_USE_CONNECT_TIMEOUT"))) {
56 setEventMessages($langs->trans("ErrorValueMustBeInteger"), null, 'errors');
57 $error++;
58 }
59 if (GETPOST("MAIN_USE_RESPONSE_TIMEOUT") && !is_numeric(GETPOST("MAIN_USE_RESPONSE_TIMEOUT"))) {
60 setEventMessages($langs->trans("ErrorValueMustBeInteger"), null, 'errors');
61 $error++;
62 }
63
64 if (!$error) {
65 $result = 0;
66 $result += dolibarr_set_const($db, 'MAIN_USE_CONNECT_TIMEOUT', GETPOST("MAIN_USE_CONNECT_TIMEOUT"), 'chaine', 0, '', $conf->entity);
67 $result += dolibarr_set_const($db, 'MAIN_USE_RESPONSE_TIMEOUT', GETPOST("MAIN_USE_RESPONSE_TIMEOUT"), 'chaine', 0, '', $conf->entity);
68 $result += dolibarr_set_const($db, 'MAIN_PROXY_USE', GETPOST("MAIN_PROXY_USE"), 'chaine', 0, '', $conf->entity);
69 $result += dolibarr_set_const($db, 'MAIN_PROXY_HOST', GETPOST("MAIN_PROXY_HOST"), 'chaine', 0, '', $conf->entity);
70 $result += dolibarr_set_const($db, 'MAIN_PROXY_PORT', GETPOST("MAIN_PROXY_PORT"), 'chaine', 0, '', $conf->entity);
71 $result += dolibarr_set_const($db, 'MAIN_PROXY_USER', GETPOST("MAIN_PROXY_USER"), 'chaine', 0, '', $conf->entity);
72 $result += dolibarr_set_const($db, 'MAIN_PROXY_PASS', GETPOST("MAIN_PROXY_PASS"), 'chaine', 0, '', $conf->entity);
73 if ($result < 5) {
74 dol_print_error($db);
75 }
76 }
77
78 if (!$error) {
79 setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
80 }
81}
82
83
84/*
85 * View
86 */
87
88$form = new Form($db);
89
90$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
91llxHeader('', $langs->trans("Proxy"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-proxy');
92
93print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
94
95print '<span class="opacitymedium">'.$langs->trans("ProxyDesc")."</span><br>\n";
96print "<br>\n";
97
98
99
100print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
101print '<input type="hidden" name="token" value="'.newToken().'">';
102print '<input type="hidden" name="action" value="set_proxy">';
103
104
105$head = security_prepare_head();
106
107print dol_get_fiche_head($head, 'proxy', '', -1);
108
109print '<br>';
110
111if ($conf->use_javascript_ajax) {
112 print "\n".'<script type="text/javascript">';
113 print 'jQuery(document).ready(function () {
114 function initfields()
115 {
116 if (jQuery("#MAIN_PROXY_USE").val()==\'1\')
117 {
118 jQuery(".drag").show();
119 }
120 if (jQuery("#MAIN_PROXY_USE").val()==\'0\')
121 {
122 jQuery(".drag").hide();
123 }
124 }
125 initfields();
126 jQuery("#MAIN_PROXY_USE").change(function() {
127 initfields();
128 });
129 })';
130 print '</script>'."\n";
131}
132
133
134// Timeout
135
136print '<table class="centpercent noborder">';
137
138print '<tr class="liste_titre">';
139print '<td colspan="2">'.$langs->trans("Parameters").'</td>';
140print '<td width="200"></td>';
141print "</tr>\n";
142
143
144print '<tr class="oddeven">';
145print '<td>'.$langs->trans("ConnectionTimeout").'</td><td class="right">';
146print '</td>';
147print '<td class="nowrap">';
148print '<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).'">';
149print ' '.strtolower($langs->trans("Seconds"));
150print '</td>';
151print '</tr>';
152
153
154print '<tr class="oddeven">';
155print '<td>'.$langs->trans("ResponseTimeout").'</td><td class="right">';
156print '</td>';
157print '<td class="nowrap">';
158print '<input class="flat" name="MAIN_USE_RESPONSE_TIMEOUT" type="text" size="4" value="' . getDolGlobalString('MAIN_USE_RESPONSE_TIMEOUT').'">';
159print ' '.strtolower($langs->trans("Seconds"));
160print '</td>';
161print '</tr>';
162
163
164print '<tr class="oddeven">';
165print '<td>'.$langs->trans("MAIN_PROXY_USE").'</td><td class="right">';
166print '</td>';
167print '<td class="nowrap">';
168print $form->selectyesno('MAIN_PROXY_USE', (getDolGlobalString('MAIN_PROXY_USE') ? $conf->global->MAIN_PROXY_USE : 0), 1);
169print '</td>';
170print '</tr>';
171
172
173print '<tr class="oddeven">';
174print '<td>'.$langs->trans("MAIN_PROXY_HOST").'</td><td class="right">';
175print '</td>';
176print '<td class="nowrap">';
177print '<input class="flat" name="MAIN_PROXY_HOST" type="text" size="16" value="'.(getDolGlobalString('MAIN_PROXY_HOST') ? $conf->global->MAIN_PROXY_HOST : '').'">';
178print '</td>';
179print '</tr>';
180
181
182print '<tr class="oddeven">';
183print '<td>'.$langs->trans("MAIN_PROXY_PORT").'</td><td class="right">';
184print '</td>';
185print '<td class="nowrap">';
186print '<input class="flat" name="MAIN_PROXY_PORT" type="text" size="4" value="'.(getDolGlobalString('MAIN_PROXY_PORT') ? $conf->global->MAIN_PROXY_PORT : '').'">';
187print '</td>';
188print '</tr>';
189
190
191print '<tr class="oddeven">';
192print '<td>'.$langs->trans("MAIN_PROXY_USER").'</td><td class="right">';
193print '</td>';
194print '<td class="nowrap">';
195print '<input class="flat" name="MAIN_PROXY_USER" type="text" size="16" value="'.(getDolGlobalString('MAIN_PROXY_USER') ? $conf->global->MAIN_PROXY_USER : '').'">';
196print '</td>';
197print '</tr>';
198
199
200print '<tr class="oddeven">';
201print '<td>'.$langs->trans("MAIN_PROXY_PASS").'</td><td class="right">';
202print '</td>';
203print '<td class="nowrap">';
204print '<input class="flat" name="MAIN_PROXY_PASS" type="text" size="16" value="'.(getDolGlobalString('MAIN_PROXY_PASS') ? $conf->global->MAIN_PROXY_PASS : '').'">';
205print '</td>';
206print '</tr>';
207
208print '</table>';
209
210print $form->buttonsSaveCancel("Modify", '');
211
212print dol_get_fiche_end();
213
214print '</form>';
215
216// End of page
217llxFooter();
218$db->close();
security_prepare_head()
Prepare array with list of tabs.
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).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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_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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.