From ce1608ab2c44c3569a30e248968d75d75e43f72f Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Fri, 6 Dec 2013 09:44:57 +0100 Subject: [PATCH] set long-lasting url for news-feed (and switch to inside.froxlor.org, which will be used more often in the future to provide up-to-date content in froxlor) and prefer connection via cURL to pass a custom-useragent for possible version depended news later Signed-off-by: Michael Kaufmann (d00p) --- lib/ajax.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/ajax.php b/lib/ajax.php index e701b955..39c962e0 100644 --- a/lib/ajax.php +++ b/lib/ajax.php @@ -15,7 +15,7 @@ * @package AJAX * */ - + if(isset($_POST['action'])) { $action = $_POST['action']; } elseif(isset($_GET['action'])) { @@ -25,22 +25,25 @@ if(isset($_POST['action'])) { } if ($action == "newsfeed") { - $feed = "http://forum.froxlor.org/index.php/rss/forums/1-froxlor-announcements/"; + $feed = "http://inside.froxlor.org/news/"; if (function_exists("simplexml_load_file") == false) { die(); } - if (ini_get('allow_url_fopen')) { - $news = simplexml_load_file($feed, null, LIBXML_NOCDATA); + if (function_exists('curl_version')) { + // get version + require './tables.inc.php'; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $feed); + curl_setopt($ch, CURLOPT_USERAGENT, 'Froxlor/'.$version); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $output = curl_exec($ch); + curl_close($ch); + $news = simplexml_load_string(trim($output)); } else { - if (function_exists('curl_version')) { - $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_string(trim($output)); + if (ini_get('allow_url_fopen')) { + $news = simplexml_load_file($feed, null, LIBXML_NOCDATA); } else { $news = false; }