Example #1
0
function umc_error_log()
{
    global $UMC_DOMAIN;
    $s_post = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
    if (isset($s_post['delete'])) {
        $del_id = $s_post['delete'];
        $sql_find = "SELECT * FROM minecraft_log.`error_log` WHERE error_id={$del_id};";
        $rst_find = umc_mysql_query($sql_find);
        $f_row = umc_mysql_fetch_array($rst_find);
        $file = umc_mysql_real_escape_string($f_row['file']);
        $sql_del = "DELETE FROM minecraft_log.`error_log`\r\n            WHERE `type`='{$f_row['type']}'\r\n\t\tAND `message`='{$f_row['message']}'\r\n\t\tAND `line`='{$f_row['line']}'\r\n\t\tAND `file`={$file};";
        $rst_del = umc_mysql_query($sql_del);
        umc_mysql_free_result($rst_del);
        umc_mysql_free_result($rst_find);
    }
    $sql = "SELECT min(error_id) AS sample, count(error_id) AS freq, `type`,`message`,`line`,`file`,`referer`,max(`datetime`) AS latest\r\n        FROM minecraft_log.`error_log`\r\n\tGROUP BY type, file, line, message\r\n\tORDER BY freq DESC ";
    $rst = umc_mysql_query($sql);
    $out = "<form class=\"shoptables\" action=\"{$UMC_DOMAIN}/error-log/\" method=\"POST\" style=\"font-size:80%\">\n" . "<table>\n<tr><th>Freq</th><th>Type</th><th>Message</th><th>Line</th><th>File</th><th>Date</th><th><input type=\"submit\" name=\"submit\" value=\"Solved\"></th></tr>\n";
    while ($row = umc_mysql_fetch_array($rst)) {
        $path = substr($row['file'], 15);
        $out .= "<tr><td>{$row['freq']}</td><td>{$row['type']}</td><td>{$row['message']}</td><td>{$row['line']}</td><td>{$path}</td><td>{$row['latest']}</td>" . "<td><input type=\"radio\" name=\"delete\" value=\"{$row['sample']}\"></tr>\n";
    }
    $out .= "</table>\n</form>\n";
    umc_mysql_free_result($rst);
    return $out;
}
Example #2
0
/**
 * 1) take all item_names from pasted wiki-code
 * 2) take all item_names from the data table UMC_DATA
 * 3) take all item names from the data table $UMC_DATA_ID2NAME
 * 4) check if they match
 * 5) check if any of the tables have unknown data
 *
 */
function umc_item_name_integrity_check()
{
    global $UMC_DATA, $UMC_DATA_ID2NAME, $UMC_DATA_SPIGOT2ITEM;
    $out = '';
    $text = '';
    $tables = array('request', 'deposit', 'stock');
    if (isset($_POST['wiki_text'])) {
        $results = false;
        $text = strip_tags($_POST['wiki_text']);
        $pattern = '/minecraft:(.*)\\r/';
        preg_match_all($pattern, $text, $results);
        // process results
        $sub_results = $results[1];
        foreach ($sub_results as $wiki_string) {
            if (!isset($UMC_DATA[$wiki_string])) {
                $out .= "{$wiki_string} ! UMC_DATA ERROR<br>";
            } else {
                // now check for umc_items
                $id = $UMC_DATA[$wiki_string]['id'];
                if ($UMC_DATA_ID2NAME[$id] != $wiki_string) {
                    $wrong_name = $UMC_DATA_ID2NAME[$id];
                    $out .= "{$wiki_string} ! UMC_ITEMS ERROR (ID: {$id}, {$wrong_name})<br>";
                }
            }
        }
        foreach ($UMC_DATA_SPIGOT2ITEM as $wrong_data => $right_data) {
            if (!isset($UMC_DATA[$right_data])) {
                $out .= "{$right_data} should not be in table ({$wrong_data})!";
            }
        }
        $out .= "<pre>";
        foreach ($tables as $table) {
            $sql = "SELECT item_name FROM minecraft_iconomy.{$table} group by item_name;";
            $rst = umc_mysql_query($sql);
            while ($D = umc_mysql_fetch_array($rst)) {
                $table_item = $D['item_name'];
                if (!in_array($table_item, $sub_results)) {
                    $out .= "UPDATE minecraft_iconomy.{$table} SET item_name='{$table_item}' WHERE item_name='{$table_item}';<br>";
                }
            }
        }
        $out .= "</pre>";
    }
    $out .= '<form style="text-align:center" method="post"><input type="submit">' . '<p><textarea name="wiki_text" rows="20" style="width=100%;">' . $text . '</textarea></p>' . '<input type="submit"></form>';
    return $out;
}
/**
 * maintenance function to give all empty lots of a world to the _abandoned_ user for reset
 */
