예제 #1
0
 unset($data[0]);
 // Verify that the posts are not by admins
 if (!$panther_user['is_admin'] && $panther_user['g_mod_edit_admin_posts'] == '0') {
     $admins = get_admin_ids();
     for ($i = 0; $i < count($admins); $i++) {
         $markers_2[] = '?';
         $data_2[] = $admins[$i];
     }
     $select = array_merge($data_2, $data);
     $ps = $db->select('posts', 1, array_values($select), 'topic_id IN(' . $markers . ') AND poster_id IN(' . implode(',', $markers_2) . ')');
     if ($ps->rowCount()) {
         message($lang_common['No permission'], false, '403 Forbidden');
     }
 }
 foreach (array_values($data) as $tid) {
     attach_delete_thread($tid);
 }
 // Delete the topics and any redirect topics
 $delete = array_merge($data, $data);
 if ($panther_config['o_delete_full'] == '1') {
     $db->run('DELETE FROM ' . $db->prefix . 'topics WHERE id IN(' . $markers . ') OR moved_to IN(' . $markers . ')', array_values($delete));
 } else {
     $db->run('UPDATE ' . $db->prefix . 'topics SET deleted=1 WHERE id IN(' . $markers . ') OR moved_to IN(' . $markers . ')', array_values($delete));
 }
 // Delete any subscriptions
 $db->run('DELETE FROM ' . $db->prefix . 'topic_subscriptions WHERE topic_id IN(' . $markers . ')', array_values($data));
 // Create a list of the post IDs in this topic and then strip the search index
 $ps = $db->select('posts', 'id', array_values($data), 'topic_id IN(' . $markers . ')');
 $post_ids = array();
 foreach ($ps as $row) {
     $post_ids[] = $row['id'];
예제 #2
0
     message($lang_misc['No topics selected']);
 }
 if (isset($_POST['delete_topics_comply'])) {
     //confirm_referrer('moderate.php');
     if (@preg_match('/[^0-9,]/', $topics)) {
         message($lang_common['Bad request']);
     }
     require PUN_ROOT . 'include/search_idx.php';
     // Verify that the topic IDs are valid
     $result = $db->query('SELECT 1 FROM ' . $db->prefix . 'topics WHERE id IN(' . $topics . ') AND forum_id=' . $fid) or error('Unable to check topics', __FILE__, __LINE__, $db->error());
     if ($db->num_rows($result) != substr_count($topics, ',') + 1) {
         message($lang_common['Bad request']);
     }
     //Attachment Mod Block Start
     foreach (explode(',', $topics) as $value) {
         attach_delete_thread($value);
     }
     //Attachment Mod Block End
     // Delete the topics and any redirect topics
     $db->query('DELETE FROM ' . $db->prefix . 'topics WHERE id IN(' . $topics . ') OR moved_to IN(' . $topics . ')') or error('Unable to delete topic', __FILE__, __LINE__, $db->error());
     // Delete any subscriptions
     $db->query('DELETE FROM ' . $db->prefix . 'subscriptions WHERE topic_id IN(' . $topics . ')') or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error());
     // Create a list of the post ID's in this topic and then strip the search index
     $result = $db->query('SELECT id FROM ' . $db->prefix . 'posts WHERE topic_id IN(' . $topics . ')') or error('Unable to fetch posts', __FILE__, __LINE__, $db->error());
     $post_ids = '';
     while ($row = $db->fetch_row($result)) {
         $post_ids .= $post_ids != '' ? ',' . $row[0] : $row[0];
     }
     // We have to check that we actually have a list of post ID's since we could be deleting just a redirect topic
     if ($post_ids != '') {
         strip_search_index($post_ids);
예제 #3
0
$result = $db->query('SELECT id FROM ' . $db->prefix . 'posts WHERE topic_id=' . $cur_post['tid'] . ' ORDER BY posted LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
$topic_post_id = $db->result($result);
$is_topic_post = $id == $topic_post_id ? true : false;
// Do we have permission to edit this post?
if (($pun_user['g_delete_posts'] == '0' || $pun_user['g_delete_topics'] == '0' && $is_topic_post || $cur_post['poster_id'] != $pun_user['id'] || $cur_post['closed'] == '1') && !$is_admmod) {
    message($lang_common['No permission']);
}
// Load the delete.php language file
require PUN_ROOT . 'lang/' . $pun_user['language'] . '/delete.php';
if (isset($_POST['delete'])) {
    if ($is_admmod) {
        confirm_referrer('delete.php');
    }
    require PUN_ROOT . 'include/search_idx.php';
    if ($is_topic_post) {
        attach_delete_thread($cur_post['tid']);
        // Attachment Mod , delete the attachments in the whole thread (orphan check is checked in this function)		// Delete the topic and all of it's posts
        delete_topic($cur_post['tid']);
        update_forum($cur_post['fid']);
        redirect('viewforum.php?id=' . $cur_post['fid'], $lang_delete['Topic del redirect']);
    } else {
        attach_delete_post($id);
        // Attachment Mod , delete the attachments in this post (orphan check is checked in this function)
        // Delete just this one post
        delete_post($id, $cur_post['tid']);
        update_forum($cur_post['fid']);
        redirect('viewtopic.php?id=' . $cur_post['tid'], $lang_delete['Post del redirect']);
    }
}
$page_title = pun_htmlspecialchars($pun_config['o_board_title']) . ' / ' . $lang_delete['Delete post'];
require PUN_ROOT . 'header.php';
예제 #4
0
function delete_topic($topic_id)
{
    global $db, $panther_config;
    // Delete the topic and any redirect topics
    attach_delete_thread($topic_id);
    $data = array(':id' => $topic_id);
    $topic = array(':id' => $topic_id, ':moved_to' => $topic_id);
    $update = array('deleted' => 1);
    $post_ids = array();
    $db->update('topics', $update, 'id=:id OR moved_to=:moved_to', $topic);
    $db->delete('polls', 'topic_id=:id', $data);
    // Get all post IDs from this topic.
    $ps = $db->select('posts', 'id', $data, 'topic_id=:id');
    foreach ($ps as $cur_post) {
        $post_ids[] = $cur_post['id'];
    }
    // Make sure we have a list of post IDs
    if (!empty($post_ids)) {
        strip_search_index($post_ids);
        // Should be an array
        $db->update('posts', $update, 'topic_id=:id', $data);
    }
    if ($panther_config['o_delete_full'] == '1') {
        permanently_delete_topic($topic_id);
    }
}