php2.04,加裝人氣指數。現在有需要把人氣指數加到memberlist裏麵以方便查詢。我自己的想法是脩改memberlist.php和memberlist.tpl這兩個文件應該就可以暸,但試暸很多次都不成功。
竹貓的人氣指數自身不是數據庫裏麵的變數,所以貼變數名沒用,隻能是粘貼全部的代碼進到memberlist.php裏麵去:
代碼: 選擇全部
// RPG Ranking Hack
if($postrow[$i]['user_id'] != ANONYMOUS )
{
$sql = "SELECT COUNT(topic_id) AS count_topics, " .
"SUM(topic_replies) AS sum_topic_replies, " .
"SUM(topic_views) AS sum_topic_views " .
"FROM " . TOPICS_TABLE . " " .
"WHERE topic_poster = " . $postrow[$i]['user_id'];
$result = $db->sql_query($sql);
$rr_row = $db->sql_fetchrow($result);
// 發表的主題總數
$count_topics = $rr_row['count_topics'];
// 所有主題的回應總數
$sum_topic_replies = $rr_row['sum_topic_replies'];
// 主題人氣(觀看數)
$sum_topic_views = $rr_row['sum_topic_views'];
$profiledata = get_userdata_from_id($postrow[$i]['user_id']);
// 發文總數
$sum_posts = $profiledata['user_posts'];
// 回應文章總數 = 發文總數 - 發表的主題總數
$count_replies = $sum_posts - $count_topics;
// 魅力值 = (發表的主題總數*100 + 所有主題的回應總數*5 + 回應文章總數*100 + 主題人氣(觀看數)) / ((發文總數+1)*100)
$rr_hack = ($count_topics * 100 + $sum_topic_replies * 5 + $count_replies * 100 + $sum_topic_views) / (($sum_posts+1)*100);
// 取小數點後一位
$rr_hack = "魅力值: " . sprintf("%01.2f", $rr_hack);
}
else
{
$rr_hack = "";
}?>[/php]


