Ejemplo n.º 1
0
 function init()
 {
     if (function_exists('of_get_option')) {
         Dt_Captcha::$hide_register = of_get_option('captcha_hide_register', true);
         Dt_Captcha::$math_action_minus = of_get_option('captcha_math_action_minus', true);
         Dt_Captcha::$math_action_increase = of_get_option('captcha_math_action_increase', true);
         Dt_Captcha::$label_form = of_get_option('captcha_label_form', '');
         Dt_Captcha::$difficulty_number = of_get_option('captcha_difficulty_number', true);
         Dt_Captcha::$difficulty_word = of_get_option('captcha_difficulty_word', true);
     }
     // hopefuly add captcha theme options page
     add_filter('optionsframework_options', array('Dt_Captcha', 'add_options'));
     add_action('dt_contact_form_captcha_place', 'dt_add_captcha_to_form', 10, 1);
 }
Ejemplo n.º 2
0
/**
 * Mail function.
 */
function dt_check_current_date()
{
    $place = isset($_POST['send_contacts']) ? trim($_POST['send_contacts']) : '';
    $honey_msg = isset($_POST['send_message']) ? trim($_POST['send_message']) : '';
    $name = isset($_POST['f_name']) ? trim(strip_tags($_POST['f_name'])) : '';
    $email = isset($_POST['f_email']) ? trim(strip_tags($_POST['f_email'])) : '';
    $phone = isset($_POST['f_phone']) ? trim(strip_tags($_POST['f_phone'])) : '';
    $website = isset($_POST['f_website']) ? trim(strip_tags($_POST['f_website'])) : '';
    $msg = isset($_POST['f_comment']) ? trim(strip_tags($_POST['f_comment'])) : '';
    $captcha = isset($_POST['cptch_number']) ? trim(strip_tags($_POST['cptch_number'])) : '';
    $pid = isset($_POST['pid']) ? intval($_POST['pid']) : false;
    $nonce = isset($_POST['nonce']) ? $_POST['nonce'] : false;
    $send = false;
    $errors = '';
    Dt_Captcha::session_check();
    $check = Dt_Captcha::check($captcha, $place);
    if (!wp_verify_nonce($nonce, 'dt_contact_' . $place)) {
        $errors = _x('Nonce do not match', 'feedback msg', LANGUAGE_ZONE);
    } elseif (2 == $check) {
        $errors = _x('Captcha filled incorrectly', 'feedback msg', LANGUAGE_ZONE);
    } elseif (3 == $check) {
        $errors = _x('Fill the captcha', 'feedback msg', LANGUAGE_ZONE);
    } elseif ($name && $email && $msg && 1 == $check && !$honey_msg) {
        if ($pid) {
            $data = get_post_meta($pid, 'contact_options', true);
            $em = !empty($data['target_email']) ? strip_tags($data['target_email']) : get_option('admin_email');
        } else {
            $em = get_option('admin_email');
        }
        $headers = 'From: ' . esc_attr(strip_tags($name)) . ' <' . esc_html($email) . '>' . "\r\n";
        $headers .= 'Reply-To: ' . esc_html($email) . "\r\n";
        $msg_mail = _x('Name: ', 'feedback mail', LANGUAGE_ZONE) . esc_html($name) . "\n";
        $msg_mail .= _x('Email: ', 'feedback mail', LANGUAGE_ZONE) . esc_html($email) . "\n";
        if (!empty($phone)) {
            $msg_mail .= _x('Telephone: ', 'feedback mail', LANGUAGE_ZONE) . esc_html($phone) . "\n";
        }
        if (!empty($website)) {
            $msg_mail .= _x('Website: ', 'feedback mail', LANGUAGE_ZONE) . esc_html($website) . "\n";
        }
        $msg_mail .= _x('Message: ', 'feedback mail', LANGUAGE_ZONE) . esc_html($msg) . "\n";
        $send = wp_mail($em, '[Feedback from: ' . esc_attr(get_option('blogname')) . ']', $msg_mail, $headers);
        if ($send) {
            $errors = _x('Feedback has been sent to the administrator', 'feedback msg', LANGUAGE_ZONE);
        } else {
            $errors = _x('The message has not been sent', 'feedback msg', LANGUAGE_ZONE);
        }
        $nonce = wp_create_nonce('dt_contact_' . $place);
    } elseif ($honey_msg) {
        $errors = _x('Sorry, we suspect that you are bot', 'feedback', LANGUAGE_ZONE);
    }
    $captcha = '';
    if (Dt_Captcha::$global_enable) {
        $c_form = new Dt_Captcha(array('whoami' => $place, 'rewrite' => false));
        $captcha = $c_form->get_captcha();
    }
    //wp_nonce_field('dt_contact_'.$place,'dt_contact_form_nonce', false, false);
    $response = json_encode(array('success' => $send, 'errors' => $errors, 'captcha' => $captcha, 'nonce' => $nonce));
    // response output
    header("Content-Type: application/json");
    echo $response;
    // IMPORTANT: don't forget to "exit"
    exit;
}