| @@ -2,13 +2,13 @@ | ||
| 2 | 2 | /* |
| 3 | 3 | Plugin Name: FeedWordPress |
| 4 | 4 | Plugin URI: http://projects.radgeek.com/feedwordpress |
| 5 | 5 | Description: simple and flexible Atom/RSS syndication for WordPress |
| 6 | -Version: 2008.1214 | |
| 6 | +Version: 2008.1101 | |
| 7 | 7 | Author: Charles Johnson |
| 8 | 8 | Author URI: http://radgeek.com/ |
| 9 | 9 | License: GPL |
| 10 | -Last modified: 2008-12-14 4:29pm PST | |
| 10 | +Last modified: 2008-11-01 1:13pm PDT | |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | # This uses code derived from: |
| 14 | 14 | # - wp-rss-aggregate.php by Kellan Elliot-McCrea <kellan@protest.net> |
| @@ -15,22 +15,20 @@ | ||
| 15 | 15 | # - HTTP Navigator 2 by Keyvan Minoukadeh <keyvan@k1m.com> |
| 16 | 16 | # - Ultra-Liberal Feed Finder by Mark Pilgrim <mark@diveintomark.org> |
| 17 | 17 | # according to the terms of the GNU General Public License. |
| 18 | 18 | # |
| 19 | -# INSTALLATION: see readme.txt or <http://projects.radgeek.com/install> | |
| 19 | +# INSTALLATION: see README.text or <http://projects.radgeek.com/install> | |
| 20 | 20 | # |
| 21 | 21 | # USAGE: once FeedWordPress is installed, you manage just about everything from |
| 22 | -# the WordPress Dashboard, under the Syndication menu. To ensure that fresh | |
| 23 | -# content is added as it becomes available, you can convince your contributors | |
| 24 | -# to put your XML-RPC URI (if WordPress is installed at | |
| 22 | +# the WordPress Dashboard, under Options --> Syndication or Links --> Syndicated | |
| 23 | +# To ensure that fresh content is added as it becomes available, get your | |
| 24 | +# contributors to put your XML-RPC URI (if WordPress is installed at | |
| 25 | 25 | # <http://www.zyx.com/blog>, XML-RPC requests should be sent to |
| 26 | -# <http://www.zyx.com/blog/xmlrpc.php>), or update manually under the | |
| 27 | -# Syndication menu, or set up automatic updates under Syndication --> Settings, | |
| 28 | -# or use a cron job. | |
| 26 | +# <http://www.zyx.com/blog/xmlrpc.php>), or see `update-feeds.php` | |
| 29 | 27 | |
| 30 | 28 | # -- Don't change these unless you know what you're doing... |
| 31 | 29 | |
| 32 | -define ('FEEDWORDPRESS_VERSION', '2008.1214'); | |
| 30 | +define ('FEEDWORDPRESS_VERSION', '2008.1101'); | |
| 33 | 31 | define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact'); |
| 34 | 32 | define ('DEFAULT_SYNDICATION_CATEGORY', 'Contributors'); |
| 35 | 33 | |
| 36 | 34 | define ('FEEDWORDPRESS_DEBUG', false); |
| @@ -41,15 +39,13 @@ | ||
| 41 | 39 | define ('FEEDVALIDATOR_URI', 'http://feedvalidator.org/check.cgi'); |
| 42 | 40 | |
| 43 | 41 | define ('FEEDWORDPRESS_FRESHNESS_INTERVAL', 10*60); // Every ten minutes |
| 44 | 42 | |
| 45 | -define ('FWP_SCHEMA_HAS_USERMETA', 2966); | |
| 46 | 43 | define ('FWP_SCHEMA_20', 3308); // Database schema # for WP 2.0 |
| 47 | 44 | define ('FWP_SCHEMA_21', 4772); // Database schema # for WP 2.1 |
| 48 | 45 | define ('FWP_SCHEMA_23', 5495); // Database schema # for WP 2.3 |
| 49 | 46 | define ('FWP_SCHEMA_25', 7558); // Database schema # for WP 2.5 |
| 50 | 47 | define ('FWP_SCHEMA_26', 8201); // Database schema # for WP 2.6 |
| 51 | -define ('FWP_SCHEMA_27', 9872); // Database schema # for WP 2.7 | |
| 52 | 48 | |
| 53 | 49 | if (FEEDWORDPRESS_DEBUG) : |
| 54 | 50 | // Help us to pick out errors, if any. |
| 55 | 51 | ini_set('error_reporting', E_ALL & ~E_NOTICE); |
| @@ -252,80 +248,17 @@ | ||
| 252 | 248 | ################################################################################ |
| 253 | 249 | |
| 254 | 250 | function is_syndicated () { return (strlen(get_syndication_feed_id()) > 0); } |
| 255 | 251 | |
| 256 | -function get_syndication_source_link ($original = NULL) { | |
| 257 | - if (is_null($original)) : $original = FeedWordPress::use_aggregator_source_data(); | |
| 258 | - endif; | |
| 252 | +function the_syndication_source_link () { echo get_syndication_source_link(); } | |
| 253 | +function get_syndication_source_link () { list($n) = get_post_custom_values('syndication_source_uri'); return $n; } | |
| 259 | 254 | |
| 260 | - if ($original) : $vals = get_post_custom_values('syndication_source_uri_original'); | |
| 261 | - else : $vals = array(); | |
| 262 | - endif; | |
| 263 | - | |
| 264 | - if (count($vals) == 0) : $vals = get_post_custom_values('syndication_source_uri'); | |
| 265 | - endif; | |
| 266 | - | |
| 267 | - if (count($vals) > 0) : $ret = $vals[0]; else : $ret = NULL; endif; | |
| 255 | +function get_syndication_source () { list($n) = get_post_custom_values('syndication_source'); return $n; } | |
| 256 | +function the_syndication_source () { echo get_syndication_source(); } | |
| 268 | 257 | |
| 269 | - return $ret; | |
| 270 | -} /* function get_syndication_source_link() */ | |
| 258 | +function get_syndication_feed () { list($u) = get_post_custom_values('syndication_feed'); return $u; } | |
| 259 | +function the_syndication_feed () { echo get_syndication_feed (); } | |
| 271 | 260 | |
| 272 | -function the_syndication_source_link ($original = NULL) { echo get_syndication_source_link($original); } | |
| 273 | - | |
| 274 | -function get_syndication_source ($original = NULL) { | |
| 275 | - if (is_null($original)) : $original = FeedWordPress::use_aggregator_source_data(); | |
| 276 | - endif; | |
| 277 | - | |
| 278 | - if ($original) : $vals = get_post_custom_values('syndication_source_original'); | |
| 279 | - else : $vals = array(); | |
| 280 | - endif; | |
| 281 | - | |
| 282 | - if (count($vals) == 0) : $vals = get_post_custom_values('syndication_source'); | |
| 283 | - endif; | |
| 284 | - | |
| 285 | - if (count($vals) > 0) : $ret = $vals[0]; else : $ret = NULL; endif; | |
| 286 | - | |
| 287 | - return $ret; | |
| 288 | -} /* function get_syndication_source() */ | |
| 289 | - | |
| 290 | -function the_syndication_source ($original = NULL) { echo get_syndication_source($original); } | |
| 291 | - | |
| 292 | -function get_syndication_feed ($original = NULL) { | |
| 293 | - if (is_null($original)) : $original = FeedWordPress::use_aggregator_source_data(); | |
| 294 | - endif; | |
| 295 | - | |
| 296 | - if ($original) : $vals = get_post_custom_values('syndication_feed_original'); | |
| 297 | - else : $vals = array(); | |
| 298 | - endif; | |
| 299 | - | |
| 300 | - if (count($vals) == 0) : $vals = get_post_custom_values('syndication_feed'); | |
| 301 | - endif; | |
| 302 | - | |
| 303 | - if (count($vals) > 0) : $ret = $vals[0]; else : $ret = NULL; endif; | |
| 304 | - | |
| 305 | - return $ret; | |
| 306 | -} /* function get_syndication_feed() */ | |
| 307 | - | |
| 308 | -function the_syndication_feed ($original = NULL) { echo get_syndication_feed ($original); } | |
| 309 | - | |
| 310 | -function get_syndication_feed_guid ($original = NULL) { | |
| 311 | - if (is_null($original)) : $original = FeedWordPress::use_aggregator_source_data(); | |
| 312 | - endif; | |
| 313 | - | |
| 314 | - if ($original) : $vals = get_post_custom_values('syndication_source_id_original'); | |
| 315 | - else : $vals = array(); | |
| 316 | - endif; | |
| 317 | - | |
| 318 | - if (count($vals) == 0) : $vals = array(get_feed_meta('feed/id')); | |
| 319 | - endif; | |
| 320 | - | |
| 321 | - if (count($vals) > 0) : $ret = $vals[0]; else : $ret = NULL; endif; | |
| 322 | - | |
| 323 | - return $ret; | |
| 324 | -} /* function get_syndication_feed_guid () */ | |
| 325 | - | |
| 326 | -function the_syndication_feed_guid ($original = NULL) { echo get_syndication_feed_guid($original); } | |
| 327 | - | |
| 328 | 261 | function get_syndication_feed_id () { list($u) = get_post_custom_values('syndication_feed_id'); return $u; } |
| 329 | 262 | function the_syndication_feed_id () { echo get_syndication_feed_id(); } |
| 330 | 263 | |
| 331 | 264 | $feedwordpress_linkcache = array (); // only load links from database once |
| @@ -390,9 +323,9 @@ | ||
| 390 | 323 | <title><?php the_syndication_source(); ?></title> |
| 391 | 324 | <link rel="alternate" type="text/html" href="<?php the_syndication_source_link(); ?>" /> |
| 392 | 325 | <link rel="self" href="<?php the_syndication_feed(); ?>" /> |
| 393 | 326 | <?php |
| 394 | - $id = get_syndication_feed_guid(); | |
| 327 | + $id = get_feed_meta('feed/id'); | |
| 395 | 328 | if (strlen($id) > 0) : |
| 396 | 329 | ?> |
| 397 | 330 | <id><?php print $id; ?></id> |
| 398 | 331 | <?php |
| @@ -424,27 +357,11 @@ | ||
| 424 | 357 | function fwp_add_pages () { |
| 425 | 358 | global $fwp_capability; |
| 426 | 359 | global $fwp_path; |
| 427 | 360 | |
| 428 | - $menu = array('Syndicated Sites', 'Syndication', $fwp_capability['manage_links'], $fwp_path.'/syndication.php', NULL); | |
| 429 | - if (fwp_test_wp_version(FWP_SCHEMA_27)) : | |
| 430 | - // add icon parameter | |
| 431 | - $menu[] = WP_PLUGIN_URL.'/'.$fwp_path.'/feedwordpress-tiny.png'; | |
| 432 | - endif; | |
| 433 | - | |
| 434 | - if (fwp_test_wp_version(FWP_SCHEMA_26)) : | |
| 435 | - $options = __('Settings'); | |
| 436 | - $longoptions = __('Syndication Settings'); | |
| 437 | - else : | |
| 438 | - $options = __('Options'); | |
| 439 | - $longoptions = __('Syndication Options'); | |
| 440 | - endif; | |
| 441 | - | |
| 442 | - call_user_func_array('add_menu_page', $menu); | |
| 443 | - add_submenu_page($fwp_path.'/syndication.php', 'Syndicated Authors', 'Authors', $fwp_capability['manage_options'], $fwp_path.'/authors.php'); | |
| 444 | - add_submenu_page($fwp_path.'/syndication.php', $longoptions, $options, $fwp_capability['manage_options'], $fwp_path.'/syndication-options.php'); | |
| 445 | - | |
| 446 | - add_options_page($longoptions, 'Syndication', $fwp_capability['manage_options'], $fwp_path.'/syndication-options.php'); | |
| 361 | + add_menu_page('Syndicated Sites', 'Syndication', $fwp_capability['manage_links'], $fwp_path.'/syndication.php'); | |
| 362 | + add_submenu_page($fwp_path.'/syndication.php', 'Syndication Options', 'Options', $fwp_capability['manage_options'], $fwp_path.'/syndication-options.php'); | |
| 363 | + add_options_page('Syndication Options', 'Syndication', $fwp_capability['manage_options'], $fwp_path.'/syndication-options.php'); | |
| 447 | 364 | } // function fwp_add_pages () */ |
| 448 | 365 | |
| 449 | 366 | ################################################################################ |
| 450 | 367 | ## fwp_hold_pings() and fwp_release_pings(): Outbound XML-RPC ping reform #### |
| @@ -600,9 +517,9 @@ | ||
| 600 | 517 | # |
| 601 | 518 | # * Updates to existing posts since the last poll are mirrored in the |
| 602 | 519 | # WordPress store. |
| 603 | 520 | # |
| 604 | - function update ($uri = null, $crash_ts = null) { | |
| 521 | + function update ($uri = null) { | |
| 605 | 522 | global $wpdb; |
| 606 | 523 | |
| 607 | 524 | if (FeedWordPress::needs_upgrade()) : // Will make duplicate posts if we don't hold off |
| 608 | 525 | return NULL; |
| @@ -615,28 +532,11 @@ | ||
| 615 | 532 | endif; |
| 616 | 533 | |
| 617 | 534 | do_action('feedwordpress_update', $uri); |
| 618 | 535 | |
| 619 | - if (is_null($crash_ts)) : | |
| 620 | - $crash_dt = (int) get_option('feedwordpress_update_time_limit'); | |
| 621 | - if ($crash_dt > 0) : | |
| 622 | - $crash_ts = time() + $crash_dt; | |
| 623 | - else : | |
| 624 | - $crash_ts = NULL; | |
| 625 | - endif; | |
| 626 | - endif; | |
| 627 | - | |
| 628 | - // Randomize order for load balancing purposes | |
| 629 | - $feed_set = $this->feeds; | |
| 630 | - shuffle($feed_set); | |
| 631 | - | |
| 632 | 536 | // Loop through and check for new posts |
| 633 | 537 | $delta = NULL; |
| 634 | - foreach ($feed_set as $feed) : | |
| 635 | - if (!is_null($crash_ts) and (time() > $crash_ts)) : // Check whether we've exceeded the time limit | |
| 636 | - break; | |
| 637 | - endif; | |
| 638 | - | |
| 538 | + foreach ($this->feeds as $feed) : | |
| 639 | 539 | $pinged_that = (is_null($uri) or in_array($uri, array($feed->uri(), $feed->homepage()))); |
| 640 | 540 | |
| 641 | 541 | if (!is_null($uri)) : // A site-specific ping always updates |
| 642 | 542 | $timely = true; |
| @@ -649,12 +549,9 @@ | ||
| 649 | 549 | endif; |
| 650 | 550 | |
| 651 | 551 | if ($pinged_that and $timely) : |
| 652 | 552 | do_action('feedwordpress_check_feed', $feed->settings); |
| 653 | - $start_ts = time(); | |
| 654 | - $added = $feed->poll($crash_ts); | |
| 655 | - do_action('feedwordpress_check_feed_complete', $feed->settings, $added, time() - $start_ts); | |
| 656 | - | |
| 553 | + $added = $feed->poll(); | |
| 657 | 554 | if (isset($added['new'])) : $delta['new'] += $added['new']; endif; |
| 658 | 555 | if (isset($added['updated'])) : $delta['updated'] += $added['updated']; endif; |
| 659 | 556 | endif; |
| 660 | 557 | endforeach; |
| @@ -712,9 +609,9 @@ | ||
| 712 | 609 | if (function_exists('wp_insert_link')) { // WordPress 2.x |
| 713 | 610 | $link_id = wp_insert_link(array( |
| 714 | 611 | "link_name" => $name, |
| 715 | 612 | "link_url" => $uri, |
| 716 | - "link_category" => (fwp_test_wp_version(0, FWP_SCHEMA_21) ? $cat_id : array($cat_id)), | |
| 613 | + "link_category" => array($cat_id), | |
| 717 | 614 | "link_rss" => $rss |
| 718 | 615 | )); |
| 719 | 616 | } else { // WordPress 1.5.x |
| 720 | 617 | $result = $wpdb->query(" |
| @@ -749,33 +646,8 @@ | ||
| 749 | 646 | |
| 750 | 647 | return $ret; |
| 751 | 648 | } // function FeedWordPress::on_unfamiliar() |
| 752 | 649 | |
| 753 | - function null_email_set () { | |
| 754 | - $base = get_option('feedwordpress_null_email_set'); | |
| 755 | - | |
| 756 | - if ($base===false) : | |
| 757 | - $ret = array('noreply@blogger.com'); // default | |
| 758 | - else : | |
| 759 | - $ret = array_map('strtolower', | |
| 760 | - array_map('trim', explode("\n", $base))); | |
| 761 | - endif; | |
| 762 | - $ret = apply_filters('syndicated_item_author_null_email_set', $ret); | |
| 763 | - return $ret; | |
| 764 | - | |
| 765 | - } /* FeedWordPress::null_email_set () */ | |
| 766 | - | |
| 767 | - function is_null_email ($email) { | |
| 768 | - $ret = in_array(strtolower(trim($email)), FeedWordPress::null_email_set()); | |
| 769 | - $ret = apply_filters('syndicated_item_author_is_null_email', $ret, $email); | |
| 770 | - return $ret; | |
| 771 | - } /* FeedWordPress::is_null_email () */ | |
| 772 | - | |
| 773 | - function use_aggregator_source_data () { | |
| 774 | - $ret = get_option('feedwordpress_use_aggregator_source_data'); | |
| 775 | - return apply_filters('syndicated_post_use_aggregator_source_data', ($ret=='yes')); | |
| 776 | - } | |
| 777 | - | |
| 778 | 650 | function syndicated_links () { |
| 779 | 651 | $contributors = FeedWordPress::link_category_id(); |
| 780 | 652 | if (function_exists('get_bookmarks')) : |
| 781 | 653 | $links = get_bookmarks(array("category" => $contributors)); |
| @@ -818,12 +690,12 @@ | ||
| 818 | 690 | if (function_exists('wp_insert_term')) : |
| 819 | 691 | $term = wp_insert_term($cat, 'link_category'); |
| 820 | 692 | $cat_id = $term['term_id']; |
| 821 | 693 | // WordPress 2.1, 2.2 category API. By the way, why the fuck is this API function only available in a wp-admin module? |
| 822 | - elseif (function_exists('wp_insert_category') and !fwp_test_wp_version(FWP_SCHEMA_20, FWP_SCHEMA_21)) : | |
| 694 | + elseif (function_exists('wp_insert_category')) : | |
| 823 | 695 | $cat_id = wp_insert_category(array('cat_name' => $cat)); |
| 824 | 696 | // WordPress 1.5 and 2.0.x |
| 825 | - elseif (fwp_test_wp_version(0, FWP_SCHEMA_21)) : | |
| 697 | + elseif (!isset($wp_db_version) or $wp_db_version < FWP_SCHEMA_21) : | |
| 826 | 698 | $result = $wpdb->query(" |
| 827 | 699 | INSERT INTO $wpdb->linkcategories |
| 828 | 700 | SET |
| 829 | 701 | cat_id = 0, |
| @@ -933,16 +805,8 @@ | ||
| 933 | 805 | endswitch; |
| 934 | 806 | echo "<p>Upgrade complete. FeedWordPress is now ready to use again.</p>"; |
| 935 | 807 | } /* FeedWordPress::upgrade_database() */ |
| 936 | 808 | |
| 937 | - function create_guid_index () { | |
| 938 | - global $wpdb; | |
| 939 | - | |
| 940 | - $wpdb->query(" | |
| 941 | - CREATE INDEX {$wpdb->posts}_guid_idx ON {$wpdb->posts}(guid) | |
| 942 | - "); | |
| 943 | - } /* FeedWordPress::create_guid_index () */ | |
| 944 | - | |
| 945 | 809 | # Utility functions for handling text settings |
| 946 | 810 | function negative ($f, $setting) { |
| 947 | 811 | $nego = array ('n', 'no', 'f', 'false'); |
| 948 | 812 | return (isset($f[$setting]) and in_array(strtolower($f[$setting]), $nego)); |
| @@ -967,14 +831,8 @@ | ||
| 967 | 831 | echo "\n"; |
| 968 | 832 | echo $varname.": "; var_dump($var); echo "\n"; |
| 969 | 833 | die; |
| 970 | 834 | } |
| 971 | - | |
| 972 | - function noncritical_bug ($varname, $var, $line) { | |
| 973 | - if (FEEDWORDPRESS_DEBUG) : // halt only when we are doing debugging | |
| 974 | - FeedWordPress::critical_bug($varname, $var, $line); | |
| 975 | - endif; | |
| 976 | - } | |
| 977 | 835 | } // class FeedWordPress |
| 978 | 836 | |
| 979 | 837 | class SyndicatedPost { |
| 980 | 838 | var $item = null; |
| @@ -1095,26 +953,12 @@ | ||
| 1095 | 953 | // In case you want to point back to the blog this was syndicated from |
| 1096 | 954 | if (isset($this->feed->channel['title'])) : |
| 1097 | 955 | $this->post['meta']['syndication_source'] = apply_filters('syndicated_item_source_title', $this->feed->channel['title'], $this); |
| 1098 | 956 | endif; |
| 1099 | - | |
| 1100 | 957 | if (isset($this->feed->channel['link'])) : |
| 1101 | 958 | $this->post['meta']['syndication_source_uri'] = apply_filters('syndicated_item_source_link', $this->feed->channel['link'], $this); |
| 1102 | 959 | endif; |
| 1103 | 960 | |
| 1104 | - // Make use of atom:source data, if present in an aggregated feed | |
| 1105 | - if (isset($this->item['source_title'])) : | |
| 1106 | - $this->post['meta']['syndication_source_original'] = $this->item['source_title']; | |
| 1107 | - endif; | |
| 1108 | - | |
| 1109 | - if (isset($this->item['source_link'])) : | |
| 1110 | - $this->post['meta']['syndication_source_uri_original'] = $this->item['source_link']; | |
| 1111 | - endif; | |
| 1112 | - | |
| 1113 | - if (isset($this->item['source_id'])) : | |
| 1114 | - $this->post['meta']['syndication_source_id_original'] = $this->item['source_id']; | |
| 1115 | - endif; | |
| 1116 | - | |
| 1117 | 961 | // Store information on human-readable and machine-readable comment URIs |
| 1118 | 962 | if (isset($this->item['comments'])) : |
| 1119 | 963 | $this->post['meta']['rss:comments'] = apply_filters('syndicated_item_comments', $this->item['comments']); |
| 1120 | 964 | endif; |
| @@ -1125,12 +969,8 @@ | ||
| 1125 | 969 | // Store information to identify the feed that this came from |
| 1126 | 970 | $this->post['meta']['syndication_feed'] = $this->feedmeta['link/uri']; |
| 1127 | 971 | $this->post['meta']['syndication_feed_id'] = $this->feedmeta['link/id']; |
| 1128 | 972 | |
| 1129 | - if (isset($this->item['source_link_self'])) : | |
| 1130 | - $this->post['meta']['syndication_feed_original'] = $this->item['source_link_self']; | |
| 1131 | - endif; | |
| 1132 | - | |
| 1133 | 973 | // In case you want to know the external permalink... |
| 1134 | 974 | $this->post['meta']['syndication_permalink'] = apply_filters('syndicated_item_link', $this->item['link']); |
| 1135 | 975 | |
| 1136 | 976 | // Store a hash of the post content for checking whether something needs to be updated |
| @@ -1171,9 +1011,9 @@ | ||
| 1171 | 1011 | |
| 1172 | 1012 | // Tags: start with default tags, if any |
| 1173 | 1013 | $ft = get_option("feedwordpress_syndication_tags"); |
| 1174 | 1014 | if ($ft) : |
| 1175 | - $this->post['tags_input'] = explode(FEEDWORDPRESS_CAT_SEPARATOR, $ft); | |
| 1015 | + $this->post['tags_input'] = explode('FEEDWORDPRESS_CAT_SEPARATOR', $ft); | |
| 1176 | 1016 | else : |
| 1177 | 1017 | $this->post['tags_input'] = array(); |
| 1178 | 1018 | endif; |
| 1179 | 1019 | |
| @@ -1609,9 +1449,9 @@ | ||
| 1609 | 1449 | |
| 1610 | 1450 | // SyndicatedPost::author_id (): get the ID for an author name from |
| 1611 | 1451 | // the feed. Create the author if necessary. |
| 1612 | 1452 | function author_id ($unfamiliar_author = 'create') { |
| 1613 | - global $wpdb; | |
| 1453 | + global $wpdb, $wp_db_version; // test for WordPress 2.0 database schema | |
| 1614 | 1454 | |
| 1615 | 1455 | $a = $this->author(); |
| 1616 | 1456 | $author = $a['name']; |
| 1617 | 1457 | $email = $a['email']; |
| @@ -1616,15 +1456,8 @@ | ||
| 1616 | 1456 | $author = $a['name']; |
| 1617 | 1457 | $email = $a['email']; |
| 1618 | 1458 | $url = $a['uri']; |
| 1619 | 1459 | |
| 1620 | - $match_author_by_email = !('yes' == get_option("feedwordpress_do_not_match_author_by_email")); | |
| 1621 | - if ($match_author_by_email and !FeedWordPress::is_null_email($email)) : | |
| 1622 | - $test_email = $email; | |
| 1623 | - else : | |
| 1624 | - $test_email = NULL; | |
| 1625 | - endif; | |
| 1626 | - | |
| 1627 | 1460 | // Never can be too careful... |
| 1628 | 1461 | $login = sanitize_user($author, /*strict=*/ true); |
| 1629 | 1462 | $login = apply_filters('pre_user_login', $login); |
| 1630 | 1463 | |
| @@ -1633,9 +1466,8 @@ | ||
| 1633 | 1466 | |
| 1634 | 1467 | $reg_author = $wpdb->escape(preg_quote($author)); |
| 1635 | 1468 | $author = $wpdb->escape($author); |
| 1636 | 1469 | $email = $wpdb->escape($email); |
| 1637 | - $test_email = $wpdb->escape($test_email); | |
| 1638 | 1470 | $url = $wpdb->escape($url); |
| 1639 | 1471 | |
| 1640 | 1472 | // Check for an existing author rule.... |
| 1641 | 1473 | if (isset($this->link->settings['map authors']['name'][strtolower(trim($author))])) : |
| @@ -1654,10 +1486,34 @@ | ||
| 1654 | 1486 | |
| 1655 | 1487 | else : |
| 1656 | 1488 | // Check the database for an existing author record that might fit |
| 1657 | 1489 | |
| 1490 | + #-- WordPress 1.5.x | |
| 1491 | + if (!isset($wp_db_version)) : | |
| 1492 | + $id = $wpdb->get_var( | |
| 1493 | + "SELECT ID from $wpdb->users | |
| 1494 | + WHERE | |
| 1495 | + TRIM(LCASE(user_login)) = TRIM(LCASE('$login')) OR | |
| 1496 | + ( | |
| 1497 | + LENGTH(TRIM(LCASE(user_email))) > 0 | |
| 1498 | + AND TRIM(LCASE(user_email)) = TRIM(LCASE('$email')) | |
| 1499 | + ) OR | |
| 1500 | + TRIM(LCASE(user_firstname)) = TRIM(LCASE('$author')) OR | |
| 1501 | + TRIM(LCASE(user_nickname)) = TRIM(LCASE('$author')) OR | |
| 1502 | + TRIM(LCASE(user_nicename)) = TRIM(LCASE('$nice_author')) OR | |
| 1503 | + TRIM(LCASE(user_description)) = TRIM(LCASE('$author')) OR | |
| 1504 | + ( | |
| 1505 | + LOWER(user_description) | |
| 1506 | + RLIKE CONCAT( | |
| 1507 | + '(^|\\n)a\\.?k\\.?a\\.?( |\\t)*:?( |\\t)*', | |
| 1508 | + LCASE('$reg_author'), | |
| 1509 | + '( |\\t|\\r)*(\\n|\$)' | |
| 1510 | + ) | |
| 1511 | + ) | |
| 1512 | + "); | |
| 1513 | + | |
| 1658 | 1514 | #-- WordPress 2.0+ |
| 1659 | - if (fwp_test_wp_version(FWP_SCHEMA_HAS_USERMETA)) : | |
| 1515 | + elseif ($wp_db_version >= 2966) : | |
| 1660 | 1516 | |
| 1661 | 1517 | // First try the user core data table. |
| 1662 | 1518 | $id = $wpdb->get_var( |
| 1663 | 1519 | "SELECT ID FROM $wpdb->users |
| @@ -1664,9 +1520,9 @@ | ||
| 1664 | 1520 | WHERE |
| 1665 | 1521 | TRIM(LCASE(user_login)) = TRIM(LCASE('$login')) |
| 1666 | 1522 | OR ( |
| 1667 | 1523 | LENGTH(TRIM(LCASE(user_email))) > 0 |
| 1668 | - AND TRIM(LCASE(user_email)) = TRIM(LCASE('$test_email')) | |
| 1524 | + AND TRIM(LCASE(user_email)) = TRIM(LCASE('$email')) | |
| 1669 | 1525 | ) |
| 1670 | 1526 | OR TRIM(LCASE(user_nicename)) = TRIM(LCASE('$nice_author')) |
| 1671 | 1527 | "); |
| 1672 | 1528 | |
| @@ -1686,33 +1542,8 @@ | ||
| 1686 | 1542 | ) |
| 1687 | 1543 | ) |
| 1688 | 1544 | "); |
| 1689 | 1545 | endif; |
| 1690 | - | |
| 1691 | - #-- WordPress 1.5.x | |
| 1692 | - else : | |
| 1693 | - $id = $wpdb->get_var( | |
| 1694 | - "SELECT ID from $wpdb->users | |
| 1695 | - WHERE | |
| 1696 | - TRIM(LCASE(user_login)) = TRIM(LCASE('$login')) OR | |
| 1697 | - ( | |
| 1698 | - LENGTH(TRIM(LCASE(user_email))) > 0 | |
| 1699 | - AND TRIM(LCASE(user_email)) = TRIM(LCASE('$test_email')) | |
| 1700 | - ) OR | |
| 1701 | - TRIM(LCASE(user_firstname)) = TRIM(LCASE('$author')) OR | |
| 1702 | - TRIM(LCASE(user_nickname)) = TRIM(LCASE('$author')) OR | |
| 1703 | - TRIM(LCASE(user_nicename)) = TRIM(LCASE('$nice_author')) OR | |
| 1704 | - TRIM(LCASE(user_description)) = TRIM(LCASE('$author')) OR | |
| 1705 | - ( | |
| 1706 | - LOWER(user_description) | |
| 1707 | - RLIKE CONCAT( | |
| 1708 | - '(^|\\n)a\\.?k\\.?a\\.?( |\\t)*:?( |\\t)*', | |
| 1709 | - LCASE('$reg_author'), | |
| 1710 | - '( |\\t|\\r)*(\\n|\$)' | |
| 1711 | - ) | |
| 1712 | - ) | |
| 1713 | - "); | |
| 1714 | - | |
| 1715 | 1546 | endif; |
| 1716 | 1547 | |
| 1717 | 1548 | // ... if you don't find one, then do what you need to do |
| 1718 | 1549 | if (is_null($id)) : |
| @@ -1765,9 +1596,9 @@ | ||
| 1765 | 1596 | $cat_ids[] = $cat_id; |
| 1766 | 1597 | elseif (get_category($cat_id)) : |
| 1767 | 1598 | $cat_ids[] = $cat_id; |
| 1768 | 1599 | endif; |
| 1769 | - elseif (strlen($cat_name) > 0) : | |
| 1600 | + else : | |
| 1770 | 1601 | $esc = $wpdb->escape($cat_name); |
| 1771 | 1602 | $resc = $wpdb->escape(preg_quote($cat_name)); |
| 1772 | 1603 | |
| 1773 | 1604 | // WordPress 2.3+ |
| @@ -1789,13 +1620,9 @@ | ||
| 1789 | 1620 | elseif ('tag'==$unfamiliar_category) : |
| 1790 | 1621 | $tags[] = $cat_name; |
| 1791 | 1622 | elseif ('create'===$unfamiliar_category) : |
| 1792 | 1623 | $term = wp_insert_term($cat_name, 'category'); |
| 1793 | - if (is_wp_error($term)) : | |
| 1794 | - FeedWordPress::noncritical_bug('term insertion problem', array('cat_name' => $cat_name, 'term' => $term, 'this' => $this), __LINE__); | |
| 1795 | - else : | |
| 1796 | - $cat_ids[] = $term['term_id']; | |
| 1797 | - endif; | |
| 1624 | + $cat_ids[] = $term['term_id']; | |
| 1798 | 1625 | endif; |
| 1799 | 1626 | |
| 1800 | 1627 | // WordPress 1.5.x - 2.2.x |
| 1801 | 1628 | else : |
| @@ -2172,13 +1999,13 @@ | ||
| 2172 | 1999 | endforeach; |
| 2173 | 2000 | $this->settings['map authors'] = $ma; |
| 2174 | 2001 | endif; |
| 2175 | 2002 | endif; |
| 2176 | - } /* SyndicatedLink::SyndicatedLink () */ | |
| 2003 | + } // SyndicatedLink::SyndicatedLink () | |
| 2177 | 2004 | |
| 2178 | 2005 | function found () { |
| 2179 | 2006 | return is_object($this->link); |
| 2180 | - } /* SyndicatedLink::found () */ | |
| 2007 | + } | |
| 2181 | 2008 | |
| 2182 | 2009 | function stale () { |
| 2183 | 2010 | $stale = true; |
| 2184 | 2011 | if (isset($this->settings['update/hold']) and ($this->settings['update/hold']=='ping')) : |
| @@ -2192,25 +2019,16 @@ | ||
| 2192 | 2019 | +((int) $this->settings['update/ttl'] * 60); |
| 2193 | 2020 | $stale = (time() >= $after); |
| 2194 | 2021 | endif; |
| 2195 | 2022 | return $stale; |
| 2196 | - } /* SyndicatedLink::stale () */ | |
| 2023 | + } | |
| 2197 | 2024 | |
| 2198 | - function poll ($crash_ts = NULL) { | |
| 2025 | + function poll () { | |
| 2199 | 2026 | global $wpdb; |
| 2200 | 2027 | |
| 2201 | 2028 | $this->magpie = fetch_rss($this->link->link_rss); |
| 2202 | 2029 | $new_count = NULL; |
| 2203 | 2030 | |
| 2204 | - $resume = FeedWordPress::affirmative($this->settings, 'update/unfinished'); | |
| 2205 | - if ($resume) : | |
| 2206 | - // pick up where we left off | |
| 2207 | - $processed = array_map('trim', explode("\n", $this->settings['update/processed'])); | |
| 2208 | - else : | |
| 2209 | - // begin at the beginning | |
| 2210 | - $processed = array(); | |
| 2211 | - endif; | |
| 2212 | - | |
| 2213 | 2031 | if (is_object($this->magpie)) : |
| 2214 | 2032 | $new_count = array('new' => 0, 'updated' => 0); |
| 2215 | 2033 | |
| 2216 | 2034 | # -- Update Link metadata live from feed |
| @@ -2246,17 +2064,44 @@ | ||
| 2246 | 2064 | else : |
| 2247 | 2065 | $this->settings['update/ttl'] = rand(30, 120); // spread over time interval for staggered updates |
| 2248 | 2066 | $this->settings['update/timed'] = 'automatically'; |
| 2249 | 2067 | endif; |
| 2250 | - | |
| 2068 | + | |
| 2251 | 2069 | if (!isset($this->settings['update/hold']) or $this->settings['update/hold']!='ping') : |
| 2252 | 2070 | $this->settings['update/hold'] = 'scheduled'; |
| 2253 | 2071 | endif; |
| 2072 | + | |
| 2073 | + // Copy back without a few things that we don't want to save in the notes | |
| 2074 | + $to_notes = $this->settings; | |
| 2254 | 2075 | |
| 2255 | - $this->settings['update/unfinished'] = 'yes'; | |
| 2076 | + if (is_array($to_notes['cats'])) : | |
| 2077 | + $to_notes['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['cats']); | |
| 2078 | + endif; | |
| 2079 | + if (is_array($to_notes['tags'])) : | |
| 2080 | + $to_notes['tags'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['tags']); | |
| 2081 | + endif; | |
| 2256 | 2082 | |
| 2257 | - $update[] = "link_notes = '".$wpdb->escape($this->settings_to_notes())."'"; | |
| 2083 | + if (isset($to_notes['map authors'])) : | |
| 2084 | + $ma = array(); | |
| 2085 | + foreach ($to_notes['map authors'] as $rule_type => $author_rules) : | |
| 2086 | + foreach ($author_rules as $author_name => $author_action) : | |
| 2087 | + $ma[] = $rule_type."\n".$author_name."\n".$author_action; | |
| 2088 | + endforeach; | |
| 2089 | + endforeach; | |
| 2090 | + $to_notes['map authors'] = implode("\n\n", $ma); | |
| 2091 | + endif; | |
| 2258 | 2092 | |
| 2093 | + unset($to_notes['link/id']); unset($to_notes['link/uri']); | |
| 2094 | + unset($to_notes['link/name']); | |
| 2095 | + unset($to_notes['hardcode categories']); // Deprecated | |
| 2096 | + unset($to_notes['unfamiliar categories']); // Deprecated | |
| 2097 | + | |
| 2098 | + $notes = ''; | |
| 2099 | + foreach ($to_notes as $key => $value) : | |
| 2100 | + $notes .= $key . ": ". addcslashes($value, "\0..\37".'\\') . "\n"; | |
| 2101 | + endforeach; | |
| 2102 | + $update[] = "link_notes = '".$wpdb->escape($notes)."'"; | |
| 2103 | + | |
| 2259 | 2104 | $update_set = implode(',', $update); |
| 2260 | 2105 | |
| 2261 | 2106 | // Update the properties of the link from the feed information |
| 2262 | 2107 | $result = $wpdb->query(" |
| @@ -2265,24 +2110,14 @@ | ||
| 2265 | 2110 | WHERE link_id='$this->id' |
| 2266 | 2111 | "); |
| 2267 | 2112 | |
| 2268 | 2113 | # -- Add new posts from feed and update any updated posts |
| 2269 | - $crashed = false; | |
| 2270 | - | |
| 2271 | 2114 | if (is_array($this->magpie->items)) : |
| 2272 | 2115 | foreach ($this->magpie->items as $item) : |
| 2273 | 2116 | $post =& new SyndicatedPost($item, $this); |
| 2274 | - if (!$resume or !in_array(trim($post->guid()), $processed)) : | |
| 2275 | - $processed[] = $post->guid(); | |
| 2276 | - if (!$post->filtered()) : | |
| 2277 | - $new = $post->store(); | |
| 2278 | - if ( $new !== false ) $new_count[$new]++; | |
| 2279 | - endif; | |
| 2280 | - | |
| 2281 | - if (!is_null($crash_ts) and (time() > $crash_ts)) : | |
| 2282 | - $crashed = true; | |
| 2283 | - break; | |
| 2284 | - endif; | |
| 2117 | + if (!$post->filtered()) : | |
| 2118 | + $new = $post->store(); | |
| 2119 | + if ( $new !== false ) $new_count[$new]++; | |
| 2285 | 2120 | endif; |
| 2286 | 2121 | endforeach; |
| 2287 | 2122 | endif; |
| 2288 | 2123 | |
| @@ -2288,102 +2123,53 @@ | ||
| 2288 | 2123 | |
| 2289 | 2124 | // Copy back any changes to feed settings made in the course of updating (e.g. new author rules) |
| 2290 | 2125 | $to_notes = $this->settings; |
| 2291 | 2126 | |
| 2292 | - $this->settings['update/processed'] = $processed; | |
| 2293 | - if (!$crashed) : | |
| 2294 | - $this->settings['update/unfinished'] = 'no'; | |
| 2127 | + if (is_array($to_notes['cats'])) : | |
| 2128 | + $to_notes['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['cats']); | |
| 2295 | 2129 | endif; |
| 2130 | + if (is_array($to_notes['tags'])) : | |
| 2131 | + $to_notes['tags'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['tags']); | |
| 2132 | + endif; | |
| 2296 | 2133 | |
| 2297 | - $update_set = "link_notes = '".$wpdb->escape($this->settings_to_notes())."'"; | |
| 2134 | + if (isset($to_notes['map authors'])) : | |
| 2135 | + $ma = array(); | |
| 2136 | + foreach ($to_notes['map authors'] as $rule_type => $author_rules) : | |
| 2137 | + foreach ($author_rules as $author_name => $author_action) : | |
| 2138 | + $ma[] = $rule_type."\n".$author_name."\n".$author_action; | |
| 2139 | + endforeach; | |
| 2140 | + endforeach; | |
| 2141 | + $to_notes['map authors'] = implode("\n\n", $ma); | |
| 2142 | + endif; | |
| 2143 | + | |
| 2144 | + unset($to_notes['link/id']); unset($to_notes['link/uri']); | |
| 2145 | + unset($to_notes['link/name']); | |
| 2146 | + unset($to_notes['hardcode categories']); // Deprecated | |
| 2147 | + unset($to_notes['unfamiliar categories']); // Deprecated | |
| 2148 | + | |
| 2149 | + $notes = ''; | |
| 2150 | + foreach ($to_notes as $key => $value) : | |
| 2151 | + $notes .= $key . ": ". addcslashes($value, "\0..\37".'\\') . "\n"; | |
| 2152 | + endforeach; | |
| 2153 | + | |
| 2154 | + $update_set = "link_notes = '".$wpdb->escape($notes)."'"; | |
| 2298 | 2155 | |
| 2299 | 2156 | // Update the properties of the link from the feed information |
| 2300 | 2157 | $result = $wpdb->query(" |
| 2301 | - UPDATE $wpdb->links | |
| 2302 | - SET $update_set | |
| 2303 | - WHERE link_id='$this->id' | |
| 2158 | + UPDATE $wpdb->links | |
| 2159 | + SET $update_set | |
| 2160 | + WHERE link_id='$this->id' | |
| 2304 | 2161 | "); |
| 2305 | 2162 | endif; |
| 2306 | - | |
| 2307 | 2163 | return $new_count; |
| 2308 | 2164 | } /* SyndicatedLink::poll() */ |
| 2309 | - | |
| 2310 | - function map_name_to_new_user ($name, $newuser_name) { | |
| 2311 | - global $wpdb; | |
| 2312 | - | |
| 2313 | - if (strlen($newuser_name) > 0) : | |
| 2314 | - $userdata = array(); | |
| 2315 | - $userdata['ID'] = NULL; | |
| 2316 | - | |
| 2317 | - $userdata['user_login'] = sanitize_user($newuser_name); | |
| 2318 | - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']); | |
| 2319 | - | |
| 2320 | - $userdata['user_nicename'] = sanitize_title($newuser_name); | |
| 2321 | - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']); | |
| 2322 | - | |
| 2323 | - $userdata['display_name'] = $wpdb->escape($newuser_name); | |
| 2324 | - | |
| 2325 | - $newuser_id = wp_insert_user($userdata); | |
| 2326 | - if (is_numeric($newuser_id)) : | |
| 2327 | - if (is_null($name)) : // Unfamiliar author | |
| 2328 | - $this->settings['unfamiliar author'] = $newuser_id; | |
| 2329 | - else : | |
| 2330 | - $this->settings['map authors']['name'][$name] = $newuser_id; | |
| 2331 | - endif; | |
| 2332 | - else : | |
| 2333 | - // TODO: Add some error detection and reporting | |
| 2334 | - endif; | |
| 2335 | - else : | |
| 2336 | - // TODO: Add some error reporting | |
| 2337 | - endif; | |
| 2338 | - } /* SyndicatedLink::map_name_to_new_user () */ | |
| 2339 | - | |
| 2340 | - function settings_to_notes () { | |
| 2341 | - $to_notes = $this->settings; | |
| 2342 | - | |
| 2343 | - unset($to_notes['link/id']); // Magic setting; don't save | |
| 2344 | - unset($to_notes['link/uri']); // Magic setting; don't save | |
| 2345 | - unset($to_notes['link/name']); // Magic setting; don't save | |
| 2346 | - unset($to_notes['hardcode categories']); // Deprecated | |
| 2347 | - unset($to_notes['unfamiliar categories']); // Deprecated | |
| 2348 | - | |
| 2349 | - // Collapse array settings | |
| 2350 | - if (isset($to_notes['update/processed']) and (is_array($to_notes['update/processed']))) : | |
| 2351 | - $to_notes['update/processed'] = implode("\n", $to_notes['update/processed']); | |
| 2352 | - endif; | |
| 2353 | - | |
| 2354 | - if (is_array($to_notes['cats'])) : | |
| 2355 | - $to_notes['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['cats']); | |
| 2356 | - endif; | |
| 2357 | - if (is_array($to_notes['tags'])) : | |
| 2358 | - $to_notes['tags'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['tags']); | |
| 2359 | - endif; | |
| 2360 | - | |
| 2361 | - // Collapse the author mapping rule structure back into a flat string | |
| 2362 | - if (isset($to_notes['map authors'])) : | |
| 2363 | - $ma = array(); | |
| 2364 | - foreach ($to_notes['map authors'] as $rule_type => $author_rules) : | |
| 2365 | - foreach ($author_rules as $author_name => $author_action) : | |
| 2366 | - $ma[] = $rule_type."\n".$author_name."\n".$author_action; | |
| 2367 | - endforeach; | |
| 2368 | - endforeach; | |
| 2369 | - $to_notes['map authors'] = implode("\n\n", $ma); | |
| 2370 | - endif; | |
| 2371 | - | |
| 2372 | - $notes = ''; | |
| 2373 | - foreach ($to_notes as $key => $value) : | |
| 2374 | - $notes .= $key . ": ". addcslashes($value, "\0..\37".'\\') . "\n"; | |
| 2375 | - endforeach; | |
| 2376 | - return $notes; | |
| 2377 | - } /* SyndicatedLink::settings_to_notes () */ | |
| 2378 | - | |
| 2165 | + | |
| 2379 | 2166 | function uri () { |
| 2380 | 2167 | return (is_object($this->link) ? $this->link->link_rss : NULL); |
| 2381 | - } /* SyndicatedLink::uri () */ | |
| 2382 | - | |
| 2168 | + } | |
| 2383 | 2169 | function homepage () { |
| 2384 | 2170 | return (isset($this->settings['feed/link']) ? $this->settings['feed/link'] : NULL); |
| 2385 | - } /* SyndicatedLink::homepage () */ | |
| 2171 | + } | |
| 2386 | 2172 | |
| 2387 | 2173 | function ttl () { |
| 2388 | 2174 | if (is_object($this->magpie)) : |
| 2389 | 2175 | $channel = $this->magpie->channel; |
| @@ -2450,9 +2236,9 @@ | ||
| 2450 | 2236 | endif; |
| 2451 | 2237 | endforeach; |
| 2452 | 2238 | endif; |
| 2453 | 2239 | return $ret; |
| 2454 | - } /* SyndicatedLink::flatten_array () */ | |
| 2240 | + } // function SyndicatedLink::flatten_array () | |
| 2455 | 2241 | |
| 2456 | 2242 | function hardcode ($what) { |
| 2457 | 2243 | $default = get_option("feedwordpress_hardcode_$what"); |
| 2458 | 2244 | if ( $default === 'yes' ) : |
| @@ -2466,9 +2252,9 @@ | ||
| 2466 | 2252 | // setting is explicitly "yes" |
| 2467 | 2253 | $ret = FeedWordPress::affirmative($this->settings, "hardcode $what"); |
| 2468 | 2254 | endif; |
| 2469 | 2255 | return $ret; |
| 2470 | - } /* SyndicatedLink::hardcode () */ | |
| 2256 | + } // function SyndicatedLink::hardcode () | |
| 2471 | 2257 | |
| 2472 | 2258 | function syndicated_status ($what, $default) { |
| 2473 | 2259 | global $wpdb; |
| 2474 | 2260 | |
| @@ -2478,9 +2264,9 @@ | ||
| 2478 | 2264 | elseif (!$ret) : |
| 2479 | 2265 | $ret = $default; |
| 2480 | 2266 | endif; |
| 2481 | 2267 | return $wpdb->escape(trim(strtolower($ret))); |
| 2482 | - } /* SyndicatedLink:syndicated_status () */ | |
| 2268 | + } // function SyndicatedLink:syndicated_status () | |
| 2483 | 2269 | } // class SyndicatedLink |
| 2484 | 2270 | |
| 2485 | 2271 | ################################################################################ |
| 2486 | 2272 | ## XML-RPC HOOKS: accept XML-RPC update pings from Contributors ################ |
| @@ -2515,9 +2301,8 @@ | ||
| 2515 | 2301 | |
| 2516 | 2302 | var $verify = FALSE; |
| 2517 | 2303 | |
| 2518 | 2304 | var $_data = NULL; |
| 2519 | - var $_error = NULL; | |
| 2520 | 2305 | var $_head = NULL; |
| 2521 | 2306 | |
| 2522 | 2307 | # -- Recognition patterns |
| 2523 | 2308 | var $_feed_types = array( |
| @@ -2572,12 +2357,8 @@ | ||
| 2572 | 2357 | $this->_get($uri); |
| 2573 | 2358 | return $this->_data; |
| 2574 | 2359 | } |
| 2575 | 2360 | |
| 2576 | - function error () { | |
| 2577 | - return $this->_error; | |
| 2578 | - } | |
| 2579 | - | |
| 2580 | 2361 | function is_feed ($uri = NULL) { |
| 2581 | 2362 | $data = $this->data($uri); |
| 2582 | 2363 | |
| 2583 | 2364 | return ( |
| @@ -2596,23 +2377,23 @@ | ||
| 2596 | 2377 | if ($uri) $this->uri = $uri; |
| 2597 | 2378 | |
| 2598 | 2379 | // Is the result not yet cached? |
| 2599 | 2380 | if ($this->_cache_uri !== $this->uri) : |
| 2600 | - $headers['Connection'] = 'close'; | |
| 2601 | - $headers['Accept'] = 'application/atom+xml application/rdf+xml application/rss+xml application/xml text/html */*'; | |
| 2602 | - $headers['User-Agent'] = 'feedfinder/1.2 (compatible; PHP FeedFinder) +http://projects.radgeek.com/feedwordpress'; | |
| 2381 | + // Snoopy is an HTTP client in PHP | |
| 2382 | + $client = new Snoopy(); | |
| 2383 | + | |
| 2384 | + // Prepare headers and internal settings | |
| 2385 | + $client->rawheaders['Connection'] = 'close'; | |
| 2386 | + $client->accept = 'application/atom+xml application/rdf+xml application/rss+xml application/xml text/html */*'; | |
| 2387 | + $client->agent = 'feedfinder/1.2 (compatible; PHP FeedFinder) +http://projects.radgeek.com/feedwordpress'; | |
| 2388 | + $client->read_timeout = 25; | |
| 2389 | + | |
| 2390 | + // Fetch the HTML or feed | |
| 2391 | + @$client->fetch($this->uri); | |
| 2392 | + $this->_data = $client->results; | |
| 2603 | 2393 | |
| 2604 | - // Use function provided by MagpieRSS package | |
| 2605 | - $client = _fetch_remote_file($this->uri, $headers); | |
| 2606 | - if (isset($client->error)) : | |
| 2607 | - $this->_error = $client->error; | |
| 2608 | - else : | |
| 2609 | - $this->_error = NULL; | |
| 2610 | - endif; | |
| 2611 | - $this->_data = $client->results; | |
| 2612 | - | |
| 2613 | - // Kilroy was here | |
| 2614 | - $this->_cache_uri = $this->uri; | |
| 2394 | + // Kilroy was here | |
| 2395 | + $this->_cache_uri = $this->uri; | |
| 2615 | 2396 | endif; |
| 2616 | 2397 | } /* FeedFinder::_get () */ |
| 2617 | 2398 | |
| 2618 | 2399 | function _link_rel_feeds () { |