Postie - Version 1.3.4

Version Description

(2009.10.05) = * Fixed problem with images not posting under cron * Fixed issue with disappearing password

Download this release

Release Info

Developer robfelty
Plugin Icon 128x128 Postie
Version 1.3.4
Comparing to
See all releases

Code changes from version 1.3.3 to 1.3.4

Files changed (7) hide show
  1. Revision +2 -2
  2. cronless_postie.php +13 -3
  3. filterPostie.php +1 -1
  4. get_mail.php +53 -37
  5. postie-functions.php +18 -2
  6. postie.php +3 -3
  7. readme.txt +30 -22
Revision CHANGED
@@ -1,2 +1,2 @@
1
- Revision: 153324
2
- Last Changed Date: 2009-09-01 00:28:24 -0400 (Tue, 01 Sep 2009)
1
+ Revision: 160758
2
+ Last Changed Date: 2009-09-18 11:29:43 -0400 (Fri, 18 Sep 2009)
cronless_postie.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Cronless Postie
4
  Plugin URI: http://blog.robfelty.com/plugins/postie
5
  Description: Checks e-mail periodically using wordpress's built-in scheduling mechanism
6
  Author: Robert Felty
7
- Version: 1.3.3
8
  Author URI: http://blog.robfelty.com
9
  */
10
 
@@ -44,18 +44,28 @@ if (isset($_GET["cronless_postie_read_me"])) {
44
 
45
 
46
  function postie_cron() {
 
47
  $config=GetConfig();
48
  if (!$config['CRONLESS'] || $config['CRONLESS']=='') {
49
  $config['CRONLESS']='hourly';
50
- WriteConfig($config);
 
 
 
 
51
  }
52
  wp_schedule_event(time(),$config['CRONLESS'],'check_postie_hook');
53
  }
54
  function postie_decron() {
 
55
  wp_clear_scheduled_hook('check_postie_hook');
56
  $config=GetConfig();
57
  $config['CRONLESS']='';
58
- WriteConfig($config);
 
 
 
 
59
  }
60
 
61
  /* here we add some more options for how often to check for e-mail */
4
  Plugin URI: http://blog.robfelty.com/plugins/postie
5
  Description: Checks e-mail periodically using wordpress's built-in scheduling mechanism
6
  Author: Robert Felty
7
+ Version: 1.3.4
8
  Author URI: http://blog.robfelty.com
9
  */
10
 
44
 
45
 
46
  function postie_cron() {
47
+ global $wpdb;
48
  $config=GetConfig();
49
  if (!$config['CRONLESS'] || $config['CRONLESS']=='') {
50
  $config['CRONLESS']='hourly';
51
+ $theQuery=$wpdb->prepare("INSERT INTO ". POSTIE_TABLE . "
52
+ (label,value) VALUES
53
+ ('CRONLESS','". $config['CRONLESS'] ."');");
54
+ $q = $wpdb->query($theQuery);
55
+ //WriteConfig($config);
56
  }
57
  wp_schedule_event(time(),$config['CRONLESS'],'check_postie_hook');
58
  }
59
  function postie_decron() {
60
+ global $wpdb;
61
  wp_clear_scheduled_hook('check_postie_hook');
62
  $config=GetConfig();
63
  $config['CRONLESS']='';
64
+ $theQuery=$wpdb->prepare("INSERT INTO ". POSTIE_TABLE . "
65
+ (label,value) VALUES
66
+ ('CRONLESS','". $config['CRONLESS'] ."');");
67
+ $q = $wpdb->query($theQuery);
68
+ //WriteConfig($config);
69
  }
70
 
71
  /* here we add some more options for how often to check for e-mail */
filterPostie.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Postie Filter
4
  Plugin URI: http://blog.robfelty.com/plugins/postie
5
  Description: Adds my own custom filter to messages posted by postie
6
- Version: 1.3.3
7
  Author: Robert Felty
8
  Author URI: http://blog.robfelty.com/
9
  */
3
  Plugin Name: Postie Filter
4
  Plugin URI: http://blog.robfelty.com/plugins/postie
5
  Description: Adds my own custom filter to messages posted by postie
6
+ Version: 1.3.4
7
  Author: Robert Felty
8
  Author URI: http://blog.robfelty.com/
9
  */
get_mail.php CHANGED
@@ -1,7 +1,16 @@
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
  //Load up some usefull libraries
4
- include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR."wp-config.php");
5
  require_once (dirname(__FILE__). DIRECTORY_SEPARATOR . 'mimedecode.php');
6
  require_once (dirname(__FILE__). DIRECTORY_SEPARATOR . 'postie-functions.php');
7
 
@@ -13,48 +22,53 @@ require_once (dirname(__FILE__). DIRECTORY_SEPARATOR . 'postie-functions.php');
13
  //Retreive emails
14
  print("<pre>\n");
15
  print("This is the postie plugin\n");
 
16
  include('Revision');
17
  $config = GetConfig();
18
  //print_r($config);
19
  $emails = FetchMail($config['MAIL_SERVER'], $config['MAIL_SERVER_PORT'],
20
- $config['MAIL_USERID'], $config['MAIL_PASSWORD'], $config['INPUT_PROTOCOL'],
21
- $config['TIME_OFFSET'], $config['TEST_EMAIL'],
22
- $config['DELETE_MAIL_AFTER_PROCESSING']);
23
- //loop through messages
24
- foreach ($emails as $email) {
25
- if (function_exists('memory_get_usage'))
26
- echo "memory at start of e-mail processing:" . memory_get_usage() . "\n";
27
- //sanity check to see if there is any info in the message
28
- if ($email == NULL ) {
29
- $message= __('Dang, message is empty!', 'postie');
30
- continue;
31
- } else if ($email=='already read') {
32
- $message = "\n" . __("There does not seem to be any new mail.", 'postie') .
33
- "\n";
34
- continue;
35
- }
36
- $message='';
37
- $mimeDecodedEmail = DecodeMimeMail($email, true);
38
- $from = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["from"]));
39
- /*
40
- if ($from != "") {
41
  continue;
42
- }
43
- */
 
 
 
 
 
 
 
44
 
45
- //Check poster to see if a valid person
46
- $poster = ValidatePoster($mimeDecodedEmail, $config);
47
- if (!empty($poster)) {
48
- if ($config['TEST_EMAIL'])
49
- DebugEmailOutput($email,$mimeDecodedEmail);
50
- PostEmail($poster,$mimeDecodedEmail, $config);
51
- }
52
- else {
53
- print("<p>Ignoring email - not authorized.\n");
54
- }
55
- if (function_exists('memory_get_usage'))
56
- echo "memory at end of e-mail processing:" . memory_get_usage() . "\n";
57
- } // end looping over messages
 
 
 
