Изтриване на постове наведнъж

Автор: SandPrince

Този урок е специално по молба на потребителя Shorter , но смятам че ще е полезен за всички чийто форуми са налазени от гадни спамери или ботове и са задръстени с излишни постове по темите.

Урока е много лесен.

## Време за инсталация: 5 min
## Файлове за редакция: 5
## language/lang_english/lang_main.php
## language/lang_german/lang_main.php
## templates/subSilver/subSilver.cfg
## modcp.php
## viewtopic.php
## Добавени файлове: 2
## modcp_multi_delete.tpl
## topic_multi_delete.gif

Като за начало ни трябва тази картинка и файл modcp_multi_delete.tpl
тъй като е само един файл направо ще ви дам кода за него тук:
modcp_multi_delete.tpl

<form method="post" action="{S_DELETE_ACTION}">
<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
<tr>
<td align="left" class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a><span class="nav">
-> <a href="{U_VIEW_FORUM}" class="nav">{FORUM_NAME}</a></span></td>
</tr>
</table>
<table width="100%" cellpadding="4" cellspacing="1" border="0" class="forumline">
<tr>
<th height="25" class="thHead" colspan="3" nowrap="nowrap">{L_DELETE_MULTIPLE_POSTS}</th>
</tr>
<tr>
<td class="row2" colspan="3" align="center"><span class="gensmall">{L_DELETE_MULTIPLE_POSTS_EXPLAIN}</span></td>
</tr>
<tr>
<th class="thLeft" nowrap="nowrap">{L_AUTHOR}</th>
<th nowrap="nowrap">{L_MESSAGE}</th>
<th class="thRight" nowrap="nowrap">{L_SELECT}</th>
</tr>
<!-- BEGIN postrow -->
<tr>
<td align="left" valign="top" class="{postrow.ROW_CLASS}"><span class="name"><a name="{postrow.U_POST_ID}"></a>{postrow.POSTER_NAME}</span></td>
<td width="100%" valign="top" class="{postrow.ROW_CLASS}">
<table width="100%" cellspacing="0" cellpadding="3" border="0">
<tr>
<td valign="middle"><img src="templates/subSilver/images/icon_minipost.gif" alt="{L_POST}"><span class="postdetails">{L_POSTED}:
{postrow.POST_DATE} {L_POST_SUBJECT}: {postrow.POST_SUBJECT}</span></td>
</tr>
<tr>
<td valign="top">
<hr size="1" />
<span class="postbody">{postrow.MESSAGE}</span></td>
</tr>
</table>
</td>
<td width="5%" align="center" class="{postrow.ROW_CLASS}">{postrow.S_DELETE_CHECKBOX}</td>
</tr>
<tr>
<td colspan="3" height="1" class="row3"><img src="templates/subSilver/images/spacer.gif" width="1" height="1" alt="."></td>
</tr>
<!-- END postrow -->
<tr>
<td class="catBottom" colspan="3" height="28">
<table width="60%" cellspacing="0" cellpadding="0" border="0" align="center">
<tr>
<td width="50%" align="center">
<input class="liteoption" type="submit" name="multiple_delete_beyond" value="{L_DELETE_MULTIPLE_POSTS}" />
{S_HIDDEN_FIELDS} </td>
</tr>
</table>
</td>
</tr>
</table>
<table width="100%" cellspacing="2" border="0" align="center" cellpadding="2">
<tr>
<td align="right" valign="top"><span class="gensmall">{S_TIMEZONE}</span></td>
</tr>
</table>
</form>

Така. Сега започваме обясненията.
Първо трябва да копирате файловете modcp_multi_delete.tpl и topic_multi_delete.gif в тези директории
templates/subSilver/modcp_multi_delete.tpl
templates/subSilver/images/topic_multi_delete.gif

Сега трябва и да промените някои файлове. следвайте инструкциите както трябва и няма да има проблеми

#-----[ ОТВОРЕТЕ ]------------------------------------------
#
modcp.php

