Postie - Version 1.4.16

Version Description

(2013.01.03) = * Fixed a bug where an extra div tag was getting added. * Fixed a bug when linkifying URLs. * Fixed a bug where inline images were not being detected.

Download this release

Release Info

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

Code changes from version 1.4.15 to 1.4.16

Revision CHANGED
@@ -0,0 +1,2 @@
 
 
1
+ Revision: 647507
2
+ Last Changed Date: 2013-01-02 20:29:18 -0800 (Wed, 02 Jan 2013)
docs/Changes.txt CHANGED
@@ -3,17 +3,22 @@
3
  * All script, style and body tags are stripped from html emails.
4
 
5
  == CHANGELOG ==
6
- 1.4.15 (2013.01.02) =
 
 
 
 
 
7
  * Fixed a bug when a category is specified with [] and a colon (:) is in the subject, but not specifying a category
8
 
9
- 1.4.14 (2012.12.29) =
10
  * Fixed a bug where attached images were not being detected properly causing a "File is empty. Please upload something more substantial." error
11
  * Tweaked some CSS.
12
 
13
- 1.4.13 (2012.12.26) =
14
  * Fixed bug that was truncating content at the first html encoded character.
15
 
16
- 1.4.12 (2012.12.17) =
17
  * Added feature to limit the number of emails processed
18
  * Fixed bug where #img# was not processing the caption correctly
19
 
3
  * All script, style and body tags are stripped from html emails.
4
 
5
  == CHANGELOG ==
6
+ = 1.4.16 (2013.01.03) =
7
+ * Fixed a bug where an extra div tag was getting added.
8
+ * Fixed a bug when linkifying URLs.
9
+ * Fixed a bug where inline images were not being detected.
10
+
11
+ = 1.4.15 (2013.01.02) =
12
  * Fixed a bug when a category is specified with [] and a colon (:) is in the subject, but not specifying a category
13
 
14
+ = 1.4.14 (2012.12.29) =
15
  * Fixed a bug where attached images were not being detected properly causing a "File is empty. Please upload something more substantial." error
16
  * Tweaked some CSS.
17
 
18
+ = 1.4.13 (2012.12.26) =
19
  * Fixed bug that was truncating content at the first html encoded character.
20
 
21
+ = 1.4.12 (2012.12.17) =
22
  * Added feature to limit the number of emails processed
23
  * Fixed bug where #img# was not processing the caption correctly
24
 
docs/Postie.txt CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5
9
- Stable tag: 1.4.15
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5
9
+ Stable tag: 1.4.16
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
faq.html CHANGED
@@ -5,18 +5,19 @@
5
  <li id='question-4'><a href='#answer-4'>I read somewhere to add an iframe to my footer. Should I do this?</a></li>
6
  <li id='question-5'><a href='#answer-5'>My mail host requires SSL, but postie will not allow me to select pop3-ssl or imap-ssl</a></li>
7
  <li id='question-6'><a href='#answer-6'>Can I use postie to check a gmail account?</a></li>
8
- <li id='question-7'><a href='#answer-7'>My posts show up as being posted by 'admin' instead of me. Why?</a></li>
9
- <li id='question-8'><a href='#answer-8'>Images aren't showing up at all?</a></li>
10
- <li id='question-9'><a href='#answer-9'>Can I delete the wp-files directory needed by postie version &lt;1.3.0?</a></li>
11
- <li id='question-10'><a href='#answer-10'>How can I get rid of stupid stuff my e-mail provider adds to my messages?</a></li>
12
- <li id='question-11'><a href='#answer-11'>How can I add custom attachment icons?</a></li>
13
- <li id='question-12'><a href='#answer-12'>Can I add special text to the body of the post when using postie?</a></li>
14
- <li id='question-13'><a href='#answer-13'>Can I add special text to the title of the post when using postie?</a></li>
15
- <li id='question-14'><a href='#answer-14'>Can I select tags or categories based on the content of the e-mail?</a></li>
16
- <li id='question-15'><a href='#answer-15'>Is the IMAP extension required for postie?</a></li>
17
- <li id='question-16'><a href='#answer-16'>How can I embed youtube or vimeo videos?</a></li>
18
- <li id='question-17'><a href='#answer-17'>Something is going wrong, how do I see what is happening?</a></li>
19
- <li id='question-18'><a href='#answer-18'>Why doesn't Postie automatically publish my emails when running manually works</a></li>
 
20
  <h3>Frequently Asked Questions</h3>
21
  <h4 id='answer-0'>Postie won't connect to my mailserver. Why Not?</h4>
22
 
@@ -83,7 +84,21 @@ this would be just foo)</li>
83
  </ul></li>
84
  </ul>
85
 
86
- <h4 id='answer-7'>My posts show up as being posted by 'admin' instead of me. Why?</h4>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
  <p>If your admin account is linked to <a href="mailto:bar@gmail.com">bar@gmail.com</a>, and you send mail from
89
  <a href="mailto:bar@gmail.com">bar@gmail.com</a>, it will show up as being posted by admin. If you have a
@@ -95,7 +110,7 @@ e-mail address postie is checking. That is, if you send mail from
95
  <p>If you send an e-mail to your postie address from an e-mail address that is no
96
  t linked to a wordpress user, it will get posted as admin.</p>
97
 
98
- <h4 id='answer-8'>Images aren't showing up at all?</h4>
99
 
100
  <p>There are a couple possible reasons for this. First, check to see if you can
101
  add an image through wordpress's normal posting mechanism. If not, then there
@@ -108,14 +123,14 @@ provider about this.</p>
108
  sure that it is</li>
109
  </ol>
110
 
111
- <h4 id='answer-9'>Can I delete the wp-files directory needed by postie version &lt;1.3.0?</h4>
112
 
113
  <p>If you have posts published already by older versions of postie, getting rid
114
  of those directories will delete any files you might have had associated with
115
  those old posts. If you don't have any such posts, then you can safely delete
116
  them.</p>
117
 
118
- <h4 id='answer-10'>How can I get rid of stupid stuff my e-mail provider adds to my messages?</h4>
119
 
120
  <p>To strip off stuff that they add at the beginning of a message, start your
121
  post with :start</p>
@@ -123,7 +138,7 @@ post with :start</p>
123
  <p>To strip off stuff that they add at the end of a message, end your
124
  post with :end</p>
125
 
126
- <h4 id='answer-11'>How can I add custom attachment icons?</h4>
127
 
128
  <p>Simply upload the icons you want to the postie/icons/custom directory. You
129
  must name the icons according to the following scheme:</p>
@@ -154,22 +169,22 @@ icons)</p>
154
  <li>txt - plain text document</li>
155
  </ul>
156
 
157
- <h4 id='answer-12'>Can I add special text to the body of the post when using postie?</h4>
158
 
159
  <p>Yes. You can create your own function, and use the postie_post filter.
160
  Two short examples are included in the filterPostie.php.sample file</p>
