$rssurl) { $r =& new XML_RSS($rssurl); if (PEAR::isError($r)) continue; $r->parse(); if ($r->getChannelInfo()) $ch[$k] = $r->getChannelInfo(); $ch[$k]['items'] = $r->getItems(); } for ( $i = 0; $i < count( $ch ); $i++ ) { usort($ch[ $i ][ 'items' ], "cmp"); } //print_r($ch); //nl2br(print_r( $ch )); $arr = array(); for ( $i = 0; $i < count( $ch ); $i++ ) { $site_title = htmlspecialchars(mb_convert_encoding($ch[$i]['title'], DF_OUT_CODE, "UTF-8,EUC-JP,SJIS")); // サイト名 $site_link = $ch[$i]['link']; // サイトURL $tmp = ""; $tmp .= "【{$site_title}
"; $tmp .= "
    "; $arr[] = $tmp; $j_max = min( count( $ch[ $i ][ 'items' ] ), DF_BLOG_ARTICLE ); for ( $j=0; $j < $j_max; $j++ ) { // 記事タイトル $title = mb_convert_encoding(strip_tags($ch[$i]['items'][$j]['title']), DF_OUT_CODE, "UTF-8,EUC-JP,SJIS"); // 記事内容 $desc = mb_convert_encoding(strip_tags($ch[$i]['items'][$j]['description']), DF_OUT_CODE, "UTF-8,EUC-JP,SJIS"); // 記事URL $link = htmlspecialchars($ch[$i]['items'][$j]['link']); // 記事更新時間(UNIXタイム $time = (isset($ch[$i]['items'][$j]['pubdate'])) ? strtotime($ch[$i]['items'][$j]['pubdate']) : strtotime(str_replace("T", " ", substr($ch[$i]['items'][$j]['dc:date'], 0, 19))); // 記事更新日 $date = date("Y/m/d H:i:s", $time); // 表示 $tmp = "{$title} ({$date})
    "; $tmp = str_replace( array("\t","\n"), array( "\\t", "\\n" ), $tmp ); $arr[] = "
  1. $tmp"; } $tmp = "
"; $arr[] = $tmp; } $html = ""; $html .= "var html=document.getElementById(\"menu_test\");\n"; $html .= "var txt=\"新着ブログ
\";\n"; for ( $i = 0; $i < count( $arr ); $i++ ) { $html .= "txt=txt+\"".$arr[ $i ]."\";\n"; } $html .= "html.innerHTML=txt;\n"; echo $html; // 日付ソート関数 function cmp($a, $b) { $a = (isset($a['pubdate'])) ? strtotime($a['pubdate']) : strtotime(str_replace("T", " ", substr($a['dc:date'], 0, 19))); $b = (isset($b['pubdate'])) ? strtotime($b['pubdate']) : strtotime(str_replace("T", " ", substr($b['dc:date'], 0, 19))); if ($a == $b) return 0; return ($a > $b) ? -1 : 1; } // 外部ファイル読込 function read_file( $fname ) { $arr = array(); $fp = @fopen( $fname, "r" ); if ( $fp ) { while ( !feof( $fp ) ) { $buffer = fgets( $fp, 4096 ); $buffer = trim( $buffer ); if ( $buffer != "" ) { $arr[] = $buffer; } } fclose( $fp ); } return $arr; } ?>