tree checksum vpatch file split hunks

all signers: hanbot billymg diana_coman jfw

antecedents: mp-wp_add-footnotes-and-textselectionjs mp-wp_remove-tinymce-and-other-crud mp-wp_genesis mp-wp_comments_filtering

press order:

mp-wp_genesishanbot
mp-wp_add-footnotes-and-textselectionjsbillymg hanbot
mp-wp_update-image-references-to-svgbillymg hanbot
mp-wp_html-comments-regrindhanbot
mp-wp_remove-tinymce-and-other-crudbillymg
mp-wp_apply-htmlspecialchars-to-post-edit-contentbillymg
mp-wp_comments_filteringdiana_coman
mp-wp_remove-textselectionjs-pop3-etc-r2jfw

patch:

- 4AD5C0B7EDA9C670F311A23DA92114AB10BF30B9990B46882047AEA3AB569395F643CB4AA6144EE0BA74B9821DF1E69B26D299C1F0E9C11631A78C46F95913BD
+ 69B0EFA256E0F4DE208AB3C73A6DEC8882BD60F194A330BDB67F300B73F4CD12F2A57CCDED30B236F9D6831263184EAC2C4A3FA23C9FD30391D67C2F092BAA5E
mp-wp/manifest
(5 . 3)(5 . 4)
5 569483 mp-wp_remove-tinymce-and-other-crud billymg Remove tinymce, most of the importers, the self-update feature, and the google gears and press-this plugins
6 602064 mp-wp_apply-htmlspecialchars-to-post-edit-content billymg Run post content through htmlspecialchars() before loading into the post edit UI
7 605926 mp-wp_comments_filtering diana_coman Recent comments widget should show only people's comments (no track/pingbacks); theme default changed to show trackbacks/pingbacks as last/at the bottom in an article's comments list.
8 629903 mp-wp_remove-textselectionjs-pop3-etc-r2 jfw Remove the unreliable JS-based selection (reground: including wrapper spans), posting by POP3 login, and a stray .php.orig file. Neutralize and comment the example pingback updater.
- 219A4FC0CDFE92C1972A536E37C4D3D9DCA6758D744EB7391787D87434543F1BB2961305A0F4DAB21EE42BDE64BC0870B70981EECAD38A29F308123BB42B76B5
+ 6B99C0B24445F116108A7E92DFC7018A7420DC01813DCFD12168A09DC1C19C7EA8801120F692809E67493EEDCB4D2F3E2A9A88DD73ABBE0CE8B94E9A56AF1CA1
mp-wp/pingback-updater.php
(1 . 4)(1 . 6)
13 <?^M
14 /* See http://trilema.com/2015/how-to-fix-your-local-trackbacks/ (but note that .php files in your WP directory can be executed by anyone).^M
15 ^M
16 // Db connect data.^M
17 ^M
18 $db_name = '';^M
(45 . 4)(47 . 5)
20 ^M
21 }^M
22 ^M
23 */^M
24 ?>^M
- 261CB6FC5FC05C18A47689861FEAE94267B0BA35FA4E2F7138A2671AB615F553D10D345D6869187F3080E99DAFFA1BD0924A2C65F6D7955728C0D815AB176C95
+ C890A951B231C4C93F6B5C87CD66F0A3312C83FD26FA04718EE43A55D67B18C7E4CC2E3B44E54276E093BB952B191430260F6DE08AD6FCA55DC96E7987997C4A
mp-wp/wp-admin/includes/schema.php
(194 . 10)(194 . 6)
29 add_option('posts_per_rss', 10);
30 add_option('rss_excerpt_length', 50);
31 add_option('rss_use_excerpt', 0);
32 add_option('mailserver_url', 'mail.example.com');
33 add_option('mailserver_login', 'login@example.com');
34 add_option('mailserver_pass', 'password');
35 add_option('mailserver_port', 110);
36 add_option('default_category', 1);
37 add_option('default_comment_status', 'open');
38 add_option('default_ping_status', 'open');
- CE5DD19582EFD856B7B9F0CEC13CDE48A400ED1535E83383619A236F7490E8779BDB9AE7A1FCB28BAF6288442CE31205C946EFC24001E074CDBAF5E41367AAF0
+ 8CBBCB864590DD9ACE0C79288A9B31E43B65223E3FE0B295B4D8B79102A08D0CFB47E5FC3516AB50C6E3B92E8995586EF57624453F4532082C47AC0C39646E1C
mp-wp/wp-admin/options-writing.php
(78 . 38)(78 . 6)
43 <?php do_settings_fields('writing', 'remote_publishing'); ?>
44 </table>
45
46 <h3><?php _e('Post via e-mail') ?></h3>
47 <p><?php printf(__('To post to WordPress by e-mail you must set up a secret e-mail account with POP3 access. Any mail received at this address will be posted, so it’s a good idea to keep this address very secret. Here are three random strings you could use: <kbd>%s</kbd>, <kbd>%s</kbd>, <kbd>%s</kbd>.'), wp_generate_password(8, false), wp_generate_password(8, false), wp_generate_password(8, false)) ?></p>
48
49 <table class="form-table">
50 <tr valign="top">
51 <th scope="row"><label for="mailserver_url"><?php _e('Mail Server') ?></label></th>
52 <td><input name="mailserver_url" type="text" id="mailserver_url" value="<?php form_option('mailserver_url'); ?>" class="regular-text" />
53 <label for="mailserver_port"><?php _e('Port') ?></label>
54 <input name="mailserver_port" type="text" id="mailserver_port" value="<?php form_option('mailserver_port'); ?>" class="small-text" />
55 </td>
56 </tr>
57 <tr valign="top">
58 <th scope="row"><label for="mailserver_login"><?php _e('Login Name') ?></label></th>
59 <td><input name="mailserver_login" type="text" id="mailserver_login" value="<?php form_option('mailserver_login'); ?>" class="regular-text" /></td>
60 </tr>
61 <tr valign="top">
62 <th scope="row"><label for="mailserver_pass"><?php _e('Password') ?></label></th>
63 <td>
64 <input name="mailserver_pass" type="text" id="mailserver_pass" value="<?php form_option('mailserver_pass'); ?>" class="regular-text" />
65 </td>
66 </tr>
67 <tr valign="top">
68 <th scope="row"><label for="default_email_category"><?php _e('Default Mail Category') ?></label></th>
69 <td>
70 <?php
71 wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_email_category', 'orderby' => 'name', 'selected' => get_option('default_email_category'), 'hierarchical' => true));
72 ?>
73 </td>
74 </tr>
75 <?php do_settings_fields('writing', 'post_via_email'); ?>
76 </table>
77
78 <h3><?php _e('Update Services') ?></h3>
79
80 <?php if ( get_option('blog_public') ) : ?>
- 9425D2C2B68595447C693283E81F2F10C33327073EE84A76CD8E387981745E088B160442EE6654C82E0BCFCD45D8680A90C665F8CCA466EE7A7751226EBA3E7B
+
mp-wp/wp-comments-post.php.orig
(1 . 115)(0 . 0)
85 <?php^M
86 /**^M
87 * Handles Comment Post to WordPress and prevents duplicate comment posting.^M
88 *^M
89 * @package WordPress^M
90 */^M
91 ^M
92 if ( 'POST' != $_SERVER['REQUEST_METHOD'] ) {^M
93 header('Allow: POST');^M
94 header('HTTP/1.1 405 Method Not Allowed');^M
95 header('Content-Type: text/plain');^M
96 exit;^M
97 }^M
98 ^M
99 /** Sets up the WordPress Environment. */^M
100 require( dirname(__FILE__) . '/wp-load.php' );^M
101 ^M
102 nocache_headers();^M
103 ^M
104 $comment_post_ID = (int) $_POST['comment_post_ID'];^M
105 ^M
106 $status = $wpdb->get_row( $wpdb->prepare("SELECT post_status, comment_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) );^M
107 ^M
108 if ( empty($status->comment_status) ) {^M
109 do_action('comment_id_not_found', $comment_post_ID);^M
110 exit;^M
111 } elseif ( !comments_open($comment_post_ID) ) {^M
112 do_action('comment_closed', $comment_post_ID);^M
113 wp_die( __('Sorry, comments are closed for this item.') );^M
114 } elseif ( in_array($status->post_status, array('draft', 'pending') ) ) {^M
115 do_action('comment_on_draft', $comment_post_ID);^M
116 exit;^M
117 }^M
118 // These get changed for avoiding spammers.^M
119 ^M
120 $suffix = substr(md5(date('Y-m-d').$_SERVER['REMOTE_ADDR']).$_SERVER['HTTP_USER_AGENT'],6,7);^M
121 ^M
122 $comment_author = ( isset($_POST['author'.$suffix]) ) ? trim(strip_tags($_POST['author'.$suffix])) : null;^M
123 $comment_author_email = ( isset($_POST['email'.$suffix]) ) ? trim($_POST['email'.$suffix]) : null;^M
124 $comment_author_url = ( isset($_POST['url'.$suffix]) ) ? trim($_POST['url'.$suffix]) : null;^M
125 $comment_content = ( isset($_POST['comment']) ) ? trim(strip_tags($_POST['comment'],"<a><em><strong><i><b><blockquote><ul><ol><li>")) : null;^M
126 $comment_checks = ( isset($_POST['comment_post_time']) ) ? trim($_POST['comment_post_time']) : null;^M
127 $comment_check = explode ("-",$comment_checks);^M
128 $comment_time = $comment_check[0];^M
129 $comment_IP = $comment_check[1];^M
130 ^M
131 // Special handle for idiots.^M
132 /*^M
133 if (($comment_author_email == "icriss78@yahoo.com")||($comment_author_url == "http://blog.matinal.org")) {^M
134 $comment_author_url = "";^M
135 $comment_content.= "\n\n<em>Eu sunt <a href=http://polimedia.us/trilema/2011/trolul-perfect/>o simpla fictiune</a>. Luati ce-am scris mai sus ca atare.</em>";^M
136 }^M
137 */^M
138 ^M
139 // GPG catchall.^M
140 ^M
141 if (strpos($comment_content,"BEGIN PGP")>0) $comment_content = "<code>".$comment_content."</code>";^M
142 ^M
143 // Don't make it much more than 3 or it'll pester users.^M
144 ^M
145 if (((time() - $comment_time) < 3)||(time() - $comment_time > 5000)||($comment_IP <> $_SERVER['REMOTE_ADDR'])) wp_die( __('Looks like you tried to comment off a stale page. Reload the article, count to three and try again.') );^M
146 ^M
147 $myrows = $wpdb->get_var('SELECT comment_ID FROM tril_comments WHERE comment_author_IP = "'.$_SERVER["REMOTE_ADDR"].'" and comment_approved = "spam";');^M
148 if ($myrows > 0) wp_die( __('Spammers need not apply.') );^M
149 ^M
150 // If the user is logged in^M
151 $user = wp_get_current_user();^M
152 if ( $user->ID ) {^M
153 if ( empty( $user->display_name ) )^M
154 $user->display_name=$user->user_login;^M
155 $comment_author = $wpdb->escape($user->display_name);^M
156 $comment_author_email = $wpdb->escape($user->user_email);^M
157 $comment_author_url = $wpdb->escape($user->user_url);^M
158 if ( current_user_can('unfiltered_html') ) {^M
159 if ( wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment'] ) {^M
160 kses_remove_filters(); // start with a clean slate^M
161 kses_init_filters(); // set up the filters^M
162 }^M
163 }^M
164 } else {^M
165 if ( get_option('comment_registration') )^M
166 wp_die( __('Sorry, you must be logged in to post a comment.') );^M
167 }^M
168 ^M
169 $comment_type = '';^M
170 ^M
171 if ( get_option('require_name_email') && !$user->ID ) {^M
172 if ( 6 > strlen($comment_author_email) || '' == $comment_author )^M
173 wp_die( __('Error: please fill the required fields (name, email).') );^M
174 elseif ( !is_email($comment_author_email))^M
175 wp_die( __('Error: please enter a valid email address.') );^M
176 }^M
177 ^M
178 if ( '' == $comment_content )^M
179 wp_die( __('Error: please type a comment.') );^M
180 ^M
181 $comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0;^M
182 ^M
183 $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');^M
184 ^M
185 $comment_id = wp_new_comment( $commentdata );^M
186 ^M
187 $comment = get_comment($comment_id);^M
188 if ( !$user->ID ) {^M
189 setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);^M
190 setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);^M
191 setcookie('comment_author_url_' . COOKIEHASH, clean_url($comment->comment_author_url), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);^M
192 }^M
193 ^M
194 $location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POST['redirect_to'] . '#comment-' . $comment_id;^M
195 $location = apply_filters('comment_post_redirect', $location, $comment);^M
196 ^M
197 wp_redirect($location);^M
198 ^M
199 ?>^M
- ACDC1E30A585923E1B0879E650E51185DF6FAAF999E79BA34C37CF360181ED4A5D67E2D53E4A510C3F4958F776284B865B302130451C548A067DC5EFCA8FD575
+ 44F4703ACD8B81F7DDB3181A7E4FE2797A4AA0C2B90FCB615297FBD2E60F6CB79BEA1155E56616E2503144862066CE022A16D781D18FA12850441978BB8D2BDE
mp-wp/wp-content/themes/default/footer.php
(22 . 6)(22 . 5)
204 <?php /* "Just what do you think you're doing Dave?" */ ?>
205
206 <?php wp_footer(); ?>
207 <?php include "selection-magic.php"; ?>
208 </body>
209 </html>
- 662FA8DE62B303463EC65E384051B4EEB2D8BA2328859979B800C2D1F0B885F6B1BEDBEE756355FD13E68CE0F5E491F229BB2184F0FED9CB92F328F5A5661631
+ C3CC58384F388F422E147292EB19777D7703A2CE273ADA639C46863566CC75E63975C4B261F19069B4C0F6F95336F90E26E2CE1CDB448444C85D04817DD9ED79
mp-wp/wp-content/themes/default/page.php
(9 . 7)(9 . 6)
214 <div id="content" class="narrowcolumn">
215
216 <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
217 <span id="shash-<?php the_ID(); ?>">
218 <div class="post" id="post-<?php the_ID(); ?>">
219 <h2><?php the_title(); ?></h2>
220 <div class="entry">
(18 . 11)(17 . 10)
222
223 </div>
224 </div>
225 </span>
226 <?php endwhile; endif; ?>
227 <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
228 </div>
229
230 <?php get_sidebar(); ?>
231
232 <?php get_footer(); ?>
- 01E83A62726BEF4232415B4841942427F31063AC2DDFBAB0048D5F5B63DA00EC2ECCACF3FC30CC71997E304969960F5774037E1245E1F0C4E9853D7D3B6450E7
+
mp-wp/wp-content/themes/default/selection-magic.php
(1 . 135)(0 . 0)
239 <script type="text/javascript">
240 // Script to allow anchoring of user-selected content on html pages.
241 // Original idea deployed by http://archive.today
242 // Packaged for WordPress on http://trilema.com/2015/that-spiffy-selection-thing/
243
244 function findPos(obj) {
245 var curtop = 0;
246 while (obj && obj.offsetParent) {
247 curtop += obj.offsetTop; // todo: + webkit-transform
248 obj = obj.offsetParent;
249 }
250 return curtop;
251 }
252 var artificial = null;
253 var prevhash = "";
254 function scrollToHash() {
255 if (document.location.hash.replace(/^#/, "")==prevhash.replace(/^#/, ""))
256 return;
257 prevhash = document.location.hash;
258 if (document.location.hash.match(/#[0-9.]+%/)) {
259 var p = parseFloat(document.location.hash.substring(1));
260 if (0 < p && p < 100 /*&& p%5 != 0*/) {
261 var content = document.getElementById("shash-<?php the_ID(); ?>")
262 var y = findPos(content) + (content.offsetHeight)*p/100;
263 window.scrollTo(0, y-16);
264 }
265 }
266
267 var adr = document.location.hash.match(/selection-(\d+).(\d+)-(\d+).(\d+)/);
268 if (adr) {
269 var pos=0,begin=null,end=null;
270 function recur(e) {
271 if (e.nodeType==1) pos = (pos&~1)+2;
272 if (e.nodeType==3) pos = pos|1;
273 if (pos==adr[1]) begin=[e, adr[2]];
274 if (pos==adr[3]) end =[e, adr[4]];
275 for (var i=0; i<e.childNodes.length; i++)
276 recur(e.childNodes[i]);
277 if (e.childNodes.length>0 && e.lastChild.nodeType==3)
278 pos = (pos&~1)+2;
279 }
280 // remove old "artificial" span if any
281 if (artificial) {
282 artificial.previousSibling.data += artificial.childNodes[0].data;
283 artificial.parentNode.removeChild(artificial);
284 }
285 var content = document.getElementById("shash-<?php the_ID(); ?>");
286 recur(content.childNodes[content.childNodes[0].nodeType==3 ? 1 : 0]);
287 if (begin!=null && end!=null) {
288 // scroll to selection
289 if (begin[0].nodeType==3) {
290 var text = document.createTextNode(begin[0].data.substr(0, begin[1]));
291 artificial = document.createElement("SPAN");
292 artificial.appendChild(document.createTextNode(begin[0].data.substr(begin[1])));
293
294 begin[0].parentNode.insertBefore(text, begin[0]);
295 begin[0].parentNode.replaceChild(artificial, begin[0]);
296
297 if (end[0]===begin[0])
298 end = [artificial.childNodes[0], end[1]-begin[1]];
299 begin = [artificial.childNodes[0], 0];
300 /* window.scrollTo(0, findPos(artificial)-8); */ artificial.scrollIntoView(true);
301 } else if (begin[0].nodeType==1) {
302 /* window.scrollTo(0, findPos(begin[0])-8); */ begin[0].scrollIntoView(true);
303 }
304
305 if (window.getSelection) {
306 var sel = window.getSelection();
307 sel.removeAllRanges();
308 var range = document.createRange();
309 range.setStart(begin[0], begin[1]);
310 range.setEnd ( end[0], end[1]);
311 sel.addRange(range);
312 } else if (document.selection) { // IE
313 }
314 }
315 }
316 }
317 window.onhashchange = scrollToHash;
318 var initScrollToHashDone = false;
319 function initScrollToHash() {
320 if (!initScrollToHashDone) {
321 initScrollToHashDone = true;
322 scrollToHash();
323 }
324 }
325 window.onload = initScrollToHash;
326 setTimeout(initScrollToHash, 500); /* onload can be delayed by counter code */
327
328 //document.onselectionchange = /* only webkit has working document.onselectionchange */
329 document.onmousedown = document.onmouseup = function(e) {
330 var newhash = "";
331 if (window.getSelection) {
332 var sel=window.getSelection();
333 if (!sel.isCollapsed) {
334 var pos=0,begin=[0,0],end=[0,0];
335 var range=sel.getRangeAt(0);
336 function recur(e) {
337 if (e===artificial) {
338 if (range.startContainer===e.childNodes[0]) begin=[pos, e.previousSibling.data.length+range.startOffset];
339 if (range.endContainer ===e.childNodes[0]) end =[pos, e.previousSibling.data.length+range.endOffset ];
340 } else {
341 if (e.nodeType==1) pos = (pos&~1)+2;
342 if (e.nodeType==3) pos = pos|1;
343 if (range.startContainer===e) begin=[pos, range.startOffset];
344 if (range.endContainer ===e) end =[pos, range.endOffset ];
345 for (var i=0; i<e.childNodes.length; i++)
346 recur(e.childNodes[i]);
347 if (e.childNodes.length>0 && e.lastChild.nodeType==3)
348 pos = (pos&~1)+2;
349 }
350 }
351
352 var content = document.getElementById("shash-<?php the_ID(); ?>");
353 recur(content.childNodes[content.childNodes[0].nodeType==3 ? 1 : 0]);
354 if (begin[0]>0 && end[0]>0) {
355 newhash = "selection-"+begin[0]+"."+begin[1]+"-"+end[0]+"."+end[1];
356 }
357 }
358 } else if (document.selection) { // IE
359 }
360
361 try {
362 var oldhash = location.hash.replace(/^#/, "");
363 if (oldhash != newhash) {
364 prevhash = newhash; /* avoid firing window.onhashchange and scrolling */
365 if (history.replaceState)
366 history.replaceState('', document.title, newhash=="" ? window.location.pathname : '#'+newhash);
367 else
368 location.hash = newhash;
369 }
370 } catch(e) {
371 }
372 };
373 </script>
- 20F607B36BC9E82F8481AEDCCC77FD7029C86340E5F617020F5D6F5ECA1C57580FCD749907338F40395EB2EB2160FE3534A0FA6466ACAEEACB0123BB96CC5E62
+ 1AB328DAB276D34DB579E48ACE1C583439AE63D9FF6255BA057EB7F3CF4B303584998B8ED214A1EDB5BCA542D59E376D12B346B8E7B4A435B7A3E3F2B178F93D
mp-wp/wp-content/themes/default/single.php
(16 . 8)(16 . 7)
378 <div class="alignright"><?php next_post_link('%link »') ?></div>
379 </div>
380
381 <span id="shash-<?php the_ID(); ?>">
382 <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
383 <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
384 <h2><?php the_title(); ?></h2>
385
386 <div class="entry">
(59 . 8)(58 . 7)
388 </p>
389
390 </div>
391 </div>
392 </span>
393 </div>
394
395 <?php comments_template(); ?>
396
- 745206F90604F46CC369EB2FD4DA8C31803B3C7A0FA13F75C24111F7F3ADDA434DCB05FE7C9176E539498789D4358967B650C7F44D1C03BC781422D765DC59BB
+
mp-wp/wp-includes/class-pop3.php
(1 . 651)(0 . 0)
401 <?php
402 /**
403 * mail_fetch/setup.php
404 *
405 * @package SquirrelMail
406 *
407 * @copyright (c) 1999-2006 The SquirrelMail Project Team
408 *
409 * @copyright (c) 1999 CDI (cdi@thewebmasters.net) All Rights Reserved
410 * Modified by Philippe Mingo 2001 mingo@rotedic.com
411 * An RFC 1939 compliant wrapper class for the POP3 protocol.
412 *
413 * Licensed under the GNU GPL. For full terms see the file COPYING.
414 *
415 * pop3 class
416 *
417 * $Id: class-pop3.php 9503 2008-11-03 23:25:11Z ryan $
418 */
419
420 class POP3 {
421 var $ERROR = ''; // Error string.
422
423 var $TIMEOUT = 60; // Default timeout before giving up on a
424 // network operation.
425
426 var $COUNT = -1; // Mailbox msg count
427
428 var $BUFFER = 512; // Socket buffer for socket fgets() calls.
429 // Per RFC 1939 the returned line a POP3
430 // server can send is 512 bytes.
431
432 var $FP = ''; // The connection to the server's
433 // file descriptor
434
435 var $MAILSERVER = ''; // Set this to hard code the server name
436
437 var $DEBUG = FALSE; // set to true to echo pop3
438 // commands and responses to error_log
439 // this WILL log passwords!
440
441 var $BANNER = ''; // Holds the banner returned by the
442 // pop server - used for apop()
443
444 var $ALLOWAPOP = FALSE; // Allow or disallow apop()
445 // This must be set to true
446 // manually
447
448 function POP3 ( $server = '', $timeout = '' ) {
449 settype($this->BUFFER,"integer");
450 if( !empty($server) ) {
451 // Do not allow programs to alter MAILSERVER
452 // if it is already specified. They can get around
453 // this if they -really- want to, so don't count on it.
454 if(empty($this->MAILSERVER))
455 $this->MAILSERVER = $server;
456 }
457 if(!empty($timeout)) {
458 settype($timeout,"integer");
459 $this->TIMEOUT = $timeout;
460 if (!ini_get('safe_mode'))
461 set_time_limit($timeout);
462 }
463 return true;
464 }
465
466 function update_timer () {
467 if (!ini_get('safe_mode'))
468 set_time_limit($this->TIMEOUT);
469 return true;
470 }
471
472 function connect ($server, $port = 110) {
473 // Opens a socket to the specified server. Unless overridden,
474 // port defaults to 110. Returns true on success, false on fail
475
476 // If MAILSERVER is set, override $server with it's value
477
478 if (!isset($port) || !$port) {$port = 110;}
479 if(!empty($this->MAILSERVER))
480 $server = $this->MAILSERVER;
481
482 if(empty($server)){
483 $this->ERROR = "POP3 connect: " . _("No server specified");
484 unset($this->FP);
485 return false;
486 }
487
488 $fp = @fsockopen("$server", $port, $errno, $errstr);
489
490 if(!$fp) {
491 $this->ERROR = "POP3 connect: " . _("Error ") . "[$errno] [$errstr]";
492 unset($this->FP);
493 return false;
494 }
495
496 socket_set_blocking($fp,-1);
497 $this->update_timer();
498 $reply = fgets($fp,$this->BUFFER);
499 $reply = $this->strip_clf($reply);
500 if($this->DEBUG)
501 error_log("POP3 SEND [connect: $server] GOT [$reply]",0);
502 if(!$this->is_ok($reply)) {
503 $this->ERROR = "POP3 connect: " . _("Error ") . "[$reply]";
504 unset($this->FP);
505 return false;
506 }
507 $this->FP = $fp;
508 $this->BANNER = $this->parse_banner($reply);
509 return true;
510 }
511
512 function user ($user = "") {
513 // Sends the USER command, returns true or false
514
515 if( empty($user) ) {
516 $this->ERROR = "POP3 user: " . _("no login ID submitted");
517 return false;
518 } elseif(!isset($this->FP)) {
519 $this->ERROR = "POP3 user: " . _("connection not established");
520 return false;
521 } else {
522 $reply = $this->send_cmd("USER $user");
523 if(!$this->is_ok($reply)) {
524 $this->ERROR = "POP3 user: " . _("Error ") . "[$reply]";
525 return false;
526 } else
527 return true;
528 }
529 }
530
531 function pass ($pass = "") {
532 // Sends the PASS command, returns # of msgs in mailbox,
533 // returns false (undef) on Auth failure
534
535 if(empty($pass)) {
536 $this->ERROR = "POP3 pass: " . _("No password submitted");
537 return false;
538 } elseif(!isset($this->FP)) {
539 $this->ERROR = "POP3 pass: " . _("connection not established");
540 return false;
541 } else {
542 $reply = $this->send_cmd("PASS $pass");
543 if(!$this->is_ok($reply)) {
544 $this->ERROR = "POP3 pass: " . _("Authentication failed") . " [$reply]";
545 $this->quit();
546 return false;
547 } else {
548 // Auth successful.
549 $count = $this->last("count");
550 $this->COUNT = $count;
551 return $count;
552 }
553 }
554 }
555
556 function apop ($login,$pass) {
557 // Attempts an APOP login. If this fails, it'll
558 // try a standard login. YOUR SERVER MUST SUPPORT
559 // THE USE OF THE APOP COMMAND!
560 // (apop is optional per rfc1939)
561
562 if(!isset($this->FP)) {
563 $this->ERROR = "POP3 apop: " . _("No connection to server");
564 return false;
565 } elseif(!$this->ALLOWAPOP) {
566 $retVal = $this->login($login,$pass);
567 return $retVal;
568 } elseif(empty($login)) {
569 $this->ERROR = "POP3 apop: " . _("No login ID submitted");
570 return false;
571 } elseif(empty($pass)) {
572 $this->ERROR = "POP3 apop: " . _("No password submitted");
573 return false;
574 } else {
575 $banner = $this->BANNER;
576 if( (!$banner) or (empty($banner)) ) {
577 $this->ERROR = "POP3 apop: " . _("No server banner") . ' - ' . _("abort");
578 $retVal = $this->login($login,$pass);
579 return $retVal;
580 } else {
581 $AuthString = $banner;
582 $AuthString .= $pass;
583 $APOPString = md5($AuthString);
584 $cmd = "APOP $login $APOPString";
585 $reply = $this->send_cmd($cmd);
586 if(!$this->is_ok($reply)) {
587 $this->ERROR = "POP3 apop: " . _("apop authentication failed") . ' - ' . _("abort");
588 $retVal = $this->login($login,$pass);
589 return $retVal;
590 } else {
591 // Auth successful.
592 $count = $this->last("count");
593 $this->COUNT = $count;
594 return $count;
595 }
596 }
597 }
598 }
599
600 function login ($login = "", $pass = "") {
601 // Sends both user and pass. Returns # of msgs in mailbox or
602 // false on failure (or -1, if the error occurs while getting
603 // the number of messages.)
604
605 if( !isset($this->FP) ) {
606 $this->ERROR = "POP3 login: " . _("No connection to server");
607 return false;
608 } else {
609 $fp = $this->FP;
610 if( !$this->user( $login ) ) {
611 // Preserve the error generated by user()
612 return false;
613 } else {
614 $count = $this->pass($pass);
615 if( (!$count) || ($count == -1) ) {
616 // Preserve the error generated by last() and pass()
617 return false;
618 } else
619 return $count;
620 }
621 }
622 }
623
624 function top ($msgNum, $numLines = "0") {
625 // Gets the header and first $numLines of the msg body
626 // returns data in an array with each returned line being
627 // an array element. If $numLines is empty, returns
628 // only the header information, and none of the body.
629
630 if(!isset($this->FP)) {
631 $this->ERROR = "POP3 top: " . _("No connection to server");
632 return false;
633 }
634 $this->update_timer();
635
636 $fp = $this->FP;
637 $buffer = $this->BUFFER;
638 $cmd = "TOP $msgNum $numLines";
639 fwrite($fp, "TOP $msgNum $numLines\r\n");
640 $reply = fgets($fp, $buffer);
641 $reply = $this->strip_clf($reply);
642 if($this->DEBUG) {
643 @error_log("POP3 SEND [$cmd] GOT [$reply]",0);
644 }
645 if(!$this->is_ok($reply))
646 {
647 $this->ERROR = "POP3 top: " . _("Error ") . "[$reply]";
648 return false;
649 }
650
651 $count = 0;
652 $MsgArray = array();
653
654 $line = fgets($fp,$buffer);
655 while ( !ereg("^\.\r\n",$line))
656 {
657 $MsgArray[$count] = $line;
658 $count++;
659 $line = fgets($fp,$buffer);
660 if(empty($line)) { break; }
661 }
662
663 return $MsgArray;
664 }
665
666 function pop_list ($msgNum = "") {
667 // If called with an argument, returns that msgs' size in octets
668 // No argument returns an associative array of undeleted
669 // msg numbers and their sizes in octets
670
671 if(!isset($this->FP))
672 {
673 $this->ERROR = "POP3 pop_list: " . _("No connection to server");
674 return false;
675 }
676 $fp = $this->FP;
677 $Total = $this->COUNT;
678 if( (!$Total) or ($Total == -1) )
679 {
680 return false;
681 }
682 if($Total == 0)
683 {
684 return array("0","0");
685 // return -1; // mailbox empty
686 }
687
688 $this->update_timer();
689
690 if(!empty($msgNum))
691 {
692 $cmd = "LIST $msgNum";
693 fwrite($fp,"$cmd\r\n");
694 $reply = fgets($fp,$this->BUFFER);
695 $reply = $this->strip_clf($reply);
696 if($this->DEBUG) {
697 @error_log("POP3 SEND [$cmd] GOT [$reply]",0);
698 }
699 if(!$this->is_ok($reply))
700 {
701 $this->ERROR = "POP3 pop_list: " . _("Error ") . "[$reply]";
702 return false;
703 }
704 list($junk,$num,$size) = preg_split('/\s+/',$reply);
705 return $size;
706 }
707 $cmd = "LIST";
708 $reply = $this->send_cmd($cmd);
709 if(!$this->is_ok($reply))
710 {
711 $reply = $this->strip_clf($reply);
712 $this->ERROR = "POP3 pop_list: " . _("Error ") . "[$reply]";
713 return false;
714 }
715 $MsgArray = array();
716 $MsgArray[0] = $Total;
717 for($msgC=1;$msgC <= $Total; $msgC++)
718 {
719 if($msgC > $Total) { break; }
720 $line = fgets($fp,$this->BUFFER);
721 $line = $this->strip_clf($line);
722 if(ereg("^\.",$line))
723 {
724 $this->ERROR = "POP3 pop_list: " . _("Premature end of list");
725 return false;
726 }
727 list($thisMsg,$msgSize) = preg_split('/\s+/',$line);
728 settype($thisMsg,"integer");
729 if($thisMsg != $msgC)
730 {
731 $MsgArray[$msgC] = "deleted";
732 }
733 else
734 {
735 $MsgArray[$msgC] = $msgSize;
736 }
737 }
738 return $MsgArray;
739 }
740
741 function get ($msgNum) {
742 // Retrieve the specified msg number. Returns an array
743 // where each line of the msg is an array element.
744
745 if(!isset($this->FP))
746 {
747 $this->ERROR = "POP3 get: " . _("No connection to server");
748 return false;
749 }
750
751 $this->update_timer();
752
753 $fp = $this->FP;
754 $buffer = $this->BUFFER;
755 $cmd = "RETR $msgNum";
756 $reply = $this->send_cmd($cmd);
757
758 if(!$this->is_ok($reply))
759 {
760 $this->ERROR = "POP3 get: " . _("Error ") . "[$reply]";
761 return false;
762 }
763
764 $count = 0;
765 $MsgArray = array();
766
767 $line = fgets($fp,$buffer);
768 while ( !ereg("^\.\r\n",$line))
769 {
770 if ( $line{0} == '.' ) { $line = substr($line,1); }
771 $MsgArray[$count] = $line;
772 $count++;
773 $line = fgets($fp,$buffer);
774 if(empty($line)) { break; }
775 }
776 return $MsgArray;
777 }
778
779 function last ( $type = "count" ) {
780 // Returns the highest msg number in the mailbox.
781 // returns -1 on error, 0+ on success, if type != count
782 // results in a popstat() call (2 element array returned)
783
784 $last = -1;
785 if(!isset($this->FP))
786 {
787 $this->ERROR = "POP3 last: " . _("No connection to server");
788 return $last;
789 }
790
791 $reply = $this->send_cmd("STAT");
792 if(!$this->is_ok($reply))
793 {
794 $this->ERROR = "POP3 last: " . _("Error ") . "[$reply]";
795 return $last;
796 }
797
798 $Vars = preg_split('/\s+/',$reply);
799 $count = $Vars[1];
800 $size = $Vars[2];
801 settype($count,"integer");
802 settype($size,"integer");
803 if($type != "count")
804 {
805 return array($count,$size);
806 }
807 return $count;
808 }
809
810 function reset () {
811 // Resets the status of the remote server. This includes
812 // resetting the status of ALL msgs to not be deleted.
813 // This method automatically closes the connection to the server.
814
815 if(!isset($this->FP))
816 {
817 $this->ERROR = "POP3 reset: " . _("No connection to server");
818 return false;
819 }
820 $reply = $this->send_cmd("RSET");
821 if(!$this->is_ok($reply))
822 {
823 // The POP3 RSET command -never- gives a -ERR
824 // response - if it ever does, something truely
825 // wild is going on.
826
827 $this->ERROR = "POP3 reset: " . _("Error ") . "[$reply]";
828 @error_log("POP3 reset: ERROR [$reply]",0);
829 }
830 $this->quit();
831 return true;
832 }
833
834 function send_cmd ( $cmd = "" )
835 {
836 // Sends a user defined command string to the
837 // POP server and returns the results. Useful for
838 // non-compliant or custom POP servers.
839 // Do NOT includ the \r\n as part of your command
840 // string - it will be appended automatically.
841
842 // The return value is a standard fgets() call, which
843 // will read up to $this->BUFFER bytes of data, until it
844 // encounters a new line, or EOF, whichever happens first.
845
846 // This method works best if $cmd responds with only
847 // one line of data.
848
849 if(!isset($this->FP))
850 {
851 $this->ERROR = "POP3 send_cmd: " . _("No connection to server");
852 return false;
853 }
854
855 if(empty($cmd))
856 {
857 $this->ERROR = "POP3 send_cmd: " . _("Empty command string");
858 return "";
859 }
860
861 $fp = $this->FP;
862 $buffer = $this->BUFFER;
863 $this->update_timer();
864 fwrite($fp,"$cmd\r\n");
865 $reply = fgets($fp,$buffer);
866 $reply = $this->strip_clf($reply);
867 if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
868 return $reply;
869 }
870
871 function quit() {
872 // Closes the connection to the POP3 server, deleting
873 // any msgs marked as deleted.
874
875 if(!isset($this->FP))
876 {
877 $this->ERROR = "POP3 quit: " . _("connection does not exist");
878 return false;
879 }
880 $fp = $this->FP;
881 $cmd = "QUIT";
882 fwrite($fp,"$cmd\r\n");
883 $reply = fgets($fp,$this->BUFFER);
884 $reply = $this->strip_clf($reply);
885 if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
886 fclose($fp);
887 unset($this->FP);
888 return true;
889 }
890
891 function popstat () {
892 // Returns an array of 2 elements. The number of undeleted
893 // msgs in the mailbox, and the size of the mbox in octets.
894
895 $PopArray = $this->last("array");
896
897 if($PopArray == -1) { return false; }
898
899 if( (!$PopArray) or (empty($PopArray)) )
900 {
901 return false;
902 }
903 return $PopArray;
904 }
905
906 function uidl ($msgNum = "")
907 {
908 // Returns the UIDL of the msg specified. If called with
909 // no arguments, returns an associative array where each
910 // undeleted msg num is a key, and the msg's uidl is the element
911 // Array element 0 will contain the total number of msgs
912
913 if(!isset($this->FP)) {
914 $this->ERROR = "POP3 uidl: " . _("No connection to server");
915 return false;
916 }
917
918 $fp = $this->FP;
919 $buffer = $this->BUFFER;
920
921 if(!empty($msgNum)) {
922 $cmd = "UIDL $msgNum";
923 $reply = $this->send_cmd($cmd);
924 if(!$this->is_ok($reply))
925 {
926 $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]";
927 return false;
928 }
929 list ($ok,$num,$myUidl) = preg_split('/\s+/',$reply);
930 return $myUidl;
931 } else {
932 $this->update_timer();
933
934 $UIDLArray = array();
935 $Total = $this->COUNT;
936 $UIDLArray[0] = $Total;
937
938 if ($Total < 1)
939 {
940 return $UIDLArray;
941 }
942 $cmd = "UIDL";
943 fwrite($fp, "UIDL\r\n");
944 $reply = fgets($fp, $buffer);
945 $reply = $this->strip_clf($reply);
946 if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); }
947 if(!$this->is_ok($reply))
948 {
949 $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]";
950 return false;
951 }
952
953 $line = "";
954 $count = 1;
955 $line = fgets($fp,$buffer);
956 while ( !ereg("^\.\r\n",$line)) {
957 if(ereg("^\.\r\n",$line)) {
958 break;
959 }
960 list ($msg,$msgUidl) = preg_split('/\s+/',$line);
961 $msgUidl = $this->strip_clf($msgUidl);
962 if($count == $msg) {
963 $UIDLArray[$msg] = $msgUidl;
964 }
965 else
966 {
967 $UIDLArray[$count] = 'deleted';
968 }
969 $count++;
970 $line = fgets($fp,$buffer);
971 }
972 }
973 return $UIDLArray;
974 }
975
976 function delete ($msgNum = "") {
977 // Flags a specified msg as deleted. The msg will not
978 // be deleted until a quit() method is called.
979
980 if(!isset($this->FP))
981 {
982 $this->ERROR = "POP3 delete: " . _("No connection to server");
983 return false;
984 }
985 if(empty($msgNum))
986 {
987 $this->ERROR = "POP3 delete: " . _("No msg number submitted");
988 return false;
989 }
990 $reply = $this->send_cmd("DELE $msgNum");
991 if(!$this->is_ok($reply))
992 {
993 $this->ERROR = "POP3 delete: " . _("Command failed ") . "[$reply]";
994 return false;
995 }
996 return true;
997 }
998
999 // *********************************************************
1000
1001 // The following methods are internal to the class.
1002
1003 function is_ok ($cmd = "") {
1004 // Return true or false on +OK or -ERR
1005
1006 if( empty($cmd) )
1007 return false;
1008 else
1009 return( ereg ("^\+OK", $cmd ) );
1010 }
1011
1012 function strip_clf ($text = "") {
1013 // Strips \r\n from server responses
1014
1015 if(empty($text))
1016 return $text;
1017 else {
1018 $stripped = str_replace("\r",'',$text);
1019 $stripped = str_replace("\n",'',$stripped);
1020 return $stripped;
1021 }
1022 }
1023
1024 function parse_banner ( $server_text ) {
1025 $outside = true;
1026 $banner = "";
1027 $length = strlen($server_text);
1028 for($count =0; $count < $length; $count++)
1029 {
1030 $digit = substr($server_text,$count,1);
1031 if(!empty($digit)) {
1032 if( (!$outside) && ($digit != '<') && ($digit != '>') )
1033 {
1034 $banner .= $digit;
1035 }
1036 if ($digit == '<')
1037 {
1038 $outside = false;
1039 }
1040 if($digit == '>')
1041 {
1042 $outside = true;
1043 }
1044 }
1045 }
1046 $banner = $this->strip_clf($banner); // Just in case
1047 return "<$banner>";
1048 }
1049
1050 } // End class
1051 ?>
- 2915BB3A275F2961BC736FB095F7A5F6E289DE2EA82F2E3F89483D7D34802AEDCD971D4BAC56BFB3F324D6E68A3ADF48A50AC19A927117CD542577C54A75F557
+
mp-wp/wp-mail.php
(1 . 209)(0 . 0)
1056 <?php
1057 /**
1058 * Gets the email message from the user's mailbox to add as
1059 * a WordPress post. Mailbox connection information must be
1060 * configured under Settings > Writing
1061 *
1062 * @package WordPress
1063 */
1064
1065 /** Make sure that the WordPress bootstrap has run before continuing. */
1066 require(dirname(__FILE__) . '/wp-load.php');
1067
1068 /** Get the POP3 class with which to access the mailbox. */
1069 require_once( ABSPATH . WPINC . '/class-pop3.php' );
1070
1071 $time_difference = absint(get_option('gmt_offset')) * 3600;
1072
1073 $phone_delim = '::';
1074
1075 $pop3 = new POP3();
1076
1077 if ( ! $pop3->connect(get_option('mailserver_url'), get_option('mailserver_port') ) ||
1078 ! $pop3->user(get_option('mailserver_login')) ||
1079 ( ! $count = $pop3->pass(get_option('mailserver_pass')) ) ) {
1080 $pop3->quit();
1081 wp_die( ( 0 === $count ) ? __("There doesn't seem to be any new mail.") : wp_specialchars($pop3->ERROR) );
1082 }
1083
1084 for ( $i = 1; $i <= $count; $i++ ) {
1085
1086 $message = $pop3->get($i);
1087
1088 $bodysignal = false;
1089 $boundary = '';
1090 $charset = '';
1091 $content = '';
1092 $content_type = '';
1093 $content_transfer_encoding = '';
1094 $post_author = 1;
1095 $author_found = false;
1096 $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
1097 foreach ($message as $line) {
1098 // body signal
1099 if ( strlen($line) < 3 )
1100 $bodysignal = true;
1101 if ( $bodysignal ) {
1102 $content .= $line;
1103 } else {
1104 if ( preg_match('/Content-Type: /i', $line) ) {
1105 $content_type = trim($line);
1106 $content_type = substr($content_type, 14, strlen($content_type) - 14);
1107 $content_type = explode(';', $content_type);
1108 if ( ! empty( $content_type[1] ) ) {
1109 $charset = explode('=', $content_type[1]);
1110 $charset = ( ! empty( $charset[1] ) ) ? trim($charset[1]) : '';
1111 }
1112 $content_type = $content_type[0];
1113 }
1114 if ( preg_match('/Content-Transfer-Encoding: /i', $line) ) {
1115 $content_transfer_encoding = trim($line);
1116 $content_transfer_encoding = substr($content_transfer_encoding, 27, strlen($content_transfer_encoding) - 27);
1117 $content_transfer_encoding = explode(';', $content_transfer_encoding);
1118 $content_transfer_encoding = $content_transfer_encoding[0];
1119 }
1120 if ( ( $content_type == 'multipart/alternative' ) && ( false !== strpos($line, 'boundary="') ) && ( '' == $boundary ) ) {
1121 $boundary = trim($line);
1122 $boundary = explode('"', $boundary);
1123 $boundary = $boundary[1];
1124 }
1125 if (preg_match('/Subject: /i', $line)) {
1126 $subject = trim($line);
1127 $subject = substr($subject, 9, strlen($subject) - 9);
1128 // Captures any text in the subject before $phone_delim as the subject
1129 if ( function_exists('iconv_mime_decode') ) {
1130 $subject = iconv_mime_decode($subject, 2, get_option('blog_charset'));
1131 } else {
1132 $subject = wp_iso_descrambler($subject);
1133 }
1134 $subject = explode($phone_delim, $subject);
1135 $subject = $subject[0];
1136 }
1137
1138 // Set the author using the email address (From or Reply-To, the last used)
1139 // otherwise use the site admin
1140 if ( preg_match('/(From|Reply-To): /', $line) ) {
1141 if ( preg_match('|[a-z0-9_.-]+@[a-z0-9_.-]+(?!.*<)|i', $line, $matches) )
1142 $author = $matches[0];
1143 else
1144 $author = trim($line);
1145 $author = sanitize_email($author);
1146 if ( is_email($author) ) {
1147 echo '<p>' . sprintf(__('Author is %s'), $author) . '</p>';
1148 $userdata = get_user_by_email($author);
1149 if ( empty($userdata) ) {
1150 $author_found = false;
1151 } else {
1152 $post_author = $userdata->ID;
1153 $author_found = true;
1154 }
1155 } else {
1156 $author_found = false;
1157 }
1158 }
1159
1160 if (preg_match('/Date: /i', $line)) { // of the form '20 Mar 2002 20:32:37'
1161 $ddate = trim($line);
1162 $ddate = str_replace('Date: ', '', $ddate);
1163 if (strpos($ddate, ',')) {
1164 $ddate = trim(substr($ddate, strpos($ddate, ',') + 1, strlen($ddate)));
1165 }
1166 $date_arr = explode(' ', $ddate);
1167 $date_time = explode(':', $date_arr[3]);
1168
1169 $ddate_H = $date_time[0];
1170 $ddate_i = $date_time[1];
1171 $ddate_s = $date_time[2];
1172
1173 $ddate_m = $date_arr[1];
1174 $ddate_d = $date_arr[0];
1175 $ddate_Y = $date_arr[2];
1176 for ( $j = 0; $j < 12; $j++ ) {
1177 if ( $ddate_m == $dmonths[$j] ) {
1178 $ddate_m = $j+1;
1179 }
1180 }
1181
1182 $time_zn = intval($date_arr[4]) * 36;
1183 $ddate_U = gmmktime($ddate_H, $ddate_i, $ddate_s, $ddate_m, $ddate_d, $ddate_Y);
1184 $ddate_U = $ddate_U - $time_zn;
1185 $post_date = gmdate('Y-m-d H:i:s', $ddate_U + $time_difference);
1186 $post_date_gmt = gmdate('Y-m-d H:i:s', $ddate_U);
1187 }
1188 }
1189 }
1190
1191 // Set $post_status based on $author_found and on author's publish_posts capability
1192 if ( $author_found ) {
1193 $user = new WP_User($post_author);
1194 $post_status = ( $user->has_cap('publish_posts') ) ? 'publish' : 'pending';
1195 } else {
1196 // Author not found in DB, set status to pending. Author already set to admin.
1197 $post_status = 'pending';
1198 }
1199
1200 $subject = trim($subject);
1201
1202 if ( $content_type == 'multipart/alternative' ) {
1203 $content = explode('--'.$boundary, $content);
1204 $content = $content[2];
1205 // match case-insensitive content-transfer-encoding
1206 if ( preg_match( '/Content-Transfer-Encoding: quoted-printable/i', $content, $delim) ) {
1207 $content = explode($delim[0], $content);
1208 $content = $content[1];
1209 }
1210 $content = strip_tags($content, '<img><p><br><i><b><u><em><strong><strike><font><span><div>');
1211 }
1212 $content = trim($content);
1213
1214 if ( false !== stripos($content_transfer_encoding, "quoted-printable") ) {
1215 $content = quoted_printable_decode($content);
1216 }
1217
1218 if ( function_exists('iconv') && ! empty( $charset ) ) {
1219 $content = iconv($charset, get_option('blog_charset'), $content);
1220 }
1221
1222 // Captures any text in the body after $phone_delim as the body
1223 $content = explode($phone_delim, $content);
1224 $content = empty( $content[1] ) ? $content[0] : $content[1];
1225
1226 $content = trim($content);
1227
1228 $post_content = apply_filters('phone_content', $content);
1229
1230 $post_title = xmlrpc_getposttitle($content);
1231
1232 if ($post_title == '') $post_title = $subject;
1233
1234 $post_category = array(get_option('default_email_category'));
1235
1236 $post_data = compact('post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status');
1237 $post_data = add_magic_quotes($post_data);
1238
1239 $post_ID = wp_insert_post($post_data);
1240 if ( is_wp_error( $post_ID ) )
1241 echo "\n" . $post_ID->get_error_message();
1242
1243 // We couldn't post, for whatever reason. Better move forward to the next email.
1244 if ( empty( $post_ID ) )
1245 continue;
1246
1247 do_action('publish_phone', $post_ID);
1248
1249 echo "\n<p>" . sprintf(__('<strong>Author:</strong> %s'), wp_specialchars($post_author)) . '</p>';
1250 echo "\n<p>" . sprintf(__('<strong>Posted title:</strong> %s'), wp_specialchars($post_title)) . '</p>';
1251
1252 if(!$pop3->delete($i)) {
1253 echo '<p>' . sprintf(__('Oops: %s'), wp_specialchars($pop3->ERROR)) . '</p>';
1254 $pop3->reset();
1255 exit;
1256 } else {
1257 echo '<p>' . sprintf(__('Mission complete. Message <strong>%s</strong> deleted.'), $i) . '</p>';
1258 }
1259
1260 }
1261
1262 $pop3->quit();
1263
1264 ?>