161
 
162
- <h4 id='answer-13'>Can I add special text to the title of the post when using postie?</h4>
163
 
164
  <p>Yes. You can create your own function, and use the postie_post filter.
165
  Two short examples are included in the filterPostie.php.sample file</p>
166
 
167
- <h4 id='answer-14'>Can I select tags or categories based on the content of the e-mail?</h4>
168
 
169
  <p>Yes. You can create your own function, and use the postie_post filter.
170
  See the filterPostie.php.sample file for examples.</p>
171
 
172
- <h4 id='answer-15'>Is the IMAP extension required for postie?</h4>
173
 
174
  <p>The IMAP extension is not required, but it is strongly recommended, especially
175
  is you are using non-English text. There is more information on php.net about
@@ -187,12 +202,12 @@ often not hard to install.</p>
187
  <p>The IMAP extension is known to be installed on the following popular webhosts:
188
  * Dreamhost</p>
189
 
190
- <h4 id='answer-16'>How can I embed youtube or vimeo videos?</h4>
191
 
192
  <p>Simply put the url in the body of your e-mail. (Make sure that you have the
193
  option to convert url into links turned on)</p>
194
 
195
- <h4 id='answer-17'>Something is going wrong, how do I see what is happening?</h4>
196
 
197
  <p>Add the following lines to your wp-config.php file</p>
198
 
@@ -205,7 +220,7 @@ file. There may also be all sorts of warnings and messages in your site as well
205
  depending on how well behaved your other plugins and themes are, so you will not
206
  want to leave these settings set to true all the time.</p>
207
 
208
- <h4 id='answer-18'>Why doesn't Postie automatically publish my emails when running manually works</h4>
209
 
210
  <p>WordPress cron (which Postie relies on) doesn't run unless a page is accessed on the
211
  site. So if you send an email, but nobody accesses the site for 3 days Postie won't
5
  <li id='question-4'><a href='#answer-4'>I read somewhere to add an iframe to my footer. Should I do this?</a></li>
6
  <li id='question-5'><a href='#answer-5'>My mail host requires SSL, but postie will not allow me to select pop3-ssl or imap-ssl</a></li>
7
  <li id='question-6'><a href='#answer-6'>Can I use postie to check a gmail account?</a></li>
8
+ <li id='question-7'><a href='#answer-7'>Can I use postie with GoDaddy hosting?</a></li>
9
+ <li id='question-8'><a href='#answer-8'>My posts show up as being posted by 'admin' instead of me. Why?</a></li>
10
+ <li id='question-9'><a href='#answer-9'>Images aren't showing up at all?</a></li>
11
+ <li id='question-10'><a href='#answer-10'>Can I delete the wp-files directory needed by postie version &lt;1.3.0?</a></li>
12
+ <li id='question-11'><a href='#answer-11'>How can I get rid of stupid stuff my e-mail provider adds to my messages?</a></li>
13
+ <li id='question-12'><a href='#answer-12'>How can I add custom attachment icons?</a></li>
14
+ <li id='question-13'><a href='#answer-13'>Can I add special text to the body of the post when using postie?</a></li>
15
+ <li id='question-14'><a href='#answer-14'>Can I add special text to the title of the post when using postie?</a></li>
16
+ <li id='question-15'><a href='#answer-15'>Can I select tags or categories based on the content of the e-mail?</a></li>
17
+ <li id='question-16'><a href='#answer-16'>Is the IMAP extension required for postie?</a></li>
18
+ <li id='question-17'><a href='#answer-17'>How can I embed youtube or vimeo videos?</a></li>
19
+ <li id='question-18'><a href='#answer-18'>Something is going wrong, how do I see what is happening?</a></li>
20
+ <li id='question-19'><a href='#answer-19'>Why doesn't Postie automatically publish my emails when running manually works</a></li>
21
  <h3>Frequently Asked Questions</h3>
22
  <h4 id='answer-0'>Postie won't connect to my mailserver. Why Not?</h4>
23
 
84
  </ul></li>
85
  </ul>
86
 
87
+ <h4 id='answer-7'>Can I use postie with GoDaddy hosting?</h4>
88
+
89
+ <p>Yes, but you must use an email set up using the GoDaddy email service and the following settings:</p>
90
+
91
+ <ul>
92
+ <li>protocol - pop3</li>
93
+ <li>server - pop.secureserver.net</li>
94
+ <li>port - 110</li>
95
+ <li>userid - xxxxx@yourdomain</li>
96
+ <li>password - your password </li>
97
+ </ul>
98
+
99
+ <p>GoDaddy hosting does not allow you to connect to non-GoDaddy mail servers like Gmail.</p>
100
+
101
+ <h4 id='answer-8'>My posts show up as being posted by 'admin' instead of me. Why?</h4>
102
 
103
  <p>If your admin account is linked to <a href="mailto:bar@gmail.com">bar@gmail.com</a>, and you send mail from
104
  <a href="mailto:bar@gmail.com">bar@gmail.com</a>, it will show up as being posted by admin. If you have a
110
  <p>If you send an e-mail to your postie address from an e-mail address that is no
111
  t linked to a wordpress user, it will get posted as admin.</p>
112
 
113
+ <h4 id='answer-9'>Images aren't showing up at all?</h4>
114
 
115
  <p>There are a couple possible reasons for this. First, check to see if you can
116
  add an image through wordpress's normal posting mechanism. If not, then there
123
  sure that it is</li>
124
  </ol>
125
 
126
+ <h4 id='answer-10'>Can I delete the wp-files directory needed by postie version &lt;1.3.0?</h4>
127
 
128
  <p>If you have posts published already by older versions of postie, getting rid
129
  of those directories will delete any files you might have had associated with
130
  those old posts. If you don't have any such posts, then you can safely delete
131
  them.</p>
132
 
133
+ <h4 id='answer-11'>How can I get rid of stupid stuff my e-mail provider adds to my messages?</h4>
134
 
135
  <p>To strip off stuff that they add at the beginning of a message, start your
136
  post with :start</p>
138
  <p>To strip off stuff that they add at the end of a message, end your
139
  post with :end</p>
140
 
141
+ <h4 id='answer-12'>How can I add custom attachment icons?</h4>
142
 
143
  <p>Simply upload the icons you want to the postie/icons/custom directory. You
144
  must name the icons according to the following scheme:</p>
169
  <li>txt - plain text document</li>
170
  </ul>
171
 
172
+ <h4 id='answer-13'>Can I add special text to the body of the post when using postie?</h4>
173
 
174
  <p>Yes. You can create your own function, and use the postie_post filter.
175
  Two short examples are included in the filterPostie.php.sample file</p>
176
 
177
+ <h4 id='answer-14'>Can I add special text to the title of the post when using postie?</h4>
178
 
179
  <p>Yes. You can create your own function, and use the postie_post filter.
180
  Two short examples are included in the filterPostie.php.sample file</p>
181
 
182
+ <h4 id='answer-15'>Can I select tags or categories based on the content of the e-mail?</h4>
183
 
184
  <p>Yes. You can create your own function, and use the postie_post filter.
185
  See the filterPostie.php.sample file for examples.</p>
186
 
187
+ <h4 id='answer-16'>Is the IMAP extension required for postie?</h4>
188
 
189
  <p>The IMAP extension is not required, but it is strongly recommended, especially
190
  is you are using non-English text. There is more information on php.net about
202
  <p>The IMAP extension is known to be installed on the following popular webhosts:
203
  * Dreamhost</p>
204
 
205
+ <h4 id='answer-17'>How can I embed youtube or vimeo videos?</h4>
206
 
207
  <p>Simply put the url in the body of your e-mail. (Make sure that you have the
208
  option to convert url into links turned on)</p>
209
 
210
+ <h4 id='answer-18'>Something is going wrong, how do I see what is happening?</h4>
211
 
212
  <p>Add the following lines to your wp-config.php file</p>
213
 
220
  depending on how well behaved your other plugins and themes are, so you will not
221
  want to leave these settings set to true all the time.</p>
222
 
223
+ <h4 id='answer-19'>Why doesn't Postie automatically publish my emails when running manually works</h4>
224
 
225
  <p>WordPress cron (which Postie relies on) doesn't run unless a page is accessed on the
226
  site. So if you send an email, but nobody accesses the site for 3 days Postie won't
postie-functions.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /*
4
- $Id: postie-functions.php 647311 2013-01-03 04:18:03Z WayneAllen $
5
  */
6
 
