dolibarr 20.0.2
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 *
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
25if (!defined('NOTOKENRENEWAL')) {
26 define('NOTOKENRENEWAL', 1); // Disables token renewal
27}
28if (!defined('NOLOGIN')) {
29 define("NOLOGIN", 1);
30}
31if (!defined('NOCSRFCHECK')) {
32 define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
33}
34if (!defined('NOREQUIREMENU')) {
35 define('NOREQUIREMENU', '1');
36}
37if (!defined('NOREQUIREHTML')) {
38 define('NOREQUIREHTML', '1');
39}
40if (!defined('NOREQUIREAJAX')) {
41 define('NOREQUIREAJAX', '1');
42}
43if (!defined('NOIPCHECK')) {
44 define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
45}
46if (!defined('NOBROWSERNOTIF')) {
47 define('NOBROWSERNOTIF', '1');
48}
49
55function llxHeader()
56{
57}
63function llxFooter()
64{
65}
66
67require '../../master.inc.php';
68require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
69
70
71$error = 0;
72$website = GETPOST('website', 'alpha');
73$websiteid = GETPOSTINT('websiteid');
74$pageid = GETPOST('page', 'alpha') ? GETPOST('page', 'alpha') : GETPOST('pageid', 'alpha');
75
76$accessallowed = 1;
77$type = '';
78
79
80/*
81 * View
82 */
83
84$appli = constant('DOL_APPLICATION_TITLE');
85if (getDolGlobalString('MAIN_APPLICATION_TITLE')) {
86 $appli = getDolGlobalString('MAIN_APPLICATION_TITLE');
87}
88
89//print 'Directory with '.$appli.' websites.<br>';
90
91if (empty($pageid)) {
92 require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
93 require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
94
95 $object = new Website($db);
96 if ($websiteid) {
97 $object->fetch($websiteid);
98 $website = $object->ref;
99 } else {
100 $object->fetch(0, $website);
101 }
102
103 $objectpage = new WebsitePage($db);
104 /* Not required for CSS file
105 $array=$objectpage->fetchAll($object->id);
106
107 if (is_array($array) && count($array) > 0)
108 {
109 $firstrep=reset($array);
110 $pageid=$firstrep->id;
111 }
112 */
113}
114/* Not required for CSS file
115if (empty($pageid))
116{
117 $langs->load("website");
118 print $langs->trans("PreviewOfSiteNotYetAvailable");
119 exit;
120}
121*/
122
123// Security: Delete string ../ into $original_file
124global $dolibarr_main_data_root;
125
126$original_file = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$website.'/styles.css.php';
127
128// Find the subdirectory name as the reference
129$refname = basename(dirname($original_file)."/");
130
131// Security:
132// Limit access if permissions are insufficient
133if (!$accessallowed) {
135}
136
137// Security:
138// On interdit les remontees de repertoire ainsi que les pipe dans
139// les noms de fichiers.
140if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) {
141 dol_syslog("Refused to deliver file ".$original_file);
142 $file = basename($original_file); // Do no show plain path of original_file in shown error message
143 dol_print_error(null, $langs->trans("ErrorFileNameInvalid", $file));
144 exit;
145}
146
147clearstatcache();
148
149$filename = basename($original_file);
150
151// Output file on browser
152dol_syslog("styles.css.php include $original_file $filename content-type=$type");
153$original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset
154
155// This test if file exists should be useless. We keep it to find bug more easily
156if (!file_exists($original_file_osencoded)) {
157 $langs->load("website");
158 print $langs->trans("RequestedPageHasNoContentYet", $pageid);
159 //dol_print_error(null,$langs->trans("ErrorFileDoesNotExists",$original_file));
160 exit;
161}
162
163
164// Output page content
165define('USEDOLIBARRSERVER', 1);
166print '/* Page content '.$original_file.' : CSS content that was saved into tpl dir */'."\n";
167require_once $original_file_osencoded;
168
169
170if (is_object($db)) {
171 $db->close();
172}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
Class Website.
Class Websitepage.
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 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()
Header empty.
llxFooter()
Footer empty.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.