frames.php 4.7 KB

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