set_timeout() public method

This allows you to change the maximum time the feed's server to respond and send the feed back.
Since: 1.0 Beta 3
public set_timeout ( integer $timeout = 10 )
$timeout integer The maximum number of seconds to spend waiting to retrieve a feed.
 private function loadFromWebService()
 {
     $feed = new \SimplePie();
     $feed->set_feed_url($this->endPoint);
     $feed->set_cache_location(THELIA_ROOT . 'cache/feeds');
     $feed->init();
     $feed->handle_content_type();
     $feed->set_timeout(10);
     $this->data = $feed->get_items();
 }
コード例 #2
0
ファイル: Feed.php プロジェクト: alex63530/thelia
 public function buildArray()
 {
     $cachedir = THELIA_ROOT . 'cache/feeds';
     if (!is_dir($cachedir)) {
         if (!mkdir($cachedir)) {
             throw new \Exception(sprintf("Failed to create cache directory '%s'", $cachedir));
         }
     }
     $feed = new \SimplePie($this->getUrl(), THELIA_ROOT . 'cache/feeds');
     $feed->init();
     $feed->handle_content_type();
     $feed->set_timeout($this->getTimeout());
     $items = $feed->get_items();
     return $items;
 }
コード例 #3
0
 /**
  * Opens an RSS feed, parses and loads the contents.
  *
  * @param string $url         The URL of the RSS feed
  * @param bool   $nativeOrder If true, disable order by date to preserve native ordering
  * @param bool   $force       Force SimplePie to parse the feed despite errors
  *
  * @return object An object that encapsulates the feed contents and operations on those contents.
  * @throws FeedParserException If opening or parsing feed fails
  **/
 public function parseFeed($url, $nativeOrder = false, $force = false)
 {
     require_once PATH_SYSTEM . '/vendors/SimplePie.php';
     $feed = new SimplePie();
     $feed->set_timeout($this->timeout);
     $feed->set_feed_url($url);
     $feed->enable_order_by_date(!$nativeOrder);
     $feed->force_feed($force);
     if ($this->cacheDuration != null) {
         $feed->set_cache_duration(intval($this->cacheDuration));
     }
     if ($this->cacheDirectory != null) {
         $feed->set_cache_location($this->cacheDirectory);
     }
     if ($this->stripHtmlTags != null) {
         $feed->strip_htmltags($this->stripHtmlTags);
     }
     @$feed->init();
     if ($err = $feed->error()) {
         throw new FeedParserException($err);
     }
     return $feed;
 }
コード例 #4
0
ファイル: BlogFeed.php プロジェクト: johnleesw/mustardseedwp
 public function fetchPosts()
 {
     global $_wp_additional_image_sizes;
     global $wpdb;
     $lastRefreshTime = (int) get_option('wpab_last_refresh_time', 0);
     $fetchPeriod = (int) get_option('wpab_fetch_feed_period', 30) * MINUTE_IN_SECONDS;
     if (time() - $lastRefreshTime < $fetchPeriod) {
         return;
     }
     WPAutoblog_Log::log(null, 'Started updating feeds');
     set_time_limit($fetchPeriod);
     update_option('wpab_last_refresh_time', time());
     $body = null;
     $blogs = get_posts(array('post_type' => self::postName(), 'posts_per_page' => -1));
     $cache_ids = array();
     foreach ($blogs as $k => $blog) {
         $url = get_post_meta($blog->ID, WPAB_ID . '-feed', true) ?: get_post_meta($blog->ID, WPAB_ID . '-url', true);
         $feed = new SimplePie();
         $feed->set_feed_url($url);
         $feed->set_cache_location('../cache/');
         $feed->set_cache_duration($fetchPeriod);
         $feed->set_timeout(15);
         $result = $feed->init();
         $feed->handle_content_type();
         if (!$result) {
             WPAutoblog_Log::log($feed->error(), 'An error occured while fetching the feed: <i>' . $blog->post_title . '</i>');
             continue;
         }
         $items = $feed->get_items();
         foreach ($items as $item) {
             if (!in_array($item->get_id(), $cache_ids)) {
                 $posts = get_posts(array('hierarchical' => false, 'meta_key' => WPAB_ID . '-uuid', 'meta_value' => $item->get_id(), 'post_type' => WPAutoblog_BlogFeedPost::postName()));
                 if (count($posts) === 0) {
                     $images = $this->extractImages($item->get_content());
                     $attachments = array();
                     $isFeaturedImageFeatured = get_field('featured_image_featured', $blog->ID);
                     $isFirstImageFeatured = get_field('first_image_featured', $blog->ID);
                     $featuredImageFetched = false;
                     if ($isFeaturedImageFeatured) {
                         $enclosure = $item->get_enclosure();
                         $featuredImageUrl = $enclosure->get_link();
                         if ($featuredImageUrl) {
                             $attachments[] = WPAutoblog_BlogFeedPost::prepareAttachment($featuredImageUrl);
                             $featuredImageFetched = true;
                         }
                     }
                     if ($isFirstImageFeatured && count($images) && !$featuredImageFetched) {
                         $attachments[] = WPAutoblog_BlogFeedPost::prepareAttachment($images[0]);
                     }
                     if ($this->readability->isAvailable()) {
                         $body = $this->readability->parse($item->get_permalink());
                     }
                     $cache_ids[] = $item->get_id();
                     $post_id = $this->createBlogPost($blog, $item, $body, $attachments);
                     $this->assignCategories($post_id, $blog->ID);
                     do_action(WPAB_ID . '_blog_post_created_from_feed', $post_id, $item, $attachments);
                     WPAutoblog_Stat::incrementPostsCount($item->get_date('Y/m/d'));
                 }
             }
         }
     }
     $postsToSweep = $wpdb->get_results('SELECT post_id FROM `wp_postmeta`
         WHERE meta_key =  "' . WPAB_ID . '-uuid"
         GROUP BY meta_value
         HAVING COUNT(*) > 1
         LIMIT 0, 100', ARRAY_A);
     $postsToSweepIds = array_map(function ($item) {
         return $item['post_id'];
     }, $postsToSweep);
     WPAutoblog_Sweeper::remove($postsToSweepIds);
     WPAutoblog_Log::log($feed, 'Finished updating feeds');
 }
コード例 #5
0
/**
 * Refresh the flickr images cache
 */
function ikit_social_remote_fetch_flickr_images_rss()
{
    global $g_options;
    $flickr_user_id = null;
    if (isset($g_options[IKIT_PLUGIN_OPTION_FLICKR_USER_ID])) {
        $flickr_user_id = $g_options[IKIT_PLUGIN_OPTION_FLICKR_USER_ID];
    }
    if ($flickr_user_id != null) {
        $feed = new SimplePie();
        $feed->set_cache_duration(0);
        $feed->set_timeout(5);
        $feed->set_feed_url(sprintf(IKIT_SOCIAL_FLICKR_IMAGES_RSS_URL, $flickr_user_id));
        $feed->set_cache_location(IKIT_DIR_CACHE);
        $feed->init();
    }
}
コード例 #6
0
ファイル: feed-importing.php プロジェクト: kivivuori/jotain
/**
 * A clone of the function 'fetch_feed' in wp-includes/feed.php [line #529]
 *
 * Called from 'wprss_get_feed_items'
 *
 * @since 3.5
 */
function wprss_fetch_feed($url, $source = NULL)
{
    // Import SimplePie
    require_once ABSPATH . WPINC . '/class-feed.php';
    // Trim the URL
    $url = trim($url);
    // Initialize the Feed
    $feed = new SimplePie();
    // Obselete method calls ?
    //$feed->set_cache_class( 'WP_Feed_Cache' );
    //$feed->set_file_class( 'WP_SimplePie_File' );
    $feed->set_feed_url($url);
    $feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_ALL);
    // If a feed source was passed
    if ($source !== NULL) {
        // Get the force feed option for the feed source
        $force_feed = get_post_meta($source, 'wprss_force_feed', TRUE);
        // If turned on, force the feed
        if ($force_feed == 'true') {
            $feed->force_feed(TRUE);
        }
    }
    // Set timeout to 30s. Default: 15s
    $feed->set_timeout(30);
    //$feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) );
    $feed->enable_cache(FALSE);
    // Reference array action hook, for the feed object and the URL
    do_action_ref_array('wp_feed_options', array(&$feed, $url));
    // Prepare the tags to strip from the feed
    $tags_to_strip = apply_filters('wprss_feed_tags_to_strip', $feed->strip_htmltags, $source);
    // Strip them
    $feed->strip_htmltags($tags_to_strip);
    // Fetch the feed
    $feed->init();
    $feed->handle_content_type();
    // Convert the feed error into a WP_Error, if applicable
    if ($feed->error()) {
        return new WP_Error('simplepie-error', $feed->error());
    }
    // If no error, return the feed
    return $feed;
}
コード例 #7
0
/* Set the maximum number of items here */
$rss_url = 'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml';
/* Enter the URL of your RSS feed here */
$show_errors = 'no';
?>
    <div id="block_rss" class="block">
	<div class="block_header">
	    <h4><a href="http://news.bbc.co.uk/">BBC News</a></h4>
	</div>
	    <div class="block_body">
		<ul>

		    <?php 
echo "\n";
$feed = new SimplePie();
$feed->set_timeout(30);
$feed->set_feed_url($rss_url);
$feed->enable_cache(TRUE);
$feed->set_cache_location('files/cache');
$feed->set_item_limit($number_of_items);
$feed->set_cache_duration(900);
$feed->init();
$feed->handle_content_type();
$feed_items = $feed->get_items(0, $number_of_items);
if ($show_errors == 'yes' && $feed->error()) {
    echo $feed->error();
}
foreach ($feed_items as $item) {
    $item_link = $item->get_permalink();
    $item_title = $item->get_title();
    echo "\t\t\t\t\t\t\t<li><a href=\"{$item_link}\">{$item_title}</a></li>\n";
コード例 #8
0
ファイル: function.php プロジェクト: JackBuh/kindle
function updateRSS()
{
    $db = DBCxn::get();
    $selectRSS = $db->query("SELECT id, rssLink, updateMd5 FROM rss");
    $selectRSS->setFetchMode(PDO::FETCH_ASSOC);
    $selectRSS = $selectRSS->fetchAll();
    //构建分析
    $feed = new SimplePie();
    $feed->enable_order_by_date(false);
    $feed->enable_cache(true);
    $feed->set_useragent('Mozilla/4.0 ' . SIMPLEPIE_USERAGENT);
    $feed->set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/cache');
    //拿出每个RSS调用分析函数
    foreach ($selectRSS as $rows) {
        $rssId = $rows['id'];
        //博客ID
        $updateMd5 = $rows['updateMd5'];
        //最后更新记录的md5值
        $feed->set_feed_url($rows['rssLink']);
        //feed地址做参数进行解析操作
        $feed->set_timeout(30);
        $feed->init();
        //如果feed出错,执行下一个
        if ($feed->error()) {
            continue;
        }
        readRSS($rssId, $updateMd5, $feed);
    }
    return true;
}
コード例 #9
0
ファイル: makepdf.php プロジェクト: BackupTheBerlios/oos-svn
	foreach($feeds_array as $feed_item) {
		if (trim($feed_item['feeds']) != '') {
			$feed_urls[] = trim($feed_item['feeds']);
		}
		// limit to 10 URLs in OPML
		if (count($feed_urls) >= 10) break;
	}
	// setup SimplePie again
	if ($order == 'asc') {
		$feed = new SimplePie_Chronological();
	} else {
		$feed = new SimplePie();
	}
	$feed->set_feed_url($feed_urls);
	//$feed->force_feed(true);
	$feed->set_timeout(120);
	$feed->enable_cache(false);
	$feed->set_stupidly_fast(true);
	$feed->enable_order_by_date(true);
	$feed->set_url_replacements(array());
	$result = $feed->init();
	//$feed->handle_content_type();
	//if ($feed->error()) echo $feed->error();exit;
	if (!$result) {
		die('Sorry, no feed items found');
	}
}

/////////////////////////////////////////////////
// Create new PDF document (LETTER/A4)
/////////////////////////////////////////////////
コード例 #10
0
/**
 * The actual function that can be called on webpages.
 */
