コード例 #1
0
ファイル: index.php プロジェクト: kms/simplerss
if (sizeof($column) < 1) {
    printHeader();
    printf("<p>Please add feeds!</p>\n");
    printFooter();
    exit;
}
printHeader();
/* Calculate width of individual columns. */
$COLUMN_WIDTH = round(100 / sizeof($column));
foreach ($column as $x => $col) {
    if (is_array($col)) {
        print "<div class=\"blog\" style=\"width: {$COLUMN_WIDTH}%;\">\n";
        /* Iterate through elements. */
        foreach ($col as $y => $feed) {
            $data = getFeed($feed, $x, $y);
            $p = new feedParser();
            $info = $p->parseFeed($data["data"]);
            if (sizeof($info["item"]) > 0) {
                print "<div class=\"blogTitle\">";
                if ($info["channel"]["link"] != "") {
                    print "<a href=\"" . $info["channel"]["link"] . "\">" . $info["channel"]["title"] . "</a>\n";
                } else {
                    print $info["channel"]["title"] . "\n";
                }
                print "<a href=\"" . $feed["url"] . "\">\n";
                print "<img src=\"xml-tiny.png\" /></a></div>";
                print "<div class=\"manage\">(";
                print $x . $ALPHA[$y] . ":&nbsp;\n";
                print "<a href=\"";
                $tmp = $column;
                if (!is_array($tmp[$x - 1])) {
コード例 #2
0
function get_arch_feeds($buf, $url)
{
    global $command_line, $no_log, $debug, $cl, $max_links, $dc, $preferred, $cdata;
    $html = '';
    $xml = XML_IsWellFormed($buf);
    //      check for well-formed XML
    if ($xml != '1') {
        if ($debug > 0) {
            printNotWellFormedXML($xml, $cl);
        }
    } else {
        $rss = new feedParser();
        // define options for feed parser
        $rss->limit = $max_links;
        //   save time by limiting the items/entries to be processed
        $rss->in_cp = strtoupper($contents['charset']);
        //  charset of actual file
        $rss->out_cp = 'UTF-8';
        //  convert all into this charset
        $rss->cache_dir = '';
        //  currently unused
        $rss->dc = $dc;
        //  treat Dublin Core tags in RDF feeds
        $rss->pro = $preferred;
        //  obey the PREFERRED directive in RSD feeds
        $rss->file = '1';
        //  use $buf as feed (as a string, not URL)
        if ($cdata != 1) {
            $rss->CDATA = 'content';
            //  get it all  (naughty)
        } else {
            $rss->CDATA = 'nochange';
            //  well educated crawler
        }
        //  get feed as array
        if ($feed = $rss->get($url, $buf)) {
            //  if you want to see the feed, uncomment the following row
            //echo "<br>Feed array:<br><pre>";print_r($feed);echo "</pre>";
            $link = '';
            $textinput_link = '';
            $image_url = '';
            $image_link = '';
            $docs = '';
            $subjects = '';
            $count = '';
            $type = $feed[type];
            $count = $feed[sub_count];
            $cached = $feed[cached];
            //  kill all no longer required values
            $feed[type] = '';
            $feed[sub_count] = '';
            $feed[encoding_in] = '';
            $feed[encoding_out] = '';
            $feed[items_count] = '';
            $feed[cached] = '';
            if (!$count) {
                $count = '0';
            }
            if ($type == 'RSD') {
                //      prepare all RSD APIs
                for ($i = 0; $i < $count; $i++) {
                    $subjects .= '' . $feed['api'][$i]['name'] . '<br />
                                ' . $feed['api'][$i]['apiLink'] . '<br />
                                ' . $feed['api'][$i]['blogID'] . '<br />
                                ' . $feed['api'][$i]['settings_docs'] . '<br />
                                ' . $feed['api'][$i]['settings_notes'] . '<br />';
                }
            }
            if ($type == 'Atom') {
                //      prepare all Atom entries
                for ($i = 0; $i < $count; $i++) {
                    $subjects .= '' . $feed['entries'][$i]['link'] . '<br />
                                ' . $feed['entries'][$i]['title'] . '<br />
                                ' . $feed['entries'][$i]['id'] . '<br />
                                ' . $feed['entries'][$i]['published'] . '<br />
                                ' . $feed['entries'][$i]['updated'] . '<br />
                                ' . $feed['entries'][$i]['summary'] . '<br />
                                ' . $feed['entries'][$i]['rights'] . '<br />
                                ' . $feed['entries'][$i]['author_name'] . ' ' . $feed['entries'][$i]['author_email'] . ' ' . $feed['entries'][$i]['author_uri'] . '<br />
                                ' . $feed['entries'][$i]['category_term'] . ' ' . $feed['entries'][$i]['category_label'] . ' ' . $feed['entries'][$i]['category_scheme'] . '<br />
                                ' . $feed['entries'][$i]['contributor_name'] . ' ' . $feed['entries'][$i]['contributor_email'] . ' ' . $feed['entries'][$i]['contributor_uri'] . '<br />
                            ';
                }
            }
            if ($type == 'RDF' | $type == 'RSS v.0.91/0.92' | $type == 'RSS v.2.0') {
                //  For RDF and RSS feeds enter here
                //  prepare channel image
                $image_url = $feed[image_url];
                if ($image_url) {
                    $width = $feed[image_width];
                    if (!$width || $width > '144') {
                        $width = '88';
                        //set to default value
                    }
                    $height = $feed[image_height];
                    if (!$height || $height > '400') {
                        $height = '31';
                        //set to default value
                    }
                    $feed[image_url] = "<img id=\"rss_007\" src=\"" . $image_url . "\" alt=\"" . $feed[image_title] . "\" width=\"" . $width . "\" height=\"" . $height . "\">";
                }
                $image_link = $feed[image_link];
                if ($image_link) {
                    $feed[image_link] = "<a href=\"" . $image_link . "\">" . $image_link . "</a>";
                }
                //      prepare all RDF or RSS items
                for ($i = 0; $i < $count; $i++) {
                    $subjects .= '' . $feed['items'][$i]['link'] . '<br />
                                ' . $feed['items'][$i]['title'] . '<br />
                                ' . $feed['items'][$i]['description'] . '<br />
                                ' . $feed['items'][$i]['author'] . '<br />
                                ' . $feed['items'][$i]['category'] . '<br />
                                ' . $feed['items'][$i]['guid'] . '<br />
                                ' . $feed['items'][$i]['comments'] . '<br />
                                ' . $feed['items'][$i]['pubDate'] . '<br />
                                ' . $feed['items'][$i]['source'] . '<br />
                                ' . $feed['items'][$i]['enclosure'] . '<br />
                                ' . $feed['items'][$i]['country'] . '<br />
                                ' . $feed['items'][$i]['coverage'] . '<br />
                                ' . $feed['items'][$i]['contributor'] . '<br />
                                ' . $feed['items'][$i]['date'] . '<br />
                                ' . $feed['items'][$i]['industry'] . '<br />
                                ' . $feed['items'][$i]['language'] . '<br />
                                ' . $feed['items'][$i]['publisher'] . '<br />
                                ' . $feed['items'][$i]['state'] . '<br />
                                ' . $feed['items'][$i]['subject'] . '<br />
                            ';
                }
            }
            //  convert  the channel/feed part  into a string
            $feed_common = implode(" ", $feed);
            //  build something that could be indexed
            $html .= "<html>\r\n<head>\r\n<title>" . $feed['title'] . "</title>\r\n<meta name=\"description\" content=\"" . $feed['description'] . " \">\r\n</head>\r\n";
            $html .= "<body>\r\n" . $feed_common . "\r\n" . $subjects . "\r\n</body>\r\n</html>\r\n";
        }
        if (strlen($html) < '100') {
            //  can't be a valid feed
            printStandardReport('invalidRSS', $command_line, $no_log);
        } else {
            if ($debug > 0) {
                printValidFeed($type, $count, $cl);
            }
        }
    }
    return $html;
}
コード例 #3
0
<?php

require './feedParserClass.php';
$url = './products.xml';
$filter = "category";
/*Index is the postion of the element you want to filter. 
If the elements in the node are not separated by a delimiter then use 0. 
If the specified index does not exist an error will be thrown.
*/
$index = 1;
$delimiter = ">";
$directory = "/tmp/feed";
$params = ["url" => $url, "filter" => $filter, "index" => $index, "delimiter" => ">"];
try {
    $parser = new feedParser($params);
    $parser->filterFeed();
    $parser->write($directory);
} catch (Exception $e) {
    echo $e->getMessage();
}