Postie - Version 1.9.56

Version Description

(2021-08-06) * remove Allow HTML In Mail Body from settings as it didn't do anything * add Allow Duplicate Comments setting to deal with WordPress killing the import * fix issue where unknown email was leaving tmppost, now creates draft message * add setting to disable legacy commands

Download this release

Release Info

Developer WayneAllen
Plugin Icon 128x128 Postie
Version 1.9.56
Comparing to
See all releases

Code changes from version 1.9.53 to 1.9.56

config_form_image.php CHANGED
@@ -9,7 +9,7 @@
9
  echo PostieAdmin::boolean_select_html(__("Image Location", 'postie'), "postie-settings[images_append]", $images_append, __("Location of attachments if using 'plain' format. Before or After content. For 'html' content this will only affect attachments that are not inline.", 'postie'), array('After', 'Before'));
10
  echo PostieAdmin::boolean_select_html(__("Start Image Count At", 'postie'), "postie-settings[start_image_count_at_zero]", $start_image_count_at_zero, __('For use if using "Image Place Holder Tag" below.', 'postie'), array('Start at 0', 'Start at 1'));
11
  echo PostieAdmin::boolean_select_html(__("Use custom image field for images", 'postie'), "postie-settings[custom_image_field]", $custom_image_field, __("When set to 'Yes' no images will appear in the post (other attachment types will be processed normally). Instead the url to the attachment will be put into a custom field named 'image'. Your theme will need logic to display these attachments", 'postie'));
12
- echo PostieAdmin::boolean_select_html(__("Create Alternate Image Sizes", 'postie'), "postie-settings[image_resize]", $image_resize, __("Some hosts have issues with image resizing. Use this setting to disable resizing.", 'postie'));
13
  ?>
14
  <tr>
15
  <th scope="row"><?php _e('Image Place Holder Tag', 'postie') ?></th>
9
  echo PostieAdmin::boolean_select_html(__("Image Location", 'postie'), "postie-settings[images_append]", $images_append, __("Location of attachments if using 'plain' format. Before or After content. For 'html' content this will only affect attachments that are not inline.", 'postie'), array('After', 'Before'));
10
  echo PostieAdmin::boolean_select_html(__("Start Image Count At", 'postie'), "postie-settings[start_image_count_at_zero]", $start_image_count_at_zero, __('For use if using "Image Place Holder Tag" below.', 'postie'), array('Start at 0', 'Start at 1'));
11
  echo PostieAdmin::boolean_select_html(__("Use custom image field for images", 'postie'), "postie-settings[custom_image_field]", $custom_image_field, __("When set to 'Yes' no images will appear in the post (other attachment types will be processed normally). Instead the url to the attachment will be put into a custom field named 'image'. Your theme will need logic to display these attachments", 'postie'));
12
+ //echo PostieAdmin::boolean_select_html(__("Create Alternate Image Sizes", 'postie'), "postie-settings[image_resize]", $image_resize, __("Some hosts have issues with image resizing. Use this setting to disable resizing.", 'postie'));
13
  ?>
14
  <tr>
15
  <th scope="row"><?php _e('Image Place Holder Tag', 'postie') ?></th>
config_form_message.php CHANGED
@@ -110,14 +110,15 @@
110
  <p class='description'><?php _e('(optional) only used if no subject is supplied by the email (rare)', 'postie') ?></p>
111
  </td>
112
  </tr>
 
113
 
114
  <?php echo PostieAdmin::boolean_select_html(__("Treat Replies As", 'postie'), "postie-settings[reply_as_comment]", $reply_as_comment, "", array("comments", "new posts")); ?>
115
  <?php echo PostieAdmin::boolean_select_html(__("Strip Original Content from Replies", 'postie'), "postie-settings[strip_reply]", $strip_reply, "Only applicable if replies are treated as comments"); ?>
 
116
 
117
  <?php echo PostieAdmin::boolean_select_html(__("Forward Rejected Mail", 'postie'), "postie-settings[forward_rejected_mail]", $forward_rejected_mail); ?>
118
  <?php echo PostieAdmin::boolean_select_html(__("Allow Subject In Mail", 'postie'), "postie-settings[allow_subject_in_mail]", $allow_subject_in_mail, "Enclose the subject between '#' on the very first line. E.g. #this is my subject#"); ?>
119
  <?php echo PostieAdmin::boolean_select_html(__("Allow HTML In Mail Subject", 'postie'), "postie-settings[allow_html_in_subject]", $allow_html_in_subject); ?>
120
- <?php echo PostieAdmin::boolean_select_html(__("Allow HTML In Mail Body", 'postie'), "postie-settings[allow_html_in_body]", $allow_html_in_body); ?>
121
  <tr>
122
  <th scope="row"><?php _e('Text for Message Start', 'postie') ?> </th>
123
  <td>
110
  <p class='description'><?php _e('(optional) only used if no subject is supplied by the email (rare)', 'postie') ?></p>
111
  </td>
112
  </tr>
113
+ <?php echo PostieAdmin::boolean_select_html(__("Allow Legacy Commands", 'postie'), "postie-settings[legacy_commands]", $legacy_commands, "Process commands such as comments, status, delay, excerptstart, excerptend, date, tags."); ?>
114
 
115
  <?php echo PostieAdmin::boolean_select_html(__("Treat Replies As", 'postie'), "postie-settings[reply_as_comment]", $reply_as_comment, "", array("comments", "new posts")); ?>
