Version Description
(2017-04-05) = * Allow user to specify a IMAP folder (supplied by Alejandro Liu) * Fix postie_file_added action * New setting "use time offset" which controls whether or not the postie time offset is applied. * New setting "ignore_email_date" which controls whether or not the email "from" date is used. * Other email to post date improvements * New setting "Notify on Error" to control who gets notified on significant errors. * Email admins on some errors * Fix bug when parsing headers that have multiple encoded sections
Download this release
Release Info
Developer | WayneAllen |
Plugin | Postie |
Version | 1.8.36 |
Comparing to | |
See all releases |
Code changes from version 1.8.35 to 1.8.36
- config_form_server.php +18 -9
- docs/Changes.txt +10 -0
- docs/Postie.txt +1 -1
- lib/fMailbox.php +28 -25
- lib/pConnection.php +16 -0
- lib/pCurlConnection.php +1 -1
- lib/pImapMailServer.php +4 -4
- lib/pSocketConnection.php +1 -1
- postie-functions.php +228 -45
- postie.php +13 -53
- readme.txt +11 -1
config_form_server.php
CHANGED
@@ -54,6 +54,10 @@
|
|
54 |
<input name='postie-settings[mail_password]' type="password" id='postie-settings-mail_password' autocomplete='new-password' value="<?php echo esc_attr($mail_password); ?>" size="40" />
|
55 |
</td>
|
56 |
</tr>
|
|
|
|
|
|
|
|
|
57 |
<tr>
|
58 |
<th scope="row"><?php _e('Postie Time Correction', 'postie') ?></th>
|
59 |
<td><input style="width: 70px;" name='postie-settings[time_offset]' type="number" step="0.5" id='postie-settings-time_offset' size="2" value="<?php echo esc_attr($time_offset); ?>" />
|
@@ -147,11 +151,7 @@
|
|
147 |
</th>
|
148 |
<td>
|
149 |
<select name='postie-settings[maxemails]' id='postie-settings-maxemails'>
|
150 |
-
<option value="0" <?php
|
151 |
-
if ($maxemails == '0') {
|
152 |
-
echo "selected='selected'";
|
153 |
-
}
|
154 |
-
?>><?php _e('All', 'postie'); ?></option>
|
155 |
<option value="1" <?php if ($maxemails == '1') echo "selected='selected'" ?>>1</option>
|
156 |
<option value="2" <?php if ($maxemails == '2') echo "selected='selected'" ?>>2</option>
|
157 |
<option value="5" <?php if ($maxemails == '5') echo "selected='selected'" ?>>5</option>
|
@@ -161,11 +161,20 @@
|
|
161 |
</select>
|
162 |
</td>
|
163 |
</tr>
|
164 |
-
<?php
|
165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
|
167 |
-
|
168 |
-
|
169 |
|
170 |
</table>
|
171 |
</div>
|
54 |
<input name='postie-settings[mail_password]' type="password" id='postie-settings-mail_password' autocomplete='new-password' value="<?php echo esc_attr($mail_password); ?>" size="40" />
|
55 |
</td>
|
56 |
</tr>
|
57 |
+
|
58 |
+
<?php echo BuildBooleanSelect(__("Ignore Email Date", 'postie'), 'postie-settings[ignore_email_date]', $ignore_email_date, __("If set the email date will be ignored and the post will be published with the system time. If cleared the 'From' date in the email will be used as the post date.", 'postie')); ?>
|
59 |
+
<?php echo BuildBooleanSelect(__("Use Postie Time Correction", 'postie'), 'postie-settings[use_time_offset]', $use_time_offset, __("If set adjust the time according to Postie Time Correction otherwise use the date provided by the email.", 'postie')); ?>
|
60 |
+
|
61 |
<tr>
|
62 |
<th scope="row"><?php _e('Postie Time Correction', 'postie') ?></th>
|
63 |
<td><input style="width: 70px;" name='postie-settings[time_offset]' type="number" step="0.5" id='postie-settings-time_offset' size="2" value="<?php echo esc_attr($time_offset); ?>" />
|
151 |
</th>
|
152 |
<td>
|
153 |
<select name='postie-settings[maxemails]' id='postie-settings-maxemails'>
|
154 |
+
<option value="0" <?php if ($maxemails == '0') echo "selected='selected'"; ?>><?php _e('All', 'postie'); ?></option>
|
|
|
|
|
|
|
|
|
155 |
<option value="1" <?php if ($maxemails == '1') echo "selected='selected'" ?>>1</option>
|
156 |
<option value="2" <?php if ($maxemails == '2') echo "selected='selected'" ?>>2</option>
|
157 |
<option value="5" <?php if ($maxemails == '5') echo "selected='selected'" ?>>5</option>
|
161 |
</select>
|
162 |
</td>
|
163 |
</tr>
|
164 |
+
<?php
|
165 |
+
echo BuildBooleanSelect(__("Delete email after posting", 'postie'), 'postie-settings[delete_mail_after_processing]', $delete_mail_after_processing, __("Only set to no for testing purposes", 'postie'));
|
166 |
+
//echo 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'));
|
167 |
+
|
168 |
+
echo BuildBooleanSelect(__("Enable Error Logging", 'postie'), 'postie-settings[postie_log_error]', $postie_log_error, __("Log error messages to the web server error log.", 'postie'));
|
169 |
+
|
170 |
+
$notification_options = array('(Nobody)', '(All Admins)');
|
171 |
+
foreach (get_users(array('role' => 'administrator')) as $user) {
|
172 |
+
$notification_options[] = $user->user_login;
|
173 |
+
}
|
174 |
+
echo BuildSelect(__('Notify on Error', 'postie'), 'postie-settings[postie_log_error_notify]', $postie_log_error_notify, $notification_options);
|
175 |
|
176 |
+
echo BuildBooleanSelect(__("Enable Debug Logging", 'postie'), 'postie-settings[postie_log_debug]', $postie_log_debug, __("Log debug messages to the web server error log.", 'postie'));
|
177 |
+
?>
|
178 |
|
179 |
</table>
|
180 |
</div>
|
docs/Changes.txt
CHANGED
@@ -35,6 +35,16 @@ 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.8.35 (2017-03-21) =
|
39 |
* Check for blank image file extension and replace with mime subtype to get around new filetype checking in WordPress 4.7.2 https://core.trac.wordpress.org/ticket/39550
|
40 |
* Additional logging of message and part headers
|
35 |
Attachments are now processed in the order they were attached.
|
36 |
|
37 |
== CHANGELOG ==
|
38 |
+
= 1.8.36 (2017-04-05) =
|
39 |
+
* Allow user to specify a IMAP folder (supplied by Alejandro Liu)
|
40 |
+
* Fix postie_file_added action
|
41 |
+
* New setting "use time offset" which controls whether or not the postie time offset is applied.
|
42 |
+
* New setting "ignore_email_date" which controls whether or not the email "from" date is used.
|
43 |
+
* Other email to post date improvements
|
44 |
+
* New setting "Notify on Error" to control who gets notified on significant errors.
|
45 |
+
* Email admins on some errors
|
46 |
+
* Fix bug when parsing headers that have multiple encoded sections
|
47 |
+
|
48 |
= 1.8.35 (2017-03-21) =
|
49 |
* Check for blank image file extension and replace with mime subtype to get around new filetype checking in WordPress 4.7.2 https://core.trac.wordpress.org/ticket/39550
|
50 |
* Additional logging of message and part headers
|
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.7.3
|
9 |
-
Stable tag: 1.8.
|
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.7.3
|
9 |
+
Stable tag: 1.8.36
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
lib/fMailbox.php
CHANGED
@@ -100,11 +100,13 @@ class fMailbox {
|
|
100 |
* @return string The decoded UTF-8
|
101 |
*/
|
102 |
static public function decodeHeader($text) {
|
|
|
103 |
$parts = preg_split('#(=\?[^\?]+\?[QB]\?[^\?]+\?=)#i', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
|
104 |
-
|
|
|
105 |
$part_with_encoding = array();
|
106 |
$output = '';
|
107 |
-
$
|
108 |
foreach ($parts as $part) {
|
109 |
if ($part === '') {
|
110 |
continue;
|
@@ -113,7 +115,7 @@ class fMailbox {
|
|
113 |
if (preg_match_all('#=\?([^\?]+)\?([QB])\?([^\?]+)\?=#i', $part, $matches, PREG_SET_ORDER)) {
|
114 |
DebugEcho("decodeHeader: found encoded value: '$part'");
|
115 |
//DebugDump($matches);
|
116 |
-
$
|
117 |
foreach ($matches as $match) {
|
118 |
if (strtoupper($match[2]) == 'Q') {
|
119 |
$part_string = rawurldecode(strtr(
|
@@ -129,37 +131,38 @@ class fMailbox {
|
|
129 |
}
|
130 |
$lower_encoding = strtolower($match[1]);
|
131 |
$last_key = count($part_with_encoding) - 1;
|
132 |
-
|
133 |
-
$part_with_encoding[$last_key]['string'] .= $part_string;
|
134 |
-
} else {
|
135 |
-
$part_with_encoding[] = array('encoding' => $lower_encoding, 'string' => $part_string . ' ');
|
136 |
-
}
|
137 |
}
|
138 |
//DebugDump($part_with_encoding);
|
139 |
} else {
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
}
|
144 |
-
if (!($isencoded && $part == '')) {
|
145 |
$last_key = count($part_with_encoding) - 1;
|
146 |
-
|
147 |
-
$part_with_encoding[$last_key]['string'] .= $part;
|
148 |
-
} else {
|
149 |
-
$part_with_encoding[] = array('encoding' => 'iso-8859-1', 'string' => $part);
|
150 |
-
}
|
151 |
-
} else {
|
152 |
-
//DebugEcho("decodeHeader: skipping whitespace in encoded header");
|
153 |
}
|
154 |
}
|
155 |
}
|
156 |
|
157 |
//DebugEcho("decodeHeader: convert encoding");
|
158 |
-
|
159 |
-
|
160 |
-
$output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
}
|
162 |
-
//DebugEcho("decodeHeader: $output");
|
163 |
|
164 |
return trim($output);
|
165 |
}
|
@@ -536,7 +539,7 @@ class fMailbox {
|
|
536 |
|
537 |
$headers = array();
|
538 |
foreach ($header_lines as $header_line) {
|
539 |
-
|
540 |
$header_line = preg_replace("#\r\n\s+#", ' ', $header_line);
|
541 |
|
542 |
if (false !== strpos($header_line, ':')) {
|
100 |
* @return string The decoded UTF-8
|
101 |
*/
|
102 |
static public function decodeHeader($text) {
|
103 |
+
DebugEcho("decodeHeader: start");
|
104 |
$parts = preg_split('#(=\?[^\?]+\?[QB]\?[^\?]+\?=)#i', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
|
105 |
+
//DebugEcho("decodeHeader: parts");
|
106 |
+
//DebugDump($parts);
|
107 |
$part_with_encoding = array();
|
108 |
$output = '';
|
109 |
+
$islastencoded = false;
|
110 |
foreach ($parts as $part) {
|
111 |
if ($part === '') {
|
112 |
continue;
|
115 |
if (preg_match_all('#=\?([^\?]+)\?([QB])\?([^\?]+)\?=#i', $part, $matches, PREG_SET_ORDER)) {
|
116 |
DebugEcho("decodeHeader: found encoded value: '$part'");
|
117 |
//DebugDump($matches);
|
118 |
+
$islastencoded = true;
|
119 |
foreach ($matches as $match) {
|
120 |
if (strtoupper($match[2]) == 'Q') {
|
121 |
$part_string = rawurldecode(strtr(
|
131 |
}
|
132 |
$lower_encoding = strtolower($match[1]);
|
133 |
$last_key = count($part_with_encoding) - 1;
|
134 |
+
$part_with_encoding[] = array('encoding' => $lower_encoding, 'string' => $part_string, 'encoded' => 1);
|
|
|
|
|
|
|
|
|
135 |
}
|
136 |
//DebugDump($part_with_encoding);
|
137 |
} else {
|
138 |
+
DebugEcho("decodeHeader: found non-encoded value: '$part'");
|
139 |
+
|
140 |
+
if (!($islastencoded && $part == '')) {
|
|
|
|
|
141 |
$last_key = count($part_with_encoding) - 1;
|
142 |
+
$part_with_encoding[] = array('encoding' => 'iso-8859-1', 'string' => $part, 'encoded' => 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
}
|
144 |
}
|
145 |
}
|
146 |
|
147 |
//DebugEcho("decodeHeader: convert encoding");
|
148 |
+
//DebugDump($part_with_encoding);
|
149 |
+
if (count($part_with_encoding) > 0) {
|
150 |
+
$output = self::iconv($part_with_encoding[0]['encoding'], 'UTF-8', $part_with_encoding[0]['string']);
|
151 |
+
$i = 1;
|
152 |
+
while ($i <= count($part_with_encoding) - 1) {
|
153 |
+
if (count($part_with_encoding) - 1 > $i) {
|
154 |
+
$p = trim($part_with_encoding[$i]['string']);
|
155 |
+
if (empty($p) && $part_with_encoding[$i - 1]['encoded'] == 1 && $part_with_encoding[$i + 1]['encoded'] == 1) {
|
156 |
+
//noop
|
157 |
+
} else {
|
158 |
+
$output .= self::iconv($part_with_encoding[$i]['encoding'], 'UTF-8', $part_with_encoding[$i]['string']);
|
159 |
+
}
|
160 |
+
} else {
|
161 |
+
$output .= self::iconv($part_with_encoding[$i]['encoding'], 'UTF-8', $part_with_encoding[$i]['string']);
|
162 |
+
}
|
163 |
+
$i++;
|
164 |
+
}
|
165 |
}
|
|
|
166 |
|
167 |
return trim($output);
|
168 |
}
|
539 |
|
540 |
$headers = array();
|
541 |
foreach ($header_lines as $header_line) {
|
542 |
+
DebugEcho("headerline: $header_line");
|
543 |
$header_line = preg_replace("#\r\n\s+#", ' ', $header_line);
|
544 |
|
545 |
if (false !== strpos($header_line, ':')) {
|
lib/pConnection.php
CHANGED
@@ -8,6 +8,7 @@ abstract class pConnection {
|
|
8 |
protected $port;
|
9 |
protected $secure;
|
10 |
protected $timeout;
|
|
|
11 |
|
12 |
public function __construct($type, $host, $username, $password, $port, $secure = FALSE, $timeout = NULL) {
|
13 |
|
@@ -27,6 +28,16 @@ abstract class pConnection {
|
|
27 |
$this->type = $type;
|
28 |
$this->host = $host;
|
29 |
$this->username = $username;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
$this->password = $password;
|
31 |
$this->port = $port;
|
32 |
$this->secure = $secure;
|
@@ -42,4 +53,9 @@ abstract class pConnection {
|
|
42 |
abstract function open();
|
43 |
|
44 |
abstract function isPersistant();
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
8 |
protected $port;
|
9 |
protected $secure;
|
10 |
protected $timeout;
|
11 |
+
protected $mailbox;
|
12 |
|
13 |
public function __construct($type, $host, $username, $password, $port, $secure = FALSE, $timeout = NULL) {
|
14 |
|
28 |
$this->type = $type;
|
29 |
$this->host = $host;
|
30 |
$this->username = $username;
|
31 |
+
if (($i = strpos($username, '/')) !== false) {
|
32 |
+
$this->username = substr($username, 0, $i);
|
33 |
+
$this->mailbox = substr($username, $i + 1);
|
34 |
+
} else {
|
35 |
+
$this->username = $username;
|
36 |
+
$this->mailbox = 'INBOX';
|
37 |
+
}
|
38 |
+
//DebugEcho('USERNAME: ' . $this->username);
|
39 |
+
DebugEcho('pConnection: mailbox: ' . $this->mailbox);
|
40 |
+
|
41 |
$this->password = $password;
|
42 |
$this->port = $port;
|
43 |
$this->secure = $secure;
|
53 |
abstract function open();
|
54 |
|
55 |
abstract function isPersistant();
|
56 |
+
|
57 |
+
public function getMailbox() {
|
58 |
+
return $this->mailbox;
|
59 |
+
}
|
60 |
+
|
61 |
}
|
lib/pCurlConnection.php
CHANGED
@@ -27,7 +27,7 @@ class pCurlConnection extends pConnection {
|
|
27 |
return;
|
28 |
}
|
29 |
|
30 |
-
$suffix = '/
|
31 |
}
|
32 |
|
33 |
$url = ($this->type == 'imap' ? 'imap' : 'pop3') . ($this->secure ? 's' : '') . '://' . $this->host . $suffix;
|
27 |
return;
|
28 |
}
|
29 |
|
30 |
+
$suffix = '/' . $this->mailbox;
|
31 |
}
|
32 |
|
33 |
$url = ($this->type == 'imap' ? 'imap' : 'pop3') . ($this->secure ? 's' : '') . '://' . $this->host . $suffix;
|
lib/pImapMailServer.php
CHANGED
@@ -59,9 +59,9 @@ class pImapMailServer extends pMailServer {
|
|
59 |
function countMessages() {
|
60 |
$total_messages = 0;
|
61 |
|
62 |
-
$response = $this->connection->write('STATUS "
|
63 |
foreach ($response as $line) {
|
64 |
-
if (preg_match('#^\s*\*\s+STATUS\s+"?
|
65 |
$details = $this->parseResponse($match[1], TRUE);
|
66 |
$total_messages = $details['messages'];
|
67 |
}
|
@@ -122,9 +122,9 @@ class pImapMailServer extends pMailServer {
|
|
122 |
}
|
123 |
|
124 |
$total_messages = 0;
|
125 |
-
$response = $this->connection->write('STATUS "
|
126 |
foreach ($response as $line) {
|
127 |
-
if (preg_match('#^\s*\*\s+STATUS\s+"?
|
128 |
$details = self::parseResponse($match[1], TRUE);
|
129 |
$total_messages = $details['messages'];
|
130 |
}
|
59 |
function countMessages() {
|
60 |
$total_messages = 0;
|
61 |
|
62 |
+
$response = $this->connection->write('STATUS "' . $this->connection->getMailbox() . '" (MESSAGES)');
|
63 |
foreach ($response as $line) {
|
64 |
+
if (preg_match('#^\s*\*\s+STATUS\s+"?[^"]+"?\s+\((.*)\)\s*$#', $line, $match)) {
|
65 |
$details = $this->parseResponse($match[1], TRUE);
|
66 |
$total_messages = $details['messages'];
|
67 |
}
|
122 |
}
|
123 |
|
124 |
$total_messages = 0;
|
125 |
+
$response = $this->connection->write('STATUS "' . $this->connection->getMailbox() . '" (MESSAGES)');
|
126 |
foreach ($response as $line) {
|
127 |
+
if (preg_match('#^\s*\*\s+STATUS\s+"?[^"]+"?\s+\((.*)\)\s*$#', $line, $match)) {
|
128 |
$details = self::parseResponse($match[1], TRUE);
|
129 |
$total_messages = $details['messages'];
|
130 |
}
|
lib/pSocketConnection.php
CHANGED
@@ -60,7 +60,7 @@ class pSocketConnection extends pConnection {
|
|
60 |
if (!$response || !preg_match('#^[^ ]+\s+OK#', $response[count($response) - 1])) {
|
61 |
throw new fValidationException('The username and password provided were not accepted for the %1$s server %2$s on port %3$s', strtoupper($this->type), $this->host, $this->port);
|
62 |
}
|
63 |
-
$this->write('SELECT "
|
64 |
} elseif ($this->type == 'pop3') {
|
65 |
$response = $this->read(1);
|
66 |
if (isset($response[0])) {
|
60 |
if (!$response || !preg_match('#^[^ ]+\s+OK#', $response[count($response) - 1])) {
|
61 |
throw new fValidationException('The username and password provided were not accepted for the %1$s server %2$s on port %3$s', strtoupper($this->type), $this->host, $this->port);
|
62 |
}
|
63 |
+
$this->write('SELECT "' . $this->mailbox . '"');
|
64 |
} elseif ($this->type == 'pop3') {
|
65 |
$response = $this->read(1);
|
66 |
if (isset($response[0])) {
|
postie-functions.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
$Id: postie-functions.php
|
4 |
*/
|
5 |
|
6 |
class PostiePostModifiers {
|
@@ -58,19 +58,51 @@ if (!function_exists('mb_str_replace')) {
|
|
58 |
}
|
59 |
|
60 |
function postie_environment($force_display = false) {
|
61 |
-
DebugEcho("Postie Version: " . POSTIE_VERSION, $force_display);
|
62 |
-
DebugEcho("Wordpress Version: " . get_bloginfo('version'), $force_display);
|
63 |
-
DebugEcho("PHP Version: " . phpversion(), $force_display);
|
64 |
DebugEcho("OS: " . php_uname(), $force_display);
|
65 |
-
DebugEcho("
|
66 |
-
DebugEcho("
|
67 |
-
DebugEcho("
|
68 |
-
DebugEcho("
|
69 |
-
|
70 |
if (function_exists('curl_version')) {
|
71 |
$cv = curl_version();
|
72 |
-
DebugEcho("cURL version: " . $cv['version'], $force_display);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
if (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
|
75 |
DebugEcho("Alternate cron is enabled", $force_display);
|
76 |
}
|
@@ -79,12 +111,31 @@ function postie_environment($force_display = false) {
|
|
79 |
DebugEcho("WordPress cron is disabled. Postie will not run unless you have an external cron set up.", $force_display);
|
80 |
}
|
81 |
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
-
if (defined('WP_CRON_LOCK_TIMEOUT')
|
86 |
-
DebugEcho("
|
87 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
}
|
89 |
|
90 |
function postie_disable_revisions($restore = false) {
|
@@ -344,14 +395,19 @@ function postie_create_post($poster, $mimeDecodedEmail, $post_id, &$is_reply, $c
|
|
344 |
$message_date = NULL;
|
345 |
if (array_key_exists("date", $mimeDecodedEmail['headers']) && !empty($mimeDecodedEmail['headers']['date'])) {
|
346 |
DebugEcho("date header: {$mimeDecodedEmail['headers']['date']}");
|
347 |
-
|
348 |
-
|
|
|
|
|
|
|
|
|
|
|
349 |
} else {
|
350 |
DebugEcho("date header missing");
|
351 |
}
|
352 |
$message_date = tag_Date($content, $message_date, 'html' == $config['prefer_text_type']);
|
353 |
|
354 |
-
list($post_date, $
|
355 |
if ($fulldebug) {
|
356 |
DebugEcho("post date: $content");
|
357 |
}
|
@@ -491,7 +547,7 @@ function postie_create_post($poster, $mimeDecodedEmail, $post_id, &$is_reply, $c
|
|
491 |
'user_ID' => $postAuthorDetails['user_ID'],
|
492 |
'email_author' => $postAuthorDetails['email'],
|
493 |
'post_date' => $post_date,
|
494 |
-
|
495 |
'post_content' => $content,
|
496 |
'post_title' => $subject,
|
497 |
'post_type' => $post_type, /* Added by Raam Dev <raam@raamdev.com> */
|
@@ -563,6 +619,7 @@ function PostEmail($poster, $mimeDecodedEmail, $config) {
|
|
563 |
EchoError("PostEmail wp_insert_post failed: " . $post_id->get_error_message());
|
564 |
DebugDump($post_id->get_error_messages());
|
565 |
DebugDump($post_id->get_error_data());
|
|
|
566 |
}
|
567 |
postie_disable_revisions(true);
|
568 |
DebugEcho("Done");
|
@@ -609,7 +666,6 @@ function tag_PostType(&$subject, $postmodifiers, $config) {
|
|
609 |
|
610 |
function filter_Linkify($text) {
|
611 |
DebugEcho("begin: filter_linkify");
|
612 |
-
require_once( ABSPATH . WPINC . '/class-oembed.php' );
|
613 |
$oe = _wp_oembed_get_object();
|
614 |
|
615 |
$al = new PostieAutolink();
|
@@ -779,12 +835,33 @@ function postie_getemails($type, $server, $port, $email, $password, $protocol, $
|
|
779 |
DebugEcho("postie_getemails: closing connection");
|
780 |
$mailbox->close();
|
781 |
} catch (Exception $e) {
|
782 |
-
EchoError($e->getMessage());
|
|
|
783 |
}
|
784 |
|
785 |
return $emails;
|
786 |
}
|
787 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
788 |
/**
|
789 |
* This function handles putting the actual entry into the database
|
790 |
*/
|
@@ -797,6 +874,9 @@ function postie_save_post($details, $isReply, $customImageField, $postmodifiers)
|
|
797 |
DebugDump($post_ID->get_error_messages());
|
798 |
DebugDump($post_ID->get_error_data());
|
799 |
wp_delete_post($details['ID']);
|
|
|
|
|
|
|
800 |
$post_ID = null;
|
801 |
}
|
802 |
} else {
|
@@ -844,6 +924,7 @@ function isBannedFileName($filename, $bannedFiles) {
|
|
844 |
foreach ($bannedFiles as $bannedFile) {
|
845 |
if (fnmatch($bannedFile, $filename)) {
|
846 |
EchoError("Ignoring attachment: $filename - it is on the banned files list.");
|
|
|
847 |
return true;
|
848 |
}
|
849 |
}
|
@@ -1034,6 +1115,7 @@ function postie_save_attachment(&$attachment, $post_id, $poster, $config) {
|
|
1034 |
DebugEcho("postie_save_attachment: text attachment: adding '$filename'");
|
1035 |
} else {
|
1036 |
EchoError($file_id->get_error_message());
|
|
|
1037 |
}
|
1038 |
|
1039 |
break;
|
@@ -1050,6 +1132,7 @@ function postie_save_attachment(&$attachment, $post_id, $poster, $config) {
|
|
1050 |
}
|
1051 |
} else {
|
1052 |
EchoError("postie_save_attachment image error: " . $file_id->get_error_message());
|
|
|
1053 |
}
|
1054 |
break;
|
1055 |
|
@@ -1060,6 +1143,7 @@ function postie_save_attachment(&$attachment, $post_id, $poster, $config) {
|
|
1060 |
$attachment['wp_id'] = $file_id;
|
1061 |
} else {
|
1062 |
EchoError("postie_save_attachment audio error: " . $file_id->get_error_message());
|
|
|
1063 |
}
|
1064 |
break;
|
1065 |
|
@@ -1069,7 +1153,8 @@ function postie_save_attachment(&$attachment, $post_id, $poster, $config) {
|
|
1069 |
if (!is_wp_error($file_id)) {
|
1070 |
$attachment['wp_id'] = $file_id;
|
1071 |
} else {
|
1072 |
-
EchoError($file_id->get_error_message());
|
|
|
1073 |
}
|
1074 |
break;
|
1075 |
|
@@ -1087,12 +1172,14 @@ function postie_save_attachment(&$attachment, $post_id, $poster, $config) {
|
|
1087 |
$file = wp_get_attachment_url($file_id);
|
1088 |
DebugEcho("postie_save_attachment: uploaded $file_id ($file)");
|
1089 |
} else {
|
1090 |
-
EchoError($file_id->get_error_message());
|
|
|
1091 |
}
|
1092 |
} else {
|
1093 |
EchoError("$filename has an unsupported MIME type $mimetype_primary and was not added.");
|
1094 |
DebugEcho("postie_save_attachment: Not in supported filetype list: '$mimetype_primary'");
|
1095 |
DebugDump($config['supported_file_types']);
|
|
|
1096 |
}
|
1097 |
break;
|
1098 |
}
|
@@ -1304,7 +1391,7 @@ function filter_RemoveSignatureWorker(&$html, $pattern) {
|
|
1304 |
DebugEcho("filter_RemoveSignatureWorker sig new text:\n$presig");
|
1305 |
$html->innertext = $presig;
|
1306 |
} else {
|
1307 |
-
DebugEcho("filter_RemoveSignatureWorker: no matches
|
1308 |
//DebugDump($matches);
|
1309 |
}
|
1310 |
|
@@ -1444,7 +1531,23 @@ function tag_Delay(&$content, $message_date = NULL, $offset = 0) {
|
|
1444 |
$minutes = $minuteMatches[1];
|
1445 |
}
|
1446 |
$delay = (($days * 24 + $hours) * 60 + $minutes) * 60;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1447 |
DebugEcho("tag_Delay: calculated delay: $delay");
|
|
|
1448 |
$content = preg_replace("/delay:$matches[1]/i", "", $content);
|
1449 |
}
|
1450 |
|
@@ -1455,21 +1558,41 @@ function tag_Delay(&$content, $message_date = NULL, $offset = 0) {
|
|
1455 |
DebugEcho("tag_Delay: timezone: $tzs");
|
1456 |
|
1457 |
if (empty($message_date)) {
|
1458 |
-
$dateInSeconds = current_time('
|
1459 |
-
DebugEcho("tag_Delay: using current date: " .
|
1460 |
} else {
|
1461 |
-
DebugEcho("tag_Delay: using message date: $message_date");
|
1462 |
-
$dateInSeconds =
|
|
|
1463 |
}
|
1464 |
-
$delayeddateInSeconds = $dateInSeconds + $delay;
|
1465 |
|
1466 |
-
|
1467 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1468 |
DebugEcho("tag_Delay: delay: $delay");
|
1469 |
-
DebugEcho("tag_Delay:
|
1470 |
-
DebugEcho("tag_Delay: delayed
|
|
|
1471 |
|
1472 |
-
return array($corrected_date, $
|
1473 |
}
|
1474 |
|
1475 |
/**
|
@@ -1505,11 +1628,14 @@ function postie_media_handle_upload($attachment, $post_id) {
|
|
1505 |
if ($fp) {
|
1506 |
fwrite($fp, $attachment['data']);
|
1507 |
fclose($fp);
|
|
|
1508 |
} else {
|
1509 |
EchoError("postie_media_handle_upload: Could not write to temp file: '$tmpFile' ");
|
|
|
1510 |
}
|
1511 |
} else {
|
1512 |
EchoError("postie_media_handle_upload: Could not create temp file in " . get_temp_dir());
|
|
|
1513 |
}
|
1514 |
|
1515 |
$file_array = array(
|
@@ -1522,17 +1648,17 @@ function postie_media_handle_upload($attachment, $post_id) {
|
|
1522 |
DebugEcho("postie_media_handle_upload: adding " . $file_array['name']);
|
1523 |
DebugDump($file_array);
|
1524 |
|
1525 |
-
require_once(ABSPATH . 'wp-admin/includes/file.php');
|
1526 |
-
require_once(ABSPATH . 'wp-admin/includes/image.php');
|
1527 |
-
require_once(ABSPATH . 'wp-admin/includes/media.php');
|
1528 |
$id = media_handle_sideload($file_array, $post_id);
|
1529 |
|
1530 |
if (!is_wp_error($id)) {
|
1531 |
-
|
|
|
|
|
1532 |
} else {
|
1533 |
EchoError("There was an error adding the attachement: " . $id->get_error_message());
|
1534 |
DebugDump($id->get_error_messages());
|
1535 |
DebugDump($id->get_error_data());
|
|
|
1536 |
}
|
1537 |
|
1538 |
return $id;
|
@@ -1582,7 +1708,6 @@ function postie_header_encode($value) {
|
|
1582 |
}
|
1583 |
|
1584 |
function postie_email_reject($email, $recipients, $returnToSender) {
|
1585 |
-
require_once(ABSPATH . 'wp-admin/includes/file.php'); //wp_tempnam()
|
1586 |
DebugEcho("postie_email_reject: start");
|
1587 |
|
1588 |
if (count($recipients) == 0) {
|
@@ -2049,6 +2174,7 @@ function tag_Excerpt(&$content, $config) {
|
|
2049 |
* @return array
|
2050 |
*/
|
2051 |
function tag_Categories(&$subject, $defaultCategoryId, $config, $post_id) {
|
|
|
2052 |
$category_match = $config['category_match'];
|
2053 |
$original_subject = $subject;
|
2054 |
$found = false;
|
@@ -2101,6 +2227,7 @@ function tag_Categories(&$subject, $defaultCategoryId, $config, $post_id) {
|
|
2101 |
DebugEcho("tag_Categories: subject: $subject");
|
2102 |
$tax = postie_lookup_taxonomy_name($categoryid);
|
2103 |
if ('category' == $tax) {
|
|
|
2104 |
$post_categories[] = $categoryid;
|
2105 |
} else {
|
2106 |
DebugEcho("tag_Categories: custom taxonomy $tax");
|
@@ -2397,7 +2524,10 @@ function config_GetDefaults() {
|
|
2397 |
'category_dash' => true,
|
2398 |
'category_bracket' => true,
|
2399 |
'prefer_text_convert' => true,
|
2400 |
-
'category_remove' => true
|
|
|
|
|
|
|
2401 |
);
|
2402 |
}
|
2403 |
|
@@ -2859,7 +2989,8 @@ function postie_test_config() {
|
|
2859 |
DebugEcho("Current time: " . current_time('mysql'), true);
|
2860 |
DebugEcho("Current time (gmt): " . current_time('mysql', 1), true);
|
2861 |
DebugEcho("Postie time correction: {$config['time_offset']}", true);
|
2862 |
-
$offsetdate = strtotime(current_time('mysql')) + $config['time_offset'];
|
|
|
2863 |
DebugEcho("Post time: " . date('Y-m-d H:i:s', $offsetdate), true);
|
2864 |
?>
|
2865 |
<h2>Encoding</h2>
|
@@ -2981,10 +3112,6 @@ function postie_get_conn_info($config) {
|
|
2981 |
}
|
2982 |
|
2983 |
function postie_get_mail() {
|
2984 |
-
if (!function_exists('file_get_html')) {
|
2985 |
-
require_once (plugin_dir_path(__FILE__) . 'simple_html_dom.php');
|
2986 |
-
}
|
2987 |
-
|
2988 |
$config = config_Read();
|
2989 |
if (true == $config['postie_log_error'] || (defined('POSTIE_DEBUG') && true == POSTIE_DEBUG)) {
|
2990 |
add_action('postie_log_error', 'postie_log_error');
|
@@ -2996,11 +3123,13 @@ function postie_get_mail() {
|
|
2996 |
add_action('postie_log_debug', 'postie_log_debug');
|
2997 |
}
|
2998 |
|
2999 |
-
do_action('postie_session_start');
|
3000 |
DebugEcho('Starting mail fetch');
|
3001 |
DebugEcho('WordPress datetime: ' . current_time('mysql'));
|
3002 |
|
|
|
|
|
3003 |
postie_environment();
|
|
|
3004 |
$wp_content_path = dirname(dirname(dirname(__FILE__)));
|
3005 |
DebugEcho("wp_content_path: $wp_content_path");
|
3006 |
if (file_exists($wp_content_path . DIRECTORY_SEPARATOR . 'filterPostie.php')) {
|
@@ -3079,3 +3208,57 @@ function postie_get_mail() {
|
|
3079 |
DebugEcho('memory at end of email processing: ' . memory_get_usage());
|
3080 |
}
|
3081 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
/*
|
3 |
+
$Id: postie-functions.php 1630360 2017-04-05 16:03:31Z WayneAllen $
|
4 |
*/
|
5 |
|
6 |
class PostiePostModifiers {
|
58 |
}
|
59 |
|
60 |
function postie_environment($force_display = false) {
|
|
|
|
|
|
|
61 |
DebugEcho("OS: " . php_uname(), $force_display);
|
62 |
+
DebugEcho("PHP Version: " . phpversion(), $force_display);
|
63 |
+
DebugEcho("PHP error_log: " . ini_get('error_log'), $force_display);
|
64 |
+
DebugEcho("PHP log_errors: " . (ini_get('log_errors') ? 'On' : 'Off'), $force_display);
|
65 |
+
DebugEcho("PHP get_temp_dir: " . get_temp_dir(), $force_display);
|
|
|
66 |
if (function_exists('curl_version')) {
|
67 |
$cv = curl_version();
|
68 |
+
DebugEcho("PHP cURL version: " . $cv['version'], $force_display);
|
69 |
+
}
|
70 |
+
|
71 |
+
DebugEcho("WordPress Version: " . get_bloginfo('version'), $force_display);
|
72 |
+
if (defined('MULTISITE') && MULTISITE) {
|
73 |
+
DebugEcho("WordPress Multisite", $force_display);
|
74 |
+
DebugEcho("network_home_url(): " . network_home_url(), $force_display);
|
75 |
+
} else {
|
76 |
+
DebugEcho("WordPress Singlesite", $force_display);
|
77 |
+
}
|
78 |
+
DebugEcho("WP_TEMP_DIR: " . (defined('WP_TEMP_DIR') ? WP_TEMP_DIR : '(none)'), $force_display);
|
79 |
+
DebugEcho("WP_HOME: " . (defined('WP_HOME') ? WP_HOME : '(none)'), $force_display);
|
80 |
+
DebugEcho("home_url(): " . home_url(), $force_display);
|
81 |
+
DebugEcho("WP_SITEURL: " . (defined('WP_SITEURL') ? WP_SITEURL : '(none)'), $force_display);
|
82 |
+
DebugEcho("site_url(): " . site_url(), $force_display);
|
83 |
+
|
84 |
+
if (defined('WP_DEBUG')) {
|
85 |
+
DebugEcho("WP_DEBUG: " . (WP_DEBUG === true ? 'On' : 'Off'), $force_display);
|
86 |
+
} else {
|
87 |
+
DebugEcho("WP_DEBUG: Off", $force_display);
|
88 |
}
|
89 |
+
|
90 |
+
if (defined('WP_DEBUG_DISPLAY')) {
|
91 |
+
if (null == WP_DEBUG_DISPLAY) {
|
92 |
+
DebugEcho("WP_DEBUG_DISPLAY: null", $force_display);
|
93 |
+
} else {
|
94 |
+
DebugEcho("WP_DEBUG_DISPLAY: " . (WP_DEBUG_DISPLAY === true ? 'On' : 'Off'), $force_display);
|
95 |
+
}
|
96 |
+
} else {
|
97 |
+
DebugEcho("WP_DEBUG_DISPLAY: Off", $force_display);
|
98 |
+
}
|
99 |
+
|
100 |
+
if (defined('WP_DEBUG_LOG')) {
|
101 |
+
DebugEcho("WP_DEBUG_LOG: " . (WP_DEBUG_LOG === true ? 'On' : 'Off'), $force_display);
|
102 |
+
} else {
|
103 |
+
DebugEcho("WP_DEBUG_LOG: Off", $force_display);
|
104 |
+
}
|
105 |
+
|
106 |
if (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
|
107 |
DebugEcho("Alternate cron is enabled", $force_display);
|
108 |
}
|
111 |
DebugEcho("WordPress cron is disabled. Postie will not run unless you have an external cron set up.", $force_display);
|
112 |
}
|
113 |
|
114 |
+
if (defined('WP_MAX_MEMORY_LIMIT ')) {
|
115 |
+
DebugEcho("WP_MAX_MEMORY_LIMIT: " . WP_MAX_MEMORY_LIMIT, $force_display);
|
116 |
+
} else {
|
117 |
+
DebugEcho("WP_MAX_MEMORY_LIMIT: 256M (default)", $force_display);
|
118 |
+
}
|
119 |
+
|
120 |
+
if (defined('WP_MEMORY_LIMIT')) {
|
121 |
+
DebugEcho("WP_MEMORY_LIMIT: " . WP_MEMORY_LIMIT, $force_display);
|
122 |
+
} else {
|
123 |
+
DebugEcho("WP_MEMORY_LIMIT: 32M (default)", $force_display);
|
124 |
+
}
|
125 |
+
|
126 |
+
DebugEcho("DISABLE_WP_CRON: " . (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON === true ? 'On' : 'Off'), $force_display);
|
127 |
+
DebugEcho("ALTERNATE_WP_CRON: " . (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON === true ? 'On' : 'Off'), $force_display);
|
128 |
|
129 |
+
if (defined('WP_CRON_LOCK_TIMEOUT')) {
|
130 |
+
DebugEcho("WP_CRON_LOCK_TIMEOUT: " . WP_CRON_LOCK_TIMEOUT, $force_display);
|
131 |
}
|
132 |
+
|
133 |
+
DebugEcho('Active plugins', $force_display);
|
134 |
+
DebugDump(get_option('active_plugins'));
|
135 |
+
|
136 |
+
DebugEcho("Postie is in " . plugin_dir_path(__FILE__), $force_display);
|
137 |
+
DebugEcho("Postie Version: " . POSTIE_VERSION, $force_display);
|
138 |
+
DebugEcho("POSTIE_DEBUG: " . (IsDebugMode() ? 'On' : 'Off'), $force_display);
|
139 |
}
|
140 |
|
141 |
function postie_disable_revisions($restore = false) {
|
395 |
$message_date = NULL;
|
396 |
if (array_key_exists("date", $mimeDecodedEmail['headers']) && !empty($mimeDecodedEmail['headers']['date'])) {
|
397 |
DebugEcho("date header: {$mimeDecodedEmail['headers']['date']}");
|
398 |
+
if ($config['ignore_email_date']) {
|
399 |
+
$message_date = current_time('mysql');
|
400 |
+
DebugEcho("system date: $message_date");
|
401 |
+
} else {
|
402 |
+
$message_date = $mimeDecodedEmail['headers']['date'];
|
403 |
+
DebugEcho("decoded date: $message_date");
|
404 |
+
}
|
405 |
} else {
|
406 |
DebugEcho("date header missing");
|
407 |
}
|
408 |
$message_date = tag_Date($content, $message_date, 'html' == $config['prefer_text_type']);
|
409 |
|
410 |
+
list($post_date, $delay) = tag_Delay($content, $message_date, (!$config['ignore_email_date'] && $config['use_time_offset']) ? $config['time_offset'] : 0);
|
411 |
if ($fulldebug) {
|
412 |
DebugEcho("post date: $content");
|
413 |
}
|
547 |
'user_ID' => $postAuthorDetails['user_ID'],
|
548 |
'email_author' => $postAuthorDetails['email'],
|
549 |
'post_date' => $post_date,
|
550 |
+
'post_date_gmt' => get_gmt_from_date($post_date),
|
551 |
'post_content' => $content,
|
552 |
'post_title' => $subject,
|
553 |
'post_type' => $post_type, /* Added by Raam Dev <raam@raamdev.com> */
|
619 |
EchoError("PostEmail wp_insert_post failed: " . $post_id->get_error_message());
|
620 |
DebugDump($post_id->get_error_messages());
|
621 |
DebugDump($post_id->get_error_data());
|
622 |
+
postie_notify_error("PostEmail wp_insert_post failed creating placeholder", $post_id->get_error_message());
|
623 |
}
|
624 |
postie_disable_revisions(true);
|
625 |
DebugEcho("Done");
|
666 |
|
667 |
function filter_Linkify($text) {
|
668 |
DebugEcho("begin: filter_linkify");
|
|
|
669 |
$oe = _wp_oembed_get_object();
|
670 |
|
671 |
$al = new PostieAutolink();
|
835 |
DebugEcho("postie_getemails: closing connection");
|
836 |
$mailbox->close();
|
837 |
} catch (Exception $e) {
|
838 |
+
EchoError("postie_getemails: " . $e->getMessage());
|
839 |
+
postie_notify_error("Error: postie_getemails", $e->getMessage());
|
840 |
}
|
841 |
|
842 |
return $emails;
|
843 |
}
|
844 |
|
845 |
+
function postie_notify_error($subject, $message) {
|
846 |
+
$recipients = array();
|
847 |
+
$config = config_Read();
|
848 |
+
if ($config['postie_log_error_notify'] == '(Nobody)') {
|
849 |
+
return;
|
850 |
+
}
|
851 |
+
if ($config['postie_log_error_notify'] == '(All Admins)') {
|
852 |
+
foreach (get_users(array('role' => 'administrator')) as $user) {
|
853 |
+
$recipients[] = $user->user_email;
|
854 |
+
}
|
855 |
+
} else {
|
856 |
+
$user = get_user_by('login', $config['postie_log_error_notify']);
|
857 |
+
if ($user === false) {
|
858 |
+
return;
|
859 |
+
}
|
860 |
+
$recipients[] = $user->user_login;
|
861 |
+
}
|
862 |
+
wp_mail($recipients, $subject, $message);
|
863 |
+
}
|
864 |
+
|
865 |
/**
|
866 |
* This function handles putting the actual entry into the database
|
867 |
*/
|
874 |
DebugDump($post_ID->get_error_messages());
|
875 |
DebugDump($post_ID->get_error_data());
|
876 |
wp_delete_post($details['ID']);
|
877 |
+
|
878 |
+
postie_notify_error("Failed to create {$details['post_type']}: {$details['post_title']}", "Error: " . $post_ID->get_error_message() . "\n\n" . $details['post_content']);
|
879 |
+
|
880 |
$post_ID = null;
|
881 |
}
|
882 |
} else {
|
924 |
foreach ($bannedFiles as $bannedFile) {
|
925 |
if (fnmatch($bannedFile, $filename)) {
|
926 |
EchoError("Ignoring attachment: $filename - it is on the banned files list.");
|
927 |
+
postie_notify_error("Ignoring attachment: $filename - it is on the banned files list.", "Ignoring attachment: $filename - it is on the banned files list.");
|
928 |
return true;
|
929 |
}
|
930 |
}
|
1115 |
DebugEcho("postie_save_attachment: text attachment: adding '$filename'");
|
1116 |
} else {
|
1117 |
EchoError($file_id->get_error_message());
|
1118 |
+
postie_notify_error("Failed to add text media file: $filename", $file_id->get_error_message());
|
1119 |
}
|
1120 |
|
1121 |
break;
|
1132 |
}
|
1133 |
} else {
|
1134 |
EchoError("postie_save_attachment image error: " . $file_id->get_error_message());
|
1135 |
+
postie_notify_error("Failed to add image media file: $filename", $file_id->get_error_message());
|
1136 |
}
|
1137 |
break;
|
1138 |
|
1143 |
$attachment['wp_id'] = $file_id;
|
1144 |
} else {
|
1145 |
EchoError("postie_save_attachment audio error: " . $file_id->get_error_message());
|
1146 |
+
postie_notify_error("Failed to add audio media file: $filename", $file_id->get_error_message());
|
1147 |
}
|
1148 |
break;
|
1149 |
|
1153 |
if (!is_wp_error($file_id)) {
|
1154 |
$attachment['wp_id'] = $file_id;
|
1155 |
} else {
|
1156 |
+
EchoError("postie_save_attachment video error: " . $file_id->get_error_message());
|
1157 |
+
postie_notify_error("Failed to add video file: $filename", $file_id->get_error_message());
|
1158 |
}
|
1159 |
break;
|
1160 |
|
1172 |
$file = wp_get_attachment_url($file_id);
|
1173 |
DebugEcho("postie_save_attachment: uploaded $file_id ($file)");
|
1174 |
} else {
|
1175 |
+
EchoError("postie_save_attachment file error: " . $file_id->get_error_message());
|
1176 |
+
postie_notify_error("Failed to add media file: $filename", $file_id->get_error_message());
|
1177 |
}
|
1178 |
} else {
|
1179 |
EchoError("$filename has an unsupported MIME type $mimetype_primary and was not added.");
|
1180 |
DebugEcho("postie_save_attachment: Not in supported filetype list: '$mimetype_primary'");
|
1181 |
DebugDump($config['supported_file_types']);
|
1182 |
+
postie_notify_error("Unsupported MIME type: $mimetype_primary", "$filename has an unsupported MIME type $mimetype_primary and was not added.\nSupported types:\n" . print_r($config['supported_file_types'], true));
|
1183 |
}
|
1184 |
break;
|
1185 |
}
|
1391 |
DebugEcho("filter_RemoveSignatureWorker sig new text:\n$presig");
|
1392 |
$html->innertext = $presig;
|
1393 |
} else {
|
1394 |
+
DebugEcho("filter_RemoveSignatureWorker: no matches " . preg_last_error() . " '$pattern' $html->plaintext");
|
1395 |
//DebugDump($matches);
|
1396 |
}
|
1397 |
|
1531 |
$minutes = $minuteMatches[1];
|
1532 |
}
|
1533 |
$delay = (($days * 24 + $hours) * 60 + $minutes) * 60;
|
1534 |
+
$interval = 'P';
|
1535 |
+
if (abs($days) > 0) {
|
1536 |
+
$interval .= abs($days) . 'D';
|
1537 |
+
}
|
1538 |
+
if (abs($hours) > 0) {
|
1539 |
+
$interval .= 'T' . abs($hours) . 'H';
|
1540 |
+
}
|
1541 |
+
if (abs($minutes) > 0) {
|
1542 |
+
if (abs($hours) > 0) {
|
1543 |
+
$interval .= abs($minutes) . 'M';
|
1544 |
+
} else {
|
1545 |
+
$interval .= 'T' . abs($minutes) . 'M';
|
1546 |
+
}
|
1547 |
+
}
|
1548 |
+
|
1549 |
DebugEcho("tag_Delay: calculated delay: $delay");
|
1550 |
+
DebugEcho("tag_Delay: interval: $interval");
|
1551 |
$content = preg_replace("/delay:$matches[1]/i", "", $content);
|
1552 |
}
|
1553 |
|
1558 |
DebugEcho("tag_Delay: timezone: $tzs");
|
1559 |
|
1560 |
if (empty($message_date)) {
|
1561 |
+
$dateInSeconds = new DateTimeImmutable(current_time('mysql'));
|
1562 |
+
DebugEcho("tag_Delay: using current date: " . $dateInSeconds->format(DATE_RFC2822));
|
1563 |
} else {
|
1564 |
+
DebugEcho("tag_Delay: using message date(1): $message_date");
|
1565 |
+
$dateInSeconds = new DateTimeImmutable($message_date);
|
1566 |
+
DebugEcho("tag_Delay: using message date(2): " . $dateInSeconds->format(DATE_RFC2822));
|
1567 |
}
|
|
|
1568 |
|
1569 |
+
if ($delay > 0) {
|
1570 |
+
$delayeddateInSeconds = $dateInSeconds->add(new DateInterval($interval));
|
1571 |
+
}
|
1572 |
+
if ($delay < 0) {
|
1573 |
+
$delayeddateInSeconds = $dateInSeconds->sub(new DateInterval($interval));
|
1574 |
+
}
|
1575 |
+
if ($delay == 0) {
|
1576 |
+
$delayeddateInSeconds = clone $dateInSeconds;
|
1577 |
+
}
|
1578 |
+
|
1579 |
+
if ($offset > 0) {
|
1580 |
+
$corrected_date = $delayeddateInSeconds->add(new DateInterval('PT' . $offset . 'H'));
|
1581 |
+
}
|
1582 |
+
if ($offset < 0) {
|
1583 |
+
$corrected_date = $delayeddateInSeconds->sub(new DateInterval('PT' . $offset . 'H'));
|
1584 |
+
}
|
1585 |
+
if ($offset == 0) {
|
1586 |
+
$corrected_date = clone $delayeddateInSeconds;
|
1587 |
+
}
|
1588 |
+
|
1589 |
+
DebugEcho("tag_Delay: message date: " . $dateInSeconds->format(DATE_RFC2822));
|
1590 |
DebugEcho("tag_Delay: delay: $delay");
|
1591 |
+
DebugEcho("tag_Delay: offset: $offset");
|
1592 |
+
DebugEcho("tag_Delay: delayed date: " . $delayeddateInSeconds->format(DATE_RFC2822));
|
1593 |
+
DebugEcho("tag_Delay: delayed with offset: " . $corrected_date->format(DATE_RFC2822));
|
1594 |
|
1595 |
+
return array($corrected_date->format(DATE_W3C), $delay);
|
1596 |
}
|
1597 |
|
1598 |
/**
|
1628 |
if ($fp) {
|
1629 |
fwrite($fp, $attachment['data']);
|
1630 |
fclose($fp);
|
1631 |
+
DebugEcho("postie_media_handle_upload: wrote data to '$tmpFile'");
|
1632 |
} else {
|
1633 |
EchoError("postie_media_handle_upload: Could not write to temp file: '$tmpFile' ");
|
1634 |
+
postie_notify_error("postie_media_handle_upload: Could not write to temp file: '$tmpFile' ", "postie_media_handle_upload: Could not write to temp file: '$tmpFile' ");
|
1635 |
}
|
1636 |
} else {
|
1637 |
EchoError("postie_media_handle_upload: Could not create temp file in " . get_temp_dir());
|
1638 |
+
postie_notify_error("postie_media_handle_upload: Could not create temp file in " . get_temp_dir(), "postie_media_handle_upload: Could not create temp file in " . get_temp_dir());
|
1639 |
}
|
1640 |
|
1641 |
$file_array = array(
|
1648 |
DebugEcho("postie_media_handle_upload: adding " . $file_array['name']);
|
1649 |
DebugDump($file_array);
|
1650 |
|
|
|
|
|
|
|
1651 |
$id = media_handle_sideload($file_array, $post_id);
|
1652 |
|
1653 |
if (!is_wp_error($id)) {
|
1654 |
+
$mediapath = get_attached_file($id);
|
1655 |
+
$file_array['tmp_name'] = $mediapath;
|
1656 |
+
do_action('postie_file_added', $post_id, $id, $file_array);
|
1657 |
} else {
|
1658 |
EchoError("There was an error adding the attachement: " . $id->get_error_message());
|
1659 |
DebugDump($id->get_error_messages());
|
1660 |
DebugDump($id->get_error_data());
|
1661 |
+
postie_notify_error("There was an error adding the attachement: " . $attachment['wp_filename'], $id->get_error_message());
|
1662 |
}
|
1663 |
|
1664 |
return $id;
|
1708 |
}
|
1709 |
|
1710 |
function postie_email_reject($email, $recipients, $returnToSender) {
|
|
|
1711 |
DebugEcho("postie_email_reject: start");
|
1712 |
|
1713 |
if (count($recipients) == 0) {
|
2174 |
* @return array
|
2175 |
*/
|
2176 |
function tag_Categories(&$subject, $defaultCategoryId, $config, $post_id) {
|
2177 |
+
DebugEcho("tag_Categories: start");
|
2178 |
$category_match = $config['category_match'];
|
2179 |
$original_subject = $subject;
|
2180 |
$found = false;
|
2227 |
DebugEcho("tag_Categories: subject: $subject");
|
2228 |
$tax = postie_lookup_taxonomy_name($categoryid);
|
2229 |
if ('category' == $tax) {
|
2230 |
+
DebugEcho("tag_Categories: standard taxonomy $tax");
|
2231 |
$post_categories[] = $categoryid;
|
2232 |
} else {
|
2233 |
DebugEcho("tag_Categories: custom taxonomy $tax");
|
2524 |
'category_dash' => true,
|
2525 |
'category_bracket' => true,
|
2526 |
'prefer_text_convert' => true,
|
2527 |
+
'category_remove' => true,
|
2528 |
+
'ignore_email_date' => false,
|
2529 |
+
'use_time_offset' => false,
|
2530 |
+
'postie_log_error_notify' => '(All Admins)'
|
2531 |
);
|
2532 |
}
|
2533 |
|
2989 |
DebugEcho("Current time: " . current_time('mysql'), true);
|
2990 |
DebugEcho("Current time (gmt): " . current_time('mysql', 1), true);
|
2991 |
DebugEcho("Postie time correction: {$config['time_offset']}", true);
|
2992 |
+
$offsetdate = strtotime(current_time('mysql')) + ($config['use_time_offset'] ? $config['time_offset'] * 3600 : 0);
|
2993 |
+
|
2994 |
DebugEcho("Post time: " . date('Y-m-d H:i:s', $offsetdate), true);
|
2995 |
?>
|
2996 |
<h2>Encoding</h2>
|
3112 |
}
|
3113 |
|
3114 |
function postie_get_mail() {
|
|
|
|
|
|
|
|
|
3115 |
$config = config_Read();
|
3116 |
if (true == $config['postie_log_error'] || (defined('POSTIE_DEBUG') && true == POSTIE_DEBUG)) {
|
3117 |
add_action('postie_log_error', 'postie_log_error');
|
3123 |
add_action('postie_log_debug', 'postie_log_debug');
|
3124 |
}
|
3125 |
|
|
|
3126 |
DebugEcho('Starting mail fetch');
|
3127 |
DebugEcho('WordPress datetime: ' . current_time('mysql'));
|
3128 |
|
3129 |
+
do_action('postie_session_start');
|
3130 |
+
|
3131 |
postie_environment();
|
3132 |
+
|
3133 |
$wp_content_path = dirname(dirname(dirname(__FILE__)));
|
3134 |
DebugEcho("wp_content_path: $wp_content_path");
|
3135 |
if (file_exists($wp_content_path . DIRECTORY_SEPARATOR . 'filterPostie.php')) {
|
3208 |
DebugEcho('memory at end of email processing: ' . memory_get_usage());
|
3209 |
}
|
3210 |
}
|
3211 |
+
|
3212 |
+
/* here we add some more cron options for how often to check for email */
|
3213 |
+
|
3214 |
+
function postie_more_reccurences($schedules) {
|
3215 |
+
//Do not echo output in filters, it seems to break some installs
|
3216 |
+
//error_log("postie_more_reccurences: setting cron schedules");
|
3217 |
+
$schedules['weekly'] = array('interval' => (60 * 60 * 24 * 7), 'display' => __('Once Weekly', 'postie'));
|
3218 |
+
$schedules['twiceperhour'] = array('interval' => 60 * 30, 'display' => __('Twice per hour', 'postie'));
|
3219 |
+
$schedules['tenminutes'] = array('interval' => 60 * 10, 'display' => __('Every 10 minutes', 'postie'));
|
3220 |
+
$schedules['fiveminutes'] = array('interval' => 60 * 5, 'display' => __('Every 5 minutes', 'postie'));
|
3221 |
+
$schedules['oneminute'] = array('interval' => 60 * 1, 'display' => __('Every 1 minute', 'postie'));
|
3222 |
+
$schedules['thirtyseconds'] = array('interval' => 30, 'display' => __('Every 30 seconds', 'postie'));
|
3223 |
+
$schedules['fifteenseconds'] = array('interval' => 15, 'display' => __('Every 15 seconds', 'postie'));
|
3224 |
+
return $schedules;
|
3225 |
+
}
|
3226 |
+
|
3227 |
+
function postie_cron($interval = false) {
|
3228 |
+
//Do not echo output in filters, it seems to break some installs
|
3229 |
+
//error_log("postie_cron: setting up cron task: $interval");
|
3230 |
+
//$schedules = wp_get_schedules();
|
3231 |
+
//error_log("postie_cron\n" . print_r($schedules, true));
|
3232 |
+
|
3233 |
+
if (!$interval) {
|
3234 |
+
$config = config_Read();
|
3235 |
+
$interval = $config['interval'];
|
3236 |
+
//error_log("postie_cron: setting up cron task from config: $interval");
|
3237 |
+
}
|
3238 |
+
if (!$interval || $interval == '') {
|
3239 |
+
$interval = 'hourly';
|
3240 |
+
//error_log("Postie: setting up cron task: defaulting to hourly");
|
3241 |
+
}
|
3242 |
+
if ($interval == 'manual') {
|
3243 |
+
postie_decron();
|
3244 |
+
//error_log("postie_cron: clearing cron (manual)");
|
3245 |
+
} else {
|
3246 |
+
if ($interval != wp_get_schedule('check_postie_hook')) {
|
3247 |
+
postie_decron(); //remove existing
|
3248 |
+
//try to create the new schedule with the first run in 5 minutes
|
3249 |
+
if (false === wp_schedule_event(time() + 5 * 60, $interval, 'check_postie_hook')) {
|
3250 |
+
//error_log("postie_cron: Failed to set up cron task: $interval");
|
3251 |
+
} else {
|
3252 |
+
//error_log("postie_cron: Set up cron task: $interval");
|
3253 |
+
}
|
3254 |
+
} else {
|
3255 |
+
//error_log("postie_cron: OK: $interval");
|
3256 |
+
//don't need to do anything, cron already scheduled
|
3257 |
+
}
|
3258 |
+
}
|
3259 |
+
}
|
3260 |
+
|
3261 |
+
function postie_decron() {
|
3262 |
+
//error_log("postie_decron: clearing cron");
|
3263 |
+
wp_clear_scheduled_hook('check_postie_hook');
|
3264 |
+
}
|
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.
|
8 |
Author: Wayne Allen
|
9 |
Author URI: http://PostiePlugin.com/
|
10 |
License: GPL2
|
@@ -28,7 +28,7 @@
|
|
28 |
*/
|
29 |
|
30 |
/*
|
31 |
-
$Id: postie.php
|
32 |
*/
|
33 |
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib/fException.php");
|
34 |
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib/fUnexpectedException.php");
|
@@ -50,7 +50,17 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib_autolink.php");
|
|
50 |
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
|
51 |
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-api.php");
|
52 |
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
define("POSTIE_ROOT", dirname(__FILE__));
|
55 |
define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
|
56 |
|
@@ -297,56 +307,6 @@ function check_postie() {
|
|
297 |
postie_get_mail();
|
298 |
}
|
299 |
|
300 |
-
function postie_cron($interval = false) {
|
301 |
-
//Do not echo output in filters, it seems to break some installs
|
302 |
-
//error_log("postie_cron: setting up cron task: $interval");
|
303 |
-
//$schedules = wp_get_schedules();
|
304 |
-
//error_log("postie_cron\n" . print_r($schedules, true));
|
305 |
|
306 |
-
if (!$interval) {
|
307 |
-
$config = config_Read();
|
308 |
-
$interval = $config['interval'];
|
309 |
-
//error_log("postie_cron: setting up cron task from config: $interval");
|
310 |
-
}
|
311 |
-
if (!$interval || $interval == '') {
|
312 |
-
$interval = 'hourly';
|
313 |
-
//error_log("Postie: setting up cron task: defaulting to hourly");
|
314 |
-
}
|
315 |
-
if ($interval == 'manual') {
|
316 |
-
postie_decron();
|
317 |
-
//error_log("postie_cron: clearing cron (manual)");
|
318 |
-
} else {
|
319 |
-
if ($interval != wp_get_schedule('check_postie_hook')) {
|
320 |
-
postie_decron(); //remove existing
|
321 |
-
//try to create the new schedule with the first run in 5 minutes
|
322 |
-
if (false === wp_schedule_event(time() + 5 * 60, $interval, 'check_postie_hook')) {
|
323 |
-
//error_log("postie_cron: Failed to set up cron task: $interval");
|
324 |
-
} else {
|
325 |
-
//error_log("postie_cron: Set up cron task: $interval");
|
326 |
-
}
|
327 |
-
} else {
|
328 |
-
//error_log("postie_cron: OK: $interval");
|
329 |
-
//don't need to do anything, cron already scheduled
|
330 |
-
}
|
331 |
-
}
|
332 |
-
}
|
333 |
|
334 |
-
function postie_decron() {
|
335 |
-
//error_log("postie_decron: clearing cron");
|
336 |
-
wp_clear_scheduled_hook('check_postie_hook');
|
337 |
-
}
|
338 |
|
339 |
-
/* here we add some more cron options for how often to check for email */
|
340 |
-
|
341 |
-
function postie_more_reccurences($schedules) {
|
342 |
-
//Do not echo output in filters, it seems to break some installs
|
343 |
-
//error_log("postie_more_reccurences: setting cron schedules");
|
344 |
-
$schedules['weekly'] = array('interval' => (60 * 60 * 24 * 7), 'display' => __('Once Weekly', 'postie'));
|
345 |
-
$schedules['twiceperhour'] = array('interval' => 60 * 30, 'display' => __('Twice per hour', 'postie'));
|
346 |
-
$schedules['tenminutes'] = array('interval' => 60 * 10, 'display' => __('Every 10 minutes', 'postie'));
|
347 |
-
$schedules['fiveminutes'] = array('interval' => 60 * 5, 'display' => __('Every 5 minutes', 'postie'));
|
348 |
-
$schedules['oneminute'] = array('interval' => 60 * 1, 'display' => __('Every 1 minute', 'postie'));
|
349 |
-
$schedules['thirtyseconds'] = array('interval' => 30, 'display' => __('Every 30 seconds', 'postie'));
|
350 |
-
$schedules['fifteenseconds'] = array('interval' => 15, 'display' => __('Every 15 seconds', 'postie'));
|
351 |
-
return $schedules;
|
352 |
-
}
|
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.36
|
8 |
Author: Wayne Allen
|
9 |
Author URI: http://PostiePlugin.com/
|
10 |
License: GPL2
|
28 |
*/
|
29 |
|
30 |
/*
|
31 |
+
$Id: postie.php 1630364 2017-04-05 16:08:01Z WayneAllen $
|
32 |
*/
|
33 |
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib/fException.php");
|
34 |
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "lib/fUnexpectedException.php");
|
50 |
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-functions.php");
|
51 |
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "postie-api.php");
|
52 |
|
53 |
+
require_once(ABSPATH . 'wp-admin/includes/file.php');
|
54 |
+
require_once(ABSPATH . 'wp-admin/includes/image.php');
|
55 |
+
require_once(ABSPATH . 'wp-admin/includes/media.php');
|
56 |
+
require_once(ABSPATH . 'wp-admin/includes/file.php'); //wp_tempnam()
|
57 |
+
require_once( ABSPATH . WPINC . '/class-oembed.php' );
|
58 |
+
|
59 |
+
if (!function_exists('file_get_html')) {
|
60 |
+
require_once (plugin_dir_path(__FILE__) . 'simple_html_dom.php');
|
61 |
+
}
|
62 |
+
|
63 |
+
define('POSTIE_VERSION', '1.8.36');
|
64 |
define("POSTIE_ROOT", dirname(__FILE__));
|
65 |
define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
|
66 |
|
307 |
postie_get_mail();
|
308 |
}
|
309 |
|
|
|
|
|
|
|
|
|
|
|
310 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
|
|
|
|
|
|
|
|
|
312 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.7.3
|
9 |
-
Stable tag: 1.8.
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
@@ -242,6 +242,16 @@ All script, style and body tags are stripped from html emails.
|
|
242 |
Attachments are now processed in the order they were attached.
|
243 |
|
244 |
== CHANGELOG ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
= 1.8.35 (2017-03-21) =
|
246 |
* Check for blank image file extension and replace with mime subtype to get around new filetype checking in WordPress 4.7.2 https://core.trac.wordpress.org/ticket/39550
|
247 |
* Additional logging of message and part headers
|
6 |
Tags: e-mail, email, post-by-email
|
7 |
Requires at least: 3.3.0
|
8 |
Tested up to: 4.7.3
|
9 |
+
Stable tag: 1.8.36
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
242 |
Attachments are now processed in the order they were attached.
|
243 |
|
244 |
== CHANGELOG ==
|
245 |
+
= 1.8.36 (2017-04-05) =
|
246 |
+
* Allow user to specify a IMAP folder (supplied by Alejandro Liu)
|
247 |
+
* Fix postie_file_added action
|
248 |
+
* New setting "use time offset" which controls whether or not the postie time offset is applied.
|
249 |
+
* New setting "ignore_email_date" which controls whether or not the email "from" date is used.
|
250 |
+
* Other email to post date improvements
|
251 |
+
* New setting "Notify on Error" to control who gets notified on significant errors.
|
252 |
+
* Email admins on some errors
|
253 |
+
* Fix bug when parsing headers that have multiple encoded sections
|
254 |
+
|
255 |
= 1.8.35 (2017-03-21) =
|
256 |
* Check for blank image file extension and replace with mime subtype to get around new filetype checking in WordPress 4.7.2 https://core.trac.wordpress.org/ticket/39550
|
257 |
* Additional logging of message and part headers
|