dolibarr 18.0.6
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 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29if (!defined('NOSCANPOSTFORINJECTION')) {
30 define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti CSRF attack test
31}
32
33// Load Dolibarr environment
34require '../../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
36
37
38if (!$user->admin) {
40}
41
42// Load translation files required by the page
43$langs->loadLangs(array('admin', 'other', 'externalsite'));
44
45$action = GETPOST('action', 'aZ09');
46
47
48/*
49 * Actions
50 */
51
52// Sauvegardes parametres
53if ($action == 'update') {
54 $i = 0;
55
56 $db->begin();
57
58 $label = GETPOST('EXTERNALSITE_LABEL', 'alphanohtml');
59
60 // exturl can be an url or a HTML string
61 $exturl = GETPOST('EXTERNALSITE_URL', 'restricthtml');
62 $exturl = dol_string_onlythesehtmltags($exturl, 1, 1, 0, 1, array(), 1);
63 $exturl = dol_string_onlythesehtmlattributes($exturl);
64
65 $i += dolibarr_set_const($db, 'EXTERNALSITE_LABEL', trim($label), 'chaine', 0, '', $conf->entity);
66 $i += dolibarr_set_const($db, 'EXTERNALSITE_URL', trim($exturl), 'chaine', 0, '', $conf->entity);
67
68 if ($i >= 2) {
69 $db->commit();
70 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
71 } else {
72 $db->rollback();
73 setEventMessages($db->lasterror(), null, 'errors');
74 }
75}
76
77
82llxHeader();
83
84$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
85print load_fiche_titre($langs->trans("ExternalSiteSetup"), $linkback, 'title_setup');
86print '<br>';
87
88print '<span class="opacitymedium">'.$langs->trans("Module100Desc")."</span><br>\n";
89print '<br>';
90
91print '<form name="externalsiteconfig" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
92print '<input type="hidden" name="token" value="'.newToken().'">';
93print '<input type="hidden" name="action" value="update">';
94print "<table class=\"noborder\" width=\"100%\">";
95
96print "<tr class=\"liste_titre\">";
97print "<td width=\"30%\">".$langs->trans("Parameter")."</td>";
98print "<td>".$langs->trans("Value")."</td>";
99print "<td>".$langs->trans("Examples")."</td>";
100print "</tr>";
101
102
103print '<tr class="oddeven">';
104print '<td class="fieldrequired">'.$langs->trans("Label")."</td>";
105print "<td><input type=\"text\" class=\"flat\" name=\"EXTERNALSITE_LABEL\" value=\"".(GETPOST('EXTERNALSITE_LABEL', 'alpha') ?GETPOST('EXTERNALSITE_LABEL', 'alpha') : ((empty($conf->global->EXTERNALSITE_LABEL) || $conf->global->EXTERNALSITE_LABEL == 'ExternalSite') ? '' : $conf->global->EXTERNALSITE_LABEL))."\" size=\"12\"></td>";
106print "<td>".$langs->trans("ExampleMyMenuEntry")."</td>";
107print "</tr>";
108
109
110print '<tr class="oddeven">';
111print '<td class="fieldrequired">'.$langs->trans("ExternalSiteURL")."</td>";
112print '<td><textarea class="flat minwidth500" name="EXTERNALSITE_URL">';
113
114$exturl = GETPOST('EXTERNALSITE_URL', 'restricthtml');
115$exturl = dol_string_onlythesehtmltags($exturl, 1, 1, 0, 1, array(), 1);
116$exturl = dol_string_onlythesehtmlattributes($exturl);
117
118print (GETPOSTISSET('EXTERNALSITE_URL') ? $exturl : (empty($conf->global->EXTERNALSITE_URL) ? '' : $conf->global->EXTERNALSITE_URL));
119print '</textarea></td>';
120print "<td>http://localhost/myurl/";
121print "<br>https://wikipedia.org/";
122print "<br>&lt;iframe&gt;...&lt;/iframe&gt;";
123print "</td>";
124print "</tr>";
125
126print "</table>";
127
128
129print $form->buttonsSaveCancel("Save", '');
130
131print "</form>\n";
132
133llxFooter();
134
135$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()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array(), $allowlink=0)
Clean a string to keep only desirable HTML tags.
dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes=array("allow", "allowfullscreen", "alt", "class", "contenteditable", "data-html", "frameborder", "height", "href", "id", "name", "src", "style", "target", "title", "width"))
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.
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.