Merge branch 'ent-5570-9352-Bug-al-crear-PDF-con-graficas-con-token-allow-url-fopen' into 'develop'

Ent 5570 9352 bug al crear pdf con graficas con token allow url fopen

See merge request artica/pandorafms!3222
This commit is contained in:
Daniel Rodriguez 2020-06-02 09:22:27 +02:00
commit 58ac2e10da
1 changed files with 15 additions and 0 deletions

View File

@ -133,6 +133,7 @@ class ImageProcessor implements \Psr\Log\LoggerAwareInterface
public function getImage(&$file, $firsttime = true, $allowvector = true, $orig_srcpath = false, $interpolation = false)
{
global $config;
// mPDF 6
// firsttime i.e. whether to add to this->images - use false when calling iteratively
// Image Data passed directly as var:varname
@ -214,6 +215,20 @@ class ImageProcessor implements \Psr\Log\LoggerAwareInterface
$type = $this->guesser->guess($data);
}
}
if ((!$data || !$type) && !ini_get('allow_url_fopen') && preg_match('/data:image.*;base64/', $file)) {
$base_to_php = explode(',', $file);
$img_base64 = base64_decode($base_to_php[1]);
$filepath = $config['attachment_store']."/downloads/".uniqid().".jpg";
$result = file_put_contents($filepath, $img_base64);
if ($result !== false) {
$data = file_get_contents($filepath);
if ($data) {
$type = $this->guesser->guess($data);
}
unlink($filepath);
}
}
}
if (!$data) {