Postie - Version 1.5.16

Version Description

(2013.09.15) = * Fixed date detection bug in forwarded messages. * Possible fix for blank screen issue (flush buffers rather than check for sent headers). * Fixed images showing up in excerpts when not specified. * Fixed bug where time offset was applied twice. * Fixed bug where excerpts where not getting the newline settings applied. * Fixed bug where the attachment template was not getting set on new installs. * Fixed bug where mp3 files were causing failures when getting meta-data. * Verified compatibility with WP 36. and 3.6.1

Download this release

Release Info

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

Code changes from version 1.5.15 to 1.5.16

Files changed (10) hide show
  1. docs/Changes.txt +9 -0
  2. docs/Postie.txt +2 -2
  3. docs/TODO.txt +13 -1
  4. docs/Usage.txt +3 -3
  5. get_mail.php +1 -0
  6. postie-functions.php +66 -64
  7. postie.php +4 -4
  8. postieIMAP.php +1 -1
  9. readme.html +6 -6
  10. readme.txt +14 -6
docs/Changes.txt CHANGED
@@ -22,6 +22,15 @@ All script, style and body tags are stripped from html emails.
22
  Attachments are now processed in the order they were attached.
23
 
24
  == CHANGELOG ==
 
 
 
 
 
 
 
 
 
25
 
26
  = 1.5.15 (2013.07.01) =
27
  * Added message warning that filter 'postie_post' has been deprecated.
22
  Attachments are now processed in the order they were attached.
23
 
24
  == CHANGELOG ==
25
+ = 1.5.16 (2013.09.15) =
26
+ * Fixed date detection bug in forwarded messages.
27
+ * Possible fix for blank screen issue (flush buffers rather than check for sent headers).
28
+ * Fixed images showing up in excerpts when not specified.
29
+ * Fixed bug where time offset was applied twice.
30
+ * Fixed bug where excerpts where not getting the newline settings applied.
31
+ * Fixed bug where the attachment template was not getting set on new installs.
32
+ * Fixed bug where mp3 files were causing failures when getting meta-data.
33
+ * Verified compatibility with WP 36. and 3.6.1
34
 
35
  = 1.5.15 (2013.07.01) =
36
  * Added message warning that filter 'postie_post' has been deprecated.
docs/Postie.txt CHANGED
@@ -5,8 +5,8 @@ Author URI: http://allens-home.com/
5
  Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
- Tested up to: 3.5.2
9
- Stable tag: 1.5.15
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
5
  Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
+ Tested up to: 3.6.1
9
+ Stable tag: 1.5.16
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
docs/TODO.txt CHANGED
@@ -7,6 +7,12 @@ Update tag_* and filter_* to handle HTML (per tag_Tags)
7
  dynamically determine video size (height/width) - https://code.google.com/p/phpvideotoolkit/
8
  gallery logic does not handle both images and non-images
9
  plugin conflict - Image Rotation Fixer
 
 
 
 
 
 
10
 
11
  =========
12
  Postie 2.0
@@ -44,4 +50,10 @@ change all Postie command to use a more consistent and easy to parse syntax
44
  tag w/o data
45
  @more (new)
46
  @comments-open, @comments-closed, @comments-registeredonly
47
- @status-draft, @status-publish, @status-pending, @status-private
 
 
 
 
 
 
7
  dynamically determine video size (height/width) - https://code.google.com/p/phpvideotoolkit/
8
  gallery logic does not handle both images and non-images
9
  plugin conflict - Image Rotation Fixer
10
+ send email notice when attachments are rejected.
11
+
12
+ =========
13
+ AddOn Ideas
14
+ (done) Google Alerts - turn each alert into a post
15
+ HTML cleaning - use http://htmlpurifier.org/ to convert Word Html and other bad html into standard html
16
 
17
  =========
18
  Postie 2.0
50
  tag w/o data
51
  @more (new)
52
  @comments-open, @comments-closed, @comments-registeredonly
53
+ @status-draft, @status-publish, @status-pending, @status-private
54
+
55
+ alternate syntax
56
+ {{@cmd data }}
57
+ {{@status draft}}
58
+ {{@category one, two, three}}
59
+ {{@custom name="field name" data="field value" }}
docs/Usage.txt CHANGED
@@ -73,10 +73,8 @@
73
  * You can also set a default tag to be applied if no tags are included.
74
 
75
  = Image Handling =
76
- Note you can only use this feature if your "Preferred Text Type" is set to "plain"
77
-
78
  * Allows you to attach images to your email and automatically post
79
- them to your blog
80
  * You can publish images in the text of your message by using #img1#
81
  #img2# - each one will be replaced with the HTML for the image
82
  you attached
@@ -91,6 +89,8 @@ Note you can only use this feature if your "Preferred Text Type" is set to "plai
91
  Note that the images are processed in the order they are attached as of version
92
  1.4.6.
93
 
 
 
94
  * Image templates
95
  Postie now uses the default wordpress image template, but you can specify a
96
  different one if you wish.
73
  * You can also set a default tag to be applied if no tags are included.
74
 
75
  = Image Handling =
 
 
76
  * Allows you to attach images to your email and automatically post
77
+ them to your blog.
78
  * You can publish images in the text of your message by using #img1#
79
  #img2# - each one will be replaced with the HTML for the image
80
  you attached
89
  Note that the images are processed in the order they are attached as of version
90
  1.4.6.
91
 
92
+ Note you can only use the #img# feature if your "Preferred Text Type" is set to "plain"
93
+
94
  * Image templates
95
  Postie now uses the default wordpress image template, but you can specify a
