From abe8db6e8b33ae83a3e1ae1cc0aaafa535b4b9ce Mon Sep 17 00:00:00 2001 From: Jonas Leder Date: Tue, 8 Mar 2022 12:46:06 +0100 Subject: [PATCH] get impressum mail from graphQL --- public/API/getMail.php | 22 ---------------------- public/API/queries/mailAddress.php | 22 ++++++++++++++++++++++ public/API/queries/queries.php | 8 ++++++++ public/impressum.html | 30 +++++++++++++++++------------- 4 files changed, 47 insertions(+), 35 deletions(-) delete mode 100644 public/API/getMail.php create mode 100644 public/API/queries/mailAddress.php diff --git a/public/API/getMail.php b/public/API/getMail.php deleted file mode 100644 index b2f438b..0000000 --- a/public/API/getMail.php +++ /dev/null @@ -1,22 +0,0 @@ - $secretkey, - 'response' => $_POST['h-captcha-response'] -); -$client = new Client(); - -$response = $client->post("https://hcaptcha.com/siteverify", [ - "form_params" => $data -]); - -$responseData = json_decode($response->getBody()); -if($responseData->success) { - echo("$contactmail"); -} else { - echo("Failed to verify Captcha"); -} \ No newline at end of file diff --git a/public/API/queries/mailAddress.php b/public/API/queries/mailAddress.php new file mode 100644 index 0000000..df35464 --- /dev/null +++ b/public/API/queries/mailAddress.php @@ -0,0 +1,22 @@ + $secretkey, + 'response' => $hCaptchaResponse + ); + $client = new Client(); + + $response = $client->post("https://hcaptcha.com/siteverify", [ + "form_params" => $data + ]); + + $responseData = json_decode($response->getBody()); + if($responseData->success) { + return "$contactmail"; + } else { + return "Failed to verify Captcha"; + } +} \ No newline at end of file diff --git a/public/API/queries/queries.php b/public/API/queries/queries.php index fe1d471..e755805 100644 --- a/public/API/queries/queries.php +++ b/public/API/queries/queries.php @@ -5,6 +5,7 @@ use GraphQL\Type\Definition\Type; require "./queries/skills.php"; require "./queries/blogPost.php"; require "./queries/comments.php"; +require "./queries/mailAddress.php"; $queryType = new ObjectType([ 'name' => 'Query', @@ -13,6 +14,13 @@ $queryType = new ObjectType([ 'type' => Type::string(), 'resolve' => fn ($rootValue, $args) => $sitekey, ], + 'mailAddress' => [ + 'type' => Type::string(), + "args" => [ + "hCaptchaResponse" => Type::string() + ], + 'resolve' => fn ($rootValue, $args) => mailAddress($args["hCaptchaResponse"]), + ], 'skills' => [ 'type' => Type::listOf(Type::string()), 'resolve' => fn ($rootValue, $args) => getSkills(), diff --git a/public/impressum.html b/public/impressum.html index 92ca021..55ec96f 100644 --- a/public/impressum.html +++ b/public/impressum.html @@ -49,20 +49,24 @@ Privacy Policy and Terms of Service apply.