private function _sendPostResult($jsonInfo, $act) { $res = $this->initWebApiArray(); switch ($act) { case 'new': $res['head']['errInfo'] = WebUtils::t('发贴成功'); break; case 'reply': $res['head']['errInfo'] = WebUtils::t('回贴成功'); break; default: $res['head']['errInfo'] = WebUtils::t('编辑成功'); break; } $app = Yii::app()->getController()->mobcentDiscuzApp; $app->loadForum($jsonInfo['fid'], $jsonInfo['tid']); if (($checkMessage = mobcent_cknewuser()) != '') { return $this->makeErrorInfo($res, WebUtils::emptyHtml($checkMessage)); } require_once libfile('class/credit'); require_once libfile('function/post'); global $_G; if ($_G['forum']['simple'] & 1 || $_G['forum']['redirect']) { return $this->makeErrorInfo($res, lang('message', 'forum_disablepost')); } /*初始化变量*/ $pid = 0; $sortid = 0; $typeid = 0; $special = 0; $readperm = 0; $_GET['tid'] = $jsonInfo['tid']; $_GET['fid'] = $jsonInfo['fid']; $_G['tid'] = $jsonInfo['tid']; $_GET['typeoption'] = WebUtils::jsonDecode(rawurldecode($jsonInfo['typeOption'])); $typeInfo = array(); foreach ($_GET['typeoption'] as $k => $v) { $typeInfo[$k] = WebUtils::t($v); } $_GET['typeoption'] = $typeInfo; $_GET['isanonymous'] = $jsonInfo['isAnonymous']; $_GET['hiddenreplies'] = $jsonInfo['isOnlyAuthor']; $_GET['usesig'] = 1; $_GET['allownoticeauthor'] = 1; if ($jsonInfo['typeId']) { $typeid = $jsonInfo['typeId']; } //copy dz from source/module/forum/forum_post.php $postinfo = array('subject' => ''); $thread = array('readperm' => '', 'pricedisplay' => '', 'hiddenreplies' => ''); $_G['forum_dtype'] = $_G['forum_checkoption'] = $_G['forum_optionlist'] = $tagarray = $_G['forum_typetemplate'] = array(); if ($jsonInfo['sortId'] && $jsonInfo['sortId'] > 0) { $sortid = $jsonInfo['sortId']; require_once libfile('post/threadsorts', 'include'); } /*找出哪项是图片上传项和多项选择项,拼接成所想要的数组类型*/ $optionId = DB::fetch_all("SELECT optionid FROM " . DB::table('forum_typevar') . " WHERE sortid=%d", array($sortid)); foreach ($optionId as $key => $value) { $type = DB::fetch_first("SELECT identifier,type FROM " . DB::table('forum_typeoption') . " WHERE optionid=%d", array($value['optionid'])); if ($type['type'] == 'image') { $attachImg = DB::fetch_first("SELECT attachment FROM " . DB::table('forum_attachment_unused') . " WHERE aid = %d ", array($_GET['typeoption'][$type['identifier']])); $attachImg = $_G['setting']['attachurl'] . 'forum/' . $attachImg['attachment']; $_GET['typeoption'][$type['identifier']] = array('aid' => $_GET['typeoption'][$type['identifier']], 'url' => $attachImg); } if ($type['type'] == 'checkbox') { $_GET['typeoption'][$type['identifier']] = explode(',', $_GET['typeoption'][$type['identifier']]); } } require_once libfile('function/discuzcode'); if ($act == 'edit' || $act == 'reply') { $thread = C::t('forum_thread')->fetch($_G['tid']); if (!$_G['forum_auditstatuson'] && !($thread['displayorder'] >= 0 || in_array($thread['displayorder'], array(-4, -2)) && $thread['authorid'] == $_G['uid'])) { $thread = array(); } if (!empty($thread)) { if ($thread['readperm'] && $thread['readperm'] > $_G['group']['readaccess'] && !$_G['forum']['ismoderator'] && $thread['authorid'] != $_G['uid']) { return WebUtils::makeErrorInfo_oldVersion($res, 'thread_nopermission', array('{readperm}' => $thread['readperm'])); } $_G['fid'] = $thread['fid']; $special = $thread['special']; } else { return WebUtils::makeErrorInfo_oldVersion($res, 'thread_nonexistence'); } if ($thread['closed'] == 1 && !$_G['forum']['ismoderator']) { return WebUtils::makeErrorInfo_oldVersion($res, 'post_thread_closed'); } } if ($jsonInfo['isQuote'] && $jsonInfo['replyId'] > 0) { $_GET['repquote'] = $jsonInfo['replyId']; $language = lang('forum/misc'); $noticeauthor = $noticetrimstr = ''; $thaquote = C::t('forum_post')->fetch('tid:' . $_G['tid'], $_GET['repquote']); if (!($thaquote && ($thaquote['invisible'] == 0 || $thaquote['authorid'] == $_G['uid'] && $thaquote['invisible'] == -2))) { $thaquote = array(); } if ($thaquote['tid'] != $_G['tid']) { return WebUtils::makeErrorInfo_oldVersion($res, 'reply_quotepost_error'); } if (getstatus($thread['status'], 2) && $thaquote['authorid'] != $_G['uid'] && $_G['uid'] != $thread['authorid'] && $thaquote['first'] != 1 && !$_G['forum']['ismoderator']) { return WebUtils::makeErrorInfo_oldVersion($res, 'reply_quotepost_error'); } if (!($thread['price'] && !$thread['special'] && $thaquote['first'])) { $quotefid = $thaquote['fid']; $message = $thaquote['message']; if ($_G['setting']['bannedmessages'] && $thaquote['authorid']) { $author = getuserbyuid($thaquote['authorid']); if (!$author['groupid'] || $author['groupid'] == 4 || $author['groupid'] == 5) { $message = $language['post_banned']; } elseif ($thaquote['status'] & 1) { $message = $language['post_single_banned']; } } $time = dgmdate($thaquote['dateline']); $message = messagecutstr($message, 100); $message = implode("\n", array_slice(explode("\n", $message), 0, 3)); $thaquote['useip'] = substr($thaquote['useip'], 0, strrpos($thaquote['useip'], '.')) . '.x'; if ($thaquote['author'] && $thaquote['anonymous']) { $thaquote['author'] = lang('forum/misc', 'anonymoususer'); } elseif (!$thaquote['author']) { $thaquote['author'] = lang('forum/misc', 'guestuser') . ' ' . $thaquote['useip']; } else { $thaquote['author'] = $thaquote['author']; } $post_reply_quote = lang('forum/misc', 'post_reply_quote', array('author' => $thaquote['author'], 'time' => $time)); $noticeauthormsg = dhtmlspecialchars($message); if (!defined('IN_MOBILE')) { $message = "[quote][size=2][color=#999999]{$post_reply_quote}[/color] [url=forum.php?mod=redirect&goto=findpost&pid={$_GET['repquote']}&ptid={$_G['tid']}][img]static/image/common/back.gif[/img][/url][/size]\n{$message}[/quote]"; } else { $message = "[quote][color=#999999]{$post_reply_quote}[/color]\n[color=#999999]{$message}[/color][/quote]"; } $quotemessage = discuzcode($message, 0, 0); $noticeauthor = dhtmlspecialchars(authcode('q|' . $thaquote['authorid'], 'ENCODE')); $noticetrimstr = dhtmlspecialchars($message); $_GET['noticetrimstr'] = $noticetrimstr; $_GET['noticeauthor'] = $noticeauthor; } } //periodscheck('postbanperiods'); if ($_G['forum']['password'] && $_G['forum']['password'] != $_G['cookie']['fidpw' . $_G['fid']]) { return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd'); } if (empty($_G['forum']['allowview'])) { if (!$_G['forum']['viewperm'] && !$_G['group']['readaccess']) { return WebUtils::makeErrorInfo_oldVersion($res, 'group_nopermission', array('{grouptitle}' => $_G['group']['grouptitle'])); } elseif ($_G['forum']['viewperm'] && !forumperm($_G['forum']['viewperm'])) { $msg = mobcent_showmessagenoperm('viewperm', $_G['fid']); return WebUtils::makeErrorInfo_oldVersion($res, $msg['message'], $msg['params']); } } elseif ($_G['forum']['allowview'] == -1) { return WebUtils::makeErrorInfo_oldVersion($res, 'forum_access_view_disallow'); } $msg = mobcent_formulaperm($_G['forum']['formulaperm']); if ($msg['message'] != '') { return WebUtils::makeErrorInfo_oldVersion($res, $msg['message'], $msg['params']); } //formulaperm($_G['forum']['formulaperm']); if (!$_G['adminid'] && $_G['setting']['newbiespan'] && (!getuserprofile('lastpost') || TIMESTAMP - getuserprofile('lastpost') < $_G['setting']['newbiespan'] * 60) && TIMESTAMP - $_G['member']['regdate'] < $_G['setting']['newbiespan'] * 60) { return WebUtils::makeErrorInfo_oldVersion($res, 'post_newbie_span', array('{newbiespan}' => $_G['setting']['newbiespan'])); } $special = $special > 0 && $special < 7 || $special == 127 ? intval($special) : 0; $jsonInfo['title'] = rawurldecode($jsonInfo['title']); $subject = isset($jsonInfo['title']) ? dhtmlspecialchars(censor(trim($jsonInfo['title']))) : ''; $subject = !empty($subject) ? str_replace("\t", ' ', $subject) : $subject; $subject = WebUtils::t($subject); /*贴子内容处理*/ $_GET['attachnew'] = array(); $aid = $jsonInfo['aid']; if (isset($aid) && !empty($aid)) { $aid_Img = explode(',', $aid); foreach ($aid_Img as $key => $value) { $_GET['attachnew'][$value] = array('description' => ''); } } $message = ''; $i = 0; if ($act == 'new') { $act = 'newthread'; } $jsonInfo['content'] = WebUtils::jsonDecode(rawurldecode($jsonInfo['content'])); foreach ($jsonInfo['content'] as $k => $v) { switch ($v["type"]) { case 0: // 解析文本的超链接 // @author: xjp $v['infor'] = preg_replace('/(https?:\\/\\/\\S+)/i', '[url=$1]$1[/url]', $v['infor']); $message .= $v["infor"] . "\r\n"; break; case 1: if (empty($aid_Img)) { if ($aid != 0) { $message .= '[attachimg]' . $aid . '[/attachimg]'; } else { $message .= '[img]' . $v['infor'] . '[/img]'; } } else { if ($aid_Img[$i] != 0) { $message .= '[attachimg]' . $aid_Img[$i] . '[/attachimg]'; } else { $message .= '[img]' . $v['infor'] . '[/img]'; } $i = $i + 1; } $attachment = 2; $message .= "\r\n"; break; case 3: $message .= "[audio]" . $v["infor"] . "[/audio]"; break; } } //表情处理 $message = $this->smilesReplace($message); WebUtils::getDzPluginAppbymeAppConfig('forum_allow_gbk_special') && ($message = mb_convert_encoding($message, 'HTML-ENTITIES', 'UTF-8')); $message = WebUtils::t($message); $readperm = isset($_GET['readperm']) ? intval($_GET['readperm']) : 0; $price = isset($_GET['price']) ? intval($_GET['price']) : 0; if (empty($bbcodeoff) && !$_G['group']['allowhidecode'] && !empty($message) && preg_match("/\\[hide=?\\d*\\].*?\\[\\/hide\\]/is", preg_replace("/(\\[code\\](.+?)\\[\\/code\\])/is", ' ', $message))) { return WebUtils::makeErrorInfo_oldVersion($res, 'post_hide_nopermission'); } $modnewthreads = $modnewreplies = 0; if (($subject || $message) && empty($_GET['save'])) { $extramessage = ($special == 5 ? "\t" . $_GET['affirmpoint'] . "\t" . $_GET['negapoint'] : '') . ($special == 4 ? "\t" . $_GET['activityplace'] . "\t" . $_GET['activitycity'] . "\t" . $_GET['activityclass'] : '') . ($special == 2 ? "\t" . $_GET['item_name'] . "\t" . $_GET['item_locus'] : '') . ($_GET['typeoption'] ? "\t" . implode("\t", $_GET['typeoption']) : '') . ($_GET['polloptions'] || $_GET['polloption'] ? "\t" . implode("\t", $_GET['tpolloption'] == 2 ? explode("\n", $_GET['polloptions']) : $_GET['polloption']) : ''); list($modnewthreads, $modnewreplies) = threadmodstatus($subject . "\t" . $message . $extramessage); unset($extramessage); } $urloffcheck = $usesigcheck = $smileyoffcheck = $codeoffcheck = $htmloncheck = $emailcheck = ''; $seccodecheck = $_G['setting']['seccodestatus'] & 4 && (!$_G['setting']['seccodedata']['minposts'] || getuserprofile('posts') < $_G['setting']['seccodedata']['minposts']); $secqaacheck = $_G['setting']['secqaa']['status'] & 2 && (!$_G['setting']['secqaa']['minposts'] || getuserprofile('posts') < $_G['setting']['secqaa']['minposts']); $_G['group']['allowpostpoll'] = $_G['group']['allowpost'] && $_G['group']['allowpostpoll'] && $_G['forum']['allowpostspecial'] & 1; $_G['group']['allowposttrade'] = $_G['group']['allowpost'] && $_G['group']['allowposttrade'] && $_G['forum']['allowpostspecial'] & 2; $_G['group']['allowpostreward'] = $_G['group']['allowpost'] && $_G['group']['allowpostreward'] && $_G['forum']['allowpostspecial'] & 4; $_G['group']['allowpostactivity'] = $_G['group']['allowpost'] && $_G['group']['allowpostactivity'] && $_G['forum']['allowpostspecial'] & 8; $_G['group']['allowpostdebate'] = $_G['group']['allowpost'] && $_G['group']['allowpostdebate'] && $_G['forum']['allowpostspecial'] & 16; $usesigcheck = $_G['uid'] && $_G['group']['maxsigsize'] ? 'checked="checked"' : ''; $ordertypecheck = !empty($thread['tid']) && getstatus($thread['status'], 4) ? 'checked="checked"' : ''; $specialextra = !empty($_GET['specialextra']) ? $_GET['specialextra'] : ''; $_G['forum']['threadplugin'] = dunserialize($_G['forum']['threadplugin']); $_G['group']['allowanonymous'] = $_G['forum']['allowanonymous'] || $_G['group']['allowanonymous'] ? 1 : 0; if ($specialextra) { $special = 127; } if ($act == 'newthread') { $policykey = 'post'; } elseif ($act == 'reply') { $policykey = 'reply'; } else { $policykey = ''; } if ($policykey) { $postcredits = $_G['forum'][$policykey . 'credits'] ? $_G['forum'][$policykey . 'credits'] : $_G['setting']['creditspolicy'][$policykey]; } if ($act == 'reply') { $allow = $this->check_allow_action($res, 'allowreply'); } else { $allow = $this->check_allow_action($res, 'allowpost'); } if ($allow) { return $allow; } if (!empty($jsonInfo['location'])) { $jsonInfo['location'] = WebUtils::t(rawurldecode($jsonInfo['location'])); } $extract = array('modnewthreads' => $modnewthreads, 'modnewreplies' => $modnewreplies, 'thread' => $thread, 'res' => $res, 'special' => $special, 'subject' => $subject, 'message' => $message, 'jsonInfo' => $jsonInfo, 'sortid' => $sortid, 'typeid' => $typeid); switch ($act) { case 'newthread': $result = $this->sendPost($extract); break; case 'reply': $result = $this->replyPost($extract); break; case 'edit': $result = $this->editPost($extract); break; } if ($result['errcode'] != WebUtils::t('发贴成功')) { return $result; } $res = array_merge($result, $res); return $res; }
protected function getResult($params = array()) { extract($params); $res = WebUtils::initWebApiArray(); $res = array_merge(array('rs' => 1, 'errcode' => ''), $res); $topic = ForumUtils::getTopicInfo($tid); if (empty($topic)) { return $this->_makeErrorInfo($res, 'thread_nonexistence'); } // 该主题是由别的版块移动过来的 if ($topic['closed'] > 1) { $tid = $topic['closed']; $topic['tid'] = $tid; } $app = Yii::app()->getController()->mobcentDiscuzApp; $app->loadForum($topic['fid'], $topic['tid']); // 检查权限 global $_G; if (empty($_G['forum']['allowview'])) { if (!$_G['forum']['viewperm'] && !$_G['group']['readaccess']) { return $this->_makeErrorInfo($res, 'group_nopermission', array('{grouptitle}' => $_G['group']['grouptitle'])); } elseif ($_G['forum']['viewperm'] && !forumperm($_G['forum']['viewperm'])) { $msg = mobcent_showmessagenoperm('viewperm', $_G['fid']); return $this->_makeErrorInfo($res, $msg['message'], $msg['params']); } } elseif ($_G['forum']['allowview'] == -1) { return $this->_makeErrorInfo($res, 'forum_access_view_disallow'); } if ($_G['forum']['formulaperm']) { $msg = mobcent_formulaperm($_G['forum']['formulaperm']); if ($msg['message'] != '') { return $this->_makeErrorInfo($res, $msg['message'], $msg['params']); } } // if($_G['forum']['password'] && $_G['forum']['password'] != $_G['cookie']['fidpw'.$_G['fid']]) { // dheader("Location: $_G[siteurl]forum.php?mod=forumdisplay&fid=$_G[fid]"); // } if ($_G['forum']['password']) { return $this->_makeErrorInfo($res, 'mobcent_forum_passwd'); } if ($_G['forum']['price'] && !$_G['forum']['ismoderator']) { $membercredits = C::t('common_member_forum_buylog')->get_credits($_G['uid'], $_G['fid']); $paycredits = $_G['forum']['price'] - $membercredits; if ($paycredits > 0) { // dheader("Location: $_G[siteurl]forum.php?mod=forumdisplay&fid=$_G[fid]"); } } if ($_G['forum_thread']['readperm'] && $_G['forum_thread']['readperm'] > $_G['group']['readaccess'] && !$_G['forum']['ismoderator'] && $_G['forum_thread']['authorid'] != $_G['uid']) { return $this->_makeErrorInfo($res, 'thread_nopermission', array('{readperm}' => $_G['forum_thread']['readperm'])); } // 编辑权限相关 start if ($_G['forum']['alloweditpost'] && $_G['uid']) { $alloweditpost_status = getstatus($_G['setting']['alloweditpost'], $_G['forum_thread']['special'] + 1); if (!$alloweditpost_status) { $edittimelimit = $_G['group']['edittimelimit'] * 60; } } $editPerm = array(); $editPerm['alloweditpost_status'] = $alloweditpost_status; $editPerm['edittimelimit'] = $edittimelimit; // edit end $params = array('editPerm' => $editPerm); if ($page <= 1 && ($authorId == 0 || $authorId == $topic['authorid'])) { $res['topic'] = $this->_getTopicInfo($topic, $params); if (empty($res['topic'])) { return $this->_makeErrorInfo($res, 'post_not_found'); } } $res = $this->_getPostInfos($res, $topic, $page, $pageSize, $order, $authorId, $params); $res['forumName'] = WebUtils::emptyHtml($_G['forum']['name']); $res['forumTopicUrl'] = Yii::app()->getController()->dzRootUrl . "/forum.php?mod=viewthread&tid=" . $tid; $res['img_url'] = ''; $res['icon_url'] = ''; Mobcent::import(sprintf('%s/forum_viewthread_%s.php', MOBCENT_APP_ROOT . '/components/discuz/forum', MobcentDiscuz::getMobcentDiscuzVersion())); viewthread_updateviews($_G['forum_thread']['threadtableid']); // print_r($res);die; return $res; }
protected function getResult($params = array()) { extract($params); $res = WebUtils::initWebApiArray_oldVersion(); if ($fid != 0) { ForumUtils::initForum($fid); // check permisson global $_G; if (empty($_G['forum']['fid'])) { return $this->_makeErrorInfo($res, 'forum_nonexistence'); } if ($_G['forum']['viewperm'] && !forumperm($_G['forum']['viewperm']) && !$_G['forum']['allowview']) { $msg = mobcent_showmessagenoperm('viewperm', $_G['fid'], $_G['forum']['formulaperm']); return $this->_makeErrorInfo($res, $msg['message'], $msg['params']); } elseif ($_G['forum']['formulaperm']) { $msg = mobcent_formulaperm($_G['forum']['formulaperm']); if ($msg['message'] != '') { return $this->_makeErrorInfo($res, $msg['message'], $msg['params']); } } if ($_G['forum']['password']) { if ($_GET['action'] == 'pwverify') { if ($_GET['pw'] != $_G['forum']['password']) { showmessage('forum_passwd_incorrect', NULL); } else { dsetcookie('fidpw' . $_G['fid'], $_GET['pw']); showmessage('forum_passwd_correct', "forum.php?mod=forumdisplay&fid={$_G['fid']}"); } // } elseif($_G['forum']['password'] != $_G['cookie']['fidpw'.$_G['fid']]) { } else { // include template('forum/forumdisplay_passwd'); // exit(); return $this->_makeErrorInfo($res, 'mobcent_forum_passwd'); } } if ($_G['forum']['price'] && !$_G['forum']['ismoderator']) { $membercredits = C::t('common_member_forum_buylog')->get_credits($_G['uid'], $_G['fid']); $paycredits = $_G['forum']['price'] - $membercredits; if ($paycredits > 0) { // if($_GET['action'] == 'paysubmit') { // updatemembercount($_G['uid'], array($_G['setting']['creditstransextra'][1] => -$paycredits), 1, 'FCP', $_G['fid']); // C::t('common_member_forum_buylog')->update_credits($_G['uid'], $_G['fid'], $_G['forum']['price']); // showmessage('forum_pay_correct', "forum.php?mod=forumdisplay&fid=$_G[fid]"); // } else { if (getuserprofile('extcredits' . $_G['setting']['creditstransextra'][1]) < $paycredits) { return $this->makeErrorInfo($res, lang('message', 'forum_pay_incorrect', array('paycredits' => $paycredits, 'credits' => $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['unit'] . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['title'], 'title' => $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['title']))); } else { return $this->makeErrorInfo($res, 'forum_pay_incorrect_paying', array('{paycredits}' => $paycredits, '{credits}' => $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['unit'] . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['title'], 'title' => $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['title'])); // include template('forum/forumdisplay_pay'); // exit(); } // } } } } $res['newTopicPanel'] = $this->_getNewTopicPanel(); $topicClassfications = $this->_getTopicClassificationInfos($fid); $res['classificationTop_list'] = $topicClassfications['sorts']; $res['classificationType_list'] = $topicClassfications['types']; $res['isOnlyTopicType'] = $topicClassfications['requireTypes'] ? 1 : 0; // 获取公告列表 $hasAnnouncements = $fid != 0 && $page == 1; $res['anno_list'] = !$hasAnnouncements ? array() : $this->_getAnnouncementList($sort); $topicInfos = $this->_getTopicInfos($fid, $page, $pageSize, $sort, $filterType, $filterId, $isImageList, $topOrder); $list = $topicInfos['list']; $topTopicList = $topicInfos['topTopicList']; $count = $topicInfos['count']; $res['forumInfo'] = $this->_getForumInfo($fid); $res['topTopicList'] = $topTopicList; $res['list'] = $list; $res = array_merge($res, WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $count)); return $res; }