query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.first_post_id, t.closed, p.posted, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); if (!$db->num_rows($result)) message($lang_common['Bad request']); $cur_post = $db->fetch_assoc($result); if ($pun_config['o_censoring'] == '1') $cur_post['subject'] = censor_words($cur_post['subject']); // Sort out who the moderators are and if we are currently a moderator (or an admin) $mods_array = ($cur_post['moderators'] != '') ? unserialize($cur_post['moderators']) : array(); $is_admmod = ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_moderator'] == '1' && array_key_exists($pun_user['username'], $mods_array))) ? true : false; $is_topic_post = ($id == $cur_post['first_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) { // 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 { // Delete just this one post delete_post($id, $cur_post['tid']); update_forum($cur_post['fid']); // Redirect towards the previous post $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$cur_post['tid'].' AND id < '.$id.' ORDER BY id DESC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); $post_id = $db->result($result); redirect('viewtopic.php?pid='.$post_id.'#p'.$post_id, $lang_delete['Post del redirect']); } } $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_delete['Delete post']); define ('PUN_ACTIVE_PAGE', 'index'); require PUN_ROOT.'header.php'; require PUN_ROOT.'include/parser.php'; $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']); ?>