reformat file and fix new comment function
This commit is contained in:
parent
fa7109260e
commit
b818a962d5
1 changed files with 21 additions and 21 deletions
|
@ -15,7 +15,8 @@ $commentField = new ObjectType([
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function comments($article, $conn) {
|
function comments($article, $conn)
|
||||||
|
{
|
||||||
$response = [];
|
$response = [];
|
||||||
$result = $conn->query("SELECT * FROM comments WHERE article='$article'");
|
$result = $conn->query("SELECT * FROM comments WHERE article='$article'");
|
||||||
while ($row = $result->fetch_assoc()) {
|
while ($row = $result->fetch_assoc()) {
|
||||||
|
@ -29,10 +30,10 @@ function comments($article, $conn) {
|
||||||
array_push($response, $commentElement);
|
array_push($response, $commentElement);
|
||||||
}
|
}
|
||||||
return $response;
|
return $response;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function newComment($conn, $article, $name, $email, $comment, $hCaptchaResponse) {
|
function newComment($conn, $article, $name, $email, $comment, $hCaptchaResponse)
|
||||||
|
{
|
||||||
require "./lib/config.php";
|
require "./lib/config.php";
|
||||||
$data = array(
|
$data = array(
|
||||||
'secret' => $secretkey,
|
'secret' => $secretkey,
|
||||||
|
@ -47,6 +48,7 @@ function newComment($conn, $article, $name, $email, $comment, $hCaptchaResponse)
|
||||||
$responseData = json_decode($response->getBody());
|
$responseData = json_decode($response->getBody());
|
||||||
if (!$responseData->success) {
|
if (!$responseData->success) {
|
||||||
return "Failed to verify Captcha";
|
return "Failed to verify Captcha";
|
||||||
|
}
|
||||||
|
|
||||||
$article = $conn->escape_string($article);
|
$article = $conn->escape_string($article);
|
||||||
$name = $conn->escape_string($name);
|
$name = $conn->escape_string($name);
|
||||||
|
@ -61,5 +63,3 @@ function newComment($conn, $article, $name, $email, $comment, $hCaptchaResponse)
|
||||||
return "Error: " . $sql . "<br>" . $conn->error;
|
return "Error: " . $sql . "<br>" . $conn->error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in a new issue