function SimplePieWP($feed_url, $options = null)
{
    // Quit if the SimplePie class isn't loaded.
    if (!class_exists('SimplePie')) {
        die('<p style="font-size:16px; line-height:1.5em; background-color:#c00; color:#fff; padding:10px; border:3px solid #f00; text-align:left;"><img src="' . SIMPLEPIE_PLUGINDIR_WEB . '/images/error.png" /> There is a problem with the SimplePie Plugin for WordPress. Check your <a href="' . WP_CPANEL . '" style="color:#ff0; text-decoration:underline;">Installation Status</a> for more information.</p>');
    }
    if (isset($locale) && !empty($locale) && $locale != 'auto') {
        setlocale(LC_TIME, $locale);
    }
    // Default general settings
    $template = get_option('simplepie_template');
    $items = get_option('simplepie_items');
    $items_per_feed = get_option('simplepie_items_per_feed');
    $date_format = get_option('simplepie_date_format');
    $enable_cache = get_option('simplepie_enable_cache');
    $set_cache_location = get_option('simplepie_set_cache_location');
    $set_cache_duration = get_option('simplepie_set_cache_duration');
    $enable_order_by_date = get_option('simplepie_enable_order_by_date');
    $set_timeout = get_option('simplepie_set_timeout');
    // Default text-shortening settings
    $truncate_feed_title = get_option('simplepie_truncate_feed_title');
    $truncate_feed_description = get_option('simplepie_truncate_feed_description');
    $truncate_item_title = get_option('simplepie_truncate_item_title');
    $truncate_item_description = get_option('simplepie_truncate_item_description');
    // Default advanced settings
    $processing = get_option('simplepie_processing');
    $locale = get_option('simplepie_locale');
    $local_date_format = get_option('simplepie_local_date_format');
    $strip_htmltags = get_option('simplepie_strip_htmltags');
    $strip_attributes = get_option('simplepie_strip_attributes');
    $set_max_checked_feeds = get_option('simplepie_set_max_checked_feeds');
    // Overridden settings
    if ($options) {
        // Fix the template location if one was passed in.
        if (isset($options['template']) && !empty($options['template'])) {
            $options['template'] = SIMPLEPIE_PLUGINDIR . '/templates/' . strtolower(str_replace(' ', '_', $options['template'])) . '.tmpl';
        }
        // Fix the processing location if one was passed in.
        if (isset($options['processing']) && !empty($options['processing'])) {
            $options['processing'] = SIMPLEPIE_PLUGINDIR . '/processing/' . strtolower(str_replace(' ', '_', $options['processing'])) . '.php';
        }
        extract($options);
    }
    // Load post-processing file.
    if ($processing && $processing != '') {
        include_once $processing;
    }
    // If template doesn't exist, die.
    if (!file_exists($template) || !is_readable($template)) {
        die('<p style="font-size:16px; line-height:1.5em; background-color:#c00; color:#fff; padding:10px; border:3px solid #f00; text-align:left;"><img src="' . SIMPLEPIE_PLUGINDIR_WEB . '/images/error.png" /> The SimplePie template file is not readable by WordPress. Check the <a href="' . WP_CPANEL . '" style="color:#ff0; text-decoration:underline;">WordPress Control Panel</a> for more information.</p>');
    }
    // Initialize SimplePie
    $feed = new SimplePie();
    $feed->set_feed_url($feed_url);
    $feed->enable_cache($enable_cache);
    $feed->set_item_limit($items_per_feed);
    $feed->set_cache_location($set_cache_location);
    $feed->set_cache_duration($set_cache_duration);
    $feed->enable_order_by_date($enable_order_by_date);
    $feed->set_timeout($set_timeout);
    $feed->strip_htmltags(explode(' ', $strip_htmltags));
    $feed->strip_attributes(explode(' ', $strip_attributes));
    $feed->set_max_checked_feeds($set_max_checked_feeds);
    $feed->init();
    // Load up the selected template file
    $handle = fopen($template, 'r');
    $tmpl = fread($handle, filesize($template));
    fclose($handle);
    /**************************************************************************************************************/
    // ERRORS
    // I'm absolutely sure that there is a better way to do this.
    // Define what we're looking for
    $error_start_tag = '{IF_ERROR_BEGIN}';
    $error_end_tag = '{IF_ERROR_END}';
    $error_start_length = strlen($error_start_tag);
    $error_end_length = strlen($error_end_tag);
    // Find what we're looking for
    $error_start_pos = strpos($tmpl, $error_start_tag);
    $error_end_pos = strpos($tmpl, $error_end_tag);
    $error_length_pos = $error_end_pos - $error_start_pos;
    // Grab what we're looking for
    $error_string = substr($tmpl, $error_start_pos + $error_start_length, $error_length_pos - $error_start_length);
    $replacable_string = $error_start_tag . $error_string . $error_end_tag;
    if ($error_message = $feed->error()) {
        $tmpl = str_replace($replacable_string, $error_string, $tmpl);
        $tmpl = str_replace('{ERROR_MESSAGE}', SimplePie_WordPress::post_process('ERROR_MESSAGE', $error_message), $tmpl);
    } elseif ($feed->get_item_quantity() == 0) {
        $tmpl = str_replace($replacable_string, $error_string, $tmpl);
        $tmpl = str_replace('{ERROR_MESSAGE}', SimplePie_WordPress::post_process('ERROR_MESSAGE', 'There are no items in this feed.'), $tmpl);
    } else {
        $tmpl = str_replace($replacable_string, '', $tmpl);
    }
    /**************************************************************************************************************/
    // FEED
    // FEED_AUTHOR_EMAIL
    /*	if ($author = $feed->get_author())
    	{
    		if ($email = $author->get_email())
    		{
    			$tmpl = str_replace('{FEED_AUTHOR_EMAIL}', SimplePie_WordPress::post_process('FEED_AUTHOR_EMAIL', $email), $tmpl);
    		}
    		else
    		{
    			$tmpl = str_replace('{FEED_AUTHOR_EMAIL}', '', $tmpl);
    		}
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_AUTHOR_EMAIL}', '', $tmpl);
    	}
    
    	// FEED_AUTHOR_LINK
    	if ($author = $feed->get_author())
    	{
    		if ($link = $author->get_link())
    		{
    			$tmpl = str_replace('{FEED_AUTHOR_LINK}', SimplePie_WordPress::post_process('FEED_AUTHOR_LINK', $link), $tmpl);
    		}
    		else
    		{
    			$tmpl = str_replace('{FEED_AUTHOR_LINK}', '', $tmpl);
    		}
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_AUTHOR_LINK}', '', $tmpl);
    	}
    
    	// FEED_AUTHOR_NAME
    	if ($author = $feed->get_author())
    	{
    		if ($name = $author->get_name())
    		{
    			$tmpl = str_replace('{FEED_AUTHOR_NAME}', SimplePie_WordPress::post_process('FEED_AUTHOR_NAME', $name), $tmpl);
    		}
    		else
    		{
    			$tmpl = str_replace('{FEED_AUTHOR_NAME}', '', $tmpl);
    		}
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_AUTHOR_NAME}', '', $tmpl);
    	}
    
    	// FEED_CONTRIBUTOR_EMAIL
    	if ($contributor = $feed->get_contributor())
    	{
    		if ($email = $contributor->get_email())
    		{
    			$tmpl = str_replace('{FEED_CONTRIBUTOR_EMAIL}', SimplePie_WordPress::post_process('FEED_CONTRIBUTOR_EMAIL', $email), $tmpl);
    		}
    		else
    		{
    			$tmpl = str_replace('{FEED_CONTRIBUTOR_EMAIL}', '', $tmpl);
    		}
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_CONTRIBUTOR_EMAIL}', '', $tmpl);
    	}
    
    	// FEED_CONTRIBUTOR_LINK
    	if ($contributor = $feed->get_contributor())
    	{
    		if ($link = $contributor->get_link())
    		{
    			$tmpl = str_replace('{FEED_CONTRIBUTOR_LINK}', SimplePie_WordPress::post_process('FEED_CONTRIBUTOR_LINK', $link), $tmpl);
    		}
    		else
    		{
    			$tmpl = str_replace('{FEED_CONTRIBUTOR_LINK}', '', $tmpl);
    		}
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_CONTRIBUTOR_LINK}', '', $tmpl);
    	}
    
    	// FEED_CONTRIBUTOR_NAME
    	if ($contributor = $feed->get_contributor())
    	{
    		if ($name = $contributor->get_name())
    		{
    			$tmpl = str_replace('{FEED_CONTRIBUTOR_NAME}', SimplePie_WordPress::post_process('FEED_CONTRIBUTOR_NAME', $name), $tmpl);
    		}
    		else
    		{
    			$tmpl = str_replace('{FEED_CONTRIBUTOR_NAME}', '', $tmpl);
    		}
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_CONTRIBUTOR_NAME}', '', $tmpl);
    	}
    
    	// FEED_COPYRIGHT
    	if ($copyright = $feed->get_copyright())
    	{
    		$tmpl = str_replace('{FEED_COPYRIGHT}', SimplePie_WordPress::post_process('FEED_COPYRIGHT', $copyright), $tmpl);
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_COPYRIGHT}', '', $tmpl);
    	}
    
    	// FEED_DESCRIPTION
    	if ($description = $feed->get_description())
    	{
    		$tmpl = str_replace('{FEED_DESCRIPTION}', SimplePie_WordPress::post_process('FEED_DESCRIPTION', $description), $tmpl);
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_DESCRIPTION}', '', $tmpl);
    	}
    
    	// FEED_ENCODING
    	if ($encoding = $feed->get_encoding())
    	{
    		$tmpl = str_replace('{FEED_ENCODING}', SimplePie_WordPress::post_process('FEED_ENCODING', $encoding), $tmpl);
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_ENCODING}', '', $tmpl);
    	}
    
    	// FEED_FAVICON
    	if ($favicon = $feed->get_favicon())
    	{
    		$tmpl = str_replace('{FEED_FAVICON}', SimplePie_WordPress::post_process('FEED_FAVICON', $favicon), $tmpl);
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_FAVICON}', '', $tmpl);
    	}
    
    	// FEED_IMAGE_HEIGHT
    	if ($image_height = $feed->get_image_height())
    	{
    		$tmpl = str_replace('{FEED_IMAGE_HEIGHT}', SimplePie_WordPress::post_process('FEED_IMAGE_HEIGHT', $image_height), $tmpl);
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_IMAGE_HEIGHT}', '', $tmpl);
    	}
    
    	// FEED_IMAGE_LINK
    	if ($image_link = $feed->get_image_link())
    	{
    		$tmpl = str_replace('{FEED_IMAGE_LINK}', SimplePie_WordPress::post_process('FEED_IMAGE_LINK', $image_link), $tmpl);
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_IMAGE_LINK}', '', $tmpl);
    	}
    
    	// FEED_IMAGE_TITLE
    	if ($image_title = $feed->get_image_title())
    	{
    		$tmpl = str_replace('{FEED_IMAGE_TITLE}', SimplePie_WordPress::post_process('FEED_IMAGE_TITLE', $image_title), $tmpl);
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_IMAGE_TITLE}', '', $tmpl);
    	}
    
    	// FEED_IMAGE_URL
    	if ($image_url = $feed->get_image_url())
    	{
    		$tmpl = str_replace('{FEED_IMAGE_URL}', SimplePie_WordPress::post_process('FEED_IMAGE_URL', $image_url), $tmpl);
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_IMAGE_URL}', '', $tmpl);
    	}
    
    	// FEED_IMAGE_WIDTH
    	if ($image_width = $feed->get_image_width())
    	{
    		$tmpl = str_replace('{FEED_IMAGE_WIDTH}', SimplePie_WordPress::post_process('FEED_IMAGE_WIDTH', $image_width), $tmpl);
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_IMAGE_WIDTH}', '', $tmpl);
    	}
    
    	// FEED_LANGUAGE
    	if ($language = $feed->get_language())
    	{
    		$tmpl = str_replace('{FEED_LANGUAGE}', SimplePie_WordPress::post_process('FEED_LANGUAGE', $language), $tmpl);
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_LANGUAGE}', '', $tmpl);
    	}
    
    	// FEED_LATITUDE
    	if ($latitude = $feed->get_latitude())
    	{
    		$tmpl = str_replace('{FEED_LATITUDE}', SimplePie_WordPress::post_process('FEED_LATITUDE', $latitude), $tmpl);
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_LATITUDE}', '', $tmpl);
    	}
    
    	// FEED_LONGITUDE
    	if ($longitude = $feed->get_longitude())
    	{
    		$tmpl = str_replace('{FEED_LONGITUDE}', SimplePie_WordPress::post_process('FEED_LONGITUDE', $longitude), $tmpl);
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_LONGITUDE}', '', $tmpl);
    	}
    
    	// FEED_PERMALINK
    	if ($permalink = $feed->get_permalink())
    	{
    		$tmpl = str_replace('{FEED_PERMALINK}', SimplePie_WordPress::post_process('FEED_PERMALINK', $permalink), $tmpl);
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_PERMALINK}', '', $tmpl);
    	}
    
    	// FEED_TITLE
    	if ($title = $feed->get_title())
    	{
    		$tmpl = str_replace('{FEED_TITLE}', SimplePie_WordPress::post_process('FEED_TITLE', $title), $tmpl);
    	}
    	else
    	{
    		$tmpl = str_replace('{FEED_TITLE}', '', $tmpl);
    	}
    
    	// SUBSCRIBE_URL
    	if ($subscribe_url = $feed->subscribe_url())
    	{
    		$tmpl = str_replace('{SUBSCRIBE_URL}', SimplePie_WordPress::post_process('SUBSCRIBE_URL', $subscribe_url), $tmpl);
    	}
    	else
    	{
    		$tmpl = str_replace('{SUBSCRIBE_URL}', '', $tmpl);
    	}
    
    	// TRUNCATE_FEED_DESCRIPTION
    	if ($description = $feed->get_description())
    	{
    		$tmpl = str_replace('{TRUNCATE_FEED_DESCRIPTION}', SimplePie_Truncate(SimplePie_WordPress::post_process('TRUNCATE_FEED_DESCRIPTION', $description), $truncate_feed_description), $tmpl);
    	}
    	else
    	{
    		$tmpl = str_replace('{TRUNCATE_FEED_DESCRIPTION}', '', $tmpl);
    	}
    
    	// TRUNCATE_FEED_TITLE
    	if ($title = $feed->get_title())
    	{
    		$tmpl = str_replace('{TRUNCATE_FEED_TITLE}', SimplePie_Truncate(SimplePie_WordPress::post_process('TRUNCATE_FEED_TITLE', $title), $truncate_feed_title), $tmpl);
    	}
    	else
    	{
    		$tmpl = str_replace('{TRUNCATE_FEED_TITLE}', '', $tmpl);
    	}
    */
    /**************************************************************************************************************/
    // ITEMS
    // Separate out the pre-item template
    $tmpl = explode('{ITEM_LOOP_BEGIN}', $tmpl);
    $pre_tmpl = $tmpl[0];
    // Separate out the item template
    $tmpl = explode('{ITEM_LOOP_END}', $tmpl[1]);
    $item_tmpl = $tmpl[0];
    // Separate out the post-item template
    $post_tmpl = $tmpl[1];
    // Clear out the variable
    unset($tmpl);
    // Start putting the output string together.
    $tmpl = $pre_tmpl;
    // Loop through all of the items that we're supposed to.
    foreach ($feed->get_items(0, $items) as $item) {
        // Get a reference to the parent $feed object.
        $parent = $item->get_feed();
        // Get a working copy of the item template.  We don't want to edit the original.
        $working_item = $item_tmpl;
        // ITEM_CONTRIBUTOR_EMAIL
        /*		if ($contributor = $item->get_contributor())
        		{
        			if ($email = $contributor->get_email())
        			{
        				$working_item = str_replace('{ITEM_CONTRIBUTOR_EMAIL}', SimplePie_WordPress::post_process('ITEM_CONTRIBUTOR_EMAIL', $email), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_CONTRIBUTOR_EMAIL}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_CONTRIBUTOR_EMAIL}', '', $working_item);
        		}
        
        		// ITEM_CONTRIBUTOR_LINK
        		if ($contributor = $item->get_contributor())
        		{
        			if ($link = $contributor->get_link())
        			{
        				$working_item = str_replace('{ITEM_CONTRIBUTOR_LINK}', SimplePie_WordPress::post_process('ITEM_CONTRIBUTOR_LINK', $link), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_CONTRIBUTOR_LINK}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_CONTRIBUTOR_LINK}', '', $working_item);
        		}
        
        		// ITEM_CONTRIBUTOR_NAME
        		if ($contributor = $item->get_contributor())
        		{
        			if ($name = $contributor->get_name())
        			{
        				$working_item = str_replace('{ITEM_CONTRIBUTOR_NAME}', SimplePie_WordPress::post_process('ITEM_CONTRIBUTOR_NAME', $name), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_CONTRIBUTOR_NAME}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_CONTRIBUTOR_NAME}', '', $working_item);
        		}
        
        		// ITEM_COPYRIGHT
        		if ($copyright = $item->get_copyright())
        		{
        			$working_item = str_replace('{ITEM_COPYRIGHT}', SimplePie_WordPress::post_process('ITEM_COPYRIGHT', $copyright), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_COPYRIGHT}', '', $working_item);
        		}
        
        		// ITEM_PARENT_AUTHOR_EMAIL
        		if ($author = $parent->get_author())
        		{
        			if ($email = $author->get_email())
        			{
        				$working_item = str_replace('{ITEM_PARENT_AUTHOR_EMAIL}', SimplePie_WordPress::post_process('ITEM_PARENT_AUTHOR_EMAIL', $email), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_PARENT_AUTHOR_EMAIL}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_AUTHOR_EMAIL}', '', $working_item);
        		}
        
        		// ITEM_PARENT_AUTHOR_LINK
        		if ($author = $parent->get_author())
        		{
        			if ($link = $author->get_link())
        			{
        				$working_item = str_replace('{ITEM_PARENT_AUTHOR_LINK}', SimplePie_WordPress::post_process('ITEM_PARENT_AUTHOR_LINK', $link), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_PARENT_AUTHOR_LINK}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_AUTHOR_LINK}', '', $working_item);
        		}
        
        		// ITEM_PARENT_AUTHOR_NAME
        		if ($author = $parent->get_author())
        		{
        			if ($name = $author->get_name())
        			{
        				$working_item = str_replace('{ITEM_PARENT_AUTHOR_NAME}', SimplePie_WordPress::post_process('ITEM_PARENT_AUTHOR_NAME', $name), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_PARENT_AUTHOR_NAME}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_AUTHOR_NAME}', '', $working_item);
        		}
        
        		// ITEM_PARENT_CONTRIBUTOR_EMAIL
        		if ($contributor = $parent->get_contributor())
        		{
        			if ($email = $contributor->get_email())
        			{
        				$working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_EMAIL}', SimplePie_WordPress::post_process('ITEM_PARENT_CONTRIBUTOR_EMAIL', $email), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_EMAIL}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_EMAIL}', '', $working_item);
        		}
        
        		// ITEM_PARENT_CONTRIBUTOR_LINK
        		if ($contributor = $parent->get_contributor())
        		{
        			if ($link = $contributor->get_link())
        			{
        				$working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_LINK}', SimplePie_WordPress::post_process('ITEM_PARENT_CONTRIBUTOR_LINK', $link), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_LINK}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_LINK}', '', $working_item);
        		}
        
        		// ITEM_PARENT_CONTRIBUTOR_NAME
        		if ($contributor = $parent->get_contributor())
        		{
        			if ($name = $contributor->get_name())
        			{
        				$working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_NAME}', SimplePie_WordPress::post_process('ITEM_PARENT_CONTRIBUTOR_NAME', $name), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_NAME}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_NAME}', '', $working_item);
        		}
        
        		// ITEM_AUTHOR_EMAIL
        		if ($author = $item->get_author())
        		{
        			if ($email = $author->get_email())
        			{
        				$working_item = str_replace('{ITEM_AUTHOR_EMAIL}', SimplePie_WordPress::post_process('ITEM_AUTHOR_EMAIL', $email), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_AUTHOR_EMAIL}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_AUTHOR_EMAIL}', '', $working_item);
        		}
        
        		// ITEM_AUTHOR_LINK
        		if ($author = $item->get_author())
        		{
        			if ($link = $author->get_link())
        			{
        				$working_item = str_replace('{ITEM_AUTHOR_LINK}', SimplePie_WordPress::post_process('ITEM_AUTHOR_LINK', $link), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_AUTHOR_LINK}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_AUTHOR_LINK}', '', $working_item);
        		}
        
        		// ITEM_AUTHOR_NAME
        		if ($author = $item->get_author())
        		{
        			if ($name = $author->get_name())
        			{
        				$working_item = str_replace('{ITEM_AUTHOR_NAME}', SimplePie_WordPress::post_process('ITEM_AUTHOR_NAME', $name), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_AUTHOR_NAME}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_AUTHOR_NAME}', '', $working_item);
        		}
        
        		// ITEM_CATEGORY
        		if ($category = $item->get_category())
        		{
        			if ($label = $category->get_label())
        			{
        				$working_item = str_replace('{ITEM_CATEGORY}', SimplePie_WordPress::post_process('ITEM_CATEGORY', $label), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_CATEGORY}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_CATEGORY}', '', $working_item);
        		}
        */
        // ITEM_CONTENT
        if ($content = $item->get_content()) {
            $working_item = str_replace('{ITEM_CONTENT}', SimplePie_WordPress::post_process('ITEM_CONTENT', $content), $working_item);
        } else {
            $working_item = str_replace('{ITEM_CONTENT}', '', $working_item);
        }
        // ITEM_DATE
        if ($date = $item->get_date($date_format)) {
            $working_item = str_replace('{ITEM_DATE}', SimplePie_WordPress::post_process('ITEM_DATE', $date), $working_item);
        } else {
            $working_item = str_replace('{ITEM_DATE}', '', $working_item);
        }
        // ITEM_DATE_UTC
        if ($date = $item->get_date('U')) {
            $date = gmdate($date_format, $date);
            $working_item = str_replace('{ITEM_DATE_UTC}', SimplePie_WordPress::post_process('ITEM_DATE_UTC', $date), $working_item);
        } else {
            $working_item = str_replace('{ITEM_DATE_UTC}', '', $working_item);
        }
        // ITEM_DESCRIPTION
        if ($description = $item->get_description()) {
            $working_item = str_replace('{ITEM_DESCRIPTION}', SimplePie_WordPress::post_process('ITEM_DESCRIPTION', $description), $working_item);
        } else {
            $working_item = str_replace('{ITEM_DESCRIPTION}', '', $working_item);
        }
        /*
        		// ITEM_ENCLOSURE_EMBED
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->native_embed())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_EMBED}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_EMBED', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_EMBED}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_EMBED}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_EXTENSION
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_extension())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_EXTENSION}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_EXTENSION', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_EXTENSION}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_EXTENSION}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_HANDLER
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_handler())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_HANDLER}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_HANDLER', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_HANDLER}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_HANDLER}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_LENGTH
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_length())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_LENGTH}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_LENGTH', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_LENGTH}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_LENGTH}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_LINK
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_link())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_LINK}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_LINK', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_LINK}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_LINK}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_REAL_TYPE
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_real_type())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_REAL_TYPE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_REAL_TYPE', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_REAL_TYPE}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_REAL_TYPE}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_SIZE
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_size())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_SIZE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_SIZE', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_SIZE}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_SIZE}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_TYPE
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_type())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_TYPE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_TYPE', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_TYPE}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_TYPE}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_BITRATE
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_bitrate())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_BITRATE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_BITRATE', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_BITRATE}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_BITRATE}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_CHANNELS
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_channels())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_CHANNELS}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_CHANNELS', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_CHANNELS}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_CHANNELS}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_DESCRIPTION
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_description())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_DESCRIPTION}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_DESCRIPTION', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_DESCRIPTION}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_DESCRIPTION}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_DURATION
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_duration())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_DURATION}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_DURATION', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_DURATION}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_DURATION}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_EXPRESSION
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_expression())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_EXPRESSION}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_EXPRESSION', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_EXPRESSION}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_EXPRESSION}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_FRAMERATE
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_framerate())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_FRAMERATE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_FRAMERATE', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_FRAMERATE}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_FRAMERATE}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_HASH
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_hash())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_HASH}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_HASH', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_HASH}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_HASH}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_HEIGHT
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_height())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_HEIGHT}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_HEIGHT', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_HEIGHT}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_HEIGHT}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_LANGUAGE
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_language())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_LANGUAGE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_LANGUAGE', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_LANGUAGE}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_LANGUAGE}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_MEDIUM
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_medium())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_MEDIUM}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_MEDIUM', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_MEDIUM}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_MEDIUM}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_PLAYER
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_player())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_PLAYER}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_PLAYER', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_PLAYER}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_PLAYER}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_SAMPLINGRATE
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_sampling_rate())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_SAMPLINGRATE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_SAMPLINGRATE', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_SAMPLINGRATE}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_SAMPLINGRATE}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_THUMBNAIL
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_thumbnail())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_THUMBNAIL}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_THUMBNAIL', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_THUMBNAIL}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_THUMBNAIL}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_TITLE
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_title())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_TITLE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_TITLE', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_TITLE}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_TITLE}', '', $working_item);
        		}
        
        		// ITEM_ENCLOSURE_WIDTH
        		if ($enclosure = $item->get_enclosure())
        		{
        			if ($encltemp = $enclosure->get_width())
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_WIDTH}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_WIDTH', $encltemp), $working_item);
        			}
        			else
        			{
        				$working_item = str_replace('{ITEM_ENCLOSURE_WIDTH}', '', $working_item);
        			}
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ENCLOSURE_WIDTH}', '', $working_item);
        		}
        
        		// ITEM_ID
        		if ($id = $item->get_id())
        		{
        			$working_item = str_replace('{ITEM_ID}', SimplePie_WordPress::post_process('ITEM_ID', $id), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_ID}', '', $working_item);
        		}
        
        		// ITEM_ID
        		if ($latitude = $item->get_latitude())
        		{
        			$working_item = str_replace('{ITEM_LATITUDE}', SimplePie_WordPress::post_process('ITEM_LATITUDE', $latitude), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_LATITUDE}', '', $working_item);
        		}
        
        		// ITEM_LOCAL_DATE
        		if ($local_date = $item->get_local_date($local_date_format))
        		{
        			$working_item = str_replace('{ITEM_LOCAL_DATE}', SimplePie_WordPress::post_process('ITEM_LOCAL_DATE', $local_date), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_LOCAL_DATE}', '', $working_item);
        		}
        
        		// ITEM_LOCAL_DATE_UTC
        		if ($local_date = $item->get_date('U'))
        		{
        			$local_date = gmdate('U', $local_date);
        			$local_date = strftime($local_date_format, $local_date);
        			$working_item = str_replace('{ITEM_LOCAL_DATE_UTC}', SimplePie_WordPress::post_process('ITEM_LOCAL_DATE_UTC', $local_date), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_LOCAL_DATE_UTC}', '', $working_item);
        		}
        
        		// ITEM_LONGITUDE
        		if ($longitude = $item->get_longitude())
        		{
        			$working_item = str_replace('{ITEM_LONGITUDE}', SimplePie_WordPress::post_process('ITEM_LONGITUDE', $longitude), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_LONGITUDE}', '', $working_item);
        		}
        */
        // ITEM_PERMALINK
        if ($permalink = $item->get_permalink()) {
            $working_item = str_replace('{ITEM_PERMALINK}', SimplePie_WordPress::post_process('ITEM_PERMALINK', $permalink), $working_item);
        } else {
            $working_item = str_replace('{ITEM_PERMALINK}', '', $working_item);
        }
        // ITEM_TITLE
        if ($title = $item->get_title()) {
            $working_item = str_replace('{ITEM_TITLE}', SimplePie_WordPress::post_process('ITEM_TITLE', $title), $working_item);
        } else {
            $working_item = str_replace('{ITEM_TITLE}', '', $working_item);
        }
        /*
        		// ITEM_PARENT_COPYRIGHT
        		if ($copyright = $parent->get_copyright())
        		{
        			$working_item = str_replace('{ITEM_PARENT_COPYRIGHT}', SimplePie_WordPress::post_process('ITEM_PARENT_COPYRIGHT', $copyright), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_COPYRIGHT}', '', $working_item);
        		}
        
        		// ITEM_PARENT_DESCRIPTION
        		if ($description = $parent->get_description())
        		{
        			$working_item = str_replace('{ITEM_PARENT_DESCRIPTION}', SimplePie_WordPress::post_process('ITEM_PARENT_DESCRIPTION', $description), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_DESCRIPTION}', '', $working_item);
        		}
        
        		// ITEM_PARENT_ENCODING
        		if ($encoding = $parent->get_encoding())
        		{
        			$working_item = str_replace('{ITEM_PARENT_ENCODING}', SimplePie_WordPress::post_process('ITEM_PARENT_ENCODING', $encoding), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_ENCODING}', '', $working_item);
        		}
        
        		// ITEM_PARENT_FAVICON
        		if ($favicon = $parent->get_favicon())
        		{
        			$working_item = str_replace('{ITEM_PARENT_FAVICON}', SimplePie_WordPress::post_process('ITEM_PARENT_FAVICON', $favicon), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_FAVICON}', '', $working_item);
        		}
        
        		// ITEM_PARENT_IMAGE_HEIGHT
        		if ($image_height = $parent->get_image_height())
        		{
        			$working_item = str_replace('{ITEM_PARENT_IMAGE_HEIGHT}', SimplePie_WordPress::post_process('ITEM_PARENT_IMAGE_HEIGHT', $image_height), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_IMAGE_HEIGHT}', '', $working_item);
        		}
        
        		// ITEM_PARENT_IMAGE_LINK
        		if ($image_link = $parent->get_image_link())
        		{
        			$working_item = str_replace('{ITEM_PARENT_IMAGE_LINK}', SimplePie_WordPress::post_process('ITEM_PARENT_IMAGE_LINK', $image_link), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_IMAGE_LINK}', '', $working_item);
        		}
        
        		// ITEM_PARENT_IMAGE_TITLE
        		if ($image_title = $parent->get_image_title())
        		{
        			$working_item = str_replace('{ITEM_PARENT_IMAGE_TITLE}', SimplePie_WordPress::post_process('ITEM_PARENT_IMAGE_TITLE', $image_title), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_IMAGE_TITLE}', '', $working_item);
        		}
        
        		// ITEM_PARENT_IMAGE_URL
        		if ($image_url = $parent->get_image_url())
        		{
        			$working_item = str_replace('{ITEM_PARENT_IMAGE_URL}', SimplePie_WordPress::post_process('ITEM_PARENT_IMAGE_URL', $image_url), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_IMAGE_URL}', '', $working_item);
        		}
        
        		// ITEM_PARENT_IMAGE_WIDTH
        		if ($image_width = $parent->get_image_width())
        		{
        			$working_item = str_replace('{ITEM_PARENT_IMAGE_WIDTH}', SimplePie_WordPress::post_process('ITEM_PARENT_IMAGE_WIDTH', $image_width), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_IMAGE_WIDTH}', '', $working_item);
        		}
        
        		// ITEM_PARENT_LANGUAGE
        		if ($language = $parent->get_language())
        		{
        			$working_item = str_replace('{ITEM_PARENT_LANGUAGE}', SimplePie_WordPress::post_process('ITEM_PARENT_LANGUAGE', $language), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_LANGUAGE}', '', $working_item);
        		}
        
        		// ITEM_PARENT_LATITUDE
        		if ($latitude = $parent->get_latitude())
        		{
        			$working_item = str_replace('{ITEM_PARENT_LATITUDE}', SimplePie_WordPress::post_process('ITEM_PARENT_LATITUDE', $latitude), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_LATITUDE}', '', $working_item);
        		}
        
        		// ITEM_PARENT_LONGITUDE
        		if ($longitude = $parent->get_longitude())
        		{
        			$working_item = str_replace('{ITEM_PARENT_LONGITUDE}', SimplePie_WordPress::post_process('ITEM_PARENT_LONGITUDE', $longitude), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_LONGITUDE}', '', $working_item);
        		}
        
        		// ITEM_PARENT_PERMALINK
        		if ($permalink = $parent->get_permalink())
        		{
        			$working_item = str_replace('{ITEM_PARENT_PERMALINK}', SimplePie_WordPress::post_process('ITEM_PARENT_PERMALINK', $permalink), $working_item);
        		}
        		else
        		{
        
        			$working_item = str_replace('{ITEM_PARENT_PERMALINK}', '', $working_item);
        		}
        
        		// ITEM_PARENT_TITLE
        		if ($title = $parent->get_title())
        		{
        			$working_item = str_replace('{ITEM_PARENT_TITLE}', SimplePie_WordPress::post_process('ITEM_PARENT_TITLE', $title), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_TITLE}', '', $working_item);
        		}
        
        		// ITEM_PARENT_SUBSCRIBE_URL
        		if ($subscribe_url = $parent->subscribe_url())
        		{
        			$working_item = str_replace('{ITEM_PARENT_SUBSCRIBE_URL}', SimplePie_WordPress::post_process('ITEM_PARENT_SUBSCRIBE_URL', $subscribe_url), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{ITEM_PARENT_SUBSCRIBE_URL}', '', $working_item);
        		}
        */
        // TRUNCATE_ITEM_DESCRIPTION
        if ($description = $item->get_description()) {
            $working_item = str_replace('{TRUNCATE_ITEM_DESCRIPTION}', SimplePie_Truncate(SimplePie_WordPress::post_process('TRUNCATE_ITEM_DESCRIPTION', $description), $truncate_item_description), $working_item);
        } else {
            $working_item = str_replace('{TRUNCATE_ITEM_DESCRIPTION}', '', $working_item);
        }
        // TRUNCATE_ITEM_TITLE
        if ($title = $item->get_title()) {
            $working_item = str_replace('{TRUNCATE_ITEM_TITLE}', SimplePie_Truncate(SimplePie_WordPress::post_process('TRUNCATE_ITEM_TITLE', $title), $truncate_item_title), $working_item);
        } else {
            $working_item = str_replace('{TRUNCATE_ITEM_TITLE}', '', $working_item);
        }
        /*
        		// TRUNCATE_ITEM_PARENT_DESCRIPTION
        		if ($description = $parent->get_description())
        		{
        			$working_item = str_replace('{TRUNCATE_ITEM_PARENT_DESCRIPTION}', SimplePie_Truncate(SimplePie_WordPress::post_process('TRUNCATE_ITEM_PARENT_DESCRIPTION', $description), $truncate_feed_description), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{TRUNCATE_ITEM_PARENT_DESCRIPTION}', '', $working_item);
        		}
        
        		// TRUNCATE_ITEM_PARENT_TITLE
        		if ($title = $parent->get_title())
        		{
        			$working_item = str_replace('{TRUNCATE_ITEM_PARENT_TITLE}', SimplePie_Truncate(SimplePie_WordPress::post_process('TRUNCATE_ITEM_PARENT_TITLE', $title), $truncate_feed_title), $working_item);
        		}
        		else
        		{
        			$working_item = str_replace('{TRUNCATE_ITEM_PARENT_TITLE}', '', $working_item);
        		}
        */
        $tmpl .= $working_item;
    }
    /**************************************************************************************************************/
    // LAST STUFF
    // Start by removing all line breaks and tabs.
    $tmpl = preg_replace('/(\\n|\\r|\\t)/i', "", $tmpl);
    // PLUGIN_DIR
    $tmpl = str_replace('{PLUGIN_DIR}', SIMPLEPIE_PLUGINDIR_WEB, $tmpl);
    $tmpl .= $post_tmpl;
    // Kill the object to prevent memory leaks.
    $feed->__destruct();
    unset($feed);
    unset($encltemp);
    unset($working_item);
    // Return the data back to the page.
    return $tmpl;
}
コード例 #11
0
ファイル: repressed.php プロジェクト: austinjp/repressed
function repress_blog($feed_url)
{
    $output = array();
    $output[snippet] = '';
    $output[title] = '';
    $output[link] = '';
    if (filter_var($feed_url, FILTER_VALIDATE_URL)) {
        /* Check in cache if we've collected the latest post from this blog within past 24 hours */
        $cache_file = repressed_cache_dirname() . '/' . repressed_cache_filename($feed_url);
        /* Cache the whole RSS to a file if the file isn't there, or if it's older than 24 hours */
        $expire_seconds = 86400;
        $expire_date = time() + $expire_seconds;
        $max = 3;
        /* Number of posts to collect from each feed */
        $feed = new SimplePie();
        $feed->set_feed_url($feed_url);
        $feed->set_cache_name_function('repressed_cache_filename');
        $feed->enable_order_by_date(true);
        $feed->set_cache_duration($expire_seconds);
        $feed->set_cache_location(repressed_cache_dirname());
        $feed->enable_cache(true);
        $feed->set_timeout(3);
        $feed->set_item_limit($max);
        $feed->init();
        $post_title = array();
        $post_link = array();
        $post_snip = array();
        $post_date = array();
        $snip_words = 15;
        /* Length of snippet in words */
        foreach ($feed->get_items() as $item) {
            array_push($post_title, $item->get_title());
            array_push($post_link, $item->get_link());
            $snip = substr(strip_tags($item->get_content()), 0, 500);
            $snip = implode(" ", array_slice(explode(" ", $snip), 0, $snip_words));
            $snip = preg_replace('/\\s*$/', '...', $snip);
            array_push($post_snip, $snip);
        }
        $output[title] = $post_title[0];
        $output[link] = $post_link[0];
        $output[snippet] = $post_snip[0];
        return $output;
    } else {
        return FALSE;
    }
}
コード例 #12
0
ファイル: rss.php プロジェクト: kosir/wp-pipes
 public static function get_items_feed($url, $params = null)
 {
     $feed = new SimplePie();
     $mode = isset($params->mode) ? $params->mode : 0;
     if ($mode == 0) {
         $feed->set_feed_url($url);
     } else {
         $html = ogbFile::get_curl($url);
         $feed->set_raw_data($html);
     }
     $feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE);
     $feed->set_timeout(20);
     $feed->enable_cache(false);
     $feed->set_stupidly_fast(true);
     $feed->enable_order_by_date(false);
     // we don't want to do anything to the feed
     $feed->set_url_replacements(array());
     $feed->force_feed(true);
     $result = $feed->init();
     if (isset($_GET['x'])) {
         echo "\n\n<br /><i><b>File:</b>" . __FILE__ . ' <b>Line:</b>' . __LINE__ . "</i><br />\n\n";
         echo "<p>URL: [{$url}]</p>";
         echo "<p>Error: [{$feed->error}]</p>";
     }
     $items = $feed->get_items();
     $c_items = count($items);
     if ($c_items == 0) {
         echo "<p>Error: [{$feed->error}]</p>";
         return array();
     }
     for ($i = 0; $i < count($items); $i++) {
         $row = new stdclass();
         $row->title = $items[$i]->get_title();
         # the title for the post
         $row->link = $items[$i]->get_link();
         # a single link for the post
         $row->description = $items[$i]->get_description();
         # the content of the post (prefers summaries)
         $row->author = $items[$i]->get_author();
         # a single author for the post
         $row->date = $items[$i]->get_date('Y-m-d H:i:s');
         $row->enclosures = $items[$i]->get_enclosures();
         $rows[] = $row;
     }
     return $rows;
 }
コード例 #13
0
ファイル: loadInfo.php プロジェクト: JackBuh/kindle
function initRss($rssLink, $user)
{
    $db = DBCxn::get();
    //构建对象
    $feed = new SimplePie();
    $feed->set_feed_url($rssLink);
    //feed地址做参数进行解析操作
    $feed->set_timeout(30);
    $feed->enable_cache(false);
    $feed->init();
    if ($feed->error()) {
        //feed地址错误
        //echo $feed->error();
        return "error";
    }
    $blogName = $feed->get_title();
    $blogLink = $feed->get_link();
    $selectOneRSS = $db->prepare("SELECT id FROM rss WHERE blogLink = ?");
    $selectOneRSS->execute(array($blogLink));
    $blogLinkId = $selectOneRSS->fetchColumn();
    //此RSS在数据库表中id
    //检查是否存在,如果不存在添加此feed
    if ($blogLinkId > 0) {
        //echo "此订阅源已经存在!";
        //检查用户是否已经订阅
        $checkSub = $db->prepare("SELECT count(*) FROM readinfo WHERE userName = ? AND rssId = ?");
        $checkSub->execute(array($user, $blogLinkId));
        $boolCheckSub = $checkSub->fetchColumn();
        if ($boolCheckSub != 1) {
            //用户没有订阅
            $insertReadInfo = $db->prepare("INSERT INTO readinfo(userName,rssId) VALUES(:user,:blogLinkId)");
            $insertReadInfo->bindParam(':user', $user);
            $insertReadInfo->bindParam(':blogLinkId', $blogLinkId);
            $insertReadInfo->execute();
            //"此源已经存在,你之前尚未订阅,现在已经订阅";
            //return "succeed1";
            return "rss-" . $blogLinkId;
        } else {
            //"此源已经存在,你之前已经订阅";
            return "succeed2";
        }
    } else {
        $sql = "INSERT INTO rss(blogName,blogLink,rssLink,updateMd5) VALUES(:blogName,:blogLink,:rssLink,:updateMd5)";
        $insertRSS = $db->prepare($sql);
        $insertRSS->bindParam(':blogName', $blogName);
        $insertRSS->bindParam(':blogLink', $blogLink);
        $insertRSS->bindParam(':rssLink', $rssLink);
        $insertRSS->bindParam(':updateMd5', $updateMd5);
        $updateMd5 = md5("123456");
        $insertRSS->execute();
        //查询该源的ID
        $selectOneRSS = $db->prepare("SELECT id FROM rss WHERE blogLink = ?");
        $selectOneRSS->execute(array($blogLink));
        $blogLinkId = $selectOneRSS->fetchColumn();
        //订阅此源
        //$db->exec("INSERT INTO readinfo(userName,rssId) VALUES ($user, $blogLinkId)");
        $insertReadInfo = $db->prepare("INSERT INTO readinfo(userName,rssId) VALUES(:user,:blogLinkId)");
        $insertReadInfo->bindParam(':user', $user);
        $insertReadInfo->bindParam(':blogLinkId', $blogLinkId);
        $insertReadInfo->execute();
        //"此源不存在,现在已经订阅";
        return "rss-" . $blogLinkId;
    }
}
コード例 #14
0
function WPZOOM_Dashboard()
{
    ?>
<div class="table table_news">
    <p class="sub">From our Blog</p>
    <div class="rss-widget">
        <?php 
    /**
     * Get RSS Feed(s)
     */
    $items = get_transient('wpzoom_dashboard_widget_news');
    if (!(is_array($items) && count($items))) {
        include_once ABSPATH . WPINC . '/class-simplepie.php';
        $rss = new SimplePie();
        $rss->set_timeout(5);
        $rss->set_feed_url('http://www.wpzoom.com/feed/');
        $rss->strip_htmltags(array_merge($rss->strip_htmltags, array('h1', 'a', 'img')));
        $rss->enable_cache(false);
        $rss->init();
        $items = $rss->get_items(0, 3);
        $cached = array();
        foreach ($items as $item) {
            $cached[] = array('url' => $item->get_permalink(), 'title' => $item->get_title(), 'date' => $item->get_date("d M Y"), 'content' => substr(strip_tags($item->get_content()), 0, 128) . "...");
        }
        $items = $cached;
        set_transient('wpzoom_dashboard_widget_news', $cached, 60 * 60 * 24);
    }
    ?>

        <ul class="news">
            <?php 
    if (empty($items)) {
        echo '<li>No items</li>';
    } else {
        foreach ($items as $item) {
            ?>

                <li class="post">
                    <a href="<?php 
            echo $item['url'];
            ?>
" class="rsswidget"><?php 
            echo $item['title'];
            ?>
</a>
                    <span class="rss-date"><?php 
            echo $item['date'];
            ?>
</span>
                    <div class="rssSummary"><?php 
            echo $item['content'];
            ?>
</div>
                </li>

            <?php 
        }
    }
    ?>
        </ul><!-- end of .news -->
    </div>
</div>

<div class="table table_theme">
    <p class="sub">Latest Theme</p>
    <div class="theme_thumb">
        <?php 
    $current = get_transient('wpzoom_dashboard_widget_theme');
    if (!is_object($current) || !isset($current->data)) {
        $current = new stdClass();
        $current->lastChecked = 0;
    }
    $time_changed = 24 * HOUR_IN_SECONDS < time() - $current->lastChecked;
    if ($time_changed) {
        $response = wp_remote_get('http://www.wpzoom.com/frame/latest_theme.html');
        if (!is_wp_error($response) && 200 == wp_remote_retrieve_response_code($response)) {
            $current->data = wp_remote_retrieve_body($response);
        }
        $current->lastChecked = time();
        set_transient('wpzoom_dashboard_widget_theme', $current);
    }
    ?>

        <?php 
    if ($current) {
        echo $current->data;
    }
    ?>

    </div>

    <a href="http://wpzoom.com/themes/" target="_blank" alt="Browse our wide selection of WordPress themes to find the right one for you" class="button">Browse more &rarr;</a>
</div>

<div class="clear">&nbsp;</div>
<?php 
}
コード例 #15
0
 public function execute()
 {
     parent::execute();
     if ($this->action == 'NewsreaderCache') {
         $urls = preg_split('/\\r?\\n/', SPNRBOX_FEEDS);
         $cache_location = WBB_DIR . 'lib/data/boxes/SimplePieNewsReader/cache';
         // CHARSET
         if (!defined('CHARSET')) {
             define('CHARSET', 'UTF-8');
         }
         if (!defined('SPNRBOX_CHARSET')) {
             define('SPNRBOX_CHARSET', 'UTF-8');
         }
         if (SPNRBOX_CHARSET == 'default') {
             $charset = CHARSET;
         } else {
             $charset = SPNRBOX_CHARSET;
         }
         // FILTER?
         if (SPNRBOX_FILTER && strlen(SPNRBOX_FILTERWORDS) >= 3) {
             require_once WBB_DIR . 'lib/data/boxes/SimplePieNewsReader/simplepie_filter.php';
             $feed = new SimplePie_Filter();
             if (!defined('SPNRBOX_FILTERCLASS')) {
                 define('SPNRBOX_FILTERCLASS', 'hightlight');
             }
             define('SPNRBOX_FILTERON', 1);
         } else {
             $feed = new SimplePie();
             define('SPNRBOX_FILTERON', 0);
         }
         $feed->set_feed_url($urls);
         $feed->set_cache_location($cache_location);
         $feed->set_autodiscovery_cache_duration(0);
         $feed->set_cache_duration(0);
         $feed->set_favicon_handler(RELATIVE_WBB_DIR . 'lib/data/boxes/SimplePieNewsReader/handler_image.php');
         $feed->set_image_handler(RELATIVE_WBB_DIR . 'lib/data/boxes/SimplePieNewsReader/handler_image.php');
         $feed->set_output_encoding($charset);
         $feed->set_timeout(10);
         $feed->init();
         $feed->handle_content_type();
         if (SPNRBOX_FILTERON) {
             $feed->set_filter(SPNRBOX_FILTERWORDS, SPNRBOX_FILTERMODE);
         }
         header("Content-type: text/plain; charset=UTF-8");
         foreach ($urls as $feeds) {
             $feeds = trim($feeds);
             if (empty($feeds)) {
                 continue;
             }
             $feed->set_feed_url($feeds);
             $feed->init();
             $items = $feed->get_items();
             if (SPNRBOX_FILTERON) {
                 $items = $feed->filter($items);
             }
             echo $feed->get_title() . "\n";
             if (!count($items)) {
                 echo "\tKeine Feeds gefunden.\n";
             } else {
                 $i = 0;
                 foreach ($items as $item) {
                     if ($i >= SPNRBOX_NUMOFFEEDS) {
                         break;
                     }
                     SPNRBOX_FILTERON ? $this->highlight(SPNRBOX_FILTERWORDS, $item->get_content(), SPNRBOX_FILTERCLASS) : $item->get_content();
                     echo "\t\"" . $item->get_title() . "\" -> wurde geladen.\n";
                     $i++;
                 }
             }
         }
     }
 }
コード例 #16
0
 /**
  * _createSimplePie
  *
  * @param   string  &$feed  Params
  *
  * @return	object
  */
 private function _createSimplePie(&$feed)
 {
     include_once JPATH_AUTOTWEET . '/libs/SimplePie_autoloader.php';
     // Process the feed with SimplePie
     $simplePie = new SimplePie();
     $simplePie->set_feed_url($feed->xtform->get('url'));
     $simplePie->set_stupidly_fast(true);
     $simplePie->enable_order_by_date(true);
     if ($feed->xtform->get('encoding', 'utf-8')) {
         $simplePie->set_input_encoding($feed->xtform->get('encoding'));
     }
     if ($feed->xtform->get('force_fsockopen')) {
         $simplePie->force_fsockopen(true);
     }
     $use_sp_cache = EParameter::getComponentParam(CAUTOTWEETNG, 'use_sp_cache', true);
     if ($use_sp_cache && is_writable(JPATH_CACHE)) {
         $simplePie->set_cache_location(JPATH_CACHE);
         $simplePie->enable_cache(true);
     } else {
         $simplePie->enable_cache(false);
     }
     $set_sp_timeout = EParameter::getComponentParam(CAUTOTWEETNG, 'set_sp_timeout', 10);
     if ($set_sp_timeout) {
         $simplePie->set_timeout((int) $set_sp_timeout);
     }
     $simplePie->init();
     return $simplePie;
 }
コード例 #17
0
 private function loadFeed($url)
 {
     // I prefer simplepie to zend_feed
     $feed = new SimplePie();
     $feed->set_feed_url($url);
     $feed->set_timeout(30);
     $feed->set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/temp');
     $feed->set_cache_duration(300);
     $feed->init();
     //$feed->handle_content_type();
     return $feed;
 }
コード例 #18
0
ファイル: rssreader.php プロジェクト: kosir/wp-pipes
 public static function get_default_item()
 {
     $id = filter_input(INPUT_POST, 'id');
     $value_default = filter_input(INPUT_POST, 'val_default');
     if ($value_default == '') {
         return 'Do nothing!';
     }
     $feed = new SimplePie();
     $path = OGRAB_EDATA . 'item-' . $id . DS . 'row-default.dat';
     $feed->set_feed_url($value_default);
     $feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE);
     $feed->set_timeout(20);
     $feed->enable_cache(false);
     $feed->set_stupidly_fast(true);
     $feed->enable_order_by_date(false);
     // we don't want to do anything to the feed
     $feed->set_url_replacements(array());
     $result = $feed->init();
     if (isset($_GET['x'])) {
         echo "\n\n<br /><i><b>File:</b>" . __FILE__ . ' <b>Line:</b>' . __LINE__ . "</i><br />\n\n";
         echo "<p>URL: [{$value_default}]</p>";
         echo "<p>Error: [{$feed->error}]</p>";
     }
     $items = $feed->get_items();
     $c_items = count($items);
     if ($c_items == 0) {
         echo "<p>Error: [{$feed->error}]</p>";
         return array();
     }
     $row = new stdclass();
     $row->title = html_entity_decode($items[0]->get_title(), ENT_QUOTES, 'UTF-8');
     # the title for the post
     $row->link = $items[0]->get_link();
     # a single link for the post
     $row->description = $items[0]->get_description();
     # the content of the post (prefers summaries)
     $row->author = $items[0]->get_author();
     # a single author for the post
     $row->date = $items[0]->get_date('Y-m-d H:i:s');
     $row->enclosures = $items[0]->get_enclosures();
     if (!is_file($path)) {
         $source = new stdClass();
     } else {
         $source = ogb_common::get_default_data('', $id);
     }
     $source->so = $row;
     $cache = serialize($source);
     if (isset($_GET['x2'])) {
         //echo "\n\n<br /><i><b>File:</b>".__FILE__.' <b>Line:</b>'.__LINE__."</i><br />\n\n";
         echo '<br>Path: ' . $path;
     }
     ogbFile::write($path, $cache);
     exit;
 }
コード例 #19
0
 public function create()
 {
     if (!$this->axipi_session->userdata('mbr_id')) {
         redirect(base_url() . '?u=' . $this->input->get('u'));
     }
     $data = array();
     $content = array();
     $this->load->library(array('form_validation', 'analyzer_library'));
     if ($this->config->item('folders')) {
         $query = $this->db->query('SELECT flr.* FROM ' . $this->db->dbprefix('folders') . ' AS flr WHERE flr.mbr_id = ? GROUP BY flr.flr_id ORDER BY flr.flr_title ASC', array($this->member->mbr_id));
         $data['folders'] = array();
         $data['folders'][0] = $this->lang->line('no_folder');
         if ($query->num_rows() > 0) {
             foreach ($query->result() as $flr) {
                 $data['folders'][$flr->flr_id] = $flr->flr_title;
             }
         }
     }
     $this->form_validation->set_rules('url', 'lang:url_feed', 'required');
     if ($this->config->item('folders')) {
         $this->form_validation->set_rules('folder', 'lang:folder', 'required');
     }
     $this->form_validation->set_rules('priority', 'lang:priority', 'numeric');
     //$this->form_validation->set_rules('direction', 'lang:direction', '');
     $data['error'] = false;
     $data['feeds'] = array();
     if ($this->input->post('url') && !$this->input->post('analyze_done')) {
         $this->analyzer_library->start($this->input->post('url'));
         $metas = $this->analyzer_library->metas;
         if (count($metas) > 0) {
             $data['feeds'][''] = '-';
             foreach ($metas as $meta) {
                 $add = true;
                 $headers = get_headers($meta['href'], 1);
                 if (isset($headers['Location']) == 1) {
                     $meta['href'] = $headers['Location'];
                     $headers = get_headers($meta['href'], 1);
                     if (isset($headers['Location']) == 1) {
                         $add = false;
                     }
                 }
                 if ($add) {
                     if ($meta['title'] == '') {
                         $data['feeds'][$meta['href']] = $meta['href'];
                     } else {
                         $this->analyzer_library->encoding($meta['title']);
                         $data['feeds'][$meta['href']] = $meta['title'];
                     }
                 }
             }
         }
     }
     if ($this->form_validation->run() == FALSE || count($data['feeds']) > 0) {
         $content = $this->load->view('subscriptions_create', $data, TRUE);
     } else {
         if ($this->config->item('folders')) {
             $folder = false;
             if ($this->input->post('folder')) {
                 $query = $this->db->query('SELECT flr.* FROM ' . $this->db->dbprefix('folders') . ' AS flr WHERE flr.mbr_id = ? AND flr.flr_id = ? GROUP BY flr.flr_id', array($this->member->mbr_id, $this->input->post('folder')));
                 if ($query->num_rows() > 0) {
                     $folder = $this->input->post('folder');
                 }
             }
         }
         $query = $this->db->query('SELECT fed.*, sub.sub_id FROM ' . $this->db->dbprefix('feeds') . ' AS fed LEFT JOIN ' . $this->db->dbprefix('subscriptions') . ' AS sub ON sub.fed_id = fed.fed_id AND sub.mbr_id = ? WHERE fed.fed_link = ? GROUP BY fed.fed_id', array($this->member->mbr_id, $this->input->post('url')));
         if ($query->num_rows() == 0) {
             $parse_url = parse_url($this->input->post('url'));
             if (isset($parse_url['host']) == 1 && $parse_url['host'] == 'instagram.com' && $this->config->item('instagram/enabled')) {
                 if ($this->config->item('instagram/access_token')) {
                     $parts = explode('/', rtrim($parse_url['path'], '/'));
                     $total_parts = count($parts);
                     $last_part = $parts[$total_parts - 1];
                     $result = json_decode(file_get_contents('https://api.instagram.com/v1/users/search?q=' . $last_part . '&count=15&access_token=' . $this->config->item('instagram/access_token')));
                     if (count($result->data) == 0) {
                         $data['error'] = 'User not found';
                     } else {
                         $user_id = false;
                         foreach ($result->data as $user) {
                             if ($user->username == $last_part) {
                                 $user_id = $user->id;
                                 break;
                             }
                         }
                         if (!$user_id) {
                             $data['error'] = 'User not found';
                         } else {
                             $result = json_decode(file_get_contents('https://api.instagram.com/v1/users/' . $user_id . '?access_token=' . $this->config->item('instagram/access_token')));
                             $this->db->set('fed_title', 'Instagram @' . $result->data->username);
                             $this->db->set('fed_url', $this->input->post('url'));
                             $this->db->set('fed_description', $result->data->bio);
                             $this->db->set('fed_image', $result->data->profile_picture);
                             $this->db->set('fed_link', $this->input->post('url'));
                             if (isset($parse_url['host']) == 1) {
                                 $this->db->set('fed_host', $parse_url['host']);
                             }
                             $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                             $this->db->set('fed_datecreated', date('Y-m-d H:i:s'));
                             $this->db->insert('feeds');
                             $fed_id = $this->db->insert_id();
                             $this->db->set('mbr_id', $this->member->mbr_id);
                             $this->db->set('fed_id', $fed_id);
                             if ($this->config->item('folders')) {
                                 if ($folder) {
                                     $this->db->set('flr_id', $folder);
                                 }
                             }
                             $this->db->set('sub_priority', $this->input->post('priority'));
                             $this->db->set('sub_direction', $this->input->post('direction'));
                             $this->db->set('sub_datecreated', date('Y-m-d H:i:s'));
                             $this->db->insert('subscriptions');
                             $sub_id = $this->db->insert_id();
                             $result = json_decode(file_get_contents('https://api.instagram.com/v1/users/' . $user_id . '/media/recent?access_token=' . $this->config->item('instagram/access_token')));
                             $this->readerself_library->crawl_items_instagram($fed_id, $result->data);
                         }
                     }
                 }
             } else {
                 if (isset($parse_url['host']) == 1 && $parse_url['host'] == 'www.facebook.com' && $this->config->item('facebook/enabled')) {
                     include_once 'thirdparty/facebook/autoload.php';
                     $fb = new Facebook\Facebook(array('app_id' => $this->config->item('facebook/id'), 'app_secret' => $this->config->item('facebook/secret')));
                     $fbApp = $fb->getApp();
                     $accessToken = $fbApp->getAccessToken();
                     try {
                         $parts = explode('/', rtrim($parse_url['path'], '/'));
                         $total_parts = count($parts);
                         $last_part = $parts[$total_parts - 1];
                         $request = new Facebook\FacebookRequest($fbApp, $accessToken, 'GET', $last_part . '?fields=link,name,about');
                         $response = $fb->getClient()->sendRequest($request);
                         $result = $response->getDecodedBody();
                         $this->db->set('fed_title', $result['name']);
                         $this->db->set('fed_url', $result['link']);
                         $this->db->set('fed_description', $result['about']);
                         $this->db->set('fed_link', $result['link']);
                         if (isset($parse_url['host']) == 1) {
                             $this->db->set('fed_host', $parse_url['host']);
                         }
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         $this->db->set('fed_datecreated', date('Y-m-d H:i:s'));
                         $this->db->insert('feeds');
                         $fed_id = $this->db->insert_id();
                         $this->db->set('mbr_id', $this->member->mbr_id);
                         $this->db->set('fed_id', $fed_id);
                         if ($this->config->item('folders')) {
                             if ($folder) {
                                 $this->db->set('flr_id', $folder);
                             }
                         }
                         $this->db->set('sub_priority', $this->input->post('priority'));
                         $this->db->set('sub_direction', $this->input->post('direction'));
                         $this->db->set('sub_datecreated', date('Y-m-d H:i:s'));
                         $this->db->insert('subscriptions');
                         $sub_id = $this->db->insert_id();
                         $request = new Facebook\FacebookRequest($fbApp, $accessToken, 'GET', $last_part . '?fields=feed{created_time,id,message,story,full_picture,place,type,status_type,link}');
                         $response = $fb->getClient()->sendRequest($request);
                         $posts = $response->getDecodedBody();
                         $this->readerself_library->crawl_items_facebook($fed_id, $posts['feed']['data']);
                         redirect(base_url() . 'subscriptions/read/' . $sub_id);
                     } catch (Facebook\Exceptions\FacebookResponseException $e) {
                         $data['error'] = 'Graph returned an error: ' . $e->getMessage();
                     } catch (Facebook\Exceptions\FacebookSDKException $e) {
                         $data['error'] = 'Facebook SDK returned an error: ' . $e->getMessage();
                     }
                 } else {
                     include_once 'thirdparty/simplepie/autoloader.php';
                     include_once 'thirdparty/simplepie/idn/idna_convert.class.php';
                     $sp_feed = new SimplePie();
                     $sp_feed->set_feed_url(convert_to_ascii($this->input->post('url')));
                     $sp_feed->enable_cache(false);
                     $sp_feed->set_timeout(60);
                     $sp_feed->force_feed(true);
                     $sp_feed->init();
                     $sp_feed->handle_content_type();
                     if ($sp_feed->error()) {
                         $data['error'] = $sp_feed->error();
                     } else {
                         $parse_url = parse_url($sp_feed->get_link());
                         $this->db->set('fed_title', $sp_feed->get_title());
                         $this->db->set('fed_url', $sp_feed->get_link());
                         $this->db->set('fed_description', $sp_feed->get_description());
                         $this->db->set('fed_link', $sp_feed->subscribe_url());
                         if (isset($parse_url['host']) == 1) {
                             $this->db->set('fed_host', $parse_url['host']);
                         }
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         $this->db->set('fed_datecreated', date('Y-m-d H:i:s'));
                         $this->db->insert('feeds');
                         $fed_id = $this->db->insert_id();
                         $this->db->set('mbr_id', $this->member->mbr_id);
                         $this->db->set('fed_id', $fed_id);
                         if ($this->config->item('folders')) {
                             if ($folder) {
                                 $this->db->set('flr_id', $folder);
                             }
                         }
                         $this->db->set('sub_priority', $this->input->post('priority'));
                         $this->db->set('sub_direction', $this->input->post('direction'));
                         $this->db->set('sub_datecreated', date('Y-m-d H:i:s'));
                         $this->db->insert('subscriptions');
                         $sub_id = $this->db->insert_id();
                         $data['sub_id'] = $sub_id;
                         $data['fed_title'] = $sp_feed->get_title();
                         $this->readerself_library->crawl_items($fed_id, $sp_feed->get_items());
                     }
                     $sp_feed->__destruct();
                     unset($sp_feed);
                 }
             }
         } else {
             $fed = $query->row();
             if (!$fed->sub_id) {
                 $this->db->set('mbr_id', $this->member->mbr_id);
                 $this->db->set('fed_id', $fed->fed_id);
                 if ($this->config->item('folders')) {
                     if ($folder) {
                         $this->db->set('flr_id', $folder);
                     }
                 }
                 $this->db->set('sub_priority', $this->input->post('priority'));
                 $this->db->set('sub_direction', $this->input->post('direction'));
                 $this->db->set('sub_datecreated', date('Y-m-d H:i:s'));
                 $this->db->insert('subscriptions');
                 $sub_id = $this->db->insert_id();
             } else {
                 $sub_id = $fed->sub_id;
             }
             $data['sub_id'] = $sub_id;
             $data['fed_title'] = $fed->fed_title;
         }
         if ($data['error']) {
             $content = $this->load->view('subscriptions_create', $data, TRUE);
         } else {
             redirect(base_url() . 'subscriptions/read/' . $sub_id);
         }
     }
     $this->readerself_library->set_content($content);
 }
