Postie - Version 1.8.7

Version Description

(2016-10-20) * Make code compatible with PHP 5.2 * Fix bug where the connection tried to use TLS even though it shouldn't * Switch to stream API vs sockets since sockets don't seem to be installed typically and the stream API is core. * Allow self signed certificates with socket connections * Don't check peer name with socket connections, many hosting companies aren't configured correctly

Download this release

Release Info

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

Code changes from version 1.8.6 to 1.8.7

docs/Changes.txt CHANGED
@@ -32,6 +32,14 @@ All script, style and body tags are stripped from html emails.
32
  Attachments are now processed in the order they were attached.
33
 
34
  == CHANGELOG ==
 
 
 
 
 
 
 
 
35
  = 1.8.6 (2016-10-19)
36
  * Fix bug where the featured image was not included even though config said it should be.
37
  * Ensure Socket connections try to connect with TLS 1.0, 1.1 and 1.2 if SSL is specified.
32
  Attachments are now processed in the order they were attached.
33
 
34
  == CHANGELOG ==
35
+ = 1.8.7 (2016-10-20)
36
+ * Make code compatible with PHP 5.2
37
+ * Fix bug where the connection tried to use TLS even though it shouldn't
38
+ * Switch to stream API vs sockets since sockets don't seem to be installed typically and the stream API is core.
39
+ * Allow self signed certificates with socket connections
40
+ * Don't check peer name with socket connections, many hosting companies aren't configured correctly
41
+
42
+
43
  = 1.8.6 (2016-10-19)
44
  * Fix bug where the featured image was not included even though config said it should be.
45
  * Ensure Socket connections try to connect with TLS 1.0, 1.1 and 1.2 if SSL is specified.
docs/Postie.txt CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email, post-by-email
7
  Requires at least: 3.3.0
8
  Tested up to: 4.6.1
9
- Stable tag: 1.8.6
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
6
  Tags: e-mail, email, post-by-email
7
  Requires at least: 3.3.0
8
  Tested up to: 4.6.1
9
+ Stable tag: 1.8.7
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
lib/pCurlConnection.php CHANGED
@@ -82,16 +82,8 @@ class pCurlConnection extends pConnection {
82
  throw new fConnectivityException('Unable to write data to %1$s server %2$s on port %3$s', strtoupper($this->type), $this->host, $this->port);
83
  } else {
84
  $res = explode("\r\n", $verboseLog);
85
-
86
- $res = array_filter($res, function($l) {
87
- return strlen($l) > 1 && substr($l, 0, 2) == '< ';
88
- });
89
-
90
- array_walk($res, function(&$l) {
91
- $l = substr($l, 2);
92
- });
93
- //DebugDump($res);
94
-
95
  $this->buffer = array_merge($this->buffer, $res);
96
  }
97
  curl_close($ch);
@@ -101,6 +93,14 @@ class pCurlConnection extends pConnection {
101
  return $this->read($expected);
102
  }
103
 
 
 
 
 
 
 
 
 
104
  public function read($expect = NULL) {
105
  $response = array();
106
  while (count($this->buffer) > 0) {
82
  throw new fConnectivityException('Unable to write data to %1$s server %2$s on port %3$s', strtoupper($this->type), $this->host, $this->port);
83
  } else {
84
  $res = explode("\r\n", $verboseLog);
85
+ $res = array_filter($res, 'popoutput');
86
+ array_walk($res, 'first2');
 
 
 
 
 
 
 
 
87
  $this->buffer = array_merge($this->buffer, $res);
88
  }
89
  curl_close($ch);
93
  return $this->read($expected);
94
  }
95
 
