当前位置: 首页>>代码示例>>PHP>>正文


PHP SimplePie::set_output_encoding方法代码示例

本文整理汇总了PHP中SimplePie::set_output_encoding方法的典型用法代码示例。如果您正苦于以下问题:PHP SimplePie::set_output_encoding方法的具体用法?PHP SimplePie::set_output_encoding怎么用?PHP SimplePie::set_output_encoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimplePie的用法示例。


在下文中一共展示了SimplePie::set_output_encoding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generate

 /**
  * Display a wildcard in the back end
  *
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         /** @var \BackendTemplate|object $objTemplate */
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['rss_reader'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = '' . $GLOBALS['TL_CONFIG']['backendPath'] . '/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
         return $objTemplate->parse();
     }
     $this->objFeed = new \SimplePie();
     $arrUrls = trimsplit('[\\n\\t ]', trim($this->rss_feed));
     if (count($arrUrls) > 1) {
         $this->objFeed->set_feed_url($arrUrls);
     } else {
         $this->objFeed->set_feed_url($arrUrls[0]);
     }
     $this->objFeed->set_output_encoding(\Config::get('characterSet'));
     $this->objFeed->set_cache_location(TL_ROOT . '/system/tmp');
     $this->objFeed->enable_cache(false);
     if ($this->rss_cache > 0) {
         $this->objFeed->enable_cache(true);
         $this->objFeed->set_cache_duration($this->rss_cache);
     }
     if (!$this->objFeed->init()) {
         $this->log('Error importing RSS feed "' . $this->rss_feed . '"', __METHOD__, TL_ERROR);
         return '';
     }
     $this->objFeed->handle_content_type();
     return parent::generate();
 }
开发者ID:rheintechnology,项目名称:core,代码行数:38,代码来源:ModuleRssReader.php

示例2: addSystemMessages

 public function addSystemMessages()
 {
     if ($GLOBALS['TL_CONFIG']['be_rss_src'] == '') {
         return '';
     }
     $feed = new \SimplePie();
     $feed->set_feed_url(html_entity_decode($GLOBALS['TL_CONFIG']['be_rss_src']));
     $feed->set_output_encoding(\Config::get('characterSet'));
     $feed->set_cache_location(TL_ROOT . '/system/tmp');
     $feed->enable_cache(true);
     if (!$feed->init()) {
         $this->log('Error importing RSS feed "' . $this->rss_feed . '"', __METHOD__, TL_ERROR);
         return '';
     }
     $items = $feed->get_items(0, $GLOBALS['TL_CONFIG']['be_rss_max'] ? $GLOBALS['TL_CONFIG']['be_rss_max'] : 3);
     $output = '';
     if ($items) {
         $user = \BackendUser::getInstance();
         foreach ($items as $item) {
             $template = new \BackendTemplate('be_rss_item');
             $template->title = $item->get_title();
             $template->link = $item->get_link();
             $template->content = $item->get_content();
             $template->date = $item->get_date($GLOBALS['TL_CONFIG']['datimFormat']);
             $template->class = $item->get_date('U') > $user->lastLogin ? 'new' : 'message';
             $output .= $template->parse();
         }
     }
     $template = new \BackendTemplate('be_rss');
     $template->headline = $GLOBALS['TL_CONFIG']['be_rss_headline'];
     $template->items = $output;
     return $template->parse();
 }
开发者ID:mindbird,项目名称:contao-be-rss,代码行数:33,代码来源:BeRss.php

示例3: flickr_photos

function flickr_photos($feed_url, $max_items = 10)
{
    //$items = combine_feeds( array($feed_url), $max_items, '~', false);
    $feed = new SimplePie();
    $feed->set_feed_url($feed_url);
    $feed->set_cache_location(ABSPATH . '/cache');
    $feed->set_output_encoding('ISO-8859-1');
    $feed->init();
    $html = '';
    if ($feed->data) {
        foreach ($feed->get_items(0, $max_items) as $item) {
            $image = $item->get_description();
            $image = substr($image, strpos($image, 'src=') + 4);
            // '<img') + 10);
            $image = trim(substr($image, 0, strpos($image, '.jpg') + 4));
            // , "\" width")));
            $healthy = array("%3A", "%2F", '"', 'm.jpg');
            $yummy = array(":", "/", '', 's.jpg');
            $image = str_replace($healthy, $yummy, $image);
            //$image = str_replace('m.jpg', 's.jpg', $image);
            $html .= '<a href="' . $item->get_permalink() . '">';
            $html .= '<img src="' . $image . '" alt="[flickr photo: ' . $item->get_title() . ']" title="' . $item->get_title() . '" />';
            $html .= "</a>\n";
        }
    }
    return $html;
}
开发者ID:vertino,项目名称:pez,代码行数:27,代码来源:functions.php

