From 16e7ea7b281d42057669429171d8fef9c488add6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=91=E7=AB=99=E7=BD=91?= Date: Wed, 26 Jan 2022 05:50:36 +0000 Subject: [PATCH] =?UTF-8?q?=E6=8E=8C=E4=B8=8A=E8=AE=BA=E5=9D=9BAPI?= =?UTF-8?q?=E6=B3=84=E9=9C=B2=E6=97=A0=E6=9D=83=E6=9F=A5=E7=9C=8B=E9=99=84?= =?UTF-8?q?=E4=BB=B6=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../source/plugin/mobile/api/1/viewthread.php | 25 +++++++++++++++++++ .../source/plugin/mobile/api/4/viewthread.php | 23 +++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/upload/source/plugin/mobile/api/1/viewthread.php b/upload/source/plugin/mobile/api/1/viewthread.php index 7ced30697..e588c2fd1 100644 --- a/upload/source/plugin/mobile/api/1/viewthread.php +++ b/upload/source/plugin/mobile/api/1/viewthread.php @@ -88,6 +88,31 @@ class mobile_api { preg_match('/\[tthread=(.+?),(.+?)\](.*?)\[\/tthread\]/', $variable['postlist'][$k]['message'], $matches); $variable['postlist'][$k]['message'] = preg_replace('/\[tthread=(.+?)\](.*?)\[\/tthread\]/', lang('plugin/qqconnect', 'connect_tthread_message', array('username' => $matches[1], 'nick' => $matches[2])), $variable['postlist'][$k]['message']); } + $firstpost = current($GLOBALS['postarr']); + if($firstpost['first'] && strpos($firstpost['message'],'[/hide]') !== FALSE ){ + $authorreplyexist = false; + if(!$_G['forum']['ismoderator']) { + if($_G['uid']) { + $_post = C::t('forum_post')->fetch('tid:'.$_G['tid'], $pid); + $authorreplyexist = $_post['tid'] == $_G['tid'] ? C::t('forum_post')->fetch_pid_by_tid_authorid($_G['tid'], $_G['uid']) : false; + } + } else { + $authorreplyexist = true; + } + if(!$authorreplyexist){ + $aids = array(); + preg_match_all("/\[hide(.*?)?\]\s*(.*?)\s*\[\/hide\]/is",$firstpost['message'],$matches); + foreach ($matches[2] as $match){ + preg_match_all("/\[attach\](\d+)\[\/attach\]/i",$match,$matchaids); + $aids = array_merge($aids,$matchaids[1]); + } + foreach($aids as $aid){ + unset($variable['postlist'][$k]['attachments'][$aid]); + } + $variable['postlist'][$k]['attachlist'] = array_diff($variable['postlist'][$k]['attachlist'],$aids); + $variable['postlist'][$k]['imagelist'] = array_diff($variable['postlist'][$k]['imagelist'],$aids); + } + } } foreach($GLOBALS['aimgs'] as $pid => $aids) { diff --git a/upload/source/plugin/mobile/api/4/viewthread.php b/upload/source/plugin/mobile/api/4/viewthread.php index d46c60dfe..dcda4f963 100644 --- a/upload/source/plugin/mobile/api/4/viewthread.php +++ b/upload/source/plugin/mobile/api/4/viewthread.php @@ -131,6 +131,29 @@ class mobile_api { $variable['postlist'][$k]['message'] = preg_replace('/( ){2,}/', '', $variable['postlist'][$k]['message']); $variable['postlist'][$k]['dateline'] = strip_tags($post['dateline']); $variable['postlist'][$k]['groupiconid'] = mobile_core::usergroupIconId($post['groupid']); + if($firstpost['first'] && strpos($firstpost['message'],'[/hide]') !== FALSE ){ + $authorreplyexist = false; + if(!$_G['forum']['ismoderator']) { + if($_G['uid']) { + $_post = C::t('forum_post')->fetch('tid:'.$_G['tid'], $pid); + $authorreplyexist = $_post['tid'] == $_G['tid'] ? C::t('forum_post')->fetch_pid_by_tid_authorid($_G['tid'], $_G['uid']) : false; + } + } else { + $authorreplyexist = true; + } + if(!$authorreplyexist){ + $aids = array(); + preg_match_all("/\[hide(.*?)?\]\s*(.*?)\s*\[\/hide\]/is",$firstpost['message'],$matches); + foreach ($matches[2] as $match){ + preg_match_all("/\[attach\](\d+)\[\/attach\]/i",$match,$matchaids); + $aids = array_merge($aids,$matchaids[1]); + } + foreach($aids as $aid){ + unset($variable['postlist'][$k]['attachments'][$aid]); + } + $variable['postlist'][$k]['attachlist'] = array_diff($variable['postlist'][$k]['attachlist'],$aids); + } + } } if (!empty($GLOBALS['polloptions'])) { -- Gitee