Added fallback if allow_url_fopen is off

This commit is contained in:
BNoiZe
2013-11-20 18:16:24 +01:00
parent 254672f2dd
commit 37e6158b57

View File

@@ -26,11 +26,22 @@ if(isset($_POST['action'])) {
} }
if ($action == "newsfeed") { if ($action == "newsfeed") {
$feed = "http://forum.froxlor.org/index.php/rss/forums/1-froxlor-announcements/";
if (function_exists("simplexml_load_file") == false) { if (function_exists("simplexml_load_file") == false) {
die(); die();
} }
$news = simplexml_load_file('http://froxlor.org/feed.rss.php', null, LIBXML_NOCDATA); if (ini_get('allow_url_fopen')) {
$news = simplexml_load_file($feed, null, LIBXML_NOCDATA);
} else {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $feed);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$news = simplexml_load_file(trim($output));
}
if ($news !== false) { if ($news !== false) {
for ($i = 0; $i < 3; $i++) { for ($i = 0; $i < 3; $i++) {