31 if (!defined(
'NOREQUIRESOC')) define(
'NOREQUIRESOC',
'1');
32 if (!defined(
'NOREQUIRETRAN')) define(
'NOREQUIRETRAN',
'1');
33 if (!defined(
'NOCSRFCHECK')) define(
'NOCSRFCHECK',
'1');
34 if (!defined(
'NOTOKENRENEWAL')) define(
'NOTOKENRENEWAL',
'1');
35 if (!defined(
'NOREQUIREMENU')) define(
'NOREQUIREMENU',
'1');
36 if (!defined(
'NOREQUIREHTML')) define(
'NOREQUIREHTML',
'1');
37 if (!defined(
'NOREQUIREAJAX')) define(
'NOREQUIREAJAX',
'1');
41 if (isset($_GET[
"modulepart"]) && $_GET[
"modulepart"] ==
'mycompany' && preg_match(
'/^\/?logos\//', $_GET[
'file']))
43 if (!defined(
"NOLOGIN")) define(
"NOLOGIN", 1);
44 if (!defined(
"NOCSRFCHECK")) define(
"NOCSRFCHECK", 1);
45 if (!defined(
"NOIPCHECK")) define(
"NOIPCHECK", 1);
48 if (isset($_GET[
"hashp"]) && !defined(
"NOLOGIN"))
50 if (!defined(
"NOLOGIN")) define(
"NOLOGIN", 1);
51 if (!defined(
"NOCSRFCHECK")) define(
"NOCSRFCHECK", 1);
52 if (!defined(
"NOIPCHECK")) define(
"NOIPCHECK", 1);
55 if (isset($_GET[
"modulepart"]) && $_GET[
"modulepart"] ==
'medias')
57 if (!defined(
"NOLOGIN")) define(
"NOLOGIN", 1);
58 if (!defined(
"NOCSRFCHECK")) define(
"NOCSRFCHECK", 1);
59 if (!defined(
"NOIPCHECK")) define(
"NOIPCHECK", 1);
63 if (isset($_GET[
"modulepart"]) && $_GET[
"modulepart"] ==
'product' && isset($_GET[
"publictakepos"]))
65 if (!defined(
"NOLOGIN")) define(
"NOLOGIN", 1);
66 if (!defined(
"NOCSRFCHECK")) define(
"NOCSRFCHECK", 1);
67 if (!defined(
"NOIPCHECK")) define(
"NOIPCHECK", 1);
71 $entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
72 if (is_numeric($entity)) define(
"DOLENTITY", $entity);
93 require
'main.inc.php';
94 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
96 $action =
GETPOST(
'action',
'aZ09');
97 $original_file =
GETPOST(
'file',
'alphanohtml');
98 $hashp =
GETPOST(
'hashp',
'aZ09');
99 $modulepart =
GETPOST(
'modulepart',
'alpha');
100 $urlsource =
GETPOST(
'urlsource',
'alpha');
101 $entity =
GETPOST(
'entity',
'int') ?
GETPOST(
'entity',
'int') : $conf->entity;
104 if (empty($modulepart) && empty($hashp))
accessforbidden(
'Bad link. Bad value for parameter modulepart', 0, 0, 1);
105 if (empty($original_file) && empty($hashp) && $modulepart !=
'barcode')
accessforbidden(
'Bad link. Missing identification to find file (param file or hashp)', 0, 0, 1);
106 if ($modulepart ==
'fckeditor') $modulepart =
'medias';
126 if (empty($dolibarr_nocache))
128 header(
'Cache-Control: max-age=3600, public, must-revalidate');
129 header(
'Pragma: cache');
130 }
else header(
'Cache-Control: no-cache');
137 include_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmfiles.class.php';
139 $result = $ecmfile->fetch(0,
'',
'',
'', $hashp);
142 $tmp = explode(
'/', $ecmfile->filepath, 2);
144 if (is_numeric($tmp[0]))
146 $tmp = explode(
'/', $tmp[1], 2);
148 $moduleparttocheck = $tmp[0];
152 if ($moduleparttocheck == $modulepart)
155 $original_file = (($tmp[1] ? $tmp[1].
'/' :
'').$ecmfile->filename);
158 accessforbidden(
'Bad link. File is from another module part.', 0, 0, 1);
161 $modulepart = $moduleparttocheck;
162 $original_file = (($tmp[1] ? $tmp[1].
'/' :
'').$ecmfile->filename);
165 $langs->load(
"errors");
166 accessforbidden($langs->trans(
"ErrorFileNotFoundWithSharedLink"), 0, 0, 1);
171 $type =
'application/octet-stream';
176 if (preg_match(
'/html/i', $type))
accessforbidden(
'Error: Using the image wrapper to output a file with a mime type HTML is not possible.', 0, 0, 1);
178 if (preg_match(
'/\.noexe$/i', $original_file))
accessforbidden(
'Error: Using the image wrapper to output a file ending with .noexe is not allowed.', 0, 0, 1);
181 $original_file = str_replace(
"../",
"/", $original_file);
184 $refname = basename(dirname($original_file).
"/");
187 if (empty($modulepart))
accessforbidden(
'Bad value for parameter modulepart', 0, 0, 1);
190 $accessallowed = $check_access[
'accessallowed'];
191 $sqlprotectagainstexternals = $check_access[
'sqlprotectagainstexternals'];
192 $fullpath_original_file = $check_access[
'original_file'];
194 if (!empty($hashp)) {
196 $sqlprotectagainstexternals =
'';
197 } elseif (isset($_GET[
"publictakepos"])) {
198 if (!empty($conf->global->TAKEPOS_AUTO_ORDER)) {
203 if ($user->socid > 0)
205 if ($sqlprotectagainstexternals)
207 $resql = $db->query($sqlprotectagainstexternals);
210 $num = $db->num_rows(
$resql);
214 $obj = $db->fetch_object(
$resql);
215 if ($user->socid != $obj->fk_soc)
236 if (preg_match(
'/\.\./', $fullpath_original_file) || preg_match(
'/[<>|]/', $fullpath_original_file))
238 dol_syslog(
"Refused to deliver file ".$fullpath_original_file);
239 print "ErrorFileNameInvalid: ".dol_escape_htmltag($original_file);
245 if ($modulepart ==
'barcode')
247 $generator =
GETPOST(
"generator",
"alpha");
248 $code =
GETPOST(
"code",
'none');
249 $encoding =
GETPOST(
"encoding",
"alpha");
250 $readable =
GETPOST(
"readable",
'alpha') ?
GETPOST(
"readable",
"alpha") :
"Y";
252 if (empty($generator) || empty($encoding))
254 print 'Error: Parameter "generator" or "encoding" not defined';
258 $dirbarcode = array_merge(array(
"/core/modules/barcode/doc/"), $conf->modules_parts[
'barcode']);
262 foreach ($dirbarcode as $reldir)
268 if (!is_dir($newdir))
continue;
270 $result = @include_once $newdir.$generator.
'.modules.php';
275 $classname =
"mod".ucfirst($generator);
276 $module =
new $classname($db);
277 if ($module->encodingIsSupported($encoding))
279 $result = $module->buildBarCode($code, $encoding, $readable);
285 $filename = basename($fullpath_original_file);
288 dol_syslog(
"viewimage.php return file $fullpath_original_file filename=$filename content-type=$type");
291 if (!
dol_is_file($fullpath_original_file) && empty($_GET[
"noalt"]))
293 $fullpath_original_file = DOL_DOCUMENT_ROOT.
'/public/theme/common/nophoto.png';
303 header(
'Content-Disposition: inline; filename="'.basename($fullpath_original_file).
'"');
306 header(
'Content-Disposition: inline; filename="'.basename($fullpath_original_file).
'"');
309 $fullpath_original_file_osencoded =
dol_osencode($fullpath_original_file);
311 readfile($fullpath_original_file_osencoded);
315 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.
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) ...
dol_mimetype($file, $default= 'application/octet-stream', $mode=0)
Return mime type of a file.
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.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Class to manage ECM files.