示例4: html

 public function html()
 {
     // Get settings
     $settings = $this->config;
     // Define Simplepie
     $feed = new \SimplePie();
     $feed->set_feed_url($settings['feed']);
     $feed->enable_cache($settings['enable_cache']);
     $feed->set_cache_location(cache_path());
     $feed->set_cache_duration(60 * 60 * 12);
     $feed->set_output_encoding($settings['charset']);
     $feed->init();
     $title = $settings['title'];
     $data = [];
     foreach ($feed->get_items($settings['offset'], $settings['limit']) as $key => $item) {
         $data[$key]['title'] = $item->get_title();
         $data[$key]['permalink'] = $item->get_permalink();
         $data[$key]['date'] = $item->get_date();
         $data[$key]['updated_date'] = $item->get_updated_date();
         $data[$key]['author'] = $item->get_author();
         $data[$key]['category'] = $item->get_category();
         $data[$key]['description'] = $item->get_description();
         $data[$key]['content'] = $item->get_content();
     }
     return $this->view('rssfeed', compact('title', 'data'));
 }
开发者ID:lesaff,项目名称:statamic-rssfeed,代码行数:26,代码来源:RSSFeedWidget.php

示例5: fetchRss

 function fetchRss($url)
 {
     $feed = new SimplePie();
     $feed->set_feed_url($url);
     $feed->set_output_encoding("UTF-8");
     $feed->enable_order_by_date(false);
     $feed->set_cache_location(Configure::read('Rss.cache_path'));
     $feed->init();
     return $feed->get_items();
 }
开发者ID:searchfirst,项目名称:Lenore,代码行数:10,代码来源:rss.php

