本文整理汇总了PHP中delete_posts函数的典型用法代码示例。如果您正苦于以下问题:PHP delete_posts函数的具体用法?PHP delete_posts怎么用?PHP delete_posts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete_posts函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: disapprove_post
/**
* Disapprove Post/Topic
*/
function disapprove_post($post_id_list, $mode)
{
global $db, $template, $user, $config;
global $phpEx, $phpbb_root_path;
if (!($forum_id = check_ids($post_id_list, POSTS_TABLE, 'post_id', 'm_approve'))) {
trigger_error('NOT_AUTHORIZED');
}
$redirect = request_var('redirect', build_url(array('t', 'mode')) . '&mode=unapproved_topics');
$reason = request_var('reason', '', true);
$reason_id = request_var('reason_id', 0);
$success_msg = $additional_msg = '';
$s_hidden_fields = build_hidden_fields(array('i' => 'queue', 'mode' => $mode, 'post_id_list' => $post_id_list, 'f' => $forum_id, 'action' => 'disapprove', 'redirect' => $redirect));
$notify_poster = isset($_REQUEST['notify_poster']) ? true : false;
$disapprove_reason = '';
if ($reason_id) {
$sql = 'SELECT reason_title, reason_description
FROM ' . REPORTS_REASONS_TABLE . "\n\t\t\tWHERE reason_id = {$reason_id}";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$row || !$reason && $row['reason_title'] == 'other') {
$additional_msg = $user->lang['NO_REASON_DISAPPROVAL'];
unset($_POST['confirm']);
} else {
// If the reason is defined within the language file, we will use the localized version, else just use the database entry...
$disapprove_reason = $row['reason_title'] != 'other' ? isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]) ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])] : $row['reason_description'] : '';
$disapprove_reason .= $reason ? "\n\n" . $reason : '';
}
}
if (confirm_box(true)) {
$post_info = get_post_data($post_id_list, 'm_approve');
// If Topic -> forum_topics_real -= 1
// If Post -> topic_replies_real -= 1
$forum_topics_real = 0;
$topic_replies_real_sql = $post_disapprove_sql = $topic_id_list = array();
foreach ($post_info as $post_id => $post_data) {
$topic_id_list[$post_data['topic_id']] = 1;
// Topic or Post. ;)
if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id) {
if ($post_data['forum_id']) {
$forum_topics_real++;
}
} else {
if (!isset($topic_replies_real_sql[$post_data['topic_id']])) {
$topic_replies_real_sql[$post_data['topic_id']] = 1;
} else {
$topic_replies_real_sql[$post_data['topic_id']]++;
}
}
$post_disapprove_sql[] = $post_id;
}
if ($forum_topics_real) {
$sql = 'UPDATE ' . FORUMS_TABLE . "\n\t\t\t\tSET forum_topics_real = forum_topics_real - {$forum_topics_real}\n\t\t\t\tWHERE forum_id = {$forum_id}";
$db->sql_query($sql);
}
if (sizeof($topic_replies_real_sql)) {
foreach ($topic_replies_real_sql as $topic_id => $num_replies) {
$sql = 'UPDATE ' . TOPICS_TABLE . "\n\t\t\t\t\tSET topic_replies_real = topic_replies_real - {$num_replies}\n\t\t\t\t\tWHERE topic_id = {$topic_id}";
$db->sql_query($sql);
}
}
if (sizeof($post_disapprove_sql)) {
if (!function_exists('delete_posts')) {
include_once $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
}
// We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts
delete_posts('post_id', $post_disapprove_sql);
}
unset($post_disapprove_sql, $topic_replies_real_sql);
update_post_information('topic', array_keys($topic_id_list));
update_post_information('forum', $forum_id);
unset($topic_id_list);
$messenger = new messenger();
// Notify Poster?
if ($notify_poster) {
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
foreach ($post_info as $post_id => $post_data) {
if ($post_data['poster_id'] == ANONYMOUS) {
continue;
}
$email_template = $post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id'] ? 'topic_disapproved' : 'post_disapproved';
$messenger->template($email_template, $post_data['user_lang']);
$messenger->replyto($config['board_email']);
$messenger->to($post_data['user_email'], $post_data['username']);
$messenger->im($post_data['user_jabber'], $post_data['username']);
$messenger->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'USERNAME' => html_entity_decode($post_data['username']), 'REASON' => html_entity_decode($disapprove_reason), 'POST_SUBJECT' => html_entity_decode(censor_text($post_data['post_subject'])), 'TOPIC_TITLE' => html_entity_decode(censor_text($post_data['topic_title']))));
$messenger->send($post_data['user_notify_type']);
$messenger->reset();
}
$messenger->save_queue();
}
unset($post_info, $disapprove_reason);
if ($forum_topics_real) {
$success_msg = $forum_topics_real == 1 ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS';
} else {
$success_msg = sizeof($post_id_list) == 1 ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS';
}
//.........这里部分代码省略.........
示例2: main
//.........这里部分代码省略.........
}
$message = $user_row['user_type'] == USER_INACTIVE ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED';
$log = $user_row['user_type'] == USER_INACTIVE ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE';
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, $log, false, array($user_row['username']));
$phpbb_log->add('user', $user->data['user_id'], $user->ip, $log . '_USER', false, array('reportee_id' => $user_id));
trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&u=' . $user_id));
break;
case 'delsig':
if (!check_form_key($form_name)) {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
$sql_ary = array('user_sig' => '', 'user_sig_bbcode_uid' => '', 'user_sig_bbcode_bitfield' => '');
$sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}";
$db->sql_query($sql);
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_SIG', false, array($user_row['username']));
$phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_SIG_USER', false, array('reportee_id' => $user_id));
trigger_error($user->lang['USER_ADMIN_SIG_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
break;
case 'delavatar':
if (!check_form_key($form_name)) {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
// Delete old avatar if present
/* @var $phpbb_avatar_manager \phpbb\avatar\manager */
$phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
$phpbb_avatar_manager->handle_avatar_delete($db, $user, $phpbb_avatar_manager->clean_row($user_row, 'user'), USERS_TABLE, 'user_');
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_AVATAR', false, array($user_row['username']));
$phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_AVATAR_USER', false, array('reportee_id' => $user_id));
trigger_error($user->lang['USER_ADMIN_AVATAR_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
break;
case 'delposts':
if (confirm_box(true)) {
// Delete posts, attachments, etc.
delete_posts('poster_id', $user_id);
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_POSTS', false, array($user_row['username']));
trigger_error($user->lang['USER_POSTS_DELETED'] . adm_back_link($this->u_action . '&u=' . $user_id));
} else {
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true)));
}
break;
case 'delattach':
if (confirm_box(true)) {
/** @var \phpbb\attachment\manager $attachment_manager */
$attachment_manager = $phpbb_container->get('attachment.manager');
$attachment_manager->delete('user', $user_id);
unset($attachment_manager);
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_DEL_ATTACH', false, array($user_row['username']));
trigger_error($user->lang['USER_ATTACHMENTS_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
} else {
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true)));
}
break;
case 'deloutbox':
if (confirm_box(true)) {
$msg_ids = array();
$lang = 'EMPTY';
$sql = 'SELECT msg_id
FROM ' . PRIVMSGS_TO_TABLE . "\n\t\t\t\t\t\t\t\t\tWHERE author_id = {$user_id}\n\t\t\t\t\t\t\t\t\t\tAND folder_id = " . PRIVMSGS_OUTBOX;
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) {
if (!function_exists('delete_pm')) {
include $phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx;
}
do {
$msg_ids[] = (int) $row['msg_id'];
} while ($row = $db->sql_fetchrow($result));
示例3: run_tool
/**
* Perform the right actions
* @param Array $error An array that will be filled with error messages that might occure
* @return void
*/
function run_tool(&$error)
{
global $db, $user;
$user->add_lang('ucp');
if (!check_form_key('orphaned_posts')) {
$error[] = 'FORM_INVALID';
return;
}
$mode = request_var('mode', '');
switch ($mode) {
case 'empty_topics':
case 'orphaned_shadows':
$topic_ids = request_var('topics', array(0 => 0));
if (!sizeof($topic_ids)) {
trigger_error('NO_TOPICS_SELECTED');
}
if (!function_exists('delete_topics')) {
include $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
}
$return = delete_topics('topic_id', $topic_ids);
trigger_error(sprintf($user->lang['TOPICS_DELETED'], $return['topics']));
break;
case 'forum_orphaned_posts':
// No break
// No break
case 'orphaned_posts':
if (isset($_POST['reassign'])) {
$post_map = request_var('posts', array(0 => 0));
foreach ($post_map as $post_id => $topic_id) {
if ($topic_id == 0) {
unset($post_map[$post_id]);
}
}
if (!sizeof($post_map)) {
trigger_error('NO_TOPIC_IDS');
}
// Make sure the specified topic IDs exist
$topic_ids = array_values($post_map);
$sql = 'SELECT topic_id, forum_id FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
$result = $db->sql_query($sql);
$existing_topics = array();
while ($row = $db->sql_fetchrow($result)) {
$existing_topics[] = (int) $row['topic_id'];
}
$db->sql_freeresult($result);
$missing_topics = array_diff($topic_ids, $existing_topics);
if (sizeof($missing_topics)) {
trigger_error(sprintf($user->lang['NONEXISTENT_TOPIC_IDS'], implode(', ', $missing_topics)));
}
// Update the topics with their new IDs
foreach ($post_map as $post_id => $topic_id) {
$sql = 'SELECT forum_id FROM ' . TOPICS_TABLE . ' WHERE topic_id = ' . (int) $topic_id . '';
$result = $db->sql_query_limit($sql, 1);
$forum_id = (int) $db->sql_fetchfield('forum_id');
$db->sql_freeresult($result);
$sql = 'UPDATE ' . POSTS_TABLE . ' SET topic_id = ' . (int) $topic_id . ', forum_id = ' . (int) $forum_id . ' WHERE post_id = ' . (int) $post_id;
$db->sql_query($sql);
}
trigger_error(sprintf($user->lang['POSTS_REASSIGNED'], sizeof($post_map)));
} else {
if (isset($_POST['delete'])) {
$post_ids = request_var('posts_del', array(0 => 0));
if (!sizeof($post_ids)) {
trigger_error('NO_POSTS_SELECTED');
}
if (!function_exists('delete_posts')) {
include $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
}
$return = delete_posts('post_id', $post_ids);
trigger_error(sprintf($user->lang['POSTS_DELETED'], $return));
} else {
trigger_error('NO_MODE');
}
}
break;
default:
trigger_error('NO_MODE');
break;
}
}
示例4: user_delete
//.........这里部分代码省略.........
if ($post_username === false) {
$post_username = $user->lang['GUEST'];
}
// If the user is inactive and newly registered we assume no posts from this user being there...
if ($user_row['user_type'] == USER_INACTIVE && $user_row['user_inactive_reason'] == INACTIVE_REGISTER && !$user_row['user_posts']) {
} else {
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET forum_last_poster_id = ' . ANONYMOUS . ", forum_last_poster_name = '" . $db->sql_escape($post_username) . "', forum_last_poster_colour = ''\n\t\t\t\t\tWHERE forum_last_poster_id = {$user_id}";
$db->sql_query($sql);
$sql = 'UPDATE ' . POSTS_TABLE . '
SET poster_id = ' . ANONYMOUS . ", post_username = '" . $db->sql_escape($post_username) . "'\n\t\t\t\t\tWHERE poster_id = {$user_id}";
$db->sql_query($sql);
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_edit_user = ' . ANONYMOUS . "\n\t\t\t\t\tWHERE post_edit_user = {$user_id}";
$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_poster = ' . ANONYMOUS . ", topic_first_poster_name = '" . $db->sql_escape($post_username) . "', topic_first_poster_colour = ''\n\t\t\t\t\tWHERE topic_poster = {$user_id}";
$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_last_poster_id = ' . ANONYMOUS . ", topic_last_poster_name = '" . $db->sql_escape($post_username) . "', topic_last_poster_colour = ''\n\t\t\t\t\tWHERE topic_last_poster_id = {$user_id}";
$db->sql_query($sql);
// Since we change every post by this author, we need to count this amount towards the anonymous user
// Update the post count for the anonymous user
if ($user_row['user_posts']) {
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_posts = user_posts + ' . $user_row['user_posts'] . '
WHERE user_id = ' . ANONYMOUS;
$db->sql_query($sql);
}
}
$db->sql_transaction('commit');
break;
case 'remove':
if (!function_exists('delete_posts')) {
include $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
}
$sql = 'SELECT topic_id, COUNT(post_id) AS total_posts
FROM ' . POSTS_TABLE . "\n\t\t\t\tWHERE poster_id = {$user_id}\n\t\t\t\tGROUP BY topic_id";
$result = $db->sql_query($sql);
$topic_id_ary = array();
while ($row = $db->sql_fetchrow($result)) {
$topic_id_ary[$row['topic_id']] = $row['total_posts'];
}
$db->sql_freeresult($result);
if (sizeof($topic_id_ary)) {
$sql = 'SELECT topic_id, topic_replies, topic_replies_real
FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', array_keys($topic_id_ary));
$result = $db->sql_query($sql);
$del_topic_ary = array();
while ($row = $db->sql_fetchrow($result)) {
if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']]) {
$del_topic_ary[] = $row['topic_id'];
}
}
$db->sql_freeresult($result);
if (sizeof($del_topic_ary)) {
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $del_topic_ary);
$db->sql_query($sql);
}
}
// Delete posts, attachments, etc.
delete_posts('poster_id', $user_id);
break;
}
示例5: main
//.........这里部分代码省略.........
add_log('admin', 'LOG_USER_DEL_AVATAR', $user_row['username']);
add_log('user', $user_id, 'LOG_USER_DEL_AVATAR_USER');
trigger_error($user->lang['USER_ADMIN_AVATAR_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
break;
case 'delposts':
if (confirm_box(true)) {
$sql = 'SELECT topic_id, COUNT(post_id) AS total_posts
FROM ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\t\tWHERE poster_id = {$user_id}\n\t\t\t\t\t\t\t\t\tGROUP BY topic_id";
$result = $db->sql_query($sql);
$topic_id_ary = array();
while ($row = $db->sql_fetchrow($result)) {
$topic_id_ary[$row['topic_id']] = $row['total_posts'];
}
$db->sql_freeresult($result);
if (sizeof($topic_id_ary)) {
$sql = 'SELECT topic_id, topic_replies, topic_replies_real
FROM ' . TOPICS_TABLE . '
WHERE topic_id IN (' . implode(', ', array_keys($topic_id_ary)) . ')';
$result = $db->sql_query($sql);
$del_topic_ary = array();
while ($row = $db->sql_fetchrow($result)) {
if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']]) {
$del_topic_ary[] = $row['topic_id'];
}
}
$db->sql_freeresult($result);
if (sizeof($del_topic_ary)) {
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
WHERE topic_id IN (' . implode(', ', $del_topic_ary) . ')';
$db->sql_query($sql);
}
}
// Delete posts, attachments, etc.
delete_posts('poster_id', $user_id);
add_log('admin', 'LOG_USER_DEL_POSTS', $user_row['username']);
trigger_error($user->lang['USER_POSTS_DELETED'] . adm_back_link($this->u_action . '&u=' . $user_id));
} else {
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true)));
}
break;
case 'delattach':
if (confirm_box(true)) {
delete_attachments('user', $user_id);
add_log('admin', 'LOG_USER_DEL_ATTACH', $user_row['username']);
trigger_error($user->lang['USER_ATTACHMENTS_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
} else {
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('u' => $user_id, 'i' => $id, 'mode' => $mode, 'action' => $action, 'update' => true)));
}
break;
case 'moveposts':
$new_forum_id = request_var('new_f', 0);
if (!$new_forum_id) {
$this->page_title = 'USER_ADMIN_MOVE_POSTS';
$template->assign_vars(array('S_SELECT_FORUM' => true, 'U_ACTION' => $this->u_action . "&action={$action}&u={$user_id}", 'U_BACK' => $this->u_action . "&u={$user_id}", 'S_FORUM_OPTIONS' => make_forum_select(false, false, false, true)));
return;
}
// Two stage?
// Move topics comprising only posts from this user
$topic_id_ary = $move_topic_ary = $move_post_ary = $new_topic_id_ary = array();
$forum_id_ary = array($new_forum_id);
$sql = 'SELECT topic_id, COUNT(post_id) AS total_posts
FROM ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\tWHERE poster_id = {$user_id}\n\t\t\t\t\t\t\t\t\tAND forum_id <> {$new_forum_id}\n\t\t\t\t\t\t\t\tGROUP BY topic_id";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$topic_id_ary[$row['topic_id']] = $row['total_posts'];
}
示例6: main
//.........这里部分代码省略.........
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING);
}
$sql_ary = array(
'user_avatar' => '',
'user_avatar_type' => 0,
'user_avatar_width' => 0,
'user_avatar_height' => 0,
);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
WHERE user_id = $user_id";
$db->sql_query($sql);
// Delete old avatar if present
if ($user_row['user_avatar'] && $user_row['user_avatar_type'] != AVATAR_GALLERY)
{
avatar_delete('user', $user_row);
}
add_log('admin', 'LOG_USER_DEL_AVATAR', $user_row['username']);
add_log('user', $user_id, 'LOG_USER_DEL_AVATAR_USER');
trigger_error($user->lang['USER_ADMIN_AVATAR_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
break;
case 'delposts':
if (confirm_box(true))
{
// Delete posts, attachments, etc.
delete_posts('poster_id', $user_id);
add_log('admin', 'LOG_USER_DEL_POSTS', $user_row['username']);
trigger_error($user->lang['USER_POSTS_DELETED'] . adm_back_link($this->u_action . '&u=' . $user_id));
}
else
{
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
'u' => $user_id,
'i' => $id,
'mode' => $mode,
'action' => $action,
'update' => true))
);
}
break;
case 'delattach':
if (confirm_box(true))
{
delete_attachments('user', $user_id);
add_log('admin', 'LOG_USER_DEL_ATTACH', $user_row['username']);
trigger_error($user->lang['USER_ATTACHMENTS_REMOVED'] . adm_back_link($this->u_action . '&u=' . $user_id));
}
else
{
confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
'u' => $user_id,
'i' => $id,
'mode' => $mode,
示例7: disapprove_post
/**
* Disapprove Post/Topic
*/
function disapprove_post($post_id_list, $id, $mode)
{
global $db, $template, $user, $config;
global $phpEx, $phpbb_root_path;
if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) {
trigger_error('NOT_AUTHORISED');
}
$redirect = request_var('redirect', build_url(array('t', 'mode', 'quickmod')) . "&mode={$mode}");
$reason = utf8_normalize_nfc(request_var('reason', '', true));
$reason_id = request_var('reason_id', 0);
$success_msg = $additional_msg = '';
$s_hidden_fields = build_hidden_fields(array('i' => $id, 'mode' => $mode, 'post_id_list' => $post_id_list, 'action' => 'disapprove', 'redirect' => $redirect));
$notify_poster = isset($_REQUEST['notify_poster']) ? true : false;
$disapprove_reason = '';
if ($reason_id) {
$sql = 'SELECT reason_title, reason_description
FROM ' . REPORTS_REASONS_TABLE . "\n\t\t\tWHERE reason_id = {$reason_id}";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$row || !$reason && strtolower($row['reason_title']) == 'other') {
$additional_msg = $user->lang['NO_REASON_DISAPPROVAL'];
unset($_POST['confirm']);
} else {
// If the reason is defined within the language file, we will use the localized version, else just use the database entry...
$disapprove_reason = strtolower($row['reason_title']) != 'other' ? isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]) ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])] : $row['reason_description'] : '';
$disapprove_reason .= $reason ? "\n\n" . $reason : '';
if (isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])])) {
$disapprove_reason_lang = strtoupper($row['reason_title']);
}
$email_disapprove_reason = $disapprove_reason;
}
}
$post_info = get_post_data($post_id_list, 'm_approve');
if (confirm_box(true)) {
// If Topic -> forum_topics_real -= 1
// If Post -> topic_replies_real -= 1
$num_disapproved = 0;
$forum_topics_real = $topic_id_list = $forum_id_list = $topic_replies_real_sql = $post_disapprove_sql = $disapprove_log = array();
foreach ($post_info as $post_id => $post_data) {
$topic_id_list[$post_data['topic_id']] = 1;
if ($post_data['forum_id']) {
$forum_id_list[$post_data['forum_id']] = 1;
}
// Topic or Post. ;)
/**
* @todo this probably is a different method than the one used by delete_posts, does this cause counter inconsistency?
*/
if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id) {
if ($post_data['forum_id']) {
if (!isset($forum_topics_real[$post_data['forum_id']])) {
$forum_topics_real[$post_data['forum_id']] = 0;
}
$forum_topics_real[$post_data['forum_id']]++;
$num_disapproved++;
}
$disapprove_log[] = array('type' => 'topic', 'post_subject' => $post_data['post_subject'], 'forum_id' => $post_data['forum_id'], 'topic_id' => 0);
} else {
if (!isset($topic_replies_real_sql[$post_data['topic_id']])) {
$topic_replies_real_sql[$post_data['topic_id']] = 0;
}
$topic_replies_real_sql[$post_data['topic_id']]++;
$disapprove_log[] = array('type' => 'post', 'post_subject' => $post_data['post_subject'], 'forum_id' => $post_data['forum_id'], 'topic_id' => $post_data['topic_id']);
}
$post_disapprove_sql[] = $post_id;
}
unset($post_data);
if (sizeof($forum_topics_real)) {
foreach ($forum_topics_real as $forum_id => $topics_real) {
$sql = 'UPDATE ' . FORUMS_TABLE . "\n\t\t\t\t\tSET forum_topics_real = forum_topics_real - {$topics_real}\n\t\t\t\t\tWHERE forum_id = {$forum_id}";
$db->sql_query($sql);
}
}
if (sizeof($topic_replies_real_sql)) {
foreach ($topic_replies_real_sql as $topic_id => $num_replies) {
$sql = 'UPDATE ' . TOPICS_TABLE . "\n\t\t\t\t\tSET topic_replies_real = topic_replies_real - {$num_replies}\n\t\t\t\t\tWHERE topic_id = {$topic_id}";
$db->sql_query($sql);
}
}
if (sizeof($post_disapprove_sql)) {
if (!function_exists('delete_posts')) {
include_once $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
}
// We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts
delete_posts('post_id', $post_disapprove_sql);
foreach ($disapprove_log as $log_data) {
add_log('mod', $log_data['forum_id'], $log_data['topic_id'], $log_data['type'] == 'topic' ? 'LOG_TOPIC_DISAPPROVED' : 'LOG_POST_DISAPPROVED', $log_data['post_subject'], $disapprove_reason);
}
}
unset($post_disapprove_sql, $topic_replies_real_sql);
update_post_information('topic', array_keys($topic_id_list));
if (sizeof($forum_id_list)) {
update_post_information('forum', array_keys($forum_id_list));
}
unset($topic_id_list, $forum_id_list);
$messenger = new messenger();
// Notify Poster?
//.........这里部分代码省略.........
示例8: bh_del_posts
private function bh_del_posts()
{
$user_id = $this->user_id;
// Close reports.
// Topics can have more than one reported post so we need to get them first.
$sql = 'SELECT p.post_id, p.topic_id, p.poster_id, p.post_reported, p.forum_id, t.topic_id, t.topic_first_post_id, t.topic_poster
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t\n\t\t\t\tWHERE p.poster_id = {$user_id}\n\t\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\t\tORDER BY t.topic_id ASC, p.post_id ASC";
$result = $this->db->sql_query($sql);
$posts = $topics = array();
// Step through the topics and count reported posts in each topic where this user is reported.
while ($row = $this->db->sql_fetchrow($result)) {
$posts[$row['post_id']] = $row;
if ($row['post_reported'] == 1) {
$topics[$row['topic_id']] = isset($topics[$row['topic_id']]) ? ++$topics[$row['topic_id']] : 1;
}
}
$this->db->sql_freeresult($result);
// And now handle the reports.
$sql = 'SELECT report_id, post_id, report_closed
FROM ' . REPORTS_TABLE . '
WHERE report_closed = 0
AND post_id <> 0';
$result = $this->db->sql_query($sql);
$close_reports = $unreport_topics = array();
while ($row = $this->db->sql_fetchrow($result)) {
if (!empty($row['post_id']) && !empty($posts[$row['post_id']])) {
// A reported post.
$close_reports[] = (int) $row['report_id'];
// Check if the topic has more reported posts
if (isset($topics[$posts[$row['post_id']]['topic_id']]) && --$topics[$posts[$row['post_id']]['topic_id']] <= 0) {
$unreport_topics[] = (int) $posts[$row['post_id']]['topic_id'];
}
}
}
$this->db->sql_freeresult($result);
// Close reports. Posts will be deleted so there is no need to unmark them as reported.
if (!empty($close_reports)) {
$sql = 'UPDATE ' . REPORTS_TABLE . '
SET report_closed = 1
WHERE ' . $this->db->sql_in_set('report_id', $close_reports);
$this->db->sql_query($sql);
}
// Unreport topics
if (!empty($unreport_topics)) {
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 0
WHERE ' . $this->db->sql_in_set('topic_id', $unreport_topics);
$this->db->sql_query($sql);
}
// Delete some posts.
if (!function_exists('delete_posts')) {
include $this->root_path . 'includes/functions_admin.' . $this->php_ext;
}
delete_posts('post_id', array_keys($posts));
// Delete from other tables.
$this->db->sql_query('DELETE FROM ' . BOOKMARKS_TABLE . " WHERE user_id = {$user_id}");
$this->db->sql_query('DELETE FROM ' . DRAFTS_TABLE . " WHERE user_id = {$user_id}");
$this->db->sql_query('DELETE FROM ' . FORUMS_TRACK_TABLE . " WHERE user_id = {$user_id}");
$this->db->sql_query('DELETE FROM ' . FORUMS_WATCH_TABLE . " WHERE user_id = {$user_id}");
$this->db->sql_query('DELETE FROM ' . MODERATOR_CACHE_TABLE . " WHERE user_id = {$user_id}");
$this->db->sql_query('DELETE FROM ' . NOTIFICATIONS_TABLE . " WHERE user_id = {$user_id}");
$this->db->sql_query('DELETE FROM ' . POLL_VOTES_TABLE . " WHERE vote_user_id = {$user_id}");
$this->db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE . " WHERE user_id = {$user_id}");
$this->db->sql_query('DELETE FROM ' . TOPICS_TRACK_TABLE . " WHERE user_id = {$user_id}");
$this->db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . " WHERE user_id = {$user_id}");
$this->db->sql_query('DELETE FROM ' . USER_NOTIFICATIONS_TABLE . " WHERE user_id = {$user_id}");
}
示例9: user_active_flip
if ($config['asacp_ocban_deactivate']) {
user_active_flip('deactivate', $user_id, INACTIVE_MANUAL);
}
// Move the user to a certain group
if ($config['asacp_ocban_move_to_group']) {
$sql = 'SELECT group_id FROM ' . USER_GROUP_TABLE . ' WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
group_user_del($row['group_id'], array($user_id), array($username));
}
$db->sql_freeresult($result);
group_user_add($config['asacp_ocban_move_to_group'], array($user_id), array($username), false, true);
}
// Delete the user's posts
if ($config['asacp_ocban_delete_posts']) {
delete_posts('poster_id', $user_id);
}
// Delete the user's avatar
if ($config['asacp_ocban_delete_avatar'] && $user_row['user_avatar']) {
avatar_delete('user', $user_row, true);
}
// Delete the user's signature
if ($config['asacp_ocban_delete_signature']) {
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', array('user_sig' => '', 'user_sig_bbcode_uid' => '', 'user_sig_bbcode_bitfield' => '')) . '
WHERE user_id = ' . $user_id;
$db->sql_query($sql);
}
// Delete the user's blog
if ($config['asacp_ocban_blog'] && file_exists($phpbb_root_path . 'blog/includes/functions_admin.' . $phpEx)) {
if (!function_exists('blog_delete_user')) {
示例10: main
//.........这里部分代码省略.........
$this->template->assign_block_vars('info', array('TEXT' => "<center><h3>" . $this->user->lang('MAPS_ERROR_MARK') . "</h3></center><meta http-equiv=\"refresh\" content=\"2; url=maps\">"));
}
}
} else {
login_box('', $this->user->lang['LOGIN_REPUTATION_PAGE']);
}
}
if (isset($_POST['down'])) {
$map_id = request_var('id', '', true);
if ($this->user->data['user_id'] != ANONYMOUS) {
$sql = "SELECT *\n\t\t\tFROM " . MAP_REPA . "\n\t\t\t\tWHERE map_id = {$map_id}\n\t\t\t\t\tAND user_id = {$userid}";
$res = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($res);
if ($row > 0) {
$this->template->assign_block_vars('info', array('TEXT' => "<center><h3>" . $this->user->lang('MAPS_UP_DOWN_NO') . "</h3></center><meta http-equiv=\"refresh\" content=\"2; url=maps\">"));
} else {
$insert = $this->db->sql_query("INSERT INTO " . MAP_REPA . " (user_id, map_id) VALUES ('{$userid}', '{$map_id}')");
$update = $this->db->sql_query("UPDATE " . MAP . " SET repa=repa-1 WHERE id='{$map_id}'");
if ($insert and $update) {
$this->template->assign_block_vars('info', array('TEXT' => "<center><h3>" . $this->user->lang('MAPS_UP_DOWN_YES') . "</h3></center><meta http-equiv=\"refresh\" content=\"2; url=maps\">"));
} else {
$this->template->assign_block_vars('info', array('TEXT' => "<center><h3>" . $this->user->lang('MAPS_ERROR_MARK') . "</h3></center><meta http-equiv=\"refresh\" content=\"2; url=maps\">"));
}
}
} else {
login_box('', $this->user->lang['LOGIN_REPUTATION_PAGE']);
}
}
if (isset($_POST['delete'])) {
$del = request_var('del', '', true);
$tid = request_var('tid', '', true);
$delete = $this->db->sql_query("DELETE FROM " . MAP . " WHERE id = {$del}");
if ($delete) {
if ($tid != 0) {
$sql = "SELECT post_id \n\t\t\t FROM " . POSTS_TABLE . " \n\t\t\t WHERE topic_id = {$tid}";
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
if ($row) {
if (!function_exists('delete_posts')) {
include $this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext;
}
delete_posts('post_id', $row);
}
}
$this->template->assign_block_vars('info', array('TEXT' => "<center><h3>" . $this->user->lang('MAPS_DELELE_MARK') . "</h3></center><meta http-equiv=\"refresh\" content=\"2; url=maps\">"));
} else {
$this->template->assign_block_vars('info', array('TEXT' => "<center><h3>" . $this->user->lang('MAPS_ERROR_MARK') . "</h3></center><meta http-equiv=\"refresh\" content=\"2; url=maps\">"));
}
}
if (isset($_POST['but'])) {
$pcoord = request_var('pcoord', '', true);
$descriptpoint = strip_tags(str_replace("'", '"', html_entity_decode(request_var('descriptpoint', '', true), ENT_QUOTES)));
$title = strip_tags(str_replace("'", '"', html_entity_decode(request_var('title', '', true), ENT_QUOTES)));
if ($maps_post == '1') {
$bbmaps = '[yandexmaps=' . $title . ']' . $pcoord . '[/yandexmaps]<br />' . $descriptpoint . '';
} else {
$bbmaps = "{$descriptpoint}";
}
if ($descriptpoint == '') {
unset($descriptpoint);
}
if ($title == '') {
unset($title);
}
if (isset($title) && isset($descriptpoint)) {
$sql = "SELECT * \n\t\t\tFROM " . MAP . " \n\t\t\tWHERE coord \n\t\t\tLIKE '{$pcoord}'";
$res = $this->db->sql_query($sql);
if ($this->db->sql_affectedrows($res) != 0) {
$this->template->assign_block_vars('info', array('TEXT' => "<center><h3>" . $this->user->lang('MAPS_EXISTS_MARK') . "</h3></center><meta http-equiv=\"refresh\" content=\"2; url=maps\">"));
} else {
if ($placemark_posts == 1) {
include $this->phpbb_root_path . '/includes/functions_posting.' . $this->php_ext;
global $post_data;
$poll = $uid = $bitfield = $options = '';
generate_text_for_storage($title, $uid, $bitfield, $options, false, false, false);
generate_text_for_storage($bbmaps, $uid, $bitfield, $options, true, true, true);
$post_data = array('topic_type' => POST_NORMAL, 'post_subject' => $title);
$data = array('forum_id' => $maps_posts_forum, 'icon_id' => false, 'enable_bbcode' => (bool) true, 'enable_smilies' => (bool) true, 'enable_urls' => (bool) true, 'enable_sig' => (bool) true, 'message' => $bbmaps, 'message_md5' => (string) '', 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid, 'post_edit_locked' => 0, 'topic_title' => $title, 'notify_set' => false, 'notify' => false, 'post_time' => 0, 'forum_name' => '', 'enable_indexing' => (bool) false, 'post_id' => '', 'topic_first_post_id' => '', 'force_approved_state' => 1);
submit_post('post', $title, '', POST_NORMAL, $poll, $data);
$topic = $data['topic_id'];
} else {
$topic = 0;
}
$insert = $this->db->sql_query("INSERT INTO " . MAP . " (user_id, title, descr, coord, repa, topic, forum) VALUES ('{$userid}', '{$title}', '{$descriptpoint}', '{$pcoord}', '0', '{$topic}', '{$maps_posts_forum}')");
if ($insert) {
$this->template->assign_block_vars('info', array('TEXT' => "<center><h3>" . $this->user->lang('MAPS_SAVE_MARK') . "</h3></center><meta http-equiv=\"refresh\" content=\"2; url=maps\">"));
} else {
$this->template->assign_block_vars('info', array('TEXT' => "<center><h3>" . $this->user->lang('MAPS_ERROR_MARK') . "</h3></center><meta http-equiv=\"refresh\" content=\"2; url=maps\">"));
}
}
} else {
$this->template->assign_block_vars('info', array('TEXT' => "<center><h3>" . $this->user->lang('MAPS_ERROR2_MARK') . "</h3></center><meta http-equiv=\"refresh\" content=\"2; url=maps\">"));
}
}
page_header($this->config['maps_title']);
$this->template->set_filenames(array('body' => 'maps_body.html'));
page_footer();
return new Response($this->template->return_display('body'), 200);
}
示例11: delete_post
/**
* Delete Post
*/
function delete_post($forum_id, $topic_id, $post_id, &$data)
{
global $_CLASS, $config;
// Specify our post mode
$post_mode = $data['topic_first_post_id'] == $data['topic_last_post_id'] ? 'delete_topic' : ($data['topic_first_post_id'] == $post_id ? 'delete_first_post' : ($data['topic_last_post_id'] == $post_id ? 'delete_last_post' : 'delete'));
$sql_data = array();
$next_post_id = 0;
require_once SITE_FILE_ROOT . 'includes/forums/functions_admin.php';
$_CLASS['core_db']->transaction();
if (!delete_posts('post_id', array($post_id), false, false)) {
// Try to delete topic, we may had an previous error causing inconsistency
if ($post_mode == 'delete_topic') {
delete_topics('topic_id', array($topic_id), false);
}
trigger_error('ALREADY_DELETED');
}
$_CLASS['core_db']->transaction('commit');
// Collect the necessary information for updating the tables
$sql_data[FORUMS_FORUMS_TABLE] = '';
switch ($post_mode) {
case 'delete_topic':
delete_topics('topic_id', array($topic_id), false);
if ($data['topic_type'] != POST_GLOBAL) {
$sql_data[FORUMS_FORUMS_TABLE] .= 'forum_posts = forum_posts - 1, forum_topics_real = forum_topics_real - 1';
$sql_data[FORUMS_FORUMS_TABLE] .= $data['topic_approved'] ? ', forum_topics = forum_topics - 1' : '';
}
$update_sql = update_post_information('forum', $forum_id, true);
if (sizeof($update_sql)) {
$sql_data[FORUMS_FORUMS_TABLE] .= $sql_data[FORUMS_FORUMS_TABLE] ? ', ' : '';
$sql_data[FORUMS_FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]);
}
break;
case 'delete_first_post':
$sql = 'SELECT p.post_id, p.poster_id, p.post_username, u.username
FROM ' . FORUMS_POSTS_TABLE . ' p, ' . CORE_USERS_TABLE . " u\r\n\t\t\t\tWHERE p.topic_id = {$topic_id}\r\n\t\t\t\t\tAND p.poster_id = u.user_id\r\n\t\t\t\tORDER BY p.post_time ASC";
$result = $_CLASS['core_db']->query_limit($sql, 1);
$row = $_CLASS['core_db']->fetch_row_assoc($result);
$_CLASS['core_db']->free_result($result);
if ($data['topic_type'] != POST_GLOBAL) {
$sql_data[FORUMS_FORUMS_TABLE] = 'forum_posts = forum_posts - 1';
}
$sql_data[FORUMS_TOPICS_TABLE] = 'topic_first_post_id = ' . intval($row['post_id']) . ", topic_first_poster_name = '" . ($row['poster_id'] == ANONYMOUS ? $_CLASS['core_db']->escape($row['post_username']) : $_CLASS['core_db']->escape($row['username'])) . "'";
$sql_data[FORUMS_TOPICS_TABLE] .= ', topic_replies_real = topic_replies_real - 1' . ($data['post_approved'] ? ', topic_replies = topic_replies - 1' : '');
$next_post_id = (int) $row['post_id'];
break;
case 'delete_last_post':
if ($data['topic_type'] != POST_GLOBAL) {
$sql_data[FORUMS_FORUMS_TABLE] = 'forum_posts = forum_posts - 1';
}
$update_sql = update_post_information('forum', $forum_id, true);
if (sizeof($update_sql)) {
$sql_data[FORUMS_FORUMS_TABLE] .= $sql_data[FORUMS_FORUMS_TABLE] ? ', ' : '';
$sql_data[FORUMS_FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]);
}
$sql_data[FORUMS_TOPICS_TABLE] = 'topic_bumped = 0, topic_bumper = 0, topic_replies_real = topic_replies_real - 1' . ($data['post_approved'] ? ', topic_replies = topic_replies - 1' : '');
$update_sql = update_post_information('topic', $topic_id, true);
if (sizeof($update_sql)) {
$sql_data[FORUMS_TOPICS_TABLE] .= ', ' . implode(', ', $update_sql[$topic_id]);
$next_post_id = (int) str_replace('topic_last_post_id = ', '', $update_sql[$topic_id][0]);
} else {
$sql = 'SELECT MAX(post_id) as last_post_id
FROM ' . FORUMS_POSTS_TABLE . "\r\n\t\t\t\t\tWHERE topic_id = {$topic_id} " . (!$_CLASS['forums_auth']->acl_get('m_approve', $forum_id) ? 'AND post_approved = 1' : '');
$result = $_CLASS['core_db']->query($sql);
$row = $_CLASS['core_db']->fetch_row_assoc($result);
$_CLASS['core_db']->free_result($result);
$next_post_id = (int) $row['last_post_id'];
}
break;
case 'delete':
$sql = 'SELECT post_id
FROM ' . FORUMS_POSTS_TABLE . "\r\n\t\t\t\tWHERE topic_id = {$topic_id} " . (!$_CLASS['forums_auth']->acl_get('m_approve', $forum_id) ? 'AND post_approved = 1' : '') . '
AND post_time > ' . $data['post_time'] . '
ORDER BY post_time ASC';
$result = $_CLASS['core_db']->query_limit($sql, 1);
$row = $_CLASS['core_db']->fetch_row_assoc($result);
$_CLASS['core_db']->free_result($result);
if ($data['topic_type'] != POST_GLOBAL) {
$sql_data[FORUMS_FORUMS_TABLE] = 'forum_posts = forum_posts - 1';
}
$sql_data[FORUMS_TOPICS_TABLE] = 'topic_replies_real = topic_replies_real - 1' . ($data['post_approved'] ? ', topic_replies = topic_replies - 1' : '');
$next_post_id = (int) $row['post_id'];
break;
}
//$sql_data[CORE_USERS_TABLE] = ($_CLASS['forums_auth']->acl_get('f_postcount', $forum_id)) ? 'user_posts = user_posts - 1' : '';
$_CLASS['core_db']->transaction();
$where_sql = array(FORUMS_FORUMS_TABLE => "forum_id = {$forum_id}", FORUMS_TOPICS_TABLE => "topic_id = {$topic_id}", CORE_USERS_TABLE => 'user_id = ' . $data['poster_id']);
foreach ($sql_data as $table => $update_sql) {
if ($update_sql) {
$_CLASS['core_db']->query("UPDATE {$table} SET {$update_sql} WHERE " . $where_sql[$table]);
}
}
unset($sql_data);
$_CLASS['core_db']->transaction('commit');
// Adjust posted info for this user by looking for a post by him/her within this topic...
/*
if ($post_mode != 'delete_topic' && $config['load_db_track'] && $_CLASS['core_user']->is_user)
{
//.........这里部分代码省略.........
示例12: disapprove_post
/**
* Disapprove Post/Topic
*/
function disapprove_post($post_id_list, $mode)
{
global $_CLASS, $_CORE_CONFIG, $config;
$forum_id = request_var('f', 0);
if (!check_ids($post_id_list, FORUMS_POSTS_TABLE, 'post_id', 'm_approve')) {
trigger_error('NOT_AUTHORIZED');
}
$redirect = request_var('redirect', $_CLASS['core_user']->data['session_page']);
$reason = request_var('reason', '', true);
$reason_id = request_var('reason_id', 0);
$success_msg = $additional_msg = '';
$s_hidden_fields = build_hidden_fields(array('i' => 'queue', 'f' => $forum_id, 'mode' => $mode, 'post_id_list' => $post_id_list, 'mode' => 'disapprove', 'redirect' => $redirect));
$notify_poster = isset($_REQUEST['notify_poster']);
$disapprove_reason = '';
if ($reason_id) {
$sql = 'SELECT reason_title, reason_description
FROM ' . FORUMS_REPORTS_REASONS_TABLE . " \n\t\t\tWHERE reason_id = {$reason_id}";
$result = $_CLASS['core_db']->query($sql);
$row = $_CLASS['core_db']->fetch_row_assoc($result);
$_CLASS['core_db']->free_result($result);
if (!$row || !$reason && $row['reason_name'] === 'other') {
$additional_msg = $_CLASS['core_user']->lang['NO_REASON_DISAPPROVAL'];
unset($_POST['confirm']);
} else {
$disapprove_reason = $row['reason_title'] != 'other' ? isset($_CLASS['core_user']->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]) ? $_CLASS['core_user']->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])] : $row['reason_description'] : '';
$disapprove_reason .= $reason ? "\n\n" . $reason : '';
unset($reason);
}
}
require_once SITE_FILE_ROOT . 'includes/forums/functions_display.php';
$reason = display_reasons($reason_id);
$_CLASS['core_template']->assign_array(array('S_NOTIFY_POSTER' => true, 'S_APPROVE' => false, 'REASON' => $reason, 'ADDITIONAL_MSG' => $additional_msg));
if (display_confirmation($_CLASS['core_user']->get_lang('DISAPPROVE_POST' . (sizeof($post_id_list) == 1 ? '' : 'S')), $s_hidden_fields, 'modules/forums/mcp_approve.html')) {
$post_info = get_post_data($post_id_list, 'm_approve');
// If Topic -> forum_topics_real -= 1
// If Post -> topic_replies_real -= 1
$forum_topics_real = 0;
$topic_replies_real_sql = $post_disapprove_sql = $topic_id_list = array();
foreach ($post_info as $post_id => $post_data) {
$topic_id_list[$post_data['topic_id']] = 1;
// Topic or Post. ;)
if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id) {
if ($post_data['forum_id']) {
$forum_topics_real++;
}
} else {
if (!isset($topic_replies_real_sql[$post_data['topic_id']])) {
$topic_replies_real_sql[$post_data['topic_id']] = 1;
} else {
$topic_replies_real_sql[$post_data['topic_id']]++;
}
}
$post_disapprove_sql[] = $post_id;
}
if ($forum_topics_real) {
$sql = 'UPDATE ' . FORUMS_FORUMS_TABLE . "\n\t\t\t\tSET forum_topics_real = forum_topics_real - {$forum_topics_real}\n\t\t\t\tWHERE forum_id = {$forum_id}";
$_CLASS['core_db']->query($sql);
}
if (!empty($topic_replies_real_sql)) {
foreach ($topic_replies_real_sql as $topic_id => $num_replies) {
$sql = 'UPDATE ' . FORUMS_TOPICS_TABLE . "\n\t\t\t\t\tSET topic_replies_real = topic_replies_real - {$num_replies}\n\t\t\t\t\tWHERE topic_id = {$topic_id}";
$_CLASS['core_db']->query($sql);
}
}
if (sizeof($post_disapprove_sql)) {
if (!function_exists('delete_posts')) {
require_once SITE_FILE_ROOT . 'includes/forums/functions_admin.php';
}
// We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts
delete_posts('post_id', $post_disapprove_sql);
}
unset($post_disapprove_sql, $topic_replies_real_sql);
update_post_information('topic', array_keys($topic_id_list));
update_post_information('forum', $forum_id);
unset($topic_id_list);
// Notify Poster?
if ($notify_poster) {
require_once SITE_FILE_ROOT . 'includes/mailer.php';
$mailer = new core_mailer();
foreach ($post_info as $post_id => $post_data) {
if ($post_data['poster_id'] == ANONYMOUS) {
continue;
}
$post_data['post_subject'] = censor_text($post_data['post_subject'], true);
$post_data['topic_title'] = censor_text($post_data['topic_title'], true);
if ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) {
$email_template = 'topic_disapproved.txt';
$subject = 'Topic Disapproved - ' . $post_data['topic_title'];
} else {
$email_template = 'post_disapproved.txt';
$subject = 'Post Disapproved - ' . $post_data['post_subject'];
}
$mailer->to($post_data['user_email'], $post_data['username']);
//$mailer->reply_to($_CORE_CONFIG['email']['site_email']);
$mailer->subject($subject);
//$messenger->im($post_data['user_jabber'], $post_data['username']);
$_CLASS['core_template']->assign_array(array('SITENAME' => $_CORE_CONFIG['global']['site_name'], 'USERNAME' => $post_data['username'], 'REASON' => stripslashes($disapprove_reason), 'POST_SUBJECT' => $post_data['post_subject'], 'TOPIC_TITLE' => $post_data['topic_title']));
//.........这里部分代码省略.........
示例13: user_delete
/**
* Remove User
*/
function user_delete($mode, $user_id, $post_username = false)
{
global $config, $db, $user, $auth;
$db->sql_transaction('begin');
switch ($mode) {
case 'retain':
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET forum_last_poster_id = ' . ANONYMOUS . ($post_username !== false ? ", forum_last_poster_name = '" . $db->sql_escape($post_username) . "'" : '') . "\n\t\t\t\tWHERE forum_last_poster_id = {$user_id}";
$db->sql_query($sql);
$sql = 'UPDATE ' . POSTS_TABLE . '
SET poster_id = ' . ANONYMOUS . ($post_username !== false ? ", post_username = '" . $db->sql_escape($post_username) . "'" : '') . "\n\t\t\t\tWHERE poster_id = {$user_id}";
$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_poster = ' . ANONYMOUS . "\n\t\t\t\tWHERE topic_poster = {$user_id}";
$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_last_poster_id = ' . ANONYMOUS . ($post_username !== false ? ", topic_last_poster_name = '" . $db->sql_escape($post_username) . "'" : '') . "\n\t\t\t\tWHERE topic_last_poster_id = {$user_id}";
$db->sql_query($sql);
break;
case 'remove':
if (!function_exists('delete_posts')) {
global $phpbb_root_path, $phpEx;
include_once $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
}
$sql = 'SELECT topic_id, COUNT(post_id) AS total_posts
FROM ' . POSTS_TABLE . "\n\t\t\t\tWHERE poster_id = {$user_id}\n\t\t\t\tGROUP BY topic_id";
$result = $db->sql_query($sql);
$topic_id_ary = array();
while ($row = $db->sql_fetchrow($result)) {
$topic_id_ary[$row['topic_id']] = $row['total_posts'];
}
$db->sql_freeresult($result);
if (sizeof($topic_id_ary)) {
$sql = 'SELECT topic_id, topic_replies, topic_replies_real
FROM ' . TOPICS_TABLE . '
WHERE topic_id IN (' . implode(', ', array_keys($topic_id_ary)) . ')';
$result = $db->sql_query($sql);
$del_topic_ary = array();
while ($row = $db->sql_fetchrow($result)) {
if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']]) {
$del_topic_ary[] = $row['topic_id'];
}
}
$db->sql_freeresult($result);
if (sizeof($del_topic_ary)) {
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
WHERE topic_id IN (' . implode(', ', $del_topic_ary) . ')';
$db->sql_query($sql);
}
}
// Delete posts, attachments, etc.
delete_posts('poster_id', $user_id);
break;
}
$table_ary = array(USERS_TABLE, USER_GROUP_TABLE, TOPICS_WATCH_TABLE, FORUMS_WATCH_TABLE, ACL_USERS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, FORUMS_TRACK_TABLE);
foreach ($table_ary as $table) {
$sql = "DELETE FROM {$table}\n\t\t\tWHERE user_id = {$user_id}";
$db->sql_query($sql);
}
// Reset newest user info if appropriate
if ($config['newest_user_id'] == $user_id) {
update_last_username();
}
set_config('num_users', $config['num_users'] - 1, true);
$db->sql_transaction('commit');
return false;
}
示例14: mcp_delete_post
function mcp_delete_post($post_ids)
{
global $_CLASS;
if (!check_ids($post_ids, FORUMS_POSTS_TABLE, 'post_id', 'm_delete')) {
return;
}
$redirect = get_variable('redirect', 'POST', $_CLASS['core_user']->data['session_url']);
$hidden_fields = generate_hidden_fields(array('post_id_list' => $post_ids, 'mode' => 'delete_post', 'redirect' => $redirect));
$success_msg = '';
$message = $_CLASS['core_user']->get_lang(count($post_ids) === 1 ? 'DELETE_POST' : 'DELETE_POSTS');
if (display_confirmation($message, $hidden_fields)) {
// Count the number of topics that are affected
// I did not use COUNT(DISTINCT ...) because I remember having problems
// with it on older versions of MySQL -- Ashe
$sql = 'SELECT DISTINCT topic_id
FROM ' . FORUMS_POSTS_TABLE . '
WHERE post_id IN (' . implode(', ', $post_ids) . ')';
$result = $_CLASS['core_db']->query($sql);
$topic_id_list = array();
while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) {
$topic_id_list[] = $row['topic_id'];
}
$_CLASS['core_db']->free_result($result);
$affected_topics = count($topic_id_list);
$post_data = get_post_data($post_ids);
foreach ($post_data as $id => $row) {
add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_DELETE_POST', $row['post_subject']);
}
unset($post_data);
// Now delete the posts, topics and forums are automatically resync'ed
delete_posts('post_id', $post_ids);
$sql = 'SELECT COUNT(topic_id) AS topics_left
FROM ' . FORUMS_TOPICS_TABLE . '
WHERE topic_id IN (' . implode(', ', $topic_id_list) . ')';
$result = $_CLASS['core_db']->query($sql);
$row = $_CLASS['core_db']->fetch_row_assoc($result);
$_CLASS['core_db']->free_result($result);
$deleted_topics = $row['topics_left'] ? $affected_topics - $row['topics_left'] : $affected_topics;
$topic_id = request_var('t', 0);
// Return links
$return_link = array();
if ($affected_topics === 1 && !$deleted_topics && $topic_id) {
$return_link[] = sprintf($_CLASS['core_user']->lang['RETURN_TOPIC'], '<a href="' . generate_link("forums&file=viewtopic&f={$forum_id}&t={$topic_id}") . '">', '</a>');
}
$return_link[] = sprintf($_CLASS['core_user']->lang['RETURN_FORUM'], '<a href="' . generate_link('forums&file=viewforum&f=' . $forum_id) . '">', '</a>');
if (count($post_ids) === 1) {
if ($deleted_topics) {
// We deleted the only post of a topic, which in turn has
// been removed from the database
$success_msg = $_CLASS['core_user']->lang['TOPIC_DELETED_SUCCESS'];
} else {
$success_msg = $_CLASS['core_user']->lang['POST_DELETED_SUCCESS'];
}
} else {
if ($deleted_topics) {
// Some of topics disappeared
$success_msg = $_CLASS['core_user']->lang['POSTS_DELETED_SUCCESS'] . '<br /><br />' . $_CLASS['core_user']->lang['EMPTY_TOPICS_REMOVED_WARNING'];
} else {
$success_msg = $_CLASS['core_user']->lang['POSTS_DELETED_SUCCESS'];
}
}
}
$redirect = generate_link('forums');
if (!$success_msg) {
redirect($redirect);
} else {
$_CLASS['core_display']->meta_refresh(3, $redirect);
trigger_error($success_msg . '<br /><br />' . sprintf($_CLASS['core_user']->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>') . '<br /><br />' . implode('<br /><br />', $return_link));
}
}
示例15: delete
/**
* Deletes an idea and the topic to go with it.
*
* @param int $id The ID of the idea to be deleted.
* @param int $topic_id The ID of the idea topic. Optional, but preferred.
*
* @return boolean Whether the idea was deleted or not.
*/
public function delete($id, $topic_id = 0)
{
if (!$topic_id) {
$idea = $this->get_idea($id);
$topic_id = $idea['topic_id'];
}
// Delete topic
delete_posts('topic_id', $topic_id);
// Delete idea
$deleted = $this->delete_idea_data($id, 'table_ideas');
// Delete votes
$this->delete_idea_data($id, 'table_votes');
return $deleted;
}