1 頁 (共 1 頁)

[問題] ModCP Merge Hack

發表於 : 2004-03-01 16:43
alex20
一個關於主題/合併文章的 Mods

安裝後出現問題,亦己 search old posts

希望大家能夠解答

代碼: 選擇全部

######################################################## 
## Mod Title: ModCP Merge Hack 
## Mod Version: 1.0.1 
## Author: sickb0y < http://www.p2pitalia.com > 
## Description: This mod adds topics merge function 
## in moderator control panel. 
## 
## Installation Level: (intermediate) 
## Installation Time: 5-10 Minutes 
## Files To Edit: 4 
## Included Files: modcp_merge.tpl 
######################################################## 
## 
## Installation Notes: 
## 
## 
## Put modcp_merge.tpl in templates/xxx/ 
## 
######################################################## 


# 
#-----[ OPEN includes/functions_admin.php ]------------------- 
# 
# 
#-----[ FIND ]---------------------------------- 
# 
function make_forum_select($box_name, $ignore_forum = false, $select_forum = '') 
{ 
global $db, $userdata; 

$is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata); 

$sql = "SELECT forum_id, forum_name 
FROM " . FORUMS_TABLE . " 
ORDER BY cat_id, forum_order"; 
if ( !($result = $db->sql_query($sql)) ) 
{ 
message_die(GENERAL_ERROR, 'Couldn not obtain forums information', '', __LINE__, __FILE__, $sql); 
} 

$forum_list = ''; 
while( $row = $db->sql_fetchrow($result) ) 
{ 
if ( $is_auth_ary[$row['forum_id']]['auth_read'] && $ignore_forum != $row['forum_id'] ) 
{ 
$selected = ( $select_forum == $row['forum_id'] ) ? ' selected="selected"' : ''; 
$forum_list .= '<option value="' . $row['forum_id'] . '"' . $selected .'>' . $row['forum_name'] . '</option>'; 
} 
} 

$forum_list = ( $forum_list == '' ) ? '<option value="-1">-- ! No Forums ! --</option>' : '<select name="' . $box_name . '">' . $forum_list . '</select>'; 

return $forum_list; 
} 


# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
function make_topic_select($box_name, $forum_id) 
{ 
global $db, $userdata; 

$is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata); 

$sql = "SELECT topic_id, topic_title 
FROM " . TOPICS_TABLE . " 
WHERE forum_id = $forum_id 
ORDER BY topic_title"; 
if ( !($result = $db->sql_query($sql)) ) 
{ 
message_die(GENERAL_ERROR, 'Couldn not obtain topics information', '', __LINE__, __FILE__, $sql); 
} 

$topic_list = ''; 
while( $row = $db->sql_fetchrow($result) ) 
{ 
$topic_list .= '<option value="' . $row['topic_id'] . '">' . $row['topic_title'] . '</option>'; 
} 

$topic_list = ( $topic_list == '' ) ? '<option value="-1">-- ! No Topics ! --</option>' : '<select name="' . $box_name . '">' . $topic_list . '</select>'; 

return $topic_list; 
} 
# 
#-----[ CLOSE ]---------------------------------- 
# 



# 
#-----[ OPEN modcp.php ]------------------- 
# 
# 
#-----[ FIND ]---------------------------------- 
# 
else if ( $unlock ) 
{ 
$mode = 'unlock'; 
} 
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
else if ( $merge ) 
{ 
$mode = 'merge'; 
} 

# 
#-----[ FIND ]---------------------------------- 
# 
message_die(GENERAL_MESSAGE, $lang['Topics_Unlocked'] . '<br /><br />' . $message); 

break; 
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
case 'merge': 
$page_title = $lang['Mod_CP']; 
include($phpbb_root_path . 'includes/page_header.'.$phpEx); 

if ( $confirm ) 
{ 
if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) ) 
{ 
message_die(GENERAL_MESSAGE, $lang['None_selected']); 
} 

$new_topic_id = $HTTP_POST_VARS['new_topic']; 

for ($i=0; $i < count($topic_id_list); $i++) { 

$old_topic_id = $topic_id_list[$i]; 

if ( $new_topic_id != $old_topic_id ) 
{ 
$sql = "UPDATE " . POSTS_TABLE . " 
SET topic_id = $new_topic_id 
WHERE topic_id = $topic_id_list[$i]"; 

if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) ) 
{ 
message_die(GENERAL_ERROR, 'Could not update posts', '', __LINE__, __FILE__, $sql); 
} 

$sql = "DELETE FROM " . TOPICS_TABLE . " 
WHERE topic_id = $topic_id_list[$i]"; 

if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) ) 
{ 
message_die(GENERAL_ERROR, 'Could not update posts', '', __LINE__, __FILE__, $sql); 
} 

$sql = "DELETE FROM " . TOPICS_WATCH_TABLE . " 
WHERE topic_id = $topic_id_list[$i]"; 

if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) ) 
{ 
message_die(GENERAL_ERROR, 'Could not update posts', '', __LINE__, __FILE__, $sql); 
} 

// Sync the forum indexes 
sync('forum', $forum_id); 
sync('topic', $new_topic_id); 

