FeedWordPress - Version 2011.1018

Version Description

  • HTTP BASIC AND DIGEST AUTHENTICATION SUPPORT: FeedWordPress now offers improved support for syndicating feeds that make use of HTTP Basic or HTTP Digest authentication methods. In order to set up authentication on one of your feeds, just go to its Settings > Feed page, and click on the "Uses Username/Password" link underneath the Feed URL. Enter the username and password for accessing the feed, then select the authentication method. (If you're not sure which method your feed provider uses, try Basic first.) Save Changes, and syndicate away.

    NOTE: HTTP Digest support requires the curl module for PHP. If you are not sure whether this module has been installed, contact your web hosting provider to check.

  • WP 3.3 (BETA) COMPATIBILITY: This version fixes an init-sequence bug that could cause intrusive warning messages or fatal errors in WP 3.3 beta versions.

  • BUGFIX: FIXES LONG DELAYS IN UPDATES SCHEDULES IN LARGE INSTALLATIONS. A performance feature introduced in version 2011.0721 had some flaws in its implementation, which tended to create serious delays (on the order of several hours) in FeedWordPress's attempts to schedule updates for feeds, when users had a very large number of feeds (several dozen or more) in their FeedWordPress installation. This feature has been reconfigured to adjust dynamically to the number of feeds in Syndicated Sources and the frequency with which they are updated. If you've seen a lot of ready-to-update feeds piling up, several hours after they were supposed to get updated, then this upgrade should better ensure that your feeds get updated in a timely fashion.

  • BUGFIX: syndicated_item_guid FILTERS FIXED. Previous versions of FeedWordPress theoretically allowed for filters on the syndicated_item_guid hook, which was intended to filter the globally-unique identifier element (rss:guid or atom:id) -- useful if you need to convince FeedWordPress to use different guids, or to recognize two or more incoming posts as versions of the same post rather than as distinct items. However, while the hook affected the guid stored in the WordPress database, it did not affect the guid used to check whether an incoming feed item had already been syndicated or was a new item -- which greatly limited the practical usefulness of the filter. This bug has been fixed: syndicated_item_guid filters should now properly control not only the final database record, but also the initial uniqueness test applied to posts.

Download this release

Release Info

Developer radgeek
Plugin Icon wp plugin FeedWordPress
Version 2011.1018
Comparing to
See all releases

Code changes from version 2011.0721 to 2011.1018

feeds-page.php CHANGED
@@ -193,11 +193,24 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
193
  <option value="no"<?php echo (!$automatic_updates)?' selected="selected"':''; ?>>cron job or manual updates</option>
194
  </select>
195
  <div id="cron-job-explanation" class="setting-description">
196
- <p>If you want to use a cron job,
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  you can perform scheduled updates by sending regularly-scheduled
198
- requests to <a href="<?php bloginfo('home'); ?>?update_feedwordpress=1"><code><?php bloginfo('url') ?>?update_feedwordpress=1</code></a>
199
  For example, inserting the following line in your crontab:</p>
200
- <pre style="font-size: 0.80em"><code>*/10 * * * * /usr/bin/curl --silent <?php bloginfo('url'); ?>?update_feedwordpress=1</code></pre>
201
  <p class="setting-description">will check in every 10 minutes
202
  and check for updates on any feeds that are ready to be polled for updates.</p>
203
  </div>
@@ -412,6 +425,32 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
412
  $hardcode['url'] = get_option('feedwordpress_hardcode_url');
413
  endif;
414
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
415
  // Hey ho, let's go
416
  ?>
417
  <table class="edit-form">
@@ -425,6 +464,26 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
425
  title="Check feed &lt;<?php echo esc_html($rss_url); ?>&gt; for validity">validate</a>)
426
  <input type="submit" name="feedfinder" value="switch &rarr;" style="font-size:smaller" />
427
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
428
  <table id="link-rss-params">
429
  <tbody>
430
  <?php
@@ -450,6 +509,35 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
450
  <div><input type="hidden" id="link-rss-params-num" name="link_rss_params_num" value="<?php print $i; ?>" /></div>
451
 
452
  <script type="text/javascript">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
453
  function linkParamsRowRemove (element) {
454
  jQuery(element).closest('tr').fadeOut('slow', function () {
455
  jQuery(this).remove();
@@ -459,7 +547,7 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
459
  jQuery('<td><a href="#" class="add-remove link-rss-params-remove"><span class="x">(X)</span> Remove</a></td>').insertAfter('.link-rss-params-value-cell');
460
 
461
  jQuery('#link-rss-params-new').hide();
462
- jQuery('<a class="add-remove" id="link-rss-params-add" href="#">+ Add a query parameter</a>').insertAfter('#link-rss-params');
463
  jQuery('#link-rss-params-add').click( function () {
464
  var next = jQuery('#link-rss-params-num').val();
465
  var newRow = jQuery('#link-rss-params-new').clone().attr('id', 'link-rss-params-'+next);
@@ -867,6 +955,7 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
867
 
868
  function save_settings ($post) {
869
  if ($this->for_feed_settings()) :
 
870
  if (isset($post['link_rss_params_key'])) :
871
  $qp = array();
872
  foreach ($post['link_rss_params_key'] as $index => $key) :
@@ -968,8 +1057,37 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
968
  if (isset($post['update_minimum'])) :
969
  $this->update_setting('update/minimum', $post['update_minimum']);
970
  endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
971
 
972
  $this->updatedPosts->accept_POST($post);
 
973
  parent::save_settings($post);
974
  } /* FeedWordPressFeedsPage::save_settings() */
975
 
193
  <option value="no"<?php echo (!$automatic_updates)?' selected="selected"':''; ?>>cron job or manual updates</option>
194
  </select>
195
  <div id="cron-job-explanation" class="setting-description">
196
+ <p><?php
197
+ $path = `which curl`; $opts = '--silent %s';
198
+ if (is_null($path) or strlen(trim($path))==0) :
199
+ $path = `which wget`; $opts = '-q -O - %s';
200
+ if (is_null($path) or strlen(trim($path))==0) :
201
+ $path = '/usr/bin/curl'; $opts = '--silent %s';
202
+ endif;
203
+ endif;
204
+ $path = preg_replace('/\n+$/', '', $path);
205
+ $crontab = `crontab -l`;
206
+
207
+ $cmdline = $path . ' ' . sprintf($opts, get_bloginfo('url').'?update_feedwordpress=1');
208
+
209
+ ?>If you want to use a cron job,
210
  you can perform scheduled updates by sending regularly-scheduled
211
+ requests to <a href="<?php bloginfo('url'); ?>?update_feedwordpress=1"><code><?php bloginfo('url') ?>?update_feedwordpress=1</code></a>
212
  For example, inserting the following line in your crontab:</p>
213
+ <pre style="font-size: 0.80em"><code>*/10 * * * * <?php print esc_html($cmdline); ?></code></pre>
214
  <p class="setting-description">will check in every 10 minutes
215
  and check for updates on any feeds that are ready to be polled for updates.</p>
216
  </div>
425
  $hardcode['url'] = get_option('feedwordpress_hardcode_url');
426
  endif;
427
 
428
+ $hideAuth = false;
429
+
430
+ $username = $this->setting('http username', NULL);
431
+
432
+ if (is_null($username)) :
433
+ $username = '';
434
+ $hideAuth = true;
435
+ endif;
436
+
437
+ $password = $this->setting('http password', NULL);
438
+ if (is_null($password)) :
439
+ $password = '';
440
+ endif;
441
+
442
+ $auth = $this->setting('http auth method', NULL);
443
+
444
+ $authMethods = apply_filters('feedwordpress_http_auth_methods', array(
445
+ 'basic' => 'Basic',
446
+ 'digest' => 'Digest',
447
+ '-' => 'None',
448
+ ));
449
+ if (is_null($auth)) :
450
+ $auth = '-';
451
+ $hideAuth = true;
452
+ endif;
453
+
454
  // Hey ho, let's go
455
  ?>
456
  <table class="edit-form">
464
  title="Check feed &lt;<?php echo esc_html($rss_url); ?>&gt; for validity">validate</a>)
465
  <input type="submit" name="feedfinder" value="switch &rarr;" style="font-size:smaller" />
466
 
467
+ <table id="link-rss-authentication">
468
+ <tbody>
469
+ <tr id="link-rss-authentication-credentials">
470
+ <td><label>user: <input type="text" name="link_rss_username"
471
+ value="<?php print esc_attr($username); ?>" size="16"
472
+ placeholder="username to access this feed" /></label></td>
473
+ <td><label>pass: <input type="text" name="link_rss_password"
474
+ value="<?php print esc_attr($password); ?>" size="16"
475
+ placeholder="password to access this feed" /></label></td>
476
+ <td id="link-rss-authentication-method"><label>method: <select id="link-rss-auth-method" name="link_rss_auth_method" size="1">
477
+ <?php foreach ($authMethods as $value => $label) : ?>
478
+ <option value="<?php print esc_attr($value); ?>"<?php
479
+ if ($value == $auth) : ?> selected="selected"<?php
480
+ endif; ?>><?php print esc_html($label); ?></option>
481
+ <?php endforeach; ?>
482
+ </select></label></td>
483
+ </tr>
484
+ </tbody>
485
+ </table>
486
+
487
  <table id="link-rss-params">
488
  <tbody>
489
  <?php
509
  <div><input type="hidden" id="link-rss-params-num" name="link_rss_params_num" value="<?php print $i; ?>" /></div>
510
 
511
  <script type="text/javascript">
512
+ function linkUserPassFlip (init) {
513
+ var speed = 'slow';
514
+ if (typeof(init)=='boolean' && init) {
515
+ speed = 0;
516
+ }
517
+
518
+ if (jQuery('#link-rss-auth-method').val()=='-') {
519
+ jQuery('<a style="display: none" class="add-remove" id="link-rss-userpass-use" href="#">+ Uses username/password</a>')
520
+ .insertAfter('#link-rss-authentication')
521
+ .click( function () {
522
+ jQuery('#link-rss-auth-method').val('basic');
523
+ linkUserPassFlip();
524
+ return false;
525
+ } )
526
+ .show(speed);
527
+ jQuery('#link-rss-authentication').hide(speed);
528
+ } else {
529
+ jQuery('#link-rss-userpass-use').hide(speed, function () { jQuery(this).remove(); } );
530
+ jQuery('#link-rss-authentication').show(speed);
531
+ }
532
+ }
533
+ jQuery('<td><a class="add-remove remove-it" id="link-rss-userpass-remove" href="#"><span class="x">(X)</span> Remove</a></td>')
534
+ .appendTo('#link-rss-authentication-credentials').click(function () {
535
+ jQuery('#link-rss-auth-method').val('-');
536
+ linkUserPassFlip();
537
+ } );
538
+ jQuery('#link-rss-auth-method').change( linkUserPassFlip );
539
+ linkUserPassFlip(/*init=*/ true);
540
+
541
  function linkParamsRowRemove (element) {
542
  jQuery(element).closest('tr').fadeOut('slow', function () {
543
  jQuery(this).remove();
547
  jQuery('<td><a href="#" class="add-remove link-rss-params-remove"><span class="x">(X)</span> Remove</a></td>').insertAfter('.link-rss-params-value-cell');
548
 
549
  jQuery('#link-rss-params-new').hide();
550
+ jQuery('<a class="add-remove" id="link-rss-params-add" href="#">+ Add a query parameter</a>').insertAfter('#link-rss-params');
551
  jQuery('#link-rss-params-add').click( function () {
552
  var next = jQuery('#link-rss-params-num').val();
553
  var newRow = jQuery('#link-rss-params-new').clone().attr('id', 'link-rss-params-'+next);
955
 
956
  function save_settings ($post) {
957
  if ($this->for_feed_settings()) :
958
+
959
  if (isset($post['link_rss_params_key'])) :
960
  $qp = array();
961
  foreach ($post['link_rss_params_key'] as $index => $key) :
1057
  if (isset($post['update_minimum'])) :
1058
  $this->update_setting('update/minimum', $post['update_minimum']);
1059
  endif;
1060
+
1061
+ if (
1062
+ isset($post['link_rss_auth_method'])
1063
+ and $post['link_rss_auth_method']
1064
+ and ('-' != $post['link_rss_auth_method'])
1065
+ ) :
1066
+ $this->update_setting('http auth method', $post['link_rss_auth_method']);
1067
+ else :
1068
+ $this->update_setting('http auth method', NULL);
1069
+ endif;
1070
+
1071
+ if (
1072
+ isset($post['link_rss_username'])
1073
+ and (strlen($post['link_rss_username']) > 0)
1074
+ ) :
1075
+ $this->update_setting('http username', $post['link_rss_username']);
1076
+ else :
1077
+ $this->update_setting('http username', NULL);
1078
+ endif;
1079
+
1080
+ if (
1081
+ isset($post['link_rss_password'])
1082
+ and (strlen($post['link_rss_password']) > 0)
1083
+ ) :
1084
+ $this->update_setting('http password', $post['link_rss_password']);
1085
+ else :
1086
+ $this->update_setting('http password', NULL);
1087
+ endif;
1088
 
1089
  $this->updatedPosts->accept_POST($post);
1090
+
1091
  parent::save_settings($post);
1092
  } /* FeedWordPressFeedsPage::save_settings() */
1093
 
feedwordpress-elements.css CHANGED
@@ -387,6 +387,20 @@ table.twofer td.secondary { padding-left: 10px; width: 30%; }
387
  vertical-align: middle;
388
  }
389
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
390
  #feedwordpress-admin-feeds .link-rss-params-row { vertical-align: middle; }
391
  #feedwordpress-admin-feeds .link-rss-params-remove, .feedwordpress-admin .remove-it {
392
  display: block;
387
  vertical-align: middle;
388
  }
389
 
390
+ #link-rss-userpass-use, #link-rss-authentication {
391
+ display: block;
392
+ font-size: 75%;
393
+ white-space: nowrap;
394
+ padding: 0.5em 0;
395
+ }
396
+ #link-rss-authentication label {
397
+ font-weight: bold;
398
+ padding-left: 1.5em;
399
+ }
400
+ #link-rss-authentication td {
401
+ width: 25%;
402
+ }
403
+
404
  #feedwordpress-admin-feeds .link-rss-params-row { vertical-align: middle; }
405
  #feedwordpress-admin-feeds .link-rss-params-remove, .feedwordpress-admin .remove-it {
406
  display: block;
feedwordpress.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: FeedWordPress
4
  Plugin URI: http://feedwordpress.radgeek.com/
5
  Description: simple and flexible Atom/RSS syndication for WordPress
6
- Version: 2011.0721
7
  Author: Charles Johnson
8
  Author URI: http://radgeek.com/
9
  License: GPL
@@ -11,7 +11,7 @@ License: GPL
11
 
12
  /**
13
  * @package FeedWordPress
14
- * @version 2011.0721
15
  */
16
 
17
  # This uses code derived from:
@@ -34,7 +34,7 @@ License: GPL
34
 
35
  # -- Don't change these unless you know what you're doing...
36
 
37
- define ('FEEDWORDPRESS_VERSION', '2011.0721');
38
  define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
39
 
40
  if (!defined('FEEDWORDPRESS_BLEG')) :
@@ -122,6 +122,7 @@ require_once("${dir}/syndicationdataqueries.class.php");
122
  require_once("${dir}/feedwordpress_file.class.php");
123
  require_once("${dir}/feedwordpress_parser.class.php");
124
  require_once("${dir}/feedwordpressrpc.class.php");
 
125
 
126
  // Magic quotes are just about the stupidest thing ever.
127
  if (is_array($_POST)) :
@@ -144,24 +145,6 @@ else : // Something went wrong. Let's just guess.
144
  $fwp_path = 'feedwordpress';
145
  endif;
146
 
147
- // If this is a FeedWordPress admin page, queue up scripts for AJAX functions that FWP uses
148
- // If it is a display page or a non-FeedWordPress admin page, don't.
149
- wp_register_style('feedwordpress-elements', WP_PLUGIN_URL.'/'.$fwp_path.'/feedwordpress-elements.css');
150
- if (FeedWordPressSettingsUI::is_admin()) :
151
- // For JavaScript that needs to be generated dynamically
152
- add_action('admin_print_scripts', array('FeedWordPressSettingsUI', 'admin_scripts'));
153
-
154
- // For CSS that needs to be generated dynamically.
155
- add_action('admin_print_styles', array('FeedWordPressSettingsUI', 'admin_styles'));
156
-
157
- wp_enqueue_style('dashboard');
158
- wp_enqueue_style('feedwordpress-elements');
159
-
160
- if (function_exists('wp_admin_css')) :
161
- wp_admin_css('css/dashboard');
162
- endif;
163
- endif;
164
-
165
  if (!FeedWordPress::needs_upgrade()) : // only work if the conditions are safe!
166
 
167
  # Syndicated items are generally received in output-ready (X)HTML and
@@ -915,6 +898,7 @@ class FeedWordPress {
915
 
916
  var $feeds = NULL;
917
 
 
918
  # function FeedWordPress (): Contructor; retrieve a list of feeds
919
  function FeedWordPress () {
920
  $this->feeds = array ();
@@ -922,6 +906,8 @@ class FeedWordPress {
922
  if ($links): foreach ($links as $link):
923
  $this->feeds[] = new SyndicatedLink($link);
924
  endforeach; endif;
 
 
925
  } // FeedWordPress::FeedWordPress ()
926
 
927
  # function update (): polls for updates on one or more Contributor feeds
@@ -998,13 +984,22 @@ class FeedWordPress {
998
  if (is_null($crash_ts)) :
999
  $crash_ts = $this->crash_ts();
1000
  endif;
1001
-
1002
- $max_polls = apply_filters('feedwordpress_polls_per_update', get_option('feedwordpress_polls_per_update', 10), $uri);
1003
 
1004
  // Randomize order for load balancing purposes
1005
  $feed_set = $this->feeds;
1006
  shuffle($feed_set);
1007
 
 
 
 
 
 
 
 
 
 
 
 
1008
  $feed_set = apply_filters('feedwordpress_update_feeds', $feed_set, $uri);
1009
 
1010
  // Loop through and check for new posts
@@ -1163,6 +1158,27 @@ class FeedWordPress {
1163
  } // FeedWordPress::stale()
1164
 
1165
  function init () {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1166
  $this->clear_cache_magic_url();
1167
  $this->update_magic_url();
1168
  } /* FeedWordPress::init() */
@@ -1574,7 +1590,7 @@ class FeedWordPress {
1574
  if (!is_array($params)) :
1575
  $force_feed = $params;
1576
  else : // Parameter array
1577
- $args = shortcode_atts(array(
1578
  'force_feed' => $force_feed,
1579
  'timeout' => $timeout
1580
  ), $params);
3
  Plugin Name: FeedWordPress
4
  Plugin URI: http://feedwordpress.radgeek.com/
5
  Description: simple and flexible Atom/RSS syndication for WordPress
6
+ Version: 2011.1018
7
  Author: Charles Johnson
8
  Author URI: http://radgeek.com/
9
  License: GPL
11
 
12
  /**
13
  * @package FeedWordPress
14
+ * @version 2011.1018
15
  */
16
 
17
  # This uses code derived from:
34
 
35
  # -- Don't change these unless you know what you're doing...
36
 
37
+ define ('FEEDWORDPRESS_VERSION', '2011.1018');
38
  define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
39
 
40
  if (!defined('FEEDWORDPRESS_BLEG')) :
122
  require_once("${dir}/feedwordpress_file.class.php");
123
  require_once("${dir}/feedwordpress_parser.class.php");
124
  require_once("${dir}/feedwordpressrpc.class.php");
125
+ require_once("${dir}/feedwordpresshttpauthenticator.class.php");
126
 
127
  // Magic quotes are just about the stupidest thing ever.
128
  if (is_array($_POST)) :
145
  $fwp_path = 'feedwordpress';
146
  endif;
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  if (!FeedWordPress::needs_upgrade()) : // only work if the conditions are safe!
149
 
150
  # Syndicated items are generally received in output-ready (X)HTML and
898
 
899
  var $feeds = NULL;
900
 
901
+ var $httpauth = NULL;
902
  # function FeedWordPress (): Contructor; retrieve a list of feeds
903
  function FeedWordPress () {
904
  $this->feeds = array ();
906
  if ($links): foreach ($links as $link):
907
  $this->feeds[] = new SyndicatedLink($link);
908
  endforeach; endif;
909
+
910
+ $this->httpauth = new FeedWordPressHTTPAuthenticator;
911
  } // FeedWordPress::FeedWordPress ()
912
 
913
  # function update (): polls for updates on one or more Contributor feeds
984
  if (is_null($crash_ts)) :
985
  $crash_ts = $this->crash_ts();
986
  endif;
 
 
987
 
988
  // Randomize order for load balancing purposes
989
  $feed_set = $this->feeds;
990
  shuffle($feed_set);
991
 
992
+ $updateWindow = (int) get_option('feedwordpress_update_window', DEFAULT_UPDATE_PERIOD) * 60 /* sec/min */;
993
+ $interval = (int) get_option('feedwordpress_freshness', FEEDWORDPRESS_FRESHNESS_INTERVAL);
994
+ $portion = max(
995
+ (int) ceil(count($feed_set) / ($updateWindow / $interval)),
996
+ 10
997
+ );
998
+
999
+ $max_polls = apply_filters('feedwordpress_polls_per_update', get_option(
1000
+ 'feedwordpress_polls_per_update', $portion
1001
+ ), $uri);
1002
+
1003
  $feed_set = apply_filters('feedwordpress_update_feeds', $feed_set, $uri);
1004
 
1005
  // Loop through and check for new posts
1158
  } // FeedWordPress::stale()
1159
 
1160
  function init () {
1161
+ global $fwp_path;
1162
+
1163
+ // If this is a FeedWordPress admin page, queue up scripts for AJAX
1164
+ // functions that FWP uses. If it is a display page or a non-FWP admin
1165
+ // page, don't.
1166
+ wp_register_style('feedwordpress-elements', WP_PLUGIN_URL.'/'.$fwp_path.'/feedwordpress-elements.css');
1167
+ if (FeedWordPressSettingsUI::is_admin()) :
1168
+ // For JavaScript that needs to be generated dynamically
1169
+ add_action('admin_print_scripts', array('FeedWordPressSettingsUI', 'admin_scripts'));
1170
+
1171
+ // For CSS that needs to be generated dynamically.
1172
+ add_action('admin_print_styles', array('FeedWordPressSettingsUI', 'admin_styles'));
1173
+
1174
+ wp_enqueue_style('dashboard');
1175
+ wp_enqueue_style('feedwordpress-elements');
1176
+
1177
+ if (function_exists('wp_admin_css')) :
1178
+ wp_admin_css('css/dashboard');
1179
+ endif;
1180
+ endif;
1181
+
1182
  $this->clear_cache_magic_url();
1183
  $this->update_magic_url();
1184
  } /* FeedWordPress::init() */
1590
  if (!is_array($params)) :
1591
  $force_feed = $params;
1592
  else : // Parameter array
1593
+ $args = wp_parse_args(array(
1594
  'force_feed' => $force_feed,
1595
  'timeout' => $timeout
1596
  ), $params);
feedwordpress_file.class.php CHANGED
@@ -5,12 +5,52 @@ class FeedWordPress_File extends WP_SimplePie_File {
5
  }
6
 
7
  function __construct ($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) {
8
- if (is_callable(array('WP_SimplePie_File', 'WP_SimplePie_File'))) : // PHP 4 idiom
9
- WP_SimplePie_File::WP_SimplePie_File($url, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
10
- else : // PHP 5+
11
- parent::__construct($url, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
12
- endif;
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  // SimplePie makes a strongly typed check against integers with
15
  // this, but WordPress puts a string in. Which causes caching
16
  // to break and fall on its ass when SimplePie is getting a 304,
5
  }
6
 
7
  function __construct ($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) {
8
+ $this->url = $url;
9
+ $this->timeout = $timeout;
10
+ $this->redirects = $redirects;
11
+ $this->headers = $headers;
12
+ $this->useragent = $useragent;
13
 
14
+ $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE;
15
+
16
+ global $wpdb;
17
+
18
+ if ( preg_match('/^http(s)?:\/\//i', $url) ) {
19
+ $args = array( 'timeout' => $this->timeout, 'redirection' => $this->redirects);
20
+
21
+ if ( !empty($this->headers) )
22
+ $args['headers'] = $this->headers;
23
+
24
+ if ( SIMPLEPIE_USERAGENT != $this->useragent ) //Use default WP user agent unless custom has been specified
25
+ $args['user-agent'] = $this->useragent;
26
+
27
+ $links = $wpdb->get_results(
28
+ $wpdb->prepare("SELECT * FROM {$wpdb->links} WHERE link_rss = '%s'", $url)
29
+ );
30
+ if ($links) :
31
+ $source = new SyndicatedLink($links[0]);
32
+ $args['authentication'] = $source->authentication_method();
33
+ $args['username'] = $source->username();
34
+ $args['password'] = $source->password();
35
+ endif;
36
+
37
+ $res = wp_remote_request($url, $args);
38
+
39
+ if ( is_wp_error($res) ) {
40
+ $this->error = 'WP HTTP Error: ' . $res->get_error_message();
41
+ $this->success = false;
42
+ } else {
43
+ $this->headers = wp_remote_retrieve_headers( $res );
44
+ $this->body = wp_remote_retrieve_body( $res );
45
+ $this->status_code = wp_remote_retrieve_response_code( $res );
46
+ }
47
+ } else {
48
+ if ( ! $this->body = file_get_contents($url) ) {
49
+ $this->error = 'file_get_contents could not read the file';
50
+ $this->success = false;
51
+ }
52
+ }
53
+
54
  // SimplePie makes a strongly typed check against integers with
55
  // this, but WordPress puts a string in. Which causes caching
56
  // to break and fall on its ass when SimplePie is getting a 304,
feedwordpresshttpauthenticator.class.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class FeedWordPressHTTPAuthenticator {
3
+ var $args = array();
4
+
5
+ function FeedWordPressHTTPAuthenticator () {
6
+ self::__construct();
7
+ }
8
+
9
+ function __construct () {
10
+ add_filter('use_curl_transport', array(&$this, 'digest_do_it'), 2, 1000);
11
+ foreach (array('fsockopen', 'fopen', 'streams', 'http_extension') as $transport) :
12
+ add_filter("use_{$transport}_transport", array(&$this, 'digest_dont'), 2, 1000);
13
+ endforeach;
14
+
15
+ add_filter('pre_http_request', array(&$this, 'pre_http_request'), 10, 3);
16
+ add_action('http_api_curl', array(&$this, 'set_auth_options'), 1000, 1);
17
+ } /* FeedWordPerssHTTPAuthenticator::__construct () */
18
+
19
+ function need_curl ($args) {
20
+ $args = wp_parse_args($args, array(
21
+ 'authentication' => NULL,
22
+ ));
23
+
24
+ switch ($args['authentication']) :
25
+ case 'digest' :
26
+ $use = true;
27
+ break;
28
+ default :
29
+ $use = false;
30
+ endswitch;
31
+ return $use;
32
+ } /* FeedWordPerssHTTPAuthenticator::need_curl () */
33
+
34
+ function digest_do_it ($use, $args) {
35
+ if ($this->need_curl($args)) :
36
+ $use = true;
37
+ endif;
38
+ return $use;
39
+ } /* FeedWordPerssHTTPAuthenticator::digest_do_it () */
40
+
41
+ function digest_dont ($use, $args) {
42
+ if ($this->need_curl($args)) :
43
+ $use = false;
44
+ endif;
45
+ return false;
46
+ } /* FeedWordPerssHTTPAuthenticator::digest_dont () */
47
+
48
+ function pre_http_request ($pre, $args, $url) {
49
+ $this->args = wp_parse_args($args, array(
50
+ 'authentication' => NULL,
51
+ 'username' => NULL,
52
+ 'password' => NULL,
53
+ ));
54
+ return $pre;
55
+ }
56
+
57
+ function set_auth_options (&$handle) {
58
+ if ('digest'==$this->args['authentication']) :
59
+ curl_setopt($handle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
60
+ endif;
61
+
62
+ if (!is_null($this->args['username'])) :
63
+ $userPass = $this->args['username'];
64
+ if (!is_null($this->args['password'])) :
65
+ $userPass .= ':'.$this->args['password'];
66
+ endif;
67
+
68
+ curl_setopt($handle, CURLOPT_USERPWD, $userPass);
69
+ endif;
70
+
71
+ } /* FeedWordPressHTTPAuthenticator::set_auth_options() */
72
+
73
+ } /* class FeedWordPressHTTPAuthenticator */
feedwordpresssyndicationpage.class.php CHANGED
@@ -207,6 +207,8 @@ class FeedWordPressSyndicationPage extends FeedWordPressAdminPage {
207
  if (isset($_FILES['opml_upload']['name']) and
208
  (strlen($_FILES['opml_upload']['name']) > 0)) :
209
  $in = 'tag:localhost';
 
 
210
  $localData = file_get_contents($_FILES['opml_upload']['tmp_name']);
211
  $merge_all = true;
212
  elseif (isset($fwp_post['multilookup'])) :
207
  if (isset($_FILES['opml_upload']['name']) and
208
  (strlen($_FILES['opml_upload']['name']) > 0)) :
209
  $in = 'tag:localhost';
210
+
211
+ /*FIXME: check whether $_FILES['opml_upload']['error'] === UPLOAD_ERR_OK or not...*/
212
  $localData = file_get_contents($_FILES['opml_upload']['tmp_name']);
213
  $merge_all = true;
214
  elseif (isset($fwp_post['multilookup'])) :
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Charles Johnson
3
  Donate link: http://feedwordpress.radgeek.com/
4
  Tags: syndication, aggregation, feed, atom, rss
5
  Requires at least: 3.0
6
- Tested up to: 3.2
7
- Stable tag: 2011.0721
8
 
9
  FeedWordPress syndicates content from feeds you choose into your WordPress weblog.
10
 
@@ -94,6 +94,49 @@ outs, see the documentation at the [FeedWordPress project homepage][].
94
 
95
  == Changelog ==
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  = 2011.0721 =
98
 
99
  * BUGFIX: SERIOUS BUG CAUSING RARE UNEXPECTED DELETION OF PAGES AND OTHER
@@ -124,7 +167,7 @@ outs, see the documentation at the [FeedWordPress project homepage][].
124
  specific scheduling decisions are made because of, e.g., requests from the
125
  feed producer.
126
 
127
- * FEED UPDATE SCHEDULING IMPROVEMENTS: ENFORCEABLE "MINIMUM INTERVAL" SETTIN
128
  TO SPACE OUT UPDATES. Some feeds request specific update schedules, using
129
  standard elements such as sy:updateFrequency and rss:ttl. Normally,
130
  FeedWordPress respects any scheduling requests that a feed makes -- if it
3
  Donate link: http://feedwordpress.radgeek.com/
4
  Tags: syndication, aggregation, feed, atom, rss
5
  Requires at least: 3.0
6
+ Tested up to: 3.2.1
7
+ Stable tag: 2011.1018
8
 
9
  FeedWordPress syndicates content from feeds you choose into your WordPress weblog.
10
 
94
 
95
  == Changelog ==
96
 
97
+ = 2011.1018 =
98
+
99
+ * HTTP BASIC AND DIGEST AUTHENTICATION SUPPORT: FeedWordPress now offers
100
+ improved support for syndicating feeds that make use of HTTP Basic or HTTP
101
+ Digest authentication methods. In order to set up authentication on one of
102
+ your feeds, just go to its Settings > Feed page, and click on the "Uses
103
+ Username/Password" link underneath the Feed URL. Enter the username and
104
+ password for accessing the feed, then select the authentication method. (If
105
+ you're not sure which method your feed provider uses, try Basic first.)
106
+ Save Changes, and syndicate away.
107
+
108
+ NOTE: HTTP Digest support requires the curl module for PHP. If you are not
109
+ sure whether this module has been installed, contact your web hosting
110
+ provider to check.
111
+
112
+ * WP 3.3 (BETA) COMPATIBILITY: This version fixes an init-sequence bug that
113
+ could cause intrusive warning messages or fatal errors in WP 3.3 beta
114
+ versions.
115
+
116
+ * BUGFIX: FIXES LONG DELAYS IN UPDATES SCHEDULES IN LARGE INSTALLATIONS. A
117
+ performance feature introduced in version 2011.0721 had some flaws in its
118
+ implementation, which tended to create serious delays (on the order of
119
+ several hours) in FeedWordPress's attempts to schedule updates for feeds,
120
+ when users had a very large number of feeds (several dozen or more) in their
121
+ FeedWordPress installation. This feature has been reconfigured to adjust
122
+ dynamically to the number of feeds in Syndicated Sources and the frequency
123
+ with which they are updated. If you've seen a lot of ready-to-update feeds
124
+ piling up, several hours after they were supposed to get updated, then this
125
+ upgrade should better ensure that your feeds get updated in a timely fashion.
126
+
127
+ * BUGFIX: syndicated_item_guid FILTERS FIXED. Previous versions of
128
+ FeedWordPress theoretically allowed for filters on the syndicated_item_guid
129
+ hook, which was intended to filter the globally-unique identifier element
130
+ (rss:guid or atom:id) -- useful if you need to convince FeedWordPress to use
131
+ different guids, or to recognize two or more incoming posts as versions of
132
+ the same post rather than as distinct items. However, while the hook
133
+ affected the guid stored in the WordPress database, it did not affect the
134
+ guid used to check whether an incoming feed item had already been syndicated
135
+ or was a new item -- which greatly limited the practical usefulness of the
136
+ filter. This bug has been fixed: syndicated_item_guid filters should now
137
+ properly control not only the final database record, but also the initial
138
+ uniqueness test applied to posts.
139
+
140
  = 2011.0721 =
141
 
142
  * BUGFIX: SERIOUS BUG CAUSING RARE UNEXPECTED DELETION OF PAGES AND OTHER
167
  specific scheduling decisions are made because of, e.g., requests from the
168
  feed producer.
169
 
170
+ * FEED UPDATE SCHEDULING IMPROVEMENTS: ENFORCEABLE "MINIMUM INTERVAL" SETTING
171
  TO SPACE OUT UPDATES. Some feeds request specific update schedules, using
172
  standard elements such as sy:updateFrequency and rss:ttl. Normally,
173
  FeedWordPress respects any scheduling requests that a feed makes -- if it
syndicatedlink.class.php CHANGED
@@ -630,6 +630,22 @@ class SyndicatedLink {
630
  return $uri;
631
  } /* SyndicatedLink::uri () */
632
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
633
  function property_cascade ($fromFeed, $link_field, $setting, $simplepie_method) {
634
  $value = NULL;
635
  if ($fromFeed) :
630
  return $uri;
631
  } /* SyndicatedLink::uri () */
632
 
633
+ function username () {
634
+ return $this->setting('http username', 'http_username', NULL);
635
+ } /* SyndicatedLink::username () */
636
+
637
+ function password () {
638
+ return $this->setting('http password', 'http_password', NULL);
639
+ } /* SyndicatedLink::password () */
640
+
641
+ function authentication_method () {
642
+ $auth = $this->setting('http auth method', NULL);
643
+ if (('-' == $auth) or (strlen($auth)==0)) :
644
+ $auth = NULL;
645
+ endif;
646
+ return $auth;
647
+ } /* SyndicatedLink::authentication_method () */
648
+
649
  function property_cascade ($fromFeed, $link_field, $setting, $simplepie_method) {
650
  $value = NULL;
651
  if ($fromFeed) :
syndicatedpost.class.php CHANGED
@@ -10,7 +10,7 @@ require_once(dirname(__FILE__).'/feedtime.class.php');
10
  * different feed formats, which may be useful to FeedWordPress users
11
  * who make use of feed data in PHP add-ons and filters.
12
  *
13
- * @version 2011.0601
14
  */
15
  class SyndicatedPost {
16
  var $item = null; // MagpieRSS representation
@@ -1239,12 +1239,13 @@ class SyndicatedPost {
1239
  endif;
1240
 
1241
  if (is_null($this->_freshness)) : // Not yet checked and cached.
1242
- $guid = $wpdb->escape($this->guid());
 
1243
 
1244
  $q = new WP_Query(array(
1245
  'fields' => '_synfresh', // id, guid, post_modified_gmt
1246
  'ignore_sticky_posts' => true,
1247
- 'guid' => $this->guid(),
1248
  ));
1249
 
1250
  $old_post = NULL;
@@ -1255,7 +1256,7 @@ class SyndicatedPost {
1255
  endif;
1256
 
1257
  if (is_null($old_post)) : // No post with this guid
1258
- FeedWordPress::diagnostic('feed_items:freshness', 'Item ['.$this->guid().'] "'.$this->entry->get_title().'" is a NEW POST.');
1259
  $this->_wp_id = NULL;
1260
  $this->_freshness = 2; // New content
1261
  else :
@@ -1293,7 +1294,7 @@ class SyndicatedPost {
1293
  $updated = ($updated and !$frozen);
1294
 
1295
  if ($updated) :
1296
- FeedWordPress::diagnostic('feed_items:freshness', 'Item ['.$this->guid().'] "'.$this->entry->get_title().'" is an update of an existing post.');
1297
  $this->_freshness = 1; // Updated content
1298
  $this->_wp_id = $old_post->ID;
1299
 
@@ -1304,7 +1305,7 @@ class SyndicatedPost {
1304
  array($this->update_hash())
1305
  );
1306
  else :
1307
- FeedWordPress::diagnostic('feed_items:freshness', 'Item ['.$this->guid().'] "'.$this->entry->get_title().'" is a duplicate of an existing post.');
1308
  $this->_freshness = 0; // Same old, same old
1309
  $this->_wp_id = $old_post->ID;
1310
  endif;
10
  * different feed formats, which may be useful to FeedWordPress users
11
  * who make use of feed data in PHP add-ons and filters.
12
  *
13
+ * @version 2011.0831
14
  */
15
  class SyndicatedPost {
16
  var $item = null; // MagpieRSS representation
1239
  endif;
1240
 
1241
  if (is_null($this->_freshness)) : // Not yet checked and cached.
1242
+ $guid = $this->post['guid'];
1243
+ $eguid = $wpdb->escape($this->post['guid']);
1244
 
1245
  $q = new WP_Query(array(
1246
  'fields' => '_synfresh', // id, guid, post_modified_gmt
1247
  'ignore_sticky_posts' => true,
1248
+ 'guid' => $guid,
1249
  ));
1250
 
1251
  $old_post = NULL;
1256
  endif;
1257
 
1258
  if (is_null($old_post)) : // No post with this guid
1259
+ FeedWordPress::diagnostic('feed_items:freshness', 'Item ['.$guid.'] "'.$this->entry->get_title().'" is a NEW POST.');
1260
  $this->_wp_id = NULL;
1261
  $this->_freshness = 2; // New content
1262
  else :
1294
  $updated = ($updated and !$frozen);
1295
 
1296
  if ($updated) :
1297
+ FeedWordPress::diagnostic('feed_items:freshness', 'Item ['.$guid.'] "'.$this->entry->get_title().'" is an update of an existing post.');
1298
  $this->_freshness = 1; // Updated content
1299
  $this->_wp_id = $old_post->ID;
1300
 
1305
  array($this->update_hash())
1306
  );
1307
  else :
1308
+ FeedWordPress::diagnostic('feed_items:freshness', 'Item ['.$guid.'] "'.$this->entry->get_title().'" is a duplicate of an existing post.');
1309
  $this->_freshness = 0; // Same old, same old
1310
  $this->_wp_id = $old_post->ID;
1311
  endif;