public function putIndex() { if (!$this->isLoggedIn || !$this->user->ability(null, 'admin.adkats.reports.edit')) { throw new AccessDeniedHttpException('Authorization Denied!'); } $r = App::make('BFACP\\Repositories\\ReportRepository'); $v = Validator::make(Input::all(), ['id' => 'required|numeric|exists:adkats_records_main,record_id', 'action' => 'required|numeric|in:' . implode(',', $r::$allowedCommands), 'reason' => 'required|string|between:3,500', 'extras.tban.duration' => 'required_if:action,7|numeric|between:1,525960'], ['extras.tban.duration.required_if' => 'The duration is required for temp bans.', 'extras.tban.duration.between' => 'The duration must be between :min minute and :max minutes.']); if ($v->fails()) { throw new ResourceException(null, $v->errors()); } try { $record = $r->getReportById(Input::get('id')); if (!in_array($record->command_action, [18, 20])) { throw new UpdateResourceFailedException('Unable to complete action. Report has already been acted on.'); } // If the action is {Accept, Deny, Ignore} Round Report then we just need to update the existing record. if (in_array(Input::get('action'), [40, 41, 61])) { $record->command_action = Input::get('action'); $record->save(); } else { $newRecord = $record->replicate(); $newRecord->command_type = Input::get('action'); $newRecord->command_action = Input::get('action'); if (Input::get('action') == 7) { $maxDuration = Setting::where('setting_name', 'Maximum Temp-Ban Duration Minutes')->where('server_id', 1)->pluck('setting_value'); $duration = Input::get('extras.tban.duration', $maxDuration); $commandNumeric = (int) $duration > (int) $maxDuration ? $maxDuration : $duration; } else { $commandNumeric = 0; } $newRecord->command_numeric = $commandNumeric; $newMessage = trim(Input::get('reason', $newRecord->record_message)); $oldMessage = trim($newRecord->record_message); if ($newMessage != $oldMessage && !empty($newMessage)) { $newRecord->record_message = $newMessage; } $source = MainHelper::getAdminPlayer($this->user, $newRecord->server->game->GameID); if (!is_null($source)) { $newRecord->source_id = $source->PlayerID; $newRecord->source_name = $source->SoldierName; } else { $newRecord->source_id = null; $newRecord->source_name = $this->user->username; } $newRecord->record_time = Carbon::now(); $newRecord->adkats_read = 'N'; $newRecord->save(); $record->command_action = 40; $record->save(); } return MainHelper::response(['old' => $record, 'new' => isset($newRecord) ? $newRecord : null], 'Report updated', null, null, false, true); } catch (ModelNotFoundException $e) { return MainHelper::response(null, 'Report was not found. Aborting!', 'error', null, false, true); } }
public function edit($id) { $settings = Setting::where('server_id', $id)->get(); return View::make('admin.adkats.settings.edit', compact('settings'))->with('page_title', sprintf('AdKats Settings for #%s', $id)); }
/** * Gathers the server information * * @return $this */ private function serverinfo() { $info = $this->client->getServerInfo(); $this->serverinfo = $info; $length = count($info); if ($this->gameName == 'BF4') { switch ($info[4]) { case 'SquadDeathMatch0': case 'TeamDeathMatch0': $ticketcap = $length < 28 ? null : intval($info[13]); $uptime = $length < 28 ? (int) $info[14] : (int) $info[18]; $round = $length < 28 ? (int) $info[15] : (int) $info[19]; break; case 'CaptureTheFlag0': case 'Obliteration': case 'Chainlink0': case 'RushLarge0': case 'Domination0': case 'ConquestLarge0': case 'ConquestSmall0': if ($info[4] == 'CaptureTheFlag0') { $ticketcap = null; } else { $ticketcap = $length < 26 ? null : intval($info[11]); } $uptime = $length < 26 ? (int) $info[14] : (int) $info[16]; $round = $length < 26 ? (int) $info[15] : (int) $info[17]; break; default: $ticketcap = null; $uptime = -1; $round = -1; break; } } elseif ($this->gameName == 'BF3') { switch ($info[4]) { case 'SquadDeathMatch0': case 'TeamDeathMatch0': $ticketcap = $length < 25 ? null : intval($info[11]); $uptime = $length < 25 ? (int) $info[12] : (int) $info[16]; $round = $length < 25 ? (int) $info[13] : (int) $info[17]; break; case 'CaptureTheFlag0': case 'Obliteration': case 'Chainlink0': case 'RushLarge0': case 'Domination0': case 'ConquestLarge0': case 'ConquestSmall0': if ($info[4] == 'CaptureTheFlag0') { $ticketcap = null; } else { $ticketcap = $length < 25 ? null : intval($info[11]); } $uptime = $length < 25 ? (int) $info[12] : (int) $info[16]; $round = $length < 25 ? (int) $info[13] : (int) $info[17]; break; default: $ticketcap = null; $uptime = -1; $round = -1; break; } } elseif ($this->gameName == 'BFHL') { switch ($info[4]) { case 'TurfWarLarge0': case 'TurfWarSmall0': case 'Heist0': case 'Hotwire0': case 'BloodMoney0': case 'Hit0': case 'Hostage0': case 'TeamDeathMatch0': case 'CashGrab0': $ticketcap = $length < 25 ? null : intval($info[11]); $uptime = $length < 25 ? (int) $info[14] : (int) $info[16]; $round = $length < 25 ? (int) $info[15] : (int) $info[17]; break; default: $ticketcap = null; $uptime = -1; $round = -1; break; } } if (method_exists($this->client, 'adminVarGetRoundTimeLimit')) { $startingTimer = BattlefieldHelper::roundStartingTimer($info[4], $this->client->adminVarGetRoundTimeLimit(), $this->gameName); } else { $startingTimer = 0; } if (method_exists($this->client, 'adminVarGetGameModeCounter')) { $startingTickets = BattlefieldHelper::startingTickets($info[4], $this->client->adminVarGetGameModeCounter(), $this->gameName); } else { $startingTickets = 0; } if ($this->isLoggedIn) { $presetMessages = Setting::servers($this->serverID)->settings('Pre-Message List')->first()->setting_value; } $_playmode = $this->client->getPlaymodeName($info[4]); $_map = $this->client->getMapName($info[5]); $this->data['server'] = ['name' => $info[1], 'description' => trim($this->client->adminVarGetServerDescription()), 'type' => method_exists($this->client, 'adminVarGetServerType') ? $this->client->adminVarGetServerType() : null, 'isNoobOnly' => method_exists($this->client, 'adminVarGetNoobJoin') ? $this->client->adminVarGetNoobJoin() : null, 'game' => $this->server->game, 'players' => ['online' => (int) $info[2], 'max' => (int) $info[3], 'spectators' => 0, 'commanders' => 0, 'queue' => $this->server->in_queue], 'mode' => ['name' => !is_string($_playmode) ? head($_playmode) : $_playmode, 'uri' => $info[4]], 'map' => ['name' => !is_string($_map) ? head($_map) : $_map, 'uri' => $info[5], 'next' => $this->getNextMap(), 'images' => $this->server->map_image_paths], 'tickets_needed' => $ticketcap, 'tickets_starting' => $startingTickets, 'round_duration' => $startingTimer, 'times' => ['round' => ['humanize' => MainHelper::secToStr($round, true), 'seconds' => (int) $round], 'uptime' => ['humanize' => MainHelper::secToStr($uptime, true), 'seconds' => (int) $uptime], 'remaining' => ['humanize' => $info[2] >= 4 ? MainHelper::secToStr($startingTimer - $round, true) : 'PreMatch', 'seconds' => $info[2] >= 4 ? $startingTimer - $round : $startingTimer]]]; $this->setFactions(); $this->data['_presetmessages'] = isset($presetMessages) ? [''] + $presetMessages : []; $this->data['_teams'] = [['id' => 1, 'label' => sprintf('%s (%s)', $this->TEAM1['full_name'], 'Team 1')], ['id' => 2, 'label' => sprintf('%s (%s)', $this->TEAM2['full_name'], 'Team 2')], ['id' => 3, 'label' => sprintf('%s (%s)', $this->TEAM3['full_name'], 'Team 3')], ['id' => 4, 'label' => sprintf('%s (%s)', $this->TEAM4['full_name'], 'Team 4')]]; return $this; }
/** * Gets the next punishment name * * @param string|null $key * @param integer|null $index * @param integer|null $serverid * * @return string|null */ public function getNextPunishment($key, $index = null, $serverid = null) { try { // If the index is less than 1 just return false if ($index < 1) { return false; } if (!is_null($index) && !is_null($serverid)) { $settings = AdKatsSetting::servers($serverid)->settings('Punishment Hierarchy')->first(); $key = $settings->setting_value[$index]; } $hierarchy = ['warn' => 'Warn', 'kill' => 'Kill', 'kick' => 'Kick', 'tban60' => 'Temp-Ban 1 Hour', 'tban120' => 'Temp-Ban 2 Hours', 'tbanday' => 'Temp-Ban 1 Day', 'tbanweek' => 'Temp-Ban 1 Week', 'tban2weeks' => 'Temp-Ban 2 Weeks', 'tbanmonth' => 'Temp-Ban 1 Month', 'ban' => 'Perma-Ban']; if (array_key_exists($key, $hierarchy)) { return $hierarchy[$key]; } } catch (Exception $e) { } return null; }