dolibarr 21.0.0-beta
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2003 Eric Seigne <erics@rycks.com>
4 * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
6 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
7 * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
8 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30if (!defined('NOSCANPOSTFORINJECTION')) {
31 define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti CSRF attack test
32}
33
34// Load Dolibarr environment
35require '../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
37
47// Load translation files required by the page
48$langs->loadLangs(array('admin', 'other', 'externalsite'));
49
50if (!$user->admin) {
52}
53
54$action = GETPOST('action', 'aZ09');
55
56
57/*
58 * Actions
59 */
60
61// Sauvegardes parameters
62if ($action == 'update') {
63 $i = 0;
64
65 $db->begin();
66
67 $label = GETPOST('EXTERNALSITE_LABEL', 'alphanohtml');
68
69 // exturl can be an url or a HTML string
70 $exturl = GETPOST('EXTERNALSITE_URL', 'restricthtml');
71 $exturl = dol_string_onlythesehtmltags($exturl, 1, 1, 0, 1, array(), 1);
72 $exturl = dol_string_onlythesehtmlattributes($exturl);
73
74 $i += dolibarr_set_const($db, 'EXTERNALSITE_LABEL', trim($label), 'chaine', 0, '', $conf->entity);
75 $i += dolibarr_set_const($db, 'EXTERNALSITE_URL', trim($exturl), 'chaine', 0, '', $conf->entity);
76
77 if ($i >= 2) {
78 $db->commit();
79 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
80 } else {
81 $db->rollback();
82 setEventMessages($db->lasterror(), null, 'errors');
83 }
84}
85
86
91llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-externalsite page-index');
92
93$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
94print load_fiche_titre($langs->trans("ExternalSiteSetup"), $linkback, 'title_setup');
95print '<br>';
96
97print '<span class="opacitymedium">'.$langs->trans("Module100Desc")."</span><br>\n";
98print '<br>';
99
100print '<form name="externalsiteconfig" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
101print '<input type="hidden" name="token" value="'.newToken().'">';
102print '<input type="hidden" name="action" value="update">';
103print "<table class=\"noborder\" width=\"100%\">";
104
105print "<tr class=\"liste_titre\">";
106print "<td width=\"30%\">".$langs->trans("Parameter")."</td>";
107print "<td>".$langs->trans("Value")."</td>";
108print "<td>".$langs->trans("Examples")."</td>";
109print "</tr>";
110
111
112print '<tr class="oddeven">';
113print '<td class="fieldrequired">'.$langs->trans("Label")."</td>";
114print "<td><input type=\"text\" class=\"flat\" name=\"EXTERNALSITE_LABEL\" value=\"".(GETPOST('EXTERNALSITE_LABEL', 'alpha') ? GETPOST('EXTERNALSITE_LABEL', 'alpha') : ((!getDolGlobalString('EXTERNALSITE_LABEL') || getDolGlobalString('EXTERNALSITE_LABEL') == 'ExternalSite') ? '' : $conf->global->EXTERNALSITE_LABEL))."\" size=\"12\"></td>";
115print "<td>".$langs->trans("ExampleMyMenuEntry")."</td>";
116print "</tr>";
117
118
119print '<tr class="oddeven">';
120print '<td class="fieldrequired">'.$langs->trans("ExternalSiteURL")."</td>";
121print '<td><textarea class="flat minwidth500" name="EXTERNALSITE_URL">';
122
123$exturl = GETPOST('EXTERNALSITE_URL', 'restricthtml');
124$exturl = dol_string_onlythesehtmltags($exturl, 1, 1, 0, 1, array(), 1);
125$exturl = dol_string_onlythesehtmlattributes($exturl);
126
127print(GETPOSTISSET('EXTERNALSITE_URL') ? $exturl : (!getDolGlobalString('EXTERNALSITE_URL') ? '' : $conf->global->EXTERNALSITE_URL));
128print '</textarea></td>';
129print "<td>http://localhost/myurl/";
130print "<br>https://wikipedia.org/";
131print "<br>&lt;iframe&gt;...&lt;/iframe&gt;";
132print "</td>";
133print "</tr>";
134
135print "</table>";
136
137
138print $form->buttonsSaveCancel("Save", '');
139
140print "</form>\n";
141
142llxFooter();
143
144$db->close();
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
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_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array(), $allowlink=0, $allowscript=0, $allowstyle=0)
Clean a string to keep only desirable HTML tags.
dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes=null)
Clean a string from some undesirable HTML tags.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.