本文整理汇总了PHP中strip_search_index函数的典型用法代码示例。如果您正苦于以下问题:PHP strip_search_index函数的具体用法?PHP strip_search_index怎么用?PHP strip_search_index使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strip_search_index函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_topic
}
//Update topics and forum if required
update_topic($new_topic_id);
if ($del_old_topic || $all_id) {
delete_topic($old_topic_id);
update_forum($old_fid);
// Update the forum FROM which the topic was moved
if ($new_forum) {
update_forum($new_fid);
}
// Update the forum FROM which the topic was moved
require PUN_ROOT . 'include/search_idx.php';
// Bit silly should be probably improved: in order to remove the subject from the old topic, we need:
// 1. remove all the words (message and subject) from the search tables
// 2. add the words from the message only in the search tables !!!
strip_search_index($post_id);
update_search_index('post', $post_id, $message);
} else {
update_topic($old_topic_id);
if ($new_forum) {
update_forum($old_fid);
// Update the forum FROM which the topic was moved
update_forum($new_fid);
// Update the forum TO which the topic was moved
}
}
redirect('viewtopic.php?pid=' . $post_id . '#p' . $post_id, $lang_movepost['Mark move redirect']);
} else {
//Count the topics to diplayed
$result = $db->query('SELECT count(id) FROM ' . $db->prefix . 'topics WHERE forum_id =' . $fid . ' AND moved_to IS NULL') or error('Unable to count topics in forum', __FILE__, __LINE__, $db->error());
$num_topics = $db->result($result);
示例2: delete_topics
public function delete_topics($topics, $fid)
{
global $lang_misc, $lang_common;
if (@preg_match('%[^0-9,]%', $topics)) {
message($lang_common['Bad request'], '404');
}
require FEATHER_ROOT . 'include/search_idx.php';
$topics_sql = explode(',', $topics);
// Verify that the topic IDs are valid
$result = DB::for_table('topics')->where_in('id', $topics_sql)->where('forum_id', $fid)->find_many();
if (count($result) != substr_count($topics, ',') + 1) {
message($lang_common['Bad request'], '404');
}
// Verify that the posts are not by admins
if ($this->user->g_id != FEATHER_ADMIN) {
$authorized = DB::for_table('posts')->where_in('topic_id', $topics_sql)->where('poster_id', get_admin_ids())->find_many();
if ($authorized) {
message($lang_common['No permission'], '403');
}
}
// Delete the topics
DB::for_table('topics')->where_in('id', $topics_sql)->delete_many();
// Delete any redirect topics
DB::for_table('topics')->where_in('moved_to', $topics_sql)->delete_many();
// Delete any subscriptions
DB::for_table('topic_subscriptions')->where_in('topic_id', $topics_sql)->delete_many();
// Create a list of the post IDs in this topic and then strip the search index
$find_ids = DB::for_table('posts')->select('id')->where_in('topic_id', $topics_sql)->find_many();
foreach ($find_ids as $id) {
$ids_post[] = $id['id'];
}
$post_ids = implode(', ', $ids_post);
// We have to check that we actually have a list of post IDs since we could be deleting just a redirect topic
if ($post_ids != '') {
strip_search_index($post_ids);
}
// Delete posts
DB::for_table('posts')->where_in('topic_id', $topics_sql)->delete_many();
update_forum($fid);
redirect(get_link('forum/' . $fid . '/'), $lang_misc['Delete topics redirect']);
}
示例3: delete_post
function delete_post($post_id, $topic_id, $forum_id)
{
global $forum_db, $db_type;
$return = ($hook = get_hook('fn_delete_post_start')) ? eval($hook) : null;
if ($return != null) {
return;
}
$query = array('SELECT' => 'p.id, p.poster, p.posted', 'FROM' => 'posts AS p', 'WHERE' => 'p.topic_id=' . $topic_id, 'ORDER BY' => 'p.id DESC', 'LIMIT' => '2');
($hook = get_hook('fn_qr_get_topic_lastposts_info')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
list($last_id, , ) = $forum_db->fetch_row($result);
list($second_last_id, $second_poster, $second_posted) = $forum_db->fetch_row($result);
// Delete the post
$query = array('DELETE' => 'posts', 'WHERE' => 'id=' . $post_id);
($hook = get_hook('fn_delete_post_qr_delete_post')) ? eval($hook) : null;
$forum_db->query_build($query) or error(__FILE__, __LINE__);
if (!defined('FORUM_SEARCH_IDX_FUNCTIONS_LOADED')) {
require FORUM_ROOT . 'include/search_idx.php';
}
strip_search_index($post_id);
// Count number of replies in the topic
$query = array('SELECT' => 'COUNT(p.id)', 'FROM' => 'posts AS p', 'WHERE' => 'p.topic_id=' . $topic_id);
($hook = get_hook('fn_qr_get_topic_reply_count2')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$num_replies = $forum_db->result($result) - 1;
// Update the topic now that a post has been deleted
$query = array('UPDATE' => 'topics', 'SET' => 'num_replies=' . $num_replies, 'WHERE' => 'id=' . $topic_id);
// If we deleted the most recent post, we need to sync up last post data as wel
if ($last_id == $post_id) {
$query['SET'] .= ', last_post=' . $second_posted . ', last_post_id=' . $second_last_id . ', last_poster=\'' . $forum_db->escape($second_poster) . '\'';
}
($hook = get_hook('fn_qr_update_topic2')) ? eval($hook) : null;
$forum_db->query_build($query) or error(__FILE__, __LINE__);
sync_forum($forum_id);
($hook = get_hook('fn_delete_post_end')) ? eval($hook) : null;
}
示例4: prune
function prune($forum_id, $prune_sticky, $prune_date)
{
global $db;
// Fetch topics to prune
$query = $db->select(array('id' => 't.id'), 'topics AS t');
$query->where = 't.forum_id = :forum_id';
$params = array(':forum_id' => $forum_id);
if ($prune_date != -1) {
$query->where .= ' AND t.last_post < :prune_date';
$params[':prune_date'] = $prune_date;
}
if (!$prune_sticky) {
$query->where .= ' AND t.sticky = 0';
}
$result = $query->run($params);
$topic_ids = array();
foreach ($result as $row) {
$topic_ids[] = $row['id'];
}
unset($query, $params, $result);
if (!empty($topic_ids)) {
// Fetch posts to prune
$query = $db->select(array('id' => 'p.id'), 'posts AS p');
$query->where = 'p.topic_id IN :topic_ids';
$params = array(':topic_ids' => $topic_ids);
$result = $query->run($params);
$post_ids = array();
foreach ($result as $row) {
$post_ids[] = $row['id'];
}
unset($query, $params, $result);
if (!empty($post_ids)) {
// Delete topics
$query = $db->delete('topics');
$query->where = 'id IN :topic_ids';
$params = array(':topic_ids' => $topic_ids);
$query->run($params);
unset($query, $params);
// Delete subscriptions
$query = $db->delete('topic_subscriptions');
$query->where = 'topic_id IN :topic_ids';
$params = array(':topic_ids' => $topic_ids);
$query->run($params);
unset($query, $params);
// Delete posts
$query = $db->delete('posts');
$query->where = 'id IN :post_ids';
$params = array(':post_ids' => $post_ids);
$query->run($params);
unset($query, $params);
// We removed a bunch of posts, so now we have to update the search index
require_once PUN_ROOT . 'include/search_idx.php';
strip_search_index($post_ids);
}
}
}
示例5: prune
function prune($forum_id, $prune_sticky, $prune_date)
{
global $forum_db, $db_type;
$return = ($hook = get_hook('ca_fn_prune_start')) ? eval($hook) : null;
if ($return != null) {
return;
}
// Fetch topics to prune
$query = array('SELECT' => 't.id', 'FROM' => 'topics AS t', 'WHERE' => 't.forum_id=' . $forum_id);
if ($prune_date != -1) {
$query['WHERE'] .= ' AND last_post<' . $prune_date;
}
if (!$prune_sticky) {
$query['WHERE'] .= ' AND sticky=\'0\'';
}
($hook = get_hook('ca_fn_prune_qr_get_topics_to_prune')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$topic_ids = array();
while ($row = $forum_db->fetch_row($result)) {
$topic_ids[] = $row[0];
}
if (!empty($topic_ids)) {
$topic_ids = implode(',', $topic_ids);
// Fetch posts to prune (used lated for updating the search index)
$query = array('SELECT' => 'p.id', 'FROM' => 'posts AS p', 'WHERE' => 'p.topic_id IN(' . $topic_ids . ')');
($hook = get_hook('ca_fn_prune_qr_get_posts_to_prune')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$post_ids = array();
while ($row = $forum_db->fetch_row($result)) {
$post_ids[] = $row[0];
}
// Delete topics
$query = array('DELETE' => 'topics', 'WHERE' => 'id IN(' . $topic_ids . ')');
($hook = get_hook('ca_fn_prune_qr_prune_topics')) ? eval($hook) : null;
$forum_db->query_build($query) or error(__FILE__, __LINE__);
// Delete posts
$query = array('DELETE' => 'posts', 'WHERE' => 'topic_id IN(' . $topic_ids . ')');
($hook = get_hook('ca_fn_prune_qr_prune_posts')) ? eval($hook) : null;
$forum_db->query_build($query) or error(__FILE__, __LINE__);
// Delete subscriptions
$query = array('DELETE' => 'subscriptions', 'WHERE' => 'topic_id IN(' . $topic_ids . ')');
($hook = get_hook('ca_fn_prune_qr_prune_subscriptions')) ? eval($hook) : null;
$forum_db->query_build($query) or error(__FILE__, __LINE__);
// We removed a bunch of posts, so now we have to update the search index
if (!defined('FORUM_SEARCH_IDX_FUNCTIONS_LOADED')) {
require FORUM_ROOT . 'include/search_idx.php';
}
strip_search_index($post_ids);
}
}
示例6: delete_post
function delete_post($post_id, $topic_id)
{
// Get Slim current session
$feather = \Slim\Slim::getInstance();
$result = \DB::for_table('posts')->select_many('id', 'poster', 'posted')->where('topic_id', $topic_id)->order_by_desc('id')->limit(2)->find_many();
$i = 0;
foreach ($result as $cur_result) {
if ($i == 0) {
$last_id = $cur_result['id'];
} else {
$second_last_id = $cur_result['id'];
$second_poster = $cur_result['poster'];
$second_posted = $cur_result['posted'];
}
++$i;
}
// Delete the post
\DB::for_table('posts')->where('id', $post_id)->find_one()->delete();
strip_search_index($post_id);
// Count number of replies in the topic
$num_replies = \DB::for_table('posts')->where('topic_id', $topic_id)->count() - 1;
// If the message we deleted is the most recent in the topic (at the end of the topic)
if ($last_id == $post_id) {
// If there is a $second_last_id there is more than 1 reply to the topic
if (isset($second_last_id)) {
$update_topic = array('last_post' => $second_posted, 'last_post_id' => $second_last_id, 'last_poster' => $second_poster, 'num_replies' => $num_replies);
\DB::for_table('topics')->where('id', $topic_id)->find_one()->set($update_topic)->save();
} else {
// We deleted the only reply, so now last_post/last_post_id/last_poster is posted/id/poster from the topic itself
\DB::for_table('topics')->where('id', $topic_id)->find_one()->set_expr('last_post', 'posted')->set_expr('last_post_id', 'id')->set_expr('last_poster', 'poster')->set('num_replies', $num_replies)->save();
}
} else {
// Otherwise we just decrement the reply counter
\DB::for_table('topics')->where('id', $topic_id)->find_one()->set('num_replies', $num_replies)->save();
}
}
示例7: delete_post
function delete_post($post_id, $topic_id)
{
global $db;
$result = $db->query('SELECT id, poster, posted FROM ' . $db->prefix . 'posts WHERE topic_id=' . $topic_id . ' ORDER BY id DESC LIMIT 2') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
list($last_id, , ) = $db->fetch_row($result);
list($second_last_id, $second_poster, $second_posted) = $db->fetch_row($result);
// Delete the post
$db->query('DELETE FROM ' . $db->prefix . 'posts WHERE id=' . $post_id) or error('Unable to delete post', __FILE__, __LINE__, $db->error());
strip_search_index($post_id);
// Count number of replies in the topic
$result = $db->query('SELECT COUNT(id) FROM ' . $db->prefix . 'posts WHERE topic_id=' . $topic_id) or error('Unable to fetch post count for topic', __FILE__, __LINE__, $db->error());
$num_replies = $db->result($result, 0) - 1;
// If the message we deleted is the most recent in the topic (at the end of the topic)
if ($last_id == $post_id) {
// If there is a $second_last_id there is more than 1 reply to the topic
if (!empty($second_last_id)) {
$db->query('UPDATE ' . $db->prefix . 'topics SET last_post=' . $second_posted . ', last_post_id=' . $second_last_id . ', last_poster=\'' . $db->escape($second_poster) . '\', num_replies=' . $num_replies . ' WHERE id=' . $topic_id) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
} else {
// We deleted the only reply, so now last_post/last_post_id/last_poster is posted/id/poster from the topic itself
$db->query('UPDATE ' . $db->prefix . 'topics SET last_post=posted, last_post_id=id, last_poster=poster, num_replies=' . $num_replies . ' WHERE id=' . $topic_id) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
}
} else {
// Otherwise we just decrement the reply counter
$db->query('UPDATE ' . $db->prefix . 'topics SET num_replies=' . $num_replies . ' WHERE id=' . $topic_id) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
}
}
示例8: prune
public function prune($forum_id, $prune_sticky, $prune_date)
{
// Fetch topics to prune
$topics_id = DB::for_table('topics')->select('id')->where('forum_id', $forum_id);
if ($prune_date != -1) {
$topics_id = $topics_id->where_lt('last_post', $prune_date);
}
if (!$prune_sticky) {
$topics_id = $topics_id->where('sticky', 0);
}
$topics_id = $topics_id->find_many();
$topic_ids = array();
foreach ($topics_id as $row) {
$topic_ids[] = $row['id'];
}
if (!empty($topic_ids)) {
// Fetch posts to prune
$posts_id = DB::for_table('posts')->select('id')->where_in('topic_id', $topic_ids)->find_many();
$post_ids = array();
foreach ($posts_id as $row) {
$post_ids[] = $row['id'];
}
if ($post_ids != '') {
// Delete topics
DB::for_table('topics')->where_in('id', $topic_ids)->delete_many();
// Delete subscriptions
DB::for_table('topic_subscriptions')->where_in('topic_id', $topic_ids)->delete_many();
// Delete posts
DB::for_table('posts')->where_in('id', $post_ids)->delete_many();
// We removed a bunch of posts, so now we have to update the search index
require_once FEATHER_ROOT . 'include/search_idx.php';
strip_search_index($post_ids);
}
}
}
示例9: delete_post
function delete_post($post_id, $topic_id)
{
global $db, $pun_user;
$result = $db->query('SELECT `id`, `poster`, `posted` FROM `' . $db->prefix . 'posts` WHERE `topic_id` = ' . $topic_id . ' ORDER BY `id` DESC LIMIT 2') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
list($last_id, $poster, ) = $db->fetch_row($result);
list($second_last_id, $second_poster, $second_posted) = $db->fetch_row($result);
// Delete the post
$db->query('DELETE FROM `' . $db->prefix . 'posts` WHERE `id` = ' . $post_id) or error('Unable to delete post', __FILE__, __LINE__, $db->error());
strip_search_index($post_id);
include PUN_ROOT . 'lang/' . $pun_user['language'] . '/fileup.php';
include_once PUN_ROOT . 'include/file_upload.php';
delete_post_attachments($post_id);
// Count number of replies in the topic
$result = $db->query('SELECT COUNT(1) FROM `' . $db->prefix . 'posts` WHERE `topic_id`=' . $topic_id) or error('Unable to fetch post count for topic', __FILE__, __LINE__, $db->error());
$num_replies = $db->result($result, 0) - 1;
// уменьшаем кол-во постов
$db->query('UPDATE `' . $db->prefix . 'users` SET `num_posts` = `num_posts` - 1 WHERE `username` = "' . $db->escape($poster) . '" LIMIT 1');
// If the message we deleted is the most recent in the topic (at the end of the topic)
if ($last_id == $post_id) {
// If there is a $second_last_id there is more than 1 reply to the topic
if ($second_last_id) {
$db->query('UPDATE `' . $db->prefix . 'topics` SET `last_post`=' . $second_posted . ', `last_post_id`=' . $second_last_id . ', `last_poster`=\'' . $db->escape($second_poster) . '\', `num_replies`=' . $num_replies . ' WHERE `id`=' . $topic_id) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
} else {
// We deleted the only reply, so now last_post/last_post_id/last_poster is posted/id/poster from the topic itself
$db->query('UPDATE `' . $db->prefix . 'topics` SET `last_post`=posted, `last_post_id`=id, `last_poster`=poster, `num_replies`=' . $num_replies . ' WHERE `id`=' . $topic_id) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
}
} else {
// Otherwise we just decrement the reply counter
$db->query('UPDATE `' . $db->prefix . 'topics` SET `num_replies`=' . $num_replies . ' WHERE `id`=' . $topic_id) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
}
}
示例10: prune
function prune($forum_id, $prune_sticky, $prune_date)
{
global $db;
$extra_sql = $prune_date != -1 ? ' AND last_post<' . $prune_date : '';
if (!$prune_sticky) {
$extra_sql .= ' AND sticky=\'0\'';
}
// Fetch topics to prune
$result = $db->query('SELECT id FROM ' . $db->prefix . 'topics WHERE forum_id=' . $forum_id . $extra_sql, true) or error('Unable to fetch topics', __FILE__, __LINE__, $db->error());
$topic_ids = '';
while ($row = $db->fetch_row($result)) {
$topic_ids .= ($topic_ids != '' ? ',' : '') . $row[0];
}
if ($topic_ids != '') {
// Fetch posts to prune
$result = $db->query('SELECT id FROM ' . $db->prefix . 'posts WHERE topic_id IN(' . $topic_ids . ')', true) or error('Unable to fetch posts', __FILE__, __LINE__, $db->error());
$post_ids = '';
while ($row = $db->fetch_row($result)) {
$post_ids .= ($post_ids != '' ? ',' : '') . $row[0];
}
if ($post_ids != '') {
// Delete topics
$db->query('DELETE FROM ' . $db->prefix . 'topics WHERE id IN(' . $topic_ids . ')') or error('Unable to prune topics', __FILE__, __LINE__, $db->error());
// Delete subscriptions
$db->query('DELETE FROM ' . $db->prefix . 'subscriptions WHERE topic_id IN(' . $topic_ids . ')') or error('Unable to prune subscriptions', __FILE__, __LINE__, $db->error());
// Delete posts
$db->query('DELETE FROM ' . $db->prefix . 'posts WHERE id IN(' . $post_ids . ')') or error('Unable to prune posts', __FILE__, __LINE__, $db->error());
// We removed a bunch of posts, so now we have to update the search index
require_once PUN_ROOT . 'include/search_idx.php';
strip_search_index($post_ids);
}
}
}
示例11: prune
function prune($forum_id, $prune_sticky, $prune_date)
{
global $db;
$data = array(':id' => $forum_id);
$where_cond = 'forum_id=:id';
if ($prune_date != -1) {
$where_cond .= ' And last_post<:last_post';
$data[':last_post'] = $prune_date;
}
if (!$prune_sticky) {
$where_cond .= ' AND sticky=0';
}
// Fetch topics to prune
$ps = $db->select('topics', 'id', $data, $where_cond);
$topic_ids = array();
foreach ($ps as $cur_topic) {
$topic_ids[] = $cur_topic['id'];
$placeholders[] = '?';
}
if (!empty($topic_ids)) {
// Fetch posts to prune
$ps = $db->run('SELECT id FROM ' . $db->prefix . 'posts WHERE topic_id IN(' . implode(',', $placeholders) . ')', $topic_ids);
$post_ids = array();
foreach ($ps as $cur_post) {
$markers[] = '?';
$post_ids[] = $cur_post['id'];
}
if ($post_ids != '') {
$db->run('DELETE FROM ' . $db->prefix . 'topics WHERE id IN(' . implode(',', $placeholders) . ')', $topic_ids);
$db->run('DELETE FROM ' . $db->prefix . 'topic_subscriptions WHERE topic_id IN(' . implode(',', $placeholders) . ')', $topic_ids);
$db->run('DELETE FROM ' . $db->prefix . 'posts WHERE id IN(' . implode(',', $markers) . ')', $post_ids);
// We removed a bunch of posts, so now we have to update the search index
require_once PANTHER_ROOT . 'include/search_idx.php';
strip_search_index($post_ids);
}
}
}
示例12: delete_post
function delete_post($post_id, $topic_id)
{
global $db;
$query = $db->select(array('id' => 'p.id', 'poster' => 'p.poster', 'posted' => 'p.posted'), 'posts AS p');
$query->where = 'p.topic_id = :topic_id';
$query->order = array('p.id DESC');
$query->limit = 2;
$params = array(':topic_id' => $topic_id);
$result = $query->run($params);
if (count($result) > 0) {
$last_id = $result[0]['id'];
}
if (count($result) > 1) {
list($second_last_id, $second_poster, $second_posted) = array($result[1]['id'], $result[1]['poster'], $result[1]['posted']);
} else {
list($second_last_id, $second_poster, $second_posted) = array('', '', '');
}
unset($query, $params, $result);
// Delete the post
$query = $db->delete('posts');
$query->where = 'id = :post_id';
$params = array(':post_id' => $post_id);
$query->run($params);
unset($query, $params);
strip_search_index($post_id);
// Count number of replies in the topic
$query = $db->select(array('post_count' => 'COUNT(p.id) AS post_count'), 'posts AS p');
$query->where = 'topic_id = :topic_id';
$params = array(':topic_id' => $topic_id);
$result = $query->run($params);
$num_replies = $result[0]['post_count'] - 1;
unset($query, $params, $result);
// If the message we deleted is the most recent in the topic (at the end of the topic)
if ($last_id == $post_id) {
// If there is a $second_last_id there is more than 1 reply to the topic
if (!empty($second_last_id)) {
$query = $db->update(array('last_post' => ':second_posted', 'last_post_id' => ':second_last_id', 'last_poster' => ':second_poster', 'num_replies' => ':num_replies'), 'topics');
$query->where = 'id = :topic_id';
$params = array(':second_posted' => $second_posted, ':second_last_id' => $second_last_id, ':second_poster' => $second_poster, ':num_replies' => $num_replies, ':topic_id' => $topic_id);
$query->run($params);
unset($query, $params);
} else {
// We deleted the only reply, so now last_post/last_post_id/last_poster is posted/id/poster from the topic itself
$query = $db->update(array('last_post' => 'posted', 'last_post_id' => 'id', 'last_poster' => 'poster', 'num_replies' => ':num_replies'), 'topics');
$query->where = 'id = :topic_id';
$params = array(':num_replies' => $num_replies, ':topic_id' => $topic_id);
$query->run($params);
unset($query, $params);
}
} else {
// Otherwise we just decrement the reply counter
$query = $db->update(array('num_replies' => ':num_replies'), 'topics');
$query->where = 'id = :topic_id';
$params = array(':num_replies' => $num_replies, ':topic_id' => $topic_id);
$query->run($params);
unset($query, $params);
}
}
示例13: IN
}
}
// Delete the threads and any redirect threads
$db->query('DELETE FROM ' . $db->prefix . 'threads WHERE id IN(' . $threads . ') OR moved_to IN(' . $threads . ')') or error('Unable to delete thread', __FILE__, __LINE__, $db->error());
// Delete any subscriptions
$db->query('DELETE FROM ' . $db->prefix . 'thread_subscriptions WHERE thread_id IN(' . $threads . ')') or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error());
// Create a list of the comment IDs in this thread and then strip the search index
$result = $db->query('SELECT id FROM ' . $db->prefix . 'comments WHERE thread_id IN(' . $threads . ')') or error('Unable to fetch comments', __FILE__, __LINE__, $db->error());
$comment_ids = '';
while ($row = $db->fetch_row($result)) {
$comment_ids .= $comment_ids != '' ? ',' . $row[0] : $row[0];
}
// We have to check that we actually have a list of comment IDs since we could be deleting just a redirect thread
if ($comment_ids != '') {
decrease_comment_counts($comment_ids);
strip_search_index($comment_ids);
}
// Delete comments
$db->query('DELETE FROM ' . $db->prefix . 'comments WHERE thread_id IN(' . $threads . ')') or error('Unable to delete comments', __FILE__, __LINE__, $db->error());
update_forum($fid);
redirect('viewforum.php?id=' . $fid);
}
$page_title = array(luna_htmlspecialchars($luna_config['o_board_title']), __('Admin', 'luna'), __('Moderate', 'luna'));
define('LUNA_ACTIVE_PAGE', 'admin');
require 'header.php';
load_admin_nav('content', 'moderate');
?>
<form method="post" action="moderate.php?fid=<?php
echo $fid;
?>
示例14: prune
function prune($forum_id, $prune_sticky, $prune_date)
{
global $db, $pun_user, $pun_config, $Poll;
// for included files
$extra_sql = $prune_date != -1 ? ' AND last_post<' . $prune_date : '';
if (!$prune_sticky) {
$extra_sql .= ' AND sticky=\'0\'';
}
// Fetch topics to prune
$result = $db->query('SELECT `id` FROM `' . $db->prefix . 'topics` WHERE `forum_id`=' . $forum_id . $extra_sql) or error('Unable to fetch topics', __FILE__, __LINE__, $db->error());
$topic_ids = null;
while ($row = $db->fetch_row($result)) {
$topic_ids .= ($topic_ids ? ',' : '') . $row[0];
}
if ($topic_ids) {
// Fetch posts to prune
$result = $db->query('SELECT `id` FROM `' . $db->prefix . 'posts` WHERE `topic_id` IN(' . $topic_ids . ')') or error('Unable to fetch posts', __FILE__, __LINE__, $db->error());
$post_ids = null;
while ($row = $db->fetch_row($result)) {
$post_ids .= ($post_ids ? ',' : '') . $row[0];
}
if ($post_ids) {
// hcs AJAX POLL MOD BEGIN
include_once PUN_ROOT . 'include/poll/poll.inc.php';
$Poll->deleteTopic($topic_ids);
// hcs AJAX POLL MOD END
// Delete topics
$db->query('DELETE FROM ' . $db->prefix . 'topics WHERE id IN(' . $topic_ids . ')') or error('Unable to prune topics', __FILE__, __LINE__, $db->error());
// Delete subscriptions
$db->query('DELETE FROM ' . $db->prefix . 'subscriptions WHERE topic_id IN(' . $topic_ids . ')') or error('Unable to prune subscriptions', __FILE__, __LINE__, $db->error());
// Delete posts
$db->query('DELETE FROM ' . $db->prefix . 'posts WHERE id IN(' . $post_ids . ')') or error('Unable to prune posts', __FILE__, __LINE__, $db->error());
// We removed a bunch of posts, so now we have to update the search index
include_once PUN_ROOT . 'include/search_idx.php';
strip_search_index($post_ids);
// Delete attachments
include PUN_ROOT . 'lang/' . $pun_user['language'] . '/fileup.php';
include_once PUN_ROOT . 'include/file_upload.php';
delete_post_attachments($post_ids);
}
}
}
示例15: delete_post
function delete_post($post_id, $topic_id)
{
global $db, $panther_config;
$topic_data = array(':id' => $topic_id);
$post_data = array(':id' => $post_id);
$ps = $db->select('posts', 'id, poster, posted', $topic_data, 'topic_id=:id AND approved=1 AND deleted=0', 'id DESC LIMIT 2');
list($last_id, , ) = $ps->fetch(PDO::FETCH_NUM);
list($second_last_id, $second_poster, $second_posted) = $ps->fetch(PDO::FETCH_NUM);
// Delete the post
attach_delete_post($post_id);
$update = array('deleted' => 1);
$db->update('posts', $update, 'id=:id', $post_data);
strip_search_index(array($post_id));
// Count number of replies in the topic
$ps = $db->select('posts', 'COUNT(id)', $topic_data, 'topic_id=:id AND approved=1 AND deleted=0');
$num_replies = $ps->fetchColumn() - 1;
// Decrement the deleted post
// If the message we deleted is the most recent in the topic (at the end of the topic)
if ($last_id == $post_id) {
// If there is a $second_last_id there is more than 1 reply to the topic
if (!empty($second_last_id)) {
$update = array('last_post' => $second_posted, 'last_post_id' => $second_last_id, 'last_poster' => $second_poster, 'num_replies' => $num_replies);
$data = array(':id' => $topic_id);
$db->update('topics', $update, 'id=:id', $data);
} else {
$data = array(':id' => $topic_id, ':num_replies' => $num_replies - 1);
// We deleted the only reply, so now last_post/last_post_id/last_poster is posted/id/poster from the topic itself
$db->run('UPDATE ' . $db->prefix . 'topics SET last_post=posted, last_post_id=id, last_poster=poster, num_replies=:num_replies WHERE id=:id', $data);
}
} else {
$update = array('num_replies' => $num_replies);
$db->update('topics', $update, 'id=:id', $topic_data);
}
if ($panther_config['o_delete_full'] == '1') {
permanently_delete_post($post_id);
}
}