예제 #1
0
파일: bridge.php 프로젝트: a2call/commsy
#global $rss_ticker_array;
#$rsslist = $rss_ticker_array;
////Beginners don't need to configure past here////////////////////
$rssid = $_GET['id'];
$rssurl = isset($rsslist[$rssid]) ? $rsslist[$rssid] : die("Error: Can't find requested RSS in list.");
// -------------------------------------------------------------------
// outputRSS_XML()- Outputs the "title", "link", "description", and "pubDate" elements of an RSS feed in XML format
// -------------------------------------------------------------------
function outputRSS_XML($url)
{
    global $rss;
    $cacheseconds = (int) $_GET["cachetime"];
    //typecast "cachetime" parameter as integer (0 or greater)
    $rss->cache_time = $cacheseconds;
    if ($rs = $rss->get($url)) {
        echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<rss version=\"2.0\">\n<channel>\n";
        foreach ($rs['items'] as $item) {
            echo "<item>\n<link>{$item['link']}</link>\n<title>{$item['title']}</title>\n<description>{$item['description']}</description>\n<pubDate>{$item['pubDate']}</pubDate>\n</item>\n\n";
        }
        echo "</channel></rss>";
        if ($rs['items_count'] <= 0) {
            echo "<li>Sorry, no items found in the RSS file :-(</li>";
        }
    } else {
        echo "Sorry: It's not possible to reach RSS file {$url}\n<br />";
        // you will probably hide this message in a live version
    }
}
// ===============================================================================
outputRSS_XML($rssurl);
예제 #2
0
// outputRSS_XML()- Outputs the "title", "link", "description", and "pubDate" elements of an RSS feed in XML format
// -------------------------------------------------------------------

function outputRSS_XML($url,$rss) {
   $cacheseconds=(int) $_GET["cachetime"]; //typecast "cachetime" parameter as integer (0 or greater)
   $rss->cache_time = $cacheseconds;
   if ($rs = $rss->get($url)) {
      $encoding = 'ISO-8859-1';
      if ( !empty($rs['encoding']) ) {
         $encoding = $rs['encoding'];
      }
      echo "<?xml version=\"1.0\" encoding=\"".$encoding."\"?>\n<rss version=\"2.0\">\n<channel>\n";
      foreach ($rs['items'] as $item) {
         if (isset($item['description'])){
            echo "<item>\n<link>$item[link]</link>\n<title>$item[title]</title>\n<description>$item[description]</description>\n<pubDate>$item[pubDate]</pubDate>\n</item>\n\n";
         }else{
            echo "<item>\n<link>$item[link]</link>\n<title>$item[title]</title>\n<description>...</description>\n<pubDate>$item[pubDate]</pubDate>\n</item>\n\n";
         }
      }
      echo "</channel></rss>";
      if ($rs['items_count'] <= 0) { echo "<li>Sorry, no items found in the RSS file :-(</li>"; }
   } else {
      echo "Sorry: It's not possible to reach RSS file $url\n<br />";
      // you will probably hide this message in a live version
   }
}

// ===============================================================================

outputRSS_XML($rssurl,$rss);
?>