| 1 |
<?php |
| 2 |
# update-feeds.php: Instruct FeedWordPress to scan for fresh content |
| 3 |
# |
| 4 |
# Project: FeedWordPress |
| 5 |
# URI: <http://projects.radgeek.com/feedwordpress> |
| 6 |
# Author: Charles Johnson <technophilia@radgeek.com> |
| 7 |
# License: GPL |
| 8 |
# Version: 0.8 |
| 9 |
# Last modified: 2005-03-21 |
| 10 |
# |
| 11 |
# USAGE |
| 12 |
# ----- |
| 13 |
# update-feeds.php is a useful script for instructing the FeedWordPress plugin |
| 14 |
# to scan for fresh content on the feeds that it syndicates. This is handy if |
| 15 |
# you want your syndication site to actually syndicate content, and you can't |
| 16 |
# rely on all your contributors to send you an XML-RPC ping when they update. |
| 17 |
# |
| 18 |
# 1. Install FeedWordPress and activate the FeedWordPress plugin. (See |
| 19 |
# <http://projects.radgeek.com/feedwordpress/install> if you need a guide |
| 20 |
# for the perplexed.) |
| 21 |
# |
| 22 |
# 2. Set up a cron job to run update-feeds.php locally: |
| 23 |
# |
| 24 |
# cd <your-wordpress>/wp-content ; php update-feeds.php |
| 25 |
# |
| 26 |
# or to send an HTTP GET request to the appropriate URI: |
| 27 |
# |
| 28 |
# curl http://xyz.com/wp-content/update-feeds.php?shibboleth=foo |
| 29 |
# |
| 30 |
# 4. If you want to update *one* of the feeds rather than *all* of them, then |
| 31 |
# pass the URI and title as command-line arguments: |
| 32 |
# |
| 33 |
# $ php update-feeds.php http://www.radgeek.com "Geekery Today" |
| 34 |
# |
| 35 |
# or in the GET query: |
| 36 |
# |
| 37 |
# $ curl http://www.xyz.com/wp-content/update-feeds.php?uri=http://www.radgeek.com\&title=Geekery+Today\&shibboleth=yourshibboleth |
| 38 |
# |
| 39 |
|
| 40 |
require_once ('../wp-config.php'); |
| 41 |
require_once (ABSPATH . WPINC . '/class-IXR.php'); |
| 42 |
|
| 43 |
# -- CHANGE THESE TO REFLECT YOUR SITE SETTINGS! |
| 44 |
define ('RPC_URI', NULL); // Change this setting to ping a URI of your own devising |
| 45 |
|
| 46 |
# -- Don't change these unless you know what you're doing... |
| 47 |
define ('RPC_MAGIC', 'tag:radgeek.com/projects/feedwordpress/'); // update all |
| 48 |
|
| 49 |
if (is_null(RPC_URI)): |
| 50 |
$rpc_uri = get_settings('siteurl'); |
| 51 |
if (substr($rpc_uri,-1)!='/') $rpc_uri .= '/'; |
| 52 |
$rpc_uri .= 'xmlrpc.php'; |
| 53 |
else: |
| 54 |
$rpc_uri = RPC_URI; |
| 55 |
endif; |
| 56 |
|
| 57 |
# -- Are we running from an HTTP GET or from the command line? |
| 58 |
if (isset($_SERVER['REQUEST_URI'])) { |
| 59 |
$rpc_secret = (isset($_REQUEST['shibboleth'])?$_REQUEST['shibboleth']:''); |
| 60 |
$uri = (isset($_REQUEST['uri']) ? $_REQUEST['uri'] : RPC_MAGIC.$rpc_secret); |
| 61 |
$blog = (isset($_REQUEST['title']) ? $_REQUEST['title'] : 'Refresh'); |
| 62 |
|
| 63 |
echo <<< EOHTML |
| 64 |
<html> |
| 65 |
<head> |
| 66 |
<title>update-feeds :: FeedWordPress</title> |
| 67 |
</head> |
| 68 |
|
| 69 |
<body> |
| 70 |
<h1>update-feeds: instruct FeedWordPress to look for new syndicated content</h1> |
| 71 |
|
| 72 |
<p>Sending ping to <$rpc_uri>...</p> |
| 73 |
|
| 74 |
<p> |
| 75 |
EOHTML; |
| 76 |
} else { |
| 77 |
// Query secret word from database |
| 78 |
$rpc_secret = get_settings('feedwordpress_rpc_secret'); |
| 79 |
|
| 80 |
$uri = (isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : RPC_MAGIC.$rpc_secret); |
| 81 |
$blog = (isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2] : 'Refresh'); |
| 82 |
} |
| 83 |
|
| 84 |
$client =& new IXR_Client($rpc_uri); |
| 85 |
$ret = $client->query('weblogUpdates.ping', $blog, $uri); |
| 86 |
|
| 87 |
if (!$ret): |
| 88 |
if (!isset($_SERVER['REQUEST_URI'])) echo "[".date('Y-m-d H:i:s')."][update-feeds] "; |
| 89 |
echo "The XML-RPC ping failed (local): ".wp_specialchars($client->getErrorMessage())."\n"; |
| 90 |
else: |
| 91 |
$response = $client->getResponse(); |
| 92 |
if ($response['flerror']): |
| 93 |
if (!isset($_SERVER['REQUEST_URI'])) echo "[".date('Y-m-d H:i:s')."][update-feeds] "; |
| 94 |
echo "The XML-RPC ping failed (remote): ".wp_specialchars($response['message'])."\n"; |
| 95 |
elseif (isset($_SERVER['REQUEST_URI'])): |
| 96 |
if (!isset($_SERVER['REQUEST_URI'])) echo "[".date('Y-m-d H:i:s')."][update-feeds] "; |
| 97 |
echo "The XML-RPC ping succeeded: ".wp_specialchars($response['message'])."\n"; |
| 98 |
endif; |
| 99 |
endif; |
| 100 |
|
| 101 |
if (isset($_SERVER['REQUEST_URI'])) { |
| 102 |
echo <<<EOHTML |
| 103 |
</p> |
| 104 |
|
| 105 |
<p><a href="../wp-admin">← Return to WordPress Dashboard</a></p> |
| 106 |
</body> |
| 107 |
</html> |
| 108 |
EOHTML; |
| 109 |
} |
| 110 |
?> |
| 111 |
|