function email_form($content, $echo = true, $subtitle = true, $div = true, $error_field = '') { global $wpdb, $multipage; // Variables $multipage = false; $post_title = email_get_title(); $post_author = the_author('', false); $post_date = get_the_time(get_option('date_format') . ' (' . get_option('time_format') . ')', '', '', false); $post_category = email_category(__(',', 'wp-email') . ' '); $post_category_alt = strip_tags($post_category); $email_fields = get_option('email_fields'); $email_image_verify = intval(get_option('email_imageverify')); $email_options = get_option('email_options'); $email_type = intval($email_options['email_type']); $error_field = apply_filters('email_form-fieldvalues', $error_field); $output = ''; // Template - Subtitle if ($subtitle) { $template_subtitle = stripslashes(get_option('email_template_subtitle')); $template_subtitle = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_subtitle); $template_subtitle = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_subtitle); $template_subtitle = str_replace("%EMAIL_POST_DATE%", $post_date, $template_subtitle); $template_subtitle = str_replace("%EMAIL_POST_CATEGORY%", $post_category, $template_subtitle); $template_subtitle = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_subtitle); $template_subtitle = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_subtitle); $template_subtitle = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_subtitle); $output .= $template_subtitle; } // Display WP-EMail Form if ($div) { $output .= '<div id="wp-email-content" class="wp-email">' . "\n"; } if (not_spamming()) { if (not_password_protected()) { if ($email_type == 2) { $output .= email_popup_form_header(false, !empty($error_field['id']) ? $error_field['id'] : 0); } else { $output .= email_form_header(false, !empty($error_field['id']) ? $error_field['id'] : 0); } $output .= '<p id="wp-email-required">' . __('* Required Field', 'wp-email') . '</p>' . "\n"; if (intval($email_fields['yourname']) == 1) { $output .= '<p>' . "\n"; $output .= '<label for="yourname">' . __('Your Name: *', 'wp-email') . '</label><br />' . "\n"; $output .= '<input type="text" size="50" id="yourname" name="yourname" class="TextField" value="' . $error_field['yourname'] . '" />' . "\n"; $output .= '</p>' . "\n"; } if (intval($email_fields['youremail']) == 1) { $output .= '<p>' . "\n"; $output .= '<label for="youremail">' . __('Your E-Mail: *', 'wp-email') . '</label><br />' . "\n"; $output .= '<input type="text" size="50" id="youremail" name="youremail" class="TextField" value="' . $error_field['youremail'] . '" dir="ltr" />' . "\n"; $output .= '</p>' . "\n"; } if (intval($email_fields['yourremarks']) == 1) { $output .= '<p>' . "\n"; $output .= ' <label for="yourremarks">' . __('Your Remark:', 'wp-email') . '</label><br />' . "\n"; $output .= ' <textarea cols="49" rows="8" id="yourremarks" name="yourremarks" class="Forms">'; $val = email_get_remark(); if (!empty($error_field['yourremarks'])) { $val = $error_field['yourremarks']; } if (!empty($val)) { $output .= esc_html($val); } $output .= '</textarea>' . "\n"; $output .= '</p>' . "\n"; } if (intval($email_fields['friendname']) == 1) { $output .= '<p>' . "\n"; $output .= '<label for="friendname">' . __('Friend\'s Name: *', 'wp-email') . '</label><br />' . "\n"; $output .= '<input type="text" size="50" id="friendname" name="friendname" class="TextField" value="' . (!empty($error_field['friendname']) ? $error_field['friendname'] : '') . '" />' . email_multiple(false) . "\n"; $output .= '</p>' . "\n"; } $output .= '<p>' . "\n"; $output .= '<label for="friendemail">' . __('Friend\'s E-Mail: *', 'wp-email') . '</label><br />' . "\n"; $output .= '<input type="text" size="50" id="friendemail" name="friendemail" class="TextField" value="' . (!empty($error_field['friendemail']) ? $error_field['friendemail'] : '') . '" dir="ltr" />' . email_multiple(false) . "\n"; $output .= '</p>' . "\n"; if ($email_image_verify) { $output .= '<p>' . "\n"; $output .= '<label for="imageverify">' . __('Image Verification: *', 'wp-email') . '</label><br />' . "\n"; $output .= '<img src="' . plugins_url('wp-email/email-image-verify.php') . '" width="55" height="15" alt="' . __('E-Mail Image Verification', 'wp-email') . '" /><input type="text" size="5" maxlength="5" id="imageverify" name="imageverify" class="TextField" />' . "\n"; $output .= '</p>' . "\n"; } $output .= '<p id="wp-email-button"><input type="button" value="' . __(' Mail It! ', 'wp-email') . '" id="wp-email-submit" class="Button" onclick="email_form();" onkeypress="email_form();" /></p>' . "\n"; $output .= '</form>' . "\n"; } else { $output .= get_the_password_form(); } // End if(not_password_protected()) } else { $output .= '<p>' . sprintf(_n('Please wait for <strong>%s Minute</strong> before sending the next article.', 'Please wait for <strong>%s Minutes</strong> before sending the next article.', email_flood_interval(false), 'wp-email'), email_flood_interval(false)) . '</p>' . "\n"; } // End if (not_spamming()) $output .= '<div id="wp-email-loading" class="wp-email-loading"><img src="' . plugins_url('wp-email/images/loading.gif') . '" width="16" height="16" alt="' . __('Loading', 'wp-email') . ' ..." title="' . __('Loading', 'wp-email') . ' ..." class="wp-email-image" /> ' . __('Loading', 'wp-email') . ' ...</div>' . "\n"; if ($div) { $output .= '</div>' . "\n"; } email_removefilters(); if ($echo) { echo $output; } else { return $output; } }
function email_form($popup = false, $echo = true) { global $post_excerpt, $post_content, $post_content_alt, $wpdb; // Variables $post_title = get_the_title(); $post_author = the_author('', false); $post_date = get_the_time(get_option('date_format') . ' (' . get_option('time_format') . ')', '', '', false); $post_category = email_category(); $post_category_alt = strip_tags($post_category); $email_fields = get_option('email_fields'); $email_image_verify = intval(get_option('email_imageverify')); $yourname = strip_tags(stripslashes(trim($_POST['yourname']))); $youremail = strip_tags(stripslashes(trim($_POST['youremail']))); $yourremarks = strip_tags(stripslashes(trim($_POST['yourremarks']))); $friendname = strip_tags(stripslashes(trim($_POST['friendname']))); $friendemail = strip_tags(stripslashes(trim($_POST['friendemail']))); $output = '<div class="wp-email">' . "\n"; $template_subtitle = stripslashes(get_option('email_template_subtitle')); $template_subtitle = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_subtitle); $template_subtitle = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_subtitle); $template_subtitle = str_replace("%EMAIL_POST_DATE%", $post_date, $template_subtitle); $template_subtitle = str_replace("%EMAIL_POST_CATEGORY%", $post_category, $template_subtitle); $template_subtitle = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_subtitle); $template_subtitle = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_subtitle); $template_subtitle = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_subtitle); $output .= $template_subtitle; // If User Click On Mail if (!empty($_POST['wp-email'])) { // SMTP $imageverify = $_POST['imageverify']; $smtp_info = get_option('email_smtp'); $smtp_info = explode('|', $smtp_info); $error = ''; // Multiple Names/Emails $friends = array(); $friendname_count = 0; $friendemail_count = 0; $multiple_names = explode(',', $friendname); $multiple_emails = explode(',', $friendemail); $multiple_max = intval(get_option('email_multiple')); if ($multiple_max == 0) { $multiple_max = 1; } // Checking Your Name Field For Errors if (intval($email_fields['yourname']) == 1) { if (empty($yourname)) { $error .= '<br /><strong>»</strong> ' . __('Your name is empty.', 'wp-email'); } } // Checking Your E-Mail Field For Errors if (intval($email_fields['youremail']) == 1) { if (!is_valid_email($youremail) || empty($youremail)) { $error .= '<br /><strong>»</strong> ' . __('Your email is invalid or is empty.', 'wp-email'); } } // Checking Your Remarks Field For Errors if (intval($email_fields['yourremarks']) == 1) { if (!is_valid_remarks($yourremarks)) { $error .= '<br /><strong>»</strong> ' . __('Your remark is invalid.', 'wp-email'); } } // Checking Friend's Name Field For Errors if (intval($email_fields['friendname']) == 1) { if ($multiple_names) { foreach ($multiple_names as $multiple_name) { $multiple_name = trim($multiple_name); if (empty($multiple_name)) { $error .= '<br /><strong>»</strong> ' . sprintf(__('Friend\'s name (%s) is empty.', 'wp-email'), $multiple_name); } else { $friends[$friendname_count]['name'] = $multiple_name; $friendname_count++; } if ($friendname_count > $multiple_max) { break; } } } } // Checking Friend's E-Mail Field For Errors if (intval($email_fields['friendemail']) == 1) { if ($multiple_emails) { foreach ($multiple_emails as $multiple_email) { $multiple_email = trim($multiple_email); if (!is_valid_email($multiple_email) || empty($multiple_email)) { $error .= '<br /><strong>»</strong> ' . sprintf(__('Friend\'s email (%s) is invalid or is empty.', 'wp-email'), $multiple_email); } else { $friends[$friendemail_count]['email'] = $multiple_email; $friendemail_count++; } if ($friendemail_count > $multiple_max) { break; } } } } // Checking If The Fields Exceed The Size Of Maximum Entries Allowed if (intval($email_fields['friendname']) == 1 || intval($email_fields['friendemail']) == 1) { if (sizeof($friends) > $multiple_max) { $error .= '<br /><strong>»</strong> ' . sprintf(__('Maximum %s entries allowed', 'wp-email'), $multiple_max); } } if (intval($email_fields['friendname']) == 1 && intval($email_fields['friendemail']) == 1) { if ($friendname_count != $friendemail_count) { $error .= '<br /><strong>»</strong> ' . __('Friends\' name count does not tally with friends\' email count.', 'wp-email'); } } // Check Whether We Enable Image Verification if ($email_image_verify) { $imageverify = strtoupper($imageverify); if (empty($imageverify)) { $error .= '<br /><strong>»</strong> ' . __('Image verification is empty.', 'wp-email'); } else { if ($_SESSION['email_verify'] != md5($imageverify)) { $error .= '<br /><strong>»</strong> ' . __('Image verification failed.', 'wp-email'); } } } // If There Is No Error, We Process The E-Mail if (empty($error) && not_spamming()) { // If Remarks Is Empty, Assign N/A if (empty($yourremarks)) { $yourremarks = __('N/A', 'wp-email'); } // Template For E-Mail Subject $template_email_subject = stripslashes(get_option('email_template_subject')); $template_email_subject = str_replace("%EMAIL_YOUR_NAME%", $yourname, $template_email_subject); $template_email_subject = str_replace("%EMAIL_YOUR_EMAIL%", $youremail, $template_email_subject); $template_email_subject = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_subject); $template_email_subject = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_email_subject); $template_email_subject = str_replace("%EMAIL_POST_DATE%", $post_date, $template_email_subject); $template_email_subject = str_replace("%EMAIL_POST_CATEGORY%", $post_category_alt, $template_email_subject); $template_email_subject = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_subject); $template_email_subject = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_subject); $template_email_subject = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_subject); // Template For E-Mail Body $template_email_body = stripslashes(get_option('email_template_body')); $template_email_body = str_replace("%EMAIL_YOUR_NAME%", $yourname, $template_email_body); $template_email_body = str_replace("%EMAIL_YOUR_EMAIL%", $youremail, $template_email_body); $template_email_body = str_replace("%EMAIL_YOUR_REMARKS%", $yourremarks, $template_email_body); $template_email_body = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_body); $template_email_body = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_body); $template_email_body = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_body); $template_email_body = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_email_body); $template_email_body = str_replace("%EMAIL_POST_DATE%", $post_date, $template_email_body); $template_email_body = str_replace("%EMAIL_POST_CATEGORY%", $post_category, $template_email_body); $template_email_body = str_replace("%EMAIL_POST_EXCERPT%", $post_excerpt, $template_email_body); $template_email_body = str_replace("%EMAIL_POST_CONTENT%", $post_content, $template_email_body); $template_email_body = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_body); $template_email_body = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_body); $template_email_body = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_body); // Template For E-Mail Alternate Body $template_email_bodyalt = stripslashes(get_option('email_template_bodyalt')); $template_email_bodyalt = str_replace("%EMAIL_YOUR_NAME%", $yourname, $template_email_bodyalt); $template_email_bodyalt = str_replace("%EMAIL_YOUR_EMAIL%", $youremail, $template_email_bodyalt); $template_email_bodyalt = str_replace("%EMAIL_YOUR_REMARKS%", $yourremarks, $template_email_bodyalt); $template_email_bodyalt = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_bodyalt); $template_email_bodyalt = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_bodyalt); $template_email_bodyalt = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_bodyalt); $template_email_bodyalt = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_email_bodyalt); $template_email_bodyalt = str_replace("%EMAIL_POST_DATE%", $post_date, $template_email_bodyalt); $template_email_bodyalt = str_replace("%EMAIL_POST_CATEGORY%", $post_category_alt, $template_email_bodyalt); $template_email_bodyalt = str_replace("%EMAIL_POST_EXCERPT%", $post_excerpt, $template_email_bodyalt); $template_email_bodyalt = str_replace("%EMAIL_POST_CONTENT%", $post_content_alt, $template_email_bodyalt); $template_email_bodyalt = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_bodyalt); $template_email_bodyalt = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_bodyalt); $template_email_bodyalt = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_bodyalt); // PHP Mailer Variables $mail = new PHPMailer(); $mail->From = $youremail; $mail->FromName = $yourname; foreach ($friends as $friend) { $mail->AddAddress($friend['email'], $friend['name']); } $mail->Username = $smtp_info[0]; $mail->Password = $smtp_info[1]; $mail->Host = $smtp_info[2]; $mail->Mailer = get_option('email_mailer'); $mail->ContentType = get_option('email_contenttype'); $mail->Subject = $template_email_subject; if (get_option('email_contenttype') == 'text/plain') { $mail->Body = $template_email_bodyalt; } else { $mail->Body = $template_email_body; $mail->AltBody = $template_email_bodyalt; } // Send The Mail if ($mail->Send()) { $email_status = __('Success', 'wp-email'); // Template For Sent Successfully $template_email_sentsuccess = stripslashes(get_option('email_template_sentsuccess')); $template_email_sentsuccess = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_sentsuccess); $template_email_sentsuccess = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_sentsuccess); $template_email_sentsuccess = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_sentsuccess); $template_email_sentsuccess = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_sentsuccess); $template_email_sentsuccess = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_sentsuccess); $template_email_sentsuccess = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_sentsuccess); // If There Is Error Sending } else { if ($yourremarks == __('N/A', 'wp-email')) { $yourremarks = ''; } $email_status = __('Failed', 'wp-email'); // Template For Sent Failed $template_email_sentfailed = stripslashes(get_option('email_template_sentfailed')); $template_email_sentfailed = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_sentfailed); $template_email_sentfailed = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_sentfailed); $template_email_sentfailed = str_replace("%EMAIL_ERROR_MSG%", $mail->ErrorInfo, $template_email_sentfailed); $template_email_sentfailed = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_sentfailed); $template_email_sentfailed = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_sentfailed); $template_email_sentfailed = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_sentfailed); $template_email_sentfailed = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_sentfailed); } // Logging $email_yourname = addslashes($yourname); $email_youremail = addslashes($youremail); $email_yourremarks = addslashes($yourremarks); $email_postid = intval(get_the_id()); $email_posttitle = addslashes($post_title); $email_timestamp = current_time('timestamp'); $email_ip = get_email_ipaddress(); $email_host = @gethostbyaddr($email_ip); foreach ($friends as $friend) { $email_friendname = addslashes($friend['name']); $email_friendemail = addslashes($friend['email']); $wpdb->query("INSERT INTO {$wpdb->email} VALUES (0, '{$email_yourname}', '{$email_youremail}', '{$email_yourremarks}', '{$email_friendname}', '{$email_friendemail}', {$email_postid}, '{$email_posttitle}', '{$email_timestamp}', '{$email_ip}', '{$email_host}', '{$email_status}')"); } // If There Are Errors } else { $error = substr($error, 21); $template_email_error = stripslashes(get_option('email_template_error')); $template_email_error = str_replace("%EMAIL_ERROR_MSG%", $error, $template_email_error); $template_email_error = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_error); $template_email_error = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_error); $template_email_error = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_error); } // End if(empty($error)) } // End if(!empty($_POST['wp-email'])) // Display WP-EMail Success if ($email_status == __('Success', 'wp-email')) { $output .= $template_email_sentsuccess; // Display WP-EMail Form } else { if (not_spamming()) { if (not_password_protected()) { if ($popup) { $output .= email_popup_form_header(false); } else { $output .= email_form_header(false); } $output .= '<!-- Display Error, If There Is Any -->' . "\n"; $output .= $template_email_sentfailed; $output .= $template_email_error; $output .= '<!-- End Display Error, If There Is Any -->' . "\n"; $output .= '<p><strong>' . __('* Required Field', 'wp-email') . '</strong></p>' . "\n"; if (intval($email_fields['yourname']) == 1) { $output .= '<p>' . "\n"; $output .= '<strong><label for="yourname">' . __('Your Name: *', 'wp-email') . '</label></strong><br />' . "\n"; $output .= '<input type="text" size="50" id="yourname" name="yourname" class="Forms" value="' . $yourname . '" />' . "\n"; $output .= '</p>' . "\n"; } if (intval($email_fields['youremail']) == 1) { $output .= '<p>' . "\n"; $output .= '<strong><label for="youremail">' . __('Your E-Mail: *', 'wp-email') . '</label></strong><br />' . "\n"; $output .= '<input type="text" size="50" id="youremail" name="youremail" class="Forms" value="' . $youremail . '" />' . "\n"; $output .= '</p>' . "\n"; } if (intval($email_fields['yourremarks']) == 1) { $output .= '<p>' . "\n"; $output .= ' <strong><label for="yourremarks">' . __('Your Remark:', 'wp-email') . '</label></strong><br />' . "\n"; $output .= ' <textarea cols="49" rows="8" id="yourremarks" name="yourremarks" class="Forms">' . $yourremarks . '</textarea>' . "\n"; $output .= '</p>' . "\n"; } if (intval($email_fields['friendname']) == 1) { $output .= '<p>' . "\n"; $output .= '<strong><label for="friendname">' . __('Friend\'s Name: *', 'wp-email') . '</label></strong><br />' . "\n"; $output .= '<input type="text" size="50" id="friendname" name="friendname" class="Forms" value="' . $friendname . '" />' . email_multiple(false) . "\n"; $output .= '</p>' . "\n"; } if (intval($email_fields['friendemail']) == 1) { $output .= '<p>' . "\n"; $output .= '<strong><label for="friendemail">' . __('Friend\'s E-Mail: *', 'wp-email') . '</label></strong><br />' . "\n"; $output .= '<input type="text" size="50" id="friendemail" name="friendemail" class="Forms" value="' . $friendemail . '" />' . email_multiple(false) . "\n"; $output .= '</p>' . "\n"; } if ($email_image_verify) { $output .= '<p>' . "\n"; $output .= '<strong><label for="imageverify">' . __('Image Verification: *', 'wp-email') . '</label></strong><br />' . "\n"; $output .= '<img src="' . get_option('siteurl') . '/wp-content/plugins/email/email-image-verify.php" width="55" height="15" alt="' . __('E-Mail Image Verification', 'wp-email') . '" /><input type="text" size="5" maxlength="5" id="imageverify" name="imageverify" class="Forms" />' . "\n"; $output .= '</p>' . "\n"; } $output .= '<p style="text-align: center"><input type="submit" value="' . __(' Mail It! ', 'wp-email') . '" name="wp-email" class="Buttons" /></p>' . "\n"; $output .= '</form>' . "\n"; } else { $output .= get_the_password_form(); } // End if(not_password_protected()) } else { $output .= '<p>' . sprintf(__('Please wait for <strong>%s Minutes</strong> before sending the next article.', 'wp-email'), email_flood_interval(false)) . '</p>' . "\n"; } // End if (not_spamming()) } // End if($email_status == __('Success', 'wp-email')) $output .= '</div><p> ' . "\n"; email_removefilters(); if ($echo) { echo $output; } else { return $output; } }