FeedWordPress - Version 2008.1105

Version Description

Download this release

Release Info

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

Code changes from version 2008.1101 to 2008.1105

Files changed (7) hide show
  1. ChangeLog.text +110 -8
  2. admin-ui.php +23 -1
  3. authors.php +412 -0
  4. feedwordpress.php +298 -112
  5. readme.txt +2 -2
  6. syndication-options.php +103 -18
  7. syndication.php +65 -81
ChangeLog.text CHANGED
@@ -1,6 +1,107 @@
1
  FeedWordPress Change Log
2
  ========================
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  Changes from 2008.1030 to 2008.1101
5
  -----------------------------------
6
 
@@ -12,7 +113,7 @@ Changes from 2008.1030 to 2008.1101
12
  Changes from 0.993 to 2008.1030
13
  -------------------------------
14
 
15
- * WORDPRESS 2.6 COMPATABILITY: FeedWordPress should now be compatible with
16
  WordPress 2.6, and should work more or less seamlessly with the new post
17
  revision system. A bug which caused multiple new revisions to be created
18
  for posts on certain feeds, regardless of whether or not the item had
@@ -67,7 +168,7 @@ Changes from 0.993 to 2008.1030
67
  FeedWordPress, you can now do so by changing the "Formatting Filters"
68
  setting from "Protect" to "Expose."
69
 
70
- * **`<atom:source>` ELEMENTS NOW INCLUDED IN ATOM FEED:** Atom 1.0 provides
71
  a standard method for aggregators to indicate information about the original source of
72
  a syndicated post, using the `<atom:source>` element. FeedWordPress now
73
  introduces standard `<atom:source>` elements including the title, homepage, and
@@ -147,7 +248,7 @@ Changes from 0.991 to 0.992
147
 
148
  Changes from 0.99 to 0.991
149
  --------------------------
150
- * WORDPRESS MU COMPATABILITY: FeedWordPress should now be compatible with
151
  recent releases of WordPress MU. Once FeedWordPress is made available
152
  as a plugin, each individual blog can choose to activate FeedWordPress
153
  and syndicate content from its own set of contributors.
@@ -166,10 +267,10 @@ Changes from 0.99 to 0.991
166
  incompatability has now been fixed; hopefully, authors with
167
  international characters in their names should now be handled properly.
168
 
169
- * media:content BUG IN MAGPIERSS FIXED: A bug in MagpieRSS's handling of
170
- namespaced elements has been fixed. Among other things, this bug caused
171
- items containing a Yahoo MediaRSS `<media:content>` element (such as
172
- many of the feeds produced by wordpress.com) to be represented
173
  incorrectly, with only a capital "A" where the content of the post
174
  should have been. Feeds containing `<media:content>` elements should now
175
  be syndicated correctly.
@@ -547,7 +648,8 @@ Changes from 0.95 to 0.96
547
  will have its enclosure listed in your blog's RSS 2 newsfeed.
548
 
549
  Note that enclosure support requires using the optional MagpieRSS
550
- upgrade (i.e., replacing your `wp-includes/rss-functions.php` with `OPTIONAL/wp-includes/rss-functions.php` from the FWP archive)
 
551
 
552
  * FEATURE: for completeness's sake, there is now a feed setting,
553
  `hardcode url`, that allows you to set the URI for the front page
1
  FeedWordPress Change Log
2
  ========================
3
 
4
+ Changes from 2008.1101 to 2008.1105
5
+ -----------------------------------
6
+
7
+ * INTERFACE RESTRUCTURING AND SYNDICATION --> AUTHORS PAGE: As a first
8
+ step towards modularizing and better organizing the user interface, a
9
+ new "Authors" subpage has been created under the Syndication menu, which
10
+ controls settings for syndicated authors, both at the global default
11
+ level and at level of individual syndicated feeds.
12
+
13
+ * BUG RELATED TO THE ATTRIBUTION OF POSTS TO THE WRONG AUTHOR FIXED: Some
14
+ users encountered an issue in which posts by different authors on
15
+ different blogs -- especially blogs generated by Blogger -- were
16
+ mistakenly attributed to a single author. The problem was caused by the
17
+ way in which FeedWordPress matches syndicated authors to user accounts
18
+ in the WordPress database: normally, if two feeds each list an author
19
+ with the same e-mail address, they are counted as being the same person.
20
+ Normally this works well, but it creates an issue in cases where
21
+ blogging software assigns a single anonymous e-mail address to users who
22
+ do not want their real e-mail address published. This is, for example,
23
+ what Blogger does (by giving all users a default e-mail address of
24
+ <noreply@blogger.com> if they don't want their own e-mail address
25
+ listed). FeedWordPress now allows the user to correct for this problem
26
+ with a couple of new settings under **Syndication --> Authors**, which
27
+ allow users to turn off e-mail based author matching for particular
28
+ addresses, or, if desired, to turn it off entirely. By default, e-mail
29
+ based author matching is still turned on, but disabled for a list of
30
+ known generic e-mail addresses. Right now, the "list" consists entirely
31
+ of <noreply@blogger.com>; if you know other addresses that should be
32
+ added, please [contact me](http://radgeek.com/contact) to let me know.
33
+
34
+ Please note that if you have already encountered this issue on your
35
+ blog, upgrading FeedWordPress will prevent it from re-occurring in the
36
+ future, but you still need to do two other things to fix the existing
37
+ problem on your blog.
38
+
39
+ First, for each feed where posts have been mis-attributed, you need to
40
+ change the existing author mapping rules to re-map a a syndicated
41
+ author's name to the proper target account. Go to **Syndication -->
42
+ Authors**, select the feed you want to change from the drop-down list,
43
+ and then change the settings under the "Syndicated Authors" section.
44
+ (You will probably need to select "will be assigned to a new user..." to
45
+ create a new user account with the appropriate name.)
46
+
47
+ Second, for each feed where posts have been mis-attributed, you need to
48
+ re-assign already-syndicated posts that were mis-attributed to the
49
+ correct author. You can do that from **Syndication --> Authors** by
50
+ using the author re-assignment feature, described below.
51
+
52
+ * AUTHOR RE-ASSIGNMENT FOR A PARTICULAR FEED: The author settings page
53
+ for each syndicated feed, under **Syndication --> Authors**, now
54
+ includes an section titled "Fixing mis-matched authors," which provides
55
+ an interface for re-assigning or deleting all posts attributed to a
56
+ particular author on a particular feed.
57
+
58
+ * SUPPORT FOR `<atom:source>` ELEMENT IN SYNDICATED FEEDS: Some feeds
59
+ (for example, those produced by FeedWordPress) aggregate content from
60
+ several different sources, and include information about the original
61
+ source of the post in an `<atom:source>` element. A new setting under
62
+ **Syndication --> Options** allows you to control what FeedWordPress
63
+ will report as the source of posts syndicated from aggregator feeds in
64
+ your templates and feeds: you can have FeedWordPress report that the
65
+ source of a post is the aggregator feed itself, or you can have it
66
+ report that the source of a post is the original source that the
67
+ aggregator originally syndicated the post from.
68
+
69
+ By default, FeedWordPress will report the aggregator, not the original
70
+ source, as the source of a syndicated item.
71
+
72
+ * LOAD BALANCING AND TIME LIMITING FEATURES FOR UPDATES: Some users have
73
+ encountered issues due to running up against PHP execution time limits
74
+ during the process of updating large syndicated feeds, or a very large
75
+ set of syndicated feeds. FeedWordPress now has a feature that allows you
76
+ to limit the total amount of time spent updating a feed, through the
77
+ "Time limit on updates" setting under **Syndication --> Options**. By
78
+ turning on this setting and adjusting the time limit to a low enough
79
+ figure to avoid your PHP installation's time-out setting. (PHP execution
80
+ time limits are usually in the vicinity of 30 seconds, so an update
81
+ time limit of 25 seconds or so should provide plenty of time for updates
82
+ while allowing a cushion of time for other, non-update-related functions
83
+ to do their work.)
84
+
85
+ If feed updates are interrupted by the time limit, FeedWordPress uses
86
+ some simple load balancing features to make sure that updates to other
87
+ feeds will not be blocked by the time-hogging feed, and will also make
88
+ sure that when the interrupted update is resumed, FeedWordPress will
89
+ skip ahead to resume processing items at the point at which it was
90
+ interrupted last time, so that posts further down in the feed will
91
+ eventually get processed, and not get blocked by the amount of time it
92
+ takes to process the items higher up in the feed.
93
+
94
+ * `guid` INDEX CREATION BUTTON: FeedWordPress frequently issues queries on
95
+ the `guid` column of the WordPress posts database (since it uses post
96
+ guid URIs to keep track of which posts it has syndicated). In very large
97
+ FeedWordPress installations, you can often significantly improve
98
+ performance by creating a database index on the `guid` column, but
99
+ normally you would need to poke around with MySQL or a tool like
100
+ phpMyAdmin to do this. FeedWordPress can now save you the trouble: to
101
+ create an index on the `guid` column, just go to
102
+ **Syndication --> Options**, and mash the button at the bottom of the
103
+ "Back End" section.
104
+
105
  Changes from 2008.1030 to 2008.1101
106
  -----------------------------------
107
 
113
  Changes from 0.993 to 2008.1030
114
  -------------------------------
115
 
116
+ * WORDPRESS 2.6 COMPATIBILITY: FeedWordPress should now be compatible with
117
  WordPress 2.6, and should work more or less seamlessly with the new post
118
  revision system. A bug which caused multiple new revisions to be created
119
  for posts on certain feeds, regardless of whether or not the item had
168
  FeedWordPress, you can now do so by changing the "Formatting Filters"
169
  setting from "Protect" to "Expose."
170
 
171
+ * `<atom:source>` ELEMENTS NOW INCLUDED IN ATOM FEED: Atom 1.0 provides
172
  a standard method for aggregators to indicate information about the original source of
173
  a syndicated post, using the `<atom:source>` element. FeedWordPress now
174
  introduces standard `<atom:source>` elements including the title, homepage, and
248
 
249
  Changes from 0.99 to 0.991
250
  --------------------------
251
+ * WORDPRESS MU COMPATIBILITY: FeedWordPress should now be compatible with
252
  recent releases of WordPress MU. Once FeedWordPress is made available
253
  as a plugin, each individual blog can choose to activate FeedWordPress
254
  and syndicate content from its own set of contributors.
267
  incompatability has now been fixed; hopefully, authors with
268
  international characters in their names should now be handled properly.
269
 
270
+ * `<media:content>` BUG IN MAGPIERSS FIXED: A bug in MagpieRSS's handling
271
+ of namespaced elements has been fixed. Among other things, this bug
272
+ caused items containing a Yahoo MediaRSS `<media:content>` element (such
273
+ as many of the feeds produced by wordpress.com) to be represented
274
  incorrectly, with only a capital "A" where the content of the post
275
  should have been. Feeds containing `<media:content>` elements should now
276
  be syndicated correctly.
648
  will have its enclosure listed in your blog's RSS 2 newsfeed.
649
 
650
  Note that enclosure support requires using the optional MagpieRSS
651
+ upgrade (i.e., replacing your `wp-includes/rss-functions.php` with
652
+ `OPTIONAL/wp-includes/rss-functions.php` from the FWP archive)
653
 
654
  * FEATURE: for completeness's sake, there is now a feed setting,
655
  `hardcode url`, that allows you to set the URI for the front page
admin-ui.php CHANGED
@@ -44,6 +44,25 @@ function fwp_linkedit_periodic_submit ($caption = NULL) {
44
  endif;
45
  }
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  function fwp_option_box_opener ($legend, $id, $class = "stuffbox") {
48
  global $wp_db_version;
49
  if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) :
