Exemplo n.º 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();
     $uids = !empty($parameter['uids']) ? explode(',', $parameter['uids']) : array();
     $startrow = isset($parameter['startrow']) ? intval($parameter['startrow']) : 0;
     $items = isset($parameter['items']) ? intval($parameter['items']) : 10;
     $digest = isset($parameter['digest']) ? $parameter['digest'] : 0;
     $stick = isset($parameter['stick']) ? $parameter['stick'] : 0;
     $orderby = isset($parameter['orderby']) ? in_array($parameter['orderby'], array('dateline', 'todayhots', 'weekhots', 'monthhots')) ? $parameter['orderby'] : 'dateline' : 'dateline';
     $titlelength = !empty($parameter['titlelength']) ? intval($parameter['titlelength']) : 40;
     $summarylength = !empty($parameter['summarylength']) ? intval($parameter['summarylength']) : 80;
     $recommend = !empty($parameter['recommend']) ? 1 : 0;
     $keyword = !empty($parameter['keyword']) ? $parameter['keyword'] : '';
     $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();
     if ($keyword) {
         if (preg_match("(AND|\\+|&|\\s)", $keyword) && !preg_match("(OR|\\|)", $keyword)) {
             $andor = ' AND ';
             $keywordsrch = '1';
             $keyword = preg_replace("/( AND |&| )/is", "+", $keyword);
         } else {
             $andor = ' OR ';
             $keywordsrch = '0';
             $keyword = preg_replace("/( OR |\\|)/is", "+", $keyword);
         }
         $keyword = str_replace('*', '%', addcslashes($keyword, '%_'));
         foreach (explode('+', $keyword) as $text) {
             $text = trim($text);
             if ($text) {
                 $keywordsrch .= $andor;
                 $keywordsrch .= "tr.subject LIKE '%{$text}%'";
             }
         }
         $keyword = " AND ({$keywordsrch})";
     } else {
         $keyword = '';
     }
     $sql = ($fids ? ' AND t.fid IN (' . dimplode($fids) . ')' : '') . ($tids ? ' AND t.tid IN (' . dimplode($tids) . ')' : '') . ($digest ? ' AND t.digest IN (' . dimplode($digest) . ')' : '') . ($stick ? ' AND t.displayorder IN (' . dimplode($stick) . ')' : '') . " AND t.isgroup='1'";
     $where = '';
     if (in_array($orderby, array('todayhots', 'weekhots', 'monthhots'))) {
         $historytime = 0;
         switch ($orderby) {
             case 'todayhots':
                 $historytime = mktime(0, 0, 0, date('m', TIMESTAMP), date('d', TIMESTAMP), date('Y', TIMESTAMP));
                 break;
             case 'weekhots':
                 $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 'monthhots':
                 $historytime = mktime(0, 0, 0, date('m', TIMESTAMP), 1, date('Y', TIMESTAMP));
                 break;
         }
         $where = ' WHERE tr.dateline>=' . $historytime;
         $orderby = 'totalitems';
     }
     $where .= ($uids ? ' AND tr.sellerid IN (' . dimplode($uids) . ')' : '') . $keyword;
     $where .= $bannedids ? ' AND tr.pid NOT IN (' . dimplode($bannedids) . ')' : '';
     $sqlfrom = " INNER JOIN `" . DB::table('forum_thread') . "` t ON t.tid=tr.tid {$sql} AND t.displayorder>='0'";
     if ($recommend) {
         $sqlfrom .= " INNER JOIN `" . DB::table('forum_forumrecommend') . "` fc ON fc.tid=tr.tid";
     }
     $query = DB::query("SELECT tr.pid, tr.tid, tr.aid, tr.price, tr.credit, tr.subject, tr.totalitems, tr.seller, tr.sellerid\n\t\t\tFROM " . DB::table('forum_trade') . " tr {$sqlfrom} {$where}\n\t\t\tORDER BY tr.{$orderby} DESC\n\t\t\tLIMIT {$startrow},{$items};");
     include_once libfile('block/thread', 'class');
     $bt = new block_thread();
     while ($data = DB::fetch($query)) {
         $list[] = array('id' => $data['pid'], 'idtype' => 'pid', 'title' => cutstr(str_replace('\\\'', ''', addslashes($data['subject'])), $titlelength), 'url' => 'forum.php?mod=viewthread&do=tradeinfo&tid=' . $data['tid'] . '&pid=' . $data['pid'], 'pic' => $data['aid'] ? getforumimg($data['aid']) : IMGDIR . '/nophoto.gif', 'picflag' => '0', 'summary' => !empty($style['getsummary']) ? $bt->getthread($data['tid'], $summarylength, true) : '', 'fields' => array('totalitems' => $data['totalitems'], 'author' => $data['seller'] ? $data['seller'] : 'Anonymous', 'authorid' => $data['sellerid'] ? $data['sellerid'] : 0, 'price' => ($data['price'] > 0 ? '¥ ' . $data['price'] : '') . ($data['credit'] > 0 ? ($data['price'] > 0 ? lang('block/grouptrade', 'grouptrade_price_add') : '') . $data['credit'] . ' ' . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][5]]['unit'] . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][5]]['title'] : '')));
     }
     return array('html' => '', 'data' => $list);
 }
Exemplo n.º 2
0
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     loadcache('forums');
     $tids = !empty($parameter['tids']) ? explode(',', $parameter['tids']) : array();
     $uids = !empty($parameter['uids']) ? explode(',', $parameter['uids']) : array();
     $startrow = !empty($parameter['startrow']) ? intval($parameter['startrow']) : 0;
     $items = !empty($parameter['items']) ? intval($parameter['items']) : 10;
     $digest = isset($parameter['digest']) ? $parameter['digest'] : 0;
     $stick = isset($parameter['stick']) ? $parameter['stick'] : 0;
     $orderby = isset($parameter['orderby']) ? in_array($parameter['orderby'], array('dateline', 'weekstart', 'monthstart', 'weekexp', 'monthexp', 'weekhot', 'monthhot', 'alltimehot')) ? $parameter['orderby'] : 'dateline' : 'dateline';
     $titlelength = !empty($parameter['titlelength']) ? intval($parameter['titlelength']) : 40;
     $summarylength = !empty($parameter['summarylength']) ? intval($parameter['summarylength']) : 80;
     $recommend = !empty($parameter['recommend']) ? 1 : 0;
     $keyword = !empty($parameter['keyword']) ? $parameter['keyword'] : '';
     $place = !empty($parameter['place']) ? $parameter['place'] : '';
     $class = !empty($parameter['class']) ? trim($parameter['class']) : '';
     $gender = !empty($parameter['gender']) ? intval($parameter['gender']) : '';
     $viewmod = !empty($parameter['viewmod']) ? 1 : 0;
     $highlight = !empty($parameter['highlight']) ? 1 : 0;
     $fids = array();
     if (!empty($parameter['fids'])) {
         if ($parameter['fids'][0] == '0') {
             unset($parameter['fids'][0]);
         }
         $fids = $parameter['fids'];
     }
     $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
     require_once libfile('function/post');
     require_once libfile('function/search');
     $datalist = $list = array();
     $keyword = $keyword ? searchkey($keyword, "t.subject LIKE '%{text}%'") : '';
     $sql = ($fids ? ' AND t.fid IN (' . dimplode($fids) . ')' : '') . $keyword . ($tids ? ' AND t.tid IN (' . dimplode($tids) . ')' : '') . ($bannedids ? ' AND t.tid NOT IN (' . dimplode($bannedids) . ')' : '') . ($digest ? ' AND t.digest IN (' . dimplode($digest) . ')' : '') . ($stick ? ' AND t.displayorder IN (' . dimplode($stick) . ')' : '') . " AND t.isgroup='0'";
     $where = '';
     if (in_array($orderby, array('weekstart', 'monthstart'))) {
         $historytime = 0;
         switch ($orderby) {
             case 'weekstart':
                 $historytime = TIMESTAMP + 86400 * 7;
                 break;
             case 'monthstart':
                 $historytime = TIMESTAMP + 86400 * 30;
                 break;
         }
         $where = ' WHERE a.starttimefrom>=' . TIMESTAMP . ' AND a.starttimefrom<=' . $historytime;
         $orderby = 'a.starttimefrom ASC';
     } elseif (in_array($orderby, array('weekexp', 'monthexp'))) {
         $historytime = 0;
         switch ($orderby) {
             case 'weekexp':
                 $historytime = TIMESTAMP + 86400 * 7;
                 break;
             case 'monthexp':
                 $historytime = TIMESTAMP + 86400 * 30;
                 break;
         }
         $where = ' WHERE a.expiration>=' . TIMESTAMP . ' AND a.expiration<=' . $historytime;
         $orderby = 'a.expiration ASC';
     } elseif (in_array($orderby, array('weekhot', 'monthhot'))) {
         $historytime = 0;
         switch ($orderby) {
             case 'weekhot':
                 $historytime = TIMESTAMP + 86400 * 7;
                 break;
             case 'monthhot':
                 $historytime = TIMESTAMP + 86400 * 30;
                 break;
         }
         $where = ' WHERE a.expiration>=' . TIMESTAMP . ' AND a.expiration<=' . $historytime;
         $orderby = 'a.applynumber DESC';
     } elseif ($orderby == 'alltimehot') {
         $where = ' WHERE (a.expiration>=' . TIMESTAMP . " OR a.expiration='0')";
         $orderby = 'a.applynumber DESC';
     } else {
         $orderby = 't.dateline DESC';
     }
     $where .= $uids ? ' AND t.authorid IN (' . dimplode($uids) . ')' : '';
     if ($gender) {
         $where .= " AND a.gender='{$gender}'";
     }
     if ($class) {
         $where .= " AND a.class='{$class}'";
     }
     $sqlfrom = " INNER JOIN `" . DB::table('forum_thread') . "` t ON t.tid=a.tid {$sql} AND t.displayorder>='0'";
     $joinmethod = empty($tids) ? 'INNER' : 'LEFT';
     if ($recommend) {
         $sqlfrom .= " {$joinmethod} JOIN `" . DB::table('forum_forumrecommend') . "` fc ON fc.tid=tr.tid";
     }
     $sqlfield = $highlight ? ', t.highlight' : '';
     $query = DB::query("SELECT a.*, t.tid, t.subject, t.authorid, t.author{$sqlfield}\n\t\t\tFROM " . DB::table('forum_activity') . " a {$sqlfrom} {$where}\n\t\t\tORDER BY {$orderby}\n\t\t\tLIMIT {$startrow},{$items};");
     require_once libfile('block_thread', 'class/block/forum');
     $bt = new block_thread();
     $listtids = $threadtids = $threads = $aid2tid = $attachtables = array();
     while ($data = DB::fetch($query)) {
         $data['time'] = dgmdate($data['starttimefrom']);
         if ($data['starttimeto']) {
             $data['time'] .= ' - ' . dgmdate($data['starttimeto']);
         }
         if ($style['getsummary']) {
             $threadtids[$data['posttableid']][] = $data['tid'];
         }
         if ($data['aid']) {
             $aid2tid[$data['aid']] = $data['tid'];
             $attachtable = getattachtableid($data['tid']);
             $attachtables[$attachtable][] = $data['aid'];
         }
         $listtids[] = $data['tid'];
         $list[$data['tid']] = array('id' => $data['tid'], 'idtype' => 'tid', 'title' => cutstr(str_replace('\\\'', '&#39;', $data['subject']), $titlelength, ''), 'url' => 'forum.php?mod=viewthread&tid=' . $data['tid'] . ($viewmod ? '&from=portal' : ''), 'pic' => $data['aid'] ? '' : $_G['style']['imgdir'] . '/nophoto.gif', 'picflag' => '0', 'fields' => array('fulltitle' => str_replace('\\\'', '&#39;', addslashes($data['subject'])), 'time' => $data['time'], 'expiration' => $data['expiration'] ? dgmdate($data['expiration']) : 'N/A', 'author' => $data['author'] ? $data['author'] : $_G['setting']['anonymoustext'], 'authorid' => $data['authorid'] ? $data['authorid'] : 0, 'cost' => $data['cost'], 'place' => $data['place'], 'class' => $data['class'], 'gender' => $data['gender'], 'number' => $data['number'], 'applynumber' => $data['applynumber']));
         if ($highlight && $data['highlight']) {
             $list[$data['tid']]['fields']['showstyle'] = $bt->getthreadstyle($data['highlight']);
         }
     }
     if (!empty($listtids)) {
         $query = DB::query("SELECT tid,COUNT(*) as sum FROM " . DB::table('forum_activityapply') . " WHERE tid IN(" . dimplode($listtids) . ") GROUP BY tid");
         while ($value = DB::fetch($query)) {
             $list[$value['tid']]['fields']['applynumber'] = $value['sum'];
         }
         $threads = $bt->getthread($threadtids, $summarylength, true);
         if ($threads) {
             foreach ($threads as $tid => $var) {
                 $list[$tid]['summary'] = $var;
             }
         }
         foreach ($attachtables as $tableid => $taids) {
             $query = DB::query('SELECT aid, attachment, remote FROM ' . DB::table('forum_attachment_' . $tableid) . ' WHERE aid IN (' . dimplode($taids) . ')');
             while ($avalue = DB::fetch($query)) {
                 $list[$aid2tid[$avalue['aid']]]['pic'] = 'forum/' . $avalue['attachment'];
                 $list[$aid2tid[$avalue['aid']]]['picflag'] = $avalue['remote'] ? '2' : '1';
             }
         }
         foreach ($listtids as $key => $value) {
             $datalist[] = $list[$value];
         }
     }
     return array('html' => '', 'data' => $datalist);
 }
Exemplo n.º 3
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();
     $keyword = !empty($parameter['keyword']) ? $parameter['keyword'] : '';
     $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;
     $postdateline = isset($parameter['postdateline']) ? intval($parameter['postdateline']) : 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;
     $highlight = !empty($parameter['highlight']) ? 1 : 0;
     $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');
     require_once libfile('function/search');
     $datalist = $list = $listtids = $pictids = $pics = $threadtids = $threads = array();
     $threadtypeids = array();
     $keyword = $keyword ? searchkey($keyword, "t.subject LIKE '%{text}%'") : '';
     $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' : '') . $keyword;
     if (empty($fids)) {
         $sql .= " AND t.isgroup='1'";
         if ($gviewwhere) {
             $sql .= $gviewwhere;
         }
     }
     if ($postdateline) {
         $time = TIMESTAMP - $postdateline;
         $sql .= " AND t.dateline >= '{$time}'";
     }
     if ($lastpost) {
         $time = TIMESTAMP - $lastpost;
         $sql .= " AND t.lastpost >= '{$time}'";
     }
     if ($orderby == 'heats') {
         $sql .= " AND t.heats>'0'";
     }
     $sqlfrom = $sqlfield = $joinmethodpic = '';
     if ($picrequired) {
         $joinmethodpic = 'INNER';
     } else {
         if ($style['getpic']) {
             $joinmethodpic = 'LEFT';
         }
     }
     if ($joinmethodpic) {
         /*vot*/
         $sqlfrom .= " {$joinmethodpic} JOIN `" . DB::table('forum_threadimage') . "` ti ON (t.tid=ti.tid AND ti.tid>0)";
         $sqlfield = ', ti.attachment as attachmenturl, ti.remote';
     }
     if (empty($fids)) {
         $sqlfield .= ', f.name groupname';
         /*vot*/
         $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\tFROM `" . DB::table('forum_thread') . "` t\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['block_thread'][$data['tid']] = $data;
         if ($style['getsummary']) {
             $threadtids[$data['posttableid']][] = $data['tid'];
         }
         $listtids[] = $data['tid'];
         $list[$data['tid']] = array('id' => $data['tid'], 'idtype' => 'tid', 'title' => cutstr(str_replace('\\\'', '&#39;', $data['subject']), $titlelength, ''), 'url' => 'forum.php?mod=viewthread&tid=' . $data['tid'], 'pic' => $data['attachmenturl'] ? 'forum/' . $data['attachmenturl'] : STATICURL . 'image/common/nophoto.gif', 'picflag' => $data['attachmenturl'] ? $data['remote'] ? '2' : '1' : '0', 'fields' => array('fulltitle' => str_replace('\\\'', '&#39;', addslashes($data['subject'])), 'icon' => 'forum/' . $data['icon'], 'author' => $data['author'] ? $data['author'] : $_G['setting']['anonymoustext'], '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']));
         if ($highlight && $data['highlight']) {
             $list[$data['tid']]['fields']['showstyle'] = $bt->getthreadstyle($data['highlight']);
         }
     }
     $threads = $bt->getthread($threadtids, $summarylength);
     if ($threads) {
         foreach ($threads as $tid => $var) {
             $list[$tid]['summary'] = $var;
         }
     }
     if ($listtids) {
         foreach ($listtids as $key => $value) {
             $datalist[] = $list[$value];
         }
     }
     return array('html' => '', 'data' => $datalist);
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
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();
     $uids = !empty($parameter['uids']) ? explode(',', $parameter['uids']) : array();
     $startrow = !empty($parameter['startrow']) ? intval($parameter['startrow']) : 0;
     $items = !empty($parameter['items']) ? intval($parameter['items']) : 10;
     $digest = isset($parameter['digest']) ? $parameter['digest'] : 0;
     $stick = isset($parameter['stick']) ? $parameter['stick'] : 0;
     $orderby = isset($parameter['orderby']) ? in_array($parameter['orderby'], array('dateline', 'weekstart', 'monthstart', 'weekexp', 'monthexp')) ? $parameter['orderby'] : 'dateline' : 'dateline';
     $titlelength = !empty($parameter['titlelength']) ? intval($parameter['titlelength']) : 40;
     $summarylength = !empty($parameter['summarylength']) ? intval($parameter['summarylength']) : 80;
     $recommend = !empty($parameter['recommend']) ? 1 : 0;
     $keyword = !empty($parameter['keyword']) ? $parameter['keyword'] : '';
     $place = !empty($parameter['place']) ? $parameter['place'] : '';
     $class = !empty($parameter['class']) ? $parameter['class'] : '';
     $gender = !empty($parameter['gender']) ? intval($parameter['gender']) : '';
     $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();
     if ($keyword) {
         if (preg_match("(AND|\\+|&|\\s)", $keyword) && !preg_match("(OR|\\|)", $keyword)) {
             $andor = ' AND ';
             $keywordsrch = '1';
             $keyword = preg_replace("/( AND |&| )/is", "+", $keyword);
         } else {
             $andor = ' OR ';
             $keywordsrch = '0';
             $keyword = preg_replace("/( OR |\\|)/is", "+", $keyword);
         }
         $keyword = str_replace('*', '%', addcslashes($keyword, '%_'));
         foreach (explode('+', $keyword) as $text) {
             $text = trim($text);
             if ($text) {
                 $keywordsrch .= $andor;
                 $keywordsrch .= "t.subject LIKE '%{$text}%'";
             }
         }
         $keyword = " AND ({$keywordsrch})";
     } else {
         $keyword = '';
     }
     $sql = ($fids ? ' AND t.fid IN (' . dimplode($fids) . ')' : '') . $keyword . ($tids ? ' AND t.tid IN (' . dimplode($tids) . ')' : '') . ($bannedids ? ' AND t.tid NOT IN (' . dimplode($bannedids) . ')' : '') . ($digest ? ' AND t.digest IN (' . dimplode($digest) . ')' : '') . ($stick ? ' AND t.displayorder IN (' . dimplode($stick) . ')' : '') . " AND t.isgroup='1'";
     $where = '';
     if (in_array($orderby, array('weekstart', 'monthstart'))) {
         $historytime = 0;
         switch ($orderby) {
             case 'weekstart':
                 $historytime = TIMESTAMP + 86400 * 7;
                 break;
             case 'monthstart':
                 $historytime = TIMESTAMP + 86400 * 30;
                 break;
         }
         $where = ' WHERE a.starttimefrom >= ' . TIMESTAMP . ' AND a.starttimefrom<=' . $historytime;
         $orderby = 'a.starttimefrom ASC';
     } elseif (in_array($orderby, array('weekexp', 'monthexp'))) {
         $historytime = 0;
         switch ($orderby) {
             case 'weekexp':
                 $historytime = TIMESTAMP + 86400 * 7;
                 break;
             case 'monthexp':
                 $historytime = TIMESTAMP + 86400 * 30;
                 break;
         }
         $where = ' WHERE a.expiration >= ' . TIMESTAMP . ' AND a.expiration<=' . $historytime;
         $orderby = 'a.expiration ASC';
     } else {
         $orderby = 't.dateline DESC';
     }
     $where .= $uids ? ' AND t.authorid IN (' . dimplode($uids) . ')' : '';
     if ($gender) {
         $where .= " AND a.gender='{$gender}'";
     }
     $sqlfrom = " INNER JOIN `" . DB::table('forum_thread') . "` t ON t.tid=a.tid {$sql} AND t.displayorder>='0'";
     if ($recommend) {
         $sqlfrom .= " INNER JOIN `" . DB::table('forum_forumrecommend') . "` fc ON fc.tid=tr.tid";
     }
     $query = DB::query("SELECT a.*, t.tid, t.subject, t.authorid, t.author\n\t\t\tFROM " . DB::table('forum_activity') . " a {$sqlfrom} {$where}\n\t\t\tORDER BY {$orderby}\n\t\t\tLIMIT {$startrow},{$items};");
     include_once libfile('block/thread', 'class');
     $bt = new block_thread();
     while ($data = DB::fetch($query)) {
         $data['time'] = dgmdate($data['starttimefrom']);
         if ($data['starttimeto']) {
             $data['time'] .= ' - ' . dgmdate($data['starttimeto']);
         }
         $list[] = array('id' => $data['pid'], 'idtype' => 'pid', 'title' => cutstr(str_replace('\\\'', '&#39;', addslashes($data['subject'])), $titlelength), 'url' => 'forum.php?mod=viewthread&tid=' . $data['tid'], 'pic' => $data['aid'] ? getforumimg($data['aid']) : IMGDIR . '/nophoto.gif', 'picflag' => '0', 'summary' => !empty($style['getsummary']) ? $bt->getthread($data['tid'], $summarylength, true) : '', 'fields' => array('time' => $data['time'], 'expiration' => $data['expiration'] ? dgmdate($data['expiration']) : 'N/A', 'author' => $data['author'] ? $data['author'] : 'Anonymous', 'authorid' => $data['authorid'] ? $data['authorid'] : 0, 'cost' => $data['cost'], 'place' => $data['place'], 'class' => $data['class'], 'gender' => $data['gender'], 'number' => $data['number'], 'applynumber' => $data['applynumber']));
     }
     return array('html' => '', 'data' => $list);
 }
Exemplo n.º 6
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'];
     }
     $startrow = isset($parameter['startrow']) ? intval($parameter['startrow']) : 0;
     $items = isset($parameter['items']) ? intval($parameter['items']) : 10;
     $titlelength = !empty($parameter['titlelength']) ? intval($parameter['titlelength']) : 40;
     $summarylength = !empty($parameter['summarylength']) ? intval($parameter['summarylength']) : 80;
     $digest = isset($parameter['digest']) ? $parameter['digest'] : 0;
     $special = isset($parameter['special']) ? $parameter['special'] : array();
     $rewardstatus = isset($parameter['rewardstatus']) ? intval($parameter['rewardstatus']) : 0;
     $orderby = isset($parameter['orderby']) ? in_array($parameter['orderby'], array('dateline', 'downloads')) ? $parameter['orderby'] : 'dateline' : 'dateline';
     $dateline = isset($parameter['dateline']) ? intval($parameter['dateline']) : '8640000';
     $threadmethod = !empty($parameter['threadmethod']) ? 1 : 0;
     $isimage = isset($parameter['isimage']) ? intval($parameter['isimage']) : '';
     $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' => '');
         }
     }
     $datalist = $list = array();
     $sql = ($fids ? ' AND t.fid IN (' . dimplode($fids) . ')' : '') . ($tids ? ' AND t.tid IN (' . dimplode($tids) . ')' : '') . ($digest ? ' AND t.digest IN (' . dimplode($digest) . ')' : '') . ($special ? ' AND t.special IN (' . dimplode($special) . ')' : '') . (in_array(3, $special) && $rewardstatus ? $rewardstatus == 1 ? ' AND t.price < 0' : ' AND t.price > 0' : '');
     if (empty($fids)) {
         $sql .= " AND t.isgroup='1'";
         if ($gviewwhere) {
             $sql .= $gviewwhere;
         }
     }
     $orderbysql = $historytime = '';
     switch ($orderby) {
         case 'dateline':
             $orderbysql = "ORDER BY `attach`.`dateline` DESC";
             break;
         case 'downloads':
             $orderbysql = "ORDER BY `attach`.`downloads` DESC";
             break;
     }
     $htsql = '';
     $dateline = !empty($dateline) ? intval($dateline) : 8640000;
     $historytime = TIMESTAMP - $dateline;
     $htsql = "`attach`.`dateline`>='{$historytime}'";
     $sqlfield = $sqljoin = '';
     if ($style['getsummary']) {
         $sqlfield = ',af.description';
         $sqljoin = "LEFT JOIN `" . DB::table('forum_attachmentfield') . "` af ON attach.aid=af.aid";
     }
     if ($isimage) {
         $sql .= $isimage == 1 ? "AND `attach`.`isimage` IN ('1', '-1')" : "AND `attach`.`isimage`='0'";
     }
     $sqlgroupby = '';
     if ($threadmethod) {
         if ($isimage == 1) {
             $sql .= ' AND t.attachment=2';
         } elseif ($isimage == 2) {
             $sql .= ' AND t.attachment=1';
         } else {
             $sql .= ' AND t.attachment>0';
         }
         $sqlgroupby = ' GROUP BY t.tid';
     }
     $sqlban = !empty($bannedids) ? ' AND attach.tid NOT IN (' . dimplode($bannedids) . ')' : '';
     if (empty($fids)) {
         $sqlfield = ', f.name groupname';
         $sqljoin .= ' 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 attach.*,t.tid,t.author,t.authorid,t.subject {$sqlfield}\r\n\t\t\tFROM `" . DB::table('forum_attachment') . "` attach\r\n\t\t\tINNER JOIN `" . DB::table('forum_thread') . "` t\r\n\t\t\tON `t`.`tid`=`attach`.`tid` AND `displayorder`>='0'\r\n\t\t\t{$sqljoin}\r\n\t\t\tWHERE {$htsql} AND `attach`.`readperm`='0' AND `attach`.`price`='0'\r\n\t\t\t{$sql}\r\n\t\t\t{$sqlban}\r\n\t\t\t{$sqlgroupby}\r\n\t\t\t{$orderbysql}\r\n\t\t\tLIMIT {$startrow},{$items};");
     require_once libfile('block_thread', 'class/block/forum');
     $bt = new block_thread();
     while ($data = DB::fetch($query)) {
         $list[] = array('id' => $data['aid'], 'idtype' => 'aid', 'title' => cutstr(str_replace('\\\'', '&#39;', $data['filename']), $titlelength, ''), 'url' => 'forum.php?mod=attachment&aid=' . aidencode($data['aid']), 'pic' => $data['isimage'] == 1 || $data['isimage'] == -1 ? 'forum/' . $data['attachment'] : '', 'picflag' => $data['remote'] ? '2' : '1', 'summary' => $data['description'] ? cutstr(str_replace('\\\'', '&#39;', $data['description']), $summarylength, '') : '', 'fields' => array('fulltitle' => str_replace('\\\'', '&#39;', addslashes($data['subject'])), 'author' => $data['author'], 'authorid' => $data['authorid'], 'filesize' => sizecount($data['filesize']), 'dateline' => $data['dateline'], 'downloads' => $data['downloads'], 'hourdownloads' => $data['downloads'], 'todaydownloads' => $data['downloads'], 'weekdownloads' => $data['downloads'], 'monthdownloads' => $data['downloads'], 'threadurl' => 'forum.php?mod=viewthread&tid=' . $data['tid'], 'threadsubject' => cutstr(str_replace('\\\'', '&#39;', $data['subject']), $titlelength, ''), 'threadsummary' => $bt->getthread($data['tid'], $summarylength)));
     }
     return array('html' => '', 'data' => $list);
 }
Exemplo n.º 7
0
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     loadcache('forums');
     $fids = isset($parameter['fids']) && !in_array(0, (array) $parameter['fids']) ? $parameter['fids'] : array_keys($_G['cache']['forums']);
     $tids = !empty($parameter['tids']) ? explode(',', $parameter['tids']) : array();
     $startrow = isset($parameter['startrow']) ? intval($parameter['startrow']) : 0;
     $items = isset($parameter['items']) ? intval($parameter['items']) : 10;
     $digest = isset($parameter['digest']) ? $parameter['digest'] : 0;
     $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 = isset($parameter['orderby']) ? in_array($parameter['orderby'], array('dateline', 'downloads', 'hourdownloads', 'todaydownloads', 'weekdownloads', 'monthdownloads')) ? $parameter['orderby'] : 'dateline' : 'dateline';
     $threadmethod = !empty($parameter['threadmethod']) ? 1 : 0;
     $isimage = isset($parameter['isimage']) ? intval($parameter['isimage']) : '';
     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);
     }
     $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
     $datalist = $list = array();
     $sql = ($fids ? ' AND t.fid IN (' . dimplode($fids) . ')' : '') . ($tids ? ' AND t.tid IN (' . dimplode($tids) . ')' : '') . ($digest ? ' AND t.digest IN (' . dimplode($digest) . ')' : '') . ($special ? ' AND t.special IN (' . dimplode($special) . ')' : '') . (in_array(3, $special) && $rewardstatus ? $rewardstatus == 1 ? ' AND t.price < 0' : ' AND t.price > 0' : '') . " AND t.isgroup='0'";
     $orderbysql = $historytime = '';
     switch ($orderby) {
         case 'dateline':
             $orderbysql = "ORDER BY `attach`.`dateline` DESC";
             break;
         case 'downloads':
             $orderbysql = "ORDER BY `attach`.`downloads` DESC";
             break;
         case 'hourdownloads':
             $historytime = TIMESTAMP - 3600;
             $orderbysql = "ORDER BY `attach`.`downloads` DESC";
             break;
         case 'todaydownloads':
             $historytime = mktime(0, 0, 0, date('m', TIMESTAMP), date('d', TIMESTAMP), date('Y', TIMESTAMP));
             $orderbysql = "ORDER BY `attach`.`downloads` DESC";
             break;
         case 'weekdownloads':
             $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));
             $orderbysql = "ORDER BY `attach`.`downloads` DESC";
             break;
         case 'monthdownloads':
             $historytime = mktime(0, 0, 0, date('m', TIMESTAMP), 1, date('Y', TIMESTAMP));
             $orderbysql = "ORDER BY `attach`.`downloads` DESC";
             break;
     }
     $historytime = !$historytime ? TIMESTAMP - 8640000 : $historytime;
     $htsql = "`attach`.`dateline`>='{$historytime}'";
     $sqlfield = $sqljoin = '';
     if ($style['getsummary']) {
         $sqlfield = ',af.description';
         $sqljoin = "LEFT JOIN `" . DB::table('forum_attachmentfield') . "` af ON attach.aid=af.aid";
     }
     if ($isimage) {
         $sql .= $isimage == 1 ? "AND `attach`.`isimage` IN ('1', '-1')" : "AND `attach`.`isimage`='0'";
     }
     $sqlgroupby = '';
     if ($threadmethod) {
         if ($isimage == 1) {
             $sql .= ' AND t.attachment=2';
         } elseif ($isimage == 2) {
             $sql .= ' AND t.attachment=1';
         } else {
             $sql .= ' AND t.attachment>0';
         }
         $sqlgroupby = ' GROUP BY t.tid';
     }
     $sqlban = !empty($bannedids) ? ' AND attach.aid NOT IN (' . dimplode($bannedids) . ')' : '';
     $query = DB::query("SELECT attach.*,t.tid,t.author,t.authorid,t.subject {$sqlfield}\n\t\t\tFROM `" . DB::table('forum_attachment') . "` attach\n\t\t\t{$sqljoin}\n\t\t\tINNER JOIN `" . DB::table('forum_thread') . "` t\n\t\t\tON `t`.`tid`=`attach`.`tid` AND `displayorder`>='0'\n\t\t\tWHERE {$htsql} AND `attach`.`readperm`='0' AND `attach`.`price`='0'\n\t\t\t{$sql}\n\t\t\t{$sqlban}\n\t\t\t{$sqlgroupby}\n\t\t\t{$orderbysql}\n\t\t\tLIMIT {$startrow},{$items};");
     include_once libfile('block/thread', 'class');
     $bt = new block_thread();
     while ($data = DB::fetch($query)) {
         $list[] = array('id' => $data['aid'], 'idtype' => 'aid', 'title' => cutstr(str_replace('\\\'', '&#39;', $data['filename']), $titlelength), 'url' => 'forum.php?mod=attachment&aid=' . aidencode($data['aid']), 'pic' => $data['isimage'] == 1 || $data['isimage'] == -1 ? 'forum/' . $data['attachment'] : '', 'picflag' => $data['remote'] ? '2' : '1', 'summary' => !empty($data['description']) ? cutstr(str_replace('\\\'', '&#39;', $data['description']), $summarylength) : '', 'fields' => array('author' => $data['author'], 'authorid' => $data['authorid'], 'filesize' => sizecount($data['filesize']), 'dateline' => $data['dateline'], 'downloads' => $data['downloads'], 'hourdownloads' => $data['downloads'], 'todaydownloads' => $data['downloads'], 'weekdownloads' => $data['downloads'], 'monthdownloads' => $data['downloads'], 'threadurl' => 'forum.php?mod=viewthread&tid=' . $data['tid'], 'threadsubject' => cutstr(str_replace('\\\'', '&#39;', $data['subject']), $titlelength), 'threadsummary' => $bt->getthread($data['tid'], $summarylength)));
     }
     return array('html' => '', 'data' => $list);
 }