function wpcf7_ajax_json_echo() { if ('POST' != $_SERVER['REQUEST_METHOD'] || !isset($_POST['_wpcf7_is_ajax_call'])) { return; } $echo = ''; if (isset($_POST['_wpcf7'])) { $id = (int) $_POST['_wpcf7']; $unit_tag = wpcf7_sanitize_unit_tag($_POST['_wpcf7_unit_tag']); if ($contact_form = wpcf7_contact_form($id)) { WPCF7_ContactForm::set_current($contact_form); $items = array('mailSent' => false, 'into' => '#' . $unit_tag, 'captcha' => null); $result = $contact_form->submit(true); if (!empty($result['message'])) { $items['message'] = $result['message']; } if ($result['mail_sent']) { $items['mailSent'] = true; } if (!$result['valid']) { $invalids = array(); foreach ($result['invalid_reasons'] as $name => $reason) { $invalid = array('into' => 'span.wpcf7-form-control-wrap.' . sanitize_html_class($name), 'message' => $reason); if (isset($result['invalid_fields'][$name]) && wpcf7_is_name($result['invalid_fields'][$name])) { $invalid['idref'] = $result['invalid_fields'][$name]; } $invalids[] = $invalid; } $items['invalids'] = $invalids; } if ($result['spam']) { $items['spam'] = true; } if (!empty($result['scripts_on_sent_ok'])) { $items['onSentOk'] = $result['scripts_on_sent_ok']; } if (!empty($result['scripts_on_submit'])) { $items['onSubmit'] = $result['scripts_on_submit']; } $items = apply_filters('wpcf7_ajax_json_echo', $items, $result); WPCF7_ContactForm::reset_current(); } } $echo = json_encode($items); if (wpcf7_is_xhr()) { @header('Content-Type: application/json; charset=' . get_option('blog_charset')); echo $echo; } else { @header('Content-Type: text/html; charset=' . get_option('blog_charset')); echo '<textarea>' . $echo . '</textarea>'; } exit; }
function wpcf7_ajax_json_echo() { $echo = ''; if (isset($_POST['_wpcf7'])) { $id = (int) $_POST['_wpcf7']; $unit_tag = wpcf7_sanitize_unit_tag($_POST['_wpcf7_unit_tag']); if ($contact_form = wpcf7_contact_form($id)) { $items = array('mailSent' => false, 'into' => '#' . $unit_tag, 'captcha' => null); $result = $contact_form->submit(true); if (!empty($result['message'])) { $items['message'] = $result['message']; } if ('mail_sent' == $result['status']) { $items['mailSent'] = true; } if ('validation_failed' == $result['status']) { $invalids = array(); foreach ($result['invalid_fields'] as $name => $field) { $invalids[] = array('into' => 'span.wpcf7-form-control-wrap.' . sanitize_html_class($name), 'message' => $field['reason'], 'idref' => $field['idref']); } $items['invalids'] = $invalids; } if ('spam' == $result['status']) { $items['spam'] = true; } if (!empty($result['scripts_on_sent_ok'])) { $items['onSentOk'] = $result['scripts_on_sent_ok']; } if (!empty($result['scripts_on_submit'])) { $items['onSubmit'] = $result['scripts_on_submit']; } $items = apply_filters('wpcf7_ajax_json_echo', $items, $result); } } $echo = json_encode($items); if (wpcf7_is_xhr()) { @header('Content-Type: application/json; charset=' . get_option('blog_charset')); echo $echo; } else { @header('Content-Type: text/html; charset=' . get_option('blog_charset')); echo '<textarea>' . $echo . '</textarea>'; } exit; }
function cf7_cognalys_control_init() { $settings = get_option('cf7_cognalys_addon'); $cognalys_app_id = $settings['cognalys_app_id']; $cognalys_access_token = $settings['cognalys_access_token']; if ($settings['cognalys_enabled'] != 1) { return; } if (!isset($_SERVER['REQUEST_METHOD'])) { return; } if ($_REQUEST['cf7_check_cognayls'] == 1) { $mobiles = $_REQUEST['mobile']; if ($mobiles != "") { $mobiles = split(',', $mobiles); $json = ""; foreach ($mobiles as $mobile) { $url = 'https://www.cognalys.com/api/v1/otp/?app_id=' . $cognalys_app_id . '&access_token=' . $cognalys_access_token . '&mobile=' . $mobile; if ($json != "") { $json .= ","; } $json .= file_get_contents($url); } $json = "[" . $json . "]"; if (wpcf7_is_xhr()) { @header('Content-Type: application/json; charset=' . get_option('blog_charset')); echo $json; } else { @header('Content-Type: text/html; charset=' . get_option('blog_charset')); echo '<textarea>' . $json . '</textarea>'; } } exit; } else { if ($_REQUEST['cf7_check_cognayls'] == 2) { $keymatchs = $_REQUEST['keymatch']; $otps = $_REQUEST['otp']; if ($keymatchs != "") { $keymatchs = split(',', $keymatchs); $otps = split(',', $otps); $json = ""; for ($i = 0; $i < count($keymatchs); $i++) { $keymatch = $keymatchs[$i]; $otp = $otps[$i]; $url = 'https://www.cognalys.com/api/v1/otp/confirm/?app_id=' . $cognalys_app_id . '&access_token=' . $cognalys_access_token . '&keymatch=' . $keymatch . '&otp=' . $otp; if ($json != "") { $json .= ","; } $json .= file_get_contents($url); } $json = "[" . $json . "]"; if (wpcf7_is_xhr()) { @header('Content-Type: application/json; charset=' . get_option('blog_charset')); echo $json; } else { @header('Content-Type: text/html; charset=' . get_option('blog_charset')); echo '<textarea>' . $json . '</textarea>'; } } exit; } } }