|
|
<?php
|
|
|
/******************************
|
|
|
* This script dependent on *
|
|
|
* XML_Feed_Parser PEAR module *
|
|
|
******************************/
|
|
|
|
|
|
require_once('include/admin.inc.php');
|
|
|
require_once("PEAR.php");
|
|
|
require_once("XML/Feed/Parser.php");
|
|
|
|
|
|
// Workaround since DreamHost disables allow_url_fopen
|
|
|
$ch = curl_init();
|
|
|
$timeout = 5; // set to zero for no timeout
|
|
|
curl_setopt ($ch, CURLOPT_URL, FEED_URL);
|
|
|
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
|
|
|
$feed_src = curl_exec($ch);
|
|
|
curl_close($ch);
|
|
|
|
|
|
// Use if allow_url_fopen not disabled
|
|
|
// $feed_src = file_get_contents(FEED_URL);
|
|
|
|
|
|
$feed = new XML_Feed_Parser($feed_src);
|
|
|
|
|
|
for ($count = 0; $count < 5; $count++) {
|
|
|
$entry = $feed->getEntryByOffset($count);
|
|
|
|
|
|
$dbConnection->executeUpdate('INSERT INTO fredart (pubdate, title, link) VALUES (FROM_UNIXTIME(?), ?, ?)', array($entry->pubdate, $entry->title, $entry->link));
|
|
|
}
|
|
|
|
|
|
header('Content-Type: text/xml');
|
|
|
header('Content-Length: 440');
|
|
|
?>
|
|
|
<?php echo "<?xml version=\"1.0\" ?>\n"; ?>
|
|
|
<methodResponse>
|
|
|
<params>
|
|
|
<param>
|
|
|
<value>
|
|
|
<struct>
|
|
|
<member>
|
|
|
<name>flerror</name>
|
|
|
<value>
|
|
|
<boolean>0</boolean>
|
|
|
</value>
|
|
|
</member>
|
|
|
<member>
|
|
|
<name>message</name>
|
|
|
<value>Thanks for the ping.</value>
|
|
|
</member>
|
|
|
</struct>
|
|
|
</value>
|
|
|
</param>
|
|
|
</params>
|
|
|
</methodResponse>
|
|
|
|