コード例 #20
0
/**
 * A clone of the function 'fetch_feed' in wp-includes/feed.php [line #529]
 *
 * Called from 'wprss_get_feed_items'
 *
 * @since 3.5
 */
function wprss_fetch_feed($url, $source = NULL, $param_force_feed = FALSE)
{
    // Trim the URL
    $url = trim($url);
    // Initialize the Feed
    $feed = new SimplePie();
    // Obselete method calls ?
    //$feed->set_cache_class( 'WP_Feed_Cache' );
    //$feed->set_file_class( 'WP_SimplePie_File' );
    $feed->set_feed_url($url);
    $feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_ALL);
    // If a feed source was passed
    if ($source !== NULL || $param_force_feed) {
        // Get the force feed option for the feed source
        $force_feed = get_post_meta($source, 'wprss_force_feed', TRUE);
        // If turned on, force the feed
        if ($force_feed == 'true' || $param_force_feed) {
            $feed->force_feed(TRUE);
        }
    }
    // Set timeout limit
    $fetch_time_limit = wprss_get_feed_fetch_time_limit();
    $feed->set_timeout($fetch_time_limit);
    //$feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) );
    $feed->enable_cache(FALSE);
    // Reference array action hook, for the feed object and the URL
    do_action_ref_array('wp_feed_options', array(&$feed, $url));
    // Prepare the tags to strip from the feed
    $tags_to_strip = apply_filters('wprss_feed_tags_to_strip', $feed->strip_htmltags, $source);
    // Strip them
    $feed->strip_htmltags($tags_to_strip);
    do_action('wprss_fetch_feed_before', $feed);
    // Fetch the feed
    $feed->init();
    $feed->handle_content_type();
    do_action('wprss_fetch_feed_after', $feed);
    // Convert the feed error into a WP_Error, if applicable
    if ($feed->error()) {
        if ($source !== NULL) {
            $msg = sprintf(__('Failed to fetch the RSS feed. Error: %s', WPRSS_TEXT_DOMAIN), $feed->error());
            update_post_meta($source, 'wprss_error_last_import', $msg);
        }
        return new WP_Error('simplepie-error', $feed->error());
    }
    // If no error, return the feed and remove any error meta
    delete_post_meta($source, "wprss_error_last_import");
    return $feed;
}
コード例 #21
0
ファイル: refresh.php プロジェクト: esironal/readerself
 public function items()
 {
     if ($this->input->is_ajax_request()) {
         $this->readerself_library->set_template('_json');
         $this->readerself_library->set_content_type('application/json');
         $content = array();
     } else {
         $this->readerself_library->set_template('_plain');
         $this->readerself_library->set_content_type('text/plain');
         $content = '';
     }
     if ($this->input->is_cli_request() && !$this->config->item('refresh_by_cron')) {
         $content .= 'Refresh by cron disabled' . "\n";
     } else {
         include_once 'thirdparty/simplepie/autoloader.php';
         include_once 'thirdparty/simplepie/idn/idna_convert.class.php';
         if ($this->config->item('facebook/enabled')) {
             include_once 'thirdparty/facebook/autoload.php';
             $fb = new Facebook\Facebook(array('app_id' => $this->config->item('facebook/id'), 'app_secret' => $this->config->item('facebook/secret')));
             $fbApp = $fb->getApp();
             $accessToken = $fbApp->getAccessToken();
         }
         $query = $this->db->query('SELECT fed.* FROM ' . $this->db->dbprefix('feeds') . ' AS fed WHERE fed.fed_nextcrawl IS NULL OR fed.fed_nextcrawl <= ? GROUP BY fed.fed_id HAVING (SELECT COUNT(DISTINCT(sub.mbr_id)) FROM ' . $this->db->dbprefix('subscriptions') . ' AS sub WHERE sub.fed_id = fed.fed_id) > 0', array(date('Y-m-d H:i:s')));
         if ($query->num_rows() > 0) {
             $microtime_start = microtime(1);
             $errors = 0;
             foreach ($query->result() as $fed) {
                 $parse_url = parse_url($fed->fed_link);
                 if (isset($parse_url['host']) == 1 && $parse_url['host'] == 'www.facebook.com' && $this->config->item('facebook/enabled')) {
                     try {
                         $parts = explode('/', $parse_url['path']);
                         $total_parts = count($parts);
                         $last_part = $parts[$total_parts - 1];
                         $request = new Facebook\FacebookRequest($fbApp, $accessToken, 'GET', $last_part . '?fields=link,name,about');
                         $response = $fb->getClient()->sendRequest($request);
                         $result = $response->getDecodedBody();
                         $request = new Facebook\FacebookRequest($fbApp, $accessToken, 'GET', $last_part . '?fields=feed{created_time,id,message,story,full_picture,place,type,status_type,link}');
                         $response = $fb->getClient()->sendRequest($request);
                         $posts = $response->getDecodedBody();
                         $this->readerself_library->crawl_items_facebook($fed->fed_id, $posts['feed']['data']);
                         $lastitem = $this->db->query('SELECT itm.itm_datecreated FROM ' . $this->db->dbprefix('items') . ' AS itm WHERE itm.fed_id = ? GROUP BY itm.itm_id ORDER BY itm.itm_id DESC LIMIT 0,1', array($fed->fed_id))->row();
                         $this->db->set('fed_title', $result['name']);
                         $this->db->set('fed_url', $result['link']);
                         $this->db->set('fed_link', $result['link']);
                         if (isset($parse_url['host']) == 1) {
                             $this->db->set('fed_host', $parse_url['host']);
                         }
                         $this->db->set('fed_description', $result['about']);
                         $this->db->set('fed_lasterror', '');
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         if ($lastitem) {
                             $nextcrawl = '';
                             //older than 96 hours, next crawl in 12 hours
                             if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 24 * 96)) {
                                 $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 12);
                                 //older than 48 hours, next crawl in 6 hours
                             } else {
                                 if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 48)) {
                                     $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 6);
                                     //older than 24 hours, next crawl in 3 hours
                                 } else {
                                     if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 24)) {
                                         $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 3);
                                     }
                                 }
                             }
                             $this->db->set('fed_nextcrawl', $nextcrawl);
                         }
                         $this->db->where('fed_id', $fed->fed_id);
                         $this->db->update('feeds');
                     } catch (Facebook\Exceptions\FacebookResponseException $e) {
                         $errors++;
                         $this->db->set('fed_lasterror', 'Graph returned an error: ' . $e->getMessage());
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         $this->db->where('fed_id', $fed->fed_id);
                         $this->db->update('feeds');
                     } catch (Facebook\Exceptions\FacebookSDKException $e) {
                         $errors++;
                         $this->db->set('fed_lasterror', 'Facebook SDK returned an error: ' . $e->getMessage());
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         $this->db->where('fed_id', $fed->fed_id);
                         $this->db->update('feeds');
                     }
                 } else {
                     $sp_feed = new SimplePie();
                     $sp_feed->set_feed_url(convert_to_ascii($fed->fed_link));
                     $sp_feed->enable_cache(false);
                     $sp_feed->set_timeout(5);
                     $sp_feed->force_feed(true);
                     $sp_feed->init();
                     $sp_feed->handle_content_type();
                     if ($sp_feed->error()) {
                         $errors++;
                         $this->db->set('fed_lasterror', $sp_feed->error());
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         $this->db->where('fed_id', $fed->fed_id);
                         $this->db->update('feeds');
                     } else {
                         $this->readerself_library->crawl_items($fed->fed_id, $sp_feed->get_items());
                         $lastitem = $this->db->query('SELECT itm.itm_datecreated FROM ' . $this->db->dbprefix('items') . ' AS itm WHERE itm.fed_id = ? GROUP BY itm.itm_id ORDER BY itm.itm_id DESC LIMIT 0,1', array($fed->fed_id))->row();
                         $parse_url = parse_url($sp_feed->get_link());
                         $this->db->set('fed_title', $sp_feed->get_title());
                         $this->db->set('fed_url', $sp_feed->get_link());
                         $this->db->set('fed_link', $sp_feed->subscribe_url());
                         if (isset($parse_url['host']) == 1) {
                             $this->db->set('fed_host', $parse_url['host']);
                         }
                         if ($sp_feed->get_type() & SIMPLEPIE_TYPE_RSS_ALL) {
                             $this->db->set('fed_type', 'rss');
                         } else {
                             if ($sp_feed->get_type() & SIMPLEPIE_TYPE_ATOM_ALL) {
                                 $this->db->set('fed_type', 'atom');
                             }
                         }
                         if ($sp_feed->get_image_url()) {
                             $this->db->set('fed_image', $sp_feed->get_image_url());
                         }
                         $this->db->set('fed_description', $sp_feed->get_description());
                         $this->db->set('fed_lasterror', '');
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         if ($lastitem) {
                             $nextcrawl = '';
                             //older than 96 hours, next crawl in 12 hours
                             if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 24 * 96)) {
                                 $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 12);
                                 //older than 48 hours, next crawl in 6 hours
                             } else {
                                 if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 48)) {
                                     $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 6);
                                     //older than 24 hours, next crawl in 3 hours
                                 } else {
                                     if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 24)) {
                                         $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 3);
                                     }
                                 }
                             }
                             $this->db->set('fed_nextcrawl', $nextcrawl);
                         }
                         $this->db->where('fed_id', $fed->fed_id);
                         $this->db->update('feeds');
                     }
                     $sp_feed->__destruct();
                     unset($sp_feed);
                 }
             }
             $this->db->set('crr_time', microtime(1) - $microtime_start);
             if (function_exists('memory_get_peak_usage')) {
                 $this->db->set('crr_memory', memory_get_peak_usage());
             }
             $this->db->set('crr_feeds', $query->num_rows());
             if ($errors > 0) {
                 $this->db->set('crr_errors', $errors);
             }
             $this->db->set('crr_datecreated', date('Y-m-d H:i:s'));
             $this->db->insert('crawler');
             if ($this->db->dbdriver == 'mysqli') {
                 $this->db->query('OPTIMIZE TABLE categories, connections, enclosures, favorites, feeds, folders, history, items, members, share, subscriptions');
             }
         }
     }
     $this->readerself_library->set_content($content);
 }
コード例 #22
0
ファイル: dashboard.php プロジェクト: siriuzwhite/alpha
function WPZOOM_Dashboard()
{
    ?>
<div class="table table_news">
    <p class="sub">From our Blog</p>
    <div class="rss-widget">
        <?php 
    /**
     * Get RSS Feed(s)
     */
    $items = get_transient('wpzoom_dashboard_widget_news');
    if (!(is_array($items) && count($items))) {
        include_once ABSPATH . WPINC . '/class-simplepie.php';
        $rss = new SimplePie();
        $rss->set_timeout(5);
        $rss->set_feed_url('http://www.wpzoom.com/feed/');
        $rss->strip_htmltags(array_merge($rss->strip_htmltags, array('h1', 'a', 'img')));
        $rss->enable_cache(false);
        $rss->init();
        $items = $rss->get_items(0, 3);
        $cached = array();
        foreach ($items as $item) {
            $cached[] = array('url' => $item->get_permalink(), 'title' => $item->get_title(), 'date' => $item->get_date("d M Y"), 'content' => substr(strip_tags($item->get_content()), 0, 128) . "...");
        }
        $items = $cached;
        set_transient('wpzoom_dashboard_widget_news', $cached, 60 * 60 * 24);
    }
    ?>

        <ul class="news">
            <?php 
    if (empty($items)) {
        echo '<li>No items</li>';
    } else {
        foreach ($items as $item) {
            ?>

                <li class="post">
                    <a href="<?php 
            echo $item['url'];
            ?>
" class="rsswidget"><?php 
            echo $item['title'];
            ?>
</a>
                    <span class="rss-date"><?php 
            echo $item['date'];
            ?>
</span>
                    <div class="rssSummary"><?php 
            echo $item['content'];
            ?>
</div>
                </li>

            <?php 
        }
    }
    ?>
        </ul><!-- end of .news -->
    </div>
</div>

<div class="table table_theme">
    <p class="sub">Latest Theme</p>
    <div class="theme_thumb">
        <?php 
    $lastTheme = get_transient('wpzoom_dashboard_widget_theme');
    if (!$lastTheme) {
        $lastTheme = @file_get_contents('http://www.wpzoom.com/themes/?last-theme=true');
        if ($lastTheme) {
            set_transient('wpzoom_dashboard_widget_theme', $lastTheme, 60 * 60 * 24);
        }
    }
    ?>

        <?php 
    if ($lastTheme) {
        echo $lastTheme;
    }
    ?>

    </div>

    <a href="http://wpzoom.com/themes/" target="_blank" alt="Browse our wide selection of WordPress themes to find the right one for you" class="button">Browse more &rarr;</a>
</div>

<div class="clear">&nbsp;</div>
<?php 
}
コード例 #23
0
ファイル: helper.php プロジェクト: pguilford/vcomcc
 public static function getFeedData($params)
 {
     $rssurl = str_replace("\n", ",", JString::trim($params->get('rssurl', '')));
     $feedTimeout = (int) $params->get('feedTimeout', 10);
     $rssdateorder = (int) $params->get('rssdateorder', 1);
     $dformat = $params->get('dformat', '%d %b %Y %H:%M %P');
     $rssperfeed = (int) $params->get('rssperfeed', 3);
     $textfilter = JString::trim($params->get('textfilter', ''));
     $pagination = (int) $params->get('pagination', 0);
     $totalfeeds = (int) $params->get('rssitems', 5);
     $filtermode = (int) $params->get('filtermode', 0);
     $showfeedinfo = (int) $params->get('showfeedinfo', 1);
     $input_encoding = JString::trim($params->get('inputencoding', ''));
     $showimage = (int) $params->get('rssimage', 1);
     $cacheTime = (int) $params->get('feedcache', 15) * 60;
     //minutes
     $orderBy = $params->get('orderby', 'date');
     $tmzone = (int) $params->get('tmzone', 0) ? true : false;
     $cachePath = JPATH_SITE . DS . 'cache' . DS . 'mod_we_ufeed_display';
     $start = $end = 0;
     if ($pagination) {
         $pagination_items = (int) $params->get('paginationitems', 5);
         $current_limit = modFeedShowHelper::getPage($params->get('mid', 0));
         $start = ($current_limit - 1) * $pagination_items;
         $end = $current_limit * $pagination_items;
     }
     #Get clean array
     $rss_urls = @array_filter(explode(",", $rssurl));
     #If only 1 link, use totalfeeds for total limit
     if (count($rss_urls) == 1) {
         $rssperfeed = $totalfeeds;
     }
     # Intilize RSS Doc
     if (!class_exists('SimplePie')) {
         jimport('simplepie.simplepie');
     }
     //Parser Code
     $simplepie = new SimplePie();
     $simplepie->set_cache_location($cachePath);
     $simplepie->set_cache_duration($cacheTime);
     $simplepie->set_stupidly_fast(true);
     $simplepie->force_feed(true);
     //$simplepie->force_fsockopen(false); //gives priority to CURL if is installed
     $simplepie->set_timeout($feedTimeout);
     $simplepie->set_item_limit($rssperfeed);
     $simplepie->enable_order_by_date(false);
     if ($input_encoding) {
         $simplepie->set_input_encoding($input_encoding);
         $simplepie->set_output_encoding('UTF-8');
     }
     $simplepie->set_feed_url($rss_urls);
     $simplepie->init();
     $rssTotalItems = (int) $simplepie->get_item_quantity($totalfeeds);
     if ((int) $params->get('debug', 0)) {
         echo "<h3>Total RSS Items:" . $rssTotalItems . "</h3>";
         echo print_r($simplepie, true);
         #debug
     }
     if (get_class($simplepie) != 'SimplePie' || !$rssTotalItems) {
         return array("rsstotalitems" => 0, 'items' => false);
     }
     $feedItems = array();
     #store all feeds items
     $counter = 1;
     foreach ($simplepie->get_items($start, $end) as $key => $feed) {
         #Word Filter
         if (!empty($textfilter) && $filtermode != 0) {
             $filter = modFeedShowHelper::filterItems($feed, $textfilter);
             #Include						#Exclude
             if ($filtermode == 1 && !$filter || $filtermode == 2 && $filter) {
                 $rssTotalItems--;
                 continue;
                 #Include
             }
         }
         $FeedValues[$key] = new stdClass();
         # channel header and link
         $channel = $feed->get_feed();
         $FeedValues[$key]->FeedTitle = $channel->get_title();
         $FeedValues[$key]->FeedLink = $channel->get_link();
         if ($showfeedinfo) {
             $FeedValues[$key]->FeedFavicon = 'http://g.etfv.co/' . urlencode($FeedValues[$key]->FeedLink);
         }
         $FeedValues[$key]->FeedDescription = $channel->get_description();
         $FeedValues[$key]->FeedLogo = $channel->get_image_url();
         #Item
         $FeedValues[$key]->ItemTitle = $feed->get_title();
         $feeDateUNIX = $feed->get_date('U');
         if ($feeDateUNIX < 1) {
             $feeDateUNIX = strtotime(trim(str_replace(",", "", $feed->get_date(''))));
         }
         $FeedValues[$key]->ItemDate = WEJM16 ? JHTML::_('date', $feeDateUNIX, $dformat, $tmzone) : JHtml::date($feeDateUNIX, $dformat, $tmzone);
         $FeedValues[$key]->ItemLink = $feed->get_link();
         //$feed->get_permalink();
         $FeedValues[$key]->ItemText = $feed->get_description();
         $FeedValues[$key]->ItemFulltext = $feed->get_content();
         $FeedValues[$key]->ItemEnclosure = $feed->get_enclosure();
         $FeedValues[$key]->ItemEnclosures = $feed->get_enclosures();
         if ($showimage) {
             $FeedValues[$key]->ItemImage = "";
         }
         //for next version
         if ($orderBy == 'title') {
             $idx = str_replace(array(':', '-', '(', ')', '+', '*', ' '), '', JString::strtolower(strip_tags($FeedValues[$key]->ItemTitle)));
             //ORDER BY TITLE
         } else {
             $idx = $feeDateUNIX;
             //Order By date
         }
         if (isset($feedItems[$idx])) {
             $idx .= $counter;
         }
         #unique idx
         $feedItems[$idx] = $FeedValues[$key];
         $counter++;
     }
     if ($rssdateorder == 1) {
         krsort($feedItems);
     } elseif ($rssdateorder == 2) {
         ksort($feedItems);
     } elseif ($rssdateorder == 3) {
         shuffle($feedItems);
     }
     if ((int) $params->get('debug', 0)) {
         echo "<p>Total RSS in Array:" . count($feedItems) . "</p>";
     }
     return array("rsstotalitems" => $rssTotalItems, 'items' => $feedItems);
 }
