[外掛]整合式 Top5

MODs Released by Other phpbb Sites
非官方認證通過之 MOD ,或許有安全性之疑慮,所有問題由原發表者回覆!

版主: 版主管理群

主題已鎖定
bu
版面管理員
版面管理員
文章: 443
註冊時間: 2003-02-23 12:46
來自: 25° 4′N 121° 29′E
聯繫:

[外掛]整合式 Top5

文章 bu »

這個是 TOP5(OOHOO 版) 2.1 整合加入 index 的改法,請參考 :mrgreen:

原作者: OOHOO 修改者: bu
這不是 V2 , V2 請按
適用版本: 2.0.6 or higher?

index.php
1.開 OPEN

代碼: 選擇全部

index.php
2.找到 FIND

代碼: 選擇全部

	//
	// Find which forums are visible for this user
	//
	$is_auth_ary = array();
	$is_auth_ary = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata, $forum_data);
3.在後面加入 AFTER, ADD

代碼: 選擇全部

	//
	// TOP5 MOD Begin Edit by bu MOD by OOHOO
	//

//
// Mod setting
//
// Topics text length
$MAX_STR_LEN = 60;
// Topics to display
$MAX_TOPICS = 5;
// 0 => users can see all topics including authorized issue(but they cant read the posts)
// 1 => users can see only authorized topics
$AUTH_SECRUITY = 1;

function cutStr($str) {

	global $MAX_STR_LEN;

	$str = (strlen($str) > $MAX_STR_LEN) ? (substr($str, 0, $MAX_STR_LEN - 1) . "...") : $str;
	return $str;
}
\r
// query
$sql = "SELECT topic_id, topic_title, topic_poster, topic_views, topic_replies, topic_last_post_id, f.forum_id, forum_name
	FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
	WHERE t.forum_id = f.forum_id
	AND topic_moved_id = '0'
	$auth_forums
	ORDER BY topic_last_post_id DESC LIMIT 0, $MAX_TOPICS";

if( !$result = $db->sql_query($sql) )
{
	echo '<p align="center"><font color="red"><b>ADV_TOPN_MOD TOPICS QUERY ERROR!!</b></font></p>';
	exit;
}

// fetch rows
while( $rows = $db->sql_fetchrow($result) )
{
	$topic_url = append_sid("viewtopic.$phpEx?t=" . $rows['topic_id']);
	$forum_url = append_sid("viewforum.$phpEx?f=" . $rows['forum_id']);

	$topic_poster = $rows['topic_poster'];
	$topic_last_post_id = $rows['topic_last_post_id'];

	// Grab topic poster and last replier data
	$sql = "SELECT post_username, user_id, username
		FROM " . POSTS_TABLE . ", " . USERS_TABLE . "
		WHERE topic_id = '" . $rows['topic_id'] . "'
		AND poster_id = user_id
		ORDER BY post_id LIMIT 0, 1";

	if( !$p_result = $db->sql_query($sql) )
	{
		message_die(GENERAL_MESSAGE, 'ADV_TOP5 MOD TOPIC_POSTER QUERY ERROR!!');
	}

	$p_row = $db->sql_fetchrow($p_result);

	$poster_name = ( $topic_poster != ANONYMOUS ) ? $p_row['username'] : ( !$p_row['post_username'] ? $lang['Guest'] : $p_row['post_username']);
	$poster_url = ( $topic_poster != ANONYMOUS && !$p_row['post_username'] ) ? ('<a href="' . append_sid("profile.$phpEx?mode=viewprofile&u=$topic_poster") . '" target="_top">' . "$poster_name</a>") : $poster_name;

	$sql = "SELECT post_username, user_id, username, post_time
		FROM " . POSTS_TABLE . ", " . USERS_TABLE . "
		WHERE post_id = '$topic_last_post_id'
		AND poster_id = user_id";

	if( !$r_result = $db->sql_query($sql) )
	{
		message_die(GENERAL_MESSAGE, 'ADV_TOP5 MOD LAST_REPLIER QUERY ERROR!!');
	}

	$r_row = $db->sql_fetchrow($r_result);

	$replier_id = $r_row['user_id'];
	$replier_name = ( $replier_id != ANONYMOUS ) ? $r_row['username'] : ( !$r_row['post_username'] ? $lang['Guest'] : $r_row['post_username']);
	$replier_url = ( $replier_id != ANONYMOUS && !$r_row['post_username'] ) ? ('<a href="' . append_sid("profile.$phpEx?mode=viewprofile&u=$replier_id") . '" target="_top">' . "$replier_name</a>") : $replier_name;

	$last_post_url = append_sid("viewtopic.$phpEx?p=$topic_last_post_id#$topic_last_post_id");

	$template->assign_block_vars("top5row", array(
		"forum_name" => $rows['forum_name'],
		"forum_url" => $forum_url,
		"topic" => cutStr($rows['topic_title']),
		"topic_url" => $topic_url,
		"topic_views" => $rows['topic_views'],
		"topic_replies" => $rows['topic_replies'],
		"post_time" => create_date($board_config['default_dateformat'], $r_row['post_time'], $board_config['board_timezone']),
		"poster_url" => $poster_url,
		"replier_url" => $replier_url,
		"last_post_url" => $last_post_url
	));
	}

	//
	// TOP5 MOD END Edit by bu
	//