96
  different one if you wish.
get_mail.php CHANGED
@@ -64,6 +64,7 @@ foreach ($emails as $email) {
64
  }
65
  flush();
66
  }
 
67
 
68
  if (function_exists('memory_get_usage'))
69
  DebugEcho("memory at end of e-mail processing:" . memory_get_usage());
64
  }
65
  flush();
66
  }
67
+ EchoInfo("Mail fetch complete, $message_number emails");
68
 
69
  if (function_exists('memory_get_usage'))
70
  DebugEcho("memory at end of e-mail processing:" . memory_get_usage());
postie-functions.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /*
4
- $Id: postie-functions.php 734856 2013-07-01 22:32:53Z WayneAllen $
5
  */
6
 
7
  //to turn on debug output add the following line to wp-config.php
@@ -47,12 +47,12 @@ if (!function_exists('mb_str_replace')) {
47
  }
48
 
49
  function postie_environment() {
50
- EchoInfo("Postie Version: " . POSTIE_VERSION);
51
- EchoInfo("WordPres Version: " . get_bloginfo('version'));
52
- EchoInfo("PHP Version: " . phpversion());
53
- EchoInfo("OS: " . php_uname());
54
- EchoInfo("Debug mode: " . (IsDebugMode() ? "On" : "Off"));
55
- EchoInfo("Time: " . date('Y-m-d H:i:s', time()) . " GMT");
56
  DebugEcho("Error log: " . ini_get('error_log'));
57
 
58
  if (isMarkdownInstalled()) {
@@ -136,9 +136,11 @@ function EchoInfo($v) {
136
  if (php_sapi_name() == "cli") {
137
  print( "$v\n");
138
  } else {
139
- if (headers_sent()) {
140
- print( "<pre>" . htmlspecialchars($v) . "</pre>\n");
 
141
  }
 
142
  }
143
  LogInfo($v);
144
  }
@@ -149,11 +151,13 @@ function DebugDump($v) {
149
  if (php_sapi_name() == "cli") {
150
  print( "$o\n");
151
  } else {
152
- if (headers_sent()) {
153
- print( "<pre>\n");
154
- EchoInfo($o);
155
- print( "</pre>\n");
156
  }
 
 
 
157
  }
158
  }
159
  }
@@ -164,7 +168,8 @@ function DebugEcho($v) {
164
  }
165
  }
166
 
167
- function tag_Date(&$content, $message_date, $time_offset) {
 
168
  $html = LoadDOM($content);
169
  if ($html !== false) {
170
  $es = $html->find('text');
@@ -178,10 +183,6 @@ function tag_Date(&$content, $message_date, $time_offset) {
178
  $t = date("H:i:s", $newdate);
179
  DebugEcho("tag_Date: original time: $t");
180
 
181
- $newdate = $newdate + $time_offset * 3600;
182
- $t = date("H:i:s", $newdate);
183
- DebugEcho("tag_Date: adjusted time: $t");
184
-
185
  $format = "Y-m-d";
186
  if ($t != '00:00:00') {
187
  $format.= " H:i:s";
@@ -212,7 +213,7 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config, $
212
  );
213
 
214
  if (array_key_exists('message-id', $mimeDecodedEmail->headers)) {
215
- EchoInfo("Message Id is :" . htmlentities($mimeDecodedEmail->headers["message-id"]));
216
  if ($fulldebugdump)
217
  DebugDump($mimeDecodedEmail);
218
  }
@@ -231,7 +232,7 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config, $
231
  if ($fulldebug)
232
  DebugEcho("post sig: $content");
233
 
234
- $post_excerpt = tag_Excerpt($content, $filternewlines, $convertnewline);
235
  if ($fulldebug)
236
  DebugEcho("post excerpt: $content");
237
 
@@ -251,7 +252,7 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config, $
251
  }
252
  $message_date = HandleMessageEncoding($cte, $cs, $mimeDecodedEmail->headers["date"], $message_encoding, $message_dequote);
253
  }
254
- $message_date = tag_Date($content, $message_date, $time_offset);
255
 
256
  list($post_date, $post_date_gmt, $delay) = filter_Delay($content, $message_date, $time_offset);
257
  if ($fulldebug)
@@ -321,7 +322,7 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config, $
321
  }
322
  }