コード例 #24
0
ファイル: Feed.php プロジェクト: Clansuite/Clansuite
 /**
  * Fetches a feed by URL and caches it - using the SimplePie Library.
  *
  * @param string $feed_url       This is the URL you want to parse.
  * @param int    $cache_duration This is the number of seconds that you want to store the feedcache file for.
  * @param string $cache_location This is where you want the cached feeds to be stored.
  */
 public static function fetchRSS($feed_url, $number_of_items = null, $cache_duration = null, $cache_location = null)
 {
     /**
      * SimplePie is a bunch of crap, and not e_strict, yet. hmpf!
      * Therefore we have to cheat with the error_reporting toggle.
      * @link: http://tech.groups.yahoo.com/group/simplepie-support/message/3289
      */
     $old_errorlevel = error_reporting();
     error_reporting(0);
     // load simplepie
     include ROOT_LIBRARIES . 'simplepie/simplepie.inc';
     // instantiate simplepie
     $simplepie = new \SimplePie();
     // if cache_location was not specified manually
     if ($cache_location == null) {
         // we set it to the default cache directory for feeds
         $cache_location = ROOT_CACHE;
         // . 'feeds';
     }
     // if cache_duration was not specified manually
     if ($cache_duration == null) {
         // we set it to the default cache duration time of 1800
         $cache_duration = 1800;
     }
     // if number of items to fetch is null
     if ($number_of_items == null) {
         // we set it to the default value of 5 items
         $number_of_items = 5;
     }
     // finally: fetch the feed and cache it!
     $simplepie->set_feed_url($feed_url);
     $simplepie->set_cache_location($cache_location);
     $simplepie->set_cache_duration($cache_duration);
     $simplepie->set_timeout(5);
     $simplepie->set_output_encoding('UTF-8');
     $simplepie->set_stupidly_fast(true);
     $simplepie->init();
     $simplepie->handle_content_type();
     // set old error reporting level
     error_reporting($old_errorlevel);
     return $simplepie;
 }
コード例 #25
0
/**
 * Returns a list of the latest flickr images as SimplePie objects
 * safe to call multiple times, cacheing is taken care of, you should
 * use the functions ikit_social_flickr_image_from_description and
 * ikit_social_flickr_image_resize to get the image URL from each feed
 * item.
 */
