X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fnetwork.php;h=4bec4a172778db2c1c452b937787fe25a9f7aaac;hb=912e008ded3d439f7779310eb422e4b871a9b63d;hp=22157ff1889ce6ef4cebb8df3e09cce902ae7fba;hpb=bdd275474044152a5d9a33ea6b8a8071b931d27e;p=friendica.git diff --git a/include/network.php b/include/network.php old mode 100755 new mode 100644 index 22157ff188..4bec4a1727 --- a/include/network.php +++ b/include/network.php @@ -172,7 +172,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0) $url_parsed = @parse_url($newurl); if (isset($url_parsed)) { $redirects++; - return fetch_url($newurl,$binary,$redirects,$timeout); + return fetch_url($newurl,false,$redirects,$timeout); } } $a->set_curl_code($http_code); @@ -206,6 +206,7 @@ function xml_status($st, $message = '') { if(! function_exists('http_status_exit')) { function http_status_exit($val) { + $err = ''; if($val >= 400) $err = 'Error'; if($val >= 200 && $val < 300) @@ -364,6 +365,9 @@ function lrdd($uri, $debug = false) { logger('lrdd: host_meta: ' . $xml, LOGGER_DATA); + if(! stristr($xml,'getElementsByTagName('link'); foreach($items as $item) { $x = $item->getAttribute('rel'); @@ -584,13 +588,14 @@ function fetch_xrd_links($url) { if(! function_exists('validate_url')) { function validate_url(&$url) { - // no naked subdomains - if(strpos($url,'.') === false) + + // no naked subdomains (allow localhost for tests) + if(strpos($url,'.') === false && strpos($url,'/localhost/') === false) return false; if(substr($url,0,4) != 'http') $url = 'http://' . $url; $h = @parse_url($url); - + if(($h) && (dns_get_record($h['host'], DNS_A + DNS_CNAME + DNS_PTR))) { return true; } @@ -689,18 +694,23 @@ function allowed_email($email) { }} -if(! function_exists('gravatar_img')) { -function gravatar_img($email) { - $size = 175; - $opt = 'identicon'; // psuedo-random geometric pattern if not found - $rating = 'pg'; - $hash = md5(trim(strtolower($email))); - - $url = 'http://www.gravatar.com/avatar/' . $hash . '.jpg' - . '?s=' . $size . '&d=' . $opt . '&r=' . $rating; +if(! function_exists('avatar_img')) { +function avatar_img($email) { + + $a = get_app(); - logger('gravatar: ' . $email . ' ' . $url); - return $url; + $avatar['size'] = 175; + $avatar['email'] = $email; + $avatar['url'] = ''; + $avatar['success'] = false; + + call_hooks('avatar_lookup', $avatar); + + if(! $avatar['success']) + $avatar['url'] = $a->get_baseurl() . '/images/person-175.jpg'; + + logger('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], LOGGER_DEBUG); + return $avatar['url']; }} @@ -821,3 +831,48 @@ function scale_external_images($s,$include_link = true) { } return $s; } + + +function fix_contact_ssl_policy(&$contact,$new_policy) { + + $ssl_changed = false; + if((intval($new_policy) == SSL_POLICY_SELFSIGN || $new_policy === 'self') && strstr($contact['url'],'https:')) { + $ssl_changed = true; + $contact['url'] = str_replace('https:','http:',$contact['url']); + $contact['request'] = str_replace('https:','http:',$contact['request']); + $contact['notify'] = str_replace('https:','http:',$contact['notify']); + $contact['poll'] = str_replace('https:','http:',$contact['poll']); + $contact['confirm'] = str_replace('https:','http:',$contact['confirm']); + $contact['poco'] = str_replace('https:','http:',$contact['poco']); + } + + if((intval($new_policy) == SSL_POLICY_FULL || $new_policy === 'full') && strstr($contact['url'],'http:')) { + $ssl_changed = true; + $contact['url'] = str_replace('http:','https:',$contact['url']); + $contact['request'] = str_replace('http:','https:',$contact['request']); + $contact['notify'] = str_replace('http:','https:',$contact['notify']); + $contact['poll'] = str_replace('http:','https:',$contact['poll']); + $contact['confirm'] = str_replace('http:','https:',$contact['confirm']); + $contact['poco'] = str_replace('http:','https:',$contact['poco']); + } + + if($ssl_changed) { + q("update contact set + url = '%s', + request = '%s', + notify = '%s', + poll = '%s', + confirm = '%s', + poco = '%s' + where id = %d limit 1", + dbesc($contact['url']), + dbesc($contact['request']), + dbesc($contact['notify']), + dbesc($contact['poll']), + dbesc($contact['confirm']), + dbesc($contact['poco']), + intval($contact['id']) + ); + } +} +