<?php
function http_get($url){
$url_stuff = parse_url($url);
$port = isset($url_stuff['port']) ? $url_stuff['port'] : 80;
$fp = fsockopen($url_stuff['host'], $port);
if($fp){
if(!empty($url_stuff['query'])) $query = 'GET ' . $url_stuff['path'].'?'.$url_stuff['query'] . " HTTP/1.0\n";
else $query = 'GET ' . $url_stuff['path'] . " HTTP/1.0\n";
$query .= 'Host: ' . $url_stuff['host'];
$query .= "\n\n";
fwrite($fp, $query);
while ($tmp = fread($fp, 1024)) {
$buffer .= $tmp;
}
}else{
$buffer="";
}
return $buffer;
}
function vergleich($wert_a, $wert_b) {
$a = $wert_a["date"];
$b = $wert_b["date"];
if ($a == $b) {
return 0;
}
return ($a > $b) ? -1 : +1;
}
function getRssfeed($rssfeed, $cssclass="", $encode="auto", $anzahl=10, $mode=0)
{
$data = http_get($rssfeed);
if(strpos($data,"</item>") > 0)
{
preg_match_all("/<item.*>(.+)<\/item>/Uism", $data, $items);
$atom = 0;
}
elseif(strpos($data,"</entry>") > 0)
{
preg_match_all("/<entry.*>(.+)<\/entry>/Uism", $data, $items);
$atom = 1;
}
if($encode == "auto")
{
preg_match("/<?xml.*encoding=\"(.+)\".*?>/Uism", $data, $encodingarray);
$encoding = $encodingarray[1];
}
else
{$encoding = $encode;}
if(is_array($items[1])) {
foreach ($items[1] as $item) {
preg_match("/<title.*>(.+)<\/title>/Uism", $item, $title);
if(empty($title)) preg_match("/<media:title.*>(.+)<\/media:title>/Uism", $item, $title);
preg_match("/<pubDate.*>(.+)<\/pubDate>/Uism", $item, $date);
$date = strip_tags($date);
if($atom == 0) {
preg_match("/<link>(.+)<\/link>/Uism", $item, $link);
}
elseif($atom == 1) {
preg_match("/<link.*alternate.*text\/html.*href=[\"\'](.+)[\"\'].*\/>/Uism", $item, $link);
}
if($atom == 0) {
preg_match("/<description>(.*)<\/description>/Uism", $item, $description);
}
elseif($atom == 1) {
preg_match("/<summary.*>(.*)<\/summary>/Uism", $item, $description);
}
$title = preg_replace('/<!\[CDATA\[(.+)\]\]>/Uism', '$1', $title);
$description = preg_replace('/<!\[CDATA\[(.+)\]\]>/Uism', '$1', $description);
$link = preg_replace('/<!\[CDATA\[(.+)\]\]>/Uism', '$1', $link);
$RSSAc = count($RSSA);
if($encode != "no")
$RSSA[$RSSAc]["title"] = "<h2>".htmlentities($title[1],ENT_QUOTES,$encoding)."</h2>";
else
$RSSA[$RSSAc]["title"] = "<h2>".$title[1]."</h2>";
//$RSS .= $title[1];
if(!empty($date[1])) {
if(strtotime($date[1]) < (mktime()-604800)) break;
$RSSA[$RSSAc]["date"] = "<small><em>".date("d-m-Y H:i", strtotime($date[1]))."</em></small><br>";
}
$description[1] = str_replace("\n", "", $description[1]);
$A1 = array("<br>", "<br />", "<p");
$A2 = array("\n","\n","\n<p");
$RSSA[$RSSAc]["desc"] = nl2br(strip_tags(str_replace($A1, $A2, html_entity_decode($description[1]))));
if(strlen($RSSA[$RSSAc]["desc"]) > 500) $RSSA[$RSSAc]["desc"] = substr($RSSA[$RSSAc]["desc"],0,500)." [...]";
$RSSA[$RSSAc]["link"] = "<div style=\"text-align:right; width:100%;\"><a href=\"".$link[1]."\" title=\"".$title[1]."\" target=\"_blank\">...read more about it</a></div>";
if ($anzahl-- <= 1) break;
}
}
return $RSSA;
}
//Hier deine Feed Url Eingeben... bei mehreren URLs einfach eine neue Zeile machen
$RSSA[] = "DEINE_RSS_FEED_URL";
//$RSSA[] = "DEINE_RSS_FEED_URL2";
//Wordpress Header
get_header();
//RSS FEED
$RSSData = array();
foreach($RSSA AS $key => $value) {
$RSSData = array_merge($RSSData ,getRssfeed($value,"","no",10,3));
}
//Sortieren
usort($RSSData, 'vergleich');
$RSS="";
foreach ($RSSData AS $key => $value) {
echo "<div style=\"padding:5px; border-bottom:2px solid #999;\">\n";
echo $value["title"];
echo $value["date"];
echo "<p>\n";
echo $value["desc"];
echo "</p>\n";
echo $value["link"];
echo "</div>\n";
}
get_sidebar();
get_footer();
?>