public function update($id) { try { $server = Server::findOrFail($id); $setting = $server->setting; if (Input::has('rcon_password') && !empty(trim(Input::get('rcon_password')))) { $password = Input::get('rcon_password'); $setting->rcon_password = trim($password); } if (Input::has('filter')) { $chars = array_map('trim', explode(',', Input::get('filter'))); $setting->filter = implode(',', $chars); } else { $setting->filter = null; } if (Input::has('battlelog_guid')) { $setting->battlelog_guid = trim(Input::get('battlelog_guid')); } else { $setting->battlelog_guid = null; } $setting->save(); $server->ConnectionState = Input::get('status', 'off'); $server->save(); return Redirect::route('admin.site.servers.index')->with('messages', [sprintf('Successfully Updated %s', $server->ServerName)]); } catch (ModelNotFoundException $e) { return Redirect::route('admin.site.servers.index')->withErrors(['Server doesn\'t exist.']); } }
public function __construct() { parent::__construct(); $permissions = Cache::get('admin.perm.list'); if (!$this->isLoggedIn || !$this->user->ability(null, $permissions['scoreboard'])) { throw new AccessDeniedHttpException(); } $id = Input::get('server_id'); if (!is_numeric($id) || !filter_var($id, FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]])) { throw new NotFoundHttpException('Invalid Server ID'); } try { $this->server = Server::findOrFail($id); } catch (ModelNotFoundException $e) { throw new NotFoundHttpException(sprintf('No server found with id of %s.', $id)); } $this->repository = App::make('BFACP\\Repositories\\Scoreboard\\LiveServerRepository', [$this->server])->attempt(); if (Input::has('players')) { $this->players = array_map('trim', explode(',', Input::get('players'))); } }
public function scoreboardAdmin() { try { $id = Input::get('server_id'); if (!is_numeric($id) || $id <= 0) { throw new NotFoundHttpException('Invalid Server ID'); } $allowedMethods = ['yell', 'say', 'kill', 'move', 'kick', 'punish']; $permissions = Cache::get('admin.perm.list'); if (!Input::has('method') || !in_array(Input::get('method'), $allowedMethods)) { throw new NotFoundHttpException(); } if (!$this->isLoggedIn || !$this->user->ability(null, $permissions['scoreboard'])) { throw new AccessDeniedHttpException(); } $scoreboard = new LiveServerRepository(Server::findOrFail($id)); if ($scoreboard->attempt()->check()) { $players = []; if (Input::has('players')) { $players = explode(',', Input::get('players')); } switch (Input::get('method')) { case 'yell': $this->hasPermission('admin.scoreboard.yell'); if (Input::get('type') == 'Player' && Input::has('players')) { foreach ($players as $player) { $scoreboard->adminYell(Input::get('message', null), $player, null, Input::get('duration', 5), 'Player'); } } else { $scoreboard->adminYell(Input::get('message', null), Input::get('player', null), Input::get('team', null), Input::get('duration', 5), Input::get('type', 'All')); } break; case 'say': $this->hasPermission('admin.scoreboard.say'); if (Input::get('type') == 'Player' && Input::has('players')) { foreach ($players as $player) { $scoreboard->adminSay(Input::get('message', null), $player, null, 'Player'); } } else { $scoreboard->adminSay(Input::get('message', null), Input::get('player', null), Input::get('team', null), Input::get('type', 'All')); } break; case 'kill': $this->hasPermission('admin.scoreboard.kill'); if (Input::has('players')) { $unkilled = []; foreach ($players as $player) { try { $scoreboard->adminKill($player, Input::get('message', null)); } catch (PlayerNotFoundException $e) { $unkilled[] = ['name' => $player, 'reason' => $e->getMessage()]; } } if (!empty($unkilled)) { $data = $unkilled; } } else { throw new RconException(400, 'No players selected.'); } break; case 'kick': $this->hasPermission('admin.scoreboard.kick'); if (Input::has('players')) { $unkicked = []; foreach ($players as $player) { try { $scoreboard->adminKick($player, Input::get('message', null)); } catch (PlayerNotFoundException $e) { $unkicked[] = ['name' => $player, 'reason' => $e->getMessage()]; } } if (!empty($unkicked)) { $data = $unkicked; } } else { throw new RconException(400, 'No player selected.'); } break; case 'move': $this->hasPermission('admin.scoreboard.teamswitch'); if (Input::has('players')) { $unmoved = []; foreach ($players as $player) { try { $scoreboard->adminMovePlayer($player, Input::get('team', null), Input::get('squad', null)); } catch (PlayerNotFoundException $e) { $unmoved[] = ['name' => $player, 'reason' => $e->getMessage()]; } catch (RconException $e) { $unmoved[] = ['name' => $player, 'reason' => $e->getMessage()]; } } if (!empty($unmoved)) { $data = $unmoved; } } else { throw new RconException(400, 'No player selected.'); } break; case 'punish': $this->hasPermission('admin.scoreboard.punish'); if (Input::has('players')) { foreach ($players as $player) { $data[] = $scoreboard->adminPunish($player, Input::get('message')); } } else { throw new RconException(400, 'No player selected.'); } break; case 'forgive': $this->hasPermission('admin.scoreboard.forgive'); if (Input::has('players')) { foreach ($players as $player) { $scoreboard->adminForgive($player, Input::get('message')); } } else { throw new RconException(400, 'No player selected.'); } break; default: throw new NotFoundHttpException(); } if (!isset($data)) { $data = []; } return MainHelper::response($data, null, null, null, false, true); } } catch (PlayerNotFoundException $e) { return MainHelper::response(null, $e->getMessage(), 'error', null, false, true); } catch (ModelNotFoundException $e) { throw new NotFoundHttpException(sprintf('No server found with id %s', $id)); } catch (Exception $e) { throw $e; } }