96
+ function popoutput($l) {
97
+ return strlen($l) > 1 && substr($l, 0, 2) == '< ';
98
+ }
99
+
100
+ function first2(&$l) {
101
+ $l = substr($l, 2);
102
+ }
103
+
104
  public function read($expect = NULL) {
105
  $response = array();
106
  while (count($this->buffer) > 0) {
lib/pSocketConnection.php CHANGED
@@ -26,9 +26,15 @@ class pSocketConnection extends pConnection {
26
  return;
27
  }
28
 
29
- $connstr = $this->secure ? 'tls://' . $this->host : $this->host;
30
- DebugEcho("Socket: $connstr:$this->port");
31
- $this->socket = fsockopen($connstr, $this->port, $error_number, $error_string, $this->timeout);
 
 
 
 
 
 
32
  DebugEcho("Socket error: $error_number - $error_string");
33
 
34
  if (!$this->socket) {
@@ -38,7 +44,7 @@ class pSocketConnection extends pConnection {
38
  stream_set_timeout($this->socket, $this->timeout);
39
 
40
  if ($this->type == 'imap') {
41
- if (!$this->secure && extension_loaded('openssl')) {
42
  $response = $this->write('CAPABILITY');
43
  if (preg_match('#\bstarttls\b#i', $response[0])) {
44
  $this->write('STARTTLS');
@@ -66,7 +72,7 @@ class pSocketConnection extends pConnection {
66
  preg_match('#<[^@]+@[^>]+>#', $response[0], $match);
67
  }
68
 
69
- if (!$this->secure && extension_loaded('openssl')) {
70
  $response = $this->write('STLS', 1);
71
  if ($response[0][0] == '+') {
72
  $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT;
26
  return;
27
  }
28
 
29
+ $connstr = ($this->secure ? 'tls://' : '') . "$this->host:$this->port";
30
+ DebugEcho("Socket: $connstr");
31
+ $error_number = 0;
32
+ $error_string = '';
33
+ $context = stream_context_create();
34
+ stream_context_set_option($context, "ssl", "allow_self_signed", true);
35
+ //stream_context_set_option($context, "ssl", "verify_peer", false);
36
+ stream_context_set_option($context, "ssl", "verify_peer_name", false);
37
+ $this->socket = stream_socket_client($connstr, $error_number, $error_string, $this->timeout, STREAM_CLIENT_CONNECT, $context);
38
  DebugEcho("Socket error: $error_number - $error_string");
39
 
40
  if (!$this->socket) {
44
  stream_set_timeout($this->socket, $this->timeout);
45
 
46
  if ($this->type == 'imap') {
47
+ if ($this->secure && extension_loaded('openssl')) {
48
  $response = $this->write('CAPABILITY');
49
  if (preg_match('#\bstarttls\b#i', $response[0])) {
50
  $this->write('STARTTLS');
72
  preg_match('#<[^@]+@[^>]+>#', $response[0], $match);
73
  }
74
 
75
+ if ($this->secure && extension_loaded('openssl')) {
76
  $response = $this->write('STLS', 1);
77
  if ($response[0][0] == '+') {
78
  $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT;
lib_autolink.php CHANGED
@@ -33,7 +33,7 @@ class PostieAutolink {
33
  while (($cursor < strlen($text)) && $loop) {
34
 
35
  $ok = 1;
36
- $m = [];
37
  $matched = preg_match($sub, $text_l, $m, PREG_OFFSET_CAPTURE, $cursor);
38
 
39
  if (!$matched) {
@@ -110,7 +110,7 @@ class PostieAutolink {
110
  #
111
 
112
  if ($ok) {
113
- $matches = [];
114
  if (preg_match('/^([a-z0-9\-\.\/\-_%~!?=,:;&+*#@\(\)\$]+)/i', $post, $matches)) {
115
 
116
  $url = $hit . $matches[1];
@@ -308,7 +308,7 @@ class PostieAutolink {
308
  #
309
 
310
  if ($ok) {
311
- $matches = [];
312
  if (preg_match("!($atom(\.$atom)*)\$!", $pre, $matches)) {
313
 
314
  # move matched part of address into $hit
33
  while (($cursor < strlen($text)) && $loop) {
34
 
35
  $ok = 1;
36
+ $m = array();
37
  $matched = preg_match($sub, $text_l, $m, PREG_OFFSET_CAPTURE, $cursor);
38
 
39
  if (!$matched) {
110
  #
111
 
112
  if ($ok) {
113
+ $matches = array();
114
  if (preg_match('/^([a-z0-9\-\.\/\-_%~!?=,:;&+*#@\(\)\$]+)/i', $post, $matches)) {
115
 
116
  $url = $hit . $matches[1];
308
  #
309
 
310
  if ($ok) {
311
+ $matches = array();
312
  if (preg_match("!($atom(\.$atom)*)\$!", $pre, $matches)) {
313
 
314
  # move matched part of address into $hit
postie-functions.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /*
3
- $Id: postie-functions.php 1518084 2016-10-19 19:43:15Z WayneAllen $
4
  */
5
 
6
  class PostiePostModifiers {
@@ -202,7 +202,7 @@ function tag_CustomImageField($post_ID, $email, $config) {
202
 
203
  function filter_AttachmentTemplates($content, $mimeDecodedEmail, $post_id, $config) {
204
 
205
- $matches = [];
206
  $addimages = !($config['custom_image_field'] || $config['auto_gallery'] || preg_match("/\[gallery[^\[]*\]/", $content, $matches));
207
  $fiid = -1;
208
 
@@ -730,11 +730,13 @@ function postie_getemails($type, $server, $port, $email, $password, $protocol, $
730
  $emails = array();
731
 
732
  try {
 
733
  if ($connectiontype == 'curl') {
734
  $conn = new pCurlConnection($type, trim($server), $email, $password, $port, ($protocol == 'imap-ssl' || $protocol == 'pop3-ssl'));
735
  } else {
736
  $conn = new pSocketConnection($type, trim($server), $email, $password, $port, ($protocol == 'imap-ssl' || $protocol == 'pop3-ssl'));
737
  }
 
738
  if ($type == 'imap') {
739
  $srv = new pImapMailServer($conn);
740
  } else {
@@ -2078,7 +2080,7 @@ function filter_ReplaceImagePlaceHolders($content, &$email, $config, $post_id, $
2078
  DebugEcho("filter_ReplaceImagePlaceHolders: Found $img_placeholder_temp0");
2079
  $caption = '';
2080
  $img_placeholder_temp = $img_placeholder_temp0;
2081
- $matches = [];
2082
  if (preg_match("/$img_placeholder_temp caption=(.*?)#/i", $content, $matches)) {
2083
  //DebugDump($matches);
2084
  $caption = trim($matches[1]);
1
  <?php
2
  /*
3
+ $Id: postie-functions.php 1518798 2016-10-20 19:13:42Z WayneAllen $
4
  */
5
 
6
  class PostiePostModifiers {
202
 
203
  function filter_AttachmentTemplates($content, $mimeDecodedEmail, $post_id, $config) {
204
 
205
+ $matches = array();
206
  $addimages = !($config['custom_image_field'] || $config['auto_gallery'] || preg_match("/\[gallery[^\[]*\]/", $content, $matches));
207
  $fiid = -1;
208
 
730
  $emails = array();
731
 
732
  try {
733
+ DebugEcho("postie_getemails: procol: $protocol");
734
  if ($connectiontype == 'curl') {
735
  $conn = new pCurlConnection($type, trim($server), $email, $password, $port, ($protocol == 'imap-ssl' || $protocol == 'pop3-ssl'));
736
  } else {
737
  $conn = new pSocketConnection($type, trim($server), $email, $password, $port, ($protocol == 'imap-ssl' || $protocol == 'pop3-ssl'));
738
  }
739
+
740
  if ($type == 'imap') {
741
  $srv = new pImapMailServer($conn);
742
  } else {
2080
  DebugEcho("filter_ReplaceImagePlaceHolders: Found $img_placeholder_temp0");
2081
  $caption = '';
2082
  $img_placeholder_temp = $img_placeholder_temp0;
2083
+ $matches = array();
2084
  if (preg_match("/$img_placeholder_temp caption=(.*?)#/i", $content, $matches)) {
2085
  //DebugDump($matches);
2086
  $caption = trim($matches[1]);
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.8.6
8
  Author: Wayne Allen
9
  Author URI: http://PostiePlugin.com/
10
  License: GPL2
@@ -28,7 +28,7 @@
28
  */
29
 
30
  /*
31
- $Id: postie.php 1518084 2016-10-19 19:43:15Z WayneAllen $
32
  */
33
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib/fException.php");
34
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib/fUnexpectedException.php");
@@ -49,7 +49,7 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib/pPop3MailServer.php"
49
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib_autolink.php");
50
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
51
 
52
- define('POSTIE_VERSION', '1.8.6');
53
  define("POSTIE_ROOT", dirname(__FILE__));
54
  define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
55
 
@@ -239,11 +239,11 @@ function postie_warnings() {
239
  add_action('admin_notices', 'postie_iconv_warning');
240
  }
241
 
242
- if (!fCore::checkVersion('5.3.0')) {
243
 
244
  function postie_php_warning() {
245
  echo "<div id='postie-lst-warning' class='error'><p><strong>";
246
- _e("Warning! Postie requires that PHP be verion 5.3 or higher. You have version " . phpversion(), 'postie');
247
  echo "</strong></p></div>";
248
  }
249
 
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.8.7
8
  Author: Wayne Allen
9
  Author URI: http://PostiePlugin.com/
10
  License: GPL2
28
  */
29
 
30
  /*
31
+ $Id: postie.php 1518809 2016-10-20 19:25:00Z WayneAllen $
32
  */
33
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib/fException.php");
34
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib/fUnexpectedException.php");
49
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib_autolink.php");
50
  require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
51
 
52
+ define('POSTIE_VERSION', '1.8.7');
53
  define("POSTIE_ROOT", dirname(__FILE__));
54
  define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
55
 
239
  add_action('admin_notices', 'postie_iconv_warning');
240
  }
241
 
242
+ if (!fCore::checkVersion('5.2.0')) {
243
 
244
  function postie_php_warning() {
245
  echo "<div id='postie-lst-warning' class='error'><p><strong>";
246
+ _e("Warning! Postie requires that PHP be verion 5.2 or higher. You have version " . phpversion(), 'postie');
247
  echo "</strong></p></div>";
248
  }
249
 
readme.txt CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email, post-by-email
7
  Requires at least: 3.3.0
8
  Tested up to: 4.6.1
9
- Stable tag: 1.8.6
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -240,6 +240,14 @@ All script, style and body tags are stripped from html emails.
240
  Attachments are now processed in the order they were attached.
241
 
242
  == CHANGELOG ==
 
 
 
 
 
 
 
 
243
  = 1.8.6 (2016-10-19)
244
  * Fix bug where the featured image was not included even though config said it should be.
245
  * Ensure Socket connections try to connect with TLS 1.0, 1.1 and 1.2 if SSL is specified.
6
  Tags: e-mail, email, post-by-email
7
  Requires at least: 3.3.0
8
  Tested up to: 4.6.1
9
+ Stable tag: 1.8.7
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
240
  Attachments are now processed in the order they were attached.
241
 
242
  == CHANGELOG ==
243
+ = 1.8.7 (2016-10-20)
244
+ * Make code compatible with PHP 5.2
245
+ * Fix bug where the connection tried to use TLS even though it shouldn't
246
+ * Switch to stream API vs sockets since sockets don't seem to be installed typically and the stream API is core.
247
+ * Allow self signed certificates with socket connections
248
+ * Don't check peer name with socket connections, many hosting companies aren't configured correctly
249
+
250
+
251
  = 1.8.6 (2016-10-19)
252
  * Fix bug where the featured image was not included even though config said it should be.
253
  * Ensure Socket connections try to connect with TLS 1.0, 1.1 and 1.2 if SSL is specified.