Postie - Version 1.4.15

Version Description

  • Attachments are now processed in the order they were attached.
  • All script, style and body tags are stripped from html emails.
Download this release

Release Info

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

Code changes from version 1.4.14 to 1.4.15

docs/Changes.txt CHANGED
@@ -3,6 +3,9 @@
3
  * All script, style and body tags are stripped from html emails.
4
 
5
  == CHANGELOG ==
 
 
 
6
  1.4.14 (2012.12.29) =
7
  * Fixed a bug where attached images were not being detected properly causing a "File is empty. Please upload something more substantial." error
8
  * Tweaked some CSS.
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.
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.14
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.15
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
postie-functions.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /*
4
- $Id: postie-functions.php 646011 2012-12-30 07:02:11Z WayneAllen $
5
  */
6
 
7
  /* TODO
@@ -2037,43 +2037,36 @@ function GetPostCategories(&$subject, $defaultCategory) {
2037
  global $wpdb;
2038
  $original_subject = $subject;
2039
  $post_categories = array();
 
2040
  $matches = array();
2041
  //try and determine category
2042
- if (preg_match('/(.+): (.*)/', $subject, $matches)) { // <category>:<Subject>
2043
- $subject = trim($matches[2]);
2044
- $matches[1] = array($matches[1]);
2045
- } else if (preg_match_all('/\[(.[^\[]*)\]/', $subject, $matches)) { // [<category1>] [<category2>] <Subject>
2046
  preg_match("/]([^\[]*)$/", $subject, $subject_matches);
 
2047
  $subject = trim($subject_matches[1]);
2048
- } else if (preg_match_all('/-(.[^-]*)-/', $subject, $matches)) { // -<category>- -<category2>- <Subject>
 
 
2049
  preg_match("/-(.[^-]*)$/", $subject, $subject_matches);
2050
  $subject = trim($subject_matches[1]);
 
2051
  }
2052
- if (count($matches)) {
2053
- foreach ($matches[1] as $match) {
2054
- $match = trim($match);
2055
- $category = NULL;
2056
- //EchoInfo("Categories - Working on $match");
2057
-
2058
- $sql_name = 'SELECT term_id
2059
- FROM ' . $wpdb->terms . '
2060
- WHERE name=\'' . addslashes($match) . '\'';
2061
- $sql_id = 'SELECT term_id
2062
- FROM ' . $wpdb->terms . '
2063
- WHERE term_id=\'' . addslashes($match) . '\'';
2064
- $sql_sub_name = 'SELECT term_id
2065
- FROM ' . $wpdb->terms . '
2066
- WHERE name LIKE \'' . addslashes($match) . '%\' limit 1';
2067
-
2068
- if ($category = $wpdb->get_var($sql_name)) {
2069
- //then category is a named and found
2070
- } elseif ($category = $wpdb->get_var($sql_id)) {
2071
- //then cateogry was an ID and found
2072
- } elseif ($category = $wpdb->get_var($sql_sub_name)) {
2073
- //then cateogry is a start of a name and found
2074
- }
2075
- if (!empty($category)) {
2076
- $post_categories[] = $category;
2077
  }
2078
  }
2079
  }
@@ -2084,6 +2077,26 @@ function GetPostCategories(&$subject, $defaultCategory) {
2084
  return $post_categories;
2085
  }
2086
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2087
  /**
2088
  * This function just outputs a simple html report about what is being posted in
2089
  */
1
  <?php
2
 
3
  /*
4
+ $Id: postie-functions.php 647311 2013-01-03 04:18:03Z WayneAllen $
5
  */
6
 
7
  /* TODO
2037
  global $wpdb;
2038
  $original_subject = $subject;
2039
  $post_categories = array();
2040
+ $matchtypes = array();
2041
  $matches = array();
2042
  //try and determine category
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
+ }
2050
+ if (preg_match_all('/-(.[^-]*)-/', $subject, $matches)) { // -<category>- -<category2>- <Subject>
2051
  preg_match("/-(.[^-]*)$/", $subject, $subject_matches);
2052
  $subject = trim($subject_matches[1]);
2053
+ $matchtypes[] = $matches;
2054
  }
2055
+ if (preg_match('/(.+): (.*)/', $subject, $matches)) { // <category>:<Subject>
2056
+ $category = CategoryLookup($matches[1]);
2057
+ if (!empty($category)) {
2058
+ $subject = trim($matches[2]);
2059
+ $post_categories[] = $category;
2060
+ }
2061
+ }
2062
+
2063
+ foreach ($matchtypes as $matches) {
2064
+ if (count($matches)) {
2065
+ foreach ($matches[1] as $match) {
2066
+ $category = CategoryLookup($match);
2067
+ if (!empty($category)) {
2068
+ $post_categories[] = $category;
2069
+ }
 
 
 
 
 
 
 
 
 
 
2070
  }
2071
  }
2072
  }
2077
  return $post_categories;
2078
  }
2079
 
2080
+ function CategoryLookup($trial_category) {
2081
+ global $wpdb;
2082
+ $trial_category = trim($trial_category);
2083
+ $found_category = NULL;
2084
+ EchoInfo("Categories - Working on $trial_category");
2085
+
2086
+ $sql_name = 'SELECT term_id FROM ' . $wpdb->terms . ' WHERE name=\'' . addslashes($trial_category) . '\'';
2087
+ $sql_id = 'SELECT term_id FROM ' . $wpdb->terms . ' WHERE term_id=\'' . addslashes($trial_category) . '\'';
2088
+ $sql_sub_name = 'SELECT term_id FROM ' . $wpdb->terms . ' WHERE name LIKE \'' . addslashes($trial_category) . '%\' limit 1';
2089
+
2090
+ if ($found_category = $wpdb->get_var($sql_name)) {
2091
+ //then category is a named and found
2092
+ } elseif ($found_category = $wpdb->get_var($sql_id)) {
2093
+ //then cateogry was an ID and found
2094
+ } elseif ($found_category = $wpdb->get_var($sql_sub_name)) {
2095
+ //then cateogry is a start of a name and found
2096
+ }
2097
+ return $found_category;
2098
+ }
2099
+
2100
  /**
2101
  * This function just outputs a simple html report about what is being posted in
2102
  */
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.14
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 646010 2012-12-30 07:01:19Z 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.15
8
  Author: Wayne Allen
9
  Author URI: http://allens-home.com/
10
  License: GPL2
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
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.14
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -370,6 +370,9 @@ 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.14 (2012.12.29) =
374
  * Fixed a bug where attached images were not being detected properly causing a "File is empty. Please upload something more substantial." error
375
  * Tweaked some CSS.
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
  * 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.
test/postie-functionsTest.php CHANGED
@@ -154,10 +154,9 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
154
 
155
  $c = "tags: Station, Kohnen, Flugzeug\n:end\n21.10.2012";
156
  $this->assertEquals("tags: Station, Kohnen, Flugzeug\n", EndFilter($c, ":end"));
157
-
158
  $c = "This is a test :end";
159
  $this->assertEquals("This is a test ", EndFilter($c, ":end"));
160
-
161
  }
162
 
163
  public function testFilterNewLines() {
@@ -281,12 +280,13 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
281
  $this->assertEquals("general", $c[0]);
282
  $this->assertEquals("test", $s);
283
 
 
284
  $s = "[general] test";
285
  $c = GetPostCategories($s, "default");
286
  $this->assertEquals("general", $c[0]);
287
  $this->assertEquals("test", $s);
288
 
289
-
290
  $s = "-general- test";
291
  $c = GetPostCategories($s, "default");
292
  $this->assertEquals("general", $c[0]);
@@ -298,13 +298,19 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
298
  $this->assertEquals("default", $c[0]);
299
  $this->assertEquals("specific: test", $s);
300
 
301
- $wpdb->t_get_var = "1";
302
  $s = "[1] [1] test";
303
  $c = GetPostCategories($s, "default");
304
  $this->assertEquals(2, count($c));
305
  $this->assertEquals("1", $c[0]);
306
  $this->assertEquals("1", $c[1]);
307
  $this->assertEquals("test", $s);
 
 
 
 
 
 
308
  }
309
 
