Exemplo n.º 1
0
/**
 * Create a jQuery accordion
 *
 * @global array $UMC_FAQ
 * @param type $id
 * @return string
 */
function umc_faq_web($id = 'accordion')
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    global $UMC_FAQ;
    $s_get = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
    if (isset($s_get['id']) && isset($UMC_FAQ[$s_get['id']])) {
        $active = $s_get['id'] - 1;
    } else {
        $active = 0;
    }
    if (isset($s_get['cat'])) {
        $presel_cat = $s_get['cat'];
    } else {
        $presel_cat = 'all';
    }
    $out = "<script>\r\n    jQuery(document).ready(function(\$) {\r\n        \$( \"#{$id}\" ).accordion({\r\n            collapsible: true, heightStyle: \"content\", active: {$active}\r\n        });\r\n    });\r\n</script>" . "<div id=\"{$id}\">\n";
    $cat_arr = array('all' => 'All');
    foreach ($UMC_FAQ as $faq_id => $F) {
        // we cannot do array_merge since we need to set the keys for the dropdown
        foreach ($F['categories'] as $cat) {
            $cat_arr[$cat] = ucwords($cat);
        }
        $cat_text = implode(", ", $F['categories']);
        if ($presel_cat == 'all' || in_array($presel_cat, $F['categories'])) {
            $out .= "    <h3 id=\"FAQ{$faq_id}\">{$faq_id}: {$F['question']}</h3>\r\n            <div>\r\n                <p class=\"answer\">{$F['answer']}</p>\r\n                <p class=\"categories\"><a href=\"?id={$faq_id}#FAQ{$faq_id}\">Direct link</a> | Categories: {$cat_text}</p>\r\n            </div>";
        }
    }
    $out .= "</div>";
    $drop = "Categories: <form style=\"display:inline;\" action=\"\" method=\"get\">\n" . umc_web_dropdown($cat_arr, 'cat', $presel_cat, true) . "</form>";
    $out = $drop . $out;
    return $out;
}
Exemplo n.º 2
0
function run_umc_scheduler()
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    // list of what to do & undo or temp permissions
    $schedule_arr = array(1 => array('on_cmd' => array(0 => 'ch qm u Today bloody is Monday, beware of the mobs!', 1 => 'bloodmoon start darklands'), 'off_cmd' => array()), 2 => array('on_cmd' => array(0 => 'ch qm u Today is Tuesday, nothing special!', 1 => 'bloodmoon stop darklands', 2 => 'time 00:00 darklands'), 'off_cmd' => array()), 3 => array('on_cmd' => array(0 => 'ch qm u Hungry Wednesday started!', 1 => 'mv modify set autoheal false darklands', 2 => 'mv gamerule naturalRegeneration false darklands', 3 => 'region flag darklands_spawn greeting -w darklands ATTENTION: Today Darklands autoheal is OFF! You being fed does not heal you!'), 'off_cmd' => array(0 => 'ch qm u Hungry Wednesday is over!', 1 => 'mv modify set autoheal true darklands', 2 => 'mv gamerule naturalRegeneration true darklands', 3 => 'region flag darklands_spawn greeting -w darklands Welcome to the Darklands! Today everything is normal. Whatever that means.')), 4 => array('on_cmd' => array(0 => 'ch qm u Today is Thursday, nothing special!'), 'off_cmd' => array()), 5 => array('on_cmd' => array(0 => 'ch qm u Freaky Frydays started!', 1 => 'time 12:00 darklands', 2 => 'sunburn darklands on', 3 => 'region flag darklands_spawn greeting -w darklands ATTENTION: Today it\'s daylight in the Darklands, but the sun will burn you! find shadow!'), 'off_cmd' => array(0 => 'ch qm u Freaky Frydays is over!', 1 => 'time 00:00 darklands', 2 => 'sunburn darklands off', 3 => 'region flag darklands_spawn greeting -w darklands Welcome to the Darklands! Today everything is normal. Whatever that means.')), 6 => array('on_cmd' => array(0 => 'ch qm u Today is Saturday, nothing special!'), 'off_cmd' => array()), 0 => array('on_cmd' => array(0 => 'mv modify set pvp true darklands', 1 => 'region flag darklands_spawn greeting -w darklands ATTENTION: Today Darklands is PVP ON! You are safe here, but further out it\'s dangerous!', 2 => 'ch qm u ATTENTION: PVP is now ON in the darklands (except the area around spawn)!', 3 => 'region flag darklands_spawn farewell -w darklands ATTENTION: You are now entering a PVP area!!'), 'off_cmd' => array(0 => 'mv modify set pvp false darklands', 1 => 'region flag darklands_spawn greeting -w darklands Today Darklands is PVP OFF!', 2 => 'ch qm u ATTENTION: PVP is now OFF in the darklands. You are safe!', 3 => 'region flag darklands_spawn farewell -w darklands Welcome to the Darklands! Today everything is normal. Whatever that means.')));
    // find current day
    $date_new = umc_datetime();
    $today = $date_new->format('w');
    // echo "Echo today is $today: " . $date_new->format("Y-m-d H:i:s");
    if ($today == 0) {
        $yesterday = 6;
    } else {
        $yesterday = $today - 1;
    }
    // execute last day's off-commands
    $cmds = $schedule_arr[$yesterday]['off_cmd'];
    // var_dump($cmds);
    umc_schedule_exec($cmds);
    umc_log('scheduler', "yesterday", "executing commands for yesterday: {$yesterday}");
    // execute todays on-commands
    $cmds = $schedule_arr[$today]['on_cmd'];
    umc_log('scheduler', "today", "executing commands for yesterday: {$today}");
    umc_schedule_exec($cmds);
    $default_commands = array("mv gamerule doDaylightCycle false darklands", "mv gamerule naturalRegeneration false deathlands");
    foreach ($default_commands as $cmd) {
        umc_exec_command($cmd);
    }
    umc_ban_to_database();
    // make a new ID file in case item data has changed
    include_once '/home/minecraft/server/bin/commands/make_id_file.php';
}
Exemplo n.º 3
0
function umc_info_setpass()
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    global $UMC_USER;
    $uuid = $UMC_USER['uuid'];
    $user_login = umc_wp_get_login_from_uuid($uuid);
    // get userdata
    // this code is copied from wp-login.php, round line 325, grep for 'get_password_reset_key'
    $user_data = get_user_by('login', $user_login);
    $reset_key = get_password_reset_key($user_data);
    $url = network_site_url("wp-login.php?action=rp&key={$reset_key}&login="******"Password Reset Link");
    umc_echo("Please click on the following link to set a new password:");
    umc_echo($shortenedurl);
    umc_footer();
}
 /**
  * Connects to a Websend server.
  * Returns true if successful.
  */
 public function connect()
 {
     XMPP_ERROR_trace(__FUNCTION__, func_get_args());
     $this->stream = fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
     if ($this->stream) {
         $this->writeRawByte(21);
         $this->writeString("websendmagic");
         $seed = $this->readRawInt();
         $hashedPassword = hash($this->hashAlgorithm, $seed . $this->password);
         $this->writeString($hashedPassword);
         $result = $this->readRawInt();
         if ($result == 1) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
 public function ban($reason)
 {
     XMPP_ERROR_trace(__CLASS__ . " // " . __FUNCTION__, func_get_args());
     global $UMC_USERS;
     $cmd = "ban {$this->username} {$reason}";
     if ($this->context == 'websend') {
         umc_ws_cmd($cmd, 'asConsole', false, false);
         $admin = $UMC_USERS['current_user']->username;
     } else {
         umc_exec_command($cmd, 'asConsole', false);
         $admin = 'wordpress';
     }
     $sql = "INSERT INTO minecraft_srvr.`banned_users`(`username`, `reason`, `admin`, `uuid`) VALUES ('{$this->username}','{$reason}', '{$admin}', '{$this->uuid}');";
     umc_mysql_query($sql, true);
     // remove shop inventory
     umc_shop_cleanout_olduser($this->uuid);
     // remove from teamspeak
     umc_ts_clear_rights($this->uuid);
     $text = "{$admin} banned \${$this->username} ({$this->uuid}) because of {$reason}";
     umc_log('mod', 'ban', $text);
     XMPP_ERROR_send_msg($text);
     // iterate plugins to check for plugin relared post ban processes
 }
function umc_array2file_line($array, $layer, $val_change_func = false)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $in_text = umc_array2file_indent($layer);
    $out = "";
    foreach ($array as $key => $value) {
        if ($val_change_func) {
            $value = $val_change_func($key, $value);
        }
        $out .= "{$in_text}'{$key}' => ";
        if (is_array($value)) {
            $layer++;
            $out .= "array(\n" . umc_array2file_line($value, $layer, $val_change_func) . "{$in_text}),\n";
            $layer--;
        } else {
            if (is_numeric($value)) {
                $out .= "{$value},\n";
            } else {
                $out .= "'{$value}',\n";
            }
        }
    }
    return $out;
}
Exemplo n.º 7
0
/**
 * Converts a JSON date to a DateTime Object
 *
 * @param string $json_date
 * @return DateTimeObj or false
 */
function umc_timer_from_json($json_date)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    // do we have a timezone string or not?
    if (strlen($json_date) == 13) {
        $json_date .= "-0000";
    }
    //1433044095000 <- No timezone
    //1365004652303-0500 <- timezone
    $pattern = '/(\\d{10})(\\d{3})([\\+\\-]\\d{4})/';
    $format = "U.u.O";
    $mask = '%2$s.%3$s.%4$s';
    $matches = false;
    $r = preg_match($pattern, $json_date, $matches);
    if (!$r) {
        XMPP_ERROR_trigger("Failed to match date in {$json_date}");
    }
    $buffer = vsprintf($mask, $matches);
    $result = DateTime::createFromFormat($format, $buffer);
    if (!$result) {
        XMPP_ERROR_trigger(sprintf('Failed To Create from Format "%s" for "%s".', $format, $buffer));
    }
    return $result;
}
Exemplo n.º 8
0
function umc_bottomkarma()
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $sql = "SELECT SUM(karma) as sum_karma, receivers.username as receiver_name FROM minecraft_srvr.karma\r\n        LEFT JOIN minecraft_srvr.UUID as senders ON sender_uuid=senders.UUID\r\n        LEFT JOIN minecraft_srvr.UUID as receivers ON receiver_uuid=receivers.UUID\r\n        WHERE senders.lot_count > 0 AND receivers.lot_count > 0\r\n        GROUP BY receivers.username\r\n        HAVING sum(karma) < 0\r\n        ORDER BY sum(karma) ASC LIMIT 0,10";
    $D = umc_mysql_fetch_all($sql);
    umc_echo("Bottom ten Karma users:");
    umc_echo("-∞     =>    Uncovery");
    foreach ($D as $row) {
        $sum_karma = $row['sum_karma'];
        $receiver = $row['receiver_name'];
        if (!umc_user_is_banned($receiver)) {
            umc_echo("{$sum_karma}    =>    {$receiver}");
        }
    }
}
Exemplo n.º 9
0
 function write()
 {
     global $UNC_GALLERY;
     if ($UNC_GALLERY['debug']) {
         XMPP_ERROR_trace(__FUNCTION__, func_get_args());
     }
     if (!function_exists('iptcembed')) {
         if ($UNC_GALLERY['debug']) {
             XMPP_ERROR_trace(__FUNCTION__, "iptcembed Does not exist!!");
         }
         return false;
     }
     $mode = 0;
     $content = iptcembed($this->binary(), $this->file, $mode);
     $filename = $this->file;
     @unlink($filename);
     #delete if exists
     $fp = fopen($filename, "w");
     fwrite($fp, $content);
     fclose($fp);
 }
Exemplo n.º 10
0
function umc_mysql_fetch_all($sql)
{
    global $UNC_DB;
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $stmt = $UNC_DB['link']->prepare($sql);
    if (!$stmt) {
        $error = $UNC_DB['link']->errorInfo();
        XMPP_ERROR_trigger($error);
        return false;
    } else {
        $stmt->execute();
    }
    $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
    return $result;
}
Exemplo n.º 11
0
function umc_mod_blockcheck_fill_inv($start)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    global $UMC_DATA, $UMC_USER;
    $end_item = 'record_wait';
    $username = $UMC_USER['username'];
    $inv_slots = 36;
    $c = 0;
    $started = false;
    foreach ($UMC_DATA as $item_name => $D) {
        if ($c >= $start && !$started) {
            $started = true;
        }
        $id = 0;
        if (!isset($D['subtypes'])) {
            $D['subtypes'] = array(0 => array('name' => $item_name, 'avail' => $D['avail']));
        }
        foreach ($D['subtypes'] as $id => $d) {
            // we assume that the current availability information is correct
            $avail = $d['avail'];
            if ($avail) {
                umc_ws_cmd("give {$username} {$item_name}:{$id} 1;", 'asConsole');
                $c++;
            }
            // we bail if we filled the inventory
            // and return the current position in the array
            if ($c == $inv_slots) {
                return array('item_name' => $item_name, 'id' => $id, 'count' => $c);
            }
        }
    }
}
Exemplo n.º 12
0
/**
 * returns likely accounts shared by UUIDs
 * 
 */
function umc_web_usercheck()
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $tables = array('Same IP' => 'last_ip', 'Same Browser' => 'browser_id', 'Same TeamSpeak' => 'ts_uuid');
    $out = '';
    foreach ($tables as $table_name => $crit_field) {
        $sql = "SELECT {$crit_field} FROM minecraft_srvr.UUID WHERE {$crit_field} <> '' " . "GROUP BY {$crit_field} HAVING count({$crit_field}) > 1 ORDER BY count({$crit_field}) DESC, onlinetime DESC";
        $L = umc_mysql_fetch_all($sql);
        $out_arr = array();
        foreach ($L as $l) {
            $line_sql = "SELECT username, userlevel, lot_count, onlinetime, INET_NTOA(last_ip) as ip, " . "CONCAT(browser_id, '<br>', ts_uuid) AS 'Browser & TS ID' " . "FROM minecraft_srvr.UUID WHERE {$crit_field} = '{$l[$crit_field]}'" . "ORDER BY onlinetime DESC";
            $D = umc_mysql_fetch_all($line_sql);
            foreach ($D as $d) {
                $out_arr[] = $d;
            }
        }
        $out .= umc_web_table($table_name, 0, $out_arr, "<h2>{$table_name}</h2>");
    }
    return $out;
}
Exemplo n.º 13
0
function umc_donation_level($user, $debug = false)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $U = umc_uuid_getboth($user);
    $uuid = $U['uuid'];
    $username = $U['username'];
    $debug_txt = '';
    global $UMC_SETTING;
    $date_now = new DateTime("now");
    $sql = "SELECT amount, date FROM minecraft_srvr.donations WHERE uuid='{$uuid}';";
    $level = umc_get_uuid_level($uuid);
    if ($level == 'Owner') {
        return false;
    }
    $D = umc_mysql_fetch_all($sql);
    // if there are 0 donations, user should not be changes
    if (count($D) == 0 && strstr($level, "Donator")) {
        XMPP_ERROR_trigger("User {$username} ({$uuid}) never donated but has a donator level ({$level})");
    } else {
        if (count($D) == 0) {
            $debug_txt .= "{$username} ({$uuid}) does not have any donations\n";
            return;
        }
    }
    $debug_txt .= "Checking donation upgrade of user {$username}, current UserLevel: {$level}\n";
    $donation_level = 0;
    // go through all donations and find out how much is still active
    foreach ($D as $row) {
        $date_donation = new DateTime($row['date']);
        $interval = $date_donation->diff($date_now);
        $years = $interval->format('%y');
        $months = $interval->format('%m');
        $donation_term = $years * 12 + $months;
        $donation_leftover = $row['amount'] - $donation_term;
        if ($donation_leftover < 0) {
            $donation_leftover = 0;
            // do not create negative carryforward
        }
        $donation_level = $donation_level + $donation_leftover;
        $debug_txt .= "Amount donated {$row['amount']} {$years} years {$months} m ago = {$donation_term} months ago, {$donation_leftover} leftover, level: {$donation_level}\n";
    }
    $donation_level_rounded = ceil($donation_level);
    // get userlevel and check if demotion / promotion is needed
    $debug_txt .= "user {$username} ({$uuid}) has donation level of {$donation_level_rounded}, now is {$level}\n";
    // current userlevel
    $ranks_lvl = array_flip($UMC_SETTING['ranks']);
    $cur_lvl = $ranks_lvl[$level];
    // get current promotion level
    if (strpos($level, 'DonatorPlus')) {
        $current = 2;
    } else {
        if (strpos($level, 'Donator')) {
            $current = 1;
        } else {
            $current = 0;
        }
    }
    // get future promotion level
    if (count($D) == 0) {
        // this never happens since it's excluded above
        $future = 0;
    } else {
        if ($donation_level_rounded >= 1) {
            $future = 2;
        } else {
            if ($donation_level_rounded < 1) {
                $future = 1;
            }
        }
    }
    $debug_txt .= "future = {$future}, current = {$current}\n";
    $change = $future - $current;
    if ($change == 0) {
        $debug_txt .= "User has right level, nothing to do\n";
        return false;
        // bail if no change needed
    } else {
        // we have a change in level, let's get an error report
        $debug = true;
    }
    $debug_txt .= "User will change {$change} levels\n";
    // get currect rank index
    $debug_txt .= "Current Rank index = {$cur_lvl}\n";
    // calculate base level
    $base_lvl = $cur_lvl - $current;
    $debug_txt .= "User base level = {$base_lvl}\n";
    $new_lvl = $base_lvl + $future;
    if ($new_lvl == $cur_lvl) {
        XMPP_ERROR_send_msg("Donations upgrade: Nothing to do, CHECK this should have bailed earlier!");
        return false;
    }
    $new_rank = $UMC_SETTING['ranks'][$new_lvl];
    $debug_txt .= "User {$username} upgraded from {$level} to {$new_rank}\n";
    umc_exec_command("pex user {$uuid} group set {$new_rank}");
    umc_log('Donations', 'User Level de/promotion', "User {$username} upgraded from {$level} to {$new_rank}");
    if ($debug) {
        XMPP_ERROR_send_msg($debug_txt);
    }
    return $donation_level_rounded;
    // . "($donation_level $current - $future - $change)";
}
/**
 * takes the wordpress userlogin and returns the UUID as stored in the meta data
 *
 * @param type $user_login
 * @return type
 */
function umc_wp_get_uuid_from_userlogin($user_login)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $user = get_user_by('login', $user_login);
    $uuid = get_user_meta($user->ID, 'minecraft_uuid', true);
    return $uuid;
}
Exemplo n.º 15
0
/**
 * Add items to a user inventory. If cancel=true, we check if the current user is owner of the goods
 *
 * @global type $UMC_USER
 * @param type $id
 * @param type $amount
 * @param type $table
 * @param boolean $cancel
 * @param type $to_deposit
 * @param string $uuid
 * @return string
 */
function umc_checkout_goods($id, $amount, $table = 'stock', $cancel = false, $to_deposit = false, $uuid = false)
{
    global $UMC_USER, $UMC_ENV;
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    if (!$uuid) {
        $player = $UMC_USER['username'];
        $uuid = $UMC_USER['uuid'];
    } else {
        $player = umc_user2uuid($uuid);
    }
    if (!is_numeric($id)) {
        umc_error('{red}Invalid ID. Please use {yellow}/shophelp;');
    }
    // the fact that the source is also a condition prevents people to cancel other users' items.
    if ($table == 'stock') {
        if ($cancel) {
            $sql = "SELECT * FROM minecraft_iconomy.stock WHERE uuid='{$uuid}' AND id='{$id}' LIMIT 1;";
        } else {
            $sql = "SELECT * FROM minecraft_iconomy.stock WHERE id='{$id}' LIMIT 1;";
        }
    } else {
        if ($table == 'deposit') {
            $sql = "SELECT * FROM minecraft_iconomy.deposit WHERE (sender_uuid='{$uuid}' OR recipient_uuid='{$uuid}') AND id='{$id}' LIMIT 1;";
        }
    }
    $D = umc_mysql_fetch_all($sql);
    if (count($D) == 0) {
        umc_error("{red}Id {white}{$id}{red} not found! Please try again.;");
    } else {
        $row = $D[0];
        $item = umc_goods_get_text($row['item_name'], $row['damage'], $row['meta']);
        $meta_cmd = $meta = '';
        if ($row['meta'] != '') {
            $meta_arr = unserialize($row['meta']);
            if (!is_array($meta_arr)) {
                XMPP_ERROR_trigger("Could not get Meta Data array for {$table} id {$id}: " . var_export($row, true));
            }
            if ($row['item_name'] == "banner") {
                $meta_cmd = umc_banner_get_data($meta_arr);
            } else {
                foreach ($meta_arr as $type => $lvl) {
                    $meta_cmd .= " {$type}:{$lvl}";
                }
            }
        }
        // handle unlimited items
        $unlimited = false;
        if ($row['amount'] == -1) {
            $row['amount'] = $amount;
            $unlimited = true;
        }
        //umc_echo('There were ' . $row['amount'] . " pieces of " . $item['item_name'] . "$meta_txt stored.");
        // determine withdrawal amount
        if (is_numeric($amount) && $amount <= $row['amount']) {
            $sellamount = $amount;
        } else {
            if ($amount == 'max') {
                // withdraw all
                $sellamount = $row['amount'];
                //umc_echo("You are withdrawing all ($sellamount) {$item['name']}$meta_txt");
            } else {
                if (is_numeric($amount) && $amount > $row['amount']) {
                    umc_echo("{yellow}[!]{gray} Available amount ({yellow}{$row['amount']}{gray}) less than amount specified ({yellow}{$amount}{gray})");
                    $sellamount = $row['amount'];
                } else {
                    umc_error("{red}Amount {white}'{$amount}'{red} is not numeric;");
                }
            }
        }
        if ($table != 'stock') {
            umc_echo("{green}[+]{gray} You are withdrawing {yellow} {$amount} {gray} of {$item['full']}{gray}.");
        }
        if ($table == 'stock') {
            $cost = $sellamount * $row['price'];
            if ($cancel) {
                $target = $uuid;
                $source = 'cancel00-sell-0000-0000-000000000000';
            } else {
                $target = $uuid;
                $source = $row['uuid'];
            }
        } else {
            if ($table == 'deposit') {
                if ($row['recipient_uuid'] == $uuid) {
                    $cancel = true;
                }
                $cost = 0;
                if ($cancel) {
                    $target = $uuid;
                    $source = 'cancel00-depo-0000-0000-000000000000';
                } else {
                    $target = $row['recipient_uuid'];
                    $source = $row['sender_uuid'];
                }
            }
        }
        if (!$to_deposit) {
            umc_check_space($sellamount, $item['item_name'], $item['type']);
            // the in-game command does not understand item_names yet
            umc_ws_cmd("give {$player} {$item['item_name']}:{$item['type']} {$sellamount}{$meta_cmd};", 'asConsole');
            umc_log('inventory', 'give', "{$player} received {$item['full_clean']} {$sellamount}");
        } else {
            umc_deposit_give_item($target, $item['item_name'], $item['type'], $meta, $sellamount, $source);
            umc_log('inventory', 'give_deposit', "{$player} recived in deposit {$item['full_clean']} {$sellamount}");
        }
        //umc_echo("./give $player {$item['id']}:{$item['type']} $sellamount$meta_cmd");
        // check status
        umc_shop_transaction_record($source, $target, $sellamount, $cost, $item['item_name'], $item['type'], $meta);
        if ($unlimited) {
            return "unlimited";
        }
        // fix the stock levels
        $amount_left = umc_db_take_item($table, $id, $sellamount, $source);
        if ($UMC_ENV == 'websend') {
            if ($amount_left == 0) {
                umc_echo("{green}[+]{gray} No more {green}{$item['full']}{gray} now in stock.");
            } else {
                umc_echo("{green}[+]{yellow} {$amount_left}{green} {$item['full']}{gray} remaining in stock.");
            }
        }
        return $amount_left;
    }
}
Exemplo n.º 16
0
/**
 * analyses arrays for differences
 *
 * @param type $array1
 * @param type $array2
 * @return type
 */
function unc_tools_array_analyse($array1, $array2)
{
    global $UNC_GALLERY;
    if ($UNC_GALLERY['debug']) {
        XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    }
    $only_1 = array_diff($array1, $array2);
    $only_2 = array_diff($array2, $array1);
    $section = array_intersect($array1, $array2);
    $union = array_merge($only_1, $only_2, $section);
    $out = array('only_in_1' => $only_1, 'only_in_2' => $only_2, 'common' => $section, 'complete_set' => $union);
    return $out;
}
Exemplo n.º 17
0
function umc_get_userinfo($user_raw)
{
    $username = strtolower($user_raw);
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    // get registration date from Wordpress
    $uuid = umc_user2uuid($username);
    $user['uuid'] = $uuid;
    // get userlevel, balance, onlinetime
    $sql = "SELECT userlevel, onlinetime, lastlogin, lastlogout, username, UUID.UUID, balance, lot_count, firstlogin\r\n        FROM minecraft_srvr.UUID\r\n        LEFT JOIN minecraft_iconomy.mineconomy_accounts ON UUID.`UUID` = mineconomy_accounts.uuid\r\n        WHERE UUID.`UUID` = '{$uuid}'";
    $D = umc_mysql_fetch_all($sql);
    $d = $D[0];
    if ($d['userlevel'] == null) {
        $level = 'Guest';
    } else {
        $level = $d['userlevel'];
    }
    $username_history = umc_uuid_username_history($uuid);
    if ($username_history) {
        $user['Username History'] = $username_history;
    }
    $user['Level'] = $level;
    $user['Last Seen'] = $d['lastlogin'];
    if ($d['onlinetime'] == NULL) {
        $online_time = "n/a";
    } else {
        $online_time = umc_seconds_to_time($d['onlinetime']);
    }
    $firstdate = substr($d['firstlogin'], 0, 10);
    $today_ts = strtotime("now");
    $firsttime_ts = strtotime($firstdate);
    $days = round(abs($today_ts - $firsttime_ts) / 60 / 60 / 24);
    $user['User since'] = "{$firstdate} ({$days} days)";
    if ($firstdate > '2013-11-20') {
        // not all play time recorded
        $user['Online time since 2013-11-20'] = $online_time;
    } else {
        $user['Online time'] = $online_time;
    }
    if ($d['balance'] == NULL) {
        $user['Uncs'] = '0.00';
    } else {
        $user['Uncs'] = number_format($d['balance'], 2, ".", "'");
    }
    $user['First login'] = $d['firstlogin'];
    $homes_count = umc_home_count(false, $uuid);
    $user['Homes count'] = $homes_count;
    $karma = umc_getkarma($user['uuid'], true);
    $user['Karma'] = $karma;
    $lots = umc_user_getlots($uuid);
    $display_lots = array();
    foreach ($lots as $lot => $data) {
        $display_lots[$data['world']][] = $lot;
    }
    foreach ($display_lots as $world => $lots) {
        $World = ucfirst($world);
        if (count($lots) < 5) {
            $user["{$World} lots"] = implode(", ", $lots);
        } else {
            $user["{$World} lots"] = count($lots) . " lots";
        }
    }
    return $user;
}
Exemplo n.º 18
0
/**
 * Show a list of deposit box contents
 *
 * @global type $UMC_USER
 * @global array $UMC_SETTING
 * @param type $silent
 * @param type $user
 * @param type $web
 * @return string|boolean
 */
function umc_show_depotlist($silent = false)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    global $UMC_USER, $UMC_SETTING, $UMC_ENV;
    $player = $UMC_USER['username'];
    $uuid = $UMC_USER['uuid'];
    if (isset($UMC_USER['args'][2]) && !in_array($player, $UMC_SETTING['admins'])) {
        umc_error("You are not allowed to look at other's boxes'");
    } else {
        if (isset($UMC_USER['args'][2])) {
            $player = $UMC_USER['args'][2];
            $uuid = umc_uuid_getone($player, 'uuid');
        }
    }
    $userlevel = umc_get_uuid_level($uuid);
    $web = false;
    if ($UMC_ENV == 'wordpress') {
        $web = true;
    }
    $sql = "SELECT * FROM minecraft_iconomy.deposit WHERE sender_uuid='{$uuid}' OR recipient_uuid='{$uuid}' ORDER BY id, damage, amount DESC;";
    $D = umc_mysql_fetch_all($sql);
    $num_rows = count($D);
    $web_arr = array();
    if ($silent && $num_rows == 0) {
        return '';
    } else {
        if ($num_rows == 0) {
            if ($web) {
                return false;
            } else {
                umc_error("{gold}{$player}{red} has nothing in the deposit!");
            }
        } else {
            if (!$web) {
                umc_header();
                umc_echo("{gray}Depot-Id   Description");
            }
            $count = 0;
            foreach ($D as $row) {
                $sender_uuid = $row['sender_uuid'];
                $sender = umc_user2uuid($sender_uuid);
                $recipient_uuid = $row['recipient_uuid'];
                $recipient = umc_user2uuid($recipient_uuid);
                $item = umc_goods_get_text($row["item_name"], $row["damage"], $row['meta']);
                if (!$item) {
                    // could not identify item_name
                    XMPP_ERROR_trigger("Error deposit ID {$row['id']}, Item Name {$row["item_name"]} could not be found!");
                }
                if ($row['amount'] == -1) {
                    $row['amount'] = 'inf.';
                }
                if ($recipient_uuid == $uuid) {
                    $count++;
                }
                $label = "";
                if ($sender_uuid != $uuid && $recipient_uuid == $uuid) {
                    $label = "{green}from {gold}" . $sender;
                } elseif ($sender_uuid == $uuid && $recipient_uuid != $uuid) {
                    $label = "{blue}for {gold}" . $recipient;
                }
                if ($web) {
                    $web_arr[$row['id']] = array('item' => "{$row['amount']} {$item['full']}", 'sender' => $sender, 'recipient' => $recipient);
                } else {
                    umc_echo(sprintf("{green}%7d     {yellow}%s", $row['id'], $row['amount'] . " {$item['full']} {$label}"));
                }
            }
            if (!$web) {
                $allowed = $UMC_SETTING['depositbox_limit'][$userlevel];
                umc_pretty_bar("darkblue", "-", " {green}{$count} / {$allowed} slots used ");
                umc_echo("{cyan}[*] {green}Withdraw with {yellow}/withdraw <Depot-Id>");
                umc_footer();
            } else {
                return $web_arr;
            }
        }
    }
}
Exemplo n.º 19
0
/**
 * returns a random date
 *
 * @global type $UNC_GALLERY
 * @return type
 */
function unc_day_date_random()
{
    global $UNC_GALLERY, $wpdb;
    if ($UNC_GALLERY['debug']) {
        XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    }
    $img_table_name = $wpdb->prefix . "unc_gallery_img";
    $sql = "SELECT SUBSTR(file_time, 1, 10) as date_str FROM `{$img_table_name}` GROUP BY SUBSTR(file_time, 1, 10) ORDER BY RAND() LIMIT 1";
    $file_data = $wpdb->get_results($sql, 'ARRAY_A');
    $date_str = $file_data[0]['date_str'];
    return $date_str;
}
Exemplo n.º 20
0
function umc_lottery_roll_dice($chance = false)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    global $lottery;
    // vars set to 0 :S
    $rank = 0;
    $lastrank = 0;
    // if chance is defined, set roll to chance
    if ($chance) {
        $roll = $chance;
    } else {
        // TODO - range should be defined by count of chances in lottery array
        $roll = mt_rand(1, 1000);
    }
    XMPP_ERROR_trace("Rolled: ", $roll);
    // set last_item to false why
    $last_item = false;
    // iterate through lottery array of data
    foreach ($lottery as $item => $data) {
        // while last item flag is false
        if (!$last_item) {
            $last_item = $item;
            // set last item to current item in lottery array
        }
        $chance = $data['chance'];
        // get the chance of the item roll
        $rank = $rank + $chance;
        // add chance to running total
        XMPP_ERROR_trace("Chance check between {$lastrank} and {$rank}");
        // if roll matches the item chances range
        if ($roll <= $rank && $roll > $lastrank) {
            return array('item' => $item, 'luck' => $roll);
            // return the item and the roll
        }
        $lastrank = $rank;
        // set lastrank to running total of chance
        $last_item = $item;
        // set the last item to item currently iterated
    }
    // we should not arrive here in any case
    XMPP_ERROR_trigger("Dice roll ({$roll}) in lottery did not match lottery item!");
}
Exemplo n.º 21
0
/**
 * returns the list of available names with their main item name and the type number
 *
 * @global array $UMC_DATA
 * @return type
 */
function umc_item_data_get_namelist()
{
    global $UMC_DATA;
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $out = array();
    foreach ($UMC_DATA as $item_name => $data) {
        $out[$item_name] = array('item_name' => $item_name, 'type' => 0);
        if (isset($data['subtypes'])) {
            foreach ($data['subtypes'] as $sub_id => $subtype) {
                if (!isset($out[$subtype['name']])) {
                    $out[$subtype['name']] = array('item_name' => $item_name, 'type' => $sub_id);
                }
            }
        }
    }
    return $out;
}
Exemplo n.º 22
0
/**
 * Resize an image so the long edge becomes a given value
 *
 * @global array $UNC_GALLERY
 * @param string $image_file_path
 * @param string $target_file_path
 * @param int $size target size of the image
 * @param string $extension the file extension
 * @param int @quality quality from 1 (worst) to 100 (best)
 * @param string $format
 * @return boolean
 */
function unc_import_image_resize($image_file_path, $target_file_path, $size, $extension, $quality, $format = false)
{
    global $UNC_GALLERY;
    if ($UNC_GALLERY['debug']) {
        XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    }
    $img_types = array(1 => 'GIF', 2 => 'JPEG', 3 => 'PNG');
    //
    if (!isset($UNC_GALLERY['upload_file_info'])) {
        $image_data = unc_image_info_read($image_file_path);
        $original_width = $image_data['exif']['file_width'];
        $original_height = $image_data['exif']['file_height'];
        $image_ext = $img_types[2];
        // TODO this should not be hardcoded, but currently we only accept JPG
        $file_date = $image_data['date_str'];
    } else {
        // let's get the image size from the last check
        $arr_image_details = $UNC_GALLERY['upload_file_info']['image_size'];
        $original_width = $arr_image_details[0];
        $original_height = $arr_image_details[1];
        $image_ext = $img_types[$arr_image_details[2]];
        $file_date = $UNC_GALLERY['upload_file_info']['date_str'];
    }
    //XMPP_ERROR_trace("width / height", "$original_width / $original_height");
    if ($UNC_GALLERY['debug']) {
        XMPP_ERROR_trace("Read image date result", $file_date);
    }
    // for long-edge fitting, check which one is longer
    if ($original_height > $original_width) {
        $long_edge = 'height';
        $short_edge = 'width';
    } else {
        $long_edge = 'width';
        $short_edge = 'height';
    }
    //XMPP_ERROR_trace("Long edge", $long_edge);
    if ($original_height > $original_width) {
        $square_x = 0;
        $square_y = ceil(($original_height - $original_width) / 2);
    } else {
        $square_x = ceil(($original_width - $original_height) / 2);
        $square_y = 0;
    }
    // if we go for square, the target edge is the short one
    if ($format == 'square') {
        $new_height = $size;
        $new_width = $size;
    } else {
        // if ($format == 'max_height') {
        $new_height = $size;
        $new_width = intval($original_width * ($size / $original_height));
    }
    if ($UNC_GALLERY['debug']) {
        XMPP_ERROR_trace("New image dims", "{$original_width} x {$original_height} ==> {$new_width} x {$new_height}");
    }
    // get image extension from MIME type
    // set the function names for processing
    $img_generator = "Image" . $extension;
    $imgcreatefrom = "ImageCreateFrom" . $image_ext;
    $new_image = imagecreatetruecolor($new_width, $new_height);
    // create a blank canvas
    $old_image = $imgcreatefrom($image_file_path);
    // take the old image to memort
    $source_width = $original_width;
    $source_height = $original_height;
    if ($format == 'square') {
        $source_x = $square_x;
        $source_y = $square_y;
        if ($long_edge == 'height') {
            $source_height = $original_width;
        } else {
            $source_width = $original_height;
        }
    } else {
        $source_x = 0;
        $source_y = 0;
    }
    $resize_check = imagecopyresized($new_image, $old_image, 0, 0, $source_x, $source_y, $new_width, $new_height, $source_width, $source_height);
    // resize it
    if (!$resize_check) {
        // ;et's check if the file was resized
        echo "Could not resize image to dimensions {$new_width}, {$new_height}, {$original_width}, {$original_height}!";
        wp_die();
    }
    $image_check = $img_generator($new_image, $target_file_path, $quality);
    if (!$image_check || !file_exists($target_file_path)) {
        // let's check if the file was created
        echo "File {$target_file_path} was not created through {$img_generator} at quality {$quality}!";
        wp_die();
    }
    // write ipct date to new thumbnail file
    unc_ipct_date_write($target_file_path, $file_date);
    $new_file_date = unc_image_date($target_file_path);
    if ($UNC_GALLERY['debug']) {
        XMPP_ERROR_trace("check IPCT result", $new_file_date);
    }
    //XMPP_ERROR_trigger("test");
    imagedestroy($new_image);
    // free up the memory
    return true;
}
Exemplo n.º 23
0
function umc_wp_get_uncovery_avatar($avatar, $id_or_email, $size, $default, $alt)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    if ($default == 'uncovery') {
        $filename = '/home/minecraft/server/bin/core_include.php';
        require_once $filename;
        if (!function_exists('umc_user_ban')) {
            XMPP_ERROR_trigger("Failed to include {$filename}!");
        }
        //Alternative text
        if (false === $alt) {
            $safe_alt = '';
        } else {
            $safe_alt = esc_attr($alt);
        }
        //Get username
        if (is_numeric($id_or_email)) {
            $id = (int) $id_or_email;
            $user = get_userdata($id);
            if ($user) {
                $username = $user->user_login;
            } else {
                return false;
                // user cannot be found, probably deleted
            }
        } else {
            if (is_object($id_or_email)) {
                if (!empty($id_or_email->user_id)) {
                    $id = (int) $id_or_email->user_id;
                    $user = get_userdata($id);
                    if ($user) {
                        $username = $user->user_login;
                    } else {
                        return '';
                    }
                } else {
                    if (!empty($id_or_email->comment_author)) {
                        $username = $id_or_email->comment_author;
                    }
                }
            } else {
                if (strstr($id_or_email, '@')) {
                    // email
                    require_once ABSPATH . WPINC . '/ms-functions.php';
                    $user = get_user_by('email', $id_or_email);
                    $username = $user->user_login;
                } else {
                    // by displayname
                    $username = $id_or_email;
                }
            }
        }
        $uuid = umc_wp_get_uuid_from_userlogin($username);
        $icon = umc_user_get_icon_url($uuid);
        // 'https://crafatar.com/avatars/' . $uuid . '?size=' . $size;
        $avatar = "<img  class='avatar avatar-64 photo' alt='" . $safe_alt . "' src='" . $icon . "' class='avatar avatar-" . $size . " photo' height='" . $size . "' width='" . $size . "' />";
    }
    return $avatar;
}
Exemplo n.º 24
0
function umc_home_import()
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    // global $UMC_USER;
    // we automatically import old homes for all players on login, but only once
    // include spyc to parse YAML https://github.com/mustangostang/spyc
    require_once '/home/includes/spyc/Spyc.php';
    $users = umc_get_active_members();
    foreach ($users as $uuid => $username) {
        $path = '/home/minecraft/server/bukkit/plugins/Essentials/userdata/' . $uuid . ".yml";
        $A = Spyc::YAMLLoad($path);
        $existing_count = umc_home_count(false, $uuid);
        if ($existing_count > 0) {
            continue;
        }
        if (!isset($A['homes'])) {
            continue;
        }
        $count = count($A['homes']);
        if ($count == 0) {
            continue;
        }
        $H = $A['homes'];
        // iterate homes and import them
        foreach ($H as $home_name => $h) {
            $name = umc_mysql_real_escape_string($home_name);
            // XMPP_ERROR_trigger($h);
            $sql = "INSERT INTO minecraft_srvr.`homes`(`name`, `uuid`, `world`, `x`, `y`, `z`, `yaw`) VALUES " . "({$name},'{$uuid}','{$h['world']}','{$h['x']}','{$h['y']}','{$h['z']}','{$h['yaw']}');";
            umc_mysql_query($sql, true);
        }
        umc_log('home', 'import', "{$uuid}/{$username} {$count} homes have been imported!");
    }
}
Exemplo n.º 25
0
function umc_hunger_format_player_list($prefix, $player_list)
{
    $cnt = 0;
    $list_text = "{$prefix}";
    XMPP_ERROR_trace("check", var_export($player_list, true));
    foreach ($player_list as $status => $player_data) {
        $list_text = "{green}{$status}:{$prefix} ";
        $inner = '';
        foreach ($player_data as $uuid => $player) {
            if ($cnt % 5 == 0 && $cnt > 0) {
                $inner = ";{$prefix}";
            }
            if ($cnt == sizeof($player_list)) {
                $list_text .= " and {$player}";
            } else {
                if ($cnt == 0) {
                    $list_text .= "{$player}";
                } else {
                    $list_text .= ", {$inner}{$player}";
                }
            }
            $cnt++;
        }
    }
    umc_echo($list_text);
}
function umc_user_get_icon_url($uuid_requested, $update = false)
{
    global $UMC_DOMAIN, $UMC_PATH_MC;
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    if (strstr($uuid_requested, ' ')) {
        return '';
    }
    // make sure it's a uuid
    $uuid = umc_uuid_getone($uuid_requested, 'uuid');
    $path = "{$UMC_PATH_MC}/server/bin/data/user_icons/";
    if (!file_exists($path . $uuid . ".png") && $update) {
        // this tries to download the latest version, otherwise falls back to steve icon
        // umc_update_usericons($uuid);
        umc_usericon_get($uuid);
    } else {
        if (!file_exists($path . $uuid . ".png") && !$update) {
            return false;
        }
    }
    $url = "{$UMC_DOMAIN}/websend/user_icons/{$uuid}.png";
    return $url;
}
Exemplo n.º 27
0
function umc_read_markers_file($format = 'html', $world = 'empire', $user = false)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    /*   [0]=>
          object(stdClass)#1 (5) {
            ["timestamp"]=> string(19) "2011-01-31 14:14:47"
            ["z"]=> float(-319.54668819556)
            ["msg"]=> string(8) "Thegiant"
            ["y"]=> float(50)
            ["x"]=> float(448.69999998808)
        */
    global $UMC_SETTING, $UMC_PATH_MC;
    $file = "{$UMC_PATH_MC}/server/bin/data/markers.json";
    // $UMC_SETTING['markers_file'];
    $text = file_get_contents($file);
    if (!$file) {
        XMPP_ERROR_trigger("Could not read markers file (umc_read_markers_file)");
    }
    $m = json_decode($text);
    // no users
    if (!$m) {
        return '';
    }
    $out_arr = array();
    $map = $UMC_SETTING['world_img_dim'][$world];
    if (count($m) == 0) {
        return '';
    }
    if ($format == 'scrollto') {
        $out = "<div id=\"scroll_to_icons\">\n";
    } else {
        $out = "<div id=\"marker_list\">\n";
    }
    // check if we find the single user from the marker
    $foundplayer = false;
    // var_dump($format);
    foreach ($m as $marker) {
        $z = $marker->z;
        $x = $marker->x;
        $x_text = round($x);
        $z_text = round($z);
        $top = conv_z($marker->z, $map);
        // + $map['img_top_offset'];
        $left = conv_x($marker->x, $map);
        // + $map['img_left_offset'];
        $username = strtolower($marker->msg);
        $playerworld = $marker->world;
        if ($username == 'uncovery') {
            //continue;
        }
        $icon_url = umc_user_get_icon_url($username);
        if ($format == 'identify_user' && $username == $user) {
            $out .= '   <span class="marker" style="z-index:100; top:' . $top . 'px; left:' . $left . "px;\"><img src=\"{$icon_url}\" title=\"{$username}\" alt=\"{$username}\"> <input type=\"submit\" name=\"track_player\" value=\"That's me!\"></span>\n" . "\n";
            $foundplayer = true;
        } else {
            if ($format == 'track_user' && $username == $user) {
                $out .= '   <span class="marker"  id="' . $username . '_marker" style="z-index:100; top:' . $top . 'px; left:' . $left . "px;\"><img src=\"{$icon_url}\" title=\"{$username}\" alt=\"{$username}\"></span>\n" . "\n";
                $foundplayer = true;
            } else {
                if ($format == 'scrollto' && $marker->world == $world) {
                    $out .= "<img src=\"{$icon_url}\" title=\"{$username}\" alt=\"{$username}\" onclick=\"find_user({$left}, {$top}, '{$username}_marker')\">\n";
                } else {
                    if ($format == 'html' && $marker->world == $world) {
                        if ($world == 'hunger') {
                            $out .= '<div class="marker" style="position:relative">' . $username . '</div>' . "\n";
                        } else {
                            $out .= '   <img id="' . $username . '_marker" class="marker" style="z-index:100; top:' . $top . 'px; left:' . $left . "px;\" src=\"{$icon_url}\" title=\"{$username} (x:{$x_text} z:{$z_text})\" alt=\"{$username} (x:{$x_text} z:{$z_text})\">\n";
                        }
                    } else {
                        if ($format == 'json') {
                            $arr[] = array('name' => $username, 'url' => $icon_url, 'top' => $top, 'left' => $left);
                        } else {
                            if ($format == 'all_users') {
                                // list all users for website status
                                $out .= $username . " ";
                            } else {
                                if ($format == 'array') {
                                    $out_arr[$username] = array('name' => $username, 'url' => $icon_url, 'top' => $top, 'left' => $left, 'world' => $playerworld, 'x' => $x_text, 'z' => $z_text);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if (($format == 'identify_user' || $format == 'track_user') && $foundplayer == false) {
        // umc_error_notify("Could not find single player $user in Json Data: \n" . var_export($m, true));
    }
    if ($format == 'json') {
        $out = json_encode($arr);
    } else {
        if ($format == 'array') {
            return $out_arr;
        }
    }
    if ($format == 'scrollto') {
        $out .= "</div>\n";
    } else {
        if ($format == 'html') {
            // no idea why this was here. it would duplicate the output.
            // $out .= umc_read_markers_file('scrollto', $world);
        }
        $out .= "</div>\n";
    }
    return $out;
}
Exemplo n.º 28
0
 /**
  * This function runs during the activation of the plugin
  * 
  */
 public function __construct()
 {
     XMPP_ERROR_trace(__CLASS__ . " // " . __FUNCTION__, func_get_args());
 }
Exemplo n.º 29
0
function umc_check_lot_exists($world_id, $lot)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    if (!is_numeric($world_id)) {
        $world_id = umc_get_worldguard_id('world', $world_id);
    }
    //  Make sure the region exists
    $sql = "SELECT id FROM minecraft_worldguard.region WHERE world_id = {$world_id} AND id = '{$lot}'";
    //echo $sql;
    $C = umc_mysql_fetch_all($sql);
    if (count($C) < 1) {
        // echo("No such region '$lot' found in world '$world_id'");
        return false;
    }
    return true;
}
Exemplo n.º 30
0
/**
 * this checks if the user exists, and creats it if not. returns the amount in the account.
 * @global type $UMC_ENV
 * @param type $user
 * @return int
 */
function umc_money_check($user)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    if ($user == '') {
        XMPP_ERROR_trigger("Failed to get account status for empty user!");
    }
    // check if the user has an acoount
    if (strlen($user) <= 17) {
        $uuid = umc_user2uuid($user);
    } else {
        $uuid = $user;
        $user = umc_user2uuid($uuid);
        if ($user == '') {
            XMPP_ERROR_trigger("Failed to get username for {$uuid}!");
            die;
        }
    }
    $sql = "SELECT balance FROM `minecraft_iconomy`.`mineconomy_accounts` WHERE uuid='{$uuid}';";
    $data = umc_mysql_fetch_all($sql);
    // has account to receive, return value
    if (count($data) > 0) {
        // get amount
        return $data[0]['balance'];
    } else {
        if (count($data) == 0) {
            // create account
            // check if there is a user entry but no UUID
            $sql2 = "SELECT balance FROM `minecraft_iconomy`.`mineconomy_accounts` WHERE account='{$user}';";
            $data2 = umc_mysql_fetch_all($sql2);
            if (count($data2) == 1) {
                // yes, add the UUID
                $fix_sql = "UPDATE `minecraft_iconomy`.`mineconomy_accounts`\r\n\t\t SET uuid='{$uuid}'\r\n                 WHERE account='{$user}';";
                umc_mysql_query($fix_sql, true);
                // try again
                return umc_money_check($user);
            } else {
                // insert row
                $sql3 = "INSERT INTO `minecraft_iconomy`.`mineconomy_accounts` (`uuid`, `account`, `balance`)\r\n                VALUES ('{$uuid}', '{$user}', '100');";
                umc_mysql_query($sql3, true);
                return 0;
            }
        }
    }
}