X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fnetwork.php;h=27459112d6a9cf2476d7c51c4e7ba537bc9c7623;hb=9d2864fc587c962a4ad9d6a7c4287b6ff59f3cc5;hp=cc267966e8fd7d562cf4be36df54cb996f3f9d7c;hpb=d4bb150b4909d500b779c8cc36d0e34a4e3ba20e;p=friendica.git diff --git a/include/network.php b/include/network.php index cc267966e8..27459112d6 100644 --- a/include/network.php +++ b/include/network.php @@ -42,6 +42,7 @@ if(!function_exists('z_fetch_url')){ * @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 + * * \e string \b redirect_url => in case of redirect, content was finally retrieved from this URL * * \e string \b header => HTTP headers * * \e string \b body => fetched content */ @@ -136,6 +137,10 @@ function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) { $base = substr($base,strlen($chunk)); } + $a->set_curl_code($http_code); + $a->set_curl_content_type($curl_info['content_type']); + $a->set_curl_headers($header); + if($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) { $new_location_info = @parse_url($curl_info["redirect_url"]); $old_location_info = @parse_url($curl_info["url"]); @@ -163,13 +168,13 @@ function z_fetch_url($url,$binary = false, &$redirects = 0, $opts=array()) { $a->set_curl_content_type($curl_info['content_type']); $body = substr($s,strlen($header)); - $a->set_curl_headers($header); $rc = intval($http_code); $ret['return_code'] = $rc; $ret['success'] = (($rc >= 200 && $rc <= 299) ? true : false); + $ret['redirect_url'] = $url; if(! $ret['success']) { $ret['error'] = curl_error($ch); $ret['debug'] = $curl_info; @@ -857,64 +862,6 @@ function parse_xml_string($s,$strict = true) { return $x; }} -function add_fcontact($arr,$update = false) { - - if($update) { - $r = q("UPDATE `fcontact` SET - `name` = '%s', - `photo` = '%s', - `request` = '%s', - `nick` = '%s', - `addr` = '%s', - `batch` = '%s', - `notify` = '%s', - `poll` = '%s', - `confirm` = '%s', - `alias` = '%s', - `pubkey` = '%s', - `updated` = '%s' - WHERE `url` = '%s' AND `network` = '%s'", - dbesc($arr['name']), - dbesc($arr['photo']), - dbesc($arr['request']), - dbesc($arr['nick']), - dbesc($arr['addr']), - dbesc($arr['batch']), - dbesc($arr['notify']), - dbesc($arr['poll']), - dbesc($arr['confirm']), - dbesc($arr['alias']), - dbesc($arr['pubkey']), - dbesc(datetime_convert()), - dbesc($arr['url']), - dbesc($arr['network']) - ); - } - else { - $r = q("insert into fcontact ( `url`,`name`,`photo`,`request`,`nick`,`addr`, - `batch`, `notify`,`poll`,`confirm`,`network`,`alias`,`pubkey`,`updated` ) - values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')", - dbesc($arr['url']), - dbesc($arr['name']), - dbesc($arr['photo']), - dbesc($arr['request']), - dbesc($arr['nick']), - dbesc($arr['addr']), - dbesc($arr['batch']), - dbesc($arr['notify']), - dbesc($arr['poll']), - dbesc($arr['confirm']), - dbesc($arr['network']), - dbesc($arr['alias']), - dbesc($arr['pubkey']), - dbesc(datetime_convert()) - ); - } - - return $r; -} - - function scale_external_images($srctext, $include_link = true, $scale_replace = false) { // Suppress "view full size"