31 if (!defined(
'NOREQUIRESOC')) {
32 define(
'NOREQUIRESOC',
'1');
34 if (!defined(
'NOREQUIRETRAN')) {
35 define(
'NOREQUIRETRAN',
'1');
37 if (!defined(
'NOCSRFCHECK')) {
38 define(
'NOCSRFCHECK',
'1');
40 if (!defined(
'NOTOKENRENEWAL')) {
41 define(
'NOTOKENRENEWAL',
'1');
43 if (!defined(
'NOREQUIREMENU')) {
44 define(
'NOREQUIREMENU',
'1');
46 if (!defined(
'NOREQUIREHTML')) {
47 define(
'NOREQUIREHTML',
'1');
49 if (!defined(
'NOREQUIREAJAX')) {
50 define(
'NOREQUIREAJAX',
'1');
55 if (isset($_GET[
"modulepart"]) && $_GET[
"modulepart"] ==
'mycompany' && preg_match(
'/^\/?logos\//', $_GET[
'file'])) {
56 if (!defined(
"NOLOGIN")) {
59 if (!defined(
"NOCSRFCHECK")) {
60 define(
"NOCSRFCHECK", 1);
62 if (!defined(
"NOIPCHECK")) {
63 define(
"NOIPCHECK", 1);
67 if (isset($_GET[
"hashp"]) && !defined(
"NOLOGIN")) {
68 if (!defined(
"NOLOGIN")) {
71 if (!defined(
"NOCSRFCHECK")) {
72 define(
"NOCSRFCHECK", 1);
74 if (!defined(
"NOIPCHECK")) {
75 define(
"NOIPCHECK", 1);
79 if (isset($_GET[
"modulepart"]) && $_GET[
"modulepart"] ==
'medias') {
80 if (!defined(
"NOLOGIN")) {
83 if (!defined(
"NOCSRFCHECK")) {
84 define(
"NOCSRFCHECK", 1);
86 if (!defined(
"NOIPCHECK")) {
87 define(
"NOIPCHECK", 1);
92 if (isset($_GET[
"modulepart"]) && $_GET[
"modulepart"] ==
'product' && isset($_GET[
"publictakepos"])) {
93 if (!defined(
"NOLOGIN")) {
96 if (!defined(
"NOCSRFCHECK")) {
97 define(
"NOCSRFCHECK", 1);
99 if (!defined(
"NOIPCHECK")) {
100 define(
"NOIPCHECK", 1);
105 $entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
106 if (is_numeric($entity)) {
107 define(
"DOLENTITY", $entity);
129 require
'main.inc.php';
130 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
132 $action =
GETPOST(
'action',
'aZ09');
133 $original_file =
GETPOST(
'file',
'alphanohtml');
134 $hashp =
GETPOST(
'hashp',
'aZ09');
135 $modulepart =
GETPOST(
'modulepart',
'alpha');
136 $urlsource =
GETPOST(
'urlsource',
'alpha');
137 $entity =
GETPOST(
'entity',
'int') ?
GETPOST(
'entity',
'int') : $conf->entity;
140 if (empty($modulepart) && empty($hashp)) {
141 accessforbidden(
'Bad link. Bad value for parameter modulepart', 0, 0, 1);
143 if (empty($original_file) && empty($hashp) && $modulepart !=
'barcode') {
144 accessforbidden(
'Bad link. Missing identification to find file (param file or hashp)', 0, 0, 1);
146 if ($modulepart ==
'fckeditor') {
147 $modulepart =
'medias';
164 if (
GETPOST(
"cache",
'alpha')) {
167 if (empty($dolibarr_nocache)) {
168 header(
'Cache-Control: max-age=3600, public, must-revalidate');
169 header(
'Pragma: cache');
171 header(
'Cache-Control: no-cache');
177 if (!empty($hashp)) {
178 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
180 $result = $ecmfile->fetch(0,
'',
'',
'', $hashp);
182 $tmp = explode(
'/', $ecmfile->filepath, 2);
184 if (is_numeric($tmp[0])) {
185 $tmp = explode(
'/', $tmp[1], 2);
187 $moduleparttocheck = $tmp[0];
190 if ($moduleparttocheck == $modulepart) {
192 $original_file = (($tmp[1] ? $tmp[1].
'/' :
'').$ecmfile->filename);
195 accessforbidden(
'Bad link. File is from another module part.', 0, 0, 1);
198 $modulepart = $moduleparttocheck;
199 $original_file = (($tmp[1] ? $tmp[1].
'/' :
'').$ecmfile->filename);
202 $langs->load(
"errors");
203 accessforbidden($langs->trans(
"ErrorFileNotFoundWithSharedLink"), 0, 0, 1);
208 $type =
'application/octet-stream';
209 if (
GETPOST(
'type',
'alpha')) {
210 $type =
GETPOST(
'type',
'alpha');
216 if (preg_match(
'/html/i', $type)) {
217 accessforbidden(
'Error: Using the image wrapper to output a file with a mime type HTML is not possible.', 0, 0, 1);
220 if (preg_match(
'/\.noexe$/i', $original_file)) {
221 accessforbidden(
'Error: Using the image wrapper to output a file ending with .noexe is not allowed.', 0, 0, 1);
225 $original_file = preg_replace(
'/\.\.+/',
'..', $original_file);
226 $original_file = str_replace(
'../',
'/', $original_file);
227 $original_file = str_replace(
'..\\',
'/', $original_file);
230 $refname = basename(dirname($original_file).
"/");
238 if (empty($modulepart)) {
244 if ($modulepart ===
'medias' && $entity != $conf->entity) {
245 $conf->entity = $entity;
246 $conf->setValues($db);
250 $accessallowed = $check_access[
'accessallowed'];
251 $sqlprotectagainstexternals = $check_access[
'sqlprotectagainstexternals'];
252 $fullpath_original_file = $check_access[
'original_file'];
254 if (!empty($hashp)) {
256 $sqlprotectagainstexternals =
'';
257 } elseif (isset($_GET[
"publictakepos"])) {
258 if (!empty($conf->global->TAKEPOS_AUTO_ORDER)) {
263 if ($user->socid > 0) {
264 if ($sqlprotectagainstexternals) {
265 $resql = $db->query($sqlprotectagainstexternals);
267 $num = $db->num_rows(
$resql);
270 $obj = $db->fetch_object(
$resql);
271 if ($user->socid != $obj->fk_soc) {
284 if (!$accessallowed) {
290 if (preg_match(
'/\.\./', $fullpath_original_file) || preg_match(
'/[<>|]/', $fullpath_original_file)) {
291 dol_syslog(
"Refused to deliver file ".$fullpath_original_file);
292 print
"ErrorFileNameInvalid: ".dol_escape_htmltag($original_file);
298 if ($modulepart ==
'barcode') {
299 $generator =
GETPOST(
"generator",
"aZ09");
300 $encoding =
GETPOST(
"encoding",
"aZ09");
301 $readable =
GETPOST(
"readable",
'aZ09') ?
GETPOST(
"readable",
"aZ09") :
"Y";
302 if (in_array($encoding, array(
'EAN8',
'EAN13'))) {
303 $code =
GETPOST(
"code",
'alphanohtml');
305 $code =
GETPOST(
"code",
'restricthtml');
308 if (empty($generator) || empty($encoding)) {
309 print
'Error: Parameter "generator" or "encoding" not defined';
313 $dirbarcode = array_merge(array(
"/core/modules/barcode/doc/"), $conf->modules_parts[
'barcode']);
317 foreach ($dirbarcode as $reldir) {
322 if (!is_dir($newdir)) {
326 $result = @include_once $newdir.$generator.
'.modules.php';
333 $classname =
"mod".ucfirst($generator);
334 $module =
new $classname($db);
335 if ($module->encodingIsSupported($encoding)) {
336 $result = $module->buildBarCode($code, $encoding, $readable);
342 $filename = basename($fullpath_original_file);
345 dol_syslog(
"viewimage.php return file $fullpath_original_file filename=$filename content-type=$type");
348 if (!
dol_is_file($fullpath_original_file) && empty($_GET[
"noalt"])) {
349 $fullpath_original_file = DOL_DOCUMENT_ROOT.
'/public/theme/common/nophoto.png';
358 header(
'Content-Disposition: inline; filename="'.basename($fullpath_original_file).
'"');
361 header(
'Content-Disposition: inline; filename="'.basename($fullpath_original_file).
'"');
364 $fullpath_original_file_osencoded =
dol_osencode($fullpath_original_file);
366 readfile($fullpath_original_file_osencoded);
370 if (is_object($db)) {
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.
dolIsAllowedForPreview($file)
Return if a file is qualified for preview.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype= 'text/html', $forcenocache=0)
Show HTTP header.
dol_check_secure_access_document($modulepart, $original_file, $entity, $fuser= '', $refname= '', $mode= 'read')
Security check when accessing to a document (used by document.php, viewimage.php and webservices to g...
dol_mimetype($file, $default= 'application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
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 ...
dol_is_file($pathoffile)
Return if path is a file.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Class to manage ECM files.