Postie - Version 1.4.2

Version Description

(2011.01.29) = * Fixed mailto link bug (thanks to Jason McNeil) * Fixed bug with attachments with non-ascii characters in filename (thanks to mtakada) * checking for socket errors when checking mail (thanks elysian) * fixed issue with multiple files not being inserted correctly * Added support for ISO 8859-15 (thanks paolog) * fixed sql injection problem (thanks Jose P. Espinal for pointing it out) * Fixed namespace clashing for get_config function

Download this release

Release Info

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

Code changes from version 1.4.1 to 1.4.2

Files changed (8) hide show
  1. Revision +2 -2
  2. postie-functions.php +34 -47
  3. postie.php +25 -17
  4. postie_test.php +1 -1
  5. readme.html +56 -173
  6. readme.txt +37 -19
  7. stripParts.pl +22 -0
  8. updateVersion +24 -0
Revision CHANGED
@@ -1,2 +1,2 @@
1
- Revision: 254232
2
- Last Changed Date: 2010-06-11 14:39:35 -0400 (Fri, 11 Jun 2010)
1
+ Revision: 338604
2
+ Last Changed Date: 2010-11-23 11:21:40 -0500 (Tue, 23 Nov 2010)
postie-functions.php CHANGED
@@ -10,7 +10,7 @@ if (!ini_get('safe_mode')) {
10
 
11
  //include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR."wp-admin" . DIRECTORY_SEPARATOR . "upgrade-functions.php");
12
  /*
13
- $Id: postie-functions.php 251029 2010-06-11 18:39:35Z robfelty $
14
  */
15
 
16
  /*TODO
@@ -261,10 +261,9 @@ function clickableLink($text, $shortcode=false) {
261
 
262
  // matches an email@domain type address at the start of a line, or after a space.
263
  // Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
264
- $ret = preg_replace("#(^|[\n
265
- ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a
266
- href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
267
-
268
  // Remove our padding..
269
  $ret = substr($ret, 1);
270
  return $ret;
@@ -354,7 +353,7 @@ function checkReply(&$subject) {
354
  }
355
  $checkExistingPostQuery= "SELECT ID FROM $wpdb->posts WHERE
356
  '$tmpSubject' = post_title";
357
- if ($id=$wpdb->get_var($checkExistingPostQuery)) {
358
  if (is_array($id)) {
359
  $id=$id[count($id)-1];
360
  }
@@ -438,7 +437,7 @@ function FetchMail($server=NULL, $port=NULL, $email=NULL, $password=NULL,
438
  */
439
  function TestIMAPMessageFetch ( ) {
440
  print("**************RUNING IN TESTING MODE************\n");
441
- $config = get_config();
442
  extract( $config );
443
  $email = $test_email_account;
444
  $password = $test_email_password;
@@ -484,7 +483,7 @@ function IMAPMessageFetch ($server=NULL, $port=NULL, $email=NULL,
484
  }
485
  function TestPOP3MessageFetch ( ) {
486
  print("**************RUNING IN TESTING MODE************\n");
487
- $config = get_config();
488
  extract( $config );
489
  $email = $test_email_account;
490
  $password = $test_email_password;
@@ -644,6 +643,9 @@ function GetContent ($part,&$attachments, $post_id, $poster, $config) {
644
  $meta_return .= GetContent($section,$attachments,$post_id, $poster, $config);
645
  }
646
  } else {
 
 
 
647
  switch ( strtolower($part->ctype_primary) ) {
648
  case 'multipart':
649
  FilterTextParts($part, $prefer_text_type);
@@ -688,7 +690,7 @@ function GetContent ($part,&$attachments, $post_id, $poster, $config) {
688
 
689
  $cid = trim($part->headers["content-id"],"<>");; //cids are in <cid>
690
  $the_post=get_post($file_id);
691
- $attachments["html"][] = parseTemplate($file_id, $part->ctype_primary,
692
  $imagetemplate);
693
  if ($cid) {
694
  $attachments["cids"][$cid] = array($file,
@@ -707,7 +709,7 @@ function GetContent ($part,&$attachments, $post_id, $poster, $config) {
707
  $icon_size);
708
  $audioTemplate='<a href="{FILELINK}">' . $icon . '{FILENAME}</a>';
709
  }
710
- $attachments["html"][] = parseTemplate($file_id, $part->ctype_primary,
711
  $audioTemplate);
712
  break;
713
  case 'video':
@@ -724,7 +726,7 @@ function GetContent ($part,&$attachments, $post_id, $poster, $config) {
724
  $icon_size);
725
  $videoTemplate='<a href="{FILELINK}">' . $icon . '{FILENAME}</a>';
726
  }
727
- $attachments["html"][] = parseTemplate($file_id, $part->ctype_primary,
728
  $videoTemplate);
729
  //echo "videoTemplate = $videoTemplate\n";
730
  break;
@@ -740,9 +742,8 @@ function GetContent ($part,&$attachments, $post_id, $poster, $config) {
740
  $icon=chooseAttachmentIcon($file, $part->ctype_primary,
741
  $part->ctype_secondary, $icon_set,
742
  $icon_size);
743
- $attachments["html"][] = '<a href="' . $file .
744
- '" style="text-decoration:none">' . $icon .
745
- $part->ctype_parameters['name'] . '</a>' . "\n";
746
  if ($cid) {
747
  $attachments["cids"][$cid] = array($file,
748
  count($attachments["html"]) - 1);
@@ -1098,7 +1099,7 @@ function ConvertToUTF_8($encoding,$charset,$body) {
1098
  $body = utf8_encode($body);
1099
  break;
1100
  case "iso-2022-jp":
1101
- $body = iconv("ISO-2022-JP//TRANSLIT","UTF-8",$body);
1102
  break;
1103
  case ($charset=="windows-1252" || $charset=="cp-1252" ||
1104
  $charset=="cp 1252"):
@@ -1106,19 +1107,22 @@ function ConvertToUTF_8($encoding,$charset,$body) {
1106
  break;
1107
  case ($charset=="windows-1256" || $charset=="cp-1256" ||
1108
  $charset=="cp 1256"):
1109
- $body = iconv("Windows-1256//TRANSLIT","UTF-8",$body);
1110
  break;
1111
  case 'koi8-r':
1112
- $body = iconv("koi8-r//TRANSLIT","UTF-8",$body);
1113
  break;
1114
  case 'iso-8859-2':
1115
- $body = iconv("iso-8859-2//TRANSLIT","UTF-8",$body);
1116
  break;
1117
  case "big5":
1118
- $body = iconv("BIG5","UTF-8",$body);
1119
  break;
1120
  case "gb2312":
1121
- $body = iconv("GB2312","UTF-8",$body);
 
 
 
1122
  break;
1123
  }
1124
  return($body);
@@ -1429,7 +1433,10 @@ function postie_handle_upload( &$file, $overrides = false, $time = null ) {
1429
  // A writable uploads dir will pass this test. Again, there's no point overriding this one.
1430
  if ( ! ( ( $uploads = wp_upload_dir($time) ) && false === $uploads['error'] ) )
1431
  return $upload_error_handler( $file, $uploads['error'] );
1432
-
 
 
 
1433
  $filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );
1434
 
1435
  // Move the file to the uploads dir
@@ -1666,7 +1673,6 @@ function chooseAttachmentIcon($file, $primary, $secondary, $iconSet='silver',
1666
  $fileName=basename($file);
1667
  $parts=explode('.', $fileName);
1668
  $ext=$parts[count($parts)-1];
1669
- //echo "file='$fileName', ext=$ext, primary=$primary, secondary=$secondary\n";
1670
  $docExts=array('doc', 'docx');
1671
  $docMimes=array('msword', 'vnd.ms-word',
1672
  'vnd.openxmlformats-officedocument.wordprocessingml.document');
@@ -1718,9 +1724,7 @@ function chooseAttachmentIcon($file, $primary, $secondary, $iconSet='silver',
1718
  } else {
1719
  $fileType='default';
1720
  }
1721
- //echo "fileType=$fileType\n";
1722
  $fileName="/icons/$iconSet/$fileType-$size.png";
1723
- //echo "fileName=$fileName\n";
1724
  if (!file_exists(POSTIE_ROOT . $fileName))
1725
  $fileName="/icons/$iconSet/default-$size.png";
1726
  $iconHtml="<img src='" . POSTIE_URL . $fileName . "' alt='$fileType icon' />";
@@ -1825,6 +1829,7 @@ function ReplaceImagePlaceHolders(&$content,$attachments, $config) {
1825
  return;
1826
  }
1827
  $pictures= array();
 
1828
  foreach ( $attachments as $i => $value ) {
1829
  // looks for ' #img1# ' etc... and replaces with image
1830
  $img_placeholder_temp = str_replace("%", intval($startIndex + $i), $image_placeholder);
@@ -1854,28 +1859,10 @@ function ReplaceImagePlaceHolders(&$content,$attachments, $config) {
1854
  $value = str_replace('{CAPTION}', '', $value);
1855
  /* if using the gallery shortcode, don't add pictures at all */
1856
  if (!preg_match("/\[gallery[^\[]*\]/", $content, $matches)) {
1857
- preg_match("/src=\"(.*?)\"/", $value, $matches);
1858
- $path = $matches[1];
1859
- $filename = basename($path);
1860
- $filename = preg_replace("/-[0-9]+x[0-9]+\.(jpg|png|gif)/", '',
1861
- $filename);
1862
- if (preg_match("/[[:alpha:]_-]+([0-9]+)$/", $filename, $matches)) {
1863
- $filename = $matches[1];
1864
- }
1865
- echo "filename = $filename\n";
1866
- if ($filename!=1) {
1867
- $pictures[$filename] = $value;
1868
- } else {
1869
- $pictures[] = $value;
1870
- }
1871
  }
1872
  }
1873
  }
1874
- ksort($pictures);
1875
- $pics = '';
1876
- foreach ($pictures as $picture) {
1877
- $pics .= $picture;
1878
- }
1879
  if ($images_append) {
1880
  $content .= $pics;
1881
  } else {
@@ -2107,7 +2094,7 @@ function BuildTextArea($label,$id,$current_value,$recommendation = NULL) {
2107
  *This function resets all the configuration options to the default
2108
  */
2109
  function ResetPostieConfig() {
2110
- $newconfig = get_config_defaults();
2111
  $config = get_option( 'postie-settings' ) ;
2112
  $save_keys=array( 'mail_password', 'mail_server', 'mail_server_port', 'mail_userid', 'iinput_protocol' );
2113
  foreach ( $save_keys as $key )
@@ -2135,7 +2122,7 @@ function UpdatePostieConfig($data) {
2135
  /**
2136
  * return an array of the config defaults
2137
  */
2138
- function get_config_defaults() {
2139
  include('templates/audio_templates.php');
2140
  include('templates/image_templates.php');
2141
  include('templates/video1_templates.php');
@@ -2390,7 +2377,7 @@ function GetConfig() {
2390
  * This function returns the current config
2391
  * @return array
2392
  */
2393
- function get_config() {
2394
  $config = get_option( 'postie-settings' );
2395
  if (file_exists(POSTIE_ROOT . '/postie_test_variables.php')) {
2396
  include(POSTIE_ROOT . '/postie_test_variables.php');
@@ -2473,7 +2460,7 @@ function postie_validate_settings( $in ) {
2473
 
2474
  // use the default as a template:
2475
  // if a field is present in the defaults, we want to store it; otherwise we discard it
2476
- $allowed_keys = get_config_defaults();
2477
  foreach ( $allowed_keys as $key => $default )
2478
  $out[$key] = array_key_exists( $key, $in ) ? $in[$key] : $default;
2479
 
10
 
11
  //include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR."wp-admin" . DIRECTORY_SEPARATOR . "upgrade-functions.php");
12
  /*
13
+ $Id: postie-functions.php 338608 2011-01-29 19:46:40Z robfelty $
14
  */
15
 
16
  /*TODO
261
 
262
  // matches an email@domain type address at the start of a line, or after a space.
263
  // Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
264
+ $ret = preg_replace(
265
+ "#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i",
266
+ "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
 
267
  // Remove our padding..
268
  $ret = substr($ret, 1);
269
  return $ret;
353
  }
354
  $checkExistingPostQuery= "SELECT ID FROM $wpdb->posts WHERE
355
  '$tmpSubject' = post_title";
356
+ if ($id=$wpdb->get_var($wpdb->prepare($checkExistingPostQuery))) {
357
  if (is_array($id)) {
358
  $id=$id[count($id)-1];
359
  }
437
  */
438
  function TestIMAPMessageFetch ( ) {
439
  print("**************RUNING IN TESTING MODE************\n");
440
+ $config = get_postie_config();
441
  extract( $config );
442
  $email = $test_email_account;
443
  $password = $test_email_password;
483
  }
484
  function TestPOP3MessageFetch ( ) {
485
  print("**************RUNING IN TESTING MODE************\n");
486
+ $config = get_postie_config();
487
  extract( $config );
488
  $email = $test_email_account;
489
  $password = $test_email_password;
643
  $meta_return .= GetContent($section,$attachments,$post_id, $poster, $config);
644
  }
645
  } else {
646
+ // fix filename (remove non-standard characters)
647
+ $filename = preg_replace("/[^\x9\xA\xD\x20-\x7F]/", "",
648
+ $part->ctype_parameters['name']);
649
  switch ( strtolower($part->ctype_primary) ) {
650
  case 'multipart':
651
  FilterTextParts($part, $prefer_text_type);
690
 
691
  $cid = trim($part->headers["content-id"],"<>");; //cids are in <cid>
692
  $the_post=get_post($file_id);
693
+ $attachments["html"][$filename] = parseTemplate($file_id, $part->ctype_primary,
694
  $imagetemplate);
695
  if ($cid) {
696
  $attachments["cids"][$cid] = array($file,
709
  $icon_size);
710
  $audioTemplate='<a href="{FILELINK}">' . $icon . '{FILENAME}</a>';
711
  }
712
+ $attachments["html"][$filename] = parseTemplate($file_id, $part->ctype_primary,
713
  $audioTemplate);
714
  break;
715
  case 'video':
726
  $icon_size);
727
  $videoTemplate='<a href="{FILELINK}">' . $icon . '{FILENAME}</a>';
728
  }
729
+ $attachments["html"][$filename] = parseTemplate($file_id, $part->ctype_primary,
730
  $videoTemplate);
731
  //echo "videoTemplate = $videoTemplate\n";
732
  break;
742
  $icon=chooseAttachmentIcon($file, $part->ctype_primary,
743
  $part->ctype_secondary, $icon_set,
744
  $icon_size);
745
+ $attachments["html"][$filename] = "<a href='$file'>" .
746
+ $icon . $filename . '</a>' . "\n";
 
747
  if ($cid) {
748
  $attachments["cids"][$cid] = array($file,
749
  count($attachments["html"]) - 1);
1099
  $body = utf8_encode($body);
1100
  break;
1101
  case "iso-2022-jp":
1102
+ $body = iconv("ISO-2022-JP","UTF-8//TRANSLIT",$body);
1103
  break;
1104
  case ($charset=="windows-1252" || $charset=="cp-1252" ||
1105
  $charset=="cp 1252"):
1107
  break;
1108
  case ($charset=="windows-1256" || $charset=="cp-1256" ||
1109
  $charset=="cp 1256"):
1110
+ $body = iconv("Windows-1256","UTF-8//TRANSLIT",$body);
1111
  break;
1112
  case 'koi8-r':
1113
+ $body = iconv("koi8-r","UTF-8//TRANSLIT",$body);
1114
  break;
1115
  case 'iso-8859-2':
1116
+ $body = iconv("iso-8859-2","UTF-8//TRANSLIT",$body);
1117
  break;
1118
  case "big5":
1119
+ $body = iconv("BIG5","UTF-8//TRANSLIT",$body);
1120
  break;
1121
  case "gb2312":
1122
+ $body = iconv("GB2312","UTF-8//TRANSLIT",$body);
1123
+ break;
1124
+ case "iso-8859-15":
1125
+ $body = iconv("iso-8859-15","UTF-8//TRANSLIT",$body);
1126
  break;
1127
  }
1128
  return($body);
1433
  // A writable uploads dir will pass this test. Again, there's no point overriding this one.
1434
  if ( ! ( ( $uploads = wp_upload_dir($time) ) && false === $uploads['error'] ) )
1435
  return $upload_error_handler( $file, $uploads['error'] );
1436
+
1437
+ // fix filename (remove non-standard characters)
1438
+ $file['name'] = preg_replace("/[^\x9\xA\xD\x20-\x7F]/", "",
1439
+ $file['name']);
1440
  $filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );
1441
 
1442
  // Move the file to the uploads dir
1673
  $fileName=basename($file);
1674
  $parts=explode('.', $fileName);
1675
  $ext=$parts[count($parts)-1];
 
1676
  $docExts=array('doc', 'docx');
1677
  $docMimes=array('msword', 'vnd.ms-word',
1678
  'vnd.openxmlformats-officedocument.wordprocessingml.document');
1724
  } else {
1725
  $fileType='default';
1726
  }
 
1727
  $fileName="/icons/$iconSet/$fileType-$size.png";
 
1728
  if (!file_exists(POSTIE_ROOT . $fileName))
1729
  $fileName="/icons/$iconSet/default-$size.png";
1730
  $iconHtml="<img src='" . POSTIE_URL . $fileName . "' alt='$fileType icon' />";
1829
  return;
1830
  }
1831
  $pictures= array();
1832
+ ksort($attachments);
1833
  foreach ( $attachments as $i => $value ) {
1834
  // looks for ' #img1# ' etc... and replaces with image
1835
  $img_placeholder_temp = str_replace("%", intval($startIndex + $i), $image_placeholder);
1859
  $value = str_replace('{CAPTION}', '', $value);
1860
  /* if using the gallery shortcode, don't add pictures at all */
1861
  if (!preg_match("/\[gallery[^\[]*\]/", $content, $matches)) {
1862
+ $pics .= $value;
 
 
 
 
 
 
 
 
 
 
 
 
 
1863
  }
1864
  }
1865
  }
 
 
 
 
 
1866
  if ($images_append) {
1867
  $content .= $pics;
1868
  } else {
2094
  *This function resets all the configuration options to the default
2095
  */
2096
  function ResetPostieConfig() {
2097
+ $newconfig = get_postie_config_defaults();
2098
  $config = get_option( 'postie-settings' ) ;
2099
  $save_keys=array( 'mail_password', 'mail_server', 'mail_server_port', 'mail_userid', 'iinput_protocol' );
2100
  foreach ( $save_keys as $key )
2122
  /**
2123
  * return an array of the config defaults
2124
  */
2125
+ function get_postie_config_defaults() {
2126
  include('templates/audio_templates.php');
2127
  include('templates/image_templates.php');
2128
  include('templates/video1_templates.php');
2377
  * This function returns the current config
2378
  * @return array
2379
  */
2380
+ function get_postie_config() {
2381
  $config = get_option( 'postie-settings' );
2382
  if (file_exists(POSTIE_ROOT . '/postie_test_variables.php')) {
2383
  include(POSTIE_ROOT . '/postie_test_variables.php');
2460
 
2461
  // use the default as a template:
2462
  // if a field is present in the defaults, we want to store it; otherwise we discard it
2463
+ $allowed_keys = get_postie_config_defaults();
2464
  foreach ( $allowed_keys as $key => $default )
2465
  $out[$key] = array_key_exists( $key, $in ) ? $in[$key] : $default;
2466
 
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.4.1
7
  Author: Robert Felty
8
  Author URI: http://blog.robfelty.com/
9
  */
10
 
11
  /*
12
- $Id: postie.php 234895 2010-04-28 19:59:08Z robfelty $
13
  * -= Requests Pending =-
14
  * German Umlats don't work
15
  * Problems under PHP5
@@ -54,10 +54,10 @@ function postie_loadjs_options_page() {
54
  }
55
 
56
  function postie_loadjs_admin_head() {
57
- $plugindir = get_settings('home').'/wp-content/plugins/'.dirname(plugin_basename(__FILE__));
58
  wp_enqueue_script('loadjs', $plugindir . '/js/simpleTabs.jquery.js');
59
- echo '<link type="text/css" rel="stylesheet" href="' .get_bloginfo('url') .'/wp-content/plugins/postie/css/style.css" />'."\n";
60
- echo '<link type="text/css" rel="stylesheet" href="' .get_bloginfo('url') .'/wp-content/plugins/postie/css/simpleTabs.css" />'."\n";
61
  }
62
 
63
 
@@ -95,7 +95,7 @@ function activate_postie() {
95
  if(!$options) {
96
  $options = array();
97
  }
98
- $default_options = get_config_defaults();
99
  $old_config = array();
100
  $updated = false;
101
  $migration = false;
@@ -160,9 +160,10 @@ function postie_warnings() {
160
  }
161
 
162
  function disable_kses_content() {
163
- remove_filter('content_save_pre', 'wp_filter_post_kses');
164
  }
165
  add_action('init','disable_kses_content',20);
 
166
  function postie_whitelist($options) {
167
  $added = array( 'postie-settings' => array( 'postie-settings' ) );
168
  $options = add_option_whitelist( $added, $options );
@@ -171,16 +172,17 @@ function postie_whitelist($options) {
171
  add_filter('whitelist_options', 'postie_whitelist');
172
 
173
  function check_postie() {
174
- $host = get_option('siteurl');
175
- preg_match("/https?:\/\/(.[^\/]*)(.*)/",$host,$matches);
176
- $host = $matches[1];
177
- $url = "";
178
- if (isset($matches[2])) {
179
- $url .= $matches[2];
180
- }
181
- $url .= "/wp-content/plugins/postie/get_mail.php";
182
- $port = 80;
183
- $fp=fsockopen($host,$port,$errno,$errstr);
 
184
  fputs($fp,"GET $url HTTP/1.0\r\n");
185
  fputs($fp,"User-Agent: Cronless-Postie\r\n");
186
  fputs($fp,"Host: $host\r\n");
@@ -190,6 +192,12 @@ function check_postie() {
190
  $page.=fgets($fp,128);
191
  }
192
  fclose($fp);
 
 
 
 
 
 
193
  }
194
 
195
  function postie_cron($interval=false) {
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.4.2
7
  Author: Robert Felty
8
  Author URI: http://blog.robfelty.com/
9
  */
10
 
11
  /*
12
+ $Id: postie.php 338608 2011-01-29 19:46:40Z robfelty $
13
  * -= Requests Pending =-
14
  * German Umlats don't work
15
  * Problems under PHP5
54
  }
55
 
56
  function postie_loadjs_admin_head() {
57
+ $plugindir = get_settings('siteurl').'/wp-content/plugins/'.dirname(plugin_basename(__FILE__));
58
  wp_enqueue_script('loadjs', $plugindir . '/js/simpleTabs.jquery.js');
59
+ echo '<link type="text/css" rel="stylesheet" href="' .get_bloginfo('wpurl') .'/wp-content/plugins/postie/css/style.css" />'."\n";
60
+ echo '<link type="text/css" rel="stylesheet" href="' .get_bloginfo('wpurl') .'/wp-content/plugins/postie/css/simpleTabs.css" />'."\n";
61
  }
62
 
63
 
95
  if(!$options) {
96
  $options = array();
97
  }
98
+ $default_options = get_postie_config_defaults();
99
  $old_config = array();
100
  $updated = false;
101
  $migration = false;
160
  }
161
 
162
  function disable_kses_content() {
163
+ remove_filter('content_save_pre', 'wp_filter_post_kses');
164
  }
165
  add_action('init','disable_kses_content',20);
166
+
167
  function postie_whitelist($options) {
168
  $added = array( 'postie-settings' => array( 'postie-settings' ) );
169
  $options = add_option_whitelist( $added, $options );
172
  add_filter('whitelist_options', 'postie_whitelist');
173
 
174
  function check_postie() {
175
+ $host = get_option('siteurl');
176
+ preg_match("/https?:\/\/(.[^\/]*)(.*)/",$host,$matches);
177
+ $host = $matches[1];
178
+ $url = "";
179
+ if (isset($matches[2])) {
180
+ $url .= $matches[2];
181
+ }
182
+ $url .= "/wp-content/plugins/postie/get_mail.php";
183
+ $port = 80;
184
+ $fp=fsockopen($host,$port,$errno,$errstr);
185
+ if ($fp) {
186
  fputs($fp,"GET $url HTTP/1.0\r\n");
187
  fputs($fp,"User-Agent: Cronless-Postie\r\n");
188
  fputs($fp,"Host: $host\r\n");
192
  $page.=fgets($fp,128);
193
  }
194
  fclose($fp);
195
+ } else {
196
+ echo "Cannot connect to server on port $port. Please check to make sure
197
+ that this port is open on your webhost.
198
+ Additional information:
199
+ $errno: $errstr";
200
+ }
201
  }
202
 
203
  function postie_cron($interval=false) {
postie_test.php CHANGED
@@ -4,7 +4,7 @@ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR ."postie-functions.php");
4
  include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR. "wp-config.php");
5
  //require_once('admin.php');
6
  require_once("postie-functions.php");
7
- $config = get_config();
8
  extract($config);
9
  $title = __("Postie Diagnosis");
10
  $parent_file = 'options-general.php?page=postie/postie.php';
4
  include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR. "wp-config.php");
5
  //require_once('admin.php');
6
  require_once("postie-functions.php");
7
+ $config = get_postie_config();
8
  extract($config);
9
  $title = __("Postie Diagnosis");
10
  $parent_file = 'options-general.php?page=postie/postie.php';
readme.html CHANGED
@@ -1,173 +1,56 @@
1
- <h3>Installation</h3>
2
- <ul>
3
- <li>Either:
4
-
5
- <ul>
6
- <li>Put the postie.zip file in wp-content/plugins/ and unzip it</li>
7
- </ul></li>
8
- <li>Or:
9
-
10
- <ul>
11
- <li>Use the automatic installer (WP 2.7+)</li>
12
- </ul></li>
13
- <li>Login to WordPress as an administrator</li>
14
- <li>Goto the Plugins tab in the WordPress Admin Site</li>
15
- <li>Activate "Postie"</li>
16
- <li>Goto to the "Settings" tab and click on the sub-tab "Postie" to configure it.</li>
17
- <li>Make sure you enter the mailserver information correctly, including the type
18
- of connection and the port number. Common port configurations:
19
-
20
- <ul>
21
- <li>pop3: 110 </li>
22
- <li>pop3-ssl: 995</li>
23
- <li>imap: 143</li>
24
- <li>imap-ssl: 993</li>
25
- </ul></li>
26
- <li>(Postie ignores the settings under Settings-&gt;Writing-&gt;Writing-by-Email)</li>
27
- </ul>
28
-
29
- <h4>Automating checking e-mail</h4>
30
-
31
- <p>By default, postie checks for new e-mail every 30 minutes. You can select from
32
- a number of different checking intervals in the settings page, under the
33
- mailserver tab.</p>
34
-
35
- <p>If you would prefer to have more fine-grained control of how postie checks
36
- for mail, you can also set up a crontab. This is for advanced users only.
37
- If your site runs on a UNIX/linux server, and you have shell access, you can
38
- enable mail checking using cron; if you don't know anything about cron, skip
39
- to the cronless postie section.</p>
40
-
41
- <p>Setup a cronjob to pull down the get&#95;mail.php
42
- Examples:</p>
43
-
44
- <p>*/5 * * * * /usr/bin/lynx --source <a href="http://blog.robfelty.com/wp-content/plugins/postie/get&#95;mail.php" rel="nofollow">http://blog.robfelty.com/wp-content/plugins/postie/get&#95;mail.php</a> &gt;/dev/null 2&gt;&amp;1</p>
45
-
46
- <p>This fetches the mail every five minutes with lynx</p>
47
-
48
- <p>*/10 * * * * /usr/bin/wget -O /dev/null <a href="http://blog.robfelty.com/wp-content/plugins/postie/get&#95;mail.php" rel="nofollow">http://blog.robfelty.com/wp-content/plugins/postie/get&#95;mail.php</a> &gt;/dev/null 2&gt;&amp;1</p>
49
-
50
- <p>This fetches the mail every ten minutes with wget</p> <hr />
51
-
52
- <h3>Usage</h3>
53
- <ul>
54
- <li>If you put in :start - the message processing won't start until it sees that string</li>
55
- <li>If you put in :end - the message processing will stop once it sees that string</li>
56
- <li>Posts can be delayed by adding a line with delayXdXhXm where X is a number.
57
-
58
- <ul>
59
- <li>delay:1d - 1 day</li>
60
- <li>delay:1h - 1 hour</li>
61
- <li>delay:1m - 1 minute</li>
62
- <li>delay:1d2h4m - 1 day 2 hours 4m</li>
63
- </ul></li>
64
- <li>By putting comments:X in your message you can control if comments are allowed
65
-
66
- <ul>
67
- <li>comments:0 - means closed</li>
68
- <li>comments:1 - means open</li>
69
- <li>comments:2 - means registered only</li>
70
- </ul></li>
71
- <li>Replying to an e-mail gets posted as a comment.
72
-
73
- <ul>
74
- <li>For example, you e-mailed a post with the subject line "foo".
75
- If you then send an e-mail with the subject line "Re: foo", it will
76
- get posted as a comment to the "foo" post. This works by the subject
77
- line, so if you have two posts with titles "foo", then the comment
78
- will get placed in the more recent post.</li>
79
- </ul></li>
80
- <li>Custom excerpt
81
-
82
- <ul>
83
- <li>You can include a custom excerpt of an e-mail by putting it between
84
- :excerptstart and :excerptend</li>
85
- <li>You can include images in the excerpt by using the shortcode #eimg1#,
86
- #eimg2# etc.</li>
87
- </ul></li>
88
- </ul>
89
-
90
- <h4>Category and tag handling</h4>
91
-
92
- <ul>
93
- <li>If you put a category name in the subject with a : it will be used
94
- as the category for the post</li>
95
- <li>If you put a category id number in the subject with a : it will
96
- be used as the category for the post</li>
97
- <li><p>If you put the first part of a category name it will be posted in
98
- the first category that the system finds that matches - so if you put</p>
99
-
100
- <p>Subject: Gen: New News</p>
101
-
102
- <p>The system will post that in General.</p></li>
103
- <li><p>All of the above also applies if you put the category in brackets []</p></li>
104
- <li><p>Using [] or you can post to multiple categories at once</p>
105
-
106
- <p>Subject: [1] [Mo] [Br] My Subject</p>
107
-
108
- <p>On my blog it would post to General (Id 1), Moblog, and Brewing all at one time</p></li>
109
- <li><p>Using - or you can post to multiple categories at once</p>
110
-
111
- <p>Subject: -1- -Mo- -Br- My Subject</p>
112
-
113
- <p>On my blog it would post to General (Id 1), Moblog, and Brewing all at one time</p></li>
114
- <li>You can add tags by adding a line in the body of the message like so:
115
- tags: foo, bar</li>
116
- <li>You can also set a default tag to be applied if no tags are included.</li>
117
- </ul>
118
-
119
- <h4>Image Handling</h4>
120
-
121
- <ul>
122
- <li>Allows you to attach images to your email and automatically post
123
- them to your blog</li>
124
- <li>You can publish images in the text of your message by using #img1#
125
- #img2# - each one will be replaced with the HTML for the image
126
- you attached</li>
127
- <li><p>Captions - you can also add a caption like so:</p>
128
-
129
- <ul>
130
- <li>#img1 caption='foo'#</li>
131
- <li>#img2 caption='bar'#</li>
132
- </ul>
133
-
134
- <p>Or, if you use IPTC captions, this caption will be used (adding a caption
135
- in many photo editing programs (for example Picasa), will add an IPTC caption)</p></li>
136
- <li><p>Image templates
137
- Postie now uses the default wordpress image template, but you can specify a
138
- different one if you wish.</p>
139
-
140
- <p>You can also specify a custom image template. I use the following custom
141
- template:</p>
142
-
143
- <p>&lt;div class='imageframe alignleft'&gt;&lt;a href='{IMAGE}'&gt;&lt;img src="{THUMBNAIL}"
144
- alt="{CAPTION}" title="{CAPTION}"
145
- class="attachment" /&gt;&lt;/a&gt;&lt;div
146
- class='imagecaption'&gt;{CAPTION}&lt;/div&gt;&lt;/div&gt;</p>
147
-
148
- <ul>
149
- <li>{THUMBNAIL} gets replaced with the url to the thumbnail image</li>
150
- <li>{MEDIUM} gets replaced with the url to the medium-sized image</li>
151
- <li>{LARGE} gets replaced with the url to the large-sized image</li>
152
- <li>{FULL} gets replaced with the url to the full-sized image</li>
153
- <li>{FILENAME} gets replaced with the absolute path to the full-size image</li>
154
- <li>{RELFILENAME} gets replaced with the relative path to the full-size image</li>
155
- <li>{CAPTION} gets replaced with the caption you specified (if any)</li>
156
- <li>{WIDTH} gets replaced with width of the photo</li>
157
- <li>{HEIGHT} gets replaced with the height of the photo</li>
158
- </ul></li>
159
- </ul>
160
-
161
- <h4>Interoperability</h4>
162
-
163
- <ul>
164
- <li>If your mail client doesn't support setting the subject (nokia) you
165
- can do so by putting #your title here# at the begining of your message</li>
166
- <li>POP3,POP3-SSL,IMAP,IMAP-SSL now supported - last three require
167
- php-imap support</li>
168
- <li>The program understands enough about mime to not duplicate post
169
- if you send an HTML and plain text message</li>
170
- <li>Automatically confirms that you are installed correctly</li>
171
- </ul>
172
- <hr />
173
-
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html>
4
+ <head>
5
+ <title>Validator Error!</title>
6
+ </head>
7
+ <style type="text/css">
8
+ <!--
9
+ body {
10
+ font-family: Lucida Grande, Verdana, sans-serif;
11
+ }
12
+
13
+ code {
14
+ font-size: 1.3em
15
+ }
16
+
17
+ div.success {
18
+ background: #0f0;
19
+ width: 50%;
20
+ margin: 0 auto;
21
+ padding: 1px 10px;
22
+ border: 3px solid #0d0;
23
+ }
24
+
25
+ div.error {
26
+ padding: 1px 10px;
27
+ margin: 30px auto;
28
+ }
29
+
30
+ div.error p {
31
+ font-weight: bold;
32
+ }
33
+
34
+ div.error ul {
35
+ list-style: square;
36
+ }
37
+
38
+ div.fatal {
39
+ background: #faa;
40
+ border: 3px solid #d00;
41
+ }
42
+
43
+ div.warning {
44
+ background: #f60;
45
+ border: 3px solid #e40;
46
+ }
47
+
48
+ div.note {
49
+ background: #5cf;
50
+ border: 3px solid #3ad;
51
+ }
52
+
53
+ -->
54
+ </style>
55
+ <body>
56
+ Invalid readme.txt URL
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://blog.robfelty.com/plugins/postie
5
  Tags: e-mail, email
6
  Requires at least: 2.3
7
  Tested up to: 3.0
8
- Stable tag: 1.4.1
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,15 @@ imap and pop3, with the option for ssl with both. For usage notes, see the
19
 
20
  = What's new? =
21
 
 
 
 
 
 
 
 
 
 
22
  * 1.4.1 (2010.06.18)
23
  * Images appear in correct order when using images append = false
24
  * Images are sorted in order of filename before inserting into post
@@ -38,24 +47,6 @@ imap and pop3, with the option for ssl with both. For usage notes, see the
38
  memory_limit to infinity to allow processing of large e-mails (especially
39
  with large attachments)
40
 
41
- * 1.4 (2010.04.25)
42
- * Now using wordpress settings api (thanks for much help from Andrew S)
43
- * Cronless postie is now integrated with postie instead of a plugin
44
- * filterPostie.php moved to filterPostie.php.sample
45
- * Can use fetchmails.php to fetch mail from multiple mailboxes
46
- * Fixed problem with embedding youtube videos from html (richtext) e-mail
47
- * Added support for embedding vimeo vidoes
48
- * Fixed problem with selecting "none" as icon set for attachments (thanks
49
- tonyvitali)
50
- * Fixed problems with cronless postie settings
51
- * Fixed bug with embedding youtube and vimeo videos whose ID contains a -
52
- (thanks Jim Kehoe)
53
- * Post_author is now included with attachments
54
- * fixed confirmation_email settings so that now you can select between
55
- sender, admin, both, or none (thanks to redsalmon for pointing out bug)
56
- * Added option to automatically insert galleries
57
- * Updated FAQ and readme
58
-
59
  == Installation ==
60
  * Either:
61
  * Put the postie.zip file in wp-content/plugins/ and unzip it
@@ -199,6 +190,17 @@ class='imagecaption'&gt;{CAPTION}&lt;/div&gt;&lt;/div&gt;
199
 
200
  == Frequently Asked Questions ==
201
 
 
 
 
 
 
 
 
 
 
 
 
202
  = How can I get postie to display inline images? =
203
 
204
  Make sure that you send e-mail formatted as html (richtext), and set postie to
@@ -348,6 +350,22 @@ option to convert url into links turned on)
348
 
349
  == CHANGELOG ==
350
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
351
  = 1.4.1 (2010.06.18) =
352
  * Images appear in correct order when using images append = false
353
  * Fixed formatting problem with wordpress_default image template
5
  Tags: e-mail, email
6
  Requires at least: 2.3
7
  Tested up to: 3.0
8
+ Stable tag: 1.4.2
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.4.2 (2011.01.29)
23
+ * Fixed mailto link bug (thanks to Jason McNeil)
24
+ * Fixed bug with attachments with non-ascii characters in filename (thanks to
25
+ mtakada)
26
+ * checking for socket errors when checking mail (thanks elysian)
27
+ * fixed issue with multiple files not being inserted correctly
28
+ * Added support for ISO 8859-15 (thanks paolog)
29
+ * fixed sql injection problem (thanks Jose P. Espinal for pointing it out)
30
+
31
  * 1.4.1 (2010.06.18)
32
  * Images appear in correct order when using images append = false
33
  * Images are sorted in order of filename before inserting into post
47
  memory_limit to infinity to allow processing of large e-mails (especially
48
  with large attachments)
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  == Installation ==
51
  * Either:
52
  * Put the postie.zip file in wp-content/plugins/ and unzip it
190
 
191
  == Frequently Asked Questions ==
192
 
193
+ = Postie won't connect to my mailserver. Why Not? =
194
+
195
+ Make sure the port you are using is open. For example, bluehost seems to block
196
+ ports 993 and 995 (for pop3-ssl and imap-ssl) by default. I have heard that
197
+ you can request that they open them for you ( you might have to pay extra).
198
+
199
+ You can check for open ports with the following command on your server:
200
+ netstat -ln|grep -E ':::(993|995|143)'
201
+
202
+ If nothing shows up, then the ports are not open.
203
+
204
  = How can I get postie to display inline images? =
205
 
206
  Make sure that you send e-mail formatted as html (richtext), and set postie to
350
 
351
  == CHANGELOG ==
352
 
353
+ = 1.4.3 =
354
+ * TODO - fix corruption of rtf attachments
355
+ * TODO - add port checking in tests
356
+ * TODO - non-image uploads get ignored in content when using autogallery - see
357
+ replaceimageplaceholders
358
+
359
+ = 1.4.2 (2011.01.29) =
360
+ * Fixed mailto link bug (thanks to Jason McNeil)
361
+ * Fixed bug with attachments with non-ascii characters in filename (thanks to
362
+ mtakada)
363
+ * checking for socket errors when checking mail (thanks elysian)
364
+ * fixed issue with multiple files not being inserted correctly
365
+ * Added support for ISO 8859-15 (thanks paolog)
366
+ * fixed sql injection problem (thanks Jose P. Espinal for pointing it out)
367
+ * Fixed namespace clashing for get_config function
368
+
369
  = 1.4.1 (2010.06.18) =
370
  * Images appear in correct order when using images append = false
371
  * Fixed formatting problem with wordpress_default image template
stripParts.pl ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/perl -w
2
+ use strict;
3
+ my $string = do {local ( $/ ); <> };
4
+ $string=~s/.*(<h3>Installation)/$1/s;
5
+ $string=~s/(.*)<h3>Changelog.*(<h3>.*)/$1$2/s;
6
+ $string=~s/(.*)<h3>Screenshots.*(<h3>.*)/$1$2/s;
7
+ if ($string=~s/(<h3>Frequently Asked Questions<\/h3>.*?)<hr \/>//s) {
8
+ my $faq=$1;
9
+ my $questions;
10
+ my $faqID=0;
11
+ while ($faq=~s/<h4>(.*)<\/h4>/<h4 id='answer-$faqID'>$1<\/h4>/) {
12
+ $questions.="<li id='question-$faqID'><a href='#answer-$faqID'>$1</a></li>\n";
13
+ $faqID++;
14
+ }
15
+ $faq=$questions.$faq;
16
+ my $faqFile='faq.html';
17
+ open(FAQ,">$faqFile");
18
+ print FAQ $faq;
19
+ close(FAQ);
20
+ }
21
+ $string=~s/<h2 id=\'re-edit'.*//s;
22
+ print $string;
updateVersion ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # this script updates the version number in all relevant files in the directory
3
+ if [ $# -ne 1 ]
4
+ then
5
+ #echo 'usage: ./updateVersion versionNum'
6
+ echo 'updating revision but not versionNUm'
7
+ #exit 1
8
+ else
9
+ VER=$1
10
+ for file in *.{php,js,txt,css}; do
11
+ perl -pe "s/(version|stable tag): [0-9a-zA-Z\.]+( |$)/\$1: $VER/gi" < $file > ${file}TEMP
12
+ done
13
+ for file in *TEMP; do
14
+ mv -f $file `echo $file|perl -pe 's/TEMP//'`
15
+ done
16
+ fi
17
+
18
+
19
+ # update Revision file
20
+ svn up
21
+ svn info | grep -E '(Date|Revision)' > Revision
22
+ # convert readme.txt to readme.html using wordpress's online converter
23
+ wget --post-data='url=1&readme_url=robfelty.com/wptesting/wp-content/plugins/postie/readme.txt' http://wordpress.org/extend/plugins/about/validator/ -O - |./stripParts.pl > readme.html
24
+ #svn commit