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