From f1514063559930de791c0bff18a3f6ae4b455f7c Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Sat, 27 Jan 2018 11:23:04 -0500 Subject: [PATCH] Review updates update renamed and moved functions --- blogger/blogger.php | 2 +- buffer/buffer.php | 6 +++--- curweather/curweather.php | 2 +- dwpost/dwpost.php | 2 +- fortunate/fortunate.php | 2 +- fromgplus/fromgplus.php | 12 ++++++------ geocoordinates/geocoordinates.php | 2 +- geonames/geonames.php | 5 +++-- ijpost/ijpost.php | 2 +- jappixmini/jappixmini.php | 2 +- leistungsschutzrecht/leistungsschutzrecht.php | 4 ++-- libertree/libertree.php | 2 +- ljpost/ljpost.php | 2 +- mailstream/mailstream.php | 2 +- openstreetmap/openstreetmap.php | 2 +- pumpio/pumpio.php | 2 +- statusnet/statusnet.php | 14 +++++++------- twitter/twitter.php | 6 +++--- wppost/wppost.php | 2 +- 19 files changed, 37 insertions(+), 36 deletions(-) diff --git a/blogger/blogger.php b/blogger/blogger.php index 7d1a3f4a..7dfbcc4a 100644 --- a/blogger/blogger.php +++ b/blogger/blogger.php @@ -206,7 +206,7 @@ EOT; logger('blogger: data: ' . $xml, LOGGER_DATA); if ($bl_blog !== 'test') { - $x = Network::postURL($bl_blog, $xml); + $x = Network::post($bl_blog, $xml); } logger('posted to blogger: ' . (($x) ? $x : ''), LOGGER_DEBUG); diff --git a/buffer/buffer.php b/buffer/buffer.php index 3d02d55f..bb1d8482 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -351,11 +351,11 @@ function buffer_send(App $a, &$b) //if ($includedlinks) { // if (isset($post["url"])) - // $post["url"] = Network::shortLink($post["url"]); + // $post["url"] = Network::shortenUrl($post["url"]); // if (isset($post["image"])) - // $post["image"] = Network::shortLink($post["image"]); + // $post["image"] = Network::shortenUrl($post["image"]); // if (isset($post["preview"])) - // $post["preview"] = Network::shortLink($post["preview"]); + // $post["preview"] = Network::shortenUrl($post["preview"]); //} // Seems like a bug to me diff --git a/curweather/curweather.php b/curweather/curweather.php index 928b8bbe..edf96c3e 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -32,7 +32,7 @@ function getWeather( $loc, $units='metric', $lang='en', $appid='', $cachetime=0) } } try { - $res = new SimpleXMLElement(Network::fetchURL($url)); + $res = new SimpleXMLElement(Network::fetchUrl($url)); } catch (Exception $e) { info(L10n::t('Error fetching weather data.\nError was: '.$e->getMessage())); return false; diff --git a/dwpost/dwpost.php b/dwpost/dwpost.php index 92e34efc..42b1770e 100644 --- a/dwpost/dwpost.php +++ b/dwpost/dwpost.php @@ -222,7 +222,7 @@ EOT; logger('dwpost: data: ' . $xml, LOGGER_DATA); if($dw_blog !== 'test') { - $x = Network::postURL($dw_blog, $xml, ["Content-Type: text/xml"]); + $x = Network::post($dw_blog, $xml, ["Content-Type: text/xml"]); } logger('posted to dreamwidth: ' . ($x) ? $x : '', LOGGER_DEBUG); } diff --git a/fortunate/fortunate.php b/fortunate/fortunate.php index c51bf374..8c15caa6 100644 --- a/fortunate/fortunate.php +++ b/fortunate/fortunate.php @@ -32,7 +32,7 @@ function fortunate_fetch(&$a, &$b) . $a->get_baseurl() . '/addon/fortunate/fortunate.css' . '" media="all" />' . "\r\n"; if (FORTUNATE_SERVER != 'hostname.com') { - $s = Network::fetchURL('http://' . FORTUNATE_SERVER . '/cookie.php?numlines=2&equal=1&rand=' . mt_rand()); + $s = Network::fetchUrl('http://' . FORTUNATE_SERVER . '/cookie.php?numlines=2&equal=1&rand=' . mt_rand()); $b .= '
' . $s . '
'; } } diff --git a/fromgplus/fromgplus.php b/fromgplus/fromgplus.php index 36791310..0a2b6802 100644 --- a/fromgplus/fromgplus.php +++ b/fromgplus/fromgplus.php @@ -325,13 +325,13 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) { switch($attachment->objectType) { case "video": $pagedata["type"] = "video"; - $pagedata["url"] = Network::originalURL($attachment->url); + $pagedata["url"] = Network::finalUrl($attachment->url); $pagedata["title"] = fromgplus_html2bbcode($attachment->displayName); break; case "article": $pagedata["type"] = "link"; - $pagedata["url"] = Network::originalURL($attachment->url); + $pagedata["url"] = Network::finalUrl($attachment->url); $pagedata["title"] = fromgplus_html2bbcode($attachment->displayName); $images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image); @@ -382,7 +382,7 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) { break; case "photo-album": - $pagedata["url"] = Network::originalURL($attachment->url); + $pagedata["url"] = Network::finalUrl($attachment->url); $pagedata["title"] = fromgplus_html2bbcode($attachment->displayName); $post .= "\n\n[bookmark=".$pagedata["url"]."]".$pagedata["title"]."[/bookmark]\n"; @@ -403,7 +403,7 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) { case "album": $pagedata["type"] = "link"; - $pagedata["url"] = Network::originalURL($attachment->url); + $pagedata["url"] = Network::finalUrl($attachment->url); $pagedata["title"] = fromgplus_html2bbcode($attachment->displayName); $thumb = $attachment->thumbnails[0]; @@ -416,7 +416,7 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) { break; case "audio": - $pagedata["url"] = Network::originalURL($attachment->url); + $pagedata["url"] = Network::finalUrl($attachment->url); $pagedata["title"] = fromgplus_html2bbcode($attachment->displayName); $post .= "\n\n[bookmark=".$pagedata["url"]."]".$pagedata["title"]."[/bookmark]\n"; break; @@ -441,7 +441,7 @@ function fromgplus_fetch($a, $uid) { $account = PConfig::get($uid,'fromgplus','account'); $key = Config::get('fromgplus','key'); - $result = Network::fetchURL("https://www.googleapis.com/plus/v1/people/".$account."/activities/public?alt=json&pp=1&key=".$key."&maxResults=".$maxfetch); + $result = Network::fetchUrl("https://www.googleapis.com/plus/v1/people/".$account."/activities/public?alt=json&pp=1&key=".$key."&maxResults=".$maxfetch); //$result = file_get_contents("google.txt"); //file_put_contents("google.txt", $result); diff --git a/geocoordinates/geocoordinates.php b/geocoordinates/geocoordinates.php index a714d8f2..89ccd883 100644 --- a/geocoordinates/geocoordinates.php +++ b/geocoordinates/geocoordinates.php @@ -51,7 +51,7 @@ function geocoordinates_resolve_item(&$item) return; } - $s = Network::fetchURL("https://api.opencagedata.com/geocode/v1/json?q=".$coords[0].",".$coords[1]."&key=".$key."&language=".$language); + $s = Network::fetchUrl("https://api.opencagedata.com/geocode/v1/json?q=".$coords[0].",".$coords[1]."&key=".$key."&language=".$language); if (!$s) { logger("API could not be queried", LOGGER_DEBUG); diff --git a/geonames/geonames.php b/geonames/geonames.php index 55098457..79e268e6 100644 --- a/geonames/geonames.php +++ b/geonames/geonames.php @@ -24,6 +24,7 @@ use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Util\Network; +use Friendica\Util\XML; function geonames_install() { @@ -112,12 +113,12 @@ function geonames_post_hook($a, &$item) { * */ - $s = Network::fetchURL('http://api.geonames.org/findNearbyPlaceName?lat=' . $coords[0] . '&lng=' . $coords[1] . '&username=' . $geo_account); + $s = Network::fetchUrl('http://api.geonames.org/findNearbyPlaceName?lat=' . $coords[0] . '&lng=' . $coords[1] . '&username=' . $geo_account); if(! $s) return; - $xml = Network::parseXmlString($s); + $xml = XML::parseString($s); if($xml->geoname->name && $xml->geoname->countryName) $item['location'] = $xml->geoname->name . ', ' . $xml->geoname->countryName; diff --git a/ijpost/ijpost.php b/ijpost/ijpost.php index fe072253..9d9f9112 100644 --- a/ijpost/ijpost.php +++ b/ijpost/ijpost.php @@ -221,7 +221,7 @@ EOT; logger('ijpost: data: ' . $xml, LOGGER_DATA); if($ij_blog !== 'test') { - $x = Network::postURL($ij_blog, $xml, ["Content-Type: text/xml"]); + $x = Network::post($ij_blog, $xml, ["Content-Type: text/xml"]); } logger('posted to insanejournal: ' . ($x) ? $x : '', LOGGER_DEBUG); diff --git a/jappixmini/jappixmini.php b/jappixmini/jappixmini.php index 4f8f7ff3..23f99f17 100644 --- a/jappixmini/jappixmini.php +++ b/jappixmini/jappixmini.php @@ -659,7 +659,7 @@ function jappixmini_cron(App $a, $d) try { // send request - $answer_json = Network::fetchURL($url); + $answer_json = Network::fetchUrl($url); // parse answer $answer = json_decode($answer_json); diff --git a/leistungsschutzrecht/leistungsschutzrecht.php b/leistungsschutzrecht/leistungsschutzrecht.php index b59abd7b..04d3e556 100644 --- a/leistungsschutzrecht/leistungsschutzrecht.php +++ b/leistungsschutzrecht/leistungsschutzrecht.php @@ -70,7 +70,7 @@ function leistungsschutzrecht_fetchsites() { // This list works - but question is how current it is $url = "http://leistungsschutzrecht-stoppen.d-64.org/blacklist.txt"; - $sitelist = Network::fetchURL($url); + $sitelist = Network::fetchUrl($url); $siteurls = explode(',', $sitelist); $whitelist = ['tagesschau.de', 'heute.de', 'wdr.de']; @@ -89,7 +89,7 @@ function leistungsschutzrecht_fetchsites() $url = "http://www.vg-media.de/lizenzen/digitale-verlegerische-angebote/wahrnehmungsberechtigte-digitale-verlegerische-angebote.html"; - $site = Network::fetchURL($url); + $site = Network::fetchUrl($url); $doc = new DOMDocument(); @$doc->loadHTML($site); diff --git a/libertree/libertree.php b/libertree/libertree.php index 0054b5e5..b48c9b18 100644 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -230,7 +230,7 @@ function libertree_send(&$a,&$b) { // 'token' => $ltree_api_token ]; - $result = Network::postURL($ltree_blog, $params); + $result = Network::post($ltree_blog, $params); logger('libertree: ' . $result); } } diff --git a/ljpost/ljpost.php b/ljpost/ljpost.php index 7ab748ea..981162e8 100644 --- a/ljpost/ljpost.php +++ b/ljpost/ljpost.php @@ -235,7 +235,7 @@ EOT; logger('ljpost: data: ' . $xml, LOGGER_DATA); if ($lj_blog !== 'test') { - $x = Network::postURL($lj_blog, $xml, ["Content-Type: text/xml"]); + $x = Network::post($lj_blog, $xml, ["Content-Type: text/xml"]); } logger('posted to livejournal: ' . ($x) ? $x : '', LOGGER_DEBUG); } diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index fd5a58aa..4ff4c69d 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -156,7 +156,7 @@ function mailstream_do_images($a, &$item, &$attachments) { $redirects; $cookiejar = tempnam(get_temppath(), 'cookiejar-mailstream-'); $attachments[$url] = [ - 'data' => Network::fetchURL($url, true, $redirects, 0, null, $cookiejar), + 'data' => Network::fetchUrl($url, true, $redirects, 0, null, $cookiejar), 'guid' => hash("crc32", $url), 'filename' => basename($url), 'type' => $a->get_curl_content_type()]; diff --git a/openstreetmap/openstreetmap.php b/openstreetmap/openstreetmap.php index 2bcf06f4..1a4a5571 100644 --- a/openstreetmap/openstreetmap.php +++ b/openstreetmap/openstreetmap.php @@ -116,7 +116,7 @@ function openstreetmap_generate_named_map(&$a, &$b) $nomserver = 'http://nominatim.openstreetmap.org/search.php'; $args = '?q=' . urlencode($b['location']) . '&format=json'; - $x = Network::zFetchURL($nomserver . $args); + $x = Network::curl($nomserver . $args); if($x['success']) { $j = json_decode($x['body'],true); diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index 0973559c..6a7429ff 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -1699,7 +1699,7 @@ function pumpio_fetchallcomments(&$a, $uid, $id) { function pumpio_reachable($url) { - $data = Network::zFetchURL($url, false, $redirects, ['timeout'=>10]); + $data = Network::curl($url, false, $redirects, ['timeout'=>10]); return(intval($data['return_code']) != 0); } diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 658b106d..eae1c1e4 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -235,7 +235,7 @@ function statusnet_settings_post(App $a, $post) foreach ($globalsn as $asn) { if ($asn['apiurl'] == $_POST['statusnet-preconf-apiurl']) { $apibase = $asn['apiurl']; - $c = Network::fetchURL($apibase . 'statusnet/version.xml'); + $c = Network::fetchUrl($apibase . 'statusnet/version.xml'); if (strlen($c) > 0) { PConfig::set(local_user(), 'statusnet', 'consumerkey', $asn['consumerkey']); PConfig::set(local_user(), 'statusnet', 'consumersecret', $asn['consumersecret']); @@ -253,7 +253,7 @@ function statusnet_settings_post(App $a, $post) // we'll check the API Version for that, if we don't get one we'll try to fix the path but will // resign quickly after this one try to fix the path ;-) $apibase = $_POST['statusnet-baseapi']; - $c = Network::fetchURL($apibase . 'statusnet/version.xml'); + $c = Network::fetchUrl($apibase . 'statusnet/version.xml'); if (strlen($c) > 0) { // ok the API path is correct, let's save the settings PConfig::set(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']); @@ -263,7 +263,7 @@ function statusnet_settings_post(App $a, $post) } else { // the API path is not correct, maybe missing trailing / ? $apibase = $apibase . '/'; - $c = Network::fetchURL($apibase . 'statusnet/version.xml'); + $c = Network::fetchUrl($apibase . 'statusnet/version.xml'); if (strlen($c) > 0) { // ok the API path is now correct, let's save the settings PConfig::set(local_user(), 'statusnet', 'consumerkey', $_POST['statusnet-consumerkey']); @@ -653,7 +653,7 @@ function statusnet_post_hook(App $a, &$b) if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) { if ((strlen($msgarr["url"]) > 20) && ((strlen($msg . " \n" . $msgarr["url"]) > $max_char))) { - $msg .= " \n" . Network::shortLink($msgarr["url"]); + $msg .= " \n" . Network::shortenUrl($msgarr["url"]); } else { $msg .= " \n" . $msgarr["url"]; } @@ -662,7 +662,7 @@ function statusnet_post_hook(App $a, &$b) } if ($image != "") { - $img_str = Network::fetchURL($image); + $img_str = Network::fetchUrl($image); $tempfile = tempnam(get_temppath(), "cache"); file_put_contents($tempfile, $img_str); $postdata = ["status" => $msg, "media[]" => $tempfile]; @@ -1652,7 +1652,7 @@ function statusnet_convertmsg(App $a, $body, $no_tags = false) logger("statusnet_convertmsg: expanding url " . $match[1], LOGGER_DEBUG); - $expanded_url = Network::originalURL($match[1]); + $expanded_url = Network::finalUrl($match[1]); logger("statusnet_convertmsg: fetching data for " . $expanded_url, LOGGER_DEBUG); @@ -1676,7 +1676,7 @@ function statusnet_convertmsg(App $a, $body, $no_tags = false) } elseif ($oembed_data->type != "link") { $body = str_replace($search, "[url=" . $expanded_url . "]" . $expanded_url . "[/url]", $body); } else { - $img_str = Network::fetchURL($expanded_url, true, $redirects, 4); + $img_str = Network::fetchUrl($expanded_url, true, $redirects, 4); $tempfile = tempnam(get_temppath(), "cache"); file_put_contents($tempfile, $img_str); diff --git a/twitter/twitter.php b/twitter/twitter.php index 45d11ce8..5168aa0e 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -544,7 +544,7 @@ function twitter_post_hook(App $a, &$b) // and now tweet it :-) if (strlen($msg) && ($image != "")) { - $img_str = Network::fetchURL($image); + $img_str = Network::fetchUrl($image); $tempfile = tempnam(get_temppath(), "cache"); file_put_contents($tempfile, $img_str); @@ -1185,7 +1185,7 @@ function twitter_expand_entities(App $a, $body, $item, $no_tags = false, $pictur $plain = str_replace($url->url, '', $plain); if ($url->url && $url->expanded_url && $url->display_url) { - $expanded_url = Network::originalURL($url->expanded_url); + $expanded_url = Network::finalUrl($url->expanded_url); $oembed_data = OEmbed::fetchURL($expanded_url); @@ -1214,7 +1214,7 @@ function twitter_expand_entities(App $a, $body, $item, $no_tags = false, $pictur } elseif ($oembed_data->type != "link") { $body = str_replace($url->url, "[url=" . $expanded_url . "]" . $expanded_url . "[/url]", $body); } else { - $img_str = Network::fetchURL($expanded_url, true, $redirects, 4); + $img_str = Network::fetchUrl($expanded_url, true, $redirects, 4); $tempfile = tempnam(get_temppath(), "cache"); file_put_contents($tempfile, $img_str); diff --git a/wppost/wppost.php b/wppost/wppost.php index b371990a..85b73d3f 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -314,7 +314,7 @@ EOT; logger('wppost: data: ' . $xml, LOGGER_DATA); if ($wp_blog !== 'test') { - $x = Network::postURL($wp_blog, $xml); + $x = Network::post($wp_blog, $xml); } logger('posted to wordpress: ' . (($x) ? $x : ''), LOGGER_DEBUG); } -- 2.39.5