PluginProbe
FeedWordPress / 2008.1101
FeedWordPress v2008.1101
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
← All changes | syndication.php +511 -251 2009.06122008.1101 View file →
@@ -1,7 +1,6 @@
1 1 <?php
2 2 require_once(dirname(__FILE__) . '/admin-ui.php');
3 -require_once(dirname(__FILE__) . '/magpiemocklink.class.php');
4 3
5 4 ################################################################################
6 5 ## ADMIN MENU ADD-ONS: implement Dashboard management pages ####################
7 6 ################################################################################
@@ -41,21 +40,13 @@
41 40 elseif (isset($_POST['update_uri'])) :
42 41 $update_set[] = $_POST['update_uri'];
43 42 endif;
44 43
45 - shuffle($update_set); // randomize order for load balancing purposes...
44 +
46 45 if ($fwp_update_invoke != 'get' and count($update_set) > 0) : // Only do things with side-effects for HTTP POST or command line
47 46 $feedwordpress =& new FeedWordPress;
48 47 add_action('feedwordpress_check_feed', 'update_feeds_mention');
49 - add_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3);
50 -
51 - $crash_dt = (int) get_option('feedwordpress_update_time_limit');
52 - if ($crash_dt > 0) :
53 - $crash_ts = time() + $crash_dt;
54 - else :
55 - $crash_ts = NULL;
56 - endif;
57 -
48 +
58 49 if (fwp_test_wp_version(FWP_SCHEMA_25)) :
59 50 echo "<div class=\"youare\">\n";
60 51 else :
61 52 echo "<div class=\"updated\">\n";
@@ -62,15 +53,10 @@
62 53 endif;
63 54 echo "<ul>\n";
64 55 $tdelta = NULL;
65 56 foreach ($update_set as $uri) :
66 - if (!is_null($crash_ts) and (time() > $crash_ts)) :
67 - echo "<li><p><strong>Further updates postponed:</strong> update time limit of ".$crash_dt." second".(($crash_dt==1)?"":"s")." exceeded.</p></li>";
68 - break;
69 - endif;
70 -
71 57 if ($uri == '*') : $uri = NULL; endif;
72 - $delta = $feedwordpress->update($uri, $crash_ts);
58 + $delta = $feedwordpress->update($uri);
73 59 if (!is_null($delta)) :
74 60 if (is_null($tdelta)) :
75 61 $tdelta = $delta;
76 62 else :
@@ -119,97 +105,36 @@
119 105 if ($cont):
120 106 ?>
121 107 <?php
122 108 $links = FeedWordPress::syndicated_links();
123 -?>
124 - <div class="wrap">
125 -<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
126 - <div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div>
127 - <h2>Syndicated Sites</h2>
128 -<?php endif;
109 +
129 110 if (fwp_test_wp_version(0, FWP_SCHEMA_25)) :
130 111 fwp_dashboard_update_if_requested();
131 112 endif;
132 113
133 - if (fwp_test_wp_version(FWP_SCHEMA_27)) :
134 -?>
135 - <script type="text/javascript">
136 - jQuery(document).ready( function($) {
137 - // In case someone got here first.
138 - $('.postbox h3, .postbox .handlediv').unbind('click');
139 - $('.hide-postbox-tog').unbind('click');
140 - $('.meta-box-sortables').sortable('destroy');
141 -
142 - postboxes.add_postbox_toggles('feedwordpress_syndication');
143 - } );
144 - </script>
145 -<?php
146 - echo "<form style='display: none' method='get' action=''>\n<p>\n";
147 - wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
148 - wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
149 - echo "</p>\n</form>\n";
150 -
151 - if ($links) :
152 - add_meta_box('feedwordpress_update_box', __('Update feeds now'), 'fwp_syndication_manage_page_update_box', /*page=*/ 'feedwordpress_syndication', /*context =*/ 'normal');
153 - endif;
154 - add_meta_box('feedwordpress_feeds_box', __('Syndicated sources'), 'fwp_syndication_manage_page_links_box', /*page=*/ 'feedwordpress_syndication', /*context =*/ 'normal');
155 -?>
156 - <div class="metabox-holder">
157 - <div id="feedwordpress-sortables" class="meta-box-sortables ui-sortable">
158 -<?php
159 - do_meta_boxes('feedwordpress_syndication', 'normal', NULL);
160 - else :
161 - if ($links): // only display Update panel if there are some links to update....
162 - fwp_syndication_manage_page_update_box();
163 - endif;
164 - fwp_syndication_manage_page_links_box();
165 -?>
166 - </div> <!-- class="wrap" -->
167 -
168 - <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
114 + if ($links): // only display Update panel if there are some links to update....
115 + ?>
116 + <form action="" method="POST">
117 + <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
169 118 <div class="wrap">
170 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
171 - <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
172 - <h2>Add a new syndicated site:</h2>
173 - <div>
174 - <label for="add-uri">Website or feed:</label>
175 - <input type="text" name="lookup" id="add-uri" value="URI" size="64" />
176 - <input type="hidden" name="action" value="feedfinder" />
177 - </div>
178 - <div class="submit"><input type="submit" value="Syndicate &raquo;" /></div>
179 - </form>
180 - </div> <!-- class="wrap" -->
181 - <?php endif; ?>
182 -
183 - <div style="display: none">
184 - <div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
185 - </div>
186 -<?php
187 - endif;
188 -endif;
189 -} /* function fwp_syndication_manage_page () */
190 -
191 -function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) {
192 - $updateFeedsNow = __('Update feeds now');
193 -?>
194 - <form action="" method="POST">
195 - <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
196 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?>
197 119 <div id="rightnow">
198 - <h3 class="reallynow"><span><?php print $updateFeedsNow; ?></span>
120 + <h3 class="reallynow"><span>Update feeds now</span>
199 121 <input type="hidden" name="update_uri" value="*" /><input style="float: right; border: none;" class="rbutton" type="submit" name="update" value="Update" />
200 122 <br class="clear"/></h3>
201 - <?php elseif (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
202 - <h2><?php print $updateFeedsNow; ?></h2>
123 + <?php else : ?>
124 + <div class="wrap">
125 + <h2>Update feeds now</h2>
203 126 <?php endif; ?>
204 127
205 -<?php
128 + <?php
206 129 if (fwp_test_wp_version(FWP_SCHEMA_25)) :
207 130 fwp_dashboard_update_if_requested();
208 131 else :
209 132 ?>
210 133 <p>Check currently scheduled feeds for new and updated posts.</p>
211 -<?php endif; ?>
134 +<?php
135 + endif;
136 + ?>
212 137
213 138 <?php if (!get_option('feedwordpress_automatic_updates')) : ?>
214 139 <p class="youhave"><strong>Note:</strong> Automatic updates are currently turned
215 140 <strong>off</strong>. New posts from your feeds will not be syndicated
@@ -217,35 +142,24 @@
217 142 updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/syndication-options.php">Syndication
218 143 Options</a>.</p>
219 144 <?php endif; ?>
220 145
221 - <?php if (!fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?>
222 - <div class="submit"><input type="hidden" name="update_uri" value="*" /><input class="button-primary" type="submit" name="update" value="Update" /></div>
146 + <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
147 + <div class="submit"><input type="hidden" name="update_uri" value="*" /><input type="submit" name="update" value="Update" /></div>
223 148 <?php endif; ?>
224 -
225 - <?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
226 - <br style="clear: both" />
227 - <?php elseif (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?>
149 +
150 + <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
228 151 </div> <!-- id="rightnow" -->
229 - </div> <!-- class="wrap" -->
230 - <?php elseif (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
231 - </div> <!-- class="wrap" -->
232 152 <?php endif; ?>
153 + </div> <!-- class="wrap" -->
233 154 </form>
234 155 <?php
235 -} /* function fwp_syndication_manage_page_update_box () */
236 -
237 -function fwp_syndication_manage_page_links_box ($object = NULL, $box = NULL) {
238 - $links = FeedWordPress::syndicated_links();
156 + endif;
239 157 ?>
240 - <?php if (!fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
241 - <div class="wrap">
242 - <h2>Syndicated Sites</h2>
243 - <?php endif; ?>
244 158
159 + <div class="wrap">
245 160 <form id="syndicated-links" action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/<?php echo basename(__FILE__); ?>" method="post">
246 - <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
247 -
161 + <h2>Syndicated Sites</h2>
248 162 <?php $alt_row = true; ?>
249 163
250 164 <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
251 165 <div class="tablenav">
@@ -288,14 +202,15 @@
288 202 <table width="100%" cellpadding="3" cellspacing="3">
289 203 <?php endif; ?>
290 204 <thead>
291 205 <tr>
292 -<th class="check-column" scope="col"><?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
293 -<input type="checkbox" <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_26)) : ?>onclick="checkAll(document.getElementById('syndicated-links'));"<?php endif; ?> />
294 -<?php endif; ?></th>
295 -<th scope="col"><?php _e('Name'); ?></th>
296 -<th scope="col"><?php _e('Feed'); ?></th>
297 -<th scope="col"><?php _e('Updated'); ?></th>
206 + <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : $span = 3; ?>
207 + <th class="check-column" scope="col"><input type="checkbox" <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_26)) : ?>onclick="checkAll(document.getElementById('syndicated-links'));"<?php endif; ?> /></th>
208 + <?php else : $span = 4; ?>
209 + <?php endif; ?>
210 +<th width="20%" scope="col"><?php _e('Name'); ?></th>
211 +<th width="40%" scope="col"><?php _e('Feed'); ?></th>
212 +<th class="action-links" scope="col" colspan="<?php print $span; ?>"><?php _e('Action'); ?></th>
298 213 </tr>
299 214 </thead>
300 215
301 216 <tbody>
@@ -301,31 +216,16 @@
301 216 <tbody>
302 217 <?php if (count($links) > 0): foreach ($links as $link):
303 218 $alt_row = !$alt_row; ?>
304 219 <tr<?php echo ($alt_row?' class="alternate"':''); ?>>
220 + <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
305 221 <th class="check-column" scope="row"><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?>" /></th>
306 -<?php
307 - if (strlen($link->link_rss) > 0):
308 - $caption=__('Switch Feed');
309 - else :
310 - $caption=__('Find Feed');
311 - endif;
312 -?>
313 -<td>
314 -<strong><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=linkedit"><?php echo wp_specialchars($link->link_name, 'both'); ?></a></strong>
315 -<div class="row-actions"><div><strong>Settings &gt;</strong>
316 -<a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=linkedit"><?php _e('Feed'); ?></a>
317 -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php _e('Posts'); ?></a>
318 -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/authors-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php _e('Authors'); ?></a>
319 -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/categories-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php _e('Categories &amp; Tags'); ?></a></div>
320 -<div><strong>Actions &gt;</strong>
321 -<a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=feedfinder"><?php echo $caption; ?></a>
322 -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=Unsubscribe"><?php _e('Unsubscribe'); ?></a>
323 -| <a href="<?php echo wp_specialchars($link->link_url, 'both'); ?>"><?php _e('View')?></a></div>
324 -</div>
325 -</td>
222 + <?php endif; ?>
223 +
224 +<td><a href="<?php echo wp_specialchars($link->link_url, 'both'); ?>"><?php echo wp_specialchars($link->link_name, 'both'); ?></a></td>
326 225 <?php
327 226 if (strlen($link->link_rss) > 0):
227 + $caption='Switch Feed';
328 228 $uri_bits = parse_url($link->link_rss);
329 229 $uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']);
330 230 $display_uri =
331 231 (isset($uri_bits['user'])?$uri_bits['user'].'@':'')
@@ -334,39 +234,28 @@
334 234 .(isset($uri_bits['path'])?$uri_bits['path']:'')
335 235 .(isset($uri_bits['query'])?'?'.$uri_bits['query']:'');
336 236 if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'&#8230;'; endif;
337 237 ?>
338 - <td><a href="<?php echo wp_specialchars($link->link_rss, 'both'); ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></td>
339 - <?php else: ?>
238 + <td>
239 + <strong><a href="<?php echo wp_specialchars($link->link_rss, 'both'); ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></strong></td>
240 +<?php
241 + else:
242 + $caption='Find Feed';
243 +?>
340 244 <td style="background-color:#FFFFD0"><p><strong>no
341 245 feed assigned</strong></p></td>
342 - <?php endif; ?>
343 -
344 - <td><?php
345 - $sLink =& new SyndicatedLink($link->link_id);
346 - if (isset($sLink->settings['update/last'])) :
347 - print fwp_time_elapsed($sLink->settings['update/last']);
348 - else :
349 - _e('None yet');
246 +<?php
350 247 endif;
351 -
352 - print "<div style='font-style:italic;size:0.9em'>Ready for next update ";
353 - if (isset($sLink->settings['update/ttl']) and is_numeric($sLink->settings['update/ttl'])) :
354 - if (isset($sLink->settings['update/timed']) and $sLink->settings['update/timed']=='automatically') :
355 - $next = $sLink->settings['update/last'] + ((int) $sLink->settings['update/ttl'] * 60);
356 - print fwp_time_elapsed($next);
357 - else :
358 - echo "every ".$sLink->settings['update/ttl']." minute".(($sLink->settings['update/ttl']!=1)?"s":"");
359 - endif;
360 - else:
361 - echo "as soon as possible";
362 - endif;
363 - print "</div>";
364 248 ?>
365 - </td>
366 - </tr>
249 + <td><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=linkedit" class="edit"><?php _e('Edit')?></a></td>
250 + <td><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=feedfinder" class="edit"><?php echo $caption; ?></a></td>
251 + <td><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=Unsubscribe" class="delete"><?php _e('Unsubscribe'); ?></a></td>
252 + <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
253 + <td><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?>" /></td>
367 254 <?php
368 - endforeach;
255 + endif;
256 + echo "\n\t</tr>";
257 + endforeach;
369 258 else :
370 259 ?>
371 260 <tr><td colspan="<?php print $span+2; ?>"><p>There are no websites currently listed for syndication.</p></td></tr>
372 261 <?php
@@ -381,10 +270,31 @@
381 270 <input type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" /></div>
382 271 <?php endif; ?>
383 272
384 273 </form>
274 +
275 + </div> <!-- class="wrap" -->
276 +
277 + <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
278 + <div class="wrap">
279 + <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
280 + <h2>Add a new syndicated site:</h2>
281 + <div>
282 + <label for="add-uri">Website or newsfeed:</label>
283 + <input type="text" name="lookup" id="add-uri" value="URI" size="64" />
284 + <input type="hidden" name="action" value="feedfinder" />
285 + </div>
286 + <div class="submit"><input type="submit" value="Syndicate &raquo;" /></div>
287 + </form>
288 + </div> <!-- class="wrap" -->
289 + <?php endif; ?>
290 +
291 +<div style="display: none">
292 +<div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
293 +</div>
385 294 <?php
386 -} /* function fwp_syndication_manage_page_links_box() */
295 +endif;
296 +}
387 297
388 298 function fwp_feedfinder_page () {
389 299 global $wpdb;
390 300
@@ -401,9 +311,9 @@
401 311 else:
402 312 die (__("Cheatin' uh ?"));
403 313 endif;
404 314 else:
405 - $name = "<code>".htmlspecialchars($lookup)."</code>";
315 + $name = "New Syndicated Feed";
406 316 $link_id = 0;
407 317 endif;
408 318 ?>
409 319 <div class="wrap">
@@ -416,26 +326,10 @@
416 326 $rss = fetch_rss($f);
417 327 if ($rss):
418 328 $feed_title = isset($rss->channel['title'])?$rss->channel['title']:$rss->channel['link'];
419 329 $feed_link = isset($rss->channel['link'])?$rss->channel['link']:'';
420 - else :
421 - // Give us some sucky defaults
422 - $uri_bits = parse_url($lookup);
423 - $uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']);
424 - $display_uri =
425 - (isset($uri_bits['user'])?$uri_bits['user'].'@':'')
426 - .(isset($uri_bits['host'])?$uri_bits['host']:'')
427 - .(isset($uri_bits['port'])?':'.$uri_bits['port']:'')
428 - .(isset($uri_bits['path'])?$uri_bits['path']:'')
429 - .(isset($uri_bits['query'])?'?'.$uri_bits['query']:'');
430 - if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'&#8230;'; endif;
431 -
432 - $feed_title = $display_uri;
433 - $feed_link = $lookup;
434 - endif;
435 330 ?>
436 331 <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
437 - <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_switchfeed'); ?></div>
438 332 <fieldset style="clear: both">
439 333 <legend><?php echo $rss->feed_type; ?> <?php echo $rss->feed_version; ?> feed</legend>
440 334
441 335 <?php if ($link_id===0): ?>
@@ -449,20 +343,16 @@
449 343
450 344 <div>
451 345 <div style="float:right; background-color:#D0D0D0; color: black; width:45%; font-size:70%; border-left: 1px dotted #A0A0A0; padding-left: 0.5em; margin-left: 1.0em">
452 346 <?php if (count($rss->items) > 0): ?>
453 - <?php
454 - // Prepare to display Sample Item
455 - $link =& new MagpieMockLink($rss, $f);
456 - $post =& new SyndicatedPost($rss->items[0], $link);
457 - ?>
347 + <?php $item = $rss->items[0]; ?>
458 348 <h3>Sample Item</h3>
459 349 <ul>
460 - <li><strong>Title:</strong> <a href="<?php echo $post->post['meta']['syndication_permalink']; ?>"><?php echo $post->post['post_title']; ?></a></li>
461 - <li><strong>Date:</strong> <?php print date('d-M-y g:i:s a', $post->published()); ?></li>
350 + <li><strong>Title:</strong> <a href="<?php echo $item['link']; ?>"><?php echo $item['title']; ?></a></li>
351 + <li><strong>Date:</strong> <?php echo isset($item['date_timestamp']) ? date('d-M-y g:i:s a', $item['date_timestamp']) : 'unknown'; ?></li>
462 352 </ul>
463 353 <div class="entry">
464 - <?php print $post->post['post_content']; ?>
354 + <?php echo (isset($item['content']['encoded'])?$item['content']['encoded']:$item['description']); ?>
465 355 </div>
466 356 <?php else: ?>
467 357 <h3>No Items</h3>
468 358 <p>FeedWordPress found no posts on this feed.</p>
@@ -482,24 +372,17 @@
482 372 </div>
483 373 </div>
484 374 </fieldset>
485 375 </form>
486 -<?php
376 +<?php endif;
487 377 endforeach;
488 378 else:
489 - print "<p><strong>".__('Error').":</strong> ".__("I couldn't find any feeds at").' <code><a href="'.htmlspecialchars($lookup).'">'.htmlspecialchars($lookup).'</a></code>';
490 - if (!is_null($f->error())) :
491 - print " [".__('HTTP request error').": ".htmlspecialchars(trim($f->error()))."]";
492 - endif;
493 - print ". ".__('Try another URL')."</p>";
379 + echo "<p><strong>no feed found</strong></p>";
494 380 endif;
495 381 ?>
496 382 </div>
497 383
498 384 <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
499 - <div><?php
500 - FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds');
501 - ?></div>
502 385 <div class="wrap">
503 386 <h2>Use another feed</h2>
504 387 <div><label>Feed:</label>
505 388 <input type="text" name="lookup" value="URI" />
@@ -514,22 +397,21 @@
514 397
515 398 function fwp_switchfeed_page () {
516 399 global $wpdb, $wp_db_version;
517 400
518 - // If this is a POST, validate source and user credentials
519 - FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links');
520 -
401 + check_admin_referer();
521 402 if (!isset($_REQUEST['Cancel'])):
522 - if (isset($_POST['link_id']) and ($_POST['link_id']==0)):
403 + if (!current_user_can('manage_links')):
404 + die (__("Cheatin' uh ?"));
405 + elseif (isset($_REQUEST['link_id']) and ($_REQUEST['link_id']==0)):
523 406 $link_id = FeedWordPress::syndicate_link($_REQUEST['feed_title'], $_REQUEST['feed_link'], $_REQUEST['feed']);
524 407 if ($link_id): ?>
525 -<div class="updated"><p><a href="<?php echo stripslashes($_REQUEST['feed_link']); ?>"><?php echo wp_specialchars(stripslashes($_REQUEST['feed_title']), 'both'); ?></a>
526 -has been added as a contributing site, using the feed at &lt;<a href="<?php echo stripslashes($_REQUEST['feed']); ?>"><?php echo wp_specialchars(stripslashes($_REQUEST['feed']), 'both'); ?></a>&gt;.
527 -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link_id; ?>&amp;action=linkedit">Configure settings</a>.</div>
408 +<div class="updated"><p><a href="<?php echo $_REQUEST['feed_link']; ?>"><?php echo wp_specialchars($_REQUEST['feed_title'], 'both'); ?></a>
409 +has been added as a contributing site, using the newsfeed at &lt;<a href="<?php echo $_REQUEST['feed']; ?>"><?php echo wp_specialchars($_REQUEST['feed'], 'both'); ?></a>&gt;.</p></div>
528 410 <?php else: ?>
529 -<div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo wp_specialchars(mysql_error(), 'both'); ?>]</p></div>
411 +<div class="updated"><p>There was a problem adding the newsfeed. [SQL: <?php echo wp_specialchars(mysql_error(), 'both'); ?>]</p></div>
530 412 <?php endif;
531 - elseif (isset($_POST['link_id'])):
413 + elseif (isset($_REQUEST['link_id'])):
532 414 // Update link_rss
533 415 $result = $wpdb->query("
534 416 UPDATE $wpdb->links
535 417 SET
@@ -555,10 +437,9 @@
555 437
556 438 function fwp_linkedit_page () {
557 439 global $wpdb, $wp_db_version;
558 440
559 - // If this is a POST, validate source and user credentials
560 - FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_linkedit', /*capability=*/ 'manage_links');
441 + check_admin_referer(); // Make sure we arrived here from the Dashboard
561 442
562 443 $special_settings = array ( /* Regular expression syntax is OK here */
563 444 'cats',
564 445 'cat_split',
@@ -578,9 +459,11 @@
578 459 'feed/.*',
579 460 'link/.*',
580 461 );
581 462
582 - if (isset($_REQUEST['feedfinder'])) :
463 + if (!current_user_can('manage_links')) :
464 + die (__("Cheatin' uh ?"));
465 + elseif (isset($_REQUEST['feedfinder'])) :
583 466 return fwp_feedfinder_page(); // re-route to Feed Finder page
584 467 else :
585 468 $link_id = (int) $_REQUEST['link_id'];
586 469 $link =& new SyndicatedLink($link_id);
@@ -588,8 +471,13 @@
588 471 if ($link->found()) :
589 472 if (isset($GLOBALS['fwp_post']['save'])) :
590 473 $alter = array ();
591 474
475 + $meta = $link->settings;
476 + //if (isset($meta['cats'])):
477 + // $meta['cats'] = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, $meta['cats']);
478 + //endif;
479 +
592 480 // custom feed settings first
593 481 foreach ($GLOBALS['fwp_post']['notes'] as $mn) :
594 482 $mn['key0'] = trim($mn['key0']);
595 483 $mn['key1'] = trim($mn['key1']);
@@ -600,13 +488,13 @@
600 488 $mn['key1'] = 'user/'.$mn['key1'];
601 489 endif;
602 490
603 491 if (strlen($mn['key0']) > 0) :
604 - unset($link->settings[$mn['key0']]); // out with the old
492 + unset($meta[$mn['key0']]); // out with the old
605 493 endif;
606 494
607 495 if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
608 - $link->settings[$mn['key1']] = $mn['value']; // in with the new
496 + $meta[$mn['key1']] = $mn['value']; // in with the new
609 497 endif;
610 498 endforeach;
611 499
612 500 // now stuff through the web form
@@ -611,22 +499,22 @@
611 499
612 500 // now stuff through the web form
613 501 // hardcoded feed info
614 502 if (isset($GLOBALS['fwp_post']['hardcode_name'])) :
615 - $link->settings['hardcode name'] = $GLOBALS['fwp_post']['hardcode_name'];
616 - if (FeedWordPress::affirmative($link->settings, 'hardcode name')) :
503 + $meta['hardcode name'] = $GLOBALS['fwp_post']['hardcode_name'];
504 + if (FeedWordPress::affirmative($meta, 'hardcode name')) :
617 505 $alter[] = "link_name = '".$wpdb->escape($GLOBALS['fwp_post']['name'])."'";
618 506 endif;
619 507 endif;
620 508 if (isset($GLOBALS['fwp_post']['hardcode_description'])) :
621 - $link->settings['hardcode description'] = $GLOBALS['fwp_post']['hardcode_description'];
622 - if (FeedWordPress::affirmative($link->settings, 'hardcode description')) :
509 + $meta['hardcode description'] = $GLOBALS['fwp_post']['hardcode_description'];
510 + if (FeedWordPress::affirmative($meta, 'hardcode description')) :
623 511 $alter[] = "link_description = '".$wpdb->escape($GLOBALS['fwp_post']['description'])."'";
624 512 endif;
625 513 endif;
626 514 if (isset($GLOBALS['fwp_post']['hardcode_url'])) :
627 - $link->settings['hardcode url'] = $GLOBALS['fwp_post']['hardcode_url'];
628 - if (FeedWordPress::affirmative($link->settings, 'hardcode url')) :
515 + $meta['hardcode url'] = $GLOBALS['fwp_post']['hardcode_url'];
516 + if (FeedWordPress::affirmative($meta, 'hardcode url')) :
629 517 $alter[] = "link_url = '".$wpdb->escape($GLOBALS['fwp_post']['linkurl'])."'";
630 518 endif;
631 519 endif;
632 520
@@ -631,13 +519,180 @@
631 519 endif;
632 520
633 521 // Update scheduling
634 522 if (isset($GLOBALS['fwp_post']['update_schedule'])) :
635 - $link->settings['update/hold'] = $GLOBALS['fwp_post']['update_schedule'];
523 + $meta['update/hold'] = $GLOBALS['fwp_post']['update_schedule'];
636 524 endif;
637 525
638 - $alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'";
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;
639 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 +
544 + // Post status, comment status, ping status
545 + foreach (array('post', 'comment', 'ping') as $what) :
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;
555 +
556 + // Unfamiliar author, unfamiliar categories
557 + foreach (array("author", "category") as $what) :
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) :
565 + $userdata = array();
566 + $userdata['ID'] = NULL;
567 +
568 + $userdata['user_login'] = sanitize_user($newuser_name);
569 + $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
570 +
571 + $userdata['user_nicename'] = sanitize_title($newuser_name);
572 + $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
573 +
574 + $userdata['display_name'] = $wpdb->escape($newuser_name);
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;
582 + else :
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));
597 + $author_action = strtolower(trim($GLOBALS['fwp_post']['author_rules_action'][$key]));
598 +
599 + if (strlen($name) > 0) :
600 + if ('newuser' == $author_action) :
601 + $newuser_name = trim($GLOBALS['fwp_post']['author_rules_newuser'][$key]);
602 + if (strlen($newuser_name) > 0) :
603 + $userdata = array();
604 + $userdata['ID'] = NULL;
605 +
606 + $userdata['user_login'] = sanitize_user($newuser_name);
607 + $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
608 +
609 + $userdata['user_nicename'] = sanitize_title($newuser_name);
610 + $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
611 +
612 + $userdata['display_name'] = $wpdb->escape($newuser_name);
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;
620 + else :
621 + // TODO: Add some error reporting
622 + endif;
623 + else :
624 + $meta['map authors']['name'][$name] = $author_action;
625 + endif;
626 + endif;
627 + endforeach;
628 + endif;
629 +
630 + if (isset($GLOBALS['fwp_post']['add_author_rule_name']) and isset($GLOBALS['fwp_post']['add_author_rule_action'])) :
631 + $name = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_name']));
632 + $author_action = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_action']));
633 + if (strlen($name) > 0) :
634 + if ('newuser' == $author_action) :
635 + $newuser_name = trim($GLOBALS['fwp_post']['add_author_rule_newuser']);
636 + if (strlen($newuser_name) > 0) :
637 + $userdata = array();
638 + $userdata['ID'] = NULL;
639 +
640 + $userdata['user_login'] = sanitize_user($newuser_name);
641 + $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
642 +
643 + $userdata['user_nicename'] = sanitize_title($newuser_name);
644 + $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
645 +
646 + $userdata['display_name'] = $wpdb->escape($newuser_name);
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;
654 + else :
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 +
640 695 $alter_set = implode(", ", $alter);
641 696
642 697 // issue update query
643 698 $result = $wpdb->query("
@@ -647,11 +702,8 @@
647 702 ");
648 703 $updated_link = true;
649 704
650 705 // reload link information from DB
651 - if (function_exists('clean_bookmark_cache')) :
652 - clean_bookmark_cache($link_id);
653 - endif;
654 706 $link =& new SyndicatedLink($link_id);
655 707 else :
656 708 $updated_link = false;
657 709 endif;
@@ -659,9 +711,50 @@
659 711 $db_link = $link->link;
660 712 $link_url = wp_specialchars($db_link->link_url, 1);
661 713 $link_name = wp_specialchars($db_link->link_name, 1);
662 714 $link_description = wp_specialchars($db_link->link_description, 'both');
715 + $link_notes = wp_specialchars($db_link->link_notes, 'both');
663 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');
722 +
723 + $status['post'] = array('publish' => '', 'private' => '', 'draft' => '', 'site-default' => '');
724 + if (SyndicatedPost::use_api('post_status_pending')) :
725 + $status['post']['pending'] = '';
726 + endif;
727 +
728 + $status['comment'] = array('open' => '', 'closed' => '', 'site-default' => '');
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;
737 + endforeach;
738 +
739 + $unfamiliar['author'] = array ('create' => '','default' => '','filter' => '');
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 +
756 + $dogs = SyndicatedPost::category_ids($cats, /*unfamiliar=*/ NULL);
664 757 else :
665 758 die( __('Link not found.') );
666 759 endif;
667 760
@@ -674,8 +767,25 @@
674 767 o = document.getElementById('basics-hardcode-'+item);
675 768 if (o.value=='yes') { ed.style.display='inline'; view.style.display='none'; }
676 769 else { ed.style.display='none'; view.style.display='inline'; }
677 770 }
771 + function flip_newuser (item) {
772 + rollup=document.getElementById(item);
773 + newuser=document.getElementById(item+'-newuser');
774 + sitewide=document.getElementById(item+'-default');
775 + if (rollup) {
776 + if ('newuser'==rollup.value) {
777 + if (newuser) newuser.style.display='block';
778 + if (sitewide) sitewide.style.display='none';
779 + } else if ('site-default'==rollup.value) {
780 + if (newuser) newuser.style.display='none';
781 + if (sitewide) sitewide.style.display='block';
782 + } else {
783 + if (newuser) newuser.style.display='none';
784 + if (sitewide) sitewide.style.display='none';
785 + }
786 + }
787 + }
678 788 </script>
679 789
680 790 <?php if ($updated_link) : ?>
681 791 <div class="updated"><p>Syndicated feed settings updated.</p></div>
@@ -682,19 +792,13 @@
682 792 <?php endif; ?>
683 793
684 794 <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
685 795 <div class="wrap">
686 -<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_linkedit'); ?>
687 796 <input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
688 797 <input type="hidden" name="action" value="linkedit" />
689 798 <input type="hidden" name="save" value="link" />
690 799
691 -<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
692 - <div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div>
693 -<?php endif; ?>
694 -
695 -<h2><?php _e('Feed settings'); ?><?php if (!is_null($link) and $link->found()) : ?>: <?php echo wp_specialchars($link->link->link_name, 1); ?><?php endif; ?></h2>
696 -
800 +<h2>Edit a syndicated feed:</h2>
697 801 <div id="poststuff">
698 802 <?php fwp_linkedit_single_submit($status); ?>
699 803
700 804 <div id="post-body">
@@ -747,10 +851,10 @@
747 851
748 852 <tr>
749 853 <th width="20%"><?php _e('Last update') ?>:</th>
750 854 <td colspan="2"><?php
751 - if (isset($link->settings['update/last'])) :
752 - echo fwp_time_elapsed($link->settings['update/last'])." ";
855 + if (isset($meta['update/last'])) :
856 + echo strftime('%x %X', $meta['update/last'])." ";
753 857 else :
754 858 echo " none yet";
755 859 endif;
756 860 ?></td></tr>
@@ -755,23 +859,23 @@
755 859 endif;
756 860 ?></td></tr>
757 861 <tr><th width="20%">Next update:</th>
758 862 <td colspan="2"><?php
759 - $holdem = (isset($link->settings['update/hold']) ? $link->settings['update/hold'] : 'scheduled');
863 + $holdem = (isset($meta['update/hold']) ? $meta['update/hold'] : 'scheduled');
760 864 ?>
761 865 <select name="update_schedule">
762 866 <option value="scheduled"<?php echo ($holdem=='scheduled')?' selected="selected"':''; ?>>update on schedule <?php
763 867 echo " (";
764 - if (isset($link->settings['update/ttl']) and is_numeric($link->settings['update/ttl'])) :
765 - if (isset($link->settings['update/timed']) and $link->settings['update/timed']=='automatically') :
868 + if (isset($meta['update/ttl']) and is_numeric($meta['update/ttl'])) :
869 + if (isset($meta['update/timed']) and $meta['update/timed']=='automatically') :
766 870 echo 'next: ';
767 - $next = $link->settings['update/last'] + ((int) $link->settings['update/ttl'] * 60);
871 + $next = $meta['update/last'] + ((int) $meta['update/ttl'] * 60);
768 872 if (strftime('%x', time()) != strftime('%x', $next)) :
769 873 echo strftime('%x', $next)." ";
770 874 endif;
771 - echo strftime('%X', $link->settings['update/last']+((int) $link->settings['update/ttl']*60));
875 + echo strftime('%X', $meta['update/last']+((int) $meta['update/ttl']*60));
772 876 else :
773 - echo "every ".$link->settings['update/ttl']." minute".(($link->settings['update/ttl']!=1)?"s":"");
877 + echo "every ".$meta['update/ttl']." minute".(($meta['update/ttl']!=1)?"s":"");
774 878 endif;
775 879 else:
776 880 echo "next scheduled update";
777 881 endif;
@@ -791,19 +895,176 @@
791 895
792 896 <?php fwp_linkedit_periodic_submit(); ?>
793 897
794 898 <?php
795 - FeedWordPressSettingsUI::instead_of_posts_box($link_id);
796 - FeedWordPressSettingsUI::instead_of_authors_box($link_id);
797 - FeedWordPressSettingsUI::instead_of_categories_box($link_id);
899 +if (!(isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25)) :
900 + fwp_option_box_opener('Syndicated Posts', 'syndicatedpostsdiv', 'postbox');
901 +?>
902 +<table class="editform" width="75%" cellspacing="2" cellpadding="5">
903 +<tr><th width="27%" scope="row" style="vertical-align:top">Publication:</th>
904 +<td width="73%" style="vertical-align:top"><ul style="margin:0; list-style:none">
905 +<li><label><input type="radio" name="feed_post_status" value="site-default"
906 +<?php echo $status['post']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a>
907 +(currently: <strong><?php echo ($post_status_global ? $post_status_global : 'publish'); ?></strong>)</label></li>
908 +<li><label><input type="radio" name="feed_post_status" value="publish"
909 +<?php echo $status['post']['publish']; ?> /> Publish posts from this feed immediately</label></li>
798 910
799 - fwp_option_box_opener('Custom Feed Settings (for use in templates)', 'postcustom', 'postbox');
911 +<?php if (SyndicatedPost::use_api('post_status_pending')) : ?>
912 +<li><label><input type="radio" name="feed_post_status" value="pending"
913 +<?php echo $status['post']['pending']; ?>/> Hold posts from this feed for review; mark as Pending</label></li>
914 +<?php endif; ?>
915 +
916 +<li><label><input type="radio" name="feed_post_status" value="draft"
917 +<?php echo $status['post']['draft']; ?> /> Save posts from this feed as drafts</label></li>
918 +<li><label><input type="radio" name="feed_post_status" value="private"
919 +<?php echo $status['post']['private']; ?> /> Save posts from this feed as private posts</label></li>
920 +</ul></td>
921 +</tr>
922 +</table>
923 +<?php
924 + fwp_option_box_closer();
925 + fwp_linkedit_periodic_submit();
926 +endif;
927 +
928 + fwp_option_box_opener(__('Categories'), 'categorydiv', 'postbox');
929 + fwp_category_box($dogs, 'all syndicated posts from this feed');
800 930 ?>
801 -<p class="setting-description">These custom settings are special fields for the <strong>feed</strong> you are
802 -syndicating, to be retrieved in templates using the <code>get_feed_meta()</code> function. They do not create
803 -custom fields on syndicated <strong>posts</strong>. If you want to create custom fields that are applied to each
804 -individual post from this feed, set up the settings in <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php&amp;link_id=<?php print $link_id; ?>">Syndicated Posts</a>.</p>
931 +<table>
932 +<tr>
933 +<th width="20%" scope="row" style="vertical-align:top">Unfamiliar categories:</th>
934 +<td width="80%"><p>When one of the categories on a syndicated post is a category that FeedWordPress has not encountered before ...</p>
805 935
936 +<ul style="margin: 0; list-style:none">
937 +<li><label><input type="radio" name="unfamiliar_category" value="site-default"<?php echo $unfamiliar['category']['site-default']; ?> /> use the site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a>
938 +(currently <strong><?php echo FeedWordPress::on_unfamiliar('category'); ?></strong>)</label></li>
939 +<li><label><input type="radio" name="unfamiliar_category" value="create"<?php echo $unfamiliar['category']['create']; ?> /> create a new category</label></li>
940 +<li><label><input type="radio" name="unfamiliar_category" value="tag"<?php echo $unfamiliar['category']['tag']; ?>/> create a new tag</label></li>
941 +<li><label><input type="radio" name="unfamiliar_category" value="default"<?php echo $unfamiliar['category']['default']; ?> /> don't create new categories or tags</label></li>
942 +<li><label><input type="radio" name="unfamiliar_category" value="filter"<?php echo $unfamiliar['category']['filter']; ?> /> don't create new categories or tags and don't syndicate posts unless they match at least one familiar category</label></li>
943 +</ul></td>
944 +</tr>
945 +
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
953 +spaces (like <a href="http://del.icio.us/">del.icio.us</a>), use the pattern "\s".
954 +If the feed does not provide multiple categories in a single element, leave this
955 +blank.</td>
956 +</tr>
957 +</table>
958 +<?php
959 + fwp_option_box_closer();
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 +
967 +<?php fwp_option_box_opener('Syndicated Authors', 'authordiv', 'postbox'); ?>
968 +<?php $authorlist = fwp_author_list(); ?>
969 +<table>
970 +<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>
971 +<tr>
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>
985 + <div id="unfamiliar-author-default">Site-wide settings can be set in <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a></div>
986 + <div id="unfamiliar-author-newuser">named <input type="text" name="unfamiliar_author_newuser" value="" /></div>
987 + </td>
988 +</tr>
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>
996 + <select id="author-rules-<?php echo $i; ?>" name="author_rules_action[]" onchange="flip_newuser('author-rules-<?php echo $i; ?>');">
997 + <?php foreach ($authorlist as $local_author_id => $local_author_name) : ?>
998 + <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>
999 + <?php endforeach; ?>
1000 + <option value="newuser">will be assigned to a new user...</option>
1001 + <option value="filter"<?php if ('filter'==$author_action) : echo ' selected="selected"'; endif; ?>>get filtered out</option>
1002 + </select>
1003 + </td>
1004 + <td><div id="author-rules-<?php echo $i; ?>-newuser">named <input type="text" name="author_rules_newuser[]" value="" /></div></td>
1005 +</tr>
1006 +<?php endforeach; endforeach; endif; ?>
1007 +
1008 +<tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">Fill in to set up a new rule:</th></tr>
1009 +
1010 +<tr>
1011 + <th style="text-align: left">Posts by <input type="text" name="add_author_rule_name" /></th>
1012 + <td>
1013 + <select id="add-author-rule" name="add_author_rule_action" onchange="flip_newuser('add-author-rule');">
1014 + <?php foreach ($authorlist as $author_id => $author_name) : ?>
1015 + <option value="<?php echo $author_id; ?>">are assigned to <?php echo $author_name; ?></option>
1016 + <?php endforeach; ?>
1017 + <option value="newuser">will be assigned to a new user...</option>
1018 + <option value="filter">get filtered out</option>
1019 + </select>
1020 + </td>
1021 + <td><div id="add-author-rule-newuser">named <input type="text" name="add_author_rule_newuser" value="" /></div></td>
1022 +</tr>
1023 +
1024 +</table>
1025 +<?php fwp_option_box_closer(); ?>
1026 +
1027 +<script>
1028 + flip_newuser('unfamiliar-author');
1029 +<?php for ($j=1; $j<=$i; $j++) : ?>
1030 + flip_newuser('author-rules-<?php echo $j; ?>');
1031 +<?php endfor; ?>
1032 + flip_newuser('add-author-rule');
1033 +</script>
1034 +
1035 +<?php
1036 + fwp_linkedit_periodic_submit();
1037 + fwp_option_box_opener('Comments & Pings', 'commentstatusdiv', 'postbox');
1038 +?>
1039 +<table class="editform" width="75%" cellspacing="2" cellpadding="5">
1040 +<tr><th width="27%" scope="row" style="vertical-align:top"><?php print __('Comments'); ?>:</th>
1041 +<td width="73%"><ul style="margin:0; list-style:none">
1042 +<li><label><input type="radio" name="feed_comment_status" value="site-default"
1043 +<?php echo $status['comment']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a>
1044 +(currently: <strong><?php echo ($comment_status_global ? $comment_status_global : 'closed'); ?>)</strong></label></li>
1045 +<li><label><input type="radio" name="feed_comment_status" value="open"
1046 +<?php echo $status['comment']['open']; ?> /> Allow comments on syndicated posts from this feed</label></li>
1047 +<li><label><input type="radio" name="feed_comment_status" value="closed"
1048 +<?php echo $status['comment']['closed']; ?> /> Don't allow comments on syndicated posts from this feed</label></li>
1049 +</ul></td></tr>
1050 +
1051 +<tr><th width="27%" scope="row" style="vertical-align:top"><?php print __('Pings'); ?>:</th>
1052 +<td width="73%"><ul style="margin:0; list-style:none">
1053 +<li><label><input type="radio" name="feed_ping_status" value="site-default"
1054 +<?php echo $status['ping']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a>
1055 +(currently: <strong><?php echo ($ping_status_global ? $ping_status_global : 'closed'); ?>)</strong></label></li>
1056 +<li><label><input type="radio" name="feed_ping_status" value="open"
1057 +<?php echo $status['ping']['open']; ?> /> Accept pings on syndicated posts from this feed</label></li>
1058 +<li><label><input type="radio" name="feed_ping_status" value="closed"
1059 +<?php echo $status['ping']['closed']; ?> /> Don't accept pings on syndicated posts from this feed</label></li>
1060 +</ul></td></tr>
1061 +
1062 +</table>
1063 +<?php fwp_option_box_closer(); ?>
1064 +<?php fwp_linkedit_periodic_submit(); ?>
1065 +
1066 +<?php fwp_option_box_opener('Custom Settings (for use in templates)', 'postcustom', 'postbox'); ?>
806 1067 <div id="postcustomstuff">
807 1068 <table id="meta-list" cellpadding="3">
808 1069 <tr>
809 1070 <th>Key</th>
@@ -812,9 +1073,9 @@
812 1073 </tr>
813 1074
814 1075 <?php
815 1076 $i = 0;
816 - foreach ($link->settings as $key => $value) :
1077 + foreach ($meta as $key => $value) :
817 1078 if (!preg_match("\007^((".implode(')|(', $special_settings)."))$\007i", $key)) :
818 1079 ?>
819 1080 <tr style="vertical-align:top">
820 1081 <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo wp_specialchars($key, 'both'); ?>" />
@@ -838,9 +1099,8 @@
838 1099 </table>
839 1100 <?php fwp_option_box_closer(); ?>
840 1101
841 1102 <?php fwp_linkedit_periodic_submit(); ?>
842 -<?php fwp_linkedit_single_submit_closer(); ?>
843 1103 </div> <!-- id="post-body" -->
844 1104 </div> <!-- id="poststuff" -->
845 1105 </div>
846 1106 <?php
@@ -850,15 +1110,16 @@
850 1110
851 1111 function fwp_multidelete_page () {
852 1112 global $wpdb;
853 1113
854 - // If this is a POST, validate source and user credentials
855 - FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links');
1114 + check_admin_referer(); // Make sure the referers are kosher
856 1115
857 1116 $link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array());
858 1117 if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif;
859 1118
860 - if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'):
1119 + if (!current_user_can('manage_links')):
1120 + die (__("Cheatin' uh ?"));
1121 + elseif (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'):
861 1122 foreach ($GLOBALS['fwp_post']['link_action'] as $link_id => $what) :
862 1123 $do_it[$what][] = $link_id;
863 1124 endforeach;
864 1125
@@ -939,9 +1200,8 @@
939 1200 ");
940 1201 ?>
941 1202 <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
942 1203 <div class="wrap">
943 -<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
944 1204 <input type="hidden" name="action" value="Unsubscribe" />
945 1205 <input type="hidden" name="confirm" value="Delete" />
946 1206
947 1207 <h2>Unsubscribe from Syndicated Links:</h2>