function ebd_process_email_form($cf7)
{
    if (isset($_POST['_wpcf7_download_id'])) {
        global $wpdb, $wp_dlm_root, $wp_dlm_db, $wp_dlm_db_taxonomies, $def_format, $dlm_url, $downloadurl, $downloadtype, $wp_dlm_db_meta;
        //table names
        $table_item = $wpdb->prefix . "ebd_item";
        $table_link = $wpdb->prefix . "ebd_link";
        $table_posted_data = $wpdb->prefix . "ebd_posted_data";
        $delivered_as = get_option('email_before_download_send_email');
        $emailFrom = get_option('email_before_download_email_from');
        if (isset($_POST['email_from'])) {
            $emailFrom = htmlspecialchars_decode(urldecode($_POST['email_from']));
        }
        if (strlen($emailFrom) > 0) {
            $emailFrom = 'From: ' . $emailFrom . "\r\n";
        }
        $use_attachments = get_option('email_before_download_attachment');
        if (isset($_POST['delivered_as'])) {
            $delivered_as = $_POST['delivered_as'];
        }
        if (isset($_POST['attachment'])) {
            $use_attachments = trim($_POST['attachment']) == 'yes';
        }
        //check if email is allowed
        $email = $cf7->posted_data['your-email'];
        //compare email againts not allowed domains.
        $forbidden_domains = get_option('email_before_download_forbidden_domains');
        $domains = explode(',', $forbidden_domains);
        if (check_domains($email, $domains)) {
            $id = (int) $_POST['_wpcf7'];
            $unit_tag = $_POST['_wpcf7_unit_tag'];
            $items = array('mailSent' => false, 'into' => '#' . $unit_tag, 'captcha' => null);
            //error message
            $items['message'] = "The email that you provided is not allowed. Please provide another one.";
            $on_sent_ok = $cf7->additional_setting('on_sent_ok', false);
            $items['onSentOk'] = $on_sent_ok;
            $echo = json_encode($items);
            @header('Content-Type: application/json; charset=' . get_option('blog_charset'));
            echo $echo;
            die;
        }
        //get selected downloads
        $dIds = $_POST['ebd_downloads'];
        $dl_items = array();
        $multipleLinks = '';
        $message_mult = '';
        $attachments = array();
        $time_requested = time();
        $target = '_blank';
        //get all download monitor objects
        if ($dIds) {
            foreach ($dIds as $id) {
                $dl_it = $wpdb->get_row("SELECT * FROM {$wp_dlm_db}  WHERE id = " . $wpdb->escape($id) . ";");
                $dl_items[] = new downloadable_file($dl_it);
            }
        }
        //get edb items: it's common for all
        $dId = $_POST['_wpcf7_download_id'];
        $ebd_item = $wpdb->get_row("SELECT * FROM {$table_item}  WHERE id = " . $wpdb->escape($dId) . ";");
        //get single download, multible are comma separated so the $dl for this will be NULL
        $dl = $wpdb->get_row("SELECT * FROM {$wp_dlm_db}  WHERE id = " . $wpdb->escape($ebd_item->download_id) . ";");
        $d = new downloadable_file($dl);
        //variable for the title it wll be used only for the single downloads and the email subject
        $title = '';
        //echo 'debug: ' . $ebd_item->id . ' ' . $ebd_item->title;
        //print_r($ebd_item);
        $title = $ebd_item->title;
        if ($title == NULL || $title == '') {
            if ($ebd_item->file) {
                $title = basename($ebd_item->file);
            } else {
                $title = $d->title;
            }
        }
        $url = '';
        //titles and urls for multiple
        $titles = array();
        $urls = array();
        $innerHtml = '';
        //if checkboxes were selected
        if (count($dl_items) > 0) {
            foreach ($dl_items as $dl_item) {
                //generate unique id for the file (link)
                $uid = md5(uniqid(rand(), true));
                //expiration date if needed if it's 0 or NULL the link will never expire
                $expireAt = 0;
                if (get_option('email_before_download_expire_time') != NULL && get_option('email_before_download_expire_time') != "0") {
                    $expireAt = strtotime(get_option('email_before_download_expire_time'));
                }
                $link_data = array();
                $link_data['uid'] = $uid;
                $link_data['selected_id'] = $dl_item->id;
                $link_data['expire_time'] = $expireAt;
                $link_data['time_requested'] = $time_requested;
                $link_data['email'] = $cf7->posted_data['your-email'];
                $link_data['item_id'] = $_POST['_wpcf7_download_id'];
                $link_data['delivered_as'] = $delivered_as;
                if (isset($_POST['masked'])) {
                    $link_data['is_masked'] = $_POST['masked'];
                }
                $wpdb->insert($table_link, $link_data);
                //
                $url = WP_PLUGIN_URL . "/email-before-download/download.php?dl=" . $uid;
                $titles[] = $dl_item->title;
                $title = implode($titles, '|');
                if (isset($_POST['format'])) {
                    $link = do_shortcode('[download id="' . $dl_item->id . '" format="' . $_POST['format'] . '"]');
                    $innerHtml .= $link . '<br />';
                } else {
                    $innerHtml .= '<a class="icon-button download-icon" target="' . $target . '" href="' . $url . '"><span class="et-icon"><span>' . $dl_item->title . '</span></span></a><br clear="both" /> <br />';
                }
                //       if(get_option('email_before_download_send_email') == 'Send Email' || get_option('email_before_download_send_email') == 'Both'){
                //       }
                if ($use_attachments) {
                    $dirs = wp_upload_dir();
                    $uploadpath = trailingslashit($dirs['baseurl']);
                    $absuploadpath = trailingslashit($dirs['basedir']);
                    $attachment = NULL;
                    if ($uploadpath && (strstr($dl_item->filename, $uploadpath) || strstr($dl_item->filename, $absuploadpath))) {
                        $file = str_replace($uploadpath, "", $dl_item->filename);
                        if (is_file($absuploadpath . $file)) {
                            $attachment = $absuploadpath . $file;
                        }
                    }
                    $attachments[] = $attachment;
                }
            }
        } else {
            if (!empty($dl) || !empty($ebd_item->file)) {
                //generate unique id for the file (link)
                $uid = md5(uniqid(rand(), true));
                //expiration date if needed if it's 0 or NULL the link will never expire
                $expireAt = 0;
                if (get_option('email_before_download_expire_time') != NULL && get_option('email_before_download_expire_time') != "0") {
                    $expireAt = strtotime(get_option('email_before_download_expire_time'));
                }
                $link_data = array();
                $link_data['uid'] = $uid;
                $link_data['expire_time'] = $expireAt;
                $link_data['time_requested'] = $time_requested;
                $link_data['email'] = $cf7->posted_data['your-email'];
                $link_data['item_id'] = $_POST['_wpcf7_download_id'];
                $link_data['delivered_as'] = $delivered_as;
                $link_data['selected_id'] = 0;
                if (isset($_POST['masked'])) {
                    $link_data['is_masked'] = $_POST['masked'];
                }
                if (isset($_POST['force_download'])) {
                    $link_data['is_force_download'] = $_POST['force_download'];
                }
                $wpdb->insert($table_link, $link_data);
                if (isset($_POST['format']) && $ebd_item->download_id != NULL) {
                    $link = do_shortcode('[download id="' . $ebd_item->download_id . '" format="' . $_POST['format'] . '"]');
                    $innerHtml .= $link . '<br />';
                } else {
                    $url = WP_PLUGIN_URL . "/email-before-download/download.php?dl=" . $uid;
                    $innerHtml = '<a class="icon-button download-icon" target="' . $target . '" href="' . $url . '"><span class="et-icon"><span>' . $title . '</span></span></a><br clear="both" /> <br />';
                }
            } else {
                //we don't sent an email and throw an error
                $cf7->skip_mail = true;
                //this message doesn't seem to appear but we leave it for now
                $cf7->additional_settings = "on_sent_ok: \"document.getElementById('wpm_download_{$dId}').style.display = 'inline'; document.getElementById('wpm_download_{$dId}').innerHTML='You should select the files to dowload.'; \"";
                $id = (int) $_POST['_wpcf7'];
                $unit_tag = $_POST['_wpcf7_unit_tag'];
                $items = array('mailSent' => false, 'into' => '#' . $unit_tag, 'captcha' => null);
                //error message
                $items['message'] = "Please select at least one of the documents";
                $on_sent_ok = $cf7->additional_setting('on_sent_ok', false);
                $items['onSentOk'] = $on_sent_ok;
                $echo = json_encode($items);
                @header('Content-Type: application/json; charset=' . get_option('blog_charset'));
                echo $echo;
                die;
            }
        }
        $cf7->posted_data['your-message'] = 'The downloaded file name(s): ' . $title;
        if (strpos($cf7->mail['body'], "[your-message]") === false) {
            $cf7->posted_data['your-message'] = $title;
            $cf7->mail['body'] = $cf7->mail['body'] . "\nThe downloaded file name: [your-message]";
        }
        $target = get_option('email_before_download_link_target');
        $html_before = get_option('email_before_download_html_before_link');
        $html_after = get_option('email_before_download_html_after_link');
        //if multiple files are downloaded ???
        $message = '';
        if (count($dl_items) > 0) {
            $email_template = get_option('email_before_download_email_template_mult');
            if (strlen(trim($email_template)) > 0) {
                $message = str_replace(array('[requesting_name]', '[file_urls]'), array($cf7->posted_data['your-name'], $innerHtml), trim($email_template));
            } else {
                $message = $innerHtml;
            }
        } else {
            $email_template = get_option('email_before_download_email_template');
            if (strlen(trim($email_template)) > 0) {
                if (isset($_POST['format']) && $ebd_item->download_id != NULL) {
                    $message = 'You requested: ' . $innerHtml;
                } else {
                    $message = str_replace(array('[requesting_name]', '[file_url]', '[file_name]'), array($cf7->posted_data['your-name'], $url, $title), trim($email_template));
                }
            } else {
                if (isset($_POST['format']) && $ebd_item->download_id != NULL) {
                    $message = 'You requested: ' . $innerHtml;
                } else {
                    $message = '<a class="icon-button download-icon" target="' . $target . '" href="' . $url . '">' . $title . '</a>';
                }
            }
        }
        //$title = "Click this link to download this file.";
        $innerHtml = $html_before . $innerHtml . $html_after;
        if ($delivered_as == 'Send Email') {
            // $attachments = NULL;
            if ($use_attachments && count($dl_items) == 0) {
                $dirs = wp_upload_dir();
                $uploadpath = trailingslashit($dirs['baseurl']);
                $absuploadpath = trailingslashit($dirs['basedir']);
                $attachment = NULL;
                if ($uploadpath && (strstr($d->filename, $uploadpath) || strstr($d->filename, $absuploadpath))) {
                    $file = str_replace($uploadpath, "", $d->filename);
                    if (is_file($absuploadpath . $file)) {
                        $attachment = $absuploadpath . $file;
                    }
                }
                $attachments = array($attachment);
            }
            if (count($attachments) == 0) {
                $attachments = NULL;
            }
            $email_subject = get_option('email_before_download_subject');
            if (strlen(trim($email_subject)) > 0) {
                $email_subject = str_replace('[files]', $title, $email_subject);
            } else {
                $email_subject = 'Requested URL for the file(s): ' . $title;
            }
            //email_before_download_subject
            @wp_mail($cf7->posted_data['your-email'], $email_subject, $message, $emailFrom . "Content-Type: text/html\n", $attachments);
            $cf7->additional_settings .= "\n" . "on_sent_ok: \"document.getElementById('wpm_download_{$dId}').style.display = 'inline'; document.getElementById('wpm_download_{$dId}').innerHTML='The link to the file(s) has been emailed to you.'; \"";
        } else {
            if ($delivered_as == 'Both') {
                //$attachments = NULL;
                if ($use_attachments && count($dl_items) == 0) {
                    $dirs = wp_upload_dir();
                    $uploadpath = trailingslashit($dirs['baseurl']);
                    $absuploadpath = trailingslashit($dirs['basedir']);
                    $attachment = NULL;
                    if ($uploadpath && (strstr($d->filename, $uploadpath) || strstr($d->filename, $absuploadpath))) {
                        $file = str_replace($uploadpath, "", $d->filename);
                        if (is_file($absuploadpath . $file)) {
                            $attachment = $absuploadpath . $file;
                        }
                    }
                    $attachments = array($attachment);
                }
                if (count($attachments) == 0) {
                    $attachments = NULL;
                }
                $email_subject = get_option('email_before_download_subject');
                if (strlen(trim($email_subject)) > 0) {
                    $email_subject = str_replace('[files]', $title, $email_subject);
                } else {
                    $email_subject = 'Requested URL for the file(s): ' . $title;
                }
                @wp_mail($cf7->posted_data['your-email'], $email_subject, $message, $emailFrom . "Content-Type: text/html\n", $attachments);
                $cf7->additional_settings .= "\n" . "on_sent_ok: \"document.getElementById('wpm_download_{$dId}').style.display = 'inline'; document.getElementById('wpm_download_{$dId}').innerHTML='{$innerHtml}'; \"";
            } else {
                $cf7->additional_settings .= "\n" . "on_sent_ok: \"document.getElementById('wpm_download_{$dId}').style.display = 'inline'; document.getElementById('wpm_download_{$dId}').innerHTML='{$innerHtml}'; \"";
            }
        }
        // save the extra form information into the xml
        $xml = new SimpleXMLElement('<posted_data></posted_data>');
        foreach ($cf7->posted_data as $key => $value) {
            if (is_array($value)) {
                $value = implode(',', $value);
            }
            $xml->addChild($key, htmlentities($value, ENT_QUOTES, 'utf-8'));
            //encode some chars like '&'
        }
        $posted_data = array();
        $posted_data['time_requested'] = $time_requested;
        $posted_data['posted_data'] = $xml->asXML();
        $wpdb->insert($table_posted_data, $posted_data);
    }
    return $cf7;
}
if (isset($_POST['btn_multiCheckDm'])) {
    if (!isset($_POST['tlds']) || !is_array($_POST['tlds']) || count($_POST['tlds']) == 0 || !$_POST['txt_multi_domains']) {
        echo 'Nothing to do!';
    } else {
        //	goto NOTHING_TO_DO;
        //list tlds to check with domain name
        $listTlds2check = array_unique($_POST['tlds']);
        //more domain name check for avaiable
        $multi_domains = parse_all_domains($_POST['txt_multi_domains']);
    }
}
if (isset($multi_domains) && isset($listTlds2check)) {
    //merge history domains
    $test = array();
    mergeHistoryDomainTlds($multi_domains, $test);
    check_domains($multi_domains, $listTlds2check);
}
?>
<script>
//paAPI.hw_WhoisDomain('hoangweb.com');
</script>


<div style="background:#fff;" class="check-multidomains-holder">
<form action="" method="POST" onsubmit="return valid_frm_checkdomain(this)">
<table width="100%" border="0">
	<tr>
		<td colspan="3" style="width: 315px;position: relative; padding-top: 18px;" class="pa-tld-header">
			<div style="position:relative;width:921px;">
			<h1 style="position: absolute; top: -5px; left: 50px; font-weight: normal; font-family: 'robotocondensed-regular', tahoma; font-size: 30px; color: #363636;">Nhập tên miền</h1>
			<h1 style="position: absolute; top: -5px; left: 361px; font-weight: normal; font-family: 'robotocondensed-regular', tahoma; font-size: 30px; color: #363636">Chọn đuôi tên miền</h1>