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


PHP SimplePie::__destruct方法代码示例

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


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

示例1: init

 /**
  * Initialize our class and load the items in
  *
  * {@internal Long Description Missing}}
  */
 public function init()
 {
     if (is_null($this->simplepie)) {
         $this->load();
     }
     $this->simplepie_items =& $this->simplepie->get_items();
     /** Run through each item at least once */
     foreach ($this->simplepie_items as $item) {
         $new_item = $this->normalise($item);
         $this->items[$new_item->hash] = $new_item;
     }
     uasort($this->items, array($this, 'sort_items'));
     $this->simplepie->__destruct();
     unset($this->simplepie);
     unset($this->simplepie_items);
     return $this->items;
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:22,代码来源:class-items.php

示例2: 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

示例3: UpdateFeeds

/**
* Update the feeds
* 
*/
function UpdateFeeds()
{
    if (!is_dir('./tmp')) {
        mkdir('./tmp', 0777);
    }
    $feedData = array();
    $lock = Lock("Update Feeds", false);
    if (isset($lock)) {
        // load the list of feeds
        require_once './settings/feeds.inc';
        require_once './lib/simplepie.inc';
        // loop through and update each one
        foreach ($feeds as $category => &$feedList) {
            $feedData[$category] = array();
            foreach ($feedList as $feedSource => $feedUrl) {
                $feedUrl = trim($feedUrl);
                if (strlen($feedUrl)) {
                    $feed = new SimplePie();
                    if ($feed) {
                        $rawFeed = trim(http_fetch($feedUrl));
                        $feed->set_raw_data($rawFeed);
                        $feed->enable_cache(false);
                        $feed->init();
                        // try sanitizing the data if we have a problem parsing the feed
                        if (strlen($feed->error())) {
                            FixFeed($rawFeed);
                            $feed->set_raw_data($rawFeed);
                            $feed->enable_cache(false);
                            $feed->init();
                        }
                        foreach ($feed->get_items() as $item) {
                            $dateStr = $item->get_date(DATE_RSS);
                            if ($dateStr && strlen($dateStr)) {
                                $date = strtotime($dateStr);
                                if ($date) {
                                    // only include articles from the last 30 days
                                    $now = time();
                                    $elapsed = 0;
                                    if ($now > $date) {
                                        $elapsed = $now - $date;
                                    }
                                    $days = (int) ($elapsed / 86400);
                                    if ($days <= 30) {
                                        // make sure we don't have another article from the exact same time
                                        while (isset($feedData[$category][$date])) {
                                            $date++;
                                        }
                                        $feedData[$category][$date] = array('source' => $feedSource, 'title' => $item->get_title(), 'link' => urldecode($item->get_permalink()), 'date' => $dateStr);
                                    }
                                }
                            }
                            $item->__destruct();
                        }
                        $feed->__destruct();
                        unset($feed);
                    }
                }
            }
            if (count($feedData[$category])) {
                krsort($feedData[$category]);
            }
        }
        // save out the feed data
        file_put_contents('./tmp/feeds.dat', json_encode($feedData));
        Unlock($lock);
    }
}
开发者ID:ceeaspb,项目名称:webpagetest,代码行数:71,代码来源:updateFeeds.php

示例4: addAllGroupFeed

 public function addAllGroupFeed()
 {
     if (OW::getConfig()->getValue('grouprss', 'disablePosting') == '1') {
         return;
     }
     $commentService = BOL_CommentService::getInstance();
     $newsfeedService = NEWSFEED_BOL_Service::getInstance();
     $router = OW::getRouter();
     $displayText = OW::getLanguage()->text('grouprss', 'feed_display_text');
     $location = OW::getConfig()->getValue('grouprss', 'postLocation');
     include_once 'autoloader.php';
     $allFeeds = $this->feeddao->findAll();
     foreach ($allFeeds as $feed) {
         $simplefeed = new SimplePie();
         $simplefeed->set_feed_url($feed->feedUrl);
         $simplefeed->set_stupidly_fast(true);
         $simplefeed->enable_cache(false);
         $simplefeed->init();
         $simplefeed->handle_content_type();
         $items = $simplefeed->get_items(0, $feed->feedCount);
         foreach ($items as $item) {
             $content = UTIL_HtmlTag::autoLink($item->get_content());
             if ($location == 'wall' && !$this->isDuplicateComment($feed->groupId, $content)) {
                 $commentService->addComment('groups_wal', $feed->groupId, 'groups', $feed->userId, $content);
             }
             if (trim($location) == 'newsfeed' && !$this->isDuplicateFeed($feed->groupId, $content)) {
                 $statusObject = $newsfeedService->saveStatus('groups', (int) $feed->groupId, $content);
                 $content = UTIL_HtmlTag::autoLink($content);
                 $action = new NEWSFEED_BOL_Action();
                 $action->entityId = $statusObject->id;
                 $action->entityType = "groups-status";
                 $action->pluginKey = "newsfeed";
                 $data = array("string" => $content, "content" => "[ph:attachment]", "view" => array("iconClass" => "ow_ic_comment"), "attachment" => array("oembed" => null, "url" => null, "attachId" => null), "data" => array("userId" => $feed->userId), "actionDto" => null, "context" => array("label" => $displayText, "url" => $router->urlForRoute('groups-view', array('groupId' => $feed->groupId))));
                 $action->data = json_encode($data);
                 $actionObject = $newsfeedService->saveAction($action);
                 $activity = new NEWSFEED_BOL_Activity();
                 $activity->activityType = NEWSFEED_BOL_Service::SYSTEM_ACTIVITY_CREATE;
                 $activity->activityId = $feed->userId;
                 $activity->actionId = $actionObject->id;
                 $activity->privacy = NEWSFEED_BOL_Service::PRIVACY_EVERYBODY;
                 $activity->userId = $feed->userId;
                 $activity->visibility = NEWSFEED_BOL_Service::VISIBILITY_FULL;
                 $activity->timeStamp = time();
                 $activity->data = json_encode(array());
                 $activityObject = $newsfeedService->saveActivity($activity);
                 $newsfeedService->addActivityToFeed($activity, 'groups', $feed->groupId);
             }
         }
         $simplefeed->__destruct();
         unset($feed);
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:52,代码来源:feed_service.php

示例5: items


//.........这里部分代码省略.........
                                         $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);
 }
开发者ID:esironal,项目名称:readerself,代码行数:101,代码来源:refresh.php

示例6: array

        $aStories[] = array('title' => $sTitle, 'authors' => $oItem->get_authors(), 'description' => $oItem->get_description(), 'url' => $sLink, 'local_uri' => $sLocalUri, 'published_at' => $nTimestamp);
    }
}
$SimplePie->__destruct();
unset($SimplePie);
$_GLOBAL['aStories'] = $aStories;
// #2: Get the weather
$sWeatherFeed = 'http://www.wunderground.com/auto/rss_full/CA/Palo_Alto.xml';
$SimplePie = new SimplePie();
$SimplePie->enable_cache(false);
$SimplePie->set_feed_url($sWeatherFeed);
$SimplePie->init();
$SimplePie->handle_content_type();
if ($SimplePie->error()) {
    // TODO: Delete that feed??
    $SimplePie->__destruct();
    continue;
}
$aWeather = $SimplePie->get_items();
foreach ($aWeather as $oItem) {
    $sTitle = $oItem->get_title();
    if (stristr($sTitle, 'Current Condition')) {
        $GLOBALS['sWeather'] = mb_substr($sTitle, 21);
        break;
    }
    /*if (preg_match('/^Current Conditions : (-?[0-9]{1,3}[.][0-9])/', $sTitle, $aMatches)) {
          $GLOBALS['sCurrentTemp'] = $aMatches[1]; break;
      }*/
}
$SimplePie->__destruct();
unset($SimplePie);
开发者ID:sampurtill,项目名称:Stanford-Daily-mobile,代码行数:31,代码来源:index.php

示例7: create


//.........这里部分代码省略.........
                         $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);
 }
开发者ID:slowmotion,项目名称:readerself,代码行数:101,代码来源:Subscriptions.php

示例8: fetch

 /**
  * Fetches all current events from this extension.
  * @return {Array} List of events.
  */
 function fetch($urls = null, $initial = false)
 {
     if (!$urls) {
         $urls = $this->get_url();
     }
     if (!is_array($urls)) {
         $urls = array($urls);
     }
     $items = array();
     foreach ($urls as $url_data) {
         if (is_array($url_data)) {
             // url, key
             list($url, $key) = $url_data;
         } else {
             $url = $url_data;
             $key = '';
         }
         $feed = new SimplePie();
         $feed->enable_cache(false);
         $data = $this->lifestream->file_get_contents($url);
         $feed->set_raw_data($data);
         $feed->enable_order_by_date(false);
         $feed->force_feed(true);
         $success = $feed->init();
         if (!$success) {
             $sample = substr($data, 0, 150);
             throw new Lifestream_FeedFetchError("Error fetching feed from {$url} ({$feed->error()})....\n\n{$sample}");
         }
         $feed->handle_content_type();
         foreach ($feed->get_items() as $row) {
             $rows =& $this->yield_many($row, $url, $key);
             foreach ($rows as $row) {
                 if (!$row) {
                     continue;
                 }
                 if (!$row['key']) {
                     $row['key'] = $key;
                 }
                 if (count($row)) {
                     $items[] = $row;
                 }
             }
         }
         $feed->__destruct();
         unset($feed);
     }
     return $items;
 }
