Skip to content
This repository has been archived by the owner on Sep 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #115 from oranges13/php7.3
Browse files Browse the repository at this point in the history
Version 1.5
  • Loading branch information
oranges13 authored Nov 27, 2020
2 parents 7fe0689 + a3bf1fd commit 8dff101
Show file tree
Hide file tree
Showing 1,615 changed files with 35,292 additions and 41,901 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ installed.lock
database.sqlite
.htaccess
.editorconfig
.idea/*
.idea
.DS_Store
9 changes: 8 additions & 1 deletion application/app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Validation\ValidationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;

class Handler extends ExceptionHandler {

Expand All @@ -11,7 +15,10 @@ class Handler extends ExceptionHandler {
* @var array
*/
protected $dontReport = [
'Symfony\Component\HttpKernel\Exception\HttpException'
AuthorizationException::class,
HttpException::class,
ModelNotFoundException::class,
ValidationException::class,
];

/**
Expand Down
16 changes: 8 additions & 8 deletions application/app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function index()
$data = \Cache::remember('dashboardData', 5, function() {

$servers = \App\Server::get();
$newAccounts = \App\User::needActivation()->count();
$newAccounts = \App\User::whereRaw('1=1')->needActivation()->count();
$activePlayers = [];

$outdatedServers = [];
Expand All @@ -32,8 +32,8 @@ public function index()

foreach(\App\Server::get() as $server) {

$activeBans += \App\PlayerBan::on($server->id)->active()->count();
$activeMutes += \App\PlayerMute::on($server->id)->active()->count();
$activeBans += \App\PlayerBan::on($server->id)->whereRaw('1=1')->active()->count();
$activeMutes += \App\PlayerMute::on($server->id)->whereRaw('1=1')->active()->count();
array_push($activePlayers,
\App\Player::on($server->id)
->where('lastSeen', '>=', strtotime("-30 days"))
Expand All @@ -52,9 +52,9 @@ public function index()
$numKicks += \App\PlayerKick::on($server->id)->count();
$numNotes += \App\PlayerNote::on($server->id)->count();

if(\App\PlayerBan::on($server->id)->outdated()->count() > 0)
if(\App\PlayerBan::on($server->id)->whereRaw('1=1')->outdated()->count() > 0)
array_push($outdatedServers, $server->name);
elseif(\App\PlayerMute::on($server->id)->outdated()->count() > 0)
elseif(\App\PlayerMute::on($server->id)->whereRaw('1=1')->outdated()->count() > 0)
array_push($outdatedServers, $server->name);

}
Expand All @@ -77,7 +77,7 @@ public function activeBans()
$data = \Cache::remember('activeBansData', 1, function() {
$activeItems = collect();
foreach(\App\Server::get() as $server) {
$activeItems = $activeItems->merge(\App\PlayerBan::on($server->id)->with('actor','player')->active()->get());
$activeItems = $activeItems->merge(\App\PlayerBan::on($server->id)->with('actor','player')->whereRaw('1=1')->active()->get());
}
$title = trans('app.activeBans');
return compact('activeItems', 'title');
Expand All @@ -91,7 +91,7 @@ public function activeMutes()
$data = \Cache::remember('activeMutesData', 1, function() {
$activeItems = collect();
foreach(\App\Server::get() as $server) {
$activeItems = $activeItems->merge(\App\PlayerMute::on($server->id)->with('actor','player')->active()->get());
$activeItems = $activeItems->merge(\App\PlayerMute::on($server->id)->with('actor','player')->whereRaw('1=1')->active()->get());
}
$title = trans('app.activeMutes');
return compact('activeItems', 'title');
Expand All @@ -105,7 +105,7 @@ public function activeWarnings()
$data = \Cache::remember('activeWarningsData', 1, function() {
$activeItems = collect();
foreach(\App\Server::get() as $server) {
$activeItems = $activeItems->merge(\App\PlayerWarning::on($server->id)->with('actor','player')->active()->get());
$activeItems = $activeItems->merge(\App\PlayerWarning::on($server->id)->with('actor','player')->whereRaw('1=1')->active()->get());
}
$title = trans('app.activeWarnings');
return compact('activeItems', 'title');
Expand Down
2 changes: 1 addition & 1 deletion application/app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

abstract class Controller extends BaseController {

use DispatchesCommands, ValidatesRequests;
use ValidatesRequests;

}
38 changes: 16 additions & 22 deletions application/app/Http/Controllers/InstallController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php namespace App\Http\Controllers;

use Illuminate\Http\Request;

class InstallController extends Controller {

public function __construct()
Expand All @@ -8,12 +10,12 @@ public function __construct()
}

public function index()
{
{
return view('install.index');
}

public function config()
{
{
$host = @( $_SERVER["HTTPS"] != 'on' ) ? 'http://'.$_SERVER["SERVER_NAME"] : 'https://'.$_SERVER["SERVER_NAME"];
$host .= ( $_SERVER["SERVER_PORT"] != 80 ) ? ":".$_SERVER["SERVER_PORT"] : "";

Expand All @@ -24,36 +26,28 @@ public function config()
return view('install.config', compact('host', 'secKey', 'langs'));
}

public function install() {
$rules = [
'host' => 'required|url',
'locale' => 'required',
'timezone' => 'required',
'key' => 'required|min:32|max:32',
public function install(Request $request) {

'name' => 'required|min:3|max:255',
'email' => 'required|email|max:255', //unique:users removed, as user table does not yet exist
'password' => 'required|confirmed|min:6',
];
$this->validate($request, [
'host' => 'required|custom_url',
'locale' => 'required',
'timezone' => 'required',
'key' => 'required|min:32|max:32',

$validator = \Validator::make(\Input::all(), $rules);

if($validator->fails()) {
return redirect('/install/config')
->withErrors($validator)
->withInput(\Input::except('password'));
}
'name' => 'required|min:3|max:255',
'email' => 'required|email|max:255', //unique:users removed, as user table does not yet exist
'password' => 'required|confirmed|min:6',
]);

echo view('install.run');

try {
define('STDIN', fopen("php://stdin","r"));

//\Artisan::call('migrate:install');
\Artisan::call('migrate', [
\Artisan::call('migrate:refresh', [
'--path' => 'database/migrations',
'--env' => 'install',
'--quiet' => true,
'--quiet' => true,
'--force' => true
]);
} catch(\Exception $e) {
Expand Down
8 changes: 3 additions & 5 deletions application/app/Http/Controllers/PlayerBanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ public function index()
*/
public function create($player = null)
{
if($player == null)
unset($player);
else
if(!$player == null)
$player = $player[0];

foreach(\App\Server::get() as $server) {
Expand Down Expand Up @@ -63,7 +61,7 @@ public function store()
'player' => 'required',
'expires' => 'future'
);

$validator = \Validator::make(\Input::all(), $rules);

if ($validator->fails()) {
Expand Down Expand Up @@ -141,7 +139,7 @@ public function update($server, $id)
'player' => 'required',
'expires' => 'future'
);

$validator = \Validator::make(\Input::all(), $rules);

if ($validator->fails()) {
Expand Down
8 changes: 3 additions & 5 deletions application/app/Http/Controllers/PlayerMuteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ public function index()
*/
public function create($player = null)
{
if($player == null)
unset($player);
else
if(!$player == null)
$player = $player[0];

foreach(\App\Server::get() as $server) {
Expand Down Expand Up @@ -63,7 +61,7 @@ public function store()
'player' => 'required',
'expires' => 'future'
);

$validator = \Validator::make(\Input::all(), $rules);

if ($validator->fails()) {
Expand Down Expand Up @@ -141,7 +139,7 @@ public function update($server, $id)
'player' => 'required',
'expires' => 'future'
);

$validator = \Validator::make(\Input::all(), $rules);

if ($validator->fails()) {
Expand Down
4 changes: 1 addition & 3 deletions application/app/Http/Controllers/PlayerNoteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ public function index()
*/
public function create($player = null)
{
if($player == null)
unset($player);
else
if(!$player == null)
$player = $player[0];

foreach(\App\Server::get() as $server) {
Expand Down
8 changes: 3 additions & 5 deletions application/app/Http/Controllers/PlayerWarningController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ public function index()
*/
public function create($player = null)
{
if($player == null)
unset($player);
else
if(!$player == null)
$player = $player[0];

foreach(\App\Server::get() as $server) {
Expand All @@ -57,7 +55,7 @@ public function store()
'reason' => 'required',
'player' => 'required',
);

$validator = \Validator::make(\Input::all(), $rules);

if ($validator->fails()) {
Expand Down Expand Up @@ -120,7 +118,7 @@ public function update($server, $id)
'reason' => 'required',
'player' => 'required',
);

$validator = \Validator::make(\Input::all(), $rules);

if ($validator->fails()) {
Expand Down
4 changes: 2 additions & 2 deletions application/app/Http/Controllers/StatsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public function index()

foreach($servers as $server) {
$players[$server->id] = \App\Player::on($server->id)->count();
$activeBans[$server->id] = \App\PlayerBan::on($server->id)->active()->count();
$activeMutes[$server->id] = \App\PlayerMute::on($server->id)->active()->count();
$activeBans[$server->id] = \App\PlayerBan::on($server->id)->whereRaw('1=1')->active()->count();
$activeMutes[$server->id] = \App\PlayerMute::on($server->id)->whereRaw('1=1')->active()->count();

$numBans += \App\PlayerBan::on($server->id)->count();
$numBans += \App\PlayerBanRecord::on($server->id)->count();
Expand Down
2 changes: 1 addition & 1 deletion application/app/Http/Middleware/VerifyServers.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(Guard $auth)
*/
public function handle($request, Closure $next)
{
if (\App\Server::get()->count() <= 0)
if (\App\Server::count() <= 0)
{
return redirect('/admin/servers/create')->with('message', trans('app.addServerFirst'));
}
Expand Down
12 changes: 7 additions & 5 deletions application/app/PastRecordBaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ class PastRecordBaseModel extends Model {

public $timestamps = false;

public $incrementing = false;

public function getPastActorUuidAttribute()
{
{
$this->attributes['past_actor_uuid'] = id_to_uuid($this->attributes['pastActor_id']);
return $this->attributes['past_actor_uuid'];
}
Expand All @@ -25,7 +27,7 @@ public function setPastActorUuidAttribute($value)
}

public function getPlayerUuidAttribute()
{
{
$this->attributes['player_uuid'] = id_to_uuid($this->attributes['player_id']);
return $this->attributes['player_uuid'];
}
Expand All @@ -37,7 +39,7 @@ public function setPlayerUuidAttribute($value)
}

public function getActorUuidAttribute()
{
{
$this->attributes['actor_uuid'] = id_to_uuid($this->attributes['actor_id']);
return $this->attributes['actor_uuid'];
}
Expand Down Expand Up @@ -95,10 +97,10 @@ public function setExpiredAttribute($value)
}

public function getDurationAttribute()
{
{
if($this->expired->timestamp == 0)
return null;

return $this->expired->diffForHumans($this->pastCreated, true);
}

Expand Down
4 changes: 3 additions & 1 deletion application/app/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class Player extends Model {

public $timestamps = false;

public $incrementing = false;

public function bans()
{
return $this->hasManyRelation('App\PlayerBan');
Expand Down Expand Up @@ -58,7 +60,7 @@ public function getIpAttribute() {
}

public function getUuidAttribute()
{
{
$this->attributes['uuid'] = id_to_uuid($this->attributes['id']);
// Fixes #109 when uuid not set
return $this->attributes['uuid'] ?: 'unset';
Expand Down
11 changes: 7 additions & 4 deletions application/app/PlayerWarning.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ class PlayerWarning extends RecordBaseModel {

protected $table = 'player_warnings';

public function scopeActive($query)
{
return $query->where('expires', '>=', Carbon::now()->timestamp)->orWhere('expires', '=', 0);
}
public function scopeActive($query)
{
return $query->where(function ($query) {
$query->where('expires', '>=', Carbon::now()->timestamp)
->orWhere('expires', '=', 0);
});
}

public function scopeOutdated($query)
{
Expand Down
Loading

0 comments on commit 8dff101

Please sign in to comment.