index.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. /**
  23. * \file htdocs/externalsite/admin/index.php
  24. * \ingroup externalsite
  25. * \brief Page to setup module external site
  26. */
  27. if (!defined('NOSCANPOSTFORINJECTION')) {
  28. define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti CSRF attack test
  29. }
  30. // Load Dolibarr environment
  31. require '../../main.inc.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  33. if (!$user->admin) {
  34. accessforbidden();
  35. }
  36. // Load translation files required by the page
  37. $langs->loadLangs(array('admin', 'other', 'externalsite'));
  38. $action = GETPOST('action', 'aZ09');
  39. /*
  40. * Actions
  41. */
  42. // Sauvegardes parametres
  43. if ($action == 'update') {
  44. $i = 0;
  45. $db->begin();
  46. $label = GETPOST('EXTERNALSITE_LABEL', 'alphanohtml');
  47. // exturl can be an url or a HTML string
  48. $exturl = GETPOST('EXTERNALSITE_URL', 'restricthtml');
  49. $exturl = dol_string_onlythesehtmltags($exturl, 1, 1, 0, 1, array(), 1);
  50. $exturl = dol_string_onlythesehtmlattributes($exturl);
  51. $i += dolibarr_set_const($db, 'EXTERNALSITE_LABEL', trim($label), 'chaine', 0, '', $conf->entity);
  52. $i += dolibarr_set_const($db, 'EXTERNALSITE_URL', trim($exturl), 'chaine', 0, '', $conf->entity);
  53. if ($i >= 2) {
  54. $db->commit();
  55. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  56. } else {
  57. $db->rollback();
  58. setEventMessages($db->lasterror(), null, 'errors');
  59. }
  60. }
  61. /**
  62. * View
  63. */
  64. llxHeader();
  65. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  66. print load_fiche_titre($langs->trans("ExternalSiteSetup"), $linkback, 'title_setup');
  67. print '<br>';
  68. print '<span class="opacitymedium">'.$langs->trans("Module100Desc")."</span><br>\n";
  69. print '<br>';
  70. print '<form name="externalsiteconfig" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  71. print '<input type="hidden" name="token" value="'.newToken().'">';
  72. print '<input type="hidden" name="action" value="update">';
  73. print "<table class=\"noborder\" width=\"100%\">";
  74. print "<tr class=\"liste_titre\">";
  75. print "<td width=\"30%\">".$langs->trans("Parameter")."</td>";
  76. print "<td>".$langs->trans("Value")."</td>";
  77. print "<td>".$langs->trans("Examples")."</td>";
  78. print "</tr>";
  79. print '<tr class="oddeven">';
  80. print '<td class="fieldrequired">'.$langs->trans("Label")."</td>";
  81. 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>";
  82. print "<td>".$langs->trans("ExampleMyMenuEntry")."</td>";
  83. print "</tr>";
  84. print '<tr class="oddeven">';
  85. print '<td class="fieldrequired">'.$langs->trans("ExternalSiteURL")."</td>";
  86. print '<td><textarea class="flat minwidth500" name="EXTERNALSITE_URL">';
  87. $exturl = GETPOST('EXTERNALSITE_URL', 'restricthtml');
  88. $exturl = dol_string_onlythesehtmltags($exturl, 1, 1, 0, 1, array(), 1);
  89. $exturl = dol_string_onlythesehtmlattributes($exturl);
  90. print (GETPOSTISSET('EXTERNALSITE_URL') ? $exturl : (empty($conf->global->EXTERNALSITE_URL) ? '' : $conf->global->EXTERNALSITE_URL));
  91. print '</textarea></td>';
  92. print "<td>http://localhost/myurl/";
  93. print "<br>https://wikipedia.org/";
  94. print "<br>&lt;iframe&gt;...&lt;/iframe&gt;";
  95. print "</td>";
  96. print "</tr>";
  97. print "</table>";
  98. print $form->buttonsSaveCancel("Save", '');
  99. print "</form>\n";
  100. llxFooter();
  101. $db->close();