]> git.mxchange.org Git - friendica.git/blobdiff - include/network.php
Merge pull request #2110 from annando/1511-subscribe-feed
[friendica.git] / include / network.php
index deae348934747c4bb27db873e1784a51475bf620..d0217e2a084fb45019788a7f49f6c89d991bc11d 100644 (file)
@@ -10,16 +10,14 @@ if(! function_exists('fetch_url')) {
 function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_content=Null, $cookiejar = 0) {
 
        $ret = z_fetch_url(
-               $url, 
-               $binary, 
-               $redirects, 
-               array('timeout'=>$timeout, 
+               $url,
+               $binary,
+               $redirects,
+               array('timeout'=>$timeout,
                'accept_content'=>$accept_content,
                'cookiejar'=>$cookiejar
                ));
 
-
-
        return($ret['body']);
 }}
 
@@ -40,7 +38,7 @@ if(!function_exists('z_fetch_url')){
  *  * \b novalidate => do not validate SSL certs, default is to validate using our CA list
  *  * \b nobody => only return the header
  *     * \b cookiejar => path to cookie jar file
- * 
+ *
  * @return array an assoziative array with:
  *  * \e int \b return_code => HTTP return code or 0 if timeout or failure
  *  * \e boolean \b success => boolean true (if HTTP 2xx result) or false
@@ -50,7 +48,7 @@ if(!function_exists('z_fetch_url')){
 function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) {
 
        $ret = array('return_code' => 0, 'success' => false, 'header' => "", 'body' => "");
-       
+
 
        $stamp1 = microtime(true);
 
@@ -88,10 +86,9 @@ function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) {
        if(x($opts,'nobody')){
                @curl_setopt($ch, CURLOPT_NOBODY, $opts['nobody']);
        }
-       if(intval($timeout)) {
-               @curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
-       }
-       else {
+       if(x($opts,'timeout')){
+               @curl_setopt($ch, CURLOPT_TIMEOUT, $opts['timeout']);
+       } else {
                $curl_time = intval(get_config('system','curl_timeout'));
                @curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
        }
@@ -154,7 +151,7 @@ function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) {
                if (filter_var($newurl, FILTER_VALIDATE_URL)) {
                        $redirects++;
                        @curl_close($ch);
-                       return fetch_url($newurl,$binary,$redirects,$timeout,$accept_content,$cookiejar);
+                       return z_fetch_url($newurl,$binary, $redirects, $opts);
                }
        }
 
@@ -182,9 +179,9 @@ function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) {
                $ret['debug'] = $curl_info;
        }
        @curl_close($ch);
-       
+
        $a->save_timestamp($stamp1, "network");
-       
+
        return($ret);
 
 }}
@@ -311,16 +308,25 @@ function xml_status($st, $message = '') {
 
 
 if(! function_exists('http_status_exit')) {
-function http_status_exit($val) {
-
+function http_status_exit($val, $description = array()) {
     $err = '';
-       if($val >= 400)
+       if($val >= 400) {
                $err = 'Error';
+               if (!isset($description["title"]))
+                       $description["title"] = $err." ".$val;
+       }
        if($val >= 200 && $val < 300)
                $err = 'OK';
 
        logger('http_status_exit ' . $val);
        header($_SERVER["SERVER_PROTOCOL"] . ' ' . $val . ' ' . $err);
+
+       if (isset($description["title"])) {
+               $tpl = get_markup_template('http_status.tpl');
+               echo replace_macros($tpl, array('$title' => $description["title"],
+                                               '$description' => $description["description"]));
+       }
+
        killme();
 
 }}