7
  /* TODO
@@ -145,8 +145,11 @@ function PostEmail($poster, $mimeDecodedEmail, $config) {
145
  "image_files" => array() //holds the files for each image
146
  );
147
  EchoInfo("Message Id is :" . htmlentities($mimeDecodedEmail->headers["message-id"]));
 
148
 
149
  FilterTextParts($mimeDecodedEmail, $prefer_text_type);
 
 
150
  $tmpPost = array('post_title' => 'tmptitle', 'post_content' => 'tmpPost');
151
  /* in order to do attachments correctly, we need to associate the
152
  attachments with a post. So we add the post here, then update it
@@ -247,6 +250,8 @@ function PostEmail($poster, $mimeDecodedEmail, $config) {
247
 
248
  $post_type = GetPostType($subject);
249
 
 
 
250
  $details = array(
251
  'post_author' => $poster,
252
  'comment_author' => $postAuthorDetails['author'],
@@ -331,66 +336,77 @@ function GetPostType(&$subject) {
331
  }
332
 
333
  function clickableLink($text, $shortcode = false) {
334
- # this functions deserves credit to the fine folks at phpbb.com
335
- # It turns urls into links, and video urls into embedded players
 
336
 
337
  $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);
338
-
339
  // pad it with a space so we can match things at the start of the 1st line.
340
  $ret = ' ' . $text;
341
  if (strpos($ret, 'youtube') !== false) {
342
  // try to embed youtube videos
343
  $youtube = "#(^|[\n ]|>)[\w]+?://(www\.)?youtube\.com/watch\?v=([_a-zA-Z0-9-]+).*?([ \n]|$|<)#is";
344
- #$youtube="#(^|[\n ]|<p[^<]*>)[\w]+?://(www\.)?youtube\.com/watch\?v=([_a-zA-Z0-9]+).*?([ \n]|$|</p>)#is";
345
  if ($shortcode) {
346
  $youtube_replace = "\\1[youtube \\3]\\4";
347
  } else {
348
  $youtube_replace = "\\1<embed width='425' height='344' allowfullscreen='true' allowscriptaccess='always' type='application/x-shockwave-flash' src=\"http://www.youtube.com/v/\\3&hl=en&fs=1\" />\\4";
349
  }
350
  $ret = preg_replace($youtube, $youtube_replace, $ret);
 
351
  }
352
 
353
  if (strpos($ret, 'vimeo') !== false) {
354
  // try to embed vimeo videos
355
  # : http://vimeo.com/6348141
356
  $vimeo = "#(^|[\n ]|>)[\w]+?://(www\.)?vimeo\.com/([_a-zA-Z0-9-]+).*?([ \n]|$|<)#is";
357
- #$youtube="#(^|[\n ]|<p[^<]*>)[\w]+?://(www\.)?youtube\.com/watch\?v=([_a-zA-Z0-9]+).*?([ \n]|$|</p>)#is";
358
  if ($shortcode) {
359
  $vimeo_replace = "\\1[vimeo \\3]\\4";
360
  } else {
361
- $vimeo_replace = "\\1<object width='400' height='300'><param name='allowfullscreen'
362
- value='true' /><param name='allowscriptaccess' value='always' /><param
363
- name='movie'
364
- value='http://vimeo.com/moogaloop.swf?clip_id=\\3&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1'
365
- /><embed
366
- src='http://vimeo.com/moogaloop.swf?clip_id=\\3&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1'
367
- type='application/x-shockwave-flash' allowfullscreen='true'
368
- allowscriptaccess='always' width='400' height='300'></embed></object>\\4";
369
- //$vimeo_replace= "\\1<embed width='425' height='344' allowfullscreen='true' allowscriptaccess='always' type='application/x-shockwave-flash' src=\"http://www.youtube.com/v/\\3&hl=en&fs=1\" />\\4";
370
  }
371
  $ret = preg_replace($vimeo, $vimeo_replace, $ret);
 
372
  }
373
 
374
  // matches an "xxxx://yyyy" URL at the start of a line, or after a space.
375
  // xxxx can only be alpha characters.
376
  // yyyy is anything up to the first space, newline, comma, double quote or <
377
  $ret = preg_replace("#(^|[\n ])<?([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)>?#is", "\\1<a href=\"\\2\" >\\2</a>", $ret);
378
-
379
  // matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
380
- // Must contain at least 2 dots. xxxx contains either alphanum, or "-"
381
- // zzzz is optional.. will contain everything up to the first space, newline,
382
- // comma, double quote or <.
383
- $ret = preg_replace("#(^|[\n ])<?((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)>?#is", "\\1<a href=\"http://\\2\" >\\2</a>", $ret);
384
-
385
- // matches an email@domain type address at the start of a line, or after a space.
386
- // Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
387
- $ret = preg_replace(
388
- "#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
389
  // Remove our padding..
390
  $ret = substr($ret, 1);
 
 
391
  return $ret;
392
  }
393
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
394
  function getPostAuthorDetails(&$subject, &$content, &$mimeDecodedEmail) {
395
  /* we check whether or not the e-mail is a forwards or a redirect. If it is
396
  * a fwd, then we glean the author details from the body of the post.
@@ -699,7 +715,7 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
699
  DecodeBase64Part($part);
700
 
701
  //look for banned file names
702
- if (is_array($part->ctype_parameters) && array_key_exists('name', $part->ctype_parameters))
703
  if (BannedFileName($part->ctype_parameters['name'], $banned_files_list))
704
  return NULL;
705
 
@@ -723,6 +739,7 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
723
  }
724
 
725
  if ($part->ctype_primary == "multipart" && $part->ctype_secondary == "appledouble") {
 
726
  $mimeDecodedEmail = DecodeMIMEMail("Content-Type: multipart/mixed; boundary=" . $part->ctype_parameters["boundary"] . "\n" . $part->body);
727
  FilterTextParts($mimeDecodedEmail, $prefer_text_type);
728
  FilterAppleFile($mimeDecodedEmail);
@@ -731,16 +748,19 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
731
  }
732
  } else {
733
  $filename = "";
734
- if (is_array($part->ctype_parameters) && array_key_exists('name', $part->ctype_parameters)) {
735
  // fix filename (remove non-standard characters)
736
  $filename = preg_replace("/[^\x9\xA\xD\x20-\x7F]/", "", $part->ctype_parameters['name']);
737
  DebugEcho("Filename: $filename");
738
  }
739
  switch (strtolower($part->ctype_primary)) {
740
  case 'multipart':
 
741
  //DebugDump($part);
742
  FilterTextParts($part, $prefer_text_type);
743
  foreach ($part->parts as $section) {
 
 
744
  $meta_return .= GetContent($section, $attachments, $post_id, $poster, $config);
745
  }
746
  break;
@@ -764,6 +784,9 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
764
  if (array_key_exists('content-transfer-encoding', $part->headers)) {
765
  //DebugDump($part);
766
  $part->body = HandleMessageEncoding($encoding, $charset, $part->body, $message_encoding, $message_dequote);
 
 
 
767
  //DebugDump($part);
768
  }
769
 
@@ -777,18 +800,18 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
777
  DebugEcho("html");
778
  $meta_return .= HTML2HTML($part->body) . "\n";
779
  } else {
780
- //regular text, so just strip the pgp signature
781
  DebugEcho("plain text");
782
  if ($allow_html_in_body) {
 
783
  $meta_return .= $part->body;
 
784
  } else {
 
785
  $meta_return .= htmlentities($part->body);
786
  }
787
  $meta_return = StripPGP($meta_return);
788
- $meta_return = "<div>$meta_return</div>\n";
789
- //DebugEcho($meta_return);
790
  }
791
- DebugEcho("----");
792
  break;
793
 
794
  case 'image':
@@ -811,8 +834,10 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
811
  case 'audio':
812
  $file_id = postie_media_handle_upload($part, $post_id, $poster);
813
  $file = wp_get_attachment_url($file_id);
814
- $cid = trim($part->headers["content-id"], "<>");
815
- ; //cids are in <cid>
 
 
816
  if (in_array($part->ctype_secondary, $audiotypes)) {
817
  $audioTemplate = $audiotemplate;
818
  } else {
@@ -825,8 +850,10 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
825
  case 'video':
826
  $file_id = postie_media_handle_upload($part, $post_id, $poster);
827
  $file = wp_get_attachment_url($file_id);
828
- $cid = trim($part->headers["content-id"], "<>");
829
- ; //cids are in <cid>
 
 
830
  if (in_array(strtolower($part->ctype_secondary), $video1types)) {
831
  $videoTemplate = $video1template;
832
  } elseif (in_array(strtolower($part->ctype_secondary), $video2types)) {
@@ -859,6 +886,8 @@ function GetContent($part, &$attachments, $post_id, $poster, $config) {
859
  break;
860
  }
861
  }
 
 
862
  return $meta_return;
863
  }
864
 
@@ -1148,12 +1177,17 @@ function HandleMessageEncoding($contenttransferencoding, $charset, $body, $blogE
1148
  }
1149
 
1150
  DebugEcho("after HandleMessageEncoding");
1151
- if (strtolower($charset) != 'default')
 
 
1152
  $body = iconv($charset, $blogEncoding . '//TRANSLIT', $body);
 
 
1153
  return $body;
1154
  }
1155
 
1156
  function ConvertToUTF_8($charset, $body) {
 
1157
  return iconv($charset, "UTF-8//TRANSLIT", $body);
1158
  }
1159
 
@@ -1169,6 +1203,7 @@ function DecodeBase64Part(&$part) {
1169
  $part->body = base64_decode($part->body);
1170
  } else if (is_array($part->ctype_parameters) && array_key_exists('charset', $part->ctype_parameters)) {
1171
  $part->body = iconv($part->ctype_parameters['charset'], 'UTF-8//TRANSLIT', base64_decode($part->body));
 
1172
  $part->ctype_parameters['charset'] = 'default'; //so we don't double decode
1173
  } else {
1174
  $part->body = base64_decode($part->body);
@@ -1298,12 +1333,14 @@ function postie_media_handle_upload($part, $post_id, $poster, $post_data = array
1298
  }
1299
 
1300
  $name = 'postie-media.' . $part->ctype_secondary;
1301
- if (!is_array($part->ctype_parameters) || $part->ctype_parameters['name'] == '') {
1302
- if ($part->d_parameters['filename'] != '') {
1303
- $name = $part->d_parameters['filename'];
 
 
 
 
1304
  }
1305
- } else {
1306
- $name = $part->ctype_parameters['name'];
1307
  }
1308
  DebugEcho("name: $name, size: " . filesize($tmpFile));
1309
 
@@ -1480,49 +1517,43 @@ function postie_handle_upload(&$file, $overrides = false, $time = null) {
1480
  return $return;
1481
  }
1482
 
1483
- /**
1484
- * Searches for the existance of a certain MIME TYPE in the tree of mime attachments
1485
- * @param primary mime
1486
- * @param secondary mime
1487
- * @return boolean
1488
- */
1489
- function SearchForMIMEType($part, $primary, $secondary) {
1490
- if ($part->ctype_primary == $primary && $part->ctype_secondary == $secondary) {
1491
- return true;
1492
- }
1493
- if ($part->ctype_primary == "multipart") {
1494
- for ($i = 0; $i < count($part->parts); $i++) {
1495
- if (SearchForMIMEType($part->parts[$i], $primary, $secondary)) {
1496
- return true;
1497
- }
1498
- }
1499
- }
1500
- return false;
1501
- }
1502
-
1503
  /**
1504
  * This method sorts thru the mime parts of the message. It is looking for a certain type of text attachment. If
1505
  * that type is present it filters out all other text types. If it is not - then nothing is done
1506
  * @param object
1507
  */
