/**
 * 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);
}
Ejemplo n.º 2
0
/**
 * Verify that an externally called function is actually a vaild, no-risk function call.
 *
 * $UMC_FUNCTIONS is defined in all the files where the respective function is located
 *
 * @global type $UMC_FUNCTIONS
 * @param type $function
 */
function umc_function_call($function)
{
    global $UMC_FUNCTIONS;
    // we check if the function is in the list of known functions
    if (!isset($UMC_FUNCTIONS[$function])) {
        // if not, send a warning so that it can be included for the future
        XMPP_ERROR_send_msg("Unverified function call '{$function}'");
        $function_name = 'umc_' . $function;
    } else {
        // if yes, all fine, get proper function name
        $function_name = $UMC_FUNCTIONS[$function];
    }
    // execute code
    echo $function_name();
}
Ejemplo n.º 3
0
function umc_home_warp()
{
    global $UMC_USER;
    $playerworld = $UMC_USER['world'];
    $args = $UMC_USER['args'];
    // no home name given
    if (!isset($args[2])) {
        // check if the user has only one home
        $home_count = umc_home_count();
        if ($home_count > 1) {
            umc_error("{red}You need to specify the name of your home!");
        } else {
            if ($home_count == 0) {
                umc_error("{red}You do not have any homeslots yet!");
            } else {
                $sql = "SELECT * FROM minecraft_srvr.homes WHERE uuid='{$UMC_USER['uuid']}' LIMIT 1;";
            }
        }
    } else {
        $name = umc_mysql_real_escape_string(trim($args[2]));
        $home_count = umc_home_count($name);
        if ($home_count < 1) {
            umc_error("{red}You do not have a home with that name!");
        }
        $sql = "SELECT * FROM minecraft_srvr.homes WHERE uuid='{$UMC_USER['uuid']}' AND name={$name};";
    }
    $D = umc_mysql_fetch_all($sql);
    $row = $D[0];
    $world = $row['world'];
    if ($world != $playerworld) {
        umc_ws_cmd("mv tp {$world}", 'asPlayer');
    }
    $x = $row['x'];
    $z = $row['z'];
    $y = $row['y'];
    $yaw = $row['yaw'];
    // todo translate ESSENTIALS yaw into minecraft yaw
    XMPP_ERROR_send_msg("tppos {$x} {$y} {$z} {$yaw}");
    umc_ws_cmd("tppos {$x} {$y} {$z} {$yaw}", 'asPlayer');
}
Ejemplo n.º 4
0
/**
 * Checks if there is a valid connection from websend
 *
 * @return boolean
 */
function umc_ws_auth()
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $checkpass = file_get_contents("/home/includes/certificates/websend_code.txt");
    $hashAlgorithm = "sha512";
    $s_post = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
    if (!isset($s_post['authKey'])) {
        return false;
    } else {
        $receivedHash = $s_post['authKey'];
    }
    // check if hash is empty
    if ($receivedHash == "") {
        XMPP_ERROR_send_msg("Websend authKey is empty!");
        return false;
    }
    // check if has is valid
    if ($receivedHash !== hash($hashAlgorithm, $checkpass)) {
        XMPP_ERROR_send_msg("Websend authKey is invalid!");
        return false;
    }
    return true;
}
Ejemplo n.º 5
0
/**
 * Checks if there is a valid connection from websend
 *
 * @return boolean
 */
function umc_ws_auth()
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $checkpass = "******";
    $hashAlgorithm = "sha512";
    $s_post = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
    if (!isset($s_post['authKey'])) {
        return false;
    } else {
        $receivedHash = $s_post['authKey'];
    }
    // check if hash is empty
    if ($receivedHash == "") {
        XMPP_ERROR_send_msg("Websend authKey is empty!");
        return false;
    }
    // check if has is valid
    if ($receivedHash !== hash($hashAlgorithm, $checkpass)) {
        XMPP_ERROR_send_msg("Websend authKey is invalid!");
        return false;
    }
    return true;
}
function umc_usericon_get($users = false, $update = true)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    global $UMC_PATH_MC;
    $steve_head = '/home/minecraft/server/bin/data/steve.png';
    if (!$users) {
        $users = umc_get_active_members();
    } else {
        if (is_array($users) && count($users) == 0) {
            XMPP_ERROR_send_msg("umc_update_usericons got zero users!");
        } else {
            if (!is_array($users)) {
                $U = umc_uuid_getboth($users);
                $users = array($U['uuid'] => $U['username']);
            }
        }
    }
    $users_raw = array();
    foreach ($users as $uuid => $username) {
        $uuid_raw = str_replace("-", "", $uuid);
        $users_raw[$uuid] = $url = "https://sessionserver.mojang.com/session/minecraft/profile/{$uuid_raw}";
    }
    $no_skin = array();
    $failed_users = array();
    $skin_urls = array();
    $D = unc_serial_curl($users_raw, 0, 50, '/home/includes/unc_serial_curl/google.crt');
    foreach ($D as $uuid => $d) {
        // we only update the skin if it does not exist
        if (!$update && file_exists("{$UMC_PATH_MC}/server/bin/data/full_skins/{$uuid}.png")) {
            continue;
        }
        if ($uuid == 'abandone-0000-0000-0000-000000000000') {
            continue;
        }
        if ($d['response']['http_code'] !== 200) {
            $failed_users[] = array('uuid' => $uuid, 'url' => $d['response']['url'], 'reason' => 'Could not download user data');
        }
        $base64_texture = '';
        $d_arr = json_decode($d['content']);
        if (!$d_arr) {
            XMPP_ERROR_trigger("Failed to retrieve session profile for {$uuid}");
        }
        //object(stdClass)#2 (3) {
        //  ["id"]=>
        //  string(32) "ab3bc877443445a993bdbab6df41eabf"
        //  ["name"]=>
        //  string(8) "uncovery"
        //  ["properties"]=>
        //  array(1) {
        //    [0]=>
        //    object(stdClass)#3 (2) {
        //      ["name"]=>
        //      string(8) "textures"
        //      ["value"]=>
        //      string(308) "eyJ0aW1lc3RhbXAiOjE0NDA0NzUyOTQ2NDksInByb2ZpbGVJZCI6ImFiM2JjODc3NDQzNDQ1YTk5M2JkYmFiNmRmNDFlYWJmIiwicHJvZmlsZU5hbWUiOiJ1bmNvdmVyeSIsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9jYWVhMjljODY2ZDkyMTVhYWJjMTk5MDQyMTE1ZWMwNTUzMzJkNjZlMGI4ZWY2ZjkyNjNmZTRiMWZlNzZlIn19fQ=="
        //    }
        //  }
        //}
        if (!isset($d_arr->properties)) {
            XMPP_ERROR_trace("json", $d_arr);
            XMPP_ERROR_trigger("Failed to retrieve properties for {$uuid}");
        }
        $prop_count = count($d_arr->properties);
        for ($i = 0; $i < $prop_count; $i++) {
            if ($d_arr->properties[$i]->name == 'textures') {
                $base64_texture = $d_arr->properties[$i]->value;
            } else {
                echo "Wrong property: " . $d_arr->properties[$i]->name;
            }
        }
        $raw_texture = base64_decode($base64_texture);
        // {"timestamp":1440475294649,"profileId":"ab3bc877443445a993bdbab6df41eabf","profileName":"uncovery","textures":{"SKIN":{"url":"http://textures.minecraft.net/texture/caea29c866d9215aabc199042115ec055332d66e0b8ef6f9263fe4b1fe76e"}}}
        $texture_arr = json_decode($raw_texture);
        if (!$texture_arr) {
            XMPP_ERROR_trigger("Failed to decode texture: {$raw_texture}");
        }
        $time_stamp = $texture_arr->timestamp;
        // check if the file on the drive is newer
        $current_file = "{$UMC_PATH_MC}/server/bin/data/full_skins/{$uuid}.png";
        if (!file_exists($current_file) || filemtime($current_file) > $time_stamp) {
            if (isset($texture_arr->textures->SKIN)) {
                // user did not set skin
                $skin_urls[$uuid] = $texture_arr->textures->SKIN->url;
                // echo $texture_arr->textures->SKIN->url . "<br>\n";
            } else {
                XMPP_ERROR_trace("{$uuid} does not have a skin: {$raw_texture}");
                $no_skin[] = $uuid;
            }
        }
    }
    $S = unc_serial_curl($skin_urls);
    foreach ($S as $uuid => $s) {
        $skin_file = "{$UMC_PATH_MC}/server/bin/data/full_skins/{$uuid}.png";
        $head_file = "{$UMC_PATH_MC}/server/bin/data/user_icons/{$uuid}.png";
        if ($s['response']['content_type'] !== 'image/png' && $s['response']['http_code'] !== 200) {
            $failed_users[] = array('uuid' => $uuid, 'url' => $s['response']['url'], 'reason' => 'Could not download image');
            continue;
        }
        $written = file_put_contents($skin_file, $s['content']);
        if (!$written) {
            $failed_users[] = array('uuid' => $uuid, 'url' => $s['response']['url'], 'reason' => "Could not save file to {$skin_file}");
            continue;
        }
        // convert to head icon, resize to 20x20
        $command = "convert -crop '8x8+8+8' -scale 20 \"{$skin_file}\" \"{$head_file}\"";
        exec($command);
    }
    // process users w/o skin
    foreach ($no_skin as $uuid) {
        $head_file = "{$UMC_PATH_MC}/server/bin/data/user_icons/{$uuid}.png";
        if (!file_exists($steve_head)) {
            XMPP_ERROR_trigger("Steve head icon not available");
        } else {
            $check = copy($steve_head, $head_file);
            if (!$check || !file_exists($head_file)) {
                XMPP_ERROR_trigger("Could not create steve head for file {$head_file}");
            } else {
                XMPP_ERROR_trace("used steve head for {$head_file}");
            }
        }
    }
    if (count($failed_users) > 0) {
        XMPP_ERROR_trace("failed users:", $failed_users);
        XMPP_ERROR_trigger("Users failed to get icon, see error report for details");
    }
}
Ejemplo n.º 7
0
function umc_disassemble_map($world = 'empire')
{
    global $UMC_SETTING, $UMC_PATH_MC;
    $dim = $UMC_SETTING['world_data'][$world];
    $source = "{$UMC_PATH_MC}/server/maps";
    // get lot list with coordinates
    if ($world == 'city') {
        return;
    }
    $sql = "SELECT region_id as lot, min_x, min_z, max_x, max_z\r\n\tFROM minecraft_worldguard.region_cuboid\r\n        LEFT JOIN minecraft_worldguard.world ON world_id = id\r\n\tWHERE name='{$world}';";
    $D = umc_mysql_fetch_all($sql);
    if (count($D) == 0) {
        return;
    }
    if ($world == 'kingdom' || $world == 'draftlands') {
        $map = $UMC_SETTING['world_img_dim'][$world];
        $source = "{$UMC_PATH_MC}/server/maps";
        foreach ($D as $row) {
            $lot = $row['lot'];
            if ($lot == "__global__") {
                continue;
            }
            $x1 = conv_x($row['min_x'], $map);
            $x2 = conv_x($row['max_x'], $map);
            $z1 = conv_z($row['min_z'], $map);
            $z2 = conv_z($row['max_z'], $map);
            $base_x = min($x1, $x2);
            $base_z = min($z1, $z2);
            $size_x = max($x1, $x2) - $base_x;
            $size_z = max($z1, $z2) - $base_z;
            $command = "convert -crop '{$size_x}x{$size_z}+{$base_x}+{$base_z}' \"{$source}/{$world}.jpg\" \"{$source}/lots/{$world}/{$lot}.png\"";
            // echo $command . "\n";
            exec($command);
        }
    } else {
        $lot_size = $dim['lot_size'];
        $world_lots = $dim['lot_number'];
        if (!isset($dim['lot_number'])) {
            XMPP_ERROR_trigger("Error disassembling world {$world} map");
        }
        $command = "convert \"{$source}/{$world}.jpg\" +repage -crop {$lot_size}" . "x" . "{$lot_size} +repage \"{$source}/lots/{$world}/{$world}.png\" ";
        // echo $command . "\n";
        exec($command);
        // rename the files
        $lot_array = array();
        // this creates an array of the line number a letter would have (A=1, B=2 etc)
        for ($i = 1; $i <= $world_lots; $i++) {
            if ($i <= 26) {
                $letter = chr(96 + $i);
            } else {
                $letter = 'a' . chr(70 + $i);
            }
            $lot_array[$letter] = $i;
        }
        // var_dump($lot_array);
        foreach ($D as $row) {
            $lot = $row['lot'];
            if ($lot == "__global__") {
                continue;
            }
            $lot_str = explode("_", $lot);
            // this is needed because of the "city_spawn" lot
            if ($lot_str[1] == 'spawn') {
                continue;
            }
            $lot_coords = array();
            preg_match('#^([a-zA-Z]*)(\\d*)#', $lot_str[1], $lot_coords);
            if (!isset($lot_coords[1]) || !isset($lot_coords[2])) {
                XMPP_ERROR_send_msg("Disassemble {$world} failed: " . var_export($lot_coords, true));
            }
            $lot_letter = $lot_coords[1];
            $lot_number = $lot_coords[2];
            // this is the final line number
            if (!isset($lot_array[$lot_letter])) {
                // some lots do not fit the pattern (arena etc)
                continue;
            }
            $row_no = $world_lots - $lot_array[$lot_letter];
            $index = $row_no * $world_lots + $lot_number - 1;
            // echo "$lot: $lot_letter -> {$lot_array[$lot_letter]} of $world_lots => $row_no + $lot_number = $index <br>";
            // rename files
            // echo "renaming {$world}-$index.png -> $lot.png\n";
            if (file_exists("{$source}/lots/{$world}/{$world}-{$index}.png")) {
                rename("{$source}/lots/{$world}/{$world}-{$index}.png", "{$source}/lots/{$world}/{$lot}.png");
            } else {
                echo "File {$source}/lots/{$world}/{$world}-{$index}.png not found \n";
            }
        }
    }
}
Ejemplo n.º 8
0
/**
 * tries to find a location far out that was not used as a hunger game before
 * this will also create the warp point in essentials
 *
 * @return array('x' => $center_x, 'z' => $center_z)
 */
function umc_hunger_find_random_location()
{
    // 30 Mio is the MC hard limit
    $min_val = 1000;
    $max_val = 30000000 - 2000;
    //we take the max and some margin
    // find a center
    $center_x = rand($min_val, $max_val);
    $center_z = rand($min_val, $max_val);
    // which quarter of the map?
    $dir_x = rand(0, 1);
    if ($dir_x == 0) {
        $center_x = $center_x * -1;
    }
    $dir_z = rand(0, 1);
    if ($dir_z == 0) {
        $center_z = $center_z * -1;
    }
    // check if a game existed on that location
    $sql = "SELECT id FROM minecraft_iconomy.hunger_games\r\n        WHERE x > ({$center_x} - 500)\r\n\t    AND x < ({$center_x} + 500)\r\n\t    AND z < ({$center_z} + 500)\r\n\t    AND z > ({$center_z} - 500);";
    $data = umc_mysql_fetch_all($sql);
    // too close, try again
    if (count($data) > 0) {
        umc_log('hunger', 'found_location_fail', "Found alrady existing location X: {$center_x} Z: {$center_z} - retrying");
        XMPP_ERROR_trigger("hunger rejected location X: {$center_x} Z: {$center_z}, trying again");
        return umc_hunger_find_random_location();
    } else {
        XMPP_ERROR_send_msg("hunger Found location X: {$center_x} Z: {$center_z}");
        // update warp point
        $text = "yaw: 0.0\nname: hunger\npitch: 0.0\nz: {$center_z}\ny: 250\nworld: hunger\nx: {$center_x}";
        $filename = '/home/minecraft/server/bukkit/plugins/Essentials/warps/hunger.yml';
        file_put_contents($filename, $text);
        // reload essentials
        umc_ws_cmd('ess reload', 'asConsole');
        return array('x' => $center_x, 'z' => $center_z);
    }
}
Ejemplo n.º 9
0
/**
 * Validate password resets for banned users
 *
 * @param type $errors
 * @param type $user_obj
 */
function umc_wp_password_reset_check($errors, $user_obj)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    require_once '/home/minecraft/server/bin/index_wp.php';
    $check = umc_user_is_banned($user_obj->user_login);
    if ($check) {
        // user is banned
        $errors->add('user_is_banned', 'ERROR: You are banned from this server. Password request denied.');
        XMPP_ERROR_send_msg("Banned User " . $user_obj->user_login . " attempted password reset");
    }
}
Ejemplo n.º 10
0
 public function ban($reason)
 {
     XMPP_ERROR_trace(__CLASS__ . " // " . __FUNCTION__, func_get_args());
     global $UMC_USERS;
     $cmd = "ban {$this->username} {$reason}";
     if ($this->context == 'websend') {
         umc_ws_cmd($cmd, 'asConsole', false, false);
         $admin = $UMC_USERS['current_user']->username;
     } else {
         umc_exec_command($cmd, 'asConsole', false);
         $admin = 'wordpress';
     }
     $sql = "INSERT INTO minecraft_srvr.`banned_users`(`username`, `reason`, `admin`, `uuid`) VALUES ('{$this->username}','{$reason}', '{$admin}', '{$this->uuid}');";
     umc_mysql_query($sql, true);
     // remove shop inventory
     umc_shop_cleanout_olduser($this->uuid);
     // remove from teamspeak
     umc_ts_clear_rights($this->uuid);
     $text = "{$admin} banned \${$this->username} ({$this->uuid}) because of {$reason}";
     umc_log('mod', 'ban', $text);
     XMPP_ERROR_send_msg($text);
     // iterate plugins to check for plugin relared post ban processes
 }
