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;
 }
function viewthread_loadcache()
{
    global $_G;
    $_G['forum']['livedays'] = ceil((TIMESTAMP - $_G['forum']['dateline']) / 86400);
    $_G['forum']['lastpostdays'] = ceil((TIMESTAMP - $_G['forum']['lastthreadpost']) / 86400);
    $threadcachemark = 100 - ($_G['forum']['displayorder'] * 15 + $_G['thread']['digest'] * 10 + min($_G['thread']['views'] / max($_G['forum']['livedays'], 10) * 2, 50) + max(-10, 15 - $_G['forum']['lastpostdays']) + min($_G['thread']['replies'] / $_G['setting']['postperpage'] * 1.5, 15));
    if ($threadcachemark < $_G['forum']['threadcaches']) {
        $threadcache = getcacheinfo($_G['tid']);
        if (TIMESTAMP - $threadcache['filemtime'] > $_G['setting']['cachethreadlife']) {
            @unlink($threadcache['filename']);
            define('CACHE_FILE', $threadcache['filename']);
        } else {
            readfile($threadcache['filename']);
            viewthread_updateviews($_G['forum_thread']['threadtableid']);
            $_G['setting']['debug'] && debuginfo();
            $_G['setting']['debug'] ? die('<script type="text/javascript">document.getElementById("debuginfo").innerHTML = " ' . ($_G['setting']['debug'] ? 'Updated at ' . gmdate("H:i:s", $threadcache['filemtime'] + 3600 * 8) . ', Processed in ' . $debuginfo['time'] . ' second(s), ' . $debuginfo['queries'] . ' Queries' . ($_G['gzipcompress'] ? ', Gzip enabled' : '') : '') . '";</script>') : die;
        }
    }
}
Example #3
0
function viewthread_loadcache()
{
    global $tid, $forum, $timestamp, $cachethreadlife, $_DCACHE, $gzipcompress, $debug, $styleid;
    $forum['livedays'] = ceil(($timestamp - $forum['dateline']) / 86400);
    $forum['lastpostdays'] = ceil(($timestamp - $forum['lastthreadpost']) / 86400);
    $threadcachemark = 100 - ($forum['displayorder'] * 15 + $forum['digest'] * 10 + min($forum['views'] / max($forum['livedays'], 10) * 2, 50) + max(-10, 15 - $forum['lastpostdays']) + min($forum['replies'] / $_DCACHE['settings']['postperpage'] * 1.5, 15));
    if ($threadcachemark < $forum['threadcaches']) {
        $threadcache = getcacheinfo($tid);
        if ($timestamp - $threadcache['filemtime'] > $cachethreadlife) {
            @unlink($threadcache['filename']);
            define('CACHE_FILE', $threadcache['filename']);
            $styleid = $_DCACHE['settings']['styleid'];
            @(include DISCUZ_ROOT . './forumdata/cache/style_' . $styleid . '.php');
        } else {
            readfile($threadcache['filename']);
            viewthread_updateviews();
            $debug && debuginfo();
            $debug ? die('<script type="text/javascript">document.getElementById("debuginfo").innerHTML = " ' . ($debug ? 'Updated at ' . gmdate("H:i:s", $threadcache['filemtime'] + 3600 * 8) . ', Processed in ' . $debuginfo['time'] . ' second(s), ' . $debuginfo['queries'] . ' Queries' . ($gzipcompress ? ', Gzip enabled' : '') : '') . '";</script>') : die;
        }
    }
}