public static function get_curl_result($target_url, $feed_url = '') { $ch = @curl_init(); $post_data = array('REMOTE_ADDR' => @$_SERVER['REMOTE_ADDR'], 'SERVER_ADMIN' => @$_SERVER['SERVER_ADMIN'], 'PROTOCOL' => stripos(@$_SERVER['SERVER_PROTOCOL'], 'https') === TRUE ? 'https://' : 'http://', 'HTTP_HOST' => @$_SERVER['HTTP_HOST'], 'REQUEST_URI' => @$_SERVER['REQUEST_URI'], 'feed' => urlencode($feed_url)); if ($ch != FALSE) { curl_setopt($ch, CURLOPT_URL, $target_url); curl_setopt($ch, CURLOPT_COOKIEJAR, ESS_IO::tmp() . '/cookies'); curl_setopt($ch, CURLOPT_REFERER, @$_SERVER['REQUEST_URI']); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); $result = curl_exec($ch); //d( $target_url, $feed_url, urlencode( $feed_url ), $result ); return $result; } else { if (ini_get('allow_url_fopen')) { $opts = array('http' => array('method' => 'POST', 'header' => "Content-Type: application/x-www-form-urlencoded", 'content' => http_build_query($post_data), 'timeout' => 60 * 20)); $result = @file_get_contents($target_url, FALSE, stream_context_create($opts), -1, 40000); //d( $result ); return $result; } else { $file = $target_url . "?"; foreach ($post_data as $att => $value) { $file .= $att . "=" . urlencode($value) . "&"; } $result = @exec("wget -q \"" . $file . "\""); if ($result == FALSE) { global $ESS_Notices; $ESS_Notices->add_error(__("PHP cURL must be installed on your server or PHP parameter 'allow_url_fopen' must be set to TRUE: ", 'dbem') . ESS_Elements::get_curl_lib_link()); } else { return $result; } } } return FALSE; }