1508
- function FilterTextParts(&$mimeDecodedEmail, $preferTextType) {
 
1509
  $newParts = array();
1510
  $found = false;
 
1511
  for ($i = 0; $i < count($mimeDecodedEmail->parts); $i++) {
1512
- if (in_array($mimeDecodedEmail->parts[$i]->ctype_primary, array("text", "multipart"))) {
1513
- if (SearchForMIMEType($mimeDecodedEmail->parts[$i], "text", $preferTextType)) {
1514
- $newParts[] = &$mimeDecodedEmail->parts[$i];
1515
- $found = true;
 
1516
  }
1517
  } else {
1518
- $newParts[] = &$mimeDecodedEmail->parts[$i];
1519
  }
 
 
 
 
 
 
 
 
 
 
1520
  }
1521
- if ($found && $newParts) {
1522
  //This is now the filtered list of just the preferred type.
1523
  DebugEcho(count($newParts) . " parts");
1524
  $mimeDecodedEmail->parts = $newParts;
1525
  }
 
1526
  }
1527
 
1528
  /**
@@ -1790,19 +1821,21 @@ function parseTemplate($id, $type, $template, $size = 'medium') {
1790
 
1791
  $template = str_replace('{TITLE}', $attachment->post_title, $template);
1792
  $template = str_replace('{ID}', $id, $template);
1793
- $template = str_replace('{THUMBNAIL}', $img_src[0], $template);
1794
- $template = str_replace('{THUMB}', $img_src[0], $template);
1795
- $template = str_replace('{MEDIUM}', $img_src[1], $template);
1796
- $template = str_replace('{LARGE}', $img_src[2], $template);
 
 
 
 
 
 
 
 
1797
  $template = str_replace('{FULL}', $fileLink, $template);
1798
  $template = str_replace('{FILELINK}', $fileLink, $template);
1799
  $template = str_replace('{PAGELINK}', $pageLink, $template);
1800
- $template = str_replace('{THUMBWIDTH}', $widths[0] . 'px', $template);
1801
- $template = str_replace('{THUMBHEIGHT}', $heights[0] . 'px', $template);
1802
- $template = str_replace('{MEDIUMWIDTH}', $widths[1] . 'px', $template);
1803
- $template = str_replace('{MEDIUMHEIGHT}', $heights[1] . 'px', $template);
1804
- $template = str_replace('{LARGEWIDTH}', $widths[2] . 'px', $template);
1805
- $template = str_replace('{LARGEHEIGHT}', $heights[2] . 'px', $template);
1806
  $template = str_replace('{FILENAME}', $fileName, $template);
1807
  $template = str_replace('{IMAGE}', $fileLink, $template);
1808
  $template = str_replace('{URL}', $fileLink, $template);
@@ -1952,12 +1985,15 @@ function GetSubject(&$mimeDecodedEmail, &$content, $config) {
1952
  } else {
1953
  $subject = $mimeDecodedEmail->headers['subject'];
1954
  DebugEcho(("Predecoded subject: $subject"));
 
1955
  if (array_key_exists('content-transfer-encoding', $mimeDecodedEmail->headers)) {
1956
  $encoding = $mimeDecodedEmail->headers["content-transfer-encoding"];
1957
  } else if (array_key_exists("content-transfer-encoding", $mimeDecodedEmail->ctype_parameters)) {
1958
  $encoding = $mimeDecodedEmail->ctype_parameters["content-transfer-encoding"];
1959
  } else {
1960
- $encoding = '7bit';
 
 
1961
  }
1962
  DebugEcho("Subject encoding: $encoding");
1963
 
@@ -1971,8 +2007,8 @@ function GetSubject(&$mimeDecodedEmail, &$content, $config) {
1971
 
1972
  for ($i = 0; $i < count($elements); $i++) {
1973
  $thischarset = $elements[$i]->charset;
1974
- // if ($thischarset == 'default')
1975
- // $thischarset = $charset;
1976
 
1977
  $subject.=HandleMessageEncoding($encoding, $thischarset, $elements[$i]->text, $message_encoding, $message_dequote);
1978
  }
@@ -1990,6 +2026,7 @@ function GetSubject(&$mimeDecodedEmail, &$content, $config) {
1990
  DebugEcho("extra parsing for ISO-2022-JP");
1991
  $subject = iconv("ISO-2022-JP", "UTF-8//TRANSLIT", $subject);
1992
  }
 
1993
  return $subject;
1994
  }
1995
 
@@ -2043,7 +2080,7 @@ function GetPostCategories(&$subject, $defaultCategory) {
2043
 
2044
  if (preg_match_all('/\[(.[^\[]*)\]/', $subject, $matches)) { // [<category1>] [<category2>] <Subject>
2045
  preg_match("/]([^\[]*)$/", $subject, $subject_matches);
2046
- DebugDump($subject_matches);
2047
  $subject = trim($subject_matches[1]);
2048
  $matchtypes[] = $matches;
2049
  }
1
  <?php
2
 
3
  /*
4
+ $Id: postie-functions.php 647617 2013-01-03 22:36:57Z WayneAllen $
5
  */
6
 
