Ejemplo n.º 1
0
 private function sendPost($extract)
 {
     global $_G;
     extract($extract);
     // 获取主题和帖子要插入的状态信息
     $topicStatus = ForumUtils::getPostSendStatus('topic', $_GET['platType']);
     $postStatus = ForumUtils::getPostSendStatus('post', $_GET['platType']);
     //copy from dz source/include/post/post_newthread.php
     if (empty($_G['forum']['fid']) || $_G['forum']['type'] == 'group') {
         return WebUtils::makeErrorInfo_oldVersion($res, 'forum_nonexistence');
     }
     if ($special == 1 && !$_G['group']['allowpostpoll'] || $special == 2 && !$_G['group']['allowposttrade'] || $special == 3 && !$_G['group']['allowpostreward'] || $special == 4 && !$_G['group']['allowpostactivity'] || $special == 5 && !$_G['group']['allowpostdebate']) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'group_nopermission', array('{grouptitle}' => $_G['group']['grouptitle']));
     }
     if (!$_G['uid'] && !(!$_G['forum']['postperm'] && $_G['group']['allowpost'] || $_G['forum']['postperm'] && forumperm($_G['forum']['postperm']))) {
         if (!defined('IN_MOBILE')) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'postperm_login_nopermission', array('{login}' => 1));
         } else {
             return WebUtils::makeErrorInfo_oldVersion($res, 'postperm_login_nopermission_mobile', array('{login}' => 1));
         }
     } elseif (empty($_G['forum']['allowpost'])) {
         if (!$_G['forum']['postperm'] && !$_G['group']['allowpost']) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'postperm_none_nopermission');
         } elseif ($_G['forum']['postperm'] && !forumperm($_G['forum']['postperm'])) {
             $msg = mobcent_showmessagenoperm('postperm', $_G['fid'], $_G['forum']['formulaperm']);
             return WebUtils::makeErrorInfo_oldVersion($res, $msg['message'], $msg['params']);
         }
     } elseif ($_G['forum']['allowpost'] == -1) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_forum_newthread_nopermission');
     }
     if (!$_G['uid'] && ($_G['setting']['need_avatar'] || $_G['setting']['need_email'] || $_G['setting']['need_friendnum'])) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'postperm_login_nopermission');
     }
     if (trim($subject) == '') {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_sm_isnull');
     }
     if (!$sortid && !$special && trim($message) == '') {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_sm_isnull');
     }
     if ($post_invalid = checkpost($subject, $message, $special || $sortid)) {
         return WebUtils::makeErrorInfo_oldVersion($res, $post_invalid, array('{minpostsize}' => $_G['setting']['minpostsize'], '{maxpostsize}' => $_G['setting']['maxpostsize']));
         //showmessage($post_invalid, '', array('minpostsize' => $_G['setting']['minpostsize'], 'maxpostsize' => $_G['setting']['maxpostsize']));
     }
     if (checkflood()) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_flood_ctrl', array('{floodctrl}' => $_G['setting']['floodctrl']));
     } elseif (checkmaxperhour('tid')) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'thread_flood_ctrl_threads_per_hour', array('{threads_per_hour}' => $_G['group']['maxthreadsperhour']));
     }
     $_GET['save'] = $_G['uid'] ? $_GET['save'] : 0;
     if ($_G['group']['allowsetpublishdate'] && $_GET['cronpublish'] && $_GET['cronpublishdate']) {
         $publishdate = strtotime($_GET['cronpublishdate']);
         if ($publishdate > $_G['timestamp']) {
             $_GET['save'] = 1;
         } else {
             $publishdate = $_G['timestamp'];
         }
     } else {
         $publishdate = $_G['timestamp'];
     }
     $typeid = isset($typeid) && isset($_G['forum']['threadtypes']['types'][$typeid]) && (empty($_G['forum']['threadtypes']['moderators'][$typeid]) || $_G['forum']['ismoderator']) ? $typeid : 0;
     $displayorder = $modnewthreads ? -2 : ($_G['forum']['ismoderator'] && $_G['group']['allowstickthread'] && !empty($_GET['sticktopic']) ? 1 : (empty($_GET['save']) ? 0 : -4));
     if ($displayorder == -2) {
         C::t('forum_forum')->update($_G['fid'], array('modworks' => '1'));
     } elseif ($displayorder == -4) {
         $_GET['addfeed'] = 0;
     }
     $digest = $_G['forum']['ismoderator'] && $_G['group']['allowdigestthread'] && !empty($_GET['addtodigest']) ? 1 : 0;
     $readperm = $_G['group']['allowsetreadperm'] ? $readperm : 0;
     $isanonymous = $_G['group']['allowanonymous'] && $_GET['isanonymous'] ? 1 : 0;
     $price = intval($price);
     $price = $_G['group']['maxprice'] && !$special ? $price <= $_G['group']['maxprice'] ? $price : $_G['group']['maxprice'] : 0;
     //强制主题类别判断
     if (!$typeid && $_G['forum']['threadtypes']['required'] && !$special) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_type_isnull');
     }
     //强制主题分类判断
     if (!$sortid && $_G['forum']['threadsorts']['required'] && !$special) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_sort_isnull');
     }
     //主题售价 客户端暂不支持
     if ($price > 0 && floor($price * (1 - $_G['setting']['creditstax'])) == 0) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
         showmessage('post_net_price_iszero');
     }
     //投票贴相关
     if ($special == 1) {
         $polloption = $_GET['tpolloption'] == 2 ? explode("\n", $_GET['polloptions']) : $_GET['polloption'];
         $pollarray = array();
         foreach ($polloption as $key => $value) {
             $polloption[$key] = censor($polloption[$key]);
             if (trim($value) === '') {
                 unset($polloption[$key]);
             }
         }
         if (count($polloption) > $_G['setting']['maxpolloptions']) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('post_poll_option_toomany', '', array('maxpolloptions' => $_G['setting']['maxpolloptions']));
         } elseif (count($polloption) < 2) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('post_poll_inputmore');
         }
         $curpolloption = count($polloption);
         $pollarray['maxchoices'] = empty($_GET['maxchoices']) ? 0 : ($_GET['maxchoices'] > $curpolloption ? $curpolloption : $_GET['maxchoices']);
         $pollarray['multiple'] = empty($_GET['maxchoices']) || $_GET['maxchoices'] == 1 ? 0 : 1;
         $pollarray['options'] = $polloption;
         $pollarray['visible'] = empty($_GET['visibilitypoll']);
         $pollarray['overt'] = !empty($_GET['overt']);
         if (preg_match("/^\\d*\$/", trim($_GET['expiration']))) {
             if (empty($_GET['expiration'])) {
                 $pollarray['expiration'] = 0;
             } else {
                 $pollarray['expiration'] = TIMESTAMP + 86400 * $_GET['expiration'];
             }
         } else {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('poll_maxchoices_expiration_invalid');
         }
     }
     // 分类信息有效期
     $_GET['typeexpiration'] = $_GET['typeoption']['typeexpiration'];
     $sortid = $special && $_G['forum']['threadsorts']['types'][$sortid] ? 0 : $sortid;
     $typeexpiration = intval($_GET['typeexpiration']);
     if ($_G['forum']['threadsorts']['expiration'][$typeid] && !$typeexpiration) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'threadtype_expiration_invalid');
     }
     $_G['forum_optiondata'] = array();
     if ($_G['forum']['threadsorts']['types'][$sortid] && !$_G['forum']['allowspecialonly']) {
         Mobcent::import(MOBCENT_APP_ROOT . '/components/discuz/source/function/function_threadsort.php');
         $_G['forum_optiondata'] = mobcent_threadsort_validator($_GET['typeoption'], $pid);
         if ($_G['forum_optiondata']['message'] != '') {
             return WebUtils::makeErrorInfo_oldVersion($res, $_G['forum_optiondata']['message'], $_G['forum_optiondata']['params']);
         }
     }
     $author = !$isanonymous ? $_G['username'] : '';
     $moderated = $digest || $displayorder > 0 ? 1 : 0;
     $thread['status'] = 0;
     $_GET['ordertype'] && ($thread['status'] = setstatus(4, 1, $thread['status']));
     $_GET['hiddenreplies'] && ($thread['status'] = setstatus(2, 1, $thread['status']));
     /*             if($_G['group']['allowpostrushreply'] && $_GET['rushreply']) {
              $_GET['rushreplyfrom'] = strtotime($_GET['rushreplyfrom']);
             $_GET['rushreplyto'] = strtotime($_GET['rushreplyto']);
             $_GET['rewardfloor'] = trim($_GET['rewardfloor']);
             $_GET['stopfloor'] = intval($_GET['stopfloor']);
             $_GET['creditlimit'] = $_GET['creditlimit'] == '' ? '-996' : intval($_GET['creditlimit']);
             if($_GET['rushreplyfrom'] > $_GET['rushreplyto'] && !empty($_GET['rushreplyto'])) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('post_rushreply_timewrong');
             }
             if(($_GET['rushreplyfrom'] > $_G['timestamp']) || (!empty($_GET['rushreplyto']) && $_GET['rushreplyto'] < $_G['timestamp']) || ($_GET['stopfloor'] == 1) ) {
             $closed = true;
             }
             if(!empty($_GET['rewardfloor']) && !empty($_GET['stopfloor'])) {
             $floors = explode(',', $_GET['rewardfloor']);
             if(!empty($floors) && is_array($floors)) {
             foreach($floors AS $key => $floor) {
             if(strpos($floor, '*') === false) {
             if(intval($floor) == 0) {
             unset($floors[$key]);
             } elseif($floor > $_GET['stopfloor']) {
             unset($floors[$key]);
             }
             }
             }
             $_GET['rewardfloor'] = implode(',', $floors);
             }
             }
             $thread['status'] = setstatus(3, 1, $thread['status']);
             $thread['status'] = setstatus(1, 1, $thread['status']);
             } */
     $_GET['allownoticeauthor'] && ($thread['status'] = setstatus(6, 1, $thread['status']));
     $isgroup = $_G['forum']['status'] == 3 ? 1 : 0;
     /*  if($_G['group']['allowreplycredit']) {
              $_GET['replycredit_extcredits'] = intval($_GET['replycredit_extcredits']);
             $_GET['replycredit_times'] = intval($_GET['replycredit_times']);
             $_GET['replycredit_membertimes'] = intval($_GET['replycredit_membertimes']);
             $_GET['replycredit_random'] = intval($_GET['replycredit_random']);
     
             $_GET['replycredit_random'] = $_GET['replycredit_random'] < 0 || $_GET['replycredit_random'] > 99 ? 0 : $_GET['replycredit_random'] ;
             $replycredit = $replycredit_real = 0;
             if($_GET['replycredit_extcredits'] > 0 && $_GET['replycredit_times'] > 0) {
             $replycredit_real = ceil(($_GET['replycredit_extcredits'] * $_GET['replycredit_times']) + ($_GET['replycredit_extcredits'] * $_GET['replycredit_times'] *  $_G['setting']['creditstax']));
             if($replycredit_real > getuserprofile('extcredits'.$_G['setting']['creditstransextra'][10])) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd');
             showmessage('replycredit_morethan_self');
             } else {
             $replycredit = ceil($_GET['replycredit_extcredits'] * $_GET['replycredit_times']);
             }
             }
             } */
     $newthread = array('fid' => $_G['fid'], 'posttableid' => 0, 'readperm' => $readperm, 'price' => $price, 'typeid' => $typeid, 'sortid' => $sortid, 'author' => $author, 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => $publishdate, 'lastpost' => $publishdate, 'lastposter' => $author, 'displayorder' => $displayorder, 'digest' => $digest, 'special' => $special, 'attachment' => 0, 'moderated' => $moderated, 'status' => $thread['status'] | $topicStatus, 'isgroup' => $isgroup, 'replycredit' => $replycredit, 'closed' => $closed ? 1 : 0);
     $tid = C::t('forum_thread')->insert($newthread, true);
     useractionlog($_G['uid'], 'tid');
     if (!getuserprofile('threads') && $_G['setting']['newbie']) {
         C::t('forum_thread')->update($tid, array('icon' => $_G['setting']['newbie']));
     }
     if ($publishdate != $_G['timestamp']) {
         loadcache('cronpublish');
         $cron_publish_ids = dunserialize($_G['cache']['cronpublish']);
         $cron_publish_ids[$tid] = $tid;
         $cron_publish_ids = serialize($cron_publish_ids);
         savecache('cronpublish', $cron_publish_ids);
     }
     if (!$isanonymous) {
         C::t('common_member_field_home')->update($_G['uid'], array('recentnote' => $subject));
     }
     if ($special == 3 && $_G['group']['allowpostreward']) {
         updatemembercount($_G['uid'], array($_G['setting']['creditstransextra'][2] => -$realprice), 1, 'RTC', $tid);
     }
     if ($moderated) {
         updatemodlog($tid, $displayorder > 0 ? 'STK' : 'DIG');
         updatemodworks($displayorder > 0 ? 'STK' : 'DIG', 1);
     }
     /* if($special == 1) {
     
             foreach($pollarray['options'] as $polloptvalue) {
             $polloptvalue = dhtmlspecialchars(trim($polloptvalue));
             C::t('forum_polloption')->insert(array('tid' => $tid, 'polloption' => $polloptvalue));
             }
             $polloptionpreview = '';
             $query = C::t('forum_polloption')->fetch_all_by_tid($tid, 1, 2);
             foreach($query as $option) {
             $polloptvalue = preg_replace("/\[url=(https?){1}:\/\/([^\[\"']+?)\](.+?)\[\/url\]/i", "<a href=\"\\1://\\2\" target=\"_blank\">\\3</a>", $option['polloption']);
             $polloptionpreview .= $polloptvalue."\t";
             }
     
             $polloptionpreview = daddslashes($polloptionpreview);
     
             $data = array('tid' => $tid, 'multiple' => $pollarray['multiple'], 'visible' => $pollarray['visible'], 'maxchoices' => $pollarray['maxchoices'], 'expiration' => $pollarray['expiration'], 'overt' => $pollarray['overt'], 'pollpreview' => $polloptionpreview);
             C::t('forum_poll')->insert($data);
             } */
     if ($_G['forum']['threadsorts']['types'][$sortid] && !empty($_G['forum_optiondata']) && is_array($_G['forum_optiondata'])) {
         $filedname = $valuelist = $separator = '';
         foreach ($_G['forum_optiondata'] as $optionid => $value) {
             if ($value) {
                 $filedname .= $separator . $_G['forum_optionlist'][$optionid]['identifier'];
                 $valuelist .= $separator . "'" . daddslashes($value) . "'";
                 $separator = ' ,';
             }
             if ($_G['forum_optionlist'][$optionid]['type'] == 'image') {
                 $identifier = $_G['forum_optionlist'][$optionid]['identifier'];
                 $sortaids[] = intval($_GET['typeoption'][$identifier]['aid']);
             }
             C::t('forum_typeoptionvar')->insert(array('sortid' => $sortid, 'tid' => $tid, 'fid' => $_G['fid'], 'optionid' => $optionid, 'value' => censor($value), 'expiration' => $typeexpiration ? $publishdate + $typeexpiration : 0));
         }
         if ($filedname && $valuelist) {
             C::t('forum_optionvalue')->insert($sortid, "({$filedname}, tid, fid) VALUES ({$valuelist}, '{$tid}', '{$_G['fid']}')");
         }
     }
     if ($_G['group']['allowat']) {
         $atlist = $atlist_tmp = array();
         preg_match_all("/@([^\r\n]*?)\\s/i", $message . ' ', $atlist_tmp);
         $atlist_tmp = array_slice(array_unique($atlist_tmp[1]), 0, $_G['group']['allowat']);
         if (!empty($atlist_tmp)) {
             if (empty($_G['setting']['at_anyone'])) {
                 foreach (C::t('home_follow')->fetch_all_by_uid_fusername($_G['uid'], $atlist_tmp) as $row) {
                     $atlist[$row['followuid']] = $row['fusername'];
                 }
                 if (count($atlist) < $_G['group']['allowat']) {
                     $query = C::t('home_friend')->fetch_all_by_uid_username($_G['uid'], $atlist_tmp);
                     foreach ($query as $row) {
                         $atlist[$row['fuid']] = $row['fusername'];
                     }
                 }
             } else {
                 foreach (C::t('common_member')->fetch_all_by_username($atlist_tmp) as $row) {
                     $atlist[$row['uid']] = $row['username'];
                 }
             }
         }
         if ($atlist) {
             foreach ($atlist as $atuid => $atusername) {
                 $atsearch[] = "/@" . str_replace('/', '\\/', preg_quote($atusername)) . " /i";
                 $atreplace[] = "[url=home.php?mod=space&uid={$atuid}]@{$atusername}[/url] ";
             }
             $message = preg_replace($atsearch, $atreplace, $message . ' ', 1);
         }
     }
     $bbcodeoff = checkbbcodes($message, !empty($_GET['bbcodeoff']));
     $smileyoff = checksmilies($message, !empty($_GET['smileyoff']));
     $parseurloff = !empty($_GET['parseurloff']);
     $htmlon = $_G['group']['allowhtml'] && !empty($_GET['htmlon']) ? 1 : 0;
     $usesig = !empty($_GET['usesig']) && $_G['group']['maxsigsize'] ? 1 : 0;
     $class_tag = new tag();
     $tagstr = $class_tag->add_tag($_GET['tags'], $tid, 'tid');
     /* if($_G['group']['allowreplycredit']) {
         if($replycredit > 0 && $replycredit_real > 0) {
        updatemembercount($_G['uid'], array('extcredits'.$_G['setting']['creditstransextra'][10] => -$replycredit_real), 1, 'RCT', $tid);
        $insertdata = array(
                'tid' => $tid,
                'extcredits' => $_GET['replycredit_extcredits'],
                'extcreditstype' => $_G['setting']['creditstransextra'][10],
                'times' => $_GET['replycredit_times'],
                'membertimes' => $_GET['replycredit_membertimes'],
                'random' => $_GET['replycredit_random']
        );
        C::t('forum_replycredit')->insert($insertdata);
        }
        } */
     if ($_G['group']['allowpostrushreply'] && $_GET['rushreply']) {
         $rushdata = array('tid' => $tid, 'stopfloor' => $_GET['stopfloor'], 'starttimefrom' => $_GET['rushreplyfrom'], 'starttimeto' => $_GET['rushreplyto'], 'rewardfloor' => $_GET['rewardfloor'], 'creditlimit' => $_GET['creditlimit']);
         C::t('forum_threadrush')->insert($rushdata);
     }
     $pinvisible = $modnewthreads ? -2 : (empty($_GET['save']) ? 0 : -3);
     $message = preg_replace('/\\[attachimg\\](\\d+)\\[\\/attachimg\\]/is', '[attach]\\1[/attach]', $message);
     $pid = insertpost(array('fid' => $_G['fid'], 'tid' => $tid, 'first' => '1', 'author' => $_G['username'], 'authorid' => $_G['uid'], 'subject' => $subject, 'dateline' => $publishdate, 'message' => $message, 'useip' => $_G['clientip'], 'invisible' => $pinvisible, 'anonymous' => $isanonymous, 'usesig' => $usesig, 'htmlon' => $htmlon, 'bbcodeoff' => $bbcodeoff, 'smileyoff' => $smileyoff, 'parseurloff' => $parseurloff, 'attachment' => '0', 'tags' => $tagstr, 'replycredit' => 0, 'status' => (defined('IN_MOBILE') ? 8 : 0) | $postStatus));
     if ($_G['group']['allowat'] && $atlist) {
         foreach ($atlist as $atuid => $atusername) {
             notification_add($atuid, 'at', 'at_message', array('from_id' => $tid, 'from_idtype' => 'at', 'buyerid' => $_G['uid'], 'buyer' => $_G['username'], 'tid' => $tid, 'subject' => $subject, 'pid' => $pid, 'message' => messagecutstr($message, 150)));
         }
         set_atlist_cookie(array_keys($atlist));
     }
     $threadimageaid = 0;
     $threadimage = array();
     if ($special == 4 && $_GET['activityaid']) {
         $threadimageaid = $_GET['activityaid'];
         convertunusedattach($_GET['activityaid'], $tid, $pid);
     }
     if ($_G['forum']['threadsorts']['types'][$sortid] && !empty($_G['forum_optiondata']) && is_array($_G['forum_optiondata']) && $sortaids) {
         foreach ($sortaids as $sortaid) {
             convertunusedattach($sortaid, $tid, $pid);
         }
     }
     if (($_G['group']['allowpostattach'] || $_G['group']['allowpostimage']) && ($_GET['attachnew'] || $sortid || !empty($_GET['activityaid']))) {
         updateattach($displayorder == -4 || $modnewthreads, $tid, $pid, $_GET['attachnew']);
         if (!$threadimageaid) {
             $threadimage = C::t('forum_attachment_n')->fetch_max_image('tid:' . $tid, 'tid', $tid);
             $threadimageaid = $threadimage['aid'];
         }
     }
     $values = array('fid' => $_G['fid'], 'tid' => $tid, 'pid' => $pid, 'coverimg' => '', 'sechash' => !empty($_GET['sechash']) ? $_GET['sechash'] : '');
     $param = array();
     Mobcent::import(MOBCENT_APP_ROOT . '/components/discuz/source/function/function_post.php');
     if ($_G['forum']['picstyle']) {
         if (!mobcent_setthreadcover($pid, 0, $threadimageaid)) {
             preg_match_all("/(\\[img\\]|\\[img=\\d{1,4}[x|\\,]\\d{1,4}\\])\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/is", $message, $imglist, PREG_SET_ORDER);
             $values['coverimg'] = "<p id=\"showsetcover\">" . lang('message', 'post_newthread_set_cover') . "<span id=\"setcoverwait\"></span></p><script>if(\$('forward_a')){\$('forward_a').style.display='none';setTimeout(\"\$('forward_a').style.display=''\", 5000);};ajaxget('forum.php?mod=ajax&action=setthreadcover&tid={$tid}&pid={$pid}&fid={$_G['fid']}&imgurl={$imglist[0][2]}&newthread=1', 'showsetcover', 'setcoverwait')</script>";
             $param['clean_msgforward'] = 1;
             $param['timeout'] = $param['refreshtime'] = 15;
         }
     }
     if ($threadimageaid) {
         if (!$threadimage) {
             $threadimage = C::t('forum_attachment_n')->fetch('tid:' . $tid, $threadimageaid);
         }
         $threadimage = daddslashes($threadimage);
         C::t('forum_threadimage')->insert(array('tid' => $tid, 'attachment' => $threadimage['attachment'], 'remote' => $threadimage['remote']));
     }
     $statarr = array(0 => 'thread', 1 => 'poll', 2 => 'trade', 3 => 'reward', 4 => 'activity', 5 => 'debate', 127 => 'thread');
     include_once libfile('function/stat');
     updatestat($isgroup ? 'groupthread' : $statarr[$special]);
     if ($modnewthreads) {
         updatemoderate('tid', $tid);
         C::t('forum_forum')->update_forum_counter($_G['fid'], 0, 0, 1);
         manage_addnotify('verifythread');
         return WebUtils::makeErrorInfo_oldVersion($res, 'post_newthread_mod_succeed', array('noError' => 1));
         //showmessage('post_newthread_mod_succeed', $returnurl, $values, $param);
     } else {
         if ($displayorder >= 0 && helper_access::check_module('follow') && !empty($_GET['adddynamic']) && !$isanonymous) {
             require_once libfile('function/discuzcode');
             require_once libfile('function/followcode');
             $feedcontent = array('tid' => $tid, 'content' => followcode($message, $tid, $pid, 1000));
             C::t('forum_threadpreview')->insert($feedcontent);
             C::t('forum_thread')->update_status_by_tid($tid, '512');
             $followfeed = array('uid' => $_G['uid'], 'username' => $_G['username'], 'tid' => $tid, 'note' => '', 'dateline' => TIMESTAMP);
             $values['feedid'] = C::t('home_follow_feed')->insert($followfeed, true);
             C::t('common_member_count')->increase($_G['uid'], array('feeds' => 1));
         }
         $feed = array('icon' => '', 'title_template' => '', 'title_data' => array(), 'body_template' => '', 'body_data' => array(), 'title_data' => array(), 'images' => array());
         if ($displayorder != -4) {
             if ($digest) {
                 updatepostcredits('+', $_G['uid'], 'digest', $_G['fid']);
             }
             //updatepostcredits('+',  $_G['uid'], 'post', $_G['fid']);
             Mobcent::import(MOBCENT_APP_ROOT . '/components/discuz/source/function/function_post.php');
             //Yii::import('application.components.discuz.source.function.function_post', true);
             mobcent_updatepostcredits('+', $_G['uid'], 'post', $_G['fid']);
             if ($isgroup) {
                 C::t('forum_groupuser')->update_counter_for_user($_G['uid'], $_G['fid'], 1);
             }
             $subject = str_replace("\t", ' ', $subject);
             $lastpost = "{$tid}\t" . $subject . "\t{$_G['timestamp']}\t{$author}";
             C::t('forum_forum')->update($_G['fid'], array('lastpost' => $lastpost));
             C::t('forum_forum')->update_forum_counter($_G['fid'], 1, 1, 1);
             if ($_G['forum']['type'] == 'sub') {
                 C::t('forum_forum')->update($_G['forum']['fup'], array('lastpost' => $lastpost));
             }
         }
         if ($_G['forum']['status'] == 3) {
             C::t('forum_forumfield')->update($_G['fid'], array('lastupdate' => TIMESTAMP));
             require_once libfile('function/grouplog');
             updategroupcreditlog($_G['fid'], $_G['uid']);
         }
         /*如果显示地理位置,入库到表里*/
         if ($jsonInfo['isShowPostion']) {
             $data = DB::query('INSERT INTO  %t VALUES(null,%f,%f,%d,%d,%s)', array('home_surrounding_user', $jsonInfo['longitude'], $jsonInfo['latitude'], $tid, 3, (string) $jsonInfo['location']));
         }
         /*  //客户端发表主题积分入库
                $temp = DB::fetch_first('SELECT extcredits3  FROM '.DB::table('common_credit_rule').' WHERE rid =%d ',array(1));
                $extcredits3 = DB::fetch_first('SELECT extcredits3 FROM '.DB::table('common_member_count').' WHERE uid = %d',array($_G['uid']));
                $temp = $extcredits3['extcredits3'] + $temp['extcredits3'];
                DB::query('UPDATE '.DB::table('common_member_count').' set extcredits3 = %d WHERE uid = %d',array($temp,$_G['uid']));
             */
         //showmessage('post_newthread_succeed', $returnurl, $values, $param);
         // return array('rs'=>1,'errcode'=>WebUtils::t('发贴成功'));
         return $this->makeErrorInfo($res, 'mobcent_post_newthread_success', array('noError' => 1));
     }
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 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;
 }