116
  <?php echo PostieAdmin::boolean_select_html(__("Strip Original Content from Replies", 'postie'), "postie-settings[strip_reply]", $strip_reply, "Only applicable if replies are treated as comments"); ?>
117
+ <?php echo PostieAdmin::boolean_select_html(__("Allow Duplicate Comments", 'postie'), "postie-settings[duplicate_comments]", $duplicate_comments, 'WordPress will stop Postie from running if it decides a comment is a duplicate.'); ?>
118
 
119
  <?php echo PostieAdmin::boolean_select_html(__("Forward Rejected Mail", 'postie'), "postie-settings[forward_rejected_mail]", $forward_rejected_mail); ?>
120
  <?php echo PostieAdmin::boolean_select_html(__("Allow Subject In Mail", 'postie'), "postie-settings[allow_subject_in_mail]", $allow_subject_in_mail, "Enclose the subject between '#' on the very first line. E.g. #this is my subject#"); ?>
121
  <?php echo PostieAdmin::boolean_select_html(__("Allow HTML In Mail Subject", 'postie'), "postie-settings[allow_html_in_subject]", $allow_html_in_subject); ?>
 
122
  <tr>
123
  <th scope="row"><?php _e('Text for Message Start', 'postie') ?> </th>
124
  <td>
config_form_server.php CHANGED
@@ -1,8 +1,9 @@
1
  <div id="simpleTabs-content-1" class="simpleTabs-content">
2
 
3
- <table class='form-table'>
4
- <tr>
5
- <th scope="row"><lable for="postie-settings-input_connection"><?php _e('Connection', 'postie') ?></lable></th>
 
6
  <td>
7
  <select name='postie-settings[input_connection]' id='postie-settings-input_connection'>
8
  <option value="sockets" <?php echo (($input_connection == "socket") ? " selected='selected' " : "") ?>>Sockets</option>
@@ -173,7 +174,7 @@
173
  </tr>
174
  <?php
175
  echo PostieAdmin::boolean_select_html(__("Delete email after posting", 'postie'), 'postie-settings[delete_mail_after_processing]', $delete_mail_after_processing, __("Only set to no for testing purposes", 'postie'));
176
- //echo PostieAdmin::BuildBooleanSelect(__("Ignore mail state", 'postie'), 'postie-settings[ignore_mail_state]', $ignore_mail_state, __("Ignore whether the mails is 'read' or 'unread' If 'No' then only unread messages are processed. IMAP only", 'postie'));
177
 
178
  echo PostieAdmin::boolean_select_html(__("Enable Error Logging", 'postie'), 'postie-settings[postie_log_error]', $postie_log_error, __("Log error messages to the web server error log.", 'postie'));
179
 
@@ -185,6 +186,6 @@
185
 
186
  echo PostieAdmin::boolean_select_html(__("Enable Debug Logging", 'postie'), 'postie-settings[postie_log_debug]', $postie_log_debug, __("Log debug messages to the web server error log.", 'postie'));
187
  ?>
188
-
189
  </table>
190
- </div>
1
  <div id="simpleTabs-content-1" class="simpleTabs-content">
2
 
3
+ <table class='form-table' role='presentation'>
4
+ <tbody>
5
+ <tr>
6
+ <th scope="row"><lable for="postie-settings-input_connection"><?php _e('Connection', 'postie') ?></lable></th>
7
  <td>
8
  <select name='postie-settings[input_connection]' id='postie-settings-input_connection'>
9
  <option value="sockets" <?php echo (($input_connection == "socket") ? " selected='selected' " : "") ?>>Sockets</option>
174
  </tr>
175
  <?php
176
  echo PostieAdmin::boolean_select_html(__("Delete email after posting", 'postie'), 'postie-settings[delete_mail_after_processing]', $delete_mail_after_processing, __("Only set to no for testing purposes", 'postie'));
177
+ //echo PostieAdmin::BuildBooleanSelect(__("Ignore mail state", 'postie'), 'postie-settings[ignore_mail_state]', $ignore_mail_state, __("Ignore whether the mails is 'read' or 'unread' If 'No' then only unread messages are processed. IMAP only", 'postie'));
178
 
179
  echo PostieAdmin::boolean_select_html(__("Enable Error Logging", 'postie'), 'postie-settings[postie_log_error]', $postie_log_error, __("Log error messages to the web server error log.", 'postie'));
180
 
186
 
187
  echo PostieAdmin::boolean_select_html(__("Enable Debug Logging", 'postie'), 'postie-settings[postie_log_debug]', $postie_log_debug, __("Log debug messages to the web server error log.", 'postie'));
188
  ?>
189
+ </tbody>
190
  </table>
191
+ </div>
docs/Changes.txt CHANGED
@@ -35,6 +35,20 @@ All script, style and body tags are stripped from html emails.
35
  Attachments are now processed in the order they were attached.
36
 
37
  == CHANGELOG ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  = 1.9.53 (2020-06-05)
39
  * Add postie_subject filter
40
 
35
  Attachments are now processed in the order they were attached.
36
 
37
  == CHANGELOG ==
38
+ = 1.9.56 (2021-08-06)
39
+ * remove Allow HTML In Mail Body from settings as it didn't do anything
40
+ * add Allow Duplicate Comments setting to deal with WordPress killing the import
41
+ * fix issue where unknown email was leaving tmppost, now creates draft message
42
+ * add setting to disable legacy commands
43
+
44
+ = 1.9.55 (2021-03-09)
45
+ * Add post id to action postie_comment_after
46
+ * remove Create Alternate Image Sizes from settings as it didn't do anything
47
+ * Add compatibility for WordPress 5.7
48
+
49
+ = 1.9.54 (2020-10-18)
50
+ * Add compatibility for WordPress 5.5
51
+
52
  = 1.9.53 (2020-06-05)
