aboutsummaryrefslogtreecommitdiffstats
path: root/include/network.php
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-08-16 20:05:02 -0700
committerFriendika <info@friendika.com>2011-08-16 20:05:02 -0700
commitb28b468b2182493b958afecb388501fd66de230f (patch)
treece7adeebc826313e86b1b8ad281e2f4b8c9020a7 /include/network.php
parent98cdf5d3153ce3b4b7bc1bd505851f4ed5c73406 (diff)
downloadvolse-hubzilla-b28b468b2182493b958afecb388501fd66de230f.tar.gz
volse-hubzilla-b28b468b2182493b958afecb388501fd66de230f.tar.bz2
volse-hubzilla-b28b468b2182493b958afecb388501fd66de230f.zip
cleanup
Diffstat (limited to 'include/network.php')
-rw-r--r--include/network.php32
1 files changed, 21 insertions, 11 deletions
diff --git a/include/network.php b/include/network.php
index ddfc34977..9871b9edc 100644
--- a/include/network.php
+++ b/include/network.php
@@ -5,7 +5,7 @@
// results.
if(! function_exists('fetch_url')) {
-function fetch_url($url,$binary = false, &$redirects = 0) {
+function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0) {
$a = get_app();
@@ -17,9 +17,13 @@ function fetch_url($url,$binary = false, &$redirects = 0) {
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_USERAGENT, "Friendika");
- $curl_time = intval(get_config('system','curl_timeout'));
- curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
-
+ if(intval($timeout)) {
+ curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
+ }
+ else {
+ $curl_time = intval(get_config('system','curl_timeout'));
+ curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
+ }
// by default we will allow self-signed certs
// but you can override this
@@ -66,7 +70,7 @@ function fetch_url($url,$binary = false, &$redirects = 0) {
$url_parsed = @parse_url($url);
if (isset($url_parsed)) {
$redirects++;
- return fetch_url($url,$binary,$redirects);
+ return fetch_url($url,$binary,$redirects,$timeout);
}
}
@@ -83,7 +87,7 @@ function fetch_url($url,$binary = false, &$redirects = 0) {
// post request to $url. $params is an array of post variables.
if(! function_exists('post_url')) {
-function post_url($url,$params, $headers = null, &$redirects = 0) {
+function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0) {
$a = get_app();
$ch = curl_init($url);
if(($redirects > 8) || (! $ch))
@@ -95,8 +99,13 @@ function post_url($url,$params, $headers = null, &$redirects = 0) {
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
curl_setopt($ch, CURLOPT_USERAGENT, "Friendika");
- $curl_time = intval(get_config('system','curl_timeout'));
- curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
+ if(intval($timeout)) {
+ curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
+ }
+ else {
+ $curl_time = intval(get_config('system','curl_timeout'));
+ curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
+ }
if(defined('LIGHTTPD')) {
if(!is_array($headers)) {
@@ -150,7 +159,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0) {
$url_parsed = @parse_url($url);
if (isset($url_parsed)) {
$redirects++;
- return post_url($url,$binary,$headers,$redirects);
+ return post_url($url,$params,$headers,$redirects,$timeout);
}
}
$a->set_curl_code($http_code);
@@ -497,8 +506,9 @@ function fetch_lrdd_template($host) {
if(! function_exists('fetch_xrd_links')) {
function fetch_xrd_links($url) {
-
- $xml = fetch_url($url);
+ $xrd_timeout = intval(get_config('system','xrd_timeout'));
+ $redirects = 0;
+ $xml = fetch_url($url,false,$redirects,(($xrd_timeout) ? $xrd_timeout : 30));
logger('fetch_xrd_links: ' . $xml, LOGGER_DATA);