7
  /* TODO
145
  "image_files" => array() //holds the files for each image
146
  );
147
  EchoInfo("Message Id is :" . htmlentities($mimeDecodedEmail->headers["message-id"]));
148
+ //DebugDump($mimeDecodedEmail);
149
 
150
  FilterTextParts($mimeDecodedEmail, $prefer_text_type);
151
+ //DebugDump($mimeDecodedEmail);
152
+
153
  $tmpPost = array('post_title' => 'tmptitle', 'post_content' => 'tmpPost');
154
  /* in order to do attachments correctly, we need to associate the
155
  attachments with a post. So we add the post here, then update it
250
 
251
  $post_type = GetPostType($subject);
252
 
253
+ //DebugEcho("pre-insert content: $content");
254
+
255
  $details = array(
256
  'post_author' => $poster,
257
  'comment_author' => $postAuthorDetails['author'],
336
  }
337
 
338
  function clickableLink($text, $shortcode = false) {
339
+ # this functions deserves credit to the fine folks at phpbb.com
340
+ # It turns urls into links, and video urls into embedded players
341
+ //DebugEcho("begin: clickableLink");
342
 
343
  $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);
344
+ //DebugEcho($text);
345
  // pad it with a space so we can match things at the start of the 1st line.
346
  $ret = ' ' . $text;
347
  if (strpos($ret, 'youtube') !== false) {
348
  // try to embed youtube videos
349
  $youtube = "#(^|[\n ]|>)[\w]+?://(www\.)?youtube\.com/watch\?v=([_a-zA-Z0-9-]+).*?([ \n]|$|<)#is";
 
350
  if ($shortcode) {
351
  $youtube_replace = "\\1[youtube \\3]\\4";
352
  } else {
353
  $youtube_replace = "\\1<embed width='425' height='344' allowfullscreen='true' allowscriptaccess='always' type='application/x-shockwave-flash' src=\"http://www.youtube.com/v/\\3&hl=en&fs=1\" />\\4";
354
  }
355
  $ret = preg_replace($youtube, $youtube_replace, $ret);
356
+ //DebugEcho("youtube: $ret");
357
  }
358
 
359
  if (strpos($ret, 'vimeo') !== false) {
360
  // try to embed vimeo videos
361
  # : http://vimeo.com/6348141
362
  $vimeo = "#(^|[\n ]|>)[\w]+?://(www\.)?vimeo\.com/([_a-zA-Z0-9-]+).*?([ \n]|$|<)#is";
 
363
  if ($shortcode) {
364
  $vimeo_replace = "\\1[vimeo \\3]\\4";
365
  } else {
366
+ $vimeo_replace = "\\1<object width='400' height='300'><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='movie' value='http://vimeo.com/moogaloop.swf?clip_id=\\3&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1' /><embed src='http://vimeo.com/moogaloop.swf?clip_id=\\3&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1' type='application/x-shockwave-flash' allowfullscreen='true' allowscriptaccess='always' width='400' height='300'></embed></object>\\4";
 
 
 
 
 
 
 
 
367
  }
368
  $ret = preg_replace($vimeo, $vimeo_replace, $ret);
369
+ //DebugEcho("vimeo: $ret");
370
  }
371
 
372
  // matches an "xxxx://yyyy" URL at the start of a line, or after a space.
373
  // xxxx can only be alpha characters.
374
  // yyyy is anything up to the first space, newline, comma, double quote or <
375
  $ret = preg_replace("#(^|[\n ])<?([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)>?#is", "\\1<a href=\"\\2\" >\\2</a>", $ret);
376
+ //DebugEcho("xxxx://yyyy: $ret");
377
  // matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
378
+ $ret = make_links($ret);
379
+ //DebugEcho("www|ftp.xxxx.yyyy[/zzzz]: $ret");
 
 
 
 
 
 
 
380
  // Remove our padding..
381
  $ret = substr($ret, 1);
382
+
383
+ //DebugEcho("end: clickableLink");
384
  return $ret;
385
  }
386
 
387
+ function make_links($text) {
388
+ return preg_replace(
389
+ array(
390
+ '/(?(?=<a[^>]*>.+<\/a>)
391
+ (?:<a[^>]*>.+<\/a>)
392
+ |
393
+ ([^="\']?)((?:https?|ftp|bf2|):\/\/[^<> \n\r]+)
394
+ )/iex',
395
+ '/<a([^>]*)target="?[^"\']+"?/i',
396
+ '/<a([^>]+)>/i',
397
+ '/(^|\s)(www.[^<> \n\r]+)/iex',
398
+ '/(([_A-Za-z0-9-]+)(\\.[_A-Za-z0-9-]+)*@([A-Za-z0-9-]+)
399
+ (\\.[A-Za-z0-9-]+)*)/iex'
400
+ ), array(
401
+ "stripslashes((strlen('\\2')>0?'\\1<a href=\"\\2\">\\2</a>\\3':'\\0'))",
402
+ '<a\\1',
403
+ '<a\\1 >',
404
+ "stripslashes((strlen('\\2')>0?'\\1<a href=\"http://\\2\">\\2</a>\\3':'\\0'))",
405
+ "stripslashes((strlen('\\2')>0?'<a href=\"mailto:\\0\">\\0</a>':'\\0'))"
406
+ ), $text
407
+ );
408
+ }
409
+
410
  function getPostAuthorDetails(&$subject, &$content, &$mimeDecodedEmail) {
411
  /* we check whether or not the e-mail is a forwards or a redirect. If it is
412
  * a fwd, then we glean the author details from the body of the post.
715
  DecodeBase64Part($part);
716
 
717
  //look for banned file names
718
+ if (property_exists($part, 'ctype_parameters') && is_array($part->ctype_parameters) && array_key_exists('name', $part->ctype_parameters))
719
  if (BannedFileName($part->ctype_parameters['name'], $banned_files_list))
720
  return NULL;
721
 
739
  }
740
 
741
  if ($part->ctype_primary == "multipart" && $part->ctype_secondary == "appledouble") {
742
+ DebugEcho("multipart appledouble");
743
  $mimeDecodedEmail = DecodeMIMEMail("Content-Type: multipart/mixed; boundary=" . $part->ctype_parameters["boundary"] . "\n" . $part->body);
744
  FilterTextParts($mimeDecodedEmail, $prefer_text_type);
745
  FilterAppleFile($mimeDecodedEmail);
748
  }
749
  } else {
750
  $filename = "";
751
+ if (property_exists($part, 'ctype_parameters') && is_array($part->ctype_parameters) && array_key_exists('name', $part->ctype_parameters)) {
752
  // fix filename (remove non-standard characters)
753
  $filename = preg_replace("/[^\x9\xA\xD\x20-\x7F]/", "", $part->ctype_parameters['name']);
754
  DebugEcho("Filename: $filename");
755
  }
756
  switch (strtolower($part->ctype_primary)) {
757
  case 'multipart':
758
+ DebugEcho("multipart: " . count($part->parts));
759
  //DebugDump($part);
760
  FilterTextParts($part, $prefer_text_type);
761
  foreach ($part->parts as $section) {
762
+ DebugDump($section->headers);
763
+
764
  $meta_return .= GetContent($section, $attachments, $post_id, $poster, $config);
765
  }
766
  break;
784
  if (array_key_exists('content-transfer-encoding', $part->headers)) {
785
  //DebugDump($part);
786
  $part->body = HandleMessageEncoding($encoding, $charset, $part->body, $message_encoding, $message_dequote);
787
+ if (!empty($charset)) {
788
+ $part->ctype_parameters['charset'] = ""; //reset so we don't double decode
789
+ }
790
  //DebugDump($part);
791
  }
792
 
800
  DebugEcho("html");
801
  $meta_return .= HTML2HTML($part->body) . "\n";
802
  } else {
 
803
  DebugEcho("plain text");
804
  if ($allow_html_in_body) {
805
+ DebugEcho("html allowed");
806
  $meta_return .= $part->body;
807
+ //$meta_return = "<div>$meta_return</div>\n";
808
  } else {
809
+ DebugEcho("html not allowed (htmlentities)");
810
  $meta_return .= htmlentities($part->body);
811
  }
812
  $meta_return = StripPGP($meta_return);
 
 
813
  }
814
+
815
  break;
816
 
817
  case 'image':
834
  case 'audio':
835
  $file_id = postie_media_handle_upload($part, $post_id, $poster);
836
  $file = wp_get_attachment_url($file_id);
837
+ $cid = "";
838
+ if (array_key_exists('content-id', $part->headers)) {
839
+ $cid = trim($part->headers["content-id"], "<>");
840
+ }
841
  if (in_array($part->ctype_secondary, $audiotypes)) {
842
  $audioTemplate = $audiotemplate;
843
  } else {
850
  case 'video':
851
  $file_id = postie_media_handle_upload($part, $post_id, $poster);
852
  $file = wp_get_attachment_url($file_id);
853
+ $cid = "";
854
+ if (array_key_exists('content-id', $part->headers)) {
855
+ $cid = trim($part->headers["content-id"], "<>");
856
+ }
857
  if (in_array(strtolower($part->ctype_secondary), $video1types)) {
858
  $videoTemplate = $video1template;
859
  } elseif (in_array(strtolower($part->ctype_secondary), $video2types)) {
886
  break;
887
  }
888
  }
889
+ //DebugEcho("text: $meta_return");
890
+ DebugEcho("----");
891
  return $meta_return;
892
  }
893
 
1177
  }
1178
 
1179
  DebugEcho("after HandleMessageEncoding");
1180
+ if (!empty($charset) && strtolower($charset) != 'default') {
1181
+ DebugEcho("converting from $charset to $blogEncoding");
1182
+ //DebugEcho("before: $body");
1183
  $body = iconv($charset, $blogEncoding . '//TRANSLIT', $body);
1184
+ //DebugEcho("after: $body");
1185
+ }
1186
  return $body;
1187
  }
1188
 
1189
  function ConvertToUTF_8($charset, $body) {
1190
+ DebugEcho("convert to utf-8");
1191
  return iconv($charset, "UTF-8//TRANSLIT", $body);
1192
  }
1193
 
1203
  $part->body = base64_decode($part->body);
1204
  } else if (is_array($part->ctype_parameters) && array_key_exists('charset', $part->ctype_parameters)) {
1205
  $part->body = iconv($part->ctype_parameters['charset'], 'UTF-8//TRANSLIT', base64_decode($part->body));
1206
+ DebugEcho("convertef from: " . $part->ctype_parameters['charset']);
1207
  $part->ctype_parameters['charset'] = 'default'; //so we don't double decode
1208
  } else {
1209
  $part->body = base64_decode($part->body);
1333
  }
1334
 
1335
  $name = 'postie-media.' . $part->ctype_secondary;
1336
+ if (property_exists($part, 'ctype_parameters')) {
1337
+ if (!is_array($part->ctype_parameters) || $part->ctype_parameters['name'] == '') {
1338
+ if ($part->d_parameters['filename'] != '') {
1339
+ $name = $part->d_parameters['filename'];
1340
+ }
1341
+ } else {
1342
+ $name = $part->ctype_parameters['name'];
1343
  }
 
 
1344
  }
1345
  DebugEcho("name: $name, size: " . filesize($tmpFile));
1346
 
1517
  return $return;
1518
  }
1519
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1520
  /**
1521
  * This method sorts thru the mime parts of the message. It is looking for a certain type of text attachment. If
1522
  * that type is present it filters out all other text types. If it is not - then nothing is done
1523
  * @param object
1524
  */
