PluginProbe
FeedWordPress / 2013.0503
FeedWordPress v2013.0503
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
feedwordpress / feedwordpresssyndicationpage.class.php

feedwordpresssyndicationpage.class.php in FeedWordPress 2013.0503, at feedwordpresssyndicationpage.class.php

1,170 lines 42.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 require_once(dirname(__FILE__) . '/admin-ui.php');
3 require_once(dirname(__FILE__) . '/feedfinder.class.php');
4
5 ################################################################################
6 ## ADMIN MENU ADD-ONS: implement Dashboard management pages ####################
7 ################################################################################
8
9 define('FWP_UPDATE_CHECKED', 'Update Checked');
10 define('FWP_UNSUB_CHECKED', 'Unsubscribe');
11 define('FWP_DELETE_CHECKED', 'Delete');
12 define('FWP_RESUB_CHECKED', 'Re-subscribe');
13 define('FWP_SYNDICATE_NEW', 'Add →');
14 define('FWP_UNSUB_FULL', 'Unsubscribe from selected feeds →');
15 define('FWP_CANCEL_BUTTON', '× Cancel');
16 define('FWP_CHECK_FOR_UPDATES', 'Update');
17
18 class FeedWordPressSyndicationPage extends FeedWordPressAdminPage {
19 function FeedWordPressSyndicationPage ($filename = NULL) {
20 FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresssyndication', /*link=*/ NULL);
21
22 // No over-arching form element
23 $this->dispatch = NULL;
24 if (is_null($filename)) :
25 $this->filename = __FILE__;
26 else :
27 $this->filename = $filename;
28 endif;
29 } /* FeedWordPressSyndicationPage constructor */
30
31 function has_link () { return false; }
32
33 var $_sources = NULL;
34
35 function sources ($visibility = 'Y') {
36 if (is_null($this->_sources)) :
37 $links = FeedWordPress::syndicated_links(array("hide_invisible" => false));
38 $this->_sources = array("Y" => array(), "N" => array());
39 foreach ($links as $link) :
40 $this->_sources[$link->link_visible][] = $link;
41 endforeach;
42 endif;
43 $ret = (
44 array_key_exists($visibility, $this->_sources)
45 ? $this->_sources[$visibility]
46 : $this->_sources
47 );
48 return $ret;
49 } /* FeedWordPressSyndicationPage::sources() */
50
51 function visibility_toggle () {
52 $sources = $this->sources('*');
53
54 $defaultVisibility = 'Y';
55 if ((count($this->sources('N')) > 0)
56 and (count($this->sources('Y'))==0)) :
57 $defaultVisibility = 'N';
58 endif;
59
60 $visibility = (
61 isset($_REQUEST['visibility'])
62 ? $_REQUEST['visibility']
63 : $defaultVisibility
64 );
65
66 return $visibility;
67 } /* FeedWordPressSyndicationPage::visibility_toggle() */
68
69 function show_inactive () {
70 return ($this->visibility_toggle() == 'N');
71 }
72
73 function updates_requested () {
74 global $wpdb;
75
76 if (isset($_POST['update']) or isset($_POST['action']) or isset($_POST['update_uri'])) :
77 // Only do things with side-effects for HTTP POST or command line
78 $fwp_update_invoke = 'post';
79 else :
80 $fwp_update_invoke = 'get';
81 endif;
82
83 $update_set = array();
84 if ($fwp_update_invoke != 'get') :
85 if (is_array(MyPHP::post('link_ids'))
86 and (MyPHP::post('action')==FWP_UPDATE_CHECKED)) :
87 $targets = $wpdb->get_results("
88 SELECT * FROM $wpdb->links
89 WHERE link_id IN (".implode(",",$_POST['link_ids']).")
90 ");
91 if (is_array($targets)) :
92 foreach ($targets as $target) :
93 $update_set[] = $target->link_rss;
94 endforeach;
95 else : // This should never happen
96 FeedWordPress::critical_bug('fwp_syndication_manage_page::targets', $targets, __LINE__, __FILE__);
97 endif;
98 elseif (!is_null(MyPHP::post('update_uri'))) :
99 $targets = MyPHP::post('update_uri');
100 if (!is_array($targets)) :
101 $targets = array($targets);
102 endif;
103
104 $first = each($targets);
105 if (!is_numeric($first['key'])) : // URLs in keys
106 $targets = array_keys($targets);
107 endif;
108 $update_set = $targets;
109 endif;
110 endif;
111 return $update_set;
112 }
113
114 function accept_multiadd () {
115 global $fwp_post;
116
117 if (isset($fwp_post['cancel']) and $fwp_post['cancel']==__(FWP_CANCEL_BUTTON)) :
118 return true; // Continue ....
119 endif;
120
121 // If this is a POST, validate source and user credentials
122 FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links');
123
124 $in = (isset($fwp_post['multilookup']) ? $fwp_post['multilookup'] : '')
125 .(isset($fwp_post['opml_lookup']) ? $fwp_post['opml_lookup'] : '');
126 if (isset($fwp_post['confirm']) and $fwp_post['confirm']=='multiadd') :
127 $chex = $fwp_post['multilookup'];
128 $added = array(); $errors = array();
129 foreach ($chex as $feed) :
130 if (isset($feed['add']) and $feed['add']=='yes') :
131 // Then, add in the URL.
132 $link_id = FeedWordPress::syndicate_link(
133 $feed['title'],
134 $feed['link'],
135 $feed['url']
136 );
137 if ($link_id and !is_wp_error($link_id)):
138 $added[] = $link_id;
139 else :
140 $errors[] = array($feed['url'], $link_id);
141 endif;
142 endif;
143 endforeach;
144
145 print "<div class='updated'>\n";
146 print "<p>Added ".count($added)." new syndicated sources.</p>";
147 if (count($errors) > 0) :
148 print "<p>FeedWordPress encountered errors trying to add the following sources:</p>
149 <ul>\n";
150 foreach ($errors as $err) :
151 $url = $err[0];
152 $short = esc_html(feedwordpress_display_url($url));
153 $url = esc_html($url);
154 $wp = $err[1];
155 if (is_wp_error($err[1])) :
156 $error = $err[1];
157 $mesg = " (<code>".$error->get_error_messages()."</code>)";
158 else :
159 $mesg = '';
160 endif;
161 print "<li><a href='$url'>$short</a>$mesg</li>\n";
162 endforeach;
163 print "</ul>\n";
164 endif;
165 print "</div>\n";
166
167 elseif (is_array($in) or strlen($in) > 0) :
168 add_meta_box(
169 /*id=*/ 'feedwordpress_multiadd_box',
170 /*title=*/ __('Add Feeds'),
171 /*callback=*/ array($this, 'multiadd_box'),
172 /*page=*/ $this->meta_box_context(),
173 /*context =*/ $this->meta_box_context()
174 );
175 endif;
176 return true; // Continue...
177 }
178
179 function display_multiadd_line ($line) {
180 $short_feed = esc_html(feedwordpress_display_url($line['feed']));
181 $feed = esc_html($line['feed']);
182 $link = esc_html($line['link']);
183 $title = esc_html($line['title']);
184 $checked = $line['checked'];
185 $i = esc_html($line['i']);
186
187 print "<li><label><input type='checkbox' name='multilookup[$i][add]' value='yes' $checked />
188 $title</label> &middot; <a href='$feed'>$short_feed</a>";
189
190 if (isset($line['extra'])) :
191 print " &middot; ".esc_html($line['extra']);
192 endif;
193
194 print "<input type='hidden' name='multilookup[$i][url]' value='$feed' />
195 <input type='hidden' name='multilookup[$i][link]' value='$link' />
196 <input type='hidden' name='multilookup[$i][title]' value='$title' />
197 </li>\n";
198
199 flush();
200 }
201
202 function multiadd_box ($page, $box = NULL) {
203 global $fwp_post;
204
205 $localData = NULL;
206
207 if (isset($_FILES['opml_upload']['name']) and
208 (strlen($_FILES['opml_upload']['name']) > 0)) :
209 $in = 'tag:localhost';
210
211 /*FIXME: check whether $_FILES['opml_upload']['error'] === UPLOAD_ERR_OK or not...*/
212 $localData = file_get_contents($_FILES['opml_upload']['tmp_name']);
213 $merge_all = true;
214 elseif (isset($fwp_post['multilookup'])) :
215 $in = $fwp_post['multilookup'];
216 $merge_all = false;
217 elseif (isset($fwp_post['opml_lookup'])) :
218 $in = $fwp_post['opml_lookup'];
219 $merge_all = true;
220 else :
221 $in = '';
222 $merge_all = false;
223 endif;
224
225 if (strlen($in) > 0) :
226 $lines = preg_split(
227 "/\s+/",
228 $in,
229 /*no limit soldier*/ -1,
230 PREG_SPLIT_NO_EMPTY
231 );
232
233 $i = 0;
234 ?>
235 <form id="multiadd-form" action="<?php print $this->form_action(); ?>" method="post">
236 <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
237 <input type="hidden" name="multiadd" value="<?php print FWP_SYNDICATE_NEW; ?>" />
238 <input type="hidden" name="confirm" value="multiadd" />
239
240 <input type="hidden" name="multiadd" value="<?php print FWP_SYNDICATE_NEW; ?>" />
241 <input type="hidden" name="confirm" value="multiadd" /></div>
242
243 <div id="multiadd-status">
244 <p><img src="<?php print esc_url ( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
245 Looking up feed information...</p>
246 </div>
247
248 <div id="multiadd-buttons">
249 <input type="submit" class="button" name="cancel" value="<?php _e(FWP_CANCEL_BUTTON); ?>" />
250 <input type="submit" class="button-primary" value="<?php print _e('Subscribe to selected sources →'); ?>" />
251 </div>
252
253 <p><?php _e('Here are the feeds that FeedWordPress has discovered from the addresses that you provided. To opt out of a subscription, unmark the checkbox next to the feed.'); ?></p>
254
255 <?php
256 print "<ul id=\"multiadd-list\">\n"; flush();
257 foreach ($lines as $line) :
258 $url = trim($line);
259 if (strlen($url) > 0) :
260 // First, use FeedFinder to check the URL.
261 if (is_null($localData)) :
262 $finder = new FeedFinder($url, /*verify=*/ false, /*fallbacks=*/ 1);
263 else :
264 $finder = new FeedFinder('tag:localhost', /*verify=*/ false, /*fallbacks=*/ 1);
265 $finder->upload_data($localData);
266 endif;
267
268 $feeds = array_values(
269 array_unique(
270 $finder->find()
271 )
272 );
273
274 $found = false;
275 if (count($feeds) > 0) :
276 foreach ($feeds as $feed) :
277 $pie = FeedWordPress::fetch($feed);
278 if (!is_wp_error($pie)) :
279 $found = true;
280
281 $short_feed = esc_html(feedwordpress_display_url($feed));
282 $feed = esc_html($feed);
283 $title = esc_html($pie->get_title());
284 $checked = ' checked="checked"';
285 $link = esc_html($pie->get_link());
286
287 $this->display_multiadd_line(array(
288 'feed' => $feed,
289 'title' => $pie->get_title(),
290 'link' => $pie->get_link(),
291 'checked' => ' checked="checked"',
292 'i' => $i,
293 ));
294
295 $i++; // Increment field counter
296
297 if (!$merge_all) : // Break out after first find
298 break;
299 endif;
300 endif;
301 endforeach;
302 endif;
303
304 if (!$found) :
305 $this->display_multiadd_line(array(
306 'feed' => $url,
307 'title' => feedwordpress_display_url($url),
308 'extra' => " [FeedWordPress couldn't detect any feeds for this URL.]",
309 'link' => NULL,
310 'checked' => '',
311 'i' => $i,
312 ));
313 $i++; // Increment field counter
314 endif;
315 endif;
316 endforeach;
317 print "</ul>\n";
318 ?>
319 </form>
320
321 <script type="text/javascript">
322 jQuery(document).ready( function () {
323 // Hide it now that we're done.
324 jQuery('#multiadd-status').fadeOut(500 /*ms*/);
325 } );
326 </script>
327 <?php
328 endif;
329
330 $this->_sources = NULL; // Force reload of sources list
331 return true; // Continue
332 }
333
334 function display () {
335 global $wpdb;
336 global $fwp_post;
337
338 if (FeedWordPress::needs_upgrade()) :
339 fwp_upgrade_page();
340 return;
341 endif;
342
343 $cont = true;
344 $dispatcher = array(
345 "feedfinder" => 'fwp_feedfinder_page',
346 FWP_SYNDICATE_NEW => 'fwp_feedfinder_page',
347 "switchfeed" => 'fwp_switchfeed_page',
348 FWP_UNSUB_CHECKED => 'multidelete_page',
349 FWP_DELETE_CHECKED => 'multidelete_page',
350 'Unsubscribe' => 'multidelete_page',
351 FWP_RESUB_CHECKED => 'multiundelete_page',
352 );
353
354 $act = MyPHP::request('action');
355 if (isset($dispatcher[$act])) :
356 $method = $dispatcher[$act];
357 if (method_exists($this, $method)) :
358 $cont = $this->{$method}();
359 else :
360 $cont = call_user_func($method);
361 endif;
362 elseif (isset($fwp_post['multiadd']) and $fwp_post['multiadd']==FWP_SYNDICATE_NEW) :
363 $cont = $this->accept_multiadd($fwp_post);
364 endif;
365
366 if ($cont):
367 $links = $this->sources('Y');
368 $potential_updates = (!$this->show_inactive() and (count($this->sources('Y')) > 0));
369
370 $this->open_sheet('Syndicated Sites');
371 ?>
372 <div id="post-body">
373 <?php
374 if ($potential_updates
375 or (count($this->updates_requested()) > 0)) :
376 add_meta_box(
377 /*id=*/ 'feedwordpress_update_box',
378 /*title=*/ __('Update feeds now'),
379 /*callback=*/ 'fwp_syndication_manage_page_update_box',
380 /*page=*/ $this->meta_box_context(),
381 /*context =*/ $this->meta_box_context()
382 );
383 endif;
384 add_meta_box(
385 /*id=*/ 'feedwordpress_feeds_box',
386 /*title=*/ __('Syndicated sources'),
387 /*callback=*/ array($this, 'syndicated_sources_box'),
388 /*page=*/ $this->meta_box_context(),
389 /*context =*/ $this->meta_box_context()
390 );
391
392 do_action('feedwordpress_admin_page_syndication_meta_boxes', $this);
393 ?>
394 <div class="metabox-holder">
395 <?php
396 fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
397 ?>
398 </div> <!-- class="metabox-holder" -->
399 </div> <!-- id="post-body" -->
400
401 <?php $this->close_sheet(/*dispatch=*/ NULL); ?>
402
403 <div style="display: none">
404 <div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
405 </div>
406 <?php
407 endif;
408 } /* FeedWordPressSyndicationPage::display () */
409
410 function dashboard_box ($page, $box = NULL) {
411 global $fwp_path;
412
413 $links = FeedWordPress::syndicated_links(array("hide_invisible" => false));
414 $sources = $this->sources('*');
415
416 $visibility = 'Y';
417 $hrefPrefix = $this->form_action();
418 $activeHref = $hrefPrefix.'&visibility=Y';
419 $inactiveHref = $hrefPrefix.'&visibility=N';
420
421 $lastUpdate = get_option('feedwordpress_last_update_all', NULL);
422 $automatic_updates = get_option('feedwordpress_automatic_updates', NULL);
423
424 if ('init'==$automatic_updates) :
425 $update_setting = 'automatically before page loads';
426 elseif ('shutdown'==$automatic_updates) :
427 $update_setting = 'automatically after page loads';
428 else :
429 $update_setting = 'using a cron job or manual check-ins';
430 endif;
431
432 // Hey ho, let's go...
433 ?>
434 <div style="float: left; background: #F5F5F5; padding-top: 5px; padding-right: 5px;"><a href="<?php print $this->form_action(); ?>"><img src="<?php print esc_html(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></a></div>
435
436 <p class="info" style="margin-bottom: 0px; border-bottom: 1px dotted black;">Managed by <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a>
437 <?php print FEEDWORDPRESS_VERSION; ?>.</p>
438 <?php if (FEEDWORDPRESS_BLEG) : ?>
439 <p class="info" style="margin-top: 0px; font-style: italic; font-size: 75%; color: #666;">If you find this tool useful for your daily work, you can
440 contribute to ongoing support and development with
441 <a href="http://feedwordpress.radgeek.com/donate/">a modest donation</a>.</p>
442 <br style="clear: left;" />
443 <?php endif; ?>
444
445 <div class="feedwordpress-actions">
446 <h4>Updates</h4>
447 <ul class="options">
448 <li><strong>Scheduled:</strong> <?php print $update_setting; ?>
449 (<a href="<?php print $this->form_action('feeds-page.php'); ?>">change setting</a>)</li>
450
451 <li><?php if (!is_null($lastUpdate)) : ?>
452 <strong>Last checked:</strong> <?php print fwp_time_elapsed($lastUpdate); ?>
453 <?php else : ?>
454 <strong>Last checked:</strong> none yet
455 <?php endif; ?> </li>
456
457 </ul>
458 </div>
459
460 <div class="feedwordpress-stats">
461 <h4>Subscriptions</h4>
462 <table>
463 <tbody>
464 <tr class="first">
465 <td class="first b b-active"><a href="<?php print esc_html($activeHref); ?>"><?php print count($sources['Y']); ?></a></td>
466 <td class="t active"><a href="<?php print esc_html($activeHref); ?>">Active</a></td>
467 </tr>
468
469 <tr>
470 <td class="b b-inactive"><a href="<?php print esc_html($inactiveHref); ?>"><?php print count($sources['N']); ?></a></td>
471 <td class="t inactive"><a href="<?php print esc_html($inactiveHref); ?>">Inactive</a></td>
472 </tr>
473 </table>
474 </div>
475
476 <div id="add-single-uri">
477 <?php if (count($sources['Y']) > 0) : ?>
478 <form id="check-for-updates" action="<?php print $this->form_action(); ?>" method="POST">
479 <div class="container"><input type="submit" class="button-primary" name"update" value="<?php print FWP_CHECK_FOR_UPDATES; ?>" />
480 <?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
481 <input type="hidden" name="update_uri" value="*" /></div>
482 </form>
483 <?php endif; ?>
484
485 <form id="syndicated-links" action="<?php print $hrefPrefix; ?>&amp;visibility=<?php print $visibility; ?>" method="post">
486 <div class="container"><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
487 <label for="add-uri">Add:
488 <input type="text" name="lookup" id="add-uri" placeholder="Source URL"
489 value="Source URL" style="width: 55%;" /></label>
490
491 <?php FeedWordPressSettingsUI::magic_input_tip_js('add-uri'); ?>
492 <input type="hidden" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" />
493 <input style="vertical-align: middle;" type="image" src="<?php print WP_PLUGIN_URL.'/'.$fwp_path; ?>/plus.png" alt="<?php print FWP_SYNDICATE_NEW; ?>" /></div>
494 </form>
495 </div> <!-- id="add-single-uri" -->
496
497 <br style="clear: both;" />
498
499 <?php
500 } /* FeedWordPressSyndicationPage::dashboard_box () */
501
502 function syndicated_sources_box ($page, $box = NULL) {
503 global $fwp_path;
504
505 $links = FeedWordPress::syndicated_links(array("hide_invisible" => false));
506 $sources = $this->sources('*');
507
508 $visibility = $this->visibility_toggle();
509 $showInactive = $this->show_inactive();
510
511 $hrefPrefix = $this->form_action();
512 ?>
513 <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
514 <div class="tablenav">
515
516 <div id="add-multiple-uri" class="hide-if-js">
517 <form action="<?php print $hrefPrefix; ?>&amp;visibility=<?php print $visibility; ?>" method="post">
518 <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
519 <h4>Add Multiple Sources</h4>
520 <div>Enter one feed or website URL per line. If a URL links to a website which provides multiple feeds, FeedWordPress will use the first one listed.</div>
521 <div><textarea name="multilookup" rows="8" cols="60"
522 style="vertical-align: top"></textarea></div>
523 <div style="border-top: 1px dotted black; padding-top: 10px">
524 <div class="alignright"><input type="submit" class="button-primary" name="multiadd" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div>
525 <div class="alignleft"><input type="button" class="button-secondary" name="action" value="<?php print FWP_CANCEL_BUTTON; ?>" id="turn-off-multiple-sources" /></div>
526 </div>
527 </form>
528 </div> <!-- id="add-multiple-uri" -->
529
530 <div id="upload-opml" style="float: right" class="hide-if-js">
531 <h4>Import source list</h4>
532 <p>You can import a list of sources in OPML format, either by providing
533 a URL for the OPML document, or by uploading a copy from your
534 computer.</p>
535
536 <form enctype="multipart/form-data" action="<?php print $hrefPrefix; ?>&amp;visibility=<?php print $visibility; ?>" method="post">
537 <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?><input type="hidden" name="MAX_FILE_SIZE" value="100000" /></div>
538 <div style="clear: both"><label for="opml-lookup" style="float: left; width: 8.0em; margin-top: 5px;">From URL:</label> <input type="text" id="opml-lookup" name="opml_lookup" value="OPML document" /></div>
539 <div style="clear: both"><label for="opml-upload" style="float: left; width: 8.0em; margin-top: 5px;">From file:</label> <input type="file" id="opml-upload" name="opml_upload" /></div>
540
541 <div style="border-top: 1px dotted black; padding-top: 10px">
542 <div class="alignright"><input type="submit" class="button-primary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div>
543 <div class="alignleft"><input type="button" class="button-secondary" name="action" value="<?php print FWP_CANCEL_BUTTON; ?>" id="turn-off-opml-upload" /></div>
544 </div>
545 </form>
546 </div> <!-- id="upload-opml" -->
547
548 <div id="add-single-uri" class="alignright">
549 <form id="syndicated-links" action="<?php print $hrefPrefix; ?>&amp;visibility=<?php print $visibility; ?>" method="post">
550 <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
551 <ul class="subsubsub">
552 <li><label for="add-uri">New source:</label>
553 <input type="text" name="lookup" id="add-uri" value="Website or feed URI" />
554
555 <?php FeedWordPressSettingsUI::magic_input_tip_js('add-uri'); FeedWordPressSettingsUI::magic_input_tip_js('opml-lookup'); ?>
556
557 <input type="hidden" name="action" value="feedfinder" />
558 <input type="submit" class="button-secondary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" />
559 <div style="text-align: right; margin-right: 2.0em"><a id="turn-on-multiple-sources" href="#add-multiple-uri"><img style="vertical-align: middle" src="<?php print WP_PLUGIN_URL.'/'.$fwp_path; ?>/down.png" alt="" /> add multiple</a>
560 <span class="screen-reader-text"> or </span>
561 <a id="turn-on-opml-upload" href="#upload-opml"><img src="<?php print WP_PLUGIN_URL.'/'.$fwp_path; ?>/plus.png" alt="" style="vertical-align: middle" /> import source list</a></div>
562 </li>
563 </ul>
564 </form>
565 </div> <!-- class="alignright" -->
566
567 <div class="alignleft">
568 <?php
569 if (count($sources[$visibility]) > 0) :
570 fwp_syndication_manage_page_links_subsubsub($sources, $showInactive);
571 endif;
572 ?>
573 </div> <!-- class="alignleft" -->
574
575 </div> <!-- class="tablenav" -->
576
577 <form id="syndicated-links" action="<?php print $hrefPrefix; ?>&amp;visibility=<?php print $visibility; ?>" method="post">
578 <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
579
580 <?php if ($showInactive) : ?>
581 <div style="clear: right" class="alignright">
582 <p style="font-size: smaller; font-style: italic">FeedWordPress used to syndicate
583 posts from these sources, but you have unsubscribed from them.</p>
584 </div>
585 <?php
586 endif;
587 ?>
588
589 <?php
590 if (count($sources[$visibility]) > 0) :
591 $this->display_button_bar($showInactive);
592 else :
593 ?>
594 <?php fwp_syndication_manage_page_links_subsubsub($sources, $showInactive); ?>
595 <?php
596 endif;
597
598 fwp_syndication_manage_page_links_table_rows($sources[$visibility], $this, $visibility);
599 $this->display_button_bar($showInactive);
600 ?>
601 </form>
602 <?php
603 } /* FeedWordPressSyndicationPage::syndicated_sources_box() */
604
605 function display_button_bar ($showInactive) {
606 ?>
607 <div style="clear: left" class="alignleft">
608 <?php if ($showInactive) : ?>
609 <input class="button-secondary" type="submit" name="action" value="<?php print FWP_RESUB_CHECKED; ?>" />
610 <input class="button-secondary" type="submit" name="action" value="<?php print FWP_DELETE_CHECKED; ?>" />
611 <?php else : ?>
612 <input class="button-secondary" type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" />
613 <input class="button-secondary delete" type="submit" name="action" value="<?php print FWP_UNSUB_CHECKED; ?>" />
614 <?php endif ; ?>
615 </div> <!-- class="alignleft" -->
616
617 <br class="clear" />
618 <?php
619 }
620
621 function bleg_thanks ($page, $box = NULL) {
622 ?>
623 <div class="donation-thanks">
624 <h4>Thank you!</h4>
625 <p><strong>Thank you</strong> for your contribution to <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a> development.
626 Your generous gifts make ongoing support and development for
627 FeedWordPress possible.</p>
628 <p>If you have any questions about FeedWordPress, or if there
629 is anything I can do to help make FeedWordPress more useful for
630 you, please <a href="http://feedwordpress.radgeek.com/contact">contact me</a>
631 and let me know what you're thinking about.</p>
632 <p class="signature">&#8212;<a href="http://radgeek.com/">Charles Johnson</a>, Developer, <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a>.</p>
633 </div>
634 <?php
635 } /* FeedWordPressSyndicationPage::bleg_thanks () */
636
637 function bleg_box ($page, $box = NULL) {
638 ?>
639 <div class="donation-form">
640 <h4>Keep FeedWordPress improving</h4>
641 <form action="https://www.paypal.com/cgi-bin/webscr" accept-charset="UTF-8" method="post"><div>
642 <p><a href="http://feedwordpress.radgeek.com/">FeedWordPress</a> makes syndication
643 simple and empowers you to stream content from all over the web into your
644 WordPress hub. That's got to be worth a few lattes. If you're finding FWP useful,
645 <a href="http://feedwordpress.radgeek.com/donate/">a modest gift</a>
646 is the best way to support steady progress on development, enhancements,
647 support, and documentation.</p>
648 <div class="donate">
649 <input type="hidden" name="business" value="commerce@radgeek.com" />
650 <input type="hidden" name="cmd" value="_xclick" />
651 <input type="hidden" name="item_name" value="FeedWordPress donation" />
652 <input type="hidden" name="no_shipping" value="1" />
653 <input type="hidden" name="return" value="<?php print admin_url('admin.php'); ?>?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename($this->filename); ?>&amp;paid=yes" />
654 <input type="hidden" name="currency_code" value="USD" />
655 <input type="hidden" name="notify_url" value="http://feedwordpress.radgeek.com/ipn/donation" />
656 <input type="hidden" name="custom" value="1" />
657 <input type="image" name="submit" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif" alt="Donate through PayPal" />
658 </div>
659 </div></form>
660
661 <p>You can make a gift online (or
662 <a href="http://feedwordpress.radgeek.com/donation">set up an automatic
663 regular donation</a>) using an existing PayPal account or any major credit card.</p>
664
665 <div class="sod-off">
666 <form style="text-align: center" action="<?php print $this->form_action(); ?>" method="POST"><div>
667 <input class="button" type="submit" name="maybe_later" value="Maybe Later" />
668 <input class="button" type="submit" name="go_away" value="Dismiss" />
669 </div></form>
670 </div>
671 </div> <!-- class="donation-form" -->
672 <?php
673 } /* FeedWordPressSyndicationPage::bleg_box () */
674
675 /**
676 * Override the default display of a save-settings button and replace
677 * it with nothing.
678 */
679 function interstitial () {
680 /* NOOP */
681 } /* FeedWordPressSyndicationPage::interstitial() */
682
683 function multidelete_page () {
684 global $wpdb;
685 global $fwp_post;
686
687 // If this is a POST, validate source and user credentials
688 FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links');
689
690 if (isset($fwp_post['submit']) and $fwp_post['submit']==FWP_CANCEL_BUTTON) :
691 return true; // Continue without further ado.
692 endif;
693
694 $link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array());
695 if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif;
696
697 if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'):
698 if (isset($GLOBALS['fwp_post']['link_action']) and is_array($GLOBALS['fwp_post']['link_action'])) :
699 $actions = $GLOBALS['fwp_post']['link_action'];
700 else :
701 $actions = array();
702 endif;
703
704 $do_it = array(
705 'hide' => array(),
706 'nuke' => array(),
707 'delete' => array(),
708 );
709
710 foreach ($actions as $link_id => $what) :
711 $do_it[$what][] = $link_id;
712 endforeach;
713
714 $alter = array();
715 if (count($do_it['hide']) > 0) :
716 $hidem = "(".implode(', ', $do_it['hide']).")";
717 $alter[] = "
718 UPDATE $wpdb->links
719 SET link_visible = 'N'
720 WHERE link_id IN {$hidem}
721 ";
722 endif;
723
724 if (count($do_it['nuke']) > 0) :
725 $nukem = "(".implode(', ', $do_it['nuke']).")";
726
727 // Make a list of the items syndicated from this feed...
728 $post_ids = $wpdb->get_col("
729 SELECT post_id FROM $wpdb->postmeta
730 WHERE meta_key = 'syndication_feed_id'
731 AND meta_value IN {$nukem}
732 ");
733
734 // ... and kill them all
735 if (count($post_ids) > 0) :
736 foreach ($post_ids as $post_id) :
737 // Force scrubbing of deleted post
738 // rather than sending to Trashcan
739 wp_delete_post(
740 /*postid=*/ $post_id,
741 /*force_delete=*/ true
742 );
743 endforeach;
744 endif;
745
746 $alter[] = "
747 DELETE FROM $wpdb->links
748 WHERE link_id IN {$nukem}
749 ";
750 endif;
751
752 if (count($do_it['delete']) > 0) :
753 $deletem = "(".implode(', ', $do_it['delete']).")";
754
755 // Make the items syndicated from this feed appear to be locally-authored
756 $alter[] = "
757 DELETE FROM $wpdb->postmeta
758 WHERE meta_key = 'syndication_feed_id'
759 AND meta_value IN {$deletem}
760 ";
761
762 // ... and delete the links themselves.
763 $alter[] = "
764 DELETE FROM $wpdb->links
765 WHERE link_id IN {$deletem}
766 ";
767 endif;
768
769 $errs = array(); $success = array ();
770 foreach ($alter as $sql) :
771 $result = $wpdb->query($sql);
772 if (!$result):
773 $errs[] = mysql_error();
774 endif;
775 endforeach;
776
777 if (count($alter) > 0) :
778 echo "<div class=\"updated\">\n";
779 if (count($errs) > 0) :
780 echo "There were some problems processing your ";
781 echo "unsubscribe request. [SQL: ".implode('; ', $errs)."]";
782 else :
783 echo "Your unsubscribe request(s) have been processed.";
784 endif;
785 echo "</div>\n";
786 endif;
787
788 return true; // Continue on to Syndicated Sites listing
789 else :
790 $targets = $wpdb->get_results("
791 SELECT * FROM $wpdb->links
792 WHERE link_id IN (".implode(",",$link_ids).")
793 ");
794 ?>
795 <form action="<?php print $this->form_action(); ?>" method="post">
796 <div class="wrap">
797 <?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
798 <input type="hidden" name="action" value="Unsubscribe" />
799 <input type="hidden" name="confirm" value="Delete" />
800
801 <h2>Unsubscribe from Syndicated Links:</h2>
802 <?php foreach ($targets as $link) :
803 $subscribed = ('Y' == strtoupper($link->link_visible));
804 $link_url = esc_html($link->link_url);
805 $link_name = esc_html($link->link_name);
806 $link_description = esc_html($link->link_description);
807 $link_rss = esc_html($link->link_rss);
808 ?>
809 <fieldset>
810 <legend><?php echo $link_name; ?></legend>
811 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
812 <tr><th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
813 <td width="80%"><a href="<?php echo $link_rss; ?>"><?php echo $link_rss; ?></a></td></tr>
814 <tr><th scope="row" width="20%"><?php _e('Short description:') ?></th>
815 <td width="80%"><?php echo $link_description; ?></span></td></tr>
816 <tr><th width="20%" scope="row"><?php _e('Homepage:') ?></th>
817 <td width="80%"><a href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td></tr>
818 <tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options') ?>:</th>
819 <td width="80%"><ul style="margin:0; padding: 0; list-style: none">
820 <?php if ($subscribed) : ?>
821 <li><input type="radio" id="hide-<?php echo $link->link_id; ?>"
822 name="link_action[<?php echo $link->link_id; ?>]" value="hide" checked="checked" />
823 <label for="hide-<?php echo $link->link_id; ?>">Turn off the subscription for this
824 syndicated link<br/><span style="font-size:smaller">(Keep the feed information
825 and all the posts from this feed in the database, but don't syndicate any
826 new posts from the feed.)</span></label></li>
827 <?php endif; ?>
828 <li><input type="radio" id="nuke-<?php echo $link->link_id; ?>"<?php if (!$subscribed) : ?> checked="checked"<?php endif; ?>
829 name="link_action[<?php echo $link->link_id; ?>]" value="nuke" />
830 <label for="nuke-<?php echo $link->link_id; ?>">Delete this syndicated link and all the
831 posts that were syndicated from it</label></li>
832 <li><input type="radio" id="delete-<?php echo $link->link_id; ?>"
833 name="link_action[<?php echo $link->link_id; ?>]" value="delete" />
834 <label for="delete-<?php echo $link->link_id; ?>">Delete this syndicated link, but
835 <em>keep</em> posts that were syndicated from it (as if they were authored
836 locally).</label></li>
837 <li><input type="radio" id="nothing-<?php echo $link->link_id; ?>"
838 name="link_action[<?php echo $link->link_id; ?>]" value="nothing" />
839 <label for="nothing-<?php echo $link->link_id; ?>">Keep this feed as it is. I changed
840 my mind.</label></li>
841 </ul>
842 </table>
843 </fieldset>
844 <?php endforeach; ?>
845
846 <div class="submit">
847 <input type="submit" name="submit" value="<?php _e(FWP_CANCEL_BUTTON); ?>" />
848 <input class="delete" type="submit" name="submit" value="<?php _e(FWP_UNSUB_FULL) ?>" />
849 </div>
850 </div>
851 <?php
852 return false; // Don't continue on to Syndicated Sites listing
853 endif;
854 } /* FeedWordPressSyndicationPage::multidelete_page() */
855
856 function multiundelete_page () {
857 global $wpdb;
858
859 // If this is a POST, validate source and user credentials
860 FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links');
861
862 $link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array());
863 if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif;
864
865 if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Undelete'):
866 if (isset($GLOBALS['fwp_post']['link_action']) and is_array($GLOBALS['fwp_post']['link_action'])) :
867 $actions = $GLOBALS['fwp_post']['link_action'];
868 else :
869 $actions = array();
870 endif;
871
872 $do_it = array(
873 'unhide' => array(),
874 );
875
876 foreach ($actions as $link_id => $what) :
877 $do_it[$what][] = $link_id;
878 endforeach;
879
880 $alter = array();
881 if (count($do_it['unhide']) > 0) :
882 $unhiddem = "(".implode(', ', $do_it['unhide']).")";
883 $alter[] = "
884 UPDATE $wpdb->links
885 SET link_visible = 'Y'
886 WHERE link_id IN {$unhiddem}
887 ";
888 endif;
889
890 $errs = array(); $success = array ();
891 foreach ($alter as $sql) :
892 $result = $wpdb->query($sql);
893 if (!$result):
894 $errs[] = mysql_error();
895 endif;
896 endforeach;
897
898 if (count($alter) > 0) :
899 echo "<div class=\"updated\">\n";
900 if (count($errs) > 0) :
901 echo "There were some problems processing your ";
902 echo "re-subscribe request. [SQL: ".implode('; ', $errs)."]";
903 else :
904 echo "Your re-subscribe request(s) have been processed.";
905 endif;
906 echo "</div>\n";
907 endif;
908
909 return true; // Continue on to Syndicated Sites listing
910 else :
911 $targets = $wpdb->get_results("
912 SELECT * FROM $wpdb->links
913 WHERE link_id IN (".implode(",",$link_ids).")
914 ");
915 ?>
916 <form action="<?php print $this->form_action(); ?>" method="post">
917 <div class="wrap">
918 <?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
919 <input type="hidden" name="action" value="<?php print FWP_RESUB_CHECKED; ?>" />
920 <input type="hidden" name="confirm" value="Undelete" />
921
922 <h2>Re-subscribe to Syndicated Links:</h2>
923 <?php
924 foreach ($targets as $link) :
925 $subscribed = ('Y' == strtoupper($link->link_visible));
926 $link_url = esc_html($link->link_url);
927 $link_name = esc_html($link->link_name);
928 $link_description = esc_html($link->link_description);
929 $link_rss = esc_html($link->link_rss);
930
931 if (!$subscribed) :
932 ?>
933 <fieldset>
934 <legend><?php echo $link_name; ?></legend>
935 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
936 <tr><th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
937 <td width="80%"><a href="<?php echo $link_rss; ?>"><?php echo $link_rss; ?></a></td></tr>
938 <tr><th scope="row" width="20%"><?php _e('Short description:') ?></th>
939 <td width="80%"><?php echo $link_description; ?></span></td></tr>
940 <tr><th width="20%" scope="row"><?php _e('Homepage:') ?></th>
941 <td width="80%"><a href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td></tr>
942 <tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options') ?>:</th>
943 <td width="80%"><ul style="margin:0; padding: 0; list-style: none">
944 <li><input type="radio" id="unhide-<?php echo $link->link_id; ?>"
945 name="link_action[<?php echo $link->link_id; ?>]" value="unhide" checked="checked" />
946 <label for="unhide-<?php echo $link->link_id; ?>">Turn back on the subscription
947 for this syndication source.</label></li>
948 <li><input type="radio" id="nothing-<?php echo $link->link_id; ?>"
949 name="link_action[<?php echo $link->link_id; ?>]" value="nothing" />
950 <label for="nothing-<?php echo $link->link_id; ?>">Leave this feed as it is.
951 I changed my mind.</label></li>
952 </ul>
953 </table>
954 </fieldset>
955 <?php
956 endif;
957 endforeach;
958 ?>
959
960 <div class="submit">
961 <input class="button-primary delete" type="submit" name="submit" value="<?php _e('Re-subscribe to selected feeds &raquo;') ?>" />
962 </div>
963 </div>
964 <?php
965 return false; // Don't continue on to Syndicated Sites listing
966 endif;
967 } /* FeedWordPressSyndicationPage::multiundelete_page() */
968
969
970
971 } /* class FeedWordPressSyndicationPage */
972
973 function fwp_dashboard_update_if_requested ($object) {
974 global $wpdb;
975
976 $update_set = $object->updates_requested();
977
978 if (count($update_set) > 0) :
979 shuffle($update_set); // randomize order for load balancing purposes...
980
981 $feedwordpress = new FeedWordPress;
982 add_action('feedwordpress_check_feed', 'update_feeds_mention');
983 add_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3);
984
985 $crash_ts = $feedwordpress->crash_ts();
986
987 echo "<div class=\"update-results\">\n";
988 echo "<ul>\n";
989 $tdelta = NULL;
990 foreach ($update_set as $uri) :
991 if (!is_null($crash_ts) and (time() > $crash_ts)) :
992 echo "<li><p><strong>Further updates postponed:</strong> update time limit of ".$crash_dt." second".(($crash_dt==1)?"":"s")." exceeded.</p></li>";
993 break;
994 endif;
995
996 if ($uri == '*') : $uri = NULL; endif;
997 $delta = $feedwordpress->update($uri, $crash_ts);
998 if (!is_null($delta)) :
999 if (is_null($tdelta)) :
1000 $tdelta = $delta;
1001 else :
1002 $tdelta['new'] += $delta['new'];
1003 $tdelta['updated'] += $delta['updated'];
1004 endif;
1005 else :
1006 $display_uri = esc_html(feedwordpress_display_url($uri));
1007 $uri = esc_html($uri);
1008 echo "<li><p><strong>Error:</strong> There was a problem updating <code><a href=\"$uri\">${display_uri}</a></code></p></li>\n";
1009 endif;
1010 endforeach;
1011 echo "</ul>\n";
1012
1013 if (!is_null($tdelta)) :
1014 $mesg = array();
1015 if (isset($delta['new'])) : $mesg[] = ' '.$tdelta['new'].' new posts were syndicated'; endif;
1016 if (isset($delta['updated'])) : $mesg[] = ' '.$tdelta['updated'].' existing posts were updated'; endif;
1017 echo "<p>Update complete.".implode(' and', $mesg)."</p>";
1018 echo "\n"; flush();
1019 endif;
1020 echo "</div> <!-- class=\"updated\" -->\n";
1021 endif;
1022 }
1023
1024 define('FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*/ * 24 /*hour/day*/ * 31 /*days*/));
1025 define('FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*/ * 24 /*hour/day*/ * 183 /*days*/));
1026 function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) {
1027 $bleg_box_hidden = null;
1028 if (isset($_POST['maybe_later'])) :
1029 $bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET;
1030 elseif (isset($_REQUEST['paid']) and $_REQUEST['paid']) :
1031 $bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET;
1032 elseif (isset($_POST['go_away'])) :
1033 $bleg_box_hidden = 'permanent';
1034 endif;
1035
1036 if (!is_null($bleg_box_hidden)) :
1037 update_option('feedwordpress_bleg_box_hidden', $bleg_box_hidden);
1038 else :
1039 $bleg_box_hidden = get_option('feedwordpress_bleg_box_hidden');
1040 endif;
1041 ?>
1042 <?php
1043 $bleg_box_ready = (FEEDWORDPRESS_BLEG and (
1044 !$bleg_box_hidden
1045 or (is_numeric($bleg_box_hidden) and $bleg_box_hidden < time())
1046 ));
1047
1048 if (isset($_REQUEST['paid']) and $_REQUEST['paid']) :
1049 $object->bleg_thanks($subject, $box);
1050 elseif ($bleg_box_ready) :
1051 $object->bleg_box($object, $box);
1052 endif;
1053 ?>
1054
1055 <form
1056 action="<?php print $object->form_action(); ?>"
1057 method="POST"
1058 class="update-form<?php if ($bleg_box_ready) : ?> with-donation<?php endif; ?>"
1059 >
1060 <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
1061 <p>Check currently scheduled feeds for new and updated posts.</p>
1062
1063 <?php
1064 fwp_dashboard_update_if_requested($object);
1065
1066 if (!get_option('feedwordpress_automatic_updates')) :
1067 ?>
1068 <p class="heads-up"><strong>Note:</strong> Automatic updates are currently turned
1069 <strong>off</strong>. New posts from your feeds will not be syndicated
1070 until you manually check for them here. You can turn on automatic
1071 updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/feeds-page.php">Feed &amp; Update Settings<a></a>.</p>
1072 <?php
1073 endif;
1074 ?>
1075
1076 <div class="submit"><?php if ($object->show_inactive()) : ?>
1077 <?php foreach ($object->updates_requested() as $req) : ?>
1078 <input type="hidden" name="update_uri[]" value="<?php print esc_html($req); ?>" />
1079 <?php endforeach; ?>
1080 <?php else : ?>
1081 <input type="hidden" name="update_uri" value="*" />
1082 <?php endif; ?>
1083 <input class="button-primary" type="submit" name="update" value="<?php _e(FWP_CHECK_FOR_UPDATES); ?>" /></div>
1084
1085 <br style="clear: both" />
1086 </form>
1087 <?php
1088 } /* function fwp_syndication_manage_page_update_box () */
1089
1090 function fwp_feedfinder_page () {
1091 global $post_source, $fwp_post, $syndicationPage;
1092
1093 if (isset($fwp_post['opml_lookup']) or isset($_FILES['opml_upload'])) :
1094 $syndicationPage->accept_multiadd();
1095 return true;
1096 else :
1097 $post_source = 'feedwordpress_feeds';
1098
1099 // With action=feedfinder, this goes directly to the feedfinder page
1100 include_once(dirname(__FILE__) . '/feeds-page.php');
1101 return false;
1102 endif;
1103 } /* function fwp_feedfinder_page () */
1104
1105 function fwp_switchfeed_page () {
1106 global $wpdb, $wp_db_version;
1107 global $fwp_post;
1108
1109 // If this is a POST, validate source and user credentials
1110 FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links');
1111
1112 $changed = false;
1113 if (!isset($fwp_post['Cancel'])):
1114 if (isset($fwp_post['save_link_id']) and ($fwp_post['save_link_id']=='*')) :
1115 $changed = true;
1116 $link_id = FeedWordPress::syndicate_link($fwp_post['feed_title'], $fwp_post['feed_link'], $fwp_post['feed']);
1117 if ($link_id):
1118 $existingLink = new SyndicatedLink($link_id);
1119
1120 ?>
1121 <div class="updated"><p><a href="<?php print $fwp_post['feed_link']; ?>"><?php print esc_html($fwp_post['feed_title']); ?></a>
1122 has been added as a contributing site, using the feed at
1123 &lt;<a href="<?php print $fwp_post['feed']; ?>"><?php print esc_html($fwp_post['feed']); ?></a>&gt;.
1124 | <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/feeds-page.php&amp;link_id=<?php print $link_id; ?>">Configure settings</a>.</p></div>
1125 <?php else: ?>
1126 <div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo esc_html(mysql_error()); ?>]</p></div>
1127 <?php endif;
1128 elseif (isset($fwp_post['save_link_id'])):
1129 $existingLink = new SyndicatedLink($fwp_post['save_link_id']);
1130 $changed = $existingLink->set_uri($fwp_post['feed']);
1131
1132 if ($changed):
1133 $home = $existingLink->homepage(/*from feed=*/ false);
1134 $name = $existingLink->name(/*from feed=*/ false);
1135 ?>
1136 <div class="updated"><p>Feed for <a href="<?php echo esc_html($home); ?>"><?php echo esc_html($name); ?></a>
1137 updated to &lt;<a href="<?php echo esc_html($fwp_post['feed']); ?>"><?php echo esc_html($fwp_post['feed']); ?></a>&gt;.</p></div>
1138 <?php
1139 endif;
1140 endif;
1141 endif;
1142
1143 if (isset($existingLink)) :
1144 $auth = MyPHP::post('link_rss_auth_method');
1145 if (!is_null($auth) and (strlen($auth) > 0) and ($auth != '-')) :
1146 $existingLink->update_setting('http auth method', $auth);
1147 $existingLink->update_setting('http username',
1148 MyPHP::post('link_rss_username')
1149 );
1150 $existingLink->update_setting('http password',
1151 MyPHP::post('link_rss_password')
1152 );
1153 else :
1154 $existingLink->update_setting('http auth method', NULL);
1155 $existingLink->update_setting('http username', NULL);
1156 $existingLink->update_setting('http password', NULL);
1157 endif;
1158 do_action('feedwordpress_admin_switchfeed', $fwp_post['feed'], $existingLink);
1159 $existingLink->save_settings(/*reload=*/ true);
1160 endif;
1161
1162 if (!$changed) :
1163 ?>
1164 <div class="updated"><p>Nothing was changed.</p></div>
1165 <?php
1166 endif;
1167 return true; // Continue
1168 }
1169
1170