<?php
-require_once('include/Probe.php');
+use Friendica\App;
+use Friendica\Network\Probe;
// Included here for completeness, but this is a very dangerous operation.
// It is the caller's responsibility to confirm the requestor's intent and
$r[0]['nickname']
);
- /// @todo Should be done in a background job since this likely will run into a time out
- // don't delete yet, will be done later when contacts have deleted my stuff
- // q("DELETE FROM `contact` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `gcign` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `group` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `group_member` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `intro` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `event` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `item` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `item_id` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `mail` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `mailacct` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `manage` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `notify` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `photo` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `attach` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `profile` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `profile_check` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `pconfig` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `search` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `spam` WHERE `uid` = %d", intval($uid));
- // don't delete yet, will be done later when contacts have deleted my stuff
- // q("DELETE FROM `user` WHERE `uid` = %d", intval($uid));
+ // The user and related data will be deleted in "cron_expire_and_remove_users" (cronjobs.php)
q("UPDATE `user` SET `account_removed` = 1, `account_expires_on` = UTC_TIMESTAMP() WHERE `uid` = %d", intval($uid));
proc_run(PRIORITY_HIGH, "include/notifier.php", "removeme", $uid);
/// @TODO Get rid of this, include/datetime.php should care about it by itself
$a = get_app();
- require_once('include/datetime.php');
+ require_once 'include/datetime.php';
if ($contact['network'] === NETWORK_OSTATUS) {
- require_once('include/ostatus.php');
+ require_once 'include/ostatus.php';
// create an unfollow slap
$item = array();
$slap = ostatus::salmon($item, $user);
if ((x($contact,'notify')) && (strlen($contact['notify']))) {
- require_once('include/salmon.php');
+ require_once 'include/salmon.php';
slapper($user,$contact['notify'],$slap);
}
} elseif ($contact['network'] === NETWORK_DIASPORA) {
- require_once('include/diaspora.php');
+ require_once 'include/diaspora.php';
Diaspora::send_unshare($user,$contact);
} elseif ($contact['network'] === NETWORK_DFRN) {
- require_once('include/dfrn.php');
+ require_once 'include/dfrn.php';
dfrn::deliver($user,$contact,'placeholder', 1);
}
if($contact['archive'])
return;
- if($contact['term-date'] == '0000-00-00 00:00:00') {
+ if ($contact['term-date'] <= NULL_DATE) {
q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d",
dbesc(datetime_convert()),
intval($contact['id'])
// It's a miracle. Our dead contact has inexplicably come back to life.
q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d",
- dbesc('0000-00-00 00:00:00'),
+ dbesc(NULL_DATE),
intval($contact['id'])
);
if ($contact['url'] != '') {
q("UPDATE `contact` SET `term-date` = '%s' WHERE `nurl` = '%s'",
- dbesc('0000-00-00 00:00:00'),
+ dbesc(NULL_DATE),
dbesc(normalise_link($contact['url']))
);
}
function get_contact_details_by_url($url, $uid = -1, $default = array()) {
static $cache = array();
+ if ($url == '') {
+ return $default;
+ }
+
if ($uid == -1) {
$uid = local_user();
}
// "bd" always contains the upcoming birthday of a contact.
// "birthday" might contain the birthday including the year of birth.
- if ($profile["birthday"] != "0000-00-00") {
+ if ($profile["birthday"] > '0001-01-01') {
$bd_timestamp = strtotime($profile["birthday"]);
$month = date("m", $bd_timestamp);
$day = date("d", $bd_timestamp);
$profile["bd"] = (++$current_year)."-".$month."-".$day;
}
} else {
- $profile["bd"] = "0000-00-00";
+ $profile["bd"] = '0001-01-01';
}
} else {
$profile = $default;
$profile["location"] = "";
$profile["about"] = "";
$profile["gender"] = "";
- $profile["birthday"] = "0000-00-00";
+ $profile["birthday"] = '0001-01-01';
}
$cache[$url][$uid] = $profile;
function get_contact_details_by_addr($addr, $uid = -1) {
static $cache = array();
+ if ($addr == '') {
+ return array();
+ }
+
if ($uid == -1) {
$uid = local_user();
}
* @return integer Contact ID
*/
function get_contact($url, $uid = 0, $no_update = false) {
- require_once "include/Scrape.php";
-
logger("Get contact data for url ".$url." and user ".$uid." - ".App::callstack(), LOGGER_DEBUG);;
$data = array();
$contact_id = 0;
- // Catch-all query, may return multiple rows
+ if ($url == '') {
+ return 0;
+ }
+
+ // We first try the nurl (http://server.tld/nick), most common case
$contacts = q("SELECT `id`, `avatar-date` FROM `contact`
- WHERE ('%s' IN (`url`, `addr`, `alias`) OR '%s' IN (`nurl`, `alias`))
- AND `uid` = %d",
- dbesc($url),
- dbesc(normalise_link($url)),
- intval($uid));
+ WHERE `nurl` = '%s'
+ AND `uid` = %d",
+ dbesc(normalise_link($url)),
+ intval($uid));
+
+
+ // Then the addr (nick@server.tld)
+ if (! dbm::is_result($contacts)) {
+ $contacts = q("SELECT `id`, `avatar-date` FROM `contact`
+ WHERE `addr` = '%s'
+ AND `uid` = %d",
+ dbesc($url),
+ intval($uid));
+ }
+
+ // Then the alias (which could be anything)
+ if (! dbm::is_result($contacts)) {
+ $contacts = q("SELECT `id`, `avatar-date` FROM `contact`
+ WHERE `alias` IN ('%s', '%s')
+ AND `uid` = %d",
+ dbesc($url),
+ dbesc(normalise_link($url)),
+ intval($uid));
+ }
if (dbm::is_result($contacts)) {
$contact_id = $contacts[0]["id"];
return $contact_id;
}
} elseif ($uid != 0) {
+ // Non-existing user-specific contact, exiting
return 0;
}
- $data = probe_url($url);
- if (!$data['url']) {
- return 0;
- }
-
- $url = $data["url"];
+ $data = Probe::uri($url);
- // Does this address belongs to a valid network?
- if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) {
+ // Last try in gcontact for unsupported networks
+ if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_PUMPIO))) {
if ($uid != 0) {
return 0;
}
$data = $gcontacts[0];
}
+ $url = $data["url"];
if (!$contact_id) {
q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
*/
function posts_from_gcontact(App $a, $gcontact_id) {
- require_once('include/conversation.php');
+ require_once 'include/conversation.php';
// There are no posts with "uid = 0" with connector networks
// This speeds up the query a lot
else
$sql = "`item`.`uid` = %d";
- if(get_config('system', 'old_pager')) {
- $r = q("SELECT COUNT(*) AS `total` FROM `item`
- WHERE `gcontact-id` = %d and $sql",
- intval($gcontact_id),
- intval(local_user()));
-
- $a->set_pager_total($r[0]['total']);
- }
-
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
`author-name` AS `name`, `owner-avatar` AS `photo`,
`owner-link` AS `url`, `owner-avatar` AS `thumb`
intval($a->pager['itemspage'])
);
- $o = conversation($a,$r,'community',false);
+ $o = conversation($a, $r, 'community', false);
- if(!get_config('system', 'old_pager')) {
- $o .= alt_pager($a,count($r));
- } else {
- $o .= paginate($a);
- }
+ $o .= alt_pager($a, count($r));
return $o;
}
*/
function posts_from_contact_url(App $a, $contact_url) {
- require_once('include/conversation.php');
+ require_once 'include/conversation.php';
// There are no posts with "uid = 0" with connector networks
// This speeds up the query a lot
$author_id = intval($r[0]["author-id"]);
- if (get_config('system', 'old_pager')) {
- $r = q("SELECT COUNT(*) AS `total` FROM `item`
- WHERE `author-id` = %d and $sql",
- intval($author_id),
- intval(local_user()));
-
- $a->set_pager_total($r[0]['total']);
- }
-
$r = q(item_query()." AND `item`.`author-id` = %d AND ".$sql.
" ORDER BY `item`.`created` DESC LIMIT %d, %d",
intval($author_id),
intval($a->pager['itemspage'])
);
- $o = conversation($a,$r,'community',false);
+ $o = conversation($a, $r, 'community', false);
- if (!get_config('system', 'old_pager')) {
- $o .= alt_pager($a,count($r));
- } else {
- $o .= paginate($a);
- }
+ $o .= alt_pager($a, count($r));
return $o;
}
return $account_type;
}
-?>