示例6: mkdir

 function __construct($feed_url = null)
 {
     global $CFG;
     // Use the Moodle class for http requests
     $this->file_class = 'moodle_simplepie_file';
     // Use sensible cache directory
     $cachedir = $CFG->dataroot . '/cache/simplepie/';
     if (!file_exists($cachedir)) {
         mkdir($cachedir, 0777, true);
     }
     parent::__construct($feed_url, $cachedir);
     parent::set_output_encoding('UTF-8');
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:13,代码来源:moodle_simplepie.php

示例7: fetchSite

 protected function fetchSite($site)
 {
     $feed = new \SimplePie();
     $feed->force_feed(true);
     $feed->set_item_limit(20);
     $feed->set_feed_url($site);
     $feed->enable_cache(false);
     $feed->set_output_encoding('utf-8');
     $feed->init();
     foreach ($feed->get_items() as $item) {
         $this->outputItem(['site' => $site, 'title' => $item->get_title(), 'link' => $item->get_permalink(), 'date' => new \Carbon\Carbon($item->get_date()), 'content' => $item->get_content()]);
     }
 }
开发者ID:aukw,项目名称:phprssreader,代码行数:13,代码来源:RSSReader.php

示例8: setCron

 public function setCron()
 {
     $getUnique = $this->getAllFeedUrls();
     if (!empty($getUnique)) {
         foreach ($getUnique as $feedTableData) {
             $feed_user_title = $feedTableData->feed_user_title;
             $feed_url = $feedTableData->feed_admin_url;
             $usercat = $feedTableData->feed_user_category;
             $feed_filter_type = $feedTableData->feed_filter_type;
             $favicon_icon = $feedTableData->feed_favicon;
             $feed = new SimplePie();
             $feed->set_feed_url($feed_url);
             $feed->set_cache_location(APPPATH . '/cache');
             $feed->set_output_encoding('ISO-8859-1');
             $feed->init();
             $feed->handle_content_type();
             // Language
             $lang = $feed->get_language();
             $language = isset($lang) ? $lang : 'en-us';
             if ($feed->get_type() & SIMPLEPIE_TYPE_NONE) {
                 $feed_type = 'Unknown';
             } elseif ($feed->get_type() & SIMPLEPIE_TYPE_RSS_ALL) {
                 $feed_type = 'RSS';
             } elseif ($feed->get_type() & SIMPLEPIE_TYPE_ATOM_ALL) {
                 $feed_type = 'Atom';
             } elseif ($feed->get_type() & SIMPLEPIE_TYPE_ALL) {
                 $feed_type = 'Supported';
             }
             // Author
             if ($author = $feed->get_author()) {
                 $feedAuthor = $author->get_name();
             } else {
                 $feedAuthor = '';
             }
             if ($feed->error()) {
                 die;
             } else {
                 $feed_image_link = $feed->get_image_link();
                 $feed_image_url = $feed->get_image_url();
                 $feed_image_title = $feed->get_image_title();
                 $this->addFeeds($feed->get_items(0, 500), $feed_image_link, $feed_image_url, $feed_image_title, $usercat, $feed_url, $language, $feed_type, $feedAuthor, $feed_filter_type, $feed_user_title, $favicon_icon);
             }
         }
     }
 }
开发者ID:robdmat,项目名称:sport.net,代码行数:45,代码来源:cron_model.php

示例9: powerpress_get_news

function powerpress_get_news($feed_url, $limit = 10)
{
    include_once ABSPATH . WPINC . '/feed.php';
    $rss = fetch_feed($feed_url);
    // If feed doesn't work...
    if (is_wp_error($rss)) {
        require_once ABSPATH . WPINC . '/class-feed.php';
        // Try fetching the feed using CURL directly...
        $content = powerpress_remote_fopen($feed_url, false, array(), 3, false, true);
        if (!$content) {
            return false;
        }
        // Load the content in a fetch_feed object...
        $rss = new SimplePie();
        $rss->set_sanitize_class('WP_SimplePie_Sanitize_KSES');
        // We must manually overwrite $feed->sanitize because SimplePie's
        // constructor sets it before we have a chance to set the sanitization class
        $rss->sanitize = new WP_SimplePie_Sanitize_KSES();
        $rss->set_cache_class('WP_Feed_Cache');
        $rss->set_file_class('WP_SimplePie_File');
        $rss->set_raw_data($content);
        $rss->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $feed_url));
        do_action_ref_array('wp_feed_options', array(&$rss, $feed_url));
        $rss->init();
        $rss->set_output_encoding(get_option('blog_charset'));
        $rss->handle_content_type();
        if ($rss->error()) {
            return false;
        }
    }
    $rss_items = $rss->get_items(0, $rss->get_item_quantity($limit));
    // If the feed was erroneously
    if (!$rss_items) {
        $md5 = md5($this->feed);
        delete_transient('feed_' . $md5);
        delete_transient('feed_mod_' . $md5);
        $rss->__destruct();
        unset($rss);
        $rss = fetch_feed($this->feed);
        $rss_items = $rss->get_items(0, $rss->get_item_quantity($num));
        $rss->__destruct();
        unset($rss);
    }
    return $rss_items;
}
开发者ID:mattsims,项目名称:powerpress,代码行数:45,代码来源:powerpressadmin-dashboard.php

示例10: check

 public function check()
 {
     $feed = new SimplePie();
     $feed->set_feed_url('http://zeenews.india.com/rss/india-national-news.xml');
     $feed->set_cache_location(APPPATH . '/cache');
     $feed->set_output_encoding('ISO-8859-1');
     $feed->init();
     $feed->handle_content_type();
     //        $i = $feed->get_items(0, 500);
     $allFeeds = array();
     foreach ($feed->get_items(0, 100) as $item) {
         if ($author = $item->get_author()) {
             $email = $author->get_email();
             $name = $author->get_name();
             if ($name != '') {
                 $authorname = $name;
             } else {
                 $authorname = $email;
             }
         }
         $date = $item->get_date();
         $singleFeed = array('author' => $item->get_author(), 'authoremail' => $item->get_author(), 'categories' => $item->get_categories(), 'copyright' => $item->get_copyright(), 'content' => $item->get_content(), 'date' => $item->get_date("d.m.Y H:i"), 'description' => $item->get_description(), 'id' => $item->get_id(), 'latitude' => $item->get_latitude(), 'longitude' => $item->get_longitude(), 'permalink' => $item->get_permalink(), 'title' => $item->get_title());
         pri($item);
         array_push($allFeeds, $singleFeed);
         echo $date . '$date<br>';
     }
     die;
 }
开发者ID:robdmat,项目名称:sport.net,代码行数:28,代码来源:feeds.php

示例11: getFeedData

 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 = "";
//.........这里部分代码省略.........
开发者ID:pguilford,项目名称:vcomcc,代码行数:101,代码来源:helper.php

示例12: fetchFeeds


