function umc_get_member_form($lot, $form = false) { XMPP_ERROR_trace(__FUNCTION__, func_get_args()); global $UMC_USER; $username = $UMC_USER['username']; $members = umc_get_active_members(); $lot_members = umc_get_lot_members($lot); $out = ''; if ($lot_members) { if ($form) { $out .= '<br>Check members you want to remove: '; } // make a form where existing members can be removed foreach ($lot_members as $UUID => $member) { // remoe all inactive members from the lot if (!isset($members[$UUID])) { XMPP_ERROR_trace("Removing inactive player {$UUID} from lot, list of active members:", $members); umc_lot_rem_player($UUID, $lot, 0); } if ($form) { $out .= "{$member} <input type=\"checkbox\" name=\"remove_member[{$UUID}]\">;"; } else { $out .= "{$member}; "; } } } else { $out .= "No members"; } if (!$form) { return $out; } $out .= "<br>Add member: <select name=\"new_member\">" . "<option value=\"none\">- none -</option>\n"; foreach ($members as $member) { // do not add the lot owner if ($member == $username) { continue; } // do not add existing members again if (!$lot_members || !in_array($member, $lot_members)) { $out .= "<option value=\"{$member}\">{$member}</option>\n"; } } $out .= "</select>"; return $out; }
function umc_lot_addrem() { global $UMC_USER; $player = $UMC_USER['username']; $args = $UMC_USER['args']; /// /lotmember lot world add target if (count($args) <= 3) { umc_echo("{red}Not enough arguments given"); umc_show_help($args); return; } $addrem = $args[1]; $lot = strtolower($args[2]); $action = $args[3]; $worlds = array('emp' => 'empire', 'fla' => 'flatlands', 'dar' => 'darklands', 'aet' => 'aether', 'kin' => 'kingdom', 'dra' => 'draftlands', 'blo' => 'skyblock', 'con' => 'aether'); $world_abr = substr($lot, 0, 3); if (!isset($worlds[$world_abr])) { umc_error("Your used an invalid lot name!"); } $world = $worlds[$world_abr]; if ($player == '@Console') { $player = 'uncovery'; } $user_id = umc_get_worldguard_id('user', strtolower($player)); if (!$user_id) { umc_error("Your user id cannot be found!"); } $player_group = umc_get_userlevel($player); $world_id = umc_get_worldguard_id('world', $world); if (!$world_id) { umc_show_help($args); umc_error("The lot '{$lot}' cannot be found in any world!"); } if (!umc_check_lot_exists($world_id, $lot)) { umc_show_help($args); umc_error("There is no lot {$lot} in world {$world}!"); } if ($action == 'snow' || $action == 'ice') { // check if the user has DonatorPlus status. if ($player_group !== 'Owner') { if (!stristr($player_group, 'DonatorPlus')) { umc_error("You need to be DonatorPlus level to use the snow/ice features!;"); } $owner_switch = 0; // check if player is Owner of lot $sql = "SELECT * FROM minecraft_worldguard.region_players WHERE region_id='{$lot}' AND world_id={$world_id} AND user_id={$user_id} and Owner=1;"; $D = umc_mysql_fetch_all($sql); $num = count($D); if ($num != 1) { umc_error("It appears you {$player} ({$user_id}) are not Owner of lot {$lot} in world {$world}!"); } } // get the current status of the flags if ($addrem == 'add') { $flag = 'allow'; umc_echo("Allowing {$action} forming on lot {$lot}... "); } else { if ($addrem == 'rem') { $flag = 'deny'; umc_echo("Preventing {$action} forming on lot {$lot}... "); } else { umc_show_help($args); } } if ($action == 'snow') { $flagname = 'snow-fall'; } else { if ($action == 'ice') { $flagname = 'ice-form'; } } // does flag exist? $check_sql = "SELECT * FROM minecraft_worldguard.region_flag WHERE region_id='{$lot}' AND world_id={$world_id} AND flag='{$flagname}';"; $D2 = umc_mysql_fetch_all($check_sql); $count = count($D2); if ($count == 0) { // insert $ins_sql = "INSERT INTO minecraft_worldguard.region_flag (region_id, world_id, flag, value) VALUES ('{$lot}', {$world_id}, '{$flagname}', '{$flag}');"; umc_mysql_query($ins_sql, true); } else { // update $upd_sql = "UPDATE minecraft_worldguard.region_flag SET value='{$flag}' WHERE region_id='{$lot}' AND world_id={$world_id} AND flag='{$flagname}';"; umc_mysql_query($upd_sql, true); } umc_echo("done!"); umc_log('lot', 'addrem', "{$player} changed {$action} property of {$lot}"); } else { if ($action == 'owner' || $action == 'give') { if ($player != 'uncovery' && $player != '@Console') { umc_error("Nice try, {$player}. Think I am stupid? Want to get banned?"); } $owner_switch = 1; } else { if ($action == 'member') { $user_id = umc_get_worldguard_id('user', strtolower($player)); if (!$user_id && $player !== 'uncovery') { umc_error("Your user id cannot be found!"); } $owner_switch = 0; // check if player is Owner of lot if ($player_group !== 'Owner') { $sql = "SELECT * FROM minecraft_worldguard.region_players WHERE region_id='{$lot}' AND world_id={$world_id} AND user_id={$user_id} and Owner=1;"; $D3 = umc_mysql_fetch_all($sql); $count = count($D3); if ($count != 1) { umc_error("It appears you ({$player} {$user_id}) are not Owner of lot {$lot} in world {$world}!"); } } } else { umc_echo("Action {$action} not recognized!"); umc_show_help($args); return; } } // get list of active users $active_users = umc_get_active_members(); for ($i = 4; $i < count($args); $i++) { $target = strtolower($args[$i]); // check if target player exists $target_id = umc_get_worldguard_id('user', strtolower($target)); if (!$target_id) { umc_error("The user {$target} does not exist in the database. Please check spelling of username"); } if ($player != 'uncovery') { $targ_group = umc_get_userlevel($target); if ($targ_group == 'Guest') { umc_error("You cannnot add Guests to your lot!;"); } else { if (!in_array($target, $active_users)) { XMPP_ERROR_trigger("{$player} tried to add {$target} to his lot {$lot}, but {$target} is not an active member!"); umc_error("{$target} is not an active user! You can only add people who have their own lot! See FAQ entry #32 please."); } } } // add / remove target player from lot if ($addrem == 'add') { // make sure target is not already there $sql = "SELECT * FROM minecraft_worldguard.region_players WHERE region_id='{$lot}' AND world_id={$world_id} AND user_id={$target_id};"; $D3 = umc_mysql_fetch_all($sql); $num = count($D3); if ($num == 1) { umc_error("It appears {$target} is already member of lot {$lot} in world {$world}!"); } // add to the lot umc_lot_add_player($target, $lot, 0); umc_echo("Added {$target} to {$lot} in the {$world}!"); } else { if ($addrem == 'rem') { // check if target is there at all $sql = "SELECT * FROM minecraft_worldguard.region_players WHERE region_id='{$lot}' AND world_id={$world_id} AND user_id={$target_id} AND Owner={$owner_switch} LIMIT 1;"; $D3 = umc_mysql_fetch_all($sql); $num = count($D3); if ($num !== 1) { umc_error("It appears user {$target} is not a member of lot {$lot} in world {$world}!"); } umc_lot_rem_player($target, $lot, 0); umc_echo("Removed {$target} from {$lot} in the {$world}!"); } else { if ($addrem == 'give') { // remove all members and owners umc_lot_remove_all($lot); umc_lot_add_player($target, $lot, 1); umc_echo("Gave {$lot} to {$target} in the {$world}! All other user removed!"); // logfile entry umc_log('lot', 'addrem', "{$player} gave lot to {$target}"); } else { umc_show_help($args); } } } } } umc_ws_cmd("region load -w {$world}", 'asConsole'); }