function getSubjectByTid($tid, $param) { global $db; $tid = (int) $tid; if (!$tid) { return false; } $thread = $db->get_one("SELECT tid,fid,author,authorid,subject,type,postdate,hits,replies FROM pw_threads WHERE tid=" . pwEscape($tid)); $thread['url'] = 'read.php?tid=' . $thread['tid']; $thread['title'] = $thread['subject']; $thread['titlealt'] = $thread['subject']; $thread['image'] = ''; $thread['forumname'] = getForumName($thread['fid']); $thread['forumurl'] = getForumUrl($thread['fid']); $temp = array(); foreach ($param as $key => $value) { $temp_2 = ''; if ($key == 'descrip') { $temp_2 = getDescripByTid($tid); } elseif ($key == 'image') { $temp[$key] = getImagesByTid($tid); continue; } elseif (array_key_exists($key, $thread)) { $temp_2 = $thread[$key]; } else { $temp_2 = ''; } $temp[$key] = PW_tplGetData::_analyseResultByParameter($temp_2, $value); } return $temp; }
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; }
/** * * 数据处理 * @param array $data * @return array */ function _cookData($data) { foreach ($data as $key => $value) { $v = array(); $v['url'] = 'read.php?tid=' . $value['tid']; $v['authorurl'] = 'u.php?uid=' . $value['authorid']; $v['title'] = $value['subject']; $v['forumname'] = getForumName($value['fid']); $v['forumurl'] = getForumUrl($value['fid']); $v['author'] = $value['anonymous'] ? '匿名' : $value['author']; $v['authorid'] = $value['authorid']; $v['postdate'] = $value['postdate']; $v['topictypename'] = $value['modelname']; $v['topictypeurl'] = 'thread.php?fid=' . $value['fid'] . '&modelid=' . $value['modelid']; $data[$key] = $v; } return $data; }
function getRelateDataByKey($key) { global $db; L::loadClass('tplgetdata', 'area', false); $tid = (int) $key; if (!$tid) { return array(); } $thread = $db->get_one("SELECT tid,fid,author,authorid,subject,type,postdate,hits,replies FROM pw_threads WHERE tid=" . S::sqlEscape($tid)); if (!$thread) { return array(); } $thread['url'] = $this->_getSubjectUrl($thread['tid']); $thread['title'] = $thread['subject']; $thread['titlealt'] = $thread['subject']; $thread['authorurl'] = 'u.php?uid=' . $thread['authorid']; $thread['image'] = $this->_getImagesByTid($tid); $thread['forumname'] = getForumName($thread['fid']); $thread['forumurl'] = getForumUrl($thread['fid']); $thread['descrip'] = getDescripByTid($tid); return $thread; }
/** * * 数据处理 * @param int $fid * @return */ function _cookData($data) { $attachsService = L::loadClass('attachs', 'forum'); foreach ($data as $k => $v) { $v['url'] = 'read.php?tid=' . $v['tid']; $v['title'] = $v['subject']; if (!$v['title']) { unset($data[$k]); continue; } $v['value'] = $v['postdate']; $v['hits'] = $v['hits'] ? $v['hits'] : 0; $v['totalnum'] = $v['totalnum'] ? $v['totalnum'] : 0; $v['collectnum'] = $v['collectnum'] ? $v['collectnum'] : 0; $temp = geturl($v['cover'], 'show'); $v['image'] = $temp[0] ? $temp[0] : $GLOBALS['imgpath'] . '/imgdel_h200.jpg'; $v['forumname'] = getForumName($v['fid']); $v['forumurl'] = getForumUrl($v['fid']); $v['authorurl'] = 'u.php?uid=' . $v['authorid']; $v['addition'] = $v; $data[$k] = $v; } return $data; }
!defined('P_W') && exit('Forbidden'); define('AJAX', 1); InitGP(array('tid', 'block_id')); $tid = (int) $tid; if (!$tid) { exit; } $thread = $db->get_one("SELECT tid,fid,author,authorid,subject,type,postdate,hits,replies FROM pw_threads WHERE tid=" . pwEscape($tid)); $temp = array(); if ($thread) { $temp = array(); $temp['url'] = 'read.php?tid=' . $thread['tid']; $temp['title'] = $thread['subject']; $temp['image'] = ''; $temp['forumname'] = getForumName($thread['fid']); $temp['forumurl'] = getForumUrl($thread['fid']); $temp['descrip'] = getDescripByTid($tid); // $block = $stopic_service->getBlockById($block_id); // foreach ($block['config'] as $value) { // if ($value == 'descrip') { // $temp[$value] = getDescripByTid($tid); // } elseif (array_key_exists($value,$thread)) { // $temp[$value] = $thread[$value]; // } else { // $temp[$value] = ''; // } // } $temp = pwJsonEncode($temp); echo "success\t" . $temp; } else { echo "error";
/** * 热门点击排行 * * @param string $type * @param string $fid * @param int $num * @param int $special * @return array */ function hitSortInterface($type = 'hitsort', $fid = 0, $num = 0, $special = 0) { !$type && ($type = 'hitsort'); !in_array($type, array('hitsort', 'hitsortday', 'hitsortweek')) && Showmsg('undefined_action'); $num = intval($num) ? intval($num) : $this->defaultnum; !$fid && ($fid = getCommonFid()); if ($type == 'hitsort' && $this->ifpwcache & 16 || $type == 'hitsortday' && $this->ifpwcache & 32 || $type == 'hitsortweek' && $this->ifpwcache & 64) { $sqladd = ''; $sort = array(); $fid && ($sqladd .= " AND e.mark IN ({$fid}) "); $query = $this->db->query("SELECT t.tid,t.fid,t.author,t.authorid,t.subject,t.type,t.postdate,t.hits,t.replies FROM pw_elements e LEFT JOIN pw_threads t ON e.id=t.tid WHERE e.type=" . pwEscape($type) . " {$sqladd} ORDER BY e.value DESC " . pwLimit($num)); while ($rt = $this->db->fetch_array($query)) { $post = array(); $post['url'] = 'read.php?tid=' . $rt['tid']; $post['title'] = $rt['subject']; $post['value'] = $rt['hits']; $post['image'] = ''; $post['forumname'] = getForumName($rt['fid']); $post['forumurl'] = getForumUrl($rt['fid']); $post['addition'] = $rt; $sort[] = $post; } } else { $info = $this->singLeton(true, $num); switch ($type) { case 'hitsort': $time = 0; break; case 'hitsortday': $time = 24; break; case 'hitsortweek': $time = 7 * 24; break; default: $time = 0; } $sort = $info->getPostList('hitsort', $fid, $info->cachenum, $time); } return $sort; }
/** * * 数据处理 * @param array $data * @return array */ function _cookData($data) { foreach ($data as $key => $value) { $v = array(); $v['url'] = 'read.php?tid=' . $value['tid']; $v['title'] = $value['subject']; $v['forumname'] = getForumName($value['fid']); $v['forumurl'] = getForumUrl($value['fid']); $v['author'] = $value['anonymous'] ? '匿名' : $value['author']; $v['authorid'] = $value['authorid']; $v['authorurl'] = 'u.php?uid=' . $v['authorid']; for ($i = 1; $i < 6; $i++) { if ($value['picture' . $i]) { $temp = geturl($value['picture' . $i]); break; } } $v['image'] = $temp[0] ? $temp[0] : ''; $v['postdate'] = $value['postdate']; $v['topictypename'] = $value['modelname']; $v['topictypeurl'] = 'thread.php?fid=' . $value['fid'] . '&actmid=' . $value['actmid']; $v['starttime'] = get_date($value['starttime'], 'Y-m-d'); $v['endtime'] = get_date($value['endtime'], 'Y-m-d'); $data[$key] = $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 new attachs * $type must in array('img','txt','zip') * @param int $type * @param int $fid * @param int $num * @param int $hour * @return array */ function newAttach($type, $fid = 0, $num = 0, $hour = 0) { require_once R_P . 'require/bbscode.php'; global $timestamp, $db_ftpweb, $attachpath; $attachtype = array('img', 'txt', 'zip'); if (!in_array($type, $attachtype)) { return false; } $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 a.uploadtime>' . S::sqlEscape($time) : ''; $fid && ($sqladd .= " AND a.fid IN ({$fid}) "); if ($this->reality == false) { $sql = "SELECT a.tid as id,a.aid AS value,a.attachurl AS addition,a.ifthumb as special FROM pw_attachs a LEFT JOIN pw_threads t ON a.tid=t.tid WHERE a.type=" . S::sqlEscape($type, 1) . " AND a.pid=0 AND a.needrvrc=0 AND t.ifcheck='1' {$sqladd} GROUP BY a.tid ORDER BY a.aid DESC " . S::sqlLimit($num); } else { $sql = "SELECT a.tid,a.attachurl,t.author,t.authorid,t.subject,a.ifthumb FROM pw_attachs a LEFT JOIN pw_threads t ON a.tid=t.tid WHERE a.type=" . S::sqlEscape($type, 1) . " AND a.pid=0 AND a.needrvrc=0 AND t.ifcheck='1' {$sqladd} ORDER BY a.aid DESC " . S::sqlLimit($num); } $attachs = array(); $query = $this->db->query($sql); while ($attach = $this->db->fetch_array($query)) { $tid = $attach['tid'] ? $attach['tid'] : $attach['id']; $pw_tmsgs = GetTtable($tid); $content = $this->db->get_value("SELECT content FROM {$pw_tmsgs} WHERE tid=" . S::sqlEscape($tid)); $atc_content = substrs(stripWindCode($content), 30); if ($this->reality == true) { $tem = array(); $tem['url'] = 'read.php?tid=' . $attach['tid']; $tem['title'] = $attach['subject']; $tem['value'] = $atc_content; $tem['image'] = $this->_getImageUrl($attach['attachurl'], $attach['ifthumb']); $tem['forumname'] = getForumName($attach['fid']); $tem['forumurl'] = getForumUrl($attach['fid']); $tem['addition'] = $attach; $attachs[] = $tem; } else { if ($attachs[$attach['id']]) { continue; } $additions = array('0' => $attach['addition'], '1' => $atc_content); $addition = addslashes(serialize($additions)); $attach['addition'] = $addition; $attachs[$attach['id']] = $attach; } } return $attachs; }
/** * 获取主题的主题分类名称及url * @param $type * @param $fid * @return array */ function getTopicType($type, $fid) { $foruminfo = L::forum($fid); $topic_type = isset($foruminfo['topictype'][$type]) ? $foruminfo['topictype'][$type] : array(); return $topic_type ? array($topic_type['name'], getForumUrl($fid) . '&type=' . $type) : array('', ''); }