//.........这里部分代码省略.........
                     $date = time();
                     $fake_timestamp = true;
                     if ($this->debug) {
                         printf("DEBUG: falling back to time() = %s\n", $date);
                     }
                 }
                 // CLSC: if date is set to "now" parseDate can't parse it.
                 if ($fake_timestamp != true) {
                     $date = $this->parseDate($date);
                 }
                 if ($item['title'] == "") {
                     if ($this->debug) {
                         printf("DEBUG: skip item: title was empty for %s\n", print_r($item, true));
                     }
                     continue;
                 }
                 $item['date'] = $date;
                 $stack[] = $item;
                 // ----------------------------------------------------------
                 //    CLSC: New MagpieRSS code end
                 // ----------------------------------------------------------
             }
         } elseif ($engine == 'simplepie') {
             // hwa: new SimplePie code  ; lifted from the SimplePie demo
             $simplefeed = new SimplePie();
             $simplefeed->cache = false;
             $simplefeed->set_feed_url($feed['feedurl']);
             // Initialize the whole SimplePie object.  Read the feed, process it, parse it, cache it, and
             // all that other good stuff.  The feed's information will not be available to SimplePie before
             // this is called.
             $success = $simplefeed->init();
             // We'll make sure that the right content type and character encoding gets set automatically.
             // This function will grab the proper character encoding, as well as set the content type to text/html.
             $simplefeed->set_output_encoding(LANG_CHARSET);
             $simplefeed->handle_content_type();
             $item['new_feedicon'] = $simplefeed->get_favicon();
             // error handling
             if ($simplefeed->error()) {
                 if (!$opt['store_seperate']) {
                     printf('<p><b>ERROR:</b> ' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($simplefeed->error()) : htmlspecialchars($simplefeed->error(), ENT_COMPAT, LANG_CHARSET)) . "</p>\r\n");
                 }
             }
             if ($success) {
                 foreach ($simplefeed->get_items() as $simpleitem) {
                     // map SimplePie items to s9y items
                     $item['title'] = $simpleitem->get_title();
                     $item['date'] = $simpleitem->get_date('U');
                     $item['pubdate'] = $simpleitem->get_date('U');
                     $item['description'] = $simpleitem->get_description();
                     $item['content'] = $simpleitem->get_content();
                     $item['link'] = $simpleitem->get_permalink();
                     $item['author'] = $simpleitem->get_author();
                     //if ($this->debug) {
                     //  printf("DEBUG: SimplePie item: author: $item['author'], title: $item['title'], date: $item['date']\n");
                     //}
                     $stack[] = $item;
                 }
             } else {
                 if (!$opt['store_seperate']) {
                     printf('<p><b>ERROR:</b> ' . print_r($success, true) . "</p>\r\n");
                 }
             }
         }
         while (list($key, $item) = each($stack)) {
             if ($opt['store_seperate']) {
                 $ep_id = $cache_entries[$item['title']][$feed['feedid']][$item['date']];
开发者ID:sqall01,项目名称:additional_plugins,代码行数:67,代码来源:serendipity_event_aggregator.php

示例13: SimplePie

?>
" method="post">
<b>Enter Feed Url</b><br />
<input name="url" type="text" value="<?php 
echo $_POST['url'];
?>
" style="width:400px;"><input name="Submit" type="submit" value="Get Feed">
</form>
<?php 
if (isset($_POST['url']) && $_POST['url'] != "") {
    $url = $_POST['url'];
    include_once 'Simple/autoloader.php';
    $feed = new SimplePie();
    $feed->set_feed_url($url);
    $feed->enable_cache(false);
    $feed->set_output_encoding('Windows-1252');
    $feed->init();
    echo "<span><h1>" . $feed->get_title() . "</h1>";
    echo "<b>" . $feed->get_description() . "</b></span><hr />";
    $itemCount = $feed->get_item_quantity();
    $items = $feed->get_items();
    foreach ($items as $item) {
        ?>
<div><a href="<?php 
        echo $item->get_permalink();
        ?>
"><?php 
        echo $item->get_title();
        ?>
</a><br />
<em style="font-size:.7em;color:#666666"><?php 
开发者ID:parsinegar2015,项目名称:parsinegar,代码行数:31,代码来源:index.php

示例14: update_rss_feed

function update_rss_feed($link, $feed, $ignore_daemon = false, $no_cache = false, $override_url = false)
{
    require_once "lib/simplepie/simplepie.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,last_updated,\n\t\t\tmark_unread_on_update, owner_uid,\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;
    }
    $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"));
    $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");
    $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
    $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;
    $simplepie_cache_dir = CACHE_DIR . "/simplepie";
    if (!is_dir($simplepie_cache_dir)) {
        mkdir($simplepie_cache_dir);
    }
    $feed_data = fetch_file_contents($fetch_url, false, $auth_login, $auth_pass, false, $no_cache ? 15 : 45);
    if (!$feed_data) {
        global $fetch_last_error;
        if ($debug_enabled) {
            _debug("update_rss_feed: unable to fetch: {$fetch_last_error}");
        }
        $error_escaped = db_escape_string($fetch_last_error);
        db_query($link, "UPDATE ttrss_feeds SET last_error = '{$error_escaped}',\n\t\t\t\t\tlast_updated = NOW() WHERE id = '{$feed}'");
        return;
    }
    $pluginhost = new PluginHost($link);
    $pluginhost->set_debug($debug_enabled);
    $user_plugins = get_pref($link, "_ENABLED_PLUGINS", $owner_uid);
    $pluginhost->load(PLUGINS, $pluginhost::KIND_ALL);
    $pluginhost->load($user_plugins, $pluginhost::KIND_USER, $owner_uid);
    $pluginhost->load_data();
    foreach ($pluginhost->get_hooks($pluginhost::HOOK_FEED_FETCHED) as $plugin) {
        $feed_data = $plugin->hook_feed_fetched($feed_data);
    }
    if ($debug_enabled) {
        _debug("update_rss_feed: fetch done, parsing...");
    }
    $rss = new SimplePie();
    $rss->set_sanitize_class("SanitizeDummy");
    // simplepie ignores the above and creates default sanitizer anyway,
    // so let's override it...
    $rss->sanitize = new SanitizeDummy();
    $rss->set_output_encoding('UTF-8');
    $rss->set_raw_data($feed_data);
    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);
    $feed = db_escape_string($feed);
    if (!$rss->error()) {
        // We use local pluginhost here because we need to load different per-user feed plugins
        $pluginhost->run_hooks($pluginhost::HOOK_FEED_PARSED, "hook_feed_parsed", $rss);
        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,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_site_url = db_fetch_result($result, 0, "site_url");
        $favicon_needs_check = sql_bool_to_bool(db_fetch_result($result, 0, "favicon_needs_check"));
//.........这里部分代码省略.........
开发者ID:bohoo,项目名称:tiny_tiny_rss-openshift-quickstart-1,代码行数:101,代码来源:rssfuncs.php

示例15: unset

 $feedimport_where .= 'MD5(CONCAT(cnt_id,cnt_text))=' . _dbEscape($feedimport_source);
 unset($_getVar['feedimport']);
 $feedimport_result = _dbGet('phpwcms_content', 'cnt_id,cnt_name,cnt_text,cnt_object', $feedimport_where);
 if (isset($feedimport_result[0]['cnt_id'])) {
     $feedimport_result = $feedimport_result[0];
     $feedimport_result['cnt_object'] = @unserialize($feedimport_result['cnt_object']);
 }
 if (isset($feedimport_result['cnt_object']['structure_level_id'])) {
     // retrieve Feed now
     // Load SimplePie
     require_once PHPWCMS_ROOT . '/include/inc_ext/simplepie.inc.php';
     $rss_obj = new SimplePie();
     // Feed URL
     $rss_obj->set_feed_url($feedimport_result['cnt_text']);
     // Output Encoding Charset
     $rss_obj->set_output_encoding(PHPWCMS_CHARSET);
     // Disable Feed cache
     $rss_obj->enable_cache(false);
     // Remove surrounding DIV
     $rss_obj->remove_div(true);
     // Init Feed
     $rss_obj->init();
     if ($rss_obj->data) {
         $feedimport_result['status'] = array('Feed Importer Status - ' . date('Y-m-d, H:i:s') . LF . '===========================================', $feedimport_result['cnt_name'] . LF . $feedimport_result['cnt_text'] . LF);
         if (!empty($feedimport_result['cnt_object']['image_url_replace'])) {
             $feedimport_result['cnt_object']['image_url_replace'] = explode('>', $feedimport_result['cnt_object']['image_url_replace']);
             $feedimport_result['cnt_object']['image_url_replace'][0] = trim(trim($feedimport_result['cnt_object']['image_url_replace'][0]), '"');
             if (isset($feedimport_result['cnt_object']['image_url_replace'][1])) {
                 $feedimport_result['cnt_object']['image_url_replace'][1] = trim(trim($feedimport_result['cnt_object']['image_url_replace'][1]), '"');
             }
         } else {
开发者ID:Ideenkarosell,项目名称:phpwcms,代码行数:31,代码来源:frontend.init.php


注:本文中的SimplePie::set_output_encoding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。