Файл: sngine-v2.8/Updates/Update 2.5.8 to 2.5.9/Update_2.5.9/includes/ajax/core/contact.php
Строк: 60
<?php
/**
* ajax -> core -> contact
*
* @package Sngine
* @author Zamblek
*/
// fetch bootstrap
require('../../../bootstrap.php');
// check AJAX Request
is_ajax();
// contact
try {
// valid inputs
if(is_empty($_POST['name']) || is_empty($_POST['email']) || is_empty($_POST['subject']) || is_empty($_POST['message']) ) {
throw new Exception(__("You must fill in all of the fields"));
}
if(!valid_email($_POST['email'])) {
throw new Exception(__("Please enter a valid email address"));
}
/* check reCAPTCHA */
if($system['reCAPTCHA_enabled']) {
require_once(ABSPATH.'includes/libs/ReCaptcha/autoload.php');
$recaptcha = new ReCaptchaReCaptcha($system['reCAPTCHA_secret_key']);
$resp = $recaptcha->verify($_POST['g-recaptcha-response'], get_user_ip());
if (!$resp->isSuccess()) {
throw new Exception(__("The security check is incorrect. Please try again"));
}
}
// prepare email
$subject = "New email message from ".$system['system_title'];
$body = "Hi Admin, rnrn";
$body .= "You have a new email message rnrn";
$body .= "Email Subject: rn".$_POST['subject']."rnrn";
$body .= "Email Message: rn".$_POST['message']."rnrn";
$body .= "Sender Name: rn".$_POST['name']."rnrn";
$body .= "Sender Email: rn".$_POST['email']."rnrn";
// send email
if(!_email($system['system_email'], $subject, $body)) {
throw new Exception(__("Your email could not be sent. Please try again later"));
}
// return
return_json( array('success' => true, 'message' => __("Your message has been sent! Thanks a lot and will be back to you soon")) );
} catch (Exception $e) {
return_json( array('error' => true, 'message' => $e->getMessage()) );
}
?>