Esempio n. 1
0
 /**
  * Shows the player profile
  *
  * @param  integer $id
  * @param  string  $name
  */
 public function profile($id, $name = '')
 {
     // Cache key
     $key = sprintf('player.%u', $id);
     // Is there already a cached version for the player
     $isCached = Cache::has($key);
     // Get or Set cache for player
     $player = Cache::remember($key, 5, function () use($id) {
         $json = $this->repository->setopts(['ban.previous.server', 'ban.record.server', 'reputation', 'infractionsGlobal', 'infractionsServer.server', 'stats.server', 'specialGroups'], true)->getPlayerById($id)->toJson();
         return json_decode($json);
     });
     $charts = Cache::remember(sprintf('player.%u.charts', $id), 5, function () use($id) {
         $charts = [];
         $charts['overview'] = new Collection(DB::select(File::get(storage_path() . '/sql/playerCommandOverview.sql'), [$id]));
         $charts['spline'] = new Collection(DB::select(File::get(storage_path() . '/sql/playerCommandHistory.sql'), [$id]));
         $charts['aliases'] = Record::where('command_type', 48)->where('target_id', $id)->select(DB::raw('record_message AS `player_name`, COUNT(record_id) AS `seen`'))->groupBy('player_name')->get();
         $charts['iphistory'] = Record::where('command_type', 49)->where('target_id', $id)->where('record_message', '!=', 'No previous IP on record')->select(DB::raw('record_message AS `ip`, COUNT(record_id) AS `seen`'))->groupBy('ip')->get();
         $charts['overview'] = $charts['overview']->map(function ($command) {
             return [$command->label, intval($command->value)];
         });
         $charts['aliases'] = $charts['aliases']->map(function ($a) {
             return [$a->player_name, intval($a->seen)];
         });
         $charts['iphistory'] = $charts['iphistory']->map(function ($ip) {
             return [$ip->ip, intval($ip->seen)];
         });
         return $charts;
     });
     $groups = MainHelper::specialGroups($player->special_groups, 'player_group');
     $page_title = !empty($player->ClanTag) ? sprintf('[%s] %s', $player->ClanTag, $player->SoldierName) : $player->SoldierName;
     return View::make('player.profile', compact('player', 'page_title', 'charts', 'isCached', 'groups'));
 }
Esempio n. 2
0
 /**
  * Logs action to database
  *
  * @param string|Player $target
  * @param string        $command
  * @param string        $message
  * @param int           $duration
  * @param bool|true     $sys
  *
  * @return \BFACP\Adkats\Record
  */
 private function log($target, $command, $message = 'No Message', $duration = 0, $sys = true)
 {
     $timestamp = Carbon::now();
     $command = Command::where('command_key', $command)->first();
     if (!$command) {
         throw new RconException(500, 'Invalid command type');
     }
     if (!$target instanceof Player && is_string($target) && !in_array($command->command_key, ['server_nuke'])) {
         $target = Player::where('GameID', $this->gameID)->where('SoldierName', $target)->first();
     }
     if ($target instanceof Player) {
         $target_name = $target->SoldierName;
         $target_id = $target->PlayerID;
     } else {
         $target_name = is_null($target) ? 'Server' : $target;
         $target_id = null;
     }
     if ($this->admin instanceof Player) {
         $source_name = $this->admin->SoldierName;
         $source_id = $this->admin->PlayerID;
     } else {
         $source_name = $this->user->username;
         $source_id = null;
     }
     $data = [];
     if ($command->command_key == 'admin_say') {
         $data['chat'] = Chat::create(['ServerID' => $this->serverID, 'logDate' => $timestamp, 'logMessage' => $message, 'logPlayerID' => $source_id, 'logSoldierName' => $source_name, 'logSubset' => 'Global']);
         if ($this->admin instanceof Player) {
             $data['chat']['player'] = $this->admin;
         }
     }
     $record = new Record();
     $record->adkats_read = $sys ? 'Y' : 'N';
     $record->adkats_web = true;
     $record->command_action = $command->command_id;
     $record->command_type = $command->command_id;
     $record->command_numeric = $duration;
     $record->record_message = $message;
     $record->record_time = $timestamp;
     $record->server_id = $this->serverID;
     $record->source_name = $source_name;
     $record->source_id = $source_id;
     $record->target_name = $target_name;
     $record->target_id = $target_id;
     $record->save();
     $data['record'] = $record;
     return $data;
 }