function ikit_social_get_flickr_images_rss_items()
{
    $images = array();
    global $g_options;
    // Pull twitter feed
    $flickr_user_id = null;
    if (isset($g_options[IKIT_PLUGIN_OPTION_FLICKR_USER_ID])) {
        $flickr_user_id = $g_options[IKIT_PLUGIN_OPTION_FLICKR_USER_ID];
    }
    if ($flickr_user_id != null) {
        // SimplePie handles cacheing so we can call this on every request
        // the default cache time should be about 60 minutes
        $feed = new SimplePie();
        $feed->set_cache_duration(999999999);
        $feed->set_timeout(-1);
        $feed->set_feed_url(sprintf(IKIT_SOCIAL_FLICKR_IMAGES_RSS_URL, $flickr_user_id));
        $feed->set_cache_location(IKIT_DIR_CACHE);
        $feed->init();
        $feed->handle_content_type();
        foreach ($feed->get_items() as $item) {
            array_push($images, $item);
        }
    }
    return $images;
}
コード例 #26
0
ファイル: rssfuncs.php プロジェクト: rolfkleef/Tiny-Tiny-RSS
function update_rss_feed($link, $feed, $ignore_daemon = false, $no_cache = false, $override_url = false)
{
    require_once "lib/simplepie/simplepie.inc";
    require_once "lib/magpierss/rss_fetch.inc";
    require_once 'lib/magpierss/rss_utils.inc';
    $debug_enabled = defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug'];
    if ($debug_enabled) {
        _debug("update_rss_feed: start");
    }
    $result = db_query($link, "SELECT id,update_interval,auth_login,\n\t\t\tfeed_url,auth_pass,cache_images,update_method,last_updated,cache_content,\n\t\t\tmark_unread_on_update, owner_uid, update_on_checksum_change,\n\t\t\tpubsub_state\n\t\t\tFROM ttrss_feeds WHERE id = '{$feed}'");
    if (db_num_rows($result) == 0) {
        if ($debug_enabled) {
            _debug("update_rss_feed: feed {$feed} NOT FOUND/SKIPPED");
        }
        return false;
    }
    $update_method = db_fetch_result($result, 0, "update_method");
    $last_updated = db_fetch_result($result, 0, "last_updated");
    $owner_uid = db_fetch_result($result, 0, "owner_uid");
    $mark_unread_on_update = sql_bool_to_bool(db_fetch_result($result, 0, "mark_unread_on_update"));
    $update_on_checksum_change = sql_bool_to_bool(db_fetch_result($result, 0, "update_on_checksum_change"));
    $pubsub_state = db_fetch_result($result, 0, "pubsub_state");
    db_query($link, "UPDATE ttrss_feeds SET last_update_started = NOW()\n\t\t\tWHERE id = '{$feed}'");
    $auth_login = db_fetch_result($result, 0, "auth_login");
    $auth_pass = db_fetch_result($result, 0, "auth_pass");
    if ($update_method == 0) {
        $update_method = DEFAULT_UPDATE_METHOD + 1;
    }
    // 1 - Magpie
    // 2 - SimplePie
    // 3 - Twitter OAuth
    if ($update_method == 2) {
        $use_simplepie = true;
    } else {
        $use_simplepie = false;
    }
    if ($debug_enabled) {
        _debug("update method: {$update_method} (feed setting: {$update_method}) (use simplepie: {$use_simplepie})\n");
    }
    if ($update_method == 1) {
        $auth_login = urlencode($auth_login);
        $auth_pass = urlencode($auth_pass);
    }
    $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
    $cache_content = sql_bool_to_bool(db_fetch_result($result, 0, "cache_content"));
    $fetch_url = db_fetch_result($result, 0, "feed_url");
    $feed = db_escape_string($feed);
    if ($auth_login && $auth_pass) {
        $url_parts = array();
        preg_match("/(^[^:]*):\\/\\/(.*)/", $fetch_url, $url_parts);
        if ($url_parts[1] && $url_parts[2]) {
            $fetch_url = $url_parts[1] . "://{$auth_login}:{$auth_pass}@" . $url_parts[2];
        }
    }
    if ($override_url) {
        $fetch_url = $override_url;
    }
    if ($debug_enabled) {
        _debug("update_rss_feed: fetching [{$fetch_url}]...");
    }
    // Ignore cache if new feed or manual update.
    $cache_age = is_null($last_updated) || $last_updated == '1970-01-01 00:00:00' ? -1 : get_feed_update_interval($link, $feed) * 60;
    if ($update_method == 1) {
        define('MAGPIE_CACHE_AGE', $cache_age);
        define('MAGPIE_CACHE_ON', !$no_cache);
        define('MAGPIE_FETCH_TIME_OUT', $no_cache ? 15 : 60);
        define('MAGPIE_CACHE_DIR', CACHE_DIR . "/magpie");
        $rss = @fetch_rss($fetch_url);
    } else {
        $simplepie_cache_dir = CACHE_DIR . "/simplepie";
        if (!is_dir($simplepie_cache_dir)) {
            mkdir($simplepie_cache_dir);
        }
        $rss = new SimplePie();
        $rss->set_useragent(SELF_USER_AGENT);
        $rss->set_timeout($no_cache ? 15 : 60);
        $rss->set_feed_url($fetch_url);
        $rss->set_output_encoding('UTF-8');
        //$rss->force_feed(true);
        if ($debug_enabled) {
            _debug("feed update interval (sec): " . get_feed_update_interval($link, $feed) * 60);
        }
        $rss->enable_cache(!$no_cache);
        if (!$no_cache) {
            $rss->set_cache_location($simplepie_cache_dir);
            $rss->set_cache_duration($cache_age);
        }
        $rss->init();
    }
    //		print_r($rss);
    if ($debug_enabled) {
        _debug("update_rss_feed: fetch done, parsing...");
    }
    $feed = db_escape_string($feed);
    if ($update_method == 2) {
        $fetch_ok = !$rss->error();
    } else {
        $fetch_ok = !!$rss;
    }
    if ($fetch_ok) {
        if ($debug_enabled) {
            _debug("update_rss_feed: processing feed data...");
        }
        //			db_query($link, "BEGIN");
        if (DB_TYPE == "pgsql") {
            $favicon_interval_qpart = "favicon_last_checked < NOW() - INTERVAL '12 hour'";
        } else {
            $favicon_interval_qpart = "favicon_last_checked < DATE_SUB(NOW(), INTERVAL 12 HOUR)";
        }
        $result = db_query($link, "SELECT title,icon_url,site_url,owner_uid,\n\t\t\t\t(favicon_last_checked IS NULL OR {$favicon_interval_qpart}) AS\n\t\t\t\t\t\tfavicon_needs_check\n\t\t\t\tFROM ttrss_feeds WHERE id = '{$feed}'");
        $registered_title = db_fetch_result($result, 0, "title");
        $orig_icon_url = db_fetch_result($result, 0, "icon_url");
        $orig_site_url = db_fetch_result($result, 0, "site_url");
        $favicon_needs_check = sql_bool_to_bool(db_fetch_result($result, 0, "favicon_needs_check"));
        $owner_uid = db_fetch_result($result, 0, "owner_uid");
        if ($use_simplepie) {
            $site_url = db_escape_string(trim($rss->get_link()));
        } else {
            $site_url = db_escape_string(trim($rss->channel["link"]));
        }
        // weird, weird Magpie
        if (!$use_simplepie) {
            if (!$site_url) {
                $site_url = db_escape_string($rss->channel["link_"]);
            }
        }
        $site_url = rewrite_relative_url($fetch_url, $site_url);
        $site_url = substr($site_url, 0, 250);
        if ($debug_enabled) {
            _debug("update_rss_feed: checking favicon...");
        }
        if ($favicon_needs_check) {
            check_feed_favicon($site_url, $feed, $link);
            db_query($link, "UPDATE ttrss_feeds SET favicon_last_checked = NOW()\n\t\t\t\t\tWHERE id = '{$feed}'");
        }
        if (!$registered_title || $registered_title == "[Unknown]") {
            if ($use_simplepie) {
                $feed_title = db_escape_string($rss->get_title());
            } else {
                $feed_title = db_escape_string($rss->channel["title"]);
            }
            if ($debug_enabled) {
                _debug("update_rss_feed: registering title: {$feed_title}");
            }
            db_query($link, "UPDATE ttrss_feeds SET\n\t\t\t\t\ttitle = '{$feed_title}' WHERE id = '{$feed}'");
        }
        if ($site_url && $orig_site_url != $site_url) {
            db_query($link, "UPDATE ttrss_feeds SET\n\t\t\t\t\tsite_url = '{$site_url}' WHERE id = '{$feed}'");
        }
        //			print "I: " . $rss->channel["image"]["url"];
        if (!$use_simplepie) {
            $icon_url = db_escape_string(trim($rss->image["url"]));
        } else {
            $icon_url = db_escape_string(trim($rss->get_image_url()));
        }
        $icon_url = rewrite_relative_url($fetch_url, $icon_url);
        $icon_url = substr($icon_url, 0, 250);
        if ($icon_url && $orig_icon_url != $icon_url) {
            db_query($link, "UPDATE ttrss_feeds SET icon_url = '{$icon_url}' WHERE id = '{$feed}'");
        }
        if ($debug_enabled) {
            _debug("update_rss_feed: loading filters & labels...");
        }
        $filters = load_filters($link, $feed, $owner_uid);
        $labels = get_all_labels($link, $owner_uid);
        if ($debug_enabled) {
            //print_r($filters);
            _debug("update_rss_feed: " . count($filters) . " filters loaded.");
        }
        $filter_plugins = array();
        if (defined('_ARTICLE_FILTER_PLUGINS')) {
            foreach (explode(",", _ARTICLE_FILTER_PLUGINS) as $p) {
                $pclass = "filter_" . trim($p);
                if (class_exists($pclass)) {
                    $plugin = new $pclass($link);
                    array_push($filter_plugins, $plugin);
                }
            }
        }
        if ($debug_enabled) {
            _debug("update_rss_feed: " . count($filter_plugins) . " filter plugins loaded.");
        }
        if ($use_simplepie) {
            $iterator = $rss->get_items();
        } else {
            $iterator = $rss->items;
            if (!$iterator || !is_array($iterator)) {
                $iterator = $rss->entries;
            }
            if (!$iterator || !is_array($iterator)) {
                $iterator = $rss;
            }
        }
        if (!is_array($iterator)) {
            /* db_query($link, "UPDATE ttrss_feeds
            			SET last_error = 'Parse error: can\'t find any articles.'
            			WHERE id = '$feed'"); */
            // clear any errors and mark feed as updated if fetched okay
            // even if it's blank
            if ($debug_enabled) {
                _debug("update_rss_feed: entry iterator is not an array, no articles?");
            }
            db_query($link, "UPDATE ttrss_feeds\n\t\t\t\t\tSET last_updated = NOW(), last_error = '' WHERE id = '{$feed}'");
            return;
            // no articles
        }
        if ($pubsub_state != 2 && PUBSUBHUBBUB_ENABLED) {
            if ($debug_enabled) {
                _debug("update_rss_feed: checking for PUSH hub...");
            }
            $feed_hub_url = false;
            if ($use_simplepie) {
                $links = $rss->get_links('hub');
                if ($links && is_array($links)) {
                    foreach ($links as $l) {
                        $feed_hub_url = $l;
                        break;
                    }
                }
            } else {
                $atom = $rss->channel['atom'];
                if ($atom) {
                    if ($atom['link@rel'] == 'hub') {
                        $feed_hub_url = $atom['link@href'];
                    }
                    if (!$feed_hub_url && $atom['link#'] > 1) {
                        for ($i = 2; $i <= $atom['link#']; $i++) {
                            if ($atom["link#{$i}@rel"] == 'hub') {
                                $feed_hub_url = $atom["link#{$i}@href"];
                                break;
                            }
                        }
                    }
                } else {
                    $feed_hub_url = $rss->channel['link_hub'];
                }
            }
            if ($debug_enabled) {
                _debug("update_rss_feed: feed hub url: {$feed_hub_url}");
            }
            if ($feed_hub_url && function_exists('curl_init') && !ini_get("open_basedir")) {
                require_once 'lib/pubsubhubbub/subscriber.php';
                $callback_url = get_self_url_prefix() . "/public.php?op=pubsub&id={$feed}";
                $s = new Subscriber($feed_hub_url, $callback_url);
                $rc = $s->subscribe($fetch_url);
                if ($debug_enabled) {
                    _debug("update_rss_feed: feed hub url found, subscribe request sent.");
                }
                db_query($link, "UPDATE ttrss_feeds SET pubsub_state = 1\n\t\t\t\t\t\tWHERE id = '{$feed}'");
            }
        }
        if ($debug_enabled) {
            _debug("update_rss_feed: processing articles...");
        }
        foreach ($iterator as $item) {
            if ($_REQUEST['xdebug'] == 2) {
                print_r($item);
            }
            if ($use_simplepie) {
                $entry_guid = $item->get_id();
                if (!$entry_guid) {
                    $entry_guid = $item->get_link();
                }
                if (!$entry_guid) {
                    $entry_guid = make_guid_from_title($item->get_title());
                }
            } else {
                $entry_guid = $item["id"];
                if (!$entry_guid) {
                    $entry_guid = $item["guid"];
                }
                if (!$entry_guid) {
                    $entry_guid = $item["about"];
                }
                if (!$entry_guid) {
                    $entry_guid = $item["link"];
                }
                if (!$entry_guid) {
                    $entry_guid = make_guid_from_title($item["title"]);
                }
            }
            if ($cache_content) {
                $entry_guid = "ccache:{$entry_guid}";
            }
            if ($auth_login || $auth_pass) {
                $entry_guid = "auth,{$owner_uid}:{$entry_guid}";
            }
            if ($debug_enabled) {
                _debug("update_rss_feed: guid {$entry_guid}");
            }
            if (!$entry_guid) {
                continue;
            }
            $entry_timestamp = "";
            if ($use_simplepie) {
                $entry_timestamp = strtotime($item->get_date());
            } else {
                $rss_2_date = $item['pubdate'];
                $rss_1_date = $item['dc']['date'];
                $atom_date = $item['issued'];
                if (!$atom_date) {
                    $atom_date = $item['updated'];
                }
                if ($atom_date != "") {
                    $entry_timestamp = parse_w3cdtf($atom_date);
                }
                if ($rss_1_date != "") {
                    $entry_timestamp = parse_w3cdtf($rss_1_date);
                }
                if ($rss_2_date != "") {
                    $entry_timestamp = strtotime($rss_2_date);
                }
            }
            if ($entry_timestamp == "" || $entry_timestamp == -1 || !$entry_timestamp) {
                $entry_timestamp = time();
                $no_orig_date = 'true';
            } else {
                $no_orig_date = 'false';
            }
            $entry_timestamp_fmt = strftime("%Y/%m/%d %H:%M:%S", $entry_timestamp);
            if ($debug_enabled) {
                _debug("update_rss_feed: date {$entry_timestamp} [{$entry_timestamp_fmt}]");
            }
            if ($use_simplepie) {
                $entry_title = $item->get_title();
            } else {
                $entry_title = trim(strip_tags($item["title"]));
            }
            if ($use_simplepie) {
                $entry_link = $item->get_link();
            } else {
                // strange Magpie workaround
                $entry_link = $item["link_"];
                if (!$entry_link) {
                    $entry_link = $item["link"];
                }
            }
            $entry_link = rewrite_relative_url($site_url, $entry_link);
            if ($debug_enabled) {
                _debug("update_rss_feed: title {$entry_title}");
                _debug("update_rss_feed: link {$entry_link}");
            }
            if (!$entry_title) {
                $entry_title = date("Y-m-d H:i:s", $entry_timestamp);
            }
            $entry_link = strip_tags($entry_link);
            if ($use_simplepie) {
                $entry_content = $item->get_content();
                if (!$entry_content) {
                    $entry_content = $item->get_description();
                }
            } else {
                $entry_content = $item["content:escaped"];
                if (!$entry_content) {
                    $entry_content = $item["content:encoded"];
                }
                if (!$entry_content && is_array($entry_content)) {
                    $entry_content = $item["content"]["encoded"];
                }
                if (!$entry_content) {
                    $entry_content = $item["content"];
                }
                if (is_array($entry_content)) {
                    $entry_content = $entry_content[0];
                }
                // Magpie bugs are getting ridiculous
                if (trim($entry_content) == "Array") {
                    $entry_content = false;
                }
                if (!$entry_content) {
                    $entry_content = $item["atom_content"];
                }
                if (!$entry_content) {
                    $entry_content = $item["summary"];
                }
                if (!$entry_content || strlen($entry_content) < strlen($item["description"])) {
                    $entry_content = $item["description"];
                }
                // WTF
                if (is_array($entry_content)) {
                    $entry_content = $entry_content["encoded"];
                    if (!$entry_content) {
                        $entry_content = $entry_content["escaped"];
                    }
                }
            }
            if ($cache_images && is_writable(CACHE_DIR . '/images')) {
                $entry_content = cache_images($entry_content, $site_url, $debug_enabled);
            }
            if ($_REQUEST["xdebug"] == 2) {
                print "update_rss_feed: content: ";
                print $entry_content;
                print "\n";
            }
            $entry_content_unescaped = $entry_content;
            $entry_cached_content = "";
            if ($use_simplepie) {
                $entry_comments = strip_tags($item->data["comments"]);
                if ($item->get_author()) {
                    $entry_author_item = $item->get_author();
                    $entry_author = $entry_author_item->get_name();
                    if (!$entry_author) {
                        $entry_author = $entry_author_item->get_email();
                    }
                    $entry_author = db_escape_string($entry_author);
                }
            } else {
                $entry_comments = strip_tags($item["comments"]);
                $entry_author = db_escape_string(strip_tags($item['dc']['creator']));
                if ($item['author']) {
                    if (is_array($item['author'])) {
                        if (!$entry_author) {
                            $entry_author = db_escape_string(strip_tags($item['author']['name']));
                        }
                        if (!$entry_author) {
                            $entry_author = db_escape_string(strip_tags($item['author']['email']));
                        }
                    }
                    if (!$entry_author) {
                        $entry_author = db_escape_string(strip_tags($item['author']));
                    }
                }
            }
            if (preg_match('/^[\\t\\n\\r ]*$/', $entry_author)) {
                $entry_author = '';
            }
            $entry_guid = db_escape_string(strip_tags($entry_guid));
            $entry_guid = mb_substr($entry_guid, 0, 250);
            $result = db_query($link, "SELECT id FROM\tttrss_entries\n\t\t\t\t\tWHERE guid = '{$entry_guid}'");
            $entry_content = db_escape_string($entry_content, false);
            $entry_title = db_escape_string($entry_title);
            $entry_link = db_escape_string($entry_link);
            $entry_comments = mb_substr(db_escape_string($entry_comments), 0, 250);
            $entry_author = mb_substr($entry_author, 0, 250);
            if ($use_simplepie) {
                $num_comments = 0;
                #FIXME#
            } else {
                $num_comments = db_escape_string($item["slash"]["comments"]);
            }
            if (!$num_comments) {
                $num_comments = 0;
            }
            if ($debug_enabled) {
                _debug("update_rss_feed: looking for tags [1]...");
            }
            // parse <category> entries into tags
            $additional_tags = array();
            if ($use_simplepie) {
                $additional_tags_src = $item->get_categories();
                if (is_array($additional_tags_src)) {
                    foreach ($additional_tags_src as $tobj) {
                        array_push($additional_tags, $tobj->get_term());
                    }
                }
                if ($debug_enabled) {
                    _debug("update_rss_feed: category tags:");
                    print_r($additional_tags);
                }
            } else {
                $t_ctr = $item['category#'];
                if ($t_ctr == 0) {
                    $additional_tags = array();
                } else {
                    if ($t_ctr > 0) {
                        $additional_tags = array($item['category']);
                        if ($item['category@term']) {
                            array_push($additional_tags, $item['category@term']);
                        }
                        for ($i = 0; $i <= $t_ctr; $i++) {
                            if ($item["category#{$i}"]) {
                                array_push($additional_tags, $item["category#{$i}"]);
                            }
                            if ($item["category#{$i}@term"]) {
                                array_push($additional_tags, $item["category#{$i}@term"]);
                            }
                        }
                    }
                }
                // parse <dc:subject> elements
                $t_ctr = $item['dc']['subject#'];
                if ($t_ctr > 0) {
                    array_push($additional_tags, $item['dc']['subject']);
                    for ($i = 0; $i <= $t_ctr; $i++) {
                        if ($item['dc']["subject#{$i}"]) {
                            array_push($additional_tags, $item['dc']["subject#{$i}"]);
                        }
                    }
                }
            }
            if ($debug_enabled) {
                _debug("update_rss_feed: looking for tags [2]...");
            }
            /* taaaags */
            // <a href="..." rel="tag">Xorg</a>, //
            $entry_tags = null;
            preg_match_all("/<a.*?rel=['\"]tag['\"].*?\\>([^<]+)<\\/a>/i", $entry_content_unescaped, $entry_tags);
            $entry_tags = $entry_tags[1];
            $entry_tags = array_merge($entry_tags, $additional_tags);
            $entry_tags = array_unique($entry_tags);
            for ($i = 0; $i < count($entry_tags); $i++) {
                $entry_tags[$i] = mb_strtolower($entry_tags[$i], 'utf-8');
            }
            if ($debug_enabled) {
                //_debug("update_rss_feed: unfiltered tags found:");
                //print_r($entry_tags);
            }
            if ($debug_enabled) {
                _debug("update_rss_feed: done collecting data [TITLE:{$entry_title}]");
            }
            // TODO: less memory-hungry implementation
            if (count($filter_plugins) > 0) {
                if ($debug_enabled) {
                    _debug("update_rss_feed: applying plugin filters...");
                }
                $article = array("owner_uid" => $owner_uid, "title" => $entry_title, "content" => $entry_content, "link" => $entry_link, "tags" => $entry_tags, "author" => $entry_author);
                foreach ($filter_plugins as $plugin) {
                    $article = $plugin->filter_article($article);
                }
                $entry_title = $article["title"];
                $entry_content = $article["content"];
                $entry_tags = $article["tags"];
                $entry_author = $article["author"];
            }
            $content_hash = "SHA1:" . sha1(strip_tags($entry_content));
            db_query($link, "BEGIN");
            if (db_num_rows($result) == 0) {
                if ($debug_enabled) {
                    _debug("update_rss_feed: base guid not found");
                }
                if ($cache_content) {
                    if ($debug_enabled) {
                        _debug("update_rss_feed: caching content (initial)...");
                    }
                    $entry_cached_content = cache_content($link, $entry_link, $auth_login, $auth_pass);
                    if ($cache_images && is_writable(CACHE_DIR . '/images')) {
                        $entry_cached_content = cache_images($entry_cached_content, $site_url, $debug_enabled);
                    }
                    $entry_cached_content = db_escape_string($entry_cached_content, false);
                }
                // base post entry does not exist, create it
                $result = db_query($link, "INSERT INTO ttrss_entries\n\t\t\t\t\t\t\t(title,\n\t\t\t\t\t\t\tguid,\n\t\t\t\t\t\t\tlink,\n\t\t\t\t\t\t\tupdated,\n\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\tcontent_hash,\n\t\t\t\t\t\t\tcached_content,\n\t\t\t\t\t\t\tno_orig_date,\n\t\t\t\t\t\t\tdate_updated,\n\t\t\t\t\t\t\tdate_entered,\n\t\t\t\t\t\t\tcomments,\n\t\t\t\t\t\t\tnum_comments,\n\t\t\t\t\t\t\tauthor)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t('{$entry_title}',\n\t\t\t\t\t\t\t'{$entry_guid}',\n\t\t\t\t\t\t\t'{$entry_link}',\n\t\t\t\t\t\t\t'{$entry_timestamp_fmt}',\n\t\t\t\t\t\t\t'{$entry_content}',\n\t\t\t\t\t\t\t'{$content_hash}',\n\t\t\t\t\t\t\t'{$entry_cached_content}',\n\t\t\t\t\t\t\t{$no_orig_date},\n\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\t'{$entry_comments}',\n\t\t\t\t\t\t\t'{$num_comments}',\n\t\t\t\t\t\t\t'{$entry_author}')");
                $article_labels = array();
            } else {
                // we keep encountering the entry in feeds, so we need to
                // update date_updated column so that we don't get horrible
                // dupes when the entry gets purged and reinserted again e.g.
                // in the case of SLOW SLOW OMG SLOW updating feeds
                $base_entry_id = db_fetch_result($result, 0, "id");
                db_query($link, "UPDATE ttrss_entries SET date_updated = NOW()\n\t\t\t\t\t\tWHERE id = '{$base_entry_id}'");
                $article_labels = get_article_labels($link, $base_entry_id, $owner_uid);
            }
            // now it should exist, if not - bad luck then
            $result = db_query($link, "SELECT\n\t\t\t\t\t\tid,content_hash,no_orig_date,title,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(date_updated,1,19) as date_updated,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,19) as updated,\n\t\t\t\t\t\tnum_comments, cached_content\n\t\t\t\t\tFROM\n\t\t\t\t\t\tttrss_entries\n\t\t\t\t\tWHERE guid = '{$entry_guid}'");
            $entry_ref_id = 0;
            $entry_int_id = 0;
            if (db_num_rows($result) == 1) {
                if ($debug_enabled) {
                    _debug("update_rss_feed: base guid found, checking for user record");
                }
                // this will be used below in update handler
                $orig_content_hash = db_fetch_result($result, 0, "content_hash");
                $orig_title = db_fetch_result($result, 0, "title");
                $orig_num_comments = db_fetch_result($result, 0, "num_comments");
                $orig_cached_content = trim(db_fetch_result($result, 0, "cached_content"));
                $orig_date_updated = strtotime(db_fetch_result($result, 0, "date_updated"));
                $ref_id = db_fetch_result($result, 0, "id");
                $entry_ref_id = $ref_id;
                // check for user post link to main table
                // do we allow duplicate posts with same GUID in different feeds?
                if (get_pref($link, "ALLOW_DUPLICATE_POSTS", $owner_uid, false)) {
                    $dupcheck_qpart = "AND (feed_id = '{$feed}' OR feed_id IS NULL)";
                } else {
                    $dupcheck_qpart = "";
                }
                /* Collect article tags here so we could filter by them: */
                $article_filters = get_article_filters($filters, $entry_title, $entry_content, $entry_link, $entry_timestamp, $entry_author, $entry_tags);
                if ($debug_enabled) {
                    _debug("update_rss_feed: article filters: ");
                    if (count($article_filters) != 0) {
                        print_r($article_filters);
                    }
                }
                if (find_article_filter($article_filters, "filter")) {
                    db_query($link, "COMMIT");
                    // close transaction in progress
                    continue;
                }
                $score = calculate_article_score($article_filters);
                if ($debug_enabled) {
                    _debug("update_rss_feed: initial score: {$score}");
                }
                $query = "SELECT ref_id, int_id FROM ttrss_user_entries WHERE\n\t\t\t\t\t\t\tref_id = '{$ref_id}' AND owner_uid = '{$owner_uid}'\n\t\t\t\t\t\t\t{$dupcheck_qpart}";
                //					if ($_REQUEST["xdebug"]) print "$query\n";
                $result = db_query($link, $query);
                // okay it doesn't exist - create user entry
                if (db_num_rows($result) == 0) {
                    if ($debug_enabled) {
                        _debug("update_rss_feed: user record not found, creating...");
                    }
                    if ($score >= -500 && !find_article_filter($article_filters, 'catchup')) {
                        $unread = 'true';
                        $last_read_qpart = 'NULL';
                    } else {
                        $unread = 'false';
                        $last_read_qpart = 'NOW()';
                    }
                    if (find_article_filter($article_filters, 'mark') || $score > 1000) {
                        $marked = 'true';
                    } else {
                        $marked = 'false';
                    }
                    if (find_article_filter($article_filters, 'publish')) {
                        $published = 'true';
                    } else {
                        $published = 'false';
                    }
                    // N-grams
                    if (DB_TYPE == "pgsql" and defined('_NGRAM_TITLE_DUPLICATE_THRESHOLD')) {
                        $result = db_query($link, "SELECT COUNT(*) AS similar FROM\n\t\t\t\t\t\t\t\t\tttrss_entries,ttrss_user_entries\n\t\t\t\t\t\t\t\tWHERE ref_id = id AND updated >= NOW() - INTERVAL '7 day'\n\t\t\t\t\t\t\t\t\tAND similarity(title, '{$entry_title}') >= " . _NGRAM_TITLE_DUPLICATE_THRESHOLD . "\n\t\t\t\t\t\t\t\t\tAND owner_uid = {$owner_uid}");
                        $ngram_similar = db_fetch_result($result, 0, "similar");
                        if ($debug_enabled) {
                            _debug("update_rss_feed: N-gram similar results: {$ngram_similar}");
                        }
                        if ($ngram_similar > 0) {
                            $unread = 'false';
                        }
                    }
                    $result = db_query($link, "INSERT INTO ttrss_user_entries\n\t\t\t\t\t\t\t\t(ref_id, owner_uid, feed_id, unread, last_read, marked,\n\t\t\t\t\t\t\t\t\tpublished, score, tag_cache, label_cache, uuid)\n\t\t\t\t\t\t\tVALUES ('{$ref_id}', '{$owner_uid}', '{$feed}', {$unread},\n\t\t\t\t\t\t\t\t{$last_read_qpart}, {$marked}, {$published}, '{$score}', '', '', '')");
                    if (PUBSUBHUBBUB_HUB && $published == 'true') {
                        $rss_link = get_self_url_prefix() . "/public.php?op=rss&id=-2&key=" . get_feed_access_key($link, -2, false, $owner_uid);
                        $p = new Publisher(PUBSUBHUBBUB_HUB);
                        $pubsub_result = $p->publish_update($rss_link);
                    }
                    $result = db_query($link, "SELECT int_id FROM ttrss_user_entries WHERE\n\t\t\t\t\t\t\t\tref_id = '{$ref_id}' AND owner_uid = '{$owner_uid}' AND\n\t\t\t\t\t\t\t\tfeed_id = '{$feed}' LIMIT 1");
                    if (db_num_rows($result) == 1) {
                        $entry_int_id = db_fetch_result($result, 0, "int_id");
                    }
                } else {
                    if ($debug_enabled) {
                        _debug("update_rss_feed: user record FOUND");
                    }
                    $entry_ref_id = db_fetch_result($result, 0, "ref_id");
                    $entry_int_id = db_fetch_result($result, 0, "int_id");
                }
                if ($debug_enabled) {
                    _debug("update_rss_feed: RID: {$entry_ref_id}, IID: {$entry_int_id}");
                }
                $post_needs_update = false;
                $update_insignificant = false;
                $cached_content_needs_update = false;
                if ($orig_num_comments != $num_comments) {
                    $post_needs_update = true;
                    $update_insignificant = true;
                }
                if ($content_hash != $orig_content_hash) {
                    $post_needs_update = true;
                    $update_insignificant = false;
                    $cached_content_needs_update = true;
                }
                if ($cache_content) {
                    if ($debug_enabled) {
                        _debug("update_rss_feed: caching content because original checksum changed...");
                    }
                    $entry_cached_content = cache_content($link, $entry_link, $auth_login, $auth_pass);
                    if ($entry_cached_content) {
                        if ($cache_images && is_writable(CACHE_DIR . '/images')) {
                            $entry_cached_content = cache_images($entry_cached_content, $site_url, $debug_enabled);
                        }
                        $entry_cached_content = db_escape_string($entry_cached_content, false);
                        $post_needs_update = true;
                    } else {
                        $entry_cached_content = db_escape_string($orig_cached_content);
                    }
                } else {
                    $entry_cached_content = db_escape_string($orig_cached_content);
                }
                if (db_escape_string($orig_title) != $entry_title) {
                    $post_needs_update = true;
                    $update_insignificant = false;
                }
                // if post needs update, update it and mark all user entries
                // linking to this post as updated
                if ($post_needs_update) {
                    if (defined('DAEMON_EXTENDED_DEBUG')) {
                        _debug("update_rss_feed: post {$entry_guid} needs update...");
                    }
                    //						print "<!-- post $orig_title needs update : $post_needs_update -->";
                    db_query($link, "UPDATE ttrss_entries\n\t\t\t\t\t\t\tSET title = '{$entry_title}', content = '{$entry_content}',\n\t\t\t\t\t\t\t\tcontent_hash = '{$content_hash}',\n\t\t\t\t\t\t\t\tcached_content = '{$entry_cached_content}',\n\t\t\t\t\t\t\t\tupdated = '{$entry_timestamp_fmt}',\n\t\t\t\t\t\t\t\tnum_comments = '{$num_comments}'\n\t\t\t\t\t\t\tWHERE id = '{$ref_id}'");
                    if (!$update_insignificant) {
                        if ($mark_unread_on_update) {
                            db_query($link, "UPDATE ttrss_user_entries\n\t\t\t\t\t\t\t\t\tSET last_read = null, unread = true WHERE ref_id = '{$ref_id}'");
                        } else {
                            if ($update_on_checksum_change) {
                                db_query($link, "UPDATE ttrss_user_entries\n\t\t\t\t\t\t\t\t\tSET last_read = null WHERE ref_id = '{$ref_id}'\n\t\t\t\t\t\t\t\t\t\tAND unread = false");
                            }
                        }
                    }
                }
            }
            db_query($link, "COMMIT");
            if ($debug_enabled) {
                _debug("update_rss_feed: assigning labels...");
            }
            assign_article_to_label_filters($link, $entry_ref_id, $article_filters, $owner_uid, $article_labels);
            if ($debug_enabled) {
                _debug("update_rss_feed: looking for enclosures...");
            }
            // enclosures
            $enclosures = array();
            if ($use_simplepie) {
                $encs = $item->get_enclosures();
                if (is_array($encs)) {
                    foreach ($encs as $e) {
                        $e_item = array($e->link, $e->type, $e->length);
                        array_push($enclosures, $e_item);
                    }
                }
            } else {
                // <enclosure>
                $e_ctr = $item['enclosure#'];
                if ($e_ctr > 0) {
                    $e_item = array($item['enclosure@url'], $item['enclosure@type'], $item['enclosure@length']);
                    array_push($enclosures, $e_item);
                    for ($i = 0; $i <= $e_ctr; $i++) {
                        if ($item["enclosure#{$i}@url"]) {
                            $e_item = array($item["enclosure#{$i}@url"], $item["enclosure#{$i}@type"], $item["enclosure#{$i}@length"]);
                            array_push($enclosures, $e_item);
                        }
                    }
                }
                // <media:content>
                // can there be many of those? yes -fox
                $m_ctr = $item['media']['content#'];
                if ($m_ctr > 0) {
                    $e_item = array($item['media']['content@url'], $item['media']['content@medium'], $item['media']['content@length']);
                    array_push($enclosures, $e_item);
                    for ($i = 0; $i <= $m_ctr; $i++) {
                        if ($item["media"]["content#{$i}@url"]) {
                            $e_item = array($item["media"]["content#{$i}@url"], $item["media"]["content#{$i}@medium"], $item["media"]["content#{$i}@length"]);
                            array_push($enclosures, $e_item);
                        }
                    }
                }
            }
            if ($debug_enabled) {
                _debug("update_rss_feed: article enclosures:");
                print_r($enclosures);
            }
            db_query($link, "BEGIN");
            foreach ($enclosures as $enc) {
                $enc_url = db_escape_string($enc[0]);
                $enc_type = db_escape_string($enc[1]);
                $enc_dur = db_escape_string($enc[2]);
                $result = db_query($link, "SELECT id FROM ttrss_enclosures\n\t\t\t\t\t\tWHERE content_url = '{$enc_url}' AND post_id = '{$entry_ref_id}'");
                if (db_num_rows($result) == 0) {
                    db_query($link, "INSERT INTO ttrss_enclosures\n\t\t\t\t\t\t\t(content_url, content_type, title, duration, post_id) VALUES\n\t\t\t\t\t\t\t('{$enc_url}', '{$enc_type}', '', '{$enc_dur}', '{$entry_ref_id}')");
                }
            }
            db_query($link, "COMMIT");
            // check for manual tags (we have to do it here since they're loaded from filters)
            foreach ($article_filters as $f) {
                if ($f["type"] == "tag") {
                    $manual_tags = trim_array(explode(",", $f["param"]));
                    foreach ($manual_tags as $tag) {
                        if (tag_is_valid($tag)) {
                            array_push($entry_tags, $tag);
                        }
                    }
                }
            }
            // Skip boring tags
            $boring_tags = trim_array(explode(",", mb_strtolower(get_pref($link, 'BLACKLISTED_TAGS', $owner_uid, ''), 'utf-8')));
            $filtered_tags = array();
            $tags_to_cache = array();
            if ($entry_tags && is_array($entry_tags)) {
                foreach ($entry_tags as $tag) {
                    if (array_search($tag, $boring_tags) === false) {
                        array_push($filtered_tags, $tag);
                    }
                }
            }
            $filtered_tags = array_unique($filtered_tags);
            if ($debug_enabled) {
                _debug("update_rss_feed: filtered article tags:");
                print_r($filtered_tags);
            }
            // Save article tags in the database
            if (count($filtered_tags) > 0) {
                db_query($link, "BEGIN");
                foreach ($filtered_tags as $tag) {
                    $tag = sanitize_tag($tag);
                    $tag = db_escape_string($tag);
                    if (!tag_is_valid($tag)) {
                        continue;
                    }
                    $result = db_query($link, "SELECT id FROM ttrss_tags\n\t\t\t\t\t\t\tWHERE tag_name = '{$tag}' AND post_int_id = '{$entry_int_id}' AND\n\t\t\t\t\t\t\towner_uid = '{$owner_uid}' LIMIT 1");
                    if ($result && db_num_rows($result) == 0) {
                        db_query($link, "INSERT INTO ttrss_tags\n\t\t\t\t\t\t\t\t\t(owner_uid,tag_name,post_int_id)\n\t\t\t\t\t\t\t\t\tVALUES ('{$owner_uid}','{$tag}', '{$entry_int_id}')");
                    }
                    array_push($tags_to_cache, $tag);
                }
                /* update the cache */
                $tags_to_cache = array_unique($tags_to_cache);
                $tags_str = db_escape_string(join(",", $tags_to_cache));
                db_query($link, "UPDATE ttrss_user_entries\n\t\t\t\t\t\tSET tag_cache = '{$tags_str}' WHERE ref_id = '{$entry_ref_id}'\n\t\t\t\t\t\tAND owner_uid = {$owner_uid}");
                db_query($link, "COMMIT");
            }
            if (get_pref($link, "AUTO_ASSIGN_LABELS", $owner_uid, false)) {
                if ($debug_enabled) {
                    _debug("update_rss_feed: auto-assigning labels...");
                }
                foreach ($labels as $label) {
                    $caption = $label["caption"];
                    if (preg_match("/\\b{$caption}\\b/i", "{$tags_str} " . strip_tags($entry_content) . " {$entry_title}")) {
                        if (!labels_contains_caption($article_labels, $caption)) {
                            label_add_article($link, $entry_ref_id, $caption, $owner_uid);
                        }
                    }
                }
            }
            if ($debug_enabled) {
                _debug("update_rss_feed: article processed");
            }
        }
        if (!$last_updated) {
            if ($debug_enabled) {
                _debug("update_rss_feed: new feed, catching it up...");
            }
            catchup_feed($link, $feed, false, $owner_uid);
        }
        if ($debug_enabled) {
            _debug("purging feed...");
        }
        purge_feed($link, $feed, 0, $debug_enabled);
        db_query($link, "UPDATE ttrss_feeds\n\t\t\t\tSET last_updated = NOW(), last_error = '' WHERE id = '{$feed}'");
        //			db_query($link, "COMMIT");
    } else {
        if ($use_simplepie) {
            $error_msg = mb_substr($rss->error(), 0, 250);
        } else {
            $error_msg = mb_substr(magpie_error(), 0, 250);
        }
        if ($debug_enabled) {
            _debug("update_rss_feed: error fetching feed: {$error_msg}");
        }
        $error_msg = db_escape_string($error_msg);
        db_query($link, "UPDATE ttrss_feeds SET last_error = '{$error_msg}',\n\t\t\t\t\tlast_updated = NOW() WHERE id = '{$feed}'");
    }
    if ($use_simplepie) {
        unset($rss);
    }
    if ($debug_enabled) {
        _debug("update_rss_feed: done");
    }
}
コード例 #27
0
ファイル: main.php プロジェクト: subiet/Swiftriver
 /**
  *
  *   //get all the admin feeds in database.
  */
 private function get_new_feeds($category_id)
 {
     //get all the admin feeds in database.
     $dbfeeds = ORM::factory('feed')->select('id', 'feed_url', 'category_id')->where('category_id', $category_id)->find_all();
     if ($category_id == 0) {
         $dbfeeds = ORM::factory('feed')->select('id', 'feed_url', 'category_id')->find_all();
     }
     foreach ($dbfeeds as $dbfeed) {
         //Don't do anything about twitter categories.
         if ($dbfeed->category_id != 11) {
             $url = "";
             $feed = new SimplePie();
             $feed->enable_order_by_date(true);
             if ($dbfeed->category_id == 1) {
                 $url = "http://twitter.com/statuses/user_timeline/" . $dbfeed->feed_url . ".rss";
                 $feed->set_feed_url($url);
                 //	exit(0);
             } else {
                 $url = $dbfeed->feed_url;
                 $feed->set_feed_url($dbfeed->feed_url);
             }
             $feed->set_cache_location(APPPATH . 'cache');
             $feed->set_timeout(10);
             $feed->init();
             //		$channel = $feed->get_feed_tags('', 'channel');
             //		echo " tags=> ".$channel."<br/>";
             // echo "$url :<br/>";
             //	exit(0)
             $max_items = $feed->get_item_quantity();
             $require_new_items = 20;
             $new_item_counter = 0;
             $start = 0;
             for ($i = $start; $i < $max_items && $new_item_counter < $require_new_items; $i++) {
                 $item = $feed->get_item($i);
                 /*				//getting all the feed information.								 
                 						echo "$url:  latitude => ".$item->get_latitude();
                 						echo "   longitude => ".$item->get_longitude();
                 						echo '<a href="' . $feed->get_image_link() . '" title="' . $feed->get_image_title() . '">';
                 						echo '<img src="' . $feed->get_image_url() . '" width="' . $feed->get_image_width() . '" height="' . $feed->get_image_height() . '" />';
                 						echo '</a><br/>Title:'.$item->get_title();
                 						echo '<br/>Description:'.$item->get_description();
                 						echo '<hr/>';
                 								
                 						*/
                 $itemobj = new Feed_Item_Model();
                 $itemobj->feed_id = $dbfeed->id;
                 $itemobj->item_title = $item->get_title();
                 $itemobj->item_description = $item->get_description();
                 $itemobj->item_link = $item->get_permalink();
                 $itemobj->item_date = $item->get_date('Y-m-d h:m:s');
                 if ($author = $item->get_author()) {
                     $itemobj->item_source = $item->get_author()->get_name();
                     //temporary not working.
                 }
                 //echo "in Main Controller $dbfeed->feed_url =>  latitude =".$feed->get_latitude().", longitude =".$feed->get_longitude()."<br/>";
                 //echo "in Main Controller $dbfeed->feed_url =>   get_author() => ".$feed->get_author()."<br/>";
                 $linkCount = ORM::factory('feed_item')->where('item_link', $item->get_permalink())->count_all();
                 if ($linkCount == 0) {
                     $new_item_counter++;
                     //  echo "link:=> ".$item->get_permalink()." is new and has appear ".$linkCount." times <br/>";
                     $itemobj->save();
                 } else {
                     if ($linkCount > 0) {
                         //	echo "link:=> ".$item->get_permalink()." appears ".$linkCount." times <br/>";
                     }
                 }
             }
         }
     }
     //		exit(0);
 }
