PluginProbe
FeedWordPress / 2008.1101
FeedWordPress v2008.1101
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
← All changes | feedwordpress.php +112 -298 2008.11052008.1101 View file →
@@ -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.1105
6 +Version: 2008.1101
7 7 Author: Charles Johnson
8 8 Author URI: http://radgeek.com/
9 9 License: GPL
10 -Last modified: 2008-11-05 4:35pm 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>
@@ -26,9 +26,9 @@
26 26 # <http://www.zyx.com/blog/xmlrpc.php>), or see `update-feeds.php`
27 27
28 28 # -- Don't change these unless you know what you're doing...
29 29
30 -define ('FEEDWORDPRESS_VERSION', '2008.1105');
30 +define ('FEEDWORDPRESS_VERSION', '2008.1101');
31 31 define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
32 32 define ('DEFAULT_SYNDICATION_CATEGORY', 'Contributors');
33 33
34 34 define ('FEEDWORDPRESS_DEBUG', false);
@@ -39,9 +39,8 @@
39 39 define ('FEEDVALIDATOR_URI', 'http://feedvalidator.org/check.cgi');
40 40
41 41 define ('FEEDWORDPRESS_FRESHNESS_INTERVAL', 10*60); // Every ten minutes
42 42
43 -define ('FWP_SCHEMA_HAS_USERMETA', 2966);
44 43 define ('FWP_SCHEMA_20', 3308); // Database schema # for WP 2.0
45 44 define ('FWP_SCHEMA_21', 4772); // Database schema # for WP 2.1
46 45 define ('FWP_SCHEMA_23', 5495); // Database schema # for WP 2.3
47 46 define ('FWP_SCHEMA_25', 7558); // Database schema # for WP 2.5
@@ -249,80 +248,17 @@
249 248 ################################################################################
250 249
251 250 function is_syndicated () { return (strlen(get_syndication_feed_id()) > 0); }
252 251
253 -function get_syndication_source_link ($original = NULL) {
254 - if (is_null($original)) : $original = FeedWordPress::use_aggregator_source_data();
255 - 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; }
256 254
257 - if ($original) : $vals = get_post_custom_values('syndication_source_uri_original');
258 - else : $vals = array();
259 - endif;
260 -
261 - if (count($vals) == 0) : $vals = get_post_custom_values('syndication_source_uri');
262 - endif;
263 -
264 - 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(); }
265 257
266 - return $ret;
267 -} /* 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 (); }
268 260
269 -function the_syndication_source_link ($original = NULL) { echo get_syndication_source_link($original); }
270 -
271 -function get_syndication_source ($original = NULL) {
272 - if (is_null($original)) : $original = FeedWordPress::use_aggregator_source_data();
273 - endif;
274 -
275 - if ($original) : $vals = get_post_custom_values('syndication_source_original');
276 - else : $vals = array();
277 - endif;
278 -
279 - if (count($vals) == 0) : $vals = get_post_custom_values('syndication_source');
280 - endif;
281 -
282 - if (count($vals) > 0) : $ret = $vals[0]; else : $ret = NULL; endif;
283 -
284 - return $ret;
285 -} /* function get_syndication_source() */
286 -
287 -function the_syndication_source ($original = NULL) { echo get_syndication_source($original); }
288 -
289 -function get_syndication_feed ($original = NULL) {
290 - if (is_null($original)) : $original = FeedWordPress::use_aggregator_source_data();
291 - endif;
292 -
293 - if ($original) : $vals = get_post_custom_values('syndication_feed_original');
294 - else : $vals = array();
295 - endif;
296 -
297 - if (count($vals) == 0) : $vals = get_post_custom_values('syndication_feed');
298 - endif;
299 -
300 - if (count($vals) > 0) : $ret = $vals[0]; else : $ret = NULL; endif;
301 -
302 - return $ret;
303 -} /* function get_syndication_feed() */
304 -
305 -function the_syndication_feed ($original = NULL) { echo get_syndication_feed ($original); }
306 -
307 -function get_syndication_feed_guid ($original = NULL) {
308 - if (is_null($original)) : $original = FeedWordPress::use_aggregator_source_data();
309 - endif;
310 -
311 - if ($original) : $vals = get_post_custom_values('syndication_source_id_original');
312 - else : $vals = array();
313 - endif;
314 -
315 - if (count($vals) == 0) : $vals = array(get_feed_meta('feed/id'));
316 - endif;
317 -
318 - if (count($vals) > 0) : $ret = $vals[0]; else : $ret = NULL; endif;
319 -
320 - return $ret;
321 -} /* function get_syndication_feed_guid () */
322 -
323 -function the_syndication_feed_guid ($original = NULL) { echo get_syndication_feed_guid($original); }
324 -
325 261 function get_syndication_feed_id () { list($u) = get_post_custom_values('syndication_feed_id'); return $u; }
326 262 function the_syndication_feed_id () { echo get_syndication_feed_id(); }
327 263
328 264 $feedwordpress_linkcache = array (); // only load links from database once
@@ -387,9 +323,9 @@
387 323 <title><?php the_syndication_source(); ?></title>
388 324 <link rel="alternate" type="text/html" href="<?php the_syndication_source_link(); ?>" />
389 325 <link rel="self" href="<?php the_syndication_feed(); ?>" />
390 326 <?php
391 - $id = get_syndication_feed_guid();
327 + $id = get_feed_meta('feed/id');
392 328 if (strlen($id) > 0) :
393 329 ?>
394 330 <id><?php print $id; ?></id>
395 331 <?php
@@ -422,9 +358,8 @@
422 358 global $fwp_capability;
423 359 global $fwp_path;
424 360
425 361 add_menu_page('Syndicated Sites', 'Syndication', $fwp_capability['manage_links'], $fwp_path.'/syndication.php');
426 - add_submenu_page($fwp_path.'/syndication.php', 'Syndicated Authors', 'Authors', $fwp_capability['manage_options'], $fwp_path.'/authors.php');
427 362 add_submenu_page($fwp_path.'/syndication.php', 'Syndication Options', 'Options', $fwp_capability['manage_options'], $fwp_path.'/syndication-options.php');
428 363 add_options_page('Syndication Options', 'Syndication', $fwp_capability['manage_options'], $fwp_path.'/syndication-options.php');
429 364 } // function fwp_add_pages () */
430 365
@@ -582,9 +517,9 @@
582 517 #
583 518 # * Updates to existing posts since the last poll are mirrored in the
584 519 # WordPress store.
585 520 #
586 - function update ($uri = null, $crash_ts = null) {
521 + function update ($uri = null) {
587 522 global $wpdb;
588 523
589 524 if (FeedWordPress::needs_upgrade()) : // Will make duplicate posts if we don't hold off
590 525 return NULL;
@@ -597,28 +532,11 @@
597 532 endif;
598 533
599 534 do_action('feedwordpress_update', $uri);
600 535
601 - if (is_null($crash_ts)) :
602 - $crash_dt = (int) get_option('feedwordpress_update_time_limit');
603 - if ($crash_dt > 0) :
604 - $crash_ts = time() + $crash_dt;
605 - else :
606 - $crash_ts = NULL;
607 - endif;
608 - endif;
609 -
610 - // Randomize order for load balancing purposes
611 - $feed_set = $this->feeds;
612 - shuffle($feed_set);
613 -
614 536 // Loop through and check for new posts
615 537 $delta = NULL;
616 - foreach ($feed_set as $feed) :
617 - if (!is_null($crash_ts) and (time() > $crash_ts)) : // Check whether we've exceeded the time limit
618 - break;
619 - endif;
620 -
538 + foreach ($this->feeds as $feed) :
621 539 $pinged_that = (is_null($uri) or in_array($uri, array($feed->uri(), $feed->homepage())));
622 540
623 541 if (!is_null($uri)) : // A site-specific ping always updates
624 542 $timely = true;
@@ -631,12 +549,9 @@
631 549 endif;
632 550
633 551 if ($pinged_that and $timely) :
634 552 do_action('feedwordpress_check_feed', $feed->settings);
635 - $start_ts = time();
636 - $added = $feed->poll($crash_ts);
637 - do_action('feedwordpress_check_feed_complete', $feed->settings, $added, time() - $start_ts);
638 -
553 + $added = $feed->poll();
639 554 if (isset($added['new'])) : $delta['new'] += $added['new']; endif;
640 555 if (isset($added['updated'])) : $delta['updated'] += $added['updated']; endif;
641 556 endif;
642 557 endforeach;
@@ -731,33 +646,8 @@
731 646
732 647 return $ret;
733 648 } // function FeedWordPress::on_unfamiliar()
734 649
735 - function null_email_set () {
736 - $base = get_option('feedwordpress_null_email_set');
737 -
738 - if ($base===false) :
739 - $ret = array('noreply@blogger.com'); // default
740 - else :
741 - $ret = array_map('strtolower',
742 - array_map('trim', explode("\n", $base)));
743 - endif;
744 - $ret = apply_filters('syndicated_item_author_null_email_set', $ret);
745 - return $ret;
746 -
747 - } /* FeedWordPress::null_email_set () */
748 -
749 - function is_null_email ($email) {
750 - $ret = in_array(strtolower(trim($email)), FeedWordPress::null_email_set());
751 - $ret = apply_filters('syndicated_item_author_is_null_email', $ret, $email);
752 - return $ret;
753 - } /* FeedWordPress::is_null_email () */
754 -
755 - function use_aggregator_source_data () {
756 - $ret = get_option('feedwordpress_use_aggregator_source_data');
757 - return apply_filters('syndicated_post_use_aggregator_source_data', ($ret=='yes'));
758 - }
759 -
760 650 function syndicated_links () {
761 651 $contributors = FeedWordPress::link_category_id();
762 652 if (function_exists('get_bookmarks')) :
763 653 $links = get_bookmarks(array("category" => $contributors));
@@ -915,16 +805,8 @@
915 805 endswitch;
916 806 echo "<p>Upgrade complete. FeedWordPress is now ready to use again.</p>";
917 807 } /* FeedWordPress::upgrade_database() */
918 808
919 - function create_guid_index () {
920 - global $wpdb;
921 -
922 - $wpdb->query("
923 - CREATE INDEX {$wpdb->posts}_guid_idx ON {$wpdb->posts}(guid)
924 - ");
925 - } /* FeedWordPress::create_guid_index () */
926 -
927 809 # Utility functions for handling text settings
928 810 function negative ($f, $setting) {
929 811 $nego = array ('n', 'no', 'f', 'false');
930 812 return (isset($f[$setting]) and in_array(strtolower($f[$setting]), $nego));
@@ -1071,26 +953,12 @@
1071 953 // In case you want to point back to the blog this was syndicated from
1072 954 if (isset($this->feed->channel['title'])) :
1073 955 $this->post['meta']['syndication_source'] = apply_filters('syndicated_item_source_title', $this->feed->channel['title'], $this);
1074 956 endif;
1075 -
1076 957 if (isset($this->feed->channel['link'])) :
1077 958 $this->post['meta']['syndication_source_uri'] = apply_filters('syndicated_item_source_link', $this->feed->channel['link'], $this);
1078 959 endif;
1079 960
1080 - // Make use of atom:source data, if present in an aggregated feed
1081 - if (isset($this->item['source_title'])) :
1082 - $this->post['meta']['syndication_source_original'] = $this->item['source_title'];
1083 - endif;
1084 -
1085 - if (isset($this->item['source_link'])) :
1086 - $this->post['meta']['syndication_source_uri_original'] = $this->item['source_link'];
1087 - endif;
1088 -
1089 - if (isset($this->item['source_id'])) :
1090 - $this->post['meta']['syndication_source_id_original'] = $this->item['source_id'];
1091 - endif;
1092 -
1093 961 // Store information on human-readable and machine-readable comment URIs
1094 962 if (isset($this->item['comments'])) :
1095 963 $this->post['meta']['rss:comments'] = apply_filters('syndicated_item_comments', $this->item['comments']);
1096 964 endif;
@@ -1101,12 +969,8 @@
1101 969 // Store information to identify the feed that this came from
1102 970 $this->post['meta']['syndication_feed'] = $this->feedmeta['link/uri'];
1103 971 $this->post['meta']['syndication_feed_id'] = $this->feedmeta['link/id'];
1104 972
1105 - if (isset($this->item['source_link_self'])) :
1106 - $this->post['meta']['syndication_feed_original'] = $this->item['source_link_self'];
1107 - endif;
1108 -
1109 973 // In case you want to know the external permalink...
1110 974 $this->post['meta']['syndication_permalink'] = apply_filters('syndicated_item_link', $this->item['link']);
1111 975
1112 976 // Store a hash of the post content for checking whether something needs to be updated
@@ -1585,9 +1449,9 @@
1585 1449
1586 1450 // SyndicatedPost::author_id (): get the ID for an author name from
1587 1451 // the feed. Create the author if necessary.
1588 1452 function author_id ($unfamiliar_author = 'create') {
1589 - global $wpdb;
1453 + global $wpdb, $wp_db_version; // test for WordPress 2.0 database schema
1590 1454
1591 1455 $a = $this->author();
1592 1456 $author = $a['name'];
1593 1457 $email = $a['email'];
@@ -1592,15 +1456,8 @@
1592 1456 $author = $a['name'];
1593 1457 $email = $a['email'];
1594 1458 $url = $a['uri'];
1595 1459
1596 - $match_author_by_email = !('yes' == get_option("feedwordpress_do_not_match_author_by_email"));
1597 - if ($match_author_by_email and !FeedWordPress::is_null_email($email)) :
1598 - $test_email = $email;
1599 - else :
1600 - $test_email = NULL;
1601 - endif;
1602 -
1603 1460 // Never can be too careful...
1604 1461 $login = sanitize_user($author, /*strict=*/ true);
1605 1462 $login = apply_filters('pre_user_login', $login);
1606 1463
@@ -1609,9 +1466,8 @@
1609 1466
1610 1467 $reg_author = $wpdb->escape(preg_quote($author));
1611 1468 $author = $wpdb->escape($author);
1612 1469 $email = $wpdb->escape($email);
1613 - $test_email = $wpdb->escape($test_email);
1614 1470 $url = $wpdb->escape($url);
1615 1471
1616 1472 // Check for an existing author rule....
1617 1473 if (isset($this->link->settings['map authors']['name'][strtolower(trim($author))])) :
@@ -1630,10 +1486,34 @@
1630 1486
1631 1487 else :
1632 1488 // Check the database for an existing author record that might fit
1633 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 +
1634 1514 #-- WordPress 2.0+
1635 - if (fwp_test_wp_version(FWP_SCHEMA_HAS_USERMETA)) :
1515 + elseif ($wp_db_version >= 2966) :
1636 1516
1637 1517 // First try the user core data table.
1638 1518 $id = $wpdb->get_var(
1639 1519 "SELECT ID FROM $wpdb->users
@@ -1640,9 +1520,9 @@
1640 1520 WHERE
1641 1521 TRIM(LCASE(user_login)) = TRIM(LCASE('$login'))
1642 1522 OR (
1643 1523 LENGTH(TRIM(LCASE(user_email))) > 0
1644 - AND TRIM(LCASE(user_email)) = TRIM(LCASE('$test_email'))
1524 + AND TRIM(LCASE(user_email)) = TRIM(LCASE('$email'))
1645 1525 )
1646 1526 OR TRIM(LCASE(user_nicename)) = TRIM(LCASE('$nice_author'))
1647 1527 ");
1648 1528
@@ -1662,33 +1542,8 @@
1662 1542 )
1663 1543 )
1664 1544 ");
1665 1545 endif;
1666 -
1667 - #-- WordPress 1.5.x
1668 - else :
1669 - $id = $wpdb->get_var(
1670 - "SELECT ID from $wpdb->users
1671 - WHERE
1672 - TRIM(LCASE(user_login)) = TRIM(LCASE('$login')) OR
1673 - (
1674 - LENGTH(TRIM(LCASE(user_email))) > 0
1675 - AND TRIM(LCASE(user_email)) = TRIM(LCASE('$test_email'))
1676 - ) OR
1677 - TRIM(LCASE(user_firstname)) = TRIM(LCASE('$author')) OR
1678 - TRIM(LCASE(user_nickname)) = TRIM(LCASE('$author')) OR
1679 - TRIM(LCASE(user_nicename)) = TRIM(LCASE('$nice_author')) OR
1680 - TRIM(LCASE(user_description)) = TRIM(LCASE('$author')) OR
1681 - (
1682 - LOWER(user_description)
1683 - RLIKE CONCAT(
1684 - '(^|\\n)a\\.?k\\.?a\\.?( |\\t)*:?( |\\t)*',
1685 - LCASE('$reg_author'),
1686 - '( |\\t|\\r)*(\\n|\$)'
1687 - )
1688 - )
1689 - ");
1690 -
1691 1546 endif;
1692 1547
1693 1548 // ... if you don't find one, then do what you need to do
1694 1549 if (is_null($id)) :
@@ -2144,13 +1999,13 @@
2144 1999 endforeach;
2145 2000 $this->settings['map authors'] = $ma;
2146 2001 endif;
2147 2002 endif;
2148 - } /* SyndicatedLink::SyndicatedLink () */
2003 + } // SyndicatedLink::SyndicatedLink ()
2149 2004
2150 2005 function found () {
2151 2006 return is_object($this->link);
2152 - } /* SyndicatedLink::found () */
2007 + }
2153 2008
2154 2009 function stale () {
2155 2010 $stale = true;
2156 2011 if (isset($this->settings['update/hold']) and ($this->settings['update/hold']=='ping')) :
@@ -2164,25 +2019,16 @@
2164 2019 +((int) $this->settings['update/ttl'] * 60);
2165 2020 $stale = (time() >= $after);
2166 2021 endif;
2167 2022 return $stale;
2168 - } /* SyndicatedLink::stale () */
2023 + }
2169 2024
2170 - function poll ($crash_ts = NULL) {
2025 + function poll () {
2171 2026 global $wpdb;
2172 2027
2173 2028 $this->magpie = fetch_rss($this->link->link_rss);
2174 2029 $new_count = NULL;
2175 2030
2176 - $resume = FeedWordPress::affirmative($this->settings, 'update/unfinished');
2177 - if ($resume) :
2178 - // pick up where we left off
2179 - $processed = array_map('trim', explode("\n", $this->settings['update/processed']));
2180 - else :
2181 - // begin at the beginning
2182 - $processed = array();
2183 - endif;
2184 -
2185 2031 if (is_object($this->magpie)) :
2186 2032 $new_count = array('new' => 0, 'updated' => 0);
2187 2033
2188 2034 # -- Update Link metadata live from feed
@@ -2218,17 +2064,44 @@
2218 2064 else :
2219 2065 $this->settings['update/ttl'] = rand(30, 120); // spread over time interval for staggered updates
2220 2066 $this->settings['update/timed'] = 'automatically';
2221 2067 endif;
2222 -
2068 +
2223 2069 if (!isset($this->settings['update/hold']) or $this->settings['update/hold']!='ping') :
2224 2070 $this->settings['update/hold'] = 'scheduled';
2225 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;
2226 2075
2227 - $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;
2228 2082
2229 - $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;
2230 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 +
2231 2104 $update_set = implode(',', $update);
2232 2105
2233 2106 // Update the properties of the link from the feed information
2234 2107 $result = $wpdb->query("
@@ -2237,24 +2110,14 @@
2237 2110 WHERE link_id='$this->id'
2238 2111 ");
2239 2112
2240 2113 # -- Add new posts from feed and update any updated posts
2241 - $crashed = false;
2242 -
2243 2114 if (is_array($this->magpie->items)) :
2244 2115 foreach ($this->magpie->items as $item) :
2245 2116 $post =& new SyndicatedPost($item, $this);
2246 - if (!$resume or !in_array(trim($post->guid()), $processed)) :
2247 - $processed[] = $post->guid();
2248 - if (!$post->filtered()) :
2249 - $new = $post->store();
2250 - if ( $new !== false ) $new_count[$new]++;
2251 - endif;
2252 -
2253 - if (!is_null($crash_ts) and (time() > $crash_ts)) :
2254 - $crashed = true;
2255 - break;
2256 - endif;
2117 + if (!$post->filtered()) :
2118 + $new = $post->store();
2119 + if ( $new !== false ) $new_count[$new]++;
2257 2120 endif;
2258 2121 endforeach;
2259 2122 endif;
2260 2123
@@ -2260,102 +2123,53 @@
2260 2123
2261 2124 // Copy back any changes to feed settings made in the course of updating (e.g. new author rules)
2262 2125 $to_notes = $this->settings;
2263 2126
2264 - $this->settings['update/processed'] = $processed;
2265 - if (!$crashed) :
2266 - $this->settings['update/unfinished'] = 'no';
2127 + if (is_array($to_notes['cats'])) :
2128 + $to_notes['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['cats']);
2267 2129 endif;
2130 + if (is_array($to_notes['tags'])) :
2131 + $to_notes['tags'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['tags']);
2132 + endif;
2268 2133
2269 - $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)."'";
2270 2155
2271 2156 // Update the properties of the link from the feed information
2272 2157 $result = $wpdb->query("
2273 - UPDATE $wpdb->links
2274 - SET $update_set
2275 - WHERE link_id='$this->id'
2158 + UPDATE $wpdb->links
2159 + SET $update_set
2160 + WHERE link_id='$this->id'
2276 2161 ");
2277 2162 endif;
2278 -
2279 2163 return $new_count;
2280 2164 } /* SyndicatedLink::poll() */
2281 -
2282 - function map_name_to_new_user ($name, $newuser_name) {
2283 - global $wpdb;
2284 -
2285 - if (strlen($newuser_name) > 0) :
2286 - $userdata = array();
2287 - $userdata['ID'] = NULL;
2288 -
2289 - $userdata['user_login'] = sanitize_user($newuser_name);
2290 - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
2291 -
2292 - $userdata['user_nicename'] = sanitize_title($newuser_name);
2293 - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
2294 -
2295 - $userdata['display_name'] = $wpdb->escape($newuser_name);
2296 -
2297 - $newuser_id = wp_insert_user($userdata);
2298 - if (is_numeric($newuser_id)) :
2299 - if (is_null($name)) : // Unfamiliar author
2300 - $this->settings['unfamiliar author'] = $newuser_id;
2301 - else :
2302 - $this->settings['map authors']['name'][$name] = $newuser_id;
2303 - endif;
2304 - else :
2305 - // TODO: Add some error detection and reporting
2306 - endif;
2307 - else :
2308 - // TODO: Add some error reporting
2309 - endif;
2310 - } /* SyndicatedLink::map_name_to_new_user () */
2311 -
2312 - function settings_to_notes () {
2313 - $to_notes = $this->settings;
2314 -
2315 - unset($to_notes['link/id']); // Magic setting; don't save
2316 - unset($to_notes['link/uri']); // Magic setting; don't save
2317 - unset($to_notes['link/name']); // Magic setting; don't save
2318 - unset($to_notes['hardcode categories']); // Deprecated
2319 - unset($to_notes['unfamiliar categories']); // Deprecated
2320 -
2321 - // Collapse array settings
2322 - if (isset($to_notes['update/processed']) and (is_array($to_notes['update/processed']))) :
2323 - $to_notes['update/processed'] = implode("\n", $to_notes['update/processed']);
2324 - endif;
2325 -
2326 - if (is_array($to_notes['cats'])) :
2327 - $to_notes['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['cats']);
2328 - endif;
2329 - if (is_array($to_notes['tags'])) :
2330 - $to_notes['tags'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['tags']);
2331 - endif;
2332 -
2333 - // Collapse the author mapping rule structure back into a flat string
2334 - if (isset($to_notes['map authors'])) :
2335 - $ma = array();
2336 - foreach ($to_notes['map authors'] as $rule_type => $author_rules) :
2337 - foreach ($author_rules as $author_name => $author_action) :
2338 - $ma[] = $rule_type."\n".$author_name."\n".$author_action;
2339 - endforeach;
2340 - endforeach;
2341 - $to_notes['map authors'] = implode("\n\n", $ma);
2342 - endif;
2343 -
2344 - $notes = '';
2345 - foreach ($to_notes as $key => $value) :
2346 - $notes .= $key . ": ". addcslashes($value, "\0..\37".'\\') . "\n";
2347 - endforeach;
2348 - return $notes;
2349 - } /* SyndicatedLink::settings_to_notes () */
2350 -
2165 +
2351 2166 function uri () {
2352 2167 return (is_object($this->link) ? $this->link->link_rss : NULL);
2353 - } /* SyndicatedLink::uri () */
2354 -
2168 + }
2355 2169 function homepage () {
2356 2170 return (isset($this->settings['feed/link']) ? $this->settings['feed/link'] : NULL);
2357 - } /* SyndicatedLink::homepage () */
2171 + }
2358 2172
2359 2173 function ttl () {
2360 2174 if (is_object($this->magpie)) :
2361 2175 $channel = $this->magpie->channel;
@@ -2422,9 +2236,9 @@
2422 2236 endif;
2423 2237 endforeach;
2424 2238 endif;
2425 2239 return $ret;
2426 - } /* SyndicatedLink::flatten_array () */
2240 + } // function SyndicatedLink::flatten_array ()
2427 2241
2428 2242 function hardcode ($what) {
2429 2243 $default = get_option("feedwordpress_hardcode_$what");
2430 2244 if ( $default === 'yes' ) :
@@ -2438,9 +2252,9 @@
2438 2252 // setting is explicitly "yes"
2439 2253 $ret = FeedWordPress::affirmative($this->settings, "hardcode $what");
2440 2254 endif;
2441 2255 return $ret;
2442 - } /* SyndicatedLink::hardcode () */
2256 + } // function SyndicatedLink::hardcode ()
2443 2257
2444 2258 function syndicated_status ($what, $default) {
2445 2259 global $wpdb;
2446 2260
@@ -2450,9 +2264,9 @@
2450 2264 elseif (!$ret) :
2451 2265 $ret = $default;
2452 2266 endif;
2453 2267 return $wpdb->escape(trim(strtolower($ret)));
2454 - } /* SyndicatedLink:syndicated_status () */
2268 + } // function SyndicatedLink:syndicated_status ()
2455 2269 } // class SyndicatedLink
2456 2270
2457 2271 ################################################################################
2458 2272 ## XML-RPC HOOKS: accept XML-RPC update pings from Contributors ################