Postie - Version 1.5.13

Version Description

(2013.06.18) = * Added more robust charset conversion to deal with malformed emails. * Ensure the default title is used when category etc parsing results in blank title * Consolidate procedure for locating wp-config.php * Additional debug output. * Fixed a bug where the default author was being used even though the email had a valid author. * Added feature to disable IMAP authentication with GSSAPI or NTLM to improve MS Exchange compatibility.

Download this release

Release Info

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

Code changes from version 1.5.12 to 1.5.13

Revision CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ Revision: 726477
2
+ Last Changed Date: 2013-06-12 16:39:49 -0700 (Wed, 12 Jun 2013)
docs/Changes.txt CHANGED
@@ -22,6 +22,14 @@ 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
  = 1.5.12 (2013.06.08) =
26
  * Added full paths to includes in config_form due to some hosts having include_path set in a way that breaks Postie.
27
  * Added some checks for emails that aren't correctly formatted (AirMail/WinLink)
22
  Attachments are now processed in the order they were attached.
23
 
24
  == CHANGELOG ==
25
+ = 1.5.13 (2013.06.18) =
26
+ * Added more robust charset conversion to deal with malformed emails.
27
+ * Ensure the default title is used when category etc parsing results in blank title
28
+ * Consolidate procedure for locating wp-config.php
29
+ * Additional debug output.
30
+ * Fixed a bug where the default author was being used even though the email had a valid author.
31
+ * Added feature to disable IMAP authentication with GSSAPI or NTLM to improve MS Exchange compatibility.
32
+
33
  = 1.5.12 (2013.06.08) =
34
  * Added full paths to includes in config_form due to some hosts having include_path set in a way that breaks Postie.
35
  * Added some checks for emails that aren't correctly formatted (AirMail/WinLink)
docs/Postie.txt CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5.1
9
- Stable tag: 1.5.12
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5.1
9
+ Stable tag: 1.5.13
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
docs/TODO.txt CHANGED
@@ -13,6 +13,7 @@ standardize tags
13
  Postie 2.0
14
 
15
  setting to turn off individual tags
 
16
  plugin mechanism to add new tags (and define "built-in ones")
17
  fix postie settings http://alisothegeek.com/2011/01/wordpress-settings-api-tutorial-1/
18
  Make sure all failures are sent to admin (option?) failed attachments, etc.
13
  Postie 2.0
14
 
15
  setting to turn off individual tags
16
+ process single email at a time and don't delete unless successful
17
  plugin mechanism to add new tags (and define "built-in ones")
18
  fix postie settings http://alisothegeek.com/2011/01/wordpress-settings-api-tutorial-1/
19
  Make sure all failures are sent to admin (option?) failed attachments, etc.
get_mail.php CHANGED
@@ -1,17 +1,6 @@
1
  <?php
2
 
3
- //support moving wp-config.php as described here http://codex.wordpress.org/Hardening_WordPress#Securing_wp-config.php
4
- $wp_config_path = dirname(dirname(dirname(dirname(__FILE__))));
5
- if (file_exists($wp_config_path . DIRECTORY_SEPARATOR . "wp-config.php")) {
6
- include_once($wp_config_path . DIRECTORY_SEPARATOR . "wp-config.php");
7
- } elseif (file_exists(dirname($wp_config_path) . DIRECTORY_SEPARATOR . "wp-config.php")) {
8
- include_once (dirname($wp_config_path)) . DIRECTORY_SEPARATOR . "wp-config.php";
9
- } elseif (file_exists('/usr/share/wordpress/wp-config.php')) {
10
- include_once('/usr/share/wordpress/wp-config.php');
11
- } else {
12
- die("wp-config.php could not be found.");
13
- }
14
-
15
  require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mimedecode.php');
16
  require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'postie-functions.php');
17
  if (!function_exists('file_get_html'))
1
  <?php
2
 
3
+ require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'postie-wp-config.php');
 
 
 
 
 
 
 
 
 
 
 
4
  require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mimedecode.php');
5
  require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'postie-functions.php');
6
  if (!function_exists('file_get_html'))
postie-functions.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /*
4
- $Id: postie-functions.php 724556 2013-06-09 01:11:57Z WayneAllen $
5
  */
6
 
7
  //to turn on debug output add the following line to wp-config.php
