dolibarr 24.0.0-beta
frames.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 *
18 */
19
30// Load Dolibarr environment
31require '../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
33
46// Load translation files required by the page
47$langs->load("other");
48
49
50$mainmenu = GETPOST('mainmenu', "aZ09");
51$leftmenu = GETPOST('leftmenu', "aZ09");
52$idmenu = GETPOSTINT('idmenu');
53$theme = GETPOST('theme', 'aZ09');
54$codelang = GETPOST('lang', 'aZ09');
55
56$menu = new Menubase($db);
57$menu->fetch($idmenu);
58
59if (!$menu->id || empty($menu->showtopmenuinframe)) {
60 accessforbidden('Parameter idmenu is wrong. Must be the ID of a menu entry allowed to be output into a frame');
61}
62
63
64
65/*
66 * View
67 */
68
69// The content of the top frame
70if (GETPOST('top')) {
71 top_htmlhead("", "");
72
73 print '<body id="mainbody">'."\n";
74
75 top_menu("", "", "_top");
76
77 print '</body>';
78
79 exit;
80}
81
82$reg = array();
83
84$keyforcontent = '';
85if (preg_match('/^__[(.+)]__$/', $menu->url, $reg)) {
86 $keyforcontent = $reg[1];
87}
88
89if ($keyforcontent) {
90 llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-externalsite page-frames');
91
92 print '<div class="framecontent" style="height: '.($_SESSION['dol_screenheight'] - 90).'px">';
93
94 if (!getDolGlobalString($keyforcontent)) {
95 $langs->load("errors");
96 print $langs->trans("ErrorVariableKeyForContentMustBeSet", $keyforcontent, $keyforcontent);
97 } else {
98 if (preg_match('/EXTERNAL_SITE_URL_/', $keyforcontent)) {
99 print '<iframe src="'.getDolGlobalString($keyforcontent).'"></iframe>';
100 } else {
101 print getDolGlobalString($keyforcontent);
102 }
103 }
104
105 print '<div>';
106 llxFooter();
107} else {
108 if (preg_match('/^\//', $menu->url) || preg_match('/^http/i', $menu->url)) {
109 // menu->url is an URL starting with http or /
110 print "
111 <html>
112 <head>
113 <title>Dolibarr frame for external web site</title>
114 </head>
115
116 <frameset ".(!getDolGlobalString('MAIN_MENU_INVERT') ? "rows" : "cols")."=\"".$heightforframes.",*\" border=0 framespacing=0 frameborder=0>
117 <frame name=\"barre\" src=\"".$_SERVER["PHP_SELF"]."?top=1&mainmenu=".$mainmenu."&leftmenu=".$leftmenu."&idmenu=".$idmenu.($theme ? '&theme='.$theme : '').($codelang ? '&lang='.$codelang : '')."&nobackground=1\" noresize scrolling=\"NO\" noborder>
118 ";
119 print '<frame name="main" src="';
120 print $menu->url;
121 print '">';
122 print "
123 <noframes>
124 <body>
125
126 </body>
127 </noframes>
128 </frameset>
129
130 <noframes>
131 <body>
132 <br><div class=\"center\">
133 Sorry, your browser is too old or not correctly configured to view this area.<br>
134 Your browser must support frames.<br>
135 </div>
136 </body>
137 </noframes>
138
139 </html>
140 ";
141 } else {
142 // menu->url is an URL starting with http or /
143 llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-externalsite page-frames');
144 print '<div class="framecontent" style="height: '.($_SESSION['dol_screenheight'] - 90).'px">';
145 print $menu->url;
146 print '<div>';
147 llxFooter();
148 }
149}
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage menu entries.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $morequerystring='', $helppagename='')
Show an HTML header + a BODY + The top menu bar.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.