#
#-----[ НАМЕРЕТЕ ]------------------------------------------
#
case 'split':

#
#-----[ ПРЕДИ ТОВА ДОБАВЕТЕ ]------------------------------------------
#
case 'multi_del':
$page_title = $lang['Mod_CP'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

$post_id_sql = '';

if (isset($HTTP_POST_VARS['multiple_delete_beyond']))
{
$posts = $HTTP_POST_VARS['post_id_list'];

for ($i = 0; $i < count($posts); $i++)
{
$post_id_sql .= (($post_id_sql != '') ? ', ' : '') . intval($posts[$i]);
}
}

if ($post_id_sql != '')
{
$sql = "DELETE FROM " . POSTS_TABLE . "
WHERE post_id IN ($post_id_sql)
AND forum_id = $forum_id";
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not delete post informations', '', __LINE__, __FILE__, $sql);
}

$sql = "DELETE FROM " . POSTS_TEXT_TABLE . "
WHERE post_id IN ($post_id_sql)";
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not delete post informations', '', __LINE__, __FILE__, $sql);
}

sync('topic', $topic_id);
sync('forum', $forum_id);

$template->assign_vars(array(
'META' => '<meta http-equiv="refresh" content="3;url=' . "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&sid=" . $userdata['session_id'] . '">')
);

$message = $lang['Multiple_posts_delete'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&sid=" . $userdata['session_id'] . '">', '</a>');
message_die(GENERAL_MESSAGE, $message);
}
else
{
//
// Set template files
//
$template->set_filenames(array(
'multiple_delete_body' => 'modcp_multi_delete.tpl')
);

$sql = "SELECT u.username, p.*, pt.post_text, pt.bbcode_uid, pt.post_subject, p.post_username
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
WHERE p.topic_id = $topic_id
AND p.poster_id = u.user_id
AND p.post_id = pt.post_id
ORDER BY p.post_time ASC";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not get topic/post information', '', __LINE__, __FILE__, $sql);
}

$s_hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" /><input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" /><input type="hidden" name="mode" value="multi_del" />';

if( ( $total_posts = $db->sql_numrows($result) ) > 0 )
{
$postrow = $db->sql_fetchrowset($result);

$template->assign_vars(array(
'L_DELETE_MULTIPLE_POSTS' => $lang['Delete_multiple_posts'],
'L_DELETE_MULTIPLE_POSTS_EXPLAIN' => $lang['Delete_multiple_posts_explain'],
'L_AUTHOR' => $lang['Author'],
'L_MESSAGE' => $lang['Message'],
'L_SELECT' => $lang['Select'],
'L_POSTED' => $lang['Posted'],
'L_SUBMIT' => $lang['Submit'],
'L_POST_SUBJECT' => $lang['Post_subject'],
'L_MARK_ALL' => $lang['Mark_all'],
'L_UNMARK_ALL' => $lang['Unmark_all'],
'L_POST' => $lang['Post'],

'FORUM_NAME' => $forum_name,

'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"),

'S_DELETE_ACTION' => append_sid("modcp.$phpEx"),
'S_HIDDEN_FIELDS' => $s_hidden_fields)
);

//
// Define censored word matches
//
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);