@@ -132,10 +132,10 @@ function LogInfo($v) {
132
 
133
  function EchoInfo($v) {
134
  if (php_sapi_name() == "cli") {
135
- echo "$v\n";
136
  } else {
137
  if (headers_sent()) {
138
- echo "<pre>" . htmlspecialchars($v) . "</pre>\n";
139
  }
140
  }
141
  LogInfo($v);
@@ -145,12 +145,12 @@ function DebugDump($v) {
145
  if (IsDebugMode()) {
146
  $o = print_r($v, true);
147
  if (php_sapi_name() == "cli") {
148
- echo "$o\n";
149
  } else {
150
  if (headers_sent()) {
151
- echo "<pre>\n";
152
  EchoInfo($o);
153
- echo "</pre>\n";
154
  }
155
  }
156
  }
@@ -198,7 +198,8 @@ function tag_Date(&$content, $message_date, $time_offset) {
198
 
199
  function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config, $postmodifiers) {
200
 
201
- $fulldebug = false;
 
202
 
203
  extract($config);
204
 
@@ -210,12 +211,12 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config, $
210
 
211
  if (array_key_exists('message-id', $mimeDecodedEmail->headers)) {
212
  EchoInfo("Message Id is :" . htmlentities($mimeDecodedEmail->headers["message-id"]));
213
- if ($fulldebug)
214
  DebugDump($mimeDecodedEmail);
215
  }
216
 
217
  filter_PreferedText($mimeDecodedEmail, $prefer_text_type);
218
- if ($fulldebug)
219
  DebugDump($mimeDecodedEmail);
220
 
221
  $content = GetContent($mimeDecodedEmail, $attachments, $post_id, $poster, $config);
@@ -364,6 +365,11 @@ function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config, $
364
 
365
  DebugEcho("excerpt: $post_excerpt");
366
 
 
 
 
 
 
367
  $details = array(
368
  'post_author' => $poster,
369
  'comment_author' => $postAuthorDetails['author'],
@@ -1345,7 +1351,7 @@ function ValidatePoster(&$mimeDecodedEmail, $config) {
1345
  $user_ID = "";
1346
  }
1347
  }
1348
- if ($turn_authorization_off || isEmailAddressAuthorized($from, $authorized_addresses) || isEmailAddressAuthorized($resentFrom, $authorized_addresses)) {
1349
  DebugEcho("ValidatePoster: looking up default user $admin_username");
1350
  $user = get_user_by('login', $admin_username);
1351
  if ($user === false) {
@@ -1557,11 +1563,15 @@ function HandleMessageEncoding($contenttransferencoding, $charset, $body, $blogE
1557
  }
1558
 
1559
  DebugEcho("after HandleMessageEncoding");
1560
- if (!empty($charset) && strtolower($charset) != 'default' && strtolower($charset) != strtolower($blogEncoding)) {
1561
- DebugEcho("converting from $charset to $blogEncoding");
1562
- //DebugEcho("before: $body");
1563
- $body = iconv($charset, $blogEncoding . '//TRANSLIT', $body);
1564
- //DebugEcho("after: $body");
 
 
 
 
1565
  }
1566
  return $body;
1567
  }
@@ -2301,10 +2311,6 @@ function filter_ReplaceImageCIDs(&$content, &$attachments, $config) {
2301
  */
2302
  function filter_ReplaceImagePlaceHolders(&$content, $attachments, $config, $post_id) {
2303
  if (!$config['custom_image_field']) {
2304
- if (!$config['allow_html_in_body']) {
2305
- $content = html_entity_decode($content, ENT_QUOTES);
2306
- }
2307
-
2308
  $startIndex = $config['start_image_count_at_zero'] ? 0 : 1;
2309
 
2310
  $images = get_posts(array(
1
  <?php
2
 
3
  /*
4
+ $Id: postie-functions.php 728059 2013-06-18 20:21:15Z WayneAllen $
5
  */
6
 
7
  //to turn on debug output add the following line to wp-config.php
132
 
133
  function EchoInfo($v) {
134
  if (php_sapi_name() == "cli") {
135
+ print( "$v\n");
136
  } else {
137
  if (headers_sent()) {
138
+ print( "<pre>" . htmlspecialchars($v) . "</pre>\n");
139
  }
140
  }
141
  LogInfo($v);
145
  if (IsDebugMode()) {
146
  $o = print_r($v, true);
147
  if (php_sapi_name() == "cli") {
148
+ print( "$o\n");
149
  } else {
150
  if (headers_sent()) {
151
+ print( "<pre>\n");
152
  EchoInfo($o);
153
+ print( "</pre>\n");
154
  }
155
  }
156
  }
198
 
199
  function CreatePost($poster, $mimeDecodedEmail, $post_id, &$is_reply, $config, $postmodifiers) {
200
 
201
+ $fulldebug = IsDebugMode();
202
+ $fulldebugdump = false;
203
 
204
  extract($config);
205
 
211
 
212
  if (array_key_exists('message-id', $mimeDecodedEmail->headers)) {
213
  EchoInfo("Message Id is :" . htmlentities($mimeDecodedEmail->headers["message-id"]));
214
+ if ($fulldebugdump)
215
  DebugDump($mimeDecodedEmail);
216
  }
217
 
218
  filter_PreferedText($mimeDecodedEmail, $prefer_text_type);
219
+ if ($fulldebugdump)
220
  DebugDump($mimeDecodedEmail);
221
 
222
  $content = GetContent($mimeDecodedEmail, $attachments, $post_id, $poster, $config);
365
 
366
  DebugEcho("excerpt: $post_excerpt");
367
 
368
+ if (trim($subject) == "") {
369
+ $subject = $default_title;
370
+ DebugEcho("post parsing subject is blank using: $default_title");
371
+ }
372
+
373
  $details = array(
374
  'post_author' => $poster,
375
  'comment_author' => $postAuthorDetails['author'],
1351
  $user_ID = "";
1352
  }
1353
  }
1354
+ if (empty($user_ID) && ($turn_authorization_off || isEmailAddressAuthorized($from, $authorized_addresses) || isEmailAddressAuthorized($resentFrom, $authorized_addresses))) {
1355
  DebugEcho("ValidatePoster: looking up default user $admin_username");
1356
  $user = get_user_by('login', $admin_username);
1357
  if ($user === false) {
1563
  }
1564
 
1565
  DebugEcho("after HandleMessageEncoding");
1566
+ if (strtolower($charset) != strtolower($blogEncoding)) {
1567
+ if (!empty($charset) && strtolower($charset) != 'default' && strtolower($charset) != $blogEncoding) {
1568
+ DebugEcho("converting from $charset to $blogEncoding");
1569
+ //DebugEcho("before: $body");
1570
+ $body = iconv($charset, $blogEncoding . '//IGNORE//TRANSLIT', $body);
1571
+ //DebugEcho("after: $body");
1572
+ } else {
1573
+ $body = iconv($blogEncoding, $blogEncoding . '//IGNORE//TRANSLIT', $body);
1574
+ }
1575
  }
1576
  return $body;
1577
  }
2311
  */
2312
  function filter_ReplaceImagePlaceHolders(&$content, $attachments, $config, $post_id) {
2313
  if (!$config['custom_image_field']) {
 
 
 
 
2314
  $startIndex = $config['start_image_count_at_zero'] ? 0 : 1;
2315
 
2316
  $images = get_posts(array(
postie-wp-config.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //support moving wp-config.php as described here http://codex.wordpress.org/Hardening_WordPress#Securing_wp-config.php
4
+ $wp_config_path = dirname(dirname(dirname(dirname(__FILE__))));
5
+ if (file_exists($wp_config_path . DIRECTORY_SEPARATOR . "wp-config.php")) {
6
+ include_once($wp_config_path . DIRECTORY_SEPARATOR . "wp-config.php");
7
+ } elseif (file_exists(dirname($wp_config_path) . DIRECTORY_SEPARATOR . "wp-config.php")) {
8
+ include_once (dirname($wp_config_path)) . DIRECTORY_SEPARATOR . "wp-config.php";
9
+ } elseif (file_exists('/usr/share/wordpress/wp-config.php')) {
10
+ include_once('/usr/share/wordpress/wp-config.php');
11
+ } else {
12
+ die("wp-config.php could not be found.");
13
+ }
14
+ ?>
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.12
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 724558 2013-06-09 01:26:50Z WayneAllen $
31
  */
32
 
33
- define('POSTIE_VERSION', '1.5.12');
34
  define("POSTIE_ROOT", dirname(__FILE__));
35
  define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
36
 
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.13
8
  Author: Wayne Allen
9
  Author URI: http://allens-home.com/
10
  License: GPL2
27
  */
28
 
29
  /*
30
+ $Id: postie.php 728097 2013-06-18 23:15:20Z WayneAllen $
31
  */
32
 
33
+ define('POSTIE_VERSION', '1.5.13');
34
  define("POSTIE_ROOT", dirname(__FILE__));
35
  define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
36
 
postieIMAP.php CHANGED
@@ -80,7 +80,7 @@ class PostieIMAP {
80
  $this->_server_string = "{" . $server . ":" . $port . $option . "}";
81
  }
82
  DebugEcho("IMAP: connection string - {$this->_server_string}");
83
- $this->_connection = imap_open($this->_server_string, $login, $password);
84
 
85
  if ($this->_connection) {
86
  $this->_connected = true;
@@ -164,16 +164,16 @@ class PostieIMAP {
164
  * @return PostieIMAP|PostieIMAPSSL|PostimePOP3SSL
165
  * @static
166
  */
167
- function &Factory($protocol) {
168
  switch (strtolower($protocol)) {
169
  case "imap":
170
- $object = &new PostieIMAP();
171
  break;
172
  case "imap-ssl":
173
- $object = &new PostieIMAPSSL();
174
  break;
175
  case "pop3-ssl":
176
- $object = &new PostiePOP3SSL();
177
  break;
178
  default:
179
  die("$protocol not supported");
80
  $this->_server_string = "{" . $server . ":" . $port . $option . "}";
81
  }
82
  DebugEcho("IMAP: connection string - {$this->_server_string}");
83
+ $this->_connection = imap_open($this->_server_string, $login, $password, NULL, 1, array('DISABLE_AUTHENTICATOR' => 'GSSAPI'));
84
 
85
  if ($this->_connection) {
86
  $this->_connected = true;
164
  * @return PostieIMAP|PostieIMAPSSL|PostimePOP3SSL
165
  * @static
166
  */
167
+ static function &Factory($protocol) {
168
  switch (strtolower($protocol)) {
169
  case "imap":
170
+ $object = new PostieIMAP();
171
  break;
172
  case "imap-ssl":
173
+ $object = new PostieIMAPSSL();
174
  break;
175
  case "pop3-ssl":
176
+ $object = new PostiePOP3SSL();
177
  break;
178
  default:
179
  die("$protocol not supported");
postie_test.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  // try to connect to server with different protocols/ and userids
 
3
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
4
- include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . "wp-config.php");
5
  require_once("postie-functions.php");
6
 
7
  $config = config_Read();
1
  <?php
2
  // try to connect to server with different protocols/ and userids
3
+ require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'postie-wp-config.php');
4
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
 
5
  require_once("postie-functions.php");
6
 
7
  $config = config_Read();
readme.txt CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5.1
9
- Stable tag: 1.5.12
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -445,6 +445,14 @@ All script, style and body tags are stripped from html emails.
445
  Attachments are now processed in the order they were attached.
446
 
447
  == CHANGELOG ==
 
 
 
 
 
 
 
 
448
  = 1.5.12 (2013.06.08) =
449
  * Added full paths to includes in config_form due to some hosts having include_path set in a way that breaks Postie.
450
  * Added some checks for emails that aren't correctly formatted (AirMail/WinLink)
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5.1
9
+ Stable tag: 1.5.13
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
445
  Attachments are now processed in the order they were attached.
446
 
447
  == CHANGELOG ==
448
+ = 1.5.13 (2013.06.18) =
449
+ * Added more robust charset conversion to deal with malformed emails.
450
+ * Ensure the default title is used when category etc parsing results in blank title
451
+ * Consolidate procedure for locating wp-config.php
452
+ * Additional debug output.
453
+ * Fixed a bug where the default author was being used even though the email had a valid author.
454
+ * Added feature to disable IMAP authentication with GSSAPI or NTLM to improve MS Exchange compatibility.
455
+
456
  = 1.5.12 (2013.06.08) =
457
  * Added full paths to includes in config_form due to some hosts having include_path set in a way that breaks Postie.
458
  * Added some checks for emails that aren't correctly formatted (AirMail/WinLink)