/** * Delete user * * This function deletes the needed stuff when a user is deleted */ function blog_delete_user($user_id) { global $config, $db, $phpbb_root_path, $phpEx; $user_id = (int) $user_id; include "{$phpbb_root_path}blog/includes/constants.{$phpEx}"; if (!function_exists('setup_blog_search')) { include "{$phpbb_root_path}blog/includes/functions.{$phpEx}"; } if (!function_exists('put_blogs_in_cats')) { include "{$phpbb_root_path}blog/includes/functions_categories.{$phpEx}"; } $blog_search = setup_blog_search(); $num_blogs = $num_blog_replies = 0; $result = $db->sql_query('SELECT * FROM ' . BLOGS_TABLE . ' WHERE user_id = ' . $user_id); while ($row = $db->sql_fetchrow($result)) { $num_blogs++; $num_blog_replies += $row['blog_real_reply_count']; $blog_search->index_remove($row['blog_id']); put_blogs_in_cats($row['blog_id'], array(), true, 'soft_delete'); // Delete the Attachments $rids = array(); $sql = 'SELECT reply_id FROM ' . BLOGS_REPLY_TABLE . ' WHERE blog_id = ' . $row['blog_id']; $result1 = $db->sql_query($sql); while ($row1 = $db->sql_fetchrow($result1)) { $rids[] = $row1['reply_id']; } $db->sql_freeresult($result1); if (sizeof($rids)) { $sql = 'SELECT physical_filename FROM ' . BLOGS_ATTACHMENT_TABLE . ' WHERE blog_id = ' . $row['blog_id'] . ' OR ' . $db->sql_in_set('reply_id', $rids); } else { $sql = 'SELECT physical_filename FROM ' . BLOGS_ATTACHMENT_TABLE . ' WHERE blog_id = ' . $row['blog_id']; } $result1 = $db->sql_query($sql); while ($row1 = $db->sql_fetchrow($result1)) { @unlink($phpbb_root_path . $config['upload_path'] . '/blog_mod/' . $row1['physical_filename']); } $db->sql_freeresult($result1); if (sizeof($rids)) { $db->sql_query('DELETE FROM ' . BLOGS_ATTACHMENT_TABLE . ' WHERE blog_id = ' . $row['blog_id'] . ' OR ' . $db->sql_in_set('reply_id', $rids)); } else { $db->sql_query('DELETE FROM ' . BLOGS_ATTACHMENT_TABLE . ' WHERE blog_id = ' . $row['blog_id']); } // delete the blog $db->sql_query('DELETE FROM ' . BLOGS_TABLE . ' WHERE blog_id = ' . $row['blog_id']); // delete the replies $db->sql_query('DELETE FROM ' . BLOGS_REPLY_TABLE . ' WHERE blog_id = ' . $row['blog_id']); // delete from the blogs_in_categories $db->sql_query('DELETE FROM ' . BLOGS_IN_CATEGORIES_TABLE . ' WHERE blog_id = ' . $row['blog_id']); // delete from the blogs_ratings $db->sql_query('DELETE FROM ' . BLOGS_RATINGS_TABLE . ' WHERE blog_id = ' . $row['blog_id']); // Delete the subscriptions $db->sql_query('DELETE FROM ' . BLOGS_SUBSCRIPTION_TABLE . ' WHERE blog_id = ' . $row['blog_id']); // Delete the Polls $db->sql_query('DELETE FROM ' . BLOGS_POLL_OPTIONS_TABLE . ' WHERE blog_id = ' . $row['blog_id']); $db->sql_query('DELETE FROM ' . BLOGS_POLL_VOTES_TABLE . ' WHERE blog_id = ' . $row['blog_id']); } $db->sql_freeresult($result); $result = $db->sql_query('SELECT * FROM ' . BLOGS_REPLY_TABLE . ' WHERE user_id = ' . $user_id); while ($row = $db->sql_fetchrow($result)) { $num_blog_replies++; $blog_search->index_remove(false, $row['reply_id']); // Delete the Attachments $sql = 'SELECT physical_filename FROM ' . BLOGS_ATTACHMENT_TABLE . ' WHERE reply_id = ' . $row['reply_id']; $result1 = $db->sql_query($sql); while ($row1 = $db->sql_fetchrow($result1)) { @unlink($phpbb_root_path . $config['upload_path'] . '/blog_mod/' . $row1['physical_filename']); } $db->sql_freeresult($result1); $db->sql_query('DELETE FROM ' . BLOGS_ATTACHMENT_TABLE . ' WHERE reply_id = ' . $row['reply_id']); // delete the reply $db->sql_query('DELETE FROM ' . BLOGS_REPLY_TABLE . ' WHERE reply_id = ' . $row['reply_id']); } $db->sql_freeresult($result); $sql = 'UPDATE ' . USERS_TABLE . ' SET blog_count = 0 WHERE user_id = ' . $user_id; $db->sql_query($sql); // Resync reply counts resync_blog('reply_count'); resync_blog('real_reply_count'); set_config('num_blogs', $config['num_blogs'] - $num_blogs, true); set_config('num_blog_replies', $config['num_blog_replies'] - $num_blog_replies, true); }
<?php /** * * @package phpBB3 User Blog * @version $Id: resync.php 485 2008-08-15 23:33:57Z exreaction@gmail.com $ * @copyright (c) 2008 EXreaction * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ if (!defined('IN_PHPBB')) { exit; } // Setup the page header and sent the title of the page that will go into the browser header page_header($user->lang['RESYNC_BLOG']); // Generate the breadcrumbs generate_blog_breadcrumbs($user->lang['RESYNC_BLOG']); if (confirm_box(true)) { include $phpbb_root_path . 'blog/includes/functions_admin.' . $phpEx; resync_blog('all'); $message = $user->lang['RESYNC_BLOG_SUCCESS'] . '<br /><br />'; $message .= sprintf($user->lang['RETURN_MAIN'], '<a href="' . append_sid("{$phpbb_root_path}blog.{$phpEx}") . '">', '</a>'); trigger_error($message); } else { confirm_box(false, 'RESYNC_BLOG'); } blog_meta_refresh(0, append_sid("{$phpbb_root_path}blog.{$phpEx}"));
$sql_array[] = 'DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option = \'u_blognocaptcha\''; set_config('user_blog_guest_captcha', true); $blog_permissions = array('local' => array(), 'global' => array('u_blogmoderate')); $auth_admin->acl_add_option($blog_permissions); case 'A17': case 'A18': $sql_array[] = 'CREATE TABLE IF NOT EXISTS ' . BLOGS_USERS_TABLE . " (\n\t\t\t\tuser_id MEDIUMINT( 8 ) UNSIGNED NOT NULL,\n\t\t\t\tguest TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '2',\n\t\t\t\tregistered TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '2',\n\t\t\t\tfoe TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '2',\n\t\t\t\tfriend TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '2',\n\t\t\t\ttitle VARCHAR ( 255 ) NOT NULL DEFAULT '',\n\t\t\t\tdescription MEDIUMTEXT NOT NULL,\n\t\t\t\tdescription_bbcode_bitfield varchar(255) NOT NULL default '',\n\t\t\t\tdescription_bbcode_uid varchar(8) NOT NULL default '',\n\t\t\t\tPRIMARY KEY ( user_id )\n\t\t\t);"; case 'A19': $sql_array[] = 'ALTER TABLE ' . BLOGS_TABLE . " ADD perm_guest TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '2',\n\t\t\t\tADD perm_registered TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '2',\n\t\t\t\tADD perm_foe TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '2',\n\t\t\t\tADD perm_friend TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '2';"; $sql_array[] = 'ALTER TABLE ' . BLOGS_USERS_TABLE . " CHANGE guest perm_guest TINYINT( 1 ) UNSIGNED NOT NULL ,\n\t\t\t\tCHANGE registered perm_registered TINYINT( 1 ) UNSIGNED NOT NULL ,\n\t\t\t\tCHANGE foe perm_foe TINYINT( 1 ) UNSIGNED NOT NULL ,\n\t\t\t\tCHANGE friend perm_friend TINYINT( 1 ) UNSIGNED NOT NULL;"; // Must do all the SQL changes before we resync. foreach ($sql_array as $sql) { $db->sql_query($sql); } $sql_array = array(); resync_blog('user_permissions'); case 'A20': $sql_array[] = 'ALTER TABLE ' . BLOGS_USERS_TABLE . " CHANGE perm_guest perm_guest TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1',\n\t\t\t\tCHANGE perm_foe perm_foe TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0';"; $sql_array[] = 'ALTER TABLE ' . BLOGS_TABLE . " CHANGE perm_guest perm_guest TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1',\n\t\t\t\tCHANGE perm_foe perm_foe TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0';"; case '0.3.21': // Changing the version number scheme $sql_array[] = 'ALTER TABLE ' . BLOGS_USERS_TABLE . " ADD instant_redirect TINYINT(1) UNSIGNED NOT NULL DEFAULT '0'"; $sql_array[] = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE config_name = \'user_blog_founder_all_perm\''; case '0.3.22': case '0.3.23': case '0.3.24': if ($config['user_blog_force_prosilver']) { set_config('user_blog_force_style', 1); } else { set_config('user_blog_force_style', 0); }
<?php // Stuff required to work with phpBB3 define('IN_PHPBB', true); $phpbb_root_path = defined('PHPBB_ROOT_PATH') ? PHPBB_ROOT_PATH : './'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include $phpbb_root_path . 'common.' . $phpEx; // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup(); include $phpbb_root_path . 'blog/functions.' . $phpEx; include $phpbb_root_path . 'blog/includes/functions_admin.' . $phpEx; resync_blog('reply_count'); resync_blog('real_reply_count'); resync_blog('user_blog_count'); trigger_error('Done!');