310
  public function testHTML2HTML() {
@@ -348,8 +354,8 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
348
  $t = postie_get_tags($c, "");
349
  $this->assertEquals(0, count($t));
350
  $this->assertEquals("test", $c);
351
-
352
- $c = "test";
353
  $t = postie_get_tags($c, array("tag1"));
354
  $this->assertEquals(1, count($t));
355
  $this->assertEquals("tag1", $t[0]);
@@ -369,7 +375,7 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
369
  $t = postie_get_tags($c, "");
370
  $this->assertEquals(1, count($t));
371
  $this->assertEquals("test ", $c);
372
-
373
  $c = "test\ntags: tag1";
374
  $t = postie_get_tags($c, "");
375
  $this->assertEquals(1, count($t));
@@ -386,27 +392,27 @@ class postiefunctionsTest extends PHPUnit_Framework_TestCase {
386
  $this->assertEquals(1, count($t));
387
  $this->assertEquals("tag1", $t[0]);
388
  $this->assertEquals("test ", $c);
389
-
390
- $c = "test tags:tag1";
391
  $t = postie_get_tags($c, array("tagx"));
392
  $this->assertEquals(1, count($t));
393
  $this->assertEquals("tag1", $t[0]);
394
  $this->assertEquals("test ", $c);
395
-
396
  $c = "test tags:tag1,tag2";
397
  $t = postie_get_tags($c, "");
398
  $this->assertEquals(2, count($t));
399
  $this->assertEquals("tag1", $t[0]);
400
  $this->assertEquals("tag2", $t[1]);
401
  $this->assertEquals("test ", $c);
402
-
403
  $c = "test tags: tag3,tag4\nmore stuff\n:end";
404
  $t = postie_get_tags($c, "");
405
  $this->assertEquals(2, count($t));
406
  $this->assertEquals("tag3", $t[0]);
407
  $this->assertEquals("tag4", $t[1]);
408
  $this->assertEquals("test \nmore stuff\n:end", $c);
409
-
410
  $c = "test tags:tag1,tag2\nmore stuff\n:end";
411
  $t = postie_get_tags($c, "");
412
  $this->assertEquals(2, count($t));
154
 
155
  $c = "tags: Station, Kohnen, Flugzeug\n:end\n21.10.2012";
156
  $this->assertEquals("tags: Station, Kohnen, Flugzeug\n", EndFilter($c, ":end"));
157
+
158
  $c = "This is a test :end";
159
  $this->assertEquals("This is a test ", EndFilter($c, ":end"));
 
160
  }
161
 
162
  public function testFilterNewLines() {
280
  $this->assertEquals("general", $c[0]);
281
  $this->assertEquals("test", $s);
282
 
283
+ $wpdb->t_get_var = "general";
284
  $s = "[general] test";
285
  $c = GetPostCategories($s, "default");
286
  $this->assertEquals("general", $c[0]);
287
  $this->assertEquals("test", $s);
288
 
289
+ $wpdb->t_get_var = "general";
290
  $s = "-general- test";
291
  $c = GetPostCategories($s, "default");
292
  $this->assertEquals("general", $c[0]);
298
  $this->assertEquals("default", $c[0]);
299
  $this->assertEquals("specific: test", $s);
300
 
301
+ $wpdb->t_get_var = array("1", "1");
302
  $s = "[1] [1] test";
303
  $c = GetPostCategories($s, "default");
304
  $this->assertEquals(2, count($c));
305
  $this->assertEquals("1", $c[0]);
306
  $this->assertEquals("1", $c[1]);
307
  $this->assertEquals("test", $s);
308
+
309
+ $wpdb->t_get_var = array(null, null, null, "general");
310
+ $s = "[general] test: with colon";
311
+ $c = GetPostCategories($s, "default");
312
+ $this->assertEquals("general", $c[0]);
313
+ $this->assertEquals("test: with colon", $s);
314
  }
315
 
316
  public function testHTML2HTML() {
354
  $t = postie_get_tags($c, "");
355
  $this->assertEquals(0, count($t));
356
  $this->assertEquals("test", $c);
357
+
358
+ $c = "test";
359
  $t = postie_get_tags($c, array("tag1"));
360
  $this->assertEquals(1, count($t));
361
  $this->assertEquals("tag1", $t[0]);
375
  $t = postie_get_tags($c, "");
376
  $this->assertEquals(1, count($t));
377
  $this->assertEquals("test ", $c);
378
+
379
  $c = "test\ntags: tag1";
380
  $t = postie_get_tags($c, "");
381
  $this->assertEquals(1, count($t));
392
  $this->assertEquals(1, count($t));
393
  $this->assertEquals("tag1", $t[0]);
394
  $this->assertEquals("test ", $c);
395
+
396
+ $c = "test tags:tag1";
397
  $t = postie_get_tags($c, array("tagx"));
398
  $this->assertEquals(1, count($t));
399
  $this->assertEquals("tag1", $t[0]);
400
  $this->assertEquals("test ", $c);
401
+
402
  $c = "test tags:tag1,tag2";
403
  $t = postie_get_tags($c, "");
404
  $this->assertEquals(2, count($t));
405
  $this->assertEquals("tag1", $t[0]);
406
  $this->assertEquals("tag2", $t[1]);
407
  $this->assertEquals("test ", $c);
408
+
409
  $c = "test tags: tag3,tag4\nmore stuff\n:end";
410
  $t = postie_get_tags($c, "");
411
  $this->assertEquals(2, count($t));
412
  $this->assertEquals("tag3", $t[0]);
413
  $this->assertEquals("tag4", $t[1]);
414
  $this->assertEquals("test \nmore stuff\n:end", $c);
415
+
416
  $c = "test tags:tag1,tag2\nmore stuff\n:end";
417
  $t = postie_get_tags($c, "");
418
  $this->assertEquals(2, count($t));
test/wpstub.php CHANGED
@@ -9,9 +9,20 @@ class wpdb {
9
  public $terms = 'wp_terms';
10
 
11
  public function get_var($query, $column_offset = 0, $row_offset = 0) {
12
- return $this->t_get_var;
 
 
 
 
 
 
 
 
 
 
 
 
13
  }
14
-
15
  }
16
 
17
  class WP_Error {
9
  public $terms = 'wp_terms';
10
 
11
  public function get_var($query, $column_offset = 0, $row_offset = 0) {
12
+ if (is_array($this->t_get_var)) {
13
+ if (count($this->t_get_var) > 0) {
14
+ $r = $this->t_get_var[0];
15
+ unset($this->t_get_var[0]);
16
+ $this->t_get_var = array_values($this->t_get_var);
17
+ } else {
18
+ $r = null;
19
+ }
20
+ } else {
21
+ $r = $this->t_get_var;
22
+ $this->t_get_var = "";
23
+ }
24
+ return $r;
25
  }
 
26
  }
27
 
28
  class WP_Error {