Quote:
Originally Posted by liljimmy
Anybody have any luck fixing the "Syndicated content not available" message after installing this hack? Like a previous poster mentioned, my host is Dreamhost.
|
I was able to get this fixed. The reason it was breaking is that many hosting providers have disabled fopen. As mentioned in a previous post in this thread the fopen calls needed to be replaced with cURL. I did a little research to figure out what needed to be done.
You need to edit the includes/xmlparser.php file and replace the render_news function with the code below:
New function (use this):
PHP Code:
function render_news($feed_url, $showdetail, $headlinestyle, $detailstyle) {
global $show_detail, $headline_style, $detail_style, $max, $count, $insideitem, $insideimage, $code2;
$insideitem=false;
$insideimage=false;
$count = 0;
$show_detail = $showdetail;
$headline_style = $headlinestyle;
$detail_style = $detailstyle;
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $feed_url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
$xml = curl_exec ($ch);
curl_close ($ch);
if (!xml_parse($xml_parser, $xml, True))
{
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
// Free up memory used by the XML parser
xml_parser_free($xml_parser);
}
Old function (for comparison):
PHP Code:
function render_news($feed_url, $showdetail, $headlinestyle, $detailstyle) {
global $show_detail, $headline_style, $detail_style, $max, $count, $insideitem, $insideimage, $code2;
$insideitem=false;
$insideimage=false;
$count = 0;
$show_detail = $showdetail;
$headline_style = $headlinestyle;
$detail_style = $detailstyle;
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = @fopen($feed_url,"r");
// or die("Error reading RSS data.");
if ($fp) {
while ($data = fread($fp, 4096))
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
fclose($fp);
} else {
$code2 .= "<span class=\"". $detail_style ."\">Syndicated content not available</span>";
}
// Free up memory used by the XML parser
xml_parser_free($xml_parser);
}