コード例 #1
0
ファイル: page-contact.php プロジェクト: alikris/OTA
$contact_message = '';
$contact_email = '';
$contact_name = '';
if (isset($_POST['contact_submit'])) {
    $form_submitted = true;
    if (empty($_POST) || !wp_verify_nonce($_POST['contact_form_nonce'], 'contact_form')) {
        // failed to verify nonce so exit.
        exit;
    } else {
        // process form data since nonce was verified
        $contact_message = wp_kses($_POST['contact_message'], '');
        $contact_email = wp_kses($_POST['contact_email'], '');
        $contact_name = wp_kses($_POST['contact_name'], '');
        $c_val_s = intval(wp_kses($_POST['c_val_s'], ''));
        $c_val_1 = intval(BYT_Theme_Utils::decrypt(wp_kses($_POST['c_val_1'], ''), $enc_key));
        $c_val_2 = intval(BYT_Theme_Utils::decrypt(wp_kses($_POST['c_val_2'], ''), $enc_key));
        if ($add_captcha_to_forms && $c_val_s != $c_val_1 + $c_val_2) {
            $contact_error = __('Invalid captcha, please try again!', 'bookyourtravel');
        } else {
            if (!empty($contact_name) && !empty($contact_email) && !empty($contact_message)) {
                $email_to = get_option('admin_email');
                if (!empty($business_contact_email)) {
                    $email_to = $business_contact_email;
                }
                $subject = sprintf(__('Contact form submission from %s', 'bookyourtravel'), $contact_name);
                $body = sprintf(__("Name: %s\n\nEmail: %s\n\nMessage: %s", 'bookyourtravel'), $contact_name, $contact_email, $contact_message);
                $headers = 'From: ' . $contact_name . ' <' . $contact_email . '>' . "\r\n" . 'Reply-To: ' . $contact_email;
                wp_mail($email_to, $subject, $body, $headers);
            } else {
                $contact_error = __('To submit contact form, please enable JavaScript', 'bookyourtravel');
            }
コード例 #2
0
 function inquiry_ajax_request()
 {
     global $byt_theme_globals;
     if (isset($_REQUEST)) {
         $enc_key = $byt_theme_globals->get_enc_key();
         $add_captcha_to_forms = $byt_theme_globals->add_captcha_to_forms();
         $your_name = wp_kses($_REQUEST['your_name'], '');
         $your_email = wp_kses($_REQUEST['your_email'], '');
         $your_phone = wp_kses($_REQUEST['your_phone'], '');
         $your_message = wp_kses($_REQUEST['your_message'], '');
         $postId = intval(wp_kses($_REQUEST['postId'], ''));
         $user_id = intval(wp_kses($_REQUEST['userId'], ''));
         $c_val_s = intval(wp_kses($_REQUEST['c_val_s'], ''));
         $c_val_1_str = BYT_Theme_Utils::decrypt(wp_kses($_REQUEST['c_val_1'], ''), $enc_key);
         $c_val_2_str = BYT_Theme_Utils::decrypt(wp_kses($_REQUEST['c_val_2'], ''), $enc_key);
         $c_val_1 = intval($c_val_1_str);
         $c_val_2 = intval($c_val_2_str);
         $nonce = $_REQUEST['nonce'];
         if (wp_verify_nonce($nonce, 'byt-ajax-nonce')) {
             if ($add_captcha_to_forms && $c_val_s != $c_val_1 + $c_val_2) {
                 echo 'captcha_error';
                 die;
             } else {
                 // nonce passed ok
                 $post = get_post($postId);
                 if ($post) {
                     $admin_email = get_bloginfo('admin_email');
                     $contact_email = get_post_meta($postId, $post->post_type . '_contact_email', true);
                     $contact_emails = explode(';', $contact_email);
                     if (empty($contact_email)) {
                         $contact_emails = array($admin_email);
                     }
                     $subject = __('New inquiry', 'bookyourtravel');
                     $message = __("The following inquiry has just arrived: \n Name: %s \n Email: %s \n Phone: %s \n Message: %s \n Inquiring about: %s \n", 'bookyourtravel');
                     $message = sprintf($message, $your_name, $your_email, $your_phone, $your_message, $post->post_title);
                     $headers = array();
                     $headers[] = "MIME-Version: 1.0";
                     $headers[] = "Content-type: text/plain; charset=utf-8";
                     $headers[] = "From: " . get_bloginfo('name') . " <" . $admin_email . ">";
                     $headers[] = "Reply-To: " . get_bloginfo('name') . " <" . $admin_email . ">";
                     $headers[] = "X-Mailer: PHP/" . phpversion();
                     $headers_str = implode("\r\n", $headers);
                     foreach ($contact_emails as $email) {
                         if (!empty($email)) {
                             wp_mail($email, $subject, $message, $headers_str, '-f ' . $admin_email);
                         }
                     }
                 }
             }
         }
     }
     // Always die in functions echoing ajax content
     die;
 }