Esempio n. 3
0
 /**
  * Returns the player record history
  * @param  integer $id    Player ID
  * @param  integer $limit Results to return
  * @return object
  */
 public function getPlayerRecords($id, $limit = 25)
 {
     $records = Record::with('target', 'source', 'type', 'action')->orderBy('record_time', 'desc')->whereNotIn('command_type', [48, 49, 85, 86])->where(function ($query) use($id) {
         $query->where('target_id', $id);
         $query->orWhere('source_id', $id);
     });
     // If a command id is present we are going to only pull records
     // that have the specific id
     if (Input::has('cmdid')) {
         $cmdid = Input::get('cmdid', null);
         // Make sure the input is a number and greater than zero
         if (!is_null($cmdid) && is_numeric($cmdid) && $cmdid > 0) {
             $records->where(function ($query) use($cmdid) {
                 $query->where('command_type', $cmdid);
                 $query->orWhere('command_action', $cmdid);
             });
         }
     }
     return $records->paginate($limit);
 }
Esempio n. 4
0
 /**
  * Fetchs special records to be applyed to the reputation values
  * @return mixed
  */
 public function special()
 {
     $records = Record::select(DB::raw('command_type, command_action, COUNT(record_id) AS command_count'))->where('source_id', $this->player->PlayerID)->where('target_id', $this->player->PlayerID)->where('command_type', 51)->where('command_action', 51)->groupBy('command_type')->groupBy('command_action')->get();
     foreach ($records as $record) {
         $command = sprintf('%u|%u', $record->command_type, $record->command_action);
         foreach ($this->weights as $weight) {
             if ($command == $weight['command_typeaction']) {
                 $this->sourceReputation += $weight['source_weight'] * $record->command_count;
                 $this->targetReputation += $weight['target_weight'] * $record->command_count;
                 break;
             }
         }
     }
     return $this;
 }
 private function log($player, $command, $message = 'No Message', $duration = 0, $sys = true)
 {
     $timestamp = Carbon::now();
     if (!is_null($player)) {
         $player = Player::where('GameID', $this->gameID)->where('SoldierName', $player)->first();
     }
     $command = Command::where('command_key', $command)->first();
     if ($command == 'admin_say') {
         Chat::create(['ServerID' => $this->serverID, 'logDate' => $timestamp, 'logMessage' => $message, 'logPlayerID' => is_null($this->admin) ? null : $this->admin->PlayerID, 'logSoldierName' => is_null($this->admin) ? $this->user->username : $this->admin->SoldierName, 'logSubset' => 'Global']);
     }
     $record = new Record();
     $record->adkats_read = $sys ? 'Y' : 'N';
     $record->adkats_web = true;
     $record->command_action = $command->command_id;
     $record->command_type = $command->command_id;
     $record->command_numeric = $duration;
     $record->record_message = $message;
     $record->record_time = $timestamp;
     $record->server_id = $this->serverID;
     $record->source_name = is_null($this->admin) ? $this->user->username : $this->admin->SoldierName;
     $record->source_id = is_null($this->admin) ? null : $this->admin->PlayerID;
     $record->target_name = is_null($player) ? 'Server' : $player->SoldierName;
     $record->target_id = is_null($player) ? null : $player->PlayerID;
     $record->save();
     return $record;
 }
Esempio n. 6
0
 /**
  * Get's a report by its ID
  *
  * @param  integer $id
  *
  * @return object
  */
 public function getReportById($id)
 {
     return Record::with('server', 'type', 'action')->whereIn('command_type', [18, 20])->findOrFail($id);
 }