58
  print $message;
59
  print("</pre>\n");
60
 
@@ -62,3 +76,5 @@ print("</pre>\n");
62
 
63
  // end of script
64
  ?>
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4
+ <head>
5
+ <meta http-equiv="content-type"
6
+ content="application/xhtml+xml; charset=utf-8" />
7
+ <title>Postie - fetching mail</title>
8
+ </head>
9
+ <body>
10
  <?php
11
 
12
  //Load up some usefull libraries
13
+ include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR."wp-config.php");
14
  require_once (dirname(__FILE__). DIRECTORY_SEPARATOR . 'mimedecode.php');
15
  require_once (dirname(__FILE__). DIRECTORY_SEPARATOR . 'postie-functions.php');
16
 
22
  //Retreive emails
23
  print("<pre>\n");
24
  print("This is the postie plugin\n");
25
+ print("time:" . time() . "\n");
26
  include('Revision');
27
  $config = GetConfig();
28
  //print_r($config);
29
  $emails = FetchMail($config['MAIL_SERVER'], $config['MAIL_SERVER_PORT'],
30
+ $config['MAIL_USERID'], $config['MAIL_PASSWORD'], $config['INPUT_PROTOCOL'],
31
+ $config['TIME_OFFSET'], $config['TEST_EMAIL'],
32
+ $config['DELETE_MAIL_AFTER_PROCESSING']);
33
+ if ($emails!==false) {
34
+ //loop through messages
35
+ foreach ($emails as $email) {
36
+ if (function_exists('memory_get_usage'))
37
+ echo "memory at start of e-mail processing:" . memory_get_usage() . "\n";
38
+ //sanity check to see if there is any info in the message
39
+ if ($email == NULL ) {
40
+ $message= __('Dang, message is empty!', 'postie');
41
+ continue;
42
+ } else if ($email=='already read') {
43
+ $message = "\n" . __("There does not seem to be any new mail.", 'postie') .
44
+ "\n";
 
 
 
 
 
 
45
  continue;
46
+ }
47
+ $message='';
48
+ $mimeDecodedEmail = DecodeMimeMail($email, true);
49
+ $from = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["from"]));
50
+ /*
51
+ if ($from != "") {
52
+ continue;
53
+ }
54
+ */
55
 
