index.php 4.4 KB

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