Version Description
Download this release
Release Info
Developer | robfelty |
Plugin | Postie |
Version | 1.2.2 |
Comparing to | |
See all releases |
Code changes from version 1.2.1 to 1.2.2
- config_form.php +2 -2
- cronless_postie.php +1 -1
- get_mail.php +9 -2
- languages/makepot +6 -0
- languages/postie-de_DE.mo +0 -0
- languages/postie-de_DE.po +12 -12
- postie-functions.php +329 -293
- postie.php +16 -32
- readme.txt +78 -13
config_form.php
CHANGED
@@ -230,7 +230,7 @@ fieldset {border: 1px solid black;}
|
|
230 |
<td>
|
231 |
<?php
|
232 |
$defaultCat=$config['DEFAULT_POST_CATEGORY'];
|
233 |
-
wp_dropdown_categories("name=DEFAULT_POST_CATEGORY&hierarchical=1&selected=$defaultCat"); ?>
|
234 |
<!--
|
235 |
<td><select name="DEFAULT_POST_CATEGORY" id="DEFAULT_POST_CATEGORY">
|
236 |
<?php
|
@@ -547,5 +547,5 @@ Recommended:
|
|
547 |
<a href="http://validator.w3.org/check?uri=referer">valid xhtml</a>
|
548 |
<a href="http://jigsaw.w3.org/css-validator/check/referer">valid css</a><br />
|
549 |
Postie Version:
|
550 |
-
$Id: config_form.php
|
551 |
</div>
|
230 |
<td>
|
231 |
<?php
|
232 |
$defaultCat=$config['DEFAULT_POST_CATEGORY'];
|
233 |
+
wp_dropdown_categories("name=DEFAULT_POST_CATEGORY&hierarchical=1&selected=$defaultCat&hide_empty=0"); ?>
|
234 |
<!--
|
235 |
<td><select name="DEFAULT_POST_CATEGORY" id="DEFAULT_POST_CATEGORY">
|
236 |
<?php
|
547 |
<a href="http://validator.w3.org/check?uri=referer">valid xhtml</a>
|
548 |
<a href="http://jigsaw.w3.org/css-validator/check/referer">valid css</a><br />
|
549 |
Postie Version:
|
550 |
+
$Id: config_form.php 117137 2009-05-11 15:07:43Z robfelty $
|
551 |
</div>
|
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.2.
|
8 |
Author URI: http://blog.robfelty.com
|
9 |
*/
|
10 |
|
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.2.2
|
8 |
Author URI: http://blog.robfelty.com
|
9 |
*/
|
10 |
|
get_mail.php
CHANGED
@@ -18,11 +18,18 @@ TestWPMailInstallation();
|
|
18 |
|
19 |
//Retreive emails
|
20 |
print("<pre>\n");
|
21 |
-
$
|
|
|
|
|
|
|
|
|
22 |
//loop through messages
|
23 |
foreach ($emails as $email) {
|
24 |
//sanity check to see if there is any info in the message
|
25 |
-
if ($email == NULL ) {
|
|
|
|
|
|
|
26 |
|
27 |
$mimeDecodedEmail = DecodeMimeMail($email);
|
28 |
$from = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["from"]));
|
18 |
|
19 |
//Retreive emails
|
20 |
print("<pre>\n");
|
21 |
+
$config = GetConfig();
|
22 |
+
//print_r($config);
|
23 |
+
$emails = FetchMail($config['MAIL_SERVER'], $config['MAIL_SERVER_PORT'],
|
24 |
+
$config['MAIL_USERID'], $config['MAIL_PASSWORD'], $config['INPUT_PROTOCOL'],
|
25 |
+
$config['TIME_OFFSET'], $config['TEST_EMAIL']);
|
26 |
//loop through messages
|
27 |
foreach ($emails as $email) {
|
28 |
//sanity check to see if there is any info in the message
|
29 |
+
if ($email == NULL ) {
|
30 |
+
print 'Dang, message is empty!';
|
31 |
+
continue;
|
32 |
+
}
|
33 |
|
34 |
$mimeDecodedEmail = DecodeMimeMail($email);
|
35 |
$from = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["from"]));
|
languages/makepot
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
find . -iname '*php' >files.tmp
|
3 |
+
xgettext --language=PHP --keyword=__ --keyword=_e --keyword=__ngettext:1,2 --keyword=BuildBooleanSelect:1 --keyword=BuildTextArea:1 -F -n --from-code=UTF8 -o languages/postie.pot -f files.tmp
|
4 |
+
xgettext --language=PHP --keyword=BuildBooleanSelect:4 --keyword=BuildTextArea:4 -F -n --from-code=UTF8 -j -o languages/postie.pot -f files.tmp
|
5 |
+
rm files.tmp
|
6 |
+
|
languages/postie-de_DE.mo
CHANGED
Binary file
|
languages/postie-de_DE.po
CHANGED
@@ -44,7 +44,7 @@ msgstr "If you have problems with Postie this will run a special script to test
|
|
44 |
|
45 |
#: config_form.php:41
|
46 |
msgid "Test Config"
|
47 |
-
msgstr "
|
48 |
|
49 |
msgid "Yes"
|
50 |
msgstr "Ja"
|
@@ -58,7 +58,7 @@ msgstr "Authorization Settings"
|
|
58 |
|
59 |
#: config_form.php
|
60 |
msgid "Allow Anyone To Post Via Email"
|
61 |
-
msgstr "
|
62 |
|
63 |
#: config_form.php
|
64 |
msgid "Changing this to yes is NOT RECOMMEDED - anything that gets sent in will automatically be posted. This could make it easier to compromise your server - YOU HAVE BEEN WARNED."
|
@@ -74,7 +74,7 @@ msgstr "This allows you to grant access to other users to post if they have the
|
|
74 |
|
75 |
#: config_form.php
|
76 |
msgid "Authorized Addresses"
|
77 |
-
msgstr "
|
78 |
|
79 |
#: config_form.php
|
80 |
msgid "Put each email address on a single line. Posts from emails in this list will be treated as if they came from the admin. If you would prefer to have users post under their own name - create a WordPress user with the correct access level."
|
@@ -82,15 +82,15 @@ msgstr "Put each email address on a single line. Posts from emails in this list
|
|
82 |
|
83 |
#: config_form.php
|
84 |
msgid "Directory Settings"
|
85 |
-
msgstr "
|
86 |
|
87 |
#: config_form.php
|
88 |
msgid "Directory For Photos:"
|
89 |
-
msgstr "
|
90 |
|
91 |
#: config_form.php
|
92 |
msgid "Recommended"
|
93 |
-
msgstr "
|
94 |
|
95 |
#: config_form.php
|
96 |
msgid "Directory For Files:"
|
@@ -106,7 +106,7 @@ msgstr "Default post by mail category:"
|
|
106 |
|
107 |
#: config_form.php
|
108 |
msgid "Default Title:"
|
109 |
-
msgstr "Default
|
110 |
|
111 |
#: config_form.php
|
112 |
msgid "Live from the field"
|
@@ -134,11 +134,11 @@ msgstr "Allow Subject In Mail"
|
|
134 |
|
135 |
#: config_form.php
|
136 |
msgid "Allow HTML In Mail Subject"
|
137 |
-
msgstr "
|
138 |
|
139 |
#: config_form.php
|
140 |
msgid "Allow HTML In Mail Body"
|
141 |
-
msgstr "
|
142 |
|
143 |
#: config_form.php
|
144 |
msgid "Encoding for pages and feeds:"
|
@@ -158,7 +158,7 @@ msgstr "Decode Quoted Printable Data"
|
|
158 |
|
159 |
#: config_form.php
|
160 |
msgid "Should be yes in most cases."
|
161 |
-
msgstr "
|
162 |
|
163 |
#: config_form.php
|
164 |
msgid "Supported File Types"
|
@@ -166,7 +166,7 @@ msgstr "Supported File Types"
|
|
166 |
|
167 |
#: config_form.php
|
168 |
msgid "Put each type on a single line."
|
169 |
-
msgstr "
|
170 |
|
171 |
#: config_form.php
|
172 |
msgid "Banned File Names"
|
@@ -190,7 +190,7 @@ msgstr "Put each pattern on a seperate line and make sure to escape any special
|
|
190 |
|
191 |
#: config_form.php
|
192 |
msgid "Image Settings"
|
193 |
-
msgstr "
|
194 |
|
195 |
#: config_form.php
|
196 |
msgid "No GD Support"
|
44 |
|
45 |
#: config_form.php:41
|
46 |
msgid "Test Config"
|
47 |
+
msgstr "Einstellungen testen"
|
48 |
|
49 |
msgid "Yes"
|
50 |
msgstr "Ja"
|
58 |
|
59 |
#: config_form.php
|
60 |
msgid "Allow Anyone To Post Via Email"
|
61 |
+
msgstr "Alle können per E-mail posten"
|
62 |
|
63 |
#: config_form.php
|
64 |
msgid "Changing this to yes is NOT RECOMMEDED - anything that gets sent in will automatically be posted. This could make it easier to compromise your server - YOU HAVE BEEN WARNED."
|
74 |
|
75 |
#: config_form.php
|
76 |
msgid "Authorized Addresses"
|
77 |
+
msgstr "Bestätigte E-mailaddressen"
|
78 |
|
79 |
#: config_form.php
|
80 |
msgid "Put each email address on a single line. Posts from emails in this list will be treated as if they came from the admin. If you would prefer to have users post under their own name - create a WordPress user with the correct access level."
|
82 |
|
83 |
#: config_form.php
|
84 |
msgid "Directory Settings"
|
85 |
+
msgstr "Ordner Einstellungen"
|
86 |
|
87 |
#: config_form.php
|
88 |
msgid "Directory For Photos:"
|
89 |
+
msgstr "Ordner für Bilder:"
|
90 |
|
91 |
#: config_form.php
|
92 |
msgid "Recommended"
|
93 |
+
msgstr "Empfohlen"
|
94 |
|
95 |
#: config_form.php
|
96 |
msgid "Directory For Files:"
|
106 |
|
107 |
#: config_form.php
|
108 |
msgid "Default Title:"
|
109 |
+
msgstr "Default Titel:"
|
110 |
|
111 |
#: config_form.php
|
112 |
msgid "Live from the field"
|
134 |
|
135 |
#: config_form.php
|
136 |
msgid "Allow HTML In Mail Subject"
|
137 |
+
msgstr "HTML in Subjekt erlauben"
|
138 |
|
139 |
#: config_form.php
|
140 |
msgid "Allow HTML In Mail Body"
|
141 |
+
msgstr "HTML in Text erlauben"
|
142 |
|
143 |
#: config_form.php
|
144 |
msgid "Encoding for pages and feeds:"
|
158 |
|
159 |
#: config_form.php
|
160 |
msgid "Should be yes in most cases."
|
161 |
+
msgstr "Normalerweise ja."
|
162 |
|
163 |
#: config_form.php
|
164 |
msgid "Supported File Types"
|
166 |
|
167 |
#: config_form.php
|
168 |
msgid "Put each type on a single line."
|
169 |
+
msgstr "Eine pro Zeile."
|
170 |
|
171 |
#: config_form.php
|
172 |
msgid "Banned File Names"
|
190 |
|
191 |
#: config_form.php
|
192 |
msgid "Image Settings"
|
193 |
+
msgstr "Bild Einstellungen"
|
194 |
|
195 |
#: config_form.php
|
196 |
msgid "No GD Support"
|
postie-functions.php
CHANGED
@@ -1,7 +1,11 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
2 |
/*TODO
|
3 |
* check if image height is being consulted
|
4 |
* html purify
|
|
|
5 |
*/
|
6 |
#global $config,$debug;
|
7 |
#$debug=true;
|
@@ -26,102 +30,102 @@ if (!function_exists('fnmatch')) {
|
|
26 |
* This is the main handler for all of the processing
|
27 |
*/
|
28 |
function PostEmail($poster,$mimeDecodedEmail) {
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
#print("<p>Email has following attachments after filtering:");
|
43 |
# foreach($mimeDecodedEmail->parts as $parts) {
|
44 |
# print("<p>".$parts->ctype_primary ." ".$parts->ctype_secondary) ."<br />\n";
|
45 |
# }
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
|
70 |
-
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
} else {
|
88 |
-
//BMS: removing metadata from post body?
|
89 |
-
//$content = $postAuthorDetails['content'] . $content;
|
90 |
-
$content = $content;
|
91 |
-
}
|
92 |
} else {
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
}
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
$
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
125 |
}
|
126 |
/** FUNCTIONS **/
|
127 |
|
@@ -158,92 +162,93 @@ function clickableLink($text) {
|
|
158 |
$ret = substr($ret, 1);
|
159 |
return $ret;
|
160 |
}
|
|
|
161 |
function getPostAuthorDetails(&$subject,&$content,&$mimeDecodedEmail) {
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
$mimeDecodedEmail->headers['from']=$theAuthor;
|
174 |
-
}
|
175 |
-
if (preg_match("/\ndate:(.*?)\n/i",$content,$matches)) {
|
176 |
-
$theDate=$matches[1];
|
177 |
-
$mimeDecodedEmail->headers['date']=$theDate;
|
178 |
-
}
|
179 |
-
} else {
|
180 |
-
$theDate=$mimeDecodedEmail->headers['date'];
|
181 |
-
$theAuthor=GetNameFromEmail($mimeDecodedEmail->headers['from']);
|
182 |
-
$theEmail = RemoveExtraCharactersInEmailAddress(trim(
|
183 |
-
$mimeDecodedEmail->headers["from"]));
|
184 |
-
}
|
185 |
-
// now get rid of forwarding info in the content
|
186 |
-
$lines=preg_split("/\r\n/",$content);
|
187 |
-
$newContents='';
|
188 |
-
foreach ($lines as $line) {
|
189 |
-
if (preg_match("/^(from|subject|to|date):.*?/i",$line,$matches)==0 &&
|
190 |
-
// preg_match("/^$/i",$line,$matches)==0 &&
|
191 |
-
preg_match("/^-+\s*forwarded\s*message\s*-+/i",$line,$matches)==0) {
|
192 |
-
$newContents.=preg_replace("/\r/","",$line) . "\n" ;
|
193 |
-
}
|
194 |
}
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
'
|
201 |
-
'
|
202 |
-
|
203 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
}
|
|
|
205 |
function checkReply(&$subject) {
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
}
|
241 |
}
|
242 |
-
|
|
|
243 |
}
|
244 |
|
245 |
function postie_read_me() {
|
246 |
-
|
247 |
}
|
248 |
/**
|
249 |
* This sets up the configuration menu
|
@@ -260,88 +265,89 @@ function PostieMenu() {
|
|
260 |
* This handles actually showing the form
|
261 |
*/
|
262 |
function ConfigurePostie() {
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
}
|
271 |
|
272 |
/**
|
273 |
* This function handles determining the protocol and fetching the mail
|
274 |
* @return array
|
275 |
*/
|
276 |
-
function FetchMail(
|
277 |
-
$
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
}
|
320 |
-
return($emails);
|
321 |
}
|
322 |
/**
|
323 |
*Handles fetching messages from an imap server
|
324 |
*/
|
325 |
function TestIMAPMessageFetch ( ) {
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
|
|
|
|
331 |
|
332 |
}
|
333 |
/**
|
334 |
*Handles fetching messages from an imap server
|
335 |
*/
|
336 |
-
function IMAPMessageFetch ($
|
|
|
337 |
if (!$config) {
|
338 |
$config = GetConfig();
|
339 |
}
|
340 |
require_once("postieIMAP.php");
|
341 |
|
342 |
-
$mail_server = &PostieIMAP::Factory($
|
343 |
-
print("\nConnecting to $
|
344 |
-
if (!$mail_server->connect($
|
345 |
print("Mail Connection Time Out\n
|
346 |
Common Reasons: \n
|
347 |
Server Down \n
|
@@ -370,23 +376,26 @@ function IMAPMessageFetch ($config = NULL ) {
|
|
370 |
return $emails;
|
371 |
}
|
372 |
function TestPOP3MessageFetch ( ) {
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
|
|
|
|
378 |
}
|
379 |
/**
|
380 |
*Retrieves email via POP3
|
381 |
*/
|
382 |
-
function POP3MessageFetch ($
|
|
|
383 |
if (!$config) {
|
384 |
$config = GetConfig();
|
385 |
}
|
386 |
require_once(ABSPATH.WPINC.DIRECTORY_SEPARATOR.'class-pop3.php');
|
387 |
$pop3 = &new POP3();
|
388 |
-
print("\nConnecting to $
|
389 |
-
if (!$pop3->connect($
|
390 |
if (strpos($pop3->ERROR,"POP3: premature NOOP OK, NOT an RFC 1939 Compliant server") === false) {
|
391 |
print("Mail Connection Time Out\n
|
392 |
Common Reasons: \n
|
@@ -399,7 +408,7 @@ function POP3MessageFetch ($config = NULL) {
|
|
399 |
}
|
400 |
|
401 |
//Check to see if there is any mail, if not die
|
402 |
-
$msg_count = $pop3->login($
|
403 |
if (!$msg_count) {
|
404 |
$pop3->quit();
|
405 |
return(array());
|
@@ -485,7 +494,13 @@ function PostToDB($details) {
|
|
485 |
$post_ID = wp_insert_comment($comment);
|
486 |
}
|
487 |
if ($config["CUSTOM_IMAGE_FIELD"]) {
|
488 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
489 |
add_post_meta($post_ID, 'image', $image);
|
490 |
}
|
491 |
}
|
@@ -597,8 +612,6 @@ function GetContent ($part,&$attachments) {
|
|
597 |
if ($config["USE_IMAGEMAGICK"] && $config["AUTO_SMART_SHARP"]) {
|
598 |
ImageMagickSharpen($file);
|
599 |
}
|
600 |
-
$mimeTag = '<!--Mime Type of File is
|
601 |
-
'.$part->ctype_primary."/".$part->ctype_secondary.' --></p>';
|
602 |
$thumbImage = NULL;
|
603 |
$cid = trim($part->headers["content-id"],"<>");; //cids are in <cid>
|
604 |
if ($config["RESIZE_LARGE_IMAGES"]) {
|
@@ -613,28 +626,34 @@ function GetContent ($part,&$attachments) {
|
|
613 |
$onclick='';
|
614 |
if ($config['IMAGE_NEW_WINDOW']) {
|
615 |
$onclick='" onclick="window.open(' . "'"
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
}
|
620 |
if ($thumbImage) {
|
621 |
if ($config['USEIMAGETEMPLATE']) {
|
622 |
-
$attachments["html"][]
|
623 |
-
|
624 |
} else {
|
625 |
-
|
626 |
-
|
627 |
-
|
|
|
|
|
|
|
|
|
|
|
628 |
}
|
629 |
if ($cid) {
|
630 |
-
|
|
|
631 |
}
|
632 |
} else {
|
633 |
if ($config['USEIMAGETEMPLATE']) {
|
634 |
$attachments["html"][]
|
635 |
.=parseImageTemplate('',$fileName,$caption);
|
636 |
} else {
|
637 |
-
$attachments["html"][] .=
|
638 |
. '" alt="' . $part->ctype_parameters['name'] . '" style="'
|
639 |
. $config["IMAGESTYLE"] . '" class="' . $config["IMAGECLASS"] . '" /></div>' . "\n";
|
640 |
if ($cid) {
|
@@ -817,13 +836,14 @@ $search = array(
|
|
817 |
'/<\/html>/',
|
818 |
'/<title>/',
|
819 |
'/<\/title>/',
|
820 |
-
'/<body
|
821 |
'/<\/body>/',
|
822 |
'/<head>/',
|
823 |
'/<\/head>/',
|
824 |
-
'/<meta
|
825 |
-
'
|
826 |
-
'
|
|
|
827 |
// '/<img src="cid:(.*)" .*>/'
|
828 |
);
|
829 |
|
@@ -846,8 +866,6 @@ $replace = array (
|
|
846 |
return ($content);
|
847 |
}
|
848 |
|
849 |
-
|
850 |
-
|
851 |
/**
|
852 |
* Determines if the sender is a valid user.
|
853 |
* @return integer|NULL
|
@@ -1071,6 +1089,9 @@ function ConvertToUTF_8($encoding,$charset,&$body) {
|
|
1071 |
case "iso-2022-jp":
|
1072 |
$body = iconv("ISO-2022-JP//TRANSLIT","UTF-8",$body);
|
1073 |
break;
|
|
|
|
|
|
|
1074 |
}
|
1075 |
}
|
1076 |
|
@@ -1348,6 +1369,7 @@ function CustomImageRotate($src_img, $angle, $bicubic=false) {
|
|
1348 |
|
1349 |
return($rotate);
|
1350 |
}
|
|
|
1351 |
function DetermineScale($width,$height, $max_width, $max_height) {
|
1352 |
if (!empty($max_width)) {
|
1353 |
return($max_width/$width);
|
@@ -1357,6 +1379,22 @@ function DetermineScale($width,$height, $max_width, $max_height) {
|
|
1357 |
}
|
1358 |
return(1);
|
1359 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1360 |
|
1361 |
function ResizeImageWithImageMagick($file,$type) {
|
1362 |
//print("<h1>Using ImageMagick</h1>");
|
@@ -2242,7 +2280,7 @@ function GetConfig() {
|
|
2242 |
$config["FILESDIR"] .= DIRECTORY_SEPARATOR;
|
2243 |
}
|
2244 |
//These should only be modified if you are testing
|
2245 |
-
$config["DELETE_MAIL_AFTER_PROCESSING"] =
|
2246 |
$config["POST_TO_DB"] = true;
|
2247 |
$config["TEST_EMAIL"] = false;
|
2248 |
$config["TEST_EMAIL_ACCOUNT"] = "blogtest";
|
@@ -2255,8 +2293,7 @@ function GetConfig() {
|
|
2255 |
||!file_exists($config["IMAGEMAGICK_CONVERT"])) {
|
2256 |
$config["RESIZE_LARGE_IMAGES"] = false;
|
2257 |
}
|
2258 |
-
}
|
2259 |
-
else {
|
2260 |
if (!HasGDInstalled(false)) {
|
2261 |
$config["RESIZE_LARGE_IMAGES"] = false;
|
2262 |
}
|
@@ -2291,28 +2328,28 @@ function GetListOfArrayConfig() {
|
|
2291 |
* @return boolean
|
2292 |
*/
|
2293 |
function HasIMAPSupport($display = true) {
|
2294 |
-
|
2295 |
-
|
2296 |
-
|
2297 |
-
|
2298 |
-
|
2299 |
-
|
2300 |
}
|
2301 |
function HasIconvInstalled($display = true) {
|
2302 |
-
|
2303 |
-
|
2304 |
}
|
2305 |
function HasGDInstalled($display = true) {
|
2306 |
-
|
2307 |
-
|
2308 |
-
|
2309 |
-
|
2310 |
-
|
2311 |
-
|
2312 |
-
|
2313 |
-
|
2314 |
-
|
2315 |
-
|
2316 |
}
|
2317 |
/**
|
2318 |
* Handles verifing that a list of functions exists
|
@@ -2320,34 +2357,33 @@ function HasGDInstalled($display = true) {
|
|
2320 |
* @param array
|
2321 |
*/
|
2322 |
function HasFunctions($function_list,$display = true) {
|
2323 |
-
|
2324 |
-
|
2325 |
-
|
2326 |
-
|
2327 |
-
|
2328 |
-
|
2329 |
-
}
|
2330 |
}
|
2331 |
-
|
2332 |
-
|
2333 |
}
|
2334 |
/**
|
2335 |
* This filter makes it easy to change the html from showing the thumbnail to the actual picture
|
2336 |
*/
|
2337 |
function filter_postie_thumbnail_with_full($content) {
|
2338 |
-
|
2339 |
-
|
2340 |
}
|
2341 |
/**
|
2342 |
* This function tests to see if postie is its own directory
|
2343 |
*/
|
2344 |
function TestPostieDirectory() {
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
|
2349 |
-
|
2350 |
-
|
2351 |
}
|
2352 |
/**
|
2353 |
*This function looks for markdown which causes problems with postie
|
1 |
<?php
|
2 |
+
/*
|
3 |
+
$Id: postie-functions.php 118031 2009-05-14 23:18:23Z robfelty $
|
4 |
+
*/
|
5 |
/*TODO
|
6 |
* check if image height is being consulted
|
7 |
* html purify
|
8 |
+
* windows 1252 encoding
|
9 |
*/
|
10 |
#global $config,$debug;
|
11 |
#$debug=true;
|
30 |
* This is the main handler for all of the processing
|
31 |
*/
|
32 |
function PostEmail($poster,$mimeDecodedEmail) {
|
33 |
+
$config = GetConfig();
|
34 |
+
$GLOBALS["POSTIE_IMAGE_ROTATION"] = 0;
|
35 |
+
$attachments = array(
|
36 |
+
"html" => array(), //holds the html for each image
|
37 |
+
"cids" => array(), //holds the cids for HTML email
|
38 |
+
"image_files" => array() //holds the files for each image
|
39 |
+
);
|
40 |
+
print("<p>Message Id is :" . $mimeDecodedEmail->headers["message-id"] . "</p><br/>\n");
|
41 |
+
print("<p>Email has following attachments:</p>");
|
42 |
+
foreach($mimeDecodedEmail->parts as $parts) {
|
43 |
+
print("<p>".$parts->ctype_primary ." ".$parts->ctype_secondary) ."</p><br />\n";
|
44 |
+
}
|
45 |
+
FilterTextParts($mimeDecodedEmail);
|
46 |
#print("<p>Email has following attachments after filtering:");
|
47 |
# foreach($mimeDecodedEmail->parts as $parts) {
|
48 |
# print("<p>".$parts->ctype_primary ." ".$parts->ctype_secondary) ."<br />\n";
|
49 |
# }
|
50 |
+
$content = GetContent($mimeDecodedEmail,$attachments);
|
51 |
+
$subject = GetSubject($mimeDecodedEmail,$content);
|
52 |
+
if ($debug) {
|
53 |
+
echo "the subject is $subject, right after calling GetSubject\n";
|
54 |
+
}
|
55 |
+
$rotation = GetRotation($mimeDecodedEmail,$content);
|
56 |
+
if ($rotation != "0" && count($attachments["image_files"])) {
|
57 |
+
RotateImages($rotation,$attachments["image_files"]);
|
58 |
+
}
|
59 |
+
$customImages = SpecialMessageParsing($content,$attachments);
|
60 |
+
$post_excerpt = GetPostExcerpt($content);
|
61 |
+
$postAuthorDetails=getPostAuthorDetails($subject,$content,
|
62 |
+
$mimeDecodedEmail);
|
63 |
+
$message_date = NULL;
|
64 |
+
if (array_key_exists("date",$mimeDecodedEmail->headers)
|
65 |
+
&& !empty($mimeDecodedEmail->headers["date"])) {
|
66 |
+
HandleMessageEncoding(
|
67 |
+
$mimeDecodedEmail->headers["content-transfer-encoding"],
|
68 |
+
$mimeDecodedEmail->ctype_parameters["charset"],
|
69 |
+
$mimeDecodedEmail->headers["date"]);
|
70 |
+
$message_date = $mimeDecodedEmail->headers['date'];
|
71 |
+
}
|
72 |
+
list($post_date,$post_date_gmt) = DeterminePostDate($content, $message_date);
|
73 |
|
74 |
+
ubb2HTML($content);
|
75 |
|
76 |
+
if ($config['FILTERNEWLINES'])
|
77 |
+
$content = FilterNewLines($content);
|
78 |
+
//$content = FixEmailQuotes($content);
|
79 |
+
|
80 |
+
$id=checkReply($subject);
|
81 |
+
$post_categories = GetPostCategories($subject);
|
82 |
+
$post_tags = GetPostTags($content);
|
83 |
+
$comment_status = AllowCommentsOnPost($content);
|
84 |
+
|
85 |
+
if ((empty($id) || is_null($id)) &&
|
86 |
+
$config['ADD_META']=='yes') {
|
87 |
+
if ($config['WRAP_PRE']=='yes') {
|
88 |
+
//BMS: removing metadata from post body?
|
89 |
+
//$content = $postAuthorDetails['content'] . "<pre>\n" . $content . "</pre>\n";
|
90 |
+
$content = "<pre>\n" . $content . "</pre>\n";
|
|
|
|
|
|
|
|
|
|
|
91 |
} else {
|
92 |
+
//BMS: removing metadata from post body?
|
93 |
+
//$content = $postAuthorDetails['content'] . $content;
|
94 |
+
$content = $content;
|
95 |
}
|
96 |
+
} else {
|
97 |
+
if ($config['WRAP_PRE']=='yes') {
|
98 |
+
$content = "<pre>\n" . $content . "</pre>\n";
|
99 |
+
}
|
100 |
+
}
|
101 |
+
if ($config['CONVERTURLS']) {
|
102 |
+
$content=clickableLink($content);
|
103 |
+
}
|
104 |
+
|
105 |
+
|
106 |
+
$post_status=$config['POST_STATUS'];
|
107 |
+
$details = array(
|
108 |
+
'post_author' => $poster,
|
109 |
+
'comment_author' => $postAuthorDetails['author'],
|
110 |
+
'email_author' => $postAuthorDetails['email'],
|
111 |
+
'post_date' => $post_date,
|
112 |
+
'post_date_gmt' => $post_date_gmt,
|
113 |
+
'post_content' => $content,
|
114 |
+
'post_title' => $subject,
|
115 |
+
'post_modified' => $post_date,
|
116 |
+
'post_modified_gmt' => $post_date_gmt,
|
117 |
+
'ping_status' => get_option('default_ping_status'),
|
118 |
+
'post_category' => $post_categories,
|
119 |
+
'tags_input' => $post_tags,
|
120 |
+
'comment_status' => $comment_status,
|
121 |
+
'post_name' => sanitize_title($subject),
|
122 |
+
'post_excerpt' => $post_excerpt,
|
123 |
+
'ID' => $id,
|
124 |
+
'customImages' => $customImages,
|
125 |
+
'post_status' => $post_status
|
126 |
+
);
|
127 |
+
DisplayEmailPost($details);
|
128 |
+
PostToDB($details);
|
129 |
}
|
130 |
/** FUNCTIONS **/
|
131 |
|
162 |
$ret = substr($ret, 1);
|
163 |
return $ret;
|
164 |
}
|
165 |
+
|
166 |
function getPostAuthorDetails(&$subject,&$content,&$mimeDecodedEmail) {
|
167 |
+
/* we check whether or not the e-mail is a forwards or a redirect. If it is
|
168 |
+
* a fwd, then we glean the author details from the body of the post.
|
169 |
+
* Otherwise we get them from the headers
|
170 |
+
*/
|
171 |
+
global $wpdb;
|
172 |
+
// see if subject starts with Fwd:
|
173 |
+
if (preg_match("/(^Fwd:) (.*)/", $subject, $matches)) {
|
174 |
+
$subject=trim($matches[2]);
|
175 |
+
if (preg_match("/\nfrom:(.*?)\n/i",$content,$matches)) {
|
176 |
+
$theAuthor=GetNameFromEmail($matches[1]);
|
177 |
+
$mimeDecodedEmail->headers['from']=$theAuthor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
}
|
179 |
+
if (preg_match("/\ndate:(.*?)\n/i",$content,$matches)) {
|
180 |
+
$theDate=$matches[1];
|
181 |
+
$mimeDecodedEmail->headers['date']=$theDate;
|
182 |
+
}
|
183 |
+
} else {
|
184 |
+
$theDate=$mimeDecodedEmail->headers['date'];
|
185 |
+
$theAuthor=GetNameFromEmail($mimeDecodedEmail->headers['from']);
|
186 |
+
$theEmail = RemoveExtraCharactersInEmailAddress(trim(
|
187 |
+
$mimeDecodedEmail->headers["from"]));
|
188 |
+
}
|
189 |
+
// now get rid of forwarding info in the content
|
190 |
+
$lines=preg_split("/\r\n/",$content);
|
191 |
+
$newContents='';
|
192 |
+
foreach ($lines as $line) {
|
193 |
+
if (preg_match("/^(from|subject|to|date):.*?/i",$line,$matches)==0 &&
|
194 |
+
// preg_match("/^$/i",$line,$matches)==0 &&
|
195 |
+
preg_match("/^-+\s*forwarded\s*message\s*-+/i",$line,$matches)==0) {
|
196 |
+
$newContents.=preg_replace("/\r/","",$line) . "\n" ;
|
197 |
+
}
|
198 |
+
}
|
199 |
+
$content=$newContents;
|
200 |
+
$theDetails=array(
|
201 |
+
'content' =>"<div class='postmetadata alt'>On $theDate, $theAuthor" .
|
202 |
+
" posted:</div>",
|
203 |
+
'emaildate' => $theDate,
|
204 |
+
'author' => $theAuthor,
|
205 |
+
'email' => $theEmail
|
206 |
+
);
|
207 |
+
return($theDetails);
|
208 |
}
|
209 |
+
|
210 |
function checkReply(&$subject) {
|
211 |
+
/* we check whether or not the e-mail is a reply to a previously
|
212 |
+
* published post. First we check whether it starts with Re:, and then
|
213 |
+
* we see if the remainder matches an already existing post. If so,
|
214 |
+
* then we add that post id to the details array, which will cause the
|
215 |
+
* existing post to be overwritten, instead of a new one being
|
216 |
+
* generated
|
217 |
+
*/
|
218 |
+
|
219 |
+
global $wpdb;
|
220 |
+
// see if subject starts with Re:
|
221 |
+
if (preg_match("/(^Re:) (.*)/", $subject, $matches)) {
|
222 |
+
$subject=trim($matches[2]);
|
223 |
+
// strip out category info into temporary variable
|
224 |
+
$tmpSubject=$subject;
|
225 |
+
if ( preg_match('/(.+): (.*)/', $tmpSubject, $matches)) {
|
226 |
+
$tmpSubject = trim($matches[2]);
|
227 |
+
$matches[1] = array($matches[1]);
|
228 |
+
}
|
229 |
+
else if (preg_match_all('/\[(.[^\[]*)\]/', $tmpSubject, $matches)) {
|
230 |
+
preg_match("/](.[^\[]*)$/",$tmpSubject,$tmpSubject_matches);
|
231 |
+
$tmpSubject = trim($tmpSubject_matches[1]);
|
232 |
+
}
|
233 |
+
else if ( preg_match_all('/-(.[^-]*)-/', $tmpSubject, $matches) ) {
|
234 |
+
preg_match("/-(.[^-]*)$/",$tmpSubject,$tmpSubject_matches);
|
235 |
+
$tmpSubject = trim($tmpSubject_matches[1]);
|
236 |
+
}
|
237 |
+
$checkExistingPostQuery= "SELECT ID FROM $wpdb->posts WHERE
|
238 |
+
'$tmpSubject' = post_title";
|
239 |
+
if ($id=$wpdb->get_var($checkExistingPostQuery)) {
|
240 |
+
if (is_array($id)) {
|
241 |
+
$id=$id[count($id)-1];
|
242 |
+
}
|
243 |
+
} else {
|
244 |
+
$id=NULL;
|
|
|
245 |
}
|
246 |
+
}
|
247 |
+
return($id);
|
248 |
}
|
249 |
|
250 |
function postie_read_me() {
|
251 |
+
include(POSTIE_ROOT . DIRECTORY_SEPARATOR. "postie_read_me.php");
|
252 |
}
|
253 |
/**
|
254 |
* This sets up the configuration menu
|
265 |
* This handles actually showing the form
|
266 |
*/
|
267 |
function ConfigurePostie() {
|
268 |
+
//PostieAdminPermissions();
|
269 |
+
//if (current_user_can('config_postie')) {
|
270 |
+
include(POSTIE_ROOT . DIRECTORY_SEPARATOR. "config_form.php");
|
271 |
+
//}
|
272 |
+
//else {
|
273 |
+
//postie_read_me();
|
274 |
+
//}
|
275 |
}
|
276 |
|
277 |
/**
|
278 |
* This function handles determining the protocol and fetching the mail
|
279 |
* @return array
|
280 |
*/
|
281 |
+
function FetchMail($server=NULL, $port=NULL, $email=NULL, $password=NULL,
|
282 |
+
$protocol=NULL, $offset=NULL, $test=NULL) {
|
283 |
+
//$config = GetConfig();
|
284 |
+
$emails = array();
|
285 |
+
if (!$server || !$port || !$email) {
|
286 |
+
die("Missing Configuration For Mail Server\n");
|
287 |
+
}
|
288 |
+
if ($server == "pop.gmail.com") {
|
289 |
+
print("\nMAKE SURE POP IS TURNED ON IN SETTING AT Gmail\n");
|
290 |
+
}
|
291 |
+
switch ( strtolower($protocol) ) {
|
292 |
+
case 'smtp': //direct
|
293 |
+
$fd = fopen("php://stdin", "r");
|
294 |
+
$input = "";
|
295 |
+
while (!feof($fd)) {
|
296 |
+
$input .= fread($fd, 1024);
|
297 |
+
}
|
298 |
+
fclose($fd);
|
299 |
+
$emails[0] = $input;
|
300 |
+
break;
|
301 |
+
case 'imap':
|
302 |
+
case 'imap-ssl':
|
303 |
+
case 'pop3-ssl':
|
304 |
+
HasIMAPSupport(false);
|
305 |
+
if ($test) {
|
306 |
+
$emails = TestIMAPMessageFetch();
|
307 |
+
} else {
|
308 |
+
$emails = IMAPMessageFetch($server, $port, $email,
|
309 |
+
$password, $protocol, $offset, $test);
|
310 |
+
}
|
311 |
+
break;
|
312 |
+
case 'pop3':
|
313 |
+
default:
|
314 |
+
if ($test) {
|
315 |
+
$emails = TestPOP3MessageFetch();
|
316 |
+
} else {
|
317 |
+
$emails =POP3MessageFetch ($server, $port, $email,
|
318 |
+
$password, $protocol, $offset, $test);
|
319 |
+
}
|
320 |
+
}
|
321 |
+
if (!$emails)
|
322 |
+
die("\nThere does not seem to be any new mail.\n");
|
323 |
+
return($emails);
|
|
|
|
|
324 |
}
|
325 |
/**
|
326 |
*Handles fetching messages from an imap server
|
327 |
*/
|
328 |
function TestIMAPMessageFetch ( ) {
|
329 |
+
print("**************RUNING IN TESTING MODE************\n");
|
330 |
+
$config = GetConfig();
|
331 |
+
$email = $config["TEST_EMAIL_ACCOUNT"];
|
332 |
+
$password = $config["TEST_EMAIL_PASSWORD"];
|
333 |
+
return(IMAPMessageFetch($config['MAIL_SERVER'], $config['MAIL_SERVER_PORT'],
|
334 |
+
$email, $password, $config['INPUT_PROTOCOL'],
|
335 |
+
$config['TIME_OFFSET'], $config['TEST_EMAIL']));
|
336 |
|
337 |
}
|
338 |
/**
|
339 |
*Handles fetching messages from an imap server
|
340 |
*/
|
341 |
+
function IMAPMessageFetch ($server=NULL, $port=NULL, $email=NULL,
|
342 |
+
$password=NULL, $protocol=NULL, $offset=NULL, $test=NULL) {
|
343 |
if (!$config) {
|
344 |
$config = GetConfig();
|
345 |
}
|
346 |
require_once("postieIMAP.php");
|
347 |
|
348 |
+
$mail_server = &PostieIMAP::Factory($protocol);
|
349 |
+
print("\nConnecting to $server:$port ($protocol) \n");
|
350 |
+
if (!$mail_server->connect($server, $port,$email,$password)) {
|
351 |
print("Mail Connection Time Out\n
|
352 |
Common Reasons: \n
|
353 |
Server Down \n
|
376 |
return $emails;
|
377 |
}
|
378 |
function TestPOP3MessageFetch ( ) {
|
379 |
+
print("**************RUNING IN TESTING MODE************\n");
|
380 |
+
$config = GetConfig();
|
381 |
+
$email = $config["TEST_EMAIL_ACCOUNT"];
|
382 |
+
$password = $config["TEST_EMAIL_PASSWORD"];
|
383 |
+
return(POP3MessageFetch($config['MAIL_SERVER'], $config['MAIL_SERVER_PORT'],
|
384 |
+
$email, $password, $config['INPUT_PROTOCOL'],
|
385 |
+
$config['TIME_OFFSET'], $config['TEST_EMAIL']));
|
386 |
}
|
387 |
/**
|
388 |
*Retrieves email via POP3
|
389 |
*/
|
390 |
+
function POP3MessageFetch ($server=NULL, $port=NULL, $email=NULL,
|
391 |
+
$password=NULL, $protocol=NULL, $offset=NULL, $test=NULL) {
|
392 |
if (!$config) {
|
393 |
$config = GetConfig();
|
394 |
}
|
395 |
require_once(ABSPATH.WPINC.DIRECTORY_SEPARATOR.'class-pop3.php');
|
396 |
$pop3 = &new POP3();
|
397 |
+
print("\nConnecting to $server:$port ($protocol)) \n");
|
398 |
+
if (!$pop3->connect($server, $port)) {
|
399 |
if (strpos($pop3->ERROR,"POP3: premature NOOP OK, NOT an RFC 1939 Compliant server") === false) {
|
400 |
print("Mail Connection Time Out\n
|
401 |
Common Reasons: \n
|
408 |
}
|
409 |
|
410 |
//Check to see if there is any mail, if not die
|
411 |
+
$msg_count = $pop3->login($email, $password);
|
412 |
if (!$msg_count) {
|
413 |
$pop3->quit();
|
414 |
return(array());
|
494 |
$post_ID = wp_insert_comment($comment);
|
495 |
}
|
496 |
if ($config["CUSTOM_IMAGE_FIELD"]) {
|
497 |
+
if (count($details['customImages'])>1) {
|
498 |
+
$imageField=1;
|
499 |
+
foreach ($details['customImages'] as $image) {
|
500 |
+
add_post_meta($post_ID, 'image'. $imageField, $image);
|
501 |
+
$imageField++;
|
502 |
+
}
|
503 |
+
} else {
|
504 |
add_post_meta($post_ID, 'image', $image);
|
505 |
}
|
506 |
}
|
612 |
if ($config["USE_IMAGEMAGICK"] && $config["AUTO_SMART_SHARP"]) {
|
613 |
ImageMagickSharpen($file);
|
614 |
}
|
|
|
|
|
615 |
$thumbImage = NULL;
|
616 |
$cid = trim($part->headers["content-id"],"<>");; //cids are in <cid>
|
617 |
if ($config["RESIZE_LARGE_IMAGES"]) {
|
626 |
$onclick='';
|
627 |
if ($config['IMAGE_NEW_WINDOW']) {
|
628 |
$onclick='" onclick="window.open(' . "'"
|
629 |
+
. $config["URLPHOTOSDIR"] . $fullImage . "','"
|
630 |
+
. "full_size_image" . "','"
|
631 |
+
. "toolbar=0,scrollbars=0,location=0,status=0,menubar=0,resizable=1,height=" . $marimey . ",width=" . $marimex . "');" . "return false;";
|
632 |
}
|
633 |
if ($thumbImage) {
|
634 |
if ($config['USEIMAGETEMPLATE']) {
|
635 |
+
$attachments["html"][] .=
|
636 |
+
parseImageTemplate($thumbImage,$fullImage,$caption);
|
637 |
} else {
|
638 |
+
$attachments["html"][] .= '<div class="' .
|
639 |
+
$config["IMAGEDIV"].'"><a href="' .
|
640 |
+
$config["URLPHOTOSDIR"] . $fullImage .
|
641 |
+
$onclick . '"><img src="' . $config["URLPHOTOSDIR"] .
|
642 |
+
$thumbImage . '" alt="' . $part->ctype_parameters['name'] .
|
643 |
+
'" title="' . $part->ctype_parameters['name'] .
|
644 |
+
'" style="'.$config["IMAGESTYLE"].'" class="'.
|
645 |
+
$config["IMAGECLASS"].'" /></a></div>' . "\n";
|
646 |
}
|
647 |
if ($cid) {
|
648 |
+
$attachments["cids"][$cid] = array($config["URLPHOTOSDIR"] .
|
649 |
+
$fullImage,count($attachments["html"]) - 1);
|
650 |
}
|
651 |
} else {
|
652 |
if ($config['USEIMAGETEMPLATE']) {
|
653 |
$attachments["html"][]
|
654 |
.=parseImageTemplate('',$fileName,$caption);
|
655 |
} else {
|
656 |
+
$attachments["html"][] .= '<div class="' . $config["IMAGEDIV"].'"><img src="' . $config["URLPHOTOSDIR"] . $fileName
|
657 |
. '" alt="' . $part->ctype_parameters['name'] . '" style="'
|
658 |
. $config["IMAGESTYLE"] . '" class="' . $config["IMAGECLASS"] . '" /></div>' . "\n";
|
659 |
if ($cid) {
|
836 |
'/<\/html>/',
|
837 |
'/<title>/',
|
838 |
'/<\/title>/',
|
839 |
+
'/<body[^<]*>/',
|
840 |
'/<\/body>/',
|
841 |
'/<head>/',
|
842 |
'/<\/head>/',
|
843 |
+
'/<meta[^<]*>/',
|
844 |
+
'/<style[^<]*>[^<]*<\/style>/',
|
845 |
+
'/<!DOCTYPE[^<]*>/',
|
846 |
+
'/<img src=[\'"][^<]*>/'
|
847 |
// '/<img src="cid:(.*)" .*>/'
|
848 |
);
|
849 |
|
866 |
return ($content);
|
867 |
}
|
868 |
|
|
|
|
|
869 |
/**
|
870 |
* Determines if the sender is a valid user.
|
871 |
* @return integer|NULL
|
1089 |
case "iso-2022-jp":
|
1090 |
$body = iconv("ISO-2022-JP//TRANSLIT","UTF-8",$body);
|
1091 |
break;
|
1092 |
+
case "Windows-1252":
|
1093 |
+
$body = iconv("Windows-1252//TRANSLIT","UTF-8",$body);
|
1094 |
+
break;
|
1095 |
}
|
1096 |
}
|
1097 |
|
1369 |
|
1370 |
return($rotate);
|
1371 |
}
|
1372 |
+
/*
|
1373 |
function DetermineScale($width,$height, $max_width, $max_height) {
|
1374 |
if (!empty($max_width)) {
|
1375 |
return($max_width/$width);
|
1379 |
}
|
1380 |
return(1);
|
1381 |
}
|
1382 |
+
*/
|
1383 |
+
function DetermineScale($width,$height, $max_width=0, $max_height=0) {
|
1384 |
+
if ($max_width!=0 || $max_height!=0) {
|
1385 |
+
$width_scale=($max_width/$width);
|
1386 |
+
$height_scale=($max_height/$height);
|
1387 |
+
if ($max_width==0) {
|
1388 |
+
$scale=$height_scale;
|
1389 |
+
} else if ($max_height==0) {
|
1390 |
+
$scale=$width_scale;
|
1391 |
+
} else {
|
1392 |
+
$scale = $width_scale < $height_scale? $width_scale : $height_scale;
|
1393 |
+
}
|
1394 |
+
return($scale);
|
1395 |
+
}
|
1396 |
+
return(1);
|
1397 |
+
}
|
1398 |
|
1399 |
function ResizeImageWithImageMagick($file,$type) {
|
1400 |
//print("<h1>Using ImageMagick</h1>");
|
2280 |
$config["FILESDIR"] .= DIRECTORY_SEPARATOR;
|
2281 |
}
|
2282 |
//These should only be modified if you are testing
|
2283 |
+
$config["DELETE_MAIL_AFTER_PROCESSING"] = false;
|
2284 |
$config["POST_TO_DB"] = true;
|
2285 |
$config["TEST_EMAIL"] = false;
|
2286 |
$config["TEST_EMAIL_ACCOUNT"] = "blogtest";
|
2293 |
||!file_exists($config["IMAGEMAGICK_CONVERT"])) {
|
2294 |
$config["RESIZE_LARGE_IMAGES"] = false;
|
2295 |
}
|
2296 |
+
} else {
|
|
|
2297 |
if (!HasGDInstalled(false)) {
|
2298 |
$config["RESIZE_LARGE_IMAGES"] = false;
|
2299 |
}
|
2328 |
* @return boolean
|
2329 |
*/
|
2330 |
function HasIMAPSupport($display = true) {
|
2331 |
+
$function_list = array("imap_open",
|
2332 |
+
"imap_delete",
|
2333 |
+
"imap_expunge",
|
2334 |
+
"imap_body",
|
2335 |
+
"imap_fetchheader");
|
2336 |
+
return(HasFunctions($function_list,$display));
|
2337 |
}
|
2338 |
function HasIconvInstalled($display = true) {
|
2339 |
+
$function_list = array("iconv");
|
2340 |
+
return(HasFunctions($function_list,$display));
|
2341 |
}
|
2342 |
function HasGDInstalled($display = true) {
|
2343 |
+
$function_list = array("getimagesize",
|
2344 |
+
"imagecreatefromjpeg",
|
2345 |
+
"imagecreatefromgif",
|
2346 |
+
"imagecreatefrompng",
|
2347 |
+
"imagecreatetruecolor",
|
2348 |
+
"imagecreatetruecolor",
|
2349 |
+
"imagecopyresampled",
|
2350 |
+
"imagejpeg",
|
2351 |
+
"imagedestroy");
|
2352 |
+
return(HasFunctions($function_list,$display));
|
2353 |
}
|
2354 |
/**
|
2355 |
* Handles verifing that a list of functions exists
|
2357 |
* @param array
|
2358 |
*/
|
2359 |
function HasFunctions($function_list,$display = true) {
|
2360 |
+
foreach ($function_list as $function) {
|
2361 |
+
if (!function_exists($function)) {
|
2362 |
+
if ($display) {
|
2363 |
+
print("<p>Missing $function");
|
2364 |
+
}
|
2365 |
+
return(false);
|
|
|
2366 |
}
|
2367 |
+
}
|
2368 |
+
return(true);
|
2369 |
}
|
2370 |
/**
|
2371 |
* This filter makes it easy to change the html from showing the thumbnail to the actual picture
|
2372 |
*/
|
2373 |
function filter_postie_thumbnail_with_full($content) {
|
2374 |
+
$content = str_replace("thumb.","",$content);
|
2375 |
+
return($content);
|
2376 |
}
|
2377 |
/**
|
2378 |
* This function tests to see if postie is its own directory
|
2379 |
*/
|
2380 |
function TestPostieDirectory() {
|
2381 |
+
$dir_parts = explode(DIRECTORY_SEPARATOR,dirname(__FILE__));
|
2382 |
+
$last_dir = array_pop($dir_parts);
|
2383 |
+
if ($last_dir != "postie") {
|
2384 |
+
return false;
|
2385 |
+
}
|
2386 |
+
return true;
|
2387 |
}
|
2388 |
/**
|
2389 |
*This function looks for markdown which causes problems with postie
|
postie.php
CHANGED
@@ -2,31 +2,19 @@
|
|
2 |
/*
|
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
|
6 |
-
|
7 |
-
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.
|
8 |
-
Version: 1.2.1
|
9 |
Author: Robert Felty
|
10 |
Author URI: http://blog.robfelty.com/
|
11 |
*/
|
12 |
|
13 |
/*
|
14 |
-
$Id: postie.php
|
15 |
* -= Requests Pending =-
|
16 |
* German Umlats don't work
|
17 |
-
* Problems under PHP5
|
18 |
* Problem with some mail server
|
19 |
* Multiple emails should tie to a single account
|
20 |
* Each user should be able to have a default category
|
21 |
-
* WP Switcher not compatible
|
22 |
-
* Setup poll
|
23 |
-
- web server
|
24 |
-
- mail clients
|
25 |
-
- plain/html
|
26 |
-
- phone/computer
|
27 |
-
- os of server
|
28 |
-
- os of client
|
29 |
-
- number of users posting
|
30 |
* Test for calling from the command line
|
31 |
* Support userid/domain as a valid username
|
32 |
* WP-switcher not compatiable http://www.alexking.org/index.php?content=software/wordpress/content.php#wp_120
|
@@ -41,11 +29,6 @@ $Id: postie.php 116205 2009-05-07 18:03:18Z robfelty $
|
|
41 |
//Older Version History is in the HISTORY file
|
42 |
|
43 |
|
44 |
-
if (!is_admin()) {
|
45 |
-
//include_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR. "wp-config.php");
|
46 |
-
//include_once (dirname(dirname(dirname(dirname(__FILE__)))) .
|
47 |
-
//DIRECTORY_SEPARATOR . 'wp-includes' . DIRECTORY_SEPARATOR . "pluggable.php");
|
48 |
-
}
|
49 |
if (isset($_GET["postie_read_me"])) {
|
50 |
include_once(ABSPATH . "wp-admin/admin.php");
|
51 |
$title = __("Edit Plugins");
|
@@ -58,17 +41,18 @@ if (isset($_GET["postie_read_me"])) {
|
|
58 |
if (is_admin()) {
|
59 |
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR ."postie-functions.php");
|
60 |
add_action("admin_menu","PostieMenu");
|
61 |
-
if(function_exists('load_plugin_textdomain')){
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
//load_plugin_textdomain( 'postie', "wp-content/plugins/postie/languages/");
|
70 |
-
}
|
71 |
-
add_action('init', 'postie_load_domain');
|
72 |
-
}
|
73 |
}
|
|
|
|
|
|
|
74 |
?>
|
|
|
|
2 |
/*
|
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 and also the <a href='http://wordpress.org/extend/plugins/postie/faq'>FAQ</a>. Visit the <a href='http://forum.robfelty.com/forum/postie'>postie forum</a> for support.
|
6 |
+
Version: 1.2.2
|
|
|
|
|
7 |
Author: Robert Felty
|
8 |
Author URI: http://blog.robfelty.com/
|
9 |
*/
|
10 |
|
11 |
/*
|
12 |
+
$Id: postie.php 118204 2009-05-15 21:17:01Z robfelty $
|
13 |
* -= Requests Pending =-
|
14 |
* German Umlats don't work
|
|
|
15 |
* Problem with some mail server
|
16 |
* Multiple emails should tie to a single account
|
17 |
* Each user should be able to have a default category
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
* Test for calling from the command line
|
19 |
* Support userid/domain as a valid username
|
20 |
* WP-switcher not compatiable http://www.alexking.org/index.php?content=software/wordpress/content.php#wp_120
|
29 |
//Older Version History is in the HISTORY file
|
30 |
|
31 |
|
|
|
|
|
|
|
|
|
|
|
32 |
if (isset($_GET["postie_read_me"])) {
|
33 |
include_once(ABSPATH . "wp-admin/admin.php");
|
34 |
$title = __("Edit Plugins");
|
41 |
if (is_admin()) {
|
42 |
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR ."postie-functions.php");
|
43 |
add_action("admin_menu","PostieMenu");
|
44 |
+
if(function_exists('load_plugin_textdomain')){
|
45 |
+
$plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
|
46 |
+
function postie_load_domain() {
|
47 |
+
load_plugin_textdomain( 'postie', $plugin_dir."/languages/",
|
48 |
+
basename(dirname(__FILE__)). '/languages/');
|
49 |
+
}
|
50 |
+
add_action('init', 'postie_load_domain');
|
51 |
+
}
|
|
|
|
|
|
|
|
|
52 |
}
|
53 |
+
/* Version info
|
54 |
+
$Id: postie.php 118204 2009-05-15 21:17:01Z robfelty $
|
55 |
+
*/
|
56 |
?>
|
57 |
+
|
58 |
+
|
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
|
6 |
Requires at least: 2.3
|
7 |
-
Tested up to: 2.
|
8 |
-
Stable tag: 1.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.
|
@@ -15,18 +15,19 @@ Postie offers many advanced features for posting to your blog via e-mail,
|
|
15 |
including the ability to assign categories by name, included pictures and
|
16 |
videos, and automatically strip off signatures. It also has support for both
|
17 |
imap and pop3, with the option for ssl with both. For usage notes, see the
|
18 |
-
[other notes](other_notes) page
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
*
|
23 |
-
*
|
24 |
-
|
25 |
-
* Fixed
|
26 |
-
*
|
27 |
-
*
|
28 |
-
*
|
29 |
-
*
|
30 |
|
31 |
== Installation ==
|
32 |
* Make sure all postie code is its own directory inside of wp-content/plugins/postie
|
@@ -200,8 +201,72 @@ class='imagecaption'>{CAPTION}</div></div>
|
|
200 |
* Automatically confirms that you are installed correctly
|
201 |
|
202 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
|
204 |
== History ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
* 1.2.1 (2009.05.07)
|
206 |
* Got rid of stupid version checking
|
207 |
* Improved cronless postie instructions and configuration
|
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.beta
|
8 |
+
Stable tag: 1.2.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.
|
15 |
including the ability to assign categories by name, included pictures and
|
16 |
videos, and automatically strip off signatures. It also has support for both
|
17 |
imap and pop3, with the option for ssl with both. For usage notes, see the
|
18 |
+
[other notes](other_notes) page. Please also see the
|
19 |
+
[FAQ](faq) page
|
20 |
|
21 |
+
|
22 |
+
= What's new in 1.2.2? =
|
23 |
+
* Show empty categories for default category in options
|
24 |
+
* Image scaling fixed so that the smaller value of max image width and max
|
25 |
+
image height is used
|
26 |
+
* Fixed some issues with parsing html e-mail
|
27 |
+
* Got rid of stupid mime tag (thanks Jeroen)
|
28 |
+
* No longer adding slashes before calling wp_insert_post
|
29 |
+
* When using custom image field, each image has a unique key
|
30 |
+
* Added FAQ
|
31 |
|
32 |
== Installation ==
|
33 |
* Make sure all postie code is its own directory inside of wp-content/plugins/postie
|
201 |
* Automatically confirms that you are installed correctly
|
202 |
|
203 |
|
204 |
+
== Frequently Asked Questions ==
|
205 |
+
|
206 |
+
= Mail is not showing up right when I send html (rich formatted) e-mail! =
|
207 |
+
|
208 |
+
Make sure you set the preferred text type to html
|
209 |
+
|
210 |
+
= Do I need to any code to my theme for postie to work? =
|
211 |
+
|
212 |
+
No.
|
213 |
+
|
214 |
+
= I read somewhere to add an iframe to my footer. Should I do this? =
|
215 |
+
|
216 |
+
No. Do not add an iframe in your footer to get postie to check mail
|
217 |
+
periodically. To check e-mail periodically, either set-up a cron job, or use
|
218 |
+
cronless postie. See installation instructions
|
219 |
+
|
220 |
+
= My mail host requires SSL, but postie will not allow me to select pop3-ssl
|
221 |
+
or imap-ssl =
|
222 |
+
|
223 |
+
You must have php-imap installed on your server for this to work. Ask your
|
224 |
+
hosting provider about this.
|
225 |
+
|
226 |
+
= Can I use postie to check a gmail account? =
|
227 |
+
|
228 |
+
Yes. You can use either pop3-ssl or imap-ssl with a gmail account. Before
|
229 |
+
attempting to use with postie, make sure that you enable pop or imap in your
|
230 |
+
gmail preferences.
|
231 |
+
|
232 |
+
* Pop3 settings:
|
233 |
+
* protocol - pop3-ssl
|
234 |
+
* server - pop.gmail.com
|
235 |
+
* port - 995
|
236 |
+
* userid - your username (e.g. if your e-mail address is foo@gmail.com,
|
237 |
+
this would be just foo)
|
238 |
+
* password - your password
|
239 |
+
* IMAP settings:
|
240 |
+
* protocol - imap-ssl
|
241 |
+
* server - imap.gmail.com
|
242 |
+
* port - 993
|
243 |
+
* userid - your username (e.g. if your e-mail address is foo@gmail.com,
|
244 |
+
this would be just foo)
|
245 |
+
* password - your password
|
246 |
+
|
247 |
+
= My posts show up as being posted by 'admin' instead of me. Why? =
|
248 |
+
|
249 |
+
If your admin account is linked to bar@gmail.com, and you send mail from
|
250 |
+
bar@gmail.com, it will show up as being posted by admin. If you have a
|
251 |
+
wordpress user named "John Doe", which is linked to johndoe@gmail.com, make
|
252 |
+
sure that you send e-mails from johndoe@gmail.com. It doesn't matter which
|
253 |
+
e-mail address postie is checking. That is, if you send mail from
|
254 |
+
johndoe@gmail.com to foo@gmail.com, it gets posted as "John Doe".
|
255 |
+
|
256 |
+
If you send an e-mail to your postie address from an e-mail address that is no
|
257 |
+
t linked to a wordpress user, it will get posted as admin.
|
258 |
|
259 |
== History ==
|
260 |
+
* 1.2.2 (2009.05.15)
|
261 |
+
* Show empty categories for default category in options
|
262 |
+
* Image scaling fixed so that the smaller value of max image width and max
|
263 |
+
image height is used
|
264 |
+
* Fixed some issues with parsing html e-mail
|
265 |
+
* Got rid of stupid mime tag (thanks Jeroen)
|
266 |
+
* No longer adding slashes before calling wp_insert_post
|
267 |
+
* When using custom image field, each image has a unique key
|
268 |
+
* Added FAQ
|
269 |
+
|
270 |
* 1.2.1 (2009.05.07)
|
271 |
* Got rid of stupid version checking
|
272 |
* Improved cronless postie instructions and configuration
|