From 324822a10937a090bd6939b16c572fd57c7791c1 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 1 Jun 2016 09:32:34 -0700 Subject: [PATCH] Support for CURL proxies. --- e107_handlers/file_class.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/e107_handlers/file_class.php b/e107_handlers/file_class.php index baeedd0a2..1be5cd49b 100644 --- a/e107_handlers/file_class.php +++ b/e107_handlers/file_class.php @@ -484,6 +484,15 @@ class e_file if(vartrue($options['decode'], false)) $address = urldecode($address); + $urlData = parse_url($address); + $referer = $urlData['scheme']."://".$urlData['host']; + + if(empty($referer)) + { + $referer = e_REQUEST_HTTP; + } + + // Keep this in first position. if (function_exists("curl_init")) // Preferred. { @@ -493,11 +502,27 @@ class e_file curl_setopt($cu, CURLOPT_HEADER, 0); curl_setopt($cu, CURLOPT_TIMEOUT, $timeout); curl_setopt($cu, CURLOPT_SSL_VERIFYPEER, FALSE); - curl_setopt($cu, CURLOPT_REFERER, e_REQUEST_HTTP); + curl_setopt($cu, CURLOPT_REFERER, $referer); curl_setopt($cu, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($cu, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); curl_setopt($cu, CURLOPT_COOKIEFILE, e_SYSTEM.'cookies.txt'); curl_setopt($cu, CURLOPT_COOKIEJAR, e_SYSTEM.'cookies.txt'); + + if(defined('e_CURL_PROXY')) + { + curl_setopt($cu, CURLOPT_PROXY, e_CURL_PROXY); // PROXY details with port + } + + if(defined('e_CURL_PROXYUSERPWD')) + { + curl_setopt($cu, CURLOPT_PROXYUSERPWD, e_CURL_PROXYUSERPWD); // Use if proxy have username and password + } + + if(defined('e_CURL_PROXYTYPE')) + { + curl_setopt($cu, CURLOPT_PROXYTYPE, e_CURL_PROXYTYPE); // If expected to cal + } + if($postData !== null) { curl_setopt($cu, CURLOPT_POST, true);