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