|
|
@ -270,6 +270,11 @@ class Posts extends BaseController |
|
|
$type = ''; |
|
|
$type = ''; |
|
|
if (!empty($content)) { |
|
|
if (!empty($content)) { |
|
|
$type = '1'; |
|
|
$type = '1'; |
|
|
|
|
|
$detectionRes = $this->detectionProcessingText($content); |
|
|
|
|
|
if (isset($detectionRes['error'])) { |
|
|
|
|
|
return error($detectionRes['error']); |
|
|
|
|
|
} |
|
|
|
|
|
$content = $detectionRes['content']; |
|
|
} |
|
|
} |
|
|
if (!empty($imgArr)) { |
|
|
if (!empty($imgArr)) { |
|
|
if (is_array($imgArr) && count($imgArr) > 9) { |
|
|
if (is_array($imgArr) && count($imgArr) > 9) { |
|
|
@ -395,6 +400,28 @@ class Posts extends BaseController |
|
|
return $data; |
|
|
return $data; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 检查文本输入内容 |
|
|
|
|
|
protected function detectionProcessingText($content, $type = 1) |
|
|
|
|
|
{ |
|
|
|
|
|
// 限制文字内容长度 |
|
|
|
|
|
$text = strip_tags($content); |
|
|
|
|
|
$textLen = mb_strlen($text); |
|
|
|
|
|
$length = 2048; |
|
|
|
|
|
$error = lang('posts.msgContentLimit') . $textLen; |
|
|
|
|
|
if ($type == 2) { |
|
|
|
|
|
$length = 500; |
|
|
|
|
|
$error = lang('im.msgContentLimit') . $textLen; |
|
|
|
|
|
} else { |
|
|
|
|
|
$content = preg_link($content); |
|
|
|
|
|
} |
|
|
|
|
|
if ($textLen > $length) { |
|
|
|
|
|
return ['error' => $error]; |
|
|
|
|
|
} |
|
|
|
|
|
// 接入聊天内容检测服务 |
|
|
|
|
|
event('GreenText',['content'=>$content,'service'=>"chat_detection"]); |
|
|
|
|
|
return ['content' => $content]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 获取上传草稿帖子数据 |
|
|
// 获取上传草稿帖子数据 |
|
|
public function getLastPosts() |
|
|
public function getLastPosts() |
|
|
{ |
|
|
{ |
|
|
@ -504,6 +531,12 @@ class Posts extends BaseController |
|
|
return error(lang('system.fail')); |
|
|
return error(lang('system.fail')); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$detectionRes = $this->detectionProcessingText($content, 2); |
|
|
|
|
|
if (isset($detectionRes['error'])) { |
|
|
|
|
|
return error($detectionRes['error']); |
|
|
|
|
|
} |
|
|
|
|
|
$content = $detectionRes['content']; |
|
|
|
|
|
|
|
|
$pid = $this->request->param('pid', 0); |
|
|
$pid = $this->request->param('pid', 0); |
|
|
$reply_user_id = 0; |
|
|
$reply_user_id = 0; |
|
|
if (!empty($pid)) { |
|
|
if (!empty($pid)) { |
|
|
|