function logout($account_id)
 {
     $db_map_misc = new dbmapping_misc();
     $db_map_misc->MAP_account_logout($account_id, $this);
 }
    function MAP_account_delete_misc($account_id, $username, $MAP_this)
    {
        ### Get the remote account id from the username
        $dbm = new db_mapping();
        $db = $dbm->DB_connect(false, $MAP_this->map['map']);
        eval('@$db_prefix = DB2_PREFIX' . strtoupper($MAP_this->map['map']) . ';');
        $sql = 'SELECT id FROM ' . $db_prefix . 'members
				WHERE name = ' . $db->qstr($username);
        $result = $db->Execute($sql);
        ### error reporting:
        if ($result === false) {
            global $C_debug;
            $C_debug->error('db_mapping.inc.php', 'Map_account_delete_misc_get_remote_account_id', $db->ErrorMsg());
            return;
        }
        $remote_account_id = $result->fields['id'];
        if ($remote_account_id != "") {
            ### Convert their posts and topics into guest postings..
            $dbm = new db_mapping();
            $db = $dbm->DB_connect(false, $MAP_this->map['map']);
            eval('@$db_prefix = DB2_PREFIX' . strtoupper($MAP_this->map['map']) . ';');
            $sql = 'UPDATE ' . $db_prefix . 'posts SET
					author_id=' . $db->qstr(0) . '
					WHERE author_id=' . $db->qstr($remote_account_id);
            $result = $db->Execute($sql);
            ### error reporting:
            if ($result === false) {
                global $C_debug;
                $C_debug->error('db_mapping.inc.php', 'Map_account_update_misc_posts_to_guests', $db->ErrorMsg());
                $smarty->assign('db_mapping_result', $db->ErrorMsg());
                return;
            }
            ### Convert their posts and topics into guest postings..
            $dbm = new db_mapping();
            $db = $dbm->DB_connect(false, $MAP_this->map['map']);
            eval('@$db_prefix = DB2_PREFIX' . strtoupper($MAP_this->map['map']) . ';');
            $sql = 'UPDATE ' . $db_prefix . 'topics SET
					starter_id=' . $db->qstr(0) . '
					WHERE starter_id=' . $db->qstr($remote_account_id);
            $result = $db->Execute($sql);
            ### error reporting:
            if ($result === false) {
                global $C_debug;
                $C_debug->error('db_mapping.inc.php', 'Map_account_update_misc_topics_to_guests', $db->ErrorMsg());
                $smarty->assign('db_mapping_result', $db->ErrorMsg());
                return;
            }
            ### Delete their profile listings
            $dbm = new db_mapping();
            $db = $dbm->DB_connect(false, $MAP_this->map['map']);
            eval('@$db_prefix = DB2_PREFIX' . strtoupper($MAP_this->map['map']) . ';');
            $sql = 'DELETE FROM ' . $db_prefix . 'pfields_content WHERE member_id=' . $db->qstr($remote_account_id);
            $result = $db->Execute($sql);
            ### error reporting:
            if ($result === false) {
                global $C_debug;
                $C_debug->error('db_mapping.inc.php', 'Map_account_delete_misc_topics_to_guests', $db->ErrorMsg());
                $smarty->assign('db_mapping_result', $db->ErrorMsg());
                return;
            }
            ### Delete member extra content
            $dbm = new db_mapping();
            $db = $dbm->DB_connect(false, $MAP_this->map['map']);
            eval('@$db_prefix = DB2_PREFIX' . strtoupper($MAP_this->map['map']) . ';');
            $sql = 'DELETE FROM ' . $db_prefix . 'member_extra WHERE id=' . $db->qstr($remote_account_id);
            $result = $db->Execute($sql);
            ### error reporting:
            if ($result === false) {
                global $C_debug;
                $C_debug->error('db_mapping.inc.php', 'Map_account_delete_misc_member_extra_content', $db->ErrorMsg());
                $smarty->assign('db_mapping_result', $db->ErrorMsg());
                return;
            }
            ### Delete member messages
            $dbm = new db_mapping();
            $db = $dbm->DB_connect(false, $MAP_this->map['map']);
            eval('@$db_prefix = DB2_PREFIX' . strtoupper($MAP_this->map['map']) . ';');
            $sql = 'DELETE FROM ' . $db_prefix . 'messages WHERE member_id=' . $db->qstr($remote_account_id);
            $result = $db->Execute($sql);
            ### error reporting:
            if ($result === false) {
                global $C_debug;
                $C_debug->error('db_mapping.inc.php', 'Map_account_delete_misc_member_messages', $db->ErrorMsg());
                $smarty->assign('db_mapping_result', $db->ErrorMsg());
                return;
            }
            ### Delete member contacts
            $dbm = new db_mapping();
            $db = $dbm->DB_connect(false, $MAP_this->map['map']);
            eval('@$db_prefix = DB2_PREFIX' . strtoupper($MAP_this->map['map']) . ';');
            $sql = 'DELETE FROM ' . $db_prefix . 'contacts WHERE member_id=' . $db->qstr($remote_account_id) . '
					OR contact_id=' . $db->qstr($remote_account_id);
            $result = $db->Execute($sql);
            ### error reporting:
            if ($result === false) {
                global $C_debug;
                $C_debug->error('db_mapping.inc.php', 'Map_account_delete_misc_member_contacts', $db->ErrorMsg());
                $smarty->assign('db_mapping_result', $db->ErrorMsg());
                return;
            }
            ### Delete member subscriptions tracker
            $dbm = new db_mapping();
            $db = $dbm->DB_connect(false, $MAP_this->map['map']);
            eval('@$db_prefix = DB2_PREFIX' . strtoupper($MAP_this->map['map']) . ';');
            $sql = 'DELETE FROM ' . $db_prefix . 'tracker WHERE member_id=' . $db->qstr($remote_account_id);
            $result = $db->Execute($sql);
            ### error reporting:
            if ($result === false) {
                global $C_debug;
                $C_debug->error('db_mapping.inc.php', 'Map_account_delete_misc_member_sub_tracker', $db->ErrorMsg());
                $smarty->assign('db_mapping_result', $db->ErrorMsg());
                return;
            }
            ### Delete member subscriptions forum tracker
            $dbm = new db_mapping();
            $db = $dbm->DB_connect(false, $MAP_this->map['map']);
            eval('@$db_prefix = DB2_PREFIX' . strtoupper($MAP_this->map['map']) . ';');
            $sql = 'DELETE FROM ' . $db_prefix . 'forum_tracker WHERE member_id=' . $db->qstr($remote_account_id);
            $result = $db->Execute($sql);
            ### error reporting:
            if ($result === false) {
                global $C_debug;
                $C_debug->error('db_mapping.inc.php', 'Map_account_delete_misc_member_sub_forum_tracker', $db->ErrorMsg());
                $smarty->assign('db_mapping_result', $db->ErrorMsg());
                return;
            }
            ### Delete member warn_logs
            $dbm = new db_mapping();
            $db = $dbm->DB_connect(false, $MAP_this->map['map']);
            eval('@$db_prefix = DB2_PREFIX' . strtoupper($MAP_this->map['map']) . ';');
            $sql = 'DELETE FROM ' . $db_prefix . 'warn_logs WHERE wlog_mid=' . $db->qstr($remote_account_id);
            $result = $db->Execute($sql);
            ### error reporting:
            if ($result === false) {
                global $C_debug;
                $C_debug->error('db_mapping.inc.php', 'Map_account_delete_misc_member_warn_logs', $db->ErrorMsg());
                $smarty->assign('db_mapping_result', $db->ErrorMsg());
                return;
            }
            ### Delete member from validating
            $dbm = new db_mapping();
            $db = $dbm->DB_connect(false, $MAP_this->map['map']);
            eval('@$db_prefix = DB2_PREFIX' . strtoupper($MAP_this->map['map']) . ';');
            $sql = 'DELETE FROM ' . $db_prefix . 'validating WHERE member_id=' . $db->qstr($remote_account_id);
            $result = $db->Execute($sql);
            ### error reporting:
            if ($result === false) {
                global $C_debug;
                $C_debug->error('db_mapping.inc.php', 'Map_account_delete_misc_member_validating', $db->ErrorMsg());
                $smarty->assign('db_mapping_result', $db->ErrorMsg());
                return;
            }
            ### Delete IBF member avatar picture
            $delete_avatars = new dbmapping_misc();
            $delete_avatars->ibf_delete_avatars($remote_account_id);
            ### Delete IBF member profile picture
            $delete_photos = new dbmapping_misc();
            $delete_photos->ibf_delete_photos($remote_account_id);
            ### Get the member count from the remote db
            $dbm = new db_mapping();
            $db = $dbm->DB_connect(false, $MAP_this->map['map']);
            eval('@$db_prefix = DB2_PREFIX' . strtoupper($MAP_this->map['map']) . ';');
            $sql = 'SELECT MEM_COUNT FROM ' . $db_prefix . 'stats';
            $result = $db->Execute($sql);
            ### error reporting:
            if ($result === false) {
                global $C_debug;
                $C_debug->error('db_mapping.inc.php', 'Map_account_add_misc_get_remote_stats', $db->ErrorMsg());
                return;
            }
            $mem_count = $result->fields['MEM_COUNT'] - 1;
            ### Update the IBF stats
            $dbm = new db_mapping();
            $db = $dbm->DB_connect(false, $MAP_this->map['map']);
            eval('@$db_prefix = DB2_PREFIX' . strtoupper($MAP_this->map['map']) . ';');
            $sql = 'UPDATE ' . $db_prefix . 'stats SET MEM_COUNT=' . $db->qstr($mem_count);
            $result = $db->Execute($sql);
            ### error reporting:
            if ($result === false) {
                global $C_debug;
                $C_debug->error('db_mapping.inc.php', 'Map_account_delete_misc_update_stats', $db->ErrorMsg());
                $smarty->assign('db_mapping_result', $db->ErrorMsg());
                return;
            }
        }
    }