function umc_read_markers_file($format = 'html', $world = 'empire', $user = false) { XMPP_ERROR_trace(__FUNCTION__, func_get_args()); /* [0]=> object(stdClass)#1 (5) { ["timestamp"]=> string(19) "2011-01-31 14:14:47" ["z"]=> float(-319.54668819556) ["msg"]=> string(8) "Thegiant" ["y"]=> float(50) ["x"]=> float(448.69999998808) */ global $UMC_SETTING, $UMC_PATH_MC; $file = "{$UMC_PATH_MC}/server/bin/data/markers.json"; // $UMC_SETTING['markers_file']; $text = file_get_contents($file); if (!$file) { XMPP_ERROR_trigger("Could not read markers file (umc_read_markers_file)"); } $m = json_decode($text); // no users if (!$m) { return ''; } $out_arr = array(); $map = $UMC_SETTING['world_img_dim'][$world]; if (count($m) == 0) { return ''; } if ($format == 'scrollto') { $out = "<div id=\"scroll_to_icons\">\n"; } else { $out = "<div id=\"marker_list\">\n"; } // check if we find the single user from the marker $foundplayer = false; // var_dump($format); foreach ($m as $marker) { $z = $marker->z; $x = $marker->x; $x_text = round($x); $z_text = round($z); $top = conv_z($marker->z, $map); // + $map['img_top_offset']; $left = conv_x($marker->x, $map); // + $map['img_left_offset']; $username = strtolower($marker->msg); $playerworld = $marker->world; if ($username == 'uncovery') { //continue; } $icon_url = umc_user_get_icon_url($username); if ($format == 'identify_user' && $username == $user) { $out .= ' <span class="marker" style="z-index:100; top:' . $top . 'px; left:' . $left . "px;\"><img src=\"{$icon_url}\" title=\"{$username}\" alt=\"{$username}\"> <input type=\"submit\" name=\"track_player\" value=\"That's me!\"></span>\n" . "\n"; $foundplayer = true; } else { if ($format == 'track_user' && $username == $user) { $out .= ' <span class="marker" id="' . $username . '_marker" style="z-index:100; top:' . $top . 'px; left:' . $left . "px;\"><img src=\"{$icon_url}\" title=\"{$username}\" alt=\"{$username}\"></span>\n" . "\n"; $foundplayer = true; } else { if ($format == 'scrollto' && $marker->world == $world) { $out .= "<img src=\"{$icon_url}\" title=\"{$username}\" alt=\"{$username}\" onclick=\"find_user({$left}, {$top}, '{$username}_marker')\">\n"; } else { if ($format == 'html' && $marker->world == $world) { if ($world == 'hunger') { $out .= '<div class="marker" style="position:relative">' . $username . '</div>' . "\n"; } else { $out .= ' <img id="' . $username . '_marker" class="marker" style="z-index:100; top:' . $top . 'px; left:' . $left . "px;\" src=\"{$icon_url}\" title=\"{$username} (x:{$x_text} z:{$z_text})\" alt=\"{$username} (x:{$x_text} z:{$z_text})\">\n"; } } else { if ($format == 'json') { $arr[] = array('name' => $username, 'url' => $icon_url, 'top' => $top, 'left' => $left); } else { if ($format == 'all_users') { // list all users for website status $out .= $username . " "; } else { if ($format == 'array') { $out_arr[$username] = array('name' => $username, 'url' => $icon_url, 'top' => $top, 'left' => $left, 'world' => $playerworld, 'x' => $x_text, 'z' => $z_text); } } } } } } } } if (($format == 'identify_user' || $format == 'track_user') && $foundplayer == false) { // umc_error_notify("Could not find single player $user in Json Data: \n" . var_export($m, true)); } if ($format == 'json') { $out = json_encode($arr); } else { if ($format == 'array') { return $out_arr; } } if ($format == 'scrollto') { $out .= "</div>\n"; } else { if ($format == 'html') { // no idea why this was here. it would duplicate the output. // $out .= umc_read_markers_file('scrollto', $world); } $out .= "</div>\n"; } return $out; }
function umc_wp_get_uncovery_avatar($avatar, $id_or_email, $size, $default, $alt) { XMPP_ERROR_trace(__FUNCTION__, func_get_args()); if ($default == 'uncovery') { $filename = '/home/minecraft/server/bin/core_include.php'; require_once $filename; if (!function_exists('umc_user_ban')) { XMPP_ERROR_trigger("Failed to include {$filename}!"); } //Alternative text if (false === $alt) { $safe_alt = ''; } else { $safe_alt = esc_attr($alt); } //Get username if (is_numeric($id_or_email)) { $id = (int) $id_or_email; $user = get_userdata($id); if ($user) { $username = $user->user_login; } else { return false; // user cannot be found, probably deleted } } else { if (is_object($id_or_email)) { if (!empty($id_or_email->user_id)) { $id = (int) $id_or_email->user_id; $user = get_userdata($id); if ($user) { $username = $user->user_login; } else { return ''; } } else { if (!empty($id_or_email->comment_author)) { $username = $id_or_email->comment_author; } } } else { if (strstr($id_or_email, '@')) { // email require_once ABSPATH . WPINC . '/ms-functions.php'; $user = get_user_by('email', $id_or_email); $username = $user->user_login; } else { // by displayname $username = $id_or_email; } } } $uuid = umc_wp_get_uuid_from_userlogin($username); $icon = umc_user_get_icon_url($uuid); // 'https://crafatar.com/avatars/' . $uuid . '?size=' . $size; $avatar = "<img class='avatar avatar-64 photo' alt='" . $safe_alt . "' src='" . $icon . "' class='avatar avatar-" . $size . " photo' height='" . $size . "' width='" . $size . "' />"; } return $avatar; }
/** * Settler test * * @global type $UMC_USER * @global type $UMC_SETTING * @global type $UMC_DOMAIN * @return string */ function umc_settler_new() { global $UMC_USER, $UMC_SETTING, $UMC_DOMAIN; $out = ''; if (!$UMC_USER) { return "You have to be <a href=\"{$UMC_DOMAIN}/wp-login.php\">logged in</a> to use this!"; } $steps = array(1 => array('begging' => true, 'griefing' => true, 'pixel_art' => true, 'minimaps' => false, 'xray_and_cheats' => true, 'not_reading_the_website' => true, 'swearing' => true, 'walls_around_your_lot' => true, 'shaders' => false)); $player = strtolower($UMC_USER['username']); $uuid = $UMC_USER['uuid']; $userlevel = $UMC_USER['userlevel']; $email = $UMC_USER['email']; if ($userlevel != 'Guest') { $out .= "You are not a Guest and can use the <a href=\"http://uncovery.me/server-access/lot-manager/\">Lot manager</a> to get a lot!"; } if (umc_user_is_banned($uuid)) { return "Sorry, you are banned from the server!"; } $icon_url = umc_user_get_icon_url($player); $user_icon = "<img src=\"{$icon_url}\">"; // get user location $s_post = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING); $step = 0; if (isset($s_post['step'])) { $step = $s_post['step']; } $loc = umc_read_markers_file('array'); $lot = false; if (isset($s_post['lot'])) { $lot = $s_post['lot']; } $world = false; if (isset($s_post['world'])) { $world = $s_post['world']; } if (isset($loc[$player])) { $player_world = $loc[$player]['world']; $player_lot = umc_lot_get_from_coords($loc[$player]['x'], $loc[$player]['z'], $loc[$player]['world']); $x = $loc[$player]['x']; $z = $loc[$player]['z']; } else { $player_lot = false; $player_world = false; $x = false; $z = false; } $error = ''; // answer check switch ($step) { case 2: if (!isset($s_post['stepone'])) { $step = 1; umc_log('settler_test', 'step_1_fail', "{$player} did not answer any questions!"); $error = "You need to answer the questions on the previous page!"; } else { $problem = false; $answers = array(); foreach ($steps[1] as $choice => $value) { if ($value == true && !in_array($choice, $s_post['stepone'])) { // Bad stuff $problem = true; $answers[] = $choice; } else { if ($value == false && in_array($choice, $s_post['stepone'])) { // but is $problem = true; $answers[] = $choice; } } } if ($problem) { umc_log('settler_test', 'step_1_fail', "{$player} failed step 1 with wrong answers " . implode("|", $answers)); $error = "<h1>Error</h1>One or more answers in the previous page were wrong.<br>Please go back and check before proceeding.<br>" . "If you need help, please read the <a href=\"{$UMC_DOMAIN}/about-this-server/rules/\">rest of the rules</a>"; $step = 1; } } break; case 3: if (!isset($s_post['world'])) { $step = 2; umc_log('settler_test', 'step_2_fail', "{$player} failed step 2"); $error = 'You need to choose a playing mode to continue!'; } break; case 4: if (!isset($s_post['lot'])) { $step = 3; umc_log('settler_test', 'step_3_fail', "{$player} failed step 3"); $error = 'You need to choose lot to continue!'; } break; case 5: if (!$player_world) { $step = 4; umc_log('settler_test', 'step_4_fail', "{$player} failed step 4 (not in game)"); $error = 'You need to be in the game to continue!'; // var_dump($loc); } else { if ($player_world != 'city' || $x > 953 || $x < 938 || $z < -814 || $z > -793) { $step = 4; umc_log('settler_test', 'step_4_fail', "{$player} failed step 4 (not in spawn house)"); $error = 'You need to type /warp spawn and then continue!'; } } break; case 6: if ($player_world != $s_post['world']) { $step = 5; umc_log('settler_test', 'step_5_fail', "{$player} failed step 5"); $error = "You need to go through the {$s_post['world']} portal! Type <strong>/warp spawn</strong> and try again!"; } break; case 8: if (strtolower($player_lot) != strtolower($s_post['check_lot'])) { $step = 7; umc_log('settler_test', 'step_7_fail', "{$player} failed step 7 by entering " . $s_post['check_lot'] . "instead of {$player_lot}"); $error = 'You need to enter the lot you see on-screen into the form to continue!'; } break; case 9: if (!$player_lot) { $step = 8; umc_log('settler_test', 'step_8_fail', "{$player} failed step 8"); $error = "We could not find you on the map. Please make sure you are on the server!"; } else { if ($player_lot != $s_post['lot']) { $step = 8; umc_log('settler_test', 'step_8_fail', "{$player} failed step 8"); $error = "You need to get lot {$s_post['lot']} before you can continue. Please either walk there or use /jump {$s_post['lot']}. You are now in lot {$player_lot}!"; } } break; } // questions $out .= "<strong>{$error}</strong><br>"; switch ($step) { case 0: umc_log('settler_test', 'start', "{$player} started the settler test"); $out .= "<form action=\"{$UMC_DOMAIN}/server-access/buildingrights/\" method=\"post\">\n" . "<h1>Step 1: Welcome!</h1>\n" . "<h2>Once you finish this test, you will be settler!</h2>\n" . "<h2>Before Applying</h2>\n" . "<ul>\n" . " <li>You must have some experience playing Minecraft.</li>\n" . " <li>Read the <a href=\"{$UMC_DOMAIN}/faq/\">FAQ</a></li>\n" . " <li>Read the <a href=\"{$UMC_DOMAIN}/rules/\">Rules</a></li>\n" . " <li>Read the <a href=\"{$UMC_DOMAIN}/user-levels/\">User Levels and Commands</a> page.</li>\n" . "</ul>\n" . "This process will guide you through the process of getting building rights on the server and at the same time give you a lot and make sure you get there. " . "You will need to login to the server with your minecraft client during the process and keep this website open.<br>" . "<input type=\"hidden\" name=\"step\" value=\"1\">\n" . "<input type=\"submit\" name=\"Next\" value=\"Next\">\n"; break; case 1: $warning = ''; $failcount = umc_settler_get_fails($player); if ($failcount > 10) { $warning = "<div style=\"color:red;font-weight:bold;font-size:120%;\">You have failed the test more than 10 times. If you fail too often, you will be banned from the server!</div>"; } else { if ($failcount > 20) { umc_user_ban($player, "Settler test failed"); return $warning = "<div style=\"color:red;font-weight:bold;font-size:120%;\">You have failed the test too often. You are now banned from the server!</div>"; } } umc_log('settler_test', 'step_1', "{$player} is at step 1"); $out .= "<form action=\"{$UMC_DOMAIN}/server-access/buildingrights/\" method=\"post\">\n" . "<h1>Step 2: Rules & regulations</h1>\n" . $warning . "Here are some basic rules you should know:" . "<ul>\n<li><strong>Do not beg for anything</strong> - Including upgrades, handouts or help with this process.</li>\n" . "<li><strong>No pixel-art</strong>. This is not 'paint by numbers'. We build stuff.</li>\n" . "<li><strong>Be considerate of others</strong>. No griefing, no stealing, no killing. We log everything, we will find out.</li>\n" . "<li><strong>Don't cheat!</strong> No Xray, no mods, no bug abuse.</li>\n" . "<li><strong>Learn yourself!</strong> Look on the <a href=\"{$UMC_DOMAIN}/about-this-server/\">website</a> for answers first, then ask other users.</li>\n" . "<li><strong>We ban forever - no appeals!</strong> You better read the <a href=\"{$UMC_DOMAIN}/about-this-server/rules/\">rest of the rules</a>.</li>\n" . "</ul>\n" . "<strong>Pick the items that are not allowed (and will therefore get you banned) (Note: Asking others about the answers will get you banned, too!): </strong><br>\n" . "<input type=\"hidden\" name=\"step\" value=\"2\">\n"; foreach ($steps[1] as $image => $check) { $image_text = umc_pretty_name($image); $out .= "<span style=\"float:left; text-align:center;\"><img height=\"180\" src=\"{$UMC_DOMAIN}/websend/{$image}.png\"><br>" . "<input type=\"checkbox\" name=\"stepone[]\" value=\"{$image}\">{$image_text}</span>\n"; } $out .= '<br style="clear:both;">' . "<input type=\"submit\" name=\"Next\" value=\"Next\">\n"; break; case 2: umc_log('settler_test', 'step_2', "{$player} is at step 2"); $out .= "<form action=\"{$UMC_DOMAIN}/server-access/buildingrights/\" method=\"post\">\n" . '<h1>Step 3: Creative or Survival?</h1>' . 'You can either build in a flat, creative world or a wild, survival world!<br>Choose one:<br>' . "<span style=\"float:left; text-align:center;\"><img width=\"400\" src=\"{$UMC_DOMAIN}/websend/empire.png\"><br><input type=\"radio\" name=\"world\" value=\"empire\">Survival mode in the Empire world</span>" . "<span style=\"float:left; text-align:center;\"><img width=\"400\" src=\"{$UMC_DOMAIN}/websend/flatlands.png\"><br><input type=\"radio\" name=\"world\" value=\"flatlands\">Creative mode in the Flatlands world</span><br style=\"clear:both;\">" . "<input type=\"hidden\" name=\"step\" value=\"3\">\n" . "<input type=\"submit\" name=\"Next\" value=\"Next\">\n"; break; case 3: umc_log('settler_test', 'step_3', "{$player} is at step 3"); $spawn_lot = $UMC_SETTING['world_data'][$world]['spawn']; $tile = umc_user_get_lot_tile(strtolower($spawn_lot)); $out .= "<form action=\"{$UMC_DOMAIN}/admin/index.php?function=create_map&world={$world}&freeonly=true\" method=\"post\">\n" . "<h1>Step 4: Find a lot!</h1>\n" . "<img style=\"float:right;\" width=\"300\" src=\"{$UMC_DOMAIN}/websend/{$world}.png\">Great! You chose to build in the <strong>{$world}</strong> world!<br>" . "You are now ready to pick a lot!<br>" . "If you made a mistake and want to play a different mode, please go back now and chose another mode. There will be no going back later.<br><br>" . "<strong>Now you need to find a lot that you like.</strong><br>" . "When you click 'Next', a map of the {$world} world will open.<br>" . "Click on the \"Find Spawn\" button in the top-left corner. It looks like this:<br>" . "<img src=\"/websend/find_spawn.png\"><br>" . "You will now see a flashing lot, which is the entrance to the {$world} world.<br>" . "It's convenient to find a lot close to it. <br>" . "The spawn lot looks like this:<br>{$tile}" . "<input type=\"hidden\" name=\"settler_test\" value=\"settler_test\">\n" . "<br><br><input type=\"submit\" name=\"Next\" value=\"Next\">\n"; break; case 4: umc_log('settler_test', 'step_4', "{$player} is at step 4"); $tile = umc_user_get_lot_tile(strtolower($lot)); $out .= "<form action=\"{$UMC_DOMAIN}/server-access/buildingrights/\" method=\"post\">\n" . '<h1>Step 5: You chose a lot!</h1>' . "<span style=\"float:left;\">{$tile}</span>The lot you have chosen is <strong>{$lot} in the {$world}</strong> world. You can see a satellite image of it on the left.<br>You should now go there, to make sure it's what you want!<br>"; if ($player_world) { $out .= "<br>To go there, you need to go to the portal house. From there you can get into the {$world} world.<br>" . "Please type <strong>/warp spawn</strong> in game to get there, it should look like this inside:<br><img src=\"/websend/portals.png\">" . "Once you see this, please come back here and press " . "<input type=\"submit\" name=\"Next\" value=\"Next\">\n" . "<input type=\"hidden\" name=\"lot\" value=\"{$lot}\">\n" . "<input type=\"hidden\" name=\"world\" value=\"{$world}\">\n" . "<input type=\"hidden\" name=\"step\" value=\"5\">\n"; } else { $out .= "Please <strong>login to the server</strong> now with your minecraft client at <strong>uncovery.me</strong> and then press " . "<input type=\"hidden\" name=\"world\" value=\"{$world}\">\n" . "<input type=\"submit\" name=\"action\" value=\"Continue\">\n" . "<input type=\"hidden\" name=\"lot\" value=\"{$lot}\">\n" . "<input type=\"hidden\" name=\"step\" value=\"5\">\n"; } break; case 5: umc_log('settler_test', 'step_5', "{$player} is at step 5"); $out .= "<form action=\"{$UMC_DOMAIN}/server-access/buildingrights/\" method=\"post\">\n" . "<h1>Step 6: Get to the {$world} world</h1>"; // check if the player is actually in the portal house // player is not in portal house if ($player_world != 'city' || $x > 953 || $x < 938 || $z < -814 || $z > -793) { $out .= "You need to be in the portal house to continue. Please type <strong>/warp spawn</strong> again to get there. " . "It should look like this inside:<br><img src=\"/websend/portals.png\"> Once you see this, press\n" . "<input type=\"submit\" name=\"Next\" value=\"Next\">\n" . "<input type=\"hidden\" name=\"lot\" value=\"{$lot}\">\n" . "<input type=\"hidden\" name=\"world\" value=\"{$world}\">\n" . "<input type=\"hidden\" name=\"step\" value=\"5\">\n"; } else { $out .= "Since you chose a lot in the {$world} world, you need to go through the {$world} portal. " . "It looks like this: Notice the name of the world is written on the sign." . "<img src=\"/websend/{$world}_portal.png\">" . "Please step through and press " . "<input type=\"submit\" name=\"Next\" value=\"Next\">\n" . "<input type=\"hidden\" name=\"lot\" value=\"{$lot}\">\n" . "<input type=\"hidden\" name=\"world\" value=\"{$world}\">\n" . "<input type=\"hidden\" name=\"step\" value=\"6\">\n"; } break; case 6: umc_log('settler_test', 'step_6', "{$player} is at step 6"); $spawn_lot = strtoupper($UMC_SETTING['world_data'][$world]['spawn']); $lower_lot = strtolower($lot); $lot_sql = "SELECT region_cuboid.region_id AS lot, sqrt(pow(max_x,2)+pow(max_z,2)) AS distance, max_x, max_z\r\n FROM minecraft_worldguard.world\r\n LEFT JOIN minecraft_worldguard.region_cuboid ON world.id=region_cuboid.world_id\r\n WHERE region_cuboid.region_id='{$lower_lot}';"; $D = umc_mysql_fetch_all($lot_sql); $lot_data = $D[0]; // north/south difference if ($lot_data['max_x'] < 0) { $direction1 = "north"; } else { if ($lot_data['max_x'] >= 0) { $direction1 = "south"; } } // north/south difference if ($lot_data['max_z'] < 0) { $direction2 = "west"; } else { if ($lot_data['max_z'] >= 0) { $direction2 = "east"; } } $out .= "<form action=\"{$UMC_DOMAIN}/admin/index.php?function=create_map&world={$world}&freeonly=true\" method=\"post\">\n" . "<h1>Step 7: Getting to lot {$lot} in the {$world} world</h1>" . "Getting to your world is easy! You are now at the center of the {$world} world." . "Your lot is <strong>{$direction1}/{$direction2}</strong> from spawn! <br>" . "You can find out which direction you are looking with the <strong>/compass</strong> command.<br>" . "As a Guest level player, you cannot be killed by mobs until you finished this here.<br>" . "So you have to leave the spawn lot either through the {$direction1} or the {$direction2} exit.<br>" . "To know where you are, you can follow your icon {$user_icon} on the map while you get around.<br>" . "Please click NEXT to open the map, there you find your icon click the button next to it!<br><br>" . "<input type=\"submit\" name=\"next\" value=\"Next\">\n" . "<input type=\"hidden\" name=\"track_player\" value=\"{$player}\">\n" . "<input type=\"hidden\" name=\"world\" value=\"{$world}\">\n" . "<input type=\"hidden\" name=\"lot\" value=\"{$lot}\">\n"; $x = $loc[$player]['x']; $z = $loc[$player]['z']; break; case 7: umc_log('settler_test', 'step_7', "{$player} is at step 7"); // whereami $out .= "<h1>Step 8: Find out where you are in-game</h1>" . "<form action=\"{$UMC_DOMAIN}/server-access/buildingrights/\" method=\"post\">\n" . "Now that you know how to find yourself on the map, you need to find out where you are when in-game.<br>" . "The command to find your location in-game is called <strong>/whereami</strong>.<br>" . "Please go into the game and type <strong>/whereami</strong><br>" . "You will see something like this:<br>" . "<img src=\"/websend/whereami.png\"><br>" . "In this example, you can see the Lot (in the first line) is <img src=\"/websend/whereami_detail.png\"> So you would enter 'emp_z7'.<br>" . "Please go now into the game, type <strong>/whereami</strong>, and enter the information here:<br>" . "I am now in lot <input type=\"text\" name=\"check_lot\" value=\"\" size=\"7\"> and then press " . "<input type=\"submit\" name=\"next\" value=\"Next\">\n" . "<input type=\"hidden\" name=\"step\" value=\"8\">\n" . "<input type=\"hidden\" name=\"world\" value=\"{$world}\">\n" . "<input type=\"hidden\" name=\"lot\" value=\"{$lot}\">\n"; // enter which lot you are in right now break; case 8: // walk to your lot umc_log('settler_test', 'step_8', "{$player} is at step 8"); $lower_lot = strtolower($lot); $out .= "<form action=\"{$UMC_DOMAIN}/admin/index.php\" method=\"post\">\n" . "<h1>Step 9: Walk to your lot {$lot}!</h1>" . "Now you have everything you need to get to your lot!<br>You should follow your steps on the 2D map.<br>" . "You can either walk there, or use the command <pre>/lot warp {$lot}</pre> to get there. Please note that this command is only available while you are Guest.<br>" . "Press 'Next' to open the 2D map and follow your icon to lot {$lot}!<br>" . "<input type=\"submit\" name=\"next\" value=\"Next\">\n" . "<input type=\"hidden\" name=\"guide_lot\" value=\"{$player}\">\n" . "<input type=\"hidden\" name=\"world\" value=\"{$world}\">\n" . "<input type=\"hidden\" name=\"freeonly\" value=\"true\">\n" . "<input type=\"hidden\" name=\"function\" value=\"create_map\">\n" . "<input type=\"hidden\" name=\"step\" value=\"9\">\n" . "<input type=\"hidden\" name=\"world\" value=\"{$world}\">\n" . "<input type=\"hidden\" name=\"lot\" value=\"{$lower_lot}\">\n"; break; case 9: umc_log('settler_test', 'step_9', "{$player} is at step 9"); // do you like it? claim it $out .= "<h1>Step 10: Do you like the lot {$s_post['lot']}?</h1>" . "<form action=\"{$UMC_DOMAIN}/server-access/buildingrights/\" method=\"post\">\n" . '<input type="radio" name="step" value="10" checked>Yes! I take it! I will type <strong>/homes buy ' . $world . '</strong> now so I can warp back here!<br>' . '<input type="radio" name="step" value="1">No,I would like to start over!<br>' . "<input type=\"hidden\" name=\"lot\" value=\"{$lot}\">\n" . "<input type=\"hidden\" name=\"world\" value=\"{$world}\">\n" . "<input type=\"submit\" name=\"next\" value=\"Finish!\">\n"; break; case 10: umc_log('settler_test', 'step_10', "{$player} is at step 10"); // final confirmation $out .= "<h1>Step 11: Congratulations!</h1>" . "You have been promoted to Settler!<br>"; if ($userlevel == 'Guest') { $cmd = "pex promote {$UMC_USER['uuid']}"; umc_exec_command($cmd); // update UUID database $sql = "UPDATE minecraft_srvr.UUID SET userlevel='Settler' WHERE UUID='{$UMC_USER['uuid']}';"; umc_mysql_query($sql); umc_exec_command('pex reload'); umc_exec_command("ch qm u Congrats {$player} for becoming Settler!"); XMPP_ERROR_send_msg("{$userlevel} {$player} got promoted with command " . $cmd); umc_log('settler_test', 'promotion', "{$player} ({$UMC_USER['uuid']})was promoted to settler (new test)"); $headers = "From: minecraft@uncovery.me\r\n" . "Reply-To: minecraft@uncovery.me\r\n" . 'X-Mailer: PHP/' . phpversion(); $subject = "[Uncovery Minecraft] Settler applicaton"; $mailtext = "The user: {$player} (email: {$email}) was promoted to Settler and got lot {$lot}.\n\n"; $check = mail('*****@*****.**', $subject, $mailtext, $headers); if (!$check) { XMPP_ERROR_trigger("The settler promotion email could not be sent!"); } // check userlevel to make sure $new_level = umc_get_userlevel($player); if ($new_level != 'Settler') { XMPP_ERROR_trigger("{$userlevel} {$player} did NOT got promoted with command " . $cmd . " he's still {$new_level}"); } } else { $out .= "Thanks for taking this test! Since you are {$userlevel} already, we will not promote you to Settler.<br>"; } // try to assign the lot $check = umc_lot_manager_check_before_assign($uuid, $lot); $out .= "Trying to assign this lot to you: <strong>{$check['text']}</strong><br>"; if ($check['result'] == false) { XMPP_ERROR_send_msg("Settler Test lot assignment failed!"); $out .= "There was an error giving the lot you reserved to you. You can get any other through your <a hreaf=\"{$UMC_DOMAIN}/server-access/lot-manager/\">lot manager</a>!<br>"; } else { umc_lot_add_player($uuid, $lot, 1, $check['cost']); $out .= $check['text']; } break; default: $out .= "This option was not recognized, please reload the page!"; } $out .= "</form>\n"; return $out; }
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&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']} " . $item['name'] . $meta; } else { $text = "({$value})"; } $out = "<a href=\"{$UMC_DOMAIN}/trading/shop/?query=stock_detail&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&user={$value}\"><img title='{$value}' src='{$icon_url}' width=\"16\" alt=\"{$value}\"> {$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&user={$username}\"><img title='{$username}' src='{$icon_url}' width=\"16\" alt=\"{$username}\"> {$username}</a>"; } else { if (preg_match("/price/i", $name)) { return number_format($value, 2, ".", ""); } else { if ($name == 'quantity' && $value < 1) { return "∞"; } } } } } } return $value; }
function umc_user_directory() { XMPP_ERROR_trace(__FUNCTION__, func_get_args()); // list all users $username_get = filter_input(INPUT_GET, 'u', FILTER_SANITIZE_STRING); if (!is_null($username_get)) { $O = array(); $wordpress_id = umc_user_get_wordpress_id($username_get); $username = strtolower(umc_check_user($username_get)); if (!$wordpress_id) { return "User does not exist!"; } $uuid = umc_user2uuid($username); // check if the user is active $count_lots = umc_user_countlots($uuid); if ($count_lots == 0) { return "User is not active!"; } // user icon $O['User'] = get_avatar($wordpress_id, $size = '96') . "<p><strong>Username:</strong> {$username}</p>\n" . "<p><strong>UUID:</strong> {$uuid}</p>\n"; $previous_names = umc_uuid_username_history($uuid); if ($previous_names) { $O['User'] .= "<p><strong>Usernames History:</strong> {$previous_names}</p>\n"; } // is user banned? if (umc_user_is_banned($uuid)) { $O['User'] .= "<p><strong>User is BANNED!</strong></p>\n"; return; } // get userlevel $level = umc_get_uuid_level($uuid); $karma = umc_getkarma($uuid, true); $money = umc_money_check($uuid); $O['User'] .= "<p><strong>Level:</strong> {$level}</p>\n" . "<p><strong>Karma:</strong> {$karma}</p>\n" . "<p><strong>Money:</strong> {$money} Uncs</p>\n"; // get lots $lots = umc_user_getlots($uuid); foreach ($lots as $data) { $world = ucwords($data['world']); $combined_worlds = array('Empire', 'Flatlands', 'Skyblock'); if (in_array($world, $combined_worlds)) { $world = 'Small lots'; } if (!isset($O[$world])) { $O[$world] = ''; } $O[$world] .= $data['image']; } $donator_level = umc_users_donators($uuid); if ($donator_level > 12) { $donator_str = 'More than 1 year'; } else { if ($donator_level) { $donator_level_rounded = round($donator_level, 1); $donator_str = "{$donator_level_rounded} Months"; } else { $donator_str = "Not a donator"; } } $O['User'] .= "<p><strong>Donations remaining:</strong> {$donator_str}</p>\n"; // get member since $online_time = umc_get_lot_owner_age('days', $uuid); if ($online_time) { $lastlogin = $online_time[$uuid]['lastlogin']['days']; $firstlogin = $online_time[$uuid]['firstlogin']['days']; $O['User'] .= "<p><strong>Member since:</strong> {$firstlogin} days</p>\n" . "<p><strong>Offline since:</strong> {$lastlogin} days</p>\n"; } // get user bio $sql = "SELECT meta_value FROM minecraft.wp_users\r\n LEFT JOIN minecraft.wp_usermeta ON wp_users.ID = wp_usermeta.user_id\r\n WHERE display_name='{$username}' AND meta_key='description';"; $D = umc_mysql_fetch_all($sql); if (count($D) > 0) { $row = $D[0]; $O['User'] .= "<p><strong>Bio:</strong> " . $row['meta_value'] . "</p>\n"; } // comments $sql2 = "SELECT comment_date, comment_author, id, comment_id, post_title FROM minecraft.wp_comments\r\n LEFT JOIN minecraft.wp_posts ON comment_post_id=id\r\n WHERE comment_author = '{$username}' AND comment_approved='1' AND id <> 'NULL'\r\n ORDER BY comment_date DESC"; $D2 = umc_mysql_fetch_all($sql2); if (count($D2) > 0) { $O['Comments'] = "<strong>Comments:</strong> (" . count($D2) . ")\n<ul>\n"; foreach ($D2 as $row) { $O['Comments'] .= "<li>" . $row['comment_date'] . " on <a href=\"/index.php?p=" . $row['id'] . "#comment-" . $row['comment_id'] . "\">" . $row['post_title'] . "</a></li>\n"; } $O['Comments'] .= "</ul>\n"; } //forum posts $sql3 = "SELECT wpp.id AS id, wpp.post_title AS title, wpp.post_date AS date,\r\n\t\twpp.post_parent AS parent, wpp.post_type AS type, parent.post_title AS parent_title\r\n FROM minecraft.wp_posts AS wpp\r\n\t LEFT JOIN minecraft.wp_users ON wpp.post_author=wp_users.id\r\n\t LEFT JOIN minecraft.wp_posts AS parent ON parent.id=wpp.post_parent\r\n\t WHERE wp_users.display_name='{$username}'\r\n\t\tAND (wpp.post_type='reply' OR wpp.post_type='topic')\r\n\t\tAND wpp.post_status='publish'\r\n\t ORDER BY wpp.post_date DESC"; $D3 = umc_mysql_fetch_all($sql3); // echo $sql; if (count($D3) > 0) { $O['Forum'] = "<strong>Forum Posts:</strong> (" . count($D3) . ")\n<ul>\n"; foreach ($D3 as $row) { $date = $row['date']; if ($row['type'] == 'reply') { $link = $row['parent'] . "#post-" . $row['id']; $title = $row['parent_title']; } else { $link = $row['id']; $title = $row['title']; } $O['Forum'] .= "<li>{$date} on <a href=\"/index.php?p={$link}\">{$title}</a></li>\n"; } $O['Forum'] .= "</ul>\n"; } echo umc_jquery_tabs($O); } else { // $bans = umc_get_banned_users(); //var_dump($bans); $out = "<script type=\"text/javascript\" src=\"/admin/js/jquery.dataTables.min.js\"></script>\n" . "<script type=\"text/javascript\">\n" . 'jQuery(document).ready(function() {jQuery' . "('#shoptable_users').dataTable( {\"order\": [[ 2, \"desc\" ]],\"paging\": false,\"ordering\": true,\"info\": true} );;} );\n" . "</script>\n" . "This table only tracks online time since 2013-11-20.<br>" . '<table id="shoptable_users"><thead>' . "<th>Username</th>" . "<th>Level</th>" . "<th>Registered days</th>" . "<th>Offline days</th>" . "<th>Lots</th>" . "<th>Online min/day</th>" . "<th>Online hrs</th>" . "</thead>\n<tbody>\n"; $sql = "SELECT username, DATEDIFF(NOW(),firstlogin) as registered_since, parent as userlevel, count(owner) as lot_count, onlinetime, DATEDIFF(NOW(), lastlogin) as days_offline\r\n FROM minecraft_srvr.UUID\r\n LEFT JOIN minecraft_srvr.permissions_inheritance ON UUID.uuid=child\r\n LEFT JOIN minecraft_worldguard.user ON UUID.uuid = user.uuid\r\n LEFT JOIN minecraft_worldguard.region_players ON user.id=region_players.user_id\r\n WHERE owner = 1 AND firstlogin >'0000-00-00 00:00:00' AND username <> '_abandoned_'\r\n GROUP BY username, owner\r\n ORDER BY firstlogin"; $rst = umc_mysql_query($sql); $now = time(); // or your date as well $your_date = strtotime("2013-11-20"); $datediff = $now - $your_date; $alt_days = floor($datediff / (60 * 60 * 24)); while ($row = umc_mysql_fetch_array($rst)) { $days_offline = $row['days_offline']; $settler_levels = array('Settler', 'SettlerDonator', 'SettlerDonatorPlus'); if (in_array($row['userlevel'], $settler_levels) && $row['onlinetime'] >= 60) { umc_promote_citizen(strtolower($row['username']), $row['userlevel']); } if ($row['registered_since'] - $days_offline > 1) { if ($alt_days < $row['registered_since']) { // people who are not in the lb-players database should not be listed, they are too old if ($alt_days - $days_offline == 0) { continue; } $avg_online = floor($row['onlinetime'] / 60 / $alt_days); } else { $avg_online = floor($row['onlinetime'] / 60 / $row['registered_since']); } } else { $avg_online = 0; } $online_total = round($row['onlinetime'] / 60 / 60); $icon_url = umc_user_get_icon_url($row['username']); $out .= "<tr>" . "<td><img title='{$row['username']}' src='{$icon_url}' alt=\"{$row['username']}\"> <a href=\"?u={$row['username']}\">{$row['username']}</a></td>" . "<td>{$row['userlevel']}</td>" . "<td class='numeric_td'>{$row['registered_since']}</td>" . "<td class='numeric_td'>{$days_offline}</td>" . "<td class='numeric_td'>{$row['lot_count']}</td>" . "<td class='numeric_td'>{$avg_online}</td>" . "<td class='numeric_td'>{$online_total}</td>" . "</tr>\n"; } $out .= "</tbody>\n</table>\n"; echo $out; } }
function umc_get_formatted_entries($contest_id = false, $new_entry_id = 0) { $id = intval($contest_id); global $prefix, $UMC_DOMAIN; if (isset($_GET['type'])) { $id = intval($_GET['type']); } // get contest title $sql = "SELECT * FROM " . $prefix . "contests WHERE id={$id};"; mysql_select_db('minecraft_srvr'); $rst = mysql_query($sql); $row = mysql_fetch_array($rst, MYSQL_ASSOC); $pre_title = 'Survival: '; if ($row['type'] == 'creative') { $pre_title = 'Creative: '; } $ret = '<div class="contest"><div class="contest_title">' . $pre_title . $row['title'] . '</div>'; $deadline_text = ""; if ($row['deadline'] != "" && $row['deadline'] != '0000-00-00' && $row['status'] == 'active') { $deadline_text = "<strong>Deadline:</strong> {$row['deadline']}"; } $ret .= '<hr>' . stripslashes($row['description']) . "<hr><strong>ID:</strong>" . $row['id'] . " {$deadline_text} <strong>Width:</strong>" . $row['x'] . ' <strong>Length:</strong>' . $row['z'] . ' <strong>Height:</strong>' . $row['y'] . '</div>'; // all entries $sql = "SELECT * FROM " . $prefix . "entries WHERE contest='" . $id . "'"; $rst = mysql_query($sql); if (mysql_num_rows($rst) > 0) { $ret .= '<div id="entries_header" class="header">Entries:</div>'; } else { $ret .= '<div id="entries_header" class="header">This contest has no entries.</div>'; } while ($row = mysql_fetch_array($rst, MYSQL_ASSOC)) { $admin_html = '<div class="opts">' . '<a href="?action=delete_entry&contest=' . $id . '&id=' . $row['id'] . '" class="delete_entry">Delete</a>' . '</div>'; if ($row['id'] == intval($new_entry_id)) { $ret .= '<div class="contest_entry new_entry">'; } else { $ret .= '<div class="contest_entry">'; } $icon_url = umc_user_get_icon_url($row['user']); $ret .= '<div class="entry_title"><a href="?action=show_entry&type=' . $row['id'] . '">' . stripslashes($row['title']) . '</a></div><div class="creator">by <img width=\\"16\\" src="' . $icon_url . '"/> <strong>' . $row['user'] . '</strong> (' . umc_get_userlevel($row['user']) . ')</div>' . umc_get_stars($row['id'], umc_get_votes_info($row['id']), "all"); if (umc_is_admin() || umc_i_am($row->user)) { $ret .= $admin_html; } $ret .= '</div>'; } //create new contest entry // find entry by user $user_arr = umc_is_online(); if ($user_arr['online'] == false) { $ret .= "To enter your contest entry, please <a href=\"{$UMC_DOMAIN}/wp-admin/profile.php\">logged in</a>!"; return $ret; } $username = $user_arr['username']; $lower_username = strtolower($username); mysql_select_db('minecraft_worldguard'); // find out if the user can have additional contest entries in this contest $sql = "SELECT * FROM world LEFT JOIN region ON world.id=region.world_id\n LEFT JOIN region_cuboid ON region.id=region_cuboid.region_id\n LEFT JOIN region_players ON region_cuboid.region_id=region_players.region_id\n LEFT JOIN user ON region_players.user_id=user.id\n WHERE region.id LIKE 'con_{$id}%' AND Owner=1 AND user.name = '{$lower_username}'\n ORDER BY max_z, max_x"; $rst = mysql_query($sql); $count = mysql_num_rows($rst); if ($count == 0) { $ret .= "To create a contest entry, please type <strong>/contest</strong> in-game!"; return $ret; } $entries = array(); while ($row = mysql_fetch_array($rst, MYSQL_ASSOC)) { $entries[] = $row['region_id']; } mysql_select_db('minecraft_srvr'); foreach ($entries as $entry) { $sql = "SELECT * FROM contest_entries WHERE contest = {$id} AND user = '******' AND lot='{$entry}';"; // echo $sql; $rst = mysql_query($sql); $count = mysql_num_rows($rst); if ($count == 1) { // entry was already submitted } else { // entry has to be submitted still $entry_html .= "<div id=\"new_entry_form\">Submit your entry from lot {$entry}: " . '<form method="post">' . '<input type="hidden" name="contest" id="contest_id" value="' . $id . '">' . '<input type="hidden" name="lot" id="lot" value="' . $entry . '">' . '<input type="text" name="title" id="new_entry_title" placeholder="Title" /><br />' . '<textarea id="new_entry_desc" name="desc" placeholder="Description"></textarea><br />' . '<input type="hidden" name="action" value="enter_contest">' . '<hr/><input type="submit" id="enter_contest" value="Enter Contest" >' . '</form>' . '</div>'; } } //if(umc_can_enter($id)) { $ret .= $entry_html; //} return $ret; // ."<br />can enter: ".umc_can_enter($id)." id: ".$id; }