PluginProbe
FeedWordPress / 2022.0123
FeedWordPress v2022.0123
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 2022.0123, at feedwordpresssyndicationpage.class.php

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