Added fallback if allow_url_fopen is off
This commit is contained in:
13
lib/ajax.php
13
lib/ajax.php
@@ -26,11 +26,22 @@ if(isset($_POST['action'])) {
|
||||
}
|
||||
|
||||
if ($action == "newsfeed") {
|
||||
$feed = "http://forum.froxlor.org/index.php/rss/forums/1-froxlor-announcements/";
|
||||
|
||||
if (function_exists("simplexml_load_file") == false) {
|
||||
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) {
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
|
||||
Reference in New Issue
Block a user