dolibarr  16.0.1
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 
29 if (!defined('NOSCANPOSTFORINJECTION')) {
30  define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti CSRF attack test
31 }
32 
33 require '../../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
35 
36 
37 if (!$user->admin) {
39 }
40 
41 // Load translation files required by the page
42 $langs->loadLangs(array('admin', 'other', 'externalsite'));
43 
44 $action = GETPOST('action', 'aZ09');
45 
46 
47 /*
48  * Actions
49  */
50 
51 // Sauvegardes parametres
52 if ($action == 'update') {
53  $i = 0;
54 
55  $db->begin();
56 
57  $label = GETPOST('EXTERNALSITE_LABEL', 'alphanohtml');
58 
59  // exturl can be an url or a HTML string
60  $exturl = GETPOST('EXTERNALSITE_URL', 'restricthtml');
61  $exturl = dol_string_onlythesehtmltags($exturl, 1, 1, 0, 1);
62  $exturl = dol_string_onlythesehtmlattributes($exturl);
63 
64  $i += dolibarr_set_const($db, 'EXTERNALSITE_LABEL', trim($label), 'chaine', 0, '', $conf->entity);
65  $i += dolibarr_set_const($db, 'EXTERNALSITE_URL', trim($exturl), 'chaine', 0, '', $conf->entity);
66 
67  if ($i >= 2) {
68  $db->commit();
69  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
70  } else {
71  $db->rollback();
72  setEventMessages($db->lasterror(), null, 'errors');
73  }
74 }
75 
76 
81 llxHeader();
82 
83 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
84 print load_fiche_titre($langs->trans("ExternalSiteSetup"), $linkback, 'title_setup');
85 print '<br>';
86 
87 print '<span class="opacitymedium">'.$langs->trans("Module100Desc")."</span><br>\n";
88 print '<br>';
89 
90 print '<form name="externalsiteconfig" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
91 print '<input type="hidden" name="token" value="'.newToken().'">';
92 print '<input type="hidden" name="action" value="update">';
93 print "<table class=\"noborder\" width=\"100%\">";
94 
95 print "<tr class=\"liste_titre\">";
96 print "<td width=\"30%\">".$langs->trans("Parameter")."</td>";
97 print "<td>".$langs->trans("Value")."</td>";
98 print "<td>".$langs->trans("Examples")."</td>";
99 print "</tr>";
100 
101 
102 print '<tr class="oddeven">';
103 print '<td class="fieldrequired">'.$langs->trans("Label")."</td>";
104 print "<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>";
105 print "<td>".$langs->trans("ExampleMyMenuEntry")."</td>";
106 print "</tr>";
107 
108 
109 print '<tr class="oddeven">';
110 print '<td class="fieldrequired">'.$langs->trans("ExternalSiteURL")."</td>";
111 print '<td><textarea class="flat minwidth500" name="EXTERNALSITE_URL">';
112 
113 $exturl = GETPOST('EXTERNALSITE_URL', 'restricthtml');
114 $exturl = dol_string_onlythesehtmltags($exturl, 1, 1, 0, 1);
115 $exturl = dol_string_onlythesehtmlattributes($exturl);
116 
117 print (GETPOSTISSET('EXTERNALSITE_URL') ? $exturl : (empty($conf->global->EXTERNALSITE_URL) ? '' : $conf->global->EXTERNALSITE_URL));
118 print '</textarea></td>';
119 print "<td>http://localhost/myurl/";
120 print "<br>https://wikipedia.org/";
121 print "<br>&lt;iframe&gt;...&lt;/iframe&gt;";
122 print "</td>";
123 print "</tr>";
124 
125 print "</table>";
126 
127 
128 print $form->buttonsSaveCancel("Save", '');
129 
130 print "</form>\n";
131 
132 llxFooter();
133 
134 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Definition: card.php:142
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=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.
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:627
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
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 Calling this function terminate execution ...
llxFooter()
Empty footer.
Definition: wrapper.php:73