public function check($postDm) { $data = $postDm->getData(); $content = Pw::substrs(Pw::stripWindCode($data['content']), 30) == $data['subject'] ? $data['content'] : $data['subject'] . $data['content']; $banedStrLen = strlen($data['subject']); $wordFilter = Wekit::load('SRV:word.srv.PwWordFilter'); list($type, $words, $isTip) = $wordFilter->filterWord($content); if (!$type) { return true; } $words = array_unique($words); foreach ($words as $k => $v) { if ($k < $banedStrLen) { return new PwError('WORD:content.error.tip', array('{wordstr}' => implode(',', $words))); } } switch ($type) { case 1: return new PwError('WORD:content.error.tip', array('{wordstr}' => implode(',', $words))); case 2: $this->_isVerified = 1; if ($this->_confirm) { return true; } case 3: $this->_word = 1; default: return true; } return true; }
/** * 设置验证码 * * @return void */ protected static function setRandCode() { switch (self::$verifyType) { case '1': $str = '1234567890'; break; case '2': $str = 'abcdefghjkmnpqrstuvwxyABCDEFGHJKLMNPQRSTUVWXY'; break; case '3': default: $str = '3456789bcefghjkmpqrtvwxyzBCEFGHJKMPQRTVWXYZ'; break; case '5': $str = '人之初性本善性相近习相远苟不教性乃迁教之道贵以专昔孟母择邻处子不学断机杼窦燕山有义方教五子名俱扬养段算适讲按值美态黄易彪服早班麦削信排台声该击素张密害侯草何树肥继右属市严径螺检左页抗苏显苦英快称坏移约巴材省黑武培著河帝仅针怎植京助升王眼她抓含苗副杂普谈围食射源例致酸旧却充足短划剂宣环落首尺波承粉践府鱼随考刻靠够满夫失包住促枝局菌杆周护岩师举曲春元超负砂封换太模贫减阳扬江析亩木言球朝医校古呢稻宋听唯输滑站另卫字鼓刚写刘微略范供阿块某功套友限项余倒卷创律雨让骨远帮初皮播优占死毒圈伟季训控激找叫云互跟裂粮粒母练塞钢顶策双留误础吸阻故寸盾晚丝女散焊功株亲院冷彻弹错散商视艺灭版烈零室轻血倍缺厘泵察绝富城冲喷壤简否柱李望盘磁雄似困巩益洲脱投送奴侧润盖挥距触星松送获兴独官混纪依未突架宽冬章湿偏纹吃执阀矿寨责熟稳夺硬价努翻奇甲预职评读背协损棉侵灰虽矛厚罗泥辟告卵箱掌氧恩爱停曾溶营终纲孟钱待尽俄缩沙退陈讨奋械载胞幼哪剥迫旋征槽倒握担仍呀鲜吧卡粗介钻逐弱脚怕盐末阴丰编印蜂急拿扩伤飞露核缘游振操央伍域甚迅辉异序免纸夜乡久隶缸夹念兰映沟乙吗儒杀汽磷艰晶插埃燃欢铁补咱芽永瓦倾阵碳演威附牙芽永瓦斜灌欧献顺猪洋腐请透司危括脉宜笑若尾束壮暴企菜穗楚汉愈绿拖牛份染既秋遍锻玉夏疗尖殖井费州访吹荣铜沿替滚客召旱悟刺脑'; break; case '4': case '6': self::$verifyCode = self::_convert(self::$askCode); return true; case '7': //目前只有这些声音文件 $str = '123456789BCEFGHJKMPQRTVWXYZ'; break; } $_tmp = Pw::strlen($str) - 1; $_num = 0; for ($i = 0; $i < self::$verifyLength; $i++) { $_num = mt_rand(0, $_tmp); $_code = Pw::substrs($str, 1, $_num, false); self::$verifyCode .= self::_convert($_code); } }
/** * 回复列表 */ public function replyAction() { list($page, $perpage) = $this->getInput(array('page', 'perpage')); $page = $page ? $page : 1; $perpage = $perpage ? $perpage : $this->perpage; list($start, $limit) = Pw::page2limit($page, $perpage); $count = $this->_getThreadExpandDs()->countDisabledPostByUid($this->loginUser->uid); if ($count) { $tmpPosts = $this->_getThreadExpandDs()->getDisabledPostByUid($this->loginUser->uid, $limit, $start); $posts = $tids = array(); foreach ($tmpPosts as $v) { $tids[] = $v['tid']; } $threads = $this->_getThreadDs()->fetchThread($tids); foreach ($tmpPosts as $v) { $v['threadSubject'] = Pw::substrs($threads[$v['tid']]['subject'], 30); $v['content'] = Pw::substrs($v['content'], 30); $v['created_time'] = PW::time2str($v['created_time'], 'auto'); $posts[] = $v; } } $this->setOutput($count, 'count'); $this->setOutput($page, 'page'); $this->setOutput($perpage, 'perpage'); $this->setOutput($posts, 'posts'); // seo设置 Wind::import('SRV:seo.bo.PwSeoBo'); $seoBo = PwSeoBo::getInstance(); $lang = Wind::getComponent('i18n'); $seoBo->setCustomSeo($lang->getMessage('SEO:bbs.article.reply.title'), '', ''); Wekit::setV('seo', $seoBo); }
public function buildTitle($param = 0, $extendParams = null, $aggregatedNotice = null) { if ($extendParams['title']) { $title = $extendParams['title']; } else { $title = Pw::substrs($extendParams['content'], 60); } return $title; }
/** * 后台设置-email设置 */ public function dorunAction() { $password = $this->getInput('mailPassword', 'post'); $config = $this->_getConfig(); $t = Pw::strlen($config['mail.password']); $passwordO = Pw::substrs($config['mail.password'], 1, 0, false) . '********' . Pw::substrs($config['mail.password'], 1, $t - 1, false); $password = $password == $passwordO ? $config['mail.password'] : $password; $config = new PwConfigSet('email'); $config->set('mailOpen', $this->getInput('mailOpen', 'post'))->set('mailMethod', 'smtp')->set('mail.host', $this->getInput('mailHost', 'post'))->set('mail.port', $this->getInput('mailPort', 'post'))->set('mail.from', $this->getInput('mailFrom', 'post'))->set('mail.auth', $this->getInput('mailAuth', 'post'))->set('mail.user', $this->getInput('mailUser', 'post'))->set('mail.password', $password)->flush(); $this->showMessage('ADMIN:success'); }
public function addPost($pid, $tid) { $params = array(); $params['replyContent'] = $this->content; $params['replyUserid'] = $this->user->uid; $params['replyUsername'] = $this->user->username; $params['postTitle'] = Pw::substrs($this->postInfo['content'], 30); $params['postId'] = $this->postInfo['pid']; $params['postUserid'] = $this->postInfo['created_userid']; $params['replies'] = $this->postInfo['replies']; return $this->_getNoticeService()->sendNotice($this->postInfo['created_userid'], 'postreply', $this->postInfo['pid'], $params); }
public function displayContent($content, $useubb, $remindUser = array(), $contentLength = 140) { $content = WindSecurity::escapeHTML($content); if ($useubb) { $ubb = new PwUbbCodeConvertThread(); $ubb->setRemindUser($remindUser); $content = PwSimpleUbbCode::convert($content, $contentLength, $ubb); } else { $content = Pw::substrs($content, $contentLength); } return $content; }
/** * 通过公告记录组装前台显示效果 * 帖子列表滚动展示标题用 * * @return array */ public function getAnnounceForBbsScroll() { $announces = array(); $announceInfos = $this->_getPwAnnounceDs()->getAnnounceByTimeOrderByVieworder(Pw::str2time(Pw::time2str(Pw::getTime(), 'Y-m-d')), 9, 0); foreach ($announceInfos as $value) { $announces[$value['aid']] = $value; $announces[$value['aid']]['start_date'] = Pw::time2str($value['start_date'], 'Y-m-d'); if (Pw::strlen($value['subject']) > 18) { $announces[$value['aid']]['subject'] = Pw::substrs($value['subject'], 18); } } return $announces; }
public function buildDm($type_id) { $threadDs = Wekit::load('forum.PwThread'); $result = $threadDs->getThread($type_id); if (!$result) { return false; } $content = Pw::substrs($result['subject'], 20); $hrefUrl = WindUrlHelper::createUrl('bbs/read/run', array('tid' => $result['tid'], 'fid' => $result['fid'])); $this->fid = $result['fid']; $dm = new PwReportDm(); $dm->setContent($content)->setContentUrl($hrefUrl)->setAuthorUserid($result['created_userid']); return $dm; }
public function dataProcessing($postDm) { if ($this->_check() !== true) { return $postDm; } $atc_content = $postDm->getField('content'); $atc_content = preg_replace('/\\[quote(=.+?\\,\\d+)?\\].*?\\[\\/quote\\]/is', '', $atc_content); $this->_atc_title = Pw::substrs(trim(Pw::stripWindCode($atc_content, true)), 20); $reminds = $this->_getRemindService()->bulidRemind($atc_content); $this->_reminds = $this->_getRemindService()->buildUsers($this->loginUser->uid, $reminds, $this->_maxNum); $reminds = $this->_getRemindService()->formatReminds($this->_reminds); $postDm->setReminds($reminds); return $postDm; }
/** * * 云存储api(同步附件) * * @param string $dir */ public function getAttachesForStorage($dir) { $attachDir = Wind::getRealDir('PUBLIC:') . PUBLIC_ATTACH; $dir = trim($dir); if (!$dir) { return array(); } $result = array(); $baseUrl = Pw::substrs(PUBLIC_URL, strrpos(PUBLIC_URL, 'aCloud'), 0, false); foreach (glob($attachDir . $dir . '/*') as $fileName) { if ($fileName == '.' || $fileName == '..' || preg_match('/\\.(htm|html|db)$/i', $fileName)) { continue; } $result[] = array('attachurl' => str_replace(Wind::getRealDir('PUBLIC:'), $baseUrl, $fileName), 'dir' => str_replace(Wind::getRealDir('PUBLIC:'), '', $fileName)); } return $result; }
/** * (non-PHPdoc) * @see wekit/wind/web/WindController::run() */ public function run() { $page = (int) $this->getInput('page', 'get'); if ($page < 1) { $page = 1; } $this->setOutput('index', 'src'); $this->setOutput($page, 'page'); // seo设置 Wind::import('SRV:seo.bo.PwSeoBo'); $lang = Wind::getComponent('i18n'); $des = Pw::substrs($this->space->space['space_descrip'], 100, 0, false); if ($page == 1) { PwSeoBo::setCustomSeo($lang->getMessage('SEO:space.index.run.title', array($this->space->space['space_name'])), '', $des); } else { PwSeoBo::setCustomSeo($lang->getMessage('SEO:space.index.run.page.title', array($page, $this->space->space['space_name'])), '', $des); } }
public function __construct($fresh, PwUserBo $user) { if ($fresh['type'] == 2) { $post = $this->_getThread()->getPost($fresh['src_id']); $tid = $post['tid']; $rpid = $post['pid']; $post = $this->_getThread()->getPost($rpid); if ($post && $post['tid'] == $tid && $post['ischeck']) { $content = preg_replace('/\\[quote(=.+?\\,\\d+)?\\].*?\\[\\/quote\\]/is', '', $post['content']); $this->quote = '[quote=' . $post['created_username'] . ',' . $rpid . ']' . Pw::substrs($content, 120) . '[/quote]'; } } else { $tid = $fresh['src_id']; $rpid = 0; } $this->post = new PwPost(new PwReplyPost($tid, $user)); $this->dm = $this->post->getDm(); $this->dm->setReplyPid($rpid); }
protected function _bulidContent($array, &$errcode) { $errcode = array(); $array['content'] = str_replace(array("\r", "\n", "\t"), '', $array['content']); $array['content'] = WindSecurity::escapeHTML($array['content']); if ($array['ifshield']) { $array['subject'] = ''; $array['content'] = '<span style="text-decoration: line-through">此帖已被屏蔽</span>'; } elseif ($array['useubb']) { $ubb = new PwUbbCodeConvertThread(); $array['reminds'] && $ubb->setRemindUser($array['reminds']); $array['pic'] && $ubb->setAttachParser(new PwFreshAttachDisplay($array['pic'])); $array['content'] = PwSimpleUbbCode::convert($array['content'], 140, $ubb); PwSimpleUbbCode::isSubstr() && ($errcode['is_read_all'] = true); } elseif (Pw::strlen($array['content']) > 140) { $errcode['is_read_all'] = true; $array['content'] = Pw::substrs($array['content'], 140); } return $array; }
private function _addRemind($tid) { if ($this->_check() !== true) { return false; } if (!$this->_reminds) { return false; } $reminds = $this->_maxNum && count($this->_reminds) > $this->_maxNum ? array_slice($this->_reminds, 0, $this->_maxNum) : $this->_reminds; $remindUids = array_keys($reminds); $this->_getRemindService()->addRemind($this->loginUser->uid, $remindUids); //发送通知 $title = Pw::substrs(trim($this->_atc_title), 20); $extendParams = array('remindUid' => $this->loginUser->uid, 'remindUsername' => $this->loginUser->username, 'title' => $title, 'notice' => '在帖子 <a href="' . WindUrlHelper::createUrl('bbs/read/run', array('tid' => $tid)) . '" target="_blank">' . $title . '</a> @了您'); // 是否黑名单 $remindUids = $this->_checkBlack($remindUids); foreach ($remindUids as $uid) { $this->_getPwNoticeService()->sendNotice($uid, 'remind', $tid, $extendParams); } }
public function decorateSaveProperty($property) { //if ($property['isblank']) $blak = $property['limit'] = 1; $property['width'] = (int) $property['width']; $property['height'] = (int) $property['height']; $property['intro'] = Pw::substrs($property['intro'], 50); if ($property['cover'] == 2) { $result = $this->_uploadFile(); if ($result instanceof PwError) { return $result; } $property['image'] = $result; } $property['html_tpl'] = '<for:><a href="{url}"><img src="{image}" '; $property['html_tpl'] .= $property['intro'] ? 'title="{intro}" ' : ''; $property['html_tpl'] .= $property['width'] ? 'width="{width}" ' : ''; $property['html_tpl'] .= $property['height'] ? 'height="{height}" ' : ''; $property['html_tpl'] .= '></a></for>'; return $property; }
/** * 我的回复 * */ public function postAction() { list($page, $perpage) = $this->getInput(array('page', 'perpage')); $page = $page ? $page : 1; $perpage = 20; list($start, $limit) = Pw::page2limit($page, $perpage); $count = $this->_getCountPost($this->space->spaceUid, $this->loginUser->uid); if ($count) { $tmpPosts = $this->_getPost($this->space->spaceUid, $this->loginUser->uid, $limit, $start); $posts = $tids = array(); foreach ($tmpPosts as $v) { $tids[] = $v['tid']; } $threads = $this->_getThreadDs()->fetchThread($tids); foreach ($tmpPosts as $v) { $v['threadSubject'] = Pw::substrs($threads[$v['tid']]['subject'], 30); $v['content'] = Pw::substrs($v['content'], 30); $v['created_time'] = PW::time2str($v['created_time'], 'auto'); $posts[] = $v; } } $args = array('uid' => $this->space->spaceUid); $this->setOutput($args, 'args'); $this->setOutput($count, 'count'); $this->setOutput($page, 'page'); $this->setOutput($perpage, 'perpage'); $this->setOutput($posts, 'posts'); $this->setOutput('thread', 'src'); // seo设置 Wind::import('SRV:seo.bo.PwSeoBo'); $seoBo = PwSeoBo::getInstance(); $lang = Wind::getComponent('i18n'); $des = $lang->getMessage('SEO:space.thread.post.description', array($this->space->spaceUser['username'])); if ($page <= 1) { $seoBo->setCustomSeo($lang->getMessage('SEO:space.thread.post.title', array($this->space->spaceUser['username'], $this->space->space['space_name'])), '', $des); } else { $seoBo->setCustomSeo($lang->getMessage('SEO:space.thread.post.page.title', array($this->space->spaceUser['username'], $page, $this->space->space['space_name'])), '', $des); } Wekit::setV('seo', $seoBo); }
public function run($id) { if ($this->tag) { $data = Wekit::load('weibo.PwWeibo')->getWeibo($id); if (!$data) { return false; } $tag = $this->tag; /* @var $logSrv PwLogService */ $logSrv = Wekit::load('log.srv.PwLogService'); $langArgs = array(); $langArgs['tag_url'] = WindUrlHelper::createUrl('tag/index/view', array('name' => $tag['tag_name'])); $langArgs['tag'] = $tag['tag_name']; $langArgs['content_url'] = ''; $langArgs['content'] = Pw::substrs(strip_tags(Pw::stripWindCode($data['content'])), 20, 0, true); $langArgs['type'] = '微博'; $dm = new PwLogDm(); $dm->setOperatedUser($data['created_userid'], $data['created_username']); //从话题中屏蔽帖子。管理日志添加 $logSrv->addShieldTagLog($this->srv->user, $dm, $langArgs, $this->srv->ifShield); } }
/** * 发送推送消息 */ public function afterPush($pushid) { $extend = ''; $pushDs = Wekit::load('design.PwDesignPush'); $push = $pushDs->getPush($pushid); if (!$push) { return false; } $thread = Wekit::load('forum.PwThread')->getThread($push['push_from_id']); if (!$thread) { return false; } $info = unserialize($push['push_extend']); $standard = unserialize($push['push_standard']); $sTitle = $info[$standard['sTitle']]; $sUrl = $info[$standard['sUrl']]; $user = Wekit::load('SRV:user.PwUser')->getUserByUid($push['created_userid']); Wind::import('SRV:credit.bo.PwCreditBo'); Wind::import('SRV:forum.bo.PwForumBo'); $credit = PwCreditBo::getInstance(); $operation = 'push_thread'; $forum = new PwForumBo($thread['fid']); $credit->operate($operation, PwUserBo::getInstance($thread['created_userid']), true, array('forumname' => $forum->foruminfo['name']), $forum->getCreditSet($operation)); $credit->execute(); $strategy = $credit->getStrategy($operation); foreach ((array) $strategy['credit'] as $k => $v) { $v && ($extend .= $credit->cType[$k] . '+' . $v); } //$bo->sets($push['author_uid'], $credit['credit']); if ($push['neednotice']) { $content = '恭喜,您的帖子<a href="' . $sUrl . '">' . Pw::substrs($sTitle, 20) . '</a>被<a href="' . WindUrlHelper::createUrl('space/index/run', array('uid' => $push['created_userid']), '', 'pw') . '">' . $user['username'] . '</a>执行 推送 操作。'; $extend && ($content .= '获得' . $extend); $title = '帖子《<a href="' . $sUrl . '">' . Pw::substrs($sTitle, 20) . '</a>》被推送'; Wekit::load('SRV:message.srv.PwNoticeService')->sendDefaultNotice($push['author_uid'], $content, $title); $pushDs->updateNeedNotice($pushid, 0); } return true; }
private function _sendReplyNotice($pid, $tid) { $info = Wekit::load('thread.PwThread')->getPost($this->_rpid); $param = $info['pid']; $params = array(); $params['replyUserid'] = $this->user->uid; $params['replyUsername'] = $this->user->username; $info['content'] = preg_replace('/\\[quote(=.+?\\,\\d+)?\\].*?\\[\\/quote\\]/is', '', $info['content']); $params['postTitle'] = Pw::stripWindCode($info['content']); $params['postTitle'] = $params['postTitle'] ? $params['postTitle'] : 'Re:' . $this->info['subject']; $params['postTitle'] = Pw::substrs($params['postTitle'], 30); $params['threadId'] = $info['tid']; $params['pid'] = $pid; $params['postUserid'] = $info['created_userid']; $type = 'postreply'; if (!$info['reply_notice'] || $this->user->uid == $info['created_userid']) { return false; } $blackUid = Wekit::load('user.PwUserBlack')->checkUserBlack($this->user->uid, $info['created_userid']); if ($blackUid) { return false; } return $this->_getNoticeService()->sendNotice($info['created_userid'], $type, $param, $params); }
private function _parseEmotion($message) { Wind::import('LIB:ubb.PwUbbCode'); $message = $this->_parseUrl($message); $message = Pw::substrs($message, 36); return PwUbbCode::parseEmotion($message); }
/** * 获取积分设置 todo */ protected function setCredits($credits, $tid, $pid = 0) { if (!$credits) { return false; } $loginUser = Wekit::getLoginUser(); Wind::import('SRV:credit.bo.PwCreditBo'); $creditBo = PwCreditBo::getInstance(); $threadDs = Wekit::load('forum.PwThread'); if ($pid) { $data = $threadDs->getPost($pid); $subject = Pw::substrs($data['content'], '15'); $created_userid = $data['created_userid']; $created_username = $data['created_username']; } else { $data = $threadDs->getThread($tid); $subject = Pw::substrs($data['subject'], '15'); $created_userid = $data['created_userid']; $created_username = $data['created_username']; } if (!$data) { return new PwError('数据错误,帖子或者回复已被删除'); } $app_mark_credits = $loginUser->getPermission('app_mark_credits'); $toCredits = $creditLog = array(); foreach ($credits as $k => $v) { $absV = $v > 0 ? abs($v) : $v; $creditLog[$k] = $absV; $creditBo->set($created_userid, $k, $absV, true); // 扣除自己的积分 if (!$app_mark_credits[$k]['markdt']) { continue; } $affect = -abs($v); $toCredits[$k] = $affect; $creditBo->set($loginUser->uid, $k, $affect, true); } $creditBo->addLog('app_mark', $creditLog, new PwUserBo($created_userid), array('subject' => $subject, 'username' => $loginUser->username)); $creditBo->addLog('app_tomark', $toCredits, $loginUser, array('subject' => $subject, 'username' => $loginUser->username)); $creditBo->execute(); return $data; }
protected function modelPostList($limit, $page) { $ds = Wekit::load('forum.PwThread'); list($offset, $limit) = Pw::page2limit($page, $limit); $count = $ds->countPostByUid($this->spaceUid); if ($count) { $tmpPosts = $ds->getPostByUid($this->spaceUid, $limit, $offset); $posts = $tids = array(); foreach ($tmpPosts as $v) { $tids[] = $v['tid']; } $threads = $this->_getThreadDs()->fetchThread($tids); foreach ($tmpPosts as $v) { $v['threadSubject'] = Pw::substrs($threads[$v['tid']]['subject'], 30); $v['content'] = Pw::substrs($v['content'], 30); $v['created_time'] = PW::time2str($v['created_time'], 'auto'); $posts[] = $v; } } return array($count, $posts); }
/** * 获取当前路径导航条 * * @return string */ public function getHeadguide() { return $this->forum->headguide() . $this->forum->bulidGuide(array(Pw::substrs($this->thread->info['subject'], 30), WindUrlHelper::createUrl('bbs/read/run', array('tid' => $this->tid, 'fid' => $this->fid)))); }
public function buildTitle($param = 0, $extendParams = null, $aggregatedNotice = null) { return Pw::substrs(strip_tags($extendParams['content']), 28); }
public function setName($name) { $this->_data['module_name'] = Pw::substrs($name, 20); return $this; }
public function setTagname($tagname) { $this->_data['tagname'] = Pw::substrs($tagname, 10); return $this; }
public function setEmotionName($emotionName) { $this->_data['emotion_name'] = Pw::substrs($emotionName, 10); return $this; }
/** * 格式化简介 * @param string $time */ protected final function _formatDes($string) { $string = Pw::stripWindCode($string); $string = preg_replace("/\r\n|\n|\r/", '', $string); $string = str_replace(' ', '', $string); return $this->_viewSet['desnum'] > 0 ? Pw::substrs($string, $this->_viewSet['desnum']) : $string; }
/** * 获取列表页展示的帖子数据 */ public function fetchThreadsList($tids, $uid = 0, $result_type = 'ASSOC') { if (!$tids) { return array(); } Wind::import('SRV:like.PwLikeContent'); $threads = Wekit::loadDao('native.dao.PwNativeThreadsDao')->fetchThreads($tids); $threads_place = Wekit::loadDao('native.dao.PwThreadsPlaceDao')->fetchByTids($tids); $threads_content = Wekit::loadDao('forum.dao.PwThreadsContentDao')->fetchThread($tids); $PwThreadService = Wekit::load('forum.srv.PwThreadService'); $PwNativeThreadService = Wekit::load('native.PwNativeThread'); $threadLikeData = Wekit::load('like.srv.reply.do.PwLikeDoReply')->getAllLikeUserids(PwLikeContent::THREAD, $tids); foreach ($threadLikeData as $k => $v) { if (!in_array($uid, $v)) { unset($threadLikeData[$k]); } } $tag_names_str = ''; foreach ($threads as $k => $v) { $content = isset($threads_content[$k]['content']) ? $threads_content[$k]['content'] : ''; $threads[$k]['tags'] = $threads[$k]['tags_origin'] = isset($threads_content[$k]['tags']) ? $threads_content[$k]['tags'] : ''; $threads[$k]['from_type'] = isset($threads_place[$k]['from_type']) ? $threads_place[$k]['from_type'] : 0; $threads[$k]['created_address'] = isset($threads_place[$k]['created_address']) ? $threads_place[$k]['created_address'] : ''; $threads[$k]['area_code'] = isset($threads_place[$k]['area_code']) ? $threads_place[$k]['area_code'] : ''; $threads[$k]['tags'] && ($tag_names_str .= ',' . $threads[$k]['tags']); $threads[$k]['avatar'] = Pw::getAvatar($v['created_userid'], 'small'); $threads[$k]['created_time'] = Pw::time2str($v['created_time'], 'auto'); $threads[$k]['lastpost_time'] = Pw::time2str($v['lastpost_time'], 'auto'); preg_match("/\\[mp3.*?\\].*?\\[\\/mp3\\]/i", $content, $matches); $threads[$k]['have_mp3'] = $matches ? true : false; preg_match("/\\[flash.*?\\].*?\\[\\/flash\\]/i", $content, $matches); $threads[$k]['have_flash'] = $matches ? true : false; $format_content = Pw::formatContent($content); //格式化移动端帖子内容去除ubb标签、分享链接内容、推广链接内容 $threads[$k]['isliked'] = isset($threadLikeData[$k]) ? true : false; $imgs = array_shift($PwNativeThreadService->getThreadAttach(array($k), array(0))); ksort($imgs); $imgs = array_slice($imgs, 0, 9); foreach ($imgs as $imgs_k => $imgs_v) { $imgs[$imgs_k]['realpath'] = str_replace("/thumb/mini", "", $imgs_v['path']); } $threads[$k]['content'] = array('text' => preg_replace('/(\\[)[^\\]]*$/i', '', Pw::substrs($format_content['content'], 70, 0, false)), 'imgs' => $imgs, 'share' => $format_content['share'], 'origin_content' => $content, 'format_content' => $format_content); } $tag_names_arr = array_unique(explode(',', trim($tag_names_str, ','))); $tag_names = Wekit::loadDao('tag.dao.PwTagDao')->getTagsByNames($tag_names_arr); // var_dump($tag_names);exit; foreach ($threads as $k => $v) { if ($v['tags']) { $tag_arr = explode(',', $v['tags']); $tag_tmp = array(); foreach ($tag_arr as $name) { array_key_exists($name, $tag_names) && ($tag_tmp[] = array('tag_id' => $tag_names[$name]['tag_id'], 'tag_name' => $name)); } $threads[$k]['tags'] = $tag_tmp; } } $threads_tmp = array(); $sort_num = 0; if ($result_type == 'ASSOC') { //按照tids的顺序重新排序结果集,tid作为索引 foreach ($tids as $v) { if (isset($threads[$v])) { $threads_tmp[$v] = $threads[$v]; $threads_tmp[$v]['sort'] = $sort_num++; } } } else { //tid会有重复的情况,置顶帖在列表中显示2次,数字顺序索引 foreach ($tids as $v) { if (isset($threads[$v])) { $threads[$v]['sort'] = $sort_num++; $threads_tmp[] = $threads[$v]; } } } // print_r($threads_tmp);exit; return $threads_tmp; }