Redesign + Fixes
This commit is contained in:
parent
7718ed6c32
commit
7fe8056e35
67 changed files with 1898 additions and 2799 deletions
|
@ -1,45 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use App\Color\MinecraftColor;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
|
||||
class ControlController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware(['auth', 'verified', '2fa']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @param $attraction_id
|
||||
* @param $pin
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
public function index($attraction_id, $pin)
|
||||
{
|
||||
if(!preg_match('/^([0-9]){9}$/', $pin))
|
||||
return Redirect::route('status');
|
||||
|
||||
$data = DB::table('attraction')->select('name')->where('id', '=', $attraction_id)->first();
|
||||
if(empty($data))
|
||||
return Redirect::route('status');
|
||||
|
||||
return view('control')->with([
|
||||
'attraction_id' => $attraction_id,
|
||||
'attraction_name' => MinecraftColor::stripColor( $data->name),
|
||||
'pin' => $pin
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
|
@ -26,8 +26,11 @@ class HomeController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
if(!env('HOME_PAGE', false))
|
||||
return redirect()->route('status');
|
||||
|
||||
return view('home')->with([
|
||||
'message' => ''
|
||||
'message' => \App\Message::orderByDesc('id')->first()
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,9 +27,9 @@ class HomeController extends Controller
|
|||
public function index()
|
||||
{
|
||||
$users = User::count();
|
||||
$regions = DB::table('region')->count();
|
||||
$attractions = DB::table('attraction')->where('type', '!=', 'GLOBAL')->count();
|
||||
$shows = Show::count();
|
||||
$regions = DB::table('regions')->count();
|
||||
$attractions = DB::table('attractions')->count();
|
||||
$shows = env('SHOWS', false) ? Show::count() : 0;
|
||||
return view('panel.home')->with([
|
||||
'users' => $users,
|
||||
'regions' => $regions,
|
||||
|
|
111
app/Http/Controllers/Panel/ToolController.php
Normal file
111
app/Http/Controllers/Panel/ToolController.php
Normal file
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Panel;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Show;
|
||||
use App\ShowDate;
|
||||
use App\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class ToolController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware(['auth', 'verified', '2fa', 'admin']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the operator tool.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
public function operator()
|
||||
{
|
||||
return view('panel.operator');
|
||||
}
|
||||
|
||||
//Default values for cssTags
|
||||
private $cssDefaults = [
|
||||
'banner' => 'url("../img/banner.png") center center',
|
||||
'bg' => '#f2f2f2',
|
||||
'light' => '#2ecc71',
|
||||
'dark' => "#27ae60",
|
||||
'text' => '#fff',
|
||||
];
|
||||
|
||||
//Tags that can be changed in root.css
|
||||
private $cssTags = [
|
||||
'banner' => 'banner',
|
||||
"bg" => "bg",
|
||||
"light" => "color-light",
|
||||
"dark" => "color-dark",
|
||||
"text" => "color-text",
|
||||
];
|
||||
|
||||
public function css() {
|
||||
$styles = $this->cssDefaults;
|
||||
|
||||
if(file_exists(storage_path('app/public/css.json'))) {
|
||||
$json = file_get_contents(storage_path('app/public/css.json'));
|
||||
$json = json_decode($json);
|
||||
if(json_last_error() != JSON_ERROR_NONE && !empty($json))
|
||||
$styles = $json;
|
||||
}
|
||||
|
||||
return view('panel.css')->with([
|
||||
'styles' => $styles,
|
||||
]);
|
||||
}
|
||||
|
||||
public function cssPost(Request $request) {
|
||||
$rules = [];
|
||||
foreach($this->cssTags as $key => $value)
|
||||
$rules[$key] = ['required'];
|
||||
|
||||
$validator = Validator::make($request->all(), $rules);
|
||||
|
||||
if(!$validator->passes())
|
||||
return Redirect::back()->withErrors($validator->errors());
|
||||
|
||||
$styles = [];
|
||||
foreach($request->all() as $key => $value)
|
||||
if(array_key_exists($key, $this->cssTags))
|
||||
$styles[$key] = $value;
|
||||
|
||||
file_put_contents(storage_path('app/public/css.json'), json_encode($styles));
|
||||
|
||||
$str = ":root {\n";
|
||||
foreach($styles as $key => $value)
|
||||
$str .= "\t--".$this->cssTags[$key].': '.$value.";\n";
|
||||
|
||||
file_put_contents(public_path('assets/css/root.css'), $str.'}');
|
||||
|
||||
return view('panel.css')->with([
|
||||
'styles' => $styles,
|
||||
]);
|
||||
}
|
||||
|
||||
public function cssReset() {
|
||||
$styles = $this->cssDefaults;
|
||||
|
||||
file_put_contents(storage_path('app/public/css.json'), json_encode($styles));
|
||||
|
||||
$str = ":root {\n";
|
||||
foreach($styles as $key => $value)
|
||||
$str .= '--'.$this->cssTags[$key].': '.$value.";\n";
|
||||
|
||||
file_put_contents(public_path('assets/css/root.css'), $str.'}');
|
||||
|
||||
return Redirect::back();
|
||||
}
|
||||
|
||||
}
|
|
@ -35,7 +35,7 @@ class SecurityController extends Controller
|
|||
$tfa = $google2fa->isActivated();
|
||||
$pages = Session::where('user_id', Auth::id())->count();
|
||||
$pages = (int) ceil($pages/10);
|
||||
if($page > $pages)
|
||||
if($page < 1 || ($page > $pages && $page != 1))
|
||||
return redirect()->route('security', ['page' => $pages]);
|
||||
|
||||
$sessions = Session::where('user_id', Auth::id())->where('id', '!=', session()->getId())->skip(($page - 1)*10)->take(($page != 1 ? 10 : 9))->orderBy('last_activity', 'desc')->get();
|
||||
|
|
|
@ -26,26 +26,57 @@ class RidecountController extends Controller
|
|||
*/
|
||||
public function index($attraction_id)
|
||||
{
|
||||
$name = DB::table('attraction')->select('name')->where('id', '=', $attraction_id)->first()->name;
|
||||
$top10 = DB::table(DB::raw('ridecount, (SELECT @row_number:=0) AS t'))->select('uuid', DB::raw('SUM(`count`) AS `count`'), DB::raw('(@row_number:=@row_number + 1) AS `num`'))
|
||||
->where('attractionId', '=', $attraction_id)
|
||||
->whereRaw('YEARWEEK(date, 1) = YEARWEEK(CURDATE(), 1)')
|
||||
->whereRaw('YEAR(date) = YEAR(CURDATE())')
|
||||
->groupBy('uuid')
|
||||
$attraction = DB::table('attractions')->select(['cover','name','status_id'])->where('id', '=', $attraction_id)->first();
|
||||
if(empty($attraction))
|
||||
return redirect()->route('status');
|
||||
|
||||
$type = env('TOP', 1);
|
||||
if($type < 0 || $type > 4)
|
||||
return redirect()->route('status');
|
||||
|
||||
switch ($type) {
|
||||
case 1:
|
||||
$filter = 'week = WEEK(CURDATE(), 1)';
|
||||
break;
|
||||
case 2:
|
||||
$filter = 'month = MONTH(CURDATE())';
|
||||
break;
|
||||
case 3:
|
||||
$filter = 0;
|
||||
break;
|
||||
case 4:
|
||||
$filter = -1;
|
||||
break;
|
||||
default:
|
||||
$filter = 'day = DAYOFYEAR(CURDATE())';
|
||||
break;
|
||||
}
|
||||
|
||||
$top10 = DB::table(DB::raw('ridecounts, (SELECT @row_number:=0) AS t'))->select('uuid', DB::raw('SUM(`count`) AS `count`'), DB::raw('(@row_number:=@row_number + 1) AS `num`'))
|
||||
->where('attraction_id', '=', $attraction_id);
|
||||
|
||||
if(!empty($filter))
|
||||
$top10 = $top10->whereRaw($filter);
|
||||
|
||||
if($filter !== -1)
|
||||
$top10 = $top10->whereRaw('year = YEAR(CURDATE())');
|
||||
|
||||
$top10 = $top10->groupBy('uuid')
|
||||
->orderByDesc('count')
|
||||
->take(10)->get()->all();
|
||||
|
||||
$personal = DB::table('ridecount')
|
||||
->where('attractionId', '=', $attraction_id)
|
||||
->where('uuid', '=', Auth::user()->uuid)
|
||||
$personal = DB::table('ridecounts')
|
||||
->where('attraction_id', '=', $attraction_id)
|
||||
->where('uuid', '=', Auth::user()->fixedUUID())
|
||||
->sum('count');
|
||||
|
||||
$total = DB::table('ridecount')
|
||||
->where('attractionId', '=', $attraction_id)
|
||||
$total = DB::table('ridecounts')
|
||||
->where('attraction_id', '=', $attraction_id)
|
||||
->sum('count');
|
||||
|
||||
$attraction->status = DB::table('states')->where('id', '=', $attraction->status_id)->first();
|
||||
return view('ridecount')->with([
|
||||
'name' => $name,
|
||||
'attraction' => $attraction,
|
||||
'top10' => $top10,
|
||||
'personal' => $personal,
|
||||
'total' => $total
|
||||
|
|
|
@ -29,14 +29,14 @@ class ShowController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$shows = DB::select(DB::raw('SELECT t1.* FROM `shows` AS t1 RIGHT JOIN `show_dates` AS t2 ON t1.`id` = t2.`show_id` WHERE t2.`date` > CURDATE() GROUP BY t1.`id`'));
|
||||
$shows = DB::select(DB::raw('SELECT t1.* FROM `shows` AS t1 RIGHT JOIN `show_dates` AS t2 ON t1.`id` = t2.`show_id` WHERE t2.`date` > CURRENT_TIMESTAMP() GROUP BY t1.`id`'));
|
||||
return view('show')->with([
|
||||
'shows' => $shows
|
||||
]);
|
||||
}
|
||||
|
||||
public function order($show_id) {
|
||||
$show = Show::join('show_dates', 'show_dates.show_id', '=', 'shows.id')->select('shows.*')->where('shows.id', '=', $show_id)->firstOrFail();
|
||||
$show = Show::join('show_dates', 'show_dates.show_id', '=', 'shows.id')->select('shows.*')->where('shows.id', '=', $show_id)->where('show_dates.date', '>', DB::raw('CURRENT_TIMESTAMP()'))->firstOrFail();
|
||||
$dates = $show->getShowDates(Auth::user()->uuid);
|
||||
|
||||
return view('order')->with([
|
||||
|
|
|
@ -19,7 +19,6 @@ class Kernel extends HttpKernel
|
|||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
\App\Http\Middleware\HttpsProtocol::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
class HttpsProtocol
|
||||
{
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (!$request->secure() && in_array(App::environment(), ['stage', 'production']))
|
||||
return redirect()->secure($request->getRequestUri());
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
Reference in a new issue