dolibarr  16.0.5
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 
24 if (!defined('NOTOKENRENEWAL')) {
25  define('NOTOKENRENEWAL', 1); // Disables token renewal
26 }
27 if (!defined('NOLOGIN')) {
28  define("NOLOGIN", 1);
29 }
30 if (!defined('NOCSRFCHECK')) {
31  define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
32 }
33 if (!defined('NOREQUIREMENU')) {
34  define('NOREQUIREMENU', '1');
35 }
36 if (!defined('NOREQUIREHTML')) {
37  define('NOREQUIREHTML', '1');
38 }
39 if (!defined('NOREQUIREAJAX')) {
40  define('NOREQUIREAJAX', '1');
41 }
42 if (!defined('NOIPCHECK')) {
43  define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
44 }
45 if (!defined('NOBROWSERNOTIF')) {
46  define('NOBROWSERNOTIF', '1');
47 }
48 
54 function llxHeader()
55 {
56 }
62 function llxFooter()
63 {
64 }
65 
66 require '../../master.inc.php';
67 require_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');
84 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
85  $appli = $conf->global->MAIN_APPLICATION_TITLE;
86 }
87 
88 //print 'Directory with '.$appli.' websites.<br>';
89 
90 if (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
114 if (empty($pageid))
115 {
116  $langs->load("website");
117  print $langs->trans("PreviewOfSiteNotYetAvailable");
118  exit;
119 }
120 */
121 
122 // Security: Delete string ../ into $original_file
123 global $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
132 if (!$accessallowed) {
133  accessforbidden();
134 }
135 
136 // Security:
137 // On interdit les remontees de repertoire ainsi que les pipe dans
138 // les noms de fichiers.
139 if (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 
146 clearstatcache();
147 
148 $filename = basename($original_file);
149 
150 // Output file on browser
151 dol_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
155 if (!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
164 define('USEDOLIBARRSERVER', 1);
165 print '/* Page content '.$original_file.' : CSS content that was saved into tpl dir */'."\n";
166 require_once $original_file_osencoded;
167 
168 
169 if (is_object($db)) {
170  $db->close();
171 }
WebsitePage
Class Websitepage.
Definition: websitepage.class.php:36
dol_osencode
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
Definition: functions.lib.php:8499
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
llxHeader
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.
Definition: styles.css.php:54
llxFooter
llxFooter()
Footer empty.
Definition: styles.css.php:62
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
Website
Class Website.
Definition: website.class.php:36
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933