diff --git a/app/Http/Controllers/Api/FileController.php b/app/Http/Controllers/Api/FileController.php index 3290bbaf2..b4a2d4373 100755 --- a/app/Http/Controllers/Api/FileController.php +++ b/app/Http/Controllers/Api/FileController.php @@ -519,7 +519,7 @@ class FileController extends AbstractController if ($file->type == 'document') { $data = Base::json2array($content); $isRep = false; - preg_match_all("/ $text) { $tmpPath = "uploads/file/document/" . date("Ym") . "/" . $id . "/attached/"; Base::makeDir(public_path($tmpPath)); diff --git a/app/Models/ProjectTaskContent.php b/app/Models/ProjectTaskContent.php index 97ab0a176..d6233ca93 100644 --- a/app/Models/ProjectTaskContent.php +++ b/app/Models/ProjectTaskContent.php @@ -61,7 +61,7 @@ class ProjectTaskContent extends AbstractModel { $path = 'uploads/task/content/' . date("Ym") . '/' . $task_id . '/'; // - preg_match_all("/ $text) { $tmpPath = $path . 'attached/'; Base::makeDir(public_path($tmpPath)); diff --git a/app/Models/WebSocketDialogMsg.php b/app/Models/WebSocketDialogMsg.php index 1ed73c77c..4167e88ea 100644 --- a/app/Models/WebSocketDialogMsg.php +++ b/app/Models/WebSocketDialogMsg.php @@ -207,7 +207,7 @@ class WebSocketDialogMsg extends AbstractModel public static function formatMsg($text, $dialog_id) { // 图片 [:IMAGE:className:width:height:src:alt:] - preg_match_all("/(<\/img>)*/s", $text, $matchs); + preg_match_all("/(<\/img>)*/s", $text, $matchs); foreach ($matchs[2] as $key => $base64) { $tmpPath = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/"; Base::makeDir(public_path($tmpPath)); @@ -218,7 +218,7 @@ class WebSocketDialogMsg extends AbstractModel } } // 表情图片 - preg_match_all("//s", $text, $matchs); + preg_match_all("//s", $text, $matchs); foreach ($matchs[1] as $key => $str) { preg_match("/data-asset=\"(.*?)\"/", $str, $matchAsset); preg_match("/data-name=\"(.*?)\"/", $str, $matchName); @@ -227,8 +227,27 @@ class WebSocketDialogMsg extends AbstractModel $text = str_replace($matchs[0][$key], "[:IMAGE:emoticon:{$imagesize[0]}:{$imagesize[1]}:{$matchAsset[1]}:{$matchName[1]}:]", $text); } } + // 其他网络图片 + preg_match_all("/]*?src=([\"'])(.*?\.(png|jpg|jpeg|gif))\\1[^>]*?>/is", $text, $matchs); + foreach ($matchs[2] as $key => $str) { + $tmpPath = "uploads/chat/" . date("Ym") . "/" . $dialog_id . "/"; + Base::makeDir(public_path($tmpPath)); + $tmpPath .= md5s($str) . "." . $matchs[3][$key]; + if (file_exists(public_path($tmpPath))) { + $imagesize = getimagesize(public_path($tmpPath)); + $text = str_replace($matchs[0][$key], "[:IMAGE:browse:{$imagesize[0]}:{$imagesize[1]}:{$tmpPath}::]", $text); + } else { + $image = file_get_contents($str); + if (empty($image)) { + $text = str_replace($matchs[0][$key], "[:IMAGE:browse:90:90:images/other/imgerr.jpg::]", $text); + } else if (file_put_contents(public_path($tmpPath), $image)) { + $imagesize = getimagesize(public_path($tmpPath)); + $text = str_replace($matchs[0][$key], "[:IMAGE:browse:{$imagesize[0]}:{$imagesize[1]}:{$tmpPath}::]", $text); + } + } + } // @成员、#任务 - preg_match_all("/.*?<\/span>.*?<\/span>.*?<\/span>/s", $text, $matchs); + preg_match_all("/.*?<\/span>.*?<\/span>.*?<\/span>/s", $text, $matchs); foreach ($matchs[1] as $key => $str) { preg_match("/data-denotation-char=\"(.*?)\"/", $str, $matchChar); preg_match("/data-id=\"(.*?)\"/", $str, $matchId); @@ -237,7 +256,7 @@ class WebSocketDialogMsg extends AbstractModel } // 过滤标签 $text = strip_tags($text, '
 
    • '); - $text = preg_replace("/\<(blockquote|strong|pre|ol|ul|li|em|p|s|u).*?\>/i", "<$1>", $text); + $text = preg_replace("/\<(blockquote|strong|pre|ol|ul|li|em|p|s|u).*?\>/is", "<$1>", $text); $text = preg_replace("/\[:IMAGE:(.*?):(.*?):(.*?):(.*?):(.*?):\]/i", "\"$5\"/", $text); $text = preg_replace("/\[:@:(.*?):(.*?):\]/i", "@$2", $text); $text = preg_replace("/\[:#:(.*?):(.*?):\]/i", "#$2", $text);