PluginProbe
FeedWordPress / 2015.0514
FeedWordPress v2015.0514
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 2015.0514, at feedwordpresssyndicationpage.class.php

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