public static function getPostExtraPanel() { $panels = array('topic' => array(), 'post' => array()); global $_G; // 评分的权限控制 $ratePlugConfig = (int) WebUtils::getDzPluginAppbymeAppConfig('forum_allow_topic_rate'); if ($ratePlugConfig && $_G['group']['raterange']) { $panels['topic'][] = array('action' => 'rate', 'title' => WebUtils::t('评分')); // $panels['post'][] = array('action' => 'rate', 'title' => WebUtils::t('评分')); } // 赞 $topicConfig = (int) WebUtils::getDzPluginAppbymeAppConfig('forum_allow_topic_recommend'); $postConfig = (int) WebUtils::getDzPluginAppbymeAppConfig('forum_allow_post_recommend'); // $topicConfig = $postConfig = 1; $support = $_G['setting']['recommendthread']; if ($support['status'] && $topicConfig == 1) { $panels['topic'][] = array('action' => 'support', 'title' => WebUtils::emptyHtml($support['addtext'])); } $supportPost = $_G['setting']['repliesrank']; if (MobcentDiscuz::getMobcentDiscuzVersion() > 'x25' && $supportPost && $postConfig == 1) { $panels['post'][] = array('action' => 'support', 'title' => WebUtils::emptyHtml(WebUtils::t('支持')), 'recommendAdd' => ''); } return $panels; }
private function _applyActivityTopic($res, $tid, $uid, $data) { // from forum_misc.php require_once libfile('function/post'); $activity = DzForumActivity::getActivityByTid($tid); if ($activity['expiration'] && $activity['expiration'] < TIMESTAMP) { return $this->_makeErrorInfo($res, 'activity_stop'); } $applyinfo = DzForumActivityApply::getApplyByTidUid($tid, $uid); if ($applyinfo && $applyinfo['verified'] < DzForumActivityApply::STATUS_VERIFIED_IMPROVE) { return $this->_makeErrorInfo($res, 'activity_repeat_apply'); } global $_G; $_GET = $data; $thread = ForumUtils::getTopicInfo($tid); $payvalue = intval($_GET['payvalue']); $payment = $_GET['payment'] ? $payvalue : -1; $message = cutstr(dhtmlspecialchars($_GET['message']), 200); $verified = $thread['authorid'] == $uid ? 1 : 0; $ufielddata = ''; if ($activity['ufield']) { $ufielddata = array(); $version = MobcentDiscuz::getMobcentDiscuzVersion(); $activity['ufield'] = $version != MobcentDiscuz::VERSION_X20 ? dunserialize($activity['ufield']) : unserialize($activity['ufield']); if (!empty($activity['ufield']['userfield'])) { if ($version == MobcentDiscuz::VERSION_X20) { if (!class_exists('discuz_censor')) { include libfile('class/censor'); } } $censor = discuz_censor::instance(); loadcache('profilesetting'); foreach ($data as $key => $value) { if (empty($_G['cache']['profilesetting'][$key])) { continue; } if (is_array($value)) { $value = implode(',', $value); } $value = cutstr(dhtmlspecialchars(trim($value)), 100, '.'); // if ($_G['cache']['profilesetting'][$key]['formtype'] == 'file' && !preg_match("/^https?:\/\/(.*)?\.(jpg|png|gif|jpeg|bmp)$/i", $value)) { // showmessage('activity_imgurl_error'); // } if (empty($value) && $key != 'residedist' && $key != 'residecommunity') { return $this->_makeErrorInfo($res, 'activity_exile_field'); } $ufielddata['userfield'][$key] = $value; } } if (!empty($activity['ufield']['extfield'])) { foreach ($activity['ufield']['extfield'] as $fieldid) { $value = cutstr(dhtmlspecialchars(trim($_GET['' . $fieldid])), 50, '.'); $ufielddata['extfield'][$fieldid] = $value; } } $ufielddata = !empty($ufielddata) ? serialize($ufielddata) : ''; } if ($_G['setting']['activitycredit'] && $activity['credit'] && empty($applyinfo['verified'])) { checklowerlimit(array('extcredits' . $_G['setting']['activitycredit'] => '-' . $activity['credit'])); updatemembercount($uid, array($_G['setting']['activitycredit'] => '-' . $activity['credit']), true, 'ACC', $tid); } $data = array('tid' => $tid, 'username' => $_G['username'], 'uid' => $uid, 'message' => $message, 'verified' => $verified, 'dateline' => $_G['timestamp'], 'payment' => $payment, 'ufielddata' => $ufielddata); if ($applyinfo && $applyinfo['verified'] == DzForumActivityApply::STATUS_VERIFIED_IMPROVE) { DzForumActivityApply::updateApplyById($data, $applyinfo['applyid']); } else { DzForumActivityApply::insertApply($data); } DzForumActivity::updateApplyNumberByTid($tid); if ($thread['authorid'] != $uid) { notification_add($thread['authorid'], 'activity', 'activity_notice', array('tid' => $tid, 'subject' => $thread['subject'])); $space = array(); space_merge($space, 'field_home'); if (!empty($space['privacy']['feed']['newreply'])) { $feed['icon'] = 'activity'; $feed['title_template'] = 'feed_reply_activity_title'; $feed['title_data'] = array('subject' => "<a href=\"forum.php?mod=viewthread&tid={$tid}\">{$thread['subject']}</a>", 'hash_data' => "tid{$tid}"); $feed['id'] = $tid; $feed['idtype'] = 'tid'; postfeed($feed); } } $res = $this->_makeErrorInfo($res, 'activity_completion'); $res['rs'] = 1; return $res; }
public function loadForum($fid, $tid = 0) { require_once libfile('function/forum'); $path = Yii::getPathOfAlias('application.components.discuz.source.function'); require_once sprintf('%s/function_forum_%s.php', $path, MobcentDiscuz::getMobcentDiscuzVersion()); $_GET['fid'] = $fid; $_GET['tid'] = $tid; global $_G; $_G['setting']['forumpicstyle'] = null; loadforum(); }
public function actionPluginInfo() { $hasPortal = WebUtils::getDzPluginAppbymeAppConfig('portal_allow_open'); $hasPortal = $hasPortal == 1 ? 1 : 0; echo WebUtils::jsonEncode(array('mobcent_version' => MOBCENT_VERSION, 'mobcent_release' => MOBCENT_RELEASE, 'mobcent_release_debug' => MOBCENT_RELEASE_DEBUG, 'discuz_version' => MobcentDiscuz::getDiscuzVersion(), 'mobcent_discuz_version' => MobcentDiscuz::getMobcentDiscuzVersion(), 'has_portal' => $hasPortal)); }
<?php define('IN_DISCUZ', true); define('DISCUZ_ROOT', substr(dirname(__FILE__), 0, -29)); require_once DISCUZ_ROOT . '/source/discuz_version.php'; require_once DISCUZ_ROOT . '/config/config_ucenter.php'; Mobcent::import(sprintf('%s/discuz_core_%s.php', dirname(__FILE__), MobcentDiscuz::getMobcentDiscuzVersion())); Mobcent::import(MOBCENT_APP_ROOT . '/components/discuz/source/function/function_core.php'); class MobcentDiscuz { const VERSION_X20 = 'x20'; const VERSION_X25 = 'x25'; const VERSION_X30 = 'x30'; const VERSION_X31 = 'x30'; private static $_discuzVersions = array('X2' => self::VERSION_X20, 'X2.5' => self::VERSION_X25, 'X3' => self::VERSION_X30, 'X3.1' => self::VERSION_X30); public static function getDiscuzVersions() { return self::$_discuzVersions; } public static function getDiscuzVersion() { return DISCUZ_VERSION; } public static function getMobcentDiscuzVersion() { if (isset(self::$_discuzVersions[self::getDiscuzVersion()])) { return self::$_discuzVersions[self::getDiscuzVersion()]; } else { $version = end(self::$_discuzVersions); reset(self::$_discuzVersions); return $version;
private function _getPostInfos($res, $topic, $page, $pageSize, $order, $authorId, $params = array()) { extract($params); $postInfos = array(); $tid = (int) $topic['tid']; $postCount = ForumUtils::getPostCount($tid, array('authorId' => $authorId)); if (!empty($topic)) { global $_G; $isOnlyAuthorTopic = ForumUtils::isOnlyAuthorTopic($topic); $postList = ForumUtils::getPostList($tid, $page, $pageSize, array('order' => $order ? 'dateline DESC' : 'dateline ASC', 'authorId' => $authorId)); $position = $order ? $postCount + 1 - $pageSize * ($page - 1) : $pageSize * ($page - 1) + 2; if (MobcentDiscuz::getMobcentDiscuzVersion() > 'x25' && $_G['setting']['repliesrank'] && $postList) { if ($postList) { $tempPids = array(); $tempPostRecommends = array(); foreach ($postList as $post) { $tempPids[] = (int) $post['pid']; } foreach (C::t('forum_hotreply_number')->fetch_all_by_pids(array_values($tempPids)) as $pid => $post) { $tempPostRecommends[$pid]['support'] = dintval($post['support']); // $tempPostRecommends[$pid]['against'] = dintval($post['against']); } $isSupport = DzSupportInfo::getSupportPostsByUidAndTid($_G['uid'], $tid); } } foreach ($postList as $post) { $pid = (int) $post['pid']; $content = ForumUtils::getPostContent($tid, $pid, $post); $isOnlyAuthorPost = $isOnlyAuthorTopic && $_G['uid'] != $post['authorid'] && $_G['uid'] != $_G['forum_thread']['authorid'] && !$post['first'] && !$_G['forum']['ismoderator']; $postInfo['reply_id'] = ForumUtils::isAnonymousPost($tid, $post) ? 0 : (int) $post['authorid']; $postInfo['reply_content'] = $isOnlyAuthorPost ? $this->_filterContent(array(array('content' => WebUtils::t('此帖仅作者可见'), 'type' => 'text'))) : $this->_getPostContent($content); $postInfo['reply_type'] = 'normal'; $this->_isComplexContent($postInfo['reply_content']) && ($postInfo['reply_type'] = 'normal_complex'); $postInfo['reply_name'] = ForumUtils::isAnonymousPost($tid, $post) ? $this->_getAnonymoustext() : $post['author']; $postInfo['reply_posts_id'] = $pid; // 抢楼帖时采用原楼层 if (getstatus($topic['status'], 3)) { $postInfo['position'] = $post['position']; } else { $postInfo['position'] = $order ? $position-- : $position++; } $postInfo['posts_date'] = $post['dateline'] . '000'; $postInfo['icon'] = UserUtils::getUserAvatar($postInfo['reply_id']); $postInfo['level'] = $this->_getUserLevel($postInfo['reply_id']); $postInfo['userTitle'] = UserUtils::getUserTitle($postInfo['reply_id']); $postInfo['location'] = ForumUtils::getPostLocation($pid); $postInfo['mobileSign'] = ForumUtils::getMobileSign($post['status']); // if(empty($post['author']) && isset($post['authorid']) && !empty($post['authorid'])){ // $postInfo['reply_status'] = -1; // }elseif(empty($post ['author']) && empty($post ['authorid'])){ // $postInfo['reply_status'] = 0; // }else{ // $postInfo['reply_status'] = 1; // } $postInfo['reply_status'] = 1; $postInfo['status'] = 1; $postInfo['role_num'] = 1; $postInfo['title'] = ''; $postInfo = array_merge($postInfo, $this->_getPostQuoteInfo($content, $isOnlyAuthorPost)); // 回帖管理面板编辑 start $userMember = $this->_getUserInfoByAuthorid($post['authorid']); $userMember = array_merge($userMember, $post); $params = array('editPerm' => $editPerm, 'userMember' => $userMember); // end $manageItems = ForumUtils::getPostManagePanel($params); foreach ($manageItems['post'] as $key => $item) { if ($item['action'] == 'edit') { $item['action'] = WebUtils::getHttpFileName("forum.php?mod=post&action=edit&fid={$post['fid']}&tid={$post['tid']}&pid={$post['pid']}"); } else { $item['action'] = WebUtils::createUrl_oldVersion('forum/topicadminview', array('fid' => $post['fid'], 'tid' => $tid, 'pid' => $post['pid'], 'act' => $item['action'], 'type' => 'post')); } $manageItems['post'][$key] = $item; } $count = mb_strlen($postInfo['reply_content'][0]['infor'], $_G['charset']); if ($count < $_G['setting']['threadfilternum']) { $isWater = true; } $isWater = false; $count = mb_strlen($postInfo['reply_content'][0]['infor'], $_G['charset']); if ($_G['setting']['filterednovote'] && $count < $_G['setting']['threadfilternum']) { $isWater = true; } $extraItems = array(); $tempExtraItems = ForumUtils::getPostExtraPanel(); foreach ($tempExtraItems['post'] as $key => $item) { $item['extParams'] = array('beforeAction' => ''); $item['type'] = $item['action']; $item['action'] = ''; if ($item['type'] == 'support' && !$isWater) { $item['action'] = WebUtils::createUrl_oldVersion('forum/support', array('tid' => $tid, 'pid' => $post['pid'], 'type' => 'post')); $item['extParams']['recommendAdd'] = (int) $tempPostRecommends[$post['pid']]['support']; $isRecommendAdd = in_array($post['pid'], $isSupport) ? 1 : 0; $item['extParams']['isHasRecommendAdd'] = (int) $isRecommendAdd; } if ($item['type'] != 'support' || !$isWater) { $extraItems[] = $item; } } $postInfo['managePanel'] = $manageItems['post']; $postInfo['extraPanel'] = $extraItems; $postInfos[] = $postInfo; } } $res = WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $postCount, $res); $res['list'] = $postInfos; return $res; }
public static function transPostContentToHtml($post) { Mobcent::import(sprintf('%s/forum_viewthread_%s.php', MOBCENT_APP_ROOT . '/components/discuz/forum', MobcentDiscuz::getMobcentDiscuzVersion())); ForumUtils::initForum($post['fid'], $post['tid']); loadcache('usergroups'); $userInfo = UserUtils::getUserInfo($post['authorid']); $post = array_merge($userInfo, $post); global $_G; // 处理主题价格 $_G['forum_threadpay'] = FALSE; if ($post['first']) { if ($_G['forum_thread']['price'] > 0 && $_G['forum_thread']['special'] == 0) { if ($_G['setting']['maxchargespan'] && TIMESTAMP - $_G['forum_thread']['dateline'] >= $_G['setting']['maxchargespan'] * 3600) { C::t('forum_thread')->update($_G['tid'], array('price' => 0), false, false, $archiveid); $_G['forum_thread']['price'] = 0; } else { $exemptvalue = $_G['forum']['ismoderator'] ? 128 : 16; if (!($_G['group']['exempt'] & $exemptvalue) && $_G['forum_thread']['authorid'] != $_G['uid']) { if (!C::t('common_credit_log')->count_by_uid_operation_relatedid($_G['uid'], 'BTC', $_G['tid'])) { require_once libfile('thread/pay', 'include'); $_G['forum_threadpay'] = TRUE; } } } } } $lastvisit = $_G['member']['lastvisit']; $ordertype = $maxposition = 0; // 处理附件 $_G['forum_attachpids'] = $_G['forum_attachtags'] = ''; $_G['tid'] = $post['tid']; // 去掉干扰码 $_G['forum']['jammer'] = 0; $post = viewthread_procpost($post, $lastvisit, $ordertype, $maxposition); $postlist[$post['pid']] = $post; if ($_G['forum_attachpids'] && !defined('IN_ARCHIVER')) { require_once libfile('function/attachment'); if (is_array($threadsortshow) && !empty($threadsortshow['sortaids'])) { $skipaids = $threadsortshow['sortaids']; } parseattach($_G['forum_attachpids'], $_G['forum_attachtags'], $postlist, $skipaids); } if (empty($postlist)) { showmessage('post_not_found'); } elseif (!defined('IN_MOBILE_API')) { foreach ($postlist as $pid => $post) { // 取出没有插入的附件 if (!empty($post['imagelist'])) { $postlist[$pid]['message'] .= showattach($post, 1); } if ($post['attachlist']) { $postlist[$pid]['message'] .= showattach($post); } $postlist[$pid]['message'] = preg_replace("/\\[attach\\]\\d+\\[\\/attach\\]/i", '', $postlist[$pid]['message']); } } if ($post['first'] && $_G['forum_threadpay']) { $postlist[$pid]['message'] = $thread['freemessage']; } // 处理屏蔽 if (!$_G['forum']['ismoderator'] && $postlist[$pid]['status'] & 1) { $postlist[$pid]['message'] = WebUtils::t('该帖被管理员或版主屏蔽'); } return $postlist[$post['pid']]; }