/**
* Get a specific RSS feed
*
* @param $url string/array URL of the feed or array of URL
* @param $cache_duration timestamp cache duration (default DAY_TIMESTAMP)
*
* @return feed object
**/
static function getRSSFeed($url, $cache_duration = DAY_TIMESTAMP)
{
global $CFG_GLPI;
$feed = new SimplePie();
$feed->set_cache_location(GLPI_RSS_DIR);
$feed->set_cache_duration($cache_duration);
// proxy support
if (!empty($CFG_GLPI["proxy_name"])) {
$prx_opt = array();
$prx_opt[CURLOPT_PROXY] = $CFG_GLPI["proxy_name"];
$prx_opt[CURLOPT_PROXYPORT] = $CFG_GLPI["proxy_port"];
if (!empty($CFG_GLPI["proxy_user"])) {
$prx_opt[CURLOPT_HTTPAUTH] = CURLAUTH_ANYSAFE;
$prx_opt[CURLOPT_PROXYUSERPWD] = $CFG_GLPI["proxy_user"] . ":" . Toolbox::decrypt($CFG_GLPI["proxy_passwd"], GLPIKEY);
}
$feed->set_curl_options($prx_opt);
}
$feed->enable_cache(true);
$feed->set_feed_url($url);
$feed->force_feed(true);
// Initialize the whole SimplePie object. Read the feed, process it, parse it, cache it, and
// all that other good stuff. The feed's information will not be available to SimplePie before
// this is called.
$feed->init();
// We'll make sure that the right content type and character encoding gets set automatically.
// This function will grab the proper character encoding, as well as set the content type to text/html.
$feed->handle_content_type();
if ($feed->error()) {
return false;
}
return $feed;
}