diff --git a/app/Http/Controllers/AuthIVAOController.php b/app/Http/Controllers/AuthIVAOController.php index 9d36420..140c834 100644 --- a/app/Http/Controllers/AuthIVAOController.php +++ b/app/Http/Controllers/AuthIVAOController.php @@ -34,7 +34,7 @@ public function sso(Request $request, $url = "home") $base_url = $openid_data["authorization_endpoint"]; $reponse_type = "code"; - $scopes = "profile friends:read friends:write flight_plans:read flight_plans:write"; + $scopes = "profile friends:read friends:write flight_plans:read flight_plans:write tracker"; $state = rand(100000, 999999); // Random string to prevent CSRF attacks $query = [ diff --git a/app/Http/Controllers/DiscordContoller.php b/app/Http/Controllers/DiscordContoller.php index 5abcaf5..6a008c1 100644 --- a/app/Http/Controllers/DiscordContoller.php +++ b/app/Http/Controllers/DiscordContoller.php @@ -37,10 +37,10 @@ public function push_github(Request $request) public function description(Request $request) { $text = $request->body; - if($request->link != null){ - return "Type:".$request->labels." \n\n". $text .= "\n\n Link direct github: [Issue](" . $request->link . ")"; - }else{ - return "Type:".$request->labels." \n\n". $text; + if ($request->link != null) { + return "Type:" . $request->labels . " \n\n" . $text .= "\n\n Link direct github: [Issue](" . $request->link . ")"; + } else { + return "Type:" . $request->labels . " \n\n" . $text; } } @@ -54,37 +54,56 @@ public function send_feedback(Request $request) "body" => $request->body, "user_id" => $request->user_id, "labels" => $request->labels, - "link"=> $request->link, + "link" => $request->link, ]); $usersController = new UsersController(); $user = $usersController->get_info_user($request->user_id); - if(!$user){ - $user = [ - "name" => "Anonymous", - "vid" => "0000000", - ]; - } - $push = Http::post($this->url_webhooks(), [ - "avatar_url" => "https://i.pinimg.com/originals/99/1e/53/991e534b8f6038f4bdf67a97a7984822.jpg", - "embeds" => [ - [ - "title" => "Feedback from: " . $user->name . " (VID: " . $user->vid . ")", - "description" => $this->description($request), - "url" => $request->link ?? null, - "color" => "16711680", - "footer" => [ - "text" => "Feedback Form the website", - ], - "timestamp" => date("Y-m-d H:i:s") + if (!$user) { + $user = [ + "name" => "Anonymous", + "vid" => "0000000", + ]; + $push = Http::post($this->url_webhooks(), [ + "avatar_url" => "https://i.pinimg.com/originals/99/1e/53/991e534b8f6038f4bdf67a97a7984822.jpg", + "embeds" => [ + [ + "title" => "Feedback from: " . $user["name"], + "description" => $this->description($request), + "url" => $request->link ?? null, + "color" => "16711680", + "footer" => [ + "text" => "Feedback Form the website", + ], + "timestamp" => date("Y-m-d H:i:s") + ] ] - ] - ]); - return $push; + ]); + return $push; + } else { + $push = Http::post($this->url_webhooks(), [ + "avatar_url" => "https://i.pinimg.com/originals/99/1e/53/991e534b8f6038f4bdf67a97a7984822.jpg", + "embeds" => [ + [ + "title" => "Feedback from: " . $user->name . " (VID: " . $user->vid . ")", + "description" => $this->description($request), + "url" => $request->link ?? null, + "color" => "16711680", + "footer" => [ + "text" => "Feedback Form the website", + ], + "timestamp" => date("Y-m-d H:i:s") + ] + ] + + ]); + return $push; + } } - public function url_discord_for_code(Request $request){ - $url = "https://discord.com/api/oauth2/authorize?client_id=".env("discord_client_id")."&redirect_uri=http%3A%2F%2F127.0.0.1%3A8000%2Ftest2&response_type=code&scope=identify"; + public function url_discord_for_code(Request $request) + { + $url = "https://discord.com/api/oauth2/authorize?client_id=" . env("discord_client_id") . "&redirect_uri=http%3A%2F%2F127.0.0.1%3A8000%2Ftest2&response_type=code&scope=identify"; $request->merge([ "code" => $request->code, ]); @@ -94,6 +113,4 @@ public function url_discord_for_code(Request $request){ ]; return $url["code"]; } - - } diff --git a/app/Http/Controllers/GithubController.php b/app/Http/Controllers/GithubController.php index f3dd43b..45cc8e5 100644 --- a/app/Http/Controllers/GithubController.php +++ b/app/Http/Controllers/GithubController.php @@ -3,55 +3,79 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Http; +use App\Http\Controllers\DiscordContoller; + class GithubController extends Controller { - public function url_issue(){ - $url = "https://api.github.com/repos/alexcaussades/L10/issues"; + public function url_issue() + { + $url = "https://api.github.com/repos/alexcaussades/Ivatrac/issues"; return $url; } - public function token(){ + public function token() + { $token = env('Github_token_issue'); return $token; } - public function call_API(){ + public function call_API() + { $f = http::withToken($this->token())->post($this->url_issue()); return $f; - } - public function send_issue(Request $request){ + public function send_issue(Request $request) + { /** Send issue to github on the repo alexcaussades/l10 is token is valid*/ $users = new UsersController(); - + $user = $users->get_info_user($request->user_id); - if(!$user){ - $users = [ + if (!$user) { + $user = []; + $user = [ "name" => "Anonymous", "vid" => "Anonymous" ]; + $issue = Http::withToken($this->token())->post($this->url_issue(), [ + "title" => "Feedback from: " . $user["name"], + "body" => $request->body, + "labels" => [ + $request->labels + ] + ]); + /** header location de l'issue */ + $url = $this->return_url($issue); + return $url["html_url"]; + } else { + $issue = Http::withToken($this->token())->post($this->url_issue(), [ + "title" => "Feedback from: " . $user->name . " (VID: " . $user->vid . ")", + "body" => $request->body, + "labels" => [ + $request->labels + ] + ]); + /** header location de l'issue */ + $url = $this->return_url($issue); + return $url["html_url"]; } - $issue = Http::withToken($this->token())->post($this->url_issue(), [ - "title" => "Feedback from: " . $user->name . " (VID: ".$user->vid.")", - "body" => $request->body, - "labels" => [ - $request->labels - ] - ]); - /** header location de l'issue */ - $url = $this->return_url($issue->header('location')); - return $url; } - public function return_url($url){ - $url = explode("/", $url); - $new_url = "https://github.com/alexcaussades/L10/issues/" . $url[7]; - return $new_url; - + public function return_url($url) + { + $issue = $url->json(); + $issue_post = []; + $issue_post = [ + "url" => $issue["url"], + "html_url" => $issue["html_url"], + "repository_url" => $issue["repository_url"], + "labels" => $issue["labels"], + "title" => $issue["title"], + ]; + return $issue_post; } } - diff --git a/app/Http/Controllers/usersController.php b/app/Http/Controllers/usersController.php index 93adb76..585353b 100644 --- a/app/Http/Controllers/usersController.php +++ b/app/Http/Controllers/usersController.php @@ -120,7 +120,7 @@ public function connect_via_ivao($request, $data) 'vid' => $data["id"], 'name_first' => $data["firstName"], 'name_last' => $data["lastName"], - 'email' => $data["email"], + 'email' => $data["email"] ?? "null", 'password' => Hash::make("ivao"), 'email_verified_at' => now(), 'remember_token' => Str::random(10), @@ -188,7 +188,6 @@ public function logout(Request $request) $request->session()->forget('remember_token'); $request->session()->forget('ivao_tokens'); $request->session()->flush(); - } public function get_info_user($id) diff --git a/app/Http/Controllers/whazzupController.php b/app/Http/Controllers/whazzupController.php index 6ea91b6..198849b 100644 --- a/app/Http/Controllers/whazzupController.php +++ b/app/Http/Controllers/whazzupController.php @@ -338,18 +338,34 @@ public function user_me() $users_me = $users_me->json(); $users_me = collect($users_me); $users_me = $users_me->toArray(); + + /** convertir timestant uniquement en heure en addition des jours */ $heure = Carbon::createFromTimestamp(0)->format('Y-m-d H:i:s'); - $atc = Carbon::createFromTimestamp($users_me["hours"][0]["hours"])->format('Y-m-d H:i:s'); + $atc = Carbon::createFromTimestamp($users_me["hours"][0]["hours"])->format('Y-m-d H:i'); /** diff entre heure et minutes $atc */ $atc1 = Carbon::parse($atc); $heure = Carbon::parse($heure); $atc = $atc1->diffInHours($heure); $atc = $atc1->diffInMinutes($heure) / 60; - $heure = Carbon::createFromTimestamp($users_me["hours"][1]["hours"])->format('Y-m-d H:i:s'); - $heure = Carbon::parse($heure); - $heure = $heure->diffInHours($heure); - + /** Rounded heure ATC */ + $atc = round($atc, 2); + + /** Pilot */ + $pilot = Carbon::createFromTimestamp($users_me["hours"][1]["hours"])->format('Y-m-d H:i'); + $pilot1 = Carbon::parse($pilot); + $pilot = $pilot1->diffInHours($heure); + $pilot = $pilot1->diffInMinutes($heure) / 60; + /** Rounded heure Pilot */ + $pilot = round($pilot, 2); + + /** Staff */ + $staff = Carbon::createFromTimestamp($users_me["hours"][2]["hours"])->format('Y-m-d H:i'); + $staff1 = Carbon::parse($staff); + $staff = $staff1->diffInHours($heure); + $staff = $staff1->diffInMinutes($heure) / 60; + /** Rounded heure Staff */ + $staff = round($staff, 2); @@ -361,10 +377,10 @@ public function user_me() "Hours" => [ /** conversion value timestamp en heure */ - "AtcHours" => Carbon::createFromTimestamp($users_me["hours"][0]["hours"]), - "PilotHours" => $users_me["hours"][1]["hours"], - "StaffHours" => $users_me["hours"][2]["hours"], - "TotalHours" => null, + "AtcHours" => $atc, + "PilotHours" => $pilot, + "StaffHours" => $staff, + "TotalHours" => $atc + $pilot, ], @@ -633,4 +649,12 @@ public function get_aircrafts($icao_code) return $aircrafts; } + + public function event_ivao() + { + $event = $this->API_request("/v1/events"); + $event = $event->json(); + return $event; + } + } diff --git a/database/changelog.json b/database/changelog.json index a6c8327..d6e5a95 100644 --- a/database/changelog.json +++ b/database/changelog.json @@ -7,7 +7,7 @@ "option": [ { "id": 0, - "type": "Feacture", + "type": "Feature", "btn": "success", "description": "Connect SSO with the application on IVAO" }, @@ -33,7 +33,7 @@ }, { "id": 1, - "type": "Feacture", + "type": "Feature", "btn": "success", "description": "Add Booking System (hors add on IVAO)" }, @@ -65,13 +65,13 @@ }, { "id": 1, - "type": "Feacture", + "type": "Feature", "btn": "success", "description": " Add Changelog page" } ] }, - "3":{ + "3": { "id": 4, "name": "2023 / 29", "date": "2023-10-02", @@ -85,7 +85,7 @@ }, { "id": 1, - "type": "Feacture", + "type": "Feature", "btn": "success", "description": " Add Changelog page for menu" }, @@ -97,7 +97,7 @@ } ] }, - "4":{ + "4": { "id": 5, "name": "2023 / 30", "date": "2023-10-04", @@ -105,38 +105,37 @@ "option": [ { "id": 0, - "type": "Feacture", + "type": "Feature", "btn": "success", "description": "Add Page Event Ximea" }, { "id": 1, - "type": "Feacture", + "type": "Feature", "btn": "success", "description": "Create Controller event Ximea" }, { "id": 2, - "type": "Feacture", + "type": "Feature", "btn": "success", "description": "Create Model event Ximea" }, { "id": 3, - "type": "Feacture", + "type": "Feature", "btn": "success", "description": "Create View event Ximea" }, { "id": 4, - "type": "Feacture", + "type": "Feature", "btn": "success", "description": "Create CSS event Ximea" } - ] }, - "5":{ + "5": { "id": 6, "name": "2023 / 31", "date": "2023-10-18", @@ -160,16 +159,14 @@ "btn": "warning", "description": "Change Version VID search" } - ] - }, - "6": - { + }, + "6": { "id": 7, "name": "2023 / 32", "date": "2023-10-23", "version": "26.2.3", - "option":[ + "option": [ { "id": 0, "type": "Change", @@ -177,14 +174,14 @@ "description": "Modification API IVAO" } ] - }, - "7": - { + }, + "7": { + "id": 8, "name": "2023 / 33", "date": "2023-11-02", "version": "26.2.4", - "option":[ + "option": [ { "id": 0, "type": "Change", @@ -199,10 +196,36 @@ }, { "id": 2, - "type": "Feacture", + "type": "Feature", "btn": "success", "description": "Add Page users offline" } ] - } + }, + "8": { + "id": 9, + "name": "2023 / 34", + "date": "2023-11-11", + "version": "26.2.5", + "option": [ + { + "id": 0, + "type": "Bug Fix", + "btn": "danger", + "description": "Fixed tracker infos pages welcome" + }, + { + "id": 1, + "type": "Bug Fix", + "btn": "danger", + "description": "Correct parase data on the page welcome" + }, + { + "id": 2, + "type": "Feature", + "btn": "success", + "description": "Prepare the favorites metar (not finished) | (V.0.0.2 in progress)" + } + ] + } } diff --git a/routes/api.php b/routes/api.php index 18a5eec..ffc58aa 100644 --- a/routes/api.php +++ b/routes/api.php @@ -66,6 +66,26 @@ Route::get("/whazzup", function(Request $request){ $whazzup = new whazzupController(); + $whazzup->get_session(); $r = $whazzup->whazzup_api_traker(); return $r; }); + + +Route::get("info_plateforme/{icao}", function(Request $request){ + $whazzup = new whazzupController(); + $ATC = $whazzup->ckeck_online_atc($request->icao); + $PILOT = $whazzup->get_traffics_count($request->icao); + $METAR = $whazzup->Get_metar($request->icao); + $METAR = json_decode($METAR, true); + $METAR = $METAR["metar"]; + $info = [ + "ATC" => $ATC, + "PILOT" => $PILOT, + "METAR" => $METAR + ]; + $k = serialize($info); + $k = base64_encode($k); + + return $k; +}); \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 3bec35f..50fa3dd 100644 --- a/routes/web.php +++ b/routes/web.php @@ -80,7 +80,7 @@ $whaz = new whazzupController(); $online = $whaz->online_me(); $users_me = $whaz->user_me(); - + //dd($online->json(), $users_me); $online = json_decode($online, true); return response()->view('welcome', ["whazzup" => $whazzup, "online" => $online]); } @@ -618,8 +618,31 @@ })->middleware(["auth:web"]); Route::get("test", function (Request $request) { - $event = new eventController("LFMT"); - $r = $event->get_general(); - return $r; + $w = new whazzupController(); + $u = $w->get_rwys("LFBO"); + $g = json_decode($u, true); + $unit_pi = "ft"; + $unit_km = "km"; + $rwy = []; + for ($i = 0; $i < count($g); $i++) { + $rwy[$i]["runway"] = $g[$i]["runway"]; + $rwy[$i]["length_pi"] = $g[$i]["length"]; + $rwy[$i]["length_KM"] = $g[$i]["length"] / 3281; + $rwy[$i]["length_KM"] = round($rwy[$i]["length_KM"], 2); + } + $data = [ + "rwy" => $rwy, + "unit_pi" => $unit_pi, + "unit_km" => $unit_km + ]; + $data = json_encode($data); + return $data; }); + +Route::get("test2", function (Request $request) { + $w = new whazzupController(); + $u = $w->event_ivao(); + $g = json_decode($u); + return $g; +});