frames.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. /* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. *
  17. */
  18. /**
  19. * \file htdocs/externalsite/frames.php
  20. * \ingroup externalsite
  21. * \brief Page that build two frames: One for menu, the other for the target page to show
  22. * Usage:
  23. * /externalsite/frames.php to show URL set into setup
  24. * /externalsite/frames.php?keyforcontent=EXTERNAL_SITE_CONTENT_abc to show html text defined into $conf->global->EXTERNAL_SITE_CONTENT_abc
  25. * /externalsite/frames.php?keyforcontent=EXTERNAL_SITE_URL_abc to show URL defined into $conf->global->EXTERNAL_SITE_URL_abc
  26. */
  27. // Load Dolibarr environment
  28. require '../main.inc.php';
  29. // Load translation files required by the page
  30. $langs->load("other");
  31. $mainmenu = GETPOST('mainmenu', "aZ09");
  32. $leftmenu = GETPOST('leftmenu', "aZ09");
  33. $idmenu = GETPOST('idmenu', 'int');
  34. $theme = GETPOST('theme', 'aZ09');
  35. $codelang = GETPOST('lang', 'aZ09');
  36. $keyforcontent = GETPOST('keyforcontent', 'aZ09');
  37. if (!isModEnabled("externalsite")) {
  38. accessforbidden('Module externalsite not enabled');
  39. }
  40. /*
  41. * View
  42. */
  43. if (empty($keyforcontent) && empty($conf->global->EXTERNALSITE_URL)) {
  44. llxHeader();
  45. print '<div class="error">'.$langs->trans('ExternalSiteModuleNotComplete').'</div>';
  46. llxFooter();
  47. exit;
  48. }
  49. if (!empty($keyforcontent)) {
  50. llxHeader();
  51. print '<div class="framecontent" style="height: '.($_SESSION['dol_screenheight'] - 90).'px">';
  52. if (!preg_match('/EXTERNAL_SITE_CONTENT_/', $keyforcontent)
  53. && !preg_match('/EXTERNAL_SITE_URL_/', $keyforcontent)) {
  54. $langs->load("errors");
  55. print $langs->trans("ErrorBadSyntaxForParamKeyForContent", 'EXTERNAL_SITE_CONTENT_', 'EXTERNAL_SITE_URL_');
  56. } elseif (!getDolGlobalString($keyforcontent)) {
  57. $langs->load("errors");
  58. print $langs->trans("ErrorVariableKeyForContentMustBeSet", 'EXTERNAL_SITE_CONTENT_'.$keyforcontent, 'EXTERNAL_SITE_URL_'.$keyforcontent);
  59. } else {
  60. if (preg_match('/EXTERNAL_SITE_CONTENT_/', $keyforcontent)) {
  61. print getDolGlobalString($keyforcontent);
  62. } elseif (preg_match('/EXTERNAL_SITE_URL_/', $keyforcontent)) {
  63. /*print "
  64. <html>
  65. <head>
  66. <title>Dolibarr frame for external web site</title>
  67. </head>
  68. <frameset ".(empty($conf->global->MAIN_MENU_INVERT)?"rows":"cols")."=\"".$heightforframes.",*\" border=0 framespacing=0 frameborder=0>
  69. <frame name=\"barre\" src=\"frametop.php?mainmenu=".$mainmenu."&leftmenu=".$leftmenu."&idmenu=".$idmenu.($theme?'&theme='.$theme:'').($codelang?'&lang='.$codelang:'')."&nobackground=1\" noresize scrolling=\"NO\" noborder>
  70. ";
  71. print '<frame name="main" src="';
  72. print getDolGlobalString($keyforcontent);
  73. print '">';
  74. print "
  75. <noframes>
  76. <body>
  77. </body>
  78. </noframes>
  79. </frameset>
  80. <noframes>
  81. <body>
  82. <br><div class=\"center\">
  83. Sorry, your browser is too old or not correctly configured to view this area.<br>
  84. Your browser must support frames.<br>
  85. </div>
  86. </body>
  87. </noframes>
  88. </html>
  89. ";*/
  90. print '<iframe src="'.getDolGlobalString($keyforcontent).'"></iframe>';
  91. }
  92. }
  93. print '<div>';
  94. llxFooter();
  95. } else {
  96. if (preg_match('/^\//', $conf->global->EXTERNALSITE_URL) || preg_match('/^http/i', $conf->global->EXTERNALSITE_URL)) {
  97. print "
  98. <html>
  99. <head>
  100. <title>Dolibarr frame for external web site</title>
  101. </head>
  102. <frameset ".(empty($conf->global->MAIN_MENU_INVERT) ? "rows" : "cols")."=\"".$heightforframes.",*\" border=0 framespacing=0 frameborder=0>
  103. <frame name=\"barre\" src=\"frametop.php?mainmenu=".$mainmenu."&leftmenu=".$leftmenu."&idmenu=".$idmenu.($theme ? '&theme='.$theme : '').($codelang ? '&lang='.$codelang : '')."&nobackground=1\" noresize scrolling=\"NO\" noborder>
  104. ";
  105. print '<frame name="main" src="';
  106. print $conf->global->EXTERNALSITE_URL;
  107. print '">';
  108. print "
  109. <noframes>
  110. <body>
  111. </body>
  112. </noframes>
  113. </frameset>
  114. <noframes>
  115. <body>
  116. <br><div class=\"center\">
  117. Sorry, your browser is too old or not correctly configured to view this area.<br>
  118. Your browser must support frames.<br>
  119. </div>
  120. </body>
  121. </noframes>
  122. </html>
  123. ";
  124. } else {
  125. llxHeader();
  126. print '<div class="framecontent" style="height: '.($_SESSION['dol_screenheight'] - 90).'px">';
  127. print $conf->global->EXTERNALSITE_URL;
  128. print '<div>';
  129. llxFooter();
  130. }
  131. }