Beispiel #1
0
function umc_create_map()
{
    global $UMC_SETTING, $UMC_DOMAIN, $UMC_PATH_MC, $UMC_ENV;
    $timer = array();
    $UMC_ENV = '2Dmap';
    $file = $UMC_SETTING['map_css_file'];
    $css = "\n" . '<style type="text/css">' . file_get_contents($file) . "\n";
    $worlds = array('city', 'empire', 'aether', 'flatlands', 'kingdom', 'draftlands', 'skyblock', 'empire_new');
    $longterm = $UMC_SETTING['longterm'];
    $s_post = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
    $s_get = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
    if (isset($s_get['world'])) {
        $world = $s_get['world'];
        if (!in_array($world, $worlds)) {
            exit;
        }
    } else {
        if (isset($s_post['world'])) {
            $world = $s_post['world'];
            if (!in_array($world, $worlds)) {
                exit;
            }
        } else {
            $world = 'empire';
        }
    }
    // get donators
    $donators = umc_users_donators();
    $track_player_icon = '';
    $find_lot = false;
    $settler_test = false;
    $track_player = false;
    // part of the settler test
    if (isset($s_post['settler_test'])) {
        $settler_test = true;
    } else {
        if (isset($s_post['track_player'])) {
            $player = $s_post['track_player'];
            $loc = umc_read_markers_file('array', $world);
            // something is wrong: player is not online or in the wrong world
            if (!isset($loc[$player])) {
                //umc_error_longmsg("Could not find player $player on the 2D map for the settler test! (track_player)\n" . umc_ws_vardump($loc));
                return "You need to be login on the server and be in the {$world} world to do this. Please go back to the previous page and try again.";
            } else {
                // player is in the right world.
                $track_player = true;
                $track_player_icon = "&identify_user={$player}";
            }
        } else {
            if (isset($s_post['guide_lot'])) {
                $player = $s_post['guide_lot'];
                $loc = umc_read_markers_file('array', $world);
                if (!isset($loc[$player])) {
                    XMPP_ERROR_trigger("Could not find player {$player} on the 2D map for the settler test! (guide_lot)\n" . umc_ws_vardump($loc));
                    return "You need to be login on the server and be in the {$world} world to do this. Please go back to the previous page and try again.";
                } else {
                    // player is in the right world.
                    $find_lot = true;
                    $track_player_icon = "&track_user={$player}";
                }
                $player_z = floor($loc[$player]['top']) + 20;
                $player_x = floor($loc[$player]['left']) + 10;
                $player_lot = $s_post['lot'];
            } else {
                $player_x = 0;
                $player_z = 0;
                $lot_x = 0;
                $lot_z = 0;
            }
        }
    }
    $lag = false;
    if (isset($s_get['lag'])) {
        $lag = true;
    }
    $freeonly = false;
    if (isset($s_get['freeonly']) && $s_get['freeonly'] == 'true' || isset($s_post['freeonly']) && $s_post['freeonly'] == 'true') {
        $freeonly = true;
    }
    $menu = '';
    if ($settler_test) {
        $menu .= "<form action=\"{$UMC_DOMAIN}/server-access/buildingrights/\" method=\"post\">\n" . "<input type=\"hidden\" name=\"step\" value=\"4\">\n<input type=\"hidden\" name=\"world\" value=\"{$world}\">\n";
    } else {
        if ($track_player) {
            $player_lot = $s_post['lot'];
            $menu .= "<form action=\"{$UMC_DOMAIN}/server-access/buildingrights/\" method=\"post\">\n" . "<input type=\"hidden\" name=\"step\" value=\"7\">\n<input type=\"hidden\" name=\"world\" value=\"{$world}\"><input type=\"hidden\" name=\"lot\" value=\"{$player_lot}\">\n";
        } else {
            if ($find_lot) {
                $menu .= "<form action=\"{$UMC_DOMAIN}/server-access/buildingrights/\" method=\"post\">\n" . "<input type=\"hidden\" name=\"step\" value=\"9\">\n<input type=\"hidden\" name=\"world\" value=\"{$world}\"><input type=\"hidden\" name=\"lot\" value=\"{$player_lot}\">\n";
            }
        }
    }
    $menu .= "<div id=\"menu_2d_map\">\n";
    if (!$settler_test && !$track_player && !$find_lot) {
        // create the top menu
        $menu .= umc_map_menu($worlds, $world, $freeonly);
    } else {
        if ($settler_test) {
            $menu .= "Pick a lot that looks nice to you. Closer to spawn is more convenient. <button type='button' onclick='find_spawn()'>Find Spawn</button> Then click here: " . "<input id=\"settler_test_next\" type=\"submit\" name=\"Next\" value=\"Next\">\n";
        } else {
            if ($find_lot) {
                $menu .= "Walk in-game along the red line to your lot {$player_lot} and then press " . "<input type=\"submit\" name=\"Next\" value=\"Next\"> <button type='button' onclick='find_spawn()'>Find Spawn</button> \n";
            } else {
                $menu .= "Find your user head on the map and click on the button next to it!";
            }
        }
    }
    $menu .= "</div>\n";
    $new_choices = array();
    if ($world == 'empire_new') {
        $rights = umc_region_data('empire');
        // this is for the empire_new move only:
        // var_dump($new_choices);
    } else {
        $rights = umc_region_data($world);
    }
    $timer['after_region_data'] = XMPP_ERROR_ptime();
    $map = $UMC_SETTING['world_img_dim'][$world];
    $image = "{$UMC_PATH_MC}/server/maps/" . $world . ".jpg";
    $size = array(0, 0);
    if (file_exists($image)) {
        $size = getimagesize($image);
    }
    $map_width = $size[0];
    $map_height = $size[1];
    if ($lag) {
        $heatworld = $world;
        $world .= '_heatmap';
    }
    $html = '';
    if ($find_lot) {
        $html = "<canvas id=\"lot_pointer\" style=\"position: absolute; top: 30px; left: 10px; z-index: 99;\" width=\"{$map_width}\" height=\"{$map_height}\"></canvas>\n";
    }
    $html .= '<div id="outer_box">' . "\n" . '    <img src="/map/' . $world . '.jpg" id="image_box" alt="map">' . "\n";
    if ($track_player) {
        $html .= umc_read_markers_file('identify_user', $world, $player);
    } else {
        if ($find_lot) {
            $html .= umc_read_markers_file('track_user', $world, $player);
        } else {
            if ($lag) {
                $html .= umc_read_markers_file('html', $heatworld);
            } else {
                $html .= umc_read_markers_file('html', $world);
            }
        }
    }
    //$repl_arr = array(',','-');
    $kingdom = '';
    if ($world == 'kingdom' || $world == 'draftlands') {
        $kingdom = 'center';
    }
    if (isset($UMC_SETTING['world_data'][$world]['spawn'])) {
        $spawn_lot = strtoupper($UMC_SETTING['world_data'][$world]['spawn']);
    } else {
        $spawn_lot = '';
    }
    // $old_users =
    $timer['before_owner_age'] = XMPP_ERROR_ptime();
    $all_lastlogins = umc_users_active_lastlogin_and_level();
    // what date was 1 month ago?
    $now_datetime = umc_datetime();
    $now_datetime->modify('-1 month');
    $one_months_ago = $now_datetime->format('Y-m-d H:i:s');
    $now_datetime->modify('-1 month');
    // what date was 2 months ago?
    $two_months_ago = $now_datetime->format('Y-m-d H:i:s');
    $timer['after_owner_age'] = XMPP_ERROR_ptime();
    $banned_users = umc_banned_users();
    $timer['after_banned_users'] = XMPP_ERROR_ptime();
    $css_lot_sizes = array();
    //$user_str = "<div class=\"user\">";
    //$css_lot_types = array();
    // var_dump($old_users);
    foreach ($rights as $lot => $opt) {
        $class = '';
        if (substr($lot, 0, 2) == '__') {
            continue;
        }
        // we need to switch for the proper coordinates
        // we need the 1 coordinate to be the top left one
        // Lot A1
        // min: {z: 1152.0, y: 0.0, x: -1280.0}
        // max: {z: 1279.0, y: 128.0, x: -1153.0}
        // take the larger X (west)
        $min = $opt['min'];
        $max = $opt['max'];
        if ($min['z'] < $max['z']) {
            $z1 = $min['z'];
            $z2 = $max['z'];
        } else {
            $z1 = $max['z'];
            $z2 = $min['z'];
        }
        // get the smaller z (north)
        if ($min['x'] < $max['x']) {
            $x1 = $min['x'];
            $x2 = $max['x'];
        } else {
            $x1 = $max['x'];
            $x2 = $min['x'];
        }
        $coord_1 = $x1;
        $coord_2 = $z1;
        $chunk = "Region " . floor($x1 / 512) . "/" . floor($z1 / 512) . ", Chunks " . floor($x1 / 16) . "/" . floor($z1 / 16);
        $x1 = conv_x($x1, $map);
        $x2 = conv_x($x2, $map);
        $z1 = conv_z($z1, $map);
        $z2 = conv_z($z2, $map);
        if ($find_lot && $player_lot == $lot) {
            $lot_x = $x1 + 60;
            $lot_z = $z1 + 60;
        }
        $lowercase_lot = $lot;
        $lot = strtoupper($lot);
        $lot_str = $lot;
        $width = $x2 - $x1 - 3;
        $height = $z2 - $z1 - 3;
        //$css .='#'. $lot . ' {width:'. $width. 'px; height:'. $height . 'px; top:' . $z1 . 'px; left:'. $x1 . 'px;}'. "\n";
        $css_lot_location = ' style="top:' . $z1 . 'px; left:' . $x1 . 'px;"';
        $css_lot_sizes["size{$width}_{$height}"] = '{width:' . $width . 'px; height:' . $height . 'px;}';
        $size_class = " size{$width}_{$height}";
        $user_string = '';
        $owner_string = '';
        // $box_color = '';
        $coord_str = "            <span class=\"coords\">{$coord_1}/{$coord_2}, {$chunk}</span>\n";
        //. '<span class="coords bottomleft">'.$x1.'/'.$z2.'</span>'
        //. '<span class="coords topright">'.$x2.'/'.$z1.'</span>'
        //. '<span class="coords bottomright">'.$x2.'/'.$z2.'</span>';
        if ($opt['owners']) {
            $owner_uuid = key($opt['owners']);
            $owner_username = $opt['owners'][$owner_uuid];
            // donation level
            $donation_level = false;
            if (isset($donators[$owner_uuid])) {
                $donation_level = $donators[$owner_uuid];
            }
            // find out who can keep their lot longer than 1 months
            $retain_lot = false;
            // kick out banned users
            if (isset($owner_uuid, $banned_users)) {
                $class = ' redout';
                $lastlogin_str = "Banned!";
            }
            $owner_lastlogin = $all_lastlogins[$owner_uuid]['lastlogin'];
            if (!isset($all_lastlogins[$owner_uuid]['userlevel'])) {
                XMPP_ERROR_trigger("{$owner_username} has no userlevel for the map!");
            }
            $lastlogin_str = $owner_lastlogin;
            $ownergroup = $all_lastlogins[$owner_uuid]['userlevel'];
            // who should be able to be away for 2 months?
            if (in_array($ownergroup, $longterm)) {
                $retain_lot = true;
            }
            // if we show only free lots, use different class
            $border = '';
            if (!$freeonly) {
                $border = 'border';
                // $box_color = ' background: rgba(0, 255, 255, 0.2);';
            }
            if ($retain_lot && $owner_lastlogin < $two_months_ago && $donation_level < 2) {
                // too late
                $class .= ' red' . $border;
            } else {
                if ($retain_lot && $owner_lastlogin < $one_months_ago && $donation_level < 2) {
                    // still yellow
                    $class .= ' yellow' . $border;
                } else {
                    if (!$retain_lot && $owner_lastlogin < $two_months_ago && $world == 'aether' && $donation_level < 1) {
                        $class .= ' red' . $border;
                    } else {
                        if (!$retain_lot && $owner_lastlogin < $one_months_ago && $donation_level < 1) {
                            $class .= ' red' . $border;
                        } else {
                            if (isset($new_choices[$lowercase_lot]) && !in_array($new_choices[$lowercase_lot]['choice'], array('keep', 'reset'))) {
                                $class .= ' whiteborder';
                            } else {
                                $class .= ' black' . $border;
                            }
                        }
                    }
                }
            }
            if (substr($lot, 0, 3) === 'CON') {
                $owner_string .= "{$owner_username}";
                $lot_str = substr($lot_str, 4);
                $class .= " small";
            } else {
                $owner_string .= "{$owner_username} ({$lastlogin_str})";
                $lot_str = $lot;
            }
        } else {
            $class .= ' whiteborder';
        }
        if ($opt['members']) {
            $members = array_unique($opt['members']);
            foreach ($members as $user) {
                $user_string .= "{$user} ";
            }
        }
        //        if ($opt['members']) {
        //            $members = array_unique($opt['members']);
        //            foreach ($members as $user) {
        //                $user_string .= "$user ";
        //            }
        //        }
        if ($opt['owners']) {
            $owner_string = "            <div class=\"Owner\">{$owner_string}</div>\n";
            if ($opt['members']) {
                $user_string = "            <span class=\"user\">{$user_string}</span>\n";
            }
        }
        $onclick = '';
        if ($settler_test && !$opt['owners']) {
            $onclick = " onclick=\"select_lot('radio_{$lot}', '{$lot}')\"";
        }
        $html .= "    <div id=\"{$lot}\" class=\"outerframe{$class}{$size_class}\"{$css_lot_location}{$onclick}>\n";
        if ($settler_test && !$opt['owners']) {
            $html .= "        <input id=\"radio_{$lot}\" class=\"settler_test\" type=\"radio\" name=\"lot\" value=\"{$lot}\"><label for=\"radio_{$lot}\">{$lot_str}</label>\n";
        } else {
            $html .= "        <div class=\"innertext {$kingdom}\">{$lot_str}<br>\n{$owner_string}{$user_string}{$coord_str}        </div>\n";
        }
        $html .= "    </div>\n";
    }
    $timer['after_regions_display'] = XMPP_ERROR_ptime();
    if ($settler_test || $track_player || $find_lot) {
        $html .= '</form>';
    }
    foreach ($css_lot_sizes as $class => $css_string) {
        $css .= ".{$class} {$css_string}\n";
    }
    if ($lag) {
        $world = $heatworld;
    }
    $css .= "</style>\n";
    $header = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <title>Uncovery Minecraft 2D Map: ' . $world . '</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript" src="/admin/js/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="/admin/js/jquery-ui.min.js"></script>
        <script type="text/javascript">
            function find_spawn() {
                window.scrollTo(($(document).width()-$(window).width())/2 + 60,($(document).height()-$(window).height())/2 - 60);
                doBlink("' . $spawn_lot . '");
            }
            function doBlink(element_id) {
                toggleBlink(element_id);
                setTimeout(function() {toggleBlink(element_id);}, 2000);
            }
            function toggleBlink(element_id) {
                $("#" + element_id).toggleClass("blink_me");
            }
            function toggleLotDisplay() {
                $(".blackborder").toggleClass("black");
                $(".redborder").toggleClass("red");
                $(".yellowborder").toggleClass("yellow");
            }
            function find_user(left, top, element_id) {
                window.scrollTo(left - ($(window).width() / 2), top - ($(window).height() / 2))
                $("#" + element_id).effect("shake");
            }
            function select_lot(lot_radio, lot_name) {
                $("#" + lot_radio).prop("checked", true);
                $("#settler_test_next").prop("value", "Chose Lot " + lot_name);
            }
            var markers_url = "' . $UMC_DOMAIN . '/admin/index.php?function=display_markers&world=' . $world . $track_player_icon . '";
            var markers_menu_url = "' . $UMC_DOMAIN . '/admin/index.php?function=display_markers&format=scrollto&world=' . $world . '";
            function update_positions() {
                $.ajax({
                    url: markers_menu_url,
                    success: function(data) {
                        $("#scroll_to_icons").remove();
                        $(data).insertAfter( "#link_3d_maps" );
                        // $("#link_3d_maps").html($("#link_3d_maps").html() + data);
                    }
                });
                $.ajax({
                    url: markers_url,
                    success: function(data) {
                        $("#marker_list").remove();
                        $("#outer_box").html(data + $("#outer_box").html());
                        setTimeout("update_positions()", 4000);' . "\n";
    if ($find_lot) {
        $header .= '                draw_line();
                    }
                });

            }
            function draw_line() {
                var player_left = parseInt($("#' . $player . '_marker").css("left"), 10) + 10;
                var player_top = parseInt($("#' . $player . '_marker").css("top"), 10) + 10;
                var c = document.getElementById("lot_pointer");
                var ctx = c.getContext("2d");
                ctx.setTransform(1, 0, 0, 1, 0, 0);
                ctx.beginPath();
                ctx.clearRect(0, 0, ' . $map_width . ', ' . $map_height . ');
                ctx.strokeStyle="red";
                ctx.moveTo(player_left, player_top);
                ctx.lineTo(' . $lot_x . ',' . $lot_z . ');
                ctx.stroke();
            }
';
    } else {
        $header .= '                        }
                    });
                }
