PluginProbe
FeedWordPress / 2024.0511
FeedWordPress v2024.0511
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 2024.0511, at feedwordpresssyndicationpage.class.php

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