get_type() public method

This returns a SIMPLEPIE_TYPE_* constant, which can be tested against using {@link http://php.net/language.operators.bitwise bitwise operators}
See also: SIMPLEPIE_TYPE_NONE Unknown.
See also: SIMPLEPIE_TYPE_RSS_090 RSS 0.90.
See also: SIMPLEPIE_TYPE_RSS_091_NETSCAPE RSS 0.91 (Netscape).
See also: SIMPLEPIE_TYPE_RSS_091_USERLAND RSS 0.91 (Userland).
See also: SIMPLEPIE_TYPE_RSS_091 RSS 0.91.
See also: SIMPLEPIE_TYPE_RSS_092 RSS 0.92.
See also: SIMPLEPIE_TYPE_RSS_093 RSS 0.93.
See also: SIMPLEPIE_TYPE_RSS_094 RSS 0.94.
See also: SIMPLEPIE_TYPE_RSS_10 RSS 1.0.
See also: SIMPLEPIE_TYPE_RSS_20 RSS 2.0.x.
See also: SIMPLEPIE_TYPE_RSS_RDF RDF-based RSS.
See also: SIMPLEPIE_TYPE_RSS_SYNDICATION Non-RDF-based RSS (truly intended as syndication format).
See also: SIMPLEPIE_TYPE_RSS_ALL Any version of RSS.
See also: SIMPLEPIE_TYPE_ATOM_03 Atom 0.3.
See also: SIMPLEPIE_TYPE_ATOM_10 Atom 1.0.
See also: SIMPLEPIE_TYPE_ATOM_ALL Any version of Atom.
See also: SIMPLEPIE_TYPE_ALL Any known/supported feed type.
Since: 0.8 (usage changed to using constants in 1.0)
public get_type ( ) : integer
return integer SIMPLEPIE_TYPE_* constant
示例#1
0
 /**
  */
 public function add()
 {
     $feed_user_title = $this->input->post('feed_title', TRUE);
     $feed_url = $this->input->post('feed_url');
     $usercat = $this->input->post('category');
     $feed_filter_type = $this->input->post('feed_type');
     $_icon = $this->input->post('favicon_icon');
     $favicon_icon = $_icon;
     if (!isset($feed_url) || $feed_url == '') {
         $this->stencil->title('Feeds');
         $this->stencil->layout('admin_layout');
         $this->stencil->css(array('admin_css/bootstrap.min', 'admin_css/bootstrap-responsive.min', 'admin_css/styles'));
         $this->stencil->js(array('vendors/datatables/js/jquery.dataTables.min.js', 'DT_bootstrap'));
         $this->stencil->paint('admin/feeds/add');
     } else {
         $check = $this->validateUrl($feed_url);
         if ($check == FALSE) {
             echo json_encode(array('result' => 'fail', 'msg' => '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button>Url Already exists in the database!</div>'));
             die;
         }
         $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()) {
             echo json_encode(array('result' => 'fail', 'msg' => '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button>Found error while making request</div>'));
         } else {
             //                $return = $this->feed_model->addFeeds($feed->get_items(0, 500));
             $feed_image_link = $feed->get_image_link();
             $feed_image_url = $feed->get_image_url();
             $feed_image_title = $feed->get_image_title();
             $return = $this->feedModel->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);
             if ($return) {
                 echo json_encode(array('result' => 'success', 'msg' => '<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button>Blog is added successfully</div>'));
             } else {
                 echo json_encode(array('result' => 'fail', 'msg' => '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button>Found error while making request</div>'));
             }
         }
     }
 }
示例#2
0
 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);
             }
         }
     }
 }
示例#3
0
 function get_type()
 {
     // Allow filters to pre-empt a type determination from SimplePie
     $ret = apply_filters('feedwordpie_get_type', NULL, $this);
     // If not preempted by a filter, fall back on SimplePie
     if (is_null($ret)) {
         $ret = parent::get_type();
     }
     return $ret;
 }
示例#4
0
 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);
 }
