PluginProbe
FeedWordPress / 2009.0618
FeedWordPress v2009.0618
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 +275 -461 2008.11052009.0618 View file →
@@ -1,7 +1,50 @@
1 1 <?php
2 2 require_once(dirname(__FILE__) . '/admin-ui.php');
3 +require_once(dirname(__FILE__) . '/magpiemocklink.class.php');
4 +require_once(dirname(__FILE__) . '/feedfinder.class.php');
3 5
6 +$FeedWordPressHTTPStatusMessages = array (
7 + 200 => 'OK. FeedWordPress had no problems retrieving the content at this URL but the content does not seem to be a feed, and does not seem to include links to any feeds.',
8 + 201 => 'Created',
9 + 202 => 'Accepted',
10 + 203 => 'Non-Authoritative information',
11 + 204 => 'No Content',
12 + 205 => 'Reset Content',
13 + 206 => 'Partial Content',
14 + 300 => 'Multiple Choices',
15 + 301 => 'Moved Permanently',
16 + 302 => 'Found',
17 + 303 => 'See Other',
18 + 304 => 'Not Modified',
19 + 305 => 'Use Proxy',
20 + 307 => 'Temporary Redirect',
21 + 400 => 'Bad Request',
22 + 401 => 'Unauthorized. This URL probably needs a username and password for you to access it.',
23 + 402 => 'Payment Required',
24 + 403 => 'Forbidden. The URL is not made available for the machine that FeedWordPress is running on.',
25 + 404 => 'Not Found. There is nothing at this URL. Have you checked the address for typos?',
26 + 405 => 'Method Not Allowed',
27 + 406 => 'Not Acceptable',
28 + 407 => 'Proxy Authentication Required',
29 + 408 => 'Request Timeout',
30 + 409 => 'Conflict',
31 + 410 => 'Gone. This URL is no longer available on this server and no forwarding address is known.',
32 + 411 => 'Length Required',
33 + 412 => 'Precondition Failed',
34 + 413 => 'Request Entity Too Large',
35 + 414 => 'Request URI Too Long',
36 + 415 => 'Unsupported Media Type',
37 + 416 => 'Requested Range Not Satisfiable',
38 + 417 => 'Expectation Failed',
39 + 500 => 'Internal Server Error. Something unexpected went wrong with the configuration of the server that hosts this URL. You might try again later to see if this issue has been resolved.',
40 + 501 => 'Not Implemented',
41 + 502 => 'Bad Gateway',
42 + 503 => 'Service Unavailable. The server is currently unable to handle the request due to a temporary overloading or maintenance of the server that hosts this URL. This is probably a temporary condition and you should try again later to see if the issue has been resolved.',
43 + 504 => 'Gateway Timeout',
44 + 505 => 'HTTP Version Not Supported',
45 +);
46 +
4 47 ################################################################################
5 48 ## ADMIN MENU ADD-ONS: implement Dashboard management pages ####################
6 49 ################################################################################
7 50
@@ -118,36 +161,97 @@
118 161 if ($cont):
119 162 ?>
120 163 <?php
121 164 $links = FeedWordPress::syndicated_links();
122 -
165 +?>
166 + <div class="wrap">
167 +<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
168 + <div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div>
169 + <h2>Syndicated Sites</h2>
170 +<?php endif;
123 171 if (fwp_test_wp_version(0, FWP_SCHEMA_25)) :
124 172 fwp_dashboard_update_if_requested();
125 173 endif;
126 174
127 - if ($links): // only display Update panel if there are some links to update....
128 - ?>
175 + if (fwp_test_wp_version(FWP_SCHEMA_27)) :
176 +?>
177 + <script type="text/javascript">
178 + jQuery(document).ready( function($) {
179 + // In case someone got here first.
180 + $('.postbox h3, .postbox .handlediv').unbind('click');
181 + $('.hide-postbox-tog').unbind('click');
182 + $('.meta-box-sortables').sortable('destroy');
183 +
184 + postboxes.add_postbox_toggles('feedwordpress_syndication');
185 + } );
186 + </script>
187 +<?php
188 + echo "<form style='display: none' method='get' action=''>\n<p>\n";
189 + wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
190 + wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
191 + echo "</p>\n</form>\n";
192 +
193 + if ($links) :
194 + add_meta_box('feedwordpress_update_box', __('Update feeds now'), 'fwp_syndication_manage_page_update_box', /*page=*/ 'feedwordpress_syndication', /*context =*/ 'normal');
195 + endif;
196 + add_meta_box('feedwordpress_feeds_box', __('Syndicated sources'), 'fwp_syndication_manage_page_links_box', /*page=*/ 'feedwordpress_syndication', /*context =*/ 'normal');
197 +?>
198 + <div class="metabox-holder">
199 + <div id="feedwordpress-sortables" class="meta-box-sortables ui-sortable">
200 +<?php
201 + do_meta_boxes('feedwordpress_syndication', 'normal', NULL);
202 + else :
203 + if ($links): // only display Update panel if there are some links to update....
204 + fwp_syndication_manage_page_update_box();
205 + endif;
206 + fwp_syndication_manage_page_links_box();
207 +?>
208 + </div> <!-- class="wrap" -->
209 +
210 + <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
211 + <div class="wrap">
212 + <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
213 + <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
214 + <h2>Add a new syndicated site:</h2>
215 + <div>
216 + <label for="add-uri">Website or feed:</label>
217 + <input type="text" name="lookup" id="add-uri" value="URI" size="64" />
218 + <input type="hidden" name="action" value="feedfinder" />
219 + </div>
220 + <div class="submit"><input type="submit" value="Syndicate &raquo;" /></div>
221 + </form>
222 + </div> <!-- class="wrap" -->
223 + <?php endif; ?>
224 +
225 + <div style="display: none">
226 + <div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
227 + </div>
228 +<?php
229 + endif;
230 +endif;
231 +} /* function fwp_syndication_manage_page () */
232 +
233 +function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) {
234 + $updateFeedsNow = __('Update feeds now');
235 +?>
129 236 <form action="" method="POST">
130 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
131 - <div class="wrap">
237 + <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
238 + <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?>
132 239 <div id="rightnow">
133 - <h3 class="reallynow"><span>Update feeds now</span>
240 + <h3 class="reallynow"><span><?php print $updateFeedsNow; ?></span>
134 241 <input type="hidden" name="update_uri" value="*" /><input style="float: right; border: none;" class="rbutton" type="submit" name="update" value="Update" />
135 242 <br class="clear"/></h3>
136 - <?php else : ?>
137 - <div class="wrap">
138 - <h2>Update feeds now</h2>
243 + <?php elseif (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
244 + <h2><?php print $updateFeedsNow; ?></h2>
139 245 <?php endif; ?>
140 246
141 - <?php
247 +<?php
142 248 if (fwp_test_wp_version(FWP_SCHEMA_25)) :
143 249 fwp_dashboard_update_if_requested();
144 250 else :
145 251 ?>
146 252 <p>Check currently scheduled feeds for new and updated posts.</p>
147 -<?php
148 - endif;
149 - ?>
253 +<?php endif; ?>
150 254
151 255 <?php if (!get_option('feedwordpress_automatic_updates')) : ?>
152 256 <p class="youhave"><strong>Note:</strong> Automatic updates are currently turned
153 257 <strong>off</strong>. New posts from your feeds will not be syndicated
@@ -155,24 +259,35 @@
155 259 updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/syndication-options.php">Syndication
156 260 Options</a>.</p>
157 261 <?php endif; ?>
158 262
159 - <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
160 - <div class="submit"><input type="hidden" name="update_uri" value="*" /><input type="submit" name="update" value="Update" /></div>
263 + <?php if (!fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?>
264 + <div class="submit"><input type="hidden" name="update_uri" value="*" /><input class="button-primary" type="submit" name="update" value="Update" /></div>
161 265 <?php endif; ?>
162 -
163 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
266 +
267 + <?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
268 + <br style="clear: both" />
269 + <?php elseif (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?>
164 270 </div> <!-- id="rightnow" -->
271 + </div> <!-- class="wrap" -->
272 + <?php elseif (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
273 + </div> <!-- class="wrap" -->
165 274 <?php endif; ?>
166 - </div> <!-- class="wrap" -->
167 275 </form>
168 276 <?php
169 - endif;
277 +} /* function fwp_syndication_manage_page_update_box () */
278 +
279 +function fwp_syndication_manage_page_links_box ($object = NULL, $box = NULL) {
280 + $links = FeedWordPress::syndicated_links();
170 281 ?>
282 + <?php if (!fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
283 + <div class="wrap">
284 + <h2>Syndicated Sites</h2>
285 + <?php endif; ?>
171 286
172 - <div class="wrap">
173 287 <form id="syndicated-links" action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/<?php echo basename(__FILE__); ?>" method="post">
174 - <h2>Syndicated Sites</h2>
288 + <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
289 +
175 290 <?php $alt_row = true; ?>
176 291
177 292 <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
178 293 <div class="tablenav">
@@ -215,15 +330,14 @@
215 330 <table width="100%" cellpadding="3" cellspacing="3">
216 331 <?php endif; ?>
217 332 <thead>
218 333 <tr>
219 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : $span = 3; ?>
220 - <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>
221 - <?php else : $span = 4; ?>
222 - <?php endif; ?>
223 -<th width="20%" scope="col"><?php _e('Name'); ?></th>
224 -<th width="40%" scope="col"><?php _e('Feed'); ?></th>
225 -<th class="action-links" scope="col" colspan="<?php print $span; ?>"><?php _e('Action'); ?></th>
334 +<th class="check-column" scope="col"><?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
335 +<input type="checkbox" <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_26)) : ?>onclick="checkAll(document.getElementById('syndicated-links'));"<?php endif; ?> />
336 +<?php endif; ?></th>
337 +<th scope="col"><?php _e('Name'); ?></th>
338 +<th scope="col"><?php _e('Feed'); ?></th>
339 +<th scope="col"><?php _e('Updated'); ?></th>
226 340 </tr>
227 341 </thead>
228 342
229 343 <tbody>
@@ -229,16 +343,31 @@
229 343 <tbody>
230 344 <?php if (count($links) > 0): foreach ($links as $link):
231 345 $alt_row = !$alt_row; ?>
232 346 <tr<?php echo ($alt_row?' class="alternate"':''); ?>>
233 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
234 347 <th class="check-column" scope="row"><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?>" /></th>
235 - <?php endif; ?>
236 -
237 -<td><a href="<?php echo wp_specialchars($link->link_url, 'both'); ?>"><?php echo wp_specialchars($link->link_name, 'both'); ?></a></td>
348 +<?php
349 + if (strlen($link->link_rss) > 0):
350 + $caption=__('Switch Feed');
351 + else :
352 + $caption=__('Find Feed');
353 + endif;
354 +?>
355 +<td>
356 +<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>
357 +<div class="row-actions"><div><strong>Settings &gt;</strong>
358 +<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>
359 +| <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>
360 +| <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>
361 +| <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>
362 +<div><strong>Actions &gt;</strong>
363 +<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>
364 +| <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>
365 +| <a href="<?php echo wp_specialchars($link->link_url, 'both'); ?>"><?php _e('View')?></a></div>
366 +</div>
367 +</td>
238 368 <?php
239 369 if (strlen($link->link_rss) > 0):
240 - $caption='Switch Feed';
241 370 $uri_bits = parse_url($link->link_rss);
242 371 $uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']);
243 372 $display_uri =
244 373 (isset($uri_bits['user'])?$uri_bits['user'].'@':'')
@@ -247,28 +376,39 @@
247 376 .(isset($uri_bits['path'])?$uri_bits['path']:'')
248 377 .(isset($uri_bits['query'])?'?'.$uri_bits['query']:'');
249 378 if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'&#8230;'; endif;
250 379 ?>
251 - <td>
252 - <strong><a href="<?php echo wp_specialchars($link->link_rss, 'both'); ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></strong></td>
253 -<?php
254 - else:
255 - $caption='Find Feed';
256 -?>
380 + <td><a href="<?php echo wp_specialchars($link->link_rss, 'both'); ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></td>
381 + <?php else: ?>
257 382 <td style="background-color:#FFFFD0"><p><strong>no
258 383 feed assigned</strong></p></td>
259 -<?php
384 + <?php endif; ?>
385 +
386 + <td><?php
387 + $sLink =& new SyndicatedLink($link->link_id);
388 + if (isset($sLink->settings['update/last'])) :
389 + print fwp_time_elapsed($sLink->settings['update/last']);
390 + else :
391 + _e('None yet');
260 392 endif;
393 +
394 + print "<div style='font-style:italic;size:0.9em'>Ready for next update ";
395 + if (isset($sLink->settings['update/ttl']) and is_numeric($sLink->settings['update/ttl'])) :
396 + if (isset($sLink->settings['update/timed']) and $sLink->settings['update/timed']=='automatically') :
397 + $next = $sLink->settings['update/last'] + ((int) $sLink->settings['update/ttl'] * 60);
398 + print fwp_time_elapsed($next);
399 + else :
400 + echo "every ".$sLink->settings['update/ttl']." minute".(($sLink->settings['update/ttl']!=1)?"s":"");
401 + endif;
402 + else:
403 + echo "as soon as possible";
404 + endif;
405 + print "</div>";
261 406 ?>
262 - <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>
263 - <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>
264 - <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>
265 - <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
266 - <td><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?>" /></td>
407 + </td>
408 + </tr>
267 409 <?php
268 - endif;
269 - echo "\n\t</tr>";
270 - endforeach;
410 + endforeach;
271 411 else :
272 412 ?>
273 413 <tr><td colspan="<?php print $span+2; ?>"><p>There are no websites currently listed for syndication.</p></td></tr>
274 414 <?php
@@ -283,34 +423,14 @@
283 423 <input type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" /></div>
284 424 <?php endif; ?>
285 425
286 426 </form>
287 -
288 - </div> <!-- class="wrap" -->
289 -
290 - <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
291 - <div class="wrap">
292 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
293 - <h2>Add a new syndicated site:</h2>
294 - <div>
295 - <label for="add-uri">Website or newsfeed:</label>
296 - <input type="text" name="lookup" id="add-uri" value="URI" size="64" />
297 - <input type="hidden" name="action" value="feedfinder" />
298 - </div>
299 - <div class="submit"><input type="submit" value="Syndicate &raquo;" /></div>
300 - </form>
301 - </div> <!-- class="wrap" -->
302 - <?php endif; ?>
303 -
304 -<div style="display: none">
305 -<div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
306 -</div>
307 427 <?php
308 -endif;
309 -}
428 +} /* function fwp_syndication_manage_page_links_box() */
310 429
311 430 function fwp_feedfinder_page () {
312 431 global $wpdb;
432 + global $FeedWordPressHTTPStatusMessages;
313 433
314 434 $lookup = (isset($_REQUEST['lookup'])?$_REQUEST['lookup']:NULL);
315 435
316 436 if (isset($_REQUEST['link_id']) and ($_REQUEST['link_id']!=0)):
@@ -324,9 +444,9 @@
324 444 else:
325 445 die (__("Cheatin' uh ?"));
326 446 endif;
327 447 else:
328 - $name = "New Syndicated Feed";
448 + $name = "<code>".htmlspecialchars($lookup)."</code>";
329 449 $link_id = 0;
330 450 endif;
331 451 ?>
332 452 <div class="wrap">
@@ -339,10 +459,26 @@
339 459 $rss = fetch_rss($f);
340 460 if ($rss):
341 461 $feed_title = isset($rss->channel['title'])?$rss->channel['title']:$rss->channel['link'];
342 462 $feed_link = isset($rss->channel['link'])?$rss->channel['link']:'';
463 + else :
464 + // Give us some sucky defaults
465 + $uri_bits = parse_url($lookup);
466 + $uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']);
467 + $display_uri =
468 + (isset($uri_bits['user'])?$uri_bits['user'].'@':'')
469 + .(isset($uri_bits['host'])?$uri_bits['host']:'')
470 + .(isset($uri_bits['port'])?':'.$uri_bits['port']:'')
471 + .(isset($uri_bits['path'])?$uri_bits['path']:'')
472 + .(isset($uri_bits['query'])?'?'.$uri_bits['query']:'');
473 + if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'&#8230;'; endif;
474 +
475 + $feed_title = $display_uri;
476 + $feed_link = $lookup;
477 + endif;
343 478 ?>
344 479 <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
480 + <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_switchfeed'); ?></div>
345 481 <fieldset style="clear: both">
346 482 <legend><?php echo $rss->feed_type; ?> <?php echo $rss->feed_version; ?> feed</legend>
347 483
348 484 <?php if ($link_id===0): ?>
@@ -356,16 +492,20 @@
356 492
357 493 <div>
358 494 <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">
359 495 <?php if (count($rss->items) > 0): ?>
360 - <?php $item = $rss->items[0]; ?>
496 + <?php
497 + // Prepare to display Sample Item
498 + $link =& new MagpieMockLink($rss, $f);
499 + $post =& new SyndicatedPost($rss->items[0], $link);
500 + ?>
361 501 <h3>Sample Item</h3>
362 502 <ul>
363 - <li><strong>Title:</strong> <a href="<?php echo $item['link']; ?>"><?php echo $item['title']; ?></a></li>
364 - <li><strong>Date:</strong> <?php echo isset($item['date_timestamp']) ? date('d-M-y g:i:s a', $item['date_timestamp']) : 'unknown'; ?></li>
503 + <li><strong>Title:</strong> <a href="<?php echo $post->post['meta']['syndication_permalink']; ?>"><?php echo $post->post['post_title']; ?></a></li>
504 + <li><strong>Date:</strong> <?php print date('d-M-y g:i:s a', $post->published()); ?></li>
365 505 </ul>
366 506 <div class="entry">
367 - <?php echo (isset($item['content']['encoded'])?$item['content']['encoded']:$item['description']); ?>
507 + <?php print $post->post['post_content']; ?>
368 508 </div>
369 509 <?php else: ?>
370 510 <h3>No Items</h3>
371 511 <p>FeedWordPress found no posts on this feed.</p>
@@ -385,17 +525,39 @@
385 525 </div>
386 526 </div>
387 527 </fieldset>
388 528 </form>
389 -<?php endif;
529 +<?php
390 530 endforeach;
391 531 else:
392 - echo "<p><strong>no feed found</strong></p>";
532 + print "<p><strong>".__('Error').":</strong> ".__("FeedWordPress couldn't find any feeds at").' <code><a href="'.htmlspecialchars($lookup).'">'.htmlspecialchars($lookup).'</a></code>';
533 + print ". ".__('Try another URL').".</p>";
534 +
535 + // Diagnostics
536 + $httpObject = _wp_http_get_object();
537 + $transports = $httpObject->_getTransport();
538 + print "<div class=\"updated\" style=\"margin-left: 3.0em; margin-right: 3.0em;\">\n";
539 + print "<h3>".__('Diagnostic information')."</h3>\n";
540 + if (!is_null($f->error())) :
541 + print "<h4>".__('HTTP request failure')."</h4>\n";
542 + print "<p>".$f->error()."</p>\n";
543 + else :
544 + print "<h4>".__('HTTP request completed')."</h4>\n";
545 + print "<p><strong>Status ".$f->status().":</strong> ".$FeedWordPressHTTPStatusMessages[$f->status()]."</p>\n";
546 + endif;
547 + print "<h4>".__('HTTP Transports available').":</h4>\n";
548 + print "<ol>\n";
549 + print "<li>".implode("</li>\n<li>", array_map('get_class', $transports))."</li>\n";
550 + print "</ol>\n";
551 + print "</div>\n";
393 552 endif;
394 553 ?>
395 554 </div>
396 555
397 556 <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
557 + <div><?php
558 + FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds');
559 + ?></div>
398 560 <div class="wrap">
399 561 <h2>Use another feed</h2>
400 562 <div><label>Feed:</label>
401 563 <input type="text" name="lookup" value="URI" />
@@ -410,21 +572,22 @@
410 572
411 573 function fwp_switchfeed_page () {
412 574 global $wpdb, $wp_db_version;
413 575
414 - check_admin_referer();
576 + // If this is a POST, validate source and user credentials
577 + FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links');
578 +
415 579 if (!isset($_REQUEST['Cancel'])):
416 - if (!current_user_can('manage_links')):
417 - die (__("Cheatin' uh ?"));
418 - elseif (isset($_REQUEST['link_id']) and ($_REQUEST['link_id']==0)):
580 + if (isset($_POST['link_id']) and ($_POST['link_id']==0)):
419 581 $link_id = FeedWordPress::syndicate_link($_REQUEST['feed_title'], $_REQUEST['feed_link'], $_REQUEST['feed']);
420 582 if ($link_id): ?>
421 -<div class="updated"><p><a href="<?php echo $_REQUEST['feed_link']; ?>"><?php echo wp_specialchars($_REQUEST['feed_title'], 'both'); ?></a>
422 -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>
583 +<div class="updated"><p><a href="<?php echo stripslashes($_REQUEST['feed_link']); ?>"><?php echo wp_specialchars(stripslashes($_REQUEST['feed_title']), 'both'); ?></a>
584 +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;.
585 +| <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>
423 586 <?php else: ?>
424 -<div class="updated"><p>There was a problem adding the newsfeed. [SQL: <?php echo wp_specialchars(mysql_error(), 'both'); ?>]</p></div>
587 +<div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo wp_specialchars(mysql_error(), 'both'); ?>]</p></div>
425 588 <?php endif;
426 - elseif (isset($_REQUEST['link_id'])):
589 + elseif (isset($_POST['link_id'])):
427 590 // Update link_rss
428 591 $result = $wpdb->query("
429 592 UPDATE $wpdb->links
430 593 SET
@@ -450,9 +613,10 @@
450 613
451 614 function fwp_linkedit_page () {
452 615 global $wpdb, $wp_db_version;
453 616
454 - check_admin_referer(); // Make sure we arrived here from the Dashboard
617 + // If this is a POST, validate source and user credentials
618 + FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_linkedit', /*capability=*/ 'manage_links');
455 619
456 620 $special_settings = array ( /* Regular expression syntax is OK here */
457 621 'cats',
458 622 'cat_split',
@@ -472,11 +636,9 @@
472 636 'feed/.*',
473 637 'link/.*',
474 638 );
475 639
476 - if (!current_user_can('manage_links')) :
477 - die (__("Cheatin' uh ?"));
478 - elseif (isset($_REQUEST['feedfinder'])) :
640 + if (isset($_REQUEST['feedfinder'])) :
479 641 return fwp_feedfinder_page(); // re-route to Feed Finder page
480 642 else :
481 643 $link_id = (int) $_REQUEST['link_id'];
482 644 $link =& new SyndicatedLink($link_id);
@@ -530,153 +692,8 @@
530 692 if (isset($GLOBALS['fwp_post']['update_schedule'])) :
531 693 $link->settings['update/hold'] = $GLOBALS['fwp_post']['update_schedule'];
532 694 endif;
533 695
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 -
552 - // Post status, comment status, ping status
553 - foreach (array('post', 'comment', 'ping') as $what) :
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;
563 -
564 - // Unfamiliar author, unfamiliar categories
565 - foreach (array("author", "category") as $what) :
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) :
573 - $userdata = array();
574 - $userdata['ID'] = NULL;
575 -
576 - $userdata['user_login'] = sanitize_user($newuser_name);
577 - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
578 -
579 - $userdata['user_nicename'] = sanitize_title($newuser_name);
580 - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
581 -
582 - $userdata['display_name'] = $wpdb->escape($newuser_name);
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;
590 - else :
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));
605 - $author_action = strtolower(trim($GLOBALS['fwp_post']['author_rules_action'][$key]));
606 -
607 - if (strlen($name) > 0) :
608 - if ('newuser' == $author_action) :
609 - $newuser_name = trim($GLOBALS['fwp_post']['author_rules_newuser'][$key]);
610 - if (strlen($newuser_name) > 0) :
611 - $userdata = array();
612 - $userdata['ID'] = NULL;
613 -
614 - $userdata['user_login'] = sanitize_user($newuser_name);
615 - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
616 -
617 - $userdata['user_nicename'] = sanitize_title($newuser_name);
618 - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
619 -
620 - $userdata['display_name'] = $wpdb->escape($newuser_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;
628 - else :
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;
636 - endif;
637 -
638 - if (isset($GLOBALS['fwp_post']['add_author_rule_name']) and isset($GLOBALS['fwp_post']['add_author_rule_action'])) :
639 - $name = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_name']));
640 - $author_action = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_action']));
641 - if (strlen($name) > 0) :
642 - if ('newuser' == $author_action) :
643 - $newuser_name = trim($GLOBALS['fwp_post']['add_author_rule_newuser']);
644 - if (strlen($newuser_name) > 0) :
645 - $userdata = array();
646 - $userdata['ID'] = NULL;
647 -
648 - $userdata['user_login'] = sanitize_user($newuser_name);
649 - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
650 -
651 - $userdata['user_nicename'] = sanitize_title($newuser_name);
652 - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
653 -
654 - $userdata['display_name'] = $wpdb->escape($newuser_name);
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;
662 - else :
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 696 $alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'";
680 697
681 698 $alter_set = implode(", ", $alter);
682 699
@@ -688,8 +705,11 @@
688 705 ");
689 706 $updated_link = true;
690 707
691 708 // reload link information from DB
709 + if (function_exists('clean_bookmark_cache')) :
710 + clean_bookmark_cache($link_id);
711 + endif;
692 712 $link =& new SyndicatedLink($link_id);
693 713 else :
694 714 $updated_link = false;
695 715 endif;
@@ -698,47 +718,8 @@
698 718 $link_url = wp_specialchars($db_link->link_url, 1);
699 719 $link_name = wp_specialchars($db_link->link_name, 1);
700 720 $link_description = wp_specialchars($db_link->link_description, 'both');
701 721 $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');
706 -
707 - $status['post'] = array('publish' => '', 'private' => '', 'draft' => '', 'site-default' => '');
708 - if (SyndicatedPost::use_api('post_status_pending')) :
709 - $status['post']['pending'] = '';
710 - endif;
711 -
712 - $status['comment'] = array('open' => '', 'closed' => '', 'site-default' => '');
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;
721 - endforeach;
722 -
723 - $unfamiliar['author'] = array ('create' => '','default' => '','filter' => '');
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 -
740 - $dogs = SyndicatedPost::category_ids($cats, /*unfamiliar=*/ NULL);
741 722 else :
742 723 die( __('Link not found.') );
743 724 endif;
744 725
@@ -751,25 +732,8 @@
751 732 o = document.getElementById('basics-hardcode-'+item);
752 733 if (o.value=='yes') { ed.style.display='inline'; view.style.display='none'; }
753 734 else { ed.style.display='none'; view.style.display='inline'; }
754 735 }
755 - function flip_newuser (item) {
756 - rollup=document.getElementById(item);
757 - newuser=document.getElementById(item+'-newuser');
758 - sitewide=document.getElementById(item+'-default');
759 - if (rollup) {
760 - if ('newuser'==rollup.value) {
761 - if (newuser) newuser.style.display='block';
762 - if (sitewide) sitewide.style.display='none';
763 - } else if ('site-default'==rollup.value) {
764 - if (newuser) newuser.style.display='none';
765 - if (sitewide) sitewide.style.display='block';
766 - } else {
767 - if (newuser) newuser.style.display='none';
768 - if (sitewide) sitewide.style.display='none';
769 - }
770 - }
771 - }
772 736 </script>
773 737
774 738 <?php if ($updated_link) : ?>
775 739 <div class="updated"><p>Syndicated feed settings updated.</p></div>
@@ -776,13 +740,19 @@
776 740 <?php endif; ?>
777 741
778 742 <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
779 743 <div class="wrap">
744 +<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_linkedit'); ?>
780 745 <input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
781 746 <input type="hidden" name="action" value="linkedit" />
782 747 <input type="hidden" name="save" value="link" />
783 748
784 -<h2>Edit a syndicated feed:</h2>
749 +<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
750 + <div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div>
751 +<?php endif; ?>
752 +
753 +<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>
754 +
785 755 <div id="poststuff">
786 756 <?php fwp_linkedit_single_submit($status); ?>
787 757
788 758 <div id="post-body">
@@ -836,9 +806,9 @@
836 806 <tr>
837 807 <th width="20%"><?php _e('Last update') ?>:</th>
838 808 <td colspan="2"><?php
839 809 if (isset($link->settings['update/last'])) :
840 - echo strftime('%x %X', $link->settings['update/last'])." ";
810 + echo fwp_time_elapsed($link->settings['update/last'])." ";
841 811 else :
842 812 echo " none yet";
843 813 endif;
844 814 ?></td></tr>
@@ -879,176 +849,19 @@
879 849
880 850 <?php fwp_linkedit_periodic_submit(); ?>
881 851
882 852 <?php
883 -if (!(isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25)) :
884 - fwp_option_box_opener('Syndicated Posts', 'syndicatedpostsdiv', 'postbox');
885 -?>
886 -<table class="editform" width="75%" cellspacing="2" cellpadding="5">
887 -<tr><th width="27%" scope="row" style="vertical-align:top">Publication:</th>
888 -<td width="73%" style="vertical-align:top"><ul style="margin:0; list-style:none">
889 -<li><label><input type="radio" name="feed_post_status" value="site-default"
890 -<?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>
891 -(currently: <strong><?php echo ($post_status_global ? $post_status_global : 'publish'); ?></strong>)</label></li>
892 -<li><label><input type="radio" name="feed_post_status" value="publish"
893 -<?php echo $status['post']['publish']; ?> /> Publish posts from this feed immediately</label></li>
853 + FeedWordPressSettingsUI::instead_of_posts_box($link_id);
854 + FeedWordPressSettingsUI::instead_of_authors_box($link_id);
855 + FeedWordPressSettingsUI::instead_of_categories_box($link_id);
894 856
895 -<?php if (SyndicatedPost::use_api('post_status_pending')) : ?>
896 -<li><label><input type="radio" name="feed_post_status" value="pending"
897 -<?php echo $status['post']['pending']; ?>/> Hold posts from this feed for review; mark as Pending</label></li>
898 -<?php endif; ?>
899 -
900 -<li><label><input type="radio" name="feed_post_status" value="draft"
901 -<?php echo $status['post']['draft']; ?> /> Save posts from this feed as drafts</label></li>
902 -<li><label><input type="radio" name="feed_post_status" value="private"
903 -<?php echo $status['post']['private']; ?> /> Save posts from this feed as private posts</label></li>
904 -</ul></td>
905 -</tr>
906 -</table>
907 -<?php
908 - fwp_option_box_closer();
909 - fwp_linkedit_periodic_submit();
910 -endif;
911 -
912 - fwp_option_box_opener(__('Categories'), 'categorydiv', 'postbox');
913 - fwp_category_box($dogs, 'all syndicated posts from this feed');
857 + fwp_option_box_opener('Custom Feed Settings (for use in templates)', 'postcustom', 'postbox');
914 858 ?>
915 -<table>
916 -<tr>
917 -<th width="20%" scope="row" style="vertical-align:top">Unfamiliar categories:</th>
918 -<td width="80%"><p>When one of the categories on a syndicated post is a category that FeedWordPress has not encountered before ...</p>
859 +<p class="setting-description">These custom settings are special fields for the <strong>feed</strong> you are
860 +syndicating, to be retrieved in templates using the <code>get_feed_meta()</code> function. They do not create
861 +custom fields on syndicated <strong>posts</strong>. If you want to create custom fields that are applied to each
862 +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>
919 863
920 -<ul style="margin: 0; list-style:none">
921 -<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>
922 -(currently <strong><?php echo FeedWordPress::on_unfamiliar('category'); ?></strong>)</label></li>
923 -<li><label><input type="radio" name="unfamiliar_category" value="create"<?php echo $unfamiliar['category']['create']; ?> /> create a new category</label></li>
924 -<li><label><input type="radio" name="unfamiliar_category" value="tag"<?php echo $unfamiliar['category']['tag']; ?>/> create a new tag</label></li>
925 -<li><label><input type="radio" name="unfamiliar_category" value="default"<?php echo $unfamiliar['category']['default']; ?> /> don't create new categories or tags</label></li>
926 -<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>
927 -</ul></td>
928 -</tr>
929 -
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
937 -spaces (like <a href="http://del.icio.us/">del.icio.us</a>), use the pattern "\s".
938 -If the feed does not provide multiple categories in a single element, leave this
939 -blank.</td>
940 -</tr>
941 -</table>
942 -<?php
943 - fwp_option_box_closer();
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 -
951 -<?php fwp_option_box_opener('Syndicated Authors', 'authordiv', 'postbox'); ?>
952 -<?php $authorlist = fwp_author_list(); ?>
953 -<table>
954 -<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>
955 -<tr>
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>
969 - <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>
970 - <div id="unfamiliar-author-newuser">named <input type="text" name="unfamiliar_author_newuser" value="" /></div>
971 - </td>
972 -</tr>
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>
980 - <select id="author-rules-<?php echo $i; ?>" name="author_rules_action[]" onchange="flip_newuser('author-rules-<?php echo $i; ?>');">
981 - <?php foreach ($authorlist as $local_author_id => $local_author_name) : ?>
982 - <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>
983 - <?php endforeach; ?>
984 - <option value="newuser">will be assigned to a new user...</option>
985 - <option value="filter"<?php if ('filter'==$author_action) : echo ' selected="selected"'; endif; ?>>get filtered out</option>
986 - </select>
987 - </td>
988 - <td><div id="author-rules-<?php echo $i; ?>-newuser">named <input type="text" name="author_rules_newuser[]" value="" /></div></td>
989 -</tr>
990 -<?php endforeach; endforeach; endif; ?>
991 -
992 -<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>
993 -
994 -<tr>
995 - <th style="text-align: left">Posts by <input type="text" name="add_author_rule_name" /></th>
996 - <td>
997 - <select id="add-author-rule" name="add_author_rule_action" onchange="flip_newuser('add-author-rule');">
998 - <?php foreach ($authorlist as $author_id => $author_name) : ?>
999 - <option value="<?php echo $author_id; ?>">are assigned to <?php echo $author_name; ?></option>
1000 - <?php endforeach; ?>
1001 - <option value="newuser">will be assigned to a new user...</option>
1002 - <option value="filter">get filtered out</option>
1003 - </select>
1004 - </td>
1005 - <td><div id="add-author-rule-newuser">named <input type="text" name="add_author_rule_newuser" value="" /></div></td>
1006 -</tr>
1007 -
1008 -</table>
1009 -<?php fwp_option_box_closer(); ?>
1010 -
1011 -<script>
1012 - flip_newuser('unfamiliar-author');
1013 -<?php for ($j=1; $j<=$i; $j++) : ?>
1014 - flip_newuser('author-rules-<?php echo $j; ?>');
1015 -<?php endfor; ?>
1016 - flip_newuser('add-author-rule');
1017 -</script>
1018 -
1019 -<?php
1020 - fwp_linkedit_periodic_submit();
1021 - fwp_option_box_opener('Comments & Pings', 'commentstatusdiv', 'postbox');
1022 -?>
1023 -<table class="editform" width="75%" cellspacing="2" cellpadding="5">
1024 -<tr><th width="27%" scope="row" style="vertical-align:top"><?php print __('Comments'); ?>:</th>
1025 -<td width="73%"><ul style="margin:0; list-style:none">
1026 -<li><label><input type="radio" name="feed_comment_status" value="site-default"
1027 -<?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>
1028 -(currently: <strong><?php echo ($comment_status_global ? $comment_status_global : 'closed'); ?>)</strong></label></li>
1029 -<li><label><input type="radio" name="feed_comment_status" value="open"
1030 -<?php echo $status['comment']['open']; ?> /> Allow comments on syndicated posts from this feed</label></li>
1031 -<li><label><input type="radio" name="feed_comment_status" value="closed"
1032 -<?php echo $status['comment']['closed']; ?> /> Don't allow comments on syndicated posts from this feed</label></li>
1033 -</ul></td></tr>
1034 -
1035 -<tr><th width="27%" scope="row" style="vertical-align:top"><?php print __('Pings'); ?>:</th>
1036 -<td width="73%"><ul style="margin:0; list-style:none">
1037 -<li><label><input type="radio" name="feed_ping_status" value="site-default"
1038 -<?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>
1039 -(currently: <strong><?php echo ($ping_status_global ? $ping_status_global : 'closed'); ?>)</strong></label></li>
1040 -<li><label><input type="radio" name="feed_ping_status" value="open"
1041 -<?php echo $status['ping']['open']; ?> /> Accept pings on syndicated posts from this feed</label></li>
1042 -<li><label><input type="radio" name="feed_ping_status" value="closed"
1043 -<?php echo $status['ping']['closed']; ?> /> Don't accept pings on syndicated posts from this feed</label></li>
1044 -</ul></td></tr>
1045 -
1046 -</table>
1047 -<?php fwp_option_box_closer(); ?>
1048 -<?php fwp_linkedit_periodic_submit(); ?>
1049 -
1050 -<?php fwp_option_box_opener('Custom Settings (for use in templates)', 'postcustom', 'postbox'); ?>
1051 864 <div id="postcustomstuff">
1052 865 <table id="meta-list" cellpadding="3">
1053 866 <tr>
1054 867 <th>Key</th>
@@ -1083,8 +896,9 @@
1083 896 </table>
1084 897 <?php fwp_option_box_closer(); ?>
1085 898
1086 899 <?php fwp_linkedit_periodic_submit(); ?>
900 +<?php fwp_linkedit_single_submit_closer(); ?>
1087 901 </div> <!-- id="post-body" -->
1088 902 </div> <!-- id="poststuff" -->
1089 903 </div>
1090 904 <?php
@@ -1094,16 +908,15 @@
1094 908
1095 909 function fwp_multidelete_page () {
1096 910 global $wpdb;
1097 911
1098 - check_admin_referer(); // Make sure the referers are kosher
912 + // If this is a POST, validate source and user credentials
913 + FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links');
1099 914
1100 915 $link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array());
1101 916 if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif;
1102 917
1103 - if (!current_user_can('manage_links')):
1104 - die (__("Cheatin' uh ?"));
1105 - elseif (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'):
918 + if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'):
1106 919 foreach ($GLOBALS['fwp_post']['link_action'] as $link_id => $what) :
1107 920 $do_it[$what][] = $link_id;
1108 921 endforeach;
1109 922
@@ -1184,8 +997,9 @@
1184 997 ");
1185 998 ?>
1186 999 <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
1187 1000 <div class="wrap">
1001 +<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
1188 1002 <input type="hidden" name="action" value="Unsubscribe" />
1189 1003 <input type="hidden" name="confirm" value="Delete" />
1190 1004
1191 1005 <h2>Unsubscribe from Syndicated Links:</h2>