dolibarr 21.0.0-beta
styles.css.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2016-2017 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';
94$error = 0;
95$website = GETPOST('website', 'alpha');
96$websiteid = GETPOSTINT('websiteid');
97$pageid = GETPOST('page', 'alpha') ? GETPOST('page', 'alpha') : GETPOST('pageid', 'alpha');
98
99$accessallowed = 1;
100$type = '';
101
102
103/*
104 * View
105 */
106
107$appli = constant('DOL_APPLICATION_TITLE');
108if (getDolGlobalString('MAIN_APPLICATION_TITLE')) {
109 $appli = getDolGlobalString('MAIN_APPLICATION_TITLE');
110}
111
112//print 'Directory with '.$appli.' websites.<br>';
113
114if (empty($pageid)) {
115 require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
116 require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
117
118 $object = new Website($db);
119 if ($websiteid) {
120 $object->fetch($websiteid);
121 $website = $object->ref;
122 } else {
123 $object->fetch(0, $website);
124 }
125
126 $objectpage = new WebsitePage($db);
127 /* Not required for CSS file
128 $array=$objectpage->fetchAll($object->id);
129
130 if (is_array($array) && count($array) > 0)
131 {
132 $firstrep=reset($array);
133 $pageid=$firstrep->id;
134 }
135 */
136}
137/* Not required for CSS file
138if (empty($pageid))
139{
140 $langs->load("website");
141 print $langs->trans("PreviewOfSiteNotYetAvailable");
142 exit;
143}
144*/
145
146// Security: Delete string ../ into $original_file
147global $dolibarr_main_data_root;
148
149$original_file = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$website.'/styles.css.php';
150
151// Find the subdirectory name as the reference
152$refname = basename(dirname($original_file)."/");
153
154// Security:
155// Limit access if permissions are insufficient
156if (!$accessallowed) {
158}
159
160// Security:
161// On interdit les remontees de repertoire ainsi que les pipe dans
162// les noms de fichiers.
163if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) {
164 dol_syslog("Refused to deliver file ".$original_file);
165 $file = basename($original_file); // Do no show plain path of original_file in shown error message
166 dol_print_error(null, $langs->trans("ErrorFileNameInvalid", $file));
167 exit;
168}
169
170clearstatcache();
171
172$filename = basename($original_file);
173
174// Output file on browser
175dol_syslog("styles.css.php include $original_file $filename content-type=$type");
176$original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset
177
178// This test if file exists should be useless. We keep it to find bug more easily
179if (!file_exists($original_file_osencoded)) {
180 $langs->load("website");
181 print $langs->trans("RequestedPageHasNoContentYet", $pageid);
182 //dol_print_error(null,$langs->trans("ErrorFileDoesNotExists",$original_file));
183 exit;
184}
185
186
187// Output page content
188define('USEDOLIBARRSERVER', 1);
189print '/* Page content '.$original_file.' : CSS content that was saved into tpl dir */'."\n";
190require_once $original_file_osencoded;
191
192
193if (is_object($db)) {
194 $db->close();
195}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
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.