function delete_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id) { global $board_config, $lang, $db, $phpbb_root_path, $phpEx; global $userdata, $user_ip; if ($mode != 'poll_delete') { include $phpbb_root_path . 'includes/functions_search.' . $phpEx; $sql = "DELETE FROM " . POSTS_TABLE . " \r\n\t\t\tWHERE post_id = {$post_id}"; if (!$db->sql_query($sql)) { $db->clear_cache('posts_'); message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); } $sql = "DELETE FROM " . POSTS_TEXT_TABLE . " \r\n\t\t\tWHERE post_id = {$post_id}"; if (!$db->sql_query($sql)) { $db->clear_cache('posts_'); message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); } if ($post_data['last_post']) { if ($post_data['first_post']) { $forum_update_sql .= ', forum_topics = forum_topics - 1'; $sql = "DELETE FROM " . TOPICS_TABLE . " \r\n\t\t\t\t\tWHERE topic_id = {$topic_id} \r\n\t\t\t\t\t\tOR topic_moved_id = {$topic_id}"; if (!$db->sql_query($sql)) { $db->clear_cache('posts_'); message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); } $sql = "DELETE FROM " . TOPICS_WATCH_TABLE . "\r\n\t\t\t\t\tWHERE topic_id = {$topic_id}"; if (!$db->sql_query($sql)) { $db->clear_cache('posts_'); message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql); } } } remove_search_post($post_id); } if ($mode == 'poll_delete' || $mode == 'delete' && $post_data['first_post'] && $post_data['last_post'] && $post_data['has_poll'] && $post_data['edit_poll']) { $sql = "DELETE FROM " . VOTE_DESC_TABLE . " \r\n\t\t\tWHERE topic_id = {$topic_id}"; if (!$db->sql_query($sql)) { $db->clear_cache('posts_'); message_die(GENERAL_ERROR, 'Error in deleting poll', '', __LINE__, __FILE__, $sql); } $sql = "DELETE FROM " . VOTE_RESULTS_TABLE . " \r\n\t\t\tWHERE vote_id = {$poll_id}"; if (!$db->sql_query($sql)) { $db->clear_cache('posts_'); message_die(GENERAL_ERROR, 'Error in deleting poll', '', __LINE__, __FILE__, $sql); } $sql = "DELETE FROM " . VOTE_USERS_TABLE . " \r\n\t\t\tWHERE vote_id = {$poll_id}"; if (!$db->sql_query($sql)) { $db->clear_cache('posts_'); message_die(GENERAL_ERROR, 'Error in deleting poll', '', __LINE__, __FILE__, $sql); } } if ($mode == 'delete' && $post_data['first_post'] && $post_data['last_post']) { $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("viewforum.{$phpEx}?" . POST_FORUM_URL . '=' . $forum_id) . '">'; $message = $lang['Deleted']; } else { $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.{$phpEx}?" . POST_TOPIC_URL . '=' . $topic_id) . '">'; $message = ($mode == 'poll_delete' ? $lang['Poll_delete'] : $lang['Deleted']) . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.{$phpEx}?" . POST_TOPIC_URL . "={$topic_id}") . '">', '</a>'); } if ($board_config['points_post'] && !$post_info['points_disabled'] && ($mode == 'delete' || $mode == 'poll_delete')) { if ($userdata['user_id'] == $post_data['first_post'] && ($userdata['user_id'] != ANONYMOUS && $userdata['admin_allow_points'])) { subtract_points($userdata['user_id'], $board_config['points_topic']); } else { if ($userdata['user_id'] != ANONYMOUS && $userdata['admin_allow_points']) { subtract_points($userdata['user_id'], $board_config['points_reply']); } } } $message .= '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.{$phpEx}?" . POST_FORUM_URL . "={$forum_id}") . '">', '</a>'); $db->clear_cache('posts_'); $db->clear_cache('topics_recent_'); return; }
if (abs(intval($HTTP_POST_VARS['amount'])) == 0) { $error = true; $error_msg .= (!empty($error_msg) ? '<br />' : '') . sprintf($lang['Points_enter_some_donate'], $board_config['points_name']); } if (isset($error)) { $template->set_filenames(array('reg_header' => 'error_body.tpl')); $template->assign_vars(array('ERROR_MESSAGE' => $error_msg)); $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); } else { $amount = abs(intval($HTTP_POST_VARS['amount'])); $from_points = get_user_points($userdata['user_id']); if ($amount > $from_points) { message_die(GENERAL_MESSAGE, sprintf($lang['Points_cant_donate'], $board_config['points_name'])); } add_points($user_id, $amount); subtract_points($userdata['user_id'], $amount); //Send doation email if the user wants it $sql = "SELECT username, user_lang, user_email, user_notify_donation \r\n\t\t\t\tFROM " . USERS_TABLE . "\r\n\t\t\t\tWHERE user_id = {$user_id}"; if (!($result = $db->sql_query($sql))) { message_die(GENERAL_ERROR, "Could not get username & user_notify_donation & user_lang & user_email", '', __LINE__, __FILE__, $sql); } $to_userdata = $db->sql_fetchrow($result); if ($to_userdata['user_notify_donation']) { include $phpbb_root_path . 'includes/emailer.' . $phpEx; $emailer = new emailer($board_config['smtp_delivery']); $email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\n"; $emailer->use_template('user_notify_donation', $to_userdata['user_lang']); $emailer->email_address($to_userdata['user_email']); $emailer->extra_headers($email_headers); $emailer->assign_vars(array('DONATOR' => $userdata['username'], 'USERNAME' => $to_userdata['username'], 'AMOUNT_DONATE' => $amount, 'TOTAL_POINTS' => get_user_points($user_id), 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']), 'L_POINTS' => $board_config['points_name'])); $emailer->send();