update all function calls to use class, insert use statements and remove require_once statements
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
+use Friendica\Util\Network;
function blogger_install()
{
logger('blogger: data: ' . $xml, LOGGER_DATA);
if ($bl_blog !== 'test') {
- $x = post_url($bl_blog, $xml);
+ $x = Network::postURL($bl_blog, $xml);
}
logger('posted to blogger: ' . (($x) ? $x : ''), LOGGER_DEBUG);
$client_secret = Config::get("buffer", "client_secret");
$access_token = PConfig::get($b['uid'], "buffer","access_token");
- if($access_token) {
+ if ($access_token) {
$buffer = new BufferApp($client_id, $client_secret, $callback_url, $access_token);
- require_once 'include/network.php';
-
$profiles = $buffer->go('/profiles');
if (is_array($profiles)) {
logger("Will send these parameter ".print_r($b, true), LOGGER_DEBUG);
//if ($includedlinks) {
// if (isset($post["url"]))
- // $post["url"] = short_link($post["url"]);
+ // $post["url"] = Network::shortLink($post["url"]);
// if (isset($post["image"]))
- // $post["image"] = short_link($post["image"]);
+ // $post["image"] = Network::shortLink($post["image"]);
// if (isset($post["preview"]))
- // $post["preview"] = short_link($post["preview"]);
+ // $post["preview"] = Network::shortLink($post["preview"]);
//}
// Seems like a bug to me
*
*/
-require_once 'include/network.php';
require_once 'mod/proxy.php';
require_once 'include/text.php';
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
+use Friendica\Util\Network;
// get the weather data from OpenWeatherMap
function getWeather( $loc, $units='metric', $lang='en', $appid='', $cachetime=0) {
}
}
try {
- $res = new SimpleXMLElement(fetch_url($url));
+ $res = new SimpleXMLElement(Network::fetchURL($url));
} catch (Exception $e) {
info(L10n::t('Error fetching weather data.\nError was: '.$e->getMessage()));
return false;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
+use Friendica\Util\Network;
function dwpost_install() {
Addon::registerHook('post_local', 'addon/dwpost/dwpost.php', 'dwpost_post_local');
logger('dwpost: data: ' . $xml, LOGGER_DATA);
- if($dw_blog !== 'test')
- $x = post_url($dw_blog,$xml,["Content-Type: text/xml"]);
+ if($dw_blog !== 'test') {
+ $x = Network::postURL($dw_blog, $xml, ["Content-Type: text/xml"]);
+ }
logger('posted to dreamwidth: ' . ($x) ? $x : '', LOGGER_DEBUG);
-
}
}
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/
use Friendica\Core\Addon;
+use Friendica\Util\Network;
// IMPORTANT: SET THIS to your fortunate server
-define ('FORTUNATE_SERVER', 'hostname.com');
+define('FORTUNATE_SERVER', 'hostname.com');
-function fortunate_install() {
+function fortunate_install()
+{
Addon::registerHook('page_end', 'addon/fortunate/fortunate.php', 'fortunate_fetch');
- if(FORTUNATE_SERVER == 'hostname.com' && is_site_admin()) {
+ if (FORTUNATE_SERVER == 'hostname.com' && is_site_admin()) {
notice('Fortunate addon requires configuration. See README');
}
}
-function fortunate_uninstall() {
+function fortunate_uninstall()
+{
Addon::unregisterHook('page_end', 'addon/fortunate/fortunate.php', 'fortunate_fetch');
}
-function fortunate_fetch(&$a,&$b) {
-
+function fortunate_fetch(&$a, &$b)
+{
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'
. $a->get_baseurl() . '/addon/fortunate/fortunate.css' . '" media="all" />' . "\r\n";
- if(FORTUNATE_SERVER != 'hostname.com') {
- $s = fetch_url('http://' . FORTUNATE_SERVER . '/cookie.php?numlines=2&equal=1&rand=' . mt_rand());
+ if (FORTUNATE_SERVER != 'hostname.com') {
+ $s = Network::fetchURL('http://' . FORTUNATE_SERVER . '/cookie.php?numlines=2&equal=1&rand=' . mt_rand());
$b .= '<div class="fortunate">' . $s . '</div>';
}
}
-
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Object\Image;
+use Friendica\Util\Network;
require_once 'mod/share.php';
require_once 'mod/parse_url.php';
}
function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
- require_once("include/items.php");
- require_once("include/network.php");
+ require_once 'include/items.php';
$post = "";
$quote = "";
switch($attachment->objectType) {
case "video":
$pagedata["type"] = "video";
- $pagedata["url"] = original_url($attachment->url);
+ $pagedata["url"] = Network::originalURL($attachment->url);
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
break;
case "article":
$pagedata["type"] = "link";
- $pagedata["url"] = original_url($attachment->url);
+ $pagedata["url"] = Network::originalURL($attachment->url);
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
$images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
break;
case "photo-album":
- $pagedata["url"] = original_url($attachment->url);
+ $pagedata["url"] = Network::originalURL($attachment->url);
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
$post .= "\n\n[bookmark=".$pagedata["url"]."]".$pagedata["title"]."[/bookmark]\n";
case "album":
$pagedata["type"] = "link";
- $pagedata["url"] = original_url($attachment->url);
+ $pagedata["url"] = Network::originalURL($attachment->url);
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
$thumb = $attachment->thumbnails[0];
break;
case "audio":
- $pagedata["url"] = original_url($attachment->url);
+ $pagedata["url"] = Network::originalURL($attachment->url);
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
$post .= "\n\n[bookmark=".$pagedata["url"]."]".$pagedata["title"]."[/bookmark]\n";
break;
$account = PConfig::get($uid,'fromgplus','account');
$key = Config::get('fromgplus','key');
- $result = fetch_url("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);
use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\L10n;
+use Friendica\Util\Network;
function geocoordinates_install()
{
return;
}
- $s = fetch_url("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);
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
+use Friendica\Util\Network;
function geonames_install() {
*
*/
- $s = fetch_url('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 = parse_xml_string($s);
+ $xml = Network::parseXmlString($s);
if($xml->geoname->name && $xml->geoname->countryName)
$item['location'] = $xml->geoname->name . ', ' . $xml->geoname->countryName;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
+use Friendica\Util\Network;
function ijpost_install() {
Addon::registerHook('post_local', 'addon/ijpost/ijpost.php', 'ijpost_post_local');
logger('ijpost: data: ' . $xml, LOGGER_DATA);
- if($ij_blog !== 'test')
- $x = post_url($ij_blog,$xml,["Content-Type: text/xml"]);
+ if($ij_blog !== 'test') {
+ $x = Network::postURL($ij_blog, $xml, ["Content-Type: text/xml"]);
+ }
logger('posted to insanejournal: ' . ($x) ? $x : '', LOGGER_DEBUG);
}
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Model\User;
+use Friendica\Util\Network;
function jappixmini_install()
{
try {
// send request
- $answer_json = fetch_url($url);
+ $answer_json = Network::fetchURL($url);
// parse answer
$answer = json_decode($answer_json);
*/
use Friendica\Core\Addon;
use Friendica\Core\Config;
+use Friendica\Util\Network;
function leistungsschutzrecht_install() {
Addon::registerHook('cron', 'addon/leistungsschutzrecht/leistungsschutzrecht.php', 'leistungsschutzrecht_cron');
return $text;
}
-function leistungsschutzrecht_fetchsites() {
- require_once("include/network.php");
-
+function leistungsschutzrecht_fetchsites()
+{
// This list works - but question is how current it is
$url = "http://leistungsschutzrecht-stoppen.d-64.org/blacklist.txt";
- $sitelist = fetch_url($url);
+ $sitelist = Network::fetchURL($url);
$siteurls = explode(',', $sitelist);
$whitelist = ['tagesschau.de', 'heute.de', 'wdr.de'];
$sites = [];
- foreach ($siteurls AS $site) {
+ foreach ($siteurls as $site) {
if (!in_array($site, $whitelist)) {
$sites[$site] = $site;
}
$url = "http://www.vg-media.de/lizenzen/digitale-verlegerische-angebote/wahrnehmungsberechtigte-digitale-verlegerische-angebote.html";
- $site = fetch_url($url);
+ $site = Network::fetchURL($url);
$doc = new DOMDocument();
@$doc->loadHTML($site);
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
+use Friendica\Util\Network;
function libertree_install() {
Addon::registerHook('post_local', 'addon/libertree/libertree.php', 'libertree_post_local');
// 'token' => $ltree_api_token
];
- $result = post_url($ltree_blog,$params);
+ $result = Network::postURL($ltree_blog, $params);
logger('libertree: ' . $result);
-
}
}
-
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
+use Friendica\Util\Network;
function ljpost_install() {
Addon::registerHook('post_local', 'addon/ljpost/ljpost.php', 'ljpost_post_local');
logger('ljpost: data: ' . $xml, LOGGER_DATA);
- if($lj_blog !== 'test')
- $x = post_url($lj_blog,$xml,["Content-Type: text/xml"]);
+ if ($lj_blog !== 'test') {
+ $x = Network::postURL($lj_blog, $xml, ["Content-Type: text/xml"]);
+ }
logger('posted to livejournal: ' . ($x) ? $x : '', LOGGER_DEBUG);
-
}
}
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Database\DBM;
+use Friendica\Util\Network;
function mailstream_install() {
Addon::registerHook('addon_settings', 'addon/mailstream/mailstream.php', 'mailstream_addon_settings');
$redirects;
$cookiejar = tempnam(get_temppath(), 'cookiejar-mailstream-');
$attachments[$url] = [
- 'data' => fetch_url($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()];
use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\L10n;
+use Friendica\Util\Network;
function openstreetmap_install()
{
$nomserver = 'http://nominatim.openstreetmap.org/search.php';
$args = '?q=' . urlencode($b['location']) . '&format=json';
- $x = z_fetch_url($nomserver . $args);
+ $x = Network::zFetchURL($nomserver . $args);
if($x['success']) {
$j = json_decode($x['body'],true);
use Friendica\Model\User;
use Friendica\Model\Item;
use Friendica\Model\Queue;
+use Friendica\Util\Network;
require 'addon/pumpio/oauth/http.php';
require 'addon/pumpio/oauth/oauth_client.php';
function pumpio_reachable($url) {
- $data = z_fetch_url($url, false, $redirects, ['timeout'=>10]);
+ $data = Network::zFetchURL($url, false, $redirects, ['timeout'=>10]);
return(intval($data['return_code']) != 0);
}
use Friendica\Model\Group;
use Friendica\Model\Photo;
use Friendica\Model\User;
+use Friendica\Util\Network;
class StatusNetOAuth extends TwitterOAuth
{
foreach ($globalsn as $asn) {
if ($asn['apiurl'] == $_POST['statusnet-preconf-apiurl']) {
$apibase = $asn['apiurl'];
- $c = fetch_url($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']);
// 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 = fetch_url($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']);
} else {
// the API path is not correct, maybe missing trailing / ?
$apibase = $apibase . '/';
- $c = fetch_url($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']);
PConfig::set($b['uid'], 'statusnet', 'max_char', $max_char);
$tempfile = "";
- require_once "include/network.php";
$msgarr = BBCode::toPlaintext($b, $max_char, true, 7);
$msg = $msgarr["text"];
if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) {
if ((strlen($msgarr["url"]) > 20) &&
((strlen($msg . " \n" . $msgarr["url"]) > $max_char))) {
- $msg .= " \n" . short_link($msgarr["url"]);
+ $msg .= " \n" . Network::shortLink($msgarr["url"]);
} else {
$msg .= " \n" . $msgarr["url"];
}
}
if ($image != "") {
- $img_str = fetch_url($image);
+ $img_str = Network::fetchURL($image);
$tempfile = tempnam(get_temppath(), "cache");
file_put_contents($tempfile, $img_str);
$postdata = ["status" => $msg, "media[]" => $tempfile];
if (is_array($items)) {
$posts = array_reverse($items);
- foreach ($posts AS $post) {
+ foreach ($posts as $post) {
$postarray = statusnet_createpost($a, $uid, $post, $self, false, false);
if (trim($postarray['body']) == "") {
function statusnet_convertmsg(App $a, $body, $no_tags = false)
{
require_once "include/items.php";
- require_once "include/network.php";
$body = preg_replace("=\[url\=https?://([0-9]*).([0-9]*).([0-9]*).([0-9]*)/([0-9]*)\](.*?)\[\/url\]=ism", "$1.$2.$3.$4/$5", $body);
logger("statusnet_convertmsg: expanding url " . $match[1], LOGGER_DEBUG);
- $expanded_url = original_url($match[1]);
+ $expanded_url = Network::originalURL($match[1]);
logger("statusnet_convertmsg: fetching data for " . $expanded_url, LOGGER_DEBUG);
} elseif ($oembed_data->type != "link") {
$body = str_replace($search, "[url=" . $expanded_url . "]" . $expanded_url . "[/url]", $body);
} else {
- $img_str = fetch_url($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);
use Friendica\Model\Queue;
use Friendica\Model\User;
use Friendica\Object\Image;
+use Friendica\Util\Network;
require_once 'include/enotify.php';
function twitter_post_hook(App $a, &$b)
{
// Post to Twitter
- require_once "include/network.php";
-
if (!PConfig::get($b["uid"], 'twitter', 'import')
&& ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))) {
return;
// and now tweet it :-)
if (strlen($msg) && ($image != "")) {
- $img_str = fetch_url($image);
+ $img_str = Network::fetchURL($image);
$tempfile = tempnam(get_temppath(), "cache");
file_put_contents($tempfile, $img_str);
function twitter_expand_entities(App $a, $body, $item, $no_tags = false, $picture)
{
- require_once "include/network.php";
-
$tags = "";
$plain = $body;
$footerlink = "";
$footer = "";
- foreach ($item->entities->urls AS $url) {
+ foreach ($item->entities->urls as $url) {
$plain = str_replace($url->url, '', $plain);
if ($url->url && $url->expanded_url && $url->display_url) {
- $expanded_url = original_url($url->expanded_url);
+ $expanded_url = Network::originalURL($url->expanded_url);
$oembed_data = OEmbed::fetchURL($expanded_url);
} elseif ($oembed_data->type != "link") {
$body = str_replace($url->url, "[url=" . $expanded_url . "]" . $expanded_url . "[/url]", $body);
} else {
- $img_str = fetch_url($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);
logger('wppost: data: ' . $xml, LOGGER_DATA);
- if($wp_blog !== 'test') {
- $x = post_url($wp_blog,$xml);
+ if ($wp_blog !== 'test') {
+ $x = Network::postURL($wp_blog, $xml);
}
logger('posted to wordpress: ' . (($x) ? $x : ''), LOGGER_DEBUG);
-
}
}