set_curl_options() public method

This allows you to change default curl options
Since: 1.0 Beta 3
public set_curl_options ( array $curl_options = [] )
$curl_options array Curl options to add to default settings
Esempio n. 1
0
 /**
  * Get a specific RSS feed
  *
  * @param $url             string/array   URL of the feed or array of URL
  * @param $cache_duration  timestamp      cache duration (default DAY_TIMESTAMP)
  *
  * @return feed object
  **/
 static function getRSSFeed($url, $cache_duration = DAY_TIMESTAMP)
 {
     global $CFG_GLPI;
     $feed = new SimplePie();
     $feed->set_cache_location(GLPI_RSS_DIR);
     $feed->set_cache_duration($cache_duration);
     // proxy support
     if (!empty($CFG_GLPI["proxy_name"])) {
         $prx_opt = array();
         $prx_opt[CURLOPT_PROXY] = $CFG_GLPI["proxy_name"];
         $prx_opt[CURLOPT_PROXYPORT] = $CFG_GLPI["proxy_port"];
         if (!empty($CFG_GLPI["proxy_user"])) {
             $prx_opt[CURLOPT_HTTPAUTH] = CURLAUTH_ANYSAFE;
             $prx_opt[CURLOPT_PROXYUSERPWD] = $CFG_GLPI["proxy_user"] . ":" . Toolbox::decrypt($CFG_GLPI["proxy_passwd"], GLPIKEY);
         }
         $feed->set_curl_options($prx_opt);
     }
     $feed->enable_cache(true);
     $feed->set_feed_url($url);
     $feed->force_feed(true);
     // 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.
     $feed->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.
     $feed->handle_content_type();
     if ($feed->error()) {
         return false;
     }
     return $feed;
 }
Esempio n. 2
0
function customSimplePie()
{
    $system_conf = Minz_Configuration::get('system');
    $limits = $system_conf->limits;
    $simplePie = new SimplePie();
    $simplePie->set_useragent(_t('gen.freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ') ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION);
    $simplePie->set_syslog($system_conf->simplepie_syslog_enabled);
    $simplePie->set_cache_location(CACHE_PATH);
    $simplePie->set_cache_duration($limits['cache_duration']);
    $simplePie->set_timeout($limits['timeout']);
    $simplePie->set_curl_options($system_conf->curl_options);
    $simplePie->strip_htmltags(array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'link', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'plaintext', 'script', 'style'));
    $simplePie->strip_attributes(array_merge($simplePie->strip_attributes, array('autoplay', 'onload', 'onunload', 'onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmousemove', 'onmouseout', 'onfocus', 'onblur', 'onkeypress', 'onkeydown', 'onkeyup', 'onselect', 'onchange', 'seamless')));
    $simplePie->add_attributes(array('img' => array('lazyload' => '', 'postpone' => ''), 'audio' => array('lazyload' => '', 'postpone' => '', 'preload' => 'none'), 'iframe' => array('lazyload' => '', 'postpone' => '', 'sandbox' => 'allow-scripts allow-same-origin'), 'video' => array('lazyload' => '', 'postpone' => '', 'preload' => 'none')));
    $simplePie->set_url_replacements(array('a' => 'href', 'area' => 'href', 'audio' => 'src', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'iframe' => 'src', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite', 'source' => 'src', 'track' => 'src', 'video' => array('poster', 'src')));
    return $simplePie;
}