2013-11-15 21:11:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This file is part of the Froxlor project.
|
2013-11-28 09:58:37 +00:00
|
|
|
* Copyright (c) 2013 the Froxlor Team (see authors).
|
2013-11-15 21:11:25 +00:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the COPYING
|
|
|
|
* file that was distributed with this source code. You can also view the
|
|
|
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
|
|
|
*
|
|
|
|
* @copyright (c) the authors
|
|
|
|
* @author Roman Schmerold <bnoize@froxlor.org>
|
|
|
|
* @author Froxlor team <team@froxlor.org> (2010-)
|
|
|
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
|
|
|
* @package AJAX
|
|
|
|
*
|
|
|
|
*/
|
2013-12-06 08:44:57 +00:00
|
|
|
|
2013-11-15 21:11:25 +00:00
|
|
|
if(isset($_POST['action'])) {
|
|
|
|
$action = $_POST['action'];
|
|
|
|
} elseif(isset($_GET['action'])) {
|
|
|
|
$action = $_GET['action'];
|
|
|
|
} else {
|
|
|
|
$action = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($action == "newsfeed") {
|
2013-12-06 08:44:57 +00:00
|
|
|
$feed = "http://inside.froxlor.org/news/";
|
2013-11-20 17:16:24 +00:00
|
|
|
|
2013-11-16 16:36:47 +00:00
|
|
|
if (function_exists("simplexml_load_file") == false) {
|
|
|
|
die();
|
|
|
|
}
|
2013-11-28 09:58:37 +00:00
|
|
|
|
2013-12-06 09:31:22 +00:00
|
|
|
// get version
|
|
|
|
require './tables.inc.php';
|
|
|
|
|
2013-12-06 08:44:57 +00:00
|
|
|
if (function_exists('curl_version')) {
|
|
|
|
$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));
|
2013-11-20 17:16:24 +00:00
|
|
|
} else {
|
2013-12-06 08:44:57 +00:00
|
|
|
if (ini_get('allow_url_fopen')) {
|
2013-12-06 09:31:22 +00:00
|
|
|
ini_set('user_agent', 'Froxlor/'.$version);
|
2013-12-06 08:44:57 +00:00
|
|
|
$news = simplexml_load_file($feed, null, LIBXML_NOCDATA);
|
2013-11-21 08:56:06 +00:00
|
|
|
} else {
|
|
|
|
$news = false;
|
|
|
|
}
|
2013-11-20 17:16:24 +00:00
|
|
|
}
|
2013-11-15 21:11:25 +00:00
|
|
|
|
|
|
|
if ($news !== false) {
|
|
|
|
for ($i = 0; $i < 3; $i++) {
|
|
|
|
$item = $news->channel->item[$i];
|
2013-11-28 09:58:37 +00:00
|
|
|
|
2013-11-15 21:50:54 +00:00
|
|
|
$title = (string)$item->title;
|
|
|
|
$link = (string)$item->link;
|
2013-12-04 18:53:55 +00:00
|
|
|
$date = date("Y-m-d G:i", strtotime($item->pubDate));
|
2014-02-08 16:41:10 +00:00
|
|
|
$content = preg_replace("/[\r\n]+/", " ", strip_tags($item->description));
|
|
|
|
$content = substr($content, 0, 150) . "...";
|
2013-11-28 09:58:37 +00:00
|
|
|
|
2014-02-08 16:41:10 +00:00
|
|
|
echo "<tr class=\"newsitem\"><td><small>" . $date . "</small><br /><a href=\"" . $link . "\" target=\"_blank\"><b>" . $title . "</b><br />" . $content . "</a></td></tr>";
|
2013-11-15 21:11:25 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
echo "";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
echo "No action set.";
|
2013-11-21 09:09:05 +00:00
|
|
|
}
|