rendered paste body function autodiscovery_all($local_only = true)
{
$feeds = array();
// Is file already a feed ?
if ($this->is_feed($this->file))
{
$feeds[] = $this->file->url;
return $feeds;
}
// Search for feeds in <link> elements
$links = SimplePie_Misc::get_element('link', $this->file->body());
$done = array();
foreach ($links as $link)
{
if (!empty($link['attribs']['TYPE']['data']) && !empty($link['attribs']['HREF']['data']))
{
$type = strtolower(trim($link['attribs']['TYPE']['data']));
$href = SimplePie_Misc::absolutize_url(trim($link['attribs']['HREF']['data']), $this->file->url);
if (!in_array($href, $done) && in_array($type, array('application/rss+xml', 'application/atom+xml', 'application/rdf+xml', 'application/xml+rss', 'application/xml+atom', 'application/xml+rdf', 'application/xml', 'application/x.atom+xml', 'text/xml')))
{
$feed = $this->is_feed($href);
if ($feed)
{
$feeds[] = $href;
}
}
$done[] = $href;
}
}
// Find links to feeds in <body>
$this->useragent = $this->file->useragent;
if ($this->get_links($this->file))
{
if (!empty($this->local))
{
foreach ($this->local as $key => $value)
{
$value = SimplePie_Misc::absolutize_url($value, $this->file->url);
if (in_array(strrchr($value, '.'), array('.rss', '.rdf', '.atom', '.xml')))
{
if ($this->is_feed($value))
{
$feeds[] = $value;
}
else
{
unset($array[$key]);
}
}
}
foreach ($this->local as $key => $value)
{
$value = SimplePie_Misc::absolutize_url($value, $this->file->url);
if (preg_match('/(rss|rdf|atom|xml)/i', $value))
{
if ($this->is_feed($value))
{
$feeds[] = $value;
}
else
{
unset($array[$key]);
}
}
}
}
if (!empty($this->elsewhere) && $local_only == false)
{
foreach ($this->elsewhere as $key => $value)
{
$value = SimplePie_Misc::absolutize_url($value, $this->file->url);
if (in_array(strrchr($value, '.'), array('.rss', '.rdf', '.atom', '.xml')))
{
if ($this->is_feed($value))
{
$feeds[] = $value;
}
else
{
unset($array[$key]);
}
}
}
foreach ($this->elsewhere as $key => $value)
{
$value = SimplePie_Misc::absolutize_url($value, $this->file->url);
if (preg_match('/(rss|rdf|atom|xml)/i', $value))
{
if ($this->is_feed($value))
{
$feeds[] = $value;
}
else
{
unset($array[$key]);
}
}
}
}
}
if(!empty($feeds)) return array_unique($feeds);
else return false;
}