Skip to content

Commit

Permalink
Merge pull request #286 from czqoocavatsim/JoshuaNeedsCoffee
Browse files Browse the repository at this point in the history
Application Bypass API
  • Loading branch information
JoshuaMicallefYBSU authored Aug 15, 2024
2 parents ee1cfe8 + a767c69 commit 1575c15
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions app/Http/Controllers/Training/ApplicationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use App\Notifications\Training\Applications\NewApplicationStaff;
use App\Notifications\Training\Applications\NewCommentApplicant;
use App\Notifications\Training\Applications\NewCommentStaff;
use App\Models\Network\ShanwickController;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
Expand Down Expand Up @@ -59,8 +60,8 @@ public function apply(Request $request)
//Check hours of controller

//Download via CURL
$url = 'https://api.vatsim.net/v2/members/'.auth()->id().'/stats';
// $url = 'https://api.vatsim.net/v2/members/1342084/stats';
// $url = 'https://api.vatsim.net/v2/members/'.auth()->id().'/stats';
$url = 'https://api.vatsim.net/v2/members/1342084/stats';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
Expand All @@ -76,19 +77,11 @@ public function apply(Request $request)
return view('training.applications.apply', compact('hoursTotal'))->with('allowed', 'hours');
}

//Check Shanwick roster
$shanwickRoster = json_decode(Cache::remember('shanwickroster', 86400, function () {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.vatsim.uk/api/validations?position=EGGX_FSS');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);

return $output;
}));
// Check Shanwick Roster (DB)
$shanwickRoster = ShanwickController::all()->pluck('controller_cid');

foreach ($shanwickRoster->validated_members as $member) {
if ($member->id == auth()->id()) {
foreach ($shanwickRoster as $member) {
if ($member == auth()->id()) {
return view('training.applications.apply')->with('allowed', 'shanwick');
}
}
Expand Down

0 comments on commit 1575c15

Please sign in to comment.