Postie - Version 1.4.1

Version Description

(2010.06.18) = * Images appear in correct order when using images append

Download this release

Release Info

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

Code changes from version 1.4 to 1.4.1

Revision CHANGED
@@ -1,2 +1,2 @@
1
- Revision: 233507
2
- Last Changed Date: 2010-04-25 13:52:31 -0400 (Sun, 25 Apr 2010)
1
+ Revision: 254232
2
+ Last Changed Date: 2010-06-11 14:39:35 -0400 (Fri, 11 Jun 2010)
config_form.php CHANGED
@@ -164,7 +164,7 @@ $messages[2] = __("Error - unable to save configuration",'postie');
164
  </td>
165
  </tr>
166
  <?php echo BuildBooleanSelect("Delete email after
167
- posting",'postie-settings[delete_mail_after_processing]',$delete_mail_after_processing,"Only set to yes for testing purposes");?>
168
  </table>
169
  </div>
170
  <div id="simpleTabs-content-2" class="simpleTabs-content">
@@ -185,9 +185,8 @@ $messages[2] = __("Error - unable to save configuration",'postie');
185
  $role = &$wp_roles->get_role($roleId);
186
  if ($roleId != "administrator") { ?>
187
  <tr><td>
188
- <input type='checkbox' value='1' name='postie-settings[role_access][<?php
189
- echo $roleId;
190
- ?>]' <?php echo checked($role->has_cap("post_via_postie")); ?> >
191
  <?php echo $name; ?>
192
  </td></tr>
193
  <?php
164
  </td>
165
  </tr>
166
  <?php echo BuildBooleanSelect("Delete email after
167
+ posting",'postie-settings[delete_mail_after_processing]',$delete_mail_after_processing,"Only set to no for testing purposes");?>
168
  </table>
169
  </div>
170
  <div id="simpleTabs-content-2" class="simpleTabs-content">
185
  $role = &$wp_roles->get_role($roleId);
186
  if ($roleId != "administrator") { ?>
187
  <tr><td>
188
+ <input type='checkbox' value='1' name='postie-settings[role_access][<?php echo $roleId; ?>]' <?php if ($role->has_cap("post_via_postie")) echo
189
+ 'checked="checked"'; ?> >
 
190
  <?php echo $name; ?>
191
  </td></tr>
192
  <?php
css/style.css CHANGED
@@ -11,6 +11,9 @@ margin-right: 10px;
11
  margin-top: 50px;
12
  }
13
 
 
 
 
14
  table.form-table td {line-height:1em;
15
  margin:0;
16
  padding:0;
11
  margin-top: 50px;
12
  }
13
 
14
+ table.form-table {
15
+ background: #E5F3FF;
16
+ }
17
  table.form-table td {line-height:1em;
18
  margin:0;
19
  padding:0;
faq.html CHANGED
@@ -1,38 +1,45 @@
1
- <li id='question-0'><a href='#answer-0'>Mail is not showing up right when I send html (rich formatted) e-mail!</a></li>
2
- <li id='question-1'><a href='#answer-1'>Do I need to any code to my theme for postie to work?</a></li>
3
- <li id='question-2'><a href='#answer-2'>I read somewhere to add an iframe to my footer. Should I do this?</a></li>
4
- <li id='question-3'><a href='#answer-3'>My mail host requires SSL, but postie will not allow me to select pop3-ssl or imap-ssl</a></li>
5
- <li id='question-4'><a href='#answer-4'>Can I use postie to check a gmail account?</a></li>
6
- <li id='question-5'><a href='#answer-5'>My posts show up as being posted by 'admin' instead of me. Why?</a></li>
7
- <li id='question-6'><a href='#answer-6'>Images aren't showing up at all?</a></li>
8
- <li id='question-7'><a href='#answer-7'>Can I delete the wp-files directory needed by postie version &lt;1.3.0?</a></li>
9
- <li id='question-8'><a href='#answer-8'>How can I get rid of stupid stuff my e-mail provider adds to my messages?</a></li>
10
- <li id='question-9'><a href='#answer-9'>How can I add custom attachment icons?</a></li>
11
- <li id='question-10'><a href='#answer-10'>Can I add special text to the body of the post when using postie?</a></li>
12
- <li id='question-11'><a href='#answer-11'>Can I add special text to the title of the post when using postie?</a></li>
13
- <li id='question-12'><a href='#answer-12'>Is the IMAP extension required for postie?</a></li>
14
- <li id='question-13'><a href='#answer-13'>How can I embed youtube or vimeo videos?</a></li>
 
 
15
  <h3>Frequently Asked Questions</h3>
16
- <h4 id='answer-0'>Mail is not showing up right when I send html (rich formatted) e-mail!</h4>
 
 
 
 
 
17
 
18
  <p>Make sure you set the preferred text type to html</p>
19
 
20
- <h4 id='answer-1'>Do I need to any code to my theme for postie to work?</h4>
21
 
22
  <p>No.</p>
23
 
24
- <h4 id='answer-2'>I read somewhere to add an iframe to my footer. Should I do this?</h4>
25
 
26
  <p>No. Do not add an iframe in your footer to get postie to check mail
27
  periodically. To check e-mail periodically, either set-up a cron job, or use
28
  cronless postie. See installation instructions</p>
29
 
30
- <h4 id='answer-3'>My mail host requires SSL, but postie will not allow me to select pop3-ssl or imap-ssl</h4>
31
 
32
  <p>You must have php-imap installed on your server for this to work. Ask your
33
  hosting provider about this.</p>
34
 
35
- <h4 id='answer-4'>Can I use postie to check a gmail account?</h4>
36
 
37
  <p>Yes. You can use either pop3-ssl or imap-ssl with a gmail account. Before
38
  attempting to use with postie, make sure that you enable pop or imap in your
@@ -61,7 +68,7 @@ this would be just foo)</li>
61
  </ul></li>
62
  </ul>
63
 
64
- <h4 id='answer-5'>My posts show up as being posted by 'admin' instead of me. Why?</h4>
65
 
66
  <p>If your admin account is linked to <a href="mailto:bar@gmail.com">bar@gmail.com</a>, and you send mail from
67
  <a href="mailto:bar@gmail.com">bar@gmail.com</a>, it will show up as being posted by admin. If you have a
@@ -73,7 +80,7 @@ e-mail address postie is checking. That is, if you send mail from
73
  <p>If you send an e-mail to your postie address from an e-mail address that is no
74
  t linked to a wordpress user, it will get posted as admin.</p>
75
 
76
- <h4 id='answer-6'>Images aren't showing up at all?</h4>
77
 
78
  <p>There are a couple possible reasons for this. First, check to see if you can
79
  add an image through wordpress's normal posting mechanism. If not, then there
@@ -86,14 +93,14 @@ provider about this.</p>
86
  sure that it is</li>
87
  </ol>
88
 
89
- <h4 id='answer-7'>Can I delete the wp-files directory needed by postie version &lt;1.3.0?</h4>
90
 
91
  <p>If you have posts published already by older versions of postie, getting rid
92
  of those directories will delete any files you might have had associated with
93
  those old posts. If you don't have any such posts, then you can safely delete
94
  them.</p>
95
 
96
- <h4 id='answer-8'>How can I get rid of stupid stuff my e-mail provider adds to my messages?</h4>
97
 
98
  <p>To strip off stuff that they add at the beginning of a message, start your
99
  post with :start</p>
@@ -101,7 +108,7 @@ post with :start</p>
101
  <p>To strip off stuff that they add at the end of a message, end your
102
  post with :end</p>
103
 
104
- <h4 id='answer-9'>How can I add custom attachment icons?</h4>
105
 
106
  <p>Simply upload the icons you want to the postie/icons/custom directory. You
107
  must name the icons according to the following scheme:
@@ -132,17 +139,22 @@ icons)</p>
132
  <li>txt - plain text document</li>
133
  </ul>
134
 
135
- <h4 id='answer-10'>Can I add special text to the body of the post when using postie?</h4>
 
 
 
 
 
136
 
137
- <p>Yes. You can create your own function, and use the postie_post filter
138
- Two short examples are included in the filterPostie.php file</p>
139
 
140
- <h4 id='answer-11'>Can I add special text to the title of the post when using postie?</h4>
141
 
142
- <p>Yes. You can create your own function, and use the postie_post filter
143
- Two short examples are included in the filterPostie.php file</p>
144
 
145
- <h4 id='answer-12'>Is the IMAP extension required for postie?</h4>
146
 
147
  <p>The IMAP extension is not required, but it is strongly recommended, especially
148
  is you are using non-English text. There is more information on php.net about
@@ -158,7 +170,7 @@ sudo yuminstall php-imap</p>
158
  <p>The IMAP extension is known to be installed on the following popular webhosts:
159
  * Dreamhost</p>
160
 
161
- <h4 id='answer-13'>How can I embed youtube or vimeo videos?</h4>
162
 
163
  <p>Simply put the url in the body of your e-mail. (Make sure that you have the
164
  option to convert url into links turned on)</p>
1
+ <li id='question-0'><a href='#answer-0'>How can I get postie to display inline images?</a></li>
2
+ <li id='question-1'><a href='#answer-1'>Mail is not showing up right when I send html (rich formatted) e-mail!</a></li>
3
+ <li id='question-2'><a href='#answer-2'>Do I need to any code to my theme for postie to work?</a></li>
4
+ <li id='question-3'><a href='#answer-3'>I read somewhere to add an iframe to my footer. Should I do this?</a></li>
5
+ <li id='question-4'><a href='#answer-4'>My mail host requires SSL, but postie will not allow me to select pop3-ssl or imap-ssl</a></li>
6
+ <li id='question-5'><a href='#answer-5'>Can I use postie to check a gmail account?</a></li>
7
+ <li id='question-6'><a href='#answer-6'>My posts show up as being posted by 'admin' instead of me. Why?</a></li>
8
+ <li id='question-7'><a href='#answer-7'>Images aren't showing up at all?</a></li>
9
+ <li id='question-8'><a href='#answer-8'>Can I delete the wp-files directory needed by postie version &lt;1.3.0?</a></li>
10
+ <li id='question-9'><a href='#answer-9'>How can I get rid of stupid stuff my e-mail provider adds to my messages?</a></li>
11
+ <li id='question-10'><a href='#answer-10'>How can I add custom attachment icons?</a></li>
12
+ <li id='question-11'><a href='#answer-11'>Can I add special text to the body of the post when using postie?</a></li>
13
+ <li id='question-12'><a href='#answer-12'>Can I add special text to the title of the post when using postie?</a></li>
14
+ <li id='question-13'><a href='#answer-13'>Can I select tags or categories based on the content of the e-mail?</a></li>
15
+ <li id='question-14'><a href='#answer-14'>Is the IMAP extension required for postie?</a></li>
16
+ <li id='question-15'><a href='#answer-15'>How can I embed youtube or vimeo videos?</a></li>
17
  <h3>Frequently Asked Questions</h3>
18
+ <h4 id='answer-0'>How can I get postie to display inline images?</h4>
19
+
20
+ <p>Make sure that you send e-mail formatted as html (richtext), and set postie to
21
+ prefer html messages (in the message tab of the postie settings)</p>
22
+
23
+ <h4 id='answer-1'>Mail is not showing up right when I send html (rich formatted) e-mail!</h4>
24
 
25
  <p>Make sure you set the preferred text type to html</p>
26
 
27
+ <h4 id='answer-2'>Do I need to any code to my theme for postie to work?</h4>
28
 
29
  <p>No.</p>
30
 
31
+ <h4 id='answer-3'>I read somewhere to add an iframe to my footer. Should I do this?</h4>
32
 
33
  <p>No. Do not add an iframe in your footer to get postie to check mail
34
  periodically. To check e-mail periodically, either set-up a cron job, or use
35
  cronless postie. See installation instructions</p>
36
 
37
+ <h4 id='answer-4'>My mail host requires SSL, but postie will not allow me to select pop3-ssl or imap-ssl</h4>
38
 
39
  <p>You must have php-imap installed on your server for this to work. Ask your
40
  hosting provider about this.</p>
41
 
42
+ <h4 id='answer-5'>Can I use postie to check a gmail account?</h4>
43
 
44
  <p>Yes. You can use either pop3-ssl or imap-ssl with a gmail account. Before
45
  attempting to use with postie, make sure that you enable pop or imap in your
68
  </ul></li>
69
  </ul>
70
 
71
+ <h4 id='answer-6'>My posts show up as being posted by 'admin' instead of me. Why?</h4>
72
 
73
  <p>If your admin account is linked to <a href="mailto:bar@gmail.com">bar@gmail.com</a>, and you send mail from
74
  <a href="mailto:bar@gmail.com">bar@gmail.com</a>, it will show up as being posted by admin. If you have a
80
  <p>If you send an e-mail to your postie address from an e-mail address that is no
81
  t linked to a wordpress user, it will get posted as admin.</p>
82
 
83
+ <h4 id='answer-7'>Images aren't showing up at all?</h4>
84
 
85
  <p>There are a couple possible reasons for this. First, check to see if you can
86
  add an image through wordpress's normal posting mechanism. If not, then there
93
  sure that it is</li>
94
  </ol>
95
 
96
+ <h4 id='answer-8'>Can I delete the wp-files directory needed by postie version &lt;1.3.0?</h4>
97
 
98
  <p>If you have posts published already by older versions of postie, getting rid
99
  of those directories will delete any files you might have had associated with
100
  those old posts. If you don't have any such posts, then you can safely delete
101
  them.</p>
102
 
103
+ <h4 id='answer-9'>How can I get rid of stupid stuff my e-mail provider adds to my messages?</h4>
104
 
105
  <p>To strip off stuff that they add at the beginning of a message, start your
106
  post with :start</p>
108
  <p>To strip off stuff that they add at the end of a message, end your
109
  post with :end</p>
110
 
111
+ <h4 id='answer-10'>How can I add custom attachment icons?</h4>
112
 
113
  <p>Simply upload the icons you want to the postie/icons/custom directory. You
114
  must name the icons according to the following scheme:
139
  <li>txt - plain text document</li>
140
  </ul>
141
 
142
+ <h4 id='answer-11'>Can I add special text to the body of the post when using postie?</h4>
143
+
144
+ <p>Yes. You can create your own function, and use the postie_post filter.
145
+ Two short examples are included in the filterPostie.php.sample file</p>
146
+
147
+ <h4 id='answer-12'>Can I add special text to the title of the post when using postie?</h4>
148
 
149
+ <p>Yes. You can create your own function, and use the postie_post filter.
150
+ Two short examples are included in the filterPostie.php.sample file</p>
151
 
152
+ <h4 id='answer-13'>Can I select tags or categories based on the content of the e-mail?</h4>
153
 
154
+ <p>Yes. You can create your own function, and use the postie_post filter.
155
+ See the filterPostie.php.sample file for examples.</p>
156
 
157
+ <h4 id='answer-14'>Is the IMAP extension required for postie?</h4>
158
 
159
  <p>The IMAP extension is not required, but it is strongly recommended, especially
160
  is you are using non-English text. There is more information on php.net about
170
  <p>The IMAP extension is known to be installed on the following popular webhosts:
171
  * Dreamhost</p>
172
 
173
+ <h4 id='answer-15'>How can I embed youtube or vimeo videos?</h4>
174
 
175
  <p>Simply put the url in the body of your e-mail. (Make sure that you have the
176
  option to convert url into links turned on)</p>
postie-functions.php CHANGED
@@ -2,12 +2,15 @@
2
  $revisions= WP_POST_REVISIONS;
3
  define('WP_POST_REVISIONS', false);
4
  //define('POSTIE_DEBUG', true);
5
- $original_mem_limit = ini_get('memory_limit');
6
- //ini_set('memory_limit', -1);
 
 
 
7
 
8
  //include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR."wp-admin" . DIRECTORY_SEPARATOR . "upgrade-functions.php");
9
  /*
10
- $Id: postie-functions.php 230537 2010-04-18 17:20:49Z robfelty $
11
  */
12
 
13
  /*TODO
@@ -680,20 +683,16 @@ function GetContent ($part,&$attachments, $post_id, $poster, $config) {
680
  break;
681
 
682
  case 'image':
683
- echo "looking at an image\n";
684
  $file_id = postie_media_handle_upload($part, $post_id, $poster);
685
  $file = wp_get_attachment_url($file_id);
686
 
687
  $cid = trim($part->headers["content-id"],"<>");; //cids are in <cid>
688
  $the_post=get_post($file_id);
689
- /* TODO make these options */
690
- if (!$auto_gallery) {
691
- $attachments["html"][] = parseTemplate($file_id, $part->ctype_primary,
692
- $imagetemplate);
693
- if ($cid) {
694
- $attachments["cids"][$cid] = array($file,
695
- count($attachments["html"]) - 1);
696
- }
697
  }
698
  break;
699
  case 'audio':
@@ -737,7 +736,6 @@ function GetContent ($part,&$attachments, $post_id, $poster, $config) {
737
  break;
738
  $file_id = postie_media_handle_upload($part, $post_id, $poster);
739
  $file = wp_get_attachment_url($file_id);
740
- echo "file=$file\n";
741
  $cid = trim($part->headers["content-id"],"<>");; //cids are in <cid>
742
  $icon=chooseAttachmentIcon($file, $part->ctype_primary,
743
  $part->ctype_secondary, $icon_set,
@@ -890,20 +888,20 @@ if ( empty($from) ) {
890
  print("Confirming Access For $from \n");
891
  $sql = 'SELECT id FROM '. $wpdb->users.' WHERE user_email=\'' . addslashes($from) . "' LIMIT 1;";
892
  $user_ID= $wpdb->get_var($sql);
893
- $user = new WP_User($user_ID);
894
  if (!empty($user_ID)) {
895
- $poster = $user_ID;
 
 
 
 
 
 
 
896
  } elseif ($turn_authorization_off ||
897
  CheckEmailAddress($from, $authorized_addresses) ||
898
  CheckEmailAddress($resentFrom, $authorized_addresses)) {
899
- print("$from is authorized to post as the administrator\n");
900
- $from = get_option("admin_email");
901
- $adminUser=$admin_username;
902
- echo "adminUser='$adminUser'";
903
- $poster = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE
904
- user_login = '$adminUser'");
905
- } else if ($user->has_cap("post_via_postie")) {
906
- $poster = $user_ID;
907
  }
908
  $validSMTP=checkSMTP($mimeDecodedEmail, $smtp);
909
  if (!$poster || !$validSMTP) {
@@ -922,6 +920,14 @@ if ( empty($from) ) {
922
  return $poster;
923
  }
924
 
 
 
 
 
 
 
 
 
925
  function checkSMTP($mimeDecodedEmail, $smtpservers) {
926
  if ( empty( $smtpservers ) ) return true;
927
  foreach ( (array) $mimeDecodedEmail->headers['received'] as $received ) {
@@ -1108,6 +1114,12 @@ function ConvertToUTF_8($encoding,$charset,$body) {
1108
  case 'iso-8859-2':
1109
  $body = iconv("iso-8859-2//TRANSLIT","UTF-8",$body);
1110
  break;
 
 
 
 
 
 
1111
  }
1112
  return($body);
1113
  }
@@ -1273,8 +1285,6 @@ function postie_media_handle_upload($part, $post_id, $poster, $post_data = array
1273
  } else {
1274
  echo "could not write to temp file: '$tmpFile' ";
1275
  }
1276
- echo "wrote to temp file\n";
1277
- //print_r($part);
1278
  if ($part->ctype_parameters['name']=='') {
1279
  if ($part->d_parameters['filename']!='') {
1280
  $name = $part->d_parameters['filename'];
@@ -1289,7 +1299,6 @@ function postie_media_handle_upload($part, $post_id, $poster, $post_data = array
1289
  'size' => filesize($tmpFile),
1290
  'error' => ''
1291
  );
1292
- print_r($the_file);
1293
  if (stristr('.zip', $name)) {
1294
  $parts=explode('.', $name);
1295
  $ext=$parts[count($parts)-1];
@@ -1306,8 +1315,6 @@ function postie_media_handle_upload($part, $post_id, $poster, $post_data = array
1306
  }
1307
 
1308
  $file = postie_handle_upload($the_file, $overrides, $time);
1309
- echo "finished postie_handle_upload\n";
1310
- print_r($file);
1311
  //unlink($tmpFile);
1312
 
1313
  if ( isset($file['error']) )
@@ -1327,7 +1334,6 @@ function postie_media_handle_upload($part, $post_id, $poster, $post_data = array
1327
  if ( trim($image_meta['caption']) )
1328
  $content = $image_meta['caption'];
1329
  }
1330
- echo "read image meta data";
1331
 
1332
  // Construct the attachment array
1333
  $attachment = array_merge( array(
@@ -1496,14 +1502,12 @@ function MailToRecipients( &$mail_content,$testEmail=false,
1496
  if ($testEmail) {
1497
  return;
1498
  }
1499
- echo "mailing to ";
1500
  $user = get_userdata('1');
1501
  $myname = $user->user_nicename;
1502
  $myemailadd = get_option("admin_email");
1503
  $blogname = get_option("blogname");
1504
  $blogurl = get_option("siteurl");
1505
  //array_push($recipients, $myemailadd);
1506
- print_r($recipients);
1507
  if (count($recipients) == 0) {
1508
  return false;
1509
  }
@@ -1615,7 +1619,8 @@ function DisplayMIMEPartTypes($mimeDecodedEmail) {
1615
  * @return boolean
1616
  */
1617
  function CheckEmailAddress($address, $authorized) {
1618
- return in_array( strtolower($address), $authorized );
 
1619
  }
1620
  /**
1621
  *This method works around a problemw with email address with extra <> in the email address
@@ -1769,6 +1774,8 @@ size. If not found, we default to medium */
1769
  $template=str_replace('{POSTTITLE}', $the_parent->post_title, $template);
1770
  if ($attachment->post_excerpt!='') {
1771
  $template=str_replace('{CAPTION}', $attachment->post_excerpt, $template);
 
 
1772
  } else {
1773
  //$template=str_replace('{CAPTION}', '', $template);
1774
  }
@@ -1784,6 +1791,7 @@ size. If not found, we default to medium */
1784
  function ReplaceImageCIDs(&$content,&$attachments) {
1785
  $used = array();
1786
  foreach ($attachments["cids"] as $key => $info) {
 
1787
  $pattern = "/cid:$key/";
1788
  if(preg_match($pattern,$content)) {
1789
  $content = preg_replace($pattern,$info[0],$content);
@@ -1816,6 +1824,7 @@ function ReplaceImagePlaceHolders(&$content,$attachments, $config) {
1816
  }
1817
  return;
1818
  }
 
1819
  foreach ( $attachments as $i => $value ) {
1820
  // looks for ' #img1# ' etc... and replaces with image
1821
  $img_placeholder_temp = str_replace("%", intval($startIndex + $i), $image_placeholder);
@@ -1829,7 +1838,7 @@ function ReplaceImagePlaceHolders(&$content,$attachments, $config) {
1829
  $caption='';
1830
  $content = preg_replace("/&#0?39;/", "'", $content);
1831
  $content = preg_replace("/&(#0?34|quot);/", "\"", $content);
1832
- if ( preg_match("/$img_placeholder_temp caption=['\"]?(.*)['\"]?#/", $content, $matches)) {
1833
  $caption =$matches[1];
1834
  $img_placeholder_temp = substr($matches[0], 0, -1);
1835
  $eimg_placeholder_temp = substr($matches[0], 0, -1);
@@ -1845,14 +1854,33 @@ function ReplaceImagePlaceHolders(&$content,$attachments, $config) {
1845
  $value = str_replace('{CAPTION}', '', $value);
1846
  /* if using the gallery shortcode, don't add pictures at all */
1847
  if (!preg_match("/\[gallery[^\[]*\]/", $content, $matches)) {
1848
- if ($images_append) {
1849
- $content .= $value;
 
 
 
 
 
 
 
 
 
1850
  } else {
1851
- $content = $value . $content;
1852
  }
1853
  }
1854
  }
1855
  }
 
 
 
 
 
 
 
 
 
 
1856
  }
1857
  /**
1858
  *This function handles finding and setting the correct subject
@@ -2024,8 +2052,8 @@ function DisplayEmailPost($details) {
2024
  print '<b>Post Id</b>: ' . $details["ID"] . '<br />' . "\n";
2025
  print '<b>Posted content:</b></p><hr />' .
2026
  $details["post_content"] . '<hr /><pre>';
2027
- if (function_exists('memory_get_peak_usage'))
2028
- echo "Memory used: ". memory_get_peak_usage(). "\n";
2029
  }
2030
  /**
2031
  * Takes a value and builds a simple simple yes/no select box
@@ -2144,7 +2172,7 @@ function get_config_defaults() {
2144
  'input_protocol' => "pop3",
2145
  'interval' => 'twiceperhour',
2146
  'mail_server' => NULL,
2147
- 'mail_server_port' => NULL,
2148
  'mail_userid' => NULL,
2149
  'mail_password' => NULL,
2150
  'message_start' => ":start",
@@ -2462,7 +2490,11 @@ function postie_validate_settings( $in ) {
2462
  $out[$field] = explode( $sep, trim( $out[$field] ) );
2463
  foreach ( $out[$field] as $key => $val ) {
2464
  $tst = trim($val);
2465
- if ( empty( $tst ) ) unset( $out[$field][$key] );
 
 
 
 
2466
  }
2467
  }
2468
  }
@@ -2603,5 +2635,7 @@ if (!function_exists('get_user_by')) {
2603
  }
2604
 
2605
  define('WP_POST_REVISIONS', $revisions);
2606
- ini_set('memory_limit', $original_mem_limit);
 
 
2607
  ?>
2
  $revisions= WP_POST_REVISIONS;
3
  define('WP_POST_REVISIONS', false);
4
  //define('POSTIE_DEBUG', true);
5
+ if (!ini_get('safe_mode')) {
6
+ $original_mem_limit = ini_get('memory_limit');
7
+ ini_set('memory_limit', -1);
8
+ ini_set('max_execution_time', 300);
9
+ }
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
683
  break;
684
 
685
  case 'image':
 
686
  $file_id = postie_media_handle_upload($part, $post_id, $poster);
687
  $file = wp_get_attachment_url($file_id);
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,
695
+ count($attachments["html"]) - 1);
 
 
 
696
  }
697
  break;
698
  case 'audio':
736
  break;
737
  $file_id = postie_media_handle_upload($part, $post_id, $poster);
738
  $file = wp_get_attachment_url($file_id);
 
739
  $cid = trim($part->headers["content-id"],"<>");; //cids are in <cid>
740
  $icon=chooseAttachmentIcon($file, $part->ctype_primary,
741
  $part->ctype_secondary, $icon_set,
888
  print("Confirming Access For $from \n");
889
  $sql = 'SELECT id FROM '. $wpdb->users.' WHERE user_email=\'' . addslashes($from) . "' LIMIT 1;";
890
  $user_ID= $wpdb->get_var($sql);
 
891
  if (!empty($user_ID)) {
892
+ $user = new WP_User($user_ID);
893
+ if ($user->has_cap("post_via_postie")) {
894
+ $poster = $user_ID;
895
+ echo "posting as user $poster";
896
+ } else {
897
+ $poster = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE
898
+ user_login = '$admin_username'");
899
+ }
900
  } elseif ($turn_authorization_off ||
901
  CheckEmailAddress($from, $authorized_addresses) ||
902
  CheckEmailAddress($resentFrom, $authorized_addresses)) {
903
+ $poster = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE
904
+ user_login = '$admin_username'");
 
 
 
 
 
 
905
  }
906
  $validSMTP=checkSMTP($mimeDecodedEmail, $smtp);
907
  if (!$poster || !$validSMTP) {
920
  return $poster;
921
  }
922
 
923
+ function post_as_admin($admin_username) {
924
+ print("$from is authorized to post as the administrator\n");
925
+ //$from = get_option("admin_email");
926
+ //$adminUser=$admin_username;
927
+ //echo "adminUser='$adminUser'";
928
+ return $poster;
929
+ }
930
+
931
  function checkSMTP($mimeDecodedEmail, $smtpservers) {
932
  if ( empty( $smtpservers ) ) return true;
933
  foreach ( (array) $mimeDecodedEmail->headers['received'] as $received ) {
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);
1125
  }
1285
  } else {
1286
  echo "could not write to temp file: '$tmpFile' ";
1287
  }
 
 
1288
  if ($part->ctype_parameters['name']=='') {
1289
  if ($part->d_parameters['filename']!='') {
1290
  $name = $part->d_parameters['filename'];
1299
  'size' => filesize($tmpFile),
1300
  'error' => ''
1301
  );
 
1302
  if (stristr('.zip', $name)) {
1303
  $parts=explode('.', $name);
1304
  $ext=$parts[count($parts)-1];
1315
  }
1316
 
1317
  $file = postie_handle_upload($the_file, $overrides, $time);
 
 
1318
  //unlink($tmpFile);
1319
 
1320
  if ( isset($file['error']) )
1334
  if ( trim($image_meta['caption']) )
1335
  $content = $image_meta['caption'];
1336
  }
 
1337
 
1338
  // Construct the attachment array
1339
  $attachment = array_merge( array(
1502
  if ($testEmail) {
1503
  return;
1504
  }
 
1505
  $user = get_userdata('1');
1506
  $myname = $user->user_nicename;
1507
  $myemailadd = get_option("admin_email");
1508
  $blogname = get_option("blogname");
1509
  $blogurl = get_option("siteurl");
1510
  //array_push($recipients, $myemailadd);
 
1511
  if (count($recipients) == 0) {
1512
  return false;
1513
  }
1619
  * @return boolean
1620
  */
1621
  function CheckEmailAddress($address, $authorized) {
1622
+ $isAuthorized = in_array( strtolower($address), $authorized );
1623
+ return $isAuthorized;
1624
  }
1625
  /**
1626
  *This method works around a problemw with email address with extra <> in the email address
1774
  $template=str_replace('{POSTTITLE}', $the_parent->post_title, $template);
1775
  if ($attachment->post_excerpt!='') {
1776
  $template=str_replace('{CAPTION}', $attachment->post_excerpt, $template);
1777
+ } elseif (!preg_match("/$attachment->post_title/i", $fileName)) {
1778
+ $template=str_replace('{CAPTION}', $attachment->post_title, $template);
1779
  } else {
1780
  //$template=str_replace('{CAPTION}', '', $template);
1781
  }
1791
  function ReplaceImageCIDs(&$content,&$attachments) {
1792
  $used = array();
1793
  foreach ($attachments["cids"] as $key => $info) {
1794
+ $key = str_replace('/', '\/', $key);
1795
  $pattern = "/cid:$key/";
1796
  if(preg_match($pattern,$content)) {
1797
  $content = preg_replace($pattern,$info[0],$content);
1824
  }
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);
1838
  $caption='';
1839
  $content = preg_replace("/&#0?39;/", "'", $content);
1840
  $content = preg_replace("/&(#0?34|quot);/", "\"", $content);
1841
+ if ( preg_match("/$img_placeholder_temp caption=['\"]?(.*?)['\"]?#/", $content, $matches)) {
1842
  $caption =$matches[1];
1843
  $img_placeholder_temp = substr($matches[0], 0, -1);
1844
  $eimg_placeholder_temp = substr($matches[0], 0, -1);
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 {
1882
+ $content = $pics . $content;
1883
+ }
1884
  }
1885
  /**
1886
  *This function handles finding and setting the correct subject
2052
  print '<b>Post Id</b>: ' . $details["ID"] . '<br />' . "\n";
2053
  print '<b>Posted content:</b></p><hr />' .
2054
  $details["post_content"] . '<hr /><pre>';
2055
+ //if (function_exists('memory_get_peak_usage'))
2056
+ // echo "Memory used: ". memory_get_peak_usage(). "\n";
2057
  }
2058
  /**
2059
  * Takes a value and builds a simple simple yes/no select box
2172
  'input_protocol' => "pop3",
2173
  'interval' => 'twiceperhour',
2174
  'mail_server' => NULL,
2175
+ 'mail_server_port' => 110,
2176
  'mail_userid' => NULL,
2177
  'mail_password' => NULL,
2178
  'message_start' => ":start",
2490
  $out[$field] = explode( $sep, trim( $out[$field] ) );
2491
  foreach ( $out[$field] as $key => $val ) {
2492
  $tst = trim($val);
2493
+ if ( empty( $tst ) ) {
2494
+ unset( $out[$field][$key] );
2495
+ } else {
2496
+ $out[$field][$key] = $tst;
2497
+ }
2498
  }
2499
  }
2500
  }
2635
  }
2636
 
2637
  define('WP_POST_REVISIONS', $revisions);
2638
+ if (!ini_get('safe_mode')) {
2639
+ ini_set('memory_limit', $original_mem_limit);
2640
+ }
2641
  ?>
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
7
  Author: Robert Felty
8
  Author URI: http://blog.robfelty.com/
9
  */
10
 
11
  /*
12
- $Id: postie.php 219674 2010-03-19 17:58:46Z robfelty $
13
  * -= Requests Pending =-
14
  * German Umlats don't work
15
  * Problems under PHP5
@@ -131,7 +131,11 @@ function postie_warnings() {
131
 
132
  $config = get_option( 'postie-settings' );
133
 
134
- if ( empty( $config['mail_server'] ) && !isset($_POST['submit'] ) ) {
 
 
 
 
135
  function postie_enter_info() {
136
  echo "
137
  <div id='postie-info-warning' class='updated fade'><p><strong>".
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
131
 
132
  $config = get_option( 'postie-settings' );
133
 
134
+ if ( (empty( $config['mail_server'] ) ||
135
+ empty( $config['mail_server_port'] ) ||
136
+ empty( $config['mail_userid'] ) ||
137
+ empty( $config['mail_password'] )
138
+ ) && !isset($_POST['submit'] ) ) {
139
  function postie_enter_info() {
140
  echo "
141
  <div id='postie-info-warning' class='updated fade'><p><strong>".
postie_test.php CHANGED
@@ -5,6 +5,7 @@ include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR
5
  //require_once('admin.php');
6
  require_once("postie-functions.php");
7
  $config = get_config();
 
8
  $title = __("Postie Diagnosis");
9
  $parent_file = 'options-general.php?page=postie/postie.php';
10
  get_currentuserinfo();
@@ -43,9 +44,20 @@ get_currentuserinfo();
43
  ?>
44
 
45
  <br/>
46
- <h2>Iconv Library Test<h2>
47
- <p><i>Only required if you want to support ISO-2022-JP</i>
48
- <?php echo HasIconvInstalled();?>
 
 
 
 
 
 
 
 
 
 
 
49
  </p>
50
  <br/>
51
  <h2>Clock Tests<h2>
@@ -69,6 +81,9 @@ get_currentuserinfo();
69
  <th>Connect to Mail Host</th>
70
  <td>
71
  <?php
 
 
 
72
  switch( strtolower($config["input_protocol"]) ) {
73
  case 'imap':
74
  case 'imap-ssl':
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';
11
  get_currentuserinfo();
44
  ?>
45
 
46
  <br/>
47
+ <h2>International support<h2>
48
+ <p><i><?php _e('Only required for international character set support',
49
+ 'postie') ?></i>
50
+ <table>
51
+ <tr>
52
+ <th>iconv</th>
53
+ <td> <?php if (HasIconvInstalled()) _e('yes', 'postie'); ?></td>
54
+ </tr>
55
+ <tr>
56
+ <th>imap <small>(required for subjects)</small></th>
57
+ <td> <?php if (function_exists('imap_mime_header_decode')) _e('yes', 'postie') ; ?></td>
58
+ </tr>
59
+ </table>
60
+
61
  </p>
62
  <br/>
63
  <h2>Clock Tests<h2>
81
  <th>Connect to Mail Host</th>
82
  <td>
83
  <?php
84
+ if (!$mail_server || !$mail_server_port || !$mail_userid) {
85
+ print("NO - check server settings");
86
+ }
87
  switch( strtolower($config["input_protocol"]) ) {
88
  case 'imap':
89
  case 'imap-ssl':
readme.txt CHANGED
@@ -4,8 +4,8 @@ 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: 3.0.alpha
8
- Stable tag: 1.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,6 +19,25 @@ imap and pop3, with the option for ssl with both. For usage notes, see the
19
 
20
  = What's new? =
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  * 1.4 (2010.04.25)
23
  * Now using wordpress settings api (thanks for much help from Andrew S)
24
  * Cronless postie is now integrated with postie instead of a plugin
@@ -180,6 +199,11 @@ class='imagecaption'&gt;{CAPTION}&lt;/div&gt;&lt;/div&gt;
180
 
181
  == Frequently Asked Questions ==
182
 
 
 
 
 
 
183
  = Mail is not showing up right when I send html (rich formatted) e-mail! =
184
 
185
  Make sure you set the preferred text type to html
@@ -288,13 +312,18 @@ Currently the following filetypes are supported:
288
 
289
  = Can I add special text to the body of the post when using postie? =
290
 
291
- Yes. You can create your own function, and use the postie_post filter
292
- Two short examples are included in the filterPostie.php file
293
 
294
  = Can I add special text to the title of the post when using postie? =
295
 
296
- Yes. You can create your own function, and use the postie_post filter
297
- Two short examples are included in the filterPostie.php file
 
 
 
 
 
298
 
299
  = Is the IMAP extension required for postie? =
300
 
@@ -319,6 +348,25 @@ option to convert url into links turned on)
319
 
320
  == CHANGELOG ==
321
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
  = 1.4 (2010.04.25) =
323
  * Now using wordpress settings api (thanks for much help from Andrew S)
324
  * Cronless postie is now integrated with postie instead of a separate plugin
4
  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
 
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
25
+ * Fixed formatting problem with wordpress_default image template
26
+ * Captions now correctly work with wordpress >3.0 and <3.0
27
+ * Fixed auto_gallery feature
28
+ * Default port is now 110
29
+ * Added more configuration tests
30
+ * Added background color to settings page to make input boxes more visible
31
+ * Removed extra quote character in captions from #img# placeholders (thanks
32
+ SteelD for pointing out the error)
33
+ * Added support for big5 and gb-1232 encodings (thanks Chow)
34
+ * Fixed issue with configurations items stored as arrays, which caused
35
+ problems with validating authorized addresses
36
+ * Fixed bug with replaceImageCIDs function
37
+ * On hosts which allow it, we set max execution time to 300 seconds and
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
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
205
+ prefer html messages (in the message tab of the postie settings)
206
+
207
  = Mail is not showing up right when I send html (rich formatted) e-mail! =
208
 
209
  Make sure you set the preferred text type to html
312
 
313
  = Can I add special text to the body of the post when using postie? =
314
 
315
+ Yes. You can create your own function, and use the postie_post filter.
316
+ Two short examples are included in the filterPostie.php.sample file
317
 
318
  = Can I add special text to the title of the post when using postie? =
319
 
320
+ Yes. You can create your own function, and use the postie_post filter.
321
+ Two short examples are included in the filterPostie.php.sample file
322
+
323
+ = Can I select tags or categories based on the content of the e-mail? =
324
+
325
+ Yes. You can create your own function, and use the postie_post filter.
326
+ See the filterPostie.php.sample file for examples.
327
 
328
  = Is the IMAP extension required for postie? =
329
 
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
354
+ * Captions now correctly work with wordpress >3.0 and <3.0
355
+ * Fixed auto_gallery feature
356
+ * Default port is now 110
357
+ * Added more configuration tests
358
+ * Added background color to settings page to make input boxes more visible
359
+ * Removed extra quote character in captions from #img# placeholders (thanks
360
+ SteelD for pointing out the error)
361
+ * Added support for big5 and gb-1232 encodings (thanks Chow)
362
+ * Fixed issue with configurations items stored as arrays, which caused
363
+ problems with validating authorized addresses
364
+ * Fixed bug with replaceImageCIDs function
365
+ * On hosts which allow it, we set max execution time to 300 seconds and
366
+ memory_limit to infinity to allow processing of large e-mails (especially
367
+ with large attachments)
368
+ * Images are sorted in order of filename before inserting into post
369
+
370
  = 1.4 (2010.04.25) =
371
  * Now using wordpress settings api (thanks for much help from Andrew S)
372
  * Cronless postie is now integrated with postie instead of a separate plugin
templates/image_templates.php CHANGED
@@ -4,10 +4,8 @@ $robert_felty = '<div style="margin-right:10px;background:black;color:white;padd
4
  $no_wrappers = '<a href="{IMAGE}"><img src="{THUMBNAIL}" alt="{CAPTION}" title="{CAPTION}" class="attachment" /></a>';
5
  $thumbnail_left = '<div style="float:left;margin-right:10px;"><a href="{IMAGE}"><img src="{THUMBNAIL}" alt="{CAPTION}" title="{CAPTION}" class="attachment" /></a></div>';
6
  $thumbnail_right = '<div style="float:right;margin-left:10px;"><a href="{IMAGE}"><img src="{THUMBNAIL}" alt="{CAPTION}" title="{CAPTION}" class="attachment" /></a></div>';
7
- $wordpress_default = '<div id="attachment_{ID}" class="wp-caption alignleft"
8
- style="width: {MEDIUMWIDTH};"><a rel="attachment wp-att-{ID}" href="{PAGELINK}"><img class="size-medium wp-image-{ID}" title="{TITLE}" alt="{CAPTION}" src="{MEDIUM}" /> </a><p class="wp-caption-text">{CAPTION}</p></div>';
9
  $postie_legacy = '<div class="postie-image-div"><a href="{IMAGE}"><img src="{THUMBNAIL}" alt="{FILENAME}" title="{FILENAME}" style="border:none" class="postie-image" /></a></div>';
10
-
11
  $custom=$config['IMAGETEMPLATE'];
12
  $imageTemplates=compact('simple_link','no_wrappers',
13
  'wordpress_default','thumbnail_left','thumbnail_right','robert_felty','postie_legacy','custom');
4
  $no_wrappers = '<a href="{IMAGE}"><img src="{THUMBNAIL}" alt="{CAPTION}" title="{CAPTION}" class="attachment" /></a>';
5
  $thumbnail_left = '<div style="float:left;margin-right:10px;"><a href="{IMAGE}"><img src="{THUMBNAIL}" alt="{CAPTION}" title="{CAPTION}" class="attachment" /></a></div>';
6
  $thumbnail_right = '<div style="float:right;margin-left:10px;"><a href="{IMAGE}"><img src="{THUMBNAIL}" alt="{CAPTION}" title="{CAPTION}" class="attachment" /></a></div>';
7
+ $wordpress_default = '<div id="attachment_{ID}" class="wp-caption alignleft" style="width: {MEDIUMWIDTH};"><a rel="attachment wp-att-{ID}" href="{PAGELINK}"><img class="size-medium wp-image-{ID}" title="{TITLE}" alt="{CAPTION}" src="{MEDIUM}" /> </a><p class="wp-caption-text">{CAPTION}</p></div>';
 
8
  $postie_legacy = '<div class="postie-image-div"><a href="{IMAGE}"><img src="{THUMBNAIL}" alt="{FILENAME}" title="{FILENAME}" style="border:none" class="postie-image" /></a></div>';
 
9
  $custom=$config['IMAGETEMPLATE'];
10
  $imageTemplates=compact('simple_link','no_wrappers',
11
  'wordpress_default','thumbnail_left','thumbnail_right','robert_felty','postie_legacy','custom');