53
  * Add postie_subject filter
54
 
docs/Postie.txt CHANGED
@@ -6,8 +6,8 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email, post-by-email
7
  Requires PHP: 5.3
8
  Requires at least: 4.0
9
- Tested up to: 5.4
10
- Stable tag: 1.9.53
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
6
  Tags: e-mail, email, post-by-email
7
  Requires PHP: 5.3
8
  Requires at least: 4.0
9
+ Tested up to: 5.8
10
+ Stable tag: 1.9.56
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
docs/TODO.txt CHANGED
@@ -9,14 +9,13 @@ Configurable message for "post confirmation" - variable substitution, by post st
9
  Bugs
10
  #img# caption feature not working
11
  Comment not being created when subject contains category command []. I.e. listserv subject lines
12
- Comment not being created when subject contains fomat or type. I.e. re: image//Image subject
13
 
14
  Other
15
  Google Sign-In https://developers.google.com/identity/sign-in/web/sign-in
16
  detect links to embeddable content and remove anchor tag <a href="https://youtube.com?...">https://youtube.com</a>
17
  Add default comment status (like post status) wp_set_comment_status
18
  Test server port combination by opening a socket connection to see if any service responds. (via ajax call)
19
- date: tag is being detected in body when not wanted
20
 
21
  Change all "filters" to "addons" and allow them to be disabled (i.e. turn off processing for "date:"
22
  provide a location for custom icons. update docs about location.
9
  Bugs
10
  #img# caption feature not working
11
  Comment not being created when subject contains category command []. I.e. listserv subject lines
12
+ Comment not being created when subject contains format or type. I.e. re: image//Image subject
13
 
14
  Other
15
  Google Sign-In https://developers.google.com/identity/sign-in/web/sign-in
16
  detect links to embeddable content and remove anchor tag <a href="https://youtube.com?...">https://youtube.com</a>
17
  Add default comment status (like post status) wp_set_comment_status
18
  Test server port combination by opening a socket connection to see if any service responds. (via ajax call)
 
19
 
20
  Change all "filters" to "addons" and allow them to be disabled (i.e. turn off processing for "date:"
21
  provide a location for custom icons. update docs about location.
postie-config.class.php CHANGED
@@ -239,7 +239,9 @@ class PostieConfig {
239
  'ignore_email_date' => false,
240
  'use_time_offset' => false,
241
  'postie_log_error_notify' => '(All Admins)',
242
- 'image_resize' => true
 
 
243
  );
244
  }
245
 
239
  'ignore_email_date' => false,
240
  'use_time_offset' => false,
241
  'postie_log_error_notify' => '(All Admins)',
242
+ 'image_resize' => true,
243
+ 'duplicate_comments' => true,
244
+ 'legacy_commands' => true
245
  );
246
  }
247
 