';
    }
    if (!$settler_test) {
        $header .= '$(document).ready(function() {update_positions();});';
    }
    $header .= "\n</script>\n";
    $out = $header . $css . "</head>\n<body>\n" . $menu . $html . "</div>n</body>\n</html>\n";
    XMPP_ERROR_trace("construction done");
    echo $out;
}
/**
 * resets lots
 *
 * @global type $UMC_SETTING
 * @global array $UMC_PATH_MC
 * @param type $debug\
 */
function umc_lot_reset_process()
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    global $UMC_SETTING, $UMC_PATH_MC;
    // first of all, clean up user dibs
    umc_lot_manager_dib_cleanup();
    // get banned users UUID => username
    $banned_users = umc_banned_users();
    // var_dump($banned_users);
    // donators UUID => leftover days
    $donators = umc_users_donators();
    $dibs = umc_lot_manager_dibs_get_all();
    // Update all userlevels in UUID table
    $upd_sql = 'UPDATE minecraft_srvr.UUID
        LEFT JOIN minecraft_srvr.permissions_inheritance ON UUID.UUID=permissions_inheritance.child
        SET userlevel = parent
        WHERE parent != userlevel';
    umc_mysql_query($upd_sql, true);
    // get dates for -1 Month and -2 months
    $now_datetime = umc_datetime();
    $now_datetime->modify('-1 month');
    $one_months_ago = $now_datetime->format('Y-m-d H:i:s');
    $now_datetime->modify('-1 month');
    // what date was 2 months ago?
    $two_months_ago = $now_datetime->format('Y-m-d H:i:s');
    $longterm = $UMC_SETTING['longterm'];
    $source_path = "{$UMC_PATH_MC}/server/worlds/mint";
    $dest_path = "{$UMC_PATH_MC}/server/bukkit";
    // get all occupied lots and their owners
    // TODO: We should get first all expired users and reset their shop inventory, then do their lots.
    $list_sql = "SELECT region_id as lot, user.UUID as uuid, UUID.username as username, world.name as world, userlevel, lastlogin\n            FROM minecraft_worldguard.region_players LEFT JOIN minecraft_worldguard.user ON user_id=user.id\n            LEFT JOIN minecraft_worldguard.world ON world_id=world.id\n            LEFT JOIN minecraft_srvr.UUID ON user.UUID=UUID.UUID\n            WHERE owner=1 AND LEFT(region_id, 4) IN {$UMC_SETTING['lot_worlds_sql']}";
    $D = umc_mysql_fetch_all($list_sql);
    /**
     * Actions to be taken, with reasons
     */
    $A = array();
    foreach ($D as $row) {
        $owner_username = strtolower($row['username']);
        $owner_uuid = $row['uuid'];
        $owner_lastlogin = $row['lastlogin'];
        $owner_level = $row['userlevel'];
        if ($owner_username == 'uncovery') {
            // we do not reset uncovery's lots
            continue;
        }
        if ($owner_username == 'riedi77') {
            // we do not reset uncovery's lots
            continue;
        }
        // we do not reset active donators, except those who are banned
        if (isset($donators[$owner_uuid]) && !isset($banned_users[$owner_uuid])) {
            continue;
        }
        $lot = $row['lot'];
        $world = $row['world'];
        $lot_dibs = false;
        if (isset($dibs[$lot])) {
            $lot_dibs = $dibs[$lot];
        }
        // sanity check
        if (!isset($row['userlevel']) || !in_array($owner_level, $UMC_SETTING['ranks'])) {
            XMPP_ERROR_trigger("Could not reset lots, userlevel failure for Owner '{$owner_username} / {$owner_uuid} / {$owner_level}': {$list_sql}");
            die("userlevel error");
        }
        if (isset($banned_users[$owner_uuid])) {
            $A[$lot] = array('reason' => "{$lot} was reset because {$owner_username} / {$owner_uuid} was banned", 'source_world' => "{$source_path}/{$world}", 'dest_world' => "{$dest_path}/{$world}", 'remove_users' => true, 'reset_to' => $lot, 'user_shop_clean' => $owner_uuid, 'dibs' => $lot_dibs, 'version_sql' => false, 'del_skyblock_inv' => false);
        } else {
            if ($owner_username == '_abandoned_') {
                $A[$lot] = array('reason' => "{$lot} was reset because Owner was _abandoned_", 'source_world' => "{$source_path}/{$world}", 'dest_world' => "{$dest_path}/{$world}", 'remove_users' => true, 'reset_to' => $lot, 'user_shop_clean' => false, 'dibs' => $lot_dibs, 'version_sql' => false, 'del_skyblock_inv' => false);
            } else {
                $longterm_user = in_array($owner_level, $longterm);
                if ($owner_lastlogin < $two_months_ago && $longterm_user) {
                    $A[$lot] = array('reason' => "{$lot} was reset because {$owner_username} / {$owner_uuid} is 2 months protected but was absent for 2 months (last login {$owner_lastlogin})", 'source_world' => "{$source_path}/{$world}", 'dest_world' => "{$dest_path}/{$world}", 'remove_users' => true, 'reset_to' => $lot, 'user_shop_clean' => $owner_uuid, 'dibs' => $lot_dibs, 'version_sql' => false, 'del_skyblock_inv' => false);
                } else {
                    if ($owner_lastlogin < $one_months_ago && !$longterm_user) {
                        $A[$lot] = array('reason' => "{$lot} was reset because {$owner_username} / {$owner_uuid} was absent for 1 months (last login {$owner_lastlogin})", 'source_world' => "{$source_path}/{$world}", 'dest_world' => "{$dest_path}/{$world}", 'remove_users' => true, 'reset_to' => $lot, 'user_shop_clean' => $owner_uuid, 'dibs' => $lot_dibs, 'version_sql' => false, 'del_skyblock_inv' => false);
                    }
                }
            }
        }
        // reset skyblock inventories
        if ($world == 'skyblock' && isset($A[$lot])) {
            //
            $A[$lot]['del_skyblock_inv'] = $owner_uuid;
        }
    }
    // choice based resets
    $sql = "SELECT lot, world.name as world, choice, version, mint_version\n        FROM minecraft_srvr.lot_version\n        LEFT JOIN minecraft_worldguard.region ON lot=id\n        LEFT JOIN minecraft_worldguard.world ON world_id=world.id\n        WHERE SUBSTR(lot_version.lot, 1, 4) IN {$UMC_SETTING['lot_worlds_sql']} AND choice IS NOT NULL;";
    $R = umc_mysql_fetch_all($sql);
    // fixed choices:
    foreach ($R as $row) {
        $lot = $row['lot'];
        $version = $row['version'];
        $mint_version = $row['mint_version'];
        $choice = $row['choice'];
        $world = $row['world'];
        // reset the lot
        if ($choice == 'reset') {
            // any lot that can be reset
            // set the new version to the chosen lot
            $A[$lot] = array('reason' => "Lot {$lot} version was set from {$version} to {$mint_version} after reset", 'source_world' => "{$source_path}/{$world}", 'dest_world' => "{$dest_path}/{$world}", 'del_skyblock_inv' => false, 'remove_users' => false, 'reset_to' => $lot, 'user_shop_clean' => false, 'dibs' => false, 'version_sql' => "UPDATE minecraft_srvr.lot_version SET choice=NULL, version='{$mint_version}' WHERE lot='{$lot}' LIMIT 1;");
        } else {
            if ($choice == 'mint_king' && $world == 'draftlands') {
                $choice = umc_get_draftlands_kingdom_equivalent($lot);
                $A[$lot] = array('reason' => "Lot {$lot} version was reset to mint kingdom version {$choice} by user choice", 'source_world' => "{$source_path}/kingdom", 'dest_world' => "{$dest_path}/draftlands", 'del_skyblock_inv' => false, 'remove_users' => false, 'reset_to' => $choice, 'user_shop_clean' => false, 'dibs' => false, 'version_sql' => "UPDATE minecraft_srvr.lot_version SET choice=NULL, version='{$choice}' WHERE lot='{$lot}' LIMIT 1;");
            } else {
                if ($choice == 'curr_king' && $world == 'draftlands') {
                    $choice = umc_get_draftlands_kingdom_equivalent($lot);
                    $A[$lot] = array('reason' => "Lot {$lot} version was reset to current kingdom version {$choice} by user choice", 'source_world' => "{$dest_path}/kingdom", 'dest_world' => "{$dest_path}/draftlands", 'del_skyblock_inv' => false, 'remove_users' => false, 'reset_to' => $choice, 'user_shop_clean' => false, 'dibs' => false, 'version_sql' => "UPDATE minecraft_srvr.lot_version SET choice=NULL, version='{$choice}' WHERE lot='{$lot}' LIMIT 1;");
                } else {
                    // other non-default options to reset to, usually lot names on the same world
                    // assume that we always copy from the same world, but mint version
                    $A[$lot] = array('reason' => "Lot {$lot} version was reset to {$choice} (user choice)", 'source_world' => "{$source_path}/" . umc_get_lot_world($choice), 'dest_world' => "{$dest_path}/{$world}", 'del_skyblock_inv' => false, 'remove_users' => false, 'reset_to' => $choice, 'user_shop_clean' => false, 'dibs' => false, 'version_sql' => "UPDATE minecraft_srvr.lot_version SET choice=NULL, version='{$choice}' WHERE lot='{$lot}' LIMIT 1;");
                }
            }
        }
    }
    // iterate the items
    foreach ($A as $lot => $a) {
        umc_lot_manager_reset_lot($lot, $a);
    }
    XMPP_ERROR_trigger("Lot reset process finished");
}
function umc_ban_to_database()
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    die;
    global $UMC_SETTING;
    $ban_file = json_decode(file($UMC_SETTING['banned_players_file']));
    $banned_db = umc_banned_users();
    foreach ($ban_file as $D) {
        $uuid = $D['uuid'];
        $name = strtolower($D['name']);
        $date = $D['created'];
        $source = $D['source'];
        $reason = $D['reason'];
        $admin = $D['admin'];
        if (!in_array($uuid, $banned_db)) {
            $sql = "INSERT INTO minecraft_srvr.`banned_users`(`username`, `reason`, `admin`, `date`, `uuid`, `source`)\r\n                VALUES ('{$name}','{$reason}', '{$admin}', '{$date}', '{$uuid}', '{$source}');";
            umc_mysql_query($sql, true);
        }
    }
    /* format:
         *   {
        "uuid": "18d29691-51f1-4166-b2cb-46cab2b9fba0",
        "name": "iLoveMCPigs",
        "created": "2013-12-20 11:00:54 +0800",
        "source": "(Unknown)",
        "expires": "forever",
        "reason": "Banned by an operator."
      },
    
         */
}