function wp_email_capture_form_page($error = 0) { $url = get_option('home'); $url = addLastCharacter($url); $display = ""; $display .= "<div id='wp_email_capture_2' class='wp-email-capture wp-email-capture-display'><form name='wp_email_capture_display' method='post' action='" . $url . "'>\n"; if (isset($_GET['wp_email_capture_error'])) { $error = wp_email_capture_sanitize($_GET['wp_email_capture_error']); $display .= "<div class='wp-email-capture-error'>Error: " . " " . $error . "</div>\n"; } $display .= "<label class='wp-email-capture-name wp-email-capture-label wp-email-capture-display-worldwide wp-email-capture-name-display wp-email-capture-name-label wp-email-capture-name-label-display"; if (get_option("wp_email_capture_name_required") == 1) { $display .= " wp-email-capture-required"; } $display .= "' for='wp-email-capture-name-display'>" . __('Name:', 'WPEC') . "</label> <input name='wp-email-capture-name' id='wp-email-capture-name-display' type='text' class='wp-email-capture-name wp-email-capture-label wp-email-capture-display-worldwide wp-email-capture-name-display wp-email-capture-name-input wp-email-capture-name-input-display' title='Name' /><br/>\n"; $display .= "<label class='wp-email-capture-email wp-email-capture-label wp-email-capture-display wp-email-capture-email-display wp-email-capture-email-label wp-email-capture-email-label-display' for='wp-email-capture-email-display'>" . __('Email:', 'WPEC') . "</label> <input name='wp-email-capture-email' id='wp-email-capture-email-display' type='text' class='wp-email-capture-email wp-email-capture-input wp-email-capture-display wp-email-capture-email-display wp-email-capture-email-input wp-email-capture-email-input-display' title='Email' /><br/>\n"; $display .= "<input type='hidden' name='wp_capture_action' value='1' />\n"; $display .= "<input name='Submit' type='submit' value='" . __('Submit', 'WPEC') . "' class='wp-email-capture-submit' /></form></div>\n"; if (get_option("wp_email_capture_link") == 1) { $display .= "<p style='font-size:10px;'>" . __('Powered by', 'WPEC') . " <a href='http://wpemailcapture.com/' target='_blank'>WP Email Capture</a></p>\n"; } return $display; }
function wp_email_capture_signup() { global $wpdb; // Random confirmation code $confirm_code = md5(uniqid(rand())); $name = $_REQUEST['wp-email-capture-name']; $starturl = $_SERVER['HTTP_REFERER']; if (strpos($starturl, "?") === false) { $extrastring = "?"; } else { $extrastring = "&"; } if (get_option("wp_email_capture_name_required") == 1 && $name == "") { $error = urlencode(__('Please Provide A Name', 'WPEC')); $url = $starturl . $extrastring . "wp_email_capture_error=" . $error; wp_redirect($url); die; } $email = $_REQUEST['wp-email-capture-email']; if (!is_email($email)) { $error = urlencode(__('Not a valid email', 'WPEC')); $url = $starturl . $extrastring . "wp_email_capture_error=" . $error; wp_redirect($url); die; } if (wp_email_capture_double_check_everything($name, $email)) { // values sent from form $name = wp_email_capture_sanitize($name); $email = wp_email_capture_sanitize($email); $name = wp_email_injection_test($name); $email = wp_email_injection_test($email); $name = wp_email_stripslashes($name); $email = wp_email_stripslashes($email); $referrer = wp_email_capture_sanitize($_SERVER['HTTP_REFERER']); $ip = wp_email_capture_sanitize($_SERVER['REMOTE_ADDR']); $date = date("Y-m-d H-i"); $sqlcheck = wp_email_capture_checkIfPresent($email); if ($sqlcheck) { $error = urlencode(__('User already present', 'WPEC')); $url = $starturl . $extrastring . "wp_email_capture_error=" . $error; wp_redirect($url); die; } // Insert data into database $table_name = $wpdb->prefix . "wp_email_capture_temp_members"; $result = $wpdb->insert($table_name, array('confirm_code' => $confirm_code, 'name' => $name, 'email' => $email), array('%s', '%s', '%s')); // if suceesfully inserted data into database, send confirmation link to email if ($result) { // ---------------- SEND MAIL FORM ---------------- // send e-mail to ... $to = $email; $message = ""; $siteurl = get_option('home'); $siteurl = addLastCharacter($siteurl); // Your subject $subject = ""; $subject = get_option('wp_email_capture_subject'); if ($subject == "") { $subject = __("Sign Up For Our Newsletter", "WPEC"); } // From $from = ""; $from = get_option('wp_email_capture_from'); if ($from == "") { $from = get_option('admin_email'); } $fromname = ""; $fromname = get_option('wp_email_capture_from_name'); if ($from == "") { $fromname = get_option('blogname'); } $header = "MIME-Version: 1.0\n" . "From: " . $fromname . " <" . $from . ">\n"; $header .= "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; // Your message $message .= get_option('wp_email_capture_body') . "\n\n"; if ($message == "\n\n") { $message .= __("Thank you for signing up for our newsletter, please click the link below to confirm your subscription", "WPEC") . "\n\n"; } $message .= $siteurl . "?wp_email_confirm=1&wp_email_capture_passkey={$confirm_code}"; $message .= "\n\n----\n"; $message .= __("This is an automated message that is generated because somebody with the IP address of", 'WPEC') . " " . $ip . " " . __('(possibly you) on', 'WPEC') . " " . $date . " " . __('filled out the form on the following page', 'WPEC') . " " . $referrer . "\n"; $message .= __("If you are sure this isn't you, please ignore this message, you will not be sent another message.", 'WPEC'); $message = str_replace("%NAME%", $name, $message); // send email $sentmail = wp_mail($to, $subject, $message, $header); } } else { echo __("Not found your email in our database", 'WPEC'); } // if your email succesfully sent if ($sentmail) { $halfreg = ""; $halfreg = get_option('wp_email_capture_signup'); if ($halfreg == "") { $halfreg = get_bloginfo('url'); } wp_redirect($halfreg); die; } else { $error = urlencode(__('Email unable to be sent', 'WPEC')); $url = $starturl . $extrastring . "wp_email_capture_error=" . $error; wp_redirect($url); die; //echo "<meta http-equiv='refresh' content='0;". $url . "?wp_email_capture_error=Email%20unable%20to%20be%sent'>"; } }