Пример #1
0
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     loadcache('grouptype');
     $typeids = !empty($parameter['gtids']) && !in_array('0', $parameter['gtids']) ? $parameter['gtids'] : array_keys($_G['cache']['grouptype']['first']);
     $tids = !empty($parameter['tids']) ? explode(',', $parameter['tids']) : array();
     $fids = !empty($parameter['fids']) ? explode(',', $parameter['fids']) : array();
     $startrow = isset($parameter['startrow']) ? intval($parameter['startrow']) : 0;
     $items = isset($parameter['items']) ? intval($parameter['items']) : 10;
     $special = isset($parameter['special']) ? $parameter['special'] : array();
     $rewardstatus = isset($parameter['rewardstatus']) ? intval($parameter['rewardstatus']) : 0;
     $titlelength = !empty($parameter['titlelength']) ? intval($parameter['titlelength']) : 40;
     $summarylength = !empty($parameter['summarylength']) ? intval($parameter['summarylength']) : 80;
     $orderby = in_array($parameter['orderby'], array('dateline', 'replies', 'views', 'threads', 'heats', 'recommends', 'hourviews', 'todayviews', 'weekviews', 'monthviews')) ? $parameter['orderby'] : 'lastpost';
     $picrequired = !empty($parameter['picrequired']) ? 1 : 0;
     $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
     if (empty($fids)) {
         $plusids = $typeids ? array(0) : array();
         foreach ($typeids as $typeid) {
             if (!empty($_G['cache']['grouptype']['first'][$typeid]['secondlist'])) {
                 $plusids = array_merge($plusids, $_G['cache']['grouptype']['first'][$typeid]['secondlist']);
             }
         }
         $typeids = array_merge($typeids, $plusids);
         $groups = array();
         if ($typeids) {
             $query = DB::query('SELECT f.fid, f.name, ff.description FROM ' . DB::table('forum_forum') . " f LEFT JOIN " . DB::table('forum_forumfield') . " ff ON f.fid = ff.fid WHERE f.fup IN (" . dimplode($typeids) . ")");
             while ($value = DB::fetch($query)) {
                 $groups[$value['fid']] = $value;
                 $fids[] = intval($value['fid']);
             }
         }
     }
     require_once libfile('function/post');
     $datalist = $list = array();
     $threadtypeids = array();
     $sql = ($fids ? ' AND t.fid IN (' . dimplode($fids) . ')' : '') . ($tids ? ' AND t.tid IN (' . dimplode($tids) . ')' : '') . ($bannedids ? ' AND t.tid NOT IN (' . dimplode($bannedids) . ')' : '') . ($special ? ' AND t.special IN (' . dimplode($special) . ')' : '') . (in_array(3, $special) && $rewardstatus ? $rewardstatus == 1 ? ' AND t.price < 0' : ' AND t.price > 0' : '') . ($picrequired ? ' AND t.attachment = 2' : '') . " AND t.isgroup='1'";
     if (in_array($orderby, array('hourviews', 'todayviews', 'weekviews', 'monthviews'))) {
         $historytime = 0;
         switch ($orderby) {
             case 'hourviews':
                 $historytime = TIMESTAMP - 3600;
                 break;
             case 'todayviews':
                 $historytime = mktime(0, 0, 0, date('m', TIMESTAMP), date('d', TIMESTAMP), date('Y', TIMESTAMP));
                 break;
             case 'weekviews':
                 $week = gmdate('w', TIMESTAMP) - 1;
                 $week = $week != -1 ? $week : 6;
                 $historytime = mktime(0, 0, 0, date('m', TIMESTAMP), date('d', TIMESTAMP) - $week, date('Y', TIMESTAMP));
                 break;
             case 'monthviews':
                 $historytime = mktime(0, 0, 0, date('m', TIMESTAMP), 1, date('Y', TIMESTAMP));
                 break;
         }
         $sql .= ' AND t.dateline>=' . $historytime;
         $orderby = 'views';
     } elseif ($orderby == 'heats') {
         $heatdateline = TIMESTAMP - 86400 * $_G['setting']['indexhot']['days'];
         $sql .= " AND t.dateline>'{$heatdateline}' AND t.heats>'0'";
     }
     $sqlfrom = "FROM `" . DB::table('forum_thread') . "` t";
     $query = DB::query("SELECT t.*\n\t\t\t{$sqlfrom} WHERE t.readperm='0'\n\t\t\t{$sql}\n\t\t\tAND t.displayorder>='0'\n\t\t\tORDER BY t.{$orderby} DESC\n\t\t\tLIMIT {$startrow},{$items};");
     include_once libfile('block/thread', 'class');
     $bt = new block_thread();
     while ($data = DB::fetch($query)) {
         $_G['thread'][$data['tid']] = $data;
         if ($style['getpic'] && $data['attachment'] == '2') {
             $pic = $bt->getpic($data['tid']);
             $data['attachment'] = $pic['attachment'];
             $data['remote'] = $pic['remote'];
         }
         $list[] = array('id' => $data['tid'], 'idtype' => 'tid', 'title' => cutstr(str_replace('\\\'', '&#39;', $data['subject']), $titlelength), 'url' => 'forum.php?mod=viewthread&tid=' . $data['tid'], 'pic' => $data['attachment'] ? 'forum/' . $data['attachment'] : STATICURL . 'image/common/nophoto.gif', 'picflag' => $data['attachment'] ? $data['remote'] ? '2' : '1' : '0', 'summary' => $style['getsummary'] ? $bt->getthread($data['tid'], $summarylength) : '', 'fields' => array('icon' => 'forum/' . $data['icon'], 'author' => $data['author'] ? $data['author'] : 'Anonymous', 'authorid' => $data['author'] ? $data['authorid'] : 0, 'avatar' => avatar($data['authorid'], 'small', true), 'avatar_big' => avatar($data['authorid'], 'middle', true), 'dateline' => $data['dateline'], 'lastpost' => $data['lastpost'], 'posts' => $data['posts'], 'todayposts' => $data['todayposts'], 'replies' => $data['replies'], 'views' => $data['views'], 'heats' => $data['heats'], 'recommends' => $data['recommends'], 'groupname' => $groups[$data['fid']]['name'], 'groupurl' => 'forum.php?mod=group&fid=' . $data['fid']));
     }
     return array('html' => '', 'data' => $list);
 }
Пример #2
0
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     loadcache('grouptype');
     $typeids = array();
     if (!empty($parameter['gtids'])) {
         if ($parameter['gtids'][0] == '0') {
             unset($parameter['gtids'][0]);
         }
         $typeids = $parameter['gtids'];
     }
     $tids = !empty($parameter['tids']) ? explode(',', $parameter['tids']) : array();
     $fids = !empty($parameter['fids']) ? explode(',', $parameter['fids']) : array();
     $uids = !empty($parameter['uids']) ? explode(',', $parameter['uids']) : array();
     $startrow = isset($parameter['startrow']) ? intval($parameter['startrow']) : 0;
     $items = isset($parameter['items']) ? intval($parameter['items']) : 10;
     $special = isset($parameter['special']) ? $parameter['special'] : array();
     $lastpost = isset($parameter['lastpost']) ? intval($parameter['lastpost']) : 0;
     $rewardstatus = isset($parameter['rewardstatus']) ? intval($parameter['rewardstatus']) : 0;
     $titlelength = !empty($parameter['titlelength']) ? intval($parameter['titlelength']) : 40;
     $summarylength = !empty($parameter['summarylength']) ? intval($parameter['summarylength']) : 80;
     $orderby = in_array($parameter['orderby'], array('dateline', 'replies', 'views', 'threads', 'heats', 'recommends')) ? $parameter['orderby'] : 'lastpost';
     $picrequired = !empty($parameter['picrequired']) ? 1 : 0;
     $gviewperm = isset($parameter['gviewperm']) ? intval($parameter['gviewperm']) : -1;
     $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
     $gviewwhere = $gviewperm == -1 ? '' : " AND ff.gviewperm='{$gviewperm}'";
     $groups = array();
     if (empty($fids) && $typeids) {
         $query = DB::query('SELECT f.fid, f.name, ff.description FROM ' . DB::table('forum_forum') . " f LEFT JOIN " . DB::table('forum_forumfield') . " ff ON f.fid = ff.fid WHERE f.fup IN (" . dimplode($typeids) . ") AND threads > 0{$gviewwhere}");
         while ($value = DB::fetch($query)) {
             $groups[$value['fid']] = $value;
             $fids[] = intval($value['fid']);
         }
         if (empty($fids)) {
             return array('html' => '', 'data' => '');
         }
     }
     require_once libfile('function/post');
     $datalist = $list = array();
     $threadtypeids = array();
     $sql = ($fids ? ' AND t.fid IN (' . dimplode($fids) . ')' : '') . ($tids ? ' AND t.tid IN (' . dimplode($tids) . ')' : '') . ($bannedids ? ' AND t.tid NOT IN (' . dimplode($bannedids) . ')' : '') . ($uids ? ' AND t.authorid IN (' . dimplode($uids) . ')' : '') . ($special ? ' AND t.special IN (' . dimplode($special) . ')' : '') . (in_array(3, $special) && $rewardstatus ? $rewardstatus == 1 ? ' AND t.price < 0' : ' AND t.price > 0' : '') . ($picrequired ? ' AND t.attachment = 2' : '');
     if (empty($fids)) {
         $sql .= " AND t.isgroup='1'";
         if ($gviewwhere) {
             $sql .= $gviewwhere;
         }
     }
     if ($lastpost) {
         $time = TIMESTAMP - $lastpost;
         $sql .= " AND t.lastpost >= '{$time}'";
     }
     if ($orderby == 'heats') {
         $heatdateline = TIMESTAMP - 86400 * $_G['setting']['indexhot']['days'];
         $sql .= " AND t.dateline>'{$heatdateline}' AND t.heats>'0'";
     }
     $sqlfield = '';
     $sqlfrom = "FROM `" . DB::table('forum_thread') . "` t";
     if (empty($fids)) {
         $sqlfield = ', f.name groupname';
         $sqlfrom .= ' LEFT JOIN ' . DB::table('forum_forum') . ' f ON t.fid=f.fid LEFT JOIN ' . DB::table('forum_forumfield') . ' ff ON f.fid = ff.fid';
     }
     $query = DB::query("SELECT t.* {$sqlfield}\r\n\t\t\t{$sqlfrom} WHERE t.readperm='0'\r\n\t\t\t{$sql}\r\n\t\t\tAND t.displayorder>='0'\r\n\t\t\tORDER BY t.{$orderby} DESC\r\n\t\t\tLIMIT {$startrow},{$items};");
     require_once libfile('block_thread', 'class/block/forum');
     $bt = new block_thread();
     while ($data = DB::fetch($query)) {
         if ($data['closed'] > 1 && $data['closed'] < $data['tid']) {
             continue;
         }
         $_G['thread'][$data['tid']] = $data;
         if ($style['getpic'] && $data['attachment'] == '2') {
             $pic = $bt->getpic($data['tid']);
             $data['attachment'] = $pic['attachment'];
             $data['remote'] = $pic['remote'];
         }
         $list[] = array('id' => $data['tid'], 'idtype' => 'tid', 'title' => cutstr(str_replace('\\\'', '&#39;', $data['subject']), $titlelength, ''), 'url' => 'forum.php?mod=viewthread&tid=' . $data['tid'], 'pic' => $data['attachment'] ? 'forum/' . $data['attachment'] : STATICURL . 'image/common/nophoto.gif', 'picflag' => $data['attachment'] ? $data['remote'] ? '2' : '1' : '0', 'summary' => $style['getsummary'] ? $bt->getthread($data['tid'], $summarylength) : '', 'fields' => array('fulltitle' => str_replace('\\\'', '&#39;', addslashes($data['subject'])), 'icon' => 'forum/' . $data['icon'], 'author' => $data['author'] ? $data['author'] : 'Anonymous', 'authorid' => $data['author'] ? $data['authorid'] : 0, 'avatar' => avatar($data['author'] ? $data['authorid'] : 0, 'small', true, false, false, $_G['setting']['ucenterurl']), 'avatar_middle' => avatar($data['author'] ? $data['authorid'] : 0, 'middle', true, false, false, $_G['setting']['ucenterurl']), 'avatar_big' => avatar($data['author'] ? $data['authorid'] : 0, 'big', true, false, false, $_G['setting']['ucenterurl']), 'dateline' => $data['dateline'], 'lastpost' => $data['lastpost'], 'posts' => $data['posts'], 'todayposts' => $data['todayposts'], 'replies' => $data['replies'], 'views' => $data['views'], 'heats' => $data['heats'], 'recommends' => $data['recommends'], 'groupname' => empty($groups[$data['fid']]['name']) ? $data['groupname'] : $groups[$data['fid']]['name'], 'groupurl' => 'forum.php?mod=group&fid=' . $data['fid']));
     }
     return array('html' => '', 'data' => $list);
 }