aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorFrank Karlitschek <frank@owncloud.org>2012-12-19 10:02:18 -0800
committerFrank Karlitschek <frank@owncloud.org>2012-12-19 10:02:18 -0800
commit96100fb447475814d67429cd5742390c20e99d2d (patch)
treea1e8ac2e82a9bbdffad0bfdff43dfdeac0f5f754 /lib
parentb162e72f94b253a2e68547c8321ebb2d81dae3bc (diff)
parent1933f858a6aa596c44f6a9e8f91e3b4620131734 (diff)
downloadnextcloud-server-96100fb447475814d67429cd5742390c20e99d2d.tar.gz
nextcloud-server-96100fb447475814d67429cd5742390c20e99d2d.zip
Merge pull request #888 from owncloud/add_curl_proxy
add curl proxy support.
Diffstat (limited to 'lib')
-rwxr-xr-xlib/util.php59
1 files changed, 32 insertions, 27 deletions
diff --git a/lib/util.php b/lib/util.php
index 4d69f3d86db..4170de2125a 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -667,34 +667,39 @@ 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('proxy','')<>'') {
+ curl_setopt($curl, CURLOPT_PROXY, OC_Config::getValue('proxy'));
+ }
+ if(OC_Config::getValue('proxyuserpwd','')<>'') {
+ curl_setopt($curl, CURLOPT_PROXYUSERPWD, OC_Config::getValue('proxyuserpwd'));
+ }
+ $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;
}
}