PluginProbe
FeedWordPress / 2020.0118
FeedWordPress v2020.0118
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 2020.0118, at feedwordpresssyndicationpage.class.php

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