PluginProbe
FeedWordPress / 2025.1211
FeedWordPress v2025.1211
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
← All changes | syndication.php +3 -1241 2008.11052025.1211 View file →
@@ -1,1243 +1,5 @@
1 1 <?php
2 -require_once(dirname(__FILE__) . '/admin-ui.php');
2 + require_once dirname(__FILE__) . '/feedwordpresssyndicationpage.class.php';
3 3
4 -################################################################################
5 -## ADMIN MENU ADD-ONS: implement Dashboard management pages ####################
6 -################################################################################
7 -
8 -if (fwp_test_wp_version(0, FWP_SCHEMA_25)) :
9 - define('FWP_UPDATE_CHECKED', 'Update Checked Links');
10 - define('FWP_UNSUB_CHECKED', 'Unsubscribe from Checked Links');
11 - define('FWP_SYNDICATE_NEW', 'Syndicate »');
12 -else :
13 - define('FWP_UPDATE_CHECKED', 'Update Checked');
14 - define('FWP_UNSUB_CHECKED', 'Unsubscribe');
15 - define('FWP_SYNDICATE_NEW', 'Syndicate »');
16 -endif;
17 -
18 -function fwp_dashboard_update_if_requested () {
19 - global $wpdb;
20 -
21 - if (isset($_POST['update']) or isset($_POST['action']) or isset($_POST['update_uri'])) :
22 - $fwp_update_invoke = 'post';
23 - else :
24 - $fwp_update_invoke = 'get';
25 - endif;
26 -
27 - $update_set = array();
28 - if (isset($_POST['link_ids']) and is_array($_POST['link_ids']) and ($_POST['action']==FWP_UPDATE_CHECKED)) :
29 - $targets = $wpdb->get_results("
30 - SELECT * FROM $wpdb->links
31 - WHERE link_id IN (".implode(",",$_POST['link_ids']).")
32 - ");
33 - if (is_array($targets)) :
34 - foreach ($targets as $target) :
35 - $update_set[] = $target->link_rss;
36 - endforeach;
37 - else : // This should never happen
38 - FeedWordPress::critical_bug('fwp_syndication_manage_page::targets', $targets, __LINE__);
39 - endif;
40 - elseif (isset($_POST['update_uri'])) :
41 - $update_set[] = $_POST['update_uri'];
42 - endif;
43 -
44 - shuffle($update_set); // randomize order for load balancing purposes...
45 - if ($fwp_update_invoke != 'get' and count($update_set) > 0) : // Only do things with side-effects for HTTP POST or command line
46 - $feedwordpress =& new FeedWordPress;
47 - add_action('feedwordpress_check_feed', 'update_feeds_mention');
48 - add_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3);
49 -
50 - $crash_dt = (int) get_option('feedwordpress_update_time_limit');
51 - if ($crash_dt > 0) :
52 - $crash_ts = time() + $crash_dt;
53 - else :
54 - $crash_ts = NULL;
55 - endif;
56 -
57 - if (fwp_test_wp_version(FWP_SCHEMA_25)) :
58 - echo "<div class=\"youare\">\n";
59 - else :
60 - echo "<div class=\"updated\">\n";
61 - endif;
62 - echo "<ul>\n";
63 - $tdelta = NULL;
64 - foreach ($update_set as $uri) :
65 - if (!is_null($crash_ts) and (time() > $crash_ts)) :
66 - echo "<li><p><strong>Further updates postponed:</strong> update time limit of ".$crash_dt." second".(($crash_dt==1)?"":"s")." exceeded.</p></li>";
67 - break;
68 - endif;
69 -
70 - if ($uri == '*') : $uri = NULL; endif;
71 - $delta = $feedwordpress->update($uri, $crash_ts);
72 - if (!is_null($delta)) :
73 - if (is_null($tdelta)) :
74 - $tdelta = $delta;
75 - else :
76 - $tdelta['new'] += $delta['new'];
77 - $tdelta['updated'] += $delta['updated'];
78 - endif;
79 - else :
80 - echo "<li><p><strong>Error:</strong> There was a problem updating <a href=\"$uri\">$uri</a></p></li>\n";
81 - endif;
82 - endforeach;
83 - echo "</ul>\n";
84 -
85 - if (!is_null($tdelta)) :
86 - $mesg = array();
87 - if (isset($delta['new'])) : $mesg[] = ' '.$tdelta['new'].' new posts were syndicated'; endif;
88 - if (isset($delta['updated'])) : $mesg[] = ' '.$tdelta['updated'].' existing posts were updated'; endif;
89 - echo "<p>Update complete.".implode(' and', $mesg)."</p>";
90 - echo "\n"; flush();
91 - endif;
92 - echo "</div> <!-- class=\"updated\" -->\n";
93 - elseif (fwp_test_wp_version(FWP_SCHEMA_25)) :
94 -?>
95 - <p class="youare">Check currently scheduled feeds for new and updated posts.</p>
96 -<?php
97 - endif;
98 -}
99 -
100 -function fwp_syndication_manage_page () {
101 - global $wpdb;
102 -
103 - if (FeedWordPress::needs_upgrade()) :
104 - fwp_upgrade_page();
105 - return;
106 - endif;
107 -
108 -?>
109 -<?php $cont = true;
110 -if (isset($_REQUEST['action'])):
111 - if ($_REQUEST['action'] == 'feedfinder' or $_REQUEST['action'] == FWP_SYNDICATE_NEW) : $cont = fwp_feedfinder_page();
112 - elseif ($_REQUEST['action'] == 'switchfeed') : $cont = fwp_switchfeed_page();
113 - elseif ($_REQUEST['action'] == 'linkedit') : $cont = fwp_linkedit_page();
114 - elseif ($_REQUEST['action'] == FWP_UNSUB_CHECKED or $_REQUEST['action'] == 'Unsubscribe') : $cont = fwp_multidelete_page();
115 - endif;
116 -endif;
117 -
118 -if ($cont):
119 -?>
120 -<?php
121 - $links = FeedWordPress::syndicated_links();
122 -
123 - if (fwp_test_wp_version(0, FWP_SCHEMA_25)) :
124 - fwp_dashboard_update_if_requested();
125 - endif;
126 -
127 - if ($links): // only display Update panel if there are some links to update....
128 - ?>
129 - <form action="" method="POST">
130 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
131 - <div class="wrap">
132 - <div id="rightnow">
133 - <h3 class="reallynow"><span>Update feeds now</span>
134 - <input type="hidden" name="update_uri" value="*" /><input style="float: right; border: none;" class="rbutton" type="submit" name="update" value="Update" />
135 - <br class="clear"/></h3>
136 - <?php else : ?>
137 - <div class="wrap">
138 - <h2>Update feeds now</h2>
139 - <?php endif; ?>
140 -
141 - <?php
142 - if (fwp_test_wp_version(FWP_SCHEMA_25)) :
143 - fwp_dashboard_update_if_requested();
144 - else :
145 -?>
146 -<p>Check currently scheduled feeds for new and updated posts.</p>
147 -<?php
148 - endif;
149 - ?>
150 -
151 -<?php if (!get_option('feedwordpress_automatic_updates')) : ?>
152 - <p class="youhave"><strong>Note:</strong> Automatic updates are currently turned
153 - <strong>off</strong>. New posts from your feeds will not be syndicated
154 - until you manually check for them here. You can turn on automatic
155 - updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/syndication-options.php">Syndication
156 - Options</a>.</p>
157 -<?php endif; ?>
158 -
159 - <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
160 - <div class="submit"><input type="hidden" name="update_uri" value="*" /><input type="submit" name="update" value="Update" /></div>
161 - <?php endif; ?>
162 -
163 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
164 - </div> <!-- id="rightnow" -->
165 - <?php endif; ?>
166 - </div> <!-- class="wrap" -->
167 - </form>
168 -<?php
169 - endif;
170 -?>
171 -
172 - <div class="wrap">
173 - <form id="syndicated-links" action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/<?php echo basename(__FILE__); ?>" method="post">
174 - <h2>Syndicated Sites</h2>
175 -<?php $alt_row = true; ?>
176 -
177 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
178 - <div class="tablenav">
179 - <div class="alignright">
180 - <label for="add-uri">Add new source:</label>
181 - <input type="text" name="lookup" id="add-uri" value="Website or feed URI" />
182 -<script type="text/javascript">
183 -jQuery(document).ready( function () {
184 - var addUri = jQuery("#add-uri");
185 - var box = addUri.get(0);
186 - if (box.value==box.defaultValue) { addUri.addClass('form-input-tip'); }
187 - addUri.focus(function() {
188 - if ( this.value == this.defaultValue )
189 - jQuery(this).val( '' ).removeClass( 'form-input-tip' );
190 - });
191 - addUri.blur(function() {
192 - if ( this.value == '' )
193 - jQuery(this).val( this.defaultValue ).addClass( 'form-input-tip' );
194 - });
195 -
196 -} );
197 -</script>
198 -
199 - <input type="hidden" name="action" value="feedfinder" />
200 - <input type="submit" class="button-secondary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div>
201 -
202 -<?php if (count($links) > 0) : ?>
203 - <div class="alignleft">
204 - <input class="button-secondary" type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" />
205 - <input class="button-secondary delete" type="submit" class="delete" name="action" value="<?php print FWP_UNSUB_CHECKED; ?>" />
206 - </div>
207 -<?php endif; ?>
208 -
209 - <br class="clear" />
210 - </div>
211 - <br class="clear" />
212 -
213 - <table class="widefat">
214 - <?php else : ?>
215 - <table width="100%" cellpadding="3" cellspacing="3">
216 - <?php endif; ?>
217 -<thead>
218 -<tr>
219 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : $span = 3; ?>
220 - <th class="check-column" scope="col"><input type="checkbox" <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_26)) : ?>onclick="checkAll(document.getElementById('syndicated-links'));"<?php endif; ?> /></th>
221 - <?php else : $span = 4; ?>
222 - <?php endif; ?>
223 -<th width="20%" scope="col"><?php _e('Name'); ?></th>
224 -<th width="40%" scope="col"><?php _e('Feed'); ?></th>
225 -<th class="action-links" scope="col" colspan="<?php print $span; ?>"><?php _e('Action'); ?></th>
226 -</tr>
227 -</thead>
228 -
229 -<tbody>
230 -<?php if (count($links) > 0): foreach ($links as $link):
231 - $alt_row = !$alt_row; ?>
232 -<tr<?php echo ($alt_row?' class="alternate"':''); ?>>
233 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
234 -<th class="check-column" scope="row"><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?>" /></th>
235 - <?php endif; ?>
236 -
237 -<td><a href="<?php echo wp_specialchars($link->link_url, 'both'); ?>"><?php echo wp_specialchars($link->link_name, 'both'); ?></a></td>
238 -<?php
239 - if (strlen($link->link_rss) > 0):
240 - $caption='Switch Feed';
241 - $uri_bits = parse_url($link->link_rss);
242 - $uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']);
243 - $display_uri =
244 - (isset($uri_bits['user'])?$uri_bits['user'].'@':'')
245 - .(isset($uri_bits['host'])?$uri_bits['host']:'')
246 - .(isset($uri_bits['port'])?':'.$uri_bits['port']:'')
247 - .(isset($uri_bits['path'])?$uri_bits['path']:'')
248 - .(isset($uri_bits['query'])?'?'.$uri_bits['query']:'');
249 - if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'&#8230;'; endif;
250 -?>
251 - <td>
252 - <strong><a href="<?php echo wp_specialchars($link->link_rss, 'both'); ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></strong></td>
253 -<?php
254 - else:
255 - $caption='Find Feed';
256 -?>
257 - <td style="background-color:#FFFFD0"><p><strong>no
258 - feed assigned</strong></p></td>
259 -<?php
260 - endif;
261 -?>
262 - <td><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=linkedit" class="edit"><?php _e('Edit')?></a></td>
263 - <td><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=feedfinder" class="edit"><?php echo $caption; ?></a></td>
264 - <td><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=Unsubscribe" class="delete"><?php _e('Unsubscribe'); ?></a></td>
265 - <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
266 - <td><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?>" /></td>
267 -<?php
268 - endif;
269 - echo "\n\t</tr>";
270 - endforeach;
271 - else :
272 -?>
273 -<tr><td colspan="<?php print $span+2; ?>"><p>There are no websites currently listed for syndication.</p></td></tr>
274 -<?php
275 - endif;
276 -?>
277 -</tbody>
278 -</table>
279 -
280 -<?php if (count($links) > 0 and fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
281 -<br/><hr/>
282 -<div class="submit"><input type="submit" class="delete" name="action" value="<?php print FWP_UNSUB_CHECKED; ?>" />
283 -<input type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" /></div>
284 -<?php endif; ?>
285 -
286 - </form>
287 -
288 - </div> <!-- class="wrap" -->
289 -
290 - <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
291 - <div class="wrap">
292 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
293 - <h2>Add a new syndicated site:</h2>
294 - <div>
295 - <label for="add-uri">Website or newsfeed:</label>
296 - <input type="text" name="lookup" id="add-uri" value="URI" size="64" />
297 - <input type="hidden" name="action" value="feedfinder" />
298 - </div>
299 - <div class="submit"><input type="submit" value="Syndicate &raquo;" /></div>
300 - </form>
301 - </div> <!-- class="wrap" -->
302 - <?php endif; ?>
303 -
304 -<div style="display: none">
305 -<div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
306 -</div>
307 -<?php
308 -endif;
309 -}
310 -
311 -function fwp_feedfinder_page () {
312 - global $wpdb;
313 -
314 - $lookup = (isset($_REQUEST['lookup'])?$_REQUEST['lookup']:NULL);
315 -
316 - if (isset($_REQUEST['link_id']) and ($_REQUEST['link_id']!=0)):
317 - $link_id = $_REQUEST['link_id'];
318 - if (!is_numeric($link_id)) : FeedWordPress::critical_bug('fwp_feedfinder_page::link_id', $link_id, __LINE__); endif;
319 -
320 - $link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id='".$wpdb->escape($link_id)."'");
321 - if (is_object($link)):
322 - if (is_null($lookup)) $lookup = $link->link_url;
323 - $name = wp_specialchars($link->link_name, 'both');
324 - else:
325 - die (__("Cheatin' uh ?"));
326 - endif;
327 - else:
328 - $name = "New Syndicated Feed";
329 - $link_id = 0;
330 - endif;
331 -?>
332 - <div class="wrap">
333 - <h2>Feed Finder: <?php echo $name; ?></h2>
334 -<?php
335 - $f =& new FeedFinder($lookup);
336 - $feeds = $f->find();
337 - if (count($feeds) > 0):
338 - foreach ($feeds as $key => $f):
339 - $rss = fetch_rss($f);
340 - if ($rss):
341 - $feed_title = isset($rss->channel['title'])?$rss->channel['title']:$rss->channel['link'];
342 - $feed_link = isset($rss->channel['link'])?$rss->channel['link']:'';
343 -?>
344 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
345 - <fieldset style="clear: both">
346 - <legend><?php echo $rss->feed_type; ?> <?php echo $rss->feed_version; ?> feed</legend>
347 -
348 - <?php if ($link_id===0): ?>
349 - <input type="hidden" name="feed_title" value="<?php echo wp_specialchars($feed_title, 'both'); ?>" />
350 - <input type="hidden" name="feed_link" value="<?php echo wp_specialchars($feed_link, 'both'); ?>" />
351 - <?php endif; ?>
352 -
353 - <input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
354 - <input type="hidden" name="feed" value="<?php echo wp_specialchars($f, 'both'); ?>" />
355 - <input type="hidden" name="action" value="switchfeed" />
356 -
357 - <div>
358 - <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">
359 -<?php if (count($rss->items) > 0): ?>
360 - <?php $item = $rss->items[0]; ?>
361 - <h3>Sample Item</h3>
362 - <ul>
363 - <li><strong>Title:</strong> <a href="<?php echo $item['link']; ?>"><?php echo $item['title']; ?></a></li>
364 - <li><strong>Date:</strong> <?php echo isset($item['date_timestamp']) ? date('d-M-y g:i:s a', $item['date_timestamp']) : 'unknown'; ?></li>
365 - </ul>
366 - <div class="entry">
367 - <?php echo (isset($item['content']['encoded'])?$item['content']['encoded']:$item['description']); ?>
368 - </div>
369 -<?php else: ?>
370 - <h3>No Items</h3>
371 - <p>FeedWordPress found no posts on this feed.</p>
372 -<?php endif; ?>
373 - </div>
374 -
375 - <div>
376 - <h3>Feed Information</h3>
377 - <ul>
378 - <li><strong>Website:</strong> <a href="<?php echo $feed_link; ?>"><?php echo is_null($feed_title)?'<em>Unknown</em>':$feed_title; ?></a></li>
379 - <li><strong>Feed URI:</strong> <a href="<?php echo wp_specialchars($f, 'both'); ?>"><?php echo wp_specialchars($f, 'both'); ?></a> (<a title="Check feed &lt;<?php echo wp_specialchars($f, 'both'); ?>&gt; for validity" href="http://feedvalidator.org/check.cgi?url=<?php echo urlencode($f); ?>">validate</a>)</li>
380 - <li><strong>Encoding:</strong> <?php echo isset($rss->encoding)?wp_specialchars($rss->encoding, 'both'):"<em>Unknown</em>"; ?></li>
381 - <li><strong>Description:</strong> <?php echo isset($rss->channel['description'])?wp_specialchars($rss->channel['description'], 'both'):"<em>Unknown</em>"; ?></li>
382 - </ul>
383 - <div class="submit"><input type="submit" name="Use" value="&laquo; Use this feed" /></div>
384 - <div class="submit"><input type="submit" name="Cancel" value="&laquo; Cancel" /></div>
385 - </div>
386 - </div>
387 - </fieldset>
388 - </form>
389 -<?php endif;
390 - endforeach;
391 - else:
392 - echo "<p><strong>no feed found</strong></p>";
393 - endif;
394 -?>
395 - </div>
396 -
397 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
398 - <div class="wrap">
399 - <h2>Use another feed</h2>
400 - <div><label>Feed:</label>
401 - <input type="text" name="lookup" value="URI" />
402 - <input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
403 - <input type="hidden" name="action" value="feedfinder" /></div>
404 - <div class="submit"><input type="submit" value="Use this feed &raquo;" /></div>
405 - </div>
406 - </form>
407 -<?php
408 - return false; // Don't continue
409 -}
410 -
411 -function fwp_switchfeed_page () {
412 - global $wpdb, $wp_db_version;
413 -
414 - check_admin_referer();
415 - if (!isset($_REQUEST['Cancel'])):
416 - if (!current_user_can('manage_links')):
417 - die (__("Cheatin' uh ?"));
418 - elseif (isset($_REQUEST['link_id']) and ($_REQUEST['link_id']==0)):
419 - $link_id = FeedWordPress::syndicate_link($_REQUEST['feed_title'], $_REQUEST['feed_link'], $_REQUEST['feed']);
420 - if ($link_id): ?>
421 -<div class="updated"><p><a href="<?php echo $_REQUEST['feed_link']; ?>"><?php echo wp_specialchars($_REQUEST['feed_title'], 'both'); ?></a>
422 -has been added as a contributing site, using the newsfeed at &lt;<a href="<?php echo $_REQUEST['feed']; ?>"><?php echo wp_specialchars($_REQUEST['feed'], 'both'); ?></a>&gt;.</p></div>
423 -<?php else: ?>
424 -<div class="updated"><p>There was a problem adding the newsfeed. [SQL: <?php echo wp_specialchars(mysql_error(), 'both'); ?>]</p></div>
425 -<?php endif;
426 - elseif (isset($_REQUEST['link_id'])):
427 - // Update link_rss
428 - $result = $wpdb->query("
429 - UPDATE $wpdb->links
430 - SET
431 - link_rss = '".$wpdb->escape($_REQUEST['feed'])."'
432 - WHERE link_id = '".$wpdb->escape($_REQUEST['link_id'])."'
433 - ");
434 -
435 - if ($result):
436 - $result = $wpdb->get_row("
437 - SELECT link_name, link_url FROM $wpdb->links
438 - WHERE link_id = '".$wpdb->escape($_REQUEST['link_id'])."'
439 - ");
440 - ?>
441 -<div class="updated"><p>Feed for <a href="<?php echo $result->link_url; ?>"><?php echo wp_specialchars($result->link_name, 'both'); ?></a>
442 -updated to &lt;<a href="<?php echo $_REQUEST['feed']; ?>"><?php echo wp_specialchars($_REQUEST['feed'], 'both'); ?></a>&gt;.</p></div>
443 - <?php else: ?>
444 -<div class="updated"><p>Nothing was changed.</p></div>
445 - <?php endif;
446 - endif;
447 - endif;
448 - return true; // Continue
449 -}
450 -
451 -function fwp_linkedit_page () {
452 - global $wpdb, $wp_db_version;
453 -
454 - check_admin_referer(); // Make sure we arrived here from the Dashboard
455 -
456 - $special_settings = array ( /* Regular expression syntax is OK here */
457 - 'cats',
458 - 'cat_split',
459 - 'hardcode name',
460 - 'hardcode url',
461 - 'hardcode description',
462 - 'hardcode categories', /* Deprecated */
463 - 'post status',
464 - 'comment status',
465 - 'ping status',
466 - 'unfamiliar author',
467 - 'unfamliar categories', /* Deprecated */
468 - 'unfamiliar category',
469 - 'map authors',
470 - 'tags',
471 - 'update/.*',
472 - 'feed/.*',
473 - 'link/.*',
474 - );
475 -
476 - if (!current_user_can('manage_links')) :
477 - die (__("Cheatin' uh ?"));
478 - elseif (isset($_REQUEST['feedfinder'])) :
479 - return fwp_feedfinder_page(); // re-route to Feed Finder page
480 - else :
481 - $link_id = (int) $_REQUEST['link_id'];
482 - $link =& new SyndicatedLink($link_id);
483 -
484 - if ($link->found()) :
485 - if (isset($GLOBALS['fwp_post']['save'])) :
486 - $alter = array ();
487 -
488 - // custom feed settings first
489 - foreach ($GLOBALS['fwp_post']['notes'] as $mn) :
490 - $mn['key0'] = trim($mn['key0']);
491 - $mn['key1'] = trim($mn['key1']);
492 - if (preg_match("\007^(("
493 - .implode(')|(',$special_settings)
494 - ."))$\007i",
495 - $mn['key1'])) :
496 - $mn['key1'] = 'user/'.$mn['key1'];
497 - endif;
498 -
499 - if (strlen($mn['key0']) > 0) :
500 - unset($link->settings[$mn['key0']]); // out with the old
501 - endif;
502 -
503 - if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
504 - $link->settings[$mn['key1']] = $mn['value']; // in with the new
505 - endif;
506 - endforeach;
507 -
508 - // now stuff through the web form
509 - // hardcoded feed info
510 - if (isset($GLOBALS['fwp_post']['hardcode_name'])) :
511 - $link->settings['hardcode name'] = $GLOBALS['fwp_post']['hardcode_name'];
512 - if (FeedWordPress::affirmative($link->settings, 'hardcode name')) :
513 - $alter[] = "link_name = '".$wpdb->escape($GLOBALS['fwp_post']['name'])."'";
514 - endif;
515 - endif;
516 - if (isset($GLOBALS['fwp_post']['hardcode_description'])) :
517 - $link->settings['hardcode description'] = $GLOBALS['fwp_post']['hardcode_description'];
518 - if (FeedWordPress::affirmative($link->settings, 'hardcode description')) :
519 - $alter[] = "link_description = '".$wpdb->escape($GLOBALS['fwp_post']['description'])."'";
520 - endif;
521 - endif;
522 - if (isset($GLOBALS['fwp_post']['hardcode_url'])) :
523 - $link->settings['hardcode url'] = $GLOBALS['fwp_post']['hardcode_url'];
524 - if (FeedWordPress::affirmative($link->settings, 'hardcode url')) :
525 - $alter[] = "link_url = '".$wpdb->escape($GLOBALS['fwp_post']['linkurl'])."'";
526 - endif;
527 - endif;
528 -
529 - // Update scheduling
530 - if (isset($GLOBALS['fwp_post']['update_schedule'])) :
531 - $link->settings['update/hold'] = $GLOBALS['fwp_post']['update_schedule'];
532 - endif;
533 -
534 - // Categories
535 - if (isset($GLOBALS['fwp_post']['post_category'])) :
536 - $link->settings['cats'] = array();
537 - foreach ($GLOBALS['fwp_post']['post_category'] as $cat_id) :
538 - $link->settings['cats'][] = '{#'.$cat_id.'}';
539 - endforeach;
540 - else :
541 - unset($link->settings['cats']);
542 - endif;
543 -
544 - // Tags
545 - if (isset($GLOBALS['fwp_post']['tags_input'])) :
546 - $link->settings['tags'] = array();
547 - foreach (explode(',', $GLOBALS['fwp_post']['tags_input']) as $tag) :
548 - $link->settings['tags'][] = trim($tag);
549 - endforeach;
550 - endif;
551 -
552 - // Post status, comment status, ping status
553 - foreach (array('post', 'comment', 'ping') as $what) :
554 - $sfield = "feed_{$what}_status";
555 - if (isset($GLOBALS['fwp_post'][$sfield])) :
556 - if ($GLOBALS['fwp_post'][$sfield]=='site-default') :
557 - unset($link->settings["{$what} status"]);
558 - else :
559 - $link->settings["{$what} status"] = $GLOBALS['fwp_post'][$sfield];
560 - endif;
561 - endif;
562 - endforeach;
563 -
564 - // Unfamiliar author, unfamiliar categories
565 - foreach (array("author", "category") as $what) :
566 - $sfield = "unfamiliar_{$what}";
567 - if (isset($GLOBALS['fwp_post'][$sfield])) :
568 - if ('site-default'==$GLOBALS['fwp_post'][$sfield]) :
569 - unset($link->settings["unfamiliar {$what}"]);
570 - elseif ('newuser'==$GLOBALS['fwp_post'][$sfield]) :
571 - $newuser_name = trim($GLOBALS['fwp_post']["{$sfield}_newuser"]);
572 - if (strlen($newuser_name) > 0) :
573 - $userdata = array();
574 - $userdata['ID'] = NULL;
575 -
576 - $userdata['user_login'] = sanitize_user($newuser_name);
577 - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
578 -
579 - $userdata['user_nicename'] = sanitize_title($newuser_name);
580 - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
581 -
582 - $userdata['display_name'] = $wpdb->escape($newuser_name);
583 -
584 - $newuser_id = wp_insert_user($userdata);
585 - if (is_numeric($newuser_id)) :
586 - $link->settings["unfamiliar {$what}"] = $newuser_id;
587 - else :
588 - // TODO: Add some error detection and reporting
589 - endif;
590 - else :
591 - // TODO: Add some error reporting
592 - endif;
593 - else :
594 - $link->settings["unfamiliar {$what}"] = $GLOBALS['fwp_post'][$sfield];
595 - endif;
596 - endif;
597 - endforeach;
598 -
599 - // Handle author mapping rules
600 - if (isset($GLOBALS['fwp_post']['author_rules_name']) and isset($GLOBALS['fwp_post']['author_rules_action'])) :
601 - unset($link->settings['map authors']);
602 - foreach ($GLOBALS['fwp_post']['author_rules_name'] as $key => $name) :
603 - // Normalize for case and whitespace
604 - $name = strtolower(trim($name));
605 - $author_action = strtolower(trim($GLOBALS['fwp_post']['author_rules_action'][$key]));
606 -
607 - if (strlen($name) > 0) :
608 - if ('newuser' == $author_action) :
609 - $newuser_name = trim($GLOBALS['fwp_post']['author_rules_newuser'][$key]);
610 - if (strlen($newuser_name) > 0) :
611 - $userdata = array();
612 - $userdata['ID'] = NULL;
613 -
614 - $userdata['user_login'] = sanitize_user($newuser_name);
615 - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
616 -
617 - $userdata['user_nicename'] = sanitize_title($newuser_name);
618 - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
619 -
620 - $userdata['display_name'] = $wpdb->escape($newuser_name);
621 -
622 - $newuser_id = wp_insert_user($userdata);
623 - if (is_numeric($newuser_id)) :
624 - $link->settings['map authors']['name'][$name] = $newuser_id;
625 - else :
626 - // TODO: Add some error detection and reporting
627 - endif;
628 - else :
629 - // TODO: Add some error reporting
630 - endif;
631 - else :
632 - $link->settings['map authors']['name'][$name] = $author_action;
633 - endif;
634 - endif;
635 - endforeach;
636 - endif;
637 -
638 - if (isset($GLOBALS['fwp_post']['add_author_rule_name']) and isset($GLOBALS['fwp_post']['add_author_rule_action'])) :
639 - $name = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_name']));
640 - $author_action = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_action']));
641 - if (strlen($name) > 0) :
642 - if ('newuser' == $author_action) :
643 - $newuser_name = trim($GLOBALS['fwp_post']['add_author_rule_newuser']);
644 - if (strlen($newuser_name) > 0) :
645 - $userdata = array();
646 - $userdata['ID'] = NULL;
647 -
648 - $userdata['user_login'] = sanitize_user($newuser_name);
649 - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
650 -
651 - $userdata['user_nicename'] = sanitize_title($newuser_name);
652 - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
653 -
654 - $userdata['display_name'] = $wpdb->escape($newuser_name);
655 -
656 - $newuser_id = wp_insert_user($userdata);
657 - if (is_numeric($newuser_id)) :
658 - $link->settings['map authors']['name'][$name] = $newuser_id;
659 - else :
660 - // TODO: Add some error detection and reporting
661 - endif;
662 - else :
663 - // TODO: Add some error reporting
664 - endif;
665 - else :
666 - $link->settings['map authors']['name'][$name] = $author_action;
667 - endif;
668 - endif;
669 - endif;
670 -
671 - if (isset($GLOBALS['fwp_post']['cat_split'])) :
672 - if (strlen(trim($GLOBALS['fwp_post']['cat_split'])) > 0) :
673 - $link->settings['cat_split'] = trim($GLOBALS['fwp_post']['cat_split']);
674 - else :
675 - unset($link->settings['cat_split']);
676 - endif;
677 - endif;
678 -
679 - $alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'";
680 -
681 - $alter_set = implode(", ", $alter);
682 -
683 - // issue update query
684 - $result = $wpdb->query("
685 - UPDATE $wpdb->links
686 - SET $alter_set
687 - WHERE link_id='$link_id'
688 - ");
689 - $updated_link = true;
690 -
691 - // reload link information from DB
692 - $link =& new SyndicatedLink($link_id);
693 - else :
694 - $updated_link = false;
695 - endif;
696 -
697 - $db_link = $link->link;
698 - $link_url = wp_specialchars($db_link->link_url, 1);
699 - $link_name = wp_specialchars($db_link->link_name, 1);
700 - $link_description = wp_specialchars($db_link->link_description, 'both');
701 - $link_rss_uri = wp_specialchars($db_link->link_rss, 'both');
702 -
703 - $post_status_global = get_option('feedwordpress_syndicated_post_status');
704 - $comment_status_global = get_option('feedwordpress_syndicated_comment_status');
705 - $ping_status_global = get_option('feedwordpress_syndicated_ping_status');
706 -
707 - $status['post'] = array('publish' => '', 'private' => '', 'draft' => '', 'site-default' => '');
708 - if (SyndicatedPost::use_api('post_status_pending')) :
709 - $status['post']['pending'] = '';
710 - endif;
711 -
712 - $status['comment'] = array('open' => '', 'closed' => '', 'site-default' => '');
713 - $status['ping'] = array('open' => '', 'closed' => '', 'site-default' => '');
714 -
715 - foreach (array('post', 'comment', 'ping') as $what) :
716 - if (isset($link->settings["{$what} status"])) :
717 - $status[$what][$link->settings["{$what} status"]] = ' checked="checked"';
718 - else :
719 - $status[$what]['site-default'] = ' checked="checked"';
720 - endif;
721 - endforeach;
722 -
723 - $unfamiliar['author'] = array ('create' => '','default' => '','filter' => '');
724 - $unfamiliar['category'] = array ('create'=>'','tag' => '','default'=>'','filter'=>'');
725 -
726 - foreach (array('author', 'category') as $what) :
727 - if (is_string($link->settings["unfamiliar {$what}"]) and
728 - array_key_exists($link->settings["unfamiliar {$what}"], $unfamiliar[$what])) :
729 - $key = $link->settings["unfamiliar {$what}"];
730 - else:
731 - $key = 'site-default';
732 - endif;
733 - $unfamiliar[$what][$key] = ' checked="checked"';
734 - endforeach;
735 -
736 - if (is_array($link->settings['cats'])) : $cats = $link->settings['cats'];
737 - else : $cats = array();
738 - endif;
739 -
740 - $dogs = SyndicatedPost::category_ids($cats, /*unfamiliar=*/ NULL);
741 - else :
742 - die( __('Link not found.') );
743 - endif;
744 -
745 - ?>
746 -<script type="text/javascript">
747 - function flip_hardcode (item) {
748 - ed=document.getElementById('basics-'+item+'-edit');
749 - view=document.getElementById('basics-'+item+'-view');
750 -
751 - o = document.getElementById('basics-hardcode-'+item);
752 - if (o.value=='yes') { ed.style.display='inline'; view.style.display='none'; }
753 - else { ed.style.display='none'; view.style.display='inline'; }
754 - }
755 - function flip_newuser (item) {
756 - rollup=document.getElementById(item);
757 - newuser=document.getElementById(item+'-newuser');
758 - sitewide=document.getElementById(item+'-default');
759 - if (rollup) {
760 - if ('newuser'==rollup.value) {
761 - if (newuser) newuser.style.display='block';
762 - if (sitewide) sitewide.style.display='none';
763 - } else if ('site-default'==rollup.value) {
764 - if (newuser) newuser.style.display='none';
765 - if (sitewide) sitewide.style.display='block';
766 - } else {
767 - if (newuser) newuser.style.display='none';
768 - if (sitewide) sitewide.style.display='none';
769 - }
770 - }
771 - }
772 -</script>
773 -
774 -<?php if ($updated_link) : ?>
775 -<div class="updated"><p>Syndicated feed settings updated.</p></div>
776 -<?php endif; ?>
777 -
778 -<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
779 -<div class="wrap">
780 -<input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
781 -<input type="hidden" name="action" value="linkedit" />
782 -<input type="hidden" name="save" value="link" />
783 -
784 -<h2>Edit a syndicated feed:</h2>
785 -<div id="poststuff">
786 -<?php fwp_linkedit_single_submit($status); ?>
787 -
788 -<div id="post-body">
789 -<?php fwp_option_box_opener('Feed Information', 'feedinformationdiv'); ?>
790 - <table class="editform" width="100%" cellspacing="2" cellpadding="5">
791 - <tr>
792 - <th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
793 - <td width="60%"><a href="<?php echo wp_specialchars($link_rss_uri, 'both'); ?>"><?php echo $link_rss_uri; ?></a>
794 - (<a href="<?php echo FEEDVALIDATOR_URI; ?>?url=<?php echo urlencode($link_rss_uri); ?>"
795 - title="Check feed &lt;<?php echo wp_specialchars($link_rss_uri, 'both'); ?>&gt; for validity">validate</a>)
796 - </td>
797 - <td width="20%"><input type="submit" name="feedfinder" value="switch &rarr;" style="font-size:smaller" /></td>
798 - </tr>
799 - <tr>
800 - <th scope="row" width="20%"><?php _e('Link Name:') ?></th>
801 - <td width="60%"><input type="text" id="basics-name-edit" name="name"
802 - value="<?php echo $link_name; ?>" style="width: 95%" />
803 - <span id="basics-name-view"><strong><?php echo $link_name; ?></strong></span>
804 - </td>
805 - <td>
806 - <select id="basics-hardcode-name" onchange="flip_hardcode('name')" name="hardcode_name">
807 - <option value="no" <?php echo $link->hardcode('name')?'':'selected="selected"'; ?>>update automatically</option>
808 - <option value="yes" <?php echo $link->hardcode('name')?'selected="selected"':''; ?>>edit manually</option>
809 - </select>
810 - </td>
811 - </tr>
812 - <tr>
813 - <th scope="row" width="20%"><?php _e('Short description:') ?></th>
814 - <td width="60%">
815 - <input id="basics-description-edit" type="text" name="description" value="<?php echo $link_description; ?>" style="width: 95%" />
816 - <span id="basics-description-view"><strong><?php echo $link_description; ?></strong></span>
817 - </td>
818 - <td>
819 - <select id="basics-hardcode-description" onchange="flip_hardcode('description')"
820 - name="hardcode_description">
821 - <option value="no" <?php echo $link->hardcode('description')?'':'selected="selected"'; ?>>update automatically</option>
822 - <option value="yes" <?php echo $link->hardcode('description')?'selected="selected"':''; ?>>edit manually</option>
823 - </select></td>
824 - </tr>
825 - <tr>
826 - <th width="20%" scope="row"><?php _e('Homepage:') ?></th>
827 - <td width="60%">
828 - <input id="basics-url-edit" type="text" name="linkurl" value="<?php echo $link_url; ?>" style="width: 95%;" />
829 - <a id="basics-url-view" href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td>
830 - <td>
831 - <select id="basics-hardcode-url" onchange="flip_hardcode('url')" name="hardcode_url">
832 - <option value="no"<?php echo $link->hardcode('url')?'':' selected="selected"'; ?>>update automatically</option>
833 - <option value="yes"<?php echo $link->hardcode('url')?' selected="selected"':''; ?>>edit manually</option>
834 - </select></td></tr>
835 -
836 - <tr>
837 - <th width="20%"><?php _e('Last update') ?>:</th>
838 - <td colspan="2"><?php
839 - if (isset($link->settings['update/last'])) :
840 - echo strftime('%x %X', $link->settings['update/last'])." ";
841 - else :
842 - echo " none yet";
843 - endif;
844 - ?></td></tr>
845 - <tr><th width="20%">Next update:</th>
846 - <td colspan="2"><?php
847 - $holdem = (isset($link->settings['update/hold']) ? $link->settings['update/hold'] : 'scheduled');
848 - ?>
849 - <select name="update_schedule">
850 - <option value="scheduled"<?php echo ($holdem=='scheduled')?' selected="selected"':''; ?>>update on schedule <?php
851 - echo " (";
852 - if (isset($link->settings['update/ttl']) and is_numeric($link->settings['update/ttl'])) :
853 - if (isset($link->settings['update/timed']) and $link->settings['update/timed']=='automatically') :
854 - echo 'next: ';
855 - $next = $link->settings['update/last'] + ((int) $link->settings['update/ttl'] * 60);
856 - if (strftime('%x', time()) != strftime('%x', $next)) :
857 - echo strftime('%x', $next)." ";
858 - endif;
859 - echo strftime('%X', $link->settings['update/last']+((int) $link->settings['update/ttl']*60));
860 - else :
861 - echo "every ".$link->settings['update/ttl']." minute".(($link->settings['update/ttl']!=1)?"s":"");
862 - endif;
863 - else:
864 - echo "next scheduled update";
865 - endif;
866 - echo ")";
867 - ?></option>
868 - <option value="next"<?php echo ($holdem=='next')?' selected="selected"':''; ?>>update ASAP</option>
869 - <option value="ping"<?php echo ($holdem=='ping')?' selected="selected"':''; ?>>update only when pinged</option>
870 - </select></tr>
871 - </table>
872 -<?php fwp_option_box_closer(); ?>
873 -
874 -<script type="text/javascript">
875 -flip_hardcode('name');
876 -flip_hardcode('description');
877 -flip_hardcode('url');
878 -</script>
879 -
880 -<?php fwp_linkedit_periodic_submit(); ?>
881 -
882 -<?php
883 -if (!(isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25)) :
884 - fwp_option_box_opener('Syndicated Posts', 'syndicatedpostsdiv', 'postbox');
885 -?>
886 -<table class="editform" width="75%" cellspacing="2" cellpadding="5">
887 -<tr><th width="27%" scope="row" style="vertical-align:top">Publication:</th>
888 -<td width="73%" style="vertical-align:top"><ul style="margin:0; list-style:none">
889 -<li><label><input type="radio" name="feed_post_status" value="site-default"
890 -<?php echo $status['post']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a>
891 -(currently: <strong><?php echo ($post_status_global ? $post_status_global : 'publish'); ?></strong>)</label></li>
892 -<li><label><input type="radio" name="feed_post_status" value="publish"
893 -<?php echo $status['post']['publish']; ?> /> Publish posts from this feed immediately</label></li>
894 -
895 -<?php if (SyndicatedPost::use_api('post_status_pending')) : ?>
896 -<li><label><input type="radio" name="feed_post_status" value="pending"
897 -<?php echo $status['post']['pending']; ?>/> Hold posts from this feed for review; mark as Pending</label></li>
898 -<?php endif; ?>
899 -
900 -<li><label><input type="radio" name="feed_post_status" value="draft"
901 -<?php echo $status['post']['draft']; ?> /> Save posts from this feed as drafts</label></li>
902 -<li><label><input type="radio" name="feed_post_status" value="private"
903 -<?php echo $status['post']['private']; ?> /> Save posts from this feed as private posts</label></li>
904 -</ul></td>
905 -</tr>
906 -</table>
907 -<?php
908 - fwp_option_box_closer();
909 - fwp_linkedit_periodic_submit();
910 -endif;
911 -
912 - fwp_option_box_opener(__('Categories'), 'categorydiv', 'postbox');
913 - fwp_category_box($dogs, 'all syndicated posts from this feed');
914 -?>
915 -<table>
916 -<tr>
917 -<th width="20%" scope="row" style="vertical-align:top">Unfamiliar categories:</th>
918 -<td width="80%"><p>When one of the categories on a syndicated post is a category that FeedWordPress has not encountered before ...</p>
919 -
920 -<ul style="margin: 0; list-style:none">
921 -<li><label><input type="radio" name="unfamiliar_category" value="site-default"<?php echo $unfamiliar['category']['site-default']; ?> /> use the site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a>
922 -(currently <strong><?php echo FeedWordPress::on_unfamiliar('category'); ?></strong>)</label></li>
923 -<li><label><input type="radio" name="unfamiliar_category" value="create"<?php echo $unfamiliar['category']['create']; ?> /> create a new category</label></li>
924 -<li><label><input type="radio" name="unfamiliar_category" value="tag"<?php echo $unfamiliar['category']['tag']; ?>/> create a new tag</label></li>
925 -<li><label><input type="radio" name="unfamiliar_category" value="default"<?php echo $unfamiliar['category']['default']; ?> /> don't create new categories or tags</label></li>
926 -<li><label><input type="radio" name="unfamiliar_category" value="filter"<?php echo $unfamiliar['category']['filter']; ?> /> don't create new categories or tags and don't syndicate posts unless they match at least one familiar category</label></li>
927 -</ul></td>
928 -</tr>
929 -
930 -<tr>
931 -<th width="20%" scope="row" style="vertical-align:top">Multiple categories:</th>
932 -<td width="80%">
933 -<input type="text" size="20" id="cat_split" name="cat_split" value="<?php if (isset($link->settings['cat_split'])) : echo htmlspecialchars($link->settings['cat_split']); endif; ?>" /><br/>
934 -Enter a <a href="http://us.php.net/manual/en/reference.pcre.pattern.syntax.php">Perl-compatible regular expression</a> here if the feed provides multiple
935 -categories in a single category element. The regular expression should match
936 -the characters used to separate one category from the next. If the feed uses
937 -spaces (like <a href="http://del.icio.us/">del.icio.us</a>), use the pattern "\s".
938 -If the feed does not provide multiple categories in a single element, leave this
939 -blank.</td>
940 -</tr>
941 -</table>
942 -<?php
943 - fwp_option_box_closer();
944 - fwp_linkedit_periodic_submit();
945 -
946 -if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) :
947 - fwp_tags_box($link->settings['tags']);
948 - fwp_linkedit_periodic_submit();
949 -endif; ?>
950 -
951 -<?php fwp_option_box_opener('Syndicated Authors', 'authordiv', 'postbox'); ?>
952 -<?php $authorlist = fwp_author_list(); ?>
953 -<table>
954 -<tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">For posts by authors that haven't been syndicated before:</th></tr>
955 -<tr>
956 - <th style="text-align: left">Posts by new authors</th>
957 - <td>
958 - <select id="unfamiliar-author" name="unfamiliar_author" onchange="flip_newuser('unfamiliar-author');">
959 - <option value="site-default"<?php if (!isset($link->settings['unfamiliar author'])) : ?>selected="selected"<?php endif; ?>>are handled using site-wide settings</option>
960 - <option value="create"<?php if ('create'==$link->settings['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>create a new author account</option>
961 - <?php foreach ($authorlist as $author_id => $author_name) : ?>
962 - <option value="<?php echo $author_id; ?>"<?php if ($author_id==$link->settings['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>are assigned to <?php echo $author_name; ?></option>
963 - <?php endforeach; ?>
964 - <option value="newuser">will be assigned to a new user...</option>
965 - <option value="filter"<?php if ('filter'==$link->settings['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>get filtered out</option>
966 - </select>
967 - </td>
968 - <td>
969 - <div id="unfamiliar-author-default">Site-wide settings can be set in <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a></div>
970 - <div id="unfamiliar-author-newuser">named <input type="text" name="unfamiliar_author_newuser" value="" /></div>
971 - </td>
972 -</tr>
973 -
974 -<tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">For posts by specific authors. Blank out a name to delete the rule.</th></tr>
975 -
976 -<?php if (isset($link->settings['map authors'])) : $i=0; foreach ($link->settings['map authors'] as $author_rules) : foreach ($author_rules as $author_name => $author_action) : $i++; ?>
977 -<tr>
978 - <th style="text-align: left">Posts by <input type="text" name="author_rules_name[]" value="<?php echo htmlspecialchars($author_name); ?>" /></th>
979 - <td>
980 - <select id="author-rules-<?php echo $i; ?>" name="author_rules_action[]" onchange="flip_newuser('author-rules-<?php echo $i; ?>');">
981 - <?php foreach ($authorlist as $local_author_id => $local_author_name) : ?>
982 - <option value="<?php echo $local_author_id; ?>"<?php if ($local_author_id==$author_action) : echo ' selected="selected"'; endif; ?>>are assigned to <?php echo $local_author_name; ?></option>
983 - <?php endforeach; ?>
984 - <option value="newuser">will be assigned to a new user...</option>
985 - <option value="filter"<?php if ('filter'==$author_action) : echo ' selected="selected"'; endif; ?>>get filtered out</option>
986 - </select>
987 - </td>
988 - <td><div id="author-rules-<?php echo $i; ?>-newuser">named <input type="text" name="author_rules_newuser[]" value="" /></div></td>
989 -</tr>
990 -<?php endforeach; endforeach; endif; ?>
991 -
992 -<tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">Fill in to set up a new rule:</th></tr>
993 -
994 -<tr>
995 - <th style="text-align: left">Posts by <input type="text" name="add_author_rule_name" /></th>
996 - <td>
997 - <select id="add-author-rule" name="add_author_rule_action" onchange="flip_newuser('add-author-rule');">
998 - <?php foreach ($authorlist as $author_id => $author_name) : ?>
999 - <option value="<?php echo $author_id; ?>">are assigned to <?php echo $author_name; ?></option>
1000 - <?php endforeach; ?>
1001 - <option value="newuser">will be assigned to a new user...</option>
1002 - <option value="filter">get filtered out</option>
1003 - </select>
1004 - </td>
1005 - <td><div id="add-author-rule-newuser">named <input type="text" name="add_author_rule_newuser" value="" /></div></td>
1006 -</tr>
1007 -
1008 -</table>
1009 -<?php fwp_option_box_closer(); ?>
1010 -
1011 -<script>
1012 - flip_newuser('unfamiliar-author');
1013 -<?php for ($j=1; $j<=$i; $j++) : ?>
1014 - flip_newuser('author-rules-<?php echo $j; ?>');
1015 -<?php endfor; ?>
1016 - flip_newuser('add-author-rule');
1017 -</script>
1018 -
1019 -<?php
1020 - fwp_linkedit_periodic_submit();
1021 - fwp_option_box_opener('Comments & Pings', 'commentstatusdiv', 'postbox');
1022 -?>
1023 -<table class="editform" width="75%" cellspacing="2" cellpadding="5">
1024 -<tr><th width="27%" scope="row" style="vertical-align:top"><?php print __('Comments'); ?>:</th>
1025 -<td width="73%"><ul style="margin:0; list-style:none">
1026 -<li><label><input type="radio" name="feed_comment_status" value="site-default"
1027 -<?php echo $status['comment']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a>
1028 -(currently: <strong><?php echo ($comment_status_global ? $comment_status_global : 'closed'); ?>)</strong></label></li>
1029 -<li><label><input type="radio" name="feed_comment_status" value="open"
1030 -<?php echo $status['comment']['open']; ?> /> Allow comments on syndicated posts from this feed</label></li>
1031 -<li><label><input type="radio" name="feed_comment_status" value="closed"
1032 -<?php echo $status['comment']['closed']; ?> /> Don't allow comments on syndicated posts from this feed</label></li>
1033 -</ul></td></tr>
1034 -
1035 -<tr><th width="27%" scope="row" style="vertical-align:top"><?php print __('Pings'); ?>:</th>
1036 -<td width="73%"><ul style="margin:0; list-style:none">
1037 -<li><label><input type="radio" name="feed_ping_status" value="site-default"
1038 -<?php echo $status['ping']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a>
1039 -(currently: <strong><?php echo ($ping_status_global ? $ping_status_global : 'closed'); ?>)</strong></label></li>
1040 -<li><label><input type="radio" name="feed_ping_status" value="open"
1041 -<?php echo $status['ping']['open']; ?> /> Accept pings on syndicated posts from this feed</label></li>
1042 -<li><label><input type="radio" name="feed_ping_status" value="closed"
1043 -<?php echo $status['ping']['closed']; ?> /> Don't accept pings on syndicated posts from this feed</label></li>
1044 -</ul></td></tr>
1045 -
1046 -</table>
1047 -<?php fwp_option_box_closer(); ?>
1048 -<?php fwp_linkedit_periodic_submit(); ?>
1049 -
1050 -<?php fwp_option_box_opener('Custom Settings (for use in templates)', 'postcustom', 'postbox'); ?>
1051 -<div id="postcustomstuff">
1052 -<table id="meta-list" cellpadding="3">
1053 - <tr>
1054 - <th>Key</th>
1055 - <th>Value</th>
1056 - <th>Action</th>
1057 - </tr>
1058 -
1059 -<?php
1060 - $i = 0;
1061 - foreach ($link->settings as $key => $value) :
1062 - if (!preg_match("\007^((".implode(')|(', $special_settings)."))$\007i", $key)) :
1063 -?>
1064 - <tr style="vertical-align:top">
1065 - <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo wp_specialchars($key, 'both'); ?>" />
1066 - <input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo wp_specialchars($key, 'both'); ?>" /></th>
1067 - <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>
1068 - <td width="10%"><select name="notes[<?php echo $i; ?>][action]">
1069 - <option value="update">save changes</option>
1070 - <option value="delete">delete this setting</option>
1071 - </select></td>
1072 - </tr>
1073 -<?php
1074 - $i++;
1075 - endif;
1076 - endforeach;
1077 -?>
1078 - <tr>
1079 - <th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th>
1080 - <td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea></td>
1081 - <td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td>
1082 - </tr>
1083 -</table>
1084 -<?php fwp_option_box_closer(); ?>
1085 -
1086 -<?php fwp_linkedit_periodic_submit(); ?>
1087 -</div> <!-- id="post-body" -->
1088 -</div> <!-- id="poststuff" -->
1089 -</div>
1090 - <?php
1091 - endif;
1092 - return false; // Don't continue
1093 -}
1094 -
1095 -function fwp_multidelete_page () {
1096 - global $wpdb;
1097 -
1098 - check_admin_referer(); // Make sure the referers are kosher
1099 -
1100 - $link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array());
1101 - if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif;
1102 -
1103 - if (!current_user_can('manage_links')):
1104 - die (__("Cheatin' uh ?"));
1105 - elseif (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'):
1106 - foreach ($GLOBALS['fwp_post']['link_action'] as $link_id => $what) :
1107 - $do_it[$what][] = $link_id;
1108 - endforeach;
1109 -
1110 - $alter = array();
1111 - if (count($do_it['hide']) > 0) :
1112 - $hidem = "(".implode(', ', $do_it['hide']).")";
1113 - $alter[] = "
1114 - UPDATE $wpdb->links
1115 - SET link_visible = 'N'
1116 - WHERE link_id IN {$hidem}
1117 - ";
1118 - endif;
1119 -
1120 - if (count($do_it['nuke']) > 0) :
1121 - $nukem = "(".implode(', ', $do_it['nuke']).")";
1122 -
1123 - // Make a list of the items syndicated from this feed...
1124 - $post_ids = $wpdb->get_col("
1125 - SELECT post_id FROM $wpdb->postmeta
1126 - WHERE meta_key = 'syndication_feed_id'
1127 - AND meta_value IN {$nukem}
1128 - ");
1129 -
1130 - // ... and kill them all
1131 - if (count($post_ids) > 0) :
1132 - foreach ($post_ids as $post_id) :
1133 - wp_delete_post($post_id);
1134 - endforeach;
1135 - endif;
1136 -
1137 - $alter[] = "
1138 - DELETE FROM $wpdb->links
1139 - WHERE link_id IN {$nukem}
1140 - ";
1141 - endif;
1142 -
1143 - if (count($do_it['delete']) > 0) :
1144 - $deletem = "(".implode(', ', $do_it['delete']).")";
1145 -
1146 - // Make the items syndicated from this feed appear to be locally-authored
1147 - $alter[] = "
1148 - DELETE FROM $wpdb->postmeta
1149 - WHERE meta_key = 'syndication_feed_id'
1150 - AND meta_value IN {$deletem}
1151 - ";
1152 -
1153 - // ... and delete the links themselves.
1154 - $alter[] = "
1155 - DELETE FROM $wpdb->links
1156 - WHERE link_id IN {$deletem}
1157 - ";
1158 - endif;
1159 -
1160 - $errs = array(); $success = array ();
1161 - foreach ($alter as $sql) :
1162 - $result = $wpdb->query($sql);
1163 - if (!$result):
1164 - $errs[] = mysql_error();
1165 - endif;
1166 - endforeach;
1167 -
1168 - if (count($alter) > 0) :
1169 - echo "<div class=\"updated\">\n";
1170 - if (count($errs) > 0) :
1171 - echo "There were some problems processing your ";
1172 - echo "unsubscribe request. [SQL: ".implode('; ', $errs)."]";
1173 - else :
1174 - echo "Your unsubscribe request(s) have been processed.";
1175 - endif;
1176 - echo "</div>\n";
1177 - endif;
1178 -
1179 - return true; // Continue on to Syndicated Sites listing
1180 - else :
1181 - $targets = $wpdb->get_results("
1182 - SELECT * FROM $wpdb->links
1183 - WHERE link_id IN (".implode(",",$link_ids).")
1184 - ");
1185 -?>
1186 -<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
1187 -<div class="wrap">
1188 -<input type="hidden" name="action" value="Unsubscribe" />
1189 -<input type="hidden" name="confirm" value="Delete" />
1190 -
1191 -<h2>Unsubscribe from Syndicated Links:</h2>
1192 -<?php foreach ($targets as $link) :
1193 - $link_url = wp_specialchars($link->link_url, 1);
1194 - $link_name = wp_specialchars($link->link_name, 1);
1195 - $link_description = wp_specialchars($link->link_description, 'both');
1196 - $link_rss = wp_specialchars($link->link_rss, 'both');
1197 -?>
1198 -<fieldset>
1199 -<legend><?php echo $link_name; ?></legend>
1200 -<table class="editform" width="100%" cellspacing="2" cellpadding="5">
1201 -<tr><th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
1202 -<td width="80%"><a href="<?php echo $link_rss; ?>"><?php echo $link_rss; ?></a></td></tr>
1203 -<tr><th scope="row" width="20%"><?php _e('Short description:') ?></th>
1204 -<td width="80%"><?php echo $link_description; ?></span></td></tr>
1205 -<tr><th width="20%" scope="row"><?php _e('Homepage:') ?></th>
1206 -<td width="80%"><a href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td></tr>
1207 -<tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options') ?>:</th>
1208 -<td width="80%"><ul style="margin:0; padding: 0; list-style: none">
1209 -<li><input type="radio" id="hide-<?php echo $link->link_id; ?>"
1210 -name="link_action[<?php echo $link->link_id; ?>]" value="hide" />
1211 -<label for="hide-<?php echo $link->link_id; ?>">Turn off the subscription for this
1212 -syndicated link<br/><span style="font-size:smaller">(Keep the feed information
1213 -and all the posts from this feed in the database, but don't syndicate any
1214 -new posts from the feed.)</span></label></li>
1215 -<li><input type="radio" id="nuke-<?php echo $link->link_id; ?>"
1216 -name="link_action[<?php echo $link->link_id; ?>]" value="nuke" />
1217 -<label for="nuke-<?php echo $link->link_id; ?>">Delete this syndicated link and all the
1218 -posts that were syndicated from it</label></li>
1219 -<li><input type="radio" id="delete-<?php echo $link->link_id; ?>"
1220 -name="link_action[<?php echo $link->link_id; ?>]" value="delete" />
1221 -<label for="delete-<?php echo $link->link_id; ?>">Delete this syndicated link, but
1222 -<em>keep</em> posts that were syndicated from it (as if they were authored
1223 -locally).</label></li>
1224 -<li><input type="radio" id="nothing-<?php echo $link->link_id; ?>"
1225 -name="link_action[<?php echo $link->link_id; ?>]" value="nothing" />
1226 -<label for="nothing-<?php echo $link->link_id; ?>">Keep this feed as it is. I changed
1227 -my mind.</label></li>
1228 -</ul>
1229 -</table>
1230 -</fieldset>
1231 -<?php endforeach; ?>
1232 -
1233 -<div class="submit">
1234 -<input class="delete" type="submit" name="submit" value="<?php _e('Unsubscribe from selected feeds &raquo;') ?>" />
1235 -</div>
1236 -</div>
1237 -<?php
1238 - return false; // Don't continue on to Syndicated Sites listing
1239 - endif;
1240 -}
1241 -
1242 - fwp_syndication_manage_page();
1243 -
4 + $syndicationPage = new FeedWordPressSyndicationPage( __FILE__ );
5 + $syndicationPage->display();