1525
+ function FilterTextParts($mimeDecodedEmail, $preferTextType) {
1526
+ DebugEcho("FilterTextParts: begin " . count($mimeDecodedEmail->parts));
1527
  $newParts = array();
1528
  $found = false;
1529
+
1530
  for ($i = 0; $i < count($mimeDecodedEmail->parts); $i++) {
1531
+ DebugEcho("part: $i " . $mimeDecodedEmail->parts[$i]->ctype_primary);
1532
+
1533
+ if ($mimeDecodedEmail->parts[$i]->ctype_primary == "text") {
1534
+ if ($mimeDecodedEmail->parts[$i]->ctype_secondary == $preferTextType) {
1535
+ $newParts[] = $mimeDecodedEmail->parts[$i];
1536
  }
1537
  } else {
1538
+ $newParts[] = $mimeDecodedEmail->parts[$i];
1539
  }
1540
+
1541
+ // if (in_array($mimeDecodedEmail->parts[$i]->ctype_primary, array("text", "multipart"))) {
1542
+ // if (SearchForMIMEType($mimeDecodedEmail->parts[$i], "text", $preferTextType)) {
1543
+ // $newParts[] = $mimeDecodedEmail->parts[$i];
1544
+ // $found = true;
1545
+ // DebugEcho("found");
1546
+ // }
1547
+ // } else {
1548
+ // $newParts[] = $mimeDecodedEmail->parts[$i];
1549
+ // }
1550
  }
1551
+ if ($newParts) {
1552
  //This is now the filtered list of just the preferred type.
1553
  DebugEcho(count($newParts) . " parts");
1554
  $mimeDecodedEmail->parts = $newParts;
1555
  }
1556
+ DebugEcho("FilterTextParts: end");
1557
  }
1558
 
1559
  /**
1821
 
1822
  $template = str_replace('{TITLE}', $attachment->post_title, $template);
1823
  $template = str_replace('{ID}', $id, $template);
1824
+ if ($type == 'image') {
1825
+ $template = str_replace('{THUMBNAIL}', $img_src[0], $template);
1826
+ $template = str_replace('{THUMB}', $img_src[0], $template);
1827
+ $template = str_replace('{MEDIUM}', $img_src[1], $template);
1828
+ $template = str_replace('{LARGE}', $img_src[2], $template);
1829
+ $template = str_replace('{THUMBWIDTH}', $widths[0] . 'px', $template);
1830
+ $template = str_replace('{THUMBHEIGHT}', $heights[0] . 'px', $template);
1831
+ $template = str_replace('{MEDIUMWIDTH}', $widths[1] . 'px', $template);
1832
+ $template = str_replace('{MEDIUMHEIGHT}', $heights[1] . 'px', $template);
1833
+ $template = str_replace('{LARGEWIDTH}', $widths[2] . 'px', $template);
1834
+ $template = str_replace('{LARGEHEIGHT}', $heights[2] . 'px', $template);
1835
+ }
1836
  $template = str_replace('{FULL}', $fileLink, $template);
1837
  $template = str_replace('{FILELINK}', $fileLink, $template);
1838
  $template = str_replace('{PAGELINK}', $pageLink, $template);
 
 
 
 
 
 
1839
  $template = str_replace('{FILENAME}', $fileName, $template);
1840
  $template = str_replace('{IMAGE}', $fileLink, $template);
1841
  $template = str_replace('{URL}', $fileLink, $template);
1985
  } else {
1986
  $subject = $mimeDecodedEmail->headers['subject'];
1987
  DebugEcho(("Predecoded subject: $subject"));
1988
+
1989
  if (array_key_exists('content-transfer-encoding', $mimeDecodedEmail->headers)) {
1990
  $encoding = $mimeDecodedEmail->headers["content-transfer-encoding"];
1991
  } else if (array_key_exists("content-transfer-encoding", $mimeDecodedEmail->ctype_parameters)) {
1992
  $encoding = $mimeDecodedEmail->ctype_parameters["content-transfer-encoding"];
1993
  } else {
1994
+ $encoding = 'ISO-8859-1';
1995
+ $subject = iconv($encoding, 'UTF-8', $mimeDecodedEmail->headers['subject']);
1996
+ DebugEcho(("ISO-8859-1 decoded subject: $subject"));
1997
  }
1998
  DebugEcho("Subject encoding: $encoding");
1999
 
2007
 
2008
  for ($i = 0; $i < count($elements); $i++) {
2009
  $thischarset = $elements[$i]->charset;
2010
+ if ($thischarset == 'default')
2011
+ $thischarset = "ISO-8859-1";
2012
 
2013
  $subject.=HandleMessageEncoding($encoding, $thischarset, $elements[$i]->text, $message_encoding, $message_dequote);
2014
  }
2026
  DebugEcho("extra parsing for ISO-2022-JP");
2027
  $subject = iconv("ISO-2022-JP", "UTF-8//TRANSLIT", $subject);
2028
  }
2029
+ DebugEcho("Subject: $subject");
2030
  return $subject;
2031
  }
2032
 
2080
 
2081
  if (preg_match_all('/\[(.[^\[]*)\]/', $subject, $matches)) { // [<category1>] [<category2>] <Subject>
2082
  preg_match("/]([^\[]*)$/", $subject, $subject_matches);
2083
+ //DebugDump($subject_matches);
2084
  $subject = trim($subject_matches[1]);
2085
  $matchtypes[] = $matches;
2086
  }
postie.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Signifigantly upgrades the posting by mail features of Word Press (See <a href='options-general.php?page=postie/postie.php'>Settings and options</a>) to configure your e-mail settings. See the <a href='http://wordpress.org/extend/plugins/postie/other_notes'>Readme</a> for usage. Visit the <a href='http://wordpress.org/support/plugin/postie'>postie forum</a> for support.
7
- Version: 1.4.15
8
  Author: Wayne Allen
9
  Author URI: http://allens-home.com/
10
  License: GPL2
@@ -27,7 +27,7 @@
27
  */
