92 lines
3.3 KiB
PHP
92 lines
3.3 KiB
PHP
<?php
|
|
|
|
class Contact extends CI_Controller {
|
|
|
|
public function index() {
|
|
|
|
$data['title'] = "Contact"; // Capitalize the first letter
|
|
$data['page_title'] = "Contact WrenchBoard";
|
|
|
|
$message = "";
|
|
|
|
$email = NULL;
|
|
$firstname = NULL;
|
|
$lastname = NULL;
|
|
$your_message = NULL;
|
|
$submit = NULL;
|
|
$data['message'] ='';
|
|
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');
|
|
$your_message = $this->input->post('msg');
|
|
|
|
if ($firstname == '' || $lastname == '') {
|
|
$message = 'Both first and last name are required';
|
|
}
|
|
|
|
if ($your_message=='' || strlen($your_message)>500) {
|
|
$message = 'Message is required and must be up to 500 characters long';
|
|
}
|
|
|
|
if ($email=='' || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
$message = 'Invalid e-mail';
|
|
}
|
|
|
|
if ($message == '') {
|
|
$data['email'] = $email;
|
|
$data['firstname'] = $firstname;
|
|
$data['lastname'] = $lastname;
|
|
$data['your_message'] = $your_message;
|
|
$data['loc'] = $_SERVER['REMOTE_ADDR']; //'38.101.241.200';
|
|
$data['action'] = WRENCHBOARD_SEND_CONTACTUS;
|
|
$this->load->model('backend_model');
|
|
$out = array();
|
|
$res = $this->backend_model->wrenchboard_api($data, $out);
|
|
$message = "Your message was sent";
|
|
$email = $firstname = $lastname = $your_message = "";
|
|
} else {
|
|
//$message = 'Invalid input';
|
|
$your_message = substr($your_message,0,500);
|
|
}
|
|
$data['message'] = "<div class=\"text-left\"><div class=\"alert alert-info no-border\">" . $message . "</div></div>";
|
|
}
|
|
|
|
// $data['message'] = $message;
|
|
$data['email'] = $email;
|
|
$data['firstname'] = $firstname;
|
|
$data['lastname'] = $lastname;
|
|
$data['msg'] = $your_message;
|
|
|
|
//print_r($data);
|
|
$this->load->view('templates/header_boxed', $data);
|
|
$this->load->view('users/view_contact', $data);
|
|
$this->load->view('users/view_external_footer', $data);
|
|
}
|
|
|
|
}
|