PluginProbe
FeedWordPress / 2025.1211
FeedWordPress v2025.1211
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 +3 -1078 2009.07072025.1211 View file →
@@ -1,1080 +1,5 @@
1 1 <?php
2 -require_once(dirname(__FILE__) . '/admin-ui.php');
3 -require_once(dirname(__FILE__) . '/magpiemocklink.class.php');
4 -require_once(dirname(__FILE__) . '/feedfinder.class.php');
2 + require_once dirname(__FILE__) . '/feedwordpresssyndicationpage.class.php';
5 3
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 -
47 -################################################################################
48 -## ADMIN MENU ADD-ONS: implement Dashboard management pages ####################
49 -################################################################################
50 -
51 -if (fwp_test_wp_version(0, FWP_SCHEMA_25)) :
52 - define('FWP_UPDATE_CHECKED', 'Update Checked Links');
53 - define('FWP_UNSUB_CHECKED', 'Unsubscribe from Checked Links');
54 - define('FWP_SYNDICATE_NEW', 'Syndicate »');
55 -else :
56 - define('FWP_UPDATE_CHECKED', 'Update Checked');
57 - define('FWP_UNSUB_CHECKED', 'Unsubscribe');
58 - define('FWP_SYNDICATE_NEW', 'Syndicate »');
59 -endif;
60 -
61 -function feedwordpress_syndication_toggles () {
62 -?>
63 - <script type="text/javascript">
64 - jQuery(document).ready( function($) {
65 - // In case someone got here first.
66 - $('.postbox h3, .postbox .handlediv').unbind('click');
67 - $('.postbox h3 a').unbind('click');
68 - $('.hide-postbox-tog').unbind('click');
69 - $('.columns-prefs input[type="radio"]').unbind('click');
70 - $('.meta-box-sortables').sortable('destroy');
71 -
72 - postboxes.add_postbox_toggles('feedwordpresssyndication');
73 - } );
74 - </script>
75 -<?php
76 -}
77 -
78 -function fwp_dashboard_update_if_requested () {
79 - global $wpdb;
80 -
81 - if (isset($_POST['update']) or isset($_POST['action']) or isset($_POST['update_uri'])) :
82 - $fwp_update_invoke = 'post';
83 - else :
84 - $fwp_update_invoke = 'get';
85 - endif;
86 -
87 - $update_set = array();
88 - if (isset($_POST['link_ids']) and is_array($_POST['link_ids']) and ($_POST['action']==FWP_UPDATE_CHECKED)) :
89 - $targets = $wpdb->get_results("
90 - SELECT * FROM $wpdb->links
91 - WHERE link_id IN (".implode(",",$_POST['link_ids']).")
92 - ");
93 - if (is_array($targets)) :
94 - foreach ($targets as $target) :
95 - $update_set[] = $target->link_rss;
96 - endforeach;
97 - else : // This should never happen
98 - FeedWordPress::critical_bug('fwp_syndication_manage_page::targets', $targets, __LINE__);
99 - endif;
100 - elseif (isset($_POST['update_uri'])) :
101 - $update_set[] = $_POST['update_uri'];
102 - endif;
103 -
104 - shuffle($update_set); // randomize order for load balancing purposes...
105 - if ($fwp_update_invoke != 'get' and count($update_set) > 0) : // Only do things with side-effects for HTTP POST or command line
106 - $feedwordpress =& new FeedWordPress;
107 - add_action('feedwordpress_check_feed', 'update_feeds_mention');
108 - add_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3);
109 -
110 - $crash_dt = (int) get_option('feedwordpress_update_time_limit');
111 - if ($crash_dt > 0) :
112 - $crash_ts = time() + $crash_dt;
113 - else :
114 - $crash_ts = NULL;
115 - endif;
116 -
117 - if (fwp_test_wp_version(FWP_SCHEMA_25)) :
118 - echo "<div class=\"youare\">\n";
119 - else :
120 - echo "<div class=\"updated\">\n";
121 - endif;
122 - echo "<ul>\n";
123 - $tdelta = NULL;
124 - foreach ($update_set as $uri) :
125 - if (!is_null($crash_ts) and (time() > $crash_ts)) :
126 - echo "<li><p><strong>Further updates postponed:</strong> update time limit of ".$crash_dt." second".(($crash_dt==1)?"":"s")." exceeded.</p></li>";
127 - break;
128 - endif;
129 -
130 - if ($uri == '*') : $uri = NULL; endif;
131 - $delta = $feedwordpress->update($uri, $crash_ts);
132 - if (!is_null($delta)) :
133 - if (is_null($tdelta)) :
134 - $tdelta = $delta;
135 - else :
136 - $tdelta['new'] += $delta['new'];
137 - $tdelta['updated'] += $delta['updated'];
138 - endif;
139 - else :
140 - echo "<li><p><strong>Error:</strong> There was a problem updating <a href=\"$uri\">$uri</a></p></li>\n";
141 - endif;
142 - endforeach;
143 - echo "</ul>\n";
144 -
145 - if (!is_null($tdelta)) :
146 - $mesg = array();
147 - if (isset($delta['new'])) : $mesg[] = ' '.$tdelta['new'].' new posts were syndicated'; endif;
148 - if (isset($delta['updated'])) : $mesg[] = ' '.$tdelta['updated'].' existing posts were updated'; endif;
149 - echo "<p>Update complete.".implode(' and', $mesg)."</p>";
150 - echo "\n"; flush();
151 - endif;
152 - echo "</div> <!-- class=\"updated\" -->\n";
153 - elseif (fwp_test_wp_version(FWP_SCHEMA_25)) :
154 -?>
155 - <p class="youare">Check currently scheduled feeds for new and updated posts.</p>
156 -<?php
157 - endif;
158 -}
159 -
160 -function fwp_syndication_manage_page () {
161 - global $wpdb;
162 -
163 - if (FeedWordPress::needs_upgrade()) :
164 - fwp_upgrade_page();
165 - return;
166 - endif;
167 -
168 -?>
169 -<?php $cont = true;
170 -if (isset($_REQUEST['action'])):
171 - if ($_REQUEST['action'] == 'feedfinder' or $_REQUEST['action'] == FWP_SYNDICATE_NEW) : $cont = fwp_feedfinder_page();
172 - elseif ($_REQUEST['action'] == 'switchfeed') : $cont = fwp_switchfeed_page();
173 - elseif ($_REQUEST['action'] == 'linkedit') : $cont = fwp_linkedit_page();
174 - elseif ($_REQUEST['action'] == FWP_UNSUB_CHECKED or $_REQUEST['action'] == 'Unsubscribe') : $cont = fwp_multidelete_page();
175 - endif;
176 -endif;
177 -
178 -if ($cont):
179 -?>
180 -<?php
181 - $links = FeedWordPress::syndicated_links();
182 -?>
183 - <div class="wrap">
184 -<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
185 - <div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div>
186 - <h2>Syndicated Sites</h2>
187 -<?php endif;
188 - if (fwp_test_wp_version(0, FWP_SCHEMA_25)) :
189 - fwp_dashboard_update_if_requested();
190 - endif;
191 -
192 - if (fwp_test_wp_version(FWP_SCHEMA_27)) :
193 - if (fwp_test_wp_version(FWP_SCHEMA_27, FWP_SCHEMA_28)) :
194 - $hook_it = 'admin_footer';
195 - else : // WordPress 2.8+
196 - $hook_it = 'admin_footer-feedwordpress/syndication.php';
197 - endif;
198 - add_action($hook_it, 'feedwordpress_syndication_toggles', /*priority=*/ 10000);
199 - echo "<form style='display: none' method='get' action=''>\n<p>\n";
200 - wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
201 - wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
202 - echo "</p>\n</form>\n";
203 -
204 - if ($links) :
205 - add_meta_box(
206 - /*id=*/ 'feedwordpress_update_box',
207 - /*title=*/ __('Update feeds now'),
208 - /*callback=*/ 'fwp_syndication_manage_page_update_box',
209 - /*page=*/ 'feedwordpresssyndication',
210 - /*context =*/ 'feedwordpresssyndication'
211 - );
212 - endif;
213 - add_meta_box(
214 - /*id=*/ 'feedwordpress_feeds_box',
215 - /*title=*/ __('Syndicated sources'),
216 - /*callback=*/ 'fwp_syndication_manage_page_links_box',
217 - /*page=*/ 'feedwordpresssyndication',
218 - /*context =*/ 'feedwordpresssyndication'
219 - );
220 -?>
221 - <div class="metabox-holder">
222 - <div id="feedwordpresssyndication-sortables" class="meta-box-sortables ui-sortable">
223 -<?php
224 - do_meta_boxes('feedwordpresssyndication', 'feedwordpresssyndication', NULL);
225 - else :
226 - if ($links): // only display Update panel if there are some links to update....
227 - fwp_syndication_manage_page_update_box();
228 - endif;
229 - fwp_syndication_manage_page_links_box();
230 -?>
231 - </div> <!-- class="wrap" -->
232 -
233 - <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
234 - <div class="wrap">
235 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
236 - <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
237 - <h2>Add a new syndicated site:</h2>
238 - <div>
239 - <label for="add-uri">Website or feed:</label>
240 - <input type="text" name="lookup" id="add-uri" value="URI" size="64" />
241 - <input type="hidden" name="action" value="feedfinder" />
242 - </div>
243 - <div class="submit"><input type="submit" value="Syndicate &raquo;" /></div>
244 - </form>
245 - </div> <!-- class="wrap" -->
246 - <?php endif; ?>
247 -
248 - <div style="display: none">
249 - <div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
250 - </div>
251 -<?php
252 - endif;
253 -endif;
254 -} /* function fwp_syndication_manage_page () */
255 -
256 -function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) {
257 - $updateFeedsNow = __('Update feeds now');
258 -?>
259 - <form action="" method="POST">
260 - <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
261 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?>
262 - <div id="rightnow">
263 - <h3 class="reallynow"><span><?php print $updateFeedsNow; ?></span>
264 - <input type="hidden" name="update_uri" value="*" /><input style="float: right; border: none;" class="rbutton" type="submit" name="update" value="Update" />
265 - <br class="clear"/></h3>
266 - <?php elseif (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
267 - <h2><?php print $updateFeedsNow; ?></h2>
268 - <?php endif; ?>
269 -
270 -<?php
271 - if (fwp_test_wp_version(FWP_SCHEMA_25)) :
272 - fwp_dashboard_update_if_requested();
273 - else :
274 -?>
275 -<p>Check currently scheduled feeds for new and updated posts.</p>
276 -<?php endif; ?>
277 -
278 -<?php if (!get_option('feedwordpress_automatic_updates')) : ?>
279 - <p class="youhave"><strong>Note:</strong> Automatic updates are currently turned
280 - <strong>off</strong>. New posts from your feeds will not be syndicated
281 - until you manually check for them here. You can turn on automatic
282 - updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/syndication-options.php">Syndication
283 - Options</a>.</p>
284 -<?php endif; ?>
285 -
286 - <?php if (!fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?>
287 - <div class="submit"><input type="hidden" name="update_uri" value="*" /><input class="button-primary" type="submit" name="update" value="Update" /></div>
288 - <?php endif; ?>
289 -
290 - <?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
291 - <br style="clear: both" />
292 - <?php elseif (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?>
293 - </div> <!-- id="rightnow" -->
294 - </div> <!-- class="wrap" -->
295 - <?php elseif (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
296 - </div> <!-- class="wrap" -->
297 - <?php endif; ?>
298 - </form>
299 -<?php
300 -} /* function fwp_syndication_manage_page_update_box () */
301 -
302 -function fwp_syndication_manage_page_links_box ($object = NULL, $box = NULL) {
303 - $links = FeedWordPress::syndicated_links();
304 -?>
305 - <?php if (!fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
306 - <div class="wrap">
307 - <h2>Syndicated Sites</h2>
308 - <?php endif; ?>
309 -
310 - <form id="syndicated-links" action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/<?php echo basename(__FILE__); ?>" method="post">
311 - <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
312 -
313 -<?php $alt_row = true; ?>
314 -
315 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
316 - <div class="tablenav">
317 - <div class="alignright">
318 - <label for="add-uri">Add new source:</label>
319 - <input type="text" name="lookup" id="add-uri" value="Website or feed URI" />
320 -<script type="text/javascript">
321 -jQuery(document).ready( function () {
322 - var addUri = jQuery("#add-uri");
323 - var box = addUri.get(0);
324 - if (box.value==box.defaultValue) { addUri.addClass('form-input-tip'); }
325 - addUri.focus(function() {
326 - if ( this.value == this.defaultValue )
327 - jQuery(this).val( '' ).removeClass( 'form-input-tip' );
328 - });
329 - addUri.blur(function() {
330 - if ( this.value == '' )
331 - jQuery(this).val( this.defaultValue ).addClass( 'form-input-tip' );
332 - });
333 -
334 -} );
335 -</script>
336 -
337 - <input type="hidden" name="action" value="feedfinder" />
338 - <input type="submit" class="button-secondary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div>
339 -
340 -<?php if (count($links) > 0) : ?>
341 - <div class="alignleft">
342 - <input class="button-secondary" type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" />
343 - <input class="button-secondary delete" type="submit" class="delete" name="action" value="<?php print FWP_UNSUB_CHECKED; ?>" />
344 - </div>
345 -<?php endif; ?>
346 -
347 - <br class="clear" />
348 - </div>
349 - <br class="clear" />
350 -
351 - <table class="widefat">
352 - <?php else : ?>
353 - <table width="100%" cellpadding="3" cellspacing="3">
354 - <?php endif; ?>
355 -<thead>
356 -<tr>
357 -<th class="check-column" scope="col"><?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
358 -<input type="checkbox" <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_26)) : ?>onclick="checkAll(document.getElementById('syndicated-links'));"<?php endif; ?> />
359 -<?php endif; ?></th>
360 -<th scope="col"><?php _e('Name'); ?></th>
361 -<th scope="col"><?php _e('Feed'); ?></th>
362 -<th scope="col"><?php _e('Updated'); ?></th>
363 -</tr>
364 -</thead>
365 -
366 -<tbody>
367 -<?php if (count($links) > 0): foreach ($links as $link):
368 - $alt_row = !$alt_row; ?>
369 -<tr<?php echo ($alt_row?' class="alternate"':''); ?>>
370 -<th class="check-column" scope="row"><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?>" /></th>
371 -<?php
372 - if (strlen($link->link_rss) > 0):
373 - $caption=__('Switch Feed');
374 - else :
375 - $caption=__('Find Feed');
376 - endif;
377 -?>
378 -<td>
379 -<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>
380 -<div class="row-actions"><div><strong>Settings &gt;</strong>
381 -<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>
382 -| <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>
383 -| <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>
384 -| <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>
385 -<div><strong>Actions &gt;</strong>
386 -<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>
387 -| <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>
388 -| <a href="<?php echo wp_specialchars($link->link_url, 'both'); ?>"><?php _e('View')?></a></div>
389 -</div>
390 -</td>
391 -<?php
392 - if (strlen($link->link_rss) > 0):
393 - $uri_bits = parse_url($link->link_rss);
394 - $uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']);
395 - $display_uri =
396 - (isset($uri_bits['user'])?$uri_bits['user'].'@':'')
397 - .(isset($uri_bits['host'])?$uri_bits['host']:'')
398 - .(isset($uri_bits['port'])?':'.$uri_bits['port']:'')
399 - .(isset($uri_bits['path'])?$uri_bits['path']:'')
400 - .(isset($uri_bits['query'])?'?'.$uri_bits['query']:'');
401 - if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'&#8230;'; endif;
402 -?>
403 - <td><a href="<?php echo wp_specialchars($link->link_rss, 'both'); ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></td>
404 - <?php else: ?>
405 - <td style="background-color:#FFFFD0"><p><strong>no
406 - feed assigned</strong></p></td>
407 - <?php endif; ?>
408 -
409 - <td><?php
410 - $sLink =& new SyndicatedLink($link->link_id);
411 - if (isset($sLink->settings['update/last'])) :
412 - print fwp_time_elapsed($sLink->settings['update/last']);
413 - else :
414 - _e('None yet');
415 - endif;
416 -
417 - print "<div style='font-style:italic;size:0.9em'>Ready for next update ";
418 - if (isset($sLink->settings['update/ttl']) and is_numeric($sLink->settings['update/ttl'])) :
419 - if (isset($sLink->settings['update/timed']) and $sLink->settings['update/timed']=='automatically') :
420 - $next = $sLink->settings['update/last'] + ((int) $sLink->settings['update/ttl'] * 60);
421 - print fwp_time_elapsed($next);
422 - else :
423 - echo "every ".$sLink->settings['update/ttl']." minute".(($sLink->settings['update/ttl']!=1)?"s":"");
424 - endif;
425 - else:
426 - echo "as soon as possible";
427 - endif;
428 - print "</div>";
429 -?>
430 - </td>
431 - </tr>
432 -<?php
433 - endforeach;
434 - else :
435 -?>
436 -<tr><td colspan="<?php print $span+2; ?>"><p>There are no websites currently listed for syndication.</p></td></tr>
437 -<?php
438 - endif;
439 -?>
440 -</tbody>
441 -</table>
442 -
443 -<?php if (count($links) > 0 and fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
444 -<br/><hr/>
445 -<div class="submit"><input type="submit" class="delete" name="action" value="<?php print FWP_UNSUB_CHECKED; ?>" />
446 -<input type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" /></div>
447 -<?php endif; ?>
448 -
449 - </form>
450 -<?php
451 -} /* function fwp_syndication_manage_page_links_box() */
452 -
453 -function fwp_feedfinder_page () {
454 - global $wpdb;
455 - global $FeedWordPressHTTPStatusMessages;
456 -
457 - $lookup = (isset($_REQUEST['lookup'])?$_REQUEST['lookup']:NULL);
458 -
459 - if (isset($_REQUEST['link_id']) and ($_REQUEST['link_id']!=0)):
460 - $link_id = $_REQUEST['link_id'];
461 - if (!is_numeric($link_id)) : FeedWordPress::critical_bug('fwp_feedfinder_page::link_id', $link_id, __LINE__); endif;
462 -
463 - $link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id='".$wpdb->escape($link_id)."'");
464 - if (is_object($link)):
465 - if (is_null($lookup)) $lookup = $link->link_url;
466 - $name = wp_specialchars($link->link_name, 'both');
467 - else:
468 - die (__("Cheatin' uh ?"));
469 - endif;
470 - else:
471 - $name = "<code>".htmlspecialchars($lookup)."</code>";
472 - $link_id = 0;
473 - endif;
474 -?>
475 - <div class="wrap">
476 - <h2>Feed Finder: <?php echo $name; ?></h2>
477 -<?php
478 - $f =& new FeedFinder($lookup);
479 - $feeds = $f->find();
480 - if (count($feeds) > 0):
481 - foreach ($feeds as $key => $f):
482 - $rss = fetch_rss($f);
483 - if ($rss):
484 - $feed_title = isset($rss->channel['title'])?$rss->channel['title']:$rss->channel['link'];
485 - $feed_link = isset($rss->channel['link'])?$rss->channel['link']:'';
486 - else :
487 - // Give us some sucky defaults
488 - $uri_bits = parse_url($lookup);
489 - $uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']);
490 - $display_uri =
491 - (isset($uri_bits['user'])?$uri_bits['user'].'@':'')
492 - .(isset($uri_bits['host'])?$uri_bits['host']:'')
493 - .(isset($uri_bits['port'])?':'.$uri_bits['port']:'')
494 - .(isset($uri_bits['path'])?$uri_bits['path']:'')
495 - .(isset($uri_bits['query'])?'?'.$uri_bits['query']:'');
496 - if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'&#8230;'; endif;
497 -
498 - $feed_title = $display_uri;
499 - $feed_link = $lookup;
500 - endif;
501 -?>
502 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
503 - <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_switchfeed'); ?></div>
504 - <fieldset style="clear: both">
505 - <legend><?php echo $rss->feed_type; ?> <?php echo $rss->feed_version; ?> feed</legend>
506 -
507 - <?php if ($link_id===0): ?>
508 - <input type="hidden" name="feed_title" value="<?php echo wp_specialchars($feed_title, 'both'); ?>" />
509 - <input type="hidden" name="feed_link" value="<?php echo wp_specialchars($feed_link, 'both'); ?>" />
510 - <?php endif; ?>
511 -
512 - <input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
513 - <input type="hidden" name="feed" value="<?php echo wp_specialchars($f, 'both'); ?>" />
514 - <input type="hidden" name="action" value="switchfeed" />
515 -
516 - <div>
517 - <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">
518 -<?php if (count($rss->items) > 0): ?>
519 - <?php
520 - // Prepare to display Sample Item
521 - $link =& new MagpieMockLink($rss, $f);
522 - $post =& new SyndicatedPost($rss->items[0], $link);
523 - ?>
524 - <h3>Sample Item</h3>
525 - <ul>
526 - <li><strong>Title:</strong> <a href="<?php echo $post->post['meta']['syndication_permalink']; ?>"><?php echo $post->post['post_title']; ?></a></li>
527 - <li><strong>Date:</strong> <?php print date('d-M-y g:i:s a', $post->published()); ?></li>
528 - </ul>
529 - <div class="entry">
530 - <?php print $post->post['post_content']; ?>
531 - </div>
532 -<?php else: ?>
533 - <h3>No Items</h3>
534 - <p>FeedWordPress found no posts on this feed.</p>
535 -<?php endif; ?>
536 - </div>
537 -
538 - <div>
539 - <h3>Feed Information</h3>
540 - <ul>
541 - <li><strong>Website:</strong> <a href="<?php echo $feed_link; ?>"><?php echo is_null($feed_title)?'<em>Unknown</em>':$feed_title; ?></a></li>
542 - <li><strong>Feed URI:</strong> <a href="<?php echo wp_specialchars($f, 'both'); ?>"><?php echo wp_specialchars($f, 'both'); ?></a> (<a title="Check feed &lt;<?php echo wp_specialchars($f, 'both'); ?>&gt; for validity" href="http://feedvalidator.org/check.cgi?url=<?php echo urlencode($f); ?>">validate</a>)</li>
543 - <li><strong>Encoding:</strong> <?php echo isset($rss->encoding)?wp_specialchars($rss->encoding, 'both'):"<em>Unknown</em>"; ?></li>
544 - <li><strong>Description:</strong> <?php echo isset($rss->channel['description'])?wp_specialchars($rss->channel['description'], 'both'):"<em>Unknown</em>"; ?></li>
545 - </ul>
546 - <div class="submit"><input type="submit" name="Use" value="&laquo; Use this feed" /></div>
547 - <div class="submit"><input type="submit" name="Cancel" value="&laquo; Cancel" /></div>
548 - </div>
549 - </div>
550 - </fieldset>
551 - </form>
552 -<?php
553 - endforeach;
554 - else:
555 - print "<p><strong>".__('Error').":</strong> ".__("FeedWordPress couldn't find any feeds at").' <code><a href="'.htmlspecialchars($lookup).'">'.htmlspecialchars($lookup).'</a></code>';
556 - print ". ".__('Try another URL').".</p>";
557 -
558 - // Diagnostics
559 - $httpObject = _wp_http_get_object();
560 - $transports = $httpObject->_getTransport();
561 - print "<div class=\"updated\" style=\"margin-left: 3.0em; margin-right: 3.0em;\">\n";
562 - print "<h3>".__('Diagnostic information')."</h3>\n";
563 - if (!is_null($f->error())) :
564 - print "<h4>".__('HTTP request failure')."</h4>\n";
565 - print "<p>".$f->error()."</p>\n";
566 - else :
567 - print "<h4>".__('HTTP request completed')."</h4>\n";
568 - print "<p><strong>Status ".$f->status().":</strong> ".$FeedWordPressHTTPStatusMessages[$f->status()]."</p>\n";
569 - endif;
570 - print "<h4>".__('HTTP Transports available').":</h4>\n";
571 - print "<ol>\n";
572 - print "<li>".implode("</li>\n<li>", array_map('get_class', $transports))."</li>\n";
573 - print "</ol>\n";
574 - print "</div>\n";
575 - endif;
576 -?>
577 - </div>
578 -
579 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
580 - <div><?php
581 - FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds');
582 - ?></div>
583 - <div class="wrap">
584 - <h2>Use another feed</h2>
585 - <div><label>Feed:</label>
586 - <input type="text" name="lookup" value="URI" />
587 - <input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
588 - <input type="hidden" name="action" value="feedfinder" /></div>
589 - <div class="submit"><input type="submit" value="Use this feed &raquo;" /></div>
590 - </div>
591 - </form>
592 -<?php
593 - return false; // Don't continue
594 -}
595 -
596 -function fwp_switchfeed_page () {
597 - global $wpdb, $wp_db_version;
598 -
599 - // If this is a POST, validate source and user credentials
600 - FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links');
601 -
602 - if (!isset($_REQUEST['Cancel'])):
603 - if (isset($_POST['link_id']) and ($_POST['link_id']==0)):
604 - $link_id = FeedWordPress::syndicate_link($_REQUEST['feed_title'], $_REQUEST['feed_link'], $_REQUEST['feed']);
605 - if ($link_id): ?>
606 -<div class="updated"><p><a href="<?php echo stripslashes($_REQUEST['feed_link']); ?>"><?php echo wp_specialchars(stripslashes($_REQUEST['feed_title']), 'both'); ?></a>
607 -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;.
608 -| <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>
609 -<?php else: ?>
610 -<div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo wp_specialchars(mysql_error(), 'both'); ?>]</p></div>
611 -<?php endif;
612 - elseif (isset($_POST['link_id'])):
613 - // Update link_rss
614 - $result = $wpdb->query("
615 - UPDATE $wpdb->links
616 - SET
617 - link_rss = '".$wpdb->escape($_REQUEST['feed'])."'
618 - WHERE link_id = '".$wpdb->escape($_REQUEST['link_id'])."'
619 - ");
620 -
621 - if ($result):
622 - $result = $wpdb->get_row("
623 - SELECT link_name, link_url FROM $wpdb->links
624 - WHERE link_id = '".$wpdb->escape($_REQUEST['link_id'])."'
625 - ");
626 - ?>
627 -<div class="updated"><p>Feed for <a href="<?php echo $result->link_url; ?>"><?php echo wp_specialchars($result->link_name, 'both'); ?></a>
628 -updated to &lt;<a href="<?php echo $_REQUEST['feed']; ?>"><?php echo wp_specialchars($_REQUEST['feed'], 'both'); ?></a>&gt;.</p></div>
629 - <?php else: ?>
630 -<div class="updated"><p>Nothing was changed.</p></div>
631 - <?php endif;
632 - endif;
633 - endif;
634 - return true; // Continue
635 -}
636 -
637 -function fwp_linkedit_page () {
638 - global $wpdb, $wp_db_version;
639 -
640 - // If this is a POST, validate source and user credentials
641 - FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_linkedit', /*capability=*/ 'manage_links');
642 -
643 - $special_settings = array ( /* Regular expression syntax is OK here */
644 - 'cats',
645 - 'cat_split',
646 - 'hardcode name',
647 - 'hardcode url',
648 - 'hardcode description',
649 - 'hardcode categories', /* Deprecated */
650 - 'post status',
651 - 'comment status',
652 - 'ping status',
653 - 'unfamiliar author',
654 - 'unfamliar categories', /* Deprecated */
655 - 'unfamiliar category',
656 - 'map authors',
657 - 'tags',
658 - 'update/.*',
659 - 'feed/.*',
660 - 'link/.*',
661 - );
662 -
663 - if (isset($_REQUEST['feedfinder'])) :
664 - return fwp_feedfinder_page(); // re-route to Feed Finder page
665 - else :
666 - $link_id = (int) $_REQUEST['link_id'];
667 - $link =& new SyndicatedLink($link_id);
668 -
669 - if ($link->found()) :
670 - if (isset($GLOBALS['fwp_post']['save'])) :
671 - $alter = array ();
672 -
673 - // custom feed settings first
674 - foreach ($GLOBALS['fwp_post']['notes'] as $mn) :
675 - $mn['key0'] = trim($mn['key0']);
676 - $mn['key1'] = trim($mn['key1']);
677 - if (preg_match("\007^(("
678 - .implode(')|(',$special_settings)
679 - ."))$\007i",
680 - $mn['key1'])) :
681 - $mn['key1'] = 'user/'.$mn['key1'];
682 - endif;
683 -
684 - if (strlen($mn['key0']) > 0) :
685 - unset($link->settings[$mn['key0']]); // out with the old
686 - endif;
687 -
688 - if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
689 - $link->settings[$mn['key1']] = $mn['value']; // in with the new
690 - endif;
691 - endforeach;
692 -
693 - // now stuff through the web form
694 - // hardcoded feed info
695 - if (isset($GLOBALS['fwp_post']['hardcode_name'])) :
696 - $link->settings['hardcode name'] = $GLOBALS['fwp_post']['hardcode_name'];
697 - if (FeedWordPress::affirmative($link->settings, 'hardcode name')) :
698 - $alter[] = "link_name = '".$wpdb->escape($GLOBALS['fwp_post']['name'])."'";
699 - endif;
700 - endif;
701 - if (isset($GLOBALS['fwp_post']['hardcode_description'])) :
702 - $link->settings['hardcode description'] = $GLOBALS['fwp_post']['hardcode_description'];
703 - if (FeedWordPress::affirmative($link->settings, 'hardcode description')) :
704 - $alter[] = "link_description = '".$wpdb->escape($GLOBALS['fwp_post']['description'])."'";
705 - endif;
706 - endif;
707 - if (isset($GLOBALS['fwp_post']['hardcode_url'])) :
708 - $link->settings['hardcode url'] = $GLOBALS['fwp_post']['hardcode_url'];
709 - if (FeedWordPress::affirmative($link->settings, 'hardcode url')) :
710 - $alter[] = "link_url = '".$wpdb->escape($GLOBALS['fwp_post']['linkurl'])."'";
711 - endif;
712 - endif;
713 -
714 - // Update scheduling
715 - if (isset($GLOBALS['fwp_post']['update_schedule'])) :
716 - $link->settings['update/hold'] = $GLOBALS['fwp_post']['update_schedule'];
717 - endif;
718 -
719 - $alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'";
720 -
721 - $alter_set = implode(", ", $alter);
722 -
723 - // issue update query
724 - $result = $wpdb->query("
725 - UPDATE $wpdb->links
726 - SET $alter_set
727 - WHERE link_id='$link_id'
728 - ");
729 - $updated_link = true;
730 -
731 - // reload link information from DB
732 - if (function_exists('clean_bookmark_cache')) :
733 - clean_bookmark_cache($link_id);
734 - endif;
735 - $link =& new SyndicatedLink($link_id);
736 - else :
737 - $updated_link = false;
738 - endif;
739 -
740 - $db_link = $link->link;
741 - $link_url = wp_specialchars($db_link->link_url, 1);
742 - $link_name = wp_specialchars($db_link->link_name, 1);
743 - $link_description = wp_specialchars($db_link->link_description, 'both');
744 - $link_rss_uri = wp_specialchars($db_link->link_rss, 'both');
745 - else :
746 - die( __('Link not found.') );
747 - endif;
748 -
749 - ?>
750 -<script type="text/javascript">
751 - function flip_hardcode (item) {
752 - ed=document.getElementById('basics-'+item+'-edit');
753 - view=document.getElementById('basics-'+item+'-view');
754 -
755 - o = document.getElementById('basics-hardcode-'+item);
756 - if (o.value=='yes') { ed.style.display='inline'; view.style.display='none'; }
757 - else { ed.style.display='none'; view.style.display='inline'; }
758 - }
759 -</script>
760 -
761 -<?php if ($updated_link) : ?>
762 -<div class="updated"><p>Syndicated feed settings updated.</p></div>
763 -<?php endif; ?>
764 -
765 -<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
766 -<div class="wrap">
767 -<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_linkedit'); ?>
768 -<input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
769 -<input type="hidden" name="action" value="linkedit" />
770 -<input type="hidden" name="save" value="link" />
771 -
772 -<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
773 - <div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div>
774 -<?php endif; ?>
775 -
776 -<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>
777 -
778 -<div id="poststuff">
779 -<?php fwp_linkedit_single_submit($status); ?>
780 -
781 -<div id="post-body">
782 -<?php fwp_option_box_opener('Feed Information', 'feedinformationdiv'); ?>
783 - <table class="editform" width="100%" cellspacing="2" cellpadding="5">
784 - <tr>
785 - <th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
786 - <td width="60%"><a href="<?php echo wp_specialchars($link_rss_uri, 'both'); ?>"><?php echo $link_rss_uri; ?></a>
787 - (<a href="<?php echo FEEDVALIDATOR_URI; ?>?url=<?php echo urlencode($link_rss_uri); ?>"
788 - title="Check feed &lt;<?php echo wp_specialchars($link_rss_uri, 'both'); ?>&gt; for validity">validate</a>)
789 - </td>
790 - <td width="20%"><input type="submit" name="feedfinder" value="switch &rarr;" style="font-size:smaller" /></td>
791 - </tr>
792 - <tr>
793 - <th scope="row" width="20%"><?php _e('Link Name:') ?></th>
794 - <td width="60%"><input type="text" id="basics-name-edit" name="name"
795 - value="<?php echo $link_name; ?>" style="width: 95%" />
796 - <span id="basics-name-view"><strong><?php echo $link_name; ?></strong></span>
797 - </td>
798 - <td>
799 - <select id="basics-hardcode-name" onchange="flip_hardcode('name')" name="hardcode_name">
800 - <option value="no" <?php echo $link->hardcode('name')?'':'selected="selected"'; ?>>update automatically</option>
801 - <option value="yes" <?php echo $link->hardcode('name')?'selected="selected"':''; ?>>edit manually</option>
802 - </select>
803 - </td>
804 - </tr>
805 - <tr>
806 - <th scope="row" width="20%"><?php _e('Short description:') ?></th>
807 - <td width="60%">
808 - <input id="basics-description-edit" type="text" name="description" value="<?php echo $link_description; ?>" style="width: 95%" />
809 - <span id="basics-description-view"><strong><?php echo $link_description; ?></strong></span>
810 - </td>
811 - <td>
812 - <select id="basics-hardcode-description" onchange="flip_hardcode('description')"
813 - name="hardcode_description">
814 - <option value="no" <?php echo $link->hardcode('description')?'':'selected="selected"'; ?>>update automatically</option>
815 - <option value="yes" <?php echo $link->hardcode('description')?'selected="selected"':''; ?>>edit manually</option>
816 - </select></td>
817 - </tr>
818 - <tr>
819 - <th width="20%" scope="row"><?php _e('Homepage:') ?></th>
820 - <td width="60%">
821 - <input id="basics-url-edit" type="text" name="linkurl" value="<?php echo $link_url; ?>" style="width: 95%;" />
822 - <a id="basics-url-view" href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td>
823 - <td>
824 - <select id="basics-hardcode-url" onchange="flip_hardcode('url')" name="hardcode_url">
825 - <option value="no"<?php echo $link->hardcode('url')?'':' selected="selected"'; ?>>update automatically</option>
826 - <option value="yes"<?php echo $link->hardcode('url')?' selected="selected"':''; ?>>edit manually</option>
827 - </select></td></tr>
828 -
829 - <tr>
830 - <th width="20%"><?php _e('Last update') ?>:</th>
831 - <td colspan="2"><?php
832 - if (isset($link->settings['update/last'])) :
833 - echo fwp_time_elapsed($link->settings['update/last'])." ";
834 - else :
835 - echo " none yet";
836 - endif;
837 - ?></td></tr>
838 - <tr><th width="20%">Next update:</th>
839 - <td colspan="2"><?php
840 - $holdem = (isset($link->settings['update/hold']) ? $link->settings['update/hold'] : 'scheduled');
841 - ?>
842 - <select name="update_schedule">
843 - <option value="scheduled"<?php echo ($holdem=='scheduled')?' selected="selected"':''; ?>>update on schedule <?php
844 - echo " (";
845 - if (isset($link->settings['update/ttl']) and is_numeric($link->settings['update/ttl'])) :
846 - if (isset($link->settings['update/timed']) and $link->settings['update/timed']=='automatically') :
847 - echo 'next: ';
848 - $next = $link->settings['update/last'] + ((int) $link->settings['update/ttl'] * 60);
849 - if (strftime('%x', time()) != strftime('%x', $next)) :
850 - echo strftime('%x', $next)." ";
851 - endif;
852 - echo strftime('%X', $link->settings['update/last']+((int) $link->settings['update/ttl']*60));
853 - else :
854 - echo "every ".$link->settings['update/ttl']." minute".(($link->settings['update/ttl']!=1)?"s":"");
855 - endif;
856 - else:
857 - echo "next scheduled update";
858 - endif;
859 - echo ")";
860 - ?></option>
861 - <option value="next"<?php echo ($holdem=='next')?' selected="selected"':''; ?>>update ASAP</option>
862 - <option value="ping"<?php echo ($holdem=='ping')?' selected="selected"':''; ?>>update only when pinged</option>
863 - </select></tr>
864 - </table>
865 -<?php fwp_option_box_closer(); ?>
866 -
867 -<script type="text/javascript">
868 -flip_hardcode('name');
869 -flip_hardcode('description');
870 -flip_hardcode('url');
871 -</script>
872 -
873 -<?php fwp_linkedit_periodic_submit(); ?>
874 -
875 -<?php
876 - FeedWordPressSettingsUI::instead_of_posts_box($link_id);
877 - FeedWordPressSettingsUI::instead_of_authors_box($link_id);
878 - FeedWordPressSettingsUI::instead_of_categories_box($link_id);
879 -
880 - fwp_option_box_opener('Custom Feed Settings (for use in templates)', 'postcustom', 'postbox');
881 -?>
882 -<p class="setting-description">These custom settings are special fields for the <strong>feed</strong> you are
883 -syndicating, to be retrieved in templates using the <code>get_feed_meta()</code> function. They do not create
884 -custom fields on syndicated <strong>posts</strong>. If you want to create custom fields that are applied to each
885 -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>
886 -
887 -<div id="postcustomstuff">
888 -<table id="meta-list" cellpadding="3">
889 - <tr>
890 - <th>Key</th>
891 - <th>Value</th>
892 - <th>Action</th>
893 - </tr>
894 -
895 -<?php
896 - $i = 0;
897 - foreach ($link->settings as $key => $value) :
898 - if (!preg_match("\007^((".implode(')|(', $special_settings)."))$\007i", $key)) :
899 -?>
900 - <tr style="vertical-align:top">
901 - <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo wp_specialchars($key, 'both'); ?>" />
902 - <input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo wp_specialchars($key, 'both'); ?>" /></th>
903 - <td width="60%"><textarea rows="2" cols="40" id="notes-<?php echo $i; ?>-value" name="notes[<?php echo $i; ?>][value]"><?php echo wp_specialchars($value, 'both'); ?></textarea></td>
904 - <td width="10%"><select name="notes[<?php echo $i; ?>][action]">
905 - <option value="update">save changes</option>
906 - <option value="delete">delete this setting</option>
907 - </select></td>
908 - </tr>
909 -<?php
910 - $i++;
911 - endif;
912 - endforeach;
913 -?>
914 - <tr>
915 - <th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th>
916 - <td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea></td>
917 - <td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td>
918 - </tr>
919 -</table>
920 -<?php fwp_option_box_closer(); ?>
921 -
922 -<?php fwp_linkedit_periodic_submit(); ?>
923 -<?php fwp_linkedit_single_submit_closer(); ?>
924 -</div> <!-- id="post-body" -->
925 -</div> <!-- id="poststuff" -->
926 -</div>
927 - <?php
928 - endif;
929 - return false; // Don't continue
930 -}
931 -
932 -function fwp_multidelete_page () {
933 - global $wpdb;
934 -
935 - // If this is a POST, validate source and user credentials
936 - FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links');
937 -
938 - $link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array());
939 - if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif;
940 -
941 - if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'):
942 - foreach ($GLOBALS['fwp_post']['link_action'] as $link_id => $what) :
943 - $do_it[$what][] = $link_id;
944 - endforeach;
945 -
946 - $alter = array();
947 - if (count($do_it['hide']) > 0) :
948 - $hidem = "(".implode(', ', $do_it['hide']).")";
949 - $alter[] = "
950 - UPDATE $wpdb->links
951 - SET link_visible = 'N'
952 - WHERE link_id IN {$hidem}
953 - ";
954 - endif;
955 -
956 - if (count($do_it['nuke']) > 0) :
957 - $nukem = "(".implode(', ', $do_it['nuke']).")";
958 -
959 - // Make a list of the items syndicated from this feed...
960 - $post_ids = $wpdb->get_col("
961 - SELECT post_id FROM $wpdb->postmeta
962 - WHERE meta_key = 'syndication_feed_id'
963 - AND meta_value IN {$nukem}
964 - ");
965 -
966 - // ... and kill them all
967 - if (count($post_ids) > 0) :
968 - foreach ($post_ids as $post_id) :
969 - wp_delete_post($post_id);
970 - endforeach;
971 - endif;
972 -
973 - $alter[] = "
974 - DELETE FROM $wpdb->links
975 - WHERE link_id IN {$nukem}
976 - ";
977 - endif;
978 -
979 - if (count($do_it['delete']) > 0) :
980 - $deletem = "(".implode(', ', $do_it['delete']).")";
981 -
982 - // Make the items syndicated from this feed appear to be locally-authored
983 - $alter[] = "
984 - DELETE FROM $wpdb->postmeta
985 - WHERE meta_key = 'syndication_feed_id'
986 - AND meta_value IN {$deletem}
987 - ";
988 -
989 - // ... and delete the links themselves.
990 - $alter[] = "
991 - DELETE FROM $wpdb->links
992 - WHERE link_id IN {$deletem}
993 - ";
994 - endif;
995 -
996 - $errs = array(); $success = array ();
997 - foreach ($alter as $sql) :
998 - $result = $wpdb->query($sql);
999 - if (!$result):
1000 - $errs[] = mysql_error();
1001 - endif;
1002 - endforeach;
1003 -
1004 - if (count($alter) > 0) :
1005 - echo "<div class=\"updated\">\n";
1006 - if (count($errs) > 0) :
1007 - echo "There were some problems processing your ";
1008 - echo "unsubscribe request. [SQL: ".implode('; ', $errs)."]";
1009 - else :
1010 - echo "Your unsubscribe request(s) have been processed.";
1011 - endif;
1012 - echo "</div>\n";
1013 - endif;
1014 -
1015 - return true; // Continue on to Syndicated Sites listing
1016 - else :
1017 - $targets = $wpdb->get_results("
1018 - SELECT * FROM $wpdb->links
1019 - WHERE link_id IN (".implode(",",$link_ids).")
1020 - ");
1021 -?>
1022 -<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
1023 -<div class="wrap">
1024 -<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
1025 -<input type="hidden" name="action" value="Unsubscribe" />
1026 -<input type="hidden" name="confirm" value="Delete" />
1027 -
1028 -<h2>Unsubscribe from Syndicated Links:</h2>
1029 -<?php foreach ($targets as $link) :
1030 - $link_url = wp_specialchars($link->link_url, 1);
1031 - $link_name = wp_specialchars($link->link_name, 1);
1032 - $link_description = wp_specialchars($link->link_description, 'both');
1033 - $link_rss = wp_specialchars($link->link_rss, 'both');
1034 -?>
1035 -<fieldset>
1036 -<legend><?php echo $link_name; ?></legend>
1037 -<table class="editform" width="100%" cellspacing="2" cellpadding="5">
1038 -<tr><th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
1039 -<td width="80%"><a href="<?php echo $link_rss; ?>"><?php echo $link_rss; ?></a></td></tr>
1040 -<tr><th scope="row" width="20%"><?php _e('Short description:') ?></th>
1041 -<td width="80%"><?php echo $link_description; ?></span></td></tr>
1042 -<tr><th width="20%" scope="row"><?php _e('Homepage:') ?></th>
1043 -<td width="80%"><a href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td></tr>
1044 -<tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options') ?>:</th>
1045 -<td width="80%"><ul style="margin:0; padding: 0; list-style: none">
1046 -<li><input type="radio" id="hide-<?php echo $link->link_id; ?>"
1047 -name="link_action[<?php echo $link->link_id; ?>]" value="hide" />
1048 -<label for="hide-<?php echo $link->link_id; ?>">Turn off the subscription for this
1049 -syndicated link<br/><span style="font-size:smaller">(Keep the feed information
1050 -and all the posts from this feed in the database, but don't syndicate any
1051 -new posts from the feed.)</span></label></li>
1052 -<li><input type="radio" id="nuke-<?php echo $link->link_id; ?>"
1053 -name="link_action[<?php echo $link->link_id; ?>]" value="nuke" />
1054 -<label for="nuke-<?php echo $link->link_id; ?>">Delete this syndicated link and all the
1055 -posts that were syndicated from it</label></li>
1056 -<li><input type="radio" id="delete-<?php echo $link->link_id; ?>"
1057 -name="link_action[<?php echo $link->link_id; ?>]" value="delete" />
1058 -<label for="delete-<?php echo $link->link_id; ?>">Delete this syndicated link, but
1059 -<em>keep</em> posts that were syndicated from it (as if they were authored
1060 -locally).</label></li>
1061 -<li><input type="radio" id="nothing-<?php echo $link->link_id; ?>"
1062 -name="link_action[<?php echo $link->link_id; ?>]" value="nothing" />
1063 -<label for="nothing-<?php echo $link->link_id; ?>">Keep this feed as it is. I changed
1064 -my mind.</label></li>
1065 -</ul>
1066 -</table>
1067 -</fieldset>
1068 -<?php endforeach; ?>
1069 -
1070 -<div class="submit">
1071 -<input class="delete" type="submit" name="submit" value="<?php _e('Unsubscribe from selected feeds &raquo;') ?>" />
1072 -</div>
1073 -</div>
1074 -<?php
1075 - return false; // Don't continue on to Syndicated Sites listing
1076 - endif;
1077 -}
1078 -
1079 - fwp_syndication_manage_page();
1080 -
4 + $syndicationPage = new FeedWordPressSyndicationPage( __FILE__ );
5 + $syndicationPage->display();