add curl proxy support. Fixes #504
https://github.com/owncloud/core/issues/504
This commit is contained in:
parent
b162e72f94
commit
019da9943a
|
@ -42,6 +42,12 @@ $CONFIG = array(
|
||||||
/* Time in seconds how long an user is authenticated without entering his password again before performing sensitive actions like creating or deleting users etc...*/
|
/* Time in seconds how long an user is authenticated without entering his password again before performing sensitive actions like creating or deleting users etc...*/
|
||||||
"enhancedauthtime" => 15 * 60,
|
"enhancedauthtime" => 15 * 60,
|
||||||
|
|
||||||
|
/* A proxy to use to connect to the internet. For example "myproxy.org:88" */
|
||||||
|
"curlproxy" => "",
|
||||||
|
|
||||||
|
/* The optional authentication for the proxy to use to connect to the internet. The format is: [username]:[password] */
|
||||||
|
"curlproxyuserpwd" => "",
|
||||||
|
|
||||||
/* Theme to use for ownCloud */
|
/* Theme to use for ownCloud */
|
||||||
"theme" => "",
|
"theme" => "",
|
||||||
|
|
||||||
|
|
45
lib/util.php
45
lib/util.php
|
@ -667,34 +667,35 @@ class OC_Util {
|
||||||
* If not, file_get_element is used.
|
* If not, file_get_element is used.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static function getUrlContent($url){
|
public static function getUrlContent($url){
|
||||||
|
|
||||||
if (function_exists('curl_init')) {
|
if (function_exists('curl_init')) {
|
||||||
|
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
|
|
||||||
curl_setopt($curl, CURLOPT_HEADER, 0);
|
curl_setopt($curl, CURLOPT_HEADER, 0);
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||||
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
|
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
|
||||||
curl_setopt($curl, CURLOPT_URL, $url);
|
curl_setopt($curl, CURLOPT_URL, $url);
|
||||||
curl_setopt($curl, CURLOPT_USERAGENT, "ownCloud Server Crawler");
|
curl_setopt($curl, CURLOPT_USERAGENT, "ownCloud Server Crawler");
|
||||||
$data = curl_exec($curl);
|
if(OC_Config::getValue('curlproxy','')=='') curl_setopt($curl, CURLOPT_PROXY, OC_Config::getValue('curlproxy'));
|
||||||
curl_close($curl);
|
if(OC_Config::getValue('curlproxyuserpwd','')=='') curl_setopt($curl, CURLOPT_PROXYUSERPWD, OC_Config::getValue('curlproxyuserpwd'));
|
||||||
|
$data = curl_exec($curl);
|
||||||
|
curl_close($curl);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$ctx = stream_context_create(
|
$ctx = stream_context_create(
|
||||||
array(
|
array(
|
||||||
'http' => array(
|
'http' => array(
|
||||||
'timeout' => 10
|
'timeout' => 10
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$data=@file_get_contents($url, 0, $ctx);
|
$data=@file_get_contents($url, 0, $ctx);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return $data;
|
||||||
return $data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue