/** * 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); }
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 }
function umc_ts_authorize() { global $UMC_USER, $UMC_TEAMSPEAK; // include libraries require_once '/home/uncovery/teamspeak_php/libraries/TeamSpeak3/TeamSpeak3.php'; // connect to server if (!$UMC_TEAMSPEAK['server']) { $UMC_TEAMSPEAK['server'] = TeamSpeak3::factory("serverquery://*****:*****@74.208.45.80:10011/?server_port=9987"); } // get client by name $uuid = $UMC_USER['uuid']; $userlevel = $UMC_USER['userlevel']; $username = $UMC_USER['username']; // get required servergroup foreach ($UMC_TEAMSPEAK['user_groups'] as $g_id => $usergroups) { if (in_array($userlevel, $usergroups)) { $target_group = $g_id; break; } } // first, we see if there is a current user logged in $ts_Client = false; umc_header(); // first, we clean out old clients that are registered with minecraft umc_ts_clear_rights($uuid, true); // then, we try to find a new user on the TS server to give rights to umc_echo("Your TS level is " . $UMC_TEAMSPEAK['ts_groups'][$target_group]); umc_echo("Looking for user {$username} in TS..."); $found = 0; foreach ($UMC_TEAMSPEAK['server']->clientList() as $ts_Client) { if ($ts_Client["client_nickname"] == $username) { $found++; } } if ($found == 0) { umc_echo("You need to logon to Teamspeak with the EXACT same username (\"{$username}\")"); umc_echo("Once you did that, please try again"); umc_footer(); return false; } else { if ($found > 1) { umc_echo("There are 2 users with the same username (\"{$username}\") online."); umc_echo("Process halted. Make sure you are the only one with the correct username"); umc_echo("If there is someone else hogging your username, please send in a /ticket"); umc_footer(); return false; } } // we have a user umc_echo("Found TS user " . $ts_Client["client_nickname"]); $ts_dbid = $ts_Client["client_database_id"]; // remove all groups $servergroups = array_keys($UMC_TEAMSPEAK['server']->clientGetServerGroupsByDbid($ts_dbid)); foreach ($servergroups as $sgid) { umc_echo($ts_Client["client_nickname"] . " is member of group " . $UMC_TEAMSPEAK['ts_groups'][$sgid]); if ($sgid != $target_group && $sgid != 8) { umc_echo("Removing usergroup {$sgid}..."); $UMC_TEAMSPEAK['server']->serverGroupClientDel($sgid, $ts_dbid); // remove user from group } else { if ($sgid == $target_group) { umc_echo("Not removing usergroup {$sgid}..."); $target_group = false; } } } // add the proper group if ($target_group) { // add target group of required umc_echo("Adding you to group " . $UMC_TEAMSPEAK['ts_groups'][$target_group]); $ts_Client->addServerGroup($target_group); } // get UUID $target_ts_uuid = $ts_Client["client_unique_identifier"]; $ts_uuid = umc_mysql_real_escape_string($target_ts_uuid); $ins_sql = "UPDATE minecraft_srvr.UUID SET ts_uuid={$ts_uuid} WHERE UUID='{$uuid}';"; umc_mysql_query($ins_sql, true); umc_echo("Adding TS ID {$ts_uuid} to database"); umc_footer("Done!"); }
/** * 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}"); }
function umc_ts_authorize() { XMPP_ERROR_trace(__FUNCTION__, func_get_args()); global $UMC_USER, $UMC_TEAMSPEAK; umc_ts_connect(); // get client by name $uuid = $UMC_USER['uuid']; $userlevel = $UMC_USER['userlevel']; $username = strtolower($UMC_USER['username']); // get required servergroup foreach ($UMC_TEAMSPEAK['user_groups'] as $g_id => $usergroups) { if (in_array($userlevel, $usergroups)) { $target_group = $g_id; break; } } XMPP_ERROR_trace("target group", $target_group); umc_header(); // first, we clean out old clients that are registered with minecraft umc_ts_clear_rights($uuid, true); XMPP_ERROR_trace("Done clearing old rights"); // then, we try to find a new user on the TS server to give rights to umc_echo("Your TS level is " . $UMC_TEAMSPEAK['ts_groups'][$target_group]); XMPP_ERROR_trace("User TS level is ", $UMC_TEAMSPEAK['ts_groups'][$target_group]); umc_echo("Looking for user {$username} in TS..."); $users = umc_ts_list_users(); $found = 0; // iterate all users to make sure that there are not 2 with the same nickname foreach ($users as $user) { XMPP_ERROR_trace("comparing user {$username} to ", $user); if ($user == $username) { $found++; XMPP_ERROR_trace("found user ", $user); } } XMPP_ERROR_trace("found no if users: ", $found); if ($found == 0) { umc_echo("You need to logon to Teamspeak with the EXACT same username (\"{$username}\")"); umc_echo("Once you did that, please try again"); umc_footer(); return false; } else { if ($found > 1) { umc_echo("There are 2 users with the same username (\"{$username}\") online."); umc_echo("Process halted. Make sure you are the only one with the correct username"); umc_echo("If there is someone else hogging your username, please send in a /ticket"); umc_footer(); return false; } } // we have a user $ts_Client = $UMC_TEAMSPEAK['server']->clientGetByName($username); $ts_dbid = $ts_Client["client_database_id"]; // remove all groups $servergroups = array_keys($UMC_TEAMSPEAK['server']->clientGetServerGroupsByDbid($ts_dbid)); foreach ($servergroups as $sgid) { umc_echo($ts_Client["client_nickname"] . " is member of group " . $UMC_TEAMSPEAK['ts_groups'][$sgid]); if ($sgid != $target_group && $sgid != 8) { umc_echo("Removing usergroup {$sgid}..."); $UMC_TEAMSPEAK['server']->serverGroupClientDel($sgid, $ts_dbid); // remove user from group } else { if ($sgid == $target_group) { umc_echo("Not removing usergroup {$sgid}..."); $target_group = false; } } } // add the proper group if ($target_group) { // add target group of required umc_echo("Adding you to group " . $UMC_TEAMSPEAK['ts_groups'][$target_group]); $ts_Client->addServerGroup($target_group); } // get UUID $target_ts_uuid = $ts_Client["client_unique_identifier"]; $ts_uuid = umc_mysql_real_escape_string($target_ts_uuid); $ins_sql = "UPDATE minecraft_srvr.UUID SET ts_uuid={$ts_uuid} WHERE UUID='{$uuid}';"; umc_mysql_query($ins_sql, true); umc_echo("Adding TS ID {$ts_uuid} to database"); umc_footer("Done!"); }