Пример #1
0
 /**
  * Gathers the population for all servers
  *
  * @param $id
  *
  * @return array
  */
 public function chat($id)
 {
     $chat = Chat::with('player')->where('ServerID', $id);
     if (Input::has('nospam') && Input::get('nospam') == 1) {
         $chat = $chat->excludeSpam();
     }
     if (Input::has('sb') && Input::get('sb') == 1) {
         $chat = $chat->orderBy('logDate', 'desc')->take(100)->get();
     } else {
         $chat = $chat->simplePaginate(30);
     }
     return MainHelper::response($chat, null, null, null, false, true);
 }
Пример #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;
 }
Пример #3
0
 /**
  * Returns the player chatlogs
  * @param  integer $id    Player ID
  * @param  integer $limit Results to return
  * @return object
  */
 public function getPlayerChat($id, $limit = 30)
 {
     $chatlogs = Chat::with('server')->where('logPlayerID', $id)->excludeSpam()->orderBy('logDate', 'desc');
     // If a server is specifed then we only pull logs from that server
     if (Input::has('server')) {
         $serverId = Input::get('server', null);
         if (!is_null($serverId) && is_numeric($serverId) && $serverId > 0) {
             $chatlogs->where('ServerID', $serverId);
         }
     }
     // If user has entered keywords only pull logs that contain those keywords
     if (Input::has('keywords')) {
         $keywords = trim(Input::get('keywords', null));
         if (!is_null($keywords) && $keywords != '') {
             // Remove spaces before and after the comma
             $keywords = preg_replace('/\\s*,\\s*/', ',', $keywords);
             // Explode into an array
             $keywords = explode(',', $keywords);
             $chatlogs->where(function ($query) use($keywords) {
                 foreach ($keywords as $keyword) {
                     $query->orWhere('logMessage', 'LIKE', '%' . $keyword . '%');
                 }
             });
         }
     }
     return $chatlogs->paginate($limit);
 }
Пример #4
0
 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;
 }