Skip to content
Snippets Groups Projects
Verified Commit b818a962 authored by Jonas Leder's avatar Jonas Leder
Browse files

reformat file and fix new comment function

parent fa710926
Branches
Tags
1 merge request!8Rewrite API endpoint to graphql
......@@ -15,7 +15,8 @@ $commentField = new ObjectType([
],
]);
function comments($article, $conn) {
function comments($article, $conn)
{
$response = [];
$result = $conn->query("SELECT * FROM comments WHERE article='$article'");
while ($row = $result->fetch_assoc()) {
......@@ -29,10 +30,10 @@ function comments($article, $conn) {
array_push($response, $commentElement);
}
return $response;
}
function newComment($conn, $article, $name, $email, $comment, $hCaptchaResponse) {
function newComment($conn, $article, $name, $email, $comment, $hCaptchaResponse)
{
require "./lib/config.php";
$data = array(
'secret' => $secretkey,
......@@ -47,6 +48,7 @@ function newComment($conn, $article, $name, $email, $comment, $hCaptchaResponse)
$responseData = json_decode($response->getBody());
if (!$responseData->success) {
return "Failed to verify Captcha";
}
$article = $conn->escape_string($article);
$name = $conn->escape_string($name);
......@@ -61,5 +63,3 @@ function newComment($conn, $article, $name, $email, $comment, $hCaptchaResponse)
return "Error: " . $sql . "<br>" . $conn->error;
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment