コード例 #1
0
/**
 * Get all variables of the current user from Wordpress and add it to $UMC_USER
 */
function umc_wp_get_vars()
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    global $UMC_USERS, $UMC_USER, $UMC_ENV, $user_email, $user_login;
    if ($UMC_ENV !== 'wordpress') {
        XMPP_ERROR_trigger("Tried to get wordpress vars, but environment did not match: " . var_export($UMC_ENV, true));
        die('umc_wp_get_vars');
    }
    get_currentuserinfo();
    if (!isset($user_login) || $user_login == '' || $user_email == '') {
        $UMC_USER = false;
    } else {
        if (!function_exists('umc_get_uuid_level')) {
            XMPP_ERROR_send_msg("Could not get uuid_level, Env = {$UMC_ENV}");
            require_once '/home/minecraft/server/bin/core_include.php';
        }
        $uuid = umc_wp_get_uuid_for_currentuser();
        $UMC_USER['ip'] = filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_FLAG_IPV4);
        if (!$uuid) {
            // we have a guest who is trying to register
            $UMC_USER['username'] = $user_login;
            $UMC_USER['email'] = $user_email;
            $uuid = umc_user2uuid($user_login);
            $UMC_USER['uuid'] = $uuid;
            $UMC_USER['userlevel'] = 'Guest';
        } else {
            // there is a logged-in user
            umc_uuid_check_usernamechange($uuid);
            $UMC_USER['email'] = $user_email;
            $UMC_USER['username'] = umc_uuid_getone($uuid, 'username');
            $UMC_USER['uuid'] = $uuid;
            $UMC_USER['userlevel'] = umc_get_uuid_level($uuid);
            if (strstr($UMC_USER['userlevel'], 'DonatorPlus')) {
                $UMC_USER['donator'] = 'DonatorPlus';
            } else {
                if (strstr($UMC_USER['userlevel'], 'Donator')) {
                    $UMC_USER['donator'] = 'Donator';
                } else {
                    $UMC_USER['donator'] = false;
                }
            }
        }
        // if we did not get any UUID
        if (!$uuid) {
            $UMC_USER['username'] = $user_login;
            $UMC_USER['uuid'] = false;
            $UMC_USER['userlevel'] = 'Guest';
        }
    }
    //$UMC_USERS[$uuid] = new UMC_User($uuid);
    //$UMC_USERS[$uuid]->set_username($username);
    //$UMC_USERS[$uuid]->set_userlevel($userlevel);
}
コード例 #2
0
function umc_vanity_get_title()
{
    global $UMC_USER;
    $player = $UMC_USER['username'];
    $uuid = umc_user2uuid($player);
    $sql = "SELECT value FROM minecraft_srvr.permissions WHERE name='{$uuid}' AND permission='suffix';";
    $D = umc_mysql_fetch_all($sql);
    if (count($D) > 0) {
        $row = $D[0];
        if (strlen($row['value']) > 0) {
            return $row['value'];
        }
    }
    return false;
}
コード例 #3
0
ファイル: mod.inc.php プロジェクト: dani0010/uncovery_me
function umc_mod_unmute()
{
    global $UMC_USER, $UMC_PATH_MC;
    // umc_echo('Unmuting...');
    $player = $UMC_USER['username'];
    $args = $UMC_USER['args'];
    if (!isset($args[2])) {
        umc_show_help($args);
        die;
    } else {
        $user = umc_check_user($args[2]);
        if (!$user) {
            XMPP_ERROR_trigger("{$player} tried to un-mute {$user}, but {$user} does not exist!");
            umc_error("{red}The user {$args[2]} does not exist! See {yellow}/helpme mod");
        }
    }
    // umc_echo('checks done... ');
    $user_uuid = umc_uuid_getone($user);
    $file = "{$UMC_PATH_MC}/server/bukkit/plugins/Essentials/userdata/" . $user_uuid . ".yml";
    $txt = file_get_contents($file);
    $search = "muted: true";
    if (strstr($txt, $search)) {
        // YAML library is not installed,
        //$yml = yaml_parse_file($file);
        //if ($yml['muted'] == 'true') {
        $uuid = umc_user2uuid($user);
        umc_ws_cmd("mute {$user}", 'asPlayer');
        umc_ws_cmd("pex user {$uuid} timed remove -herochat.*;", 'asConsole');
        umc_ws_cmd("pex user {$uuid} timed remove -irc.*;", 'asConsole');
        umc_ws_cmd("pex user {$uuid} timed remove -essentials.msg;", 'asConsole');
        umc_ws_cmd("pex user {$uuid} timed remove -essentials.me;", 'asConsole');
        umc_echo("The user {$user} has been un-muted!");
        umc_log('mod', 'un-mute', "{$player} un-muted {$user}");
    } else {
        umc_log('mod', 'un-mute', "{$player} tried to un-mute {$user}, but {$user} was not muted!");
        umc_error("User {$user} was not muted!");
    }
}
コード例 #4
0
ファイル: web.php プロジェクト: dani0010/uncovery_me
function umc_web_table_format_column($name, $value)
{
    global $ENCH_ITEMS, $UMC_DOMAIN, $UMC_DATA, $UMC_DATA_ID2NAME;
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $people_types = array('username', 'buyer', 'seller', 'sender', 'recipient');
    $uuid_types = array('vendor', 'requestor');
    if ($name == 'item_name') {
        $id_parts = explode("|", $value);
        $item_arr = umc_goods_get_text($id_parts[0], $id_parts[1], $id_parts[2]);
        if (!$item_arr) {
            XMPP_ERROR_send_msg("Could not identify {$name} {$value} for web table");
        }
        $type = "&type={$id_parts[1]}";
        $out = "<a href=\"?page=goods&amp;item={$id_parts[0]}{$type}\">" . $item_arr['full'] . "</a>\n";
        return $out;
    } else {
        if ($name == 'item') {
            $meta = '';
            $id_parts = explode("|", $value);
            if (is_numeric($id_parts[0])) {
                $item_name = $UMC_DATA_ID2NAME[$id_parts[0]];
            } else {
                $item_name = $id_parts[0];
            }
            $item = umc_goods_get_text($item_name, $id_parts[1]);
            $item_dmg = $id_parts[1];
            $item_meta = $id_parts[2];
            if ($item_dmg == '' || isset($UMC_DATA[$item_name]['damage']) && $UMC_DATA[$item_name]['damage'] > 0) {
                // damage item have dmg id 0 for icon
                $item_dmg = 0;
            }
            if ($item_meta != '') {
                $meta = unserialize($item_meta);
                $meta_list = array();
                foreach ($meta as $type => $level) {
                    $nice_meta = $ENCH_ITEMS[$type]['short'];
                    array_push($meta_list, "{$nice_meta} {$level}");
                }
                $meta = ", " . implode(", ", $meta_list);
            }
            if (isset($UMC_DATA[$item_name]['subtypes']) && $UMC_DATA[$item_name]['subtypes'][$item_dmg]['icon_url'] == '?') {
                $icon_dmg = 0;
            } else {
                $icon_dmg = $item_dmg;
            }
            if ($item['name']) {
                $text = "{$item['icon']}&nbsp;" . $item['name'] . $meta;
            } else {
                $text = "({$value})";
            }
            $out = "<a href=\"{$UMC_DOMAIN}/trading/shop/?query=stock_detail&amp;item={$item_name}\">{$text}</a>\n";
            return $out;
        } else {
            if (in_array($name, $people_types)) {
                // if ($value == '')
                $icon_url = umc_user_get_icon_url($value);
                return "<a href=\"?page=users&amp;user={$value}\"><img title='{$value}' src='{$icon_url}' width=\"16\" alt=\"{$value}\">&nbsp;{$value}</a>";
            } else {
                if (in_array($name, $uuid_types)) {
                    $username = umc_user2uuid($value);
                    $icon_url = umc_user_get_icon_url($username);
                    return "<a href=\"?page=users&amp;user={$username}\"><img title='{$username}' src='{$icon_url}' width=\"16\" alt=\"{$username}\">&nbsp;{$username}</a>";
                } else {
                    if (preg_match("/price/i", $name)) {
                        return number_format($value, 2, ".", "");
                    } else {
                        if ($name == 'quantity' && $value < 1) {
                            return "&infin;";
                        }
                    }
                }
            }
        }
    }
    return $value;
}
コード例 #5
0
ファイル: donation.php プロジェクト: dani0010/uncovery_me
function umc_donation_top_table($outstanding)
{
    global $UMC_SETTING, $UMC_USER;
    $show_users = $UMC_SETTING['donation_users'];
    $username = $UMC_USER['username'];
    $uuid = $UMC_USER['uuid'];
    $sql = "SELECT SUM(amount) as sum, uuid FROM minecraft_srvr.`donations` GROUP BY uuid ORDER by sum DESC LIMIT 25;";
    $D = umc_mysql_fetch_all($sql);
    $out = "<h2>Top 25 Donators</h2>If you are on this list and would like to be named, please tell me.\n<table>";
    $out .= "\n    <tr><td style=\"text-align:right\">" . $outstanding . " USD</td><td style=\"text-align:right\">Uncovery</td></tr>\n";
    foreach ($D as $row) {
        if (isset($show_users[$row['uuid']]) && $uuid == $row['uuid']) {
            $user = $username . " (You)";
        } else {
            if ($uuid == $row['uuid']) {
                $user = "******";
            } else {
                if (isset($show_users[$row['uuid']])) {
                    $user = umc_user2uuid($row['uuid']);
                } else {
                    $user = '******';
                }
            }
        }
        $out .= "    <tr><td style=\"text-align:right\">" . $row['sum'] . " USD</td><td style=\"text-align:right\">{$user}</td></tr>\n";
    }
    $out .= "</table>\n";
    return $out;
}
コード例 #6
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;
            }
        }
    }
}
コード例 #7
0
function umc_do_sell_internal($from_deposit = false)
{
    global $UMC_USER;
    $player = $UMC_USER['username'];
    $args = $UMC_USER['args'];
    $uuid = $UMC_USER['uuid'];
    if (!isset($args[2]) || !is_numeric($args[2])) {
        umc_error("{red}You need a valid shop_id to sell to a requester. Use {yellow}/find request ...;");
        umc_error("{red}Maybe you meant {yellow}/offer{red}, for posting an offer for sale in the shop.;");
    }
    $do_check = false;
    $pos = array_search('check', $args);
    if ($pos) {
        $do_check = true;
        array_splice($args, $pos, 1);
    }
    $id = $args[2];
    $sql_request = "SELECT * FROM minecraft_iconomy.request WHERE id='{$id}' LIMIT 1;";
    $request_data = umc_mysql_fetch_all($sql_request);
    if (count($request_data) == 0) {
        umc_error("{red}The shop-id {white}{$id}{red} could not be found. Please use {yellow}/find{red} and{yellow} /shophelp sell;");
    }
    $request = $request_data[0];
    $request_item = umc_goods_get_text($request['item_name'], $request['damage'], $request['meta']);
    if ($request['uuid'] == $uuid && $player != 'uncovery') {
        umc_error("{red}You cannot fulfill your own requests. Use {yellow}/cancel r <id>{red} instead!;");
    }
    // do we sell items from deposit?
    if ($from_deposit) {
        $depot_id = $args[3];
        array_splice($args, 3, 1);
        $sql = "SELECT * from minecraft_iconomy.deposit WHERE recipient_uuid='{$uuid}' and id='{$depot_id}'";
        $D = umc_mysql_fetch_all($sql);
        if (count($D) < 1) {
            umc_error("You have no such deposit ID");
        }
        $depot_row = $D[0];
        $inv = $depot_row['amount'];
        $depot_item = umc_goods_get_text($depot_row['item_name'], $depot_row['damage'], $depot_row['meta']);
        if ($depot_item != $request_item) {
            //umc_echo("{green}$type:$data {gray} => {red}".$check_inv[$item_slot]['id'].":".$check_inv[$item_slot]['data']);
            umc_error("{red}The item in deposit-id {white}{$depot_id}{red} doesn't match request {white}{$id}{red}.");
        }
    } else {
        $item_slot = $UMC_USER['current_item'];
        $check_inv = $UMC_USER['inv'];
        if (!isset($check_inv[$item_slot])) {
            umc_error("{red}You need to hold the item you want to sell!;");
        }
        $inv_item = umc_goods_get_text($check_inv[$item_slot]['id'], $check_inv[$item_slot]['data'], $check_inv[$item_slot]['meta']);
        if ($inv_item != $request_item) {
            //umc_error_longmsg("Sell failed");
            //umc_echo("{green}$type:$data {gray} => {red}".$check_inv[$item_slot]['id'].":".$check_inv[$item_slot]['data']);
            umc_error("{red}The item you're holding doesn't match request id {white}{$id}{red}.");
        }
    }
    if (!isset($args[3])) {
        umc_echo("{yellow}[!]{gray} You did not enter an amount. Attempting to sell all.");
        $amount = false;
    } else {
        $args[3] = intval($args[3]);
        $amount = umc_sanitize_input($args[3], 'amount');
    }
    if (!$amount) {
        // sell as much as possible
        $amount = $request['amount'];
    }
    if ($amount > $request['amount']) {
        umc_error("{red}That's too much, the request is only for {yellow}{$request['amount']}{red} pieces.");
    }
    if (!$from_deposit) {
        $inv = umc_check_inventory($request_item['item_name'], $request_item['type'], $request_item['meta']);
        if ($inv == 0) {
            umc_error("{red}You don't have any of the requested item.");
        }
    }
    if ($inv < $amount) {
        umc_echo("{yellow}[!]{gray} Not enough for entire request.  Selling as much as possible.");
        $amount = $inv;
    }
    $recipient_uuid = $request['uuid'];
    $recipient = umc_user2uuid($recipient_uuid);
    if ($do_check) {
        umc_echo("{white}[?]{gray} This would sell {yellow}{$amount} {$request_item['full']}{darkgray} for {cyan}{$request['price']}{gray} each to {gold}{$recipient}");
        $sum = $amount * $request['price'];
        umc_echo("{white}[?]{gray} Your account would be credited {cyan}{$sum}{gray} Uncs.");
        return;
    }
    umc_echo("{green}[+] {gray}Selling {yellow}{$amount} {$request_item['full']}{darkgray} for {cyan}{$request['price']}{gray} each to {gold}{$recipient}");
    if ($from_deposit) {
        umc_db_take_item('deposit', $depot_id, $amount, $uuid);
    } else {
        umc_clear_inv($request_item['item_name'], $request_item['type'], $amount, $request_item['meta']);
    }
    $sum = $amount * $request['price'];
    umc_money(false, $player, $sum);
    umc_echo("{green}[\$]{gray} Your account has been credited {cyan}{$sum}{gray} Uncs.");
    $sql = "SELECT * FROM minecraft_iconomy.deposit\r\n        WHERE item_name='{$request_item['item_name']}'\r\n\t    AND recipient_uuid='{$request['uuid']}'\r\n            AND damage='{$request_item['type']}'\r\n\t    AND meta='{$request_item['meta']}'\r\n\t    AND sender_uuid='shop0000-0000-0000-0000-000000000000';";
    $D = umc_mysql_fetch_all($sql);
    // check first if item already is in the recipient's deposit
    if (count($D) > 0) {
        $update_row = $D[0];
        umc_echo("{green}[+]{gray} There is already {$request_item['full']}{gray} in the deposit for {gold}{$recipient}{gray}, adding {yellow}{$amount}{gray}.");
        $sql = "UPDATE minecraft_iconomy.`deposit` SET `amount`=amount+'{$amount}' WHERE `id`={$update_row['id']} LIMIT 1;";
    } else {
        // create a new deposit box
        umc_echo("{green}[+]{gray} Depositing {yellow} {$amount} {$request_item['full']}{gray} for {gold}{$recipient}");
        $sql = "INSERT INTO minecraft_iconomy.`deposit` (`damage` ,`sender_uuid` ,`item_name` ,`recipient_uuid` ,`amount` ,`meta`)\r\n            VALUES ('{$request_item['type']}', 'shop0000-0000-0000-0000-000000000000', '{$request_item['item_name']}', '{$recipient_uuid}', '{$amount}', '{$request_item['meta']}');";
    }
    umc_mysql_query($sql, true);
    if ($amount < $request['amount']) {
        // Update existing listing
        $sql = "UPDATE minecraft_iconomy.`request` SET `amount`=amount-'{$amount}' WHERE id={$request['id']} LIMIT 1;";
        umc_mysql_query($sql, true);
        //umc_echo("{purple}".$sql);
        //umc_echo("{red}".mysql_error());
    } else {
        // Delete the listing entirely
        $sql = "DELETE FROM minecraft_iconomy.`request` WHERE id={$request['id']}";
        umc_mysql_query($sql, true);
        //umc_echo("{red}".mysql_error());
    }
    // record transaction
    umc_shop_transaction_record($uuid, $request['uuid'], $amount, $sum, $request_item['item_name'], $request_item['type'], $request_item['meta']);
    // message recipient
    $msg = "{$player} sold you {$amount} {$request_item['full']} per your request, check your /depotlist!;";
    umc_msg_user($recipient, $msg);
    // record logfile
    umc_log('shop', 'sell_on_request', "{$player} sold {$amount} of {$request_item['full_clean']} to {$recipient} (ID: {$request['id']})");
}
コード例 #8
0
ファイル: hunger.inc.php プロジェクト: dani0010/uncovery_me
function umc_hunger_removeplayer($died = true)
{
    global $HUNGER, $UMC_USER;
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $uuid = $UMC_USER['uuid'];
    $username = $UMC_USER['username'];
    if (isset($HUNGER['current_game'])) {
        $game_id = $HUNGER['current_game']['id'];
        $status = $HUNGER['current_game']['status'];
    } else {
        return;
    }
    if (!$died) {
        $sql = "UPDATE minecraft_iconomy.`hunger_players` SET status='left', death=NOW()\r\n            WHERE game_id={$game_id} AND uuid='{$uuid}';";
    } else {
        $sql = "UPDATE minecraft_iconomy.`hunger_players` SET status='dead', death=NOW()\r\n            WHERE game_id={$game_id} AND uuid='{$uuid}';";
    }
    $rst = umc_mysql_query($sql);
    if (umc_mysql_affected_rows($rst, true) == 0) {
        return;
    }
    // read results from DB
    umc_hunger_find_players();
    umc_ws_cmd("pex user {$uuid} remove essentials.warps.hunger", 'asConsole');
    umc_ws_cmd("pex user {$uuid} remove modifyworld.* hunger", 'asConsole');
    XMPP_ERROR_send_msg("{$username} was removed from the hunger game");
    $winner = false;
    // Check for a win if the game is still on
    if ($status == 'started') {
        $winner = umc_hunger_check_winner();
        if (!$winner) {
            $admin_uuid = $HUNGER['current_game']['admin'];
            $admin = umc_user2uuid($admin_uuid);
            umc_echo("[Hunger] {green}You ({gold}{$username}{green}) were removed from Hunger Game {white}#{$game_id}.");
            if ($HUNGER['announce']) {
                umc_announce("[Hunger] The user {gold}{$username}{purple} just {cyan}left{gold} the hunger game!", $HUNGER['channel']);
            } else {
                umc_echo("[Hunger] The user {gold}{$username}{purple} just {cyan}left{gold} the hunger game!");
            }
            umc_ws_cmd("tell {$admin} The user {$username} just left the hunger game!", 'asConsole');
        }
    } else {
        if ($status == 'preparing') {
            // did we remove the last player of a game being prepared?
            $sql = "SELECT * FROM minecraft_iconomy.`hunger_players` WHERE status='preparing' AND game_id={$game_id};";
            $D3 = umc_mysql_fetch_all($sql);
            $num = count($D3);
            if ($num == 0) {
                // last player has quit, end the game
                umc_hunger_abort();
            }
        }
    }
}
コード例 #9
0
function umc_lottery()
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    global $UMC_USER, $lottery, $ENCH_ITEMS;
    $user_input = $UMC_USER['args'][2];
    // check if there is a valid user on the server before applying the vote.
    $user = umc_check_user($user_input);
    if (!$user) {
        umc_log("lottery", "voting", "user {$user} does not exist");
        return false;
    }
    // get the voting players uuid
    $uuid = umc_user2uuid($user);
    // give reinforcing feedback - set subtitle (not displayed)
    $subtitle = 'title ' . $user . ' subtitle {text:"Thanks for your vote!",color:gold}';
    umc_ws_cmd($subtitle, 'asConsole');
    // display the feedback - displays subtitle AND title
    $title = 'title ' . $user . ' title {text:"+100 Uncs",color:gold}';
    umc_ws_cmd($title, 'asConsole');
    // allow uncovery to test chance rolls for debugging purposes
    $chance = false;
    if ($user == 'uncovery' && isset($UMC_USER['args'][5])) {
        $chance = $UMC_USER['args'][5];
    }
    // get the roll array based on chance
    $roll = umc_lottery_roll_dice($chance);
    // umc_echo(umc_ws_vardump($roll));
    // define the rewards and item more legibly
    $item = $roll['item'];
    $luck = $roll['luck'];
    $prize = $lottery[$item];
    //echo "type = {$prize['type']}<br>;";
    //echo "complete chance: $chance<br>;";
    //var_dump($prize);
    // get the metadata if required for the item
    if (isset($prize['detail'])) {
        $detail = $prize['detail'];
    }
    $type = $prize['type'];
    // always give 100 uncs irrespective of roll.
    umc_money(false, $user, 100);
    // instantiate block variables
    $given_block_data = 0;
    $given_block_type = 0;
    //var_dump($prize);
    // based on item type, give reward to the player
    switch ($type) {
        case 'item':
            umc_deposit_give_item($uuid, $detail['type'], $detail['data'], $detail['ench'], 1, 'lottery');
            $item_txt = $prize['txt'];
            break;
        case 'additional_home':
            $newname = 'lottery' . "_" . umc_random_code_gen(4);
            umc_home_add($uuid, $newname, true);
            $item_txt = "an addtional home!!";
            break;
        case 'random_unc':
            $luck2 = mt_rand(1, 500);
            umc_money(false, $user, $luck2);
            $item_txt = "{$luck2} Uncs";
            break;
        case 'random_potion':
            $luck2 = mt_rand(0, 63);
            umc_deposit_give_item($uuid, 373, $luck2, '', 1, 'lottery');
            $item_txt = $prize['txt'];
            break;
        case 'random_ench':
            // pick which enchantment
            $rand_ench = array_rand($ENCH_ITEMS);
            $ench_arr = $ENCH_ITEMS[$rand_ench];
            //pick which item to enchant
            $rand_item = array_rand($ench_arr['items']);
            $rand_item_id = $ench_arr['items'][$rand_item];
            // pick level of enchantment
            $lvl_luck = mt_rand(1, $ench_arr['max']);
            //echo "$item $ench_txt $lvl_luck";
            $item_ench_arr = array($rand_ench => $lvl_luck);
            $item = umc_goods_get_text($rand_item_id, 0, $item_ench_arr);
            $item_name = $item['item_name'];
            $full = $item['full'];
            umc_deposit_give_item($uuid, $item_name, 0, $item_ench_arr, 1, 'lottery');
            $item_txt = "a " . $full;
            break;
        case 'random_pet':
            // same as blocks below but only 1 always
            umc_echo($type);
            $block = $prize['blocks'];
            $luck2 = mt_rand(0, count($prize['blocks']) - 1);
            $given_block = explode(":", $block[$luck2]);
            $given_block_type = $given_block[0];
            $given_block_data = $given_block[1];
            umc_deposit_give_item($uuid, $given_block_type, $given_block_data, '', 1, 'lottery');
            $item = umc_goods_get_text($given_block_type, $given_block_data);
            $item_txt = "a " . $item['full'];
            break;
        case 'random_common':
        case 'random_ore':
        case 'random_manuf':
            $block = $prize['blocks'];
            $luck2 = mt_rand(0, count($prize['blocks']) - 1);
            $luck3 = mt_rand(1, 64);
            $given_block = explode(":", $block[$luck2]);
            $given_block_type = $given_block[0];
            $given_block_data = $given_block[1];
            umc_deposit_give_item($uuid, $given_block_type, $given_block_data, '', $luck3, 'lottery');
            $item = umc_goods_get_text($given_block_type, $given_block_data);
            $item_txt = "{$luck3} " . $item['full'];
            break;
    }
    if ($user != 'uncovery') {
        // testing only
        $item_nocolor = umc_ws_color_remove($item_txt);
        umc_ws_cmd("ch qm N {$user} voted, rolled a {$luck} and got {$item_nocolor}!", 'asConsole');
        umc_log('votelottery', 'vote', "{$user} rolled {$luck} and got {$item_nocolor} ({$given_block_type}:{$given_block_data})");
        $userlevel = umc_get_userlevel($user);
        if (in_array($userlevel, array('Settler', 'Guest'))) {
            $msg = "You received {$item_txt} from the lottery! Use {green}/withdraw @lottery{white} to get it!";
            umc_msg_user($user, $msg);
        }
    } else {
        umc_echo("{$user} voted, rolled a {$luck} and got {$item_txt}!");
    }
    // add vote to the database
    $service_raw = strtolower($UMC_USER['args'][3]);
    // fix service
    $search = array('http://www.', 'https://www.', 'http://', 'https://');
    $service = umc_mysql_real_escape_string(str_replace($search, '', $service_raw));
    // sql log
    $sql_reward = umc_mysql_real_escape_string($type);
    $ip = umc_mysql_real_escape_string($UMC_USER['args'][4]);
    $sql = "INSERT INTO minecraft_log.votes_log (`username`, `datetime`, `website`, `ip_address`, `roll_value`, `reward`)\r\n        VALUES ('{$uuid}', NOW(), {$service}, {$ip}, {$luck}, {$sql_reward});";
    umc_mysql_query($sql, true);
}
コード例 #10
0
ファイル: story.inc.php プロジェクト: dani0010/uncovery_me
function umc_story_show()
{
    global $UMC_USER, $UMC_COLORS;
    $username = $UMC_USER['username'];
    $uuid = $UMC_USER['uuid'];
    $args = $UMC_USER['args'];
    $mode = $UMC_USER['mode'];
    $world = $UMC_USER['world'];
    if (!isset($args[2])) {
        umc_error("You have to enter a story code!");
    } else {
        $code = $args[2];
    }
    if (strpos($code, '?')) {
        umc_error('Your code is incomplete! Please replace the ? with the code that you received at the last station!');
    }
    if (strlen($code) != 5) {
        umc_error('Your code needs to have 5 letters!');
    }
    $sql = "SELECT * FROM minecraft_iconomy.story WHERE code='{$code}';";
    $D = umc_mysql_fetch_all($sql);
    $disallowed_items = array(0, 8, 9, 10, 11, 34, 36, 43, 51, 52, 55, 26, 59, 60, 63, 64, 68, 71, 75, 78, 83, 90, 92, 93, 94, 95, 97, 99, 100, 104, 105, 115, 117, 118, 119, 120, 122);
    $out = '';
    if (count($D) > 0) {
        $row = $D[0];
        $story = stripslashes($row['story']);
        $title = stripslashes($row['storyline']);
        $warp = stripslashes($row['warp']);
        if ($row['forcesurvival'] == -1 && $mode == 'CREATIVE') {
            umc_ws_cmd("gamemode survival {$username};", 'asConsole');
        }
        if ($row['clear_inv'] == -1 && ($world == 'city' || $world == 'flatlands')) {
            umc_ws_cmd("ci {$username};", 'asConsole');
        }
        $items = stripslashes($row['items']);
        if (strlen($items) > 0 && ($world == 'city' || $world == 'flatlands')) {
            $items = explode(";", $items);
            if (count($items) > 0) {
                foreach ($items as $item) {
                    $data = explode(':', $item);
                    if (count($data) == 3 && !in_array($data[0], $disallowed_items)) {
                        if (is_numeric($data[0]) && is_numeric($data[1]) && is_numeric($data[2])) {
                            umc_ws_cmd("give {$username} {$data[0]}:{$data[1]} {$data[2]};", 'asConsole');
                        }
                    }
                }
            }
        }
        if (strlen($warp) > 0 && $world == 'city') {
            $warp = "story_" . $warp;
            umc_ws_cmd("warp {$warp} {$username};", 'asConsole');
        }
        $uuid = $row['uuid'];
        $creator_name = umc_user2uuid($uuid);
        // check for duplicate entries
        $sql = "SELECT * FROM minecraft_iconomy.story_users WHERE `uuid`='{$uuid}' and `story_id`='{$row['id']}';";
        $D3 = umc_mysql_fetch_all($sql);
        $count = count($D3);
        if ($count == 0) {
            $sql = "INSERT INTO minecraft_iconomy.story_users (`uuid`, `story_id`) VALUES ('{$uuid}', '{$row['id']}');";
            umc_mysql_query($sql, true);
        }
        $pages = explode("[BR]", $story);
        $pagecount = count($pages);
        if (isset($args[2]) && is_numeric($args[2]) && isset($pages[$args[2] - 1])) {
            $page = $args[2];
        } else {
            $page = 1;
        }
        $arr_page = $page - 1;
        $this_page_raw = $pages[$arr_page];
        $search = array('[player]', "\n");
        $replace = array($username, ';');
        foreach ($UMC_COLORS as $colorcode => $data) {
            foreach ($data['names'] as $color_name) {
                $search[] = "[" . $color_name . "]";
                $replace[] = "&" . $colorcode;
            }
        }
        $this_page = str_replace($search, $replace, $this_page_raw);
        $out = "{white}----------------- {green}Story Page ({$page}/{$pagecount}): {white}-----------------;" . "{yellow}{$title} {white}by {$creator_name};" . $this_page;
        if (count($pages) > $page) {
            $nextpage = $page + 1;
            $out .= "{white}------- {green}Please type /ws story {$code} {$nextpage} to read on! {white}--------;";
        } else {
            $out .= ";-----------------------------------------------------;";
        }
    } else {
        $out .= "The story code could not be found!";
    }
    $lines = explode(";", $out);
    foreach ($lines as $line) {
        umc_echo($line, true);
    }
}
コード例 #11
0
/**
 * This retrieves the websend environment variables and returns them
 */
function umc_ws_get_vars()
{
    // make sure we are on websend
    global $UMC_ENV, $UMC_USER, $UMC_USERS;
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    if ($UMC_ENV !== 'websend') {
        XMPP_ERROR_trigger("Tried to get websend vars, but environment did not match: " . var_export($UMC_ENV, true));
        die('umc_ws_get_vars');
    }
    // TODO: find an appropriate filter to sanitize this data
    // Since the input is authenticated with the code, it should be fine, but better safe than sorry
    $json = json_decode(stripslashes($_POST["jsonData"]), true);
    if (!isset($json['Invoker']['Name'])) {
        XMPP_ERROR_trigger("No invoker name in " . var_export($json, true));
    }
    if ($json['Invoker']['Name'] == '@Console') {
        $UMC_USER['username'] = '******';
        $UMC_USER['userlevel'] = 'Owner';
        $UMC_USER['donator'] = 'DonatorPlus';
        $UMC_USER['uuid'] = 'Console0-0000-0000-0000-000000000000';
    } else {
        $UMC_USER['username'] = $json['Invoker']['Name'];
        if (isset($json['Invoker']['UUID'])) {
            $uuid = $json['Invoker']['UUID'];
        } else {
            // this is mostly used for pre-logins. it will check if the user exists and add them to the table if not.
            XMPP_ERROR_trace("Getting UUID for UMC_USER array", "n/a");
            $uuid = umc_user2uuid($json['Invoker']['Name']);
        }
        $UMC_USER['uuid'] = $uuid;
        $UMC_USER['userlevel'] = umc_get_uuid_level($uuid);
        if (strstr($UMC_USER['userlevel'], 'DonatorPlus')) {
            $UMC_USER['donator'] = 'DonatorPlus';
        } else {
            if (strstr($UMC_USER['userlevel'], 'Donator')) {
                $UMC_USER['donator'] = 'Donator';
            } else {
                $UMC_USER['donator'] = false;
            }
        }
        // following only applies for in-game users
        if (isset($json['Invoker']['Location'])) {
            $UMC_USER['current_item'] = $json['Invoker']['CurrentItemIndex'];
            $UMC_USER['mode'] = $json['Invoker']['GameMode'];
            $UMC_USER['world'] = $json['Invoker']['Location']['World'];
            $UMC_USER['coords'] = array('x' => $json['Invoker']['Location']['X'], 'y' => $json['Invoker']['Location']['Y'], 'z' => $json['Invoker']['Location']['Z'], 'yaw' => umc_ws_yaw_fix($json['Invoker']['Location']['Yaw']));
            // xp converted to points value obtained total. JSON returns fractional value.
            $UMC_USER['xplevel'] = $json['Invoker']['XPLevel'];
            $UMC_USER['xpfraction'] = $json['Invoker']['XP'];
            $UMC_USER['xp'] = umc_ws_convert_xp($json['Invoker']['XP'], $json['Invoker']['XPLevel']);
            //IP Address
            $ip_raw = $json['Invoker']['IP'];
            // ip ⇒ "/210.176.194.100:11567"
            $ip_matches = false;
            $pattern = "/^\\/((?:[0-9]{1,3}\\.){3}[0-9]{1,3})/";
            preg_match($pattern, $ip_raw, $ip_matches);
            $UMC_USER['ip'] = $ip_matches[1];
        }
        $UMC_USER['inv'] = array();
        if (isset($json['Invoker']['Inventory'])) {
            $UMC_USER['inv'] = umc_ws_get_inv($json['Invoker']['Inventory']);
            $UMC_USER['current_item'] = $json['Invoker']['CurrentItemIndex'];
        }
    }
    $UMC_USER["args"] = $_POST['args'];
    // online players; we do not retrieve userlevels etc here yet
    $players = array();
    if (isset($json['ServerStatus']['OnlinePlayers'])) {
        $playerlist = $json['ServerStatus']['OnlinePlayers'];
        $player_all_data = array();
        /*
                Name:Bugsy_danny,
                XP:0.22314094007015228,
                IP:/66.27.153.127:50676,
                GameMode:SURVIVAL,
                UUID:b5e51419-30d0-4920-b7da-c90dabac6b07,
                FoodLevel:20,
                IsOP:false,
                Health:20,
                XPLevel:28,
                Exhaustion:1.4806113243103027,
                UUIDVersion:4
        */
        foreach ($playerlist as $player_data) {
            $players[$player_data['UUID']] = strtolower($player_data['Name']);
            foreach ($player_data as $type => $value) {
                $uuid = $player_data['UUID'];
                $player_all_data[$uuid][$type] = $value;
            }
        }
        $UMC_USER['online_players'] = $players;
        $UMC_USER['player_data'] = $player_all_data;
    }
    /*
        $current_user = new User();                         // create a user object
        $current_user->set_uuid($UMC_USER['uuid']);         // give it a uuid
        $UMC_USERS['current_user'] = $UMC_USER['uuid'];     // remember that this is the current user
        $UMC_USERS[$UMC_USER['uuid']] = $current_user;      // add the object to the list of all users
    *
    */
}
コード例 #12
0
ファイル: mail.inc.php プロジェクト: dani0010/uncovery_me
/**
 * displays an interface for email on the website
 *
 * @global type $UMC_USER
 * @return string
 */
function umc_mail_web()
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    global $UMC_USER, $UMC_DOMAIN;
    if (!$UMC_USER) {
        return "You have to be logged in to use this!";
    }
    $uuid = $UMC_USER['uuid'];
    $username = $UMC_USER['username'];
    $folder_arr = array('inbox' => "recipient_uuid='{$uuid}' AND (status='sent' OR status='read')", 'outbox' => "sender_uuid='{$uuid}' AND (status='sent')", 'drafts' => "sender_uuid='{$uuid}' AND (status='draft')", 'trash' => "(recipient_uuid='{$uuid}' AND status IN ('deleted_receiver','deleted_both')) OR (sender_uuid='{$uuid}' AND status IN ('deleted_sender','deleted_both'))");
    $selected = array();
    $action = filter_input(INPUT_POST, 'action', FILTER_SANITIZE_STRING);
    if (!isset($action)) {
        $action = filter_input(INPUT_GET, 'action', FILTER_SANITIZE_STRING);
    }
    $out = '<div id="umc_ajax_container" class="webmail" style="display:block">' . "\n";
    // XMPP_ERROR_trigger("Mail");
    $sani_post = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
    $out .= "\n<!-- POST CHECK // \n" . var_export($sani_post, true) . " \n// end -->\n";
    $sani_get = filter_input_array(INPUT_GET, FILTER_SANITIZE_STRING);
    $out .= "\n<!-- GET CHECK // \n" . var_export($sani_get, true) . " \n// end -->\n";
    $subject = '';
    $message = '';
    $recipient = '';
    $error = '';
    $msg_id = '';
    if ($action == 'Mark all read') {
        $read_sql = "UPDATE minecraft_srvr.`user_mail` SET status='read' WHERE recipient_uuid='{$uuid}';";
        umc_mysql_query($read_sql, true);
    }
    if ($action == 'Reply') {
        $recipient = filter_input(INPUT_POST, 'sender', FILTER_SANITIZE_STRING);
        $subject = "Re: " . htmlentities(filter_input(INPUT_POST, 'subject', FILTER_SANITIZE_STRING));
        $action = "New Mail";
    } else {
        if ($action == 'Delete' || $action == 'Undelete') {
            $msg_id = filter_input(INPUT_POST, 'msg_id', FILTER_SANITIZE_NUMBER_INT);
            $recipient_uuid = filter_input(INPUT_POST, 'recipient_uuid', FILTER_SANITIZE_STRING);
            $sender_uuid = filter_input(INPUT_POST, 'sender_uuid', FILTER_SANITIZE_STRING);
            $status = filter_input(INPUT_POST, 'status', FILTER_SANITIZE_STRING);
            if ($sender_uuid == $uuid) {
                $role = 'sender';
            } else {
                if ($recipient_uuid == $uuid) {
                    $role = 'recipient';
                }
            }
            umc_mail_delete_update_status($status, $role, $msg_id);
        } else {
            if ($action == 'Send' || $action == 'Save Draft') {
                // send message
                $subject = filter_input(INPUT_POST, 'subject', FILTER_SANITIZE_STRING);
                $message = filter_input(INPUT_POST, 'message', FILTER_SANITIZE_STRING);
                $recipient = strtolower(filter_input(INPUT_POST, 'recipient', FILTER_SANITIZE_STRING));
                $recipient_uuid = umc_user2uuid($recipient);
                $check = umc_check_user($recipient_uuid);
                if ($recipient == $username) {
                    $check = false;
                    $error = "You cannot send emails to yourself!";
                } else {
                    if (!$check) {
                        $error = "ERROR: Recipient '{$recipient}' could not be found!";
                        $recipient = '';
                    }
                }
                $msg_id = filter_input(INPUT_GET, 'msg_id', FILTER_SANITIZE_NUMBER_INT);
                if (strlen($message) < 5) {
                    $error = "Your message is too short!";
                    $action = "New Mail";
                    $check = false;
                } else {
                    if (strlen($subject) < 5) {
                        $error = "Your subject is too short!";
                        $action = "New Mail";
                        $check = false;
                    }
                }
                if ($action == 'Send' && !$check) {
                    // only complain if we are trying to send
                    $action = "New Mail";
                } else {
                    umc_mail_send_backend($recipient_uuid, $uuid, $message, $subject, $action, $msg_id);
                    $action = '';
                }
            }
        }
    }
    $out .= $error;
    if ($action == 'edit') {
        $msg_id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
        $onemail_sql = "SELECT `msg_id`, `date_time`, `recipient_uuid`, username, `title`, `message`, `status`\r\n                FROM minecraft_srvr.`user_mail`\r\n                LEFT JOIN minecraft_srvr.UUID ON recipient_uuid=UUID\r\n                WHERE msg_id={$msg_id} AND sender_uuid='{$uuid}' AND status='draft';";
        $mail_data = umc_mysql_fetch_all($onemail_sql);
        if (count($mail_data) == 0) {
            $out .= "ERROR: The draft email with ID {$msg_id} could not be found!";
        } else {
            $mail = $mail_data[0];
            $recipient = $mail['username'];
            $subject = htmlentities(trim($mail['subject']));
            $message = htmlentities(trim($mail['message']));
            $msg_id = $mail['msg_id'];
            $action = "New Mail";
        }
    }
    $msg_id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
    if ($action == 'New Mail') {
        //onsubmit=\"return umcAjaxFormProcess('" . umc_web_curr_url() . "', event)\"
        $out .= "<form id=\"newmailform\" method=\"post\"><div>\n" . "<span style=\"max-width:50%;\">Recipient: <input type=\"text\" name=\"recipient\" value=\"{$recipient}\" style=\"width:35%;\" maxlength=\"32\"></span>\n " . "<span style=\"max-width:50%;\">Subject: <input type=\"text\" name=\"subject\" value=\"{$subject}\" style=\"width:35%;\" maxlength=\"32\"></span><br>\n" . "Message:<br><textarea name=\"message\" value=\"\" rows=\"10\" style=\"width:100%;\">{$message}</textarea><input type=\"hidden\" name=\"msg_id\" value=\"\">\n" . "<input type=\"submit\" name=\"action\" value=\"Send\"><input type=\"submit\" name=\"action\" value=\"Save Draft\"><input type=\"submit\" name=\"action\" value=\"Cancel\">\n" . "</div></form>";
    } else {
        if ($action == 'mail' && is_numeric($msg_id)) {
            $onemail_sql = "SELECT `msg_id`, `date_time`, `sender_uuid`, `recipient_uuid`, `title` as subject, `message`, `status` FROM minecraft_srvr.`user_mail`\r\n                WHERE msg_id={$msg_id} AND (recipient_uuid='{$uuid}' OR sender_uuid='{$uuid}');";
            $mail_data = umc_mysql_fetch_all($onemail_sql);
            if (count($mail_data) == 0) {
                $out .= "ERROR: The email with ID {$msg_id} could not be found!<br>";
                $out .= "<a href=\"{$UMC_DOMAIN}/server-access/mail/\">Back</a>";
            } else {
                // onsubmit=\"return umcAjaxFormProcess('" . umc_web_curr_url() . "', event)\"
                $out .= "<a href=\"{$UMC_DOMAIN}/server-access/mail/\">Back</a><br>";
                $out .= "\n<form id=\"newmailform\" method=\"POST\" action=\"{$UMC_DOMAIN}/server-access/mail/\">\n<div>";
                $mail = array();
                foreach ($mail_data[0] as $field => $value) {
                    $mail[$field] = htmlentities(stripslashes(trim($value)));
                }
                $buttons = "<div style=\"float:right\">";
                if (in_array($mail['status'], array('deleted_receiver', 'deleted_both'))) {
                    $buttons .= " <input type=\"submit\" name=\"action\" value=\"Undelete\">";
                } else {
                    $buttons .= " <input type=\"submit\" name=\"action\" value=\"Delete\">";
                }
                if ($mail['recipient_uuid'] == $uuid) {
                    $buttons .= " <input type=\"submit\" name=\"action\" value=\"Reply\">";
                }
                $buttons .= "</div>";
                if ($mail['status'] == 'sent') {
                    $read_sql = "UPDATE minecraft_srvr.`user_mail` SET status='read' WHERE msg_id={$mail['msg_id']};";
                    umc_mysql_query($read_sql, true);
                    $mail['status'] = 'read';
                }
                $sender = umc_user2uuid($mail['sender_uuid']);
                $recipient = umc_user2uuid($mail['recipient_uuid']);
                $out .= "<div class=\"line\"><div style=\"float:left;width:33%;\"><label>From:</label><span class=\"field\">{$sender}</span></div>\n" . "<div style=\"float:left;width:33%;\"><label>To:</label><span class=\"field\">{$recipient}</span></div>\n" . "<div style=\"float:left;width:33%;\"><label>Date:</label><span class=\"field\">{$mail['date_time']}</span></div>\n" . "<div style=\"clear:both;\"></div>\n</div>" . "{$buttons}<div class=\"line\" style=\"overflow:hidden\"><label>Subject:</label><span class=\"field\">{$mail['subject']}</span></div>\n" . "<div style=\"clear:both;\"></div>\n" . "<div class=\"line\"><label>Message:</label><br>" . "<div class=\"field\">{$mail['message']}</div>\n</div>\n" . "<input type=\"hidden\" name=\"status\" value=\"{$mail['status']}\">" . "<input type=\"hidden\" name=\"sender\" value=\"{$sender}\">" . "<input type=\"hidden\" name=\"subject\" value=\"{$mail['subject']}\">" . "<input type=\"hidden\" name=\"recipient_uuid\" value=\"{$mail['recipient_uuid']}\">" . "<input type=\"hidden\" name=\"msg_id\" value=\"{$msg_id}\">" . "<input type=\"hidden\" name=\"sender_uuid\" value=\"{$mail['sender_uuid']}\">" . "</div></form>";
            }
        } else {
            // show folder
            if (!isset($post_folder)) {
                $post_folder = filter_input(INPUT_POST, 'folder', FILTER_SANITIZE_STRING);
            }
            $sql_filter = $folder_arr['inbox'];
            if (isset($post_folder) && $post_folder != 'inbox') {
                if (isset($folder_arr[$post_folder])) {
                    $sql_filter = $folder_arr[$post_folder];
                } else {
                    $out .= "<h2>Folder {$post_folder} cannot be found!</h2>";
                }
            }
            // get the current value
            $alerts_saved = umc_wp_get_meta($uuid, 'mc_mail_alerts');
            $alerts_choice = filter_input(INPUT_POST, 'email_alerts', FILTER_SANITIZE_STRING);
            $submit = filter_input(INPUT_POST, 'submit_form', FILTER_SANITIZE_STRING);
            // update database only if form was submitted
            if ($submit == 'submit_form') {
                if ($alerts_choice == 'email_alerts' && $alerts_saved == 'false') {
                    umc_wp_set_meta($uuid, 'mc_mail_alerts', 'true');
                    $alerts_saved = 'true';
                } else {
                    if ($alerts_choice == NULL && $alerts_saved == 'true') {
                        umc_wp_set_meta($uuid, 'mc_mail_alerts', 'false');
                        $alerts_saved = 'false';
                    }
                }
            }
            $out .= "<form action=\"\" method=\"post\">\n<div class=\"line\">\nFolder: <select name=\"folder\" onchange='this.form.submit()'>";
            $selected[$post_folder] = " selected=\"selected\"";
            foreach ($folder_arr as $folder => $str_filter) {
                $folder_str = ucwords($folder);
                $sel_str = '';
                if (isset($selected[$folder])) {
                    $sel_str = $selected[$folder];
                }
                $out .= "<option value=\"{$folder}\"{$sel_str}>{$folder_str}</option>";
            }
            $checked = '';
            if ($alerts_saved == 'true') {
                $checked = 'checked="checked"';
            }
            $out .= "</select>\n<input type=\"submit\" name=\"action\" value=\"New Mail\"><input type=\"submit\" name=\"action\" value=\"Mark all read\"><input type=\"hidden\" name=\"submit_form\" value=\"submit_form\">\n" . "<span style=\"float:right;\"><input type=\"checkbox\" name=\"email_alerts\" value=\"email_alerts\" {$checked} onchange='this.form.submit()'> Send e-mail alerts</span>" . "</div></form>\n";
            $sql = "SELECT `msg_id`, `date_time`, s_ref.username as sender, r_ref.username as recipient, `title` as subject, status\r\n                FROM minecraft_srvr.`user_mail`\r\n                LEFT JOIN minecraft_srvr.UUID as s_ref on sender_uuid=s_ref.UUID\r\n                LEFT JOIN minecraft_srvr.UUID as r_ref on recipient_uuid=r_ref.UUID\r\n                WHERE {$sql_filter} ORDER BY date_time DESC;";
            $status_header = "";
            if ($post_folder == 'outbox') {
                $status_header = '<th>Status</th>';
            }
            $D = umc_mysql_fetch_all($sql);
            $non_numeric = array('date_time', 'sender', 'recipient', 'subject');
            $formats = array('sender' => 'umc_mail_web_formats', 'status' => 'umc_mail_web_formats', 'recipient' => 'umc_mail_web_formats', 'subject' => 'umc_mail_web_formats');
            $hide_cols = array('msg_id');
            $check = umc_web_table("mail", "0, 'desc'", $D, '', $hide_cols, $non_numeric, $formats);
            if (!$check) {
                XMPP_ERROR_trigger("Error creating web_table with SQL {$sql}");
                $out .= "Error creating data table. Admin was notified, please wait until it is fixed";
            } else {
                $out .= $check;
            }
        }
    }
    $out .= "</div>\n";
    return $out;
}
コード例 #13
0
ファイル: lottery.inc.php プロジェクト: dani0010/uncovery_me
function umc_lottery()
{
    //  umc_error_notify("User $user, $chance (umc_lottery)");
    global $UMC_USER, $lottery, $ENCH_ITEMS;
    $user_input = $UMC_USER['args'][2];
    $user = umc_check_user($user_input);
    if (!$user) {
        umc_log("lottery", "voting", "user {$user} does not exist");
        return false;
    }
    $uuid = umc_user2uuid($user);
    $chance = false;
    if ($user == 'uncovery' && isset($UMC_USER['args'][3])) {
        $chance = $UMC_USER['args'][3];
    }
    $roll = umc_lottery_roll_dice($chance);
    // umc_echo(umc_ws_vardump($roll));
    $item = $roll['item'];
    $luck = $roll['luck'];
    $prize = $lottery[$item];
    //echo "type = {$prize['type']}<br>;";
    //echo "complete chance: $chance<br>;";
    //var_dump($prize);
    if (isset($prize['detail'])) {
        $detail = $prize['detail'];
    }
    $type = $prize['type'];
    // always give 100 uncs
    umc_money(false, $user, 100);
    $given_block_data = 0;
    $given_block_type = 0;
    //var_dump($prize);
    switch ($type) {
        case 'item':
            umc_deposit_give_item($uuid, $detail['type'], $detail['data'], $detail['ench'], 1, 'lottery');
            $item_txt = $prize['txt'];
            break;
        case 'random_unc':
            $luck2 = mt_rand(1, 500);
            umc_money(false, $user, $luck2);
            $item_txt = "{$luck2} Uncs";
            break;
        case 'random_potion':
            $luck2 = mt_rand(0, 63);
            umc_deposit_give_item($uuid, 373, $luck2, '', 1, 'lottery');
            $item_txt = $prize['txt'];
            break;
        case 'random_ench':
            // pick which enchantment
            $rand_ench = array_rand($ENCH_ITEMS);
            $ench_arr = $ENCH_ITEMS[$rand_ench];
            //pick which item to enchant
            $rand_item = array_rand($ench_arr['items']);
            $rand_item_id = $ench_arr['items'][$rand_item];
            // pick level of enchantment
            $lvl_luck = mt_rand(1, $ench_arr['max']);
            //echo "$item $ench_txt $lvl_luck";
            $item_ench_arr = array($rand_ench => $lvl_luck);
            $item = umc_goods_get_text($rand_item_id, 0, $item_ench_arr);
            $item_name = $item['item_name'];
            $full = $item['full'];
            umc_deposit_give_item($uuid, $item_name, 0, $item_ench_arr, 1, 'lottery');
            $item_txt = "a " . $full;
            break;
        case 'random_pet':
            // same as blocks below but only 1 always
            umc_echo($type);
            $block = $prize['blocks'];
            $luck2 = mt_rand(0, count($prize['blocks']) - 1);
            $given_block = explode(":", $block[$luck2]);
            $given_block_type = $given_block[0];
            $given_block_data = $given_block[1];
            umc_deposit_give_item($uuid, $given_block_type, $given_block_data, '', 1, 'lottery');
            $item = umc_goods_get_text($given_block_type, $given_block_data);
            $item_txt = "a " . $item['full'];
            break;
        case 'random_common':
        case 'random_ore':
        case 'random_manuf':
            $block = $prize['blocks'];
            $luck2 = mt_rand(0, count($prize['blocks']) - 1);
            $luck3 = mt_rand(1, 64);
            $given_block = explode(":", $block[$luck2]);
            $given_block_type = $given_block[0];
            $given_block_data = $given_block[1];
            umc_deposit_give_item($uuid, $given_block_type, $given_block_data, '', $luck3, 'lottery');
            $item = umc_goods_get_text($given_block_type, $given_block_data);
            $item_txt = "{$luck3} " . $item['full'];
            break;
    }
    if ($user != 'uncovery') {
        // testing only
        $item_nocolor = umc_ws_color_remove($item_txt);
        umc_ws_cmd("ch qm N {$user} voted, rolled a {$luck} and got {$item_nocolor}!", 'asConsole');
        umc_log('votelottery', 'vote', "{$user} rolled {$luck} and got {$item_nocolor} ({$given_block_type}:{$given_block_data})");
        $userlevel = umc_get_userlevel($user);
        if (in_array($userlevel, array('Settler', 'Guest'))) {
            $msg = "You received {$item_txt} from the lottery! Use {green}/withdraw @lottery{white} to get it!";
            umc_msg_user($user, $msg);
        }
    } else {
        umc_echo("{$user} voted, rolled a {$luck} and got {$item_txt}!");
    }
    // add vote to the database
    $service = umc_mysql_real_escape_string($UMC_USER['args'][3]);
    $ip = umc_mysql_real_escape_string($UMC_USER['args'][4]);
    $sql = "INSERT INTO minecraft_log.votes_log (`username`, `datetime`, `website`, `ip_address`)\r\n        VALUES ('{$uuid}', NOW(), {$service}, {$ip});";
    umc_mysql_query($sql, true);
    // echo "$user voted for the server and got $item_txt!;";
}
コード例 #14
0
/**
 * this returns the karma of a target or the current player, if no target set
 * returns either as value or as websend message, depening on the scenario
 *
 * @global type $UMC_USER
 * @global type $UMC_ENV
 * @param type $target
 * @param type $return
 * @return string
 */
function umc_getkarma($target = false, $return = false)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    global $UMC_USER, $UMC_ENV;
    if ($UMC_ENV == 'websend') {
        $user = $UMC_USER['username'];
        $user_uuid = $UMC_USER['uuid'];
        $args = $UMC_USER['args'];
    } else {
        $user = NULL;
        $args = NULL;
    }
    // do we have a target set? If no, assume current user
    if ($target) {
        $receiver_uuid = $target;
        $receiver = umc_user2uuid($target);
    } else {
        if (!isset($args[2])) {
            // get user's own karma
            $receiver = $user;
            $receiver_uuid = $user_uuid;
        } else {
            // get argument from command
            $receiver = umc_sanitize_input($args[2], 'player');
            $receiver_uuid = umc_user2uuid($receiver);
        }
    }
    if ($receiver == 'uncovery') {
        if ($return) {
            return "n/a";
        } else {
            if ($UMC_ENV == 'websend') {
                umc_error("Thou shalt not judge the maker of all things!");
            } else {
                return;
            }
        }
    }
    $banned = umc_user_is_banned($receiver_uuid);
    if ($banned) {
        if ($return) {
            return "(banned)";
        }
        umc_echo("User {$receiver} is banned");
        exit;
    }
    # Get the user's + and - karma entries
    $pos_sql = "SELECT SUM(karma) AS sum_karma\r\n\tFROM minecraft_srvr.karma\r\n        LEFT JOIN minecraft_srvr.UUID AS senders ON sender_uuid=uuid\r\n        WHERE receiver_uuid='{$receiver_uuid}' AND karma > 0\r\n\t  AND senders.lot_count > 0\r\n        GROUP BY receiver_uuid";
    $neg_sql = "SELECT SUM(karma) AS sum_karma\r\n\tFROM minecraft_srvr.karma\r\n        LEFT JOIN minecraft_srvr.UUID AS senders ON sender_uuid=uuid\r\n        WHERE receiver_uuid='{$receiver_uuid}' AND karma < 0\r\n\t  AND senders.lot_count > 0\r\n        GROUP BY receiver_uuid";
    $pos_data = umc_mysql_fetch_all($pos_sql);
    $neg_data = umc_mysql_fetch_all($neg_sql);
    # If the user has no karma entries, use 0
    if (count($pos_data) > 0) {
        $pos_karma = $pos_data[0]['sum_karma'];
    } else {
        $pos_karma = 0;
    }
    if (count($neg_data) > 0) {
        $neg_karma = $neg_data[0]['sum_karma'];
    } else {
        $neg_karma = 0;
    }
    $karma = $pos_karma + $neg_karma;
    if ($pos_karma == NULL && $neg_karma == NULL) {
        if ($return) {
            return 'n/a';
        }
        umc_echo("User {$receiver} has no karma record");
    } else {
        if ($pos_karma == NULL) {
            $pos_karma = 0;
        }
        if ($neg_karma == NULL) {
            $neg_karma = 0;
        }
        if ($return) {
            return "{$pos_karma}/{$neg_karma}";
        }
        umc_echo("User {$receiver} has {$karma} karma ({$pos_karma}/{$neg_karma}).");
    }
}
コード例 #15
0
function umc_do_deposit_internal($all = false)
{
    global $UMC_USER, $UMC_SETTING, $UMC_DATA;
    $player = $UMC_USER['username'];
    $uuid = $UMC_USER['uuid'];
    $args = $UMC_USER['args'];
    // make sure user holds item
    $all_inv = $UMC_USER['inv'];
    if (!$all) {
        $item_slot = $UMC_USER['current_item'];
        if (!isset($all_inv[$item_slot])) {
            umc_error("{red}You need to hold the item you want to deposit! (current slot: {$item_slot});");
        }
        $all_inv = array($item_slot => $all_inv[$item_slot]);
    }
    $sent_out_of_space_msg = 0;
    $seen = array();
    foreach ($all_inv as $slot) {
        $item_id = $slot['item_name'];
        if (!isset($UMC_DATA[$item_id])) {
            XMPP_ERROR_trigger("Invalid item deposit cancelled!");
            umc_error("Sorry, the item in your inventory is bugged, uncovery was notfied and this should be fixed soon. IF you want to speed it up, please send a ticket with as much detail as possible.");
        }
        $data = $slot['data'];
        if ($slot['meta']) {
            $meta = serialize($slot['meta']);
        } else {
            $meta = false;
        }
        // don't assign the same twice
        $item = umc_goods_get_text($slot['item_name'], $slot['data'], $slot['meta']);
        if (isset($seen[$item['full']])) {
            continue;
        }
        $inv = umc_check_inventory($slot['item_name'], $slot['data'], $slot['meta']);
        if ($inv == 0) {
            XMPP_ERROR_trigger("Item held could not be found in inventory: {$slot['item_name']}, {$slot['data']}, " . var_export($slot['meta'], true));
            umc_error("There was a system error. The admin has been notified. Deposit aborted.");
        }
        if (isset($args[2]) && $args[2] != 'lot_reset') {
            $recipient = umc_sanitize_input($args[2], 'player');
            $recipient_uuid = umc_user2uuid($recipient);
        } else {
            if (isset($args[2]) && $args[2] == 'lot_reset') {
                $recipient_uuid = 'reset000-lot0-0000-0000-000000000000';
                $recipient = $args[2];
            } else {
                $recipient = $player;
                $recipient_uuid = $uuid;
                if (!$all) {
                    umc_echo("{yellow}[!]{gray} No recipient given. Depositing for {gold}{$player}");
                }
            }
        }
        if (!$all && isset($args[3])) {
            $amount = umc_sanitize_input($args[3], 'amount');
            $amount_str = $amount;
            if ($amount > $inv) {
                umc_echo("{yellow}[!]{gray} You do not have {yellow}{$amount} {green}{$item['full']}{gray}. Depositing {yellow}{$inv}{gray}.");
                $amount = $inv;
                $amount_str = $inv;
            }
        } else {
            $amount = $inv;
            $amount_str = $inv;
        }
        umc_echo("{yellow}[!]{gray} You have {yellow}{$inv}{gray} items in your inventory, depositing {yellow}{$amount}");
        // check if recipient has space
        $userlevel = umc_get_uuid_level($recipient_uuid);
        $allowed = $UMC_SETTING['depositbox_limit'][$userlevel];
        $remaining = umc_depositbox_checkspace($recipient_uuid, $userlevel);
        $count = $allowed - $remaining;
        // umc_echo("Group: $userlevel Allowed: $allowed Remaining $remaining");
        $sql = "SELECT * FROM minecraft_iconomy.deposit\r\n            WHERE item_name='{$item['item_name']}' AND recipient_uuid='{$recipient_uuid}'\r\n            AND damage='{$data}' AND meta='{$meta}' AND sender_uuid='{$uuid}';";
        $D = umc_mysql_fetch_all($sql);
        // create the seen entry so we do not do this again
        $seen[$item['full']] = 1;
        // check first if item already is being sold
        if (count($D) > 0) {
            $row = $D[0];
            umc_echo("{green}[+]{gray} You already have {$item['full']}{gray} in the deposit for {gold}{$recipient}{gray}, adding {yellow}{$amount}{gray}.");
            $sql = "UPDATE minecraft_iconomy.`deposit` SET `amount`=amount+'{$amount}' WHERE `id`={$row['id']} LIMIT 1;";
        } else {
            //check if recipient has space
            if ($count >= $allowed && $player != 'uncovery' && $recipient != 'lot_reset') {
                if (!$sent_out_of_space_msg) {
                    umc_echo("{red}[!] {gold}{$recipient}{gray} does not have any more deposit spaces left " . "(Used {white}{$count} of {$allowed}{gray} available for group {white}{$userlevel}{gray})!");
                    $sent_out_of_space_msg = 1;
                }
                continue;
            }
            // check if recipient is an active user
            $target_active = umc_user_countlots($recipient);
            if ($target_active == 0 && $recipient != 'lot_reset') {
                umc_error("{red}[!] {gold}{$recipient}{gray} is not an active user, so you cannot deposit items for them!");
            }
            // create a new deposit box
            if (strlen($item['item_name']) < 3) {
                XMPP_ERROR_trigger("Error depositing, item name too short!");
                umc_error("There was an error with the deposit. Please send a ticket to the admin so this can be fixed.");
            }
            $text = "{green}[+]{gray} Depositing {yellow}{$amount_str} {$item['full']}{gray} for {gold}{$recipient}";
            umc_echo($text);
            $sql = "INSERT INTO minecraft_iconomy.`deposit` (`damage` ,`sender_uuid` ,`item_name` ,`recipient_uuid` ,`amount` ,`meta`)\r\n                    VALUES ('{$data}', '{$uuid}', '{$item['item_name']}', '{$recipient_uuid}', '{$amount}', '{$meta}');";
            $count++;
            umc_log("Deposit", "do_deposit", $text);
        }
        umc_mysql_query($sql, true);
        umc_clear_inv($item['item_name'], $data, $amount, $meta);
    }
    if ($recipient == 'lot_reset') {
        $allowed = 'unlimited';
    }
    umc_echo("{green}[+]{gray} You have now used {white}{$count} of {$allowed}{gray} deposit boxes");
}
コード例 #16
0
/**
 * register the user to the whitelist
 * ad the uuid to the UUID table
 * add the UUID to the Meta data in wordpress
 *
 * @param type $user_id
 */
function umc_wp_register_addWhitelist($user_id)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $current_user = get_user_by('id', $user_id);
    $username = $current_user->user_login;
    require_once '/home/minecraft/server/bin/index_wp.php';
    //$check = umc_read_data('whitelist');
    // umc_update_data('whitelist', array($username => $username));
    umc_exec_command("whitelist add {$username}", 'asConsole', false);
    // add UUID to use meta
    $UUID = umc_user2uuid($username);
    add_user_meta($user_id, 'minecraft_uuid', $UUID);
    // add user to UUID table
    umc_uuid_record_usertimes('firstlogin');
}
コード例 #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;
}
コード例 #18
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;
    }
}
コード例 #19
0
/**
 * get's either the uuid or username, depending on format
 * @param string $query username or uuid
 * @param string $format of array('username', 'uuid')
 * @return string
 */
function umc_uuid_getone($query, $format = 'uuid')
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    if ($format == 'uuid' && strlen($query) > 18) {
        return $query;
    } else {
        if ($format == 'uuid' && strlen($query) < 18) {
            return umc_user2uuid($query);
        } else {
            if ($format == 'username' && strlen($query) > 18) {
                return umc_user2uuid($query);
            } else {
                if ($format == 'username' && strlen($query) < 18) {
                    return $query;
                } else {
                    XMPP_ERROR_trigger("Error format for umc_uuid_getone ({$format} / {$query})");
                }
            }
        }
    }
}