diff options
author | Frank Karlitschek <frank@owncloud.org> | 2012-12-14 18:52:16 +0100 |
---|---|---|
committer | Frank Karlitschek <frank@owncloud.org> | 2012-12-19 18:50:19 +0100 |
commit | 019da9943a594cb2e4c727140dbd87cd103231d8 (patch) | |
tree | 6576ca6d948eda503057043066448f55422b1823 /lib | |
parent | b162e72f94b253a2e68547c8321ebb2d81dae3bc (diff) | |
download | nextcloud-server-019da9943a594cb2e4c727140dbd87cd103231d8.tar.gz nextcloud-server-019da9943a594cb2e4c727140dbd87cd103231d8.zip |
add curl proxy support. Fixes #504
https://github.com/owncloud/core/issues/504
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/util.php | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/lib/util.php b/lib/util.php index 4d69f3d86db..8c71d3cb4ed 100755 --- a/lib/util.php +++ b/lib/util.php @@ -667,34 +667,35 @@ class OC_Util { * If not, file_get_element is used. */ - public static function getUrlContent($url){ + public static function getUrlContent($url){ - if (function_exists('curl_init')) { - - $curl = curl_init(); - - curl_setopt($curl, CURLOPT_HEADER, 0); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); - curl_setopt($curl, CURLOPT_URL, $url); - curl_setopt($curl, CURLOPT_USERAGENT, "ownCloud Server Crawler"); - $data = curl_exec($curl); - curl_close($curl); - - } else { - - $ctx = stream_context_create( - array( - 'http' => array( - 'timeout' => 10 - ) - ) - ); - $data=@file_get_contents($url, 0, $ctx); - - } - - return $data; + if (function_exists('curl_init')) { + + $curl = curl_init(); + + curl_setopt($curl, CURLOPT_HEADER, 0); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_USERAGENT, "ownCloud Server Crawler"); + if(OC_Config::getValue('curlproxy','')=='') curl_setopt($curl, CURLOPT_PROXY, OC_Config::getValue('curlproxy')); + if(OC_Config::getValue('curlproxyuserpwd','')=='') curl_setopt($curl, CURLOPT_PROXYUSERPWD, OC_Config::getValue('curlproxyuserpwd')); + $data = curl_exec($curl); + curl_close($curl); + + } else { + + $ctx = stream_context_create( + array( + 'http' => array( + 'timeout' => 10 + ) + ) + ); + $data=@file_get_contents($url, 0, $ctx); + + } + return $data; } } |