Updated to Laravel 9, small fixes, and more
This commit is contained in:
parent
6fc52ee512
commit
9fd844ae1a
24 changed files with 5589 additions and 2557 deletions
|
@ -1,101 +1,101 @@
|
|||
<?php
|
||||
|
||||
namespace App\Cache;
|
||||
|
||||
class Cache {
|
||||
class Cache
|
||||
{
|
||||
|
||||
public static function getUsername($uuid) {
|
||||
if(file_exists(storage_path('app/uuid/'.$uuid.'.json'))) {
|
||||
$json = file_get_contents(storage_path('app/uuid/'.$uuid.'.json'));
|
||||
public static function getUsername($uuid)
|
||||
{
|
||||
if (file_exists(storage_path('app/uuid/' . $uuid . '.json'))) {
|
||||
$json = file_get_contents(storage_path('app/uuid/' . $uuid . '.json'));
|
||||
$json = json_decode($json, true);
|
||||
if((time() - strtotime($json['time'])) > 3600) {
|
||||
$json = file_get_contents('https://api.mojang.com/user/profiles/'.$uuid.'/names');
|
||||
if(empty($json)) {
|
||||
$json = file_get_contents(storage_path('app/uuid/'.$uuid.'.json'));
|
||||
if ((time() - strtotime($json['time'])) > 3600) {
|
||||
$json = file_get_contents('https://api.mojang.com/user/profile/' . $uuid);
|
||||
if (empty($json)) {
|
||||
$json = file_get_contents(storage_path('app/uuid/' . $uuid . '.json'));
|
||||
$json = json_decode($json, true);
|
||||
return $json['name'];
|
||||
}
|
||||
|
||||
$json = json_decode($json, true);
|
||||
if(isset($json['error'])) {
|
||||
$json = file_get_contents(storage_path('app/uuid/'.$uuid.'.json'));
|
||||
if (isset($json['error'])) {
|
||||
$json = file_get_contents(storage_path('app/uuid/' . $uuid . '.json'));
|
||||
$json = json_decode($json, true);
|
||||
return $json['name'];
|
||||
}
|
||||
|
||||
$name = $json[count($json) -1]['name'];
|
||||
$name = $json['name'];
|
||||
$json = [];
|
||||
$json['id'] = $uuid;
|
||||
$json['name'] = $name;
|
||||
self::saveJson($json);
|
||||
return $json['name'];
|
||||
} else {
|
||||
return $json['name'];
|
||||
}
|
||||
} else {
|
||||
$json = file_get_contents('https://api.mojang.com/user/profiles/'.$uuid.'/names');
|
||||
if(empty($json))
|
||||
$json = file_get_contents('https://api.mojang.com/user/profile/' . $uuid);
|
||||
if (empty($json))
|
||||
return $uuid;
|
||||
|
||||
$json = json_decode($json, true);
|
||||
if(isset($json['error']))
|
||||
if (isset($json['error']))
|
||||
return $uuid;
|
||||
|
||||
$name = $json[count($json) -1]['name'];
|
||||
$name = $json['name'];
|
||||
$json = [];
|
||||
$json['id'] = $uuid;
|
||||
$json['name'] = $name;
|
||||
self::saveJson($json);
|
||||
return $json['name'];
|
||||
}
|
||||
return $json['name'];
|
||||
}
|
||||
|
||||
public static function getUUID($username) {
|
||||
foreach(glob(storage_path('app/uuid/*')) as $file) {
|
||||
public static function getUUID($username)
|
||||
{
|
||||
foreach (glob(storage_path('app/uuid/*')) as $file) {
|
||||
$json = file_get_contents($file);
|
||||
$json = json_decode($json, true);
|
||||
if($json['name'] !== $username)
|
||||
if ($json['name'] !== $username)
|
||||
continue;
|
||||
|
||||
if((time() - strtotime($json['time'])) > 3600) {
|
||||
$json = file_get_contents('https://api.mojang.com/users/profiles/minecraft/'.$username);
|
||||
if(empty($json)) {
|
||||
unlink(storage_path('app/uuid/'.$file));
|
||||
if ((time() - strtotime($json['time'])) > 3600) {
|
||||
$json = file_get_contents('https://api.mojang.com/users/profiles/minecraft/' . $username);
|
||||
if (empty($json)) {
|
||||
unlink(storage_path('app/uuid/' . $file));
|
||||
return $username;
|
||||
}
|
||||
|
||||
$json = json_decode($json, true);
|
||||
if(isset($json['error'])) {
|
||||
unlink(storage_path('app/uuid/'.$file));
|
||||
if (isset($json['error'])) {
|
||||
unlink(storage_path('app/uuid/' . $file));
|
||||
return $username;
|
||||
}
|
||||
|
||||
self::saveJson($json);
|
||||
return $json['id'];
|
||||
} else {
|
||||
return $json['id'];
|
||||
}
|
||||
return $json['id'];
|
||||
}
|
||||
|
||||
$json = file_get_contents('https://api.mojang.com/users/profiles/minecraft/'.$username);
|
||||
if(empty($json))
|
||||
$json = file_get_contents('https://api.mojang.com/users/profiles/minecraft/' . $username);
|
||||
if (empty($json))
|
||||
return $username;
|
||||
|
||||
$json = json_decode($json, true);
|
||||
if(isset($json['error']))
|
||||
if (isset($json['error']))
|
||||
return $username;
|
||||
|
||||
self::saveJson($json);
|
||||
return $json['id'];
|
||||
}
|
||||
|
||||
public static function saveJson($json) {
|
||||
public static function saveJson($json)
|
||||
{
|
||||
$array = [
|
||||
'id' => $json['id'],
|
||||
'name' => $json['name'],
|
||||
'time' => date('d-m-Y H:m:s')
|
||||
];
|
||||
|
||||
file_put_contents(storage_path('app/uuid/'.$json['id'].'.json'), json_encode($array));
|
||||
file_put_contents(storage_path('app/uuid/' . $json['id'] . '.json'), json_encode($array));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
Use Throwable;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
|
@ -29,10 +29,10 @@ class Handler extends ExceptionHandler
|
|||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @param \Throwable $exception
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $exception)
|
||||
public function report(Throwable $exception)
|
||||
{
|
||||
parent::report($exception);
|
||||
}
|
||||
|
@ -41,10 +41,10 @@ class Handler extends ExceptionHandler
|
|||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @param \Throwable $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $exception)
|
||||
public function render($request, Throwable $exception)
|
||||
{
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class HomeController extends Controller
|
|||
|
||||
public function photo() {
|
||||
$photos = DB::table('actionfotos')
|
||||
->join('attractions', 'attractions.id', '=', 'actionfotos.ride')
|
||||
->join('attraction', 'attraction.id', '=', 'actionfotos.ride')
|
||||
->where('actionfotos.uuid', '=', Auth::user()->uuid)
|
||||
->select('actionfotos.base64')
|
||||
->get()->all();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
|
@ -19,5 +19,10 @@ class TrustProxies extends Middleware
|
|||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers = Request::HEADER_X_FORWARDED_ALL;
|
||||
protected $headers =
|
||||
Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
@ -23,6 +24,6 @@ class AppServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
Schema::defaultStringLength(191);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue