Version Description
BUGFIX: "THERE ARE NO HTTP TRANSPORTS AVAILABLE" ERROR FIXED: The initial support for HTTP Basic and Digest authentication in version 2011.1018 contained a bug that could cause HTTP requests for feeds or for other WordPress resources to break down if you do not have the PHP curl module installed. This bug has been fixed, and these errors should no longer appear.
IMPROVED HTTP AUTHENTICATION SUPPORT: In addition, the HTTP Authentication support in FeedWordPress has been extended, to ensure that Basic authentication is available in many web host configurations, and to allow you to add a username and password for a feed immediately when you subscribe to it.
Download this release
Release Info
Developer | radgeek |
Plugin | FeedWordPress |
Version | 2011.1019 |
Comparing to | |
See all releases |
Code changes from version 2011.1018 to 2011.1019
- feedfinder.class.php +62 -9
- feeds-page.php +174 -64
- feedwordpress-elements.css +5 -1
- feedwordpress-elements.js +59 -0
- feedwordpress.php +8 -3
- feedwordpress_file.class.php +24 -8
- feedwordpresshttpauthenticator.class.php +114 -18
- feedwordpresssyndicationpage.class.php +16 -0
- readme.txt +16 -1
feedfinder.class.php
CHANGED
@@ -12,6 +12,7 @@ require_once(dirname(__FILE__).'/feedwordpresshtml.class.php');
|
|
12 |
|
13 |
class FeedFinder {
|
14 |
var $uri = NULL;
|
|
|
15 |
var $_cache_uri = NULL;
|
16 |
|
17 |
var $verify = FALSE;
|
@@ -36,12 +37,51 @@ class FeedFinder {
|
|
36 |
var $_obvious_feed_url = array('[./]rss', '[./]rdf', '[./]atom', '[./]feed', '\.xml');
|
37 |
var $_maybe_feed_url = array ('rss', 'rdf', 'atom', 'feed', 'xml');
|
38 |
|
39 |
-
function FeedFinder ($uri = NULL, $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
$this->uri = $uri; $this->verify = $verify;
|
41 |
$this->fallbacks = $fallbacks;
|
42 |
} /* FeedFinder::FeedFinder () */
|
43 |
|
44 |
-
function find ($uri = NULL) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
$ret = array ();
|
46 |
if (!is_null($this->data($uri))) :
|
47 |
if ($this->is_opml($uri)) :
|
@@ -50,8 +90,8 @@ class FeedFinder {
|
|
50 |
if ($this->is_feed($uri)) :
|
51 |
$href = array($this->uri);
|
52 |
else :
|
53 |
-
// Assume that we have HTML or XHTML (even if we don't, who's
|
54 |
-
// Autodiscovery is the preferred method
|
55 |
$href = $this->_link_rel_feeds();
|
56 |
|
57 |
// ... but we'll also take the little orange buttons
|
@@ -66,8 +106,8 @@ class FeedFinder {
|
|
66 |
endif;
|
67 |
endif;
|
68 |
|
69 |
-
// Our search may turn up duplicate URIs. We only need to do
|
70 |
-
// Props to Camilo <http://projects.radgeek.com/2008/12/14/feedwordpress-20081214/#comment-20090122160414>
|
71 |
$href = array_unique($href);
|
72 |
endif;
|
73 |
|
@@ -83,7 +123,7 @@ class FeedFinder {
|
|
83 |
foreach ($href as $u) :
|
84 |
$the_uri = SimplePie_Misc::absolutize_url($u, $this->uri);
|
85 |
if ($this->verify and ($u != $this->uri and $the_uri != $this->uri)) :
|
86 |
-
$feed = new FeedFinder($the_uri);
|
87 |
if ($feed->is_feed()) : $ret[] = $the_uri; endif;
|
88 |
unset($feed);
|
89 |
else :
|
@@ -91,7 +131,13 @@ class FeedFinder {
|
|
91 |
endif;
|
92 |
endforeach;
|
93 |
endif;
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
return array_values($ret);
|
96 |
} /* FeedFinder::find () */
|
97 |
|
@@ -128,6 +174,10 @@ class FeedFinder {
|
|
128 |
return $message;
|
129 |
}
|
130 |
|
|
|
|
|
|
|
|
|
131 |
function is_feed ($uri = NULL) {
|
132 |
$data = $this->data($uri);
|
133 |
|
@@ -163,9 +213,12 @@ class FeedFinder {
|
|
163 |
$headers['User-Agent'] = 'feedfinder/1.2 (compatible; PHP FeedFinder) +http://projects.radgeek.com/feedwordpress';
|
164 |
|
165 |
// Use WordPress API function
|
166 |
-
$client = wp_remote_request($this->uri,
|
|
|
|
|
167 |
'headers' => $headers,
|
168 |
'timeout' => FeedWordPress::fetch_timeout(),
|
|
|
169 |
));
|
170 |
|
171 |
$this->_response = $client;
|
12 |
|
13 |
class FeedFinder {
|
14 |
var $uri = NULL;
|
15 |
+
var $credentials = NULL;
|
16 |
var $_cache_uri = NULL;
|
17 |
|
18 |
var $verify = FALSE;
|
37 |
var $_obvious_feed_url = array('[./]rss', '[./]rdf', '[./]atom', '[./]feed', '\.xml');
|
38 |
var $_maybe_feed_url = array ('rss', 'rdf', 'atom', 'feed', 'xml');
|
39 |
|
40 |
+
function FeedFinder ($uri = NULL, $params = array(), $fallbacks = 3) {
|
41 |
+
if (is_bool($params)) :
|
42 |
+
$params = array("verify" => $params);
|
43 |
+
endif;
|
44 |
+
|
45 |
+
$params = wp_parse_args($params, array(
|
46 |
+
"verify" => true,
|
47 |
+
"authentication" => NULL,
|
48 |
+
"username" => NULL,
|
49 |
+
"password" => NULL,
|
50 |
+
));
|
51 |
+
$verify = $params['verify'];
|
52 |
+
$this->credentials = array(
|
53 |
+
"authentication" => $params['authentication'],
|
54 |
+
"username" => $params['username'],
|
55 |
+
"password" => $params['password'],
|
56 |
+
);
|
57 |
+
|
58 |
$this->uri = $uri; $this->verify = $verify;
|
59 |
$this->fallbacks = $fallbacks;
|
60 |
} /* FeedFinder::FeedFinder () */
|
61 |
|
62 |
+
function find ($uri = NULL, $params = array()) {
|
63 |
+
$params = wp_parse_args($params, array( // Defaults
|
64 |
+
"authentication" => -1,
|
65 |
+
"username" => NULL,
|
66 |
+
"password" => NULL,
|
67 |
+
));
|
68 |
+
|
69 |
+
// Equivalents
|
70 |
+
if ($params['authentication']=='-') :
|
71 |
+
$params['authentication'] = NULL;
|
72 |
+
$params['username'] = NULL;
|
73 |
+
$params['password'] = NULL;
|
74 |
+
endif;
|
75 |
+
|
76 |
+
// Set/reset
|
77 |
+
if ($params['authentication'] != -1) :
|
78 |
+
$this->credentials = array(
|
79 |
+
"authentication" => $params['authentication'],
|
80 |
+
"username" => $params['username'],
|
81 |
+
"password" => $params['password'],
|
82 |
+
);
|
83 |
+
endif;
|
84 |
+
|
85 |
$ret = array ();
|
86 |
if (!is_null($this->data($uri))) :
|
87 |
if ($this->is_opml($uri)) :
|
90 |
if ($this->is_feed($uri)) :
|
91 |
$href = array($this->uri);
|
92 |
else :
|
93 |
+
// Assume that we have HTML or XHTML (even if we don't, who's
|
94 |
+
// it gonna hurt?) Autodiscovery is the preferred method.
|
95 |
$href = $this->_link_rel_feeds();
|
96 |
|
97 |
// ... but we'll also take the little orange buttons
|
106 |
endif;
|
107 |
endif;
|
108 |
|
109 |
+
// Our search may turn up duplicate URIs. We only need to do
|
110 |
+
// any given URI once. Props to Camilo <http://projects.radgeek.com/2008/12/14/feedwordpress-20081214/#comment-20090122160414>
|
111 |
$href = array_unique($href);
|
112 |
endif;
|
113 |
|
123 |
foreach ($href as $u) :
|
124 |
$the_uri = SimplePie_Misc::absolutize_url($u, $this->uri);
|
125 |
if ($this->verify and ($u != $this->uri and $the_uri != $this->uri)) :
|
126 |
+
$feed = new FeedFinder($the_uri, $this->credentials);
|
127 |
if ($feed->is_feed()) : $ret[] = $the_uri; endif;
|
128 |
unset($feed);
|
129 |
else :
|
131 |
endif;
|
132 |
endforeach;
|
133 |
endif;
|
134 |
+
|
135 |
+
if ($this->is_401($uri)) :
|
136 |
+
$ret = array_merge(array(
|
137 |
+
new WP_Error('http_request_failed', '401 Not authorized', array("uri" => $this->uri, "status" => 401)),
|
138 |
+
), $ret);
|
139 |
+
endif;
|
140 |
+
|
141 |
return array_values($ret);
|
142 |
} /* FeedFinder::find () */
|
143 |
|
174 |
return $message;
|
175 |
}
|
176 |
|
177 |
+
function is_401 ($uri = NULL) {
|
178 |
+
return (intval($this->status($uri))==401);
|
179 |
+
} /* FeedFinder::is_401 () */
|
180 |
+
|
181 |
function is_feed ($uri = NULL) {
|
182 |
$data = $this->data($uri);
|
183 |
|
213 |
$headers['User-Agent'] = 'feedfinder/1.2 (compatible; PHP FeedFinder) +http://projects.radgeek.com/feedwordpress';
|
214 |
|
215 |
// Use WordPress API function
|
216 |
+
$client = wp_remote_request($this->uri, array_merge(
|
217 |
+
$this->credentials,
|
218 |
+
array(
|
219 |
'headers' => $headers,
|
220 |
'timeout' => FeedWordPress::fetch_timeout(),
|
221 |
+
)
|
222 |
));
|
223 |
|
224 |
$this->_response = $client;
|
feeds-page.php
CHANGED
@@ -376,6 +376,65 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
|
|
376 |
);
|
377 |
} /* FeedWordPressFeedsPage::fetch_settings_box () */
|
378 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
379 |
function feed_information_box ($page, $box = NULL) {
|
380 |
global $wpdb;
|
381 |
$link_rss_params = maybe_unserialize($page->setting('query parameters', ''));
|
@@ -441,17 +500,15 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
|
|
441 |
|
442 |
$auth = $this->setting('http auth method', NULL);
|
443 |
|
444 |
-
$
|
445 |
-
|
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">
|
457 |
|
@@ -464,25 +521,11 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
|
|
464 |
title="Check feed <<?php echo esc_html($rss_url); ?>> for validity">validate</a>)
|
465 |
<input type="submit" name="feedfinder" value="switch →" style="font-size:smaller" />
|
466 |
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
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>
|
@@ -509,35 +552,6 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
|
|
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();
|
@@ -699,10 +713,35 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
|
|
699 |
<?php
|
700 |
}
|
701 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
702 |
function display_feedfinder () {
|
703 |
global $wpdb;
|
704 |
|
705 |
$lookup = (isset($_REQUEST['lookup']) ? $_REQUEST['lookup'] : NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
706 |
|
707 |
$feeds = array(); $feedSwitch = false; $current = null;
|
708 |
if ($this->for_feed_settings()) : // Existing feed?
|
@@ -711,7 +750,11 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
|
|
711 |
// Switch Feed without a specific feed yet suggested
|
712 |
// Go to the human-readable homepage to look for
|
713 |
// auto-detection links
|
|
|
714 |
$lookup = $this->link->link->link_url;
|
|
|
|
|
|
|
715 |
|
716 |
// Guarantee that you at least have the option to
|
717 |
// stick with what works.
|
@@ -738,13 +781,13 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
|
|
738 |
$finder[$lookup] = new FeedFinder($lookup);
|
739 |
|
740 |
foreach ($finder as $url => $ff) :
|
741 |
-
$feeds = array_merge($feeds, $ff->find(
|
|
|
|
|
742 |
endforeach;
|
743 |
|
744 |
$feeds = array_values( // Renumber from 0..(N-1)
|
745 |
-
|
746 |
-
$feeds
|
747 |
-
)
|
748 |
);
|
749 |
|
750 |
if (count($feeds) > 0):
|
@@ -767,10 +810,26 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
|
|
767 |
$form_class = '';
|
768 |
endif;
|
769 |
|
|
|
|
|
770 |
foreach ($feeds as $key => $f):
|
|
|
|
|
771 |
$pie = FeedWordPress::fetch($f);
|
|
|
|
|
772 |
$rss = (is_wp_error($pie) ? $pie : new MagpieFromSimplePie($pie));
|
773 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
774 |
if ($rss and !is_wp_error($rss)):
|
775 |
$feed_link = (isset($rss->channel['link'])?$rss->channel['link']:'');
|
776 |
$feed_title = (isset($rss->channel['title'])?$rss->channel['title']:$feed_link);
|
@@ -865,6 +924,11 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
|
|
865 |
<li><strong>Encoding:</strong> <?php echo isset($rss->encoding)?esc_html($rss->encoding):"<em>Unknown</em>"; ?></li>
|
866 |
<li><strong>Description:</strong> <?php echo isset($rss->channel['description'])?esc_html($rss->channel['description']):"<em>Unknown</em>"; ?></li>
|
867 |
</ul>
|
|
|
|
|
|
|
|
|
|
|
868 |
<?php do_action('feedwordpress_feedfinder_form', $f, $post, $link, $this->for_feed_settings()); ?>
|
869 |
<div class="submit"><input type="submit" class="button-primary" name="Use" value="« Use this feed" />
|
870 |
<input type="submit" class="button" name="Cancel" value="× Cancel" /></div>
|
@@ -898,12 +962,26 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
|
|
898 |
// Do some more diagnostics if the API for it is available.
|
899 |
if (function_exists('_wp_http_get_object')) :
|
900 |
$httpObject = _wp_http_get_object();
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
907 |
print "</div>\n";
|
908 |
endif;
|
909 |
endforeach;
|
@@ -918,8 +996,22 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
|
|
918 |
return false; // Don't continue
|
919 |
} /* FeedWordPressFeedsPage::display_feedfinder() */
|
920 |
|
921 |
-
function display_alt_feed_box ($lookup, $
|
922 |
global $fwp_post;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
923 |
?>
|
924 |
<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
|
925 |
<div class="inside"><?php
|
@@ -929,6 +1021,14 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
|
|
929 |
<?php if (!$alt): ?>style="margin: 1.0em 3.0em; font-size: smaller;"<?php endif; ?>>
|
930 |
<legend><?php if ($alt) : ?>Alternative feeds<?php else: ?>Find feeds<?php endif; ?></legend>
|
931 |
<?php if ($alt) : ?><h3>Use a different feed</h3><?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
932 |
<div><label>Address:
|
933 |
<input type="text" name="lookup" id="use-another-feed"
|
934 |
placeholder="URL"
|
@@ -941,9 +1041,17 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
|
|
941 |
<?php if (is_null($lookup)) : ?>
|
942 |
<?php FeedWordPressSettingsUI::magic_input_tip_js('use-another-feed'); ?>
|
943 |
<?php endif; ?>
|
|
|
944 |
<?php $this->stamp_link_id('link_id'); ?>
|
945 |
<input type="hidden" name="action" value="feedfinder" />
|
946 |
<input type="submit" class="button<?php if ($alt): ?>-primary<?php endif; ?>" value="Check »" /></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
947 |
<p>This can be the address of a feed, or of a website. FeedWordPress
|
948 |
will try to automatically detect any feeds associated with a
|
949 |
website.</p>
|
@@ -1071,6 +1179,7 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
|
|
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 :
|
@@ -1080,6 +1189,7 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
|
|
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 :
|
376 |
);
|
377 |
} /* FeedWordPressFeedsPage::fetch_settings_box () */
|
378 |
|
379 |
+
function display_authentication_credentials_box ($params = array()) {
|
380 |
+
static $count = 0;
|
381 |
+
|
382 |
+
$params = wp_parse_args($params, array(
|
383 |
+
'username' => NULL,
|
384 |
+
'password' => NULL,
|
385 |
+
'method' => '-',
|
386 |
+
));
|
387 |
+
|
388 |
+
// Equivalents
|
389 |
+
if (is_null($params['method'])) : $params['method'] = '-'; endif;
|
390 |
+
|
391 |
+
$count++;
|
392 |
+
$slug = ($count > 1 ? '-'.$count : '');
|
393 |
+
|
394 |
+
global $feedwordpress;
|
395 |
+
$authMethods = apply_filters(
|
396 |
+
'feedwordpress_http_auth_methods',
|
397 |
+
$feedwordpress->httpauth->methods_available()
|
398 |
+
);
|
399 |
+
|
400 |
+
if (count($authMethods) > 1) : /* More than '-' */
|
401 |
+
?>
|
402 |
+
<div class="link-rss-authentication" id="link-rss-authentication<?php print $slug; ?>">
|
403 |
+
<table>
|
404 |
+
<tbody>
|
405 |
+
<tr class="link-rss-authentication-credentials" id="link-rss-authentication-credentials<?php print $slug; ?>">
|
406 |
+
<td><label>user: <input type="text" name="link_rss_username"
|
407 |
+
value="<?php print esc_attr($params['username']); ?>" size="16"
|
408 |
+
placeholder="username to access this feed" /></label></td>
|
409 |
+
<td><label>pass: <input type="text" name="link_rss_password"
|
410 |
+
value="<?php print esc_attr($params['password']); ?>" size="16"
|
411 |
+
placeholder="password to access this feed" /></label></td>
|
412 |
+
<td class="link-rss-authentication-method" id="link-rss-authentication-method<?php print $slug; ?>"><label>method: <select class="link-rss-auth-method" id="link-rss-auth-method" name="link_rss_auth_method" size="1">
|
413 |
+
<?php foreach ($authMethods as $value => $label) : ?>
|
414 |
+
<option value="<?php print esc_attr($value); ?>"<?php
|
415 |
+
if ($value == $params['method']) : ?> selected="selected"<?php
|
416 |
+
endif; ?>><?php print esc_html($label); ?></option>
|
417 |
+
<?php endforeach; ?>
|
418 |
+
</select></label></td>
|
419 |
+
</tr>
|
420 |
+
</tbody>
|
421 |
+
</table>
|
422 |
+
</div>
|
423 |
+
|
424 |
+
<script type="text/javascript">
|
425 |
+
jQuery('<td><a class="add-remove remove-it" id="link-rss-userpass-remove<?php print $slug; ?>" href="#"><span class="x">(X)</span> Remove</a></td>')
|
426 |
+
.appendTo('#link-rss-authentication-credentials<?php print $slug; ?>')
|
427 |
+
.click( feedAuthenticationMethodUnPress );
|
428 |
+
jQuery('#link-rss-auth-method<?php print $slug; ?>').change( feedAuthenticationMethod );
|
429 |
+
feedAuthenticationMethod({
|
430 |
+
init: true,
|
431 |
+
node: jQuery('#link-rss-authentication<?php print $slug; ?>') });
|
432 |
+
</script>
|
433 |
+
|
434 |
+
<?php
|
435 |
+
endif;
|
436 |
+
}
|
437 |
+
|
438 |
function feed_information_box ($page, $box = NULL) {
|
439 |
global $wpdb;
|
440 |
$link_rss_params = maybe_unserialize($page->setting('query parameters', ''));
|
500 |
|
501 |
$auth = $this->setting('http auth method', NULL);
|
502 |
|
503 |
+
global $feedwordpress;
|
504 |
+
|
|
|
|
|
|
|
505 |
if (is_null($auth)) :
|
506 |
$auth = '-';
|
507 |
$hideAuth = true;
|
508 |
endif;
|
509 |
|
510 |
// Hey ho, let's go
|
511 |
+
|
512 |
?>
|
513 |
<table class="edit-form">
|
514 |
|
521 |
title="Check feed <<?php echo esc_html($rss_url); ?>> for validity">validate</a>)
|
522 |
<input type="submit" name="feedfinder" value="switch →" style="font-size:smaller" />
|
523 |
|
524 |
+
<?php $this->display_authentication_credentials_box(array(
|
525 |
+
'username' => $username,
|
526 |
+
'password' => $password,
|
527 |
+
'method' => $auth,
|
528 |
+
)); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
529 |
|
530 |
<table id="link-rss-params">
|
531 |
<tbody>
|
552 |
<div><input type="hidden" id="link-rss-params-num" name="link_rss_params_num" value="<?php print $i; ?>" /></div>
|
553 |
|
554 |
<script type="text/javascript">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
555 |
function linkParamsRowRemove (element) {
|
556 |
jQuery(element).closest('tr').fadeOut('slow', function () {
|
557 |
jQuery(this).remove();
|
713 |
<?php
|
714 |
}
|
715 |
|
716 |
+
function url_for_401 ($err) {
|
717 |
+
$ret = NULL;
|
718 |
+
if (is_wp_error($err)) :
|
719 |
+
if ($err->get_error_code()=='http_request_failed') :
|
720 |
+
$data = $err->get_error_data('http_request_failed');
|
721 |
+
|
722 |
+
if (is_array($data) and isset($data['status'])) :
|
723 |
+
if (401==$data['status']) :
|
724 |
+
$ret = $data['uri'];
|
725 |
+
endif;
|
726 |
+
endif;
|
727 |
+
endif;
|
728 |
+
endif;
|
729 |
+
return $ret;
|
730 |
+
}
|
731 |
+
|
732 |
function display_feedfinder () {
|
733 |
global $wpdb;
|
734 |
|
735 |
$lookup = (isset($_REQUEST['lookup']) ? $_REQUEST['lookup'] : NULL);
|
736 |
+
|
737 |
+
$auth = FeedWordPress::param('link_rss_auth_method');
|
738 |
+
$username = FeedWordPress::param('link_rss_username');
|
739 |
+
$password = FeedWordPress::param('link_rss_password');
|
740 |
+
$credentials = array(
|
741 |
+
"authentication" => $auth,
|
742 |
+
"username" => $username,
|
743 |
+
"password" => $password,
|
744 |
+
);
|
745 |
|
746 |
$feeds = array(); $feedSwitch = false; $current = null;
|
747 |
if ($this->for_feed_settings()) : // Existing feed?
|
750 |
// Switch Feed without a specific feed yet suggested
|
751 |
// Go to the human-readable homepage to look for
|
752 |
// auto-detection links
|
753 |
+
|
754 |
$lookup = $this->link->link->link_url;
|
755 |
+
$auth = $this->link->setting('http auth method');
|
756 |
+
$username = $this->link->setting('http username');
|
757 |
+
$password = $this->link->setting('http password');
|
758 |
|
759 |
// Guarantee that you at least have the option to
|
760 |
// stick with what works.
|
781 |
$finder[$lookup] = new FeedFinder($lookup);
|
782 |
|
783 |
foreach ($finder as $url => $ff) :
|
784 |
+
$feeds = array_merge($feeds, $ff->find(
|
785 |
+
/*url=*/ NULL,
|
786 |
+
/*params=*/ $credentials));
|
787 |
endforeach;
|
788 |
|
789 |
$feeds = array_values( // Renumber from 0..(N-1)
|
790 |
+
$feeds
|
|
|
|
|
791 |
);
|
792 |
|
793 |
if (count($feeds) > 0):
|
810 |
$form_class = '';
|
811 |
endif;
|
812 |
|
813 |
+
global $fwp_credentials;
|
814 |
+
|
815 |
foreach ($feeds as $key => $f):
|
816 |
+
$ofc = $fwp_credentials;
|
817 |
+
$fwp_credentials = $credentials; // Set
|
818 |
$pie = FeedWordPress::fetch($f);
|
819 |
+
$fwp_credentials = $ofc; // Re-Set
|
820 |
+
|
821 |
$rss = (is_wp_error($pie) ? $pie : new MagpieFromSimplePie($pie));
|
822 |
|
823 |
+
if ($this->url_for_401($pie)) :
|
824 |
+
$this->display_alt_feed_box($lookup, array(
|
825 |
+
"err" => $pie,
|
826 |
+
"auth" => $auth,
|
827 |
+
"username" => $username,
|
828 |
+
"password" => $password
|
829 |
+
));
|
830 |
+
continue;
|
831 |
+
endif;
|
832 |
+
|
833 |
if ($rss and !is_wp_error($rss)):
|
834 |
$feed_link = (isset($rss->channel['link'])?$rss->channel['link']:'');
|
835 |
$feed_title = (isset($rss->channel['title'])?$rss->channel['title']:$feed_link);
|
924 |
<li><strong>Encoding:</strong> <?php echo isset($rss->encoding)?esc_html($rss->encoding):"<em>Unknown</em>"; ?></li>
|
925 |
<li><strong>Description:</strong> <?php echo isset($rss->channel['description'])?esc_html($rss->channel['description']):"<em>Unknown</em>"; ?></li>
|
926 |
</ul>
|
927 |
+
<?php $this->display_authentication_credentials_box(array(
|
928 |
+
'username' => $username,
|
929 |
+
'password' => $password,
|
930 |
+
'method' => $auth,
|
931 |
+
)); ?>
|
932 |
<?php do_action('feedwordpress_feedfinder_form', $f, $post, $link, $this->for_feed_settings()); ?>
|
933 |
<div class="submit"><input type="submit" class="button-primary" name="Use" value="« Use this feed" />
|
934 |
<input type="submit" class="button" name="Cancel" value="× Cancel" /></div>
|
962 |
// Do some more diagnostics if the API for it is available.
|
963 |
if (function_exists('_wp_http_get_object')) :
|
964 |
$httpObject = _wp_http_get_object();
|
965 |
+
|
966 |
+
if (is_callable(array($httpObject, '_getTransport'))) :
|
967 |
+
$transports = $httpObject->_getTransport();
|
968 |
+
|
969 |
+
print "<h4>".__('HTTP Transports available').":</h4>\n";
|
970 |
+
print "<ol>\n";
|
971 |
+
print "<li>".implode("</li>\n<li>", array_map('get_class', $transports))."</li>\n";
|
972 |
+
print "</ol>\n";
|
973 |
+
elseif (is_callable(array($httpObject, '_get_first_available_transport'))) :
|
974 |
+
$transport = $httpObject->_get_first_available_transport(
|
975 |
+
array(),
|
976 |
+
$url
|
977 |
+
);
|
978 |
+
|
979 |
+
print "<h4>".__("HTTP Transport").":</h4>\n";
|
980 |
+
print "<ol>\n";
|
981 |
+
print "<li>".FeedWordPress::val($transport)."</li>\n";
|
982 |
+
print "</ol>\n";
|
983 |
+
endif;
|
984 |
+
|
985 |
print "</div>\n";
|
986 |
endif;
|
987 |
endforeach;
|
996 |
return false; // Don't continue
|
997 |
} /* FeedWordPressFeedsPage::display_feedfinder() */
|
998 |
|
999 |
+
function display_alt_feed_box ($lookup, $params = false) {
|
1000 |
global $fwp_post;
|
1001 |
+
|
1002 |
+
if (is_bool($params)) :
|
1003 |
+
$params = array("alt" => $params);
|
1004 |
+
endif;
|
1005 |
+
|
1006 |
+
$params = wp_parse_args($params, array( // Defaults
|
1007 |
+
"alt" => false,
|
1008 |
+
"err" => NULL,
|
1009 |
+
"auth" => NULL,
|
1010 |
+
"password" => NULL,
|
1011 |
+
"username" => NULL,
|
1012 |
+
));
|
1013 |
+
$alt = $params['alt'];
|
1014 |
+
|
1015 |
?>
|
1016 |
<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
|
1017 |
<div class="inside"><?php
|
1021 |
<?php if (!$alt): ?>style="margin: 1.0em 3.0em; font-size: smaller;"<?php endif; ?>>
|
1022 |
<legend><?php if ($alt) : ?>Alternative feeds<?php else: ?>Find feeds<?php endif; ?></legend>
|
1023 |
<?php if ($alt) : ?><h3>Use a different feed</h3><?php endif; ?>
|
1024 |
+
<?php if (is_wp_error($params['err'])) :
|
1025 |
+
?>
|
1026 |
+
<p><em><strong>401 Not Authorized.</strong> This URL may require
|
1027 |
+
a username and password to access it.</em> You may want to add login
|
1028 |
+
credentials below and check it again.</p>
|
1029 |
+
<?php
|
1030 |
+
endif;
|
1031 |
+
?>
|
1032 |
<div><label>Address:
|
1033 |
<input type="text" name="lookup" id="use-another-feed"
|
1034 |
placeholder="URL"
|
1041 |
<?php if (is_null($lookup)) : ?>
|
1042 |
<?php FeedWordPressSettingsUI::magic_input_tip_js('use-another-feed'); ?>
|
1043 |
<?php endif; ?>
|
1044 |
+
|
1045 |
<?php $this->stamp_link_id('link_id'); ?>
|
1046 |
<input type="hidden" name="action" value="feedfinder" />
|
1047 |
<input type="submit" class="button<?php if ($alt): ?>-primary<?php endif; ?>" value="Check »" /></div>
|
1048 |
+
|
1049 |
+
<?php $this->display_authentication_credentials_box(array(
|
1050 |
+
'username' => $params['username'],
|
1051 |
+
'password' => $params['password'],
|
1052 |
+
'method' => $params['auth'],
|
1053 |
+
)); ?>
|
1054 |
+
|
1055 |
<p>This can be the address of a feed, or of a website. FeedWordPress
|
1056 |
will try to automatically detect any feeds associated with a
|
1057 |
website.</p>
|
1179 |
if (
|
1180 |
isset($post['link_rss_username'])
|
1181 |
and (strlen($post['link_rss_username']) > 0)
|
1182 |
+
and ('-' != $post['link_rss_auth_method'])
|
1183 |
) :
|
1184 |
$this->update_setting('http username', $post['link_rss_username']);
|
1185 |
else :
|
1189 |
if (
|
1190 |
isset($post['link_rss_password'])
|
1191 |
and (strlen($post['link_rss_password']) > 0)
|
1192 |
+
and ('-' != $post['link_rss_auth_method'])
|
1193 |
) :
|
1194 |
$this->update_setting('http password', $post['link_rss_password']);
|
1195 |
else :
|
feedwordpress-elements.css
CHANGED
@@ -387,12 +387,16 @@ table.twofer td.secondary { padding-left: 10px; width: 30%; }
|
|
387 |
vertical-align: middle;
|
388 |
}
|
389 |
|
390 |
-
#link-rss-userpass-use,
|
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;
|
387 |
vertical-align: middle;
|
388 |
}
|
389 |
|
390 |
+
#link-rss-userpass-use, .link-rss-authentication table {
|
391 |
display: block;
|
392 |
font-size: 75%;
|
393 |
white-space: nowrap;
|
394 |
padding: 0.5em 0;
|
395 |
}
|
396 |
+
#feed-finder .link-rss-authentication table {
|
397 |
+
font-size: inherit;
|
398 |
+
}
|
399 |
+
|
400 |
#link-rss-authentication label {
|
401 |
font-weight: bold;
|
402 |
padding-left: 1.5em;
|
feedwordpress-elements.js
CHANGED
@@ -368,6 +368,65 @@ $.fn.fwpList = function( settings ) {
|
|
368 |
|
369 |
})(jQuery);
|
370 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
371 |
jQuery(document).ready( function($) {
|
372 |
// Category boxes
|
373 |
$('.feedwordpress-category-div').each( function () {
|
368 |
|
369 |
})(jQuery);
|
370 |
|
371 |
+
/**
|
372 |
+
* Admin interface: Uses Username/Parameter UI for Feed Settings.
|
373 |
+
*
|
374 |
+
*/
|
375 |
+
function feedAuthenticationMethodPress (params) {
|
376 |
+
feedAuthenticationMethod({value: 'basic', node: jQuery(this)});
|
377 |
+
return false;
|
378 |
+
}
|
379 |
+
function feedAuthenticationMethodUnPress (params) {
|
380 |
+
feedAuthenticationMethod({value: '-', node: jQuery(this)});
|
381 |
+
return false;
|
382 |
+
}
|
383 |
+
function feedAuthenticationMethod (params) {
|
384 |
+
var s = jQuery.extend({}, {
|
385 |
+
init: false,
|
386 |
+
value: null,
|
387 |
+
node: jQuery(this)
|
388 |
+
}, params);
|
389 |
+
|
390 |
+
var speed = (s.init ? 0 : 'slow');
|
391 |
+
|
392 |
+
var elDiv = jQuery(s.node).closest('.link-rss-authentication');
|
393 |
+
var elTable = elDiv.find('table');
|
394 |
+
var elMethod = elTable.find('.link-rss-auth-method');
|
395 |
+
var elLink = elDiv.find('.link-rss-userpass-use');
|
396 |
+
|
397 |
+
console.log('--- ---');
|
398 |
+
console.log(s.node);
|
399 |
+
console.log(elDiv);
|
400 |
+
console.log(elTable);
|
401 |
+
console.log(elMethod);
|
402 |
+
console.log(elLink);
|
403 |
+
console.log(elMethod.val());
|
404 |
+
|
405 |
+
// Set.
|
406 |
+
if (s.value != null) {
|
407 |
+
elMethod.val(s.value);
|
408 |
+
}
|
409 |
+
|
410 |
+
if (elMethod.val()=='-') {
|
411 |
+
elTable.hide(speed, function () {
|
412 |
+
// Just in case. Make sure that we don't duplicate.
|
413 |
+
elLink.remove();
|
414 |
+
|
415 |
+
jQuery('<a style="display: none" class="add-remove link-rss-userpass-use" href="#">+ Uses username/password</a>')
|
416 |
+
.insertAfter(elTable)
|
417 |
+
.click(feedAuthenticationMethodPress)
|
418 |
+
.show(speed);
|
419 |
+
});
|
420 |
+
} else {
|
421 |
+
elLink.hide(speed, function () { jQuery(this).remove(); } );
|
422 |
+
elTable.show(speed);
|
423 |
+
} /* if */
|
424 |
+
} /* function feedAuthenticationMethod () */
|
425 |
+
|
426 |
+
/**
|
427 |
+
* Admin interface: Live category and tag boxes
|
428 |
+
*/
|
429 |
+
|
430 |
jQuery(document).ready( function($) {
|
431 |
// Category boxes
|
432 |
$('.feedwordpress-category-div').each( function () {
|
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.
|
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.
|
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.
|
38 |
define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
|
39 |
|
40 |
if (!defined('FEEDWORDPRESS_BLEG')) :
|
@@ -1582,6 +1582,11 @@ class FeedWordPress {
|
|
1582 |
}
|
1583 |
|
1584 |
/*static*/ function fetch ($url, $params = array()) {
|
|
|
|
|
|
|
|
|
|
|
1585 |
$force_feed = true; // Default
|
1586 |
|
1587 |
// Allow user to change default feed-fetch timeout with a global setting. Props Erigami Scholey-Fuller <http://www.piepalace.ca/blog/2010/11/feedwordpress-broke-my-heart.html> 'timeout' =>
|
3 |
Plugin Name: FeedWordPress
|
4 |
Plugin URI: http://feedwordpress.radgeek.com/
|
5 |
Description: simple and flexible Atom/RSS syndication for WordPress
|
6 |
+
Version: 2011.1019
|
7 |
Author: Charles Johnson
|
8 |
Author URI: http://radgeek.com/
|
9 |
License: GPL
|
11 |
|
12 |
/**
|
13 |
* @package FeedWordPress
|
14 |
+
* @version 2011.1019
|
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.1019');
|
38 |
define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
|
39 |
|
40 |
if (!defined('FEEDWORDPRESS_BLEG')) :
|
1582 |
}
|
1583 |
|
1584 |
/*static*/ function fetch ($url, $params = array()) {
|
1585 |
+
if (is_wp_error($url)) :
|
1586 |
+
// Let's bounce.
|
1587 |
+
return $url;
|
1588 |
+
endif;
|
1589 |
+
|
1590 |
$force_feed = true; // Default
|
1591 |
|
1592 |
// Allow user to change default feed-fetch timeout with a global setting. Props Erigami Scholey-Fuller <http://www.piepalace.ca/blog/2010/11/feedwordpress-broke-my-heart.html> 'timeout' =>
|
feedwordpress_file.class.php
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
<?php
|
|
|
|
|
2 |
class FeedWordPress_File extends WP_SimplePie_File {
|
3 |
function FeedWordPress_File ($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) {
|
4 |
self::__construct($url, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
|
@@ -14,6 +16,7 @@ class FeedWordPress_File extends WP_SimplePie_File {
|
|
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);
|
@@ -24,14 +27,27 @@ class FeedWordPress_File extends WP_SimplePie_File {
|
|
24 |
if ( SIMPLEPIE_USERAGENT != $this->useragent ) //Use default WP user agent unless custom has been specified
|
25 |
$args['user-agent'] = $this->useragent;
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
if ($
|
31 |
-
|
32 |
-
$args['authentication'] = $
|
33 |
-
$args['username'] = $
|
34 |
-
$args['password'] = $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
endif;
|
36 |
|
37 |
$res = wp_remote_request($url, $args);
|
1 |
<?php
|
2 |
+
$GLOBALS['fwp_credentials'] = NULL;
|
3 |
+
|
4 |
class FeedWordPress_File extends WP_SimplePie_File {
|
5 |
function FeedWordPress_File ($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) {
|
6 |
self::__construct($url, $timeout, $redirects, $headers, $useragent, $force_fsockopen);
|
16 |
$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE;
|
17 |
|
18 |
global $wpdb;
|
19 |
+
global $fwp_credentials;
|
20 |
|
21 |
if ( preg_match('/^http(s)?:\/\//i', $url) ) {
|
22 |
$args = array( 'timeout' => $this->timeout, 'redirection' => $this->redirects);
|
27 |
if ( SIMPLEPIE_USERAGENT != $this->useragent ) //Use default WP user agent unless custom has been specified
|
28 |
$args['user-agent'] = $this->useragent;
|
29 |
|
30 |
+
// This is ugly as hell, but communicating up and down the chain
|
31 |
+
// in any other way is difficult.
|
32 |
+
|
33 |
+
if (!is_null($fwp_credentials)) :
|
34 |
+
|
35 |
+
$args['authentication'] = $fwp_credentials['authentication'];
|
36 |
+
$args['username'] = $fwp_credentials['username'];
|
37 |
+
$args['password'] = $fwp_credentials['password'];
|
38 |
+
|
39 |
+
else :
|
40 |
+
|
41 |
+
$links = $wpdb->get_results(
|
42 |
+
$wpdb->prepare("SELECT * FROM {$wpdb->links} WHERE link_rss = '%s'", $url)
|
43 |
+
);
|
44 |
+
if ($links) :
|
45 |
+
$source = new SyndicatedLink($links[0]);
|
46 |
+
$args['authentication'] = $source->authentication_method();
|
47 |
+
$args['username'] = $source->username();
|
48 |
+
$args['password'] = $source->password();
|
49 |
+
endif;
|
50 |
+
|
51 |
endif;
|
52 |
|
53 |
$res = wp_remote_request($url, $args);
|
feedwordpresshttpauthenticator.class.php
CHANGED
@@ -14,8 +14,112 @@ class FeedWordPressHTTPAuthenticator {
|
|
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 |
-
} /*
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
function need_curl ($args) {
|
20 |
$args = wp_parse_args($args, array(
|
21 |
'authentication' => NULL,
|
@@ -29,30 +133,22 @@ class FeedWordPressHTTPAuthenticator {
|
|
29 |
$use = false;
|
30 |
endswitch;
|
31 |
return $use;
|
32 |
-
} /*
|
33 |
|
34 |
function digest_do_it ($use, $args) {
|
35 |
-
|
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 =
|
44 |
endif;
|
45 |
-
return
|
46 |
-
} /*
|
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']) :
|
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 |
+
} /* FeedWordPressHTTPAuthenticator::__construct () */
|
18 |
|
19 |
+
function methods_available () {
|
20 |
+
$methods = array('-' => 'None');
|
21 |
+
|
22 |
+
if ($this->have_curl(array('authentication' => 'digest'))) :
|
23 |
+
$methods = array_merge(array(
|
24 |
+
'digest' => 'Digest',
|
25 |
+
), $methods);
|
26 |
+
endif;
|
27 |
+
|
28 |
+
if (
|
29 |
+
$this->have_curl(array('authentication' => 'basic'))
|
30 |
+
or $this->have_streams(array('authentication' => 'basic'))
|
31 |
+
) :
|
32 |
+
$methods = array_merge(array(
|
33 |
+
'basic' => 'Basic',
|
34 |
+
), $methods);
|
35 |
+
endif;
|
36 |
+
|
37 |
+
return $methods;
|
38 |
+
}
|
39 |
+
|
40 |
+
function pre_http_request ($pre, $args, $url) {
|
41 |
+
$this->args = wp_parse_args($args, array(
|
42 |
+
'authentication' => NULL,
|
43 |
+
'username' => NULL,
|
44 |
+
'password' => NULL,
|
45 |
+
));
|
46 |
+
|
47 |
+
// Ruh roh...
|
48 |
+
if (!is_null($this->args['authentication'])) :
|
49 |
+
switch ($this->args['authentication']) :
|
50 |
+
case '-' :
|
51 |
+
// No HTTP Auth method. Remove this stuff.
|
52 |
+
$this->args['authentication'] = NULL;
|
53 |
+
$this->args['username'] = NULL;
|
54 |
+
$this->args['password'] = NULL;
|
55 |
+
break;
|
56 |
+
case 'basic' :
|
57 |
+
if ($this->have_curl($args, $url)) :
|
58 |
+
// Don't need to do anything. http_api_curl hook takes care
|
59 |
+
// of it.
|
60 |
+
break;
|
61 |
+
elseif ($this->have_streams($args, $url)) :
|
62 |
+
// curl has a nice native way to jam in the username and
|
63 |
+
// passwd but streams and fsockopen do not. So we have to
|
64 |
+
// make a recursive call with the credentials in the URL.
|
65 |
+
// Wee ha!
|
66 |
+
$method = $this->args['authentication'];
|
67 |
+
$credentials = $this->args['username'];
|
68 |
+
if (!is_null($this->args['password'])) :
|
69 |
+
$credentials .= ':'.$args['password'];
|
70 |
+
endif;
|
71 |
+
|
72 |
+
// Remove these so we don't recurse all the way down
|
73 |
+
unset($this->args['authentication']);
|
74 |
+
unset($this->args['username']);
|
75 |
+
unset($this->args['password']);
|
76 |
+
|
77 |
+
$url = preg_replace('!(https?://)!', '$1'.$credentials.'@', $url);
|
78 |
+
|
79 |
+
// Subsidiary request
|
80 |
+
$pre = wp_remote_request($url, $this->args);
|
81 |
+
break;
|
82 |
+
endif;
|
83 |
+
case 'digest' :
|
84 |
+
if ($this->have_curl($args, $url)) :
|
85 |
+
// Don't need to do anything. http_api_curl hook takes care
|
86 |
+
// of it.
|
87 |
+
break;
|
88 |
+
endif;
|
89 |
+
default :
|
90 |
+
if (is_callable('WP_Http', '_get_first_available_transport')) :
|
91 |
+
$trans = WP_Http::_get_first_available_transport($args, $url);
|
92 |
+
if (!$trans) :
|
93 |
+
$trans = WP_Http::_get_first_available_transport(array(), $url);
|
94 |
+
endif;
|
95 |
+
elseif (is_callable('WP_Http', '_getTransport')) :
|
96 |
+
$transports = WP_Http::_getTransport($args);
|
97 |
+
$trans = get_class(reset($transports));
|
98 |
+
else :
|
99 |
+
$trans = 'HTTP';
|
100 |
+
endif;
|
101 |
+
|
102 |
+
$pre = new WP_Error('http_request_failed',
|
103 |
+
sprintf(
|
104 |
+
__('%s cannot use %s authentication with the %s transport.'),
|
105 |
+
__CLASS__,
|
106 |
+
$args['authentication'],
|
107 |
+
$trans
|
108 |
+
)
|
109 |
+
);
|
110 |
+
endswitch;
|
111 |
+
endif;
|
112 |
+
return $pre;
|
113 |
+
} /* FeedWordPressHTTPAuthenticator::pre_http_request () */
|
114 |
+
|
115 |
+
function have_curl ($args, $url = NULL) {
|
116 |
+
return WP_Http_Curl::test($args);
|
117 |
+
}
|
118 |
+
|
119 |
+
function have_streams ($args, $url = NULL) {
|
120 |
+
return WP_Http_Streams::test($args);
|
121 |
+
}
|
122 |
+
|
123 |
function need_curl ($args) {
|
124 |
$args = wp_parse_args($args, array(
|
125 |
'authentication' => NULL,
|
133 |
$use = false;
|
134 |
endswitch;
|
135 |
return $use;
|
136 |
+
} /* FeedWordPressHTTPAuthenticator::need_curl () */
|
137 |
|
138 |
function digest_do_it ($use, $args) {
|
139 |
+
return $this->if_curl($use, $args, true);
|
|
|
|
|
|
|
140 |
} /* FeedWordPerssHTTPAuthenticator::digest_do_it () */
|
141 |
|
142 |
function digest_dont ($use, $args) {
|
143 |
+
return $this->if_curl($use, $args, false);
|
144 |
+
} /* FeedWordPressHTTPAuthenticator::digest_dont () */
|
145 |
+
|
146 |
+
function if_curl ($use, $args, $what) {
|
147 |
if ($this->need_curl($args)) :
|
148 |
+
$use = $what;
|
149 |
endif;
|
150 |
+
return $use;
|
151 |
+
} /* FeedWordPressHTTPAuthenticator::if_curl () */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
|
153 |
function set_auth_options (&$handle) {
|
154 |
if ('digest'==$this->args['authentication']) :
|
feedwordpresssyndicationpage.class.php
CHANGED
@@ -1119,6 +1119,7 @@ function fwp_switchfeed_page () {
|
|
1119 |
$link_id = FeedWordPress::syndicate_link($fwp_post['feed_title'], $fwp_post['feed_link'], $fwp_post['feed']);
|
1120 |
if ($link_id):
|
1121 |
$existingLink = new SyndicatedLink($link_id);
|
|
|
1122 |
?>
|
1123 |
<div class="updated"><p><a href="<?php print $fwp_post['feed_link']; ?>"><?php print esc_html($fwp_post['feed_title']); ?></a>
|
1124 |
has been added as a contributing site, using the feed at
|
@@ -1143,7 +1144,22 @@ updated to <<a href="<?php echo esc_html($fwp_post['feed']); ?>"><?php echo e
|
|
1143 |
endif;
|
1144 |
|
1145 |
if (isset($existingLink)) :
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1146 |
do_action('feedwordpress_admin_switchfeed', $fwp_post['feed'], $existingLink);
|
|
|
1147 |
endif;
|
1148 |
|
1149 |
if (!$changed) :
|
1119 |
$link_id = FeedWordPress::syndicate_link($fwp_post['feed_title'], $fwp_post['feed_link'], $fwp_post['feed']);
|
1120 |
if ($link_id):
|
1121 |
$existingLink = new SyndicatedLink($link_id);
|
1122 |
+
|
1123 |
?>
|
1124 |
<div class="updated"><p><a href="<?php print $fwp_post['feed_link']; ?>"><?php print esc_html($fwp_post['feed_title']); ?></a>
|
1125 |
has been added as a contributing site, using the feed at
|
1144 |
endif;
|
1145 |
|
1146 |
if (isset($existingLink)) :
|
1147 |
+
$auth = FeedWordPress::post('link_rss_auth_method');
|
1148 |
+
if (!is_null($auth) and $auth != '-') :
|
1149 |
+
$existingLink->update_setting('http auth method', $auth);
|
1150 |
+
$existingLink->update_setting('http username',
|
1151 |
+
FeedWordPress::post('link_rss_username')
|
1152 |
+
);
|
1153 |
+
$existingLink->update_setting('http password',
|
1154 |
+
FeedWordPress::post('link_rss_password')
|
1155 |
+
);
|
1156 |
+
else :
|
1157 |
+
$existingLink->update_setting('http auth method', NULL);
|
1158 |
+
$existingLink->update_setting('http username', NULL);
|
1159 |
+
$existingLink->update_setting('http password', NULL);
|
1160 |
+
endif;
|
1161 |
do_action('feedwordpress_admin_switchfeed', $fwp_post['feed'], $existingLink);
|
1162 |
+
$existingLink->save_settings(/*reload=*/ true);
|
1163 |
endif;
|
1164 |
|
1165 |
if (!$changed) :
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ 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.
|
8 |
|
9 |
FeedWordPress syndicates content from feeds you choose into your WordPress weblog.
|
10 |
|
@@ -94,6 +94,21 @@ outs, see the documentation at the [FeedWordPress project homepage][].
|
|
94 |
|
95 |
== Changelog ==
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
= 2011.1018 =
|
98 |
|
99 |
* HTTP BASIC AND DIGEST AUTHENTICATION SUPPORT: FeedWordPress now offers
|
4 |
Tags: syndication, aggregation, feed, atom, rss
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.2.1
|
7 |
+
Stable tag: 2011.1019
|
8 |
|
9 |
FeedWordPress syndicates content from feeds you choose into your WordPress weblog.
|
10 |
|
94 |
|
95 |
== Changelog ==
|
96 |
|
97 |
+
= 2011.1019 =
|
98 |
+
|
99 |
+
* BUGFIX: "THERE ARE NO HTTP TRANSPORTS AVAILABLE" ERROR FIXED: The initial
|
100 |
+
support for HTTP Basic and Digest authentication in version 2011.1018
|
101 |
+
contained a bug that could cause HTTP requests for feeds or for other
|
102 |
+
WordPress resources to break down if you do not have the PHP curl module
|
103 |
+
installed. This bug has been fixed, and these errors should no longer
|
104 |
+
appear.
|
105 |
+
|
106 |
+
* IMPROVED HTTP AUTHENTICATION SUPPORT: In addition, the HTTP Authentication
|
107 |
+
support in FeedWordPress has been extended, to ensure that Basic
|
108 |
+
authentication is available in many web host configurations, and to allow
|
109 |
+
you to add a username and password for a feed immediately when you
|
110 |
+
subscribe to it.
|
111 |
+
|
112 |
= 2011.1018 =
|
113 |
|
114 |
* HTTP BASIC AND DIGEST AUTHENTICATION SUPPORT: FeedWordPress now offers
|