28
 
29
  /*
30
- $Id: postie.php 647311 2013-01-03 04:18:03Z WayneAllen $
31
  * -= Requests Pending =-
32
  * Problem with some mail server
33
  * Multiple emails should tie to a single account
4
  Plugin Name: Postie
5
  Plugin URI: http://PostiePlugin.com/
6
  Description: Signifigantly upgrades the posting by mail features of Word Press (See <a href='options-general.php?page=postie/postie.php'>Settings and options</a>) to configure your e-mail settings. See the <a href='http://wordpress.org/extend/plugins/postie/other_notes'>Readme</a> for usage. Visit the <a href='http://wordpress.org/support/plugin/postie'>postie forum</a> for support.
7
+ Version: 1.4.16
8
  Author: Wayne Allen
9
  Author URI: http://allens-home.com/
10
  License: GPL2
27
  */
28
 
29
  /*
30
+ $Id: postie.php 647617 2013-01-03 22:36:57Z WayneAllen $
31
  * -= Requests Pending =-
32
  * Problem with some mail server
33
  * Multiple emails should tie to a single account
readme.txt CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://PostiePlugin.com/
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5
9
- Stable tag: 1.4.15
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -370,17 +370,22 @@ It is also possible to turn the WordPress cron off. Please make sure something l
370
  * All script, style and body tags are stripped from html emails.
371
 
372
  == CHANGELOG ==
373
- 1.4.15 (2013.01.02) =
 
 
 
 
 
374
  * Fixed a bug when a category is specified with [] and a colon (:) is in the subject, but not specifying a category
375
 
376
- 1.4.14 (2012.12.29) =
377
  * Fixed a bug where attached images were not being detected properly causing a "File is empty. Please upload something more substantial." error
378
  * Tweaked some CSS.
379
 
380
- 1.4.13 (2012.12.26) =
381
  * Fixed bug that was truncating content at the first html encoded character.
382
 
383
- 1.4.12 (2012.12.17) =
384
  * Added feature to limit the number of emails processed
385
  * Fixed bug where #img# was not processing the caption correctly
386
 
6
  Tags: e-mail, email
7
  Requires at least: 3.0
8
  Tested up to: 3.5
9
+ Stable tag: 1.4.16
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
370
  * All script, style and body tags are stripped from html emails.
371
 
372
  == CHANGELOG ==
373
+ = 1.4.16 (2013.01.03) =
374
+ * Fixed a bug where an extra div tag was getting added.
375
+ * Fixed a bug when linkifying URLs.
376
+ * Fixed a bug where inline images were not being detected.
377
+
378
+ = 1.4.15 (2013.01.02) =
379
  * Fixed a bug when a category is specified with [] and a colon (:) is in the subject, but not specifying a category
380
 
381
+ = 1.4.14 (2012.12.29) =
382
  * Fixed a bug where attached images were not being detected properly causing a "File is empty. Please upload something more substantial." error
383
  * Tweaked some CSS.
384
 
385
+ = 1.4.13 (2012.12.26) =
386
  * Fixed bug that was truncating content at the first html encoded character.
387
 
388
+ = 1.4.12 (2012.12.17) =
389
  * Added feature to limit the number of emails processed
390
  * Fixed bug where #img# was not processing the caption correctly
391
 
test/inlineimageTest.php CHANGED
@@ -106,7 +106,7 @@ class postiefunctions2Test extends PHPUnit_Framework_TestCase {
106
 
107
  $customImages = SpecialMessageParsing($content, $attachments, $config);
108
  $this->assertEquals(null, $customImages);
109
- $this->assertEquals("<div>test content\n\n", $content);
110
 
111
  $post_excerpt = GetPostExcerpt($content, $filternewlines, $convertnewline);
112
 
106
 
107
  $customImages = SpecialMessageParsing($content, $attachments, $config);
108
  $this->assertEquals(null, $customImages);
109
+ $this->assertEquals("test content\n\n", $content);
110
 
111
  $post_excerpt = GetPostExcerpt($content, $filternewlines, $convertnewline);
112
 
test/postie-functionsTest.php CHANGED
@@ -421,6 +421,14 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
421
  $this->assertEquals("test \nmore stuff\n:end", $c);
422
  }
423
 
 
 
 
 
 
 
 
 
424
  }
425
 
426
  ?>
421
  $this->assertEquals("test \nmore stuff\n:end", $c);
422
  }
423
 
424
+ public function testclickableLink() {
425
+ $this->assertEquals("", clickableLink(""));
426
+ $this->assertEquals("test", clickableLink("test"));
427
+ $this->assertEquals('<a href="http://www.example.com" >http://www.example.com</a>', clickableLink("http://www.example.com"));
428
+ $this->assertEquals('<a href="http://www.example.com">www.example.com</a>', clickableLink("www.example.com"));
429
+ $this->assertEquals('<a href="http://www.example.com">www.example.com</a> <a href="http://www.example.com">www.example.com</a>', clickableLink("www.example.com www.example.com"));
430
+ $this->assertEquals('<a href="mailto:bob@example.com">bob@example.com</a>', clickableLink("bob@example.com"));
431
+ }
432
  }
433
 
434
  ?>