$message = $lang['Topics_Moved'] . '<br /><br />'; 
} 
else 
{ 
$message = $lang['No_Topics_Moved'] . '<br /><br />'; 
} 

} 

if ( !empty($topic_id) ) 
{ 
$redirect_page = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id"); 
$message .= sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>'); 
} 
else 
{ 
$redirect_page = append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id"); 
$message .= sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>'); 
} 

$message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$old_forum_id") . '">', '</a>'); 

$template->assign_vars(array( 
'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">') 
); 

message_die(GENERAL_MESSAGE, $message); 
} 
else 
{ 
if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) ) 
{ 
message_die(GENERAL_MESSAGE, $lang['None_selected']); 
} 

$hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />'; 

if ( isset($HTTP_POST_VARS['topic_id_list']) ) 
{ 
$topics = $HTTP_POST_VARS['topic_id_list']; 

for($i = 0; $i < count($topics); $i++) 
{ 
$hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="' . intval($topics[$i]) . '" />'; 
} 
} 
else 
{ 
$hidden_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />'; 
} 

// 
// Set template files 
// 
$template->set_filenames(array( 
'mergetopic' => 'modcp_merge.tpl') 
); 

$template->assign_vars(array( 
'MESSAGE_TITLE' => $lang['Confirm'], 
'MESSAGE_TEXT' => $lang['Confirm_move_topic'], 

'L_MERGE_TOPIC' => $lang['Merge_topic'], 

'L_YES' => $lang['Yes'], 
'L_NO' => $lang['No'], 

'S_TOPIC_SELECT' => make_topic_select('new_topic', $forum_id), 
'S_MODCP_ACTION' => append_sid("modcp.$phpEx"), 
'S_HIDDEN_FIELDS' => $hidden_fields) 
); 

$template->pparse('mergetopic'); 

include($phpbb_root_path . 'includes/page_tail.'.$phpEx); 
} 
break; 

# 
#-----[ FIND ]---------------------------------- 
# 
'L_UNLOCK' => $lang['Unlock'], 
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
'L_MERGE' => $lang['Merge'], 
# 
#-----[ CLOSE ]---------------------------------- 
# 



# 
#-----[ OPEN language/lang_xxx/lang_main.php ]------------------- 
# 
# 
#-----[ FIND ]---------------------------------- 
# 
$lang['Unlock'] = "Unlock"; 
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
$lang['Merge'] = "Merge"; 
$lang['Merge_topic'] = "Merge to topic"; 
# 
#-----[ CLOSE ]---------------------------------- 
# 



# 
#-----[ OPEN templates/xxx/modcp_body.tpl ]------------------- 
# 
# 
#-----[ FIND ]---------------------------------- 
# 
  
<input type="submit" name="unlock" class="liteoption" value="{L_UNLOCK}" /> 
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
  
<input type="submit" name="merge" class="liteoption" value="{L_MERGE}" /> 
# 
#-----[ CLOSE ]---------------------------------- 
# 

# 
#----------------------------------------------- 
#
裝後出現 Invalid_session
http://forum.tvbdramas.net/modcp.php

PS: This forum is not owned by forumscity now

發表於 : 2004-03-01 17:11
godbless
還是不懂你到底發生啥問題的?

那我會建議拆掉,用另外兩種試試看,那兩種我都有裝過,都不會有問題,你用的這個我剛好沒裝過

http://phpbb-tw.net/phpbb/viewtopic.php?t=15915
http://phpbb-tw.net/phpbb/viewtopic.php?t=22300

發表於 : 2004-03-01 18:01
alex20
當我裝完後,一切都沒有問題


入到版面管理控制台後
剔了欲合併的文章後按合併\r
接着按確認

誰不知系统出現一般錯誤
Invalid_Session

發表於 : 2004-03-01 19:15
webspirit
把完整錯誤訊息po出來啊
不然大大們怎知如何幫你咧?

發表於 : 2004-03-01 21:41
alex20
I do not understand

發表於 : 2004-03-01 21:43
小竹子
出現問題卻不知道出現什麼問題?好矛盾的回答跟提問!

發表於 : 2004-03-01 21:55
alex20
完整錯誤訊息po

I do not understand this sentence

發表於 : 2004-03-01 21:59
alex20
godbless 寫:還是不懂你到底發生啥問題的?

那我會建議拆掉,用另外兩種試試看,那兩種我都有裝過,都不會有問題,你用的這個我剛好沒裝過

http://phpbb-tw.net/phpbb/viewtopic.php?t=15915
http://phpbb-tw.net/phpbb/viewtopic.php?t=22300
I have installed the Simple Merge Mods
Thanks

But I still want to know why

發表於 : 2004-03-01 22:10
godbless
http://www.phpbbhacks.com/viewhack.php?id=1189

原因很清楚!
因為1.0.1是針對2.0.3以前的版本來開發!

發表於 : 2004-03-01 23:56
webspirit
alex20 寫:完整錯誤訊息po

I do not understand this sentence
sorry
我早該知您非本國人\r
po就是post
您了解了嗎? ^^|||