function fwp_upgrade_page() { if (MyPHP::post('action') == 'Upgrade') { $ver = get_option('feedwordpress_version'); if (get_option('feedwordpress_version') != FEEDWORDPRESS_VERSION) { echo "<div class=\"wrap\">\n"; echo "<h2>Upgrading FeedWordPress...</h2>"; $feedwordpress = new FeedWordPress(); $feedwordpress->upgrade_database($ver); echo "<p><strong>Done!</strong> Upgraded database to version " . FEEDWORDPRESS_VERSION . ".</p>\n"; echo "<form action=\"\" method=\"get\">\n"; echo "<div class=\"submit\"><input type=\"hidden\" name=\"page\" value=\"syndication.php\" />"; echo "<input type=\"submit\" value=\"Continue »\" /></form></div>\n"; echo "</div>\n"; return; } else { echo "<div class=\"updated\"><p>Already at version " . FEEDWORDPRESS_VERSION . "!</p></div>"; } } ?> <div class="wrap"> <h2>Upgrade FeedWordPress</h2> <p>It appears that you have installed FeedWordPress <?php echo FEEDWORDPRESS_VERSION; ?> as an upgrade to an existing installation of FeedWordPress. That's no problem, but you will need to take a minute out first to upgrade your database: some necessary changes in how the software keeps track of posts and feeds will cause problems such as duplicate posts and broken templates if we were to continue without the upgrade.</p> <p>Note that most of FeedWordPress's functionality is temporarily disabled until we have successfully completed the upgrade. Everything should begin working as normal again once the upgrade is complete. There's extraordinarily little chance of any damage as the result of the upgrade, but if you're paranoid like me you may want to back up your database before you proceed.</p> <p>This may take several minutes for a large installation.</p> <form action="" method="post"> <?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_upgrade'); ?> <div class="submit"><input type="submit" name="action" value="Upgrade" /></div> </form> </div> <?php }
function display_alt_feed_box($lookup, $params = false) { global $fwp_post; if (is_bool($params)) { $params = array("alt" => $params); } $params = wp_parse_args($params, array("alt" => false, "err" => NULL, "auth" => NULL, "password" => NULL, "username" => NULL)); $alt = $params['alt']; ?> <form action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?> /<?php echo basename(__FILE__); ?> " method="post"> <div class="inside"><?php FeedWordPressCompatibility::stamp_nonce($this->dispatch); ?> <fieldset class="alt" <?php if (!$alt) { ?> style="margin: 1.0em 3.0em; font-size: smaller;"<?php } ?> > <legend><?php if ($alt) { ?> Alternative feeds<?php } else { ?> Find feeds<?php } ?> </legend> <?php if ($alt) { ?> <h3>Use a different feed</h3><?php } ?> <?php if (is_wp_error($params['err'])) { ?> <p><em><strong>401 Not Authorized.</strong> This URL may require a username and password to access it.</em> You may want to add login credentials below and check it again.</p> <?php } ?> <div><label>Address: <input type="text" name="lookup" id="use-another-feed" placeholder="URL" <?php if (is_null($lookup)) { ?> value="URL" <?php } else { ?> value="<?php print esc_html($lookup); ?> " <?php } ?> size="64" style="max-width: 80%" /></label> <?php if (is_null($lookup)) { ?> <?php FeedWordPressSettingsUI::magic_input_tip_js('use-another-feed'); ?> <?php } ?> <?php $this->stamp_link_id('link_id'); ?> <input type="hidden" name="action" value="feedfinder" /> <input type="submit" class="button<?php if ($alt) { ?> -primary<?php } ?> " value="Check »" /></div> <?php $this->display_authentication_credentials_box(array('username' => $params['username'], 'password' => $params['password'], 'method' => $params['auth'])); ?> <p>This can be the address of a feed, or of a website. FeedWordPress will try to automatically detect any feeds associated with a website.</p> </div> <!-- class="inside" --> </fieldset></form> <?php }
function multiundelete_page() { global $wpdb; // If this is a POST, validate source and user credentials FeedWordPressCompatibility::validate_http_request('feedwordpress_feeds', 'manage_links'); // Get single link ID or multiple link IDs from REQUEST parameters // if available. Sanitize values for MySQL. $link_list = $this->requested_link_ids_sql(); if (MyPHP::post('confirm') == 'Undelete') { if (is_array(MyPHP::post('link_action'))) { $actions = MyPHP::post('link_action'); } else { $actions = array(); } $do_it = array('unhide' => array()); foreach ($actions as $link_id => $what) { $do_it[$what][] = $link_id; } $alter = array(); if (count($do_it['unhide']) > 0) { $unhiddem = "(" . implode(', ', $do_it['unhide']) . ")"; $alter[] = "\n\t\t\t\tUPDATE {$wpdb->links}\n\t\t\t\tSET link_visible = 'Y'\n\t\t\t\tWHERE link_id IN {$unhiddem}\n\t\t\t\t"; } $errs = array(); $success = array(); foreach ($alter as $sql) { $result = $wpdb->query($sql); if (!$result) { $errs[] = mysql_error(); } } if (count($alter) > 0) { echo "<div class=\"updated\">\n"; if (count($errs) > 0) { echo "There were some problems processing your "; echo "re-subscribe request. [SQL: " . implode('; ', $errs) . "]"; } else { echo "Your re-subscribe request(s) have been processed."; } echo "</div>\n"; } 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("\n\t\t\t\tSELECT * FROM {$wpdb->links}\n\t\t\t\tWHERE link_id IN {$link_list}\n\t\t\t\t"); ?> <form action="<?php print $this->form_action(); ?> " method="post"> <div class="wrap"> <?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> <input type="hidden" name="action" value="<?php print FWP_RESUB_CHECKED; ?> " /> <input type="hidden" name="confirm" value="Undelete" /> <h2>Re-subscribe to Syndicated Links:</h2> <?php foreach ($targets as $link) { $subscribed = 'Y' == strtoupper($link->link_visible); $link_url = esc_html($link->link_url); $link_name = esc_html($link->link_name); $link_description = esc_html($link->link_description); $link_rss = esc_html($link->link_rss); if (!$subscribed) { ?> <fieldset> <legend><?php echo $link_name; ?> </legend> <table class="editform" width="100%" cellspacing="2" cellpadding="5"> <tr><th scope="row" width="20%"><?php _e('Feed URI:'); ?> </th> <td width="80%"><a href="<?php echo $link_rss; ?> "><?php echo $link_rss; ?> </a></td></tr> <tr><th scope="row" width="20%"><?php _e('Short description:'); ?> </th> <td width="80%"><?php echo $link_description; ?> </span></td></tr> <tr><th width="20%" scope="row"><?php _e('Homepage:'); ?> </th> <td width="80%"><a href="<?php echo $link_url; ?> "><?php echo $link_url; ?> </a></td></tr> <tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options'); ?> :</th> <td width="80%"><ul style="margin:0; padding: 0; list-style: none"> <li><input type="radio" id="unhide-<?php echo $link->link_id; ?> " name="link_action[<?php echo $link->link_id; ?> ]" value="unhide" checked="checked" /> <label for="unhide-<?php echo $link->link_id; ?> ">Turn back on the subscription for this syndication source.</label></li> <li><input type="radio" id="nothing-<?php echo $link->link_id; ?> " name="link_action[<?php echo $link->link_id; ?> ]" value="nothing" /> <label for="nothing-<?php echo $link->link_id; ?> ">Leave this feed as it is. I changed my mind.</label></li> </ul> </table> </fieldset> <?php } } ?> <div class="submit"> <input class="button-primary delete" type="submit" name="submit" value="<?php _e('Re-subscribe to selected feeds »'); ?> " /> </div> </div> <?php return false; // Don't continue on to Syndicated Sites listing } }
function open_sheet($header) { // Set up prepatory AJAX stuff ?> <script type="text/javascript"> <?php $this->ajax_interface_js(); ?> </script> <?php add_action(FeedWordPressCompatibility::bottom_script_hook($this->filename), array($this, 'fix_toggles'), 10000); FeedWordPressSettingsUI::ajax_nonce_fields(); ?> <div class="wrap feedwordpress-admin" id="feedwordpress-admin-<?php print $this->pageslug(); ?> "> <?php if (!is_null($header)) { $this->display_sheet_header($header); } if (!is_null($this->dispatch)) { ?> <form action="<?php print $this->form_action(); ?> " method="post"> <div><?php FeedWordPressCompatibility::stamp_nonce($this->dispatch); $this->stamp_link_id(); ?> </div> <?php } if ($this->has_link()) { $this->display_settings_scope_message(); } ?> <div class="tablenav"><?php if (!is_null($this->dispatch)) { ?> <div class="alignright"><?php $this->save_button(); ?> </div><?php } if ($this->has_link()) { $this->display_feed_select_dropdown(); } ?> </div> <div id="poststuff"> <?php }
function display_alt_feed_box($lookup, $alt = false) { global $fwp_post; ?> <form action="admin.php?page=<?php echo FWP_FEEDS_PAGE_SLUG; ?> " method="post"> <div class="inside"><?php FeedWordPressCompatibility::stamp_nonce(get_class($this)); ?> <fieldset class="alt" <?php if (!$alt) { ?> style="margin: 1.0em 3.0em; font-size: smaller;"<?php } ?> > <legend><?php if ($alt) { ?> Alternative feeds<?php } else { ?> Find feeds<?php } ?> </legend> <?php if ($alt) { ?> <h3>Use a different feed</h3><?php } ?> <div><label>Address: <input type="text" name="lookup" id="use-another-feed" placeholder="URL" <?php if (is_null($lookup)) { ?> value="URL" <?php } else { ?> value="<?php print esc_html($lookup); ?> " <?php } ?> size="64" style="max-width: 80%" /></label> <?php if (is_null($lookup)) { ?> <?php FeedWordPressSettingsUI::magic_input_tip_js('use-another-feed'); ?> <?php } ?> <?php $this->stamp_link_id('link_id'); ?> <input type="hidden" name="action" value="feedfinder" /> <input type="submit" class="button<?php if ($alt) { ?> -primary<?php } ?> " value="Check »" /></div> <p>This can be the address of a feed, or of a website. FeedWordPress will try to automatically detect any feeds associated with a website.</p> </div> <!-- class="inside" --> </fieldset></form> <?php }
function fwp_multidelete_page() { // If this is a POST, validate source and user credentials FeedWordPressCompatibility::validate_http_request('feedwordpress_feeds', 'manage_links'); $link_ids = isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array(); if (isset($_REQUEST['link_id'])) { array_push($link_ids, $_REQUEST['link_id']); } if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm'] == 'Delete') { if (isset($GLOBALS['fwp_post']['link_action']) and is_array($GLOBALS['fwp_post']['link_action'])) { $actions = $GLOBALS['fwp_post']['link_action']; } else { $actions = array(); } $do_it = array('hide' => array(), 'nuke' => array(), 'delete' => array()); foreach ($actions as $link_id => $what) { $do_it[$what][] = $link_id; } $alter = $errs = array(); if (count($do_it['hide']) > 0) { $links = get_bookmarks(array('include' => implode(',', $do_it['hide']))); if (is_array($links) && !empty($links)) { foreach ($links as $link) { $link->link_visible = 'N'; $alter[] = 'hiding link: ' . $link->link_id; wp_update_link((array) $link); } } } if (count($do_it['nuke']) > 0) { foreach ($do_it['nuke'] as $nuke_id) { // Make a list of the items syndicated from this feed... $args = array('posts_per_page' => -1, 'numberposts' => 0, 'meta_key' => 'syndication_feed_id', 'meta_value' => $nuke_id); $posts = get_posts($args); // ... and kill them all if (is_array($posts) && !empty($posts)) { foreach ($posts as $p) { $alter[] = 'deleting post: ' . $p->ID; wp_delete_post($p->ID, true); } } // Then delete the link wp_delete_link($nuke_id); } } if (count($do_it['delete']) > 0) { $deletem = "(" . implode(', ', $do_it['delete']) . ")"; foreach ($do_it['delete'] as $del_id) { // Make a list of the items syndicated from this feed... $args = array('posts_per_page' => -1, 'numberposts' => 0, 'meta_key' => 'syndication_feed_id', 'meta_value' => $del_id); $posts = get_posts($args); // Make the items syndicated from this feed appear to be locally-authored if (is_array($posts) && !empty($posts)) { foreach ($posts as $p) { $alter[] = 'deleting postmeta for post: ' . $p->ID; if (!delete_post_meta($p->ID, 'syndication_feed_id')) { $errs[] = 'Could not delete meta for post: ' . $p->ID; } } } // Then delete the link wp_delete_link($del_id); } } if (count($alter) > 0) { echo "<div class=\"updated\">\n"; if (count($errs) > 0) { echo "There were some problems processing your "; echo "unsubscribe request. [Errors: " . implode('; ', $errs) . "]"; } else { echo "Your unsubscribe request(s) have been processed."; } echo "</div>\n"; } return true; // Continue on to Syndicated Sites listing } else { if (count($link_ids) > 0) { $targets = get_bookmarks(array('include' => implode(',', $link_ids), 'hide_invisible' => 0)); } else { $targets = array(); } ?> <form action="admin.php?page=<?php echo FWP_SYNDICATION_PAGE_SLUG; ?> " method="post"> <div class="wrap"> <?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> <input type="hidden" name="action" value="Unsubscribe" /> <input type="hidden" name="confirm" value="Delete" /> <h2>Unsubscribe from Syndicated Links:</h2> <?php foreach ($targets as $link) { $subscribed = 'Y' == strtoupper($link->link_visible); $link_url = esc_html($link->link_url); $link_name = esc_html($link->link_name); $link_description = esc_html($link->link_description); $link_rss = esc_html($link->link_rss); ?> <fieldset> <legend><?php echo $link_name; ?> </legend> <table class="editform" width="100%" cellspacing="2" cellpadding="5"> <tr><th scope="row" width="20%"><?php _e('Feed URI:'); ?> </th> <td width="80%"><a href="<?php echo $link_rss; ?> "><?php echo $link_rss; ?> </a></td></tr> <tr><th scope="row" width="20%"><?php _e('Short description:'); ?> </th> <td width="80%"><?php echo $link_description; ?> </span></td></tr> <tr><th width="20%" scope="row"><?php _e('Homepage:'); ?> </th> <td width="80%"><a href="<?php echo $link_url; ?> "><?php echo $link_url; ?> </a></td></tr> <tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options'); ?> :</th> <td width="80%"><ul style="margin:0; padding: 0; list-style: none"> <?php if ($subscribed) { ?> <li><input type="radio" id="hide-<?php echo $link->link_id; ?> " name="link_action[<?php echo $link->link_id; ?> ]" value="hide" checked="checked" /> <label for="hide-<?php echo $link->link_id; ?> ">Turn off the subscription for this syndicated link<br/><span style="font-size:smaller">(Keep the feed information and all the posts from this feed in the database, but don't syndicate any new posts from the feed.)</span></label></li> <?php } ?> <li><input type="radio" id="nuke-<?php echo $link->link_id; ?> "<?php if (!$subscribed) { ?> checked="checked"<?php } ?> name="link_action[<?php echo $link->link_id; ?> ]" value="nuke" /> <label for="nuke-<?php echo $link->link_id; ?> ">Delete this syndicated link and all the posts that were syndicated from it</label></li> <li><input type="radio" id="delete-<?php echo $link->link_id; ?> " name="link_action[<?php echo $link->link_id; ?> ]" value="delete" /> <label for="delete-<?php echo $link->link_id; ?> ">Delete this syndicated link, but <em>keep</em> posts that were syndicated from it (as if they were authored locally).</label></li> <li><input type="radio" id="nothing-<?php echo $link->link_id; ?> " name="link_action[<?php echo $link->link_id; ?> ]" value="nothing" /> <label for="nothing-<?php echo $link->link_id; ?> ">Keep this feed as it is. I changed my mind.</label></li> </ul> </table> </fieldset> <?php } ?> <div class="submit"> <input class="delete" type="submit" name="submit" value="<?php _e('Unsubscribe from selected feeds »'); ?> " /> </div> </div> <?php return false; // Don't continue on to Syndicated Sites listing } }
function multiundelete_page () { global $wpdb; // If this is a POST, validate source and user credentials FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links'); $link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array()); if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif; if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Undelete'): if (isset($GLOBALS['fwp_post']['link_action']) and is_array($GLOBALS['fwp_post']['link_action'])) : $actions = $GLOBALS['fwp_post']['link_action']; else : $actions = array(); endif; $do_it = array( 'unhide' => array(), ); foreach ($actions as $link_id => $what) : $do_it[$what][] = $link_id; endforeach; $alter = array(); if (count($do_it['unhide']) > 0) : $unhiddem = "(".implode(', ', $do_it['unhide']).")"; $alter[] = " UPDATE $wpdb->links SET link_visible = 'Y' WHERE link_id IN {$unhiddem} "; 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 "<div class=\"updated\">\n"; if (count($errs) > 0) : echo "There were some problems processing your "; echo "re-subscribe request. [SQL: ".implode('; ', $errs)."]"; else : echo "Your re-subscribe request(s) have been processed."; endif; echo "</div>\n"; endif; return true; // Continue on to Syndicated Sites listing else : $targets = $wpdb->get_results(" SELECT * FROM $wpdb->links WHERE link_id IN (".implode(",",$link_ids).") "); ?> <form action="<?php print $this->form_action(); ?>" method="post"> <div class="wrap"> <?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> <input type="hidden" name="action" value="<?php print FWP_RESUB_CHECKED; ?>" /> <input type="hidden" name="confirm" value="Undelete" /> <h2>Re-subscribe to Syndicated Links:</h2> <?php foreach ($targets as $link) : $subscribed = ('Y' == strtoupper($link->link_visible)); $link_url = esc_html($link->link_url); $link_name = esc_html($link->link_name); $link_description = esc_html($link->link_description); $link_rss = esc_html($link->link_rss); if (!$subscribed) : ?> <fieldset> <legend><?php echo $link_name; ?></legend> <table class="editform" width="100%" cellspacing="2" cellpadding="5"> <tr><th scope="row" width="20%"><?php _e('Feed URI:') ?></th> <td width="80%"><a href="<?php echo $link_rss; ?>"><?php echo $link_rss; ?></a></td></tr> <tr><th scope="row" width="20%"><?php _e('Short description:') ?></th> <td width="80%"><?php echo $link_description; ?></span></td></tr> <tr><th width="20%" scope="row"><?php _e('Homepage:') ?></th> <td width="80%"><a href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td></tr> <tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options') ?>:</th> <td width="80%"><ul style="margin:0; padding: 0; list-style: none"> <li><input type="radio" id="unhide-<?php echo $link->link_id; ?>" name="link_action[<?php echo $link->link_id; ?>]" value="unhide" checked="checked" /> <label for="unhide-<?php echo $link->link_id; ?>">Turn back on the subscription for this syndication source.</label></li> <li><input type="radio" id="nothing-<?php echo $link->link_id; ?>" name="link_action[<?php echo $link->link_id; ?>]" value="nothing" /> <label for="nothing-<?php echo $link->link_id; ?>">Leave this feed as it is. I changed my mind.</label></li> </ul> </table> </fieldset> <?php endif; endforeach; ?> <div class="submit"> <input class="button-primary delete" type="submit" name="submit" value="<?php _e('Re-subscribe to selected feeds »') ?>" /> </div> </div> <?php return false; // Don't continue on to Syndicated Sites listing endif; } /* FeedWordPressSyndicationPage::multiundelete_page() */
function open_sheet($header) { // Set up prepatory AJAX stuff $this->ajax_interface_js(); if (function_exists('add_meta_box')) { add_action(FeedWordPressCompatibility::bottom_script_hook($this->filename), array($this, 'fix_toggles'), 10000); FeedWordPressSettingsUI::ajax_nonce_fields(); } ?> <div class="wrap" style="position:relative"> <?php if (!is_null($header)) { $this->display_sheet_header($header); } if (!is_null($this->dispatch)) { ?> <form action="admin.php?page=<?php echo $this->filename; ?> " method="post"> <div><?php FeedWordPressCompatibility::stamp_nonce($this->dispatch); $this->stamp_link_id(); ?> </div> <?php } if ($this->has_link()) { $this->display_feed_select_dropdown(); $this->display_settings_scope_message(); } if (function_exists('do_meta_boxes')) { ?> <div id="poststuff"> <?php } else { ?> </div> <!-- class="wrap" --> <?php } if (!is_null($this->dispatch)) { fwp_settings_form_single_submit(); } }