Ejemplo n.º 11
0
/**
 * 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;
}
Ejemplo n.º 12
0
function umc_donation_level($user, $debug = false)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $U = umc_uuid_getboth($user);
    $uuid = $U['uuid'];
    $username = $U['username'];
    $debug_txt = '';
    global $UMC_SETTING;
    $date_now = new DateTime("now");
    $sql = "SELECT amount, date FROM minecraft_srvr.donations WHERE uuid='{$uuid}';";
    $level = umc_get_uuid_level($uuid);
    if ($level == 'Owner') {
        return false;
    }
    $D = umc_mysql_fetch_all($sql);
    // if there are 0 donations, user should not be changes
    if (count($D) == 0 && strstr($level, "Donator")) {
        XMPP_ERROR_trigger("User {$username} ({$uuid}) never donated but has a donator level ({$level})");
    } else {
        if (count($D) == 0) {
            $debug_txt .= "{$username} ({$uuid}) does not have any donations\n";
            return;
        }
    }
    $debug_txt .= "Checking donation upgrade of user {$username}, current UserLevel: {$level}\n";
    $donation_level = 0;
    // go through all donations and find out how much is still active
    foreach ($D as $row) {
        $date_donation = new DateTime($row['date']);
        $interval = $date_donation->diff($date_now);
        $years = $interval->format('%y');
        $months = $interval->format('%m');
        $donation_term = $years * 12 + $months;
        $donation_leftover = $row['amount'] - $donation_term;
        if ($donation_leftover < 0) {
            $donation_leftover = 0;
            // do not create negative carryforward
        }
        $donation_level = $donation_level + $donation_leftover;
        $debug_txt .= "Amount donated {$row['amount']} {$years} years {$months} m ago = {$donation_term} months ago, {$donation_leftover} leftover, level: {$donation_level}\n";
    }
    $donation_level_rounded = ceil($donation_level);
    // get userlevel and check if demotion / promotion is needed
    $debug_txt .= "user {$username} ({$uuid}) has donation level of {$donation_level_rounded}, now is {$level}\n";
    // current userlevel
    $ranks_lvl = array_flip($UMC_SETTING['ranks']);
    $cur_lvl = $ranks_lvl[$level];
    // get current promotion level
    if (strpos($level, 'DonatorPlus')) {
        $current = 2;
    } else {
        if (strpos($level, 'Donator')) {
            $current = 1;
        } else {
            $current = 0;
        }
    }
    // get future promotion level
    if (count($D) == 0) {
        // this never happens since it's excluded above
        $future = 0;
    } else {
        if ($donation_level_rounded >= 1) {
            $future = 2;
        } else {
            if ($donation_level_rounded < 1) {
                $future = 1;
            }
        }
    }
    $debug_txt .= "future = {$future}, current = {$current}\n";
    $change = $future - $current;
    if ($change == 0) {
        $debug_txt .= "User has right level, nothing to do\n";
        return false;
        // bail if no change needed
    } else {
        // we have a change in level, let's get an error report
        $debug = true;
    }
    $debug_txt .= "User will change {$change} levels\n";
    // get currect rank index
    $debug_txt .= "Current Rank index = {$cur_lvl}\n";
    // calculate base level
    $base_lvl = $cur_lvl - $current;
    $debug_txt .= "User base level = {$base_lvl}\n";
    $new_lvl = $base_lvl + $future;
    if ($new_lvl == $cur_lvl) {
        XMPP_ERROR_send_msg("Donations upgrade: Nothing to do, CHECK this should have bailed earlier!");
        return false;
    }
    $new_rank = $UMC_SETTING['ranks'][$new_lvl];
    $debug_txt .= "User {$username} upgraded from {$level} to {$new_rank}\n";
    umc_exec_command("pex user {$uuid} group set {$new_rank}");
    umc_log('Donations', 'User Level de/promotion', "User {$username} upgraded from {$level} to {$new_rank}");
    if ($debug) {
        XMPP_ERROR_send_msg($debug_txt);
    }
    return $donation_level_rounded;
    // . "($donation_level $current - $future - $change)";
}
Ejemplo n.º 13
0
/**
 * Bans a user
 * can make the difference between UUID and username
 * can make the difference between websend and wordpress
 *
 * @param type $user
 */
function umc_user_ban($user, $reason)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    global $UMC_ENV, $UMC_USER;
    $U = umc_uuid_getboth($user);
    $uuid = $U['uuid'];
    $username = $U['username'];
    $cmd = "ban {$username} {$reason}";
    if ($UMC_ENV == 'websend') {
        umc_ws_cmd($cmd, 'asConsole', false, false);
        $admin = $UMC_USER['username'];
    } else {
        umc_exec_command($cmd, 'asConsole', false);
        $admin = 'wordpress';
    }
    $sql = "INSERT INTO minecraft_srvr.`banned_users`(`username`, `reason`, `admin`, `uuid`) VALUES ('{$username}','{$reason}', '{$admin}', '{$uuid}');";
    umc_mysql_query($sql, true);
    // remove shop inventory
    umc_shop_cleanout_olduser($uuid);
    // remove from teamspeak
    umc_ts_clear_rights($uuid);
    umc_wp_ban_user($uuid);
    umc_log('mod', 'ban', "{$admin} banned {$username}/{$uuid} because of {$reason}");
    XMPP_ERROR_send_msg("{$admin} banned {$username} because of {$reason}");
}
Ejemplo n.º 14
0
/**
 * Open a folder of a certain date and display all the images in there
 *
 * @global type $UNC_GALLERY
 * @return string
 */
function unc_display_images()
{
    global $UNC_GALLERY;
    if ($UNC_GALLERY['debug']) {
        XMPP_ERROR_trace(__FUNCTION__);
    }
    $D = $UNC_GALLERY['display'];
    $header = '';
    if (isset($D['dates'])) {
        $date_str = $D['dates'][0];
        if (current_user_can('manage_options') && is_admin()) {
            $url = admin_url('admin.php?page=unc_gallery_admin_menu');
            $header .= "\r\n            <span class=\"delete_folder_link\">\r\n                Sample shortcode for this day: <input id=\"short_code_sample\" onClick=\"SelectAll('short_code_sample');\" type=\"text\" value=\"[unc_gallery date=&quot;{$date_str}&quot;]\">\r\n                <a href=\"{$url}&amp;folder_del={$date_str}\">\r\n                    Delete Date: {$date_str}\r\n                </a>\r\n            </span>\n";
        }
    }
    // get all the files in the folder with attributes
    $files = $D['files'];
    // display except for skipped files and files out of time range
    $images = '';
    $featured = '';
    $featured_fixed = false;
    if ($UNC_GALLERY['featured_size_for_mixed_sizes'] != 'dynamic' && count($D['featured_image']) > 1) {
        $featured_fixed = $UNC_GALLERY['featured_size_for_mixed_sizes'];
    }
    /*if ($D['slideshow']) {
          $images .= '<ul id="lightSlider">';
      } */
    $i = 0;
    // limit images
    $max_images = intval($D['limit_images']);
    $counter = 0;
    foreach ($files as $F) {
        // stop looping once we have the max number of images
        if ($max_images && $i >= $max_images) {
            break;
        } else {
            if ($max_images && $i == $max_images - 1) {
                $not_shown = count($files) - $max_images;
                if ($not_shown > 0) {
                    $UNC_GALLERY['not_shown'] = $not_shown;
                }
            }
        }
        $F['index'] = $i;
        if (!$D['slideshow'] && $F['featured']) {
            // select size for featured images
            if ($featured_fixed) {
                $feat_size = $featured_fixed;
            } else {
                if ($UNC_GALLERY['featured_size'] != 'dynamic') {
                    $feat_size = $UNC_GALLERY['featured_size'];
                } else {
                    if ($F['orientation'] == 'portrait') {
                        $feat_size = $UNC_GALLERY['featured_size_for_portrait'];
                    } else {
                        $feat_size = $UNC_GALLERY['featured_size_for_landscape'];
                    }
                }
            }
            $height_css = 'rows_' . $feat_size;
            $counter++;
            $featured .= "<div class=\"featured_photo {$height_css}\">\n" . unc_display_image_html($F['file_path'], false, $F) . "</div>\n";
            /*} else if ($Df['slideshow']) { // slideshow does not have features
              $images .= "<li>\n"
                  . unc_display_image_html($F['file_path'], false, $F)
                  . '<p>' . unc_tools_file_desc($F) . '</p>'
                  . "</li>\n";*/
        } else {
            $counter++;
            $images .= "<div class=\"one_photo\">\n" . unc_display_image_html($F['file_path'], true, $F) . "</div>\n";
        }
        $i++;
    }
    /* if ($D['slideshow']) {
           $images .= '</ul>';
       } **/
    $photoswipe = '';
    if ($UNC_GALLERY['image_view_method'] == 'photoswipe') {
        $photoswipe = unc_display_photoswipe_js($files);
    }
    if ($UNC_GALLERY['post_keywords'] != 'none') {
        $check_tags = unc_tags_apply($files);
        if ($check_tags) {
            if ($UNC_GALLERY['debug']) {
                XMPP_ERROR_trigger("Tags have been updated");
            }
        }
    }
    if ($UNC_GALLERY['post_categories'] != 'none') {
        $check_cats = unc_categories_apply($files);
        if ($check_cats) {
            if ($UNC_GALLERY['debug']) {
                XMPP_ERROR_send_msg("Categories have been updated");
            }
        }
    }
    if ($D['slideshow']) {
        $photoswipe = '';
        /*'<script type="text/javascript">
          jQuery(document).ready(function() {
              var slider = jQuery("#lightSlider").lightSlider({
                  adaptiveHeight:true,
                  item:1,
                  auto:true,
                  slideMargin:0,
                  loop:true,
                  adaptiveHeight:true,
                  mode:\'fade\',
                  speed:800,
                  pause:4000,
                  });
          });
          </script>'; */
    }
    $summary = "<div class=\"images_summary\">{$counter} images found.</div>";
    $out = $header . $featured . $images . $photoswipe . $summary;
    if ($D['echo']) {
        ob_clean();
        echo $out;
        wp_die();
    } else {
        return $out;
    }
}
Ejemplo n.º 15
0
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 = "&amp;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;
}
Ejemplo n.º 16
0
/**
 * Do an actual lot reset
 *
 * @param type $lot
 * @param type $a
 */
function umc_lot_manager_reset_lot($lot, $a)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $debug = $a['reason'];
    // we assume reseting of chunks, unless the dibs owner does not want to
    $a['reset_chunks'] = true;
    $reason = $a['reason'];
    $a['new_owner'] = false;
    // check dibs
    if ($a['dibs']) {
        if (count($a['dibs']) > 1) {
            $debug .= "Lot {$lot} has more than 1 dibs applicant, aborting! ";
            return;
        }
        $debug .= "Lot {$lot} has dibs! ";
        // we iterate the people who asked for the lot, and
        // once we found a valid one, execute the actions
        //
        // this can only be done AFTER current owners have been removed
        // since the check_before_assign fails if the lot is owned by someone
        umc_lot_remove_all($lot);
        $a['remove_users'] = false;
        foreach ($a['dibs'] as $dibs_info) {
            $dibs_uuid = $dibs_info['uuid'];
            $debug .= " user {$dibs_uuid}: ";
            $dibs_check = umc_lot_manager_check_before_assign($dibs_uuid, $lot);
            XMPP_ERROR_trace('umc_lot_manager_check_before_assign result', $dibs_check);
            if ($dibs_check['result']) {
                $debug .= " OK!";
                $reason .= "user {$dibs_uuid} had dibs and got the lot";
                $a['new_owner'] = $dibs_uuid;
                $a['new_owner_costs'] = $dibs_check['cost'];
                if ($dibs_info['action'] == 'none') {
                    $a['reset_chunks'] = false;
                    $reason .= " but dibs owner did not want to reset!";
                }
                break;
            } else {
                $debug .= " NOT OK, going for next!";
            }
            umc_lot_manager_dib_delete($dibs_uuid, $lot);
            XMPP_ERROR_send_msg("{$debug}");
        }
        //echo $debug . "<br>";
    }
    // reset all lots
    $debug .= "Lot ready for reset!";
    $source_lot = $lot;
    if ($a['user_shop_clean']) {
        $debug .= " Shop cleanout user " . $a['user_shop_clean'] . ", ";
        umc_shop_cleanout_olduser($a['user_shop_clean']);
        // also remove teamspeak priviledges
        umc_ts_clear_rights($a['user_shop_clean'], false);
    }
    if ($a['remove_users']) {
        $debug .= " Removing all users ";
        umc_lot_remove_all($lot);
    }
    if ($a['reset_to']) {
        $source_lot = $a['reset_to'];
    }
    if ($a['del_skyblock_inv']) {
        // value is false or the uuid
        umc_lot_skyblock_inv_reset($a['del_skyblock_inv']);
    }
    if ($a['reset_chunks']) {
        umc_move_chunks($source_lot, $a['source_world'], $lot, $a['dest_world'], false);
    }
    umc_log('lot_manager', 'reset', $reason);
    if ($a['version_sql']) {
        umc_mysql_query($a['version_sql'], true);
    }
    if ($a['new_owner']) {
        // give lot to dibs owner and charge money
        umc_lot_add_player($a['new_owner'], $lot, 1, $a['new_owner_costs']);
        // remove dibs from database
        // umc_lot_manager_dib_delete($a['new_owner'], $lot);
    }
    $debug .= "{$source_lot}, {$a['source_world']}, {$lot}, {$a['dest_world']}";
    XMPP_ERROR_trace(__FUNCTION__, $debug);
}
Ejemplo n.º 17
0
/**
 * This checks if the username has changed and updates the wordpress table accordingly
 *
 * @param type $username
 * @param type $uuid
 */
