コード例 #1
0
function umc_home_import()
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    // global $UMC_USER;
    // we automatically import old homes for all players on login, but only once
    // include spyc to parse YAML https://github.com/mustangostang/spyc
    require_once '/home/includes/spyc/Spyc.php';
    $users = umc_get_active_members();
    foreach ($users as $uuid => $username) {
        $path = '/home/minecraft/server/bukkit/plugins/Essentials/userdata/' . $uuid . ".yml";
        $A = Spyc::YAMLLoad($path);
        $existing_count = umc_home_count(false, $uuid);
        if ($existing_count > 0) {
            continue;
        }
        if (!isset($A['homes'])) {
            continue;
        }
        $count = count($A['homes']);
        if ($count == 0) {
            continue;
        }
        $H = $A['homes'];
        // iterate homes and import them
        foreach ($H as $home_name => $h) {
            $name = umc_mysql_real_escape_string($home_name);
            // XMPP_ERROR_trigger($h);
            $sql = "INSERT INTO minecraft_srvr.`homes`(`name`, `uuid`, `world`, `x`, `y`, `z`, `yaw`) VALUES " . "({$name},'{$uuid}','{$h['world']}','{$h['x']}','{$h['y']}','{$h['z']}','{$h['yaw']}');";
            umc_mysql_query($sql, true);
        }
        umc_log('home', 'import', "{$uuid}/{$username} {$count} homes have been imported!");
    }
}
コード例 #2
0
function umc_get_userinfo($user_raw)
{
    $username = strtolower($user_raw);
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    // get registration date from Wordpress
    $uuid = umc_user2uuid($username);
    $user['uuid'] = $uuid;
    // get userlevel, balance, onlinetime
    $sql = "SELECT userlevel, onlinetime, lastlogin, lastlogout, username, UUID.UUID, balance, lot_count, firstlogin\r\n        FROM minecraft_srvr.UUID\r\n        LEFT JOIN minecraft_iconomy.mineconomy_accounts ON UUID.`UUID` = mineconomy_accounts.uuid\r\n        WHERE UUID.`UUID` = '{$uuid}'";
    $D = umc_mysql_fetch_all($sql);
    $d = $D[0];
    if ($d['userlevel'] == null) {
        $level = 'Guest';
    } else {
        $level = $d['userlevel'];
    }
    $username_history = umc_uuid_username_history($uuid);
    if ($username_history) {
        $user['Username History'] = $username_history;
    }
    $user['Level'] = $level;
    $user['Last Seen'] = $d['lastlogin'];
    if ($d['onlinetime'] == NULL) {
        $online_time = "n/a";
    } else {
        $online_time = umc_seconds_to_time($d['onlinetime']);
    }
    $firstdate = substr($d['firstlogin'], 0, 10);
    $today_ts = strtotime("now");
    $firsttime_ts = strtotime($firstdate);
    $days = round(abs($today_ts - $firsttime_ts) / 60 / 60 / 24);
    $user['User since'] = "{$firstdate} ({$days} days)";
    if ($firstdate > '2013-11-20') {
        // not all play time recorded
        $user['Online time since 2013-11-20'] = $online_time;
    } else {
        $user['Online time'] = $online_time;
    }
    if ($d['balance'] == NULL) {
        $user['Uncs'] = '0.00';
    } else {
        $user['Uncs'] = number_format($d['balance'], 2, ".", "'");
    }
    $user['First login'] = $d['firstlogin'];
    $homes_count = umc_home_count(false, $uuid);
    $user['Homes count'] = $homes_count;
    $karma = umc_getkarma($user['uuid'], true);
    $user['Karma'] = $karma;
    $lots = umc_user_getlots($uuid);
    $display_lots = array();
    foreach ($lots as $lot => $data) {
        $display_lots[$data['world']][] = $lot;
    }
    foreach ($display_lots as $world => $lots) {
        $World = ucfirst($world);
        if (count($lots) < 5) {
            $user["{$World} lots"] = implode(", ", $lots);
        } else {
            $user["{$World} lots"] = count($lots) . " lots";
        }
    }
    return $user;
}
コード例 #3
0
ファイル: home.inc.php プロジェクト: dani0010/uncovery_me
function umc_home_import()
{
    global $UMC_USER;
    // we automatically import old homes for all players on login, but only once
    $existing_count = umc_home_count();
    if ($existing_count > 0) {
        return;
    }
    // include spyc to parse YAML https://github.com/mustangostang/spyc
    require_once '/home/includes/spyc/Spyc.php';
    $path = '/home/minecraft/server/bukkit/plugins/Essentials/userdata/' . $UMC_USER['uuid'] . ".yml";
    $A = Spyc::YAMLLoad($path);
    if (!isset($A['homes']) || count($A['homes']) == 0) {
        return;
    }
    $H = $A['homes'];
    // iterate homes and import them
    foreach ($H as $home_name => $h) {
        $name = umc_mysql_real_escape_string($home_name);
        // XMPP_ERROR_trigger($h);
        $sql = "INSERT INTO minecraft_srvr.`homes`(`name`, `uuid`, `world`, `x`, `y`, `z`, `yaw`) VALUES " . "({$name},'{$UMC_USER['uuid']}','{$h['world']}','{$h['x']}','{$h['y']}','{$h['z']}','{$h['yaw']}');";
        umc_mysql_query($sql, true);
    }
    umc_log('homes', 'import', "{$UMC_USER['uuid']}/{$UMC_USER['username']}homes have been imported!");
}