From f4adc4ab3dbfb0ed726295d722e42be12cddf7ce Mon Sep 17 00:00:00 2001 From: Olusesan Ameye Date: Tue, 3 Nov 2020 14:09:15 -0500 Subject: [PATCH] hCaptcha --- www/application/controllers/Contact.php | 23 +++++++++++++- www/application/views/users/view_contact.php | 32 ++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/www/application/controllers/Contact.php b/www/application/controllers/Contact.php index 94337a2d..2009438b 100644 --- a/www/application/controllers/Contact.php +++ b/www/application/controllers/Contact.php @@ -18,7 +18,28 @@ class Contact extends CI_Controller { extract($_POST); if ($_POST) { - + $resp = $this->input->post('h-captcha-response'); + $secret = "0x608809f0227f7FA577E069524805cC25f5E732C0"; + $url = "https://hcaptcha.com/siteverify"; + $data = array( + "secret" => $secret, + "response" => $resp + ); + $ch = curl_init(); + curl_setopt($ch,CURLOPT_URL, $url); + curl_setopt($ch,CURLOPT_POST, count($data)); + curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($data)); + curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE); + $result = curl_exec($ch); + curl_close($ch); + $captcha = json_decode($result,true); + if (is_array($captcha) && array_key_exists("success",$captcha) && $captcha["success"]) { + // Ok + $message = ''; + } else { + $message = 'Please verify that you are human'; + } + $email = $this->input->post('email'); $firstname = $this->input->post('firstname'); $lastname = $this->input->post('lastname'); diff --git a/www/application/views/users/view_contact.php b/www/application/views/users/view_contact.php index 3c710896..7a676c68 100644 --- a/www/application/views/users/view_contact.php +++ b/www/application/views/users/view_contact.php @@ -91,6 +91,36 @@ + + +
+ +
+
+ +
+
+
@@ -116,3 +146,5 @@
+ +