dolibarr 25.0.0-alpha
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';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
37
38// Load translation files required by the page
39$langs->loadLangs(array("other", "users", "admin"));
40
41if (!$user->admin) {
43}
44
45$upload_dir = $conf->admin->dir_temp;
46
47
48/*
49 * Actions
50 */
51$error = 0;
52
53if (GETPOST('action', 'aZ09') == 'set_proxy') {
54 if (GETPOST("MAIN_USE_CONNECT_TIMEOUT") && !is_numeric(GETPOST("MAIN_USE_CONNECT_TIMEOUT"))) {
55 setEventMessages($langs->trans("ErrorValueMustBeInteger"), null, 'errors');
56 $error++;
57 }
58 if (GETPOST("MAIN_USE_RESPONSE_TIMEOUT") && !is_numeric(GETPOST("MAIN_USE_RESPONSE_TIMEOUT"))) {
59 setEventMessages($langs->trans("ErrorValueMustBeInteger"), null, 'errors');
60 $error++;
61 }
62
63 if (!$error) {
64 $result = 0;
65 $result += dolibarr_set_const($db, 'MAIN_USE_CONNECT_TIMEOUT', GETPOST("MAIN_USE_CONNECT_TIMEOUT"), 'chaine', 0, '', $conf->entity);
66 $result += dolibarr_set_const($db, 'MAIN_USE_RESPONSE_TIMEOUT', GETPOST("MAIN_USE_RESPONSE_TIMEOUT"), 'chaine', 0, '', $conf->entity);
67 $result += dolibarr_set_const($db, 'MAIN_PROXY_USE', GETPOST("MAIN_PROXY_USE"), 'chaine', 0, '', $conf->entity);
68 $result += dolibarr_set_const($db, 'MAIN_PROXY_HOST', GETPOST("MAIN_PROXY_HOST"), 'chaine', 0, '', $conf->entity);
69 $result += dolibarr_set_const($db, 'MAIN_PROXY_PORT', GETPOST("MAIN_PROXY_PORT"), 'chaine', 0, '', $conf->entity);
70 $result += dolibarr_set_const($db, 'MAIN_PROXY_USER', GETPOST("MAIN_PROXY_USER"), 'chaine', 0, '', $conf->entity);
71 $result += dolibarr_set_const($db, 'MAIN_PROXY_PASS', GETPOST("MAIN_PROXY_PASS"), 'chaine', 0, '', $conf->entity);
72 if ($result < 5) {
74 }
75 }
76
77 if (!$error) {
78 setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
79 }
80}
81
82
83/*
84 * View
85 */
86
87$form = new Form($db);
88
89$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
90llxHeader('', $langs->trans("Proxy"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-proxy');
91
92print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
93
94print '<div class="info">'.$langs->trans("ProxyDesc")."</div>\n";
95
96
97print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" spellcheck="false">';
98print '<input type="hidden" name="token" value="'.newToken().'">';
99print '<input type="hidden" name="action" value="set_proxy">';
100
101
102$head = security_prepare_head();
103
104print dol_get_fiche_head($head, 'proxy', '', -1);
105
106print '<br>';
107
108if ($conf->use_javascript_ajax) {
109 print "\n".'<script type="text/javascript">';
110 print 'jQuery(document).ready(function () {
111 function initfields()
112 {
113 if (jQuery("#MAIN_PROXY_USE").val()==\'1\')
114 {
115 jQuery(".drag").show();
116 }
117 if (jQuery("#MAIN_PROXY_USE").val()==\'0\')
118 {
119 jQuery(".drag").hide();
120 }
121 }
122 initfields();
123 jQuery("#MAIN_PROXY_USE").change(function() {
124 initfields();
125 });
126 })';
127 print '</script>'."\n";
128}
129
130
131// Timeout
132
133print '<table class="centpercent noborder">';
134
135print '<tr class="liste_titre">';
136print '<td colspan="2">'.$langs->trans("Parameters").'</td>';
137print '<td width="200"></td>';
138print "</tr>\n";
139
140
141print '<tr class="oddeven">';
142print '<td>'.$langs->trans("ConnectionTimeout").'</td><td class="right">';
143print '</td>';
144print '<td class="nowrap">';
145print '<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).'">';
146print ' '.strtolower($langs->trans("Seconds"));
147print '</td>';
148print '</tr>';
149
150
151print '<tr class="oddeven">';
152print '<td>'.$langs->trans("ResponseTimeout").'</td><td class="right">';
153print '</td>';
154print '<td class="nowrap">';
155print '<input class="flat" name="MAIN_USE_RESPONSE_TIMEOUT" type="text" size="4" value="' . getDolGlobalString('MAIN_USE_RESPONSE_TIMEOUT').'">';
156print ' '.strtolower($langs->trans("Seconds"));
157print '</td>';
158print '</tr>';
159
160
161print '<tr class="oddeven">';
162print '<td>'.$langs->trans("MAIN_PROXY_USE").'</td><td class="right">';
163print '</td>';
164print '<td class="nowrap">';
165print $form->selectyesno('MAIN_PROXY_USE', getDolGlobalInt('MAIN_PROXY_USE'), 1);
166print '</td>';
167print '</tr>';
168
169
170print '<tr class="oddeven">';
171print '<td>'.$langs->trans("MAIN_PROXY_HOST").'</td><td class="right">';
172print '</td>';
173print '<td class="nowrap">';
174print '<input class="flat" name="MAIN_PROXY_HOST" type="text" size="16" value="'.getDolGlobalString('MAIN_PROXY_HOST').'">';
175print '</td>';
176print '</tr>';
177
178
179print '<tr class="oddeven">';
180print '<td>'.$langs->trans("MAIN_PROXY_PORT").'</td><td class="right">';
181print '</td>';
182print '<td class="nowrap">';
183print '<input class="flat" name="MAIN_PROXY_PORT" type="text" size="4" value="'.getDolGlobalInt('MAIN_PROXY_PORT').'">';
184print '</td>';
185print '</tr>';
186
187
188print '<tr class="oddeven">';
189print '<td>'.$langs->trans("MAIN_PROXY_USER").'</td><td class="right">';
190print '</td>';
191print '<td class="nowrap">';
192print '<input class="flat" name="MAIN_PROXY_USER" type="text" size="16" value="'.getDolGlobalString('MAIN_PROXY_USER').'">';
193print '</td>';
194print '</tr>';
195
196
197print '<tr class="oddeven">';
198print '<td>'.$langs->trans("MAIN_PROXY_PASS").'</td><td class="right">';
199print '</td>';
200print '<td class="nowrap">';
201print '<input class="flat" name="MAIN_PROXY_PASS" type="password" size="16" value="'.getDolGlobalString('MAIN_PROXY_PASS').'">';
202print '</td>';
203print '</tr>';
204
205print '</table>';
206
207print $form->buttonsSaveCancel("Modify", '');
208
209print dol_get_fiche_end();
210
211print '</form>';
212
213// End of page
214llxFooter();
215$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).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
Class to manage generation of HTML components Only common components must be here.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:519
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:717
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.