<commit_before><?php
namespace App\Http\Controllers\App;

use App\Teamspeak\Server;
use Carbon\Carbon;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use xPaw\SourceQuery\SourceQuery;

class DashboardController extends Controller
{
    public function getIndex()
    {
        return view('app.dashboard.index')->with([
            'dynmarket' => collect(json_decode(\DB::connection('arma')->table('dynmarket')->first()->prices))->unique(0)->sortByDesc(1),
            'a3lserver' => $this->getLife(),
        ]);
    }

    public function getTest()
    {
        \Config::set('app.debug', true);

        dd($this->getTeamspeak());

        abort(403);
    }

    protected function getLife()
    {
        try {
            $sourceQuery = new SourceQuery();
            $sourceQuery->Connect(env('A3L_HOST', ''), env('A3L_PORT', 2303), 1, SourceQuery::SOURCE);
            $a3lInfo = $sourceQuery->GetInfo();
            $a3lPlayers = collect($sourceQuery->GetPlayers());
            $sourceQuery->Disconnect();

            $now = Carbon::now()->setTimezone(config('app.timezone'));
            $restarts = collect([]);
            foreach(config('a3lwebinterface.restarts') as $time) {
                $parts = explode(':', $time);
                $carbon = Carbon::now()->setTimezone(config('app.timezone'))->setTime($parts[0], $parts[1], 0);
                $restarts->put($time, [
                    'carbon' => $carbon,
                    'diff' => $now->diffInSeconds($carbon, false),
                ]);
            }

            $a3lRestart = $restarts->reject(function($restart) {
                return $restart['diff'] <= 0;
            })->sortBy('diff')->first()['carbon'];

            return [
                'info' => $a3lInfo,
                'playersOnline' => $a3lPlayers,
                'restart' => $a3lRestart,
                'online' => true,
            ];
        } catch (\Exception $e) {
            return [
                'info' => null,
                'playersOnline' => 0,
                'restart' => null,
                'online' => false,
            ];
        }
    }

    protected function getTeamspeak()
    {
        $server = new Server();
        $clients = $server->getClients();
        return [
            'server' => $server,
            'clients' => $clients,
        ];
    }
}
<commit_msg>fix ingame messages system<commit_after><?php
namespace App\Http\Controllers\App;

use App\Teamspeak\Server;
use Carbon\Carbon;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use xPaw\SourceQuery\SourceQuery;

class DashboardController extends Controller
{
    public function getIndex()
    {
        return view('app.dashboard.index')->with([
            'dynmarket' => collect(json_decode(\DB::connection('arma')->table('dynmarket')->first()->prices))->unique(0)->sortByDesc(1),
            'a3lserver' => $this->getLife(),
        ]);
    }

    public function getTest()
    {
        \Config::set('app.debug', true);

        dd($this->getTeamspeak());

        abort(403);
    }

    protected function getLife()
    {
        try {
            $sourceQuery = new SourceQuery();
            $sourceQuery->Connect(env('A3L_HOST', ''), env('A3L_PORT', 2303), 1, SourceQuery::SOURCE);
            $a3lInfo = $sourceQuery->GetInfo();
            $a3lPlayers = collect($sourceQuery->GetPlayers());
            $sourceQuery->Disconnect();

            $now = Carbon::now()->setTimezone(config('app.timezone'));
            $restarts = collect([]);
            foreach(config('a3lwebinterface.restarts') as $time) {
                $parts = explode(':', $time);
                $carbon = Carbon::now()->setTimezone(config('app.timezone'))->setTime($parts[0], $parts[1], 0);
                $restarts->put($time, [
                    'carbon' => $carbon,
                    'diff' => $now->diffInSeconds($carbon, false) > 0 ? $now->diffInSeconds($carbon, false) : $now->diffInSeconds($carbon->addDay(), false),
                ]);
            }

            $a3lRestart = $restarts->reject(function($restart) {
                return $restart['diff'] <= 0;
            })->sortBy('diff')->first()['carbon'];

            return [
                'info' => $a3lInfo,
                'playersOnline' => $a3lPlayers,
                'restart' => $a3lRestart,
                'online' => true,
            ];
        } catch (\Exception $e) {
            return [
                'info' => null,
                'playersOnline' => 0,
                'restart' => null,
                'online' => false,
            ];
        }
    }

    protected function getTeamspeak()
    {
        $server = new Server();
        $clients = $server->getClients();
        return [
            'server' => $server,
            'clients' => $clients,
        ];
    }
}

{'fraction_non_alphanumeric': 0.16615573267933784, 'fraction_numerical': 0.010423053341508276, 'mean_word_length': 1.887315634218289, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7479841', 'n_tokens_mistral': 1503, 'n_tokens_neox': 1405, 'n_words': 232}