@@ -142,9 +161,12 @@ function fwp_category_box ($checked, $object, $tags = array()) {
142
 
143
  function update_feeds_mention ($feed) {
144
  echo "<li>Updating <cite>".$feed['link/name']."</cite> from &lt;<a href=\""
145
- .$feed['link/uri']."\">".$feed['link/uri']."</a>&gt; ...</li>\n";
146
  flush();
147
  }
 
 
 
148
 
149
  function fwp_author_list () {
150
  global $wpdb;
44
  endif;
45
  }
46
 
47
+ function fwp_authors_single_submit ($link = NULL) {
48
+ global $wp_db_version;
49
+
50
+ if (fwp_test_wp_version(FWP_SCHEMA_25)) :
51
+ ?>
52
+ <div class="submitbox" id="submitlink">
53
+ <div id="previewview">
54
+ </div>
55
+ <div class="inside">
56
+ </div>
57
+
58
+ <p class="submit">
59
+ <input type="submit" name="save" value="<?php _e('Save') ?>" />
60
+ </p>
61
+ </div>
62
+ <?php
63
+ endif;
64
+ }
65
+
66
  function fwp_option_box_opener ($legend, $id, $class = "stuffbox") {
67
  global $wp_db_version;
68
  if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) :
161
 
162
  function update_feeds_mention ($feed) {
163
  echo "<li>Updating <cite>".$feed['link/name']."</cite> from &lt;<a href=\""
164
+ .$feed['link/uri']."\">".$feed['link/uri']."</a>&gt; ...";
165
  flush();
166
  }
167
+ function update_feeds_finish ($feed, $added, $dt) {
168
+ echo " completed in $dt second".(($dt==1)?'':'s')."</li>\n";
169
+ }
170
 
171
  function fwp_author_list () {
172
  global $wpdb;
authors.php ADDED
@@ -0,0 +1,412 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once(dirname(__FILE__) . '/admin-ui.php');
3
+
4
+ function fwp_authors_page () {
5
+ global $wpdb, $wp_db_version;
6
+
7
+ check_admin_referer(); // Make sure we arrived here from the Dashboard
8
+
9
+ if (isset($GLOBALS['fwp_post']['save']) or isset($GLOBALS['fwp_post']['fix_mismatch'])) :
10
+ $link_id = $_REQUEST['save_link_id'];
11
+ elseif (isset($_REQUEST['link_id'])) :
12
+ $link_id = $_REQUEST['link_id'];
13
+ else :
14
+ $link_id = NULL;
15
+ endif;
16
+
17
+ if (is_numeric($link_id) and $link_id) :
18
+ $link =& new SyndicatedLink($link_id);
19
+ else :
20
+ $link = NULL;
21
+ endif;
22
+
23
+ $mesg = null;
24
+ if (!current_user_can('manage_links')) :
25
+ die (__("Cheatin' uh ?"));
26
+ else :
27
+ if (isset($GLOBALS['fwp_post']['fix_mismatch'])) :
28
+ if ('newuser'==$GLOBALS['fwp_post']['fix_mismatch_to']) :
29
+ $newuser_name = trim($GLOBALS['fwp_post']['fix_mismatch_to_newuser']);
30
+ if (strlen($newuser_name) > 0) :
31
+ $userdata = array();
32
+ $userdata['ID'] = NULL;
33
+
34
+ $userdata['user_login'] = sanitize_user($newuser_name);
35
+ $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
36
+
37
+ $userdata['user_nicename'] = sanitize_title($newuser_name);
38
+ $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
39
+
40
+ $userdata['display_name'] = $wpdb->escape($newuser_name);
41
+
42
+ $newuser_id = wp_insert_user($userdata);
43
+ if (is_numeric($newuser_id)) :
44
+ $fix_mismatch_to_id = $newuser_id;
45
+ else :
46
+ // TODO: Add some error detection and reporting
47
+ endif;
48
+ else :
49
+ // TODO: Add some error reporting
50
+ endif;
51
+ else :
52
+ $fix_mismatch_to_id = $GLOBALS['fwp_post']['fix_mismatch_to'];
53
+ endif;
54
+ $fix_mismatch_from_id = (int) $GLOBALS['fwp_post']['fix_mismatch_from'];
55
+ if (is_numeric($fix_mismatch_from_id)) :
56
+ // Make a list of all the items by this author syndicated from this feed...
57
+ $post_ids = $wpdb->get_col("
58
+ SELECT {$wpdb->posts}.id
59
+ FROM {$wpdb->posts}, {$wpdb->postmeta}
60
+ WHERE ({$wpdb->posts}.id = {$wpdb->postmeta}.post_id)
61
+ AND {$wpdb->postmeta}.meta_key = 'syndication_feed_id'
62
+ AND {$wpdb->postmeta}.meta_value = '{$link_id}'
63
+ AND {$wpdb->posts}.post_author = '{$fix_mismatch_from_id}'
64
+ ");
65
+
66
+ if (count($post_ids) > 0) :
67
+ // Re-assign them all to the correct author
68
+ if (is_numeric($fix_mismatch_to_id)) : // re-assign to a particular user
69
+ $post_set = "(".implode(",", $post_ids).")";
70
+
71
+ // Getting the revisions too, if there are any
72
+ if (fwp_test_wp_version(FWP_SCHEMA_26)) :
73
+ $parent_in_clause = "OR {$wpdb->posts}.post_parent IN $post_set";
74
+ else :
75
+ $parent_in_clause = '';
76
+ endif;
77
+
78
+ $wpdb->query("
79
+ UPDATE {$wpdb->posts}
80
+ SET post_author='{$fix_mismatch_to_id}'
81
+ WHERE ({$wpdb->posts}.id IN $post_set
82
+ $parent_in_clause)
83
+ ");
84
+ $mesg = "Re-assigned ".count($post_ids)." post".((count($post_ids)==1)?'':'s').".";
85
+
86
+ // ... and kill them all
87
+ elseif ($fix_mismatch_to_id=='filter') :
88
+ foreach ($post_ids as $post_id) :
89
+ wp_delete_post($post_id);
90
+ endforeach;
91
+ $mesg = "Deleted ".count($post_ids)." post".((count($post_ids)==1)?'':'s').".";
92
+ endif;
93
+ else :
94
+ $mesg = "Couldn't find any posts that matched your criteria.";
95
+ endif;
96
+ endif;
97
+ elseif (isset($GLOBALS['fwp_post']['save'])) :
98
+ if (is_object($link) and $link->found()) :
99
+ $alter = array ();
100
+
101
+ // Unfamiliar author rule
102
+ if (isset($GLOBALS['fwp_post']["unfamiliar_author"])) :
103
+ if ('site-default'==$GLOBALS['fwp_post']["unfamiliar_author"]) :
104
+ unset($link->settings["unfamiliar author"]);
105
+ elseif ('newuser'==$GLOBALS['fwp_post']["unfamiliar_author"]) :
106
+ $newuser_name = trim($GLOBALS['fwp_post']["unfamiliar_author_newuser"]);
107
+ $link->map_name_to_new_user(/*name=*/ NULL, $newuser_name);
108
+ else :
109
+ $link->settings["unfamiliar author"] = $GLOBALS['fwp_post']["unfamiliar_author"];
110
+ endif;
111
+ endif;
112
+
113
+ // Handle author mapping rules
114
+ if (isset($GLOBALS['fwp_post']['author_rules_name']) and isset($GLOBALS['fwp_post']['author_rules_action'])) :
115
+ unset($link->settings['map authors']);
116
+ foreach ($GLOBALS['fwp_post']['author_rules_name'] as $key => $name) :
117
+ // Normalize for case and whitespace
118
+ $name = strtolower(trim($name));
119
+ $author_action = strtolower(trim($GLOBALS['fwp_post']['author_rules_action'][$key]));
120
+
121
+ if (strlen($name) > 0) :
122
+ if ('newuser' == $author_action) :
123
+ $newuser_name = trim($GLOBALS['fwp_post']['author_rules_newuser'][$key]);
124
+ $link->map_name_to_new_user($name, $newuser_name);
125
+ else :
126
+ $link->settings['map authors']['name'][$name] = $author_action;
127
+ endif;
128
+ endif;
129
+ endforeach;
130
+ endif;
131
+
132
+ if (isset($GLOBALS['fwp_post']['add_author_rule_name']) and isset($GLOBALS['fwp_post']['add_author_rule_action'])) :
133
+ $name = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_name']));
134
+ $author_action = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_action']));
135
+ if (strlen($name) > 0) :
136
+ if ('newuser' == $author_action) :
137
+ $newuser_name = trim($GLOBALS['fwp_post']['add_author_rule_newuser']);
138
+ $link->map_name_to_new_user($name, $newuser_name);
139
+ else :
140
+ $link->settings['map authors']['name'][$name] = $author_action;
141
+ endif;
142
+ endif;
143
+ endif;
144
+
145
+ $alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'";
146
+
147
+ $alter_set = implode(", ", $alter);
148
+
149
+ // issue update query
150
+ $result = $wpdb->query("
151
+ UPDATE $wpdb->links
152
+ SET $alter_set
153
+ WHERE link_id='$link_id'
154
+ ");
155
+ $updated_link = true;
156
+
157
+ // reload link information from DB
158
+ $link =& new SyndicatedLink($link_id);
159
+ else :
160
+ if ('newuser'==$GLOBALS['fwp_post']['unfamiliar_author']) :
161
+ $newuser_name = trim($GLOBALS['fwp_post']['unfamiliar_author_newuser']);
162
+ if (strlen($newuser_name) > 0) :
163
+ $userdata = array();
164
+ $userdata['ID'] = NULL;
165
+
166
+ $userdata['user_login'] = sanitize_user($newuser_name);
167
+ $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
168
+
169
+ $userdata['user_nicename'] = sanitize_title($newuser_name);
170
+ $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
171
+
172
+ $userdata['display_name'] = $wpdb->escape($newuser_name);
173
+
174
+ $newuser_id = wp_insert_user($userdata);
175
+ if (is_numeric($newuser_id)) :
176
+ update_option('feedwordpress_unfamiliar_author', $newuser_id);
177
+ else :
178
+ // TODO: Add some error detection and reporting
179
+ endif;
180
+ else :
181
+ // TODO: Add some error reporting
182
+ endif;
183
+ else :
184
+ update_option('feedwordpress_unfamiliar_author', $GLOBALS['fwp_post']['unfamiliar_author']);
185
+ endif;
186
+
187
+ if (isset($GLOBALS['fwp_post']['match_author_by_email']) and $GLOBALS['fwp_post']['match_author_by_email']=='yes') :
188
+ update_option('feedwordpress_do_not_match_author_by_email', 'no');
189
+ else :
190
+ update_option('feedwordpress_do_not_match_author_by_email', 'yes');
191
+ endif;
192
+
193
+ if (isset($GLOBALS['fwp_post']['null_emails'])) :
194
+ update_option('feedwordpress_null_email_set', $GLOBALS['fwp_post']['null_emails']);
195
+ endif;
196
+
197
+ $updated_link = true;
198
+ endif;
199
+ else :
200
+ $updated_link = false;
201
+ endif;
202
+
203
+ $unfamiliar = array ('create' => '','default' => '','filter' => '');
204
+
205
+ if (is_object($link) and $link->found()) :
206
+ if (is_string($link->settings["unfamiliar author"])) :
207
+ $key = $link->settings["unfamiliar author"];
208
+ else:
209
+ $key = 'site-default';
210
+ endif;
211
+ else :
212
+ $key = FeedWordPress::on_unfamiliar('author');
213
+ endif;
214
+
215
+ $unfamiliar[$key] = ' selected="selected"';
216
+
217
+ $match_author_by_email = !('yes' == get_option("feedwordpress_do_not_match_author_by_email"));
218
+ $null_emails = FeedWordPress::null_email_set();
219
+ ?>
220
+ <script type="text/javascript">
221
+ function contextual_appearance (item, appear, disappear, value, visibleStyle, checkbox) {
222
+ if (typeof(visibleStyle)=='undefined') visibleStyle = 'block';
223
+
224
+ var rollup=document.getElementById(item);
225
+ var newuser=document.getElementById(appear);
226
+ var sitewide=document.getElementById(disappear);
227
+ if (rollup) {
228
+ if ((checkbox && rollup.checked) || (!checkbox && value==rollup.value)) {
229
+ if (newuser) newuser.style.display=visibleStyle;
230
+ if (sitewide) sitewide.style.display='none';
231
+ } else {
232
+ if (newuser) newuser.style.display='none';
233
+ if (sitewide) sitewide.style.display=visibleStyle;
234
+ }
235
+ }
236
+ }
237
+ </script>
238
+
239
+ <?php if ($updated_link) : ?>
240
+ <div class="updated"><p>Syndicated author settings updated.</p></div>
241
+ <?php elseif (!is_null($mesg)) : ?>
242
+ <div class="updated"><p><?php print wp_specialchars($mesg, 1); ?></p></div>
243
+ <?php endif; ?>
244
+
245
+ <div class="wrap">
246
+ <form style="position: relative" action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
247
+ <?php if (is_numeric($link_id) and $link_id) : ?>
248
+ <input type="hidden" name="save_link_id" value="<?php echo $link_id; ?>" />
249
+ <?php else : ?>
250
+ <input type="hidden" name="save_link_id" value="*" />
251
+ <?php endif; ?>
252
+
253
+ <?php $links = FeedWordPress::syndicated_links(); ?>
254
+ <h2>Syndicated Author Settings<?php if (!is_null($link) and $link->found()) : ?>: <?php echo wp_specialchars($link->link->link_name, 1); ?><?php endif; ?></h2>
255
+ <p id="post-search">
256
+ <select name="link_id" style="max-width: 20.0em">
257
+ <option value="*"<?php if (is_null($link) or !$link->found()) : ?> selected="selected"<?php endif; ?>>- defaults for all feeds -</option>
258
+ <?php if ($links) : foreach ($links as $ddlink) : ?>
259
+ <option value="<?php print (int) $ddlink->link_id; ?>"<?php if (!is_null($link) and ($link->link->link_id==$ddlink->link_id)) : ?> selected="selected"<?php endif; ?>><?php print wp_specialchars($ddlink->link_name, 1); ?></option>
260
+ <?php endforeach; endif; ?>
261
+ </select>
262
+ <input class="button" type="submit" name="go" value="<?php _e('Go') ?> &raquo;" />
263
+ </p>
264
+
265
+ <?php if (!is_null($link) and $link->found()) : ?>
266
+ <p>These settings only affect posts syndicated from
267
+ <strong><?php echo wp_specialchars($link->link->link_name, 1); ?></strong>.</p>
268
+ <?php else : ?>
269
+ <p>These settings affect posts syndicated from any feed unless they are overridden
270
+ by settings for that specific feed.</p>
271
+ <?php endif; ?>
272
+
273
+ <h3>Assigning posts to authors</h3>
274
+ <?php
275
+ $authorlist = fwp_author_list();
276
+ ?>
277
+ <table class="form-table">
278
+ <tbody>
279
+ <tr>
280
+ <th>New authors</th>
281
+ <td><span>Authors who haven't been syndicated before</span>
282
+ <select style="max-width: 27.0em" id="unfamiliar-author" name="unfamiliar_author" onchange="contextual_appearance('unfamiliar-author', 'unfamiliar-author-newuser', 'unfamiliar-author-default', 'newuser', 'inline');">
283
+ <?php if (is_object($link) and $link->found()) : ?>
284
+ <option value="site-default"<?php print $unfamiliar['site-default']; ?>>are handled according to the default for all feeds</option>
285
+ <?php endif; ?>
286
+ <option value="create"<?php $unfamiliar['create']; ?>>will have a new author account created for them</option>
287
+ <?php foreach ($authorlist as $author_id => $author_name) : ?>
288
+ <option value="<?php echo $author_id; ?>"<?php print $unfamiliar[$author_id]; ?>>will have their posts attributed to <?php echo $author_name; ?></option>
289
+ <?php endforeach; ?>
290
+ <option value="newuser">will have their posts attributed to a new user...</option>
291
+ <option value="filter"<?php print $unfamiliar['filter'] ?>>get filtered out</option>
292
+ </select>
293
+
294
+ <span id="unfamiliar-author-newuser">named <input type="text" name="unfamiliar_author_newuser" value="" /></span></p>
295
+ </td>
296
+ </tr>
297
+
298
+ <?php
299
+ if (is_object($link) and $link->found()) :
300
+ ?>
301
+ <tr><th>Syndicated authors</th>
302
+ <td>For attributing posts by specific authors. Blank out a name to delete the rule. Fill in a new name at the bottom to create a new rule.</p>
303
+ <table style="width: 100%">
304
+ <?php
305
+ if (isset($link->settings['map authors'])) :
306
+ ?>
307
+ <?php
308
+ $i=0;
309
+ foreach ($link->settings['map authors'] as $author_rules) :
310
+ foreach ($author_rules as $author_name => $author_action) :
311
+ $i++;
312
+ ?>
313
+ <tr>
314
+ <th style="text-align: left; width: 15.0em">Posts by <input type="text" name="author_rules_name[]" value="<?php echo htmlspecialchars($author_name); ?>" size="11" /></th>
315
+ <td>
316
+ <select id="author-rules-<?php echo $i; ?>" name="author_rules_action[]" onchange="contextual_appearance('author-rules-<?php echo $i; ?>', 'author-rules-<?php echo $i; ?>-newuser', 'author-rules-<?php echo $i; ?>-default', 'newuser', 'inline');">
317
+ <?php foreach ($authorlist as $local_author_id => $local_author_name) : ?>
318
+ <option value="<?php echo $local_author_id; ?>"<?php if ($local_author_id==$author_action) : echo ' selected="selected"'; endif; ?>>are assigned to <?php echo $local_author_name; ?></option>
319
+ <?php endforeach; ?>
320
+ <option value="newuser">will be assigned to a new user...</option>
321
+ <option value="filter"<?php if ('filter'==$author_action) : echo ' selected="selected"'; endif; ?>>get filtered out</option>
322
+ </select>
323
+
324
+ <span id="author-rules-<?php echo $i; ?>-newuser">named <input type="text" name="author_rules_newuser[]" value="" /></span>
325
+ </td>
326
+ </tr>
327
+ <?php endforeach;
328
+ endforeach;
329
+ endif;
330
+ ?>
331
+
332
+ <tr>
333
+ <th style="text-align: left; width: 15.0em">Posts by <input type="text" name="add_author_rule_name" size="11" /></th>
334
+ <td>
335
+ <select id="add-author-rule" name="add_author_rule_action" onchange="contextual_appearance('add-author-rule', 'add-author-rule-newuser', 'add-author-rule-default', 'newuser', 'inline');">
336
+ <?php foreach ($authorlist as $author_id => $author_name) : ?>
337
+ <option value="<?php echo $author_id; ?>">are assigned to <?php echo $author_name; ?></option>
338
+ <?php endforeach; ?>
339
+ <option value="newuser">will be assigned to a new user...</option>
340
+ <option value="filter">get filtered out</option>
341
+ </select>
342
+
343
+ <span id="add-author-rule-newuser">named <input type="text" name="add_author_rule_newuser" value="" /></span>
344
+ </td>
345
+ </tr>
346
+ </table>
347
+ </td>
348
+ </tr>
349
+ <?php endif; ?>
350
+
351
+ <?php if (!(is_object($link) and $link->found())) : ?>
352
+ <tr>
353
+ <th scope="row">Matching Authors</th>
354
+ <td><ul style="list-style: none; margin: 0; padding: 0;">
355
+ <li><div><label><input id="match-author-by-email" type="checkbox" name="match_author_by_email" value="yes" <?php if ($match_author_by_email) : ?>checked="checked" <?php endif; ?>onchange="contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', 'block', /*checkbox=*/ true);" /> Treat syndicated authors with the same e-mail address as the same author.</label></div>
356
+ <div id="unless-null-email">
357
+ <p>Unless the e-mail address is one of the following anonymous e-mail addresses:</p>
358
+ <textarea name="null_emails" rows="3" style="width: 100%">
359
+ <?php print implode("\n", $null_emails); ?>
360
+ </textarea>
361
+ </div></li>
362
+ </ul></td>
363
+ </tr>
364
+ <?php else : ?>
365
+ <th scope="row">Fixing mis-matched authors:</th>
366
+ <td><p>Take all the posts from this feed attributed to
367
+ <select name="fix_mismatch_from">
368
+ <?php foreach ($authorlist as $author_id => $author_name) : ?>
369
+ <option value="<?php echo $author_id; ?>"><?php echo $author_name; ?></option>
370
+ <?php endforeach; ?>
371
+ </select>
372
+ and instead
373
+ <select id="fix-mismatch-to" name="fix_mismatch_to" onchange="contextual_appearance('fix-mismatch-to', 'fix-mismatch-to-newuser', null, 'newuser', 'inline');">
374
+ <?php foreach ($authorlist as $author_id => $author_name) : ?>
375
+ <option value="<?php echo $author_id; ?>">re-assign them to <?php echo $author_name; ?></option>
376
+ <?php endforeach; ?>
377
+ <option value="newuser">re-assign them to a new user...</option>
378
+ <option value="filter">delete them</option>
379
+ </select>
380
+
381
+ <span id="fix-mismatch-to-newuser">named <input type="text" name="fix_mismatch_to_newuser" value="" /></span>
382
+ <input type="submit" class="button" name="fix_mismatch" value="Fix it!" />
383
+ </td>
384
+ </td>
385
+ <?php endif; ?>
386
+ </tbody>
387
+ </table>
388
+
389
+ <script type="text/javascript">
390
+ contextual_appearance('unfamiliar-author', 'unfamiliar-author-newuser', 'unfamiliar-author-default', 'newuser', 'inline');
391
+ <?php if (is_object($link) and $link->found()) : ?>
392
+ <?php for ($j=1; $j<=$i; $j++) : ?>
393
+ contextual_appearance('author-rules-<?php echo $j; ?>', 'author-rules-<?php echo $j; ?>-newuser', 'author-rules-<?php echo $j; ?>-default', 'newuser', 'inline');
394
+ <?php endfor; ?>
395
+ contextual_appearance('add-author-rule', 'add-author-rule-newuser', 'add-author-rule-default', 'newuser', 'inline');
396
+ contextual_appearance('fix-mismatch-to', 'fix-mismatch-to-newuser', null, 'newuser', 'inline');
397
+ <?php else : ?>
398
+ contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', 'block', /*checkbox=*/ true);
399
+ <?php endif; ?>
400
+ </script>
401
+
402
+ <p class="submit">
403
+ <input type="submit" name="save" value="Save Changes" />
404
+ </p>
405
+ </form>
406
+ </div> <!-- class="wrap" -->
407
+ <?php
408
+ endif;
409
+ } /* function fwp_authors_page () */
410
+
411
+ fwp_authors_page();
412
+
feedwordpress.php CHANGED
@@ -3,11 +3,11 @@
3
  Plugin Name: FeedWordPress
4
  Plugin URI: http://projects.radgeek.com/feedwordpress
5
  Description: simple and flexible Atom/RSS syndication for WordPress
6
- Version: 2008.1101
7
  Author: Charles Johnson
8
  Author URI: http://radgeek.com/
9
  License: GPL
10
- Last modified: 2008-11-01 1:13pm PDT
11
  */
12
 
13
  # This uses code derived from:
@@ -27,7 +27,7 @@ Last modified: 2008-11-01 1:13pm PDT
27
 
28
  # -- Don't change these unless you know what you're doing...
29
 
30
- define ('FEEDWORDPRESS_VERSION', '2008.1101');
31
  define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
32
  define ('DEFAULT_SYNDICATION_CATEGORY', 'Contributors');
33
 
@@ -40,6 +40,7 @@ define ('FEEDVALIDATOR_URI', 'http://feedvalidator.org/check.cgi');
40
 
41
  define ('FEEDWORDPRESS_FRESHNESS_INTERVAL', 10*60); // Every ten minutes
42
 
 
43
  define ('FWP_SCHEMA_20', 3308); // Database schema # for WP 2.0
44
  define ('FWP_SCHEMA_21', 4772); // Database schema # for WP 2.1
45
  define ('FWP_SCHEMA_23', 5495); // Database schema # for WP 2.3
@@ -249,14 +250,77 @@ function log_feedwordpress_update_complete ($delta) {
249
 
250
  function is_syndicated () { return (strlen(get_syndication_feed_id()) > 0); }
251
 
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; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
 
255
- function get_syndication_source () { list($n) = get_post_custom_values('syndication_source'); return $n; }
256
- function the_syndication_source () { echo get_syndication_source(); }
257
 
258
- function get_syndication_feed () { list($u) = get_post_custom_values('syndication_feed'); return $u; }
259
- function the_syndication_feed () { echo get_syndication_feed (); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
 
261
  function get_syndication_feed_id () { list($u) = get_post_custom_values('syndication_feed_id'); return $u; }
262
  function the_syndication_feed_id () { echo get_syndication_feed_id(); }
@@ -324,7 +388,7 @@ function feedwordpress_item_feed_data () {
324
  <link rel="alternate" type="text/html" href="<?php the_syndication_source_link(); ?>" />
325
  <link rel="self" href="<?php the_syndication_feed(); ?>" />
326
  <?php
327
- $id = get_feed_meta('feed/id');
328
  if (strlen($id) > 0) :
329
  ?>
330
  <id><?php print $id; ?></id>
@@ -359,6 +423,7 @@ function fwp_add_pages () {
359
  global $fwp_path;
360
 
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');
364
  } // function fwp_add_pages () */
@@ -518,7 +583,7 @@ class FeedWordPress {
518
  # * Updates to existing posts since the last poll are mirrored in the
519
  # WordPress store.
520
  #
521
- function update ($uri = null) {
522
  global $wpdb;
523
 
524
  if (FeedWordPress::needs_upgrade()) : // Will make duplicate posts if we don't hold off
@@ -533,9 +598,26 @@ class FeedWordPress {
533
 
534
  do_action('feedwordpress_update', $uri);
535
 
 
 
 
 
 
 
 
 
 
 
 
 
 
536
  // Loop through and check for new posts
537
  $delta = NULL;
538
- foreach ($this->feeds as $feed) :
 
 
 
 
539
  $pinged_that = (is_null($uri) or in_array($uri, array($feed->uri(), $feed->homepage())));
540
 
541
  if (!is_null($uri)) : // A site-specific ping always updates
@@ -550,7 +632,10 @@ class FeedWordPress {
550
 
551
  if ($pinged_that and $timely) :
552
  do_action('feedwordpress_check_feed', $feed->settings);
553
- $added = $feed->poll();
 
 
 
554
  if (isset($added['new'])) : $delta['new'] += $added['new']; endif;
555
  if (isset($added['updated'])) : $delta['updated'] += $added['updated']; endif;
556
  endif;
@@ -647,6 +732,31 @@ class FeedWordPress {
647
  return $ret;
648
  } // function FeedWordPress::on_unfamiliar()
649
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
650
  function syndicated_links () {
651
  $contributors = FeedWordPress::link_category_id();
652
  if (function_exists('get_bookmarks')) :
@@ -806,6 +916,14 @@ class FeedWordPress {
806
  echo "<p>Upgrade complete. FeedWordPress is now ready to use again.</p>";
807
  } /* FeedWordPress::upgrade_database() */
808
 
 
 
 
 
 
 
 
 
809
  # Utility functions for handling text settings
810
  function negative ($f, $setting) {
811
  $nego = array ('n', 'no', 'f', 'false');
@@ -954,10 +1072,24 @@ class SyndicatedPost {
954
  if (isset($this->feed->channel['title'])) :
955
  $this->post['meta']['syndication_source'] = apply_filters('syndicated_item_source_title', $this->feed->channel['title'], $this);
956
  endif;
 
957
  if (isset($this->feed->channel['link'])) :
958
  $this->post['meta']['syndication_source_uri'] = apply_filters('syndicated_item_source_link', $this->feed->channel['link'], $this);
959
  endif;
960
 
 
 
 
 
 
 
 
 
 
 
 
 
 
961
  // Store information on human-readable and machine-readable comment URIs
962
  if (isset($this->item['comments'])) :
963
  $this->post['meta']['rss:comments'] = apply_filters('syndicated_item_comments', $this->item['comments']);
@@ -970,6 +1102,10 @@ class SyndicatedPost {
970
  $this->post['meta']['syndication_feed'] = $this->feedmeta['link/uri'];
971
  $this->post['meta']['syndication_feed_id'] = $this->feedmeta['link/id'];
972
 
 
 
 
 
973
  // In case you want to know the external permalink...
974
  $this->post['meta']['syndication_permalink'] = apply_filters('syndicated_item_link', $this->item['link']);
975
 
@@ -1450,13 +1586,20 @@ class SyndicatedPost {
1450
  // SyndicatedPost::author_id (): get the ID for an author name from
1451
  // the feed. Create the author if necessary.
1452
  function author_id ($unfamiliar_author = 'create') {
1453
- global $wpdb, $wp_db_version; // test for WordPress 2.0 database schema
1454
 
1455
  $a = $this->author();
1456
  $author = $a['name'];
1457
  $email = $a['email'];
1458
  $url = $a['uri'];
1459
 
 
 
 
 
 
 
 
1460
  // Never can be too careful...
1461
  $login = sanitize_user($author, /*strict=*/ true);
1462
  $login = apply_filters('pre_user_login', $login);
@@ -1467,6 +1610,7 @@ class SyndicatedPost {
1467
  $reg_author = $wpdb->escape(preg_quote($author));
1468
  $author = $wpdb->escape($author);
1469
  $email = $wpdb->escape($email);
 
1470
  $url = $wpdb->escape($url);
1471
 
1472
  // Check for an existing author rule....
@@ -1487,32 +1631,8 @@ class SyndicatedPost {
1487
  else :
1488
  // Check the database for an existing author record that might fit
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
-
1514
  #-- WordPress 2.0+
1515
- elseif ($wp_db_version >= 2966) :
1516
 
1517
  // First try the user core data table.
1518
  $id = $wpdb->get_var(
@@ -1521,7 +1641,7 @@ class SyndicatedPost {
1521
  TRIM(LCASE(user_login)) = TRIM(LCASE('$login'))
1522
  OR (
1523
  LENGTH(TRIM(LCASE(user_email))) > 0
1524
- AND TRIM(LCASE(user_email)) = TRIM(LCASE('$email'))
1525
  )
1526
  OR TRIM(LCASE(user_nicename)) = TRIM(LCASE('$nice_author'))
1527
  ");
@@ -1543,6 +1663,31 @@ class SyndicatedPost {
1543
  )
1544
  ");
1545
  endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1546
  endif;
1547
 
1548
  // ... if you don't find one, then do what you need to do
@@ -2000,11 +2145,11 @@ class SyndicatedLink {
2000
  $this->settings['map authors'] = $ma;
2001
  endif;
2002
  endif;
2003
- } // SyndicatedLink::SyndicatedLink ()
2004
 
2005
  function found () {
2006
  return is_object($this->link);
2007
- }
2008
 
2009
  function stale () {
2010
  $stale = true;
@@ -2020,14 +2165,23 @@ class SyndicatedLink {
2020
  $stale = (time() >= $after);
2021
  endif;
2022
  return $stale;
2023
- }
2024
 
2025
- function poll () {
2026
  global $wpdb;
2027
 
2028
  $this->magpie = fetch_rss($this->link->link_rss);
2029
  $new_count = NULL;
2030
 
 
 
 
 
 
 
 
 
 
2031
  if (is_object($this->magpie)) :
2032
  $new_count = array('new' => 0, 'updated' => 0);
2033
 
@@ -2065,42 +2219,15 @@ class SyndicatedLink {
2065
  $this->settings['update/ttl'] = rand(30, 120); // spread over time interval for staggered updates
2066
  $this->settings['update/timed'] = 'automatically';
2067
  endif;
2068
-
2069
  if (!isset($this->settings['update/hold']) or $this->settings['update/hold']!='ping') :
2070
  $this->settings['update/hold'] = 'scheduled';
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;
2075
 
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;
2082
 
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;
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
-
2104
  $update_set = implode(',', $update);
2105
 
2106
  // Update the properties of the link from the feed information
@@ -2111,12 +2238,22 @@ class SyndicatedLink {
2111
  ");
2112
 
2113
  # -- Add new posts from feed and update any updated posts
 
 
2114
  if (is_array($this->magpie->items)) :
2115
  foreach ($this->magpie->items as $item) :
2116
  $post =& new SyndicatedPost($item, $this);
2117
- if (!$post->filtered()) :
2118
- $new = $post->store();
2119
- if ( $new !== false ) $new_count[$new]++;
 
 
 
 
 
 
 
 
2120
  endif;
2121
  endforeach;
2122
  endif;
@@ -2124,51 +2261,100 @@ class SyndicatedLink {
2124
  // Copy back any changes to feed settings made in the course of updating (e.g. new author rules)
2125
  $to_notes = $this->settings;
2126
 
2127
- if (is_array($to_notes['cats'])) :
2128
- $to_notes['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['cats']);
2129
- endif;
2130
- if (is_array($to_notes['tags'])) :
2131
- $to_notes['tags'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $to_notes['tags']);
2132
- endif;
2133
-
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)."'";
2155
 
2156
  // Update the properties of the link from the feed information
2157
  $result = $wpdb->query("
2158
- UPDATE $wpdb->links
2159
- SET $update_set
2160
- WHERE link_id='$this->id'
2161
  ");
2162
  endif;
 
2163
  return $new_count;
2164
  } /* SyndicatedLink::poll() */
2165
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2166
  function uri () {
2167
  return (is_object($this->link) ? $this->link->link_rss : NULL);
2168
- }
 
2169
  function homepage () {
2170
  return (isset($this->settings['feed/link']) ? $this->settings['feed/link'] : NULL);
2171
- }
2172
 
2173
  function ttl () {
2174
  if (is_object($this->magpie)) :
@@ -2237,7 +2423,7 @@ class SyndicatedLink {
2237
  endforeach;
2238
  endif;
2239
  return $ret;
2240
- } // function SyndicatedLink::flatten_array ()
2241
 
2242
  function hardcode ($what) {
2243
  $default = get_option("feedwordpress_hardcode_$what");
@@ -2253,7 +2439,7 @@ class SyndicatedLink {
2253
  $ret = FeedWordPress::affirmative($this->settings, "hardcode $what");
2254
  endif;
2255
  return $ret;
2256
- } // function SyndicatedLink::hardcode ()
2257
 
2258
  function syndicated_status ($what, $default) {
2259
  global $wpdb;
@@ -2265,7 +2451,7 @@ class SyndicatedLink {
2265
  $ret = $default;
2266
  endif;
2267
  return $wpdb->escape(trim(strtolower($ret)));
2268
- } // function SyndicatedLink:syndicated_status ()
2269
  } // class SyndicatedLink
2270
 
2271
  ################################################################################
3
  Plugin Name: FeedWordPress
4
  Plugin URI: http://projects.radgeek.com/feedwordpress
5
  Description: simple and flexible Atom/RSS syndication for WordPress
6
+ Version: 2008.1105
7
  Author: Charles Johnson
8
  Author URI: http://radgeek.com/
9
  License: GPL
10
+ Last modified: 2008-11-05 4:35pm PST
11
  */
12
 
13
  # This uses code derived from:
27
 
28
  # -- Don't change these unless you know what you're doing...
29
 
30
+ define ('FEEDWORDPRESS_VERSION', '2008.1105');
31
  define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
32
  define ('DEFAULT_SYNDICATION_CATEGORY', 'Contributors');
33
 
40
 
41
  define ('FEEDWORDPRESS_FRESHNESS_INTERVAL', 10*60); // Every ten minutes
42
 
43
+ define ('FWP_SCHEMA_HAS_USERMETA', 2966);
44
  define ('FWP_SCHEMA_20', 3308); // Database schema # for WP 2.0
45
  define ('FWP_SCHEMA_21', 4772); // Database schema # for WP 2.1
46
  define ('FWP_SCHEMA_23', 5495); // Database schema # for WP 2.3
250
 
251
  function is_syndicated () { return (strlen(get_syndication_feed_id()) > 0); }
252
 
253
+ function get_syndication_source_link ($original = NULL) {
254
+ if (is_null($original)) : $original = FeedWordPress::use_aggregator_source_data();
255
+ endif;
256
+
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;
265
+
266
+ return $ret;
267
+ } /* function get_syndication_source_link() */
268
+
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
  function get_syndication_feed_id () { list($u) = get_post_custom_values('syndication_feed_id'); return $u; }
326
  function the_syndication_feed_id () { echo get_syndication_feed_id(); }
388
  <link rel="alternate" type="text/html" href="<?php the_syndication_source_link(); ?>" />
389
  <link rel="self" href="<?php the_syndication_feed(); ?>" />
390
  <?php
391
+ $id = get_syndication_feed_guid();
392
  if (strlen($id) > 0) :
393
  ?>
394
  <id><?php print $id; ?></id>
423
  global $fwp_path;
424
 
425
  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
  add_submenu_page($fwp_path.'/syndication.php', 'Syndication Options', 'Options', $fwp_capability['manage_options'], $fwp_path.'/syndication-options.php');
428
  add_options_page('Syndication Options', 'Syndication', $fwp_capability['manage_options'], $fwp_path.'/syndication-options.php');
429
  } // function fwp_add_pages () */
583
  # * Updates to existing posts since the last poll are mirrored in the
584
  # WordPress store.
585
  #
586
+ function update ($uri = null, $crash_ts = null) {
587
  global $wpdb;
588
 
589
  if (FeedWordPress::needs_upgrade()) : // Will make duplicate posts if we don't hold off
598
 
599
  do_action('feedwordpress_update', $uri);
600
 
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
  // Loop through and check for new posts
615
  $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
+
621
  $pinged_that = (is_null($uri) or in_array($uri, array($feed->uri(), $feed->homepage())));
622
 
623
  if (!is_null($uri)) : // A site-specific ping always updates
632
 
633
  if ($pinged_that and $timely) :
634
  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
+
639
  if (isset($added['new'])) : $delta['new'] += $added['new']; endif;
640
  if (isset($added['updated'])) : $delta['updated'] += $added['updated']; endif;
641
  endif;
732
  return $ret;
733
  } // function FeedWordPress::on_unfamiliar()
734
 
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
  function syndicated_links () {
761
  $contributors = FeedWordPress::link_category_id();
762
  if (function_exists('get_bookmarks')) :
916
  echo "<p>Upgrade complete. FeedWordPress is now ready to use again.</p>";
917
  } /* FeedWordPress::upgrade_database() */
918
 
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
  # Utility functions for handling text settings
928
  function negative ($f, $setting) {
929
  $nego = array ('n', 'no', 'f', 'false');
1072
  if (isset($this->feed->channel['title'])) :
1073
  $this->post['meta']['syndication_source'] = apply_filters('syndicated_item_source_title', $this->feed->channel['title'], $this);
1074
  endif;
1075
+
1076
  if (isset($this->feed->channel['link'])) :
1077
  $this->post['meta']['syndication_source_uri'] = apply_filters('syndicated_item_source_link', $this->feed->channel['link'], $this);
1078
  endif;
1079
 
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
  // Store information on human-readable and machine-readable comment URIs
1094
  if (isset($this->item['comments'])) :
1095
  $this->post['meta']['rss:comments'] = apply_filters('syndicated_item_comments', $this->item['comments']);
1102
  $this->post['meta']['syndication_feed'] = $this->feedmeta['link/uri'];
1103
  $this->post['meta']['syndication_feed_id'] = $this->feedmeta['link/id'];
1104
 
1105
+ if (isset($this->item['source_link_self'])) :
1106
+ $this->post['meta']['syndication_feed_original'] = $this->item['source_link_self'];
1107
+ endif;
1108
+
1109
  // In case you want to know the external permalink...
1110
  $this->post['meta']['syndication_permalink'] = apply_filters('syndicated_item_link', $this->item['link']);
1111
 
1586
  // SyndicatedPost::author_id (): get the ID for an author name from
1587
  // the feed. Create the author if necessary.
1588
  function author_id ($unfamiliar_author = 'create') {
1589
+ global $wpdb;
1590
 
1591
  $a = $this->author();
1592
  $author = $a['name'];
1593
  $email = $a['email'];
1594
  $url = $a['uri'];
1595
 
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
  // Never can be too careful...
1604
  $login = sanitize_user($author, /*strict=*/ true);
1605
  $login = apply_filters('pre_user_login', $login);
1610
  $reg_author = $wpdb->escape(preg_quote($author));
1611
  $author = $wpdb->escape($author);
1612
  $email = $wpdb->escape($email);
1613
+ $test_email = $wpdb->escape($test_email);
1614
  $url = $wpdb->escape($url);
1615
 
1616
  // Check for an existing author rule....
1631
  else :
1632
  // Check the database for an existing author record that might fit
1633
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1634
  #-- WordPress 2.0+
1635
+ if (fwp_test_wp_version(FWP_SCHEMA_HAS_USERMETA)) :
1636
 
1637
  // First try the user core data table.
1638
  $id = $wpdb->get_var(
1641
  TRIM(LCASE(user_login)) = TRIM(LCASE('$login'))
1642
  OR (
1643
  LENGTH(TRIM(LCASE(user_email))) > 0
1644
+ AND TRIM(LCASE(user_email)) = TRIM(LCASE('$test_email'))
1645
  )
1646
  OR TRIM(LCASE(user_nicename)) = TRIM(LCASE('$nice_author'))
1647
  ");
1663
  )
1664
  ");
1665
  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
  endif;
1692
 
1693
  // ... if you don't find one, then do what you need to do
2145
  $this->settings['map authors'] = $ma;
2146
  endif;
2147
  endif;
2148
+ } /* SyndicatedLink::SyndicatedLink () */
2149
 
2150
  function found () {
2151
  return is_object($this->link);
2152
+ } /* SyndicatedLink::found () */
2153
 
2154
  function stale () {
2155
  $stale = true;
2165
  $stale = (time() >= $after);
2166
  endif;
2167
  return $stale;
2168
+ } /* SyndicatedLink::stale () */
2169
 
2170
+ function poll ($crash_ts = NULL) {
2171
  global $wpdb;
2172
 
2173
  $this->magpie = fetch_rss($this->link->link_rss);
2174
  $new_count = NULL;
2175
 
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
  if (is_object($this->magpie)) :
2186
  $new_count = array('new' => 0, 'updated' => 0);
2187
 
2219
  $this->settings['update/ttl'] = rand(30, 120); // spread over time interval for staggered updates
2220
  $this->settings['update/timed'] = 'automatically';
2221
  endif;
2222
+
2223
  if (!isset($this->settings['update/hold']) or $this->settings['update/hold']!='ping') :
2224
  $this->settings['update/hold'] = 'scheduled';
2225
  endif;
 
 
 
2226
 
2227
+ $this->settings['update/unfinished'] = 'yes';
 
 
 
 
 
2228
 
2229
+ $update[] = "link_notes = '".$wpdb->escape($this->settings_to_notes())."'";
 
 
 
 
 
 
 
 
2230
 
 
 
 
 
 
 
 
 
 
 
 
2231
  $update_set = implode(',', $update);
2232
 
2233
  // Update the properties of the link from the feed information
2238
  ");
2239
 
2240
  # -- Add new posts from feed and update any updated posts
2241
+ $crashed = false;
2242
+
2243
  if (is_array($this->magpie->items)) :
2244
  foreach ($this->magpie->items as $item) :
2245
  $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;
2257
  endif;
2258
  endforeach;
2259
  endif;
2261
  // Copy back any changes to feed settings made in the course of updating (e.g. new author rules)
2262
  $to_notes = $this->settings;
2263
 
2264
+ $this->settings['update/processed'] = $processed;
2265
+ if (!$crashed) :
2266
+ $this->settings['update/unfinished'] = 'no';
 
 
 
 
 
 
 
 
 
 
 
 
2267
  endif;
2268
 
2269
+ $update_set = "link_notes = '".$wpdb->escape($this->settings_to_notes())."'";
 
 
 
 
 
 
 
 
 
 
2270
 
2271
  // Update the properties of the link from the feed information
2272
  $result = $wpdb->query("
2273
+ UPDATE $wpdb->links
2274
+ SET $update_set
2275
+ WHERE link_id='$this->id'
2276
  ");
2277
  endif;
2278
+
2279
  return $new_count;
2280
  } /* 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
+
2351
  function uri () {
2352
  return (is_object($this->link) ? $this->link->link_rss : NULL);
2353
+ } /* SyndicatedLink::uri () */
2354
+
2355
  function homepage () {
2356
  return (isset($this->settings['feed/link']) ? $this->settings['feed/link'] : NULL);
2357
+ } /* SyndicatedLink::homepage () */
2358
 
2359
  function ttl () {
2360
  if (is_object($this->magpie)) :
2423
  endforeach;
2424
  endif;
2425
  return $ret;
2426
+ } /* SyndicatedLink::flatten_array () */
2427
 
2428
  function hardcode ($what) {
2429
  $default = get_option("feedwordpress_hardcode_$what");
2439
  $ret = FeedWordPress::affirmative($this->settings, "hardcode $what");
2440
  endif;
2441
  return $ret;
2442
+ } /* SyndicatedLink::hardcode () */
2443
 
2444
  function syndicated_status ($what, $default) {
2445
  global $wpdb;
2451
  $ret = $default;
2452
  endif;
2453
  return $wpdb->escape(trim(strtolower($ret)));
2454
+ } /* SyndicatedLink:syndicated_status () */
2455
  } // class SyndicatedLink
2456
 
2457
  ################################################################################
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://projects.radgeek.com/feedwordpress/
4
  Tags: syndication, aggregation, feed, atom, rss
5
  Requires at least: 1.5
6
  Tested up to: 2.6.3
7
- Stable tag: 2008.1101
8
 
9
  FeedWordPress syndicates content from feeds you choose into your WordPress weblog.
10
 
@@ -40,7 +40,7 @@ hosts that *don't* offer shell access are *bad web hosts*.)
40
 
41
  == Installation ==
42
 
43
- To use version 2008.1030 of FeedWordPress, you will need:
44
 
45
  * an installed and configured copy of WordPress version 2.6.x, 2.5.x,
46
  2.3.x, 2.2.x, 2.1.x, 2.0.x, or 1.5.x. (FeedWordPress will also work with
4
  Tags: syndication, aggregation, feed, atom, rss
5
  Requires at least: 1.5
6
  Tested up to: 2.6.3
7
+ Stable tag: 2008.1105
8
 
9
  FeedWordPress syndicates content from feeds you choose into your WordPress weblog.
10
 
40
 
41
  == Installation ==
42
 
43
+ To use FeedWordPress, you will need:
44
 
45
  * an installed and configured copy of WordPress version 2.6.x, 2.5.x,
46
  2.3.x, 2.2.x, 2.1.x, 2.0.x, or 1.5.x. (FeedWordPress will also work with
syndication-options.php CHANGED
@@ -9,7 +9,21 @@ function fwp_syndication_options_page () {
9
  return;
10
  endif;
11
 
12
- if (isset($_POST['submit'])) :
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  check_admin_referer();
14
 
15
  if (!current_user_can('manage_options')):
@@ -17,6 +31,7 @@ function fwp_syndication_options_page () {
17
  else:
18
  update_option('feedwordpress_cat_id', $_REQUEST['syndication_category']);
19
  update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']);
 
20
  update_option('feedwordpress_formatting_filters', $_REQUEST['formatting_filters']);
21
  update_option('feedwordpress_update_logging', $_REQUEST['update_logging']);
22
 
@@ -47,9 +62,20 @@ function fwp_syndication_options_page () {
47
  update_option('feedwordpress_unfamiliar_author', $_REQUEST['unfamiliar_author']);
48
  endif;
49
 
 
 
 
 
 
 
 
 
 
 
50
  update_option('feedwordpress_unfamiliar_category', $_REQUEST['unfamiliar_category']);
51
  update_option('feedwordpress_syndicated_post_status', $_REQUEST['post_status']);
52
  update_option('feedwordpress_automatic_updates', ($_POST['automatic_updates']=='yes'));
 
53
  update_option('feedwordpress_freshness', ($_POST['freshness_interval']*60));
54
 
55
  // Categories
@@ -119,9 +145,12 @@ function fwp_syndication_options_page () {
119
 
120
  $cat_id = FeedWordPress::link_category_id();
121
  $munge_permalink = get_option('feedwordpress_munge_permalink');
 
122
  $formatting_filters = get_option('feedwordpress_formatting_filters');
123
  $update_logging = get_option('feedwordpress_update_logging');
124
 
 
 
125
  $automatic_updates = get_option('feedwordpress_automatic_updates');
126
 
127
  $freshness_interval = get_option('feedwordpress_freshness');
@@ -143,6 +172,10 @@ function fwp_syndication_options_page () {
143
  if (is_string($ua) and array_key_exists($ua, $unfamiliar_author)) :
144
  $unfamiliar_author[$ua] = ' checked="checked"';
145
  endif;
 
 
 
 
146
  $unfamiliar_category = array ('create'=>'','default'=>'','filter'=>'', 'tag'=>'');
147
  $uc = FeedWordPress::on_unfamiliar('category');
148
  if (is_string($uc) and array_key_exists($uc, $unfamiliar_category)) :
@@ -173,12 +206,12 @@ function fwp_syndication_options_page () {
173
  );
174
  ?>
175
  <script type="text/javascript">
176
- function flip_newuser (item) {
177
- rollup=document.getElementById(item);
178
- newuser=document.getElementById(item+'-newuser');
179
- sitewide=document.getElementById(item+'-default');
180
  if (rollup) {
181
- if ('newuser'==rollup.value) {
182
  if (newuser) newuser.style.display='block';
183
  if (sitewide) sitewide.style.display='none';
184
  } else {
@@ -216,8 +249,8 @@ function fwp_syndication_options_page () {
216
  ?></td>
217
  </tr>
218
 
219
- <tr>
220
- <th width="33%" scope="row">Check for new posts:</th>
221
  <td width="67%"><select name="automatic_updates" size="1" onchange="if (this.value=='yes') { disp = 'inline'; } else { disp = 'none'; }; el=document.getElementById('automatic-update-interval-span'); if (el) el.style.display=disp;">
222
  <option value="yes"<?php echo ($automatic_updates)?' selected="selected"':''; ?>>automatically</option>
223
  <option value="no"<?php echo (!$automatic_updates)?' selected="selected"':''; ?>>only when I request</option>
@@ -226,6 +259,19 @@ function fwp_syndication_options_page () {
226
  </td>
227
  </tr>
228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  <tr><th width="33%" scope="row" style="vertical-align:top">Feed information:</th>
230
  <td width="67%"><ul style="margin:0;padding:0;list-style:none">
231
  <li><input type="checkbox" name="hardcode_name" value="no"<?php echo (($hardcode_name=='yes')?'':' checked="checked"');?>/> Update the contributor title when the feed title changes</li>
@@ -249,11 +295,23 @@ function fwp_syndication_options_page () {
249
  <li><label><input type="radio" name="post_status" value="draft"<?php echo ($post_status=='draft')?' checked="checked"':''; ?> /> Save syndicated posts as drafts</label></li>
250
  <li><label><input type="radio" name="post_status" value="private"<?php echo ($post_status=='private')?' checked="checked"':''; ?> /> Save syndicated posts as private posts</label></li>
251
  </ul></td></tr>
 
252
  <tr style="vertical-align: top"><th width="44%" scope="row">Permalinks point to:</th>
253
  <td width="56%"><select name="munge_permalink" size="1">
254
  <option value="yes"<?php echo ($munge_permalink=='yes')?' selected="selected"':''; ?>>original website</option>
255
  <option value="no"<?php echo ($munge_permalink=='no')?' selected="selected"':''; ?>>this website</option>
256
  </select></td></tr>
 
 
 
 
 
 
 
 
 
 
 
257
  <tr style="vertical-align:top"><th width="44%" scope="row">Formatting filters:</th>
258
  <td width="56%">
259
  <select name="formatting_filters" size="1">
@@ -318,10 +376,10 @@ endif;
318
  ?>
319
  <table>
320
  <tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">For posts by authors that haven't been syndicated before:</th></tr>
321
- <tr>
322
  <th style="text-align: left">Posts by new authors</th>
323
  <td>
324
- <select id="unfamiliar-author" name="unfamiliar_author" onchange="flip_newuser('unfamiliar-author');">
325
  <option value="create"<?php if ('create'==$unfamiliar_author) : ?>selected="selected"<?php endif; ?>>create a new author account</option>
326
  <?php foreach ($authorlist as $author_id => $author_name) : ?>
327
  <option value="<?php echo $author_id; ?>"<?php if ($author_id==$unfamiliar_author) : ?>selected="selected"<?php endif; ?>>are assigned to <?php echo $author_name; ?></option>
@@ -331,15 +389,34 @@ endif;
331
  </select>
332
  </td>
333
  <td>
334
- <div id="unfamiliar-author-default">This is a default setting. You can override it for one or more particular feeds using the Edit link in <a href="admin.php?page=feedwordpress/feedwordpress.php">Syndicated Sites</a></div>
335
  <div id="unfamiliar-author-newuser"><input type="text" name="unfamiliar_author_newuser" value="" /></div>
336
  </td>
337
  </tr>
 
 
 
 
338
  </table>
339
 
340
- <script>
341
- flip_newuser('unfamiliar-author');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
342
  </script>
 
343
  <?php
344
  fwp_option_box_closer();
345
  fwp_linkedit_periodic_submit();
@@ -347,12 +424,19 @@ endif;
347
  fwp_option_box_opener('Back End', 'backenddiv', 'postbox');
348
  ?>
349
  <table class="editform" width="100%" cellspacing="2" cellpadding="5">
350
- <th width="33%" scope="row">Write update notices to PHP logs:</th>
 
351
  <td width="67%"><select name="update_logging" size="1">
352
- <option value="yes"<?php echo (($update_logging=='yes')?' selected="selected"':''); ?>>yes</option>
353
- <option value="no"<?php echo (($update_logging!='yes')?' selected="selected"':''); ?>>no</option>
354
  </select></td>
355
  </tr>
 
 
 
 
 
 
356
  </table>
357
  <?php
358
  fwp_option_box_closer();
@@ -360,8 +444,9 @@ endif;
360
  ?>
361
  </div>
362
  </form>
363
- </div>
364
- </div>
 
365
  <?php
366
  }
367
 
9
  return;
10
  endif;
11
 
12
+ if (isset($_POST['create_index'])) :
13
+ check_admin_referer();
14
+ if (!current_user_can('manage_options')) :
15
+ die (__("Cheatin' uh ?"));
16
+ else :
17
+ FeedWordPress::create_guid_index();
18
+ ?>
19
+ <div class="updated">
20
+ <p><?php _e('Index created on database table.')?></p>
21
+ </div>
22
+ <?php
23
+ endif;
24
+ endif;
25
+
26
+ if (isset($_POST['submit']) or isset($_POST['create_index'])) :
27
  check_admin_referer();
28
 
29
  if (!current_user_can('manage_options')):
31
  else:
32
  update_option('feedwordpress_cat_id', $_REQUEST['syndication_category']);
33
  update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']);
34
+ update_option('feedwordpress_use_aggregator_source_data', $_REQUEST['use_aggregator_source_data']);
35
  update_option('feedwordpress_formatting_filters', $_REQUEST['formatting_filters']);
36
  update_option('feedwordpress_update_logging', $_REQUEST['update_logging']);
37
 
62
  update_option('feedwordpress_unfamiliar_author', $_REQUEST['unfamiliar_author']);
63
  endif;
64
 
65
+ if (isset($_REQUEST['match_author_by_email']) and $_REQUEST['match_author_by_email']=='yes') :
66
+ update_option('feedwordpress_do_not_match_author_by_email', 'no');
67
+ else :
68
+ update_option('feedwordpress_do_not_match_author_by_email', 'yes');
69
+ endif;
70
+
71
+ if (isset($_REQUEST['null_emails'])) :
72
+ update_option('feedwordpress_null_email_set', $_REQUEST['null_emails']);
73
+ endif;
74
+
75
  update_option('feedwordpress_unfamiliar_category', $_REQUEST['unfamiliar_category']);
76
  update_option('feedwordpress_syndicated_post_status', $_REQUEST['post_status']);
77
  update_option('feedwordpress_automatic_updates', ($_POST['automatic_updates']=='yes'));
78
+ update_option('feedwordpress_update_time_limit', ($_POST['update_time_limit']=='yes')?(int) $_POST['time_limit_seconds']:0);
79
  update_option('feedwordpress_freshness', ($_POST['freshness_interval']*60));
80
 
81
  // Categories
145
 
146
  $cat_id = FeedWordPress::link_category_id();
147
  $munge_permalink = get_option('feedwordpress_munge_permalink');
148
+ $use_aggregator_source_data = get_option('feedwordpress_use_aggregator_source_data');
149
  $formatting_filters = get_option('feedwordpress_formatting_filters');
150
  $update_logging = get_option('feedwordpress_update_logging');
151
 
152
+ $update_time_limit = (int) get_option('feedwordpress_update_time_limit');
153
+
154
  $automatic_updates = get_option('feedwordpress_automatic_updates');
155
 
156
  $freshness_interval = get_option('feedwordpress_freshness');
172
  if (is_string($ua) and array_key_exists($ua, $unfamiliar_author)) :
173
  $unfamiliar_author[$ua] = ' checked="checked"';
174
  endif;
175
+
176
+ $match_author_by_email = !('yes' == get_option("feedwordpress_do_not_match_author_by_email"));
177
+ $null_emails = FeedWordPress::null_email_set();
178
+
179
  $unfamiliar_category = array ('create'=>'','default'=>'','filter'=>'', 'tag'=>'');
180
  $uc = FeedWordPress::on_unfamiliar('category');
181
  if (is_string($uc) and array_key_exists($uc, $unfamiliar_category)) :
206
  );
207
  ?>
208
  <script type="text/javascript">
209
+ function contextual_appearance (item, appear, disappear, value, checkbox) {
210
+ var rollup=document.getElementById(item);
211
+ var newuser=document.getElementById(appear);
212
+ var sitewide=document.getElementById(disappear);
213
  if (rollup) {
214
+ if ((checkbox && rollup.checked) || (!checkbox && value==rollup.value)) {
215
  if (newuser) newuser.style.display='block';
216
  if (sitewide) sitewide.style.display='none';
217
  } else {
249
  ?></td>
250
  </tr>
251
 
252
+ <tr style="vertical-align: top">
253
+ <th width="33%" scope="row">Check for feeds ready to be polled for updates:</th>
254
  <td width="67%"><select name="automatic_updates" size="1" onchange="if (this.value=='yes') { disp = 'inline'; } else { disp = 'none'; }; el=document.getElementById('automatic-update-interval-span'); if (el) el.style.display=disp;">
255
  <option value="yes"<?php echo ($automatic_updates)?' selected="selected"':''; ?>>automatically</option>
256
  <option value="no"<?php echo (!$automatic_updates)?' selected="selected"':''; ?>>only when I request</option>
259
  </td>
260
  </tr>
261
 
262
+ <tr style="vertical-align: top">
263
+ <th width="33%" scope="row"><?php print __('Time limit on updates'); ?>:</th>
264
+ <td width="67%"><select id="time-limit" name="update_time_limit" size="1" onchange="contextual_appearance('time-limit', 'time-limit-box', null, 'yes');">
265
+ <option value="no"<?php echo ($update_time_limit>0)?'':' selected="selected"'; ?>>no time limit on updates</option>
266
+ <option value="yes"<?php echo ($update_time_limit>0)?' selected="selected"':''; ?>>limit updates to no more than...</option>
267
+ </select>
268
+ <span id="time-limit-box"><label><input type="text" name="time_limit_seconds" value="<?php print $update_time_limit; ?>" size="5" /> seconds</label></span>
269
+ </tr>
270
+
271
+ <script type="text/javascript">
272
+ contextual_appearance('time-limit', 'time-limit-box', null, 'yes');
273
+ </script>
274
+
275
  <tr><th width="33%" scope="row" style="vertical-align:top">Feed information:</th>
276
  <td width="67%"><ul style="margin:0;padding:0;list-style:none">
277
  <li><input type="checkbox" name="hardcode_name" value="no"<?php echo (($hardcode_name=='yes')?'':' checked="checked"');?>/> Update the contributor title when the feed title changes</li>
295
  <li><label><input type="radio" name="post_status" value="draft"<?php echo ($post_status=='draft')?' checked="checked"':''; ?> /> Save syndicated posts as drafts</label></li>
296
  <li><label><input type="radio" name="post_status" value="private"<?php echo ($post_status=='private')?' checked="checked"':''; ?> /> Save syndicated posts as private posts</label></li>
297
  </ul></td></tr>
298
+
299
  <tr style="vertical-align: top"><th width="44%" scope="row">Permalinks point to:</th>
300
  <td width="56%"><select name="munge_permalink" size="1">
301
  <option value="yes"<?php echo ($munge_permalink=='yes')?' selected="selected"':''; ?>>original website</option>
302
  <option value="no"<?php echo ($munge_permalink=='no')?' selected="selected"':''; ?>>this website</option>
303
  </select></td></tr>
304
+
305
+ <tr style="vertical-align: top"><th width="44%" scope="row">Posts from aggregator feeds:</th>
306
+ <td width="56%"><ul style="margin: 0; padding: 0; list-style: none;">
307
+ <li><label><input type="radio" name="use_aggregator_source_data" value="no"<?php echo ($use_aggregator_source_data!="yes")?' checked="checked"':''; ?>> Give the aggregator itself as the source of posts from an aggregator feed.</label></li>
308
+ <li><label><input type="radio" name="use_aggregator_source_data" value="yes"<?php echo ($use_aggregator_source_data=="yes")?' checked="checked"':''; ?>> Give the original source of the post as the source, not the aggregator.</label></li>
309
+ </ul>
310
+ <p>Some feeds (for example, those produced by FeedWordPress) aggregate content from several different sources, and include information about the original source of the post.
311
+ This setting controls what FeedWordPress will give as the source of posts from
312
+ such an aggregator feed.</p>
313
+ </td></tr>
314
+
315
  <tr style="vertical-align:top"><th width="44%" scope="row">Formatting filters:</th>
316
  <td width="56%">
317
  <select name="formatting_filters" size="1">
376
  ?>
377
  <table>
378
  <tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">For posts by authors that haven't been syndicated before:</th></tr>
379
+ <tr style="vertical-align: top">
380
  <th style="text-align: left">Posts by new authors</th>
381
  <td>
382
+ <select style="max-width: 16.0em;" id="unfamiliar-author" name="unfamiliar_author" onchange="contextual_appearance('unfamiliar-author', 'unfamiliar-author-newuser', 'unfamiliar-author-default', 'newuser');">
383
  <option value="create"<?php if ('create'==$unfamiliar_author) : ?>selected="selected"<?php endif; ?>>create a new author account</option>
384
  <?php foreach ($authorlist as $author_id => $author_name) : ?>
385
  <option value="<?php echo $author_id; ?>"<?php if ($author_id==$unfamiliar_author) : ?>selected="selected"<?php endif; ?>>are assigned to <?php echo $author_name; ?></option>
389
  </select>
390
  </td>
391
  <td>
 
392
  <div id="unfamiliar-author-newuser"><input type="text" name="unfamiliar_author_newuser" value="" /></div>
393
  </td>
394
  </tr>
395
+ <tr><td></td>
396
+ <td colspan="2">
397
+ <p>This is a default setting. You can override it for one or more particular feeds using the Edit link in <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/syndication.php">Syndicated Sites</a></p>
398
+ </td>
399
  </table>
400
 
401
+ <script type="text/javascript">
402
+ contextual_appearance('unfamiliar-author', 'unfamiliar-author-newuser', 'unfamiliar-author-default', 'newuser');
403
+ </script>
404
+
405
+ <h4>Matching Authors</h4>
406
+ <ul style="list-style: none; margin: 0; padding: 0;">
407
+ <li><div><label><input id="match-author-by-email" type="checkbox" name="match_author_by_email" value="yes" <?php if ($match_author_by_email) : ?>checked="checked" <?php endif; ?>onchange="contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', /*checkbox=*/ true);" /> Treat syndicated authors with the same e-mail address as the same author.</label></div>
408
+ <div id="unless-null-email">
409
+ <p>Unless the e-mail address is one of the following anonymous e-mail addresses:</p>
410
+ <textarea name="null_emails" rows="3" style="width: 100%">
411
+ <?php print implode("\n", $null_emails); ?>
412
+ </textarea>
413
+ </div></li>
414
+ </ul>
415
+
416
+ <script type="text/javascript">
417
+ contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', /*checkbox=*/ true);
418
  </script>
419
+
420
  <?php
421
  fwp_option_box_closer();
422
  fwp_linkedit_periodic_submit();
424
  fwp_option_box_opener('Back End', 'backenddiv', 'postbox');
425
  ?>
426
  <table class="editform" width="100%" cellspacing="2" cellpadding="5">
427
+ <tr style="vertical-align: top">
428
+ <th width="33%" scope="row">Update notices:</th>
429
  <td width="67%"><select name="update_logging" size="1">
430
+ <option value="yes"<?php echo (($update_logging=='yes')?' selected="selected"':''); ?>>write to PHP logs</option>
431
+ <option value="no"<?php echo (($update_logging!='yes')?' selected="selected"':''); ?>>don't write to PHP logs</option>
432
  </select></td>
433
  </tr>
434
+ <tr style="vertical-align: top">
435
+ <th width="33%" scope="row">Guid index:</th>
436
+ <td width="67%"><input class="button" type="submit" name="create_index" value="Create index on guid column in posts database table" />
437
+ <p>Creating this index may significantly improve performance on some large
438
+ FeedWordPress installations.</p></td>
439
+ </tr>
440
  </table>
441
  <?php
442
  fwp_option_box_closer();
444
  ?>
445
  </div>
446
  </form>
447
+
448
+ </div> <!-- id="poststuff" -->
449
+ </div> <!-- class="wrap" -->
450
  <?php
451
  }
452
 
syndication.php CHANGED
@@ -41,11 +41,19 @@ function fwp_dashboard_update_if_requested () {
41
  $update_set[] = $_POST['update_uri'];
42
  endif;
43
 
44
-
45
  if ($fwp_update_invoke != 'get' and count($update_set) > 0) : // Only do things with side-effects for HTTP POST or command line
46
  $feedwordpress =& new FeedWordPress;
47
  add_action('feedwordpress_check_feed', 'update_feeds_mention');
48
-
 
 
 
 
 
 
 
 
49
  if (fwp_test_wp_version(FWP_SCHEMA_25)) :
50
  echo "<div class=\"youare\">\n";
51
  else :
@@ -54,8 +62,13 @@ function fwp_dashboard_update_if_requested () {
54
  echo "<ul>\n";
55
  $tdelta = NULL;
56
  foreach ($update_set as $uri) :
 
 
 
 
 
57
  if ($uri == '*') : $uri = NULL; endif;
58
- $delta = $feedwordpress->update($uri);
59
  if (!is_null($delta)) :
60
  if (is_null($tdelta)) :
61
  $tdelta = $delta;
@@ -472,11 +485,6 @@ function fwp_linkedit_page () {
472
  if (isset($GLOBALS['fwp_post']['save'])) :
473
  $alter = array ();
474
 
475
- $meta = $link->settings;
476
- //if (isset($meta['cats'])):
477
- // $meta['cats'] = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, $meta['cats']);
478
- //endif;
479
-
480
  // custom feed settings first
481
  foreach ($GLOBALS['fwp_post']['notes'] as $mn) :
482
  $mn['key0'] = trim($mn['key0']);
@@ -489,55 +497,55 @@ function fwp_linkedit_page () {
489
  endif;
490
 
491
  if (strlen($mn['key0']) > 0) :
492
- unset($meta[$mn['key0']]); // out with the old
493
  endif;
494
 
495
  if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
496
- $meta[$mn['key1']] = $mn['value']; // in with the new
497
  endif;
498
  endforeach;
499
 
500
  // now stuff through the web form
501
  // hardcoded feed info
502
  if (isset($GLOBALS['fwp_post']['hardcode_name'])) :
503
- $meta['hardcode name'] = $GLOBALS['fwp_post']['hardcode_name'];
504
- if (FeedWordPress::affirmative($meta, 'hardcode name')) :
505
  $alter[] = "link_name = '".$wpdb->escape($GLOBALS['fwp_post']['name'])."'";
506
  endif;
507
  endif;
508
  if (isset($GLOBALS['fwp_post']['hardcode_description'])) :
509
- $meta['hardcode description'] = $GLOBALS['fwp_post']['hardcode_description'];
510
- if (FeedWordPress::affirmative($meta, 'hardcode description')) :
511
  $alter[] = "link_description = '".$wpdb->escape($GLOBALS['fwp_post']['description'])."'";
512
  endif;
513
  endif;
514
  if (isset($GLOBALS['fwp_post']['hardcode_url'])) :
515
- $meta['hardcode url'] = $GLOBALS['fwp_post']['hardcode_url'];
516
- if (FeedWordPress::affirmative($meta, 'hardcode url')) :
517
  $alter[] = "link_url = '".$wpdb->escape($GLOBALS['fwp_post']['linkurl'])."'";
518
  endif;
519
  endif;
520
 
521
  // Update scheduling
522
  if (isset($GLOBALS['fwp_post']['update_schedule'])) :
523
- $meta['update/hold'] = $GLOBALS['fwp_post']['update_schedule'];
524
  endif;
525
 
526
  // Categories
527
  if (isset($GLOBALS['fwp_post']['post_category'])) :
528
- $meta['cats'] = array();
529
  foreach ($GLOBALS['fwp_post']['post_category'] as $cat_id) :
530
- $meta['cats'][] = '{#'.$cat_id.'}';
531
  endforeach;
532
  else :
533
- unset($meta['cats']);
534
  endif;
535
 
536
  // Tags
537
  if (isset($GLOBALS['fwp_post']['tags_input'])) :
538
- $meta['tags'] = array();
539
  foreach (explode(',', $GLOBALS['fwp_post']['tags_input']) as $tag) :
540
- $meta['tags'][] = trim($tag);
541
  endforeach;
542
  endif;
543
 
@@ -546,9 +554,9 @@ function fwp_linkedit_page () {
546
  $sfield = "feed_{$what}_status";
547
  if (isset($GLOBALS['fwp_post'][$sfield])) :
548
  if ($GLOBALS['fwp_post'][$sfield]=='site-default') :
549
- unset($meta["{$what} status"]);
550
  else :
551
- $meta["{$what} status"] = $GLOBALS['fwp_post'][$sfield];
552
  endif;
553
  endif;
554
  endforeach;
@@ -558,7 +566,7 @@ function fwp_linkedit_page () {
558
  $sfield = "unfamiliar_{$what}";
559
  if (isset($GLOBALS['fwp_post'][$sfield])) :
560
  if ('site-default'==$GLOBALS['fwp_post'][$sfield]) :
561
- unset($meta["unfamiliar {$what}"]);
562
  elseif ('newuser'==$GLOBALS['fwp_post'][$sfield]) :
563
  $newuser_name = trim($GLOBALS['fwp_post']["{$sfield}_newuser"]);
564
  if (strlen($newuser_name) > 0) :
@@ -575,7 +583,7 @@ function fwp_linkedit_page () {
575
 
576
  $newuser_id = wp_insert_user($userdata);
577
  if (is_numeric($newuser_id)) :
578
- $meta["unfamiliar {$what}"] = $newuser_id;
579
  else :
580
  // TODO: Add some error detection and reporting
581
  endif;
@@ -583,14 +591,14 @@ function fwp_linkedit_page () {
583
  // TODO: Add some error reporting
584
  endif;
585
  else :
586
- $meta["unfamiliar {$what}"] = $GLOBALS['fwp_post'][$sfield];
587
  endif;
588
  endif;
589
  endforeach;
590
 
591
  // Handle author mapping rules
592
  if (isset($GLOBALS['fwp_post']['author_rules_name']) and isset($GLOBALS['fwp_post']['author_rules_action'])) :
593
- unset($meta['map authors']);
594
  foreach ($GLOBALS['fwp_post']['author_rules_name'] as $key => $name) :
595
  // Normalize for case and whitespace
596
  $name = strtolower(trim($name));
@@ -613,7 +621,7 @@ function fwp_linkedit_page () {
613
 
614
  $newuser_id = wp_insert_user($userdata);
615
  if (is_numeric($newuser_id)) :
616
- $meta['map authors']['name'][$name] = $newuser_id;
617
  else :
618
  // TODO: Add some error detection and reporting
619
  endif;
@@ -621,7 +629,7 @@ function fwp_linkedit_page () {
621
  // TODO: Add some error reporting
622
  endif;
623
  else :
624
- $meta['map authors']['name'][$name] = $author_action;
625
  endif;
626
  endif;
627
  endforeach;
@@ -647,7 +655,7 @@ function fwp_linkedit_page () {
647
 
648
  $newuser_id = wp_insert_user($userdata);
649
  if (is_numeric($newuser_id)) :
650
- $meta['map authors']['name'][$name] = $newuser_id;
651
  else :
652
  // TODO: Add some error detection and reporting
653
  endif;
@@ -655,42 +663,20 @@ function fwp_linkedit_page () {
655
  // TODO: Add some error reporting
656
  endif;
657
  else :
658
- $meta['map authors']['name'][$name] = $author_action;
659
  endif;
660
  endif;
661
  endif;
662
 
663
  if (isset($GLOBALS['fwp_post']['cat_split'])) :
664
  if (strlen(trim($GLOBALS['fwp_post']['cat_split'])) > 0) :
665
- $meta['cat_split'] = trim($GLOBALS['fwp_post']['cat_split']);
666
  else :
667
- unset($meta['cat_split']);
668
  endif;
669
  endif;
670
 
671
- if (is_array($meta['cats'])) :
672
- $meta['cats'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $meta['cats']);
673
- endif;
674
- if (is_array($meta['tags'])) :
675
- $meta['tags'] = implode(FEEDWORDPRESS_CAT_SEPARATOR, $meta['tags']);
676
- endif;
677
-
678
- // Collapse the author mapping rule structure back into a flat string
679
- if (isset($meta['map authors'])) :
680
- $ma = array();
681
- foreach ($meta['map authors'] as $rule_type => $author_rules) :
682
- foreach ($author_rules as $author_name => $author_action) :
683
- $ma[] = $rule_type."\n".$author_name."\n".$author_action;
684
- endforeach;
685
- endforeach;
686
- $meta['map authors'] = implode("\n\n", $ma);
687
- endif;
688
-
689
- $notes = '';
690
- foreach ($meta as $key => $value) :
691
- $notes .= $key . ": ". addcslashes($value, "\0..\37".'\\') . "\n";
692
- endforeach;
693
- $alter[] = "link_notes = '".$wpdb->escape($notes)."'";
694
 
695
  $alter_set = implode(", ", $alter);
696
 
@@ -712,10 +698,8 @@ function fwp_linkedit_page () {
712
  $link_url = wp_specialchars($db_link->link_url, 1);
713
  $link_name = wp_specialchars($db_link->link_name, 1);
714
  $link_description = wp_specialchars($db_link->link_description, 'both');
715
- $link_notes = wp_specialchars($db_link->link_notes, 'both');
716
  $link_rss_uri = wp_specialchars($db_link->link_rss, 'both');
717
 
718
- $meta = $link->settings;
719
  $post_status_global = get_option('feedwordpress_syndicated_post_status');
720
  $comment_status_global = get_option('feedwordpress_syndicated_comment_status');
721
  $ping_status_global = get_option('feedwordpress_syndicated_ping_status');
@@ -729,8 +713,8 @@ function fwp_linkedit_page () {
729
  $status['ping'] = array('open' => '', 'closed' => '', 'site-default' => '');
730
 
731
  foreach (array('post', 'comment', 'ping') as $what) :
732
- if (isset($meta["{$what} status"])) :
733
- $status[$what][$meta["{$what} status"]] = ' checked="checked"';
734
  else :
735
  $status[$what]['site-default'] = ' checked="checked"';
736
  endif;
@@ -740,16 +724,16 @@ function fwp_linkedit_page () {
740
  $unfamiliar['category'] = array ('create'=>'','tag' => '','default'=>'','filter'=>'');
741
 
742
  foreach (array('author', 'category') as $what) :
743
- if (is_string($meta["unfamiliar {$what}"]) and
744
- array_key_exists($meta["unfamiliar {$what}"], $unfamiliar[$what])) :
745
- $key = $meta["unfamiliar {$what}"];
746
  else:
747
  $key = 'site-default';
748
  endif;
749
  $unfamiliar[$what][$key] = ' checked="checked"';
750
  endforeach;
751
 
752
- if (is_array($meta['cats'])) : $cats = $meta['cats'];
753
  else : $cats = array();
754
  endif;
755
 
@@ -852,29 +836,29 @@ function fwp_linkedit_page () {
852
  <tr>
853
  <th width="20%"><?php _e('Last update') ?>:</th>
854
  <td colspan="2"><?php
855
- if (isset($meta['update/last'])) :
856
- echo strftime('%x %X', $meta['update/last'])." ";
857
  else :
858
  echo " none yet";
859
  endif;
860
  ?></td></tr>
861
  <tr><th width="20%">Next update:</th>
862
  <td colspan="2"><?php
863
- $holdem = (isset($meta['update/hold']) ? $meta['update/hold'] : 'scheduled');
864
  ?>
865
  <select name="update_schedule">
866
  <option value="scheduled"<?php echo ($holdem=='scheduled')?' selected="selected"':''; ?>>update on schedule <?php
867
  echo " (";
868
- if (isset($meta['update/ttl']) and is_numeric($meta['update/ttl'])) :
869
- if (isset($meta['update/timed']) and $meta['update/timed']=='automatically') :
870
  echo 'next: ';
871
- $next = $meta['update/last'] + ((int) $meta['update/ttl'] * 60);
872
  if (strftime('%x', time()) != strftime('%x', $next)) :
873
  echo strftime('%x', $next)." ";
874
  endif;
875
- echo strftime('%X', $meta['update/last']+((int) $meta['update/ttl']*60));
876
  else :
877
- echo "every ".$meta['update/ttl']." minute".(($meta['update/ttl']!=1)?"s":"");
878
  endif;
879
  else:
880
  echo "next scheduled update";
@@ -946,7 +930,7 @@ endif;
946
  <tr>
947
  <th width="20%" scope="row" style="vertical-align:top">Multiple categories:</th>
948
  <td width="80%">
949
- <input type="text" size="20" id="cat_split" name="cat_split" value="<?php if (isset($meta['cat_split'])) : echo htmlspecialchars($meta['cat_split']); endif; ?>" /><br/>
950
  Enter a <a href="http://us.php.net/manual/en/reference.pcre.pattern.syntax.php">Perl-compatible regular expression</a> here if the feed provides multiple
951
  categories in a single category element. The regular expression should match
952
  the characters used to separate one category from the next. If the feed uses
@@ -960,7 +944,7 @@ blank.</td>
960
  fwp_linkedit_periodic_submit();
961
 
962
  if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) :
963
- fwp_tags_box($meta['tags']);
964
  fwp_linkedit_periodic_submit();
965
  endif; ?>
966
 
@@ -972,13 +956,13 @@ endif; ?>
972
  <th style="text-align: left">Posts by new authors</th>
973
  <td>
974
  <select id="unfamiliar-author" name="unfamiliar_author" onchange="flip_newuser('unfamiliar-author');">
975
- <option value="site-default"<?php if (!isset($meta['unfamiliar author'])) : ?>selected="selected"<?php endif; ?>>are handled using site-wide settings</option>
976
- <option value="create"<?php if ('create'==$meta['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>create a new author account</option>
977
  <?php foreach ($authorlist as $author_id => $author_name) : ?>
978
- <option value="<?php echo $author_id; ?>"<?php if ($author_id==$meta['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>are assigned to <?php echo $author_name; ?></option>
979
  <?php endforeach; ?>
980
  <option value="newuser">will be assigned to a new user...</option>
981
- <option value="filter"<?php if ('filter'==$meta['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>get filtered out</option>
982
  </select>
983
  </td>
984
  <td>
@@ -989,7 +973,7 @@ endif; ?>
989
 
990
  <tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">For posts by specific authors. Blank out a name to delete the rule.</th></tr>
991
 
992
- <?php if (isset($meta['map authors'])) : $i=0; foreach ($meta['map authors'] as $author_rules) : foreach ($author_rules as $author_name => $author_action) : $i++; ?>
993
  <tr>
994
  <th style="text-align: left">Posts by <input type="text" name="author_rules_name[]" value="<?php echo htmlspecialchars($author_name); ?>" /></th>
995
  <td>
@@ -1074,7 +1058,7 @@ endif; ?>
1074
 
1075
  <?php
1076
  $i = 0;
1077
- foreach ($meta as $key => $value) :
1078
  if (!preg_match("\007^((".implode(')|(', $special_settings)."))$\007i", $key)) :
1079
  ?>
1080
  <tr style="vertical-align:top">
41
  $update_set[] = $_POST['update_uri'];
42
  endif;
43
 
44
+ shuffle($update_set); // randomize order for load balancing purposes...
45
  if ($fwp_update_invoke != 'get' and count($update_set) > 0) : // Only do things with side-effects for HTTP POST or command line
46
  $feedwordpress =& new FeedWordPress;
47
  add_action('feedwordpress_check_feed', 'update_feeds_mention');
48
+ add_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3);
49
+
50
+ $crash_dt = (int) get_option('feedwordpress_update_time_limit');
51
+ if ($crash_dt > 0) :
52
+ $crash_ts = time() + $crash_dt;
53
+ else :
54
+ $crash_ts = NULL;
55
+ endif;
56
+
57
  if (fwp_test_wp_version(FWP_SCHEMA_25)) :
58
  echo "<div class=\"youare\">\n";
59
  else :
62
  echo "<ul>\n";
63
  $tdelta = NULL;
64
  foreach ($update_set as $uri) :
65
+ if (!is_null($crash_ts) and (time() > $crash_ts)) :
66
+ echo "<li><p><strong>Further updates postponed:</strong> update time limit of ".$crash_dt." second".(($crash_dt==1)?"":"s")." exceeded.</p></li>";
67
+ break;
68
+ endif;
69
+
70
  if ($uri == '*') : $uri = NULL; endif;
71
+ $delta = $feedwordpress->update($uri, $crash_ts);
72
  if (!is_null($delta)) :
73
  if (is_null($tdelta)) :
74
  $tdelta = $delta;
485
  if (isset($GLOBALS['fwp_post']['save'])) :
486
  $alter = array ();
487
 
 
 
 
 
 
488
  // custom feed settings first
489
  foreach ($GLOBALS['fwp_post']['notes'] as $mn) :
490
  $mn['key0'] = trim($mn['key0']);
497
  endif;
498
 
499
  if (strlen($mn['key0']) > 0) :
500
+ unset($link->settings[$mn['key0']]); // out with the old
501
  endif;
502
 
503
  if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
504
+ $link->settings[$mn['key1']] = $mn['value']; // in with the new
505
  endif;
506
  endforeach;
507
 
508
  // now stuff through the web form
509
  // hardcoded feed info
510
  if (isset($GLOBALS['fwp_post']['hardcode_name'])) :
511
+ $link->settings['hardcode name'] = $GLOBALS['fwp_post']['hardcode_name'];
512
+ if (FeedWordPress::affirmative($link->settings, 'hardcode name')) :
513
  $alter[] = "link_name = '".$wpdb->escape($GLOBALS['fwp_post']['name'])."'";
514
  endif;
515
  endif;
516
  if (isset($GLOBALS['fwp_post']['hardcode_description'])) :
517
+ $link->settings['hardcode description'] = $GLOBALS['fwp_post']['hardcode_description'];
518
+ if (FeedWordPress::affirmative($link->settings, 'hardcode description')) :
519
  $alter[] = "link_description = '".$wpdb->escape($GLOBALS['fwp_post']['description'])."'";
520
  endif;
521
  endif;
522
  if (isset($GLOBALS['fwp_post']['hardcode_url'])) :
523
+ $link->settings['hardcode url'] = $GLOBALS['fwp_post']['hardcode_url'];
524
+ if (FeedWordPress::affirmative($link->settings, 'hardcode url')) :
525
  $alter[] = "link_url = '".$wpdb->escape($GLOBALS['fwp_post']['linkurl'])."'";
526
  endif;
527
  endif;
528
 
529
  // Update scheduling
530
  if (isset($GLOBALS['fwp_post']['update_schedule'])) :
531
+ $link->settings['update/hold'] = $GLOBALS['fwp_post']['update_schedule'];
532
  endif;
533
 
534
  // Categories
535
  if (isset($GLOBALS['fwp_post']['post_category'])) :
536
+ $link->settings['cats'] = array();
537
  foreach ($GLOBALS['fwp_post']['post_category'] as $cat_id) :
538
+ $link->settings['cats'][] = '{#'.$cat_id.'}';
539
  endforeach;
540
  else :
541
+ unset($link->settings['cats']);
542
  endif;
543
 
544
  // Tags
545
  if (isset($GLOBALS['fwp_post']['tags_input'])) :
546
+ $link->settings['tags'] = array();
547
  foreach (explode(',', $GLOBALS['fwp_post']['tags_input']) as $tag) :
548
+ $link->settings['tags'][] = trim($tag);
549
  endforeach;
550
  endif;
551
 
554
  $sfield = "feed_{$what}_status";
555
  if (isset($GLOBALS['fwp_post'][$sfield])) :
556
  if ($GLOBALS['fwp_post'][$sfield]=='site-default') :
557
+ unset($link->settings["{$what} status"]);
558
  else :
559
+ $link->settings["{$what} status"] = $GLOBALS['fwp_post'][$sfield];
560
  endif;
561
  endif;
562
  endforeach;
566
  $sfield = "unfamiliar_{$what}";
567
  if (isset($GLOBALS['fwp_post'][$sfield])) :
568
  if ('site-default'==$GLOBALS['fwp_post'][$sfield]) :
569
+ unset($link->settings["unfamiliar {$what}"]);
570
  elseif ('newuser'==$GLOBALS['fwp_post'][$sfield]) :
571
  $newuser_name = trim($GLOBALS['fwp_post']["{$sfield}_newuser"]);
572
  if (strlen($newuser_name) > 0) :
583
 
584
  $newuser_id = wp_insert_user($userdata);
585
  if (is_numeric($newuser_id)) :
586
+ $link->settings["unfamiliar {$what}"] = $newuser_id;
587
  else :
588
  // TODO: Add some error detection and reporting
589
  endif;
591
  // TODO: Add some error reporting
592
  endif;
593
  else :
594
+ $link->settings["unfamiliar {$what}"] = $GLOBALS['fwp_post'][$sfield];
595
  endif;
596
  endif;
597
  endforeach;
598
 
599
  // Handle author mapping rules
600
  if (isset($GLOBALS['fwp_post']['author_rules_name']) and isset($GLOBALS['fwp_post']['author_rules_action'])) :
601
+ unset($link->settings['map authors']);
602
  foreach ($GLOBALS['fwp_post']['author_rules_name'] as $key => $name) :
603
  // Normalize for case and whitespace
604
  $name = strtolower(trim($name));
621
 
622
  $newuser_id = wp_insert_user($userdata);
623
  if (is_numeric($newuser_id)) :
624
+ $link->settings['map authors']['name'][$name] = $newuser_id;
625
  else :
626
  // TODO: Add some error detection and reporting
627
  endif;
629
  // TODO: Add some error reporting
630
  endif;
631
  else :
632
+ $link->settings['map authors']['name'][$name] = $author_action;
633
  endif;
634
  endif;
635
  endforeach;
655
 
656
  $newuser_id = wp_insert_user($userdata);
657
  if (is_numeric($newuser_id)) :
658
+ $link->settings['map authors']['name'][$name] = $newuser_id;
659
  else :
660
  // TODO: Add some error detection and reporting
661
  endif;
663
  // TODO: Add some error reporting
664
  endif;
665
  else :
666
+ $link->settings['map authors']['name'][$name] = $author_action;
667
  endif;
668
  endif;
669
  endif;
670
 
671
  if (isset($GLOBALS['fwp_post']['cat_split'])) :
672
  if (strlen(trim($GLOBALS['fwp_post']['cat_split'])) > 0) :
673
+ $link->settings['cat_split'] = trim($GLOBALS['fwp_post']['cat_split']);
674
  else :
675
+ unset($link->settings['cat_split']);
676
  endif;
677
  endif;
678
 
679
+ $alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
680
 
681
  $alter_set = implode(", ", $alter);
682
 
698
  $link_url = wp_specialchars($db_link->link_url, 1);
699
  $link_name = wp_specialchars($db_link->link_name, 1);
700
  $link_description = wp_specialchars($db_link->link_description, 'both');
 
701
  $link_rss_uri = wp_specialchars($db_link->link_rss, 'both');
702
 
 
703
  $post_status_global = get_option('feedwordpress_syndicated_post_status');
704
  $comment_status_global = get_option('feedwordpress_syndicated_comment_status');
705
  $ping_status_global = get_option('feedwordpress_syndicated_ping_status');
713
  $status['ping'] = array('open' => '', 'closed' => '', 'site-default' => '');
714
 
715
  foreach (array('post', 'comment', 'ping') as $what) :
716
+ if (isset($link->settings["{$what} status"])) :
717
+ $status[$what][$link->settings["{$what} status"]] = ' checked="checked"';
718
  else :
719
  $status[$what]['site-default'] = ' checked="checked"';
720
  endif;
724
  $unfamiliar['category'] = array ('create'=>'','tag' => '','default'=>'','filter'=>'');
725
 
726
  foreach (array('author', 'category') as $what) :
727
+ if (is_string($link->settings["unfamiliar {$what}"]) and
728
+ array_key_exists($link->settings["unfamiliar {$what}"], $unfamiliar[$what])) :
729
+ $key = $link->settings["unfamiliar {$what}"];
730
  else:
731
  $key = 'site-default';
732
  endif;
733
  $unfamiliar[$what][$key] = ' checked="checked"';
734
  endforeach;
735
 
736
+ if (is_array($link->settings['cats'])) : $cats = $link->settings['cats'];
737
  else : $cats = array();
738
  endif;
739
 
836
  <tr>
837
  <th width="20%"><?php _e('Last update') ?>:</th>
838
  <td colspan="2"><?php
839
+ if (isset($link->settings['update/last'])) :
840
+ echo strftime('%x %X', $link->settings['update/last'])." ";
841
  else :
842
  echo " none yet";
843
  endif;
844
  ?></td></tr>
845
  <tr><th width="20%">Next update:</th>
846
  <td colspan="2"><?php
847
+ $holdem = (isset($link->settings['update/hold']) ? $link->settings['update/hold'] : 'scheduled');
848
  ?>
849
  <select name="update_schedule">
850
  <option value="scheduled"<?php echo ($holdem=='scheduled')?' selected="selected"':''; ?>>update on schedule <?php
851
  echo " (";
852
+ if (isset($link->settings['update/ttl']) and is_numeric($link->settings['update/ttl'])) :
853
+ if (isset($link->settings['update/timed']) and $link->settings['update/timed']=='automatically') :
854
  echo 'next: ';
855
+ $next = $link->settings['update/last'] + ((int) $link->settings['update/ttl'] * 60);
856
  if (strftime('%x', time()) != strftime('%x', $next)) :
857
  echo strftime('%x', $next)." ";
858
  endif;
859
+ echo strftime('%X', $link->settings['update/last']+((int) $link->settings['update/ttl']*60));
860
  else :
861
+ echo "every ".$link->settings['update/ttl']." minute".(($link->settings['update/ttl']!=1)?"s":"");
862
  endif;
863
  else:
864
  echo "next scheduled update";
930
  <tr>
931
  <th width="20%" scope="row" style="vertical-align:top">Multiple categories:</th>
932
  <td width="80%">
933
+ <input type="text" size="20" id="cat_split" name="cat_split" value="<?php if (isset($link->settings['cat_split'])) : echo htmlspecialchars($link->settings['cat_split']); endif; ?>" /><br/>
934
  Enter a <a href="http://us.php.net/manual/en/reference.pcre.pattern.syntax.php">Perl-compatible regular expression</a> here if the feed provides multiple
935
  categories in a single category element. The regular expression should match
936
  the characters used to separate one category from the next. If the feed uses
944
  fwp_linkedit_periodic_submit();
945
 
946
  if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) :
947
+ fwp_tags_box($link->settings['tags']);
948
  fwp_linkedit_periodic_submit();
949
  endif; ?>
950
 
956
  <th style="text-align: left">Posts by new authors</th>
957
  <td>
958
  <select id="unfamiliar-author" name="unfamiliar_author" onchange="flip_newuser('unfamiliar-author');">
959
+ <option value="site-default"<?php if (!isset($link->settings['unfamiliar author'])) : ?>selected="selected"<?php endif; ?>>are handled using site-wide settings</option>
960
+ <option value="create"<?php if ('create'==$link->settings['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>create a new author account</option>
961
  <?php foreach ($authorlist as $author_id => $author_name) : ?>
962
+ <option value="<?php echo $author_id; ?>"<?php if ($author_id==$link->settings['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>are assigned to <?php echo $author_name; ?></option>
963
  <?php endforeach; ?>
964
  <option value="newuser">will be assigned to a new user...</option>
965
+ <option value="filter"<?php if ('filter'==$link->settings['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>get filtered out</option>
966
  </select>
967
  </td>
968
  <td>
973
 
974
  <tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">For posts by specific authors. Blank out a name to delete the rule.</th></tr>
975
 
976
+ <?php if (isset($link->settings['map authors'])) : $i=0; foreach ($link->settings['map authors'] as $author_rules) : foreach ($author_rules as $author_name => $author_action) : $i++; ?>
977
  <tr>
978
  <th style="text-align: left">Posts by <input type="text" name="author_rules_name[]" value="<?php echo htmlspecialchars($author_name); ?>" /></th>
979
  <td>
1058
 
1059
  <?php
1060
  $i = 0;
1061
+ foreach ($link->settings as $key => $value) :
1062
  if (!preg_match("\007^((".implode(')|(', $special_settings)."))$\007i", $key)) :
1063
  ?>
1064
  <tr style="vertical-align:top">