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