frames.php 4.7 KB

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