dispatch = NULL;
if (is_null($filename)) :
$this->filename = __FILE__;
else :
$this->filename = $filename;
endif;
} /* FeedWordPressSyndicationPage constructor */
function has_link () { return false; }
var $_sources = NULL;
function sources ($visibility = 'Y') {
if (is_null($this->_sources)) :
$links = FeedWordPress::syndicated_links(array("hide_invisible" => false));
$this->_sources = array("Y" => array(), "N" => array());
foreach ($links as $link) :
$this->_sources[$link->link_visible][] = $link;
endforeach;
endif;
$ret = (
array_key_exists($visibility, $this->_sources)
? $this->_sources[$visibility]
: $this->_sources
);
return $ret;
} /* FeedWordPressSyndicationPage::sources() */
function visibility_toggle () {
$sources = $this->sources('*');
$defaultVisibility = 'Y';
if ((count($this->sources('N')) > 0)
and (count($this->sources('Y'))==0)) :
$defaultVisibility = 'N';
endif;
$visibility = (
isset($_REQUEST['visibility'])
? $_REQUEST['visibility']
: $defaultVisibility
);
return $visibility;
} /* FeedWordPressSyndicationPage::visibility_toggle() */
function show_inactive () {
return ($this->visibility_toggle() == 'N');
}
/**
* sanitize_ids: Protect id numbers from untrusted sources (POST array etc.)
* from possibility of SQLi attacks. Runs everything through an intval filter
* and then for good measure through esc_sql()
*
* @param array $link_ids An array of one or more putative link IDs
* @return array
*/
public function sanitize_ids_sql ($link_ids) {
$link_ids = array_map(
'esc_sql',
array_map(
'intval',
$link_ids
)
);
return $link_ids;
} /* FeedWordPressSyndicationPage::sanitize_ids_sql () */
/**
* requested_link_ids_sql ()
*
* @return string An SQL list literal containing the link IDs, sanitized
* and escaped for direct use in MySQL queries.
*
* @uses sanitize_ids_sql()
*/
public function requested_link_ids_sql () {
// Multiple link IDs passed in link_ids[]=... . . .
$link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array());
// Or single in link_id=...
if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif;
// Filter for safe use in MySQL queries.
$link_ids = $this->sanitize_ids_sql($link_ids);
// Convert to MySQL list literal.
return "('".implode("', '", $link_ids)."')";
} /* FeedWordPressSyndicationPage::requested_link_ids_sql () */
function updates_requested () {
global $wpdb;
if (isset($_POST['update']) or isset($_POST['action']) or isset($_POST['update_uri'])) :
// Only do things with side-effects for HTTP POST or command line
$fwp_update_invoke = 'post';
else :
$fwp_update_invoke = 'get';
endif;
$update_set = array();
if ($fwp_update_invoke != 'get') :
if (is_array(MyPHP::post('link_ids'))
and (MyPHP::post('action')==FWP_UPDATE_CHECKED)) :
// Get single link ID or multiple link IDs from REQUEST parameters
// if available. Sanitize values for MySQL.
$link_list = $this->requested_link_ids_sql();
// $link_list has previously been sanitized for html by self::requested_link_ids_sql
$targets = $wpdb->get_results("
SELECT * FROM $wpdb->links
WHERE link_id IN ${link_list}
");
if (is_array($targets)) :
foreach ($targets as $target) :
$update_set[] = $target->link_rss;
endforeach;
else : // This should never happen
FeedWordPress::critical_bug('fwp_syndication_manage_page::targets', $targets, __LINE__, __FILE__);
endif;
elseif (!is_null(MyPHP::post('update_uri'))) :
$targets = MyPHP::post('update_uri');
if (!is_array($targets)) :
$targets = array($targets);
endif;
$first = each($targets);
if (!is_numeric($first['key'])) : // URLs in keys
$targets = array_keys($targets);
endif;
$update_set = $targets;
endif;
endif;
return $update_set;
}
function accept_multiadd () {
global $fwp_post;
if (isset($fwp_post['cancel']) and $fwp_post['cancel']==__(FWP_CANCEL_BUTTON)) :
return true; // Continue ....
endif;
// If this is a POST, validate source and user credentials
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links');
$in = (isset($fwp_post['multilookup']) ? $fwp_post['multilookup'] : '')
.(isset($fwp_post['opml_lookup']) ? $fwp_post['opml_lookup'] : '');
if (isset($fwp_post['confirm']) and $fwp_post['confirm']=='multiadd') :
$chex = $fwp_post['multilookup'];
$added = array(); $errors = array();
foreach ($chex as $feed) :
if (isset($feed['add']) and $feed['add']=='yes') :
// Then, add in the URL.
$link_id = FeedWordPress::syndicate_link(
$feed['title'],
$feed['link'],
$feed['url']
);
if ($link_id and !is_wp_error($link_id)):
$added[] = $link_id;
else :
$errors[] = array($feed['url'], $link_id);
endif;
endif;
endforeach;
print "
\n";
print "
Added ".count($added)." new syndicated sources.
";
if (count($errors) > 0) :
print "
FeedWordPress encountered errors trying to add the following sources:
Thank you for your contribution to FeedWordPress development.
Your generous gifts make ongoing support and development for
FeedWordPress possible.
If you have any questions about FeedWordPress, or if there
is anything I can do to help make FeedWordPress more useful for
you, please contact me
and let me know what you're thinking about.
requested_link_ids_sql();
if (MyPHP::post('confirm')=='Delete'):
if ( is_array(MyPHP::post('link_action')) ) :
$actions = MyPHP::post('link_action');
else :
$actions = array();
endif;
$do_it = array(
'hide' => array(),
'nuke' => array(),
'delete' => array(),
);
foreach ($actions as $link_id => $what) :
$do_it[$what][] = $link_id;
endforeach;
$alter = array();
if (count($do_it['hide']) > 0) :
$hidem = "(".implode(', ', $do_it['hide']).")";
$alter[] = "
UPDATE $wpdb->links
SET link_visible = 'N'
WHERE link_id IN {$hidem}
";
endif;
if (count($do_it['nuke']) > 0) :
$nukem = "(".implode(', ', $do_it['nuke']).")";
// Make a list of the items syndicated from this feed...
$post_ids = $wpdb->get_col("
SELECT post_id FROM $wpdb->postmeta
WHERE meta_key = 'syndication_feed_id'
AND meta_value IN {$nukem}
");
// ... and kill them all
if (count($post_ids) > 0) :
foreach ($post_ids as $post_id) :
// Force scrubbing of deleted post
// rather than sending to Trashcan
wp_delete_post(
/*postid=*/ $post_id,
/*force_delete=*/ true
);
endforeach;
endif;
$alter[] = "
DELETE FROM $wpdb->links
WHERE link_id IN {$nukem}
";
endif;
if (count($do_it['delete']) > 0) :
$deletem = "(".implode(', ', $do_it['delete']).")";
// Make the items syndicated from this feed appear to be locally-authored
$alter[] = "
DELETE FROM $wpdb->postmeta
WHERE meta_key = 'syndication_feed_id'
AND meta_value IN {$deletem}
";
// ... and delete the links themselves.
$alter[] = "
DELETE FROM $wpdb->links
WHERE link_id IN {$deletem}
";
endif;
$errs = array(); $success = array ();
foreach ($alter as $sql) :
$result = $wpdb->query($sql);
if (!$result):
$errs[] = mysql_error();
endif;
endforeach;
if (count($alter) > 0) :
echo "
\n";
if (count($errs) > 0) :
echo "There were some problems processing your ";
echo "unsubscribe request. [SQL: ".implode('; ', $errs)."]";
else :
echo "Your unsubscribe request(s) have been processed.";
endif;
echo "
\n";
endif;
return true; // Continue on to Syndicated Sites listing
else :
// $link_list has previously been sanitized for html by self::requested_link_ids_sql
$targets = $wpdb->get_results("
SELECT * FROM $wpdb->links
WHERE link_id IN ${link_list}
");
?>
accept_multiadd();
return true;
else :
$post_source = 'feedwordpress_feeds';
// With action=feedfinder, this goes directly to the feedfinder page
include_once(dirname(__FILE__) . '/feeds-page.php');
return false;
endif;
} /* function fwp_feedfinder_page () */
function fwp_switchfeed_page () {
global $wpdb, $wp_db_version;
global $fwp_post, $fwp_path;
// If this is a POST, validate source and user credentials
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links');
$changed = false;
if (!isset($fwp_post['Cancel'])):
if (isset($fwp_post['save_link_id']) and ($fwp_post['save_link_id']=='*')) :
$changed = true;
$link_id = FeedWordPress::syndicate_link($fwp_post['feed_title'], $fwp_post['feed_link'], $fwp_post['feed']);
if ($link_id):
$existingLink = new SyndicatedLink($link_id);
?>
has been added as a contributing site, using the feed at
<>.
| Configure settings.