frames.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. /*
  38. * View
  39. */
  40. if (empty($keyforcontent) && empty($conf->global->EXTERNALSITE_URL)) {
  41. llxHeader();
  42. print '<div class="error">'.$langs->trans('ExternalSiteModuleNotComplete').'</div>';
  43. llxFooter();
  44. exit;
  45. }
  46. if (!empty($keyforcontent)) {
  47. llxHeader();
  48. print '<div class="framecontent" style="height: '.($_SESSION['dol_screenheight'] - 90).'px">';
  49. if (!preg_match('/EXTERNAL_SITE_CONTENT_/', $keyforcontent)
  50. && !preg_match('/EXTERNAL_SITE_URL_/', $keyforcontent)) {
  51. $langs->load("errors");
  52. print $langs->trans("ErrorBadSyntaxForParamKeyForContent", 'EXTERNAL_SITE_CONTENT_', 'EXTERNAL_SITE_URL_');
  53. } elseif (empty($conf->global->$keyforcontent)) {
  54. $langs->load("errors");
  55. print $langs->trans("ErrorVariableKeyForContentMustBeSet", 'EXTERNAL_SITE_CONTENT_'.$keyforcontent, 'EXTERNAL_SITE_URL_'.$keyforcontent);
  56. } else {
  57. if (preg_match('/EXTERNAL_SITE_CONTENT_/', $keyforcontent)) {
  58. print $conf->global->$keyforcontent;
  59. } elseif (preg_match('/EXTERNAL_SITE_URL_/', $keyforcontent)) {
  60. /*print "
  61. <html>
  62. <head>
  63. <title>Dolibarr frame for external web site</title>
  64. </head>
  65. <frameset ".(empty($conf->global->MAIN_MENU_INVERT)?"rows":"cols")."=\"".$heightforframes.",*\" border=0 framespacing=0 frameborder=0>
  66. <frame name=\"barre\" src=\"frametop.php?mainmenu=".$mainmenu."&leftmenu=".$leftmenu."&idmenu=".$idmenu.($theme?'&theme='.$theme:'').($codelang?'&lang='.$codelang:'')."&nobackground=1\" noresize scrolling=\"NO\" noborder>
  67. ";
  68. print '<frame name="main" src="';
  69. print $conf->global->$keyforcontent;
  70. print '">';
  71. print "
  72. <noframes>
  73. <body>
  74. </body>
  75. </noframes>
  76. </frameset>
  77. <noframes>
  78. <body>
  79. <br><div class=\"center\">
  80. Sorry, your browser is too old or not correctly configured to view this area.<br>
  81. Your browser must support frames.<br>
  82. </div>
  83. </body>
  84. </noframes>
  85. </html>
  86. ";*/
  87. print '<iframe src="'.$conf->global->$keyforcontent.'"></iframe>';
  88. }
  89. }
  90. print '<div>';
  91. llxFooter();
  92. } else {
  93. if (preg_match('/^\//', $conf->global->EXTERNALSITE_URL) || preg_match('/^http/i', $conf->global->EXTERNALSITE_URL)) {
  94. print "
  95. <html>
  96. <head>
  97. <title>Dolibarr frame for external web site</title>
  98. </head>
  99. <frameset ".(empty($conf->global->MAIN_MENU_INVERT) ? "rows" : "cols")."=\"".$heightforframes.",*\" border=0 framespacing=0 frameborder=0>
  100. <frame name=\"barre\" src=\"frametop.php?mainmenu=".$mainmenu."&leftmenu=".$leftmenu."&idmenu=".$idmenu.($theme ? '&theme='.$theme : '').($codelang ? '&lang='.$codelang : '')."&nobackground=1\" noresize scrolling=\"NO\" noborder>
  101. ";
  102. print '<frame name="main" src="';
  103. print $conf->global->EXTERNALSITE_URL;
  104. print '">';
  105. print "
  106. <noframes>
  107. <body>
  108. </body>
  109. </noframes>
  110. </frameset>
  111. <noframes>
  112. <body>
  113. <br><div class=\"center\">
  114. Sorry, your browser is too old or not correctly configured to view this area.<br>
  115. Your browser must support frames.<br>
  116. </div>
  117. </body>
  118. </noframes>
  119. </html>
  120. ";
  121. } else {
  122. llxHeader();
  123. print '<div class="framecontent" style="height: '.($_SESSION['dol_screenheight'] - 90).'px">';
  124. print $conf->global->EXTERNALSITE_URL;
  125. print '<div>';
  126. llxFooter();
  127. }
  128. }