function _cookData($data) { foreach ($data as $k => $v) { $v['url'] = 'read.php?tid=' . $v['tid']; $v['title'] = $v['subject']; $v['value'] = $v['postdate']; $v['image'] = ''; $v['forumname'] = getForumName($v['fid']); $v['forumurl'] = getForumUrl($v['fid']); $v['authorurl'] = 'u.php?uid=' . $v['authorid']; list($v['topictypename'], $v['topictypeurl']) = getTopicType($v['type'], $v['fid']); $v['addition'] = $v; $data[$k] = $v; } return $data; }
function _cookSubjectData($data) { $post = array(); $post['url'] = 'read.php?tid=' . $data['tid']; $post['authorurl'] = 'u.php?uid=' . $data['authorid']; $post['title'] = $data['subject']; $post['value'] = $data['postdate']; $post['image'] = ''; $post['forumname'] = getForumName($data['fid']); $post['forumurl'] = getForumUrl($data['fid']); list($post['topictypename'], $post['topictypeurl']) = getTopicType($data['type'], $data['fid']); $post['addition'] = $data; return $post; }
/** * get topped lists * $type must in array(1,2,3) * * @param int $type * @param int $fid * @param int $num * @param int $hour * @return array */ function topSubject($type, $fid = 0, $num = 0, $hour = 0) { global $timestamp; $toppedtype = array(1, 2, 3); !in_array($type, $toppedtype) && ($type = 0); $type = (int) $type; $num = (int) $num; $hour = (int) $hour; !$fid && ($fid = getCommonFid()); !$num && ($num = $this->cachenum); $time = $hour ? strlen($hour) == 10 ? $hour : $timestamp - intval($hour) * 3600 : 0; $sqladd = ''; $sqladd .= $time ? ' AND postdate>' . S::sqlEscape($time) : ''; $fid && ($sqladd .= " AND fid IN ({$fid}) "); $sqlTopped = implode(',', array(PW_THREADSPECIALSORT_TOP1, PW_THREADSPECIALSORT_TOP2, PW_THREADSPECIALSORT_TOP3)); eval("\$specialSort = PW_THREADSPECIALSORT_TOP{$type};"); $sqladd .= $type ? ' AND topped=' . S::sqlEscape($specialSort) : " AND topped IN({$sqlTopped})"; if ($this->reality == false) { $sql = "SELECT tid AS id,lastpost AS value FROM pw_threads WHERE ifcheck='1' {$sqladd} ORDER BY lastpost DESC " . S::sqlLimit($num); } else { $sql = "SELECT tid,fid,author,authorid,subject,type,postdate,hits,replies FROM pw_threads WHERE ifcheck='1' {$sqladd} ORDER BY lastpost DESC " . S::sqlLimit($num); } $posts = array(); $query = $this->db->query($sql); while ($rt = $this->db->fetch_array($query)) { $post = array(); $post['url'] = 'read.php?tid=' . $rt['tid']; $post['title'] = $rt['subject']; $post['value'] = $rt['postdate']; $post['image'] = ''; $post['forumname'] = getForumName($rt['fid']); $post['forumurl'] = getForumUrl($rt['fid']); list($post['topictypename'], $post['topictypeurl']) = getTopicType($rt['type'], $rt['fid']); $post['addition'] = $rt; $posts[] = $post; } return $posts; }