示例#5
0
    /**
     * Processing the parameters into placeholders
     * @param string    $spie   snippet parameters
     * @return array    placeholders
     */
    private function _setSimplePieModxPlaceholders($spie) {
        /**
         * @link http://github.com/simplepie/simplepie/tree/one-dot-two
         */
        if (!file_exists($spie['simplePieClassFile'])) {
            return 'File ' . $spie['simplePieClassFile'] . ' does not exist.';
        }
        include_once $spie['simplePieClassFile'];
        $feed = new SimplePie();
        $joinKey = 0;
        foreach ($spie['setFeedUrl'] as $setFeedUrl) {
            $feed->set_cache_location($spie['setCacheLocation']);
            $feed->set_feed_url($setFeedUrl);

            if (isset($spie['setInputEncoding'])) {
                $feed->set_input_encoding($spie['setInputEncoding']);
            }
            if (isset($spie['setOutputEncoding'])) {
                $feed->set_output_encoding($spie['setOutputEncoding']);
            }
            // if no cURL, try fsockopen
            if (isset($spie['forceFSockopen'])) {
                $feed->force_fsockopen(true);
            }
            if (isset($spie['enableCache']))
                $feed->enable_cache($spie['enableCache']);
            if (isset($spie['enableOrderByDate']))
                $feed->enable_order_by_date($spie['enableOrderByDate']);
            if (isset($spie['setCacheDuration']))
                $feed->set_cache_duration($spie['setCacheDuration']);
            if (!empty($spie['setFaviconHandler']))
                $feed->set_favicon_handler($spie['setFaviconHandler'][0], $spie['setFaviconHandler'][1]);
            if (!empty($spie['setImageHandler'])) {
                // handler_image.php?image=67d5fa9a87bad230fb03ea68b9f71090
                $feed->set_image_handler($spie['setImageHandler'][0], $spie['setImageHandler'][1]);
            }

            // disabled since these are all splitted into a single fetching
            // it's  been used with different way, see below looping
//            if (isset($spie['setItemLimit']))
//                $feed->set_item_limit((int) $spie['setItemLimit']);

            if (isset($spie['setJavascript']))
                $feed->set_javascript($spie['setJavascript']);
            if (isset($spie['stripAttributes']))
                $feed->strip_attributes(array_merge($feed->strip_attributes, $spie['stripAttributes']));
            if (isset($spie['stripComments']))
                $feed->strip_comments($spie['stripComments']);
            if (isset($spie['stripHtmlTags']))
                $feed->strip_htmltags(array_merge($feed->strip_htmltags, $spie['stripHtmlTags']));

            /**
             * Initiating the Feeding.
             * This always be placed AFTER all the settings above.
             */
            if (!$feed->init()) {
                echo $feed->error();
                return FALSE;
            }

            $countItems = count($feed->get_items());
            if (1 > $countItems) {
                continue;
            }

            $feed->handle_content_type();

            $countLimit = 0;
            foreach ($feed->get_items($getItemStart, $getItemEnd) as $item) {

                if (isset($spie['setItemLimit']) && $spie['setItemLimit'] == $countLimit)
                    continue;

                $phArray[$joinKey]['favicon'] = $feed->get_favicon();
                $phArray[$joinKey]['link'] = $item->get_link();
                $phArray[$joinKey]['title'] = $item->get_title();
                $phArray[$joinKey]['description'] = $item->get_description();
                $phArray[$joinKey]['content'] = $item->get_content();

                $phArray[$joinKey]['permalink'] = $item->get_permalink();
                $parsedUrl = parse_url($phArray[$joinKey]['permalink']);
                $implodedParsedUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'];
                $imageLink = $feed->get_image_link() != '' ? $feed->get_image_link() : $implodedParsedUrl;
                $phArray[$joinKey]['imageLink'] = $imageLink;

                $phArray[$joinKey]['imageTitle'] = $feed->get_image_title();
                $phArray[$joinKey]['imageUrl'] = $feed->get_image_url();
                $phArray[$joinKey]['imageWidth'] = $feed->get_image_width();
                $phArray[$joinKey]['imageHeight'] = $feed->get_image_height();

                $phArray[$joinKey]['date'] = $item->get_date($spie['dateFormat']);
                $phArray[$joinKey]['localDate'] = $item->get_local_date($spie['localDateFormat']);
                $phArray[$joinKey]['copyright'] = $item->get_copyright();

                $phArray[$joinKey]['latitude'] = $feed->get_latitude();
                $phArray[$joinKey]['longitude'] = $feed->get_longitude();

                $phArray[$joinKey]['language'] = $feed->get_language();
                $phArray[$joinKey]['encoding'] = $feed->get_encoding();

                if ($item->get_authors()) {
                    foreach ($item->get_authors() as $authorObject) {
                        $authorName = $authorObject->get_name();
                        $authorLink = $authorObject->get_link();
                        $authorEmail = $authorObject->get_email();
                    }
                    $phArray[$joinKey]['authorName'] = $authorName;
                    $phArray[$joinKey]['authorLink'] = $authorLink;
                    $phArray[$joinKey]['authorEmail'] = $authorEmail;
                }

                $category = $item->get_category();
                if ($category) {
                    $phArray[$joinKey]['category'] = htmlspecialchars_decode($category->get_label(), ENT_QUOTES);
                }

                $contributor = $item->get_contributor();
                $phArray[$joinKey]['contributor'] = '';
                if ($contributor) {
                    $phArray[$joinKey]['contributor'] = $contributor->get_name();
                }

                if ($feed->get_type() & SIMPLEPIE_TYPE_NONE) {
                    $phArray[$joinKey]['getType'] = 'Unknown';
                } elseif ($feed->get_type() & SIMPLEPIE_TYPE_RSS_ALL) {
                    $phArray[$joinKey]['getType'] = 'RSS';
                } elseif ($feed->get_type() & SIMPLEPIE_TYPE_ATOM_ALL) {
                    $phArray[$joinKey]['getType'] = 'Atom';
                } elseif ($feed->get_type() & SIMPLEPIE_TYPE_ALL) {
                    $phArray[$joinKey]['getType'] = 'Supported';
                }
				
				// Media from Flickr RSS stream
				if ($enclosure = $item->get_enclosure()) {
						$phArray[$joinKey]['itemImageThumbnailUrl'] = $enclosure->get_thumbnail();
						$phArray[$joinKey]['itemImageWidth'] = $enclosure->get_width();
						$phArray[$joinKey]['itemImageHeight'] = $enclosure->get_height();
				}
				

                $countLimit++;
                $joinKey++;
            } // foreach ($feed->get_items($getItemStart, $getItemEnd) as $item)
        } // foreach ($spie['setFeedUrl'] as $setFeedUrl)
        return $this->_filterModxTags($phArray);
    }