56
+ //Check poster to see if a valid person
57
+ $poster = ValidatePoster($mimeDecodedEmail, $config);
58
+ if (!empty($poster)) {
59
+ if ($config['TEST_EMAIL'])
60
+ DebugEmailOutput($email,$mimeDecodedEmail);
61
+ PostEmail($poster,$mimeDecodedEmail, $config);
62
+ }
63
+ else {
64
+ print("<p>Ignoring email - not authorized.\n");
65
+ }
66
+ if (function_exists('memory_get_usage'))
67
+ echo "memory at end of e-mail processing:" . memory_get_usage() . "\n";
68
+ } // end looping over messages
69
+ } else {
70
+ $message = "\n" . __("There does not seem to be any new mail.", 'postie');
71
+ }
72
  print $message;
73
  print("</pre>\n");
74
 
76
 
77
  // end of script
78
  ?>
79
+ </body>
80
+ </html>
postie-functions.php CHANGED
@@ -4,8 +4,9 @@ define('WP_POST_REVISIONS', false);
4
  $original_mem_limit = ini_get('memory_limit');
5
  ini_set('memory_limit', -1);
6
 
 
7
  /*
8
- $Id: postie-functions.php 153879 2009-09-11 20:41:38Z robfelty $
9
  */
10
 
11
  /*TODO
@@ -44,6 +45,7 @@ if (!function_exists('fnmatch')) {
44
  * This is the main handler for all of the processing
45
  */
