MagpieRSS

<?php
//RSS
$rssUrl = array(
  'http://blog.livedoor.jp/news4vip2/index.rdf',//ニュー速クオリティ
  'http://himasoku.com/index.rdf',
  'http://kanasoku.info/index.rdf',
  'http://workingnews.blog117.fc.com/?xml',
  'http://blog.livedoor.jp/dgnplus/index.rdf',
  'http://majikichi.com/index.rdf',
);

//MagpieRSS
require_once('./magpierss-master/rss_fetch.inc');
define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
define('MAGPIE_CACHE_ON', false);

//配列編集
foreach ($rssUrl as $no => $rss_url){
  $rss = @fetch_rss($rss_url);
  if ($rss != NULL){
    for ($i=0; $i<count($rss->items); $i++){
      $rss->items[$i]["site_title"] = $rss->channel["title"];
      $rss->items[$i]["site_link"] = $rss->channel["link"];
    }
    $rssItemsArray[] = $rss->items;
  }
}
$contactArray = array();
for($i=0;$i<count($rssItemsArray);$i++){
$contactArray = array_merge($contactArray,$rssItemsArray&#91;$i&#93;);}
foreach ($contactArray as $no => $values){

//RSSの種類によって日付を取得
if($values['published']){$date = $values['published'];}
elseif($values['dc']['date']){$date = $values['dc']['date'];}
elseif($values['pubdate']){$date = $values['pubdate'];}
$date=date("Y-m-d H:i:s",strtotime($date));

//Filter
$nowtime = date("Y-m-d h:i:s", strtotime("now"));
if ($date > $nowtime){
} elseif(preg_match("/AD/", $values["title"])){
} elseif(preg_match("/PR/", $values["title"])){
} else {

// 値の定義
$title=$values["title"];
$link=$values["link"];
$site_title=$value["site_title"];
$site_link=$values["site_link"];

// 画像取得
$content=$values["content"]["encoded"];
preg_match('/<img.*>/i', $content, $img_all);
if(empty($img_all[0])){
  $content = $values['description'];
  preg_match('/<img.*>/i', $content, $img_all);
}
preg_match('/http.*?(\.gif|\.png|\.jpg|\.jpeg$|\.bmp)/i', $img_all[0], $gazo);
if(empty($gazo[0])){$gazo = "http://azaz.clouver.jp/antenna/noimage.png";}
else{$gazo = $gazo[0];}

//配列
$rssArray[]=array($date,$title, $link, $site_title, $site_link, $gazo);
}
}

$num = 50;
if(count($rssArray)>$num){$count=$num;}else{$count=count($rssArray);}
rsort($rssArray);

//HTML整形
for($i=0; $i<$count; $i++){
  $date=date("m/d H:i", strtotime($rssArray&#91;$i&#93;&#91;0&#93;));
  $title=$rssArray&#91;$i&#93;&#91;1&#93;;
  $link=$rssArray&#91;$i&#93;&#91;2&#93;;
  $site_title=$rssArray&#91;$i&#93;&#91;3&#93;;
  $site_link=$rssArray&#91;$i&#93;&#91;4&#93;;
  $gazo=$rssArray&#91;$i&#93;&#91;5&#93;;
    $datelink = "<div class='date'>$date</div>";
    $gazolink = "<a target='_blank' href='$link'><div class='trim'><img src='$gazo' /></div></a>";
    $titlelink = "<div class='title'><a href='$link'>$title</a></div>";
    $site_titlelink = "<div class='site_title'><a href='$site_link'>$date - [$site_title]</a></div>";
    echo "<article>$gazolink$titlelink$site_titlelink</article>";
}

?>