FIX Use of image into free text for PDF if DOL_DATA_DIR is outside of
DOL_DOCUMENT_DIR.
This commit is contained in:
parent
53ceef5b6a
commit
86eaa78f1e
@ -104,6 +104,27 @@ with
|
|||||||
//return false;
|
//return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
* Replace in tcpdf.php
|
||||||
|
|
||||||
|
if (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
|
||||||
|
|
||||||
|
with
|
||||||
|
|
||||||
|
// @CHANGE LDR Add support for src="file://..." links
|
||||||
|
if (strpos($imgsrc, 'file://') === 0) {
|
||||||
|
$imgsrc = str_replace('file://', '/', $imgsrc);
|
||||||
|
$imgsrc = urldecode($imgsrc);
|
||||||
|
$testscrtype = @parse_url($imgsrc);
|
||||||
|
if (empty($testscrtype['query'])) {
|
||||||
|
// convert URL to server path
|
||||||
|
$imgsrc = str_replace(K_PATH_URL, K_PATH_MAIN, $imgsrc);
|
||||||
|
} elseif (preg_match('|^https?://|', $imgsrc) !== 1) {
|
||||||
|
// convert URL to server path
|
||||||
|
$imgsrc = str_replace(K_PATH_MAIN, K_PATH_URL, $imgsrc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
* In tecnickcom/tcpdf/include/tcpdf_static, in function fopenLocal, replace
|
* In tecnickcom/tcpdf/include/tcpdf_static, in function fopenLocal, replace
|
||||||
|
|||||||
@ -914,7 +914,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
|
|||||||
// <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&entity=1&file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
|
// <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&entity=1&file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
|
||||||
// become
|
// become
|
||||||
// <img alt="" src="'.DOL_DATA_ROOT.'/medias/image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
|
// <img alt="" src="'.DOL_DATA_ROOT.'/medias/image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
|
||||||
$newfreetext = preg_replace('/(<img.*src=")[^\"]*viewimage\.php[^\"]*modulepart=medias[^\"]*file=([^\"]*)("[^\/]*\/>)/', '\1'.DOL_DATA_ROOT.'/medias/\2\3', $newfreetext);
|
$newfreetext = preg_replace('/(<img.*src=")[^\"]*viewimage\.php[^\"]*modulepart=medias[^\"]*file=([^\"]*)("[^\/]*\/>)/', '\1'.'file:/'.DOL_DATA_ROOT.'/medias/\2\3', $newfreetext);
|
||||||
|
|
||||||
$line .= $outputlangs->convToOutputCharset($newfreetext);
|
$line .= $outputlangs->convToOutputCharset($newfreetext);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18888,8 +18888,21 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
|
|||||||
$imgsrc = '@'.base64_decode(substr($imgsrc, 1));
|
$imgsrc = '@'.base64_decode(substr($imgsrc, 1));
|
||||||
$type = '';
|
$type = '';
|
||||||
} else {
|
} else {
|
||||||
if (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
|
// @CHANGE LDR Add support for src="file://..." links
|
||||||
// fix image path
|
if (strpos($imgsrc, 'file://') === 0) {
|
||||||
|
$imgsrc = str_replace('file://', '/', $imgsrc);
|
||||||
|
$imgsrc = urldecode($imgsrc);
|
||||||
|
$testscrtype = @parse_url($imgsrc);
|
||||||
|
if (empty($testscrtype['query'])) {
|
||||||
|
// convert URL to server path
|
||||||
|
$imgsrc = str_replace(K_PATH_URL, K_PATH_MAIN, $imgsrc);
|
||||||
|
} elseif (preg_match('|^https?://|', $imgsrc) !== 1) {
|
||||||
|
// convert URL to server path
|
||||||
|
$imgsrc = str_replace(K_PATH_MAIN, K_PATH_URL, $imgsrc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
|
||||||
|
// fix image path
|
||||||
$findroot = strpos($imgsrc, $_SERVER['DOCUMENT_ROOT']);
|
$findroot = strpos($imgsrc, $_SERVER['DOCUMENT_ROOT']);
|
||||||
if (($findroot === false) OR ($findroot > 1)) {
|
if (($findroot === false) OR ($findroot > 1)) {
|
||||||
if (substr($_SERVER['DOCUMENT_ROOT'], -1) == '/') {
|
if (substr($_SERVER['DOCUMENT_ROOT'], -1) == '/') {
|
||||||
@ -18908,6 +18921,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value:
|
|||||||
$imgsrc = str_replace(K_PATH_MAIN, K_PATH_URL, $imgsrc);
|
$imgsrc = str_replace(K_PATH_MAIN, K_PATH_URL, $imgsrc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get image type
|
// get image type
|
||||||
$type = TCPDF_IMAGES::getImageFileType($imgsrc);
|
$type = TCPDF_IMAGES::getImageFileType($imgsrc);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user