开发者ID:robv,项目名称:wp-lifestream,代码行数:52,代码来源:core.php

示例9: SimplePieWP


//.........这里部分代码省略.........
        		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;
}
开发者ID:petulko391,项目名称:linux.alian.info,代码行数:101,代码来源:simplepie_wordpress_2.php

示例10: getItemsFromFeeds


//.........这里部分代码省略.........
                $hashtags = array();
                preg_match('/#([\\d\\w]+)/', $item->get_title(), $hashtags);
                foreach ($hashtags as $tag) {
                    $tag = strtolower($tag);
                    if (!in_array($tag, $item_tags) && !in_array($tag, $reserved_tags) && !is_int($tag) && strlen($tag) > 1) {
                        $item_tags[] = $tag;
                    }
                }
                # check if some existing tags are in the title
                foreach (explode(' ', $item_title) as $word) {
                    $word = strtolower($word);
                    $tagRq = $core->con->select('SELECT tag_id FROM ' . $core->prefix . 'post_tag WHERE tag_id = \'' . $word . "'");
                    if ($tagRq->count() > 1 && !in_array($word, $item_tags) && !in_array($word, $reserved_tags) && !is_int($word) && strlen($word) > 1) {
                        $item_tags[] = $word;
                    }
                }
                if (empty($item_content)) {
                    $log_msg = logMsg(sprintf(T_("No content on feed %s"), $rs->feed_url), "", 3, $print);
                } elseif (empty($permalink)) {
                    $log_msg = logMsg(T_("Error in link cutting : ") . $permalink, "", 3, $print);
                } else {
                    $log_msg = insertPostToDatabase($rs, $permalink, $item->get_date("U"), $item_title, $item_content, $item_tags, $item_image, $print, $rs->feed_id);
                    $cpt++;
                }
                # fin du $item->get_content()
                if ($print) {
                    $output .= $log_msg;
                }
            }
            # fin du foreach
            # Le flux a ete mis a jour, on le marque a la derniere date
            $cur = $core->con->openCursor($core->prefix . 'feed');
            $cur->feed_checked = array('NOW()');
            $cur->update("WHERE feed_id = '{$rs->feed_id}'");
            $log_msg = logMsg(sprintf(T_("The feed %s is updated"), $rs->feed_url), "", 2, $print);
            if ($print) {
                $output .= $log_msg;
            }
            # On fait un reset du foreach
            reset($items);
        }
        # fin $feed->error()
        # Destruction de l'objet feed avant de passer a un autre
        $feed->__destruct();
        unset($feed);
        if ($blog_settings->get('auto_feed_disabling')) {
            $toolong = time() - 86400 * 7;
            # seven days ago
            $check_sql = "SELECT feed_checked FROM " . $core->prefix . "feed WHERE feed_id=" . $rs->feed_id;
            $rs_check = $core->con->select($check_sql);
            $last_checked = mysqldatetime_to_timestamp($rs_check->f('feed_checked'));
            if ($last_checked < $toolong) {
                $diff = (time() - $last_checked) / 86400;
                $log_msg = logMsg(sprintf(T_("The feed was not updated since %d days. It'll be disabled : "), $diff) . $rs->feed_url, "", 2, $print);
                if ($print) {
                    $output .= $log_msg;
                }
                # if feed was in error for too long, let's disable it
                $cur = $core->con->openCursor($core->prefix . 'feed');
                $cur->feed_status = 2;
                $cur->update("WHERE feed_id = '{$rs->feed_id}'");
                $from = $blog_settings->get('author_mail');
                $to = $from . ',' . $rs->user_email;
                $reply_to = $from;
                $subject = sprintf(T_("Due to errors, a feed has been disabled on %s"), $blog_settings->get('planet_title'));
                $content = sprintf(T_("The feed of %s has been disabled :\n"), $rs->user_fullname);
                $content .= $rs->feed_url . "\n";
                $content .= sprintf(T_("The feed was in error during more than %d days"), $diff);
                $content .= "\n\n" . T_("Details :");
                $content .= "\n" . T_("User id : ") . $rs->user_id;
                $content .= "\n" . T_("User name : ") . $rs->user_fullname;
                $content .= "\n" . T_("User email : ") . $rs->user_email;
                $content .= "\n" . T_("Feed url : ") . $rs->feed_url;
                $content .= "\n" . T_("Last checked timestamp : ") . $last_checked;
                $content .= "\n" . T_("Website : ") . $rs->site_url;
                if (!sendmail($from, $to, $subject, $content, 'normal', $reply_to)) {
                    $log_msg = logMsg(T_("Email alert could not be send"));
                    if ($print) {
                        $output .= $log_msg;
                    }
                } else {
                    $log_msg = logMsg(T_("Feed disabled and email alert sent !"));
                    if ($print) {
                        $output .= $log_msg;
                    }
                }
            }
        }
    }
    # fin du while
    # Duree de la mise a jour
    $fin = explode(" ", microtime());
    $fin = $fin[1] + $fin[0];
    $temps_passe = round($fin - $debut, 2);
    $log_msg = logMsg("{$cpt} articles mis a jour en {$temps_passe} secondes", "", 2, $print);
    if ($print) {
        $output .= $log_msg;
    }
    return $output;
}
开发者ID:archcidburnziso,项目名称:Bilboplanet,代码行数:101,代码来源:cron_fct.php

