Skip to content
Snippets Groups Projects
Verified Commit dcf58946 authored by Florian Azizian's avatar Florian Azizian
Browse files

Merge branch '18.04' into develop

parents 46da0a6c 893dfc49
No related branches found
No related tags found
No related merge requests found
......@@ -1123,6 +1123,7 @@ function check_docserver($collId)
}
fwrite($myfile, $_SESSION['template_modified_content']);
fclose($myfile);
$_SESSION['template_modified_content'] = '';
$_SESSION['upfile']['size'] = filesize($tmpPath);
$_SESSION['template_modified_content'] = '';
}
......
......@@ -18,7 +18,7 @@
* You should have received a copy of the GNU General Public License
* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>.
*/
//Remove html tags to avoid empty space
//Remove html tags to avoid empty space
$sessionTemplateContent = trim(str_replace(
array('&nbsp;','<p>','</p>'),
'',
......@@ -26,8 +26,8 @@ $sessionTemplateContent = trim(str_replace(
));
$sessionTemplateContent = strip_tags($sessionTemplateContent);
$sessionTemplateContent = trim(preg_replace(
'/\s*/m',
'',
'/\s*/m',
'',
$sessionTemplateContent));
$sessionTemplateContent = utf8_encode(html_entity_decode($sessionTemplateContent));
......@@ -40,42 +40,42 @@ $sessionTemplateContent = trim(str_replace(
));
$sessionTemplateContent = trim(str_replace(
"\n",
"\n",
"",
$sessionTemplateContent
));
$sessionTemplateContent = trim(preg_replace(
'/\s+/',
'',
'/\s+/',
'',
$sessionTemplateContent));
$sessionTemplateContent = trim(str_replace(
"\r",
"\r",
"",
$sessionTemplateContent
));
$sessionTemplateContent = trim(str_replace(
"\t",
"\t",
"",
$sessionTemplateContent
));
$requestTemplateContent = trim(str_replace(
"\n",
"",
"\n",
"",
$requestTemplateContent
));
$requestTemplateContent = trim(str_replace(
" ",
"",
" ",
"",
$requestTemplateContent
));
$requestTemplateContent = trim(str_replace(
"\r",
"",
"\r",
"",
$requestTemplateContent
));
$requestTemplateContent = trim(str_replace(
"\t",
"",
"\t",
"",
$requestTemplateContent
));
......
......@@ -131,7 +131,33 @@ while ($state <> 'END') {
$body = str_replace('###', ';', $email->email_body);
$body = str_replace('___', '--', $body);
$body = $sendmail_tools->rawToHtml($body);
$GLOBALS['mailer']->setHtml($body);
$body = "<html><body>".$body."<br></body></html>";
$dom = new DOMDocument();
@$dom->loadHTML($body); // Using @ to hide any parse warning sometimes resulting from markup errors
$dom->preserveWhiteSpace = false;
// Here we strip all the img tags in the document
$images = $dom->getElementsByTagName('img');
foreach ($images as $key => $tag) {
$base64_string = $tag->getAttribute('src');
$image = explode(',', $base64_string);
if (base64_encode(base64_decode($image[1], true)) === $image[1]) {
$imageData = base64_decode($image[1]);
$finfo = finfo_open();
$mime_type = finfo_buffer($finfo, $imageData, FILEINFO_MIME_TYPE);
$mime_type = explode("/", $mime_type);
$nbAttachment = $key+1;
$filename = $nbAttachment."_attachment.".$mime_type[1];
file_put_contents($GLOBALS['TmpDirectory']."/".$filename, $imageData);
$body = str_replace($base64_string, basename($filename), $body);
}
}
$GLOBALS['mailer']->setHtml($body, "", $GLOBALS['TmpDirectory']);
} else {
$body = $sendmail_tools->htmlToRaw($email->email_body);
$GLOBALS['mailer']->setText($body);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment