/** * This function displays the proposals the user has not voted on yet. It's displayed on user login **/ function umc_vote_get_votable($username = false, $web = false) { XMPP_ERROR_trace(__FUNCTION__, func_get_args()); global $UMC_DOMAIN, $vote_ranks, $UMC_USER; $out = ''; if (!$username) { $username = $UMC_USER['username']; $uuid = $UMC_USER['uuid']; } else { $uuid = umc_uuid_getone($username, 'uuid'); } if (!$username && !isset($UMC_USER['username'])) { XMPP_ERROR_trigger("websend player undidentified"); } $user_lvl = umc_get_userlevel($username); $user_lvl_id = $vote_ranks[$user_lvl]['lvl']; if ($user_lvl_id < 3) { // start voting only for designers return; } $sql = "SELECT proposals.pr_id, proposals.uuid, proposals.date, 60 - DATEDIFF(NOW(), proposals.date) as remainder, UUID.username as username FROM minecraft_srvr.proposals\r\n LEFT JOIN minecraft_srvr.proposals_votes ON proposals.pr_id=proposals_votes.pr_id AND voter_uuid='{$uuid}'\r\n LEFT JOIN minecraft_srvr.UUID ON proposals.uuid=UUID.UUID\r\n WHERE proposals_votes.pr_id IS NULL AND status='voting' ORDER BY proposals.`date` ASC"; $D = umc_mysql_fetch_all($sql); $no_votes = array(); // echo $sql; foreach ($D as $row) { $proposal = $row['uuid']; $proposal_username = $row['username']; $prop_lvl = umc_get_uuid_level($proposal); $prop_lvl_id = $vote_ranks[$prop_lvl]['lvl']; if ($prop_lvl_id < $user_lvl_id) { $days_left = $row['remainder']; $no_votes[$proposal_username] = $days_left; } } if (count($no_votes) > 0) { if ($web) { $out .= "<strong><a href=\"{$UMC_DOMAIN}/vote-for-users/\">Please vote</a>:</strong> (" . count($no_votes) . ") "; foreach ($no_votes as $proposee => $days) { $out .= "{$proposee}, "; } $out = rtrim($out, ", "); return $out; } else { umc_header('Your missing votes: (days remaining)', true); foreach ($no_votes as $proposee => $days) { $out .= "{red}{$proposee} {grey}({$days}){white}, "; } umc_echo($out, true); umc_echo("{gold}Please vote ASAP! Only YOU can determine the future of the server! {$UMC_DOMAIN}/vote-for-users/", true); umc_footer(true); } } else { return false; } }
function umc_mod_ban() { global $UMC_USER; $player = $UMC_USER['username']; $args = $UMC_USER['args']; if ($player == 'riedi73') { echo "Sorry Riedi, rerouting to ban request :)"; return umc_mod_banrequest(); } if (!isset($args[2])) { umc_show_help($args); die; } else { $user = strtolower(umc_check_user($args[2])); if (!$user) { umc_error("{red}The user {$args[2]} does not exist! See {yellow}/helpme mod"); } } $admin_arr = array('uncovery', '@Console', '@console'); if (!in_array($user, $UMC_USER['online_players']) && !in_array($player, $admin_arr)) { umc_echo("Dear {$player}, the user {$args[2]} is not currently online, a banrequest will be sent instead!", true); umc_mod_banrequest(); return; } // concatenate multi-word reasons if (!isset($args[3])) { umc_error("You need to give a reason for the ban request!"); } $reason = ""; for ($i = 3; $i < count($args); $i++) { $reason .= " " . $args[$i]; } $uuid = umc_user2uuid($user); $reason_text = trim($reason); $subject = "[Uncovery Minecraft] Ban of {$user} by {$player}"; $content = "User {$player} has banned {$user} for reason: {$reason_text}!\r\n" . "Logfile:\r\n"; $content .= umc_attach_logfile($user); $headers = 'From:minecraft@uncovery.me' . "\r\nReply-To:minecraft@uncovery.me\r\n" . 'X-Mailer: PHP/' . phpversion(); mail('*****@*****.**', $subject, $content, $headers); umc_header("Ban of {$user} by {$player}", true); umc_echo("Thanks for the ban! An email with a logfile has been sent to the admin.", true); umc_footer(true); umc_user_ban($uuid, $reason); }
function umc_lot_warp() { global $UMC_USER; $player = $UMC_USER['username']; $userlevel = $UMC_USER['userlevel']; $world = $UMC_USER['world']; $args = $UMC_USER['args']; $allowed_ranks = array('Owner', 'Guest'); if (!in_array($userlevel, $allowed_ranks)) { umc_error("Sorry, this command is only for Guests!"); } $allowed_worlds = array('empire', 'flatlands'); if (!in_array($world, $allowed_worlds)) { umc_error('Sorry, you need to be in the Empire or Flatlands to warp!'); } else { $lot = strtolower(umc_sanitize_input($args[2], 'lot')); // the above one fails already if the lot is not a proper lot $target_world = umc_get_lot_world($lot); if (!in_array($target_world, $allowed_worlds)) { umc_error('Sorry, you need to be in the Empire or Flatlands to warp!'); } if ($target_world != $world) { umc_error("Sorry, you need to be in {$target_world} to warp to {$lot}!"); } } $sql = "SELECT * FROM minecraft_worldguard.world LEFT JOIN minecraft_worldguard.region ON world.id=region.world_id\r\n LEFT JOIN minecraft_worldguard.region_cuboid ON region.id=region_cuboid.region_id\r\n WHERE world.name='{$target_world}' AND region.id = '{$lot}' "; $D = umc_mysql_fetch_all($sql); if (count($D) != 1) { umc_error("There was an error teleporting you to your lot, the admin was notified, please wait for it to be fixed!"); } $lots = $D[0]; $c_x = $lots['min_x'] + 64; $c_z = $lots['min_z'] + 64; $c_y = 256; $cmd = "tppos {$player} {$c_x} {$c_y} {$c_z} 0"; umc_ws_cmd($cmd, 'asConsole'); umc_pretty_bar("darkblue", "-", "{darkcyan} Warping to lot {$lot}"); umc_echo("You are now in the center of lot {$lot}!"); umc_footer(); }
function umc_contests_join() { global $UMC_USER; $args = $UMC_USER['args']; $player = $UMC_USER['username']; $debug = true; if (!isset($args[2])) { umc_show_help($args); die; } $id = $args[2]; umc_pretty_bar("darkblue", "-", "{darkcyan} Joining contest {$id} "); if (!is_numeric($id)) { umc_error("You have to enter a numeric contest ID ({$id}). See /contest list"); } // find out if the contest is creative or survival $sql = "SELECT * FROM minecraft_srvr.contest_contests WHERE id = {$id};"; $rst = mysql_query($sql); $contest = mysql_fetch_array($rst, MYSQL_ASSOC); $status = $contest['status']; if ($status !== 'active') { umc_error("Contest number {$id} is not active. Please chose a different contest!"); } $min = array('aether' => array('x' => -1532, 'z' => -1532, 'y' => 11, 'parent' => 'aet_p1'), 'flatlands' => array('x' => 1028, 'z' => 1028, 'y' => 64, 'parent' => 'flat_b19')); $max = array('aether' => array('x' => -1157, 'z' => -1157, 'y' => 255), 'flatlands' => array('x' => 1275, 'z' => 1275, 'y' => 255)); $gap = 4; $type = 'survival'; $world = 'aether'; if ($contest['type'] == 'creative') { $type = 'creative'; $world = 'flatlands'; } $parent = $min[$world]['parent']; $min_coords = $min[$world]; $min_x = $min_coords['x']; $min_z = $min_coords['z']; $min_y = $min_coords['y']; if ($debug) { umc_echo("Min coords are {$min_x}/{$min_y}/{$min_z}"); } $max_coords = $max[$world]; $max_x = $max_coords['x']; $max_z = $max_coords['z']; $max_y = $max_coords['y']; if ($debug) { umc_echo("MAx coords are {$max_x}/{$max_y}/{$max_z}"); } $user_id = umc_get_worldguard_id('user', strtolower($player)); $world_id = umc_get_worldguard_id('world', strtolower($world)); // find out if the user can have additional contest entries in this contest $sql = "SELECT * FROM minecraft_worldguard.world LEFT JOIN minecraft_worldguard.region ON world.id=region.world_id\r\n LEFT JOIN minecraft_worldguard.region_cuboid ON region.id=region_cuboid.region_id\r\n LEFT JOIN minecraft_worldguard.region_players ON region_cuboid.region_id=region_players.region_id\r\n WHERE world.name='{$world}' AND region.id LIKE 'con_" . $id . "%' AND user_id={$user_id} AND Owner=1\r\n ORDER BY max_z, max_x"; $rst = mysql_query($sql); $count = mysql_num_rows($rst); if ($count >= $contest['max_entries'] && $player != 'uncovery') { umc_error("You have reached the max number of entries for this contest!;"); } // find out if a contest lot already exists $sql = "SELECT * FROM minecraft_worldguard.world LEFT JOIN minecraft_worldguard.region ON world.id=region.world_id\r\n LEFT JOIN minecraft_worldguard.region_cuboid ON region.id=region_cuboid.region_id\r\n WHERE world.name='{$world}' AND region.id LIKE 'con%' ORDER BY max_z, max_x"; $rst = mysql_query($sql); $count = mysql_num_rows($rst); if ($debug) { umc_echo("{$count} entries already entered!"); } $lotnumber = $count + 1; $lot = 'con_' . $id . '_' . $lotnumber; if ($debug) { umc_echo("Trying to create entry {$lot}"); } // how many lots can I fit into the space across? $fullwidth = $max_x - $min_x; if ($debug) { umc_echo("Lot width is {$fullwidth}"); } $single_width = $contest['x'] + $gap; if ($debug) { umc_echo("One lot (with gap) is {$single_width} wide"); } $width_lots = floor($fullwidth / $single_width); if ($debug) { umc_echo("Fitting {$width_lots} per line"); } $fulldepth = $max_z - $min_z; $single_depth = $contest['z'] + $gap; if ($debug) { umc_echo("One lot (with gap) is {$single_depth} deep"); } $depth_lots = floor($fulldepth / $single_depth); if ($debug) { umc_echo("Fitting {$depth_lots} per row"); } $full_lines = floor($count / $width_lots); if ($debug) { umc_echo("{$full_lines} lines already full"); } $lastline_lots = $count - $full_lines * $width_lots; if ($debug) { umc_echo("Last line has {$lastline_lots} lots"); } $start_x = $lastline_lots * ($contest['x'] + $gap) + $min_coords['x']; $start_z = $full_lines * ($contest['z'] + $gap) + $min_coords['z']; $start_y = $min_coords['y']; if ($debug) { umc_echo("Starting coords are {$start_x}/{$start_y}/{$start_z}"); } $end_x = $start_x + $contest['x'] - 1; $end_z = $start_z + $contest['z'] - 1; $end_y = $min_coords['y'] + $contest['y'] - 1; if ($debug) { umc_echo("End coords are {$end_x}/{$end_y}/{$end_z}"); } if ($end_x > $max_x || $end_z > $max_z) { umc_error('There is no more space for additional contest entries!;'); } umc_echo("New lot {gold}{$lot}{white} in {gold}{$world}{white} was created at "); umc_echo("coordinates {gold}{$start_x}/{$start_y}/{$start_z}{white} - {gold}{$end_x}/{$end_y}/{$end_z}{white};"); umc_echo("Use {gold}/contest warp {$id} {$lotnumber}{white} to get there."); // create insert SQL id world_id type priority parent $ins_region_sql = "INSERT INTO region (id, world_id, type, priority, parent)\r\n VALUES ('{$lot}', {$world_id}, 'cuboid', 0, '{$parent}');"; $ins_region_rst = mysql_query($ins_region_sql); // insert cuboid region_id world_id min_x min_y min_z max_x max_y max_z $ins_cuboid_sql = "INSERT INTO region_cuboid (region_id, world_id, min_x, min_y, min_z, max_x, max_y, max_z)\r\n VALUES ('{$lot}', {$world_id}, {$start_x}, {$start_y}, {$start_z}, {$end_x}, {$end_y}, {$end_z});"; $ins_cuboid_rst = mysql_query($ins_cuboid_sql); // add user to lot as Owner region_id world_id user_id Owner $ins_user_sql = "INSERT INTO region_players (region_id, world_id, user_id, Owner)\r\n VALUES ('{$lot}', {$world_id}, {$user_id}, 1);"; $inc_user_rst = mysql_query($ins_user_sql); umc_ws_cmd("region load -w {$world}", 'asConsole'); umc_footer(); }
function umc_info_who() { global $UMC_USER; $args = $UMC_USER['args']; // we predefine the array to make sure proper sorting $out_arr = array('Guest' => array(), 'Settler' => array(), 'Citizen' => array(), 'Architect' => array(), 'Designer' => array(), 'Master' => array(), 'Elder' => array(), 'Owner' => array()); $user_worlds = false; if (isset($args[2]) && $args[2] == 'where') { $user_worlds = umc_read_markers_file('array'); } else { if (isset($args[2])) { // single player info $user = umc_check_user($args[2]); if ($user) { $user_info = umc_get_userinfo($user); umc_header("User info for {$user}"); $data_text = ''; foreach ($user_info as $desc => $data) { if ($desc == 'Last Seen') { if (isset($UMC_USER['player_data'][$user_info['uuid']])) { $data_text = "{$user} is currently online"; } else { $datetime = umc_datetime($data); $diff = umc_timer_format_diff($datetime); $data_text = $diff . " ago"; } } else { $data_text = $data; } umc_echo("{green}{$desc}: {white}{$data_text}"); } umc_footer(); return; } else { umc_echo("{red}Error: Command/user not recognized"); } } } $players_data = $UMC_USER['player_data']; $count = count($players_data); foreach ($players_data as $uuid => $players_details) { $level = umc_get_uuid_level($uuid); $player = $players_details['Name']; if (strstr($level, "DonatorPlus")) { $new_lvl = substr($level, 0, -11); $new_player = "{$player}{yellow}++{white}"; } else { if (strstr($level, "Donator")) { $new_lvl = substr($level, 0, -7); $new_player = "{$player}{yellow}+{white}"; } else { $new_lvl = $level; $new_player = $player; } } $lower_username = strtolower($player); if ($user_worlds && isset($user_worlds[$lower_username])) { $new_player .= " {grey}({$user_worlds[$lower_username]['world']}){white}"; } $out_arr[$new_lvl][] = $new_player; } umc_header("{$count} users online:"); foreach ($out_arr as $level => $players) { if (count($players) > 0) { umc_echo("{green}{$level}: {white}" . implode(", ", $players)); } } umc_footer(); if ($user_worlds) { umc_echo("{blue}Try {grey}/who <player>{blue} for user details"); } else { umc_echo("{blue}Try {grey}/where{blue} or {grey}/who <player>{blue} for more info"); } }
/** * 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; } } } }
function umc_hardcore_score() { $C = umc_hardcore_get_period(); // query all scores inbetween the two dates $sql = "SELECT username, score FROM minecraft_srvr.hardcore\r\n LEFT JOIN minecraft_srvr.UUID ON hardcore.UUID=UUID.UUID\r\n WHERE entry_date >= '{$C['start_date']}' AND entry_date < '{$C['end_date']}'\r\n ORDER BY score DESC;"; $D = umc_mysql_fetch_all($sql); umc_header("Hardcore Game score week {$C['number']}"); $i = 1; foreach ($D as $d) { umc_echo("{yellow}{$i} {white}{$d['username']}{gray}: {$d['score']}"); $i++; } umc_footer(); }
function umc_ts_authorize() { XMPP_ERROR_trace(__FUNCTION__, func_get_args()); global $UMC_USER, $UMC_TEAMSPEAK; umc_ts_connect(); // get client by name $uuid = $UMC_USER['uuid']; $userlevel = $UMC_USER['userlevel']; $username = strtolower($UMC_USER['username']); // get required servergroup foreach ($UMC_TEAMSPEAK['user_groups'] as $g_id => $usergroups) { if (in_array($userlevel, $usergroups)) { $target_group = $g_id; break; } } XMPP_ERROR_trace("target group", $target_group); umc_header(); // first, we clean out old clients that are registered with minecraft umc_ts_clear_rights($uuid, true); XMPP_ERROR_trace("Done clearing old rights"); // then, we try to find a new user on the TS server to give rights to umc_echo("Your TS level is " . $UMC_TEAMSPEAK['ts_groups'][$target_group]); XMPP_ERROR_trace("User TS level is ", $UMC_TEAMSPEAK['ts_groups'][$target_group]); umc_echo("Looking for user {$username} in TS..."); $users = umc_ts_list_users(); $found = 0; // iterate all users to make sure that there are not 2 with the same nickname foreach ($users as $user) { XMPP_ERROR_trace("comparing user {$username} to ", $user); if ($user == $username) { $found++; XMPP_ERROR_trace("found user ", $user); } } XMPP_ERROR_trace("found no if users: ", $found); if ($found == 0) { umc_echo("You need to logon to Teamspeak with the EXACT same username (\"{$username}\")"); umc_echo("Once you did that, please try again"); umc_footer(); return false; } else { if ($found > 1) { umc_echo("There are 2 users with the same username (\"{$username}\") online."); umc_echo("Process halted. Make sure you are the only one with the correct username"); umc_echo("If there is someone else hogging your username, please send in a /ticket"); umc_footer(); return false; } } // we have a user $ts_Client = $UMC_TEAMSPEAK['server']->clientGetByName($username); $ts_dbid = $ts_Client["client_database_id"]; // remove all groups $servergroups = array_keys($UMC_TEAMSPEAK['server']->clientGetServerGroupsByDbid($ts_dbid)); foreach ($servergroups as $sgid) { umc_echo($ts_Client["client_nickname"] . " is member of group " . $UMC_TEAMSPEAK['ts_groups'][$sgid]); if ($sgid != $target_group && $sgid != 8) { umc_echo("Removing usergroup {$sgid}..."); $UMC_TEAMSPEAK['server']->serverGroupClientDel($sgid, $ts_dbid); // remove user from group } else { if ($sgid == $target_group) { umc_echo("Not removing usergroup {$sgid}..."); $target_group = false; } } } // add the proper group if ($target_group) { // add target group of required umc_echo("Adding you to group " . $UMC_TEAMSPEAK['ts_groups'][$target_group]); $ts_Client->addServerGroup($target_group); } // get UUID $target_ts_uuid = $ts_Client["client_unique_identifier"]; $ts_uuid = umc_mysql_real_escape_string($target_ts_uuid); $ins_sql = "UPDATE minecraft_srvr.UUID SET ts_uuid={$ts_uuid} WHERE UUID='{$uuid}';"; umc_mysql_query($ins_sql, true); umc_echo("Adding TS ID {$ts_uuid} to database"); umc_footer("Done!"); }
function umc_trivia_check() { global $UMC_USER; $player = $UMC_USER['username']; // $args = $UMC_USER['args']; $quiz_arr = umc_trivia_get_current_quiz(); $master = $quiz_arr['master']; if (!$quiz_arr) { umc_error("There is no active quiz to get answers for. Please start one first."); } else { if ($player != $master) { umc_error("{$master} is running a quiz already, it has to stop first!"); } else { if ($quiz_arr['status'] != 'asked') { umc_error("You need to ask the next question before you can get the answers."); } else { if (!isset($quiz_arr['answers'])) { umc_error("Nobody has answered this question so far"); } } } } umc_header("Trivia Answers Status", true); umc_echo("{green}Question:{white} " . $quiz_arr['question']); umc_echo("{green}Correct Answer:{white} " . $quiz_arr['answer']); umc_footer(true); foreach ($quiz_arr['answers'] as $id => $answer) { umc_echo("{green}{$id}:{white} " . trim($answer)); } umc_footer(true); umc_echo("Pick a correct answer with {green}/trivia solve <No>{white}"); umc_echo("In case there are 2 correct answers, pick the one higher up."); umc_echo("Use {green}/trivia skip{white} in case you did not get any good answers"); umc_footer(true); }
function umc_skyblock_challenge_select() { global $UMC_USER; $player = $UMC_USER['username']; $args = $UMC_USER['args']; if (!is_numeric($args[2])) { umc_error("Your challenge ID needs to be a number!"); } else { $lot_sql = "SELECT region_cuboid.region_id as lot FROM `region_cuboid`\r\n LEFT JOIN region_players ON region_cuboid.region_id=region_players.region_id\r\n WHERE user_id IS NULL\r\n\t\tAND region_cuboid.`region_id` LIKE 'block%'\r\n\t\tAND min_z<-768\r\n\t\tAND min_x>=-1152\r\n\t\tAND max_x<1024;"; $D = umc_mysql_fetch_all($lot_sql); if (count($D) == 0) { XMPP_ERROR_trigger("We ran out of challenge lots!"); umc_error("Sorry, there are currently no challenge lots free!"); } else { $lot_row = $D[0]; $challenge_lot = $lot; } $id = $args[2]; $sql = "SELECT * FROM minecraft_quiz.block_challenges WHERE challenge_id={$id};"; $rst = umc_mysql_query($sql); $row = umc_mysql_fetch_array($rst); $lot = $row['lot']; $biome = $row['biome']; $inventory = $row['inventory']; $name = $row['name']; $desc = $row['desc']; $win_conditions = $row['win_conditions']; umc_header("Challenge {$id}: {$name}"); umc_echo("{white}{$desc}"); $lot_str = $lot; if ($lot == null) { $lot_str = 'standard'; } umc_echo("{green}Lot type: {white}{$lot_str}"); $biome_str = $biome; if ($biome == null) { $biome_str = 'standard'; } umc_echo("{green}Lot type: {white}{$biome_str}"); if (umc_skyblock_web_display_table($id)) { umc_echo("{green}Sub challenges: {white}This challenge has subchallenges. Please see the website for details."); } $inv_str = umc_skyblock_inv_to_desc($inventory); umc_echo("{green}Starting Inventory:{white}{$inv_str}"); $winstr = umc_skyblock_inv_to_desc($win_conditions); umc_echo("{green}Winning conditions:{white}{$winstr}"); $sub_challenge = $row['sub_challenge']; $challenge = $id; if ($sub_challenge !== null) { $challenge = $sub_challenge; } $sql = "INSERT INTO `minecraft_quiz`.`block_games` (`game_id`, `username`, `start`, `end`, `status`, `challenge_id`, `sub_challenge_id`, `lot`)\r\n VALUES (NULL, '{$player}', NOW(), NULL, 'selected', '{$challenge}', '{$sub_challenge}', '{$challenge_lot}');"; umc_mysql_query($sql, true); umc_echo("Please type {green}/skyblock start{white} or {green}/skyblock cancel"); umc_footer(); } }
function umc_ts_authorize() { global $UMC_USER, $UMC_TEAMSPEAK; // include libraries require_once '/home/uncovery/teamspeak_php/libraries/TeamSpeak3/TeamSpeak3.php'; // connect to server if (!$UMC_TEAMSPEAK['server']) { $UMC_TEAMSPEAK['server'] = TeamSpeak3::factory("serverquery://*****:*****@74.208.45.80:10011/?server_port=9987"); } // get client by name $uuid = $UMC_USER['uuid']; $userlevel = $UMC_USER['userlevel']; $username = $UMC_USER['username']; // get required servergroup foreach ($UMC_TEAMSPEAK['user_groups'] as $g_id => $usergroups) { if (in_array($userlevel, $usergroups)) { $target_group = $g_id; break; } } // first, we see if there is a current user logged in $ts_Client = false; umc_header(); // first, we clean out old clients that are registered with minecraft umc_ts_clear_rights($uuid, true); // then, we try to find a new user on the TS server to give rights to umc_echo("Your TS level is " . $UMC_TEAMSPEAK['ts_groups'][$target_group]); umc_echo("Looking for user {$username} in TS..."); $found = 0; foreach ($UMC_TEAMSPEAK['server']->clientList() as $ts_Client) { if ($ts_Client["client_nickname"] == $username) { $found++; } } if ($found == 0) { umc_echo("You need to logon to Teamspeak with the EXACT same username (\"{$username}\")"); umc_echo("Once you did that, please try again"); umc_footer(); return false; } else { if ($found > 1) { umc_echo("There are 2 users with the same username (\"{$username}\") online."); umc_echo("Process halted. Make sure you are the only one with the correct username"); umc_echo("If there is someone else hogging your username, please send in a /ticket"); umc_footer(); return false; } } // we have a user umc_echo("Found TS user " . $ts_Client["client_nickname"]); $ts_dbid = $ts_Client["client_database_id"]; // remove all groups $servergroups = array_keys($UMC_TEAMSPEAK['server']->clientGetServerGroupsByDbid($ts_dbid)); foreach ($servergroups as $sgid) { umc_echo($ts_Client["client_nickname"] . " is member of group " . $UMC_TEAMSPEAK['ts_groups'][$sgid]); if ($sgid != $target_group && $sgid != 8) { umc_echo("Removing usergroup {$sgid}..."); $UMC_TEAMSPEAK['server']->serverGroupClientDel($sgid, $ts_dbid); // remove user from group } else { if ($sgid == $target_group) { umc_echo("Not removing usergroup {$sgid}..."); $target_group = false; } } } // add the proper group if ($target_group) { // add target group of required umc_echo("Adding you to group " . $UMC_TEAMSPEAK['ts_groups'][$target_group]); $ts_Client->addServerGroup($target_group); } // get UUID $target_ts_uuid = $ts_Client["client_unique_identifier"]; $ts_uuid = umc_mysql_real_escape_string($target_ts_uuid); $ins_sql = "UPDATE minecraft_srvr.UUID SET ts_uuid={$ts_uuid} WHERE UUID='{$uuid}';"; umc_mysql_query($ins_sql, true); umc_echo("Adding TS ID {$ts_uuid} to database"); umc_footer("Done!"); }
function umc_mail_list() { global $UMC_USER; $uuid = $UMC_USER['uuid']; $args = $UMC_USER['args']; $folders = array('inbox', 'outbox', 'trash'); if (isset($args[2]) && !in_array($args[2], $folders)) { umc_error("You need to chose one of the folders {green}inbox{white}, {green}outbox{white} or {green}trash{white}"); } if (!isset($args[2])) { $folder = "All folders"; $filter = 'all'; $no_mail = "You have no emails"; } else { $folder = "Folder " . ucwords($args[2]); $filter = $args[2]; $no_mail = "You have no emails in {$folder}"; } umc_header("Uncovery Mail {$folder}"); $status_arr = array('all' => "(recipient_uuid='{$uuid}' AND status NOT IN ('deleted_recipient','deleted_both')) OR (sender_uuid='{$uuid}' AND status NOT IN ('deleted_sender','deleted_both'))", 'inbox' => "recipient_uuid='{$uuid}' AND (status='sent' OR status='read')", 'outbox' => "sender_uuid='{$uuid}' AND (status='sent')", 'trash' => "(recipient_uuid='{$uuid}' AND status IN ('deleted_recipient','deleted_both')) OR (sender_uuid='{$uuid}' AND status IN ('deleted_sender','deleted_both'))"); $sql_filter = $status_arr[$filter]; $sql = "SELECT * FROM minecraft_srvr.`user_mail` WHERE {$sql_filter} ORDER BY date_time ASC;"; $D = umc_mysql_fetch_all($sql); if (count($D) == 0) { umc_echo("No emails in this mailbox"); umc_footer(); return; } foreach ($D as $row) { if ($row['sender_uuid'] == $uuid) { $recipient = umc_user2uuid($row['recipient_uuid']); $wholine = "{red}->{white}{$recipient}"; if ($row['status'] == 'sent') { $folder = 'Outbox'; } else { if (strstr($row['status'], 'deleted')) { $folder = 'Trash'; } else { if ($row['status'] == 'draft') { $folder = 'Draft'; } } } } else { $sender = umc_user2uuid($row['sender_uuid']); $wholine = "{$sender}{red}->{white}"; if ($row['status'] == 'read') { $folder = 'Inbox'; } else { if (strstr($row['status'], 'deleted')) { $folder = 'Trash'; } else { if ($row['status'] == 'sent') { $folder = 'Unread'; } } } } umc_echo("{green}#{$row['msg_id']} {yellow}{$folder}{grey} {$row['date_time']}{white} {$wholine}: {$row['title']}"); } umc_footer(); }
function umc_show_help($args = false) { XMPP_ERROR_trace(__FUNCTION__, func_get_args()); global $UMC_USER, $WS_INIT; $player = $UMC_USER['username']; $userlevel = umc_get_userlevel($player); if ($args) { // if show_help is called from another program, we simulate a /help command being issued. $args = array_merge(array('call'), $UMC_USER['args']); } else { $args = $UMC_USER['args']; } $command = false; $command_name = ''; $plugin_name = ''; if (isset($args[1])) { $command = umc_wsplg_find_command($args[1]); $command_name = $args[1]; } // If we have a help query, a command name, but it didn't match any known commands if ($args[0] == 'help' && $command_name && !$command) { umc_error("{white}Action {green}{$command_name}{white} not recognized, try {yellow}/helpme"); } umc_header('Uncovery Help', true); umc_echo("{gray} <..> = mandatory [..] = optional {ro} = request or offer", true); $non_commands = array('default', 'events', 'disabled'); if ($command_name) { if (isset($command['help']['title'])) { // This is a 'default' listing umc_pretty_bar("darkblue", "-", "{darkcyan}" . $command['help']['title'], 52, true); umc_echo($command['help']['long'], true); foreach ($WS_INIT[$command_name] as $cmd => $cmd_data) { if (!in_array($cmd, $non_commands)) { // This command is restricted to a user level or higher if (isset($cmd_data['security']['level']) && $player != 'uncovery') { if (!umc_rank_check($userlevel, $cmd_data['security']['level'])) { continue; } } if (!isset($cmd_data['top']) || !$cmd_data['top']) { $plugin_name = $command_name . ' '; } $command_args = ''; if (isset($cmd_data['help']['args'])) { $command_args = "{yellow}" . $cmd_data['help']['args']; } umc_echo("{green}/{$plugin_name}{$cmd} {$command_args}{gray} => {white}" . $cmd_data['help']['short'], true); } } } else { if (isset($command)) { // sub-command help if (!isset($command['top']) || !$command['top']) { $plugin_name = $command_name . ' '; } $args_str = ''; if (isset($command['help']['args'])) { $args_str = "{yellow}" . $command['help']['args']; } umc_echo("{green}/{$plugin_name}{$command_name} {$args_str}{gray} => {white}" . $command['help']['short'], true); umc_pretty_bar("darkgray", "-", "", 49, true); foreach (split(';', $command['help']['long']) as $line) { if ($line != '') { umc_echo($line, true); } } } else { umc_echo("{white}No help found for command {red}/{$args[1]} {$args[2]}{white}.", true); // umc_show_help($args); // umc_echo("{white}Try {yellow}/helpme {$args[1]}{white} to see valid commands.", true); } } } else { // Show general help. foreach ($WS_INIT as $plugin => $cmd_data) { // This command is restricted to a user level or higher if (isset($cmd_data['default']['security']['level']) && $player != 'uncovery') { if (!umc_rank_check($userlevel, $cmd_data['default']['security']['level'])) { continue; } } umc_echo("{green}/{$plugin}{gray} - " . $cmd_data['default']['help']['short'], true); } umc_echo("{gray}Use {yellow}/helpme <command>{gray} for more details.", true); } umc_footer(true); return true; }
function umc_vanity_set() { global $UMC_USER; $player = $UMC_USER['username']; $args = $UMC_USER['args']; $userlevel = umc_get_userlevel($player); // umc_echo("$userlevel"); if (!isset($args[2]) || !is_numeric($args[2]) || $args[2] < 1) { umc_error("{red}You need to specify a number of days"); } else { if (!isset($args[3])) { umc_error("{red}You need to specify the title you want to have. See {yellow}/helpme vanity"); } } $days = $args[2]; $vanity_raw = ''; // concatenate all into a string for ($i = 3; $i < count($args); $i++) { $vanity_raw .= " " . $args[$i]; } $vanity = trim($vanity_raw); $donator_str = ''; if (strstr($userlevel, 'DonatorPlus')) { $donator_str = '&6++&f'; } else { if (strstr($userlevel, 'Donator')) { $donator_str = '&6+&f'; } else { if ($userlevel == 'Owner') { $donator_str = '&6++&f'; } } } $final_title = ' [' . $vanity . '&f]'; // check for invalid chars umc_vanity_sanitize($vanity); $quote_array = umc_vanity_quote_title($vanity); $total_cost = $quote_array['cost'] * $days; $balance = umc_money_check($player); if ($quote_array['length'] > 20) { umc_error("Your title is too long ({$quote_array['length']} vs. 20 max!"); } if ($total_cost > $balance) { umc_error("You do not have enough money to pay for this title for {$days} days. You need {$total_cost} but have only {$balance}!"); } // check if there is a title already set $check = umc_vanity_get_title(); if ($final_title == $check . $donator_str) { umc_header("Vanity Title"); umc_echo("The same title is already set and will be extended by {$days} days!"); } else { if ($check && $final_title != $check . $donator_str) { umc_error("You have a different title already set. You need to cancel that one first or set the same one to extend it!"); } else { // no title set yet $uuid = umc_user2uuid($player); umc_header("Vanity Title"); umc_echo("No title yet set, setting new one..."); umc_exec_command("pex user {$uuid} suffix \"{$final_title}{$donator_str}\"", 'asConsole'); } } // set timer umc_money($player, false, $total_cost); umc_timer_set($player, 'custom_title', $days); $date_out = umc_timer_get($player, 'custom_title'); $time_out = $date_out->format('Y-m-d H:i:s'); $date_today = umc_datetime(); $interval = $date_today->diff($date_out); $days_interval = $interval->days; $hours_interval = $interval->h; umc_echo("Your title [{$vanity}{white}] will expire on {$time_out} (in {$days_interval} days and {$hours_interval} hours)!"); umc_echo("Your account has been debited {$total_cost}!"); umc_log('vanity', 'set', "{$player} paid {$total_cost} for {$vanity} for {$days} days"); umc_footer(true); }
function umc_home_list() { XMPP_ERROR_trace(__FUNCTION__, func_get_args()); global $UMC_USER; $sql = "SELECT * FROM minecraft_srvr.homes WHERE uuid='{$UMC_USER['uuid']}' ORDER BY world, name;"; $D = umc_mysql_fetch_all($sql); $count = count($D); umc_header("Your home list ({$count} homes)"); $homes = array(); foreach ($D as $d) { $world = $d['world']; $name = $d['name']; $homes[$world][] = $name; } foreach ($homes as $world => $worldhomes) { $out = "{red}{$world}: {white}" . implode("{red},{white} ", $worldhomes); umc_echo($out); } umc_footer(); }
function umc_hunger_status() { global $UMC_PLAYER, $HUNGER; XMPP_ERROR_trace(__FUNCTION__, func_get_args()); umc_hunger_find_current_game(); $args = $UMC_PLAYER['args']; if (isset($args[2])) { $game_id = $args[2]; } else { $game_id = false; } $game = false; if (!$game_id && isset($HUNGER['current_game'])) { $game = $HUNGER['current_game']; $id = $game['id']; $player_list = $HUNGER['current_game']['players']; } else { if ($game_id) { $sql = "SELECT *, timediff(end,start) as duration FROM minecraft_iconomy.hunger_games WHERE id = {$game_id}"; $data = umc_mysql_fetch_all($sql); if (count($data) > 0) { $game = $data[0]; $id = $game['id']; $player_list = $game['players']; } } else { umc_error("There is no current game!"); } } umc_header(); if ($game) { $num_players = count($player_list); $admin_username = umc_user2uuid($game['admin']); if ($game['status'] == 'preparing') { umc_echo("[Hunger] {gray}A Hunger Game has been announced by {gold}{$admin_username}"); umc_echo("[Hunger] {gray}This game is still being organized. {green}{$num_players} {gray}player(s) participating:"); umc_hunger_format_player_list("{gold}", $player_list); } else { if ($game['status'] == 'aborted') { umc_echo("[Hunger] {gray}This hunger game was announced by {$admin_username}, but was aborted."); } else { $duration = umc_pretty_duration($game['duration']); if ($game['status'] == 'started') { umc_echo("[Hunger] {green}A Hunger Game is in progress (ID {$id}), organized by {gold}{$admin_username}"); umc_echo("[Hunger] {green}The game has lasted {$duration}{green} so far. Player Status:"); } else { umc_echo("[Hunger] {gold}A completed Hunger Game organized by {$admin_username}"); umc_echo("[Hunger] {gold}The game lasted {$duration}{green}. Final Player Status:"); } $sql = "SELECT hunger_players.status as status, timediff(hunger_players.death,hunger_games.start) as duration, username\r\n FROM minecraft_iconomy.hunger_games\r\n LEFT JOIN minecraft_iconomy.hunger_players ON hunger_players.game_id = hunger_games.id\r\n LEFT JOIN minecraft_srvr.UUID ON hunger_players.uuid=UUID.UUID\r\n WHERE hunger_games.id = {$id}"; $rst = umc_mysql_query($sql); while ($row = umc_mysql_fetch_array($rst)) { $duration = umc_pretty_duration($row['duration']); if ($row['status'] == 'playing') { $player_status = "{green}[Playing]"; } else { if ($row['status'] == 'left') { $player_status = "{gray}[Left @ {$duration}{gray}]"; } else { if ($row['status'] == 'dead') { $player_status = "{red}[Died @ {$duration}{red}]"; } else { if ($row['status'] == 'winner') { $player_status = "{white}[Winner!]"; } else { $player_status = "{blue}[Error]"; } } } } $player = $row['username']; umc_echo("{gold}{$player} {$player_status}"); } } } } else { umc_echo("[Hunger] {red}No game currently in progress. See {yellow}/hunger history"); } umc_footer(); }
function umc_home_list() { global $UMC_USER; $sql = "SELECT * FROM minecraft_srvr.homes WHERE uuid='{$UMC_USER['uuid']}' ORDER BY world, name;"; $D = umc_mysql_fetch_all($sql); $count = count($D); umc_header("Your home list ({$count} homes)"); $cur_world = false; $out = ''; $worldhomes = array(); foreach ($D as $d) { if ($d['world'] != $cur_world) { if ($cur_world) { $out .= implode(", ", $worldhomes); umc_echo($out); } $out = "{red}{$d['world']}:{white} "; $worldhomes = array(); } $worldhomes[] = $d['name']; $cur_world = $d['world']; } umc_footer(); }