Esempio n. 1
0
// Include SimplePie
// Located in the parent directory
include_once $c["path"] . 'plugin/feedreader/simplepie.inc';
include_once $c["path"] . 'plugin/feedreader/idn/idna_convert.class.php';
// Create a new instance of the SimplePie object
$feed = new SimplePie();
// Set these Configuration Options
$feed->strip_ads(true);
$feed->feed_url($url);
// Allow us to change the input encoding from the URL string if we want to. (optional)
if (!empty($_GET['input'])) {
    $feed->input_encoding($_GET['input']);
}
// Allow us to snap into IHBB mode.
if (!empty($_GET['image'])) {
    $feed->bypass_image_hotlink('i');
    $feed->bypass_image_hotlink_page('./ihbb.php');
}
// Initialize the whole SimplePie object.  Read the feed, process it, parse it, cache it, and
// all that other good stuff.  The feed's information will not be available to SimplePie before
// this is called.
$feed->init();
// We'll make sure that the right content type and character encoding gets set automatically.
// This function will grab the proper character encoding, as well as set the content type to text/html.
$feed->handle_content_type();
// When we end our PHP block, we want to make sure our DOCTYPE is on the top line to make
// sure that the browser snaps into Standards Mode.
$out = '';
if ($feed->data) {
    foreach ($feed->get_items() as $item) {
        $out .= '<div class="chunk"><h2>';
Esempio n. 2
0
function kingRssOutput($data)
{
    $feed = new SimplePie();
    $feed->feed_url($data['rss_url']);
    $path = explode($_SERVER["SERVER_NAME"], get_bloginfo('wpurl'));
    $feed->cache_location($_SERVER['DOCUMENT_ROOT'] . $path[1] . "/wp-content/cache");
    if (!empty($data['cache_time'])) {
        $feed->max_minutes = $data['cache_time'];
    }
    if (!empty($data['nosort'])) {
        $feed->order_by_date = false;
    }
    if (!empty($data['stripads'])) {
        $feed->strip_ads(1);
    }
    $feed->bypass_image_hotlink();
    $feed->bypass_image_hotlink_page($path[1] . "/index.php");
    #if images in feed are protected
    $success = $feed->init();
    if ($success && $feed->data) {
        $output = '';
        $replace_title_vars[0] = $feed->get_feed_link();
        $replace_title_vars[1] = $feed->get_feed_title();
        $replace_title_vars[2] = $feed->get_feed_description();
        $replace_title_vars[3] = $data['rss_url'];
        $replace_title_vars[4] = get_settings('siteurl') . '/wp-content/plugins/king-framework/images/rss.png';
        if ($feed->get_image_exist() == true) {
            $replace_title_vars[5] = $feed->get_image_url();
        }
        $search_title_vars = array('%link%', '%title%', '%descr%', '%rssurl%', '%rssicon%', '%feedimg%');
        #parse template placeholders
        $output .= str_replace($search_title_vars, $replace_title_vars, $data['titlehtml']);
        $max = $feed->get_item_quantity();
        if (!empty($data['max_items'])) {
            $max = min($data['max_items'], $feed->get_item_quantity());
        }
        for ($x = 0; $x < $max; $x++) {
            $item = $feed->get_item($x);
            $replace_vars[0] = stupifyEntities($item->get_title());
            $replace_vars[1] = $item->get_permalink();
            $replace_vars[2] = $item->get_date($data['showdate']);
            $replace_vars[3] = stupifyEntities($item->get_description());
            if ($item->get_categories() != false) {
                $categories = $item->get_categories();
                $replace_vars[4] = implode(" | ", $categories);
            }
            if ($item->get_author(0) != false) {
                $author = $item->get_author(0);
                $replace_vars[5] = $author->get_name();
            }
            # cut article text to length ... do the butcher
            if (!empty($data['shortdesc'])) {
                $suffix = '...';
                $short_desc = trim(str_replace("\n", ' ', str_replace("\r", ' ', strip_tags(stupifyEntities($item->get_description())))));
                $desc = substr($short_desc, 0, $data['shortdesc']);
                $lastchar = substr($desc, -1, 1);
                if ($lastchar == '.' || $lastchar == '!' || $lastchar == '?') {
                    $suffix = '';
                }
                $desc .= $suffix;
                $replace_vars[3] = $desc;
            }
            $search_vars = array('%title%', '%link%', '%date%', '%text%', '%category%', '%author%');
            #parse template placeholders
            $output .= str_replace($search_vars, $replace_vars, $data['rsshtml']);
        }
    } else {
        if (!empty($data['error'])) {
            $output = $data['error'];
        } else {
            if (isset($feed->error)) {
                $output = $feed->error;
            }
        }
    }
    return $output;
}
Esempio n. 3
0
<?php

// Include SimplePie
// Located in the parent directory
include_once '../simplepie.inc';
// Initialize SimplePie
$image = new SimplePie();
// Tell it to handle images sent via the 'i' parameter.
$image->bypass_image_hotlink('i');
// Initialize
$image->init();