Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
vac areodrome ou ULM
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcaussades committed Feb 19, 2024
1 parent 251f952 commit 2079ef5
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 21 deletions.
19 changes: 18 additions & 1 deletion app/Http/Controllers/CarteSIAController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,26 @@ public function config_Date()
$date = $this->Airac_date($date);
return $date;
}

public function checkdate(){
$date = new DateTime();
$date = $date->format('Y-m-d');
if($date <= $this->config_Date()){
$date = date("m")-1;
if($date < 10){
$date = "0".$date;
}
$date = $this->Airac_date($date);
}else{
$date = date("m");
}
return $date;

}

public function DateAirac()
{
$date = $this->config_Date();
$date = $this->checkdate();
$date = new DateTime($date);
$date = $date->format('d_M_Y');
$date = strtoupper($date);
Expand Down
13 changes: 8 additions & 5 deletions app/Http/Controllers/whazzupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,18 @@ public function get_token()
}

$openid_data = json_decode($openid_result, true);
//dd($openid_data);

$idclient = env("ivao_api_client_id");
$secret = env("ivao_api_client_secret");
$state = rand(100000, 999999);

$token_req_data = array(
'grant_type' => 'client_credentials',
'client_id' => $idclient,
'client_secret' => $secret,
'scope' => 'tracker'
'scope' => 'tracker',
'state' => $state
);

// use key 'http' even if you send the request to https://...
Expand All @@ -144,10 +147,10 @@ public function get_token()
$token_context = stream_context_create($token_options);
$token_result = file_get_contents($openid_data['token_endpoint'], false, $token_context);

if ($token_result === FALSE) {
/* Handle error */
die('Error while getting token');
}
// if ($token_result === FALSE) {
// /* Handle error */
// die('Error while getting token');
// }

$token_res_data = json_decode($token_result, true);
$access_token = $token_res_data['access_token']; // Here is the access token
Expand Down
1 change: 1 addition & 0 deletions resources/views/metar-base.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<link rel="stylesheet" href="{{ asset("public/asset/css/bootstrap.min.css") }} " type="text/css">
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined" rel="stylesheet" />
<link rel="stylesheet" href="{{ asset("public/asset/css/style.css") }} " type="text/css">

@endif
<!-- Google Tag Manager -->
<script>
Expand Down
59 changes: 59 additions & 0 deletions resources/views/vac/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@extends("metar-base")

@section("title", "Chart Vac")


@include("navbar")

@section('content')

<div class="container">
<p class="fs-1">VAC / ULM </p>
<form action="{{ route("vac.icao", ["icao"])}}" method="get">
<div class="form-group">
<label for="icao2">ICAO</label>
<input type="text" class="form-control" id="searchicao" name="icao" placeholder="Enter ICAO">
<div class="form-text" id="basic-addon4"></div>
<button type="submit" id="submit-btn" class="btn btn-dark mt-2">Submit</button>
</div>

</form>


<div id="status">
<hr>
<p class="fs-3"> Check statut </p>
</div>

</div>



@endsection

<script>
//documment ready change to innerHTML
document.addEventListener("DOMContentLoaded", function(event) {
document.getElementById("status").style.display = "none";
document.getElementById("submit-btn").className = "btn btn-dark mt-2";
document.getElementById("basic-addon4").innerHTML = "We are searching for the VAC of the aerodrome or ULM.";
document.getElementById("searchicao").addEventListener("input", function(event) {
document.getElementById("basic-addon4").innerHTML = "We are searching for the VAC of the aerodrome or ULM.";
if (event.target.value.length == 4) {
var searchicao = document.getElementById("searchicao").value;
document.getElementById("basic-addon4").innerHTML = "We are searching for the VAC of the aerodrome";
document.getElementById("submit-btn").className = "btn btn-success mt-2";
document.getElementById("submit-btn").disabled = false;
}
if (event.target.value.length == 6) {
var searchicao = document.getElementById("searchicao").value;
document.getElementById("basic-addon4").innerHTML = "We are searching for the VAC of the ULM";
document.getElementById("submit-btn").className = "btn btn-success mt-2";
} else {
}
});
});
</script>
50 changes: 35 additions & 15 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use Symfony\Component\HttpKernel\Controller\ErrorController;
use App\Http\Controllers\my_fav_plateController;
use App\Http\Controllers\airac_info;
use App\Http\Controllers\CarteSIAController;

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -422,20 +423,7 @@
}
})->name("pirep.create");

Route::post("/create", function (Request $request) {
$value = $request->all();
$pirep = new PirepController();
$pirep->create_for_website($value);
return redirect()->route("pirep.index");
})->name("pirep.create");

Route::get("/upload", function (Request $request) {
if (!Auth::user()) {
return redirect()->route("auth.login");
} else {
return view("pirep.upload-fpl");
}
})->name("pirep.upload");

Route::post("/upload", function (Request $request) {
$request->validate([
Expand Down Expand Up @@ -629,13 +617,45 @@
$airac = new airac_info();
$airport = "LFMT";
$Rwy = "30R";
$airac2 = $airac->get_approach($airport );
$airac2 = $airac->get_approach($airport);
$airac1 = $airac->get_departure($airport);
$ils = $airac->get_ils_information($airport, $Rwy);

$airac3 = collect(["departure" => $airac1, "arrival" => $airac2, "ils" => $ils]);

return $airac3;

});

Route::get("vac", function (Request $request) {
return view("vac.index");
})->name("vac.index");

Route::get("vac/{icao}", function (Request $request) {
$request->merge([
"icao" => $request->icao
]);
$icao = strtoupper($request->icao);
$regex_for_icao = "/[A-Za-z]{2}(?:\d{4}|[A-Za-z]{2})/";
if (!preg_match($regex_for_icao, $icao)) {
return response()->json(["error" => "Icao not valid"], 400);
}
if (strlen($icao) == 4) {
$chart_sia = new CarteSIAController();
$chart = $chart_sia->chartVFR($icao);
if ($chart == null) {
return response()->json(["error" => "Icao not valid"], 400);
}
$req = http::get($chart);
if ($req->status() != 200) {
return response()->json(["error" => "Icao not valid2"], 400);
}
return response($req->body(), 200)->header('Content-Type', 'application/pdf');
}
$req = http::get("https://basulm.ffplum.fr/PDF/" . $icao . ".pdf");
if ($req->status() != 200) {
return response()->json(["error" => "Icao not valid2"], 400);
}
return response($req->body(), 200)->header('Content-Type', 'application/pdf');
//return $airac;
})->name("vac.icao");
});

0 comments on commit 2079ef5

Please sign in to comment.