function umc_uuid_check_usernamechange($uuid)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $sql = "SELECT ID, user_login, display_name, UUID, username, wp_users.user_registered, UUID.lastlogin FROM minecraft.`wp_users`\r\n        LEFT JOIN minecraft.wp_usermeta ON ID=wp_usermeta.user_id\r\n        LEFT JOIN minecraft_srvr.UUID ON UUID.UUID=wp_usermeta.meta_value\r\n        WHERE meta_key='minecraft_uuid' AND meta_value='{$uuid}';";
    $D = umc_mysql_fetch_all($sql);
    foreach ($D as $d) {
        // get proper username from Mojang
        $uuid = $d['UUID'];
        $wordpress_name = strtolower($d['display_name']);
        $uuid_name = strtolower($d['username']);
        $wp_login = $d['user_login'];
        // $wp_id = $d['ID'];
        $mojang_raw = umc_uuid_get_from_mojang($uuid);
        $mojang_name = strtolower($mojang_raw);
        if (!$mojang_name || $mojang_name == '') {
            //XMPP_ERROR_trigger("Tried to check for username change, failed to confirm ($sql)");
            $s_server = filter_input_array(INPUT_SERVER, FILTER_SANITIZE_STRING);
            $referer = "\nREQUEST_URI: " . $s_server['REQUEST_URI'];
            XMPP_ERROR_send_msg("Fail on Username change check umc_uuid_check_usernamechange: Mojang name for {$uuid} is {$mojang_name} {$referer}");
            return;
            // let's try the user_login
            /*    $mojang_uuid = umc_uuid_get_from_mojang($wp_login);
                     // update the meta table
                     $u_sql_meta = "UPDATE minecraft.wp_usermeta SET meta_value='$mojang_uuid' WHERE user_id='$wp_id' AND meta_key='minecraft_uuid'";
                     umc_mysql_query($u_sql_meta, true);
                  *
                  */
        }
        if ($wordpress_name != $mojang_name) {
            $u_sql_wp = "UPDATE minecraft.wp_users SET display_name='{$mojang_name}' WHERE user_login='******'";
            $logtext = "User {$uuid} changed username from {$wordpress_name} to {$mojang_name} in Wordpress";
            XMPP_ERROR_send_msg($logtext);
            umc_log('UUID', 'Username Change', $logtext);
            umc_mysql_query($u_sql_wp, true);
        }
        if ($uuid_name != $mojang_name) {
            $u_sql_uuid = "UPDATE minecraft_srvr.UUID SET username='******' WHERE UUID='{$uuid}'";
            $logtext = "User {$uuid} changed username from {$uuid_name} to {$mojang_name} in UUID table";
            XMPP_ERROR_send_msg($logtext);
            umc_log('UUID', 'Username Change', $logtext);
            umc_mysql_query($u_sql_uuid, true);
        }
    }
}