diff --git a/apps/maarch_entreprise/actions/index_mlb.php b/apps/maarch_entreprise/actions/index_mlb.php index e78d19ac09d6fdfb91a26ef57c6f687577617bdc..cc0eeb0352aa9c1b83bfd40e9cf9087123116580 100755 --- a/apps/maarch_entreprise/actions/index_mlb.php +++ b/apps/maarch_entreprise/actions/index_mlb.php @@ -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'] = ''; } diff --git a/apps/maarch_entreprise/getIframeTemplateContent.php b/apps/maarch_entreprise/getIframeTemplateContent.php index c26f04de75a67f779ebaf2238193ff8de0424504..caa42421b6eea72e637e763e39adc6c6741a0299 100755 --- a/apps/maarch_entreprise/getIframeTemplateContent.php +++ b/apps/maarch_entreprise/getIframeTemplateContent.php @@ -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(' ','<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 )); diff --git a/modules/sendmail/batch/process_emails.php b/modules/sendmail/batch/process_emails.php index 2c771a1d3a2c0128d24a23f22a7f1aef34d79663..00cd7c5dffcf23634cf8d4ef0056f43a290200eb 100755 --- a/modules/sendmail/batch/process_emails.php +++ b/modules/sendmail/batch/process_emails.php @@ -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);