46
  function PostEmail($poster,$mimeDecodedEmail,$config) {
 
47
 
48
  $attachments = array(
49
  "html" => array(), //holds the html for each image
@@ -63,7 +65,13 @@ function PostEmail($poster,$mimeDecodedEmail,$config) {
63
  attachments with a post. So we add the post here, then update it
64
  */
65
  $post_id = wp_insert_post($tmpPost);
 
 
 
66
  $content = GetContent($mimeDecodedEmail,$attachments,$post_id, $config);
 
 
 
67
  $subject = GetSubject($mimeDecodedEmail,$content, $config);
68
  if ($debug) {
69
  echo "the subject is $subject, right after calling GetSubject\n";
@@ -377,7 +385,8 @@ function FetchMail($server=NULL, $port=NULL, $email=NULL, $password=NULL,
377
  }
378
  }
379
  if (!$emails)
380
- die("\n" . __('There does not seem to be any new mail.', 'postie') . "\n");
 
381
  return($emails);
382
  }
383
  /**
@@ -627,6 +636,7 @@ function GetContent ($part,&$attachments, $post_id, $config) {
627
  break;
628
 
629
  case 'image':
 
630
  $file_id = postie_media_handle_upload($part, $post_id);
631
  $file = wp_get_attachment_url($file_id);
632
 
@@ -1231,6 +1241,7 @@ function postie_media_handle_upload($part, $post_id, $post_data = array()) {
1231
  } else {
1232
  echo "could not write to temp file: '$tmpFile' ";
1233
  }
 
1234
  //print_r($part->ctype_parameters);
1235
  if ($part->ctype_parameters['name']=='') {
1236
  if ($part->ctype_parameters['filename']!='') {
@@ -1246,6 +1257,7 @@ function postie_media_handle_upload($part, $post_id, $post_data = array()) {
1246
  'size' => filesize($tmpFile),
1247
  'error' => ''
1248
  );
 
1249
  if (stristr('.zip', $name)) {
1250
  $parts=explode('.', $name);
1251
  $ext=$parts[count($parts)-1];
@@ -1262,6 +1274,8 @@ function postie_media_handle_upload($part, $post_id, $post_data = array()) {
1262
  }
1263
 
1264
  $file = postie_handle_upload($the_file, $overrides, $time);
 
 
1265
  //unlink($tmpFile);
1266
 
1267
  if ( isset($file['error']) )
@@ -1274,12 +1288,14 @@ function postie_media_handle_upload($part, $post_id, $post_data = array()) {
1274
  $content = '';
1275
 
1276
  // use image exif/iptc data for title and caption defaults if possible
 
1277
  if ( $image_meta = @wp_read_image_metadata($file) ) {
1278
  if ( trim($image_meta['title']) )
1279
  $title = $image_meta['title'];
1280
  if ( trim($image_meta['caption']) )
1281
  $content = $image_meta['caption'];
1282
  }
 
1283
 
1284
  // Construct the attachment array
1285
  $attachment = array_merge( array(
4
  $original_mem_limit = ini_get('memory_limit');
5
  ini_set('memory_limit', -1);
6
 
7
+ //include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR."wp-admin" . DIRECTORY_SEPARATOR . "upgrade-functions.php");
8
  /*
9
+ $Id: postie-functions.php 171881 2009-11-10 04:20:24Z robfelty $
10
  */
11
 
12
  /*TODO
45
  * This is the main handler for all of the processing
46
  */
47
  function PostEmail($poster,$mimeDecodedEmail,$config) {
48
+ $debug=true;
49
 
50
  $attachments = array(
51
  "html" => array(), //holds the html for each image
65
  attachments with a post. So we add the post here, then update it
66
  */
67
  $post_id = wp_insert_post($tmpPost);
68
+ if ($debug) {
69
+ echo "the id is $post_id\n";
70
+ }
71
  $content = GetContent($mimeDecodedEmail,$attachments,$post_id, $config);
72
+ if ($debug) {
73
+ echo "the content is $content\n";
74
+ }
75
  $subject = GetSubject($mimeDecodedEmail,$content, $config);
76
  if ($debug) {
77
  echo "the subject is $subject, right after calling GetSubject\n";
385
  }
386
  }
387
  if (!$emails)
388
+ //die("\n" . __('There does not seem to be any new mail.', 'postie') . "\n");
389
+ $emails=false;
390
  return($emails);
391
  }
392
  /**
636
  break;
637
 
638
  case 'image':
639
+ echo "looking at an image\n";
640
  $file_id = postie_media_handle_upload($part, $post_id);
641
  $file = wp_get_attachment_url($file_id);
642
 
1241
  } else {
1242
  echo "could not write to temp file: '$tmpFile' ";
1243
  }
1244
+ echo "wrote to temp file\n";
1245
  //print_r($part->ctype_parameters);
1246
  if ($part->ctype_parameters['name']=='') {
1247
  if ($part->ctype_parameters['filename']!='') {
1257
  'size' => filesize($tmpFile),
1258
  'error' => ''
1259
  );
1260
+ print_r($the_file);
1261
  if (stristr('.zip', $name)) {
1262
  $parts=explode('.', $name);
1263
  $ext=$parts[count($parts)-1];
1274
  }
1275
 
1276
  $file = postie_handle_upload($the_file, $overrides, $time);
1277
+ echo "finished postie_handle_upload\n";
1278
+ print_r($file);
1279
  //unlink($tmpFile);
1280
 
1281
  if ( isset($file['error']) )
1288
  $content = '';
1289
 
1290
  // use image exif/iptc data for title and caption defaults if possible
1291
+ include_once(ABSPATH . '/wp-admin/includes/image.php');
1292
  if ( $image_meta = @wp_read_image_metadata($file) ) {
1293
  if ( trim($image_meta['title']) )
1294
  $title = $image_meta['title'];
1295
  if ( trim($image_meta['caption']) )
1296
  $content = $image_meta['caption'];
1297
  }
1298
+ echo "read image meta data";
1299
 
1300
  // Construct the attachment array
1301
  $attachment = array_merge( array(
postie.php CHANGED
@@ -3,13 +3,13 @@
3
  Plugin Name: Postie
4
  Plugin URI: http://blog.robfelty.com/plugins/postie
5
  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://forum.robfelty.com/forum/postie'>postie forum</a> for support.
6
- Version: 1.3.3
7
  Author: Robert Felty
8
  Author URI: http://blog.robfelty.com/
9
  */
10
 
11
  /*
12
- $Id: postie.php 153887 2009-09-11 20:58:35Z robfelty $
13
  * -= Requests Pending =-
14
  * German Umlats don't work
15
  * Problems under PHP5
@@ -86,7 +86,7 @@ if (is_admin()) {
86
  }
87
  register_activation_hook(__FILE__, 'UpdateArrayConfig');
88
  /* Version info
89
- $Id: postie.php 153887 2009-09-11 20:58:35Z robfelty $
90
  */
91
  function postie_warnings() {
92
  $config=GetConfig();
3
  Plugin Name: Postie
4
  Plugin URI: http://blog.robfelty.com/plugins/postie
5
  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://forum.robfelty.com/forum/postie'>postie forum</a> for support.
6
+ Version: 1.3.4
7
  Author: Robert Felty
8
  Author URI: http://blog.robfelty.com/
9
  */
10
 
11
  /*
12
+ $Id: postie.php 160759 2009-10-05 20:25:31Z robfelty $
13
  * -= Requests Pending =-
14
  * German Umlats don't work
15
  * Problems under PHP5
86
  }
87
  register_activation_hook(__FILE__, 'UpdateArrayConfig');
88
  /* Version info
89
+ $Id: postie.php 160759 2009-10-05 20:25:31Z robfelty $
90
  */
91
  function postie_warnings() {
92
  $config=GetConfig();
readme.txt CHANGED
@@ -2,10 +2,10 @@
2
  Contributors: robfelty,
3
  Donate link: http://blog.robfelty.com/plugins/postie
4
  Plugin URI: http://blog.robfelty.com/plugins/postie
5
- Tags: e-mail
6
  Requires at least: 2.3
7
  Tested up to: 2.8
8
- Stable tag: 1.3.3
9
 
10
  The Postie plugin allows you to blog via e-mail, including many advanced
11
  features not found in wordpress's default post by e-mail feature.
@@ -19,6 +19,10 @@ imap and pop3, with the option for ssl with both. For usage notes, see the
19
 
20
  = What's new? =
21
 
 
 
 
 
22
  * 1.3.3 (2009.09.11)
23
  * Fixed problem with double titles
24
  * Fixed error in wp-mu
@@ -312,32 +316,36 @@ The IMAP extension is known to be installed on the following popular webhosts:
312
 
313
 
314
  == CHANGELOG ==
 
 
 
 
315
 
316
  = 1.3.3 (2009.09.11) =
317
- * Fixed problem with double titles
318
- * Fixed error in wp-mu
319
- * Cronless postie now correctly updates when changing the setting in the
320
- postie settings
321
- * Small fix in handling of names of attachments (thanks to Teejot)
322
- * Fixed delay option (thanks to redbrandonk)
323
- * Cronless option value is now correctly deleted when deactivating the
324
- cronless postie plugin
325
 
326
  = 1.3.2 (2009.08.27) =
327
- * tags are now always an array, even if no default tags are set
328
- * Subject is showing up again if you do not have the IMAP extension
329
- installed
330
- * More information on the IMAP extension and more user-friendly
331
- installation
332
- * Fixed problems with smtp server settings in 1.3.1
333
- * Added russian translation (thanks to fatcow.com)
334
 
335
  = 1.3.1 (2009.08.24) =
336
- * Changed GetContent filter to postie_post
337
- * Added database upgrade hook on activation
338
- * Fixed bug where content would be empty if trying to remove signature,
339
- and signature list was emtpy
340
- * Updated FAQ and readme
341
 
342
  = 1.3.0 (2009.08.14) =
343
  * Features
2
  Contributors: robfelty,
3
  Donate link: http://blog.robfelty.com/plugins/postie
4
  Plugin URI: http://blog.robfelty.com/plugins/postie
5
+ Tags: e-mail, email
6
  Requires at least: 2.3
7
  Tested up to: 2.8
8
+ Stable tag: 1.3.4
9
 
10
  The Postie plugin allows you to blog via e-mail, including many advanced
11
  features not found in wordpress's default post by e-mail feature.
19
 
20
  = What's new? =
21
 
22
+ * 1.3.4 (2009.10.05)
23
+ * Fixed problem with images not posting under cron
24
+ * Fixed issue with disappearing password
25
+
26
  * 1.3.3 (2009.09.11)
27
  * Fixed problem with double titles
28
  * Fixed error in wp-mu
316
 
317
 
318
  == CHANGELOG ==
319
+
320
+ = 1.3.4 (2009.10.05) =
321
+ * Fixed problem with images not posting under cron
322
+ * Fixed issue with disappearing password
323
 
324
  = 1.3.3 (2009.09.11) =
325
+ * Fixed problem with double titles
326
+ * Fixed error in wp-mu
327
+ * Cronless postie now correctly updates when changing the setting in the
328
+ postie settings
329
+ * Small fix in handling of names of attachments (thanks to Teejot)
330
+ * Fixed delay option (thanks to redbrandonk)
331
+ * Cronless option value is now correctly deleted when deactivating the
332
+ cronless postie plugin
333
 
334
  = 1.3.2 (2009.08.27) =
335
+ * tags are now always an array, even if no default tags are set
336
+ * Subject is showing up again if you do not have the IMAP extension
337
+ installed
338
+ * More information on the IMAP extension and more user-friendly
339
+ installation
340
+ * Fixed problems with smtp server settings in 1.3.1
341
+ * Added russian translation (thanks to fatcow.com)
342
 
343
  = 1.3.1 (2009.08.24) =
344
+ * Changed GetContent filter to postie_post
345
+ * Added database upgrade hook on activation
346
+ * Fixed bug where content would be empty if trying to remove signature,
347
+ and signature list was emtpy
348
+ * Updated FAQ and readme
349
 
350
  = 1.3.0 (2009.08.14) =
351
  * Features