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

Commit

Permalink
FIX #125 (#130)
Browse files Browse the repository at this point in the history
* Feacture

* testing

* Fixed Tracker

* changelog

* correct Email

* FIX php - How to protect .env file in Laravel - Stack Overflow #125
  • Loading branch information
alexcaussades authored Nov 19, 2023
1 parent 13a3720 commit f6b0def
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 59 deletions.
77 changes: 47 additions & 30 deletions app/Http/Controllers/DiscordContoller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand All @@ -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,
]);
Expand All @@ -94,6 +113,4 @@ public function url_discord_for_code(Request $request){
];
return $url["code"];
}


}
74 changes: 49 additions & 25 deletions app/Http/Controllers/GithubController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

31 changes: 27 additions & 4 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down Expand Up @@ -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;
});

0 comments on commit f6b0def

Please sign in to comment.