Пример #1
0
function forum_update_unread_data($unread_cutoff_stamp)
{
    if (!($db = db::get())) {
        return false;
    }
    if (!is_numeric($unread_cutoff_stamp)) {
        return false;
    }
    $unread_cutoff_datetime = date(MYSQL_DATETIME_MIDNIGHT, time() - $unread_cutoff_stamp);
    if (!($forum_prefix_array = forum_get_all_prefixes())) {
        return false;
    }
    foreach ($forum_prefix_array as $forum_prefix) {
        $sql = "DELETE QUICK FROM `{$forum_prefix}USER_THREAD` ";
        $sql .= "USING `{$forum_prefix}USER_THREAD` LEFT JOIN `{$forum_prefix}THREAD` ";
        $sql .= "ON (`{$forum_prefix}USER_THREAD`.`TID` = `{$forum_prefix}USER_THREAD`.`TID`) ";
        $sql .= "WHERE `{$forum_prefix}THREAD`.`MODIFIED` IS NOT NULL ";
        $sql .= "AND `{$forum_prefix}THREAD`.`MODIFIED` < CAST('{$unread_cutoff_datetime}' AS DATETIME) ";
        $sql .= "AND (`{$forum_prefix}USER_THREAD`.`INTEREST` IS NULL ";
        $sql .= "OR `{$forum_prefix}USER_THREAD`.`INTEREST` = 0)";
        if (!$db->query($sql)) {
            return false;
        }
    }
    return true;
}
Пример #2
0
function forum_update_unread_data($unread_cutoff_stamp)
{
    if (!($db_forum_update_unread_data = db_connect())) {
        return false;
    }
    if (!($table_data = get_table_prefix())) {
        return false;
    }
    if (!is_numeric($unread_cutoff_stamp)) {
        return false;
    }
    if ($unread_cutoff_stamp > 0) {
        if ($forum_prefix_array = forum_get_all_prefixes()) {
            foreach ($forum_prefix_array as $forum_prefix) {
                $sql = "INSERT INTO {$forum_prefix}THREAD_STATS (TID, UNREAD_PID, UNREAD_CREATED) ";
                $sql .= "SELECT POST.TID, MAX(POST.PID), MAX(POST.CREATED) FROM {$forum_prefix}POST POST ";
                $sql .= "LEFT JOIN {$forum_prefix}THREAD_STATS THREAD_STATS ON (THREAD_STATS.TID = POST.TID) ";
                $sql .= "WHERE POST.CREATED < FROM_UNIXTIME(UNIX_TIMESTAMP(NOW()) - {$unread_cutoff_stamp}) ";
                $sql .= "AND (THREAD_STATS.UNREAD_PID < POST.PID OR THREAD_STATS.UNREAD_PID IS NULL) ";
                $sql .= "GROUP BY POST.TID ON DUPLICATE KEY UPDATE UNREAD_PID = VALUES(UNREAD_PID), ";
                $sql .= "UNREAD_CREATED = VALUES(UNREAD_CREATED)";
                if (!($result = db_query($sql, $db_forum_update_unread_data))) {
                    return false;
                }
                $sql = "DELETE QUICK FROM {$forum_prefix}USER_THREAD ";
                $sql .= "USING {$forum_prefix}USER_THREAD ";
                $sql .= "LEFT JOIN {$forum_prefix}THREAD ";
                $sql .= "ON ({$forum_prefix}USER_THREAD.TID = ";
                $sql .= "{$forum_prefix}THREAD.TID) ";
                $sql .= "WHERE {$forum_prefix}THREAD.MODIFIED IS NOT NULL ";
                $sql .= "AND {$forum_prefix}THREAD.MODIFIED < ";
                $sql .= "FROM_UNIXTIME(UNIX_TIMESTAMP(NOW()) - {$unread_cutoff_stamp}) ";
                $sql .= "AND ({$forum_prefix}USER_THREAD.INTEREST IS NULL ";
                $sql .= "OR {$forum_prefix}USER_THREAD.INTEREST = 0) ";
                if (!($result = db_query($sql, $db_forum_update_unread_data))) {
                    return false;
                }
            }
        }
    }
    return true;
}
Пример #3
0
function user_update_sig($uid, $content, $global_update = false)
{
    if (!($db = db::get())) {
        return false;
    }
    if (!is_numeric($uid)) {
        return false;
    }
    $content = $db->escape($content);
    if ($global_update === true) {
        if (!($forum_prefix_array = forum_get_all_prefixes())) {
            return false;
        }
        foreach ($forum_prefix_array as $forum_prefix) {
            $sql = "INSERT INTO `{$forum_prefix}USER_SIG` (UID, CONTENT) ";
            $sql .= "VALUES ('{$uid}', '{$content}') ON DUPLICATE KEY ";
            $sql .= "UPDATE CONTENT = VALUES(CONTENT)";
            if (!$db->query($sql)) {
                return false;
            }
        }
    } else {
        if (!($table_prefix = get_table_prefix())) {
            return false;
        }
        $sql = "INSERT INTO `{$table_prefix}USER_SIG` (UID, CONTENT) ";
        $sql .= "VALUES ('{$uid}', '{$content}') ON DUPLICATE KEY UPDATE ";
        $sql .= "CONTENT = VALUES(CONTENT)";
        if (!$db->query($sql)) {
            return false;
        }
    }
    return true;
}
Пример #4
0
function admin_delete_user($uid, $delete_content = false)
{
    if (!($db = db::get())) {
        return false;
    }
    if (!is_numeric($uid)) {
        return false;
    }
    if (!is_bool($delete_content)) {
        $delete_content = false;
    }
    // Constants for deleting PM data
    $pm_inbox_items = PM_INBOX_ITEMS;
    $pm_sent_items = PM_SENT_ITEMS;
    $pm_outbox_items = PM_OUTBOX_ITEMS;
    $pm_saved_out = PM_SAVED_OUT;
    $pm_saved_in = PM_SAVED_IN;
    $pm_draft_items = PM_DRAFT_ITEMS;
    $current_datetime = date(MYSQL_DATETIME, time());
    // UID of current user
    $admin_uid = session::get_value('UID');
    // Before we delete we verify the user account exists and that
    // the user is not the current user account.
    if (($user_logon = user_get_logon($uid)) && $admin_uid != $uid) {
        // Check to see if we're also deleting the user's content.
        if ($delete_content === true) {
            // Get a list of available forums
            if ($forum_table_prefix_array = forum_get_all_prefixes()) {
                // Loop through all forums and delete all the user data from every forum.
                foreach ($forum_table_prefix_array as $forum_table_prefix) {
                    // Delete log entries created by the user
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}ADMIN_LOG` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete Links created by the user
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}LINKS` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete Link Votes made by the user
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}LINKS_VOTE` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete Link Comments made by the user
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}LINKS_COMMENT` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete Poll Votes made by the user
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}USER_POLL_VOTES` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete Relationship data for the user and relationships
                    // with this user made by other users.
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}USER_PEER` WHERE UID = '{$uid}' OR PEER_UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete folder preferences set by the user
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}USER_FOLDER` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete User's Preferences
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}USER_PREFS` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete User's Profile.
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}USER_PROFILE` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete User's Signature
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}USER_SIG` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete User's Thread Read Data
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}USER_THREAD` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete User's Tracking data (Post Count, etc.)
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}USER_TRACK` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete Word Filter Entries made by user
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}WORD_FILTER` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete Polls created by user
                    $sql = "UPDATE LOW_PRIORITY `{$forum_table_prefix}THREAD` SET POLL_FLAG = 'N', ";
                    $sql .= "MODIFIED = CAST('{$current_datetime}' AS DATETIME) WHERE BY_UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete threads started by the user where
                    // the thread only contains a single post.
                    $sql = "UPDATE LOW_PRIORITY `{$forum_table_prefix}THREAD` SET DELETED = 'Y', ";
                    $sql .= "MODIFIED = CAST('{$current_datetime}' AS DATETIME) WHERE BY_UID = '{$uid}' ";
                    $sql .= "AND LENGTH = 1";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete content of posts made by this user
                    $sql = "UPDATE LOW_PRIORITY `{$forum_table_prefix}POST_CONTENT` POST_CONTENT ";
                    $sql .= "LEFT JOIN `{$forum_table_prefix}POST` POST ON (POST.TID = POST_CONTENT.TID ";
                    $sql .= "AND POST.PID = POST_CONTENT.PID) SET POST_CONTENT.CONTENT = NULL ";
                    $sql .= "WHERE POST.FROM_UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Mark posts made by this user as approved so they don't appear in the
                    // approval queue.
                    $sql = "UPDATE LOW_PRIORITY `{$forum_table_prefix}POST` ";
                    $sql .= "SET APPROVED = CAST('{$current_datetime}' AS DATETIME), ";
                    $sql .= "APPROVED_BY = '{$admin_uid}' WHERE FROM_UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                }
            }
            // Delete Dictionary entries added by user
            $sql = "DELETE QUICK FROM DICTIONARY WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User Group Entries related to this user.
            $sql = "DELETE QUICK FROM GROUP_USERS WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User's PM Content
            $sql = "DELETE QUICK FROM PM_CONTENT USING PM_CONTENT ";
            $sql .= "LEFT JOIN PM ON (PM.MID = PM_CONTENT.MID) ";
            $sql .= "WHERE ((PM.TYPE & {$pm_inbox_items} > 0) AND PM.TO_UID = '{$uid}') ";
            $sql .= "OR ((PM.TYPE & {$pm_sent_items} > 0) AND PM.FROM_UID = '{$uid}' AND PM.SMID = 0) ";
            $sql .= "OR ((PM.TYPE & {$pm_outbox_items} > 0) AND PM.FROM_UID = '{$uid}') ";
            $sql .= "OR ((PM.TYPE & {$pm_saved_out} > 0) AND PM.FROM_UID = '{$uid}') ";
            $sql .= "OR ((PM.TYPE & {$pm_saved_in} > 0) AND PM.TO_UID = '{$uid}') ";
            $sql .= "OR ((PM.TYPE & {$pm_draft_items} > 0) AND PM.FROM_UID = '{$uid}') ";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User's PMs.
            $sql = "DELETE QUICK FROM PM WHERE ((TYPE & {$pm_inbox_items} > 0) ";
            $sql .= "AND TO_UID = '{$uid}') OR ((TYPE & {$pm_sent_items} > 0) ";
            $sql .= "AND FROM_UID = '{$uid}' AND SMID = 0) OR ((TYPE & {$pm_outbox_items} > 0) ";
            $sql .= "AND FROM_UID = '{$uid}') OR ((TYPE & {$pm_saved_out} > 0) ";
            $sql .= "AND FROM_UID = '{$uid}') OR ((TYPE & {$pm_saved_in} > 0) ";
            $sql .= "AND TO_UID = '{$uid}') OR ((TYPE & {$pm_draft_items} > 0) ";
            $sql .= "AND FROM_UID = '{$uid}') ";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User's PM Search Results
            $sql = "DELETE QUICK FROM PM_SEARCH_RESULTS WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User's Attachments (doesn't remove the physical files).
            $sql = "DELETE QUICK FROM POST_ATTACHMENT_FILES WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User's Search Results.
            $sql = "DELETE QUICK FROM SEARCH_RESULTS WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User's Sessions
            $sql = "DELETE QUICK FROM SESSIONS WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User's Forum Preferences and Permissions
            $sql = "DELETE QUICK FROM USER_FORUM WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User's History Data (Logon, Nickname, Email address changes)
            $sql = "DELETE QUICK FROM USER_HISTORY WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User's Global Preferences
            $sql = "DELETE QUICK FROM USER_PREFS WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User's Visitor Log Data
            $sql = "DELETE QUICK FROM VISITOR_LOG WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Add a log entry to show what we've done.
            admin_add_log_entry(DELETE_USER_DATA, array($uid, $user_logon));
        }
        // Delete the User account.
        $sql = "DELETE QUICK FROM USER WHERE UID = '{$uid}'";
        if (!$db->query($sql)) {
            return false;
        }
        // Add a log entry to show what we've done.
        admin_add_log_entry(DELETE_USER, array($user_logon));
        return true;
    }
    return false;
}
Пример #5
0
function admin_delete_user($uid, $delete_content = false)
{
    if (!($db = db::get())) {
        return false;
    }
    if (!is_numeric($uid)) {
        return false;
    }
    if (!is_bool($delete_content)) {
        $delete_content = false;
    }
    $current_datetime = date(MYSQL_DATETIME, time());
    // Mark as read cut off
    $modified_cutoff_datetime = forum_get_unread_cutoff_datetime();
    // UID of current user
    if (!isset($_SESSION['UID']) || !is_numeric($_SESSION['UID'])) {
        return false;
    }
    // Before we delete we verify the user account exists and that
    // the user is not the current user account.
    if (($user_logon = user_get_logon($uid)) && $_SESSION['UID'] != $uid) {
        // Check to see if we're also deleting the user's content.
        if ($delete_content === true) {
            // Get a list of available forums
            if (($forum_table_prefix_array = forum_get_all_prefixes()) !== false) {
                // Loop through all forums and delete all the user data from every forum.
                foreach ($forum_table_prefix_array as $forum_table_prefix) {
                    // Delete log entries created by the user
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}ADMIN_LOG` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete Links created by the user
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}LINKS` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete Link Votes made by the user
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}LINKS_VOTE` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete Link Comments made by the user
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}LINKS_COMMENT` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete Poll Votes made by the user
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}USER_POLL_VOTES` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete Relationship data for the user and relationships
                    // with this user made by other users.
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}USER_PEER` WHERE UID = '{$uid}' OR PEER_UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete folder preferences set by the user
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}USER_FOLDER` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete User's Preferences
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}USER_PREFS` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete User's Profile.
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}USER_PROFILE` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete User's Signature
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}USER_SIG` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete User's Thread Read Data
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}USER_THREAD` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete User's Tracking data (Post Count, etc.)
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}USER_TRACK` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete Word Filter Entries made by user
                    $sql = "DELETE QUICK FROM `{$forum_table_prefix}WORD_FILTER` WHERE UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete Polls created by user
                    $sql = "UPDATE LOW_PRIORITY `{$forum_table_prefix}THREAD` SET POLL_FLAG = 'N', ";
                    $sql .= "MODIFIED = IF(MODIFIED < CAST('{$modified_cutoff_datetime}' AS DATETIME), ";
                    $sql .= "MODIFIED, CAST('{$current_datetime}' AS DATETIME)) WHERE BY_UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete threads started by the user where
                    // the thread only contains a single post.
                    $sql = "UPDATE LOW_PRIORITY `{$forum_table_prefix}THREAD` SET DELETED = 'Y', ";
                    $sql .= "MODIFIED = IF(MODIFIED < CAST('{$modified_cutoff_datetime}' AS DATETIME), ";
                    $sql .= "MODIFIED, CAST('{$current_datetime}' AS DATETIME)) WHERE BY_UID = '{$uid}' ";
                    $sql .= "AND LENGTH = 1";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Delete content of posts made by this user
                    $sql = "UPDATE LOW_PRIORITY `{$forum_table_prefix}POST_CONTENT` POST_CONTENT ";
                    $sql .= "LEFT JOIN `{$forum_table_prefix}POST` POST ON (POST.TID = POST_CONTENT.TID ";
                    $sql .= "AND POST.PID = POST_CONTENT.PID) SET POST_CONTENT.CONTENT = NULL ";
                    $sql .= "WHERE POST.FROM_UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                    // Mark posts made by this user as approved so they don't appear in the
                    // approval queue.
                    $sql = "UPDATE LOW_PRIORITY `{$forum_table_prefix}POST` ";
                    $sql .= "SET APPROVED = CAST('{$current_datetime}' AS DATETIME), ";
                    $sql .= "APPROVED_BY = '{$_SESSION['UID']}' WHERE FROM_UID = '{$uid}'";
                    if (!$db->query($sql)) {
                        return false;
                    }
                }
            }
            // Delete User Group Entries related to this user.
            $sql = "DELETE QUICK FROM GROUP_USERS WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Remove all PM_TYPE records
            $sql = "DELETE QUICK FROM PM_TYPE WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Remove all PM_RECIPIENT records
            $sql = "DELETE QUICK FROM PM_RECIPIENT WHERE TO_UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete any PMs from this user.
            $sql = "DELETE QUICK FROM PM WHERE FROM_UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Remove any PMs that have no recipients.
            $sql = "DELETE QUICK FROM PM, PM_CONTENT USING PM ";
            $sql .= "LEFT JOIN PM_CONTENT ON (PM_CONTENT.MID = PM.MID) ";
            $sql .= "LEFT JOIN PM_RECIPIENT ON (PM_RECIPIENT.MID = PM.MID) ";
            $sql .= "LEFT JOIN PM_TYPE ON (PM_TYPE.MID = PM.MID) ";
            $sql .= "WHERE PM_TYPE.MID IS NULL OR PM_RECIPIENT.MID IS NULL";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete all the attachments uploaded by the user.
            $sql = "SELECT HASH FROM POST_ATTACHMENT_FILES WHERE UID = '{$uid}'";
            if (!($result = $db->query($sql))) {
                return false;
            }
            while (($attachment_data = $result->fetch_assoc()) !== null) {
                attachments_delete($attachment_data['HASH']);
            }
            // Delete User's PM Search Results
            $sql = "DELETE QUICK FROM PM_SEARCH_RESULTS WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User's Attachments (doesn't remove the physical files).
            $sql = "DELETE QUICK FROM POST_ATTACHMENT_FILES WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User's Search Results.
            $sql = "DELETE QUICK FROM SEARCH_RESULTS WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User's Sessions
            $sql = "DELETE QUICK FROM SESSIONS WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User's Forum Preferences and Permissions
            $sql = "DELETE QUICK FROM USER_FORUM WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User's History Data (Logon, Nickname, Email address changes)
            $sql = "DELETE QUICK FROM USER_HISTORY WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User's Global Preferences
            $sql = "DELETE QUICK FROM USER_PERM WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User's Global Preferences
            $sql = "DELETE QUICK FROM USER_PREFS WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Delete User's Visitor Log Data
            $sql = "DELETE QUICK FROM VISITOR_LOG WHERE UID = '{$uid}'";
            if (!$db->query($sql)) {
                return false;
            }
            // Add a log entry to show what we've done.
            admin_add_log_entry(DELETE_USER_DATA, array($uid, $user_logon));
        }
        // Delete the User account.
        $sql = "DELETE QUICK FROM USER WHERE UID = '{$uid}'";
        if (!$db->query($sql)) {
            return false;
        }
        // Add a log entry to show what we've done.
        admin_add_log_entry(DELETE_USER, array($user_logon));
        return true;
    }
    return false;
}