From 74f8a19134e5e17de1b1699a47a649a78df46d9c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Sep 2013 15:17:31 +0200 Subject: [PATCH] Qual: Make code simpler --- htdocs/core/class/CMailFile.class.php | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index f1579d5b4e2..5fa752d9619 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -962,22 +962,11 @@ class CMailFile $this->html_images[$i]["name"] = $img; // Content type - /* - * preg_replace /e modifier is deprecated in PHP 5.5 - * but anonymous functions for use in preg_replace_callback are only available from 5.3.0 - */ - if (version_compare(PHP_VERSION, '5.3.0') >= 0) { - $ext = preg_replace_callback( - '/^.*\.(\w{3,4})$/', - function ($m) { - return strtolower($m[1]); - }, - $img - ); - } else { - $ext = preg_replace('/^.*\.(\w{3,4})$/e', 'strtolower("$1")', $img); + if (preg_match('/^.+\.(\w{3,4})$/', $img, $reg)) + { + $ext=strtolower($reg[1]); + $this->html_images[$i]["content_type"] = $this->image_types[$ext]; } - $this->html_images[$i]["content_type"] = $this->image_types[$ext]; // cid $this->html_images[$i]["cid"] = dol_hash(uniqid(time()));