postie-filters.php CHANGED
@@ -10,11 +10,11 @@ function filter_AttachmentTemplates($content, $mimeDecodedEmail, $post_id, $conf
10
 
11
  DebugEcho("filter_AttachmentTemplates: custom_image_field: " . $config['custom_image_field']);
12
  DebugEcho("filter_AttachmentTemplates: auto_gallery: " . $config['auto_gallery']);
13
- DebugEcho("filter_AttachmentTemplates: [gallery]: " . $isgallery);
14
 
15
  $addimages = !($config['custom_image_field'] || $config['auto_gallery'] || $isgallery);
16
 
17
- DebugEcho("filter_AttachmentTemplates: addimages: " . $addimages);
18
 
19
  $featuredimageid = -1;
20
 
@@ -100,7 +100,6 @@ function filter_AttachmentTemplates($content, $mimeDecodedEmail, $post_id, $conf
100
  DebugEcho("filter_AttachmentTemplates: no attachments generated");
101
  }
102
 
103
-
104
  //strip featured image from html
105
  if ($featuredimageid > 0 && $config['prefer_text_type'] == 'html' && !$config['include_featured_image']) {
106
  DebugEcho("filter_AttachmentTemplates: remove featured image from post");
10
 
11
  DebugEcho("filter_AttachmentTemplates: custom_image_field: " . $config['custom_image_field']);
12
  DebugEcho("filter_AttachmentTemplates: auto_gallery: " . $config['auto_gallery']);
13
+ DebugEcho("filter_AttachmentTemplates: [gallery]: " . ($isgallery ? 'yes' : 'no'));
14
 
15
  $addimages = !($config['custom_image_field'] || $config['auto_gallery'] || $isgallery);
16
 
17
+ DebugEcho("filter_AttachmentTemplates: addimages: " . ($addimages ? 'yes' : 'no'));
18
 
19
  $featuredimageid = -1;
20
 
100
  DebugEcho("filter_AttachmentTemplates: no attachments generated");
101
  }
102
 
 
103
  //strip featured image from html
104
  if ($featuredimageid > 0 && $config['prefer_text_type'] == 'html' && !$config['include_featured_image']) {
105
  DebugEcho("filter_AttachmentTemplates: remove featured image from post");
postie-message.php CHANGED
@@ -117,10 +117,10 @@ class PostieMessage {
117
  if (empty($this->poster)) {
118
  if ($this->config['forward_rejected_mail']) {
119
  $this->email_reject();
120
- EchoError("A copy of the message has been forwarded to the administrator.");
121
  }
122
- EchoError('process: Ignoring email - not authorized.');
123
- return;
124
  }
125
 
126
  DebugEcho("process: filter: pre postie_post_pre");
@@ -474,7 +474,7 @@ class PostieMessage {
474
  $message_date = current_time('mysql');
475
  }
476
 
477
- $post_date = tag_Date($this->content, $message_date);
478
  if ($fulldebug) {
479
  DebugEcho("post tag_Date: $this->content");
480
  }
@@ -502,7 +502,7 @@ class PostieMessage {
502
  DebugEcho("post tag_Tags: $this->content");
503
  }
504
 
505
- $comment_status = tag_AllowCommentsOnPost($this->content);
506
  if ($fulldebug) {
507
  DebugEcho("post tag_AllowCommentsOnPost: $this->content");
508
  }
@@ -683,7 +683,7 @@ class PostieMessage {
683
  $post_ID = wp_new_comment($comment);
684
 
685
  DebugEcho("doing postie_comment_after");
686
- do_action('postie_comment_after', $comment);
687
  }
688
 
689
  if ($post_ID) {
117
  if (empty($this->poster)) {
118
  if ($this->config['forward_rejected_mail']) {
119
  $this->email_reject();
120
+ DebugEcho("A copy of the message has been forwarded to the administrator.");
121
  }
122
+ DebugEcho('process: not authorized, setting to draft.');
123
+ $this->config['post_status'] = 'draft';
124
  }
125
 
126
  DebugEcho("process: filter: pre postie_post_pre");
474
  $message_date = current_time('mysql');
475
  }
476
 
477
+ $post_date = tag_Date($this->content, $message_date, $this->config);
478
  if ($fulldebug) {
479
  DebugEcho("post tag_Date: $this->content");
480
  }
502
  DebugEcho("post tag_Tags: $this->content");
503
  }
504
 
505
+ $comment_status = tag_AllowCommentsOnPost($this->content, $this->config);
506
  if ($fulldebug) {
507
  DebugEcho("post tag_AllowCommentsOnPost: $this->content");
508
  }
683
  $post_ID = wp_new_comment($comment);
684
 
685
  DebugEcho("doing postie_comment_after");
686
+ do_action('postie_comment_after', $comment, $post_ID);
687
  }
688
 
689
  if ($post_ID) {
postie-tags.php CHANGED
@@ -94,23 +94,28 @@ function postie_lookup_category_id($trial_category, $category_match = true) {
94
  * Checks for the comments tag
95
  * @return boolean
96
  */
97
- function tag_AllowCommentsOnPost(&$content) {
98
  $comments_allowed = get_option('default_comment_status'); // 'open' or 'closed'
99
 
100
- foreach (postie_content_lines($content) as $line) {
101
- $matches = array();
102
- if (preg_match("/^\s*comments:\s*([0|1|2])/imu", $line, $matches)) {
103
- $content = preg_replace("/comments:$matches[1]/i", "", $content);
104
- if ($matches[1] == '1') {
105
- $comments_allowed = 'open';
106
- } else if ($matches[1] == '2') {
107
- $comments_allowed = 'registered_only';
108
- } else {
109
- $comments_allowed = 'closed';
 
 
 
110
  }
111
- break;
112
  }
 
 
113
  }
 
114
  return $comments_allowed;
115
  }
116
 
@@ -118,21 +123,26 @@ function tag_Status(&$content, $config) {
118
 
119
  $poststatus = $config['post_status'];
120
 
121
- foreach (postie_content_lines($content) as $lines) {
122
- $matches = array();
123
- if (preg_match("/^\s*status:\s*(draft|publish|pending|private|future)/imu", $lines, $matches)) {
124
- DebugEcho("tag_Status: found status $matches[1]");
125
- DebugDump($matches);
126
- $content = preg_replace("/$matches[0]/i", "", $content);
127
- $poststatus = $matches[1];
128
- break;
 
 
129
  }
 
 
130
  }
 
131
  if ($config['force_user_login']) {
132
  if (stristr('publish|future', $poststatus)) {
133
  if (!current_user_can('publish_posts')) {
134
  DebugEcho("tag_Status: user doesn't have publish_posts capability");
135
- $poststatus = 'pending';
136
  }
137
  }
138
  }
@@ -146,47 +156,51 @@ function tag_Delay(&$content, $message_date, $config) {
146
  DebugEcho("tag_Delay: start");
147
  $delay = 0;
148
 
149
- foreach (postie_content_lines($content) as $line) {
150
- $matches = array();
151
- if (preg_match("/^\s*delay:\s*(-?[0-9dhm]+)/imu", $line, $matches) && trim($matches[1])) {
152
- DebugEcho("tag_Delay: found delay: " . $matches[1]);
153
- $days = 0;
154
- $hours = 0;
155
- $minutes = 0;
156
- $dayMatches = array();
157
- if (preg_match("/(-?[0-9]+)d/iu", $matches[1], $dayMatches)) {
158
- $days = $dayMatches[1];
159
- }
160
- $hourMatches = array();
161
- if (preg_match("/(-?[0-9]+)h/iu", $matches[1], $hourMatches)) {
162
- $hours = $hourMatches[1];
163
- }
164
- $minuteMatches = array();
165
- if (preg_match("/(-?[0-9]+)m/iu", $matches[1], $minuteMatches)) {
166
- $minutes = $minuteMatches[1];
167
- }
168
- $delay = (($days * 24 + $hours) * 60 + $minutes) * 60;
169
- $interval = 'P';
170
- if (abs($days) > 0) {
171
- $interval .= abs($days) . 'D';
172
- }
173
- if (abs($hours) > 0) {
174
- $interval .= 'T' . abs($hours) . 'H';
175
- }
176
- if (abs($minutes) > 0) {
177
  if (abs($hours) > 0) {
178
- $interval .= abs($minutes) . 'M';
179
- } else {
180
- $interval .= 'T' . abs($minutes) . 'M';
 
 
 
 
 
181
  }
182
- }
183
 
184
- DebugEcho("tag_Delay: calculated delay: $delay");
185
- DebugEcho("tag_Delay: interval: $interval");
186
- DebugEcho("tag_Delay: replacing: $matches[0]");
187
- $content = preg_replace("/$matches[0]/i", "", $content);
188
- break;
 
189
  }
 
 
190
  }
191
 
192
  $tzs = get_option('timezone_string');
@@ -242,16 +256,21 @@ function tag_Delay(&$content, $message_date, $config) {
242
 
243
  function tag_Excerpt(&$content, $config) {
244
  $post_excerpt = '';
245
- $matches = array();
246
- if (preg_match('/\s*:excerptstart ?(.*):excerptend/imus', $content, $matches)) {
247
- $content = str_replace($matches[0], "", $content);
248
- $post_excerpt = $matches[1];
249
- DebugEcho("excerpt found: $post_excerpt");
250
- if ($config['filternewlines']) {
251
- DebugEcho("filtering newlines from excerpt");
252
- $post_excerpt = filter_Newlines($post_excerpt, $config);
 
 
253
  }
 
 
254
  }
 
255
  return $post_excerpt;
256
  }
257
 
@@ -368,7 +387,7 @@ function tag_PostType(&$subject, &$config) {
368
 
369
  $custom_post_type_delim = '//';
370
  $trial = '';
371
- if (strpos($subject, strval($custom_post_type_delim)) !== FALSE) {
372
  // Captures the custom post type in the subject before $custom_post_type_delim
373
  $separated_subject = explode($custom_post_type_delim, $subject);
374
  $trial = trim(strtolower($separated_subject[0]));
@@ -390,35 +409,39 @@ function tag_PostType(&$subject, &$config) {
390
  return array('post_type' => $post_type, 'post_format' => $post_format);
391
  }
392
 
393
- function tag_Date(&$content, $message_date) {
394
-
395
  DebugEcho("tag_Date: start");
396
 
397
- foreach (postie_content_lines($content) as $e) {
398
- $matches = array();
399
- if (1 === preg_match("/^\s*date:(.*)$/imu", $e, $matches)) {
400
- $possibledate = trim($matches[1]);
401
- DebugEcho("tag_Date: found date tag $matches[1]");
402
- $newdate = strtotime($possibledate);
403
- if (false !== $newdate) {
404
- $t = date('H:i:s', $newdate);
405
- DebugEcho("tag_Date: original time: $t");
406
-
407
- $format = 'Y-m-d';
408
- if ($t != '00:00:00') {
409
- $format .= ' H:i:s';
 
 
 
 
 
 
 
410
  }
411
- $message_date = date($format, $newdate);
412
- $content = str_replace($matches[0], '', $content);
413
- break;
414
  } else {
415
- DebugEcho("tag_Date: failed to parse '$possibledate' ($newdate)");
416
  }
417
- } else {
418
- //DebugEcho("tag_Date: nothing found");
419
  }
 
 
420
  }
421
-
422
  DebugEcho("tag_Date: end: $message_date");
423
 
424
  return $message_date;
@@ -428,16 +451,20 @@ function tag_Tags(&$content, $config) {
428
  $defaultTags = $config['default_post_tags'];
429
  DebugEcho("tag_Tags: starting");
430
  $post_tags = array();
431
- foreach (postie_content_lines($content, $config) as $line) {
432
- //DebugEcho("tag_Tags: line: $line");
433
- $matches = array();
 
434
  if (preg_match('/^\s*tags:\s*(.*)/imu', $line, $matches)) {
435
- if (!empty($matches[1])) {
436
- DebugEcho("tag_Tags: Found tags: $matches[1]");
437
- $content = str_replace($matches[0], "", $content);
438
- $post_tags = array_merge($post_tags, array_filter(preg_split("/,\s*/", trim($matches[1]))));
 
439
  }
440
  }
 
 
441
  }
442
 
443
  if (count($post_tags) == 0 && is_array($defaultTags)) {
94
  * Checks for the comments tag
95
  * @return boolean
96
  */
97
+ function tag_AllowCommentsOnPost(&$content, $config) {
98
  $comments_allowed = get_option('default_comment_status'); // 'open' or 'closed'
99
 
100
+ if (true == $config['legacy_commands']) {
101
+ foreach (postie_content_lines($content) as $line) {
102
+ $matches = array();
103
+ if (preg_match("/^\s*comments:\s*([0|1|2])/imu", $line, $matches)) {
104
+ $content = preg_replace("/comments:$matches[1]/i", "", $content);
105
+ if ($matches[1] == '1') {
106
+ $comments_allowed = 'open';
107
+ } else if ($matches[1] == '2') {
108
+ $comments_allowed = 'registered_only';
109
+ } else {
110
+ $comments_allowed = 'closed';
111
+ }
112
+ break;
113
  }
 
114
  }
115
+ } else {
116
+ DebugEcho("tag_AllowCommentsOnPost: disabled - ignore legacy commands");
117
  }
118
+
119
  return $comments_allowed;
120
  }
121
 
123
 
124
  $poststatus = $config['post_status'];
125
 
126
+ if (true == $config['legacy_commands']) {
127
+ foreach (postie_content_lines($content) as $lines) {
128
+ $matches = array();
129
+ if (preg_match("/^\s*status:\s*(draft|publish|pending|private|future)/imu", $lines, $matches)) {
130
+ DebugEcho("tag_Status: found status $matches[1]");
131
+ DebugDump($matches);
132
+ $content = preg_replace("/$matches[0]/i", "", $content);
133
+ $poststatus = $matches[1];
134
+ break;
135
+ }
136
  }
137
+ } else {
138
+ DebugEcho("tag_Status: disabled - ignore legacy commands");
139
  }
140
+
141
  if ($config['force_user_login']) {
142
  if (stristr('publish|future', $poststatus)) {
143
  if (!current_user_can('publish_posts')) {
144
  DebugEcho("tag_Status: user doesn't have publish_posts capability");
145
+ $poststatus = 'draft';
146
  }
147
  }
148
  }
156
  DebugEcho("tag_Delay: start");
157
  $delay = 0;
158
 
159
+ if (true == $config['legacy_commands']) {
160
+ foreach (postie_content_lines($content) as $line) {
161
+ $matches = array();
162
+ if (preg_match("/^\s*delay:\s*(-?[0-9dhm]+)/imu", $line, $matches) && trim($matches[1])) {
163
+ DebugEcho("tag_Delay: found delay: " . $matches[1]);
164
+ $days = 0;
165
+ $hours = 0;
166
+ $minutes = 0;
167
+ $dayMatches = array();
168
+ if (preg_match("/(-?[0-9]+)d/iu", $matches[1], $dayMatches)) {
169
+ $days = $dayMatches[1];
170
+ }
171
+ $hourMatches = array();
172
+ if (preg_match("/(-?[0-9]+)h/iu", $matches[1], $hourMatches)) {
173
+ $hours = $hourMatches[1];
174
+ }
175
+ $minuteMatches = array();
176
+ if (preg_match("/(-?[0-9]+)m/iu", $matches[1], $minuteMatches)) {
177
+ $minutes = $minuteMatches[1];
178
+ }
179
+ $delay = (($days * 24 + $hours) * 60 + $minutes) * 60;
180
+ $interval = 'P';
181
+ if (abs($days) > 0) {
182
+ $interval .= abs($days) . 'D';
183
+ }
 
 
 
184
  if (abs($hours) > 0) {
185
+ $interval .= 'T' . abs($hours) . 'H';
186
+ }
187
+ if (abs($minutes) > 0) {
188
+ if (abs($hours) > 0) {
189
+ $interval .= abs($minutes) . 'M';
190
+ } else {
191
+ $interval .= 'T' . abs($minutes) . 'M';
192
+ }
193
  }
 
194
 
195
+ DebugEcho("tag_Delay: calculated delay: $delay");
196
+ DebugEcho("tag_Delay: interval: $interval");
197
+ DebugEcho("tag_Delay: replacing: $matches[0]");
198
+ $content = preg_replace("/$matches[0]/i", "", $content);
199
+ break;
200
+ }
201
  }
202
+ } else {
203
+ DebugEcho("tag_Delay: disabled - ignore legacy commands");
204
  }
205
 
206
  $tzs = get_option('timezone_string');
256
 
257
  function tag_Excerpt(&$content, $config) {
258
  $post_excerpt = '';
259
+ if (true == $config['legacy_commands']) {
260
+ $matches = array();
261
+ if (preg_match('/\s*:excerptstart ?(.*):excerptend/imus', $content, $matches)) {
262
+ $content = str_replace($matches[0], "", $content);
263
+ $post_excerpt = $matches[1];
264
+ DebugEcho("tag_Excerpt: excerpt found: $post_excerpt");
265
+ if ($config['filternewlines']) {
266
+ DebugEcho("tag_Excerpt: filtering newlines from excerpt");
267
+ $post_excerpt = filter_Newlines($post_excerpt, $config);
268
+ }
269
  }
270
+ } else {
271
+ DebugEcho("tag_Excerpt: disabled - ignore legacy commands");
272
  }
273
+
274
  return $post_excerpt;
275
  }
276
 
387
 
388
  $custom_post_type_delim = '//';
389
  $trial = '';
390
+ if (strpos($subject, strval($custom_post_type_delim)) !== false) {
391
  // Captures the custom post type in the subject before $custom_post_type_delim
392
  $separated_subject = explode($custom_post_type_delim, $subject);
393
  $trial = trim(strtolower($separated_subject[0]));
409
  return array('post_type' => $post_type, 'post_format' => $post_format);
410
  }
411
 
412
+ function tag_Date(&$content, $message_date, $config) {
413
+
414
  DebugEcho("tag_Date: start");
415
 
416
+ if (true == $config['legacy_commands']) {
417
+ foreach (postie_content_lines($content) as $e) {
418
+ $matches = array();
419
+ if (1 === preg_match("/^\s*date:(.*)$/imu", $e, $matches)) {
420
+ $possibledate = trim($matches[1]);
421
+ DebugEcho("tag_Date: found date tag $matches[1]");
422
+ $newdate = strtotime($possibledate);
423
+ if (false !== $newdate) {
424
+ $t = date('H:i:s', $newdate);
425
+ DebugEcho("tag_Date: original time: $t");
426
+
427
+ $format = 'Y-m-d';
428
+ if ($t != '00:00:00') {
429
+ $format .= ' H:i:s';
430
+ }
431
+ $message_date = date($format, $newdate);
432
+ $content = str_replace($matches[0], '', $content);
433
+ break;
434
+ } else {
435
+ DebugEcho("tag_Date: failed to parse '$possibledate' ($newdate)");
436
  }
 
 
 
437
  } else {
438
+ //DebugEcho("tag_Date: nothing found");
439
  }
 
 
440
  }
441
+ } else {
442
+ DebugEcho("tag_Date: disabled - ignore legacy commands");
443
  }
444
+
445
  DebugEcho("tag_Date: end: $message_date");
446
 
447
  return $message_date;
451
  $defaultTags = $config['default_post_tags'];
452
  DebugEcho("tag_Tags: starting");
453
  $post_tags = array();
454
+ if (true == $config['legacy_commands']) {
455
+ foreach (postie_content_lines($content, $config) as $line) {
456
+ //DebugEcho("tag_Tags: line: $line");
457
+ $matches = array();
458
  if (preg_match('/^\s*tags:\s*(.*)/imu', $line, $matches)) {
459
+ if (!empty($matches[1])) {
460
+ DebugEcho("tag_Tags: Found tags: $matches[1]");
461
+ $content = str_replace($matches[0], "", $content);
462
+ $post_tags = array_merge($post_tags, array_filter(preg_split("/,\s*/", trim($matches[1]))));
463
+ }
464
  }
465
  }
466
+ } else {
467
+ DebugEcho("tag_Tags: disabled - ignore legacy commands");
468
  }
469
 
470
  if (count($post_tags) == 0 && is_array($defaultTags)) {
postie.class.php CHANGED
@@ -54,6 +54,10 @@ class Postie {
54
  if (true == $config['postie_log_debug'] || (defined('POSTIE_DEBUG') && true == POSTIE_DEBUG)) {
55
  add_action('postie_log_debug', array($this, 'log_debug'));
56
  }
 
 
 
 
57
  add_filter('intermediate_image_sizes_advanced', array($this, 'intermediate_image_sizes_advanced'));
58
 
59
  DebugEcho("doing postie_session_start");
@@ -80,10 +84,6 @@ class Postie {
80
  echo "Postie: filter 'postie_post' is depricated in favor of 'postie_post_before'";
81
  }
82
 
83
- if (!array_key_exists('maxemails', $config)) {
84
- $config['maxemails'] = 0;
85
- }
86
-
87
  //don't output the password
88
  DebugEcho("postie configuration");
89
  $tmp_config = $config;
@@ -92,7 +92,7 @@ class Postie {
92
 
93
  $conninfo = $this->connection_info($config);
94
 
95
- $this->fetch_mail($conninfo['mail_server'], $conninfo['mail_port'], $conninfo['mail_user'], $conninfo['mail_password'], $conninfo['mail_protocol'], $conninfo['email_delete_after_processing'], $conninfo['email_max'], $config);
96
 
97
  DebugEcho("doing postie_session_end");
98
  do_action('postie_session_end');
@@ -171,7 +171,8 @@ class Postie {
171
  /**
172
  * This function handles determining the protocol and fetching the mail
173
  */
174
- function fetch_mail($server, $port, $email, $password, $protocol, $deleteMessages, $maxemails, $config) {
 
175
  $emails = array();
176
  if (!$server || !$port || !$email) {
177
  EchoError("Missing Configuration For Mail Server");
@@ -180,6 +181,8 @@ class Postie {
180
 
181
  DebugEcho("fetch_mail: Connecting to $server:$port ($protocol)");
182
 
 
 
183
  try {
184
  $mailbox = $this->get_mailbox($server, $port, $email, $password, $protocol, $config);
185
  $messages = $mailbox->listMessages($maxemails);
@@ -190,6 +193,8 @@ class Postie {
190
 
191
  $message_number = 0;
192
  foreach ($messages as $message) {
 
 
193
  $message_number++;
194
  DebugEcho("fetch_mail: $message_number: ------------------------------------");
195
  DebugEcho("fetch_mail: fetch {$message['uid']}");
54
  if (true == $config['postie_log_debug'] || (defined('POSTIE_DEBUG') && true == POSTIE_DEBUG)) {
55
  add_action('postie_log_debug', array($this, 'log_debug'));
56
  }
57
+ if (true == $config['duplicate_comments']) {
58
+ DebugEcho("enabling duplicate comments");
59
+ add_filter('duplicate_comment_id', '__return_false');
60
+ }
61
  add_filter('intermediate_image_sizes_advanced', array($this, 'intermediate_image_sizes_advanced'));
62
 
63
  DebugEcho("doing postie_session_start");
84
  echo "Postie: filter 'postie_post' is depricated in favor of 'postie_post_before'";
85
  }
86
 
 
 
 
 
87
  //don't output the password
88
  DebugEcho("postie configuration");
89
  $tmp_config = $config;
92
 
93
  $conninfo = $this->connection_info($config);
94
 
95
+ $this->fetch_mail($conninfo['mail_server'], $conninfo['mail_port'], $conninfo['mail_user'], $conninfo['mail_password'], $conninfo['mail_protocol'], $conninfo['email_delete_after_processing'], $conninfo['email_max']);
96
 
97
  DebugEcho("doing postie_session_end");
98
  do_action('postie_session_end');
171
  /**
172
  * This function handles determining the protocol and fetching the mail
173
  */
174
+ function fetch_mail($server, $port, $email, $password, $protocol, $deleteMessages, $maxemails) {
175
+
176
  $emails = array();
177
  if (!$server || !$port || !$email) {
178
  EchoError("Missing Configuration For Mail Server");
181
 
182
  DebugEcho("fetch_mail: Connecting to $server:$port ($protocol)");
183
 
184
+ $config = postie_config_read();
185
+
186
  try {
187
  $mailbox = $this->get_mailbox($server, $port, $email, $password, $protocol, $config);
188
  $messages = $mailbox->listMessages($maxemails);
193
 
194
  $message_number = 0;
195
  foreach ($messages as $message) {
196
+ $config = postie_config_read(); //refresh config in case PostieMessage altered it
197
+
198
  $message_number++;
199
  DebugEcho("fetch_mail: $message_number: ------------------------------------");
200
  DebugEcho("fetch_mail: fetch {$message['uid']}");
postie.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Create posts via email. Significantly upgrades the Post by Email features of WordPress.
7
- Version: 1.9.53
8
  Author: Wayne Allen
9
  Author URI: http://PostiePlugin.com/
10
  License: GPL3
@@ -28,7 +28,7 @@
28
  */
29
 
30
  /*
31
- $Id: postie.php 2319062 2020-06-05 16:00:33Z WayneAllen $
32
  */
33
 
34
  if (!defined('WPINC')) {
@@ -61,7 +61,12 @@ if (!class_exists('PostieInit')) {
61
 
62
 
63
  //WordPress filters
64
- add_filter('whitelist_options', array($this, 'whitelist_options_filter'));
 
 
 
 
 
65
  add_filter('cron_schedules', array($this, 'cron_schedules_filter'));
66
  add_filter('query_vars', array($this, 'query_vars_filter'));
67
  add_filter("plugin_action_links_" . plugin_basename(__FILE__), array($this, 'plugin_action_links_filter'));
@@ -252,7 +257,13 @@ if (!class_exists('PostieInit')) {
252
 
253
  function whitelist_options_filter($options) {
254
  $added = array('postie-settings' => array('postie-settings'));
255
- $options = add_option_whitelist($added, $options);
 
 
 
 
 
 
256
  return $options;
257
  }
258
 
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Create posts via email. Significantly upgrades the Post by Email features of WordPress.
7
+ Version: 1.9.56
8
  Author: Wayne Allen
9
  Author URI: http://PostiePlugin.com/
10
  License: GPL3
28
  */
29
 
30
  /*
31
+ $Id: postie.php 2580545 2021-08-09 20:45:46Z WayneAllen $
32
  */
33
 
34
  if (!defined('WPINC')) {
61
 
62
 
63
  //WordPress filters
64
+ if (version_compare(get_bloginfo('version'), '5.5', '>=')) {
65
+ add_filter('allowed_options', array($this, 'whitelist_options_filter'));
66
+ } else {
67
+
68
+ add_filter('whitelist_options', array($this, 'whitelist_options_filter'));
69
+ }
70
  add_filter('cron_schedules', array($this, 'cron_schedules_filter'));
71
  add_filter('query_vars', array($this, 'query_vars_filter'));
72
  add_filter("plugin_action_links_" . plugin_basename(__FILE__), array($this, 'plugin_action_links_filter'));
257
 
258
  function whitelist_options_filter($options) {
259
  $added = array('postie-settings' => array('postie-settings'));
260
+
261
+ if (function_exists('add_allowed_options')) {
262
+ $options = add_allowed_options($added, $options);
263
+ } else {
264
+ $options = add_option_whitelist($added, $options); // deprecated in WP 5.5
265
+ }
266
+
267
  return $options;
268
  }
269
 
readme.txt CHANGED
@@ -6,8 +6,8 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email, post-by-email
7
  Requires PHP: 5.3
8
  Requires at least: 4.0
9
- Tested up to: 5.6
10
- Stable tag: 1.9.53
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
@@ -107,6 +107,20 @@ All script, style and body tags are stripped from html emails.
107
  Attachments are now processed in the order they were attached.
108
 
109
  == CHANGELOG ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  = 1.9.53 (2020-06-05)
111
  * Add postie_subject filter
112
 
6
  Tags: e-mail, email, post-by-email
7
  Requires PHP: 5.3
8
  Requires at least: 4.0
9
+ Tested up to: 5.8
10
+ Stable tag: 1.9.56
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
107
  Attachments are now processed in the order they were attached.
108
 
109
  == CHANGELOG ==
110
+ = 1.9.56 (2021-08-06)
111
+ * remove Allow HTML In Mail Body from settings as it didn't do anything
112
+ * add Allow Duplicate Comments setting to deal with WordPress killing the import
113
+ * fix issue where unknown email was leaving tmppost, now creates draft message
114
+ * add setting to disable legacy commands
115
+
116
+ = 1.9.55 (2021-03-09)
117
+ * Add post id to action postie_comment_after
118
+ * remove Create Alternate Image Sizes from settings as it didn't do anything
119
+ * Add compatibility for WordPress 5.7
120
+
121
+ = 1.9.54 (2020-10-18)
122
+ * Add compatibility for WordPress 5.5
123
+
124
  = 1.9.53 (2020-06-05)
125
  * Add postie_subject filter
126