From 12994aaccd3fc3f26d470a2638b489a90b1f8e92 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 9 Mar 2017 06:58:36 +0000 Subject: [PATCH] Deprecated parts removed --- appnet/appnet.php | 62 ++++-------------- buffer/buffer.php | 19 +++--- pumpio/pumpio.php | 15 ++--- pumpio/pumpio_sync.php | 26 ++++---- statusnet/statusnet.php | 66 ++++--------------- twitter/twitter.php | 138 +++++++++++++++------------------------ twitter/twitter_sync.php | 26 ++++---- 7 files changed, 119 insertions(+), 233 deletions(-) diff --git a/appnet/appnet.php b/appnet/appnet.php index 0c53a49f..042b2f8c 100644 --- a/appnet/appnet.php +++ b/appnet/appnet.php @@ -5,6 +5,7 @@ * Description: Bidirectional (posting and reading) connector for app.net. * Version: 0.2 * Author: Michael Vogel + * Status: Unsupported */ /* @@ -1118,36 +1119,11 @@ function appnet_expand_annotations($a, $annotations) { function appnet_fetchcontact($a, $uid, $contact, $me, $create_user) { - if (function_exists("update_gcontact")) - update_gcontact(array("url" => $contact["canonical_url"], "generation" => 2, - "network" => NETWORK_APPNET, "photo" => $contact["avatar_image"]["url"], - "name" => $contact["name"], "nick" => $contact["username"], - "about" => $contact["description"]["text"], "hide" => true, - "addr" => $contact["username"]."@app.net")); - else { - // Old Code - $r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1", - dbesc(normalise_link($contact["canonical_url"]))); - - if (count($r) == 0) - q("INSERT INTO unique_contacts (url, name, nick, avatar) VALUES ('%s', '%s', '%s', '%s')", - dbesc(normalise_link($contact["canonical_url"])), - dbesc($contact["name"]), - dbesc($contact["username"]), - dbesc($contact["avatar_image"]["url"])); - else - q("UPDATE unique_contacts SET name = '%s', nick = '%s', avatar = '%s' WHERE url = '%s'", - dbesc($contact["name"]), - dbesc($contact["username"]), - dbesc($contact["avatar_image"]["url"]), - dbesc(normalise_link($contact["canonical_url"]))); - - if (DB_UPDATE_VERSION >= "1177") - q("UPDATE `unique_contacts` SET `location` = '%s', `about` = '%s' WHERE url = '%s'", - dbesc(""), - dbesc($contact["description"]["text"]), - dbesc(normalise_link($contact["canonical_url"]))); - } + update_gcontact(array("url" => $contact["canonical_url"], "generation" => 2, + "network" => NETWORK_APPNET, "photo" => $contact["avatar_image"]["url"], + "name" => $contact["name"], "nick" => $contact["username"], + "about" => $contact["description"]["text"], "hide" => true, + "addr" => $contact["username"]."@app.net")); $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1", intval($uid), dbesc("adn::".$contact["id"])); @@ -1174,8 +1150,8 @@ function appnet_fetchcontact($a, $uid, $contact, $me, $create_user) { // create contact record q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`, `name`, `nick`, `photo`, `network`, `rel`, `priority`, - `writable`, `blocked`, `readonly`, `pending` ) - VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ", + `about`, `writable`, `blocked`, `readonly`, `pending` ) + VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, 0, 0, 0 ) ", intval($uid), dbesc(datetime_convert()), dbesc($contact["canonical_url"]), @@ -1190,6 +1166,7 @@ function appnet_fetchcontact($a, $uid, $contact, $me, $create_user) { dbesc(NETWORK_APPNET), intval(CONTACT_IS_FRIEND), intval(1), + dbesc($contact["description"]["text"]), intval(1) ); @@ -1231,15 +1208,6 @@ function appnet_fetchcontact($a, $uid, $contact, $me, $create_user) { dbesc(datetime_convert()), intval($contact_id) ); - - if (DB_UPDATE_VERSION >= "1177") - q("UPDATE `contact` SET `location` = '%s', - `about` = '%s' - WHERE `id` = %d", - dbesc(""), - dbesc($contact["description"]["text"]), - intval($contact_id) - ); } else { // update profile photos once every two weeks as we have no notification of when they change. @@ -1266,7 +1234,8 @@ function appnet_fetchcontact($a, $uid, $contact, $me, $create_user) { `nurl` = '%s', `addr` = '%s', `name` = '%s', - `nick` = '%s' + `nick` = '%s', + `about` = '%s' WHERE `id` = %d", dbesc($photos[0]), dbesc($photos[1]), @@ -1279,16 +1248,9 @@ function appnet_fetchcontact($a, $uid, $contact, $me, $create_user) { dbesc($contact["username"]."@app.net"), dbesc($contact["name"]), dbesc($contact["username"]), + dbesc($contact["description"]["text"]), intval($r[0]['id']) ); - if (DB_UPDATE_VERSION >= "1177") - q("UPDATE `contact` SET `location` = '%s', - `about` = '%s' - WHERE `id` = %d", - dbesc(""), - dbesc($contact["description"]["text"]), - intval($r[0]['id']) - ); } } diff --git a/buffer/buffer.php b/buffer/buffer.php index 162600d6..89000c1f 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -1,7 +1,7 @@ */ @@ -328,15 +328,14 @@ function buffer_send(&$a,&$b) { if (isset($post["preview"])) $post["preview"] = proxy_url($post["preview"]); - //if ($profile->service == "twitter") { - if ($includedlinks) { - if (isset($post["url"])) - $post["url"] = short_link($post["url"]); - if (isset($post["image"])) - $post["image"] = short_link($post["image"]); - if (isset($post["preview"])) - $post["preview"] = short_link($post["preview"]); - } + //if ($includedlinks) { + // if (isset($post["url"])) + // $post["url"] = short_link($post["url"]); + // if (isset($post["image"])) + // $post["image"] = short_link($post["image"]); + // if (isset($post["preview"])) + // $post["preview"] = short_link($post["preview"]); + //} // Seems like a bug to me // Buffer doesn't add links to Twitter and App.net (but pictures) diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index 65f55552..fb7ce8c1 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -976,8 +976,8 @@ function pumpio_get_contact($uid, $contact, $no_insert = false) { // create contact record q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`, `name`, `nick`, `photo`, `network`, `rel`, `priority`, - `writable`, `blocked`, `readonly`, `pending` ) - VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0)", + `location`, `about`, `writable`, `blocked`, `readonly`, `pending` ) + VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0)", intval($uid), dbesc(datetime_convert()), dbesc($contact->url), @@ -992,6 +992,8 @@ function pumpio_get_contact($uid, $contact, $no_insert = false) { dbesc(NETWORK_PUMPIO), intval(CONTACT_IS_FRIEND), intval(1), + dbesc($contact->location->displayName), + dbesc($contact->summary), intval(1) ); @@ -1014,15 +1016,6 @@ function pumpio_get_contact($uid, $contact, $no_insert = false) { require_once('include/group.php'); group_add_member($uid,'',$contact_id,$g[0]['def_gid']); } - - if (DB_UPDATE_VERSION >= "1177") - q("UPDATE `contact` SET `location` = '%s', - `about` = '%s' - WHERE `id` = %d", - dbesc($contact->location->displayName), - dbesc($contact->summary), - intval($contact_id) - ); } else { $contact_id = $r[0]["id"]; diff --git a/pumpio/pumpio_sync.php b/pumpio/pumpio_sync.php index 346376fa..af843c1d 100644 --- a/pumpio/pumpio_sync.php +++ b/pumpio/pumpio_sync.php @@ -41,21 +41,23 @@ function pumpio_sync_run(&$argv, &$argc){ } } - $lockpath = get_lockpath(); - if ($lockpath != '') { - $pidfile = new pidfile($lockpath, 'pumpio_sync'); - if($pidfile->is_already_running()) { - logger("Already running"); - if ($pidfile->running_time() > 9*60) { - $pidfile->kill(); - logger("killed stale process"); - // Calling a new instance - proc_run('php','addon/pumpio/pumpio_sync.php'); + // This is deprecated with the worker + if (function_exists("get_lockpath")) { + $lockpath = get_lockpath(); + if ($lockpath != '') { + $pidfile = new pidfile($lockpath, 'pumpio_sync'); + if($pidfile->is_already_running()) { + logger("Already running"); + if ($pidfile->running_time() > 9*60) { + $pidfile->kill(); + logger("killed stale process"); + // Calling a new instance + proc_run('php','addon/pumpio/pumpio_sync.php'); + } + exit; } - exit; } } - pumpio_sync($a); } diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index bc9bc125..9c44ef02 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -920,36 +920,11 @@ function statusnet_fetch_contact($uid, $contact, $create_user) { if ($contact->statusnet_profile_url == "") return(-1); - if (function_exists("update_gcontact")) - update_gcontact(array("url" => $contact->statusnet_profile_url, - "network" => NETWORK_STATUSNET, "photo" => $contact->profile_image_url, - "name" => $contact->name, "nick" => $contact->screen_name, - "location" => $contact->location, "about" => $contact->description, - "addr" => statusnet_address($contact), "generation" => 3)); - else { - // Old Code - $r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1", - dbesc(normalise_link($contact->statusnet_profile_url))); - - if (count($r) == 0) - q("INSERT INTO unique_contacts (url, name, nick, avatar) VALUES ('%s', '%s', '%s', '%s')", - dbesc(normalise_link($contact->statusnet_profile_url)), - dbesc($contact->name), - dbesc($contact->screen_name), - dbesc($contact->profile_image_url)); - else - q("UPDATE unique_contacts SET name = '%s', nick = '%s', avatar = '%s' WHERE url = '%s'", - dbesc($contact->name), - dbesc($contact->screen_name), - dbesc($contact->profile_image_url), - dbesc(normalise_link($contact->statusnet_profile_url))); - - if (DB_UPDATE_VERSION >= "1177") - q("UPDATE `unique_contacts` SET `location` = '%s', `about` = '%s' WHERE url = '%s'", - dbesc($contact->location), - dbesc($contact->description), - dbesc(normalise_link($contact->statusnet_profile_url))); - } + update_gcontact(array("url" => $contact->statusnet_profile_url, + "network" => NETWORK_STATUSNET, "photo" => $contact->profile_image_url, + "name" => $contact->name, "nick" => $contact->screen_name, + "location" => $contact->location, "about" => $contact->description, + "addr" => statusnet_address($contact), "generation" => 3)); $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' AND `network` = '%s'LIMIT 1", intval($uid), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(NETWORK_STATUSNET)); @@ -966,8 +941,8 @@ function statusnet_fetch_contact($uid, $contact, $create_user) { // create contact record q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`, `name`, `nick`, `photo`, `network`, `rel`, `priority`, - `writable`, `blocked`, `readonly`, `pending` ) - VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ", + `location`, `about`, `writable`, `blocked`, `readonly`, `pending` ) + VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0 ) ", intval($uid), dbesc(datetime_convert()), dbesc($contact->statusnet_profile_url), @@ -982,6 +957,8 @@ function statusnet_fetch_contact($uid, $contact, $create_user) { dbesc(NETWORK_STATUSNET), intval(CONTACT_IS_FRIEND), intval(1), + dbesc($contact->location), + dbesc($contact->description), intval(1) ); @@ -1019,16 +996,6 @@ function statusnet_fetch_contact($uid, $contact, $create_user) { dbesc(datetime_convert()), intval($contact_id) ); - - if (DB_UPDATE_VERSION >= "1177") - q("UPDATE `contact` SET `location` = '%s', - `about` = '%s' - WHERE `id` = %d", - dbesc($contact->location), - dbesc($contact->description), - intval($contact_id) - ); - } else { // update profile photos once every two weeks as we have no notification of when they change. @@ -1055,7 +1022,9 @@ function statusnet_fetch_contact($uid, $contact, $create_user) { `nurl` = '%s', `addr` = '%s', `name` = '%s', - `nick` = '%s' + `nick` = '%s', + `location` = '%s', + `about` = '%s' WHERE `id` = %d", dbesc($photos[0]), dbesc($photos[1]), @@ -1068,17 +1037,10 @@ function statusnet_fetch_contact($uid, $contact, $create_user) { dbesc(statusnet_address($contact)), dbesc($contact->name), dbesc($contact->screen_name), + dbesc($contact->location), + dbesc($contact->description), intval($r[0]['id']) ); - - if (DB_UPDATE_VERSION >= "1177") - q("UPDATE `contact` SET `location` = '%s', - `about` = '%s' - WHERE `id` = %d", - dbesc($contact->location), - dbesc($contact->description), - intval($r[0]['id']) - ); } } diff --git a/twitter/twitter.php b/twitter/twitter.php index 0f074ba3..74121d29 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -935,36 +935,11 @@ function twitter_fetch_contact($uid, $contact, $create_user) { $avatar = twitter_fix_avatar($contact->profile_image_url_https); - if (function_exists("update_gcontact")) - update_gcontact(array("url" => "https://twitter.com/".$contact->screen_name, - "network" => NETWORK_TWITTER, "photo" => $avatar, "hide" => true, - "name" => $contact->name, "nick" => $contact->screen_name, - "location" => $contact->location, "about" => $contact->description, - "addr" => $contact->screen_name."@twitter.com", "generation" => 2)); - else { - // Old Code - $r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1", - dbesc(normalise_link("https://twitter.com/".$contact->screen_name))); - - if (count($r) == 0) - q("INSERT INTO unique_contacts (url, name, nick, avatar) VALUES ('%s', '%s', '%s', '%s')", - dbesc(normalise_link("https://twitter.com/".$contact->screen_name)), - dbesc($contact->name), - dbesc($contact->screen_name), - dbesc($avatar)); - else - q("UPDATE unique_contacts SET name = '%s', nick = '%s', avatar = '%s' WHERE url = '%s'", - dbesc($contact->name), - dbesc($contact->screen_name), - dbesc($avatar), - dbesc(normalise_link("https://twitter.com/".$contact->screen_name))); - - if (DB_UPDATE_VERSION >= "1177") - q("UPDATE `unique_contacts` SET `location` = '%s', `about` = '%s' WHERE url = '%s'", - dbesc($contact->location), - dbesc($contact->description), - dbesc(normalise_link("https://twitter.com/".$contact->screen_name))); - } + update_gcontact(array("url" => "https://twitter.com/".$contact->screen_name, + "network" => NETWORK_TWITTER, "photo" => $avatar, "hide" => true, + "name" => $contact->name, "nick" => $contact->screen_name, + "location" => $contact->location, "about" => $contact->description, + "addr" => $contact->screen_name."@twitter.com", "generation" => 2)); $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1", intval($uid), dbesc("twitter::".$contact->id_str)); @@ -979,10 +954,10 @@ function twitter_fetch_contact($uid, $contact, $create_user) { if(!count($r)) { // create contact record - q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`, + q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`, `name`, `nick`, `photo`, `network`, `rel`, `priority`, - `writable`, `blocked`, `readonly`, `pending` ) - VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0) ", + `location`, `about`, `writable`, `blocked`, `readonly`, `pending`) + VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, 0, 0, 0)", intval($uid), dbesc(datetime_convert()), dbesc("https://twitter.com/".$contact->screen_name), @@ -997,6 +972,8 @@ function twitter_fetch_contact($uid, $contact, $create_user) { dbesc(NETWORK_TWITTER), intval(CONTACT_IS_FRIEND), intval(1), + dbesc($contact->location), + dbesc($contact->description), intval(1) ); @@ -1021,33 +998,25 @@ function twitter_fetch_contact($uid, $contact, $create_user) { require_once("Photo.php"); - $photos = import_profile_photo($avatar,$uid,$contact_id); - - q("UPDATE `contact` SET `photo` = '%s', - `thumb` = '%s', - `micro` = '%s', - `name-date` = '%s', - `uri-date` = '%s', - `avatar-date` = '%s' - WHERE `id` = %d", - dbesc($photos[0]), - dbesc($photos[1]), - dbesc($photos[2]), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval($contact_id) - ); + $photos = import_profile_photo($avatar, $uid, $contact_id, true); - if (DB_UPDATE_VERSION >= "1177") - q("UPDATE `contact` SET `location` = '%s', - `about` = '%s' + if ($photos) { + q("UPDATE `contact` SET `photo` = '%s', + `thumb` = '%s', + `micro` = '%s', + `name-date` = '%s', + `uri-date` = '%s', + `avatar-date` = '%s' WHERE `id` = %d", - dbesc($contact->location), - dbesc($contact->description), + dbesc($photos[0]), + dbesc($photos[1]), + dbesc($photos[2]), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + dbesc(datetime_convert()), intval($contact_id) ); - + } } else { // update profile photos once every two weeks as we have no notification of when they change. @@ -1062,42 +1031,39 @@ function twitter_fetch_contact($uid, $contact, $create_user) { require_once("Photo.php"); - $photos = import_profile_photo($avatar, $uid, $r[0]['id']); - - q("UPDATE `contact` SET `photo` = '%s', - `thumb` = '%s', - `micro` = '%s', - `name-date` = '%s', - `uri-date` = '%s', - `avatar-date` = '%s', - `url` = '%s', - `nurl` = '%s', - `addr` = '%s', - `name` = '%s', - `nick` = '%s' - WHERE `id` = %d", - dbesc($photos[0]), - dbesc($photos[1]), - dbesc($photos[2]), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc("https://twitter.com/".$contact->screen_name), - dbesc(normalise_link("https://twitter.com/".$contact->screen_name)), - dbesc($contact->screen_name."@twitter.com"), - dbesc($contact->name), - dbesc($contact->screen_name), - intval($r[0]['id']) - ); - - if (DB_UPDATE_VERSION >= "1177") - q("UPDATE `contact` SET `location` = '%s', + $photos = import_profile_photo($avatar, $uid, $r[0]['id'], true); + + if ($photos) { + q("UPDATE `contact` SET `photo` = '%s', + `thumb` = '%s', + `micro` = '%s', + `name-date` = '%s', + `uri-date` = '%s', + `avatar-date` = '%s', + `url` = '%s', + `nurl` = '%s', + `addr` = '%s', + `name` = '%s', + `nick` = '%s', + `location` = '%s', `about` = '%s' WHERE `id` = %d", + dbesc($photos[0]), + dbesc($photos[1]), + dbesc($photos[2]), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + dbesc("https://twitter.com/".$contact->screen_name), + dbesc(normalise_link("https://twitter.com/".$contact->screen_name)), + dbesc($contact->screen_name."@twitter.com"), + dbesc($contact->name), + dbesc($contact->screen_name), dbesc($contact->location), dbesc($contact->description), intval($r[0]['id']) ); + } } } diff --git a/twitter/twitter_sync.php b/twitter/twitter_sync.php index 434cb204..6c76af7c 100644 --- a/twitter/twitter_sync.php +++ b/twitter/twitter_sync.php @@ -49,19 +49,21 @@ function twitter_sync_run($argv, $argc){ $mode = intval($argv[1]); $uid = intval($argv[2]); - /// @todo Replace it with "App::is_already_running" in the next release - $lockpath = get_lockpath(); - if ($lockpath != '') { - $pidfile = new pidfile($lockpath, 'twitter_sync-'.$mode.'-'.$uid); - if ($pidfile->is_already_running()) { - logger("Already running"); - if ($pidfile->running_time() > 9*60) { - $pidfile->kill(); - logger("killed stale process"); - // Calling a new instance - proc_run('php','addon/twitter/twitter_sync.php', $mode, $uid); + // This is deprecated with the worker + if (function_exists("get_lockpath")) { + $lockpath = get_lockpath(); + if ($lockpath != '') { + $pidfile = new pidfile($lockpath, 'twitter_sync-'.$mode.'-'.$uid); + if ($pidfile->is_already_running()) { + logger("Already running"); + if ($pidfile->running_time() > 9*60) { + $pidfile->kill(); + logger("killed stale process"); + // Calling a new instance + proc_run('php','addon/twitter/twitter_sync.php', $mode, $uid); + } + exit; } - exit; } } -- 2.39.2