Beispiel #1
0
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     loadcache('forums');
     $tids = !empty($parameter['tids']) ? explode(',', $parameter['tids']) : array();
     $fids = isset($parameter['fids']) && !in_array(0, (array) $parameter['fids']) ? $parameter['fids'] : array_keys($_G['cache']['forums']);
     $startrow = !empty($parameter['startrow']) ? intval($parameter['startrow']) : 0;
     $items = !empty($parameter['showitems']) ? intval($parameter['showitems']) : 10;
     $digest = isset($parameter['digest']) ? $parameter['digest'] : 0;
     $stick = isset($parameter['stick']) ? $parameter['stick'] : 0;
     $orderby = isset($parameter['orderby']) ? in_array($parameter['orderby'], array('lastpost', 'dateline', 'replies', 'views', 'heats', 'recommends')) ? $parameter['orderby'] : 'lastpost' : 'lastpost';
     $lastpost = isset($parameter['lastpost']) ? intval($parameter['lastpost']) : 0;
     $recommend = !empty($parameter['recommend']) ? 1 : 0;
     $sortid = isset($parameter['sortids']) ? intval($parameter['sortids']) : '';
     if ($fids) {
         $thefids = array();
         foreach ($fids as $fid) {
             if ($_G['cache']['forums'][$fid]['type'] == 'group') {
                 $thefids[] = $fid;
             }
         }
         if ($thefids) {
             foreach ($_G['cache']['forums'] as $value) {
                 if ($value['fup'] && in_array($value['fup'], $thefids)) {
                     $fids[] = intval($value['fid']);
                 }
             }
         }
         $fids = array_unique($fids);
     }
     $datalist = $list = array();
     $threadtypeids = array();
     $sql = ($tids ? ' AND t.tid IN (' . dimplode($tids) . ')' : '') . ($sortid ? ' AND t.sortid=' . $sortid : '') . ($fids ? ' AND t.fid IN (' . dimplode($fids) . ')' : '') . ($digest ? ' AND t.digest IN (' . dimplode($digest) . ')' : '') . ($stick ? ' AND t.displayorder IN (' . dimplode($stick) . ')' : '') . " AND t.closed='0' AND t.isgroup='0'";
     if ($lastpost) {
         $historytime = TIMESTAMP - $lastpost;
         $sql .= " AND t.dateline>='{$historytime}'";
     }
     if ($orderby == 'heats') {
         $_G['setting']['indexhot']['days'] = !empty($_G['setting']['indexhot']['days']) ? intval($_G['setting']['indexhot']['days']) : 8;
         $heatdateline = TIMESTAMP - 86400 * $_G['setting']['indexhot']['days'];
         $sql .= " AND t.dateline>'{$heatdateline}' AND t.heats>'0'";
     }
     $sqlfrom = "FROM `" . DB::table('forum_thread') . "` t";
     $joinmethod = empty($tids) ? 'INNER' : 'LEFT';
     if ($recommend) {
         $sqlfrom .= " {$joinmethod} JOIN `" . DB::table('forum_forumrecommend') . "` fc ON fc.tid=t.tid";
     }
     require_once libfile('function/threadsort');
     $templatearray = $sortoptionarray = array();
     loadcache(array('threadsort_option_' . $sortid, 'threadsort_template_' . $sortid));
     sortthreadsortselectoption($sortid);
     $templatearray[$sortid] = $_G['cache']['threadsort_template_' . $sortid]['block'];
     $sortoptionarray[$sortid] = $_G['cache']['threadsort_option_' . $sortid];
     $isthreadtype = strpos($templatearray[$sortid], '{typename}') !== false || strpos($templatearray[$sortid], '{typename_url}') !== false ? true : false;
     $threadtypes = array();
     if ($isthreadtype && $fids) {
         foreach (C::t('forum_forumfield')->fetch_all($fids) as $fid => $forum) {
             $threadtypes[$fid] = dunserialize($forum['threadtypes']);
         }
     }
     $html = '';
     $threadlist = $verify = $verifyuids = array();
     $query = DB::query("SELECT t.*\r\n\t\t\t{$sqlfrom} WHERE 1 {$sql}\r\n\t\t\tAND t.readperm='0'\r\n\t\t\tAND t.displayorder>='0'\r\n\t\t\tORDER BY t.{$orderby} DESC\r\n\t\t\tLIMIT {$startrow},{$items};");
     while ($thread = DB::fetch($query)) {
         if (isset($_G['setting']['verify']['enabled']) && $_G['setting']['verify']['enabled']) {
             $verifyuids[$thread['authorid']] = $thread['authorid'];
         }
         if ($thread['highlight']) {
             $color = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282');
             $string = sprintf('%02d', $thread['highlight']);
             $stylestr = sprintf('%03b', $string[0]);
             $thread['highlight'] = ' style="';
             $thread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
             $thread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
             $thread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
             $thread['highlight'] .= $string[1] ? 'color: ' . $color[$string[1]] : '';
             $thread['highlight'] .= '"';
         } else {
             $thread['highlight'] = '';
         }
         $thread['lastposterenc'] = rawurlencode($thread['lastposter']);
         $fid = $thread['fid'];
         if ($thread['typeid'] && $isthreadtype && $threadtypes[$fid] && !empty($threadtypes[$fid]['prefix']) && isset($threadtypes[$fid]['types'][$thread['typeid']])) {
             if ($threadtypes[$fid]['prefix'] == 1) {
                 $thread['typehtml'] = '<em>[<a href="forum.php?mod=forumdisplay&fid=' . $fid . '&amp;filter=typeid&amp;typeid=' . $thread['typeid'] . '">' . $threadtypes[$fid]['types'][$thread['typeid']] . '</a>]</em>';
             } elseif ($threadtypes[$fid]['icons'][$thread['typeid']] && $threadtypes[$fid]['prefix'] == 2) {
                 $thread['typehtml'] = '<em><a title="' . $threadtypes[$fid]['types'][$thread['typeid']] . '" href="forum.php?mod=forumdisplay&fid=' . $fid . '&amp;filter=typeid&amp;typeid=' . $thread['typeid'] . '">' . '<img style="vertical-align: middle;padding-right:4px;" src="' . $threadtypes[$fid]['icons'][$thread['typeid']] . '" alt="' . $threadtypes[$fid]['types'][$thread['typeid']] . '" /></a></em>';
             }
             $thread['typename'] = $threadtypes[$fid]['types'][$thread['typeid']];
         } else {
             $thread['typename'] = $thread['typehtml'] = '';
         }
         $thread['dateline'] = dgmdate($thread['dateline'], 'u', '9999', getglobal('setting/dateformat'));
         $thread['lastpost'] = dgmdate($thread['lastpost'], 'u');
         $threadlist[$thread['tid']] = $thread;
     }
     if (!empty($threadlist)) {
         if ($verifyuids) {
             foreach (C::t('common_member_verify')->fetch_all($verifyuids) as $value) {
                 foreach ($_G['setting']['verify'] as $vid => $vsetting) {
                     if ($vsetting['available'] && $vsetting['showicon'] && $value['verify' . $vid] == 1) {
                         $srcurl = '';
                         if (!empty($vsetting['icon'])) {
                             $srcurl = $vsetting['icon'];
                         }
                         $verify[$value['uid']] .= "<a href=\"home.php?mod=spacecp&ac=profile&op=verify&vid={$vid}\" target=\"_blank\">" . (!empty($srcurl) ? '<img src="' . $srcurl . '" class="vm" alt="' . $vsetting['title'] . '" title="' . $vsetting['title'] . '" />' : $vsetting['title']) . '</a>';
                     }
                 }
             }
         }
         $html = implode('', showsortmodetemplate($sortid, $fids, $sortoptionarray, $templatearray, $threadlist, array_keys($threadlist), $verify));
     }
     return array('html' => $html, 'data' => null);
 }
        $groupfids[] = $row['fid'];
    }
    $forumsinfo = C::t('forum_forum')->fetch_all($groupfids);
    foreach ($groupnames as $gtid => $value) {
        $gfid = $groupnames[$gtid]['fid'];
        $groupnames[$gtid]['name'] = $forumsinfo[$gfid]['name'];
    }
}
$stemplate = null;
if ($_G['forum']['threadsorts']['types'] && $sortoptionarray && $templatearray && $threadids) {
    $sortid = intval($_GET['sortid']);
    if (!strexists($templatearray[$sortid], '{subject_url}') && !strexists($templatearray[$sortid], '{tid}')) {
        $sortlistarray = showsorttemplate($sortid, $_G['fid'], $sortoptionarray, $templatearray, $_G['forum_threadlist'], $threadids);
        $stemplate = $sortlistarray['template'];
    } else {
        $sorttemplate = showsortmodetemplate($sortid, $_G['fid'], $sortoptionarray, $templatearray, $_G['forum_threadlist'], $threadids, $verify);
        $_G['forum']['sortmode'] = 1;
    }
    if (($_GET['searchoption'] || $_GET['searchsort']) && empty($searchsorttids)) {
        $_G['forum_threadlist'] = $multipage = '';
    }
}
$separatepos = $separatepos ? $separatepos + 1 : 0;
$_G['setting']['visitedforums'] = $_G['setting']['visitedforums'] && $_G['forum']['status'] != 3 ? visitedforums() : '';
$_G['group']['allowpost'] = !$_G['forum']['postperm'] && $_G['group']['allowpost'] || $_G['forum']['postperm'] && forumperm($_G['forum']['postperm']) || isset($_G['forum']['allowpost']) && $_G['forum']['allowpost'] == 1 && $_G['group']['allowpost'];
$fastpost = $_G['setting']['fastpost'] && !$_G['forum']['allowspecialonly'] && !$_G['forum']['threadsorts']['required'] && !$_G['forum']['picstyle'];
$allowfastpost = $fastpost && $_G['group']['allowpost'];
$_G['group']['allowpost'] = isset($_G['forum']['allowpost']) && $_G['forum']['allowpost'] == -1 ? false : $_G['group']['allowpost'];
$_G['forum']['allowpostattach'] = isset($_G['forum']['allowpostattach']) ? $_G['forum']['allowpostattach'] : '';
$allowpostattach = $fastpost && ($_G['forum']['allowpostattach'] != -1 && ($_G['forum']['allowpostattach'] == 1 || !$_G['forum']['postattachperm'] && $_G['group']['allowpostattach'] || $_G['forum']['postattachperm'] && forumperm($_G['forum']['postattachperm'])));
if ($fastpost || $livethread) {