| 1 |
<?php |
| 2 |
require_once(dirname(__FILE__) . '/admin-ui.php'); |
| 3 |
require_once(dirname(__FILE__) . '/magpiemocklink.class.php'); |
| 4 |
require_once(dirname(__FILE__) . '/feedfinder.class.php'); |
| 5 |
|
| 6 |
$FeedWordPressHTTPStatusMessages = array ( |
| 7 |
200 => 'OK. FeedWordPress had no problems retrieving the content at this URL but the content does not seem to be a feed, and does not seem to include links to any feeds.', |
| 8 |
201 => 'Created', |
| 9 |
202 => 'Accepted', |
| 10 |
203 => 'Non-Authoritative information', |
| 11 |
204 => 'No Content', |
| 12 |
205 => 'Reset Content', |
| 13 |
206 => 'Partial Content', |
| 14 |
300 => 'Multiple Choices', |
| 15 |
301 => 'Moved Permanently', |
| 16 |
302 => 'Found', |
| 17 |
303 => 'See Other', |
| 18 |
304 => 'Not Modified', |
| 19 |
305 => 'Use Proxy', |
| 20 |
307 => 'Temporary Redirect', |
| 21 |
400 => 'Bad Request', |
| 22 |
401 => 'Unauthorized. This URL probably needs a username and password for you to access it.', |
| 23 |
402 => 'Payment Required', |
| 24 |
403 => 'Forbidden. The URL is not made available for the machine that FeedWordPress is running on.', |
| 25 |
404 => 'Not Found. There is nothing at this URL. Have you checked the address for typos?', |
| 26 |
405 => 'Method Not Allowed', |
| 27 |
406 => 'Not Acceptable', |
| 28 |
407 => 'Proxy Authentication Required', |
| 29 |
408 => 'Request Timeout', |
| 30 |
409 => 'Conflict', |
| 31 |
410 => 'Gone. This URL is no longer available on this server and no forwarding address is known.', |
| 32 |
411 => 'Length Required', |
| 33 |
412 => 'Precondition Failed', |
| 34 |
413 => 'Request Entity Too Large', |
| 35 |
414 => 'Request URI Too Long', |
| 36 |
415 => 'Unsupported Media Type', |
| 37 |
416 => 'Requested Range Not Satisfiable', |
| 38 |
417 => 'Expectation Failed', |
| 39 |
500 => 'Internal Server Error. Something unexpected went wrong with the configuration of the server that hosts this URL. You might try again later to see if this issue has been resolved.', |
| 40 |
501 => 'Not Implemented', |
| 41 |
502 => 'Bad Gateway', |
| 42 |
503 => 'Service Unavailable. The server is currently unable to handle the request due to a temporary overloading or maintenance of the server that hosts this URL. This is probably a temporary condition and you should try again later to see if the issue has been resolved.', |
| 43 |
504 => 'Gateway Timeout', |
| 44 |
505 => 'HTTP Version Not Supported', |
| 45 |
); |
| 46 |
|
| 47 |
################################################################################ |
| 48 |
## ADMIN MENU ADD-ONS: implement Dashboard management pages #################### |
| 49 |
################################################################################ |
| 50 |
|
| 51 |
if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : |
| 52 |
define('FWP_UPDATE_CHECKED', 'Update Checked Links'); |
| 53 |
define('FWP_UNSUB_CHECKED', 'Unsubscribe from Checked Links'); |
| 54 |
define('FWP_SYNDICATE_NEW', 'Syndicate »'); |
| 55 |
else : |
| 56 |
define('FWP_UPDATE_CHECKED', 'Update Checked'); |
| 57 |
define('FWP_UNSUB_CHECKED', 'Unsubscribe'); |
| 58 |
define('FWP_SYNDICATE_NEW', 'Syndicate »'); |
| 59 |
endif; |
| 60 |
|
| 61 |
function fwp_dashboard_update_if_requested () { |
| 62 |
global $wpdb; |
| 63 |
|
| 64 |
if (isset($_POST['update']) or isset($_POST['action']) or isset($_POST['update_uri'])) : |
| 65 |
$fwp_update_invoke = 'post'; |
| 66 |
else : |
| 67 |
$fwp_update_invoke = 'get'; |
| 68 |
endif; |
| 69 |
|
| 70 |
$update_set = array(); |
| 71 |
if (isset($_POST['link_ids']) and is_array($_POST['link_ids']) and ($_POST['action']==FWP_UPDATE_CHECKED)) : |
| 72 |
$targets = $wpdb->get_results(" |
| 73 |
SELECT * FROM $wpdb->links |
| 74 |
WHERE link_id IN (".implode(",",$_POST['link_ids']).") |
| 75 |
"); |
| 76 |
if (is_array($targets)) : |
| 77 |
foreach ($targets as $target) : |
| 78 |
$update_set[] = $target->link_rss; |
| 79 |
endforeach; |
| 80 |
else : // This should never happen |
| 81 |
FeedWordPress::critical_bug('fwp_syndication_manage_page::targets', $targets, __LINE__); |
| 82 |
endif; |
| 83 |
elseif (isset($_POST['update_uri'])) : |
| 84 |
$update_set[] = $_POST['update_uri']; |
| 85 |
endif; |
| 86 |
|
| 87 |
shuffle($update_set); // randomize order for load balancing purposes... |
| 88 |
if ($fwp_update_invoke != 'get' and count($update_set) > 0) : // Only do things with side-effects for HTTP POST or command line |
| 89 |
$feedwordpress =& new FeedWordPress; |
| 90 |
add_action('feedwordpress_check_feed', 'update_feeds_mention'); |
| 91 |
add_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3); |
| 92 |
|
| 93 |
$crash_dt = (int) get_option('feedwordpress_update_time_limit'); |
| 94 |
if ($crash_dt > 0) : |
| 95 |
$crash_ts = time() + $crash_dt; |
| 96 |
else : |
| 97 |
$crash_ts = NULL; |
| 98 |
endif; |
| 99 |
|
| 100 |
if (fwp_test_wp_version(FWP_SCHEMA_25)) : |
| 101 |
echo "<div class=\"youare\">\n"; |
| 102 |
else : |
| 103 |
echo "<div class=\"updated\">\n"; |
| 104 |
endif; |
| 105 |
echo "<ul>\n"; |
| 106 |
$tdelta = NULL; |
| 107 |
foreach ($update_set as $uri) : |
| 108 |
if (!is_null($crash_ts) and (time() > $crash_ts)) : |
| 109 |
echo "<li><p><strong>Further updates postponed:</strong> update time limit of ".$crash_dt." second".(($crash_dt==1)?"":"s")." exceeded.</p></li>"; |
| 110 |
break; |
| 111 |
endif; |
| 112 |
|
| 113 |
if ($uri == '*') : $uri = NULL; endif; |
| 114 |
$delta = $feedwordpress->update($uri, $crash_ts); |
| 115 |
if (!is_null($delta)) : |
| 116 |
if (is_null($tdelta)) : |
| 117 |
$tdelta = $delta; |
| 118 |
else : |
| 119 |
$tdelta['new'] += $delta['new']; |
| 120 |
$tdelta['updated'] += $delta['updated']; |
| 121 |
endif; |
| 122 |
else : |
| 123 |
echo "<li><p><strong>Error:</strong> There was a problem updating <a href=\"$uri\">$uri</a></p></li>\n"; |
| 124 |
endif; |
| 125 |
endforeach; |
| 126 |
echo "</ul>\n"; |
| 127 |
|
| 128 |
if (!is_null($tdelta)) : |
| 129 |
$mesg = array(); |
| 130 |
if (isset($delta['new'])) : $mesg[] = ' '.$tdelta['new'].' new posts were syndicated'; endif; |
| 131 |
if (isset($delta['updated'])) : $mesg[] = ' '.$tdelta['updated'].' existing posts were updated'; endif; |
| 132 |
echo "<p>Update complete.".implode(' and', $mesg)."</p>"; |
| 133 |
echo "\n"; flush(); |
| 134 |
endif; |
| 135 |
echo "</div> <!-- class=\"updated\" -->\n"; |
| 136 |
elseif (fwp_test_wp_version(FWP_SCHEMA_25)) : |
| 137 |
?> |
| 138 |
<p class="youare">Check currently scheduled feeds for new and updated posts.</p> |
| 139 |
<?php |
| 140 |
endif; |
| 141 |
} |
| 142 |
|
| 143 |
function fwp_syndication_manage_page () { |
| 144 |
global $wpdb; |
| 145 |
|
| 146 |
if (FeedWordPress::needs_upgrade()) : |
| 147 |
fwp_upgrade_page(); |
| 148 |
return; |
| 149 |
endif; |
| 150 |
|
| 151 |
?> |
| 152 |
<?php $cont = true; |
| 153 |
if (isset($_REQUEST['action'])): |
| 154 |
if ($_REQUEST['action'] == 'feedfinder' or $_REQUEST['action'] == FWP_SYNDICATE_NEW) : $cont = fwp_feedfinder_page(); |
| 155 |
elseif ($_REQUEST['action'] == 'switchfeed') : $cont = fwp_switchfeed_page(); |
| 156 |
elseif ($_REQUEST['action'] == 'linkedit') : $cont = fwp_linkedit_page(); |
| 157 |
elseif ($_REQUEST['action'] == FWP_UNSUB_CHECKED or $_REQUEST['action'] == 'Unsubscribe') : $cont = fwp_multidelete_page(); |
| 158 |
endif; |
| 159 |
endif; |
| 160 |
|
| 161 |
if ($cont): |
| 162 |
?> |
| 163 |
<?php |
| 164 |
$links = FeedWordPress::syndicated_links(); |
| 165 |
?> |
| 166 |
<div class="wrap"> |
| 167 |
<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?> |
| 168 |
<div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div> |
| 169 |
<h2>Syndicated Sites</h2> |
| 170 |
<?php endif; |
| 171 |
if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : |
| 172 |
fwp_dashboard_update_if_requested(); |
| 173 |
endif; |
| 174 |
|
| 175 |
if (fwp_test_wp_version(FWP_SCHEMA_27)) : |
| 176 |
?> |
| 177 |
<script type="text/javascript"> |
| 178 |
jQuery(document).ready( function($) { |
| 179 |
// In case someone got here first. |
| 180 |
$('.postbox h3, .postbox .handlediv').unbind('click'); |
| 181 |
$('.hide-postbox-tog').unbind('click'); |
| 182 |
$('.meta-box-sortables').sortable('destroy'); |
| 183 |
|
| 184 |
postboxes.add_postbox_toggles('feedwordpress_syndication'); |
| 185 |
} ); |
| 186 |
</script> |
| 187 |
<?php |
| 188 |
echo "<form style='display: none' method='get' action=''>\n<p>\n"; |
| 189 |
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
| 190 |
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
| 191 |
echo "</p>\n</form>\n"; |
| 192 |
|
| 193 |
if ($links) : |
| 194 |
add_meta_box('feedwordpress_update_box', __('Update feeds now'), 'fwp_syndication_manage_page_update_box', /*page=*/ 'feedwordpress_syndication', /*context =*/ 'normal'); |
| 195 |
endif; |
| 196 |
add_meta_box('feedwordpress_feeds_box', __('Syndicated sources'), 'fwp_syndication_manage_page_links_box', /*page=*/ 'feedwordpress_syndication', /*context =*/ 'normal'); |
| 197 |
?> |
| 198 |
<div class="metabox-holder"> |
| 199 |
<div id="feedwordpress-sortables" class="meta-box-sortables ui-sortable"> |
| 200 |
<?php |
| 201 |
do_meta_boxes('feedwordpress_syndication', 'normal', NULL); |
| 202 |
else : |
| 203 |
if ($links): // only display Update panel if there are some links to update.... |
| 204 |
fwp_syndication_manage_page_update_box(); |
| 205 |
endif; |
| 206 |
fwp_syndication_manage_page_links_box(); |
| 207 |
?> |
| 208 |
</div> <!-- class="wrap" --> |
| 209 |
|
| 210 |
<?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?> |
| 211 |
<div class="wrap"> |
| 212 |
<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 213 |
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div> |
| 214 |
<h2>Add a new syndicated site:</h2> |
| 215 |
<div> |
| 216 |
<label for="add-uri">Website or feed:</label> |
| 217 |
<input type="text" name="lookup" id="add-uri" value="URI" size="64" /> |
| 218 |
<input type="hidden" name="action" value="feedfinder" /> |
| 219 |
</div> |
| 220 |
<div class="submit"><input type="submit" value="Syndicate »" /></div> |
| 221 |
</form> |
| 222 |
</div> <!-- class="wrap" --> |
| 223 |
<?php endif; ?> |
| 224 |
|
| 225 |
<div style="display: none"> |
| 226 |
<div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug --> |
| 227 |
</div> |
| 228 |
<?php |
| 229 |
endif; |
| 230 |
endif; |
| 231 |
} /* function fwp_syndication_manage_page () */ |
| 232 |
|
| 233 |
function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) { |
| 234 |
$updateFeedsNow = __('Update feeds now'); |
| 235 |
?> |
| 236 |
<form action="" method="POST"> |
| 237 |
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div> |
| 238 |
<?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?> |
| 239 |
<div id="rightnow"> |
| 240 |
<h3 class="reallynow"><span><?php print $updateFeedsNow; ?></span> |
| 241 |
<input type="hidden" name="update_uri" value="*" /><input style="float: right; border: none;" class="rbutton" type="submit" name="update" value="Update" /> |
| 242 |
<br class="clear"/></h3> |
| 243 |
<?php elseif (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?> |
| 244 |
<h2><?php print $updateFeedsNow; ?></h2> |
| 245 |
<?php endif; ?> |
| 246 |
|
| 247 |
<?php |
| 248 |
if (fwp_test_wp_version(FWP_SCHEMA_25)) : |
| 249 |
fwp_dashboard_update_if_requested(); |
| 250 |
else : |
| 251 |
?> |
| 252 |
<p>Check currently scheduled feeds for new and updated posts.</p> |
| 253 |
<?php endif; ?> |
| 254 |
|
| 255 |
<?php if (!get_option('feedwordpress_automatic_updates')) : ?> |
| 256 |
<p class="youhave"><strong>Note:</strong> Automatic updates are currently turned |
| 257 |
<strong>off</strong>. New posts from your feeds will not be syndicated |
| 258 |
until you manually check for them here. You can turn on automatic |
| 259 |
updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/syndication-options.php">Syndication |
| 260 |
Options</a>.</p> |
| 261 |
<?php endif; ?> |
| 262 |
|
| 263 |
<?php if (!fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?> |
| 264 |
<div class="submit"><input type="hidden" name="update_uri" value="*" /><input class="button-primary" type="submit" name="update" value="Update" /></div> |
| 265 |
<?php endif; ?> |
| 266 |
|
| 267 |
<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?> |
| 268 |
<br style="clear: both" /> |
| 269 |
<?php elseif (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?> |
| 270 |
</div> <!-- id="rightnow" --> |
| 271 |
</div> <!-- class="wrap" --> |
| 272 |
<?php elseif (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?> |
| 273 |
</div> <!-- class="wrap" --> |
| 274 |
<?php endif; ?> |
| 275 |
</form> |
| 276 |
<?php |
| 277 |
} /* function fwp_syndication_manage_page_update_box () */ |
| 278 |
|
| 279 |
function fwp_syndication_manage_page_links_box ($object = NULL, $box = NULL) { |
| 280 |
$links = FeedWordPress::syndicated_links(); |
| 281 |
?> |
| 282 |
<?php if (!fwp_test_wp_version(FWP_SCHEMA_27)) : ?> |
| 283 |
<div class="wrap"> |
| 284 |
<h2>Syndicated Sites</h2> |
| 285 |
<?php endif; ?> |
| 286 |
|
| 287 |
<form id="syndicated-links" action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 288 |
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div> |
| 289 |
|
| 290 |
<?php $alt_row = true; ?> |
| 291 |
|
| 292 |
<?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?> |
| 293 |
<div class="tablenav"> |
| 294 |
<div class="alignright"> |
| 295 |
<label for="add-uri">Add new source:</label> |
| 296 |
<input type="text" name="lookup" id="add-uri" value="Website or feed URI" /> |
| 297 |
<script type="text/javascript"> |
| 298 |
jQuery(document).ready( function () { |
| 299 |
var addUri = jQuery("#add-uri"); |
| 300 |
var box = addUri.get(0); |
| 301 |
if (box.value==box.defaultValue) { addUri.addClass('form-input-tip'); } |
| 302 |
addUri.focus(function() { |
| 303 |
if ( this.value == this.defaultValue ) |
| 304 |
jQuery(this).val( '' ).removeClass( 'form-input-tip' ); |
| 305 |
}); |
| 306 |
addUri.blur(function() { |
| 307 |
if ( this.value == '' ) |
| 308 |
jQuery(this).val( this.defaultValue ).addClass( 'form-input-tip' ); |
| 309 |
}); |
| 310 |
|
| 311 |
} ); |
| 312 |
</script> |
| 313 |
|
| 314 |
<input type="hidden" name="action" value="feedfinder" /> |
| 315 |
<input type="submit" class="button-secondary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div> |
| 316 |
|
| 317 |
<?php if (count($links) > 0) : ?> |
| 318 |
<div class="alignleft"> |
| 319 |
<input class="button-secondary" type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" /> |
| 320 |
<input class="button-secondary delete" type="submit" class="delete" name="action" value="<?php print FWP_UNSUB_CHECKED; ?>" /> |
| 321 |
</div> |
| 322 |
<?php endif; ?> |
| 323 |
|
| 324 |
<br class="clear" /> |
| 325 |
</div> |
| 326 |
<br class="clear" /> |
| 327 |
|
| 328 |
<table class="widefat"> |
| 329 |
<?php else : ?> |
| 330 |
<table width="100%" cellpadding="3" cellspacing="3"> |
| 331 |
<?php endif; ?> |
| 332 |
<thead> |
| 333 |
<tr> |
| 334 |
<th class="check-column" scope="col"><?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?> |
| 335 |
<input type="checkbox" <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_26)) : ?>onclick="checkAll(document.getElementById('syndicated-links'));"<?php endif; ?> /> |
| 336 |
<?php endif; ?></th> |
| 337 |
<th scope="col"><?php _e('Name'); ?></th> |
| 338 |
<th scope="col"><?php _e('Feed'); ?></th> |
| 339 |
<th scope="col"><?php _e('Updated'); ?></th> |
| 340 |
</tr> |
| 341 |
</thead> |
| 342 |
|
| 343 |
<tbody> |
| 344 |
<?php if (count($links) > 0): foreach ($links as $link): |
| 345 |
$alt_row = !$alt_row; ?> |
| 346 |
<tr<?php echo ($alt_row?' class="alternate"':''); ?>> |
| 347 |
<th class="check-column" scope="row"><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?>" /></th> |
| 348 |
<?php |
| 349 |
if (strlen($link->link_rss) > 0): |
| 350 |
$caption=__('Switch Feed'); |
| 351 |
else : |
| 352 |
$caption=__('Find Feed'); |
| 353 |
endif; |
| 354 |
?> |
| 355 |
<td> |
| 356 |
<strong><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=linkedit"><?php echo wp_specialchars($link->link_name, 'both'); ?></a></strong> |
| 357 |
<div class="row-actions"><div><strong>Settings ></strong> |
| 358 |
<a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=linkedit"><?php _e('Feed'); ?></a> |
| 359 |
| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php&link_id=<?php echo $link->link_id; ?>"><?php _e('Posts'); ?></a> |
| 360 |
| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/authors-page.php&link_id=<?php echo $link->link_id; ?>"><?php _e('Authors'); ?></a> |
| 361 |
| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/categories-page.php&link_id=<?php echo $link->link_id; ?>"><?php _e('Categories & Tags'); ?></a></div> |
| 362 |
<div><strong>Actions ></strong> |
| 363 |
<a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=feedfinder"><?php echo $caption; ?></a> |
| 364 |
| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=Unsubscribe"><?php _e('Unsubscribe'); ?></a> |
| 365 |
| <a href="<?php echo wp_specialchars($link->link_url, 'both'); ?>"><?php _e('View')?></a></div> |
| 366 |
</div> |
| 367 |
</td> |
| 368 |
<?php |
| 369 |
if (strlen($link->link_rss) > 0): |
| 370 |
$uri_bits = parse_url($link->link_rss); |
| 371 |
$uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']); |
| 372 |
$display_uri = |
| 373 |
(isset($uri_bits['user'])?$uri_bits['user'].'@':'') |
| 374 |
.(isset($uri_bits['host'])?$uri_bits['host']:'') |
| 375 |
.(isset($uri_bits['port'])?':'.$uri_bits['port']:'') |
| 376 |
.(isset($uri_bits['path'])?$uri_bits['path']:'') |
| 377 |
.(isset($uri_bits['query'])?'?'.$uri_bits['query']:''); |
| 378 |
if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'…'; endif; |
| 379 |
?> |
| 380 |
<td><a href="<?php echo wp_specialchars($link->link_rss, 'both'); ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></td> |
| 381 |
<?php else: ?> |
| 382 |
<td style="background-color:#FFFFD0"><p><strong>no |
| 383 |
feed assigned</strong></p></td> |
| 384 |
<?php endif; ?> |
| 385 |
|
| 386 |
<td><?php |
| 387 |
$sLink =& new SyndicatedLink($link->link_id); |
| 388 |
if (isset($sLink->settings['update/last'])) : |
| 389 |
print fwp_time_elapsed($sLink->settings['update/last']); |
| 390 |
else : |
| 391 |
_e('None yet'); |
| 392 |
endif; |
| 393 |
|
| 394 |
print "<div style='font-style:italic;size:0.9em'>Ready for next update "; |
| 395 |
if (isset($sLink->settings['update/ttl']) and is_numeric($sLink->settings['update/ttl'])) : |
| 396 |
if (isset($sLink->settings['update/timed']) and $sLink->settings['update/timed']=='automatically') : |
| 397 |
$next = $sLink->settings['update/last'] + ((int) $sLink->settings['update/ttl'] * 60); |
| 398 |
print fwp_time_elapsed($next); |
| 399 |
else : |
| 400 |
echo "every ".$sLink->settings['update/ttl']." minute".(($sLink->settings['update/ttl']!=1)?"s":""); |
| 401 |
endif; |
| 402 |
else: |
| 403 |
echo "as soon as possible"; |
| 404 |
endif; |
| 405 |
print "</div>"; |
| 406 |
?> |
| 407 |
</td> |
| 408 |
</tr> |
| 409 |
<?php |
| 410 |
endforeach; |
| 411 |
else : |
| 412 |
?> |
| 413 |
<tr><td colspan="<?php print $span+2; ?>"><p>There are no websites currently listed for syndication.</p></td></tr> |
| 414 |
<?php |
| 415 |
endif; |
| 416 |
?> |
| 417 |
</tbody> |
| 418 |
</table> |
| 419 |
|
| 420 |
<?php if (count($links) > 0 and fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?> |
| 421 |
<br/><hr/> |
| 422 |
<div class="submit"><input type="submit" class="delete" name="action" value="<?php print FWP_UNSUB_CHECKED; ?>" /> |
| 423 |
<input type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" /></div> |
| 424 |
<?php endif; ?> |
| 425 |
|
| 426 |
</form> |
| 427 |
<?php |
| 428 |
} /* function fwp_syndication_manage_page_links_box() */ |
| 429 |
|
| 430 |
function fwp_feedfinder_page () { |
| 431 |
global $wpdb; |
| 432 |
global $FeedWordPressHTTPStatusMessages; |
| 433 |
|
| 434 |
$lookup = (isset($_REQUEST['lookup'])?$_REQUEST['lookup']:NULL); |
| 435 |
|
| 436 |
if (isset($_REQUEST['link_id']) and ($_REQUEST['link_id']!=0)): |
| 437 |
$link_id = $_REQUEST['link_id']; |
| 438 |
if (!is_numeric($link_id)) : FeedWordPress::critical_bug('fwp_feedfinder_page::link_id', $link_id, __LINE__); endif; |
| 439 |
|
| 440 |
$link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id='".$wpdb->escape($link_id)."'"); |
| 441 |
if (is_object($link)): |
| 442 |
if (is_null($lookup)) $lookup = $link->link_url; |
| 443 |
$name = wp_specialchars($link->link_name, 'both'); |
| 444 |
else: |
| 445 |
die (__("Cheatin' uh ?")); |
| 446 |
endif; |
| 447 |
else: |
| 448 |
$name = "<code>".htmlspecialchars($lookup)."</code>"; |
| 449 |
$link_id = 0; |
| 450 |
endif; |
| 451 |
?> |
| 452 |
<div class="wrap"> |
| 453 |
<h2>Feed Finder: <?php echo $name; ?></h2> |
| 454 |
<?php |
| 455 |
$f =& new FeedFinder($lookup); |
| 456 |
$feeds = $f->find(); |
| 457 |
if (count($feeds) > 0): |
| 458 |
foreach ($feeds as $key => $f): |
| 459 |
$rss = fetch_rss($f); |
| 460 |
if ($rss): |
| 461 |
$feed_title = isset($rss->channel['title'])?$rss->channel['title']:$rss->channel['link']; |
| 462 |
$feed_link = isset($rss->channel['link'])?$rss->channel['link']:''; |
| 463 |
else : |
| 464 |
// Give us some sucky defaults |
| 465 |
$uri_bits = parse_url($lookup); |
| 466 |
$uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']); |
| 467 |
$display_uri = |
| 468 |
(isset($uri_bits['user'])?$uri_bits['user'].'@':'') |
| 469 |
.(isset($uri_bits['host'])?$uri_bits['host']:'') |
| 470 |
.(isset($uri_bits['port'])?':'.$uri_bits['port']:'') |
| 471 |
.(isset($uri_bits['path'])?$uri_bits['path']:'') |
| 472 |
.(isset($uri_bits['query'])?'?'.$uri_bits['query']:''); |
| 473 |
if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'…'; endif; |
| 474 |
|
| 475 |
$feed_title = $display_uri; |
| 476 |
$feed_link = $lookup; |
| 477 |
endif; |
| 478 |
?> |
| 479 |
<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 480 |
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_switchfeed'); ?></div> |
| 481 |
<fieldset style="clear: both"> |
| 482 |
<legend><?php echo $rss->feed_type; ?> <?php echo $rss->feed_version; ?> feed</legend> |
| 483 |
|
| 484 |
<?php if ($link_id===0): ?> |
| 485 |
<input type="hidden" name="feed_title" value="<?php echo wp_specialchars($feed_title, 'both'); ?>" /> |
| 486 |
<input type="hidden" name="feed_link" value="<?php echo wp_specialchars($feed_link, 'both'); ?>" /> |
| 487 |
<?php endif; ?> |
| 488 |
|
| 489 |
<input type="hidden" name="link_id" value="<?php echo $link_id; ?>" /> |
| 490 |
<input type="hidden" name="feed" value="<?php echo wp_specialchars($f, 'both'); ?>" /> |
| 491 |
<input type="hidden" name="action" value="switchfeed" /> |
| 492 |
|
| 493 |
<div> |
| 494 |
<div style="float:right; background-color:#D0D0D0; color: black; width:45%; font-size:70%; border-left: 1px dotted #A0A0A0; padding-left: 0.5em; margin-left: 1.0em"> |
| 495 |
<?php if (count($rss->items) > 0): ?> |
| 496 |
<?php |
| 497 |
// Prepare to display Sample Item |
| 498 |
$link =& new MagpieMockLink($rss, $f); |
| 499 |
$post =& new SyndicatedPost($rss->items[0], $link); |
| 500 |
?> |
| 501 |
<h3>Sample Item</h3> |
| 502 |
<ul> |
| 503 |
<li><strong>Title:</strong> <a href="<?php echo $post->post['meta']['syndication_permalink']; ?>"><?php echo $post->post['post_title']; ?></a></li> |
| 504 |
<li><strong>Date:</strong> <?php print date('d-M-y g:i:s a', $post->published()); ?></li> |
| 505 |
</ul> |
| 506 |
<div class="entry"> |
| 507 |
<?php print $post->post['post_content']; ?> |
| 508 |
</div> |
| 509 |
<?php else: ?> |
| 510 |
<h3>No Items</h3> |
| 511 |
<p>FeedWordPress found no posts on this feed.</p> |
| 512 |
<?php endif; ?> |
| 513 |
</div> |
| 514 |
|
| 515 |
<div> |
| 516 |
<h3>Feed Information</h3> |
| 517 |
<ul> |
| 518 |
<li><strong>Website:</strong> <a href="<?php echo $feed_link; ?>"><?php echo is_null($feed_title)?'<em>Unknown</em>':$feed_title; ?></a></li> |
| 519 |
<li><strong>Feed URI:</strong> <a href="<?php echo wp_specialchars($f, 'both'); ?>"><?php echo wp_specialchars($f, 'both'); ?></a> (<a title="Check feed <<?php echo wp_specialchars($f, 'both'); ?>> for validity" href="http://feedvalidator.org/check.cgi?url=<?php echo urlencode($f); ?>">validate</a>)</li> |
| 520 |
<li><strong>Encoding:</strong> <?php echo isset($rss->encoding)?wp_specialchars($rss->encoding, 'both'):"<em>Unknown</em>"; ?></li> |
| 521 |
<li><strong>Description:</strong> <?php echo isset($rss->channel['description'])?wp_specialchars($rss->channel['description'], 'both'):"<em>Unknown</em>"; ?></li> |
| 522 |
</ul> |
| 523 |
<div class="submit"><input type="submit" name="Use" value="« Use this feed" /></div> |
| 524 |
<div class="submit"><input type="submit" name="Cancel" value="« Cancel" /></div> |
| 525 |
</div> |
| 526 |
</div> |
| 527 |
</fieldset> |
| 528 |
</form> |
| 529 |
<?php |
| 530 |
endforeach; |
| 531 |
else: |
| 532 |
print "<p><strong>".__('Error').":</strong> ".__("FeedWordPress couldn't find any feeds at").' <code><a href="'.htmlspecialchars($lookup).'">'.htmlspecialchars($lookup).'</a></code>'; |
| 533 |
print ". ".__('Try another URL').".</p>"; |
| 534 |
|
| 535 |
// Diagnostics |
| 536 |
$httpObject = _wp_http_get_object(); |
| 537 |
$transports = $httpObject->_getTransport(); |
| 538 |
print "<div class=\"updated\" style=\"margin-left: 3.0em; margin-right: 3.0em;\">\n"; |
| 539 |
print "<h3>".__('Diagnostic information')."</h3>\n"; |
| 540 |
if (!is_null($f->error())) : |
| 541 |
print "<h4>".__('HTTP request failure')."</h4>\n"; |
| 542 |
print "<p>".$f->error()."</p>\n"; |
| 543 |
else : |
| 544 |
print "<h4>".__('HTTP request completed')."</h4>\n"; |
| 545 |
print "<p><strong>Status ".$f->status().":</strong> ".$FeedWordPressHTTPStatusMessages[$f->status()]."</p>\n"; |
| 546 |
endif; |
| 547 |
print "<h4>".__('HTTP Transports available').":</h4>\n"; |
| 548 |
print "<ol>\n"; |
| 549 |
print "<li>".implode("</li>\n<li>", array_map('get_class', $transports))."</li>\n"; |
| 550 |
print "</ol>\n"; |
| 551 |
print "</div>\n"; |
| 552 |
endif; |
| 553 |
?> |
| 554 |
</div> |
| 555 |
|
| 556 |
<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 557 |
<div><?php |
| 558 |
FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); |
| 559 |
?></div> |
| 560 |
<div class="wrap"> |
| 561 |
<h2>Use another feed</h2> |
| 562 |
<div><label>Feed:</label> |
| 563 |
<input type="text" name="lookup" value="URI" /> |
| 564 |
<input type="hidden" name="link_id" value="<?php echo $link_id; ?>" /> |
| 565 |
<input type="hidden" name="action" value="feedfinder" /></div> |
| 566 |
<div class="submit"><input type="submit" value="Use this feed »" /></div> |
| 567 |
</div> |
| 568 |
</form> |
| 569 |
<?php |
| 570 |
return false; // Don't continue |
| 571 |
} |
| 572 |
|
| 573 |
function fwp_switchfeed_page () { |
| 574 |
global $wpdb, $wp_db_version; |
| 575 |
|
| 576 |
// If this is a POST, validate source and user credentials |
| 577 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links'); |
| 578 |
|
| 579 |
if (!isset($_REQUEST['Cancel'])): |
| 580 |
if (isset($_POST['link_id']) and ($_POST['link_id']==0)): |
| 581 |
$link_id = FeedWordPress::syndicate_link($_REQUEST['feed_title'], $_REQUEST['feed_link'], $_REQUEST['feed']); |
| 582 |
if ($link_id): ?> |
| 583 |
<div class="updated"><p><a href="<?php echo stripslashes($_REQUEST['feed_link']); ?>"><?php echo wp_specialchars(stripslashes($_REQUEST['feed_title']), 'both'); ?></a> |
| 584 |
has been added as a contributing site, using the feed at <<a href="<?php echo stripslashes($_REQUEST['feed']); ?>"><?php echo wp_specialchars(stripslashes($_REQUEST['feed']), 'both'); ?></a>>. |
| 585 |
| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link_id; ?>&action=linkedit">Configure settings</a>.</div> |
| 586 |
<?php else: ?> |
| 587 |
<div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo wp_specialchars(mysql_error(), 'both'); ?>]</p></div> |
| 588 |
<?php endif; |
| 589 |
elseif (isset($_POST['link_id'])): |
| 590 |
// Update link_rss |
| 591 |
$result = $wpdb->query(" |
| 592 |
UPDATE $wpdb->links |
| 593 |
SET |
| 594 |
link_rss = '".$wpdb->escape($_REQUEST['feed'])."' |
| 595 |
WHERE link_id = '".$wpdb->escape($_REQUEST['link_id'])."' |
| 596 |
"); |
| 597 |
|
| 598 |
if ($result): |
| 599 |
$result = $wpdb->get_row(" |
| 600 |
SELECT link_name, link_url FROM $wpdb->links |
| 601 |
WHERE link_id = '".$wpdb->escape($_REQUEST['link_id'])."' |
| 602 |
"); |
| 603 |
?> |
| 604 |
<div class="updated"><p>Feed for <a href="<?php echo $result->link_url; ?>"><?php echo wp_specialchars($result->link_name, 'both'); ?></a> |
| 605 |
updated to <<a href="<?php echo $_REQUEST['feed']; ?>"><?php echo wp_specialchars($_REQUEST['feed'], 'both'); ?></a>>.</p></div> |
| 606 |
<?php else: ?> |
| 607 |
<div class="updated"><p>Nothing was changed.</p></div> |
| 608 |
<?php endif; |
| 609 |
endif; |
| 610 |
endif; |
| 611 |
return true; // Continue |
| 612 |
} |
| 613 |
|
| 614 |
function fwp_linkedit_page () { |
| 615 |
global $wpdb, $wp_db_version; |
| 616 |
|
| 617 |
// If this is a POST, validate source and user credentials |
| 618 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_linkedit', /*capability=*/ 'manage_links'); |
| 619 |
|
| 620 |
$special_settings = array ( /* Regular expression syntax is OK here */ |
| 621 |
'cats', |
| 622 |
'cat_split', |
| 623 |
'hardcode name', |
| 624 |
'hardcode url', |
| 625 |
'hardcode description', |
| 626 |
'hardcode categories', /* Deprecated */ |
| 627 |
'post status', |
| 628 |
'comment status', |
| 629 |
'ping status', |
| 630 |
'unfamiliar author', |
| 631 |
'unfamliar categories', /* Deprecated */ |
| 632 |
'unfamiliar category', |
| 633 |
'map authors', |
| 634 |
'tags', |
| 635 |
'update/.*', |
| 636 |
'feed/.*', |
| 637 |
'link/.*', |
| 638 |
); |
| 639 |
|
| 640 |
if (isset($_REQUEST['feedfinder'])) : |
| 641 |
return fwp_feedfinder_page(); // re-route to Feed Finder page |
| 642 |
else : |
| 643 |
$link_id = (int) $_REQUEST['link_id']; |
| 644 |
$link =& new SyndicatedLink($link_id); |
| 645 |
|
| 646 |
if ($link->found()) : |
| 647 |
if (isset($GLOBALS['fwp_post']['save'])) : |
| 648 |
$alter = array (); |
| 649 |
|
| 650 |
// custom feed settings first |
| 651 |
foreach ($GLOBALS['fwp_post']['notes'] as $mn) : |
| 652 |
$mn['key0'] = trim($mn['key0']); |
| 653 |
$mn['key1'] = trim($mn['key1']); |
| 654 |
if (preg_match("\007^((" |
| 655 |
.implode(')|(',$special_settings) |
| 656 |
."))$\007i", |
| 657 |
$mn['key1'])) : |
| 658 |
$mn['key1'] = 'user/'.$mn['key1']; |
| 659 |
endif; |
| 660 |
|
| 661 |
if (strlen($mn['key0']) > 0) : |
| 662 |
unset($link->settings[$mn['key0']]); // out with the old |
| 663 |
endif; |
| 664 |
|
| 665 |
if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) : |
| 666 |
$link->settings[$mn['key1']] = $mn['value']; // in with the new |
| 667 |
endif; |
| 668 |
endforeach; |
| 669 |
|
| 670 |
// now stuff through the web form |
| 671 |
// hardcoded feed info |
| 672 |
if (isset($GLOBALS['fwp_post']['hardcode_name'])) : |
| 673 |
$link->settings['hardcode name'] = $GLOBALS['fwp_post']['hardcode_name']; |
| 674 |
if (FeedWordPress::affirmative($link->settings, 'hardcode name')) : |
| 675 |
$alter[] = "link_name = '".$wpdb->escape($GLOBALS['fwp_post']['name'])."'"; |
| 676 |
endif; |
| 677 |
endif; |
| 678 |
if (isset($GLOBALS['fwp_post']['hardcode_description'])) : |
| 679 |
$link->settings['hardcode description'] = $GLOBALS['fwp_post']['hardcode_description']; |
| 680 |
if (FeedWordPress::affirmative($link->settings, 'hardcode description')) : |
| 681 |
$alter[] = "link_description = '".$wpdb->escape($GLOBALS['fwp_post']['description'])."'"; |
| 682 |
endif; |
| 683 |
endif; |
| 684 |
if (isset($GLOBALS['fwp_post']['hardcode_url'])) : |
| 685 |
$link->settings['hardcode url'] = $GLOBALS['fwp_post']['hardcode_url']; |
| 686 |
if (FeedWordPress::affirmative($link->settings, 'hardcode url')) : |
| 687 |
$alter[] = "link_url = '".$wpdb->escape($GLOBALS['fwp_post']['linkurl'])."'"; |
| 688 |
endif; |
| 689 |
endif; |
| 690 |
|
| 691 |
// Update scheduling |
| 692 |
if (isset($GLOBALS['fwp_post']['update_schedule'])) : |
| 693 |
$link->settings['update/hold'] = $GLOBALS['fwp_post']['update_schedule']; |
| 694 |
endif; |
| 695 |
|
| 696 |
$alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'"; |
| 697 |
|
| 698 |
$alter_set = implode(", ", $alter); |
| 699 |
|
| 700 |
// issue update query |
| 701 |
$result = $wpdb->query(" |
| 702 |
UPDATE $wpdb->links |
| 703 |
SET $alter_set |
| 704 |
WHERE link_id='$link_id' |
| 705 |
"); |
| 706 |
$updated_link = true; |
| 707 |
|
| 708 |
// reload link information from DB |
| 709 |
if (function_exists('clean_bookmark_cache')) : |
| 710 |
clean_bookmark_cache($link_id); |
| 711 |
endif; |
| 712 |
$link =& new SyndicatedLink($link_id); |
| 713 |
else : |
| 714 |
$updated_link = false; |
| 715 |
endif; |
| 716 |
|
| 717 |
$db_link = $link->link; |
| 718 |
$link_url = wp_specialchars($db_link->link_url, 1); |
| 719 |
$link_name = wp_specialchars($db_link->link_name, 1); |
| 720 |
$link_description = wp_specialchars($db_link->link_description, 'both'); |
| 721 |
$link_rss_uri = wp_specialchars($db_link->link_rss, 'both'); |
| 722 |
else : |
| 723 |
die( __('Link not found.') ); |
| 724 |
endif; |
| 725 |
|
| 726 |
?> |
| 727 |
<script type="text/javascript"> |
| 728 |
function flip_hardcode (item) { |
| 729 |
ed=document.getElementById('basics-'+item+'-edit'); |
| 730 |
view=document.getElementById('basics-'+item+'-view'); |
| 731 |
|
| 732 |
o = document.getElementById('basics-hardcode-'+item); |
| 733 |
if (o.value=='yes') { ed.style.display='inline'; view.style.display='none'; } |
| 734 |
else { ed.style.display='none'; view.style.display='inline'; } |
| 735 |
} |
| 736 |
</script> |
| 737 |
|
| 738 |
<?php if ($updated_link) : ?> |
| 739 |
<div class="updated"><p>Syndicated feed settings updated.</p></div> |
| 740 |
<?php endif; ?> |
| 741 |
|
| 742 |
<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 743 |
<div class="wrap"> |
| 744 |
<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_linkedit'); ?> |
| 745 |
<input type="hidden" name="link_id" value="<?php echo $link_id; ?>" /> |
| 746 |
<input type="hidden" name="action" value="linkedit" /> |
| 747 |
<input type="hidden" name="save" value="link" /> |
| 748 |
|
| 749 |
<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?> |
| 750 |
<div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div> |
| 751 |
<?php endif; ?> |
| 752 |
|
| 753 |
<h2><?php _e('Feed settings'); ?><?php if (!is_null($link) and $link->found()) : ?>: <?php echo wp_specialchars($link->link->link_name, 1); ?><?php endif; ?></h2> |
| 754 |
|
| 755 |
<div id="poststuff"> |
| 756 |
<?php fwp_linkedit_single_submit($status); ?> |
| 757 |
|
| 758 |
<div id="post-body"> |
| 759 |
<?php fwp_option_box_opener('Feed Information', 'feedinformationdiv'); ?> |
| 760 |
<table class="editform" width="100%" cellspacing="2" cellpadding="5"> |
| 761 |
<tr> |
| 762 |
<th scope="row" width="20%"><?php _e('Feed URI:') ?></th> |
| 763 |
<td width="60%"><a href="<?php echo wp_specialchars($link_rss_uri, 'both'); ?>"><?php echo $link_rss_uri; ?></a> |
| 764 |
(<a href="<?php echo FEEDVALIDATOR_URI; ?>?url=<?php echo urlencode($link_rss_uri); ?>" |
| 765 |
title="Check feed <<?php echo wp_specialchars($link_rss_uri, 'both'); ?>> for validity">validate</a>) |
| 766 |
</td> |
| 767 |
<td width="20%"><input type="submit" name="feedfinder" value="switch →" style="font-size:smaller" /></td> |
| 768 |
</tr> |
| 769 |
<tr> |
| 770 |
<th scope="row" width="20%"><?php _e('Link Name:') ?></th> |
| 771 |
<td width="60%"><input type="text" id="basics-name-edit" name="name" |
| 772 |
value="<?php echo $link_name; ?>" style="width: 95%" /> |
| 773 |
<span id="basics-name-view"><strong><?php echo $link_name; ?></strong></span> |
| 774 |
</td> |
| 775 |
<td> |
| 776 |
<select id="basics-hardcode-name" onchange="flip_hardcode('name')" name="hardcode_name"> |
| 777 |
<option value="no" <?php echo $link->hardcode('name')?'':'selected="selected"'; ?>>update automatically</option> |
| 778 |
<option value="yes" <?php echo $link->hardcode('name')?'selected="selected"':''; ?>>edit manually</option> |
| 779 |
</select> |
| 780 |
</td> |
| 781 |
</tr> |
| 782 |
<tr> |
| 783 |
<th scope="row" width="20%"><?php _e('Short description:') ?></th> |
| 784 |
<td width="60%"> |
| 785 |
<input id="basics-description-edit" type="text" name="description" value="<?php echo $link_description; ?>" style="width: 95%" /> |
| 786 |
<span id="basics-description-view"><strong><?php echo $link_description; ?></strong></span> |
| 787 |
</td> |
| 788 |
<td> |
| 789 |
<select id="basics-hardcode-description" onchange="flip_hardcode('description')" |
| 790 |
name="hardcode_description"> |
| 791 |
<option value="no" <?php echo $link->hardcode('description')?'':'selected="selected"'; ?>>update automatically</option> |
| 792 |
<option value="yes" <?php echo $link->hardcode('description')?'selected="selected"':''; ?>>edit manually</option> |
| 793 |
</select></td> |
| 794 |
</tr> |
| 795 |
<tr> |
| 796 |
<th width="20%" scope="row"><?php _e('Homepage:') ?></th> |
| 797 |
<td width="60%"> |
| 798 |
<input id="basics-url-edit" type="text" name="linkurl" value="<?php echo $link_url; ?>" style="width: 95%;" /> |
| 799 |
<a id="basics-url-view" href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td> |
| 800 |
<td> |
| 801 |
<select id="basics-hardcode-url" onchange="flip_hardcode('url')" name="hardcode_url"> |
| 802 |
<option value="no"<?php echo $link->hardcode('url')?'':' selected="selected"'; ?>>update automatically</option> |
| 803 |
<option value="yes"<?php echo $link->hardcode('url')?' selected="selected"':''; ?>>edit manually</option> |
| 804 |
</select></td></tr> |
| 805 |
|
| 806 |
<tr> |
| 807 |
<th width="20%"><?php _e('Last update') ?>:</th> |
| 808 |
<td colspan="2"><?php |
| 809 |
if (isset($link->settings['update/last'])) : |
| 810 |
echo fwp_time_elapsed($link->settings['update/last'])." "; |
| 811 |
else : |
| 812 |
echo " none yet"; |
| 813 |
endif; |
| 814 |
?></td></tr> |
| 815 |
<tr><th width="20%">Next update:</th> |
| 816 |
<td colspan="2"><?php |
| 817 |
$holdem = (isset($link->settings['update/hold']) ? $link->settings['update/hold'] : 'scheduled'); |
| 818 |
?> |
| 819 |
<select name="update_schedule"> |
| 820 |
<option value="scheduled"<?php echo ($holdem=='scheduled')?' selected="selected"':''; ?>>update on schedule <?php |
| 821 |
echo " ("; |
| 822 |
if (isset($link->settings['update/ttl']) and is_numeric($link->settings['update/ttl'])) : |
| 823 |
if (isset($link->settings['update/timed']) and $link->settings['update/timed']=='automatically') : |
| 824 |
echo 'next: '; |
| 825 |
$next = $link->settings['update/last'] + ((int) $link->settings['update/ttl'] * 60); |
| 826 |
if (strftime('%x', time()) != strftime('%x', $next)) : |
| 827 |
echo strftime('%x', $next)." "; |
| 828 |
endif; |
| 829 |
echo strftime('%X', $link->settings['update/last']+((int) $link->settings['update/ttl']*60)); |
| 830 |
else : |
| 831 |
echo "every ".$link->settings['update/ttl']." minute".(($link->settings['update/ttl']!=1)?"s":""); |
| 832 |
endif; |
| 833 |
else: |
| 834 |
echo "next scheduled update"; |
| 835 |
endif; |
| 836 |
echo ")"; |
| 837 |
?></option> |
| 838 |
<option value="next"<?php echo ($holdem=='next')?' selected="selected"':''; ?>>update ASAP</option> |
| 839 |
<option value="ping"<?php echo ($holdem=='ping')?' selected="selected"':''; ?>>update only when pinged</option> |
| 840 |
</select></tr> |
| 841 |
</table> |
| 842 |
<?php fwp_option_box_closer(); ?> |
| 843 |
|
| 844 |
<script type="text/javascript"> |
| 845 |
flip_hardcode('name'); |
| 846 |
flip_hardcode('description'); |
| 847 |
flip_hardcode('url'); |
| 848 |
</script> |
| 849 |
|
| 850 |
<?php fwp_linkedit_periodic_submit(); ?> |
| 851 |
|
| 852 |
<?php |
| 853 |
FeedWordPressSettingsUI::instead_of_posts_box($link_id); |
| 854 |
FeedWordPressSettingsUI::instead_of_authors_box($link_id); |
| 855 |
FeedWordPressSettingsUI::instead_of_categories_box($link_id); |
| 856 |
|
| 857 |
fwp_option_box_opener('Custom Feed Settings (for use in templates)', 'postcustom', 'postbox'); |
| 858 |
?> |
| 859 |
<p class="setting-description">These custom settings are special fields for the <strong>feed</strong> you are |
| 860 |
syndicating, to be retrieved in templates using the <code>get_feed_meta()</code> function. They do not create |
| 861 |
custom fields on syndicated <strong>posts</strong>. If you want to create custom fields that are applied to each |
| 862 |
individual post from this feed, set up the settings in <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php&link_id=<?php print $link_id; ?>">Syndicated Posts</a>.</p> |
| 863 |
|
| 864 |
<div id="postcustomstuff"> |
| 865 |
<table id="meta-list" cellpadding="3"> |
| 866 |
<tr> |
| 867 |
<th>Key</th> |
| 868 |
<th>Value</th> |
| 869 |
<th>Action</th> |
| 870 |
</tr> |
| 871 |
|
| 872 |
<?php |
| 873 |
$i = 0; |
| 874 |
foreach ($link->settings as $key => $value) : |
| 875 |
if (!preg_match("\007^((".implode(')|(', $special_settings)."))$\007i", $key)) : |
| 876 |
?> |
| 877 |
<tr style="vertical-align:top"> |
| 878 |
<th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo wp_specialchars($key, 'both'); ?>" /> |
| 879 |
<input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo wp_specialchars($key, 'both'); ?>" /></th> |
| 880 |
<td width="60%"><textarea rows="2" cols="40" id="notes-<?php echo $i; ?>-value" name="notes[<?php echo $i; ?>][value]"><?php echo wp_specialchars($value, 'both'); ?></textarea></td> |
| 881 |
<td width="10%"><select name="notes[<?php echo $i; ?>][action]"> |
| 882 |
<option value="update">save changes</option> |
| 883 |
<option value="delete">delete this setting</option> |
| 884 |
</select></td> |
| 885 |
</tr> |
| 886 |
<?php |
| 887 |
$i++; |
| 888 |
endif; |
| 889 |
endforeach; |
| 890 |
?> |
| 891 |
<tr> |
| 892 |
<th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th> |
| 893 |
<td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea></td> |
| 894 |
<td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td> |
| 895 |
</tr> |
| 896 |
</table> |
| 897 |
<?php fwp_option_box_closer(); ?> |
| 898 |
|
| 899 |
<?php fwp_linkedit_periodic_submit(); ?> |
| 900 |
<?php fwp_linkedit_single_submit_closer(); ?> |
| 901 |
</div> <!-- id="post-body" --> |
| 902 |
</div> <!-- id="poststuff" --> |
| 903 |
</div> |
| 904 |
<?php |
| 905 |
endif; |
| 906 |
return false; // Don't continue |
| 907 |
} |
| 908 |
|
| 909 |
function fwp_multidelete_page () { |
| 910 |
global $wpdb; |
| 911 |
|
| 912 |
// If this is a POST, validate source and user credentials |
| 913 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links'); |
| 914 |
|
| 915 |
$link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array()); |
| 916 |
if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif; |
| 917 |
|
| 918 |
if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'): |
| 919 |
foreach ($GLOBALS['fwp_post']['link_action'] as $link_id => $what) : |
| 920 |
$do_it[$what][] = $link_id; |
| 921 |
endforeach; |
| 922 |
|
| 923 |
$alter = array(); |
| 924 |
if (count($do_it['hide']) > 0) : |
| 925 |
$hidem = "(".implode(', ', $do_it['hide']).")"; |
| 926 |
$alter[] = " |
| 927 |
UPDATE $wpdb->links |
| 928 |
SET link_visible = 'N' |
| 929 |
WHERE link_id IN {$hidem} |
| 930 |
"; |
| 931 |
endif; |
| 932 |
|
| 933 |
if (count($do_it['nuke']) > 0) : |
| 934 |
$nukem = "(".implode(', ', $do_it['nuke']).")"; |
| 935 |
|
| 936 |
// Make a list of the items syndicated from this feed... |
| 937 |
$post_ids = $wpdb->get_col(" |
| 938 |
SELECT post_id FROM $wpdb->postmeta |
| 939 |
WHERE meta_key = 'syndication_feed_id' |
| 940 |
AND meta_value IN {$nukem} |
| 941 |
"); |
| 942 |
|
| 943 |
// ... and kill them all |
| 944 |
if (count($post_ids) > 0) : |
| 945 |
foreach ($post_ids as $post_id) : |
| 946 |
wp_delete_post($post_id); |
| 947 |
endforeach; |
| 948 |
endif; |
| 949 |
|
| 950 |
$alter[] = " |
| 951 |
DELETE FROM $wpdb->links |
| 952 |
WHERE link_id IN {$nukem} |
| 953 |
"; |
| 954 |
endif; |
| 955 |
|
| 956 |
if (count($do_it['delete']) > 0) : |
| 957 |
$deletem = "(".implode(', ', $do_it['delete']).")"; |
| 958 |
|
| 959 |
// Make the items syndicated from this feed appear to be locally-authored |
| 960 |
$alter[] = " |
| 961 |
DELETE FROM $wpdb->postmeta |
| 962 |
WHERE meta_key = 'syndication_feed_id' |
| 963 |
AND meta_value IN {$deletem} |
| 964 |
"; |
| 965 |
|
| 966 |
// ... and delete the links themselves. |
| 967 |
$alter[] = " |
| 968 |
DELETE FROM $wpdb->links |
| 969 |
WHERE link_id IN {$deletem} |
| 970 |
"; |
| 971 |
endif; |
| 972 |
|
| 973 |
$errs = array(); $success = array (); |
| 974 |
foreach ($alter as $sql) : |
| 975 |
$result = $wpdb->query($sql); |
| 976 |
if (!$result): |
| 977 |
$errs[] = mysql_error(); |
| 978 |
endif; |
| 979 |
endforeach; |
| 980 |
|
| 981 |
if (count($alter) > 0) : |
| 982 |
echo "<div class=\"updated\">\n"; |
| 983 |
if (count($errs) > 0) : |
| 984 |
echo "There were some problems processing your "; |
| 985 |
echo "unsubscribe request. [SQL: ".implode('; ', $errs)."]"; |
| 986 |
else : |
| 987 |
echo "Your unsubscribe request(s) have been processed."; |
| 988 |
endif; |
| 989 |
echo "</div>\n"; |
| 990 |
endif; |
| 991 |
|
| 992 |
return true; // Continue on to Syndicated Sites listing |
| 993 |
else : |
| 994 |
$targets = $wpdb->get_results(" |
| 995 |
SELECT * FROM $wpdb->links |
| 996 |
WHERE link_id IN (".implode(",",$link_ids).") |
| 997 |
"); |
| 998 |
?> |
| 999 |
<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 1000 |
<div class="wrap"> |
| 1001 |
<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> |
| 1002 |
<input type="hidden" name="action" value="Unsubscribe" /> |
| 1003 |
<input type="hidden" name="confirm" value="Delete" /> |
| 1004 |
|
| 1005 |
<h2>Unsubscribe from Syndicated Links:</h2> |
| 1006 |
<?php foreach ($targets as $link) : |
| 1007 |
$link_url = wp_specialchars($link->link_url, 1); |
| 1008 |
$link_name = wp_specialchars($link->link_name, 1); |
| 1009 |
$link_description = wp_specialchars($link->link_description, 'both'); |
| 1010 |
$link_rss = wp_specialchars($link->link_rss, 'both'); |
| 1011 |
?> |
| 1012 |
<fieldset> |
| 1013 |
<legend><?php echo $link_name; ?></legend> |
| 1014 |
<table class="editform" width="100%" cellspacing="2" cellpadding="5"> |
| 1015 |
<tr><th scope="row" width="20%"><?php _e('Feed URI:') ?></th> |
| 1016 |
<td width="80%"><a href="<?php echo $link_rss; ?>"><?php echo $link_rss; ?></a></td></tr> |
| 1017 |
<tr><th scope="row" width="20%"><?php _e('Short description:') ?></th> |
| 1018 |
<td width="80%"><?php echo $link_description; ?></span></td></tr> |
| 1019 |
<tr><th width="20%" scope="row"><?php _e('Homepage:') ?></th> |
| 1020 |
<td width="80%"><a href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td></tr> |
| 1021 |
<tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options') ?>:</th> |
| 1022 |
<td width="80%"><ul style="margin:0; padding: 0; list-style: none"> |
| 1023 |
<li><input type="radio" id="hide-<?php echo $link->link_id; ?>" |
| 1024 |
name="link_action[<?php echo $link->link_id; ?>]" value="hide" /> |
| 1025 |
<label for="hide-<?php echo $link->link_id; ?>">Turn off the subscription for this |
| 1026 |
syndicated link<br/><span style="font-size:smaller">(Keep the feed information |
| 1027 |
and all the posts from this feed in the database, but don't syndicate any |
| 1028 |
new posts from the feed.)</span></label></li> |
| 1029 |
<li><input type="radio" id="nuke-<?php echo $link->link_id; ?>" |
| 1030 |
name="link_action[<?php echo $link->link_id; ?>]" value="nuke" /> |
| 1031 |
<label for="nuke-<?php echo $link->link_id; ?>">Delete this syndicated link and all the |
| 1032 |
posts that were syndicated from it</label></li> |
| 1033 |
<li><input type="radio" id="delete-<?php echo $link->link_id; ?>" |
| 1034 |
name="link_action[<?php echo $link->link_id; ?>]" value="delete" /> |
| 1035 |
<label for="delete-<?php echo $link->link_id; ?>">Delete this syndicated link, but |
| 1036 |
<em>keep</em> posts that were syndicated from it (as if they were authored |
| 1037 |
locally).</label></li> |
| 1038 |
<li><input type="radio" id="nothing-<?php echo $link->link_id; ?>" |
| 1039 |
name="link_action[<?php echo $link->link_id; ?>]" value="nothing" /> |
| 1040 |
<label for="nothing-<?php echo $link->link_id; ?>">Keep this feed as it is. I changed |
| 1041 |
my mind.</label></li> |
| 1042 |
</ul> |
| 1043 |
</table> |
| 1044 |
</fieldset> |
| 1045 |
<?php endforeach; ?> |
| 1046 |
|
| 1047 |
<div class="submit"> |
| 1048 |
<input class="delete" type="submit" name="submit" value="<?php _e('Unsubscribe from selected feeds »') ?>" /> |
| 1049 |
</div> |
| 1050 |
</div> |
| 1051 |
<?php |
| 1052 |
return false; // Don't continue on to Syndicated Sites listing |
| 1053 |
endif; |
| 1054 |
} |
| 1055 |
|
| 1056 |
fwp_syndication_manage_page(); |
| 1057 |
|
| 1058 |
|