force_fsockopen() public method

Force SimplePie to use fsockopen() instead of cURL
Since: 1.0 Beta 3
public force_fsockopen ( boolean $enable = false )
$enable boolean Force fsockopen() to be used
 /**
  * _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;
 }
/**
 * Refresh the eye on design cache
 */
function ikit_social_remote_fetch_eyeondesign_rss()
{
    $items = array();
    global $g_options;
    $feed = new SimplePie();
    $feed->set_cache_duration(0);
    $feed->set_timeout(5);
    $feed->set_feed_url(IKIT_SOCIAL_EYEONDESIGN_RSS_URL);
    $feed->set_cache_location(IKIT_DIR_CACHE);
    // XXX Fixes peculiar issue where feed was not pulling https://wcoaiga.atlassian.net/browse/AIGAIKIT-199
    $feed->force_feed(true);
    $feed->force_fsockopen(true);
    $feed->init();
}
Beispiel #3
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);
    }