X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fnetwork.php;h=969f583828851a59ceb55c97d072a6bae5ef325a;hb=42c2e09382d3b2846a0cb709d88cda97e717424f;hp=df46d35932fcb694b506a3bc361516e118d609fa;hpb=ba45a292c4a2a7903a05066dbe1d0633e88a660b;p=friendica.git diff --git a/include/network.php b/include/network.php index df46d35932..969f583828 100644 --- a/include/network.php +++ b/include/network.php @@ -513,8 +513,6 @@ function allowed_email($email) { function avatar_img($email) { - $a = get_app(); - $avatar['size'] = 175; $avatar['email'] = $email; $avatar['url'] = ''; @@ -522,8 +520,9 @@ function avatar_img($email) { call_hooks('avatar_lookup', $avatar); - if(! $avatar['success']) - $avatar['url'] = $a->get_baseurl() . '/images/person-175.jpg'; + if (! $avatar['success']) { + $avatar['url'] = App::get_baseurl() . '/images/person-175.jpg'; + } logger('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], LOGGER_DEBUG); return $avatar['url']; @@ -542,10 +541,11 @@ function parse_xml_string($s,$strict = true) { libxml_use_internal_errors(true); $x = @simplexml_load_string($s2); - if(! $x) { + if (! $x) { logger('libxml: parse: error: ' . $s2, LOGGER_DATA); - foreach(libxml_get_errors() as $err) + foreach (libxml_get_errors() as $err) { logger('libxml: parse: ' . $err->code." at ".$err->line.":".$err->column." : ".$err->message, LOGGER_DATA); + } libxml_clear_errors(); } return $x; @@ -554,8 +554,9 @@ function parse_xml_string($s,$strict = true) { function scale_external_images($srctext, $include_link = true, $scale_replace = false) { // Suppress "view full size" - if (intval(get_config('system','no_view_full_size'))) + if (intval(get_config('system','no_view_full_size'))) { $include_link = false; + } $a = get_app(); @@ -564,38 +565,41 @@ function scale_external_images($srctext, $include_link = true, $scale_replace = $matches = null; $c = preg_match_all('/\[img.*?\](.*?)\[\/img\]/ism',$s,$matches,PREG_SET_ORDER); - if($c) { + if ($c) { require_once('include/Photo.php'); - foreach($matches as $mtch) { + foreach ($matches as $mtch) { logger('scale_external_image: ' . $mtch[1]); - $hostname = str_replace('www.','',substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3)); - if(stristr($mtch[1],$hostname)) + $hostname = str_replace('www.','',substr(App::get_baseurl(),strpos(App::get_baseurl(),'://')+3)); + if (stristr($mtch[1],$hostname)) { continue; + } // $scale_replace, if passed, is an array of two elements. The // first is the name of the full-size image. The second is the // name of a remote, scaled-down version of the full size image. // This allows Friendica to display the smaller remote image if // one exists, while still linking to the full-size image - if($scale_replace) + if ($scale_replace) { $scaled = str_replace($scale_replace[0], $scale_replace[1], $mtch[1]); - else + } else { $scaled = $mtch[1]; - $i = @fetch_url($scaled); - if(! $i) + } + $i = fetch_url($scaled); + if (! $i) { return $srctext; + } // guess mimetype from headers or filename $type = guess_image_type($mtch[1],true); - if($i) { + if ($i) { $ph = new Photo($i, $type); - if($ph->is_valid()) { + if ($ph->is_valid()) { $orig_width = $ph->getWidth(); $orig_height = $ph->getHeight(); - if($orig_width > 640 || $orig_height > 640) { + if ($orig_width > 640 || $orig_height > 640) { $ph->scaleImage(640); $new_width = $ph->getWidth(); @@ -621,7 +625,7 @@ function scale_external_images($srctext, $include_link = true, $scale_replace = 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:')) { + 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']); @@ -631,7 +635,7 @@ function fix_contact_ssl_policy(&$contact,$new_policy) { $contact['poco'] = str_replace('https:','http:',$contact['poco']); } - if((intval($new_policy) == SSL_POLICY_FULL || $new_policy === 'full') && strstr($contact['url'],'http:')) { + 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']); @@ -641,15 +645,15 @@ function fix_contact_ssl_policy(&$contact,$new_policy) { $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", + 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']),