function umc_lot_reset_all_empty()
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $sql = "SELECT region_cuboid.region_id as lot\n        FROM minecraft_worldguard.region_cuboid LEFT JOIN minecraft_worldguard.region_players ON region_cuboid.region_id=region_players.region_id\n        WHERE SUBSTR(region_cuboid.region_id, 1, 4) IN ('bloc') AND user_id IS NULL";
    $rst = umc_mysql_query($sql);
    while ($row = umc_mysql_fetch_array($rst)) {
        $lot = $row['lot'];
        umc_lot_add_player('_abandoned_', $lot, 1);
        echo "Processed lot {$lot}!<br>";
    }
}
Example #4
0
function umc_hunger_trophy()
{
    global $UMC_USER, $HUNGER;
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $args = $UMC_USER['args'];
    $player = $UMC_USER['username'];
    $uuid = $UMC_USER['uuid'];
    $game_id = isset($args[2]) ? $args[2] + 0 : null;
    if (!$game_id) {
        umc_error("[Hunger] {red}You must specify a [game-id] for which you were the winner.");
    }
    $victim = strtolower(umc_sanitize_input($args[3], 'player'));
    $victim_uuid = umc_user2uuid($victim);
    $sql_games = "SELECT *, timediff(NOW(),end) as age FROM minecraft_iconomy.hunger_games WHERE id = {$game_id}";
    $rst_games = umc_mysql_query($sql_games);
    if (mysql_num_rows($rst_games) > 0) {
        $game = umc_mysql_fetch_array($rst_games);
    }
    if (!$game) {
        umc_error("[Hunger] {red}No such game with game-id {yellow}{$game_id}");
    }
    if ($game['winner'] != $uuid) {
        umc_error("[Hunger] {red}You were not the winner of game-id {yellow}{$game_id}{red}.");
    }
    if ($game['trophy_claimed'] == 'y') {
        umc_error("[Hunger] {red}You already claimed a trophy for game-id {yellow}{$game_id}{red}.");
    }
    if ($game['age'] > '24:00:00') {
        // umc_error("{red}That game ended more than 24 hours ago, the corpses are too rotten.");
    }
    if ($victim_uuid == $uuid) {
        umc_error("[Hunger] {red}You can't claim your own head. Weirdo.");
    }
    umc_echo("finding players of game {$game_id}...");
    $HUNGER = umc_hunger_find_players($game_id);
    $players = $HUNGER['old_game'][$game_id]['players'];
    if (!in_array($victim, $players)) {
        umc_error("[Hunger] {red}{gold}{$victim}{red} was not vanquished in that game.");
    }
    umc_echo("checking your account balance....");
    $balance = umc_money_check($player);
    if ($balance < $HUNGER['trophy_cost']) {
        umc_error("[Hunger] {red}You can't afford a trophy, they cost {green}{$HUNGER['trophy_cost']} Uncs");
    }
    umc_echo("Account is fine...");
    $item_slot = $UMC_USER['current_item'];
    if ($item_slot != 0 || isset($UMC_USER['inv'][$item_slot])) {
        umc_error("[Hunger] {red}You have to pick first hotbar slot, and it has to be empty.");
    }
    umc_echo("[Hunger] all good, taking trophy...");
    #-- All good, do the work!
    $sql = "UPDATE minecraft_iconomy.hunger_games SET trophy_claimed = 'y' WHERE id = {$game_id}";
    umc_mysql_query($sql, true);
    umc_echo("[Hunger] charging {$HUNGER['trophy_cost']}...");
    umc_money($player, false, $HUNGER['trophy_cost']);
    umc_echo("[Hunger] {yellow}[\$]{gray} You have been charged {yellow}{$HUNGER['trophy_cost']}{gray} uncs.");
    umc_echo("[Hunger] getting head...");
    // umc_ws_cmd("give $player 397:3 1","asConsole");
    umc_ws_cmd("ph spawn {$victim} {$player}", "asConsole");
    umc_echo("[Hunger] {purple}Enjoy this small memento of your victory!");
    umc_log('hunger', 'trophy', "{$player} got the head of {$victim}");
}
Example #5
0
function umc_donation_calc_average()
{
    $sql_count = "SELECT count(UUID) AS count FROM minecraft_srvr.donations;";
    $rst_count = umc_mysql_query($sql_count);
    $row_count = umc_mysql_fetch_array($rst_count);
    umc_mysql_free_result($rst_count);
    $donator_count = $row_count['count'];
    $sql_sum = "SELECT sum(amount) as sum from minecraft_srvr.donations;";
    $row_sum = umc_mysql_fetch_all($sql_sum);
    $donation_sum = $row_sum[0]['sum'];
    $donation_avg = round($donation_sum / $donator_count, 2);
    return $donation_avg;
}
Example #6
0
function umc_user_directory()
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    // list all users
    $username_get = filter_input(INPUT_GET, 'u', FILTER_SANITIZE_STRING);
    if (!is_null($username_get)) {
        $O = array();
        $wordpress_id = umc_user_get_wordpress_id($username_get);
        $username = strtolower(umc_check_user($username_get));
        if (!$wordpress_id) {
            return "User does not exist!";
        }
        $uuid = umc_user2uuid($username);
        // check if the user is active
        $count_lots = umc_user_countlots($uuid);
        if ($count_lots == 0) {
            return "User is not active!";
        }
        // user icon
        $O['User'] = get_avatar($wordpress_id, $size = '96') . "<p><strong>Username:</strong> {$username}</p>\n" . "<p><strong>UUID:</strong> {$uuid}</p>\n";
        $previous_names = umc_uuid_username_history($uuid);
        if ($previous_names) {
            $O['User'] .= "<p><strong>Usernames History:</strong> {$previous_names}</p>\n";
        }
        // is user banned?
        if (umc_user_is_banned($uuid)) {
            $O['User'] .= "<p><strong>User is BANNED!</strong></p>\n";
            return;
        }
        // get userlevel
        $level = umc_get_uuid_level($uuid);
        $karma = umc_getkarma($uuid, true);
        $money = umc_money_check($uuid);
        $O['User'] .= "<p><strong>Level:</strong> {$level}</p>\n" . "<p><strong>Karma:</strong> {$karma}</p>\n" . "<p><strong>Money:</strong> {$money} Uncs</p>\n";
        // get lots
        $lots = umc_user_getlots($uuid);
        foreach ($lots as $data) {
            $world = ucwords($data['world']);
            $combined_worlds = array('Empire', 'Flatlands', 'Skyblock');
            if (in_array($world, $combined_worlds)) {
                $world = 'Small lots';
            }
            if (!isset($O[$world])) {
                $O[$world] = '';
            }
            $O[$world] .= $data['image'];
        }
        $donator_level = umc_users_donators($uuid);
        if ($donator_level > 12) {
            $donator_str = 'More than 1 year';
        } else {
            if ($donator_level) {
                $donator_level_rounded = round($donator_level, 1);
                $donator_str = "{$donator_level_rounded} Months";
            } else {
                $donator_str = "Not a donator";
            }
        }
        $O['User'] .= "<p><strong>Donations remaining:</strong> {$donator_str}</p>\n";
        // get member since
        $online_time = umc_get_lot_owner_age('days', $uuid);
        if ($online_time) {
            $lastlogin = $online_time[$uuid]['lastlogin']['days'];
            $firstlogin = $online_time[$uuid]['firstlogin']['days'];
            $O['User'] .= "<p><strong>Member since:</strong> {$firstlogin} days</p>\n" . "<p><strong>Offline since:</strong> {$lastlogin} days</p>\n";
        }
        // get user bio
        $sql = "SELECT meta_value FROM minecraft.wp_users\r\n            LEFT JOIN minecraft.wp_usermeta ON wp_users.ID = wp_usermeta.user_id\r\n            WHERE display_name='{$username}' AND meta_key='description';";
        $D = umc_mysql_fetch_all($sql);
        if (count($D) > 0) {
            $row = $D[0];
            $O['User'] .= "<p><strong>Bio:</strong> " . $row['meta_value'] . "</p>\n";
        }
        // comments
        $sql2 = "SELECT comment_date, comment_author, id, comment_id, post_title FROM minecraft.wp_comments\r\n            LEFT JOIN minecraft.wp_posts ON comment_post_id=id\r\n            WHERE comment_author = '{$username}' AND comment_approved='1' AND id <> 'NULL'\r\n            ORDER BY comment_date DESC";
        $D2 = umc_mysql_fetch_all($sql2);
        if (count($D2) > 0) {
            $O['Comments'] = "<strong>Comments:</strong> (" . count($D2) . ")\n<ul>\n";
            foreach ($D2 as $row) {
                $O['Comments'] .= "<li>" . $row['comment_date'] . " on <a href=\"/index.php?p=" . $row['id'] . "#comment-" . $row['comment_id'] . "\">" . $row['post_title'] . "</a></li>\n";
            }
            $O['Comments'] .= "</ul>\n";
        }
        //forum posts
        $sql3 = "SELECT wpp.id AS id, wpp.post_title AS title, wpp.post_date AS date,\r\n\t\twpp.post_parent AS parent, wpp.post_type AS type, parent.post_title AS parent_title\r\n            FROM minecraft.wp_posts AS wpp\r\n\t    LEFT JOIN minecraft.wp_users ON wpp.post_author=wp_users.id\r\n\t    LEFT JOIN minecraft.wp_posts AS parent ON parent.id=wpp.post_parent\r\n\t    WHERE wp_users.display_name='{$username}'\r\n\t\tAND (wpp.post_type='reply' OR wpp.post_type='topic')\r\n\t\tAND wpp.post_status='publish'\r\n\t    ORDER BY wpp.post_date DESC";
        $D3 = umc_mysql_fetch_all($sql3);
        // echo $sql;
        if (count($D3) > 0) {
            $O['Forum'] = "<strong>Forum Posts:</strong> (" . count($D3) . ")\n<ul>\n";
            foreach ($D3 as $row) {
                $date = $row['date'];
                if ($row['type'] == 'reply') {
                    $link = $row['parent'] . "#post-" . $row['id'];
                    $title = $row['parent_title'];
                } else {
                    $link = $row['id'];
                    $title = $row['title'];
                }
                $O['Forum'] .= "<li>{$date} on <a href=\"/index.php?p={$link}\">{$title}</a></li>\n";
            }
            $O['Forum'] .= "</ul>\n";
        }
        echo umc_jquery_tabs($O);
    } else {
        // $bans = umc_get_banned_users();
        //var_dump($bans);
        $out = "<script type=\"text/javascript\" src=\"/admin/js/jquery.dataTables.min.js\"></script>\n" . "<script type=\"text/javascript\">\n" . 'jQuery(document).ready(function() {jQuery' . "('#shoptable_users').dataTable( {\"order\": [[ 2, \"desc\" ]],\"paging\": false,\"ordering\": true,\"info\": true} );;} );\n" . "</script>\n" . "This table only tracks online time since 2013-11-20.<br>" . '<table id="shoptable_users"><thead>' . "<th>Username</th>" . "<th>Level</th>" . "<th>Registered days</th>" . "<th>Offline days</th>" . "<th>Lots</th>" . "<th>Online min/day</th>" . "<th>Online hrs</th>" . "</thead>\n<tbody>\n";
        $sql = "SELECT username, DATEDIFF(NOW(),firstlogin) as registered_since, parent as userlevel, count(owner) as lot_count, onlinetime, DATEDIFF(NOW(), lastlogin) as days_offline\r\n            FROM minecraft_srvr.UUID\r\n            LEFT JOIN minecraft_srvr.permissions_inheritance ON UUID.uuid=child\r\n            LEFT JOIN minecraft_worldguard.user ON UUID.uuid = user.uuid\r\n            LEFT JOIN minecraft_worldguard.region_players ON user.id=region_players.user_id\r\n            WHERE owner = 1 AND firstlogin >'0000-00-00 00:00:00' AND username <> '_abandoned_'\r\n            GROUP BY username, owner\r\n            ORDER BY firstlogin";
        $rst = umc_mysql_query($sql);
        $now = time();
        // or your date as well
        $your_date = strtotime("2013-11-20");
        $datediff = $now - $your_date;
        $alt_days = floor($datediff / (60 * 60 * 24));
        while ($row = umc_mysql_fetch_array($rst)) {
            $days_offline = $row['days_offline'];
            $settler_levels = array('Settler', 'SettlerDonator', 'SettlerDonatorPlus');
            if (in_array($row['userlevel'], $settler_levels) && $row['onlinetime'] >= 60) {
                umc_promote_citizen(strtolower($row['username']), $row['userlevel']);
            }
            if ($row['registered_since'] - $days_offline > 1) {
                if ($alt_days < $row['registered_since']) {
                    // people who are not in the lb-players database should not be listed, they are too old
                    if ($alt_days - $days_offline == 0) {
                        continue;
                    }
                    $avg_online = floor($row['onlinetime'] / 60 / $alt_days);
                } else {
                    $avg_online = floor($row['onlinetime'] / 60 / $row['registered_since']);
                }
            } else {
                $avg_online = 0;
            }
            $online_total = round($row['onlinetime'] / 60 / 60);
            $icon_url = umc_user_get_icon_url($row['username']);
            $out .= "<tr>" . "<td><img title='{$row['username']}' src='{$icon_url}' alt=\"{$row['username']}\"> <a href=\"?u={$row['username']}\">{$row['username']}</a></td>" . "<td>{$row['userlevel']}</td>" . "<td class='numeric_td'>{$row['registered_since']}</td>" . "<td class='numeric_td'>{$days_offline}</td>" . "<td class='numeric_td'>{$row['lot_count']}</td>" . "<td class='numeric_td'>{$avg_online}</td>" . "<td class='numeric_td'>{$online_total}</td>" . "</tr>\n";
        }
        $out .= "</tbody>\n</table>\n";
        echo $out;
    }
}
function umc_skyblock_challenge_select()
{
    global $UMC_USER;
    $player = $UMC_USER['username'];
    $args = $UMC_USER['args'];
    if (!is_numeric($args[2])) {
        umc_error("Your challenge ID needs to be a number!");
    } else {
        $lot_sql = "SELECT region_cuboid.region_id as lot FROM `region_cuboid`\r\n            LEFT JOIN region_players ON region_cuboid.region_id=region_players.region_id\r\n            WHERE user_id IS NULL\r\n\t\tAND region_cuboid.`region_id` LIKE 'block%'\r\n\t\tAND min_z<-768\r\n\t\tAND min_x>=-1152\r\n\t\tAND max_x<1024;";
        $D = umc_mysql_fetch_all($lot_sql);
        if (count($D) == 0) {
            XMPP_ERROR_trigger("We ran out of challenge lots!");
            umc_error("Sorry, there are currently no challenge lots free!");
        } else {
            $lot_row = $D[0];
            $challenge_lot = $lot;
        }
        $id = $args[2];
        $sql = "SELECT * FROM minecraft_quiz.block_challenges WHERE challenge_id={$id};";
        $rst = umc_mysql_query($sql);
        $row = umc_mysql_fetch_array($rst);
        $lot = $row['lot'];
        $biome = $row['biome'];
        $inventory = $row['inventory'];
        $name = $row['name'];
        $desc = $row['desc'];
        $win_conditions = $row['win_conditions'];
        umc_header("Challenge {$id}: {$name}");
        umc_echo("{white}{$desc}");
        $lot_str = $lot;
        if ($lot == null) {
            $lot_str = 'standard';
        }
        umc_echo("{green}Lot type: {white}{$lot_str}");
        $biome_str = $biome;
        if ($biome == null) {
            $biome_str = 'standard';
        }
        umc_echo("{green}Lot type: {white}{$biome_str}");
        if (umc_skyblock_web_display_table($id)) {
            umc_echo("{green}Sub challenges: {white}This challenge has subchallenges. Please see the website for details.");
        }
        $inv_str = umc_skyblock_inv_to_desc($inventory);
        umc_echo("{green}Starting Inventory:{white}{$inv_str}");
        $winstr = umc_skyblock_inv_to_desc($win_conditions);
        umc_echo("{green}Winning conditions:{white}{$winstr}");
        $sub_challenge = $row['sub_challenge'];
        $challenge = $id;
        if ($sub_challenge !== null) {
            $challenge = $sub_challenge;
        }
        $sql = "INSERT INTO `minecraft_quiz`.`block_games` (`game_id`, `username`, `start`, `end`, `status`, `challenge_id`, `sub_challenge_id`, `lot`)\r\n            VALUES (NULL, '{$player}', NOW(), NULL, 'selected', '{$challenge}', '{$sub_challenge}', '{$challenge_lot}');";
        umc_mysql_query($sql, true);
        umc_echo("Please type {green}/skyblock start{white} or {green}/skyblock cancel");
        umc_footer();
    }
}
/**
 * move all items from the shop to deposit for a specific user
 * Normally only used when users are banned or inactive, on lot reset
 *
 * @param type $uuid
 */
function umc_shop_cleanout_olduser($uuid)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    // delete all requests
    $requests_sql = "DELETE FROM minecraft_iconomy.request WHERE uuid='{$uuid}';";
    umc_mysql_query($requests_sql, true);
    // move all items from stock to deposit
    $sql = "SELECT * FROM minecraft_iconomy.stock WHERE uuid='{$uuid}';";
    $rst = umc_mysql_query($sql);
    while ($row = umc_mysql_fetch_array($rst)) {
        umc_checkout_goods($row['id'], 'max', 'stock', true, true, $uuid);
    }
    umc_log('user_manager', 'shop-cleanout', "{$uuid} had his items moved from stock & request to deposit");
}