if (!$mlist) { exit('Invalid list identifier'); } $CREATE_NEW_USERS = $mlist->mlist_opt & 64; $FUD_OPT_2 |= $FUD_OPT_2 & ~(1024 | 8388608); $FUD_OPT_2 |= 128; $frm = db_sab('SELECT id, forum_opt, message_threshold, (max_attach_size * 1024) AS max_attach_size, max_file_attachments FROM ' . sql_p . 'forum WHERE id=' . $mlist->forum_id); $emsg = new fud_emsg(); $emsg->subject_cleanup_rgx = $mlist->subject_regex_haystack; $emsg->subject_cleanup_rep = $mlist->subject_regex_needle; $emsg->body_cleanup_rgx = $mlist->body_regex_haystack; $emsg->body_cleanup_rep = $mlist->body_regex_needle; $emsg->parse_input($mlist->mlist_opt & 16); $emsg->fetch_useful_headers(); $emsg->clean_up_data(); $msg_post = new fud_msg_edit(); // Handler for our own messages, which do not need to be imported. if (isset($emsg->headers['x-fudforum']) && preg_match('!([A-Za-z0-9]{32}) <([0-9]+)>!', $emsg->headers['x-fudforum'], $m)) { if ($m[1] == md5($GLOBALS['WWW_ROOT'])) { q("UPDATE " . sql_p . "msg SET mlist_msg_id='" . addslashes($emsg->msg_id) . "' WHERE id=" . intval($m[2]) . " AND mlist_msg_id IS NULL"); if (db_affected()) { exit; } } } $msg_post->body = apply_custom_replace($emsg->body); if (!($mlist->mlist_opt & 16)) { if ($frm->forum_opt & 16) { $msg_post->body = tags_to_html($msg_post->body, 0); } else { $msg_post->body = nl2br($msg_post->body);
function delete($rebuild_view = true, $mid = 0, $th_rm = 0) { if (!$mid) { $mid = $this->id; } if (!db_locked()) { db_lock('phpgw_fud_thr_exchange WRITE, phpgw_fud_thread_view WRITE, phpgw_fud_level WRITE, phpgw_fud_forum WRITE, phpgw_fud_forum_read WRITE, phpgw_fud_thread WRITE, phpgw_fud_msg WRITE, phpgw_fud_attach WRITE, phpgw_fud_poll WRITE, phpgw_fud_poll_opt WRITE, phpgw_fud_poll_opt_track WRITE, phpgw_fud_users WRITE, phpgw_fud_thread_notify WRITE, phpgw_fud_msg_report WRITE, phpgw_fud_thread_rate_track WRITE'); $ll = 1; } if (!($del = db_sab('SELECT phpgw_fud_msg.id, phpgw_fud_msg.attach_cnt, phpgw_fud_msg.poll_id, phpgw_fud_msg.thread_id, phpgw_fud_msg.reply_to, phpgw_fud_msg.apr, phpgw_fud_msg.poster_id, phpgw_fud_thread.replies, phpgw_fud_thread.root_msg_id AS root_msg_id, phpgw_fud_thread.last_post_id AS thread_lip, phpgw_fud_thread.forum_id, phpgw_fud_forum.last_post_id AS forum_lip FROM phpgw_fud_msg LEFT JOIN phpgw_fud_thread ON phpgw_fud_msg.thread_id=phpgw_fud_thread.id LEFT JOIN phpgw_fud_forum ON phpgw_fud_thread.forum_id=phpgw_fud_forum.id WHERE phpgw_fud_msg.id=' . $mid))) { if (isset($ll)) { db_unlock(); } return; } /* attachments */ if ($del->attach_cnt) { $res = q('SELECT location FROM phpgw_fud_attach WHERE message_id=' . $mid . " AND attach_opt=0"); while ($loc = db_rowarr($res)) { @unlink($loc[0]); } unset($res); q('DELETE FROM phpgw_fud_attach WHERE message_id=' . $mid . " AND attach_opt=0"); } q('DELETE FROM phpgw_fud_msg_report WHERE msg_id=' . $mid); if ($del->poll_id) { poll_delete($del->poll_id); } /* check if thread */ if ($del->root_msg_id == $del->id) { $th_rm = 1; /* delete all messages in the thread if there is more then 1 message */ if ($del->replies) { $rmsg = q('SELECT id FROM phpgw_fud_msg WHERE thread_id=' . $del->thread_id . ' AND id != ' . $del->id); while ($dim = db_rowarr($rmsg)) { fud_msg_edit::delete(false, $dim[0], 1); } unset($rmsg); } q('DELETE FROM phpgw_fud_thread_notify WHERE thread_id=' . $del->thread_id); q('DELETE FROM phpgw_fud_thread WHERE id=' . $del->thread_id); q('DELETE FROM phpgw_fud_thread_rate_track WHERE thread_id=' . $del->thread_id); q('DELETE FROM phpgw_fud_thr_exchange WHERE th=' . $del->thread_id); if ($del->apr) { /* we need to determine the last post id for the forum, it can be null */ $lpi = (int) q_singleval('SELECT phpgw_fud_thread.last_post_id FROM phpgw_fud_thread INNER JOIN phpgw_fud_msg ON phpgw_fud_thread.last_post_id=phpgw_fud_msg.id AND phpgw_fud_msg.apr=1 WHERE forum_id=' . $del->forum_id . ' AND moved_to=0 ORDER BY phpgw_fud_msg.post_stamp DESC LIMIT 1'); q('UPDATE phpgw_fud_forum SET last_post_id=' . $lpi . ', thread_count=thread_count-1, post_count=post_count-' . $del->replies . '-1 WHERE id=' . $del->forum_id); } } else { if (!$th_rm && $del->apr) { q('UPDATE phpgw_fud_msg SET reply_to=' . $del->reply_to . ' WHERE thread_id=' . $del->thread_id . ' AND reply_to=' . $mid); /* check if the message is the last in thread */ if ($del->thread_lip == $del->id) { list($lpi, $lpd) = db_saq('SELECT id, post_stamp FROM phpgw_fud_msg WHERE thread_id=' . $del->thread_id . ' AND apr=1 AND id!=' . $del->id . ' ORDER BY post_stamp DESC LIMIT 1'); q('UPDATE phpgw_fud_thread SET last_post_id=' . $lpi . ', last_post_date=' . $lpd . ', replies=replies-1 WHERE id=' . $del->thread_id); } else { q('UPDATE phpgw_fud_thread SET replies=replies-1 WHERE id=' . $del->thread_id); } /* check if the message is the last in the forum */ if ($del->forum_lip == $del->id) { $lp = db_saq('SELECT phpgw_fud_thread.last_post_id, phpgw_fud_thread.last_post_date FROM phpgw_fud_thread_view INNER JOIN phpgw_fud_thread ON phpgw_fud_thread_view.forum_id=phpgw_fud_thread.forum_id AND phpgw_fud_thread_view.thread_id=phpgw_fud_thread.id WHERE phpgw_fud_thread_view.forum_id=' . $del->forum_id . ' AND phpgw_fud_thread_view.page=1 AND phpgw_fud_thread.moved_to=0 ORDER BY phpgw_fud_thread.last_post_date DESC LIMIT 1'); if (!isset($lpd) || $lp[1] > $lpd) { $lpi = $lp[0]; } q('UPDATE phpgw_fud_forum SET post_count=post_count-1, last_post_id=' . $lpi . ' WHERE id=' . $del->forum_id); } else { q('UPDATE phpgw_fud_forum SET post_count=post_count-1 WHERE id=' . $del->forum_id); } } } q('DELETE FROM phpgw_fud_msg WHERE id=' . $mid); if ($del->apr) { if ($del->poster_id) { user_set_post_count($del->poster_id); } if ($rebuild_view) { rebuild_forum_view($del->forum_id); /* needed for moved thread pointers */ $r = q('SELECT forum_id, id FROM phpgw_fud_thread WHERE root_msg_id=' . $del->root_msg_id); while ($res = db_rowarr($r)) { if ($th_rm) { q('DELETE FROM phpgw_fud_thread WHERE id=' . $res[1]); } rebuild_forum_view($res[0]); } unset($r); } } if (isset($ll)) { db_unlock(); } }
echo $_POST['forumsel']; ?> "> <input type="submit" name="btn_conf" value="Yes"> <input type="submit" name="btn_cancel" value="No"> </form> </div> </body> </html> <?php exit; } else { db_lock($DBHOST_TBL_PREFIX . 'thr_exchange WRITE, ' . $DBHOST_TBL_PREFIX . 'thread_view WRITE, ' . $DBHOST_TBL_PREFIX . 'level WRITE, ' . $DBHOST_TBL_PREFIX . 'forum WRITE, ' . $DBHOST_TBL_PREFIX . 'forum_read WRITE, ' . $DBHOST_TBL_PREFIX . 'thread WRITE, ' . $DBHOST_TBL_PREFIX . 'msg WRITE, ' . $DBHOST_TBL_PREFIX . 'attach WRITE, ' . $DBHOST_TBL_PREFIX . 'poll WRITE, ' . $DBHOST_TBL_PREFIX . 'poll_opt WRITE, ' . $DBHOST_TBL_PREFIX . 'poll_opt_track WRITE, ' . $DBHOST_TBL_PREFIX . 'users WRITE, ' . $DBHOST_TBL_PREFIX . 'thread_notify WRITE, ' . $DBHOST_TBL_PREFIX . 'msg_report WRITE, ' . $DBHOST_TBL_PREFIX . 'thread_rate_track WRITE'); $c = q('SELECT root_msg_id, forum_id FROM ' . $DBHOST_TBL_PREFIX . 'thread WHERE last_post_date<' . $back . $lmt); while ($r = db_rowarr($c)) { fud_msg_edit::delete(false, $r[0], 1); $frm_list[$r[1]] = $r[1]; } unset($r); foreach ($frm_list as $v) { rebuild_forum_view($v); } db_unlock(); echo '<h2 color="red">It is highly recommended that you run a consitency checker after prunning.</h2>'; } } require $WWW_ROOT_DISK . 'adm/admpanel.php'; ?> <h2>Topic Prunning</h2> <form method="post" action="admprune.php"> <table class="datatable">