Version Description
(2017-03-07) = * Ensure password not in logs for POP3. * Additional POP3 header checks. * Additional POP3 logging. * Ensure postie_raw always gets called. * Default to GMT when timezone is blank. * Use WordPress function to upload images rather than old custom function. * Remove Generate Thumbnails option as now handled by WordPress. * ATT00001.txt and its ilk are now always considered a banned attachment regardless of MIME type. * Removed call to date_default_timezone_set() * Send notifications to all WP admins if configured. * Add support for postie_category filter.
Download this release
Release Info
Developer | WayneAllen |
Plugin | Postie |
Version | 1.8.32 |
Comparing to | |
See all releases |
Code changes from version 1.8.31 to 1.8.32
- config_form_image.php +0 -1
- config_form_message.php +3 -3
- docs/Changes.txt +13 -0
- docs/Postie.txt +2 -2
- lib/fMailbox.php +6 -1
- lib/pPop3MailServer.php +33 -3
- lib/pSocketConnection.php +1 -1
- postie-functions.php +93 -284
- postie.php +3 -3
- readme.txt +15 -2
config_form_image.php
CHANGED
@@ -7,7 +7,6 @@
|
|
7 |
echo BuildBooleanSelect(__("Automatically insert image gallery", 'postie'), "postie-settings[auto_gallery]", $auto_gallery, __("If any images are attached, they will automatically be inserted as a gallery. If the 'Preferred Text Type' is 'HTML' this will add a galery in addition to the images in the email. Not recommended.", 'postie'));
|
8 |
echo BuildSelect(__("Gallery Link Type", 'postie'), "postie-settings[auto_gallery_link]", $auto_gallery_link, array('Default', 'Post', 'File', 'None'), "Select the type of link the gallery should use");
|
9 |
echo BuildBooleanSelect(__("Image Location", 'postie'), "postie-settings[images_append]", $images_append, __("Location of attachments if using 'plain' format. Before or After content. For 'html' content this will only affect attachments that are not inline.", 'postie'), array('After', 'Before'));
|
10 |
-
echo BuildBooleanSelect(__("Generate Thumbnails", 'postie'), "postie-settings[generate_thumbnails]", $generate_thumbnails, __("Some hosts crash during thumbnail generation. Set this to 'No' if you have this issue", 'postie'));
|
11 |
echo BuildBooleanSelect(__("Start Image Count At", 'postie'), "postie-settings[start_image_count_at_zero]", $start_image_count_at_zero, __('For use if using "Image Place Holder Tag" below.', 'postie'), array('Start at 0', 'Start at 1'));
|
12 |
echo BuildBooleanSelect(__("Use custom image field for images", 'postie'), "postie-settings[custom_image_field]", $custom_image_field, __("When set to 'Yes' no images will appear in the post (other attachment types will be processed normally). Instead the url to the attachment will be put into a custom field named 'image'. Your theme will need logic to display these attachments", 'postie'));
|
13 |
?>
|
7 |
echo BuildBooleanSelect(__("Automatically insert image gallery", 'postie'), "postie-settings[auto_gallery]", $auto_gallery, __("If any images are attached, they will automatically be inserted as a gallery. If the 'Preferred Text Type' is 'HTML' this will add a galery in addition to the images in the email. Not recommended.", 'postie'));
|
8 |
echo BuildSelect(__("Gallery Link Type", 'postie'), "postie-settings[auto_gallery_link]", $auto_gallery_link, array('Default', 'Post', 'File', 'None'), "Select the type of link the gallery should use");
|
9 |
echo BuildBooleanSelect(__("Image Location", 'postie'), "postie-settings[images_append]", $images_append, __("Location of attachments if using 'plain' format. Before or After content. For 'html' content this will only affect attachments that are not inline.", 'postie'), array('After', 'Before'));
|
|
|
10 |
echo BuildBooleanSelect(__("Start Image Count At", 'postie'), "postie-settings[start_image_count_at_zero]", $start_image_count_at_zero, __('For use if using "Image Place Holder Tag" below.', 'postie'), array('Start at 0', 'Start at 1'));
|
11 |
echo BuildBooleanSelect(__("Use custom image field for images", 'postie'), "postie-settings[custom_image_field]", $custom_image_field, __("When set to 'Yes' no images will appear in the post (other attachment types will be processed normally). Instead the url to the attachment will be put into a custom field named 'image'. Your theme will need logic to display these attachments", 'postie'));
|
12 |
?>
|
config_form_message.php
CHANGED
@@ -143,9 +143,9 @@
|
|
143 |
<td>
|
144 |
<select name='postie-settings[confirmation_email]' id='postie-settings-confirmation_email'>
|
145 |
<option value="sender" <?php echo($confirmation_email == "sender") ? "selected" : "" ?>><?php _e('sender', 'postie') ?></option>
|
146 |
-
<option value="admin" <?php echo ($confirmation_email == "admin") ? "selected" : "" ?>><?php _e('administrator', 'postie') ?></option>
|
147 |
-
<option value="both" <?php echo ($confirmation_email == "both") ? "selected" : "" ?>><?php _e('sender and administrator', 'postie') ?></option>
|
148 |
-
<option value="" <?php echo ($confirmation_email == "") ? "selected" : "" ?>><?php _e('
|
149 |
</select>
|
150 |
</td>
|
151 |
</tr>
|
143 |
<td>
|
144 |
<select name='postie-settings[confirmation_email]' id='postie-settings-confirmation_email'>
|
145 |
<option value="sender" <?php echo($confirmation_email == "sender") ? "selected" : "" ?>><?php _e('sender', 'postie') ?></option>
|
146 |
+
<option value="admin" <?php echo ($confirmation_email == "admin") ? "selected" : "" ?>><?php _e('administrator(s)', 'postie') ?></option>
|
147 |
+
<option value="both" <?php echo ($confirmation_email == "both") ? "selected" : "" ?>><?php _e('sender and administrator(s)', 'postie') ?></option>
|
148 |
+
<option value="" <?php echo ($confirmation_email == "") ? "selected" : "" ?>><?php _e('nobody', 'postie') ?></option>
|
149 |
</select>
|
150 |
</td>
|
151 |
</tr>
|
docs/Changes.txt
CHANGED
@@ -35,6 +35,19 @@ 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.31 (2017-02-07) =
|
39 |
* Remove timezone warning if GMT+0
|
40 |
* Add postie_bare_link filter
|
35 |
Attachments are now processed in the order they were attached.
|
36 |
|
37 |
== CHANGELOG ==
|
38 |
+
= 1.8.32 (2017-03-07) =
|
39 |
+
* Ensure password not in logs for POP3.
|
40 |
+
* Additional POP3 header checks.
|
41 |
+
* Additional POP3 logging.
|
42 |
+
* Ensure postie_raw always gets called.
|
43 |
+
* Default to GMT when timezone is blank.
|
44 |
+
* Use WordPress function to upload images rather than old custom function.
|
45 |
+
* Remove Generate Thumbnails option as now handled by WordPress.
|
46 |
+
* ATT00001.txt and its ilk are now always considered a banned attachment regardless of MIME type.
|
47 |
+
* Removed call to date_default_timezone_set()
|
48 |
+
* Send notifications to all WP admins if configured.
|
49 |
+
* Add support for postie_category filter.
|
50 |
+
|
51 |
= 1.8.31 (2017-02-07) =
|
52 |
* Remove timezone warning if GMT+0
|
53 |
* Add postie_bare_link filter
|
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, post-by-email
|
7 |
Requires at least: 3.3.0
|
8 |
-
Tested up to: 4.7.
|
9 |
-
Stable tag: 1.8.
|
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, post-by-email
|
7 |
Requires at least: 3.3.0
|
8 |
+
Tested up to: 4.7.3
|
9 |
+
Stable tag: 1.8.32
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
lib/fMailbox.php
CHANGED
@@ -528,7 +528,7 @@ class fMailbox {
|
|
528 |
|
529 |
$headers = array();
|
530 |
foreach ($header_lines as $header_line) {
|
531 |
-
|
532 |
$header_line = preg_replace("#\r\n\s+#", ' ', $header_line);
|
533 |
|
534 |
if (false !== strpos($header_line, ':')) {
|
@@ -992,10 +992,15 @@ class fMailbox {
|
|
992 |
$this->connect();
|
993 |
|
994 |
$source = $this->fetchMessageSource($uid);
|
|
|
995 |
|
996 |
$info = self::parseMessage($source, $convert_newlines);
|
997 |
$info['uid'] = $uid;
|
998 |
|
|
|
|
|
|
|
|
|
999 |
return $info;
|
1000 |
}
|
1001 |
|
528 |
|
529 |
$headers = array();
|
530 |
foreach ($header_lines as $header_line) {
|
531 |
+
//DebugEcho("headerline: $header_line");
|
532 |
$header_line = preg_replace("#\r\n\s+#", ' ', $header_line);
|
533 |
|
534 |
if (false !== strpos($header_line, ':')) {
|
992 |
$this->connect();
|
993 |
|
994 |
$source = $this->fetchMessageSource($uid);
|
995 |
+
do_action('postie_raw', $source);
|
996 |
|
997 |
$info = self::parseMessage($source, $convert_newlines);
|
998 |
$info['uid'] = $uid;
|
999 |
|
1000 |
+
if (IsDebugMode()) {
|
1001 |
+
postie_save_email_debug($source, $info);
|
1002 |
+
}
|
1003 |
+
|
1004 |
return $info;
|
1005 |
}
|
1006 |
|
lib/pPop3MailServer.php
CHANGED
@@ -78,22 +78,52 @@ class pPop3MailServer extends pMailServer {
|
|
78 |
|
79 |
$response = trim(join("\r\n", $response));
|
80 |
$headers = fMailbox::parseHeaders($response);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
$output[$i] = array(
|
82 |
'uid' => $i,
|
83 |
-
'received' => self::cleanDate(preg_replace('#^.*;\s*([^;]+)$#', '\1', $
|
84 |
'size' => $sizes[$i],
|
85 |
-
'date' => $
|
86 |
'from' => self::joinEmails(array($headers['from'])),
|
87 |
-
'subject' =>
|
88 |
);
|
89 |
if (isset($headers['message-id'])) {
|
90 |
$output[$i]['message_id'] = $headers['message-id'];
|
|
|
|
|
91 |
}
|
|
|
92 |
if (isset($headers['to'])) {
|
93 |
$output[$i]['to'] = self::joinEmails($headers['to']);
|
|
|
|
|
94 |
}
|
|
|
95 |
if (isset($headers['in-reply-to'])) {
|
96 |
$output[$i]['in_reply_to'] = $headers['in-reply-to'];
|
|
|
|
|
97 |
}
|
98 |
}
|
99 |
return $output;
|
78 |
|
79 |
$response = trim(join("\r\n", $response));
|
80 |
$headers = fMailbox::parseHeaders($response);
|
81 |
+
|
82 |
+
$received = '';
|
83 |
+
if (array_key_exists('received', $headers) && count($headers['received']) > 0) {
|
84 |
+
$received = $headers['received'][0];
|
85 |
+
} else {
|
86 |
+
DebugEcho('pPop3MailServer::listMessages missing "received" header');
|
87 |
+
}
|
88 |
+
|
89 |
+
$date = '';
|
90 |
+
if (array_key_exists('date', $headers)) {
|
91 |
+
$date = $headers['date'];
|
92 |
+
} else {
|
93 |
+
DebugEcho('pPop3MailServer::listMessages missing "date" header');
|
94 |
+
}
|
95 |
+
|
96 |
+
$subject = '';
|
97 |
+
if (array_key_exists('subject', $headers)) {
|
98 |
+
$subject = $headers['subject'];
|
99 |
+
} else {
|
100 |
+
DebugEcho('pPop3MailServer::listMessages missing "subject" header');
|
101 |
+
}
|
102 |
+
|
103 |
$output[$i] = array(
|
104 |
'uid' => $i,
|
105 |
+
'received' => self::cleanDate(preg_replace('#^.*;\s*([^;]+)$#', '\1', $received)),
|
106 |
'size' => $sizes[$i],
|
107 |
+
'date' => $date,
|
108 |
'from' => self::joinEmails(array($headers['from'])),
|
109 |
+
'subject' => $subject
|
110 |
);
|
111 |
if (isset($headers['message-id'])) {
|
112 |
$output[$i]['message_id'] = $headers['message-id'];
|
113 |
+
} else {
|
114 |
+
DebugEcho('pPop3MailServer::listMessages missing "message-id" header');
|
115 |
}
|
116 |
+
|
117 |
if (isset($headers['to'])) {
|
118 |
$output[$i]['to'] = self::joinEmails($headers['to']);
|
119 |
+
} else {
|
120 |
+
DebugEcho('pPop3MailServer::listMessages missing "to" header');
|
121 |
}
|
122 |
+
|
123 |
if (isset($headers['in-reply-to'])) {
|
124 |
$output[$i]['in_reply_to'] = $headers['in-reply-to'];
|
125 |
+
} else {
|
126 |
+
DebugEcho('pPop3MailServer::listMessages missing "in-reply-to" header');
|
127 |
}
|
128 |
}
|
129 |
return $output;
|
lib/pSocketConnection.php
CHANGED
@@ -126,7 +126,7 @@ class pSocketConnection extends pConnection {
|
|
126 |
$command .= "\r\n";
|
127 |
}
|
128 |
|
129 |
-
if ((strpos($command, ' LOGIN') === false) & (strpos($command, 'APOP ') === false )) {
|
130 |
DebugEcho("socket write: " . trim($command));
|
131 |
} else {
|
132 |
DebugEcho("socket write: (login)");
|
126 |
$command .= "\r\n";
|
127 |
}
|
128 |
|
129 |
+
if ((strpos($command, ' LOGIN') === false) & (strpos($command, 'APOP ') === false ) & (strpos($command, 'PASS ') === false )) {
|
130 |
DebugEcho("socket write: " . trim($command));
|
131 |
} else {
|
132 |
DebugEcho("socket write: (login)");
|
postie-functions.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
$Id: postie-functions.php
|
4 |
*/
|
5 |
|
6 |
class PostiePostModifiers {
|
@@ -567,12 +567,13 @@ function PostEmail($poster, $mimeDecodedEmail, $config) {
|
|
567 |
$postid = postie_save_post($details, $is_reply, $config['custom_image_field'], $postmodifiers);
|
568 |
|
569 |
if ($config['confirmation_email'] != '') {
|
570 |
-
if ($config['confirmation_email'] == 'sender') {
|
571 |
$recipients = array($details['email_author']);
|
572 |
-
}
|
573 |
-
|
574 |
-
|
575 |
-
|
|
|
576 |
}
|
577 |
postie_email_notify($mimeDecodedEmail, $recipients, $postid);
|
578 |
}
|
@@ -784,11 +785,6 @@ function postie_getemails($type, $server, $port, $email, $password, $protocol, $
|
|
784 |
$email['html'] = filter_CleanHtml($email['html']);
|
785 |
}
|
786 |
|
787 |
-
if (IsDebugMode()) {
|
788 |
-
$raw = $mailbox->fetchMessageSource($uid);
|
789 |
-
postie_save_email_debug($raw, $email);
|
790 |
-
do_action('postie_raw', $raw);
|
791 |
-
}
|
792 |
$emails[] = $email;
|
793 |
if ($deleteMessages) {
|
794 |
DebugEcho("postie_getemails: deleting $uid");
|
@@ -854,6 +850,10 @@ function postie_save_post($details, $isReply, $customImageField, $postmodifiers)
|
|
854 |
* @return boolean
|
855 |
*/
|
856 |
function isBannedFileName($filename, $bannedFiles) {
|
|
|
|
|
|
|
|
|
857 |
if (empty($filename) || empty($bannedFiles)) {
|
858 |
return false;
|
859 |
}
|
@@ -1037,22 +1037,19 @@ function postie_save_attachment(&$attachment, $post_id, $poster, $config) {
|
|
1037 |
//DebugDump($part);
|
1038 |
|
1039 |
DebugEcho("postie_save_attachment: text Attachement: $filename");
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
DebugEcho("postie_save_attachment: text attachment: adding '$filename'");
|
1045 |
-
} else {
|
1046 |
-
EchoError($file_id->get_error_message());
|
1047 |
-
}
|
1048 |
} else {
|
1049 |
-
|
1050 |
}
|
|
|
1051 |
break;
|
1052 |
|
1053 |
case 'image':
|
1054 |
DebugEcho("postie_save_attachment: image Attachement: $filename");
|
1055 |
-
$file_id = postie_media_handle_upload($attachment, $post_id
|
1056 |
if (!is_wp_error($file_id)) {
|
1057 |
$attachment['wp_id'] = $file_id;
|
1058 |
//set the first image we come across as the featured image
|
@@ -1067,7 +1064,7 @@ function postie_save_attachment(&$attachment, $post_id, $poster, $config) {
|
|
1067 |
|
1068 |
case 'audio':
|
1069 |
DebugEcho("postie_save_attachment: audio Attachement: $filename");
|
1070 |
-
$file_id = postie_media_handle_upload($attachment, $post_id
|
1071 |
if (!is_wp_error($file_id)) {
|
1072 |
$attachment['wp_id'] = $file_id;
|
1073 |
} else {
|
@@ -1077,7 +1074,7 @@ function postie_save_attachment(&$attachment, $post_id, $poster, $config) {
|
|
1077 |
|
1078 |
case 'video':
|
1079 |
DebugEcho("postie_save_attachment: video Attachement: $filename");
|
1080 |
-
$file_id = postie_media_handle_upload($attachment, $post_id
|
1081 |
if (!is_wp_error($file_id)) {
|
1082 |
$attachment['wp_id'] = $file_id;
|
1083 |
} else {
|
@@ -1093,7 +1090,7 @@ function postie_save_attachment(&$attachment, $post_id, $poster, $config) {
|
|
1093 |
DebugEcho("postie_save_attachment: found pgp-signature - done");
|
1094 |
break;
|
1095 |
}
|
1096 |
-
$file_id = postie_media_handle_upload($attachment, $post_id
|
1097 |
if (!is_wp_error($file_id)) {
|
1098 |
$attachment['wp_id'] = $file_id;
|
1099 |
$file = wp_get_attachment_url($file_id);
|
@@ -1456,8 +1453,10 @@ function tag_Delay(&$content, $message_date = NULL, $offset = 0) {
|
|
1456 |
}
|
1457 |
|
1458 |
$tzs = get_option('timezone_string');
|
|
|
|
|
|
|
1459 |
DebugEcho("tag_Delay: timezone: $tzs");
|
1460 |
-
date_default_timezone_set($tzs);
|
1461 |
|
1462 |
if (empty($message_date)) {
|
1463 |
$dateInSeconds = current_time('timestamp');
|
@@ -1502,8 +1501,7 @@ function tag_Subject($content, $defaultTitle) {
|
|
1502 |
}
|
1503 |
}
|
1504 |
|
1505 |
-
function postie_media_handle_upload($attachment, $post_id
|
1506 |
-
$post_data = array();
|
1507 |
|
1508 |
$tmpFile = tempnam(get_temp_dir(), 'postie');
|
1509 |
if ($tmpFile !== false) {
|
@@ -1518,98 +1516,23 @@ function postie_media_handle_upload($attachment, $post_id, $poster, $generate_th
|
|
1518 |
EchoError("postie_media_handle_upload: Could not create temp file in " . get_temp_dir());
|
1519 |
}
|
1520 |
|
1521 |
-
$
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
if (isset($attachment['wp_filename']) && !empty($attachment['wp_filename'])) {
|
1526 |
-
$name = $attachment['wp_filename'];
|
1527 |
-
}
|
1528 |
-
//DebugEcho("pre-sanitize name: $name, size: " . filesize($tmpFile));
|
1529 |
-
//$name = sanitize_file_name($name);
|
1530 |
-
//DebugEcho("post sanitize name: $name");
|
1531 |
-
//DebugDump($part);
|
1532 |
-
|
1533 |
-
$the_file = array('name' => $name,
|
1534 |
'tmp_name' => $tmpFile,
|
1535 |
-
'
|
1536 |
-
'
|
1537 |
);
|
|
|
|
|
1538 |
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
$type = $attachment->primary . '/' . $attachment->secondary;
|
1544 |
-
$the_file['ext'] = $ext;
|
1545 |
-
$the_file['type'] = $type;
|
1546 |
-
}
|
1547 |
-
|
1548 |
-
$time = current_time('mysql');
|
1549 |
-
$post = get_post($post_id);
|
1550 |
-
if (substr($post->post_date, 0, 4) > 0) {
|
1551 |
-
DebugEcho("postie_media_handle_upload: using post date");
|
1552 |
-
$time = $post->post_date;
|
1553 |
-
}
|
1554 |
-
|
1555 |
-
$file = postie_handle_upload($the_file, $time, $mimetype_primary, $mimetype_secondary);
|
1556 |
-
|
1557 |
-
if (isset($file['error'])) {
|
1558 |
-
DebugDump($file['error']);
|
1559 |
-
return new WP_Error('upload_error', $file['error']);
|
1560 |
-
}
|
1561 |
-
|
1562 |
-
$url = $file['url'];
|
1563 |
-
$type = $file['type'];
|
1564 |
-
$filename = $file['file'];
|
1565 |
-
$title = preg_replace('/\.[^.]+$/', '', basename($filename));
|
1566 |
-
$content = '';
|
1567 |
-
|
1568 |
-
// use image exif/iptc data for title and caption defaults if possible
|
1569 |
-
if (file_exists(ABSPATH . '/wp-admin/includes/image.php')) {
|
1570 |
-
include_once(ABSPATH . '/wp-admin/includes/image.php');
|
1571 |
-
include_once(ABSPATH . '/wp-admin/includes/media.php');
|
1572 |
-
DebugEcho("postie_media_handle_upload: reading metadata");
|
1573 |
-
if ($image_meta = @wp_read_image_metadata($filename)) {
|
1574 |
-
if (trim($image_meta['title'])) {
|
1575 |
-
$title = $image_meta['title'];
|
1576 |
-
DebugEcho("postie_media_handle_upload: Using metadata title: $title");
|
1577 |
-
}
|
1578 |
-
if (trim($image_meta['caption'])) {
|
1579 |
-
$content = $image_meta['caption'];
|
1580 |
-
DebugEcho("postie_media_handle_upload: Using metadata caption: $content");
|
1581 |
-
}
|
1582 |
-
}
|
1583 |
-
}
|
1584 |
-
|
1585 |
-
// Construct the attachment array
|
1586 |
-
$attachment = array_merge(array(
|
1587 |
-
'post_mime_type' => $type,
|
1588 |
-
'guid' => $url,
|
1589 |
-
'post_parent' => $post_id,
|
1590 |
-
'post_title' => $title,
|
1591 |
-
'post_excerpt' => $content,
|
1592 |
-
'post_content' => $content,
|
1593 |
-
'post_author' => $poster
|
1594 |
-
), $post_data);
|
1595 |
-
|
1596 |
-
// Save the data
|
1597 |
-
DebugEcho("postie_media_handle_upload: before wp_insert_attachment");
|
1598 |
-
$id = wp_insert_attachment($attachment, $filename, $post_id);
|
1599 |
-
DebugEcho("postie_media_handle_upload: after wp_insert_attachment: attachment id: $id");
|
1600 |
|
1601 |
if (!is_wp_error($id)) {
|
1602 |
-
do_action('postie_file_added', $post_id, $id,
|
1603 |
-
|
1604 |
-
if ($generate_thubnails) {
|
1605 |
-
$amd = wp_generate_attachment_metadata($id, $filename);
|
1606 |
-
DebugEcho("postie_media_handle_upload: wp_generate_attachment_metadata");
|
1607 |
-
//DebugDump($amd);
|
1608 |
-
wp_update_attachment_metadata($id, $amd);
|
1609 |
-
DebugEcho("postie_media_handle_upload: wp_update_attachment_metadata complete");
|
1610 |
-
} else {
|
1611 |
-
DebugEcho("postie_media_handle_upload: thumbnail generation disabled");
|
1612 |
-
}
|
1613 |
} else {
|
1614 |
EchoError("There was an error adding the attachement: " . $id->get_error_message());
|
1615 |
DebugDump($id->get_error_messages());
|
@@ -1619,128 +1542,6 @@ function postie_media_handle_upload($attachment, $post_id, $poster, $generate_th
|
|
1619 |
return $id;
|
1620 |
}
|
1621 |
|
1622 |
-
function postie_handle_upload(&$file, $time = null, $mimetype_primary = null, $mimetype_secondary = null) {
|
1623 |
-
// The default error handler.
|
1624 |
-
if (!function_exists('wp_handle_upload_error')) {
|
1625 |
-
|
1626 |
-
function wp_handle_upload_error(&$file, $message) {
|
1627 |
-
return array('error' => $message);
|
1628 |
-
}
|
1629 |
-
|
1630 |
-
}
|
1631 |
-
|
1632 |
-
// A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter.
|
1633 |
-
$wp_filetype = wp_check_filetype($file['name']);
|
1634 |
-
if (!isset($file['type'])) {
|
1635 |
-
DebugEcho("postie_handle_upload: missing file[type]");
|
1636 |
-
if (!empty($wp_filetype['type'])) {
|
1637 |
-
DebugEcho("postie_handle_upload: substituting wp_filetype[type] - " . $wp_filetype['type']);
|
1638 |
-
$file['type'] = $wp_filetype['type'];
|
1639 |
-
} else if (!empty($mimetype_primary)) {
|
1640 |
-
DebugEcho("postie_handle_upload: substituting mimetype_primary - $mimetype_primary/$mimetype_secondary");
|
1641 |
-
$file['type'] = "$mimetype_primary/$mimetype_secondary";
|
1642 |
-
} else {
|
1643 |
-
DebugEcho("postie_handle_upload: no type found, implies not allowed");
|
1644 |
-
$file['type'] = '';
|
1645 |
-
}
|
1646 |
-
}
|
1647 |
-
DebugEcho("postie_handle_upload: detected file type for " . $file['name'] . " is " . $file['type']);
|
1648 |
-
|
1649 |
-
$file = apply_filters('wp_handle_upload_prefilter', $file);
|
1650 |
-
|
1651 |
-
// Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error'].
|
1652 |
-
$upload_error_strings = array(false,
|
1653 |
-
__("The uploaded file exceeds the <code>upload_max_filesize</code> directive in <code>php.ini</code>.", 'postie'),
|
1654 |
-
__("The uploaded file exceeds the <em>MAX_FILE_SIZE</em> directive that was specified in the HTML form.", 'postie'),
|
1655 |
-
__("The uploaded file was only partially uploaded.", 'postie'),
|
1656 |
-
__("No file was uploaded.", 'postie'),
|
1657 |
-
'',
|
1658 |
-
__("Missing a temporary folder.", 'postie'),
|
1659 |
-
__("Failed to write file to disk.", 'postie'));
|
1660 |
-
|
1661 |
-
// A successful upload will pass this test. It makes no sense to override this one.
|
1662 |
-
if ($file['error'] > 0) {
|
1663 |
-
return wp_handle_upload_error($file, $upload_error_strings[$file['error']]);
|
1664 |
-
}
|
1665 |
-
// A file with a valid mime type
|
1666 |
-
if (empty($file['type'])) {
|
1667 |
-
return wp_handle_upload_error($file, __('File type is not allowed', 'postie'));
|
1668 |
-
}
|
1669 |
-
// A non-empty file will pass this test.
|
1670 |
-
if (!($file['size'] > 0 )) {
|
1671 |
-
return wp_handle_upload_error($file, __('File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini.', 'postie'));
|
1672 |
-
}
|
1673 |
-
// A properly uploaded file will pass this test. There should be no reason to override this one.
|
1674 |
-
if (!file_exists($file['tmp_name'])) {
|
1675 |
-
return wp_handle_upload_error($file, __('Specified file failed upload test.', 'postie'));
|
1676 |
-
}
|
1677 |
-
|
1678 |
-
$mimetype = $file['type'];
|
1679 |
-
$ext = strtolower($wp_filetype['ext']);
|
1680 |
-
|
1681 |
-
if (empty($ext)) {
|
1682 |
-
$ext = strtolower(ltrim(strrchr($file['name'], '.'), '.'));
|
1683 |
-
}
|
1684 |
-
if (empty($ext) && !empty($mimetype_secondary)) {
|
1685 |
-
$ext = strtolower($mimetype_secondary);
|
1686 |
-
$file['name'] = $file['name'] . ".$ext";
|
1687 |
-
}
|
1688 |
-
|
1689 |
-
DebugEcho("postie_handle_upload (type/ext): '$mimetype' / '$ext'");
|
1690 |
-
|
1691 |
-
if ((empty($mimetype) && empty($ext)) && !current_user_can('unfiltered_upload')) {
|
1692 |
-
DebugEcho("postie_handle_upload: no type/ext & user restricted");
|
1693 |
-
return wp_handle_upload_error($file, __('File type does not meet security guidelines. Try another.', 'postie'));
|
1694 |
-
}
|
1695 |
-
|
1696 |
-
// A writable uploads dir will pass this test. Again, there's no point overriding this one.
|
1697 |
-
if (!( ( $uploads = wp_upload_dir($time) ) && false === $uploads['error'] )) {
|
1698 |
-
DebugEcho("postie_handle_upload: directory not writable");
|
1699 |
-
return wp_handle_upload_error($file, $uploads['error']);
|
1700 |
-
}
|
1701 |
-
// fix filename (encode non-standard characters)
|
1702 |
-
$file['name'] = filename_fix($file['name']);
|
1703 |
-
$filename = wp_unique_filename($uploads['path'], $file['name']);
|
1704 |
-
DebugEcho("wp_unique_filename: $filename");
|
1705 |
-
|
1706 |
-
// Move the file to the uploads dir
|
1707 |
-
$new_file = $uploads['path'] . "/$filename";
|
1708 |
-
|
1709 |
-
//move_uploaded_file() will not work here
|
1710 |
-
if (false === rename($file['tmp_name'], $new_file)) {
|
1711 |
-
DebugEcho("upload: rename failed");
|
1712 |
-
DebugEcho("old file: " . $file['tmp_name']);
|
1713 |
-
DebugEcho("new file: $new_file");
|
1714 |
-
//DebugDump($file);
|
1715 |
-
//DebugDump($uploads);
|
1716 |
-
return wp_handle_upload_error($file, sprintf(__('The uploaded file could not be moved to %s.', 'postie'), $uploads['path']));
|
1717 |
-
} else {
|
1718 |
-
DebugEcho("upload: rename to $new_file succeeded");
|
1719 |
-
}
|
1720 |
-
|
1721 |
-
// Set correct file permissions
|
1722 |
-
$stat = stat(dirname($new_file));
|
1723 |
-
$perms = $stat['mode'] & 0000666;
|
1724 |
-
if (chmod($new_file, $perms)) {
|
1725 |
-
DebugEcho("upload: permissions changed");
|
1726 |
-
} else {
|
1727 |
-
DebugEcho("upload: permissions not changed $new_file");
|
1728 |
-
}
|
1729 |
-
|
1730 |
-
// Compute the URL
|
1731 |
-
$url = $uploads['url'] . "/$filename";
|
1732 |
-
|
1733 |
-
DebugEcho("upload: before apply_filters");
|
1734 |
-
$return = apply_filters('wp_handle_upload', array('file' => $new_file, 'url' => $url, 'type' => $mimetype));
|
1735 |
-
DebugEcho("upload: after apply_filters");
|
1736 |
-
|
1737 |
-
return $return;
|
1738 |
-
}
|
1739 |
-
|
1740 |
-
function filename_fix($filename) {
|
1741 |
-
return str_replace('%', '', urlencode($filename));
|
1742 |
-
}
|
1743 |
-
|
1744 |
function postie_email_notify($email, $recipients, $postid) {
|
1745 |
DebugEcho("postie_email_notify: start");
|
1746 |
|
@@ -1966,45 +1767,49 @@ function chooseAttachmentIcon($file, $primary, $secondary, $iconSet = 'silver',
|
|
1966 |
|
1967 |
function parseTemplate($fileid, $type, $template, $orig_filename, $icon = "") {
|
1968 |
DebugEcho("parseTemplate: before '$template'");
|
1969 |
-
|
1970 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1971 |
if ($type == 'image') {
|
1972 |
-
$sizes = array('thumbnail', 'medium', 'large');
|
1973 |
-
$hwstrings = array();
|
1974 |
$widths = array();
|
1975 |
$heights = array();
|
1976 |
-
$
|
1977 |
|
1978 |
postie_show_filters_for('image_downsize'); //possible overrides for image_downsize()
|
1979 |
|
|
|
|
|
|
|
|
|
1980 |
for ($i = 0; $i < count($sizes); $i++) {
|
1981 |
-
|
1982 |
-
|
|
|
|
|
|
|
|
|
1983 |
}
|
1984 |
DebugEcho('parseTemplate: Sources');
|
1985 |
-
DebugDump($
|
1986 |
DebugEcho('parseTemplate: Heights');
|
1987 |
DebugDump($heights);
|
1988 |
DebugEcho('parseTemplate: Widths');
|
1989 |
DebugDump($widths);
|
1990 |
-
}
|
1991 |
-
|
1992 |
-
$attachment = get_post($fileid);
|
1993 |
-
$uploadDir = wp_upload_dir();
|
1994 |
-
$fileName = basename($attachment->guid);
|
1995 |
-
$fileType = pathinfo($fileName, PATHINFO_EXTENSION);
|
1996 |
-
$absFileName = $uploadDir['path'] . '/' . $fileName;
|
1997 |
-
$relFileName = str_replace(ABSPATH, '', $absFileName);
|
1998 |
-
$fileLink = wp_get_attachment_url($fileid);
|
1999 |
-
$pageLink = get_attachment_link($fileid);
|
2000 |
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
$template = str_replace('{
|
2005 |
-
$template = str_replace('{THUMB}', $img_src[0], $template);
|
2006 |
-
$template = str_replace('{MEDIUM}', $img_src[1], $template);
|
2007 |
-
$template = str_replace('{LARGE}', $img_src[2], $template);
|
2008 |
$template = str_replace('{THUMBWIDTH}', $widths[0] . 'px', $template);
|
2009 |
$template = str_replace('{THUMBHEIGHT}', $heights[0] . 'px', $template);
|
2010 |
$template = str_replace('{MEDIUMWIDTH}', $widths[1] . 'px', $template);
|
@@ -2012,6 +1817,7 @@ function parseTemplate($fileid, $type, $template, $orig_filename, $icon = "") {
|
|
2012 |
$template = str_replace('{LARGEWIDTH}', $widths[2] . 'px', $template);
|
2013 |
$template = str_replace('{LARGEHEIGHT}', $heights[2] . 'px', $template);
|
2014 |
}
|
|
|
2015 |
$template = str_replace('{FULL}', $fileLink, $template);
|
2016 |
$template = str_replace('{FILELINK}', $fileLink, $template);
|
2017 |
$template = str_replace('{FILETYPE}', $fileType, $template);
|
@@ -2267,20 +2073,7 @@ function tag_Categories(&$subject, $defaultCategoryId, $config, $post_id) {
|
|
2267 |
|
2268 |
if ($config['category_colon']) {
|
2269 |
if (preg_match('/(.+):\s?(.*)/', $subject, $matches)) { // <category>: <Subject>
|
2270 |
-
$
|
2271 |
-
if (!empty($category)) {
|
2272 |
-
$found = true;
|
2273 |
-
DebugEcho("colon category: $category");
|
2274 |
-
$subject = trim($matches[2]);
|
2275 |
-
DebugEcho("colon category: subject: $subject");
|
2276 |
-
$tax = lookup_taxonomy($category);
|
2277 |
-
if ('category' == $tax) {
|
2278 |
-
$post_categories[] = $category;
|
2279 |
-
} else {
|
2280 |
-
DebugEcho("colon category: custom taxonomy $tax");
|
2281 |
-
wp_set_object_terms($post_id, $category, $tax, true);
|
2282 |
-
}
|
2283 |
-
}
|
2284 |
}
|
2285 |
}
|
2286 |
|
@@ -2291,17 +2084,30 @@ function tag_Categories(&$subject, $defaultCategoryId, $config, $post_id) {
|
|
2291 |
$i = 0;
|
2292 |
foreach ($matches[1] as $match) {
|
2293 |
DebugEcho("tag_Categories: checking: $match");
|
2294 |
-
|
2295 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2296 |
$found = true;
|
2297 |
$subject = str_replace($matches[0][$i], '', $subject);
|
2298 |
DebugEcho("tag_Categories: subject: $subject");
|
2299 |
-
$tax =
|
2300 |
if ('category' == $tax) {
|
2301 |
-
$post_categories[] = $
|
2302 |
} else {
|
2303 |
DebugEcho("tag_Categories: custom taxonomy $tax");
|
2304 |
-
wp_set_object_terms($post_id, $
|
2305 |
}
|
2306 |
}
|
2307 |
$i++;
|
@@ -2317,7 +2123,7 @@ function tag_Categories(&$subject, $defaultCategoryId, $config, $post_id) {
|
|
2317 |
return $post_categories;
|
2318 |
}
|
2319 |
|
2320 |
-
function
|
2321 |
global $wpdb;
|
2322 |
$tax_sql = 'SELECT taxonomy FROM ' . $wpdb->term_taxonomy . ' WHERE term_id = ' . $termid;
|
2323 |
$tax = $wpdb->get_var($tax_sql);
|
@@ -2325,9 +2131,8 @@ function lookup_taxonomy($termid) {
|
|
2325 |
return $tax;
|
2326 |
}
|
2327 |
|
2328 |
-
function
|
2329 |
global $wpdb;
|
2330 |
-
$trial_category = trim($trial_category);
|
2331 |
DebugEcho("lookup_category: $trial_category");
|
2332 |
|
2333 |
$term = get_term_by('name', esc_attr($trial_category), 'category');
|
@@ -3094,8 +2899,12 @@ function postie_test_config() {
|
|
3094 |
DebugEcho("WordPress encoding: " . esc_attr(get_option('blog_charset')), true);
|
3095 |
DebugEcho("Postie encoding: " . $config['message_encoding'], true);
|
3096 |
?>
|
|
|
|
|
|
|
|
|
|
|
3097 |
<h2>Connect to Mail Host</h2>
|
3098 |
-
|
3099 |
<?php
|
3100 |
DebugEcho("Postie connection: " . $config['input_connection'], true);
|
3101 |
DebugEcho("Postie protocol: " . $config['input_protocol'], true);
|
1 |
<?php
|
2 |
/*
|
3 |
+
$Id: postie-functions.php 1610180 2017-03-07 23:56:06Z WayneAllen $
|
4 |
*/
|
5 |
|
6 |
class PostiePostModifiers {
|
567 |
$postid = postie_save_post($details, $is_reply, $config['custom_image_field'], $postmodifiers);
|
568 |
|
569 |
if ($config['confirmation_email'] != '') {
|
570 |
+
if ($config['confirmation_email'] == 'sender' || $config['confirmation_email'] == 'both') {
|
571 |
$recipients = array($details['email_author']);
|
572 |
+
}
|
573 |
+
if ($config['confirmation_email'] == 'admin' || $config['confirmation_email'] == 'both') {
|
574 |
+
foreach (get_users(array('role' => 'administrator')) as $user) {
|
575 |
+
$recipients[] = $user->user_email;
|
576 |
+
}
|
577 |
}
|
578 |
postie_email_notify($mimeDecodedEmail, $recipients, $postid);
|
579 |
}
|
785 |
$email['html'] = filter_CleanHtml($email['html']);
|
786 |
}
|
787 |
|
|
|
|
|
|
|
|
|
|
|
788 |
$emails[] = $email;
|
789 |
if ($deleteMessages) {
|
790 |
DebugEcho("postie_getemails: deleting $uid");
|
850 |
* @return boolean
|
851 |
*/
|
852 |
function isBannedFileName($filename, $bannedFiles) {
|
853 |
+
if (preg_match('/ATT\d\d\d\d\d.txt/i', $filename)) {
|
854 |
+
return true;
|
855 |
+
}
|
856 |
+
|
857 |
if (empty($filename) || empty($bannedFiles)) {
|
858 |
return false;
|
859 |
}
|
1037 |
//DebugDump($part);
|
1038 |
|
1039 |
DebugEcho("postie_save_attachment: text Attachement: $filename");
|
1040 |
+
$file_id = postie_media_handle_upload($attachment, $post_id);
|
1041 |
+
if (!is_wp_error($file_id)) {
|
1042 |
+
$attachment['wp_id'] = $file_id;
|
1043 |
+
DebugEcho("postie_save_attachment: text attachment: adding '$filename'");
|
|
|
|
|
|
|
|
|
1044 |
} else {
|
1045 |
+
EchoError($file_id->get_error_message());
|
1046 |
}
|
1047 |
+
|
1048 |
break;
|
1049 |
|
1050 |
case 'image':
|
1051 |
DebugEcho("postie_save_attachment: image Attachement: $filename");
|
1052 |
+
$file_id = postie_media_handle_upload($attachment, $post_id);
|
1053 |
if (!is_wp_error($file_id)) {
|
1054 |
$attachment['wp_id'] = $file_id;
|
1055 |
//set the first image we come across as the featured image
|
1064 |
|
1065 |
case 'audio':
|
1066 |
DebugEcho("postie_save_attachment: audio Attachement: $filename");
|
1067 |
+
$file_id = postie_media_handle_upload($attachment, $post_id);
|
1068 |
if (!is_wp_error($file_id)) {
|
1069 |
$attachment['wp_id'] = $file_id;
|
1070 |
} else {
|
1074 |
|
1075 |
case 'video':
|
1076 |
DebugEcho("postie_save_attachment: video Attachement: $filename");
|
1077 |
+
$file_id = postie_media_handle_upload($attachment, $post_id);
|
1078 |
if (!is_wp_error($file_id)) {
|
1079 |
$attachment['wp_id'] = $file_id;
|
1080 |
} else {
|
1090 |
DebugEcho("postie_save_attachment: found pgp-signature - done");
|
1091 |
break;
|
1092 |
}
|
1093 |
+
$file_id = postie_media_handle_upload($attachment, $post_id);
|
1094 |
if (!is_wp_error($file_id)) {
|
1095 |
$attachment['wp_id'] = $file_id;
|
1096 |
$file = wp_get_attachment_url($file_id);
|
1453 |
}
|
1454 |
|
1455 |
$tzs = get_option('timezone_string');
|
1456 |
+
if (empty($tzs)) {
|
1457 |
+
$tzs = 'GMT';
|
1458 |
+
}
|
1459 |
DebugEcho("tag_Delay: timezone: $tzs");
|
|
|
1460 |
|
1461 |
if (empty($message_date)) {
|
1462 |
$dateInSeconds = current_time('timestamp');
|
1501 |
}
|
1502 |
}
|
1503 |
|
1504 |
+
function postie_media_handle_upload($attachment, $post_id) {
|
|
|
1505 |
|
1506 |
$tmpFile = tempnam(get_temp_dir(), 'postie');
|
1507 |
if ($tmpFile !== false) {
|
1516 |
EchoError("postie_media_handle_upload: Could not create temp file in " . get_temp_dir());
|
1517 |
}
|
1518 |
|
1519 |
+
$file_array = array(
|
1520 |
+
'name' => $attachment['wp_filename'],
|
1521 |
+
'type' => $attachment['mimetype'],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1522 |
'tmp_name' => $tmpFile,
|
1523 |
+
'error' => 0,
|
1524 |
+
'size' => filesize($tmpFile)
|
1525 |
);
|
1526 |
+
DebugEcho("postie_media_handle_upload: adding " . $file_array['name']);
|
1527 |
+
DebugDump($file_array);
|
1528 |
|
1529 |
+
require_once(ABSPATH . 'wp-admin/includes/file.php');
|
1530 |
+
require_once(ABSPATH . 'wp-admin/includes/image.php');
|
1531 |
+
require_once(ABSPATH . 'wp-admin/includes/media.php');
|
1532 |
+
$id = media_handle_sideload($file_array, $post_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1533 |
|
1534 |
if (!is_wp_error($id)) {
|
1535 |
+
do_action('postie_file_added', $post_id, $id, array());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1536 |
} else {
|
1537 |
EchoError("There was an error adding the attachement: " . $id->get_error_message());
|
1538 |
DebugDump($id->get_error_messages());
|
1542 |
return $id;
|
1543 |
}
|
1544 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1545 |
function postie_email_notify($email, $recipients, $postid) {
|
1546 |
DebugEcho("postie_email_notify: start");
|
1547 |
|
1767 |
|
1768 |
function parseTemplate($fileid, $type, $template, $orig_filename, $icon = "") {
|
1769 |
DebugEcho("parseTemplate: before '$template'");
|
1770 |
+
|
1771 |
+
$attachment = get_post($fileid);
|
1772 |
+
$uploadDir = wp_upload_dir();
|
1773 |
+
$fileName = basename($attachment->guid);
|
1774 |
+
$fileType = pathinfo($fileName, PATHINFO_EXTENSION);
|
1775 |
+
$absFileName = $uploadDir['path'] . '/' . $fileName;
|
1776 |
+
$relFileName = str_replace(ABSPATH, '', $absFileName);
|
1777 |
+
$fileLink = wp_get_attachment_url($fileid);
|
1778 |
+
$pageLink = get_attachment_link($fileid);
|
1779 |
+
|
1780 |
+
$template = str_replace('{TITLE}', $attachment->post_title, $template);
|
1781 |
+
$template = str_replace('{ID}', $fileid, $template);
|
1782 |
+
|
1783 |
if ($type == 'image') {
|
|
|
|
|
1784 |
$widths = array();
|
1785 |
$heights = array();
|
1786 |
+
$img_urls = array();
|
1787 |
|
1788 |
postie_show_filters_for('image_downsize'); //possible overrides for image_downsize()
|
1789 |
|
1790 |
+
/*
|
1791 |
+
* Possible enhancement: support all sizes returned by get_intermediate_image_sizes()
|
1792 |
+
*/
|
1793 |
+
$sizes = array('thumbnail', 'medium', 'large');
|
1794 |
for ($i = 0; $i < count($sizes); $i++) {
|
1795 |
+
$iinfo = image_downsize($fileid, $sizes[$i]);
|
1796 |
+
if (false !== $iinfo) {
|
1797 |
+
$img_urls[$i] = $iinfo[0];
|
1798 |
+
$widths[$i] = $iinfo[1];
|
1799 |
+
$heights[$i] = $iinfo[2];
|
1800 |
+
}
|
1801 |
}
|
1802 |
DebugEcho('parseTemplate: Sources');
|
1803 |
+
DebugDump($img_urls);
|
1804 |
DebugEcho('parseTemplate: Heights');
|
1805 |
DebugDump($heights);
|
1806 |
DebugEcho('parseTemplate: Widths');
|
1807 |
DebugDump($widths);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1808 |
|
1809 |
+
$template = str_replace('{THUMBNAIL}', $img_urls[0], $template);
|
1810 |
+
$template = str_replace('{THUMB}', $img_urls[0], $template);
|
1811 |
+
$template = str_replace('{MEDIUM}', $img_urls[1], $template);
|
1812 |
+
$template = str_replace('{LARGE}', $img_urls[2], $template);
|
|
|
|
|
|
|
1813 |
$template = str_replace('{THUMBWIDTH}', $widths[0] . 'px', $template);
|
1814 |
$template = str_replace('{THUMBHEIGHT}', $heights[0] . 'px', $template);
|
1815 |
$template = str_replace('{MEDIUMWIDTH}', $widths[1] . 'px', $template);
|
1817 |
$template = str_replace('{LARGEWIDTH}', $widths[2] . 'px', $template);
|
1818 |
$template = str_replace('{LARGEHEIGHT}', $heights[2] . 'px', $template);
|
1819 |
}
|
1820 |
+
|
1821 |
$template = str_replace('{FULL}', $fileLink, $template);
|
1822 |
$template = str_replace('{FILELINK}', $fileLink, $template);
|
1823 |
$template = str_replace('{FILETYPE}', $fileType, $template);
|
2073 |
|
2074 |
if ($config['category_colon']) {
|
2075 |
if (preg_match('/(.+):\s?(.*)/', $subject, $matches)) { // <category>: <Subject>
|
2076 |
+
$matchtypes[] = array(array(0 => $matches[1] . ':'), array(1 => $matches[1]));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2077 |
}
|
2078 |
}
|
2079 |
|
2084 |
$i = 0;
|
2085 |
foreach ($matches[1] as $match) {
|
2086 |
DebugEcho("tag_Categories: checking: $match");
|
2087 |
+
|
2088 |
+
DebugEcho("tag_Categories: looking up: $defaultCategoryId");
|
2089 |
+
$defaultcat_name = '';
|
2090 |
+
$defaultcat = get_term_by('id', $defaultCategoryId, lookup_taxonomy_name($defaultCategoryId));
|
2091 |
+
if (false !== $defaultcat) {
|
2092 |
+
$defaultcat_name = $defaultcat->name;
|
2093 |
+
DebugEcho("tag_Categories: default: $defaultcat_name");
|
2094 |
+
} else {
|
2095 |
+
DebugEcho("tag_Categories: default not found");
|
2096 |
+
}
|
2097 |
+
$trial_category = apply_filters('postie_category', trim($match), $category_match, $defaultcat_name);
|
2098 |
+
DebugEcho("tag_Categories: post filter: $trial_category");
|
2099 |
+
|
2100 |
+
$categoryid = lookup_category_id($trial_category, $category_match);
|
2101 |
+
if (!empty($categoryid)) {
|
2102 |
$found = true;
|
2103 |
$subject = str_replace($matches[0][$i], '', $subject);
|
2104 |
DebugEcho("tag_Categories: subject: $subject");
|
2105 |
+
$tax = lookup_taxonomy_name($categoryid);
|
2106 |
if ('category' == $tax) {
|
2107 |
+
$post_categories[] = $categoryid;
|
2108 |
} else {
|
2109 |
DebugEcho("tag_Categories: custom taxonomy $tax");
|
2110 |
+
wp_set_object_terms($post_id, $categoryid, $tax, true);
|
2111 |
}
|
2112 |
}
|
2113 |
$i++;
|
2123 |
return $post_categories;
|
2124 |
}
|
2125 |
|
2126 |
+
function lookup_taxonomy_name($termid) {
|
2127 |
global $wpdb;
|
2128 |
$tax_sql = 'SELECT taxonomy FROM ' . $wpdb->term_taxonomy . ' WHERE term_id = ' . $termid;
|
2129 |
$tax = $wpdb->get_var($tax_sql);
|
2131 |
return $tax;
|
2132 |
}
|
2133 |
|
2134 |
+
function lookup_category_id($trial_category, $category_match) {
|
2135 |
global $wpdb;
|
|
|
2136 |
DebugEcho("lookup_category: $trial_category");
|
2137 |
|
2138 |
$term = get_term_by('name', esc_attr($trial_category), 'category');
|
2899 |
DebugEcho("WordPress encoding: " . esc_attr(get_option('blog_charset')), true);
|
2900 |
DebugEcho("Postie encoding: " . $config['message_encoding'], true);
|
2901 |
?>
|
2902 |
+
<h2>Images</h2>
|
2903 |
+
<?php
|
2904 |
+
DebugEcho("registered image sizes");
|
2905 |
+
DebugDump(get_intermediate_image_sizes());
|
2906 |
+
?>
|
2907 |
<h2>Connect to Mail Host</h2>
|
|
|
2908 |
<?php
|
2909 |
DebugEcho("Postie connection: " . $config['input_connection'], true);
|
2910 |
DebugEcho("Postie protocol: " . $config['input_protocol'], true);
|
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");
|
@@ -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.
|
53 |
define("POSTIE_ROOT", dirname(__FILE__));
|
54 |
define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
|
55 |
|
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.32
|
8 |
Author: Wayne Allen
|
9 |
Author URI: http://PostiePlugin.com/
|
10 |
License: GPL2
|
28 |
*/
|
29 |
|
30 |
/*
|
31 |
+
$Id: postie.php 1594552 2017-02-13 00:45:31Z 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.32');
|
53 |
define("POSTIE_ROOT", dirname(__FILE__));
|
54 |
define("POSTIE_URL", WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
|
55 |
|
readme.txt
CHANGED
@@ -5,8 +5,8 @@ Author URI: http://allens-home.com/
|
|
5 |
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.
|
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,19 @@ 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.31 (2017-02-07) =
|
246 |
* Remove timezone warning if GMT+0
|
247 |
* Add postie_bare_link filter
|
5 |
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.32
|
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.32 (2017-03-07) =
|
246 |
+
* Ensure password not in logs for POP3.
|
247 |
+
* Additional POP3 header checks.
|
248 |
+
* Additional POP3 logging.
|
249 |
+
* Ensure postie_raw always gets called.
|
250 |
+
* Default to GMT when timezone is blank.
|
251 |
+
* Use WordPress function to upload images rather than old custom function.
|
252 |
+
* Remove Generate Thumbnails option as now handled by WordPress.
|
253 |
+
* ATT00001.txt and its ilk are now always considered a banned attachment regardless of MIME type.
|
254 |
+
* Removed call to date_default_timezone_set()
|
255 |
+
* Send notifications to all WP admins if configured.
|
256 |
+
* Add support for postie_category filter.
|
257 |
+
|
258 |
= 1.8.31 (2017-02-07) =
|
259 |
* Remove timezone warning if GMT+0
|
260 |
* Add postie_bare_link filter
|