DB Entities, SQL Update
This commit is contained in:
@@ -95,8 +95,6 @@ namespace Api\Contact {
|
||||
if (!$insertDB) {
|
||||
$message .= " Mail: $dbError";
|
||||
}
|
||||
|
||||
error_log($message);
|
||||
}
|
||||
|
||||
if (!$sendMail && !$insertDB) {
|
||||
|
||||
@@ -182,13 +182,14 @@ namespace Api\Mail {
|
||||
$this->success = @$mail->Send();
|
||||
if (!$this->success) {
|
||||
$this->lastError = "Error sending Mail: $mail->ErrorInfo";
|
||||
error_log("sendMail() failed: $mail->ErrorInfo");
|
||||
$this->logger->error("sendMail() failed: $mail->ErrorInfo");
|
||||
} else {
|
||||
$this->result["messageId"] = $mail->getLastMessageID();
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->success = false;
|
||||
$this->lastError = "Error sending Mail: $e";
|
||||
$this->logger->error($this->lastError);
|
||||
}
|
||||
|
||||
return $this->success;
|
||||
|
||||
@@ -6,6 +6,12 @@ use Driver\Logger\Logger;
|
||||
use Objects\User;
|
||||
use PhpMqtt\Client\MqttClient;
|
||||
|
||||
/**
|
||||
* TODO: we need following features, probably as abstract/generic class/method:
|
||||
* - easy way for pagination (select with limit/offset)
|
||||
* - CRUD Endpoints/Objects (Create, Update, Delete)
|
||||
*/
|
||||
|
||||
abstract class Request {
|
||||
|
||||
protected User $user;
|
||||
|
||||
@@ -35,7 +35,7 @@ class Stats extends Request {
|
||||
return ($this->success ? $res[0]["count"] : 0);
|
||||
}
|
||||
|
||||
private function checkSettings() {
|
||||
private function checkSettings(): bool {
|
||||
$req = new \Api\Settings\Get($this->user);
|
||||
$this->success = $req->execute(array("key" => "^(mail_enabled|recaptcha_enabled)$"));
|
||||
$this->lastError = $req->getLastError();
|
||||
|
||||
@@ -17,10 +17,10 @@ class VerifyCaptcha extends Request {
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$settings = $this->user->getConfiguration()->getSettings();
|
||||
if (!$settings->isRecaptchaEnabled()) {
|
||||
return $this->createError("Google reCaptcha is not enabled.");
|
||||
}
|
||||
$settings = $this->user->getConfiguration()->getSettings();
|
||||
if (!$settings->isRecaptchaEnabled()) {
|
||||
return $this->createError("Google reCaptcha is not enabled.");
|
||||
}
|
||||
|
||||
$url = "https://www.google.com/recaptcha/api/siteverify";
|
||||
$secret = $settings->getRecaptchaSecretKey();
|
||||
@@ -33,12 +33,12 @@ class VerifyCaptcha extends Request {
|
||||
);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL,$url);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$response = @json_decode(curl_exec($ch), true);
|
||||
curl_close ($ch);
|
||||
curl_close($ch);
|
||||
|
||||
$this->success = false;
|
||||
$this->lastError = "Could not verify captcha: No response from google received.";
|
||||
@@ -49,10 +49,9 @@ class VerifyCaptcha extends Request {
|
||||
$this->lastError = "Could not verify captcha: " . implode(";", $response["error-codes"]);
|
||||
} else {
|
||||
$score = $response["score"];
|
||||
if($action !== $response["action"]) {
|
||||
if ($action !== $response["action"]) {
|
||||
$this->createError("Could not verify captcha: Action does not match");
|
||||
}
|
||||
else if($score < 0.7) {
|
||||
} else if ($score < 0.7) {
|
||||
$this->createError("Could not verify captcha: Google ReCaptcha Score < 0.7 (Your score: $score), you are likely a bot");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user