コード例 #28
0
ファイル: lib_rss.php プロジェクト: krisfremen/FreshRSS
function customSimplePie()
{
    $system_conf = Minz_Configuration::get('system');
    $limits = $system_conf->limits;
    $simplePie = new SimplePie();
    $simplePie->set_useragent(_t('gen.freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ') ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION);
    $simplePie->set_cache_location(CACHE_PATH);
    $simplePie->set_cache_duration($limits['cache_duration']);
    $simplePie->set_timeout($limits['timeout']);
    $simplePie->strip_htmltags(array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'link', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'plaintext', 'script', 'style'));
    $simplePie->strip_attributes(array_merge($simplePie->strip_attributes, array('autoplay', 'onload', 'onunload', 'onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmousemove', 'onmouseout', 'onfocus', 'onblur', 'onkeypress', 'onkeydown', 'onkeyup', 'onselect', 'onchange', 'seamless')));
    $simplePie->add_attributes(array('img' => array('lazyload' => '', 'postpone' => ''), 'audio' => array('lazyload' => '', 'postpone' => '', 'preload' => 'none'), 'iframe' => array('lazyload' => '', 'postpone' => '', 'sandbox' => 'allow-scripts allow-same-origin'), 'video' => array('lazyload' => '', 'postpone' => '', 'preload' => 'none')));
    $simplePie->set_url_replacements(array('a' => 'href', 'area' => 'href', 'audio' => 'src', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'iframe' => 'src', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite', 'source' => 'src', 'track' => 'src', 'video' => array('poster', 'src')));
    return $simplePie;
}
コード例 #29
0
////////////////////////////////
if (!$html_only) {
    debug('--------');
    debug("Attempting to process URL as feed");
    // Send user agent header showing PHP (prevents a HTML response from feedburner)
    $http->userAgentDefault = HumbleHttpAgent::UA_PHP;
    // configure SimplePie HTTP extension class to use our HumbleHttpAgent instance
    SimplePie_HumbleHttpAgent::set_agent($http);
    $feed = new SimplePie();
    // some feeds use the text/html content type - force_feed tells SimplePie to process anyway
    $feed->force_feed(true);
    $feed->set_file_class('SimplePie_HumbleHttpAgent');
    //$feed->set_feed_url($url); // colons appearing in the URL's path get encoded
    $feed->feed_url = $url;
    $feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE);
    $feed->set_timeout(20);
    $feed->enable_cache(false);
    $feed->set_stupidly_fast(true);
    $feed->enable_order_by_date(false);
    // we don't want to do anything to the feed
    $feed->set_url_replacements(array());
    // initialise the feed
    // the @ suppresses notices which on some servers causes a 500 internal server error
    $result = @$feed->init();
    //$feed->handle_content_type();
    //$feed->get_title();
    if ($result && (!is_array($feed->data) || count($feed->data) == 0)) {
        die('Sorry, no feed items found');
    }
    // from now on, we'll identify ourselves as a browser
    $http->userAgentDefault = HumbleHttpAgent::UA_BROWSER;
コード例 #30
0
 public function install_extension()
 {
     $modsurl = array('themes' => 'http://www.exponentcms.org/site_podcast.php?module=filedownload&src=%40random4e6a70cebdc96', 'fixes' => 'http://www.exponentcms.org/site_podcast.php?module=filedownload&src=%40random4e6a710126abf', 'mods' => 'http://www.exponentcms.org/site_podcast.php?module=filedownload&src=%40random4e6a7148c84a9');
     $RSS = new SimplePie();
     $RSS->set_cache_location(BASE . 'tmp/rsscache');
     // default is ./cache
     //	        $RSS->set_cache_duration(3600);  // default if 3600
     $RSS->set_timeout(20);
     // default is 10
     //	        $RSS->set_output_encoding('UTF-8');  // which is the default
     $items['themes'] = array();
     $items['fixes'] = array();
     $items['mods'] = array();
     foreach ($modsurl as $type => $url) {
         $RSS->set_feed_url($url);
         $feed = $RSS->init();
         if (!$feed) {
             // an error occurred in the rss.
             continue;
         }
         $RSS->handle_content_type();
         foreach ($RSS->get_items() as $rssItem) {
             $rssObject = new stdClass();
             $rssObject->title = $rssItem->get_title();
             $rssObject->body = $rssItem->get_description();
             $rssObject->rss_link = $rssItem->get_permalink();
             $rssObject->publish = $rssItem->get_date('U');
             $rssObject->publish_date = $rssItem->get_date('U');
             foreach ($rssItem->get_enclosures() as $enclosure) {
                 $rssObject->enclosure = $enclosure->get_link();
             }
             $items[$type][] = $rssObject;
         }
     }
     $form = new form();
     $form->register(null, '', new htmlcontrol(expCore::maxUploadSizeMessage()));
     $form->register('mod_archive', 'Extension Archive', new uploadcontrol());
     $form->register('submit', '', new buttongroupcontrol(gt('Upload Extension')));
     $form->meta('module', 'administration');
     $form->meta('action', 'install_extension_confirm');
     assign_to_template(array('themes' => $items['themes'], 'fixes' => $items['fixes'], 'mods' => $items['mods'], 'form_html' => $form->toHTML()));
 }