PluginProbe
WP-EMail / 2.01
WP-EMail v2.01
3.0.0 trunk 1.00 2.00b 2.01 2.02 2.03 2.04 2.04a 2.05 2.06 2.07 2.10 2.11 2.20 2.30 2.31 2.40 2.50 2.51 2.52 2.61 2.62 2.63 2.64 All 42 releases
wp-email / wp-email.php

wp-email.php in WP-EMail 2.01, at wp-email.php

262 lines 12.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 +----------------------------------------------------------------+
4 | |
5 | WordPress 2.0 Plugin: WP-EMail 2.01 |
6 | Copyright (c) 2005 Lester "GaMerZ" Chan |
7 | |
8 | File Written By: |
9 | - Lester "GaMerZ" Chan |
10 | - http://www.lesterchan.net |
11 | |
12 | File Information: |
13 | - E-Mail Post/Page To A Friend |
14 | - wp-email.php |
15 | |
16 +----------------------------------------------------------------+
17 */
18
19
20 ### If wp-email.php Loaded Directly, Load wp-blog-header.php
21 if(intval($_GET['p']) > 0 || !function_exists('single_post_title')) {
22 require(dirname(__FILE__).'/wp-blog-header.php');
23 }
24
25 ### Variables Variables Variables
26 $did_email = get_query_var('wp-email');
27
28 ### Load E-Mail Get Content Function
29 add_action('init', 'get_email_content');
30
31 ### E-Mail Page Title
32 add_filter('wp_title', 'email_pagetitle');
33
34 ### Require PHP-Mailer Class
35 require(ABSPATH.WPINC.'/class-phpmailer.php');
36
37 ### Require WP-EMail Functions
38 require(ABSPATH.WPINC.'/functions-wp-email.php');
39
40 ### If User Click On Mail
41 if(!empty($did_email)) {
42 // Variables Variables Variables
43 $yourname = strip_tags(stripslashes(trim($_POST['yourname'])));
44 $youremail = strip_tags(stripslashes(trim($_POST['youremail'])));
45 $yourremarks = strip_tags(stripslashes(trim($_POST['yourremarks'])));
46 $friendname = strip_tags(stripslashes(trim($_POST['friendname'])));
47 $friendemail = strip_tags(stripslashes(trim($_POST['friendemail'])));
48 $smtp_info = get_settings('email_smtp');
49 $smtp_info = explode('|', $smtp_info);
50 $error = '';
51 // If Remarks Is Empty, Assign N/A
52 if(empty($yourremarks)) { $yourremarks = 'N/A'; }
53
54 // If There Is Post
55 if(have_posts()){
56 while (have_posts()) {
57 the_post();
58
59 // Check Fields For Error
60 if(!is_valid_name($yourname) || empty($yourname)) {
61 $error .= '<br /><b>&raquo;</b> '.__('Your name is invalid or is empty.');
62 }
63 if(!is_valid_email($youremail) || empty($youremail)) {
64 $error .= '<br /><b>&raquo;</b> '.__('Your email is invalid or is empty.');
65 }
66 if(!is_valid_remarks($yourremarks)) {
67 $error .= '<br /><b>&raquo;</b> '.__('Your remarks is invalid.');
68 }
69 if(!is_valid_name($friendname) || empty($friendname)) {
70 $error .= '<br /><b>&raquo;</b> '.__('Your friend\'s name is invalid or is empty.');
71 }
72 if(!is_valid_email($friendemail) || empty($friendemail)) {
73 $error .= '<br /><b>&raquo;</b> '.__('Your friend\'s email is invalid or is empty.');
74 }
75
76 // If There Are Errors
77 if(!empty($error)) {
78 $error = substr($error, 20);
79 get_header();
80 echo '<div id="content" class="narrowcolumn">'."\n";
81 $template_email_error = stripslashes(get_settings('email_template_error'));
82 $template_email_error = str_replace("%EMAIL_ERROR_MSG%", $error, $template_email_error);
83 $template_email_error = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_error);
84 $template_email_error = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_error);
85 $template_email_error = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_error);
86 echo $template_email_error;
87 echo '</div>'."\n";
88 get_sidebar();
89 get_footer();
90 exit();
91 }
92
93 // Variables Variables Variables
94 $post_title = email_title();
95 $post_author = the_author('', false);
96 $post_date = the_date('jS F Y @ H:i', '', '', false);
97 $post_category = email_category();
98 $post_category_alt = strip_tags($post_category);
99 $post_content .= email_content();
100 $post_content_alt = email_content_alt();
101
102 // Template For E-Mail Subject
103 $template_email_subject = stripslashes(get_settings('email_template_subject'));
104 $template_email_subject = str_replace("%EMAIL_YOUR_NAME%", $yourname, $template_email_subject);
105 $template_email_subject = str_replace("%EMAIL_YOUR_EMAIL%", $youremail, $template_email_subject);
106 $template_email_subject = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_subject);
107 $template_email_subject = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_email_subject);
108 $template_email_subject = str_replace("%EMAIL_POST_DATE%", $post_date, $template_email_subject);
109 $template_email_subject = str_replace("%EMAIL_POST_CATEGORY%", $post_category_alt, $template_email_subject);
110 $template_email_subject = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_subject);
111 $template_email_subject = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_subject);
112 $template_email_subject = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_subject);
113
114 // Template For E-Mail Body
115 $template_email_body = stripslashes(get_settings('email_template_body'));
116 $template_email_body = str_replace("%EMAIL_YOUR_NAME%", $yourname, $template_email_body);
117 $template_email_body = str_replace("%EMAIL_YOUR_EMAIL%", $youremail, $template_email_body);
118 $template_email_body = str_replace("%EMAIL_YOUR_REMARKS%", $yourremarks, $template_email_body);
119 $template_email_body = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_body);
120 $template_email_body = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_body);
121 $template_email_body = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_body);
122 $template_email_body = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_email_body);
123 $template_email_body = str_replace("%EMAIL_POST_DATE%", $post_date, $template_email_body);
124 $template_email_body = str_replace("%EMAIL_POST_CATEGORY%", $post_category, $template_email_body);
125 $template_email_body = str_replace("%EMAIL_POST_CONTENT%", $post_content, $template_email_body);
126 $template_email_body = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_body);
127 $template_email_body = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_body);
128 $template_email_body = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_body);
129
130 // Template For E-Mail Alternate Body
131 $template_email_bodyalt = stripslashes(get_settings('email_template_bodyalt'));
132 $template_email_bodyalt = str_replace("%EMAIL_YOUR_NAME%", $yourname, $template_email_bodyalt);
133 $template_email_bodyalt = str_replace("%EMAIL_YOUR_EMAIL%", $youremail, $template_email_bodyalt);
134 $template_email_bodyalt = str_replace("%EMAIL_YOUR_REMARKS%", $yourremarks, $template_email_bodyalt);
135 $template_email_bodyalt = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_bodyalt);
136 $template_email_bodyalt = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_bodyalt);
137 $template_email_bodyalt = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_bodyalt);
138 $template_email_bodyalt = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_email_bodyalt);
139 $template_email_bodyalt = str_replace("%EMAIL_POST_DATE%", $post_date, $template_email_bodyalt);
140 $template_email_bodyalt = str_replace("%EMAIL_POST_CATEGORY%", $post_category_alt, $template_email_bodyalt);
141 $template_email_bodyalt = str_replace("%EMAIL_POST_CONTENT%", $post_content_alt, $template_email_bodyalt);
142 $template_email_bodyalt = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_bodyalt);
143 $template_email_bodyalt = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_bodyalt);
144 $template_email_bodyalt = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_bodyalt);
145
146 // PHP Mailer Variables
147 $mail = new PHPMailer();
148 $mail->From = $youremail;
149 $mail->FromName = $yourname;
150 $mail->AddAddress($friendemail, $friendname);
151 $mail->Username = $smtp_info[0];
152 $mail->Password = $smtp_info[1];
153 $mail->Host = $smtp_info[2];
154 $mail->Mailer = get_settings('email_mailer');
155 $mail->ContentType = get_settings('email_contenttype');
156 $mail->Subject = $template_email_subject;
157 if(get_settings('email_contenttype') == 'text/plain') {
158 $mail->Body = $template_email_bodyalt;
159 } else {
160 $mail->Body = $template_email_body;
161 $mail->AltBody = $template_email_bodyalt;
162 }
163 // Send The Mail
164 if($mail->Send()) {
165 $email_status = __('Success');
166 get_header();
167 // Template For Sent Successfully
168 echo '<div id="content" class="narrowcolumn">'."\n";
169 $template_email_sentsuccess = stripslashes(get_settings('email_template_sentsuccess'));
170 $template_email_sentsuccess = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_sentsuccess);
171 $template_email_sentsuccess = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_sentsuccess);
172 $template_email_sentsuccess = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_sentsuccess);
173 $template_email_sentsuccess = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_sentsuccess);
174 $template_email_sentsuccess = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_sentsuccess);
175 $template_email_sentsuccess = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_sentsuccess);
176 echo $template_email_sentsuccess;
177 echo '</div>'."\n";
178 get_sidebar();
179 get_footer();
180
181 // If There Is Error Sending
182 } else {
183 $email_status = __('Failed');
184 get_header();
185 // Template For Sent Failed
186 echo '<div id="content" class="narrowcolumn">'."\n";
187 $template_email_sentfailed = stripslashes(get_settings('email_template_sentfailed'));
188 $template_email_sentfailed = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_sentfailed);
189 $template_email_sentfailed = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_sentfailed);
190 $template_email_sentfailed = str_replace("%EMAIL_ERROR_MSG%", $mail->ErrorInfo, $template_email_sentfailed);
191 $template_email_sentfailed = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_sentfailed);
192 $template_email_sentfailed = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_sentfailed);
193 $template_email_sentfailed = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_sentfailed);
194 $template_email_sentfailed = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_sentfailed);
195 echo $template_email_sentfailed;
196 echo '</div>'."\n";
197 get_sidebar();
198 get_footer();
199 }
200 $email_yourname = addslashes($yourname);
201 $email_youremail = addslashes($youremail);
202 $email_yourremarks = addslashes($yourremarks);
203 $email_friendname = addslashes($friendname);
204 $email_friendemail = addslashes($friendemail);
205 $email_postid = email_id();
206 $email_posttitle = addslashes(email_title());
207 $email_timestamp = current_time('timestamp');
208 $email_ip = get_email_ipaddress();
209 $email_host = gethostbyaddr($email_ip);
210 $log_email_sending = email_log("0, '$email_yourname', '$email_youremail', '$email_yourremarks', '$email_friendname', '$email_friendemail', $email_postid, '$email_posttitle', '$email_timestamp', '$email_ip', '$email_host', '$email_status'");
211 if(!$log_email_sending) {
212 die('Error Logging E-Mail Sending');
213 }
214 exit();
215 }
216 }
217 }
218 ?>
219 <?php get_header(); ?>
220 <div id="content" class="narrowcolumn">
221 <?php if (not_spamming()): ?>
222 <?php if (have_posts()) : ?>
223 <?php while (have_posts()) : the_post(); ?>
224 <?php email_form_header(); ?>
225 <p align="center">
226 Article: <b><?php the_title(); ?></b> Will Be Send To Your Friend.
227 </p>
228 <p><b>* Required</b></p>
229 <p>
230 <b>Your Name: *</b><br />
231 <input type="text" size="50" maxlength="50" name="yourname" class="Forms" />
232 </p>
233 <p>
234 <b>Your E-Mail: *</b><br />
235 <input type="text" size="50" maxlength="100" name="youremail" class="Forms" />
236 </p>
237 <p>
238 <b>Your Remarks:</b><br />
239 <textarea cols="49" rows="8" name="yourremarks" class="Forms"></textarea>
240 </p>
241 <p>
242 <b>Friend's Name: *</b><br />
243 <input type="text" size="50" maxlength="100" name="friendname" class="Forms" />
244 </p>
245 <p>
246 <b>Friend's E-Mail: *</b><br />
247 <input type="text" size="50" maxlength="100" name="friendemail" class="Forms" />
248 </p>
249 <p align="center">
250 <input type="submit" value=" Mail It! " name="wp-email" class="Buttons" />
251 </p>
252 </form>
253 <?php endwhile; ?>
254 <?php else : ?>
255 <p><b>Invalid Post</b></p>
256 <?php endif; ?>
257 <?php else : ?>
258 <p>Please Wait For <b><?php email_flood_interval(); ?> Minutes</b> Before Sending The Next Article.</p>
259 <?php endif; ?>
260 </div>
261 <?php get_sidebar(); ?>
262 <?php get_footer(); ?>