3.找到 FIND

代碼: 選擇全部

		'NEWEST_USER' => sprintf($lang['Newest_user'], '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$newest_uid") . '">', 
4.在後面加入 AFTER, ADD

代碼: 選擇全部

		'icon_url' => $images['icon_latest_reply'], // TOP5
		'icon_alt' => $lang['View_latest_post'], // TOP5
   	    'L_AUTHOR' => $lang['Author'], // TOP5
5.存檔

index_body.tpl
1.打開

代碼: 選擇全部

index_body.tpl
2.在你所想要放的位置,加入

代碼: 選擇全部

<table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0" style="{background-color: white">
\n  <tr><td height="18" valign="top"><span class="nav">{nav_links}</span></td></tr>
  <tr>
    <td valign="top">
      <table width="100%" border="0" cellpadding="4" cellspacing="1" width="100%" class="forumline">
	<tr> 
	  <th align="center" class="thCornerL" width="20%"> {L_FORUM} </th>
	  <th align="center" class="thTop" width="40%"> {L_TOPICS} </th>
	  <th align="center" class="thTop" nowrap>  {L_AUTHOR}  </th>
	  <th align="center" class="thTop" nowrap> {L_REPLIES} </th>
	  <th align="center" class="thTop" nowrap> {L_VIEWS} </th>
	  <th align="center" class="thCornerR" nowrap> {L_LASTPOST} </th>
	</tr>
	<!-- BEGIN top5row -->
        <tr>
          <td class="row1" nowrap><span class="forumlink"><a href="{top5row.forum_url}" target="_top" class="forumlink">{top5row.forum_name}</a></span></td>       
          <td class="row2" nowrap><span class="topictitle"><a href="{top5row.topic_url}" target="_top" class="topictitle">{top5row.topic}</a></span></td>
          <td class="row1" align="center" nowrap><span class="name">{top5row.poster_url}</span></td>
          <td class="row2" align="center" nowrap><span class="postdetails">{top5row.topic_replies}</span></td>
          <td class="row1" align="center" nowrap><span class="postdetails">{top5row.topic_views}</span></td>
          <td class="row2" align="center" nowrap><span class="postdetails">{top5row.post_time}<br />{top5row.replier_url} <a href="{top5row.last_post_url}" target="_top"><img src="{icon_url}" border="0" alt="{icon_alt}" /></a></span></td>        
        </tr>
        <!-- END top5row -->
      </table>
    </td>  
  </tr>
</table>
3.存檔

完成啦 :mrgreen:
DEMO 站: kuloo.com
*譯文資料在phpBB 技術文件
bu.femto-size
*和我聯絡,請寄 or Google Talk 圖檔
*作品: Intergrated Toplist & Message Can
主題已鎖定

回到「非官方認證外掛」