示例11: fof_update_feed

function fof_update_feed($url)
{
    global $FOF_FEED_TABLE;
    #
    # Get feed data.
    #
    if (!$url) {
        return 0;
    }
    if (!empty($url)) {
        $piefeed = new SimplePie();
        $piefeed->set_feed_url($url);
    } else {
        return 0;
    }
    $piefeed->set_cache_location(FOF_CACHE_DIR);
    //   	echo "Memory usage after set cache: " . number_format(memory_get_usage());
    $piefeed->init();
    //echo "Memory usage after set init: " . number_format(memory_get_usage());
    $piefeed->handle_content_type();
    //echo "Memory usage after contenttype: " . number_format(memory_get_usage());
    if (!$piefeed->data) {
        //print "<font color=\"red\">" . _("error was") . "</font>: <B>" . $piefeed->error . "</b> ";
        //print "<a href=\"http://feedvalidator.org/check?url=$url\">" . _("try to validate it?") . "</a> ";
        //unset($piefeed);
        $piefeed->__destruct();
        // Do what PHP should be doing on it's own.
        return 0;
    }
    $title = $piefeed->get_title();
    $link = $piefeed->get_link();
    $description = $piefeed->get_description();
    $safeurl = mysql_escape_string($url);
    $result = fof_do_query("select id, url, aging from feeds where url='{$safeurl}'");
    $row = mysql_fetch_array($result);
    mysql_free_result($result);
    //	echo "Memory usage after first query: " . number_format(memory_get_usage());
    $feed_id = $row['id'];
    $keep_days = $row['aging'];
    if ($keep_days < 0) {
        $keep_days = 60;
    }
    //	$result2 = fof_do_query("select image from feeds where `id`='$feed_id'");
    //	$row2 = mysql_fetch_array($result2);
    //	mysql_free_result($result);
    //echo "Memory usage after second query: " . number_format(memory_get_usage());
    //  $image2 = $row2['image'];
    /*
    	if (!$image2)
    	{
    		$imagelink = $piefeed->get_favicon(true, '');
    		$HTTPRequest = @fopen($imagelink, 'r'); 
    		if ($HTTPRequest) 
    		{ 
    			stream_set_timeout($HTTPRequest, 0.1);
    			$favicon = fread($HTTPRequest, 8192);
    			$HTTPRequestData = stream_get_meta_data($HTTPRequest);
    			fclose($HTTPRequest);
    			if (!$HTTPRequestData['timed_out'] && strlen($favicon) < 42) 
    			{ 
    				$imagelink = "";
    			} 
    		}
    		else
    		{
    			$imagelink = $piefeed->get_image_url();
    			$HTTPRequest = @fopen($imagelink, 'r'); 
    			if ($HTTPRequest) 
    			{ 
    				stream_set_timeout($HTTPRequest, 0.1);
    				$favicon = fread($HTTPRequest, 8192);
    				$HTTPRequestData = stream_get_meta_data($HTTPRequest);
    				fclose($HTTPRequest);
    				if (!$HTTPRequestData['timed_out'] && strlen($favicon) < 42) 
    				{ 
    					$imagelink = "";
    				} 
    			}
    			else
    			{ 
    					$imagelink="";
    			}
    		}
    	
    		$sql = "update `$FOF_FEED_TABLE` set `image`='$imagelink' where `id`='$feed_id'";
    		$result = fof_do_query($sql);
    	mysql_free_result($result);
      
      
      }  // closes image
    */
    #
    # Get article items and attributes
    #
    foreach ($piefeed->get_items() as $item) {
        $ageflag = "0";
        $dccreator = "";
        $dcsubject = "";
        $link = mysql_escape_string($item->get_permalink());
        if (!$link) {
//.........这里部分代码省略.........
开发者ID:aboynejames,项目名称:phplifestylelinking,代码行数:101,代码来源:init.php


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