dolibarr 21.0.0-alpha
javascript.js.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2016-2023 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26if (!defined('NOTOKENRENEWAL')) {
27 define('NOTOKENRENEWAL', 1); // Disables token renewal
28}
29if (!defined('NOLOGIN')) {
30 define("NOLOGIN", 1);
31}
32if (!defined('NOCSRFCHECK')) {
33 define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
34}
35if (!defined('NOREQUIREMENU')) {
36 define('NOREQUIREMENU', '1');
37}
38if (!defined('NOREQUIREHTML')) {
39 define('NOREQUIREHTML', '1');
40}
41if (!defined('NOREQUIREAJAX')) {
42 define('NOREQUIREAJAX', '1');
43}
44if (!defined('NOIPCHECK')) {
45 define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
46}
47if (!defined('NOBROWSERNOTIF')) {
48 define('NOBROWSERNOTIF', '1');
49}
50
71function llxHeader($head = '', $title = '', $help_url = '', $target = '', $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '', $morequerystring = '', $morecssonbody = '', $replacemainareaby = '', $disablenofollow = 0, $disablenoindex = 0)
72{
73}
82function llxFooter($comment = '', $zone = 'private', $disabledoutputofmessages = 0)
83{
84}
85
86require '../../master.inc.php';
87require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
88
89
90$error = 0;
91$website = GETPOST('website', 'alpha');
92$websiteid = GETPOSTINT('websiteid');
93$pageid = GETPOST('page', 'alpha') ? GETPOST('page', 'alpha') : GETPOST('pageid', 'alpha');
94
95$accessallowed = 1;
96$type = '';
97
98
99/*
100 * View
101 */
102
103$appli = constant('DOL_APPLICATION_TITLE');
104if (getDolGlobalString('MAIN_APPLICATION_TITLE')) {
105 $appli = getDolGlobalString('MAIN_APPLICATION_TITLE');
106}
107
108//print 'Directory with '.$appli.' websites.<br>';
109
110if (empty($pageid)) {
111 require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
112 require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
113
114 $object = new Website($db);
115 if ($websiteid) {
116 $object->fetch($websiteid);
117 $website = $object->ref;
118 } else {
119 $object->fetch(0, $website);
120 }
121
122 $objectpage = new WebsitePage($db);
123 /* Not required for CSS file
124 $array=$objectpage->fetchAll($object->id);
125
126 if (is_array($array) && count($array) > 0)
127 {
128 $firstrep=reset($array);
129 $pageid=$firstrep->id;
130 }
131 */
132}
133/* Not required for CSS file
134if (empty($pageid))
135{
136 $langs->load("website");
137 print $langs->trans("PreviewOfSiteNotYetAvailable");
138 exit;
139}
140*/
141
142// Security: Delete string ../ into $original_file
143global $dolibarr_main_data_root;
144
145$original_file = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$website.'/javascript.js.php';
146
147// Find the subdirectory name as the reference
148$refname = basename(dirname($original_file)."/");
149
150// Security:
151// Limit access if permissions are insufficient
152if (!$accessallowed) {
154}
155
156// Security:
157// On interdit les remontees de repertoire ainsi que les pipe dans
158// les noms de fichiers.
159if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) {
160 dol_syslog("Refused to deliver file ".$original_file);
161 $file = basename($original_file); // Do no show plain path of original_file in shown error message
162 dol_print_error(null, $langs->trans("ErrorFileNameInvalid", $file));
163 exit;
164}
165
166clearstatcache();
167
168$filename = basename($original_file);
169
170// Output file on browser
171dol_syslog("javascript.js.css.php include $original_file $filename content-type=$type");
172$original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset
173
174// This test if file exists should be useless. We keep it to find bug more easily
175if (!file_exists($original_file_osencoded)) {
176 $langs->load("website");
177 print $langs->trans("RequestedPageHasNoContentYet", $pageid);
178 //dol_print_error(null,$langs->trans("ErrorFileDoesNotExists",$original_file));
179 exit;
180}
181
182
183// Output page content
184define('USEDOLIBARRSERVER', 1);
185print '/* Page content '.$original_file.' : JS content that was saved into tpl dir */'."\n";
186require_once $original_file_osencoded;
187
188
189if (is_object($db)) {
190 $db->close();
191}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
Class Website.
Class Websitepage.
llxFooter()
Footer empty.
Definition document.php:107
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) if(!defined('NOIPCHECK')) if(!defined( 'NOBROWSERNOTIF')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Header empty.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.