Zeile 34 | Zeile 34 |
---|
/** * Parses a feed with the specified filename (or URL) *
|
/** * Parses a feed with the specified filename (or URL) *
|
* @param string The path or URL of the feed
| * @param string $feed The path or URL of the feed
|
* @return boolean True if parsing was a success, false if failure */ function parse_feed($feed) {
|
* @return boolean True if parsing was a success, false if failure */ function parse_feed($feed) {
|
// Include the XML parser require_once MYBB_ROOT."inc/class_xml.php";
| |
// Load the feed we want to parse $contents = fetch_remote_file($feed);
| // Load the feed we want to parse $contents = fetch_remote_file($feed);
|
Zeile 65 | Zeile 62 |
---|
}
// Parse the feed and get the tree
|
}
// Parse the feed and get the tree
|
$parser = new XMLParser($contents);
| $parser = create_xml_parser($contents);
|
$tree = $parser->get_tree();
// If the feed is invalid, throw back an error
| $tree = $parser->get_tree();
// If the feed is invalid, throw back an error
|
Zeile 76 | Zeile 73 |
---|
}
// Change array key names to lower case
|
}
// Change array key names to lower case
|
$tree = $this->keys_to_lowercase($tree);
| $tree = $this->keys_to_lowercase($tree);
|
// This is an RSS feed, parse it if(array_key_exists("rss", $tree)) { $this->parse_rss($tree['rss']);
|
// This is an RSS feed, parse it if(array_key_exists("rss", $tree)) { $this->parse_rss($tree['rss']);
|
}
| }
|
// We don't know how to parse this feed else { $this->error = "unknown_feed_type"; return false; }
|
// We don't know how to parse this feed else { $this->error = "unknown_feed_type"; return false; }
|
| return true;
|
}
/** * Parses an XML structure in the format of an RSS feed *
|
}
/** * Parses an XML structure in the format of an RSS feed *
|
* @param array PHP XML parser structure
| * @param array $feed_contents PHP XML parser structure
|
* @return boolean true */ function parse_rss($feed_contents)
| * @return boolean true */ function parse_rss($feed_contents)
|
Zeile 196 | Zeile 195 |
---|
/** * Convert all array keys within an array to lowercase *
|
/** * Convert all array keys within an array to lowercase *
|
* @param array The array to be converted
| * @param array $array The array to be converted
|
* @return array The converted array */ function keys_to_lowercase($array)
| * @return array The converted array */ function keys_to_lowercase($array)
|
Zeile 220 | Zeile 219 |
---|
/** * Converts an RSS date stamp in to a unix timestamp *
|
/** * Converts an RSS date stamp in to a unix timestamp *
|
* @param string The RSS date
| * @param string $date The RSS date
|
* @return integer The unix timestamp (if successful), 0 if unsuccessful */ function get_rss_timestamp($date)
| * @return integer The unix timestamp (if successful), 0 if unsuccessful */ function get_rss_timestamp($date)
|