diff --git a/js/customElements/commentsDisplay.js b/js/customElements/commentsDisplay.js index 91984cf3333c721241085d269617266516c0324d..b165ebff3c6121168096a9b1e58f1800d4401b5b 100644 --- a/js/customElements/commentsDisplay.js +++ b/js/customElements/commentsDisplay.js @@ -3,7 +3,6 @@ class commentsDisplay extends HTMLElement { super(); let path = window.location.pathname; let pageName = path.split("/").pop(); - pageName = pageName.split(".")[0] let xhr = new XMLHttpRequest(); xhr.onreadystatechange = () => { diff --git a/js/customElements/newComment.js b/js/customElements/newComment.js index bf92254cce872308ab1f357377191cb45c8814a7..b150dd82916c2afe3fe4997f8ece5873f375d52d 100644 --- a/js/customElements/newComment.js +++ b/js/customElements/newComment.js @@ -16,7 +16,7 @@ class newComment extends HTMLElement { <input type="text" id="email" name="email"><br><br> <label for="comment">Kommentar:</label><br> - <textarea name="commebodynt" id="comment"></textarea><br><br> + <textarea name="comment" id="comment"></textarea><br><br> <div class="h-captcha" data-theme="dark" data-sitekey="${sitekey}"></div><br> diff --git a/public/API/composer.json b/public/API/composer.json index 77abbce4edac16b908bf7147da901dd36b34abaf..35c133c9a1c09a7f87ff83b93a51219781464d2b 100644 --- a/public/API/composer.json +++ b/public/API/composer.json @@ -1,6 +1,7 @@ { "require": { "aws/aws-sdk-php": "^3.181", - "symforge/chilkat-php": "9.5.0.66" + "symforge/chilkat-php": "9.5.0.66", + "guzzlehttp/guzzle": "^7.0" } } diff --git a/public/API/composer.lock b/public/API/composer.lock index c61f148ace6aa332608d53b535ed564e7d88fd69..a2b14da79e82c47cfc2ebbc62cf8ec2bece25d03 100644 --- a/public/API/composer.lock +++ b/public/API/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f1824e693565797fc0614d71a8f79648", + "content-hash": "2183fbeff4a5ee254a85bd0ba5c86597", "packages": [ { "name": "aws/aws-sdk-php", @@ -670,5 +670,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.1.0" } diff --git a/public/API/getMail.php b/public/API/getMail.php index f10a90f38b208d13bddadbdd7430e409c05e2b9c..b2f438b113e2f7f78d036114fd6212d49096c500 100644 --- a/public/API/getMail.php +++ b/public/API/getMail.php @@ -1,20 +1,20 @@ <?php include("./lib/config.php"); + +require("./vendor/autoload.php"); +use GuzzleHttp\Client; + $data = array( 'secret' => $secretkey, 'response' => $_POST['h-captcha-response'] ); +$client = new Client(); -$verify = curl_init(); -curl_setopt($verify, CURLOPT_URL, "https://hcaptcha.com/siteverify"); -curl_setopt($verify, CURLOPT_POST, true); -curl_setopt($verify, CURLOPT_POSTFIELDS, http_build_query($data)); -curl_setopt($verify, CURLOPT_RETURNTRANSFER, true); -$response_ = curl_exec($verify); -$responseData = json_decode($response_); - - +$response = $client->post("https://hcaptcha.com/siteverify", [ + "form_params" => $data +]); +$responseData = json_decode($response->getBody()); if($responseData->success) { echo("$contactmail"); } else { diff --git a/public/API/newComment.php b/public/API/newComment.php index 860a81b15436493788daff557ce87f2aa84ec541..c9e293e9a8e3f391dfee2aff286e5df16cd3f175 100644 --- a/public/API/newComment.php +++ b/public/API/newComment.php @@ -1,19 +1,22 @@ <?php +require './vendor/autoload.php'; include("./lib/config.php"); include("./lib/mysql.php"); +use GuzzleHttp\Client; + $data = array( 'secret' => $secretkey, 'response' => $_POST['h-captcha-response'] ); -$verify = curl_init(); -curl_setopt($verify, CURLOPT_URL, "https://hcaptcha.com/siteverify"); -curl_setopt($verify, CURLOPT_POST, true); -curl_setopt($verify, CURLOPT_POSTFIELDS, http_build_query($data)); -curl_setopt($verify, CURLOPT_RETURNTRANSFER, true); -$response_ = curl_exec($verify); -$responseData = json_decode($response_); +$client = new Client(); + +$response = $client->post("https://hcaptcha.com/siteverify", [ + "form_params" => $data +]); + +$responseData = json_decode($response->getBody());