Redesign + Fixes
This commit is contained in:
parent
7718ed6c32
commit
7fe8056e35
67 changed files with 1898 additions and 2799 deletions
|
@ -2,7 +2,6 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
|
||||
class OpenAudioMCController extends Controller
|
||||
{
|
||||
|
@ -30,17 +29,11 @@ class OpenAudioMCController extends Controller
|
|||
if(!filter_var($url, FILTER_VALIDATE_URL))
|
||||
return view('openaudiomc')->with(['type' => 1]);
|
||||
|
||||
$key = explode('/', $url);
|
||||
$key = $key[count($key) - 1];
|
||||
if(!preg_match('/^([a-zA-Z0-9]{8})\-([a-zA-Z0-9]{4})\-([a-zA-Z0-9]{4})\-([a-zA-Z0-9]{4})\-([a-zA-Z0-9]{12})$/', $key))
|
||||
return view('openaudiomc')->with(['type' => 1]);
|
||||
|
||||
$url = str_replace('%UUID%', Auth::user()->fixedUUID(), $url);
|
||||
$result = file_get_contents($url);
|
||||
if(!$this->isJson($result))
|
||||
$json = json_decode($result);
|
||||
if(empty($result) || json_last_error() != JSON_ERROR_NONE)
|
||||
return view('openaudiomc')->with(['type' => 1]);
|
||||
|
||||
$json = json_decode($result);
|
||||
if(isset($json->errors) && !empty($json->errors))
|
||||
return view('openaudiomc')->with(['type' => 2]);
|
||||
|
||||
|
@ -48,23 +41,28 @@ class OpenAudioMCController extends Controller
|
|||
return view('openaudiomc')->with(['type' => 2]);
|
||||
|
||||
$response = $json->response;
|
||||
if(!isset($response->isConnected) || !isset($response->sessionUrl))
|
||||
if(!isset($response->players) || empty($response->players))
|
||||
return view('openaudiomc')->with(['type' => 2]);
|
||||
|
||||
if($response->isConnected)
|
||||
$response = $response->players;
|
||||
|
||||
$uuid = Auth::user()->fixedUUID();
|
||||
$user = null;
|
||||
foreach ($response as $player) {
|
||||
if($player->uuid === $uuid) {
|
||||
$user = $player;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($user))
|
||||
return view('openaudiomc')->with(['type' => 2]);
|
||||
|
||||
if(!isset($user->isConnected) || $user->isConnected)
|
||||
return view('openaudiomc')->with(['type' => 3]);
|
||||
|
||||
$link = $json->response->sessionUrl;
|
||||
header('Location: '.$link);
|
||||
header('Location: '.$user->url);
|
||||
exit;
|
||||
}
|
||||
|
||||
private function isJson($string) {
|
||||
if(empty($string))
|
||||
return false;
|
||||
|
||||
json_decode($string);
|
||||
return (json_last_error() == JSON_ERROR_NONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue