[外掛]Latest Posts Mod 中文修正版

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

版主: 版主管理群

主題已鎖定
幻狼神威
竹貓忠實會員
竹貓忠實會員
文章: 389
註冊時間: 2002-10-29 01:54
來自: 薔薇幻境
聯繫:

[外掛]Latest Posts Mod 中文修正版

文章 幻狼神威 »

這個是應我站上會員的要求而做的外掛....... ^T63^
其實是從 Plus 1.1 中偷了部份的檔案改的

代碼: 選擇全部

latest.php 
language/your_language/lang_latest.php 
templates/your_templates/latest.tpl 
之前 Mac 北北在 Plus 版所做的修正,在非 2.0.4 的版本(包含Plus 1.0 & 1.1)上會有問題,舊版的phpBB會有功能失效,小狼有修改了格式和一些小 bug,適用於所有 2.X 的版本(包含Plus 1.0 & 1.1 小狼也測過了 :lol: )。

以下請存成l atest.php 放在你的 phpBB2 目錄下!

[php]<?php
/**********************************************************************************
########################################################
## Mod Title: Latest Post
## Mod Version: 0.1
## Author: Matt Slovig < matthias@slovig.de >
## Credits: Philip Mayer for the original phpBB 1.4x-Script I used
########################################################
**********************************************************************************/

define('IN_PHPBB', true);
$phpbb_root_path = "./";
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx);
include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_latest.' . $phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX, $board_config['session_length']);
init_userprefs($userdata);
//
// End session management
//

$page_title = $lang['latest_posts']; //fix by LERA
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

if (!isset($selorder)) $selorder = "las24";
if (!isset($nodays)) $nodays = 3;

$template->assign_vars(array(
"L_TOPIC" => $lang['Topic'],
"L_FORUM" => $lang['Forum'], //fix by LERA
"L_AUTHOR" => $lang['Author'], //fix by LERA
"L_POSTED" => $lang['Posted'], //fix by LERA
"L_MATCHES" => $lang['matches'],

"FORM_ACTION" => $PHP_SELF,
"L_LAS24_MSG" => $lang['last_24h'],
"L_TODAY_MSG" => $lang['today'],
"L_YESTR_MSG" => $lang['yesterday'],
"L_LWEEK_MSG" => $lang['last_week'],
"L_LADAY_MSG" => $lang['last_xdays'],

"L_SHOW" => $lang['show_posts'],
"L_SHOWING" => $lang['showing_posts'],
"L_DAYS" => $lang['day_posts'],
"L_LAST" => $lang['last_posts'],

"NODAYS" => $nodays,
"PAGE_NAME" => $lang['latest_posts'],

)
);

$template->set_filenames(array(
"body" => "latest.tpl")
);
// fix from_unixtime() by LERA
// SQLs:

$part1 = "
SELECT from_unixtime(p.post_time) as topic_time,
f.forum_name as forum_name,
f.forum_id as forum_id,
u.username as username,
p.poster_id as poster_id,
p.post_id as post_id,
t.topic_id as topic_id,
t.topic_title as topic_title
FROM ".TOPICS_TABLE." t,
".POSTS_TABLE." p
LEFT OUTER JOIN ".FORUMS_TABLE." f on p.forum_id = f.forum_id
LEFT OUTER JOIN ".USERS_TABLE." u on p.poster_id = u.user_id
WHERE p.post_id = t.topic_last_post_id and f.auth_view!=2 and ";

$part2 = " ORDER BY p.post_time desc";

$showdays = 86400 * $nodays;

$lastweeksql = $part1."UNIX_TIMESTAMP(NOW()) - p.post_time < 691200".$part2;
$yesterdaysql = $part1."FROM_UNIXTIME(p.post_time,'%Y%m%d') - FROM_UNIXTIME(unix_timestamp(NOW()),'%Y%m%d') = -1".$part2;
$todaysql = $part1."FROM_UNIXTIME(p.post_time,'%Y%m%d') - FROM_UNIXTIME(unix_timestamp(NOW()),'%Y%m%d') = 0".$part2;

$last24hsql = $part1."UNIX_TIMESTAMP(NOW()) - p.post_time < 86400".$part2;
$lastXdsql = $part1."UNIX_TIMESTAMP(NOW()) - p.post_time < $showdays".$part2;

switch ($selorder) {

case "las24" : $sql = $last24hsql; $template->assign_vars(array("MSG" => $lang['last_24h'])); break;
case "today" : $sql = $todaysql; $template->assign_vars(array("MSG" => $lang['today'])); break;
case "yestr" : $sql = $yesterdaysql; $template->assign_vars(array("MSG" => $lang['yesterday'])); break;
case "lweek" : $sql = $lastweeksql; $template->assign_vars(array("MSG" => $lang['last_week'])); break;
case "laday" : $sql = $lastXdsql; $template->assign_vars(array("MSG" => $lang['last_xdays1'].$nodays.$lang['last_xdays2'])); break;

}

$style = 0;

$result = $db->sql_query($sql)
or message_die(GENERAL_ERROR, "Couldn't retrieve data", "", __LINE__, __FILE__, $sql);
while( $row = $db->sql_fetchrow($result) ) {
$style++;
(!($style% 2) ) ? $class = 'row2' : $class= 'row1';
$template->assign_block_vars("posts", array(
"TOPIC_TITLE" => $row["topic_title"],
"TOPIC_TIME" => $row["topic_time"],
"TOPIC_URL" => "viewtopic.".$phpEx."?p=".$row["post_id"]."#".$row["post_id"],
"FORUM_NAME" => $row["forum_name"],
"FORUM_URL" => "viewforum.".$phpEx."?f=".$row["forum_id"],
"USERNAME" => $row["username"],
"USER_URL" => "profile.".$phpEx."?mode=viewprofile&u=".$row["poster_id"],
"POST_ID" => $row["post_id"],
"FORUM_ID" => $row["forum_id"],
"CLASS" => $class,
)
);
}

// all data ready, displaying...

$template->pparse("body");

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?>[/php]

以下請另存成 latest.tpl 丟進 template/your_template/ 裡面去!
[php]
<form name="form1" method="get" action="{FORM_ACTION}">
<table align="center" width="100%">
<tr>
<td class="maintitle">{L_MATCHES}</td>
</tr>
<tr>
<td class="genmed" align="center">
<p><br>{L_SHOWING} <strong>{MSG}</strong></p>
{L_SHOW}
[ <a href="{FORM_ACTION}?selorder=lweek">{L_LWEEK_MSG}</a> ]
[ <a href="{FORM_ACTION}?selorder=yestr">{L_YESTR_MSG}</a> ]
[ <a href="{FORM_ACTION}?selorder=las24">{L_LAS24_MSG}</a> ]
[ <a href="{FORM_ACTION}?selorder=today">{L_TODAY_MSG}</a> ]
[ {L_LAST}
<input type="text" name="nodays" size="2" value="{NODAYS}" maxlength="3" />
<input type="hidden" name="selorder" value="laday" />
<a href="javascript:document.form1.submit();">{L_DAYS}</a> ] <br>
</td>
</tr>
</table>
</form>

<table class="forumline" align="center" cellpadding="4" cellspacing="1" width="100%">

<tr>
<th align="center" width="50%">{L_TOPIC}</th>
<th align="center" width="20%">{L_FORUM}</th>
<th align="center" width="15%">{L_AUTHOR}</th>
<th align="center" width="15%">{L_POSTED}</th>
</tr>

<!-- BEGIN posts -->
<TR>
<TD class="{posts.CLASS}" ALIGN="left"><span class="genmed"><a href="{posts.TOPIC_URL}">{posts.TOPIC_TITLE}</a></span></TD>
<TD class="{posts.CLASS}" ALIGN="CENTER"><span class="genmed"><a href="{posts.FORUM_URL}">{posts.FORUM_NAME}</a></span></TD>
<TD class="{posts.CLASS}" ALIGN="CENTER"><span class="gensmall"><a href="{posts.USER_URL}">{posts.USERNAME}</a></span></TD>
<TD class="{posts.CLASS}" ALIGN="CENTER"><span class="gensmall">{posts.TOPIC_TIME}</span></TD>
</TR>
<!-- END posts -->
<tr>
<td class="cat" colspan="4"> </td>
</tr>
</table>
<br />[/php]

以下存成 lang_latest.php 丟進 language/your_language/ 裡面去!
[php]<?php
/***************************************************************************
* lang_admin.php [正體中文語系]
* -------------------
* begin : Thursday, March 13, 2003
* by : phpbb-tw 譯文組 phpBB-tw Team
* members 組員介紹 : http://phpbb-tw.net/phpbb/groupcp.php?g=13226
*
****************************************************************************/

//
// Format is same as lang_main
//

//
// Modules, this replaces the keys used
// in the modules[][] arrays in each module file
//

//
// Neueste Beitr輍e
//

$lang['latest_posts'] = "最近發表";
$lang['matches'] = "搜尋結果";
$lang['last_24h'] = "最後 24 小時";
$lang['today'] = "今天";
$lang['yesterday'] = "昨天";
$lang['last_week'] = "上週";
$lang['last_xdays1'] = "最後 ";
$lang['last_xdays2'] = " 天內";
$lang['show_posts'] = "顯示發表:";
$lang['showing_posts'] = "顯示:";
$lang['day_posts'] = "天內";
$lang['last_posts'] = "最後";
?>[/php]
以下為加入連結的部份

開啟 templates/your_template/index_body.tpl

尋找\r

代碼: 選擇全部

<!-- BEGIN switch_user_logged_in --> 
下面加入

代碼: 選擇全部

<a href="latest.php" ><span class="gensmall">檢視最後發表的文章</span></a><br /> 
[必看] phpBB 架站討論區發文規則與發問格式
學好phpBB的訣竅:
 1. 善用竹貓星球的搜尋功能,可以找到所有相似並解決的主題。
 2. 簡單清楚的把你的問題打在主題上,讓懂的人一看就能了解。
 3. 依照發文格式發文,能幫助大家比較容易的找出問題在那裡。
 4. 一時沒有回應不表示沒人理你,大家都需要一點思考的時間。
 5. 解決問題後請修改第一篇主題,並感謝曾經幫過你的高手們。


切記:PM並不能解決問題,版上發問可以集大家的意見,您的問題可能更快的被解決.....
   ↑蘿莉不在此限.......XD"
主題已鎖定

回到「非官方認證外掛」