diff --git a/app/Events/ConfigureUserMenu.php b/app/Events/ConfigureUserMenu.php index 653e9acf..1bcaea12 100644 --- a/app/Events/ConfigureUserMenu.php +++ b/app/Events/ConfigureUserMenu.php @@ -11,7 +11,7 @@ class ConfigureUserMenu extends Event * * @return void */ - public function __construct(Array &$menu) + public function __construct(array &$menu) { // pass array by reference $this->menu = &$menu; diff --git a/app/Events/PlayerInstantiated.php b/app/Events/PlayerInstantiated.php deleted file mode 100644 index 8aaa2fa7..00000000 --- a/app/Events/PlayerInstantiated.php +++ /dev/null @@ -1,7 +0,0 @@ -uid = $uid; - } - -} diff --git a/app/Events/UserTryToLogin.php b/app/Events/UserTryToLogin.php index b6bd015a..9cc7ebc0 100644 --- a/app/Events/UserTryToLogin.php +++ b/app/Events/UserTryToLogin.php @@ -10,7 +10,7 @@ class UserTryToLogin extends Event public $identification; - public $auth_type; + public $authType; /** * Create a new event instance. @@ -20,7 +20,7 @@ class UserTryToLogin extends Event public function __construct($identification, $auth_type) { $this->identification = $identification; - $this->auth_type = $auth_type; + $this->authType = $auth_type; } } diff --git a/app/Http/Controllers/PlayerController.php b/app/Http/Controllers/PlayerController.php index f3855c92..83a3a0d9 100644 --- a/app/Http/Controllers/PlayerController.php +++ b/app/Http/Controllers/PlayerController.php @@ -12,6 +12,7 @@ use App\Models\Texture; use Illuminate\Http\Request; use App\Events\PlayerWasAdded; use App\Events\PlayerWasDeleted; +use App\Events\CheckPlayerExists; use App\Exceptions\PrettyPageException; use App\Services\Repositories\UserRepository; @@ -50,6 +51,8 @@ class PlayerController extends Controller 'player_name' => 'required|'.(Option::get('allow_chinese_playername') == "1") ? 'pname_chinese' : 'player_name' ]); + Event::fire(new CheckPlayerExists($request->input('player_name'))); + if (!Player::where('player_name', $request->input('player_name'))->get()->isEmpty()) { return json(trans('user.player.add.repeated'), 6); } diff --git a/app/Http/Controllers/TextureController.php b/app/Http/Controllers/TextureController.php index 0bc37b6f..f0928589 100644 --- a/app/Http/Controllers/TextureController.php +++ b/app/Http/Controllers/TextureController.php @@ -7,6 +7,7 @@ use Option; use Storage; use Response; use Minecraft; +use Carbon\Carbon; use App\Models\User; use App\Models\Player; use App\Models\Texture; @@ -30,12 +31,16 @@ class TextureController extends Controller $player = $this->getPlayerInstance($player_name); if ($api == "csl") { - return Response::rawJson($player->getJsonProfile(Player::CSL_API)); + $content = $player->getJsonProfile(Player::CSL_API); } else if ($api == "usm") { - return Response::rawJson($player->getJsonProfile(Player::USM_API)); + $content = $player->getJsonProfile(Player::USM_API); } else { - return Response::rawJson($player->getJsonProfile(Option::get('api_type'))); + $content = $player->getJsonProfile(Option::get('api_type')); } + + return Response::rawJson($content, 200, [ + 'Last-Modified' => Carbon::createFromTimestamp($player->getLastModified())->format('D, d M Y H:i:s \G\M\T') + ]); } public function jsonWithApi($api, $player_name) diff --git a/app/Services/Database/Database.php b/app/Services/Database/Database.php index 3c9a7934..086b94e5 100644 --- a/app/Services/Database/Database.php +++ b/app/Services/Database/Database.php @@ -58,7 +58,7 @@ class Database public function table($table_name, $no_prefix = false) { if ($this->connection->real_escape_string($table_name) == $table_name) { - $this->table_name = $no_prefix ? $table_name : config('database.connections.mysql.prefix').$table_name; + $this->table_name = $no_prefix ? "{$this->config['database']}.$table_name" : config('database.connections.mysql.prefix').$table_name; return $this; } else { throw new \InvalidArgumentException('Table name contains invalid characters', 1);