PluginProbe
WP-EMail / 2.50
WP-EMail v2.50
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.50, at wp-email.php

1,486 lines 64.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: WP-EMail
4 Plugin URI: http://lesterchan.net/portfolio/programming/php/
5 Description: Allows people to recommand/send your WordPress blog's post/page to a friend.
6 Version: 2.50
7 Author: Lester 'GaMerZ' Chan
8 Author URI: http://lesterchan.net
9 */
10
11
12 /*
13 Copyright 2009 Lester Chan (email : lesterchan@gmail.com)
14
15 This program is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation; either version 2 of the License, or
18 (at your option) any later version.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 */
29
30
31 ### Define: Show Email Remarks In Logs?
32 define('EMAIL_SHOW_REMARKS', true);
33
34
35 ### Load WP-Config File If This File Is Called Directly
36 if (!function_exists('add_action')) {
37 $wp_root = '../../..';
38 if (file_exists($wp_root.'/wp-load.php')) {
39 require_once($wp_root.'/wp-load.php');
40 } else {
41 require_once($wp_root.'/wp-config.php');
42 }
43 }
44
45
46 ### Create Text Domain For Translations
47 add_action('init', 'email_textdomain');
48 function email_textdomain() {
49 load_plugin_textdomain('wp-email', false, 'wp-email');
50 }
51
52
53 ### E-Mail Table Name
54 global $wpdb;
55 $wpdb->email = $wpdb->prefix.'email';
56
57
58 ### Function: E-Mail Administration Menu
59 add_action('admin_menu', 'email_menu');
60 function email_menu() {
61 if (function_exists('add_menu_page')) {
62 add_menu_page(__('E-Mail', 'wp-email'), __('E-Mail', 'wp-email'), 'manage_email', 'wp-email/email-manager.php', '', plugins_url('wp-email/images/email_famfamfam.png'));
63 }
64 if (function_exists('add_submenu_page')) {
65 add_submenu_page('wp-email/email-manager.php', __('Manage E-Mail', 'wp-email'), __('Manage E-Mail', 'wp-email'), 'manage_email', 'wp-email/email-manager.php');
66 add_submenu_page('wp-email/email-manager.php', __('E-Mail Options', 'wp-email'), __('E-Mail Options', 'wp-email'), 'manage_email', 'wp-email/email-options.php');
67 add_submenu_page('wp-email/email-manager.php', __('Uninstall WP-EMail', 'wp-email'), __('Uninstall WP-EMail', 'wp-email'), 'manage_email', 'wp-email/email-uninstall.php');
68 }
69 }
70
71
72 ### Function: E-Mail htaccess ReWrite Rules
73 add_filter('generate_rewrite_rules', 'email_rewrite');
74 function email_rewrite($wp_rewrite) {
75 $email_link = get_permalink();
76 $page_uris = $wp_rewrite->page_uri_index();
77 $uris = $page_uris[0];
78 if(substr($email_link, -1, 1) != '/' && substr($wp_rewrite->permalink_structure, -1, 1) != '/') {
79 $email_link_text = '/email';
80 $email_popup_text = '/emailpopup';
81 } else {
82 $email_link_text = 'email';
83 $email_popup_text = 'emailpopup';
84 }
85 // WP-EMail Standalone Post Rules
86 $rewrite_rules = $wp_rewrite->generate_rewrite_rule($wp_rewrite->permalink_structure.$email_link_text, EP_PERMALINK);
87 $rewrite_rules = array_slice($rewrite_rules, 5, 1);
88 $r_rule = array_keys($rewrite_rules);
89 $r_rule = array_shift($r_rule);
90 $r_rule = str_replace('/trackback', '', $r_rule);
91 $r_link = array_values($rewrite_rules);
92 $r_link = array_shift($r_link);
93 $r_link = str_replace('tb=1', 'email=1', $r_link);
94 $wp_rewrite->rules = array_merge(array($r_rule => $r_link), $wp_rewrite->rules);
95 // WP-Email Standalone Page Rules
96 if(is_array($uris)) {
97 $email_page_rules = array();
98 foreach ($uris as $uri => $pagename) {
99 $wp_rewrite->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
100 $rewrite_rules = $wp_rewrite->generate_rewrite_rules($wp_rewrite->get_page_permastruct().'/emailpage', EP_PAGES);
101 $rewrite_rules = array_slice($rewrite_rules, 5, 1);
102 $r_rule = array_keys($rewrite_rules);
103 $r_rule = array_shift($r_rule);
104 $r_rule = str_replace('/trackback', '', $r_rule);
105 $r_link = array_values($rewrite_rules);
106 $r_link = array_shift($r_link);
107 $r_link = str_replace('tb=1', 'email=1', $r_link);
108 $email_page_rules = array_merge($email_page_rules, array($r_rule => $r_link));
109 }
110 $wp_rewrite->rules = array_merge($email_page_rules, $wp_rewrite->rules);
111 }
112
113 // WP-EMail Popup Post Rules
114 $rewrite_rules = $wp_rewrite->generate_rewrite_rule($wp_rewrite->permalink_structure.$email_popup_text, EP_PERMALINK);
115 $rewrite_rules = array_slice($rewrite_rules, 5, 1);
116 $r_rule = array_keys($rewrite_rules);
117 $r_rule = array_shift($r_rule);
118 $r_rule = str_replace('/trackback', '', $r_rule);
119 $r_link = array_values($rewrite_rules);
120 $r_link = array_shift($r_link);
121 $r_link = str_replace('tb=1', 'emailpopup=1', $r_link);
122 $wp_rewrite->rules = array_merge(array($r_rule => $r_link), $wp_rewrite->rules);
123 if(is_array($uris)) {
124 $email_page_rules = array();
125 foreach ($uris as $uri => $pagename) {
126 $wp_rewrite->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
127 $rewrite_rules = $wp_rewrite->generate_rewrite_rules($wp_rewrite->get_page_permastruct().'/emailpopuppage', EP_PAGES);
128 $rewrite_rules = array_slice($rewrite_rules, 5, 1);
129 $r_rule = array_keys($rewrite_rules);
130 $r_rule = array_shift($r_rule);
131 $r_rule = str_replace('/trackback', '', $r_rule);
132 $r_link = array_values($rewrite_rules);
133 $r_link = array_shift($r_link);
134 $r_link = str_replace('tb=1', 'emailpopup=1', $r_link);
135 $email_page_rules = array_merge($email_page_rules, array($r_rule => $r_link));
136 }
137 $wp_rewrite->rules = array_merge($email_page_rules, $wp_rewrite->rules);
138 }
139 }
140
141
142 ### Function: E-Mail Public Variables
143 add_filter('query_vars', 'email_variables');
144 function email_variables($public_query_vars) {
145 $public_query_vars[] = 'email';
146 $public_query_vars[] = 'emailpopup';
147 return $public_query_vars;
148 }
149
150
151 ### Function: Print Out jQuery Script At The Top
152 add_action('wp_head', 'email_javascripts_header');
153 function email_javascripts_header() {
154 wp_print_scripts('jquery');
155 }
156
157
158 ### Function: Enqueue E-Mail Javascripts/CSS
159 add_action('wp_enqueue_scripts', 'email_scripts');
160 function email_scripts() {
161 global $text_direction;
162 if(@file_exists(TEMPLATEPATH.'/email-css.css')) {
163 wp_enqueue_style('wp-email', get_stylesheet_directory_uri().'/email-css.css', false, '2.50', 'all');
164 } else {
165 wp_enqueue_style('wp-email', plugins_url('wp-email/email-css.css'), false, '2.50', 'all');
166 }
167 if('rtl' == $text_direction) {
168 if(@file_exists(TEMPLATEPATH.'/email-css-rtl.css')) {
169 wp_enqueue_style('wp-email-rtl', get_stylesheet_directory_uri().'/email-css-rtl.css', false, '2.50', 'all');
170 } else {
171 wp_enqueue_style('wp-email-rtl', plugins_url('wp-email/email-css-rtl.css'), false, '2.50', 'all');
172 }
173 }
174 $email_max = intval(get_option('email_multiple'));
175 wp_enqueue_script('wp-email', plugins_url('wp-email/email-js.js'), array('jquery'), '2.50', true);
176 wp_localize_script('wp-email', 'emailL10n', array(
177 'ajax_url' => plugins_url('wp-email/wp-email.php'),
178 'max_allowed' => $email_max,
179 'text_error' => __('The Following Error Occurs:', 'wp-email'),
180 'text_name_invalid' => __('- Your Name is empty/invalid', 'wp-email'),
181 'text_email_invalid' => __('- Your Email is empty/invalid', 'wp-email'),
182 'text_remarks_invalid' => __('- Your Remarks is invalid', 'wp-email'),
183 'text_friend_names_empty' => __('- Friend Name(s) is empty', 'wp-email'),
184 'text_friend_name_invalid' => __('- Friend Name is empty/invalid: ', 'wp-email'),
185 'text_max_friend_names_allowed' => sprintf(_n('- Maximum %s Friend Name allowed', '- Maximum %s Friend Names allowed', $email_max, 'wp-email'), number_format_i18n($email_max)),
186 'text_friend_emails_empty' => __('- Friend Email(s) is empty', 'wp-email'),
187 'text_friend_email_invalid' => __('- Friend Email is invalid: ', 'wp-email'),
188 'text_max_friend_emails_allowed' => sprintf(_n('- Maximum %s Friend Email allowed', '- Maximum %s Friend Emails allowed', $email_max, 'wp-email'), number_format_i18n($email_max)),
189 'text_friends_tally' => __('- Friend Name(s) count does not tally with Friend Email(s) count', 'wp-email'),
190 'text_image_verify_empty' => __('- Image Verification is empty', 'wp-email')
191 ));
192 }
193
194
195 ### Function: Enqueue E-Mail Stylesheet In WP-Admin
196 add_action('admin_enqueue_scripts', 'email_stylesheets_admin');
197 function email_stylesheets_admin($hook_suffix) {
198 $email_admin_pages = array('wp-email/email-manager.php', 'wp-email/email-options.php', 'wp-email/email-uninstall.php');
199 if(in_array($hook_suffix, $email_admin_pages)) {
200 wp_enqueue_style('wp-email-admin', plugins_url('wp-email/email-admin-css.css'), false, '2.50', 'all');
201 }
202 }
203
204
205 ### Function: Display E-Mail Link
206 function email_link($email_post_text = '', $email_page_text = '', $echo = true) {
207 global $id;
208 $output = '';
209 $using_permalink = get_option('permalink_structure');
210 $email_options = get_option('email_options');
211 $email_style = intval($email_options['email_style']);
212 $email_type = intval($email_options['email_type']);
213 if(empty($email_post_text)) {
214 $email_text = stripslashes($email_options['post_text']);
215 } else {
216 $email_text = $email_post_text;
217 }
218 $email_icon = plugins_url('wp-email/images/'.$email_options['email_icon']);
219 $email_link = get_permalink();
220 $email_html = stripslashes($email_options['email_html']);
221 $onclick = '';
222 // Fix For Static Page
223 if(get_option('show_on_front') == 'page' && is_page()) {
224 if(intval(get_option('page_on_front')) > 0) {
225 $email_link = _get_page_link();
226 }
227 }
228 switch($email_type) {
229 // E-Mail Standalone Page
230 case 1:
231 if(!empty($using_permalink)) {
232 if(substr($email_link, -1, 1) != '/') {
233 $email_link= $email_link.'/';
234 }
235 if(is_page()) {
236 if(empty($email_page_text)) {
237 $email_text = stripslashes($email_options['page_text']);
238 } else {
239 $email_text = $email_page_text;
240 }
241 $email_link = $email_link.'emailpage/';
242 } else {
243 $email_link = $email_link.'email/';
244 }
245 } else {
246 if(is_page()) {
247 if(empty($email_page_text)) {
248 $email_text = stripslashes($email_options['page_text']);
249 } else {
250 $email_text = $email_page_text;
251 }
252 }
253 $email_link = $email_link.'&amp;email=1';
254 }
255 break;
256 // E-Mail Popup
257 case 2:
258 if(!empty($using_permalink)) {
259 if(substr($email_link, -1, 1) != '/') {
260 $email_link= $email_link.'/';
261 }
262 if(is_page()) {
263 if(empty($email_page_text)) {
264 $email_text = stripslashes($email_options['page_text']);
265 } else {
266 $email_text = $email_page_text;
267 }
268 $email_link = $email_link.'emailpopuppage/';
269 } else {
270 $email_link = $email_link.'emailpopup/';
271 }
272 } else {
273 if(is_page()) {
274 if(empty($email_page_text)) {
275 $email_text = stripslashes($email_options['page_text']);
276 } else {
277 $email_text = $email_page_text;
278 }
279 }
280 $email_link = $email_link.'&amp;emailpopup=1';
281 }
282 $onclick = ' onclick="email_popup(this.href); return false;" ';
283 break;
284 }
285 unset($email_options);
286 switch($email_style) {
287 // Icon + Text Link
288 case 1:
289 $output = '<a href="'.$email_link.'"'.$onclick.' title="'.$email_text.'" rel="nofollow"><img class="WP-EmailIcon" src="'.$email_icon.'" alt="'.$email_text.'" title="'.$email_text.'" style="border: 0px;" /></a>&nbsp;<a href="'.$email_link.'"'.$onclick.' title="'.$email_text.'" rel="nofollow">'.$email_text.'</a>';
290 break;
291 // Icon Only
292 case 2:
293 $output = '<a href="'.$email_link.'"'.$onclick.' title="'.$email_text.'" rel="nofollow"><img class="WP-EmailIcon" src="'.$email_icon.'" alt="'.$email_text.'" title="'.$email_text.'" style="border: 0px;" /></a>';
294 break;
295 // Text Link Only
296 case 3:
297 $output = '<a href="'.$email_link.'"'.$onclick.' title="'.$email_text.'" rel="nofollow">'.$email_text.'</a>';
298 break;
299 case 4:
300 $email_html = str_replace("%EMAIL_URL%", $email_link, $email_html);
301 $email_html = str_replace("%EMAIL_POPUP%", $onclick, $email_html);
302 $email_html = str_replace("%EMAIL_TEXT%", $email_text, $email_html);
303 $email_html = str_replace("%EMAIL_ICON_URL%", $email_icon, $email_html);
304 $output = $email_html;
305 break;
306 }
307 if($echo) {
308 echo $output."\n";
309 } else {
310 return $output;
311 }
312 }
313
314
315 ### Function: Short Code For Inserting Email Links Into Posts/Pages
316 add_shortcode('email_link', 'email_link_shortcode');
317 function email_link_shortcode($atts) {
318 if(!is_feed()) {
319 return email_link('', '', false);
320 } else {
321 return __('Note: There is an email link embedded within this post, please visit this post to email it.', 'wp-email');
322 }
323 }
324 function email_link_shortcode2($atts) {
325 return;
326 }
327
328
329 ### Function: Short Code For DO NOT EMAIL Content
330 add_shortcode('donotemail', 'email_donotemail_shortcode');
331 function email_donotemail_shortcode($atts, $content = null) {
332 return do_shortcode($content);
333 }
334 function email_donotemail_shortcode2($atts, $content = null) {
335 return;
336 }
337
338
339 ### Function: Snippet Words
340 if(!function_exists('snippet_words')) {
341 function snippet_words($text, $length = 0) {
342 $words = split(' ', $text);
343 return join(" ",array_slice($words, 0, $length)).'...';
344 }
345 }
346
347
348 ### Function: Snippet Text
349 if(!function_exists('snippet_text')) {
350 function snippet_text($text, $length = 0) {
351 if (defined('MB_OVERLOAD_STRING')) {
352 $text = @html_entity_decode($text, ENT_QUOTES, get_option('blog_charset'));
353 if (mb_strlen($text) > $length) {
354 return htmlentities(mb_substr($text,0,$length), ENT_COMPAT, get_option('blog_charset')).'...';
355 } else {
356 return htmlentities($text, ENT_COMPAT, get_option('blog_charset'));
357 }
358 } else {
359 $text = @html_entity_decode($text, ENT_QUOTES, get_option('blog_charset'));
360 if (strlen($text) > $length) {
361 return htmlentities(substr($text,0,$length), ENT_COMPAT, get_option('blog_charset')).'...';
362 } else {
363 return htmlentities($text, ENT_COMPAT, get_option('blog_charset'));
364 }
365 }
366 }
367 }
368
369
370 ### Function: Add E-Mail Filters
371 function email_addfilters() {
372 global $emailfilters_count;
373 if(get_option('k2version') === false) {
374 $loop_count = 0;
375 } else {
376 $loop_count = 1;
377 }
378 if(intval($emailfilters_count) == $loop_count) {
379 add_filter('the_title', 'email_title');
380 add_filter('the_content', 'email_form', 10, 5);
381 }
382 $emailfilters_count++;
383 }
384
385
386 ### Function: Remove E-Mail Filters
387 function email_removefilters() {
388 remove_filter('the_title', 'email_title');
389 remove_filter('the_content', 'email_form', 10, 5);
390 }
391
392
393 ### Function: E-Mail Page Title
394 function email_pagetitle($page_title) {
395 $page_title .= ' &raquo; '.__('E-Mail', 'wp-email');
396 return $page_title;
397 }
398
399
400 ### Function: E-Mail Post ID
401 if(!function_exists('get_the_id')) {
402 function get_the_id() {
403 global $id;
404 return $id;
405 }
406 }
407
408
409 ### Function: Get E-Mail Title
410 function email_get_title() {
411 global $post;
412 $post_title = $post->post_title;
413 if(!empty($post->post_password)) {
414 $post_title = sprintf(__('Protected: %s', 'wp-email'), $post_title);
415 } elseif($post->post_status == 'private') {
416 $post_title = sprintf(__('Private: %s', 'wp-email'), $post_title);
417 }
418 return $post_title;
419 }
420
421
422 ### Function: E-Mail Title
423 function email_title($page_title) {
424 if(in_the_loop()) {
425 $post_title = email_get_title();
426 $post_author = the_author('', false);
427 $post_date = get_the_time(get_option('date_format').' ('.get_option('time_format').')', '', '', false);
428 $post_category = email_category(__(',', 'wp-email').' ');
429 $post_category_alt = strip_tags($post_category);
430 $template_title = stripslashes(get_option('email_template_title'));
431 $template_title = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_title);
432 $template_title = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_title);
433 $template_title = str_replace("%EMAIL_POST_DATE%", $post_date, $template_title);
434 $template_title = str_replace("%EMAIL_POST_CATEGORY%", $post_category, $template_title);
435 $template_title = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_title);
436 $template_title = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_title);
437 $template_title = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_title);
438 return $template_title;
439 } else {
440 return $page_title;
441 }
442 }
443
444
445 ### Function: E-Mail Category
446 function email_category($separator = ', ', $parents='') {
447 return get_the_category_list($separator, $parents);
448 }
449
450
451 ### Function: E-Mail Content
452 function email_content() {
453 $content = get_email_content();
454 $email_snippet = intval(get_option('email_snippet'));
455 if($email_snippet > 0) {
456 return snippet_words($content , $email_snippet);
457 } else {
458 return $content;
459 }
460 }
461
462
463 ### Function: E-Mail Alternate Content
464 function email_content_alt() {
465 remove_filter('the_content', 'wptexturize');
466 $content = get_email_content();
467 $content = clean_pre($content);
468 $content = strip_tags($content);
469 $email_snippet = intval(get_option('email_snippet'));
470 if($email_snippet > 0) {
471 return snippet_words($content , $email_snippet);
472 } else {
473 return $content;
474 }
475 }
476
477
478 ### Function: E-Mail Get The Content
479 function get_email_content() {
480 global $pages, $multipage, $numpages, $post;
481 if (!empty($post->post_password)) {
482 if (stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password) {
483 return __('Password Protected Post', 'wp-email');
484 }
485 }
486 if($multipage) {
487 for($page = 0; $page < $numpages; $page++) {
488 $content .= $pages[$page];
489 }
490 } else {
491 $content = $pages[0];
492 }
493 $content = html_entity_decode($content);
494 $content = htmlspecialchars_decode($content);
495 if(function_exists('print_rewrite')) {
496 remove_shortcode('donotprint');
497 add_shortcode('donotprint', 'print_donotprint_shortcode2');
498 }
499 remove_shortcode('donotemail');
500 add_shortcode('donotemail', 'email_donotemail_shortcode2');
501 remove_shortcode('email_link');
502 add_shortcode('email_link', 'email_link_shortcode2');
503 $content = apply_filters('the_content', $content);
504 return $content;
505 }
506
507
508 ### Function: Get IP Address
509 function get_email_ipaddress() {
510 if (empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
511 $ip_address = $_SERVER["REMOTE_ADDR"];
512 } else {
513 $ip_address = $_SERVER["HTTP_X_FORWARDED_FOR"];
514 }
515 if(strpos($ip_address, ',') !== false) {
516 $ip_address = explode(',', $ip_address);
517 $ip_address = $ip_address[0];
518 }
519 return esc_attr($ip_address);
520 }
521
522
523 ### Function: Check For Password Protected Post
524 function not_password_protected() {
525 global $post;
526 if (!empty($post->post_password)) {
527 if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) {
528 return false;
529 }
530 }
531 return true;
532 }
533
534
535 ### Function: There Are Still Many PHP 4.x Users
536 if(!function_exists('htmlspecialchars_decode')) {
537 function htmlspecialchars_decode($string, $style = ENT_COMPAT) {
538 $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS,$style));
539 if($style === ENT_QUOTES) {
540 $translation['&#039;'] = '\'';
541 }
542 return strtr($string, $translation);
543 }
544 }
545
546
547 ### Function: Check Vaild Name (AlphaNumeric With Spaces Allowed Only)
548 if(!function_exists('is_valid_name')) {
549 function is_valid_name($name) {
550 $regex = '/[(\*\(\)\[\]\+\,\/\?\:\;\'\"\`\~\\#\$\%\^\&\<\>)+]/';
551 return !(preg_match($regex, $name));
552 }
553 }
554
555
556 ### Function: Check Valid E-Mail Address
557 if(!function_exists('is_valid_email')) {
558 function is_valid_email($email) {
559 $regex = '/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/';
560 return (preg_match($regex, $email));
561 }
562 }
563
564
565 ### Function: Check Valid Remarks (Ensure No E-Mail Injections)
566 if(!function_exists('is_valid_remarks')) {
567 function is_valid_remarks($content) {
568 $injection_strings = array('apparently-to', 'cc', 'bcc', 'boundary', 'charset', 'content-disposition', 'content-type', 'content-transfer-encoding', 'errors-to', 'in-reply-to', 'message-id', 'mime-version', 'multipart/mixed', 'multipart/alternative', 'multipart/related', 'reply-to', 'x-mailer', 'x-sender', 'x-uidl');
569 foreach ($injection_strings as $spam) {
570 $check = strpos(strtolower($content), $spam);
571 if ($check !== false) {
572 return false;
573 }
574 }
575 return true;
576 }
577 }
578
579
580 ### Function: Check For E-Mail Spamming
581 function not_spamming() {
582 global $wpdb;
583 $current_time = current_time('timestamp');
584 $email_ip = get_email_ipaddress();
585 $email_host = @gethostbyaddr($email_ip);
586 $email_status = __('Success', 'wp-email');
587 $last_emailed = $wpdb->get_var("SELECT email_timestamp FROM $wpdb->email WHERE email_ip = '$email_ip' AND email_host = '$email_host' AND email_status = '$email_status' ORDER BY email_timestamp DESC LIMIT 1");
588 $email_allow_interval = intval(get_option('email_interval'))*60;
589 if(($current_time-$last_emailed) < $email_allow_interval) {
590 return false;
591 } else {
592 return true;
593 }
594 }
595
596
597 ### Function: E-Mail Flood Interval
598 function email_flood_interval($echo = true) {
599 $email_allow_interval_min = intval(get_option('email_interval'));
600 if($echo) {
601 echo $email_allow_interval_min;
602 } else {
603 return $email_allow_interval_min;
604 }
605 }
606
607
608 ### Function: Fill In Email Fills If Logged In (By Aaron Campbell)
609 add_filter('email_form-fieldvalues', 'email_fill_fields');
610 function email_fill_fields($email_fields) {
611 global $current_user;
612 if ($current_user->ID > 0) {
613 $email_fields['yourname'] = trim(esc_attr($current_user->first_name.' '.$current_user->last_name));
614 $email_fields['youremail'] = esc_attr($current_user->user_email);
615 }
616 return $email_fields;
617 }
618
619
620 ### Function: E-Mail Form Header
621 function email_form_header($echo = true, $temp_id) {
622 global $id;
623 if(intval($temp_id) > 0) {
624 $id = $temp_id;
625 }
626 $using_permalink = get_option('permalink_structure');
627 $permalink = get_permalink();
628 // Fix For Static Page
629 if(get_option('show_on_front') == 'page' && is_page()) {
630 if(intval(get_option('page_on_front')) > 0) {
631 $permalink = _get_page_link();
632 }
633 }
634 $output = '';
635 if(!empty($using_permalink)) {
636 if(is_page()) {
637 $output .= '<form action="'.$permalink.'emailpage/" method="post">'."\n";
638 $output .= '<p style="display: none;"><input type="hidden" id="page_id" name="page_id" value="'.$id.'" /></p>'."\n";
639 } else {
640 $output = '<form action="'.$permalink.'email/" method="post">'."\n";
641 $output .= '<p style="display: none;"><input type="hidden" id="p" name="p" value="'.$id.'" /></p>'."\n";
642 }
643 } else {
644 if(is_page()) {
645 $output .= '<form action="'.$permalink.'&amp;email=1" method="post">'."\n";
646 $output .= '<p style="display: none;"><input type="hidden" id="page_id" name="page_id" value="'.$id.'" /></p>'."\n";
647 } else {
648 $output .= '<form action="'.$permalink.'&amp;email=1" method="post">'."\n";
649 $output .= '<p style="display: none;"><input type="hidden" id="p" name="p" value="'.$id.'" /></p>'."\n";
650 }
651 }
652 if($echo) {
653 echo $output;
654 } else {
655 return $output;
656 }
657 }
658
659
660 ### Function: E-Mail Form Header For Popup
661 function email_popup_form_header($echo = true, $temp_id) {
662 global $post;
663 $id = intval($post->ID);
664 if(intval($temp_id) > 0) {
665 $id = $temp_id;
666 }
667 $using_permalink = get_option('permalink_structure');
668 $permalink = get_permalink();
669 // Fix For Static Page
670 if(get_option('show_on_front') == 'page' && is_page()) {
671 if(intval(get_option('page_on_front')) > 0) {
672 $permalink = _get_page_link();
673 }
674 }
675 $output = '';
676 if(!empty($using_permalink)) {
677 if(is_page()) {
678 $output .= '<form action="'.$permalink.'emailpopuppage/" method="post">'."\n";
679 $output .= '<p style="display: none;"><input type="hidden" id="page_id" name="page_id" value="'.$id.'" /></p>'."\n";
680 } else {
681 $output = '<form action="'.$permalink.'emailpopup/" method="post">'."\n";
682 $output .= '<p style="display: none;"><input type="hidden" id="p" name="p" value="'.$id.'" /></p>'."\n";
683 }
684 } else {
685 if(is_page()) {
686 $output .= '<form action="'.$permalink.'&amp;emailpopup=1" method="post">'."\n";
687 $output .= '<p style="display: none;"><input type="hidden" id="page_id" name="page_id" value="'.$id.'" /></p>'."\n";
688 } else {
689 $output .= '<form action="'.$permalink.'&amp;emailpopup=1" method="post">'."\n";
690 $output .= '<p style="display: none;"><input type="hidden" id="p" name="p" value="'.$id.'" /></p>'."\n";
691 }
692 }
693 if($echo) {
694 echo $output;
695 } else {
696 return $output;
697 }
698 }
699
700
701 ### Function: Multiple E-Mails
702 function email_multiple($echo = true) {
703 $email_multiple = intval(get_option('email_multiple'));
704 if($email_multiple > 1) {
705 $output = '<br /><em>'.sprintf(_n('Separate multiple entries with a comma. Maximum %s entry.', 'Separate multiple entries with a comma. Maximum %s entries.', $email_multiple, 'wp-email'), number_format_i18n($email_multiple)).'</em>';
706 if($echo) {
707 echo $outut;
708 } else {
709 return $output;
710 }
711 }
712 }
713
714
715 ### Function: Get EMail Total Sent
716 if(!function_exists('get_emails')) {
717 function get_emails($echo = true) {
718 global $wpdb;
719 $totalemails = $wpdb->get_var("SELECT COUNT(email_id) FROM $wpdb->email");
720 if($echo) {
721 echo number_format_i18n($totalemails);
722 } else {
723 return number_format_i18n($totalemails);
724 }
725 }
726 }
727
728
729 ### Function: Get EMail Total Sent Success
730 if(!function_exists('get_emails_success')) {
731 function get_emails_success($echo = true) {
732 global $wpdb;
733 $totalemails_success = $wpdb->get_var("SELECT COUNT(email_id) FROM $wpdb->email WHERE email_status = '".__('Success', 'wp-email')."'");
734 if($echo) {
735 echo number_format_i18n($totalemails_success);
736 } else {
737 return number_format_i18n($totalemails_success);
738 }
739 }
740 }
741
742
743 ### Function: Get EMail Total Sent Failed
744 if(!function_exists('get_emails_failed')) {
745 function get_emails_failed($echo = true) {
746 global $wpdb;
747 $totalemails_failed = $wpdb->get_var("SELECT COUNT(email_id) FROM $wpdb->email WHERE email_status = '".__('Failed', 'wp-email')."'");
748 if($echo) {
749 echo number_format_i18n($totalemails_failed);
750 } else {
751 return number_format_i18n($totalemails_failed);
752 }
753 }
754 }
755
756
757 ### Function: Get Most E-Mailed
758 if(!function_exists('get_mostemailed')) {
759 function get_mostemailed($mode = '', $limit = 10, $chars = 0, $echo = true) {
760 global $wpdb, $post;
761 $temp_post = $post;
762 $where = '';
763 $temp = '';
764 if(!empty($mode) && $mode != 'both') {
765 $where = "post_type = '$mode'";
766 } else {
767 $where = '1=1';
768 }
769 $mostemailed= $wpdb->get_results("SELECT $wpdb->posts.*, COUNT($wpdb->email.email_postid) AS email_total FROM $wpdb->email LEFT JOIN $wpdb->posts ON $wpdb->email.email_postid = $wpdb->posts.ID WHERE post_date < '".current_time('mysql')."' AND $where AND post_password = '' AND post_status = 'publish' GROUP BY $wpdb->email.email_postid ORDER BY email_total DESC LIMIT $limit");
770 if($mostemailed) {
771 if($chars > 0) {
772 foreach ($mostemailed as $post) {
773 $post_title = get_the_title();
774 $email_total = intval($post->email_total);
775 $temp .= "<li><a href=\"".get_permalink()."\">".snippet_text($post_title, $chars)."</a> - ".sprintf(_n('%s email', '%s emails', $email_total, 'wp-email'), number_format_i18n($email_total))."</li>\n";
776 }
777 } else {
778 foreach ($mostemailed as $post) {
779 $post_title = get_the_title();
780 $email_total = intval($post->email_total);
781 $temp .= "<li><a href=\"".get_permalink()."\">$post_title</a> - ".sprintf(_n('%s email', '%s emails', $email_total, 'wp-email'), number_format_i18n($email_total))."</li>\n";
782 }
783 }
784 } else {
785 $temp = '<li>'.__('N/A', 'wp-email').'</li>'."\n";
786 }
787 $post = $temp_post;
788 if($echo) {
789 echo $temp;
790 } else {
791 return $temp;
792 }
793 }
794 }
795
796
797 ### Function: Load WP-EMail
798 add_action('template_redirect', 'wp_email', 5);
799 function wp_email() {
800 if(intval(get_query_var('email')) == 1) {
801 include(WP_PLUGIN_DIR.'/wp-email/email-standalone.php');
802 exit();
803 } elseif(intval(get_query_var('emailpopup')) == 1) {
804 include(WP_PLUGIN_DIR.'/wp-email/email-popup.php');
805 exit();
806 }
807 }
808
809
810 ### Function: Process E-Mail Form
811 process_email_form();
812 function process_email_form() {
813 global $wpdb, $post, $text_direction;
814 // If User Click On Mail
815 if(!empty($_POST['wp-email'])) {
816 @session_start();
817 email_textdomain();
818 header('Content-Type: text/html; charset='.get_option('blog_charset').'');
819 // POST Variables
820 $yourname = strip_tags(stripslashes(trim($_POST['yourname'])));
821 $youremail = strip_tags(stripslashes(trim($_POST['youremail'])));
822 $yourremarks = strip_tags(stripslashes(trim($_POST['yourremarks'])));
823 $friendname = strip_tags(stripslashes(trim($_POST['friendname'])));
824 $friendemail = strip_tags(stripslashes(trim($_POST['friendemail'])));
825 $imageverify = $_POST['imageverify'];
826 $p = intval($_POST['p']);
827 $page_id = intval($_POST['page_id']);
828 // Get Post Information
829 if($p > 0) {
830 $query_post = 'p='.$p;
831 $id = $p;
832 } else {
833 $query_post = 'page_id='.$page_id;
834 $id = $page_id;
835 }
836 query_posts($query_post);
837 if(have_posts()) {
838 while(have_posts()) {
839 the_post();
840 $post_title = email_get_title();
841 $post_author = get_the_author();
842 $post_date = get_the_time(get_option('date_format').' ('.get_option('time_format').')', '', '', false);
843 $post_category = email_category(__(',', 'wp-email').' ');
844 $post_category_alt = strip_tags($post_category);
845 $post_excerpt = get_the_excerpt();
846 $post_content = email_content();
847 $post_content_alt = email_content_alt();
848 }
849 }
850 // Error
851 $error = '';
852 $error_field = array('yourname' => $yourname, 'youremail' => $youremail, 'yourremarks' => $yourremarks, 'friendname' => $friendname, 'friendemail' => $friendemail, 'id' => $id);
853 // Get Options
854 $email_fields = get_option('email_fields');
855 $email_image_verify = intval(get_option('email_imageverify'));
856 $email_smtp = get_option('email_smtp');
857 // Multiple Names/Emails
858 $friends = array();
859 $friendname_count = 0;
860 $friendemail_count = 0;
861 $multiple_names = explode(',', $friendname);
862 $multiple_emails = explode(',', $friendemail);
863 $multiple_max = intval(get_option('email_multiple'));
864 if($multiple_max == 0) { $multiple_max = 1; }
865 // Checking Your Name Field For Errors
866 if(intval($email_fields['yourname']) == 1) {
867 if(empty($yourname)) {
868 $error .= '<br /><strong>&raquo;</strong> '.__('Your Name is empty', 'wp-email');
869 }
870 if(!is_valid_name($yourname)) {
871 $error .= '<br /><strong>&raquo;</strong> '.__('Your Name is invalid', 'wp-email');
872 }
873 }
874 // Checking Your E-Mail Field For Errors
875 if(intval($email_fields['youremail']) == 1) {
876 if(empty($youremail)) {
877 $error .= '<br /><strong>&raquo;</strong> '.__('Your Email is empty', 'wp-email');
878 }
879 if(!is_valid_email($youremail)) {
880 $error .= '<br /><strong>&raquo;</strong> '.__('Your Email is invalid', 'wp-email');
881 }
882 }
883 // Checking Your Remarks Field For Errors
884 if(intval($email_fields['yourremarks']) == 1) {
885 if(!is_valid_remarks($yourremarks)) {
886 $error .= '<br /><strong>&raquo;</strong> '.__('Your Remarks is invalid', 'wp-email');
887 }
888 }
889 // Checking Friend's Name Field For Errors
890 if(intval($email_fields['friendname']) == 1) {
891 if(empty($friendname)) {
892 $error .= '<br /><strong>&raquo;</strong> '.__('Friend Name(s) is empty', 'wp-email');
893 } else {
894 if($multiple_names) {
895 foreach($multiple_names as $multiple_name) {
896 $multiple_name = trim($multiple_name);
897 if(empty($multiple_name)) {
898 $error .= '<br /><strong>&raquo;</strong> '.sprintf(__('Friend Name is empty: %s', 'wp-email'), $multiple_name);
899 } elseif(!is_valid_name($multiple_name)) {
900 $error .= '<br /><strong>&raquo;</strong> '.sprintf(__('Friend Name is invalid: %s', 'wp-email'), $multiple_name);
901 } else {
902 $friends[$friendname_count]['name'] = $multiple_name;
903 $friendname_count++;
904 }
905 if($friendname_count > $multiple_max) {
906 break;
907 }
908 }
909 }
910 }
911 }
912 // Checking Friend's E-Mail Field For Errors
913 if(empty($friendemail)) {
914 $error .= '<br /><strong>&raquo;</strong> '.__('Friend Email(s) is empty', 'wp-email');
915 } else {
916 if($multiple_emails) {
917 foreach($multiple_emails as $multiple_email) {
918 $multiple_email = trim($multiple_email);
919 if(empty($multiple_email)) {
920 $error .= '<br /><strong>&raquo;</strong> '.sprintf(__('Friend Email is empty: %s', 'wp-email'), $multiple_email);
921 } elseif(!is_valid_email($multiple_email)) {
922 $error .= '<br /><strong>&raquo;</strong> '.sprintf(__('Friend Email is invalid: %s', 'wp-email'), $multiple_email);
923 } else {
924 $friends[$friendemail_count]['email'] = $multiple_email;
925 $friendemail_count++;
926 }
927 if($friendemail_count > $multiple_max) {
928 break;
929 }
930 }
931 }
932 }
933 // Checking If The Fields Exceed The Size Of Maximum Entries Allowed
934 if(sizeof($friends) > $multiple_max) {
935 $error .= '<br /><strong>&raquo;</strong> '.sprintf(_n('Maximum %s Friend allowed', 'Maximum %s Friend(s) allowed', $multiple_max, 'wp-email'), number_format_i18n($multiple_max));
936 }
937 if(intval($email_fields['friendname']) == 1) {
938 if($friendname_count != $friendemail_count) {
939 $error .= '<br /><strong>&raquo;</strong> '.__('Friend Name(s) count does not tally with Friend Email(s) count', 'wp-email');
940 }
941 }
942 // Check Whether We Enable Image Verification
943 if($email_image_verify) {
944 $imageverify = strtoupper($imageverify);
945 if(empty($imageverify)) {
946 $error .= '<br /><strong>&raquo;</strong> '.__('Image Verification is empty', 'wp-email');
947 } else {
948 if($_SESSION['email_verify'] != md5($imageverify)) {
949 $error .= '<br /><strong>&raquo;</strong> '.__('Image Verification failed', 'wp-email');
950 }
951 }
952 }
953 // If There Is No Error, We Process The E-Mail
954 if(empty($error) && not_spamming()) {
955 // If Remarks Is Empty, Assign N/A
956 if(empty($yourremarks)) { $yourremarks = __('N/A', 'wp-email'); }
957 // Template For E-Mail Subject
958 $template_email_subject = stripslashes(get_option('email_template_subject'));
959 $template_email_subject = str_replace("%EMAIL_YOUR_NAME%", $yourname, $template_email_subject);
960 $template_email_subject = str_replace("%EMAIL_YOUR_EMAIL%", $youremail, $template_email_subject);
961 $template_email_subject = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_subject);
962 $template_email_subject = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_email_subject);
963 $template_email_subject = str_replace("%EMAIL_POST_DATE%", $post_date, $template_email_subject);
964 $template_email_subject = str_replace("%EMAIL_POST_CATEGORY%", $post_category_alt, $template_email_subject);
965 $template_email_subject = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_subject);
966 $template_email_subject = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_subject);
967 $template_email_subject = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_subject);
968 // Template For E-Mail Body
969 $template_email_body = stripslashes(get_option('email_template_body'));
970 $template_email_body = str_replace("%EMAIL_YOUR_NAME%", $yourname, $template_email_body);
971 $template_email_body = str_replace("%EMAIL_YOUR_EMAIL%", $youremail, $template_email_body);
972 $template_email_body = str_replace("%EMAIL_YOUR_REMARKS%", $yourremarks, $template_email_body);
973 $template_email_body = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_body);
974 $template_email_body = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_body);
975 $template_email_body = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_body);
976 $template_email_body = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_email_body);
977 $template_email_body = str_replace("%EMAIL_POST_DATE%", $post_date, $template_email_body);
978 $template_email_body = str_replace("%EMAIL_POST_CATEGORY%", $post_category, $template_email_body);
979 $template_email_body = str_replace("%EMAIL_POST_EXCERPT%", $post_excerpt, $template_email_body);
980 $template_email_body = str_replace("%EMAIL_POST_CONTENT%", $post_content, $template_email_body);
981 $template_email_body = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_body);
982 $template_email_body = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_body);
983 $template_email_body = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_body);
984 if('rtl' == $text_direction) {
985 $template_email_body = "<div style=\"direction: rtl;\">$template_email_body</div>";
986 }
987 // Template For E-Mail Alternate Body
988 $template_email_bodyalt = stripslashes(get_option('email_template_bodyalt'));
989 $template_email_bodyalt = str_replace("%EMAIL_YOUR_NAME%", $yourname, $template_email_bodyalt);
990 $template_email_bodyalt = str_replace("%EMAIL_YOUR_EMAIL%", $youremail, $template_email_bodyalt);
991 $template_email_bodyalt = str_replace("%EMAIL_YOUR_REMARKS%", $yourremarks, $template_email_bodyalt);
992 $template_email_bodyalt = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_bodyalt);
993 $template_email_bodyalt = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_bodyalt);
994 $template_email_bodyalt = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_bodyalt);
995 $template_email_bodyalt = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_email_bodyalt);
996 $template_email_bodyalt = str_replace("%EMAIL_POST_DATE%", $post_date, $template_email_bodyalt);
997 $template_email_bodyalt = str_replace("%EMAIL_POST_CATEGORY%", $post_category_alt, $template_email_bodyalt);
998 $template_email_bodyalt = str_replace("%EMAIL_POST_EXCERPT%", $post_excerpt, $template_email_bodyalt);
999 $template_email_bodyalt = str_replace("%EMAIL_POST_CONTENT%", $post_content_alt, $template_email_bodyalt);
1000 $template_email_bodyalt = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_bodyalt);
1001 $template_email_bodyalt = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_bodyalt);
1002 $template_email_bodyalt = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_bodyalt);
1003 // PHP Mailer Variables
1004 if (!class_exists("phpmailer")) {
1005 require_once(ABSPATH.'wp-includes/class-phpmailer.php');
1006 }
1007 $mail = new PHPMailer();
1008 $mail->From = $youremail;
1009 $mail->FromName = $yourname;
1010 foreach($friends as $friend) {
1011 $mail->AddAddress($friend['email'], $friend['name']);
1012 }
1013 $mail->CharSet = get_bloginfo('charset');
1014 $mail->Username = $email_smtp['username'];
1015 $mail->Password = $email_smtp['password'];
1016 $mail->Host = $email_smtp['server'];
1017 $mail->Mailer = get_option('email_mailer');
1018 if($mail->Mailer == 'smtp') {
1019 $mail->SMTPAuth = true;
1020 }
1021 $mail->ContentType = get_option('email_contenttype');
1022 $mail->Subject = $template_email_subject;
1023 if(get_option('email_contenttype') == 'text/plain') {
1024 $mail->Body = $template_email_bodyalt;
1025 } else {
1026 $mail->Body = $template_email_body;
1027 $mail->AltBody = $template_email_bodyalt;
1028 }
1029 // Send The Mail if($mail->Send()) {
1030 if($mail->Send()) {
1031 $email_status = __('Success', 'wp-email');
1032 // Template For Sent Successfully
1033 $template_email_sentsuccess = stripslashes(get_option('email_template_sentsuccess'));
1034 $template_email_sentsuccess = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_sentsuccess);
1035 $template_email_sentsuccess = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_sentsuccess);
1036 $template_email_sentsuccess = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_sentsuccess);
1037 $template_email_sentsuccess = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_sentsuccess);
1038 $template_email_sentsuccess = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_sentsuccess);
1039 $template_email_sentsuccess = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_sentsuccess);
1040 // If There Is Error Sending
1041 } else {
1042 if($yourremarks == __('N/A', 'wp-email')) { $yourremarks = ''; }
1043 $email_status = __('Failed', 'wp-email');
1044 // Template For Sent Failed
1045 $template_email_sentfailed = stripslashes(get_option('email_template_sentfailed'));
1046 $template_email_sentfailed = str_replace("%EMAIL_FRIEND_NAME%", $friendname, $template_email_sentfailed);
1047 $template_email_sentfailed = str_replace("%EMAIL_FRIEND_EMAIL%", $friendemail, $template_email_sentfailed);
1048 $template_email_sentfailed = str_replace("%EMAIL_ERROR_MSG%", $mail->ErrorInfo, $template_email_sentfailed);
1049 $template_email_sentfailed = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_email_sentfailed);
1050 $template_email_sentfailed = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_sentfailed);
1051 $template_email_sentfailed = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_sentfailed);
1052 $template_email_sentfailed = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_sentfailed);
1053 }
1054 // Logging
1055 $email_yourname = addslashes($yourname);
1056 $email_youremail = addslashes($youremail);
1057 $email_yourremarks = addslashes($yourremarks);
1058 $email_postid = intval(get_the_id());
1059 $email_posttitle = addslashes($post_title);
1060 $email_timestamp = current_time('timestamp');
1061 $email_ip = get_email_ipaddress();
1062 $email_host = @gethostbyaddr($email_ip);
1063 foreach($friends as $friend) {
1064 $email_friendname = addslashes($friend['name']);
1065 $email_friendemail = addslashes($friend['email']);
1066 $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')");
1067 }
1068 if($email_status == __('Success', 'wp-email')) {
1069 $output = $template_email_sentsuccess;
1070 } else {
1071 $output = $template_email_sentfailed;
1072 }
1073 echo $output;
1074 exit();
1075 // If There Are Errors
1076 } else {
1077 $error = substr($error, 21);
1078 $template_email_error = stripslashes(get_option('email_template_error'));
1079 $template_email_error = str_replace("%EMAIL_ERROR_MSG%", $error, $template_email_error);
1080 $template_email_error = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_email_error);
1081 $template_email_error = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_email_error);
1082 $template_email_error = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_email_error);
1083 $output = $template_email_error;
1084 $output .= email_form('', false, false, false, $error_field);
1085 echo $output;
1086 exit();
1087 } // End if(empty($error))
1088 } // End if(!empty($_POST['wp-email']))
1089 }
1090
1091
1092 ### Function: E-Mail Form
1093 function email_form($content, $echo = true, $subtitle = true, $div = true, $error_field = '') {
1094 global $wpdb, $multipage;
1095 // Variables
1096 $multipage = false;
1097 $post_title = email_get_title();
1098 $post_author = the_author('', false);
1099 $post_date = get_the_time(get_option('date_format').' ('.get_option('time_format').')', '', '', false);
1100 $post_category = email_category(__(',', 'wp-email').' ');
1101 $post_category_alt = strip_tags($post_category);
1102 $email_fields = get_option('email_fields');
1103 $email_image_verify = intval(get_option('email_imageverify'));
1104 $email_options = get_option('email_options');
1105 $email_type = intval($email_options['email_type']);
1106 $error_field = apply_filters('email_form-fieldvalues', $error_field);
1107 // Template - Subtitle
1108 if($subtitle) {
1109 $template_subtitle = stripslashes(get_option('email_template_subtitle'));
1110 $template_subtitle = str_replace("%EMAIL_POST_TITLE%", $post_title, $template_subtitle);
1111 $template_subtitle = str_replace("%EMAIL_POST_AUTHOR%", $post_author, $template_subtitle);
1112 $template_subtitle = str_replace("%EMAIL_POST_DATE%", $post_date, $template_subtitle);
1113 $template_subtitle = str_replace("%EMAIL_POST_CATEGORY%", $post_category, $template_subtitle);
1114 $template_subtitle = str_replace("%EMAIL_BLOG_NAME%", get_bloginfo('name'), $template_subtitle);
1115 $template_subtitle = str_replace("%EMAIL_BLOG_URL%", get_bloginfo('url'), $template_subtitle);
1116 $template_subtitle = str_replace("%EMAIL_PERMALINK%", get_permalink(), $template_subtitle);
1117 $output .= $template_subtitle;
1118 }
1119 // Display WP-EMail Form
1120 if($div) {
1121 $output .= '<div id="wp-email-content" class="wp-email">'."\n";
1122 }
1123 if (not_spamming()) {
1124 if(not_password_protected()) {
1125 if($email_type == 2){
1126 $output .= email_popup_form_header(false, $error_field['id']);
1127 } else {
1128 $output .= email_form_header(false, $error_field['id']);
1129 }
1130 $output .= '<!-- Display Error, If There Is Any -->'."\n";
1131 $output .= $template_email_sentfailed;
1132 $output .= $template_email_error;
1133 $output .= '<!-- End Display Error, If There Is Any -->'."\n";
1134 $output .= '<p id="wp-email-required">'.__('* Required Field', 'wp-email').'</p>'."\n";
1135 if(intval($email_fields['yourname']) == 1) {
1136 $output .= '<p>'."\n";
1137 $output .= '<label for="yourname">'.__('Your Name: *', 'wp-email').'</label><br />'."\n";
1138 $output .= '<input type="text" size="50" id="yourname" name="yourname" class="TextField" value="'.$error_field['yourname'].'" />'."\n";
1139 $output .= '</p>'."\n";
1140 }
1141 if(intval($email_fields['youremail']) == 1) {
1142 $output .= '<p>'."\n";
1143 $output .= '<label for="youremail">'.__('Your E-Mail: *', 'wp-email').'</label><br />'."\n";
1144 $output .= '<input type="text" size="50" id="youremail" name="youremail" class="TextField" value="'.$error_field['youremail'].'" dir="ltr" />'."\n";
1145 $output .= '</p>'."\n";
1146 }
1147 if(intval($email_fields['yourremarks']) == 1) {
1148 $output .= '<p>'."\n";
1149 $output .= ' <label for="yourremarks">'.__('Your Remark:', 'wp-email').'</label><br />'."\n";
1150 $output .= ' <textarea cols="49" rows="8" id="yourremarks" name="yourremarks" class="Forms">'.$error_field['yourremarks'].'</textarea>'."\n";
1151 $output .= '</p>'."\n";
1152 }
1153 if(intval($email_fields['friendname']) == 1) {
1154 $output .= '<p>'."\n";
1155 $output .= '<label for="friendname">'.__('Friend\'s Name: *', 'wp-email').'</label><br />'."\n";
1156 $output .= '<input type="text" size="50" id="friendname" name="friendname" class="TextField" value="'.$error_field['friendname'].'" />'.email_multiple(false)."\n";
1157 $output .= '</p>'."\n";
1158 }
1159 $output .= '<p>'."\n";
1160 $output .= '<label for="friendemail">'.__('Friend\'s E-Mail: *', 'wp-email').'</label><br />'."\n";
1161 $output .= '<input type="text" size="50" id="friendemail" name="friendemail" class="TextField" value="'.$error_field['friendemail'].'" dir="ltr" />'.email_multiple(false)."\n";
1162 $output .= '</p>'."\n";
1163 if($email_image_verify) {
1164 $output .= '<p>'."\n";
1165 $output .= '<label for="imageverify">'.__('Image Verification: *', 'wp-email').'</label><br />'."\n";
1166 $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";
1167 $output .= '</p>'."\n";
1168 }
1169 $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";
1170 $output .= '</form>'."\n";
1171 } else {
1172 $output .= get_the_password_form();
1173 } // End if(not_password_protected())
1174 } else {
1175 $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";
1176 } // End if (not_spamming())
1177 $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" />&nbsp;'.__('Loading', 'wp-email').' ...</div>'."\n";
1178 if($div) {
1179 $output .= '</div>'."\n";
1180 }
1181 email_removefilters();
1182 if($echo) {
1183 echo $output;
1184 } else {
1185 return $output;
1186 }
1187 }
1188
1189
1190 ### Function: Modify Default WordPress Listing To Make It Sorted By Most E-Mailed
1191 function email_fields($content) {
1192 global $wpdb;
1193 $content .= ", COUNT($wpdb->email.email_postid) AS email_total";
1194 return $content;
1195 }
1196 function email_join($content) {
1197 global $wpdb;
1198 $content .= " LEFT JOIN $wpdb->email ON $wpdb->email.email_postid = $wpdb->posts.ID";
1199 return $content;
1200 }
1201 function email_groupby($content) {
1202 global $wpdb;
1203 $content .= " $wpdb->email.email_postid";
1204 return $content;
1205 }
1206 function email_orderby($content) {
1207 $orderby = trim(addslashes($_GET['orderby']));
1208 if(empty($orderby) || ($orderby != 'asc' && $orderby != 'desc')) {
1209 $orderby = 'desc';
1210 }
1211 $content = " email_total $orderby";
1212 return $content;
1213 }
1214
1215
1216 ### Process The Sorting
1217 /*
1218 if($_GET['sortby'] == 'email') {
1219 add_filter('posts_fields', 'email_fields');
1220 add_filter('posts_join', 'email_join');
1221 add_filter('posts_groupby', 'email_groupby');
1222 add_filter('posts_orderby', 'email_orderby');
1223 }
1224 */
1225
1226
1227 ### Function: Plug Into WP-Stats
1228 if(strpos(get_option('stats_url'), $_SERVER['REQUEST_URI']) || strpos($_SERVER['REQUEST_URI'], 'stats-options.php') || strpos($_SERVER['REQUEST_URI'], 'wp-stats/wp-stats.php')) {
1229 add_filter('wp_stats_page_admin_plugins', 'email_page_admin_general_stats');
1230 add_filter('wp_stats_page_admin_most', 'email_page_admin_most_stats');
1231 add_filter('wp_stats_page_plugins', 'email_page_general_stats');
1232 add_filter('wp_stats_page_most', 'email_page_most_stats');
1233 }
1234
1235
1236 ### Function: Add WP-EMail General Stats To WP-Stats Page Options
1237 function email_page_admin_general_stats($content) {
1238 $stats_display = get_option('stats_display');
1239 if($stats_display['email'] == 1) {
1240 $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_email" value="email" checked="checked" />&nbsp;&nbsp;<label for="wpstats_email">'.__('WP-EMail', 'wp-email').'</label><br />'."\n";
1241 } else {
1242 $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_email" value="email" />&nbsp;&nbsp;<label for="wpstats_email">'.__('WP-EMail', 'wp-email').'</label><br />'."\n";
1243 }
1244 return $content;
1245 }
1246
1247
1248 ### Function: Add WP-EMail Top Most/Highest Stats To WP-Stats Page Options
1249 function email_page_admin_most_stats($content) {
1250 $stats_display = get_option('stats_display');
1251 $stats_mostlimit = intval(get_option('stats_mostlimit'));
1252 if($stats_display['emailed_most_post'] == 1) {
1253 $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_emailed_most_post" value="emailed_most_post" checked="checked" />&nbsp;&nbsp;<label for="wpstats_emailed_most_post">'.sprintf(_n('%s Most Emailed Post', '%s Most Emailed Posts', $stats_mostlimit, 'wp-email'), number_format_i18n($stats_mostlimit)).'</label><br />'."\n";
1254 } else {
1255 $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_emailed_most_post" value="emailed_most_post" />&nbsp;&nbsp;<label for="wpstats_emailed_most_post">'.sprintf(_n('%s Most Emailed Post', '%s Most Emailed Posts', $stats_mostlimit, 'wp-email'), number_format_i18n($stats_mostlimit)).'</label><br />'."\n";
1256 }
1257 if($stats_display['emailed_most_page'] == 1) {
1258 $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_emailed_most_page" value="emailed_most_page" checked="checked" />&nbsp;&nbsp;<label for="wpstats_emailed_most_page">'.sprintf(_n('%s Most Emailed Page', '%s Most Emailed Pages', $stats_mostlimit, 'wp-email'), number_format_i18n($stats_mostlimit)).'</label><br />'."\n";
1259 } else {
1260 $content .= '<input type="checkbox" name="stats_display[]" id="wpstats_emailed_most_page" value="emailed_most_page" />&nbsp;&nbsp;<label for="wpstats_emailed_most_page">'.sprintf(_n('%s Most Emailed Page', '%s Most Emailed Pages', $stats_mostlimit, 'wp-email'), number_format_i18n($stats_mostlimit)).'</label><br />'."\n";
1261 }
1262 return $content;
1263 }
1264
1265
1266 ### Function: Add WP-EMail General Stats To WP-Stats Page
1267 function email_page_general_stats($content) {
1268 global $wpdb;
1269 $stats_display = get_option('stats_display');
1270 if($stats_display['email'] == 1) {
1271 $email_stats = $wpdb->get_results("SELECT email_status, COUNT(email_id) AS email_total FROM $wpdb->email GROUP BY email_status");
1272 if($email_stats) {
1273 $email_stats_array = array();
1274 $email_stats_array['total'] = 0;
1275 foreach($email_stats as $email_stat) {
1276 $email_stats_array[$email_stat->email_status] = intval($email_stat->email_total);
1277 $email_stats_array['total'] += intval($email_stat->email_total);
1278 }
1279 }
1280 $content .= '<p><strong>'.__('WP-EMail', 'wp-email').'</strong></p>'."\n";
1281 $content .= '<ul>'."\n";
1282 $content .= '<li>'.sprintf(_n('<strong>%s</strong> email was sent.', '<strong>%s</strong> emails were sent.', $email_stats_array['total'], 'wp-email'), number_format_i18n($email_stats_array['total'])).'</li>'."\n";
1283 $content .= '<li>'.sprintf(_n('<strong>%s</strong> email was sent successfully.', '<strong>%s</strong> emails were sent successfully.', $email_stats_array[__('Success', 'wp-email')], 'wp-email'), number_format_i18n($email_stats_array[__('Success', 'wp-email')])).'</li>'."\n";
1284 $content .= '<li>'.sprintf(_n('<strong>%s</strong> email failed to send.', '<strong>%s</strong> emails failed to send.', $email_stats_array[__('Failed', 'wp-email')], 'wp-email'), number_format_i18n($email_stats_array[__('Failed', 'wp-email')])).'</li>'."\n";
1285 $content .= '</ul>'."\n";
1286 }
1287 return $content;
1288 }
1289
1290
1291 ### Function: Add WP-EMail Top Most/Highest Stats To WP-Stats Page
1292 function email_page_most_stats($content) {
1293 $stats_display = get_option('stats_display');
1294 $stats_mostlimit = intval(get_option('stats_mostlimit'));
1295 if($stats_display['emailed_most_post'] == 1) {
1296 $content .= '<p><strong>'.sprintf(_n('%s Most Emailed Post', '%s Most Emailed Posts', $stats_mostlimit, 'wp-email'), number_format_i18n($stats_mostlimit)).'</strong></p>'."\n";
1297 $content .= '<ul>'."\n";
1298 $content .= get_mostemailed('post', $stats_mostlimit, 0, false);
1299 $content .= '</ul>'."\n";
1300 }
1301 if($stats_display['emailed_most_page'] == 1) {
1302 $content .= '<p><strong>'.sprintf(_n('%s Most Emailed Page', '%s Most Emailed Pages', $stats_mostlimit, 'wp-email'), number_format_i18n($stats_mostlimit)).'</strong></p>'."\n";
1303 $content .= '<ul>'."\n";
1304 $content .= get_mostemailed('page', $stats_mostlimit, 0, false);
1305 $content .= '</ul>'."\n";
1306 }
1307 return $content;
1308 }
1309
1310
1311 ### Class: WP-EMail Widget
1312 class WP_Widget_Email extends WP_Widget {
1313 // Constructor
1314 function WP_Widget_Email() {
1315 $widget_ops = array('description' => __('WP-EMail emails statistics', 'wp-email'));
1316 $this->WP_Widget('email', __('Email', 'wp-email'), $widget_ops);
1317 }
1318
1319 // Display Widget
1320 function widget($args, $instance) {
1321 extract($args);
1322 $title = apply_filters('widget_title', esc_attr($instance['title']));
1323 $type = esc_attr($instance['type']);
1324 $mode = esc_attr($instance['mode']);
1325 $limit = intval($instance['limit']);
1326 $chars = intval($instance['chars']);
1327 //$cat_ids = explode(',', esc_attr($instance['cat_ids']));
1328 echo $before_widget.$before_title.$title.$after_title;
1329 echo '<ul>'."\n";
1330 switch($type) {
1331 case 'most_emailed':
1332 get_mostemailed($mode, $limit, $chars);
1333 break;
1334 }
1335 echo '</ul>'."\n";
1336 echo $after_widget;
1337 }
1338
1339 // When Widget Control Form Is Posted
1340 function update($new_instance, $old_instance) {
1341 if (!isset($new_instance['submit'])) {
1342 return false;
1343 }
1344 $instance = $old_instance;
1345 $instance['title'] = strip_tags($new_instance['title']);
1346 $instance['type'] = strip_tags($new_instance['type']);
1347 $instance['mode'] = strip_tags($new_instance['mode']);
1348 $instance['limit'] = intval($new_instance['limit']);
1349 $instance['chars'] = intval($new_instance['chars']);
1350 //$instance['cat_ids'] = strip_tags($new_instance['cat_ids']);
1351 return $instance;
1352 }
1353
1354 // DIsplay Widget Control Form
1355 function form($instance) {
1356 global $wpdb;
1357 $instance = wp_parse_args((array) $instance, array('title' => __('EMail', 'wp-email'), 'type' => 'most_emailed', 'mode' => 'both', 'limit' => 10, 'chars' => 200));
1358 $title = esc_attr($instance['title']);
1359 $type = esc_attr($instance['type']);
1360 $mode = esc_attr($instance['mode']);
1361 $limit = intval($instance['limit']);
1362 $chars = intval($instance['chars']);
1363 //$cat_ids = esc_attr($instance['cat_ids']);
1364 ?>
1365 <p>
1366 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'wp-email'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label>
1367 </p>
1368 <p>
1369 <label for="<?php echo $this->get_field_id('type'); ?>"><?php _e('Statistics Type:', 'wp-email'); ?>
1370 <select name="<?php echo $this->get_field_name('type'); ?>" id="<?php echo $this->get_field_id('type'); ?>" class="widefat">
1371 <option value="most_emailed"<?php selected('most_emailed', $type); ?>><?php _e('Most Emailed', 'wp-email'); ?></option>
1372 </select>
1373 </label>
1374 </p>
1375 <p>
1376 <label for="<?php echo $this->get_field_id('mode'); ?>"><?php _e('Include Views From:', 'wp-email'); ?>
1377 <select name="<?php echo $this->get_field_name('mode'); ?>" id="<?php echo $this->get_field_id('mode'); ?>" class="widefat">
1378 <option value="both"<?php selected('both', $mode); ?>><?php _e('Posts &amp; Pages', 'wp-email'); ?></option>
1379 <option value="post"<?php selected('post', $mode); ?>><?php _e('Posts Only', 'wp-email'); ?></option>
1380 <option value="page"<?php selected('page', $mode); ?>><?php _e('Pages Only', 'wp-email'); ?></option>
1381 </select>
1382 </label>
1383 </p>
1384 <p>
1385 <label for="<?php echo $this->get_field_id('limit'); ?>"><?php _e('No. Of Records To Show:', 'wp-email'); ?> <input class="widefat" id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" type="text" value="<?php echo $limit; ?>" /></label>
1386 </p>
1387 <p>
1388 <label for="<?php echo $this->get_field_id('chars'); ?>"><?php _e('Maximum Post Title Length (Characters):', 'wp-email'); ?> <input class="widefat" id="<?php echo $this->get_field_id('chars'); ?>" name="<?php echo $this->get_field_name('chars'); ?>" type="text" value="<?php echo $chars; ?>" /></label><br />
1389 <small><?php _e('<strong>0</strong> to disable.', 'wp-email'); ?></small>
1390 </p>
1391 <input type="hidden" id="<?php echo $this->get_field_id('submit'); ?>" name="<?php echo $this->get_field_name('submit'); ?>" value="1" />
1392 <?php
1393 }
1394 }
1395
1396
1397 ### Function: Init WP-EMail Widget
1398 add_action('widgets_init', 'widget_email_init');
1399 function widget_email_init() {
1400 register_widget('WP_Widget_Email');
1401 }
1402
1403
1404 ### Function: Create E-Mail Table
1405 add_action('activate_wp-email/wp-email.php', 'create_email_table');
1406 function create_email_table() {
1407 global $wpdb;
1408 email_textdomain();
1409 if(@is_file(ABSPATH.'/wp-admin/upgrade-functions.php')) {
1410 include_once(ABSPATH.'/wp-admin/upgrade-functions.php');
1411 } elseif(@is_file(ABSPATH.'/wp-admin/includes/upgrade.php')) {
1412 include_once(ABSPATH.'/wp-admin/includes/upgrade.php');
1413 } else {
1414 die('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\'');
1415 }
1416 $charset_collate = '';
1417 if($wpdb->supports_collation()) {
1418 if(!empty($wpdb->charset)) {
1419 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
1420 }
1421 if(!empty($wpdb->collate)) {
1422 $charset_collate .= " COLLATE $wpdb->collate";
1423 }
1424 }
1425 // Create E-Mail Table
1426 $create_table = "CREATE TABLE $wpdb->email (".
1427 "email_id int(10) NOT NULL auto_increment,".
1428 "email_yourname varchar(200) NOT NULL default '',".
1429 "email_youremail varchar(200) NOT NULL default '',".
1430 "email_yourremarks text NOT NULL,".
1431 "email_friendname varchar(200) NOT NULL default '',".
1432 "email_friendemail varchar(200) NOT NULL default '',".
1433 "email_postid int(10) NOT NULL default '0',".
1434 "email_posttitle text NOT NULL,".
1435 "email_timestamp varchar(20) NOT NULL default '',".
1436 "email_ip varchar(100) NOT NULL default '',".
1437 "email_host varchar(200) NOT NULL default '',".
1438 "email_status varchar(20) NOT NULL default '',".
1439 "PRIMARY KEY (email_id)) $charset_collate;";
1440 maybe_create_table($wpdb->email, $create_table);
1441 // Add In Options (12 Records)
1442 add_option('email_smtp', array('username' => '', 'password' => '', 'server' => ''), 'Your SMTP Name, Password, Server');
1443 add_option('email_contenttype', 'text/html', 'Your E-Mail Type');
1444 add_option('email_mailer', 'php', 'Your Mailer Type');
1445 add_option('email_template_subject', __('Recommended Article By %EMAIL_YOUR_NAME%: %EMAIL_POST_TITLE%', 'wp-email'), 'Template For E-Mail Subject');
1446 add_option('email_template_body', __('<p>Hi <strong>%EMAIL_FRIEND_NAME%</strong>,<br />Your friend, <strong>%EMAIL_YOUR_NAME%</strong>, has recommended this article entitled \'<strong>%EMAIL_POST_TITLE%</strong>\' to you.</p><p><strong>Here is his/her remark:</strong><br />%EMAIL_YOUR_REMARKS%</p><p><strong>%EMAIL_POST_TITLE%</strong><br />Posted By %EMAIL_POST_AUTHOR% On %EMAIL_POST_DATE% In %EMAIL_POST_CATEGORY%</p>%EMAIL_POST_CONTENT%<p>Article taken from %EMAIL_BLOG_NAME% - <a href="%EMAIL_BLOG_URL%">%EMAIL_BLOG_URL%</a><br />URL to article: <a href="%EMAIL_PERMALINK%">%EMAIL_PERMALINK%</a></p>', 'wp-email'), 'Template For E-Mail Body');
1447 add_option('email_template_bodyalt', __('Hi %EMAIL_FRIEND_NAME%,'."\n".
1448 'Your friend, %EMAIL_YOUR_NAME%, has recommended this article entitled \'%EMAIL_POST_TITLE%\' to you.'."\n\n".
1449 'Here is his/her remarks:'."\n".
1450 '%EMAIL_YOUR_REMARKS%'."\n\n".
1451 '%EMAIL_POST_TITLE%'."\n".
1452 'Posted By %EMAIL_POST_AUTHOR% On %EMAIL_POST_DATE% In %EMAIL_POST_CATEGORY%'."\n".
1453 '%EMAIL_POST_CONTENT%'."\n".
1454 'Article taken from %EMAIL_BLOG_NAME% - %EMAIL_BLOG_URL%'."\n".
1455 'URL to article: %EMAIL_PERMALINK%', 'wp-email'), 'Template For E-Mail Alternate Body');
1456 add_option('email_template_sentsuccess', '<p>'.__('Article: <strong>%EMAIL_POST_TITLE%</strong> has been sent to <strong>%EMAIL_FRIEND_NAME% (%EMAIL_FRIEND_EMAIL%)</strong></p><p>&laquo; <a href="%EMAIL_PERMALINK%">'.__('Back to %EMAIL_POST_TITLE%', 'wp-email').'</a></p>', 'wp-email'), 'Template For E-Mail That Is Sent Successfully');
1457 add_option('email_template_sentfailed', '<p>'.__('An error has occurred when trying to send this email: ', 'wp-email').'<br /><strong>&raquo;</strong> %EMAIL_ERROR_MSG%</p>', 'Template For E-Mail That Failed To Sent');
1458 add_option('email_template_error', '<p>'.__('An error has occurred: ', 'wp-email').'<br /><strong>&raquo;</strong> %EMAIL_ERROR_MSG%</p>', 'Template For E-Mail That Has An Error');
1459 add_option('email_interval', 10, 'The Number Of Minutes Before The User Can E-Mail The Next Article');
1460 add_option('email_snippet', 0, 'Enable Snippet Feature For Your E-Mail?');
1461 add_option('email_multiple', 5, 'Maximum Number Of Multiple E-Mails');
1462 // Version 2.05 Options
1463 add_option('email_imageverify', 1, 'Enable Image Verification?');
1464 // Version 2.10 Options
1465 $email_options = array('post_text' => __('Email This Post', 'wp-email'), 'page_text' => __('Email This Page', 'wp-email'), 'email_icon' => 'email_famfamfam.png', 'email_type' => 1, 'email_style' => 1, 'email_html' => '<a href="%EMAIL_URL%" rel="nofollow" title="%EMAIL_TEXT%">%EMAIL_TEXT%</a>');
1466 $email_fields = array('yourname' => 1, 'youremail' => 1, 'yourremarks' => 1, 'friendname' => 1, 'friendemail' => 1);
1467 add_option('email_options', $email_options, 'Email Options');
1468 add_option('email_fields', $email_fields, 'Email Fields');
1469 // Version 2.11 Options
1470 add_option('email_template_title', __('E-Mail \'%EMAIL_POST_TITLE%\' To A Friend', 'wp-email'), 'Template For E-Mail Page Title');
1471 add_option('email_template_subtitle', '<p style="text-align: center;">'.__('Email a copy of <strong>\'%EMAIL_POST_TITLE%\'</strong> to a friend', 'wp-email').'</p>', 'Template For E-Mail Page SubTitle');
1472 // Version 2.20 Upgrade
1473 $email_mailer = get_option('email_mailer');
1474 if($email_mailer == 'php') {
1475 update_option('email_mailer', 'mail');
1476 }
1477 // Version 2.50 Upgrade
1478 delete_option('widget_email_most_emailed');
1479 // Set 'manage_email' Capabilities To Administrator
1480 $role = get_role('administrator');
1481 if(!$role->has_cap('manage_email')) {
1482 $role->add_cap('manage_email');
1483 }
1484 }
1485 ?>
1486