323
  } else {
324
- EchoInfo("Reply detected");
325
  $is_reply = true;
326
  // strip out quoted content
327
  $lines = explode("\n", $content);
@@ -355,12 +356,12 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config, $
355
  if ($fulldebug)
356
  DebugEcho("post end: $content");
357
 
358
- filter_ReplaceImagePlaceHolders($content, $attachments["html"], $config, $id);
359
  if ($fulldebug)
360
  DebugEcho("post body img: $content");
361
 
362
  if ($post_excerpt) {
363
- filter_ReplaceImagePlaceHolders($post_excerpt, $attachments["html"], $config, $id);
364
  if ($fulldebug)
365
  DebugEcho("post excerpt img: $content");
366
  }
@@ -407,7 +408,7 @@ function PostEmail($poster, $mimeDecodedEmail, $config) {
407
  attachments with a post. So we add the post here, then update it */
408
  $tmpPost = array('post_title' => 'tmptitle', 'post_content' => 'tmpPost');
409
  $post_id = wp_insert_post($tmpPost);
410
- EchoInfo("new post id is $post_id");
411
 
412
  $is_reply = false;
413
  $postmodifiers = new PostiePostModifiers();
@@ -627,10 +628,15 @@ function getPostAuthorDetails(&$subject, &$content, &$mimeDecodedEmail) {
627
  $theAuthor = GetNameFromEmail($matches[1]);
628
  $mimeDecodedEmail->headers['from'] = $theAuthor;
629
  }
 
630
  if (preg_match("/\ndate:(.*?)\n/i", $content, $matches)) {
631
  $theDate = $matches[1];
632
  DebugEcho("date in Fwd: $theDate");
633
- $mimeDecodedEmail->headers['date'] = $theDate;
 
 
 
 
634
  }
635
 
636
  // now get rid of forwarding info in the content
@@ -764,7 +770,7 @@ function IMAPMessageFetch($server = NULL, $port = NULL, $email = NULL, $password
764
  if ($tls) {
765
  $mail_server->TLSOn();
766
  }
767
- EchoInfo("Connecting to $server:$port ($protocol)" . ($tls ? " with TLS" : ""));
768
  if ($mail_server->connect(trim($server), $port, $email, $password)) {
769
  $msg_count = $mail_server->getNumberOfMessages();
770
  } else {
@@ -805,7 +811,7 @@ function POP3MessageFetch($server = NULL, $port = NULL, $email = NULL, $password
805
  $pop3->DEBUG = POSTIE_DEBUG;
806
  }
807
 
808
- EchoInfo("Connecting to $server:$port ($protocol)");
809
 
810
  if ($pop3->connect(trim($server), $port)) {
811
  $msg_count = $pop3->login($email, $password);
@@ -1338,7 +1344,7 @@ function ValidatePoster(&$mimeDecodedEmail, $config) {
1338
 
1339
  //See if the email address is one of the special authorized ones
1340
  if (!empty($from)) {
1341
- EchoInfo("Confirming Access For $from ");
1342
  $user = get_user_by('email', $from);
1343
  if ($user !== false)
1344
  $user_ID = $user->ID;
@@ -1350,7 +1356,7 @@ function ValidatePoster(&$mimeDecodedEmail, $config) {
1350
  if ($user->has_cap("post_via_postie")) {
1351
  DebugEcho("$user_ID has 'post_via_postie' permissions");
1352
  $poster = $user_ID;
1353
- EchoInfo("posting as user $poster");
1354
  } else {
1355
  DebugEcho("$user_ID does not have 'post_via_postie' permissions");
1356
  $user_ID = "";
@@ -1392,7 +1398,7 @@ function isValidSmtpServer($mimeDecodedEmail, $smtpservers) {
1392
  foreach ((array) $mimeDecodedEmail->headers['received'] as $received) {
1393
  foreach ($smtpservers as $smtp) {
1394
  if (stristr($received, $smtp) !== false) {
1395
- EchoInfo("Sent from valid SMTP server.");
1396
  return true;
1397
  }
1398
  }
@@ -1796,6 +1802,7 @@ function postie_media_handle_upload($part, $post_id, $poster, $generate_thubnail
1796
  // use image exif/iptc data for title and caption defaults if possible
1797
  if (file_exists(ABSPATH . '/wp-admin/includes/image.php')) {
1798
  include_once(ABSPATH . '/wp-admin/includes/image.php');
 
1799
  if ($image_meta = @wp_read_image_metadata($file)) {
1800
  if (trim($image_meta['title'])) {
1801
  $title = $image_meta['title'];
@@ -2092,7 +2099,7 @@ function DecodeMIMEMail($email) {
2092
  */
2093
  function DisplayMIMEPartTypes($mimeDecodedEmail) {
2094
  foreach ($mimeDecodedEmail->parts as $part) {
2095
- EchoInfo($part->ctype_primary . " / " . $part->ctype_secondary . "/ " . $part->headers['content-transfer-encoding']);
2096
  }
2097
  }
2098
 
@@ -2122,6 +2129,7 @@ function RemoveExtraCharactersInEmailAddress($address) {
2122
  if (preg_match('/^[^<>]+<([^<> ()]+)>$/', $address, $matches)) {
2123
  $address = $matches[1];
2124
  DebugEcho("RemoveExtraCharactersInEmailAddress: $address (1)");
 
2125
  } else if (preg_match('/<([^<> ()]+)>/', $address, $matches)) {
2126
  $address = $matches[1];
2127
  DebugEcho("RemoveExtraCharactersInEmailAddress: $address (2)");
@@ -2314,7 +2322,7 @@ function filter_ReplaceImageCIDs(&$content, &$attachments, $config) {
2314
  * @param string - text of post
2315
  * @param array - array of HTML for images for post
2316
  */
2317
- function filter_ReplaceImagePlaceHolders(&$content, $attachments, $config, $post_id) {
2318
  if (!$config['custom_image_field']) {
2319
  $startIndex = $config['start_image_count_at_zero'] ? 0 : 1;
2320
 
@@ -2341,16 +2349,12 @@ function filter_ReplaceImagePlaceHolders(&$content, $attachments, $config, $post
2341
  $i = 0;
2342
  foreach ($attachments as $attachementName => $imageTemplate) {
2343
  // looks for ' #img1# ' etc... and replaces with image
2344
- $img_placeholder_temp = str_replace("%", intval($startIndex + $i), $config['image_placeholder']);
2345
- $img_placeholder_temp = rtrim($img_placeholder_temp, '#');
2346
-
2347
- $eimg_placeholder_temp = str_replace("%", intval($startIndex + $i), "#eimg%#");
2348
- $eimg_placeholder_temp = rtrim($eimg_placeholder_temp, '#');
2349
 
2350
  DebugEcho("img_placeholder_temp: $img_placeholder_temp");
2351
- if (stristr($content, $img_placeholder_temp) || stristr($content, $eimg_placeholder_temp)) {
2352
  // look for caption
2353
- DebugEcho("Found $img_placeholder_temp or $eimg_placeholder_temp");
2354
  $caption = '';
2355
  if (preg_match("/$img_placeholder_temp caption=(.*?)#/i", $content, $matches)) {
2356
  //DebugDump($matches);
@@ -2361,9 +2365,7 @@ function filter_ReplaceImagePlaceHolders(&$content, $attachments, $config, $post
2361
  DebugEcho("caption: $caption");
2362
 
2363
  $img_placeholder_temp = substr($matches[0], 0, -1);
2364
- $eimg_placeholder_temp = substr($matches[0], 0, -1);
2365
  DebugEcho($img_placeholder_temp);
2366
- DebugEcho($eimg_placeholder_temp);
2367
  } else {
2368
  DebugEcho("No caption found");
2369
  }
@@ -2372,13 +2374,11 @@ function filter_ReplaceImagePlaceHolders(&$content, $attachments, $config, $post
2372
  DebugEcho("populated template: " . $imageTemplate);
2373
 
2374
  $img_placeholder_temp.='#';
2375
- $eimg_placeholder_temp.='#';
2376
 
2377
  $content = str_ireplace($img_placeholder_temp, $imageTemplate, $content);
2378
  DebugEcho("post replace: $content");
2379
- $content = str_ireplace($eimg_placeholder_temp, $imageTemplate, $content);
2380
  } else {
2381
- DebugEcho("No $img_placeholder_temp or $eimg_placeholder_temp found");
2382
  $imageTemplate = str_replace('{CAPTION}', '', $imageTemplate);
2383
  /* if using the gallery shortcode, don't add pictures at all */
2384
  if (!preg_match("/\[gallery[^\[]*\]/", $content, $matches)) {
@@ -2389,10 +2389,12 @@ function filter_ReplaceImagePlaceHolders(&$content, $attachments, $config, $post
2389
  }
2390
  $i++;
2391
  }
2392
- if ($config['images_append']) {
2393
- $content .= $pics;
2394
- } else {
2395
- $content = $pics . $content;
 
 
2396
  }
2397
  }
2398
  }
@@ -2494,15 +2496,15 @@ function tag_Tags2(&$content, $defaultTags) {
2494
  * this function determines excerpt for the post
2495
  *
2496
  */
2497
- function tag_Excerpt(&$content, $filterNewLines, $convertNewLines) {
2498
  $post_excerpt = '';
2499
  if (preg_match('/:excerptstart ?(.*):excerptend/s', $content, $matches)) {
2500
  $content = str_replace($matches[0], "", $content);
2501
  $post_excerpt = $matches[1];
2502
  DebugEcho("excerpt found: $post_excerpt");
2503
- if ($filterNewLines) {
2504
  DebugEcho("filtering newlines from excerpt");
2505
- filter_Newlines($post_excerpt, $convertNewLines);
2506
  }
2507
  }
2508
  return $post_excerpt;
@@ -2564,7 +2566,7 @@ function lookup_category($trial_category, $category_match) {
2564
  global $wpdb;
2565
  $trial_category = trim($trial_category);
2566
  $found_category = NULL;
2567
- EchoInfo("lookup_category: $trial_category");
2568
 
2569
  $term = get_term_by('name', $trial_category, 'category');
2570
  if (!empty($term)) {
@@ -2602,18 +2604,18 @@ function lookup_category($trial_category, $category_match) {
2602
  function DisplayEmailPost($details) {
2603
  //DebugDump($details);
2604
  // Report
2605
- EchoInfo('Post Author: ' . $details["post_author"]);
2606
- EchoInfo('Date: ' . $details["post_date"]);
2607
  foreach ($details["post_category"] as $category) {
2608
- EchoInfo('Category: ' . $category);
2609
  }
2610
- EchoInfo('Ping Status: ' . $details["ping_status"]);
2611
- EchoInfo('Comment Status: ' . $details["comment_status"]);
2612
- EchoInfo('Subject: ' . $details["post_title"]);
2613
- EchoInfo('Postname: ' . $details["post_name"]);
2614
- EchoInfo('Post Id: ' . $details["ID"]);
2615
- EchoInfo('Post Type: ' . $details["post_type"]); /* Added by Raam Dev <raam@raamdev.com> */
2616
- //EchoInfo('Posted content: '.$details["post_content"]);
2617
  }
2618
 
2619
  /**
@@ -2946,7 +2948,7 @@ function config_UpgradeOld() {
2946
  $config['IMAGETEMPLATES'] = $imageTemplates;
2947
 
2948
  //general
2949
- include('templates/general_templates.php');
2950
  if (!isset($config["GENERALTEMPLATE"]))
2951
  $config["GENERALTEMPLATE"] = $postie_default;
2952
 
1
  <?php
2
 
3
  /*
4
+ $Id: postie-functions.php 771364 2013-09-13 03:34:07Z WayneAllen $
5
  */
6
 
7
  //to turn on debug output add the following line to wp-config.php
47
  }
48
 
49
  function postie_environment() {
50
+ DebugEcho("Postie Version: " . POSTIE_VERSION);
51
+ DebugEcho("WordPres Version: " . get_bloginfo('version'));
52
+ DebugEcho("PHP Version: " . phpversion());
53
+ DebugEcho("OS: " . php_uname());
54
+ DebugEcho("Debug mode: " . (IsDebugMode() ? "On" : "Off"));
55
+ DebugEcho("Time: " . date('Y-m-d H:i:s', time()) . " GMT");
56
  DebugEcho("Error log: " . ini_get('error_log'));
57
 
58
  if (isMarkdownInstalled()) {
136
  if (php_sapi_name() == "cli") {
137
  print( "$v\n");
138
  } else {
139
+ //flush the buffers
140
+ while (ob_get_level() > 0) {
141
+ ob_end_flush();
142
  }
143
+ print( "<pre>" . htmlspecialchars($v) . "</pre>\n");
144
  }
145
  LogInfo($v);
146
  }
151
  if (php_sapi_name() == "cli") {
152
  print( "$o\n");
153
  } else {
154
+ //flush the buffers
155
+ while (ob_get_level() > 0) {
156
+ ob_end_flush();
 
157
  }
158
+ print( "<pre>\n");
159
+ EchoInfo($o);
160
+ print( "</pre>\n");
161
  }
162
  }
163
  }
168
  }
169
  }
170
 
171
+ function tag_Date(&$content, $message_date) {
172
+ //don't apply any offset here as it is accounted for later
173
  $html = LoadDOM($content);
174
  if ($html !== false) {
175
  $es = $html->find('text');
183
  $t = date("H:i:s", $newdate);
184
  DebugEcho("tag_Date: original time: $t");
185
 
 
 
 
 
186
  $format = "Y-m-d";
187
  if ($t != '00:00:00') {
188
  $format.= " H:i:s";
213
  );
214
 
215
  if (array_key_exists('message-id', $mimeDecodedEmail->headers)) {
216
+ DebugEcho("Message Id is :" . htmlentities($mimeDecodedEmail->headers["message-id"]));
217
  if ($fulldebugdump)
218
  DebugDump($mimeDecodedEmail);
219
  }
232
  if ($fulldebug)
233
  DebugEcho("post sig: $content");
234
 
235
+ $post_excerpt = tag_Excerpt($content, $config);
236
  if ($fulldebug)
237
  DebugEcho("post excerpt: $content");
238
 
252
  }
253
  $message_date = HandleMessageEncoding($cte, $cs, $mimeDecodedEmail->headers["date"], $message_encoding, $message_dequote);
254
  }
255
+ $message_date = tag_Date($content, $message_date);
256
 
257
  list($post_date, $post_date_gmt, $delay) = filter_Delay($content, $message_date, $time_offset);
258
  if ($fulldebug)
322
  }
323
  }
324
  } else {
325
+ DebugEcho("Reply detected");
326
  $is_reply = true;
327
  // strip out quoted content
328
  $lines = explode("\n", $content);
356
  if ($fulldebug)
357
  DebugEcho("post end: $content");
358
 
359
+ filter_ReplaceImagePlaceHolders($content, $attachments["html"], $config, $id, $config['image_placeholder'], true);
360
  if ($fulldebug)
361
  DebugEcho("post body img: $content");
362
 
363
  if ($post_excerpt) {
364
+ filter_ReplaceImagePlaceHolders($post_excerpt, $attachments["html"], $config, $id, "#eimg%#", false);
365
  if ($fulldebug)
366
  DebugEcho("post excerpt img: $content");
367
  }
408
  attachments with a post. So we add the post here, then update it */
409
  $tmpPost = array('post_title' => 'tmptitle', 'post_content' => 'tmpPost');
410
  $post_id = wp_insert_post($tmpPost);
411
+ DebugEcho("new post id is $post_id");
412
 
413
  $is_reply = false;
414
  $postmodifiers = new PostiePostModifiers();
628
  $theAuthor = GetNameFromEmail($matches[1]);
629
  $mimeDecodedEmail->headers['from'] = $theAuthor;
630
  }
631
+ //TODO dosen't always work with HTML
632
  if (preg_match("/\ndate:(.*?)\n/i", $content, $matches)) {
633
  $theDate = $matches[1];
634
  DebugEcho("date in Fwd: $theDate");
635
+ if (($timestamp = strtotime($theDate)) === false) {
636
+ DebugEcho("bad date found: $theDate");
637
+ } else {
638
+ $mimeDecodedEmail->headers['date'] = $theDate;
639
+ }
640
  }
641
 
642
  // now get rid of forwarding info in the content
770
  if ($tls) {
771
  $mail_server->TLSOn();
772
  }
773
+ DebugEcho("Connecting to $server:$port ($protocol)" . ($tls ? " with TLS" : ""));
774
  if ($mail_server->connect(trim($server), $port, $email, $password)) {
775
  $msg_count = $mail_server->getNumberOfMessages();
776
  } else {
811
  $pop3->DEBUG = POSTIE_DEBUG;
812
  }
813
 
814
+ DebugEcho("Connecting to $server:$port ($protocol)");
815
 
816
  if ($pop3->connect(trim($server), $port)) {
817
  $msg_count = $pop3->login($email, $password);
1344
 
1345
  //See if the email address is one of the special authorized ones
1346
  if (!empty($from)) {
1347
+ DebugEcho("Confirming Access For $from ");
1348
  $user = get_user_by('email', $from);
1349
  if ($user !== false)
1350
  $user_ID = $user->ID;
1356
  if ($user->has_cap("post_via_postie")) {
1357
  DebugEcho("$user_ID has 'post_via_postie' permissions");
1358
  $poster = $user_ID;
1359
+ DebugEcho("posting as user $poster");
1360
  } else {
1361
  DebugEcho("$user_ID does not have 'post_via_postie' permissions");
1362
  $user_ID = "";
1398
  foreach ((array) $mimeDecodedEmail->headers['received'] as $received) {
1399
  foreach ($smtpservers as $smtp) {
1400
  if (stristr($received, $smtp) !== false) {
1401
+ DebugEcho("Sent from valid SMTP server.");
1402
  return true;
1403
  }
1404
  }
1802
  // use image exif/iptc data for title and caption defaults if possible
1803
  if (file_exists(ABSPATH . '/wp-admin/includes/image.php')) {
1804
  include_once(ABSPATH . '/wp-admin/includes/image.php');
1805
+ include_once(ABSPATH . '/wp-admin/includes/media.php');
1806
  if ($image_meta = @wp_read_image_metadata($file)) {
1807
  if (trim($image_meta['title'])) {
1808
  $title = $image_meta['title'];
2099
  */
2100
  function DisplayMIMEPartTypes($mimeDecodedEmail) {
2101
  foreach ($mimeDecodedEmail->parts as $part) {
2102
+ DebugEcho($part->ctype_primary . " / " . $part->ctype_secondary . "/ " . $part->headers['content-transfer-encoding']);
2103
  }
2104
  }
2105
 
2129
  if (preg_match('/^[^<>]+<([^<> ()]+)>$/', $address, $matches)) {
2130
  $address = $matches[1];
2131
  DebugEcho("RemoveExtraCharactersInEmailAddress: $address (1)");
2132
+ DebugDump($matches);
2133
  } else if (preg_match('/<([^<> ()]+)>/', $address, $matches)) {
2134
  $address = $matches[1];
2135
  DebugEcho("RemoveExtraCharactersInEmailAddress: $address (2)");
2322
  * @param string - text of post
2323
  * @param array - array of HTML for images for post
2324
  */
2325
+ function filter_ReplaceImagePlaceHolders(&$content, $attachments, $config, $post_id, $image_pattern, $autoadd_images) {
2326
  if (!$config['custom_image_field']) {
2327
  $startIndex = $config['start_image_count_at_zero'] ? 0 : 1;
2328
 
2349
  $i = 0;
2350
  foreach ($attachments as $attachementName => $imageTemplate) {
2351
  // looks for ' #img1# ' etc... and replaces with image
2352
+ $img_placeholder_temp = rtrim(str_replace("%", intval($startIndex + $i), $image_pattern), '#');
 
 
 
 
2353
 
2354
  DebugEcho("img_placeholder_temp: $img_placeholder_temp");
2355
+ if (stristr($content, $img_placeholder_temp)) {
2356
  // look for caption
2357
+ DebugEcho("Found $img_placeholder_temp");
2358
  $caption = '';
2359
  if (preg_match("/$img_placeholder_temp caption=(.*?)#/i", $content, $matches)) {
2360
  //DebugDump($matches);
2365
  DebugEcho("caption: $caption");
2366
 
2367
  $img_placeholder_temp = substr($matches[0], 0, -1);
 
2368
  DebugEcho($img_placeholder_temp);
 
2369
  } else {
2370
  DebugEcho("No caption found");
2371
  }
2374
  DebugEcho("populated template: " . $imageTemplate);
2375
 
2376
  $img_placeholder_temp.='#';
 
2377
 
2378
  $content = str_ireplace($img_placeholder_temp, $imageTemplate, $content);
2379
  DebugEcho("post replace: $content");
 
2380
  } else {
2381
+ DebugEcho("No $img_placeholder_temp found");
2382
  $imageTemplate = str_replace('{CAPTION}', '', $imageTemplate);
2383
  /* if using the gallery shortcode, don't add pictures at all */
2384
  if (!preg_match("/\[gallery[^\[]*\]/", $content, $matches)) {
2389
  }
2390
  $i++;
2391
  }
2392
+ if ($autoadd_images) {
2393
+ if ($config['images_append']) {
2394
+ $content .= $pics;
2395
+ } else {
2396
+ $content = $pics . $content;
2397
+ }
2398
  }
2399
  }
2400
  }
2496
  * this function determines excerpt for the post
2497
  *
2498
  */
2499
+ function tag_Excerpt(&$content, $config) {
2500
  $post_excerpt = '';
2501
  if (preg_match('/:excerptstart ?(.*):excerptend/s', $content, $matches)) {
2502
  $content = str_replace($matches[0], "", $content);
2503
  $post_excerpt = $matches[1];
2504
  DebugEcho("excerpt found: $post_excerpt");
2505
+ if ($config['filternewlines']) {
2506
  DebugEcho("filtering newlines from excerpt");
2507
+ filter_Newlines($post_excerpt, $config);
2508
  }
2509
  }
2510
  return $post_excerpt;
2566
  global $wpdb;
2567
  $trial_category = trim($trial_category);
2568
  $found_category = NULL;
2569
+ DebugEcho("lookup_category: $trial_category");
2570
 
2571
  $term = get_term_by('name', $trial_category, 'category');
2572
  if (!empty($term)) {
2604
  function DisplayEmailPost($details) {
2605
  //DebugDump($details);
2606
  // Report
2607
+ DebugEcho('Post Author: ' . $details["post_author"]);
2608
+ DebugEcho('Date: ' . $details["post_date"]);
2609
  foreach ($details["post_category"] as $category) {
2610
+ DebugEcho('Category: ' . $category);
2611
  }
2612
+ DebugEcho('Ping Status: ' . $details["ping_status"]);
2613
+ DebugEcho('Comment Status: ' . $details["comment_status"]);
2614
+ DebugEcho('Subject: ' . $details["post_title"]);
2615
+ DebugEcho('Postname: ' . $details["post_name"]);
2616
+ DebugEcho('Post Id: ' . $details["ID"]);
2617
+ DebugEcho('Post Type: ' . $details["post_type"]); /* Added by Raam Dev <raam@raamdev.com> */
2618
+ //DebugEcho('Posted content: '.$details["post_content"]);
2619
  }
2620
 
2621
  /**
2948
  $config['IMAGETEMPLATES'] = $imageTemplates;
2949
 
2950
  //general
2951
+ include('templates/general_template.php');
2952
  if (!isset($config["GENERALTEMPLATE"]))
2953
  $config["GENERALTEMPLATE"] = $postie_default;
2954
 
postie.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Signifigantly upgrades the posting by mail features of Word Press (See <a href='options-general.php?page=postie/postie.php'>Settings and options</a>) to configure your e-mail settings. See the <a href='http://wordpress.org/extend/plugins/postie/other_notes'>Readme</a> for usage. Visit the <a href='http://wordpress.org/support/plugin/postie'>postie forum</a> for support.
7
- Version: 1.5.15
8
  Author: Wayne Allen
9
  Author URI: http://allens-home.com/
10
  License: GPL2
@@ -27,10 +27,10 @@
27
  */
28
 
29
  /*
30
- $Id: postie.php 734872 2013-07-01 23:25:27Z WayneAllen $
31
  */
32
 
33
- define('POSTIE_VERSION', '1.5.15');
34
  define("POSTIE_ROOT", dirname(__FILE__));
35
  define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
36
 
@@ -204,7 +204,7 @@ function postie_whitelist($options) {
204
 
205
  //don't use DebugEcho or EchoInfo here as it is not defined when called as an action
206
  function check_postie() {
207
- error_log("check_postie");
208
 
209
  $fullurl = plugins_url("get_mail.php", __FILE__);
210
  preg_match("/https?:\/\/(.[^\/]*)(.*)/i", $fullurl, $matches);
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Signifigantly upgrades the posting by mail features of Word Press (See <a href='options-general.php?page=postie/postie.php'>Settings and options</a>) to configure your e-mail settings. See the <a href='http://wordpress.org/extend/plugins/postie/other_notes'>Readme</a> for usage. Visit the <a href='http://wordpress.org/support/plugin/postie'>postie forum</a> for support.
7
+ Version: 1.5.16
8
  Author: Wayne Allen
9
  Author URI: http://allens-home.com/
10
  License: GPL2
27
  */
28
 
29
  /*
30
+ $Id: postie.php 772964 2013-09-15 22:53:47Z WayneAllen $
31
  */
32
 
33
+ define('POSTIE_VERSION', '1.5.16');
34
  define("POSTIE_ROOT", dirname(__FILE__));
35
  define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
36
 
204
 
205
  //don't use DebugEcho or EchoInfo here as it is not defined when called as an action
206
  function check_postie() {
207
+ //error_log("check_postie");
208
 
209
  $fullurl = plugins_url("get_mail.php", __FILE__);
210
  preg_match("/https?:\/\/(.[^\/]*)(.*)/i", $fullurl, $matches);
postieIMAP.php CHANGED
@@ -121,7 +121,7 @@ class PostieIMAP {
121
  function fetchEmail($index) {
122
 
123
  $header_info = imap_headerinfo($this->_connection, $index);
124
- DebugDump($header_info);
125
 
126
  if (IsDebugMode() || $header_info->Recent == 'N' || $header_info->Unseen == 'U') {
127
  $email = imap_fetchheader($this->_connection, $index);
121
  function fetchEmail($index) {
122
 
123
  $header_info = imap_headerinfo($this->_connection, $index);
124
+ //DebugDump($header_info);
125
 
126
  if (IsDebugMode() || $header_info->Recent == 'N' || $header_info->Unseen == 'U') {
127
  $email = imap_fetchheader($this->_connection, $index);
readme.html CHANGED
@@ -72,6 +72,8 @@ Then use the Task Scheduler control panel to call wget or cron.</p> <hr />
72
 
73
  <h3>Upgrade Notice</h3>
74
  <dl>
 
 
75
  <dt>1.5.3</dt>
76
  <dd>Postie can now set the first image in an email to be the &quot;Featured&quot; image. There is a new setting &quot;Use First Image as Featured Image&quot; which is off by default.
77
  Postie now supports Use Transport Layer Security (TLS)</dd>
@@ -81,8 +83,6 @@ Postie now supports Use Transport Layer Security (TLS)</dd>
81
  <dd>Post format is now supported. You can specify any of the WordPress supported post formats using the Post type syntax.
82
  Post status can now be specified using the status: tag.
83
  Post status setting was renamed to Default Post Status and moved to the Message tab.</dd>
84
- <dt>1.4.18</dt>
85
- <dd>Many method names have been changed. Any custom filters may need to be updated.</dd>
86
  <dt>1.4.10</dt>
87
  <dd>All script, style and body tags are stripped from html emails.</dd>
88
  <dt>1.4.6</dt>
@@ -203,11 +203,9 @@ tags: foo, bar</li>
203
 
204
  <h4>Image Handling</h4>
205
 
206
- <p>Note you can only use this feature if your "Preferred Text Type" is set to "plain"</p>
207
-
208
  <ul>
209
  <li>Allows you to attach images to your email and automatically post
210
- them to your blog</li>
211
  <li>You can publish images in the text of your message by using #img1#
212
  #img2# - each one will be replaced with the HTML for the image
213
  you attached</li>
@@ -222,7 +220,9 @@ you attached</li>
222
  in many photo editing programs (for example Picasa), will add an IPTC caption)</p>
223
 
224
  <p>Note that the images are processed in the order they are attached as of version
225
- 1.4.6.</p></li>
 
 
226
  <li><p>Image templates
227
  Postie now uses the default wordpress image template, but you can specify a
228
  different one if you wish.</p>
72
 
73
  <h3>Upgrade Notice</h3>
74
  <dl>
75
+ <dt>1.5.14</dt>
76
+ <dd>The postie_post filter has be deprecated in favor of postie_post_before.</dd>
77
  <dt>1.5.3</dt>
78
  <dd>Postie can now set the first image in an email to be the &quot;Featured&quot; image. There is a new setting &quot;Use First Image as Featured Image&quot; which is off by default.
79
  Postie now supports Use Transport Layer Security (TLS)</dd>
83
  <dd>Post format is now supported. You can specify any of the WordPress supported post formats using the Post type syntax.
84
  Post status can now be specified using the status: tag.
85
  Post status setting was renamed to Default Post Status and moved to the Message tab.</dd>
 
 
86
  <dt>1.4.10</dt>
87
  <dd>All script, style and body tags are stripped from html emails.</dd>
88
  <dt>1.4.6</dt>
203
 
204
  <h4>Image Handling</h4>
205
 
 
 
206
  <ul>
207
  <li>Allows you to attach images to your email and automatically post
208
+ them to your blog.</li>
209
  <li>You can publish images in the text of your message by using #img1#
210
  #img2# - each one will be replaced with the HTML for the image
211
  you attached</li>
220
  in many photo editing programs (for example Picasa), will add an IPTC caption)</p>
221
 
222
  <p>Note that the images are processed in the order they are attached as of version
223
+ 1.4.6.</p>
224
+
225
+ <p>Note you can only use the #img# feature if your "Preferred Text Type" is set to "plain"</p></li>
226
  <li><p>Image templates
227
  Postie now uses the default wordpress image template, but you can specify a
228
  different one if you wish.</p>
readme.txt CHANGED
@@ -5,8 +5,8 @@ Author URI: http://allens-home.com/
5
  Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
- Tested up to: 3.5.2
9
- Stable tag: 1.5.15
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -154,10 +154,8 @@ Then use the Task Scheduler control panel to call wget or cron.
154
  * You can also set a default tag to be applied if no tags are included.
155
 
156
  = Image Handling =
157
- Note you can only use this feature if your "Preferred Text Type" is set to "plain"
158
-
159
  * Allows you to attach images to your email and automatically post
160
- them to your blog
161
  * You can publish images in the text of your message by using #img1#
162
  #img2# - each one will be replaced with the HTML for the image
163
  you attached
@@ -172,6 +170,8 @@ Note you can only use this feature if your "Preferred Text Type" is set to "plai
172
  Note that the images are processed in the order they are attached as of version
173
  1.4.6.
174
 
 
 
175
  * Image templates
176
  Postie now uses the default wordpress image template, but you can specify a
177
  different one if you wish.
@@ -428,7 +428,6 @@ The postie_post filter has be deprecated in favor of postie_post_before.
428
 
429
  = 1.5.3 =
430
  Postie can now set the first image in an email to be the "Featured" image. There is a new setting "Use First Image as Featured Image" which is off by default.
431
-
432
  Postie now supports Use Transport Layer Security (TLS)
433
 
434
  = 1.5.0 =
@@ -446,6 +445,15 @@ All script, style and body tags are stripped from html emails.
446
  Attachments are now processed in the order they were attached.
447
 
448
  == CHANGELOG ==
 
 
 
 
 
 
 
 
 
449
 
450
  = 1.5.15 (2013.07.01) =
451
  * Added message warning that filter 'postie_post' has been deprecated.
5
  Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
+ Tested up to: 3.6.1
9
+ Stable tag: 1.5.16
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
154
  * You can also set a default tag to be applied if no tags are included.
155
 
156
  = Image Handling =
 
 
157
  * Allows you to attach images to your email and automatically post
158
+ them to your blog.
159
  * You can publish images in the text of your message by using #img1#
160
  #img2# - each one will be replaced with the HTML for the image
161
  you attached
170
  Note that the images are processed in the order they are attached as of version
171
  1.4.6.
172
 
173
+ Note you can only use the #img# feature if your "Preferred Text Type" is set to "plain"
174
+
175
  * Image templates
176
  Postie now uses the default wordpress image template, but you can specify a
177
  different one if you wish.
428
 
429
  = 1.5.3 =
430
  Postie can now set the first image in an email to be the "Featured" image. There is a new setting "Use First Image as Featured Image" which is off by default.
 
431
  Postie now supports Use Transport Layer Security (TLS)
432
 
433
  = 1.5.0 =
445
  Attachments are now processed in the order they were attached.
446
 
447
  == CHANGELOG ==
448
+ = 1.5.16 (2013.09.15) =
449
+ * Fixed date detection bug in forwarded messages.
450
+ * Possible fix for blank screen issue (flush buffers rather than check for sent headers).
451
+ * Fixed images showing up in excerpts when not specified.
452
+ * Fixed bug where time offset was applied twice.
453
+ * Fixed bug where excerpts where not getting the newline settings applied.
454
+ * Fixed bug where the attachment template was not getting set on new installs.
455
+ * Fixed bug where mp3 files were causing failures when getting meta-data.
456
+ * Verified compatibility with WP 36. and 3.6.1
457
 
458
  = 1.5.15 (2013.07.01) =
459
  * Added message warning that filter 'postie_post' has been deprecated.