for($i = 0; $i < $total_posts; $i++)
{
$post_id = $postrow[$i]['post_id'];
$poster_id = $postrow[$i]['poster_id'];
$poster = $postrow[$i]['username'];

$post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']);

$bbcode_uid = $postrow[$i]['bbcode_uid'];
$message = $postrow[$i]['post_text'];
$post_subject = ( $postrow[$i]['post_subject'] != '' ) ? $postrow[$i]['post_subject'] : $topic_title;

//
// If the board has HTML off but the post has HTML
// on then we process it, else leave it alone
//
if ( !$board_config['allow_html'] )
{
if ( $postrow[$i]['enable_html'] )
{
$message = preg_replace('#(<)([\/]?.*?)(>)#is', '<\\2>', $message);
}
}

if ( $bbcode_uid != '' )
{
$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
}

if ( count($orig_word) )
{
$post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
$message = preg_replace($orig_word, $replacement_word, $message);
}

$message = make_clickable($message);

if ( $board_config['allow_smilies'] && $postrow[$i]['enable_smilies'] )
{
$message = smilies_pass($message);
}

$message = str_replace("\n", '<br />', $message);

$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

$checkbox = ( $i > 0 ) ? '<input type="checkbox" name="post_id_list[]" value="' . $post_id . '" />' : ' ';

$template->assign_block_vars('postrow', array(
'ROW_COLOR' => '#' . $row_color,
'ROW_CLASS' => $row_class,
'POSTER_NAME' => $poster,
'POST_DATE' => $post_date,
'POST_SUBJECT' => $post_subject,
'MESSAGE' => $message,
'POST_ID' => $post_id,

'S_DELETE_CHECKBOX' => $checkbox)
);
}

$template->pparse('multiple_delete_body');
}
}
break;

#
#-----[ ОТВОРЕТЕ ]------------------------------------------
#
viewtopic.php

#
#-----[ НАМЕРЕТЕ ]------------------------------------------
#
$topic_mod .= "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=delete&sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_delete'] . '" alt="' . $lang['Delete_topic'] . '" title="' . $lang['Delete_topic'] . '" border="0" /></a> ';

#
#-----[ СЛЕД ТОВА ДОБАВЕТЕ ]------------------------------------------
#
$topic_mod .= "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=multi_del&sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_multi_delete'] . '" alt="' . $lang['Delete_multiple_posts'] . '" title="' . $lang['Delete_multiple_posts'] . '" border="0" /></a> ';

#
#-----[ ОТВОРЕТЕ ]------------------------------------------
#
language/lang_english/lang_main.php

#
#-----[ НАМЕРЕТЕ ]------------------------------------------
#
$lang['Lookup_IP'] = 'Look up IP address';

#
#-----[ СЛЕД ТОВА ДОБАВЕТЕ ]------------------------------------------
#
$lang['Multiple_posts_delete'] = 'Posts deleted';
$lang['Delete_multiple_posts'] = 'Delete multiple posts';
$lang['Delete_multiple_posts_explain'] = 'From here you can delete multiple posts on one step. To do this mark the posts and click on the button at the bottom of the post list.';

#
#-----[ ОТОВОРЕТЕ ]------------------------------------------
#
language/lang_german/lang_main.php

#
#-----[ НАМЕРЕТЕ ]------------------------------------------
#
$lang['Lookup_IP'] = 'IP nachschlagen';

#
#-----[ СЛЕД ТОВА ДОБАВЕТЕ ]------------------------------------------
#
$lang['Multiple_posts_delete'] = 'Beitrдge gelцscht';
$lang['Delete_multiple_posts'] = 'Lцsche mehrere Beitrдge';
$lang['Delete_multiple_posts_explain'] = 'Hier kannst Du mehrere Beitrдge in einem Schritt lцschen. Markiere dazu die Beitrдge und klicke auf den Button unterhalb der Beitrageliste.';

#
#-----[ ОТВОРЕТЕ ]------------------------------------------
#
templates/subSilver/subSilver.cfg

#
#-----[ НАМЕРЕТЕ ]------------------------------------------
#
$images['topic_mod_delete'] = "$current_template_images/topic_delete.gif";

#
#-----[ СЛЕД ТОВА ДОБАВЕТЕ ]------------------------------------------
#
$images['topic_mod_multi_delete'] = "$current_template_images/topic_multi_delete.gif";


#
#-----[ СЪХРАНЕТЕ/ЗАТВОРЕТЕ ВСИЧКИ ФАЙЛОВЕ ]------------------------------------------

Това е! Не е чак толкоз трудно както видяхте.
Надявам се да съм бил полезен.

One Reply to “Изтриване на постове наведнъж”

Вашият коментар