From d79ee71389f9160f4cd82845917c4c41e7fde3f6 Mon Sep 17 00:00:00 2001 From: Thedro Neely Date: Thu, 28 Mar 2019 21:24:35 -0400 Subject: app/controllers/contact: Refactor contact controller Use single contact route --- app/model/Form.php | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) (limited to 'app/model') diff --git a/app/model/Form.php b/app/model/Form.php index 23e5613..7d972e7 100644 --- a/app/model/Form.php +++ b/app/model/Form.php @@ -8,43 +8,30 @@ class Form public $name; public $email; public $message; - - public function __construct($name, $email, $message) - { - $this->name = $name; - $this->email = $email; - $this->message = $message; - - $this->isSpam(); - $this->isEmpty(); - } + public $spam; public function isSpam() { - $spam = false; - - if (isset($_POST['contact'])) { - $spam = $_POST['contact']; - } - - if ((bool) $spam == true) { - http_response_code(403); + if ((bool) $this->spam == true) { error_log('Contact Form Spam: Error 403'); - exit; + return true; } } public function isEmpty() { - if ((bool) empty($this->name) == true - || (bool) empty($this->email) == true + if ((bool) empty($this->email) == true || (bool) empty($this->message) == true ) { - header('Location: /contact/'); - exit; + return true; } } + public function isEmailValid() + { + return $email = PHPMailer::validateAddress($this->email, 'auto'); + } + public function isSubmit() { // Include mail config @@ -54,7 +41,6 @@ class Form try { //Server settings - //$mail->SMTPDebug = 2; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = $config['mail']['host']; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication -- cgit v1.2.3