more DB cleanup

This commit is contained in:
friendica 2012-08-30 18:47:07 -07:00
parent 08508c4216
commit 80bd128425
29 changed files with 183 additions and 277 deletions

View File

@ -642,7 +642,7 @@ if(! class_exists('App')) {
if($this->cached_profile_picdate[$common_filename]){ if($this->cached_profile_picdate[$common_filename]){
$this->cached_profile_image[$avatar_image] = $avatar_image . $this->cached_profile_picdate[$common_filename]; $this->cached_profile_image[$avatar_image] = $avatar_image . $this->cached_profile_picdate[$common_filename];
} else { } else {
$r = q("SELECT `contact`.`avatar-date` AS picdate FROM `contact` WHERE `contact`.`thumb` like \"%%/%s\"", $r = q("SELECT `contact`.`avatar_date` AS picdate FROM `contact` WHERE `contact`.`thumb` like \"%%/%s\"",
$common_filename); $common_filename);
if(! count($r)){ if(! count($r)){
$this->cached_profile_image[$avatar_image] = $avatar_image; $this->cached_profile_image[$avatar_image] = $avatar_image;
@ -1063,17 +1063,17 @@ if(! function_exists('get_max_import_size')) {
if(! function_exists('profile_load')) { if(! function_exists('profile_load')) {
function profile_load(&$a, $nickname, $profile = 0) { function profile_load(&$a, $nickname, $profile = 0) {
if(remote_user()) { if(remote_user()) {
$r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1", $r = q("SELECT `profile_id` FROM `contact` WHERE `id` = %d LIMIT 1",
intval($_SESSION['visitor_id'])); intval($_SESSION['visitor_id']));
if(count($r)) if(count($r))
$profile = $r[0]['profile-id']; $profile = $r[0]['profile_id'];
} }
$r = null; $r = null;
if($profile) { if($profile) {
$profile_int = intval($profile); $profile_int = intval($profile);
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, entity.* FROM `profile` $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar_date` AS picdate, entity.* FROM `profile`
left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN entity ON `profile`.`uid` = entity.entity_id left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN entity ON `profile`.`uid` = entity.entity_id
WHERE entity.entity_address = '%s' AND `profile`.`id` = %d and `contact`.`self` = 1 LIMIT 1", WHERE entity.entity_address = '%s' AND `profile`.`id` = %d and `contact`.`self` = 1 LIMIT 1",
dbesc($nickname), dbesc($nickname),
@ -1081,7 +1081,7 @@ function profile_load(&$a, $nickname, $profile = 0) {
); );
} }
if((! $r) && (! count($r))) { if((! $r) && (! count($r))) {
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `entity`.* FROM `profile` $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar_date` AS picdate, `entity`.* FROM `profile`
left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN `entity` ON `profile`.`uid` = entity.entity_id left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN `entity` ON `profile`.`uid` = entity.entity_id
WHERE entity.entity_address = '%s' AND `profile`.`is_default` = 1 and `contact`.`self` = 1 LIMIT 1", WHERE entity.entity_address = '%s' AND `profile`.`is_default` = 1 and `contact`.`self` = 1 LIMIT 1",
dbesc($nickname) dbesc($nickname)

View File

@ -115,6 +115,7 @@ CREATE TABLE IF NOT EXISTS `config` (
CREATE TABLE IF NOT EXISTS `contact` ( CREATE TABLE IF NOT EXISTS `contact` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`aid` int(10) unsigned NOT NULL DEFAULT '0',
`uid` int(11) NOT NULL COMMENT 'owner uid', `uid` int(11) NOT NULL COMMENT 'owner uid',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`my_perms` int(10) unsigned NOT NULL DEFAULT '0', `my_perms` int(10) unsigned NOT NULL DEFAULT '0',
@ -130,9 +131,9 @@ CREATE TABLE IF NOT EXISTS `contact` (
`photo` text NOT NULL COMMENT 'remote photo URL initially until approved', `photo` text NOT NULL COMMENT 'remote photo URL initially until approved',
`thumb` text NOT NULL, `thumb` text NOT NULL,
`micro` text NOT NULL, `micro` text NOT NULL,
`site-pubkey` text NOT NULL, `site_pubkey` text NOT NULL,
`issued-id` char(255) NOT NULL, `issued_id` char(255) NOT NULL,
`dfrn-id` char(255) NOT NULL, `dfrn_id` char(255) NOT NULL,
`url` char(255) NOT NULL, `url` char(255) NOT NULL,
`nurl` char(255) NOT NULL, `nurl` char(255) NOT NULL,
`addr` char(255) NOT NULL, `addr` char(255) NOT NULL,
@ -146,16 +147,12 @@ CREATE TABLE IF NOT EXISTS `contact` (
`confirm` text NOT NULL, `confirm` text NOT NULL,
`poco` text NOT NULL, `poco` text NOT NULL,
`aes_allow` tinyint(1) NOT NULL DEFAULT '0', `aes_allow` tinyint(1) NOT NULL DEFAULT '0',
`ret-aes` tinyint(1) NOT NULL DEFAULT '0', `last_update` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`usehub` tinyint(1) NOT NULL DEFAULT '0',
`subhub` tinyint(1) NOT NULL DEFAULT '0',
`hub-verify` char(255) NOT NULL,
`last-update` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`success_update` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `success_update` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`name-date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `name_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`uri-date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `uri_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`avatar-date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `avatar_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`term-date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `term_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`priority` tinyint(3) NOT NULL, `priority` tinyint(3) NOT NULL,
`blocked` tinyint(1) NOT NULL DEFAULT '1', `blocked` tinyint(1) NOT NULL DEFAULT '1',
`readonly` tinyint(1) NOT NULL DEFAULT '0', `readonly` tinyint(1) NOT NULL DEFAULT '0',
@ -169,14 +166,12 @@ CREATE TABLE IF NOT EXISTS `contact` (
`reason` text NOT NULL COMMENT 'why a rating was given - will help friends decide to make friends or not', `reason` text NOT NULL COMMENT 'why a rating was given - will help friends decide to make friends or not',
`closeness` tinyint(2) NOT NULL DEFAULT '99', `closeness` tinyint(2) NOT NULL DEFAULT '99',
`info` mediumtext NOT NULL, `info` mediumtext NOT NULL,
`profile-id` int(11) NOT NULL DEFAULT '0' COMMENT 'which profile to display - 0 is public default', `profile_id` int(11) NOT NULL DEFAULT '0' COMMENT 'which profile to display - 0 is public default',
`bdyear` char(4) NOT NULL COMMENT 'birthday notify flag', `bdyear` char(4) NOT NULL COMMENT 'birthday notify flag',
`bd` date NOT NULL, `bd` date NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `uid` (`uid`), KEY `uid` (`uid`),
KEY `self` (`self`), KEY `self` (`self`),
KEY `issued-id` (`issued-id`),
KEY `dfrn-id` (`dfrn-id`),
KEY `blocked` (`blocked`), KEY `blocked` (`blocked`),
KEY `readonly` (`readonly`), KEY `readonly` (`readonly`),
KEY `network` (`network`), KEY `network` (`network`),
@ -193,7 +188,8 @@ CREATE TABLE IF NOT EXISTS `contact` (
KEY `forum` (`forum`), KEY `forum` (`forum`),
KEY `notify` (`notify`), KEY `notify` (`notify`),
KEY `my_perms` (`my_perms`), KEY `my_perms` (`my_perms`),
KEY `their_perms` (`their_perms`) KEY `their_perms` (`their_perms`),
KEY `aid` (`aid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `conv` ( CREATE TABLE IF NOT EXISTS `conv` (

View File

@ -139,8 +139,8 @@ function mark_for_death($contact) {
if($contact['archive']) if($contact['archive'])
return; return;
if($contact['term-date'] == '0000-00-00 00:00:00') { if($contact['term_date'] == '0000-00-00 00:00:00') {
q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d LIMIT 1", q("UPDATE `contact` SET `term_date` = '%s' WHERE `id` = %d LIMIT 1",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($contact['id']) intval($contact['id'])
); );
@ -151,7 +151,7 @@ function mark_for_death($contact) {
// so they won't be surprised when the contact vanishes and can take // so they won't be surprised when the contact vanishes and can take
// remedial action if this was a serious mistake or glitch // remedial action if this was a serious mistake or glitch
$expiry = $contact['term-date'] . ' + 32 days '; $expiry = $contact['term_date'] . ' + 32 days ';
if(datetime_convert() > datetime_convert('UTC','UTC',$expiry)) { if(datetime_convert() > datetime_convert('UTC','UTC',$expiry)) {
// relationship is really truly dead. // relationship is really truly dead.
@ -172,7 +172,7 @@ function mark_for_death($contact) {
if(! function_exists('unmark_for_death')) { if(! function_exists('unmark_for_death')) {
function unmark_for_death($contact) { function unmark_for_death($contact) {
// It's a miracle. Our dead contact has inexplicably come back to life. // It's a miracle. Our dead contact has inexplicably come back to life.
q("UPDATE `contact` SET `term-date` = '%s' WHERE `id` = %d LIMIT 1", q("UPDATE `contact` SET `term_date` = '%s' WHERE `id` = %d LIMIT 1",
dbesc('0000-00-00 00:00:00'), dbesc('0000-00-00 00:00:00'),
intval($contact['id']) intval($contact['id'])
); );

View File

@ -326,7 +326,7 @@
'contact_url' => $a->get_baseurl()."/contacts/".$uinfo[0]['cid'], 'contact_url' => $a->get_baseurl()."/contacts/".$uinfo[0]['cid'],
'protected' => false, 'protected' => false,
'friends_count' => intval($countfriends), 'friends_count' => intval($countfriends),
'created_at' => api_date($uinfo[0]['name-date']), 'created_at' => api_date($uinfo[0]['name_date']),
'utc_offset' => "+00:00", 'utc_offset' => "+00:00",
'time_zone' => 'UTC', //$uinfo[0]['timezone'], 'time_zone' => 'UTC', //$uinfo[0]['timezone'],
'geo_enabled' => false, 'geo_enabled' => false,
@ -738,7 +738,7 @@
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn_id`, `contact`.`self`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item`, `contact` FROM `item`, `contact`
WHERE `item`.`uid` = %d WHERE `item`.`uid` = %d
@ -808,7 +808,7 @@
/*$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, /*$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn_id`, `contact`.`self`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item`, `contact` FROM `item`, `contact`
WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0 WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
@ -887,7 +887,7 @@
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn_id`, `contact`.`self`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item`, `contact` FROM `item`, `contact`
WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0 WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
@ -932,7 +932,7 @@
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`nick` as `reply_author`, $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`nick` as `reply_author`,
`contact`.`name`, `contact`.`photo`, `contact`.`url` as `reply_url`, `contact`.`rel`, `contact`.`name`, `contact`.`photo`, `contact`.`url` as `reply_url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn_id`, `contact`.`self`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item`, `contact` FROM `item`, `contact`
WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0 WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
@ -1034,7 +1034,7 @@
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn_id`, `contact`.`self`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item`, `contact` FROM `item`, `contact`
WHERE `item`.`uid` = %d WHERE `item`.`uid` = %d
@ -1100,7 +1100,7 @@
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn_id`, `contact`.`self`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item`, `contact` FROM `item`, `contact`
WHERE `item`.`uid` = %d WHERE `item`.`uid` = %d
@ -1155,7 +1155,7 @@
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn_id`, `contact`.`self`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item`, `contact` FROM `item`, `contact`
WHERE `item`.`uid` = %d WHERE `item`.`uid` = %d

View File

@ -262,9 +262,9 @@ function delivery_run($argv, $argc){
'$profile_page' => xmlify($owner['url']), '$profile_page' => xmlify($owner['url']),
'$photo' => xmlify($owner['photo']), '$photo' => xmlify($owner['photo']),
'$thumb' => xmlify($owner['thumb']), '$thumb' => xmlify($owner['thumb']),
'$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , ATOM_TIME)) , '$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar_date'] . '+00:00' , ATOM_TIME)) ,
'$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri-date'] . '+00:00' , ATOM_TIME)) , '$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri_date'] . '+00:00' , ATOM_TIME)) ,
'$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name-date'] . '+00:00' , ATOM_TIME)) , '$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name_date'] . '+00:00' , ATOM_TIME)) ,
'$birthday' => $birthday, '$birthday' => $birthday,
'$community' => (($owner['page-flags'] == PAGE_COMMUNITY) ? '<dfrn:community>1</dfrn:community>' : '') '$community' => (($owner['page-flags'] == PAGE_COMMUNITY) ? '<dfrn:community>1</dfrn:community>' : '')
)); ));
@ -300,10 +300,10 @@ function delivery_run($argv, $argc){
if(link_compare($basepath,$a->get_baseurl())) { if(link_compare($basepath,$a->get_baseurl())) {
$nickname = basename($contact['url']); $nickname = basename($contact['url']);
if($contact['issued-id']) if($contact['issued_id'])
$sql_extra = sprintf(" AND `dfrn-id` = '%s' ", dbesc($contact['issued-id'])); $sql_extra = sprintf(" AND `dfrn_id` = '%s' ", dbesc($contact['issued_id']));
else else
$sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($contact['dfrn-id'])); $sql_extra = sprintf(" AND `issued_id` = '%s' ", dbesc($contact['dfrn_id']));
$x = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`, $x = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`,
`contact`.`pubkey` AS `cpubkey`, `contact`.`pubkey` AS `cpubkey`,

View File

@ -95,7 +95,6 @@ function new_contact($uid,$url,$interactive = false) {
$writeable = ((($ret['network'] === NETWORK_OSTATUS) && ($ret['notify'])) ? 1 : 0); $writeable = ((($ret['network'] === NETWORK_OSTATUS) && ($ret['notify'])) ? 1 : 0);
$subhub = (($ret['network'] === NETWORK_OSTATUS) ? true : false);
$hidden = 0; $hidden = 0;
@ -112,9 +111,8 @@ function new_contact($uid,$url,$interactive = false) {
if(count($r)) { if(count($r)) {
// update contact // update contact
if($r[0]['rel'] == CONTACT_IS_FOLLOWER || ($network === NETWORK_DIASPORA && $r[0]['rel'] == CONTACT_IS_SHARING)) { if($r[0]['rel'] == CONTACT_IS_FOLLOWER || ($network === NETWORK_DIASPORA && $r[0]['rel'] == CONTACT_IS_SHARING)) {
q("UPDATE `contact` SET `rel` = %d , `subhub` = %d, `readonly` = 0 WHERE `id` = %d AND `uid` = %d LIMIT 1", q("UPDATE `contact` SET `rel` = %d , `readonly` = 0 WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval(CONTACT_IS_FRIEND), intval(CONTACT_IS_FRIEND),
intval($subhub),
intval($r[0]['id']), intval($r[0]['id']),
intval($uid) intval($uid)
); );
@ -152,8 +150,8 @@ function new_contact($uid,$url,$interactive = false) {
// create contact record // create contact record
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`, $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`,
`writable`, `hidden`, `blocked`, `readonly`, `pending`, `subhub` ) `writable`, `hidden`, `blocked`, `readonly`, `pending` )
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, 0, 0, 0, %d ) ", VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, 0, 0, 0) ",
intval($uid), intval($uid),
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc($ret['url']), dbesc($ret['url']),
@ -172,8 +170,7 @@ function new_contact($uid,$url,$interactive = false) {
intval($new_relation), intval($new_relation),
intval($ret['priority']), intval($ret['priority']),
intval($writeable), intval($writeable),
intval($hidden), intval($hidden)
intval($subhub)
); );
} }
@ -206,9 +203,9 @@ function new_contact($uid,$url,$interactive = false) {
$r = q("UPDATE `contact` SET `photo` = '%s', $r = q("UPDATE `contact` SET `photo` = '%s',
`thumb` = '%s', `thumb` = '%s',
`micro` = '%s', `micro` = '%s',
`name-date` = '%s', `name_date` = '%s',
`uri-date` = '%s', `uri_date` = '%s',
`avatar-date` = '%s' `avatar_date` = '%s'
WHERE `id` = %d LIMIT 1 WHERE `id` = %d LIMIT 1
", ",
dbesc($photos[0]), dbesc($photos[0]),
@ -221,7 +218,7 @@ function new_contact($uid,$url,$interactive = false) {
); );
// pull feed and consume it, which should subscribe to the hub. // pull feed and consume it
proc_run('php',"include/poller.php","$contact_id"); proc_run('php',"include/poller.php","$contact_id");

View File

@ -111,7 +111,7 @@ function create_identity($arr) {
dbesc($a->get_baseurl() . "/photo/avatar/{$newuid}") dbesc($a->get_baseurl() . "/photo/avatar/{$newuid}")
); );
$r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `micro`, `blocked`, `pending`, `url`, `name-date`, `uri-date`, `avatar-date`, `closeness` ) $r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `micro`, `blocked`, `pending`, `url`, `name_date`, `uri_date`, `avatar_date`, `closeness` )
VALUES ( %d, '%s', 1, '%s', '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', 0 ) ", VALUES ( %d, '%s', 1, '%s', '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', 0 ) ",
intval($ret['entity']['entity_id']), intval($ret['entity']['entity_id']),
datetime_convert(), datetime_convert(),

View File

@ -25,7 +25,7 @@ function network_query($a,$arr) {
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`, $items = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn_id`, `contact`.`self`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item`, `contact` FROM `item`, `contact`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 WHERE `item`.`uid` = %d AND `item`.`visible` = 1

View File

@ -52,15 +52,15 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
$sql_extra = ''; $sql_extra = '';
switch($direction) { switch($direction) {
case (-1): case (-1):
$sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($dfrn_id)); $sql_extra = sprintf(" AND `issued_id` = '%s' ", dbesc($dfrn_id));
$my_id = $dfrn_id; $my_id = $dfrn_id;
break; break;
case 0: case 0:
$sql_extra = sprintf(" AND `issued-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id)); $sql_extra = sprintf(" AND `issued_id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
$my_id = '1:' . $dfrn_id; $my_id = '1:' . $dfrn_id;
break; break;
case 1: case 1:
$sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id)); $sql_extra = sprintf(" AND `dfrn_id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
$my_id = '0:' . $dfrn_id; $my_id = '0:' . $dfrn_id;
break; break;
default: default:
@ -120,8 +120,8 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`network`, `contact`.`photo`, `contact`.`url`, `contact`.`name`, `contact`.`network`, `contact`.`photo`, `contact`.`url`,
`contact`.`name-date`, `contact`.`uri-date`, `contact`.`avatar-date`, `contact`.`name_date`, `contact`.`uri_date`, `contact`.`avatar_date`,
`contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`thumb`, `contact`.`dfrn_id`, `contact`.`self`,
`contact`.`id` AS `contact-id`, `contact`.`uid` AS `contact-uid`, `contact`.`id` AS `contact-id`, `contact`.`uid` AS `contact-uid`,
`sign`.`signed_text`, `sign`.`signature`, `sign`.`signer` `sign`.`signed_text`, `sign`.`signature`, `sign`.`signer`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
@ -162,9 +162,9 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
'$profile_page' => xmlify($owner['url']), '$profile_page' => xmlify($owner['url']),
'$photo' => xmlify($owner['photo']), '$photo' => xmlify($owner['photo']),
'$thumb' => xmlify($owner['thumb']), '$thumb' => xmlify($owner['thumb']),
'$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , ATOM_TIME)) , '$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar_date'] . '+00:00' , ATOM_TIME)) ,
'$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri-date'] . '+00:00' , ATOM_TIME)) , '$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri_date'] . '+00:00' , ATOM_TIME)) ,
'$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name-date'] . '+00:00' , ATOM_TIME)) , '$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name_date'] . '+00:00' , ATOM_TIME)) ,
'$birthday' => ((strlen($birthday)) ? '<dfrn:birthday>' . xmlify($birthday) . '</dfrn:birthday>' : ''), '$birthday' => ((strlen($birthday)) ? '<dfrn:birthday>' . xmlify($birthday) . '</dfrn:birthday>' : ''),
'$community' => (($owner['page-flags'] == PAGE_COMMUNITY) ? '<dfrn:community>1</dfrn:community>' : '') '$community' => (($owner['page-flags'] == PAGE_COMMUNITY) ? '<dfrn:community>1</dfrn:community>' : '')
)); ));
@ -1301,11 +1301,11 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
$a = get_app(); $a = get_app();
$idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']); $idtosend = $orig_id = (($contact['dfrn_id']) ? $contact['dfrn_id'] : $contact['issued_id']);
if($contact['duplex'] && $contact['dfrn-id']) if($contact['duplex'] && $contact['dfrn_id'])
$idtosend = '0:' . $orig_id; $idtosend = '0:' . $orig_id;
if($contact['duplex'] && $contact['issued-id']) if($contact['duplex'] && $contact['issued_id'])
$idtosend = '1:' . $orig_id; $idtosend = '1:' . $orig_id;
$rino = ((function_exists('mcrypt_encrypt')) ? 1 : 0); $rino = ((function_exists('mcrypt_encrypt')) ? 1 : 0);
@ -1474,7 +1474,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
return 3; return 3;
} }
if($contact['term-date'] != '0000-00-00 00:00:00') { if($contact['term_date'] != '0000-00-00 00:00:00') {
logger("dfrn_deliver: $url back from the dead - removing mark for death"); logger("dfrn_deliver: $url back from the dead - removing mark for death");
require_once('include/Contact.php'); require_once('include/Contact.php');
unmark_for_death($contact); unmark_for_death($contact);
@ -1568,7 +1568,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
} }
} }
if((is_array($contact)) && ($photo_timestamp) && (strlen($photo_url)) && ($photo_timestamp > $contact['avatar-date'])) { if((is_array($contact)) && ($photo_timestamp) && (strlen($photo_url)) && ($photo_timestamp > $contact['avatar_date'])) {
logger('consume_feed: Updating photo for ' . $contact['name']); logger('consume_feed: Updating photo for ' . $contact['name']);
require_once("Photo.php"); require_once("Photo.php");
$photo_failure = false; $photo_failure = false;
@ -1614,7 +1614,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
$a = get_app(); $a = get_app();
q("UPDATE `contact` SET `avatar-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s' q("UPDATE `contact` SET `avatar_date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s'
WHERE `uid` = %d AND `id` = %d LIMIT 1", WHERE `uid` = %d AND `id` = %d LIMIT 1",
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc($a->get_baseurl() . '/photo/' . $hash . '-4.'.$img->getExt()), dbesc($a->get_baseurl() . '/photo/' . $hash . '-4.'.$img->getExt()),
@ -1626,13 +1626,13 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
} }
} }
if((is_array($contact)) && ($name_updated) && (strlen($new_name)) && ($name_updated > $contact['name-date'])) { if((is_array($contact)) && ($name_updated) && (strlen($new_name)) && ($name_updated > $contact['name_date'])) {
$r = q("select * from contact where uid = %d and id = %d limit 1", $r = q("select * from contact where uid = %d and id = %d limit 1",
intval($contact['uid']), intval($contact['uid']),
intval($contact['id']) intval($contact['id'])
); );
$x = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1", $x = q("UPDATE `contact` SET `name` = '%s', `name_date` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
dbesc(notags(trim($new_name))), dbesc(notags(trim($new_name))),
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($contact['uid']), intval($contact['uid']),
@ -2100,7 +2100,7 @@ function local_delivery($importer,$data) {
} }
} }
if(($photo_timestamp) && (strlen($photo_url)) && ($photo_timestamp > $importer['avatar-date'])) { if(($photo_timestamp) && (strlen($photo_url)) && ($photo_timestamp > $importer['avatar_date'])) {
logger('local_delivery: Updating photo for ' . $importer['name']); logger('local_delivery: Updating photo for ' . $importer['name']);
require_once("Photo.php"); require_once("Photo.php");
$photo_failure = false; $photo_failure = false;
@ -2146,7 +2146,7 @@ function local_delivery($importer,$data) {
$a = get_app(); $a = get_app();
q("UPDATE `contact` SET `avatar-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s' q("UPDATE `contact` SET `avatar_date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s'
WHERE `uid` = %d AND `id` = %d LIMIT 1", WHERE `uid` = %d AND `id` = %d LIMIT 1",
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc($a->get_baseurl() . '/photo/' . $hash . '-4.'.$img->getExt()), dbesc($a->get_baseurl() . '/photo/' . $hash . '-4.'.$img->getExt()),
@ -2158,13 +2158,13 @@ function local_delivery($importer,$data) {
} }
} }
if(($name_updated) && (strlen($new_name)) && ($name_updated > $importer['name-date'])) { if(($name_updated) && (strlen($new_name)) && ($name_updated > $importer['name_date'])) {
$r = q("select * from contact where uid = %d and id = %d limit 1", $r = q("select * from contact where uid = %d and id = %d limit 1",
intval($importer['importer_uid']), intval($importer['importer_uid']),
intval($importer['id']) intval($importer['id'])
); );
$x = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1", $x = q("UPDATE `contact` SET `name` = '%s', `name_date` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
dbesc(notags(trim($new_name))), dbesc(notags(trim($new_name))),
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($importer['importer_uid']), intval($importer['importer_uid']),
@ -2199,7 +2199,7 @@ function local_delivery($importer,$data) {
$newloc['confirm'] = notags(unxmlify($base['confirm'][0]['data'])); $newloc['confirm'] = notags(unxmlify($base['confirm'][0]['data']));
$newloc['notify'] = notags(unxmlify($base['notify'][0]['data'])); $newloc['notify'] = notags(unxmlify($base['notify'][0]['data']));
$newloc['poll'] = notags(unxmlify($base['poll'][0]['data'])); $newloc['poll'] = notags(unxmlify($base['poll'][0]['data']));
$newloc['site-pubkey'] = notags(unxmlify($base['site-pubkey'][0]['data'])); $newloc['site_pubkey'] = notags(unxmlify($base['site_pubkey'][0]['data']));
$newloc['pubkey'] = notags(unxmlify($base['pubkey'][0]['data'])); $newloc['pubkey'] = notags(unxmlify($base['pubkey'][0]['data']));
$newloc['prvkey'] = notags(unxmlify($base['prvkey'][0]['data'])); $newloc['prvkey'] = notags(unxmlify($base['prvkey'][0]['data']));
@ -3168,45 +3168,6 @@ function lose_sharer($importer,$contact,$datarray,$item) {
} }
function subscribe_to_hub($url,$importer,$contact,$hubmode = 'subscribe') {
$a = get_app();
if(is_array($importer)) {
$r = q("SELECT `nickname` FROM `user` WHERE `uid` = %d LIMIT 1",
intval($importer['uid'])
);
}
if(! count($r))
return;
$push_url = get_config('system','url') . '/pubsub/' . $r[0]['nickname'] . '/' . $contact['id'];
// Use a single verify token, even if multiple hubs
$verify_token = ((strlen($contact['hub-verify'])) ? $contact['hub-verify'] : random_string());
$params= 'hub.mode=' . $hubmode . '&hub.callback=' . urlencode($push_url) . '&hub.topic=' . urlencode($contact['poll']) . '&hub.verify=async&hub.verify_token=' . $verify_token;
logger('subscribe_to_hub: ' . $hubmode . ' ' . $contact['name'] . ' to hub ' . $url . ' endpoint: ' . $push_url . ' with verifier ' . $verify_token);
if(! strlen($contact['hub-verify'])) {
$r = q("UPDATE `contact` SET `hub-verify` = '%s' WHERE `id` = %d LIMIT 1",
dbesc($verify_token),
intval($contact['id'])
);
}
post_url($url,$params);
logger('subscribe_to_hub: returns: ' . $a->get_curl_code(), LOGGER_DEBUG);
return;
}
function atom_author($tag,$name,$uri,$h,$w,$photo) { function atom_author($tag,$name,$uri,$h,$w,$photo) {
$o = ''; $o = '';
if(! $tag) if(! $tag)

View File

@ -344,9 +344,9 @@ function notifier_run($argv, $argc){
'$profile_page' => xmlify($owner['url']), '$profile_page' => xmlify($owner['url']),
'$photo' => xmlify($owner['photo']), '$photo' => xmlify($owner['photo']),
'$thumb' => xmlify($owner['thumb']), '$thumb' => xmlify($owner['thumb']),
'$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , ATOM_TIME)) , '$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar_date'] . '+00:00' , ATOM_TIME)) ,
'$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri-date'] . '+00:00' , ATOM_TIME)) , '$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri_date'] . '+00:00' , ATOM_TIME)) ,
'$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name-date'] . '+00:00' , ATOM_TIME)) , '$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name_date'] . '+00:00' , ATOM_TIME)) ,
'$birthday' => $birthday, '$birthday' => $birthday,
'$community' => (($owner['page-flags'] == PAGE_COMMUNITY) ? '<dfrn:community>1</dfrn:community>' : '') '$community' => (($owner['page-flags'] == PAGE_COMMUNITY) ? '<dfrn:community>1</dfrn:community>' : '')
@ -520,10 +520,10 @@ function notifier_run($argv, $argc){
if(link_compare($basepath,$a->get_baseurl())) { if(link_compare($basepath,$a->get_baseurl())) {
$nickname = basename($contact['url']); $nickname = basename($contact['url']);
if($contact['issued-id']) if($contact['issued_id'])
$sql_extra = sprintf(" AND `dfrn-id` = '%s' ", dbesc($contact['issued-id'])); $sql_extra = sprintf(" AND `dfrn_id` = '%s' ", dbesc($contact['issued_id']));
else else
$sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($contact['dfrn-id'])); $sql_extra = sprintf(" AND `issued_id` = '%s' ", dbesc($contact['dfrn_id']));
$x = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`, $x = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`,
`contact`.`pubkey` AS `cpubkey`, `contact`.`pubkey` AS `cpubkey`,

View File

@ -38,7 +38,7 @@ function onepoll_run($argv, $argc){
$manual_id = 0; $manual_id = 0;
$generation = 0; $generation = 0;
$hub_update = false;
$force = false; $force = false;
$restart = false; $restart = false;
@ -73,18 +73,7 @@ function onepoll_run($argv, $argc){
$xml = false; $xml = false;
$t = $contact['last-update']; $t = $contact['last_update'];
if($contact['subhub']) {
$poll_interval = get_config('system','pushpoll_frequency');
$contact['priority'] = (($poll_interval !== false) ? intval($poll_interval) : 3);
$hub_update = false;
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day"))
$hub_update = true;
}
else
$hub_update = false;
$importer_uid = $contact['uid']; $importer_uid = $contact['uid'];
@ -99,17 +88,17 @@ function onepoll_run($argv, $argc){
logger("onepoll: poll: ({$contact['id']}) IMPORTER: {$importer['name']}, CONTACT: {$contact['name']}"); logger("onepoll: poll: ({$contact['id']}) IMPORTER: {$importer['name']}, CONTACT: {$contact['name']}");
$last_update = (($contact['last-update'] === '0000-00-00 00:00:00') $last_update = (($contact['last_update'] === '0000-00-00 00:00:00')
? datetime_convert('UTC','UTC','now - 7 days', ATOM_TIME) ? datetime_convert('UTC','UTC','now - 7 days', ATOM_TIME)
: datetime_convert('UTC','UTC',$contact['last-update'], ATOM_TIME) : datetime_convert('UTC','UTC',$contact['last_update'], ATOM_TIME)
); );
if($contact['network'] === NETWORK_DFRN) { if($contact['network'] === NETWORK_DFRN) {
$idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']); $idtosend = $orig_id = (($contact['dfrn_id']) ? $contact['dfrn_id'] : $contact['issued_id']);
if(intval($contact['duplex']) && $contact['dfrn-id']) if(intval($contact['duplex']) && $contact['dfrn_id'])
$idtosend = '0:' . $orig_id; $idtosend = '0:' . $orig_id;
if(intval($contact['duplex']) && $contact['issued-id']) if(intval($contact['duplex']) && $contact['issued_id'])
$idtosend = '1:' . $orig_id; $idtosend = '1:' . $orig_id;
// they have permission to write to us. We already filtered this in the contact query. // they have permission to write to us. We already filtered this in the contact query.
@ -135,8 +124,8 @@ function onepoll_run($argv, $argc){
mark_for_death($contact); mark_for_death($contact);
// set the last-update so we don't keep polling // set the last_update so we don't keep polling
$r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1", $r = q("UPDATE `contact` SET `last_update` = '%s' WHERE `id` = %d LIMIT 1",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($contact['id']) intval($contact['id'])
); );
@ -149,7 +138,7 @@ function onepoll_run($argv, $argc){
mark_for_death($contact); mark_for_death($contact);
$r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1", $r = q("UPDATE `contact` SET `last_update` = '%s' WHERE `id` = %d LIMIT 1",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($contact['id']) intval($contact['id'])
); );
@ -163,17 +152,17 @@ function onepoll_run($argv, $argc){
logger("poller: $url replied status 1 - marking for death "); logger("poller: $url replied status 1 - marking for death ");
// we may not be friends anymore. Will keep trying for one month. // we may not be friends anymore. Will keep trying for one month.
// set the last-update so we don't keep polling // set the last_update so we don't keep polling
$r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1", $r = q("UPDATE `contact` SET `last_update` = '%s' WHERE `id` = %d LIMIT 1",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($contact['id']) intval($contact['id'])
); );
mark_for_death($contact); mark_for_death($contact);
} }
else { else {
if($contact['term-date'] != '0000-00-00 00:00:00') { if($contact['term_date'] != '0000-00-00 00:00:00') {
logger("poller: $url back from the dead - removing mark for death"); logger("poller: $url back from the dead - removing mark for death");
unmark_for_death($contact); unmark_for_death($contact);
} }
@ -228,7 +217,7 @@ function onepoll_run($argv, $argc){
logger('poller: received xml : ' . $xml, LOGGER_DATA); logger('poller: received xml : ' . $xml, LOGGER_DATA);
if((! strstr($xml,'<?xml')) && (! strstr($xml,'<rss'))) { if((! strstr($xml,'<?xml')) && (! strstr($xml,'<rss'))) {
logger('poller: post_handshake: response from ' . $url . ' did not contain XML.'); logger('poller: post_handshake: response from ' . $url . ' did not contain XML.');
$r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1", $r = q("UPDATE `contact` SET `last_update` = '%s' WHERE `id` = %d LIMIT 1",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($contact['id']) intval($contact['id'])
); );
@ -243,30 +232,12 @@ function onepoll_run($argv, $argc){
consume_feed($xml,$importer,$contact,$hub,1,2); consume_feed($xml,$importer,$contact,$hub,1,2);
$hubmode = 'subscribe';
if($contact['network'] === NETWORK_DFRN || $contact['blocked'] || $contact['readonly'])
$hubmode = 'unsubscribe';
if($contact['network'] === NETWORK_OSTATUS && (! $contact['hub-verify']))
$hub_update = true;
if((strlen($hub)) && ($hub_update) && ($contact['rel'] != CONTACT_IS_FOLLOWER)) {
logger('poller: hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
$hubs = explode(',', $hub);
if(count($hubs)) {
foreach($hubs as $h) {
$h = trim($h);
if(! strlen($h))
continue;
subscribe_to_hub($h,$importer,$contact,$hubmode);
}
}
}
} }
$updated = datetime_convert(); $updated = datetime_convert();
$r = q("UPDATE `contact` SET `last-update` = '%s', `success_update` = '%s' WHERE `id` = %d LIMIT 1", $r = q("UPDATE `contact` SET `last_update` = '%s', `success_update` = '%s' WHERE `id` = %d LIMIT 1",
dbesc($updated), dbesc($updated),
dbesc($updated), dbesc($updated),
intval($contact['id']) intval($contact['id'])

View File

@ -107,7 +107,7 @@ function poller_run($argv, $argc){
$manual_id = 0; $manual_id = 0;
$generation = 0; $generation = 0;
$hub_update = false;
$force = false; $force = false;
$restart = false; $restart = false;
@ -179,7 +179,7 @@ function poller_run($argv, $argc){
$xml = false; $xml = false;
if($manual_id) if($manual_id)
$contact['last-update'] = '0000-00-00 00:00:00'; $contact['last_update'] = '0000-00-00 00:00:00';
if($contact['network'] === NETWORK_DFRN) if($contact['network'] === NETWORK_DFRN)
$contact['priority'] = 2; $contact['priority'] = 2;
@ -187,29 +187,11 @@ function poller_run($argv, $argc){
if(!get_config('system','ostatus_use_priority') and ($contact['network'] === NETWORK_OSTATUS)) if(!get_config('system','ostatus_use_priority') and ($contact['network'] === NETWORK_OSTATUS))
$contact['priority'] = 2; $contact['priority'] = 2;
if($contact['priority'] || $contact['subhub']) { if($contact['priority']) {
$hub_update = true;
$update = false; $update = false;
$t = $contact['last-update']; $t = $contact['last_update'];
// We should be getting everything via a hub. But just to be sure, let's check once a day.
// (You can make this more or less frequent if desired by setting 'pushpoll_frequency' appropriately)
// This also lets us update our subscription to the hub, and add or replace hubs in case it
// changed. We will only update hubs once a day, regardless of 'pushpoll_frequency'.
if($contact['subhub']) {
$poll_interval = get_config('system','pushpoll_frequency');
$contact['priority'] = (($poll_interval !== false) ? intval($poll_interval) : 3);
$hub_update = false;
if((datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day")) || $force)
$hub_update = true;
}
else
$hub_update = false;
/** /**
* Based on $contact['priority'], should we poll this site now? Or later? * Based on $contact['priority'], should we poll this site now? Or later?

View File

@ -24,7 +24,7 @@ function was_recently_delayed($cid) {
if(count($r)) if(count($r))
return true; return true;
$r = q("select `term-date` from contact where id = %d and `term-date` != '' and `term-date` != '0000-00-00 00:00:00' limit 1", $r = q("select `term_date` from contact where id = %d and `term_date` != '' and `term_date` != '0000-00-00 00:00:00' limit 1",
intval($cid) intval($cid)
); );
if(count($r)) if(count($r))

View File

@ -233,7 +233,7 @@ function create_user($arr) {
return $result; return $result;
} }
$r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `micro`, `blocked`, `pending`, `url`, `nurl`, $r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `micro`, `blocked`, `pending`, `url`, `nurl`,
`request`, `notify`, `poll`, `confirm`, `poco`, `name-date`, `uri-date`, `avatar-date`, `closeness` ) `request`, `notify`, `poll`, `confirm`, `poco`, `name_date`, `uri_date`, `avatar_date`, `closeness` )
VALUES ( %d, '%s', 1, '%s', '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', 0 ) ", VALUES ( %d, '%s', 1, '%s', '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', 0 ) ",
intval($newuid), intval($newuid),
datetime_convert(), datetime_convert(),

View File

@ -111,7 +111,7 @@ function abook_post(&$a) {
$info = fix_mce_lf(escape_tags(trim($_POST['info']))); $info = fix_mce_lf(escape_tags(trim($_POST['info'])));
$r = q("UPDATE `contact` SET `profile-id` = %d, `priority` = %d , `info` = '%s', $r = q("UPDATE `contact` SET `profile_id` = %d, `priority` = %d , `info` = '%s',
`hidden` = %d, closeness = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", `hidden` = %d, closeness = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($profile_id), intval($profile_id),
intval($priority), intval($priority),
@ -314,7 +314,7 @@ function abook_content(&$a) {
'$updpub' => t('Update public posts'), '$updpub' => t('Update public posts'),
'$last_update' => $last_update, '$last_update' => $last_update,
'$udnow' => t('Update now'), '$udnow' => t('Update now'),
'$profile_select' => contact_profile_assign($contact['profile-id'],(($contact['network'] !== NETWORK_DFRN) ? true : false)), '$profile_select' => contact_profile_assign($contact['profile_id'],(($contact['network'] !== NETWORK_DFRN) ? true : false)),
'$contact_id' => $contact['id'], '$contact_id' => $contact['id'],
'$block_text' => (($contact['blocked']) ? t('Unblock') : t('Block') ), '$block_text' => (($contact['blocked']) ? t('Unblock') : t('Block') ),
'$ignore_text' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ), '$ignore_text' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ),

View File

@ -111,7 +111,7 @@ function contacts_post(&$a) {
$info = fix_mce_lf(escape_tags(trim($_POST['info']))); $info = fix_mce_lf(escape_tags(trim($_POST['info'])));
$r = q("UPDATE `contact` SET `profile-id` = %d, `priority` = %d , `info` = '%s', $r = q("UPDATE `contact` SET `profile_id` = %d, `priority` = %d , `info` = '%s',
`hidden` = %d, closeness = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", `hidden` = %d, closeness = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($profile_id), intval($profile_id),
intval($priority), intval($priority),
@ -288,12 +288,12 @@ function contacts_content(&$a) {
$insecure = t('Private communications are not available for this contact.'); $insecure = t('Private communications are not available for this contact.');
$last_update = (($contact['last-update'] == '0000-00-00 00:00:00') $last_update = (($contact['last_update'] == '0000-00-00 00:00:00')
? t('Never') ? t('Never')
: datetime_convert('UTC',date_default_timezone_get(),$contact['last-update'],'D, j M Y, g:i A')); : datetime_convert('UTC',date_default_timezone_get(),$contact['last_update'],'D, j M Y, g:i A'));
if($contact['last-update'] !== '0000-00-00 00:00:00') if($contact['last_update'] !== '0000-00-00 00:00:00')
$last_update .= ' ' . (($contact['last-update'] == $contact['success_update']) ? t("\x28Update was successful\x29") : t("\x28Update was not successful\x29")); $last_update .= ' ' . (($contact['last_update'] == $contact['success_update']) ? t("\x28Update was successful\x29") : t("\x28Update was not successful\x29"));
$lblsuggest = (($contact['network'] === NETWORK_DFRN) ? t('Suggest friends') : ''); $lblsuggest = (($contact['network'] === NETWORK_DFRN) ? t('Suggest friends') : '');
@ -340,7 +340,7 @@ function contacts_content(&$a) {
$tab_tpl = get_markup_template('common_tabs.tpl'); $tab_tpl = get_markup_template('common_tabs.tpl');
$tab_str = replace_macros($tab_tpl, array('$tabs' => $tabs)); $tab_str = replace_macros($tab_tpl, array('$tabs' => $tabs));
$lost_contact = (($contact['archive'] && $contact['term-date'] != '0000-00-00 00:00:00' && $contact['term-date'] < datetime_convert('','','now')) ? t('Communications lost with this contact!') : ''); $lost_contact = (($contact['archive'] && $contact['term_date'] != '0000-00-00 00:00:00' && $contact['term_date'] < datetime_convert('','','now')) ? t('Communications lost with this contact!') : '');
$slider_tpl = get_markup_template('contact_slider.tpl'); $slider_tpl = get_markup_template('contact_slider.tpl');
$o .= replace_macros($slider_tpl,array( $o .= replace_macros($slider_tpl,array(
@ -382,7 +382,7 @@ function contacts_content(&$a) {
'$updpub' => t('Update public posts'), '$updpub' => t('Update public posts'),
'$last_update' => $last_update, '$last_update' => $last_update,
'$udnow' => t('Update now'), '$udnow' => t('Update now'),
'$profile_select' => contact_profile_assign($contact['profile-id'],(($contact['network'] !== NETWORK_DFRN) ? true : false)), '$profile_select' => contact_profile_assign($contact['profile_id'],(($contact['network'] !== NETWORK_DFRN) ? true : false)),
'$contact_id' => $contact['id'], '$contact_id' => $contact['id'],
'$block_text' => (($contact['blocked']) ? t('Unblock') : t('Block') ), '$block_text' => (($contact['blocked']) ? t('Unblock') : t('Block') ),
'$ignore_text' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ), '$ignore_text' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ),

View File

@ -83,9 +83,9 @@ function crepair_post(&$a) {
$x = q("UPDATE `contact` SET `photo` = '%s', $x = q("UPDATE `contact` SET `photo` = '%s',
`thumb` = '%s', `thumb` = '%s',
`micro` = '%s', `micro` = '%s',
`name-date` = '%s', `name_date` = '%s',
`uri-date` = '%s', `uri_date` = '%s',
`avatar-date` = '%s' `avatar_date` = '%s'
WHERE `id` = %d LIMIT 1 WHERE `id` = %d LIMIT 1
", ",
dbesc($photos[0]), dbesc($photos[0]),

View File

@ -107,7 +107,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
* *
*/ */
$r = q("SELECT * FROM `contact` WHERE ( ( `issued-id` != '' AND `issued-id` = '%s' ) OR ( `id` = %d AND `id` != 0 ) ) AND `uid` = %d AND `duplex` = 0 LIMIT 1", $r = q("SELECT * FROM `contact` WHERE ( ( `issued_id` != '' AND `issued_id` = '%s' ) OR ( `id` = %d AND `id` != 0 ) ) AND `uid` = %d AND `duplex` = 0 LIMIT 1",
dbesc($dfrn_id), dbesc($dfrn_id),
intval($cid), intval($cid),
intval($uid) intval($uid)
@ -124,11 +124,11 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$contact_id = $contact['id']; $contact_id = $contact['id'];
$relation = $contact['rel']; $relation = $contact['rel'];
$site_pubkey = $contact['site-pubkey']; $site_pubkey = $contact['site_pubkey'];
$dfrn_confirm = $contact['confirm']; $dfrn_confirm = $contact['confirm'];
$aes_allow = $contact['aes_allow']; $aes_allow = $contact['aes_allow'];
$network = ((strlen($contact['issued-id'])) ? NETWORK_DFRN : NETWORK_OSTATUS); $network = ((strlen($contact['issued_id'])) ? NETWORK_DFRN : NETWORK_OSTATUS);
if($contact['network']) if($contact['network'])
$network = $contact['network']; $network = $contact['network'];
@ -256,9 +256,9 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
notice( t('Remote site reported: ') . $message . EOL); notice( t('Remote site reported: ') . $message . EOL);
break; break;
case 1: case 1:
// birthday paradox - generate new dfrn-id and fall through. // birthday paradox - generate new dfrn_id and fall through.
$new_dfrn_id = random_string(); $new_dfrn_id = random_string();
$r = q("UPDATE contact SET `issued-id` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("UPDATE contact SET `issued_id` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
dbesc($new_dfrn_id), dbesc($new_dfrn_id),
intval($contact_id), intval($contact_id),
intval($uid) intval($uid)
@ -324,9 +324,9 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
`thumb` = '%s', `thumb` = '%s',
`micro` = '%s', `micro` = '%s',
`rel` = %d, `rel` = %d,
`name-date` = '%s', `name_date` = '%s',
`uri-date` = '%s', `uri_date` = '%s',
`avatar-date` = '%s', `avatar_date` = '%s',
`blocked` = 0, `blocked` = 0,
`pending` = 0, `pending` = 0,
`duplex` = %d, `duplex` = %d,
@ -377,9 +377,9 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$r = q("UPDATE `contact` SET `photo` = '%s', $r = q("UPDATE `contact` SET `photo` = '%s',
`thumb` = '%s', `thumb` = '%s',
`micro` = '%s', `micro` = '%s',
`name-date` = '%s', `name_date` = '%s',
`uri-date` = '%s', `uri_date` = '%s',
`avatar-date` = '%s', `avatar_date` = '%s',
`notify` = '%s', `notify` = '%s',
`poll` = '%s', `poll` = '%s',
`blocked` = 0, `blocked` = 0,
@ -594,7 +594,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
// Decrypt all this stuff we just received // Decrypt all this stuff we just received
$foreign_pubkey = $ret[0]['site-pubkey']; $foreign_pubkey = $ret[0]['site_pubkey'];
$dfrn_record = $ret[0]['id']; $dfrn_record = $ret[0]['id'];
if(! $foreign_pubkey) { if(! $foreign_pubkey) {
@ -614,16 +614,16 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$dfrn_pubkey = $public_key; $dfrn_pubkey = $public_key;
} }
$r = q("SELECT * FROM `contact` WHERE `dfrn-id` = '%s' LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `dfrn_id` = '%s' LIMIT 1",
dbesc($decrypted_dfrn_id) dbesc($decrypted_dfrn_id)
); );
if(count($r)) { if(count($r)) {
$message = t('The ID provided by your system is a duplicate on our system. It should work if you try again.'); $message = t('The ID provided by your system is a duplicate on our system. It should work if you try again.');
xml_status(1,$message); // Birthday paradox - duplicate dfrn-id xml_status(1,$message); // Birthday paradox - duplicate dfrn_id
// NOTREACHED // NOTREACHED
} }
$r = q("UPDATE `contact` SET `dfrn-id` = '%s', `pubkey` = '%s' WHERE `id` = %d LIMIT 1", $r = q("UPDATE `contact` SET `dfrn_id` = '%s', `pubkey` = '%s' WHERE `id` = %d LIMIT 1",
dbesc($decrypted_dfrn_id), dbesc($decrypted_dfrn_id),
dbesc($dfrn_pubkey), dbesc($dfrn_pubkey),
intval($dfrn_record) intval($dfrn_record)
@ -634,10 +634,10 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
} }
// It's possible that the other person also requested friendship. // It's possible that the other person also requested friendship.
// If it is a duplex relationship, ditch the issued-id if one exists. // If it is a duplex relationship, ditch the issued_id if one exists.
if($duplex) { if($duplex) {
$r = q("UPDATE `contact` SET `issued-id` = '' WHERE `id` = %d LIMIT 1", $r = q("UPDATE `contact` SET `issued_id` = '' WHERE `id` = %d LIMIT 1",
intval($dfrn_record) intval($dfrn_record)
); );
} }
@ -672,9 +672,9 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
`thumb` = '%s', `thumb` = '%s',
`micro` = '%s', `micro` = '%s',
`rel` = %d, `rel` = %d,
`name-date` = '%s', `name_date` = '%s',
`uri-date` = '%s', `uri_date` = '%s',
`avatar-date` = '%s', `avatar_date` = '%s',
`blocked` = 0, `blocked` = 0,
`pending` = 0, `pending` = 0,
`duplex` = %d, `duplex` = %d,

View File

@ -31,7 +31,7 @@ function dfrn_notify_post(&$a) {
$dfrn_id = substr($dfrn_id,2); $dfrn_id = substr($dfrn_id,2);
} }
$r = q("SELECT * FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1", $r = q("SELECT * FROM `challenge` WHERE `dfrn_id` = '%s' AND `challenge` = '%s' LIMIT 1",
dbesc($dfrn_id), dbesc($dfrn_id),
dbesc($challenge) dbesc($challenge)
); );
@ -40,7 +40,7 @@ function dfrn_notify_post(&$a) {
xml_status(3); xml_status(3);
} }
$r = q("DELETE FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1", $r = q("DELETE FROM `challenge` WHERE `dfrn_id` = '%s' AND `challenge` = '%s' LIMIT 1",
dbesc($dfrn_id), dbesc($dfrn_id),
dbesc($challenge) dbesc($challenge)
); );
@ -50,13 +50,13 @@ function dfrn_notify_post(&$a) {
$sql_extra = ''; $sql_extra = '';
switch($direction) { switch($direction) {
case (-1): case (-1):
$sql_extra = sprintf(" AND ( `issued-id` = '%s' OR `dfrn-id` = '%s' ) ", dbesc($dfrn_id), dbesc($dfrn_id)); $sql_extra = sprintf(" AND ( `issued_id` = '%s' OR `dfrn_id` = '%s' ) ", dbesc($dfrn_id), dbesc($dfrn_id));
break; break;
case 0: case 0:
$sql_extra = sprintf(" AND `issued-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id)); $sql_extra = sprintf(" AND `issued_id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
break; break;
case 1: case 1:
$sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id)); $sql_extra = sprintf(" AND `dfrn_id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
break; break;
default: default:
xml_status(3); xml_status(3);
@ -190,7 +190,7 @@ function dfrn_notify_content(&$a) {
$r = q("DELETE FROM `challenge` WHERE `expire` < " . intval(time())); $r = q("DELETE FROM `challenge` WHERE `expire` < " . intval(time()));
$r = q("INSERT INTO `challenge` ( `challenge`, `dfrn-id`, `expire` ) $r = q("INSERT INTO `challenge` ( `challenge`, `dfrn_id`, `expire` )
VALUES( '%s', '%s', %d ) ", VALUES( '%s', '%s', %d ) ",
dbesc($hash), dbesc($hash),
dbesc($dfrn_id), dbesc($dfrn_id),
@ -202,15 +202,15 @@ function dfrn_notify_content(&$a) {
$sql_extra = ''; $sql_extra = '';
switch($direction) { switch($direction) {
case (-1): case (-1):
$sql_extra = sprintf(" AND ( `issued-id` = '%s' OR `dfrn-id` = '%s' ) ", dbesc($dfrn_id), dbesc($dfrn_id)); $sql_extra = sprintf(" AND ( `issued_id` = '%s' OR `dfrn_id` = '%s' ) ", dbesc($dfrn_id), dbesc($dfrn_id));
$my_id = $dfrn_id; $my_id = $dfrn_id;
break; break;
case 0: case 0:
$sql_extra = sprintf(" AND `issued-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id)); $sql_extra = sprintf(" AND `issued_id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
$my_id = '1:' . $dfrn_id; $my_id = '1:' . $dfrn_id;
break; break;
case 1: case 1:
$sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id)); $sql_extra = sprintf(" AND `dfrn_id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
$my_id = '0:' . $dfrn_id; $my_id = '0:' . $dfrn_id;
break; break;
default: default:

View File

@ -52,15 +52,15 @@ function dfrn_poll_init(&$a) {
$sql_extra = ''; $sql_extra = '';
switch($direction) { switch($direction) {
case (-1): case (-1):
$sql_extra = sprintf(" AND ( `dfrn-id` = '%s' OR `issued-id` = '%s' ) ", dbesc($dfrn_id),dbesc($dfrn_id)); $sql_extra = sprintf(" AND ( `dfrn_id` = '%s' OR `issued_id` = '%s' ) ", dbesc($dfrn_id),dbesc($dfrn_id));
$my_id = $dfrn_id; $my_id = $dfrn_id;
break; break;
case 0: case 0:
$sql_extra = sprintf(" AND `issued-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id)); $sql_extra = sprintf(" AND `issued_id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
$my_id = '1:' . $dfrn_id; $my_id = '1:' . $dfrn_id;
break; break;
case 1: case 1:
$sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id)); $sql_extra = sprintf(" AND `dfrn_id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
$my_id = '0:' . $dfrn_id; $my_id = '0:' . $dfrn_id;
break; break;
default: default:
@ -269,7 +269,7 @@ function dfrn_poll_post(&$a) {
} }
$r = q("SELECT * FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1", $r = q("SELECT * FROM `challenge` WHERE `dfrn_id` = '%s' AND `challenge` = '%s' LIMIT 1",
dbesc($dfrn_id), dbesc($dfrn_id),
dbesc($challenge) dbesc($challenge)
); );
@ -280,7 +280,7 @@ function dfrn_poll_post(&$a) {
$type = $r[0]['type']; $type = $r[0]['type'];
$last_update = $r[0]['last_update']; $last_update = $r[0]['last_update'];
$r = q("DELETE FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1", $r = q("DELETE FROM `challenge` WHERE `dfrn_id` = '%s' AND `challenge` = '%s' LIMIT 1",
dbesc($dfrn_id), dbesc($dfrn_id),
dbesc($challenge) dbesc($challenge)
); );
@ -289,15 +289,15 @@ function dfrn_poll_post(&$a) {
$sql_extra = ''; $sql_extra = '';
switch($direction) { switch($direction) {
case (-1): case (-1):
$sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($dfrn_id)); $sql_extra = sprintf(" AND `issued_id` = '%s' ", dbesc($dfrn_id));
$my_id = $dfrn_id; $my_id = $dfrn_id;
break; break;
case 0: case 0:
$sql_extra = sprintf(" AND `issued-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id)); $sql_extra = sprintf(" AND `issued_id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
$my_id = '1:' . $dfrn_id; $my_id = '1:' . $dfrn_id;
break; break;
case 1: case 1:
$sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id)); $sql_extra = sprintf(" AND `dfrn_id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
$my_id = '0:' . $dfrn_id; $my_id = '0:' . $dfrn_id;
break; break;
default: default:
@ -397,7 +397,7 @@ function dfrn_poll_content(&$a) {
$r = q("DELETE FROM `challenge` WHERE `expire` < " . intval(time())); $r = q("DELETE FROM `challenge` WHERE `expire` < " . intval(time()));
if($type !== 'profile') { if($type !== 'profile') {
$r = q("INSERT INTO `challenge` ( `challenge`, `dfrn-id`, `expire` , `type`, `last_update` ) $r = q("INSERT INTO `challenge` ( `challenge`, `dfrn_id`, `expire` , `type`, `last_update` )
VALUES( '%s', '%s', '%s', '%s', '%s' ) ", VALUES( '%s', '%s', '%s', '%s', '%s' ) ",
dbesc($hash), dbesc($hash),
dbesc($dfrn_id), dbesc($dfrn_id),
@ -410,17 +410,17 @@ function dfrn_poll_content(&$a) {
switch($direction) { switch($direction) {
case (-1): case (-1):
if($type === 'profile') if($type === 'profile')
$sql_extra = sprintf(" AND ( `dfrn-id` = '%s' OR `issued-id` = '%s' ) ", dbesc($dfrn_id),dbesc($dfrn_id)); $sql_extra = sprintf(" AND ( `dfrn_id` = '%s' OR `issued_id` = '%s' ) ", dbesc($dfrn_id),dbesc($dfrn_id));
else else
$sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($dfrn_id)); $sql_extra = sprintf(" AND `issued_id` = '%s' ", dbesc($dfrn_id));
$my_id = $dfrn_id; $my_id = $dfrn_id;
break; break;
case 0: case 0:
$sql_extra = sprintf(" AND `issued-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id)); $sql_extra = sprintf(" AND `issued_id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
$my_id = '1:' . $dfrn_id; $my_id = '1:' . $dfrn_id;
break; break;
case 1: case 1:
$sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id)); $sql_extra = sprintf(" AND `dfrn_id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
$my_id = '0:' . $dfrn_id; $my_id = '0:' . $dfrn_id;
break; break;
default: default:

View File

@ -84,7 +84,7 @@ function dfrn_request_post(&$a) {
); );
if(count($r)) { if(count($r)) {
if(strlen($r[0]['dfrn-id'])) { if(strlen($r[0]['dfrn_id'])) {
/** /**
* We don't need to be here. It has already happened. * We don't need to be here. It has already happened.
@ -98,8 +98,7 @@ function dfrn_request_post(&$a) {
} }
if(is_array($contact_record)) { if(is_array($contact_record)) {
$r = q("UPDATE `contact` SET `ret-aes` = %d, hidden = %d WHERE `id` = %d LIMIT 1", $r = q("UPDATE `contact` SET hidden = %d WHERE `id` = %d LIMIT 1",
intval($aes_allow),
intval($hidden), intval($hidden),
intval($contact_record['id']) intval($contact_record['id'])
); );
@ -144,7 +143,7 @@ function dfrn_request_post(&$a) {
* Create a contact record on our site for the other person * Create a contact record on our site for the other person
*/ */
$r = q("INSERT INTO `contact` ( `uid`, `created`,`url`, `nurl`, `name`, `nick`, `photo`, `site-pubkey`, $r = q("INSERT INTO `contact` ( `uid`, `created`,`url`, `nurl`, `name`, `nick`, `photo`, `site_pubkey`,
`request`, `confirm`, `notify`, `poll`, `poco`, `network`, `aes_allow`, `hidden`) `request`, `confirm`, `notify`, `poll`, `poco`, `network`, `aes_allow`, `hidden`)
VALUES ( %d, '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d)", VALUES ( %d, '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d)",
intval(local_user()), intval(local_user()),
@ -170,7 +169,7 @@ function dfrn_request_post(&$a) {
info( t("Introduction complete.") . EOL); info( t("Introduction complete.") . EOL);
} }
$r = q("select id from contact where uid = %d and url = '%s' and `site-pubkey` = '%s' limit 1", $r = q("select id from contact where uid = %d and url = '%s' and `site_pubkey` = '%s' limit 1",
intval(local_user()), intval(local_user()),
dbesc($dfrn_url), dbesc($dfrn_url),
$parms['key'] // this was already escaped $parms['key'] // this was already escaped
@ -401,9 +400,9 @@ function dfrn_request_post(&$a) {
`photo` = '%s', `photo` = '%s',
`thumb` = '%s', `thumb` = '%s',
`micro` = '%s', `micro` = '%s',
`name-date` = '%s', `name_date` = '%s',
`uri-date` = '%s', `uri_date` = '%s',
`avatar-date` = '%s', `avatar_date` = '%s',
`hidden` = 0, `hidden` = 0,
WHERE `id` = %d LIMIT 1 WHERE `id` = %d LIMIT 1
", ",
@ -466,7 +465,7 @@ function dfrn_request_post(&$a) {
); );
if(count($ret)) { if(count($ret)) {
if(strlen($ret[0]['issued-id'])) { if(strlen($ret[0]['issued_id'])) {
notice( t('You have already introduced yourself here.') . EOL ); notice( t('You have already introduced yourself here.') . EOL );
return; return;
} }
@ -483,9 +482,9 @@ function dfrn_request_post(&$a) {
$issued_id = random_string(); $issued_id = random_string();
if(is_array($contact_record)) { if(is_array($contact_record)) {
// There is a contact record but no issued-id, so this // There is a contact record but no issued_id, so this
// is a reciprocal introduction from a known contact // is a reciprocal introduction from a known contact
$r = q("UPDATE `contact` SET `issued-id` = '%s' WHERE `id` = %d LIMIT 1", $r = q("UPDATE `contact` SET `issued_id` = '%s' WHERE `id` = %d LIMIT 1",
dbesc($issued_id), dbesc($issued_id),
intval($contact_record['id']) intval($contact_record['id'])
); );
@ -529,11 +528,11 @@ function dfrn_request_post(&$a) {
$parms['url'] = $url; $parms['url'] = $url;
$parms['issued-id'] = $issued_id; $parms['issued_id'] = $issued_id;
dbesc_array($parms); dbesc_array($parms);
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`,`name`, `nick`, `issued-id`, `photo`, `site-pubkey`, $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`,`name`, `nick`, `issued_id`, `photo`, `site_pubkey`,
`request`, `confirm`, `notify`, `poll`, `poco`, `network` ) `request`, `confirm`, `notify`, `poll`, `poco`, `network` )
VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
intval($uid), intval($uid),
@ -542,7 +541,7 @@ function dfrn_request_post(&$a) {
dbesc(normalise_link($parms['url'])), dbesc(normalise_link($parms['url'])),
$parms['fn'], $parms['fn'],
$parms['nick'], $parms['nick'],
$parms['issued-id'], $parms['issued_id'],
$parms['photo'], $parms['photo'],
$parms['key'], $parms['key'],
$parms['dfrn-request'], $parms['dfrn-request'],
@ -556,10 +555,10 @@ function dfrn_request_post(&$a) {
// find the contact record we just created // find the contact record we just created
if($r) { if($r) {
$r = q("SELECT `id` FROM `contact` $r = q("SELECT `id` FROM `contact`
WHERE `uid` = %d AND `url` = '%s' AND `issued-id` = '%s' LIMIT 1", WHERE `uid` = %d AND `url` = '%s' AND `issued_id` = '%s' LIMIT 1",
intval($uid), intval($uid),
$parms['url'], $parms['url'],
$parms['issued-id'] $parms['issued_id']
); );
if(count($r)) if(count($r))
$contact_record = $r[0]; $contact_record = $r[0];
@ -725,7 +724,7 @@ function dfrn_request_content(&$a) {
$handsfree = array( $handsfree = array(
'uid' => $r[0]['uid'], 'uid' => $r[0]['uid'],
'node' => $r[0]['nickname'], 'node' => $r[0]['nickname'],
'dfrn_id' => $r[0]['issued-id'], 'dfrn_id' => $r[0]['issued_id'],
'intro_id' => $intro[0]['id'], 'intro_id' => $intro[0]['id'],
'duplex' => (($r[0]['page-flags'] == PAGE_FREELOVE) ? 1 : 0), 'duplex' => (($r[0]['page-flags'] == PAGE_FREELOVE) ? 1 : 0),
'activity' => intval(get_pconfig($r[0]['uid'],'system','post_newfriend')) 'activity' => intval(get_pconfig($r[0]['uid'],'system','post_newfriend'))

View File

@ -605,7 +605,7 @@ function network_content(&$a, $update = 0, $load = false) {
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`, $items = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn_id`, `contact`.`self`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item`, `contact` FROM `item`, `contact`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 WHERE `item`.`uid` = %d AND `item`.`visible` = 1
@ -667,7 +667,7 @@ function network_content(&$a, $update = 0, $load = false) {
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`, $items = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`writable`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`writable`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn_id`, `contact`.`self`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item`, `contact` FROM `item`, `contact`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0

View File

@ -191,7 +191,7 @@ function notifications_content(&$a) {
'$str_notifytype' => t('Notification type: '), '$str_notifytype' => t('Notification type: '),
'$notify_type' => (($rr['network'] !== NETWORK_OSTATUS) ? t('Friend/Connect Request') : t('New Follower')), '$notify_type' => (($rr['network'] !== NETWORK_OSTATUS) ? t('Friend/Connect Request') : t('New Follower')),
'$dfrn_text' => $dfrn_text, '$dfrn_text' => $dfrn_text,
'$dfrn_id' => $rr['issued-id'], '$dfrn_id' => $rr['issued_id'],
'$uid' => $_SESSION['uid'], '$uid' => $_SESSION['uid'],
'$intro_id' => $rr['intro_id'], '$intro_id' => $rr['intro_id'],
'$contact_id' => $rr['contact-id'], '$contact_id' => $rr['contact-id'],

View File

@ -110,7 +110,7 @@ function profile_photo_post(&$a) {
// we'll set the updated profile-photo timestamp even if it isn't the default profile, // we'll set the updated profile-photo timestamp even if it isn't the default profile,
// so that browsers will do a cache update unconditionally // so that browsers will do a cache update unconditionally
$r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d LIMIT 1", $r = q("UPDATE `contact` SET `avatar_date` = '%s' WHERE `self` = 1 AND `uid` = %d LIMIT 1",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval(local_user()) intval(local_user())
); );
@ -207,7 +207,7 @@ function profile_photo_content(&$a) {
dbesc($resource_id) dbesc($resource_id)
); );
$r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d LIMIT 1", $r = q("UPDATE `contact` SET `avatar_date` = '%s' WHERE `self` = 1 AND `uid` = %d LIMIT 1",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval(local_user()) intval(local_user())
); );

View File

@ -289,7 +289,7 @@ function profiles_post(&$a) {
if($namechanged && $is_default) { if($namechanged && $is_default) {
$r = q("UPDATE `contact` SET `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d LIMIT 1", $r = q("UPDATE `contact` SET `name_date` = '%s' WHERE `self` = 1 AND `uid` = %d LIMIT 1",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval(local_user()) intval(local_user())
); );
@ -420,7 +420,7 @@ function profiles_content(&$a) {
// move every contact using this profile as their default to the user default // move every contact using this profile as their default to the user default
$r = q("UPDATE `contact` SET `profile-id` = (SELECT `profile`.`id` AS `profile-id` FROM `profile` WHERE `profile`.`is_default` = 1 AND `profile`.`uid` = %d LIMIT 1) WHERE `profile-id` = %d AND `uid` = %d ", $r = q("UPDATE `contact` SET `profile_id` = (SELECT `profile`.`id` AS `profile_id` FROM `profile` WHERE `profile`.`is_default` = 1 AND `profile`.`uid` = %d LIMIT 1) WHERE `profile_id` = %d AND `uid` = %d ",
intval(local_user()), intval(local_user()),
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())

View File

@ -57,7 +57,7 @@ function profperm_content(&$a) {
} }
$profile = $r[0]; $profile = $r[0];
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `profile-id` = %d", $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `profile_id` = %d",
intval(local_user()), intval(local_user()),
intval($a->argv[1]) intval($a->argv[1])
); );
@ -71,13 +71,13 @@ function profperm_content(&$a) {
if($change) { if($change) {
if(in_array($change,$ingroup)) { if(in_array($change,$ingroup)) {
q("UPDATE `contact` SET `profile-id` = 0 WHERE `id` = %d AND `uid` = %d LIMIT 1", q("UPDATE `contact` SET `profile_id` = 0 WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($change), intval($change),
intval(local_user()) intval(local_user())
); );
} }
else { else {
q("UPDATE `contact` SET `profile-id` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", q("UPDATE `contact` SET `profile_id` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]), intval($a->argv[1]),
intval($change), intval($change),
intval(local_user()) intval(local_user())
@ -85,7 +85,7 @@ function profperm_content(&$a) {
} }
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `profile-id` = %d", $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `profile_id` = %d",
intval(local_user()), intval(local_user()),
intval($a->argv[1]) intval($a->argv[1])
); );

View File

@ -18,14 +18,14 @@ function redir_init(&$a) {
if((! count($r)) || ($r[0]['network'] !== NETWORK_DFRN)) if((! count($r)) || ($r[0]['network'] !== NETWORK_DFRN))
goaway(z_root()); goaway(z_root());
$dfrn_id = $orig_id = (($r[0]['issued-id']) ? $r[0]['issued-id'] : $r[0]['dfrn-id']); $dfrn_id = $orig_id = (($r[0]['issued_id']) ? $r[0]['issued_id'] : $r[0]['dfrn_id']);
if($r[0]['duplex'] && $r[0]['issued-id']) { if($r[0]['duplex'] && $r[0]['issued_id']) {
$orig_id = $r[0]['issued-id']; $orig_id = $r[0]['issued_id'];
$dfrn_id = '1:' . $orig_id; $dfrn_id = '1:' . $orig_id;
} }
if($r[0]['duplex'] && $r[0]['dfrn-id']) { if($r[0]['duplex'] && $r[0]['dfrn_id']) {
$orig_id = $r[0]['dfrn-id']; $orig_id = $r[0]['dfrn_id'];
$dfrn_id = '0:' . $orig_id; $dfrn_id = '0:' . $orig_id;
} }

View File

@ -396,7 +396,7 @@ function settings_post(&$a) {
if($name_change) { if($name_change) {
q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `self` = 1 LIMIT 1", q("UPDATE `contact` SET `name` = '%s', `name_date` = '%s' WHERE `uid` = %d AND `self` = 1 LIMIT 1",
dbesc($username), dbesc($username),
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval(local_user()) intval(local_user())

View File

@ -48,7 +48,7 @@ function update_1000() {
q("ALTER TABLE `intro` ADD `duplex` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `knowyou` "); q("ALTER TABLE `intro` ADD `duplex` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `knowyou` ");
q("ALTER TABLE `contact` ADD `duplex` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `rel` "); q("ALTER TABLE `contact` ADD `duplex` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `rel` ");
q("ALTER TABLE `contact` CHANGE `issued-pubkey` `issued-pubkey` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL"); q("ALTER TABLE `contact` CHANGE `issued-pubkey` `issued-pubkey` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
q("ALTER TABLE `contact` ADD `term-date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `avatar-date`"); q("ALTER TABLE `contact` ADD `term_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `avatar_date`");
} }
function update_1001() { function update_1001() {
@ -64,7 +64,7 @@ function update_1003() {
q("ALTER TABLE `contact` DROP `issued-pubkey` , DROP `ret-id` , DROP `ret-pubkey` "); q("ALTER TABLE `contact` DROP `issued-pubkey` , DROP `ret-id` , DROP `ret-pubkey` ");
q("ALTER TABLE `contact` ADD `usehub` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `ret-aes`"); q("ALTER TABLE `contact` ADD `usehub` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `ret-aes`");
q("ALTER TABLE `contact` ADD `hub-verify` CHAR( 255 ) NOT NULL AFTER `usehub`"); q("ALTER TABLE `contact` ADD `hub-verify` CHAR( 255 ) NOT NULL AFTER `usehub`");
q("ALTER TABLE `contact` ADD INDEX ( `uid` ) , ADD INDEX ( `self` ), ADD INDEX ( `issued-id` ), ADD INDEX ( `dfrn-id` )"); q("ALTER TABLE `contact` ADD INDEX ( `uid` ) , ADD INDEX ( `self` ), ADD INDEX ( `issued_id` ), ADD INDEX ( `dfrn_id` )");
q("ALTER TABLE `contact` ADD INDEX ( `blocked` ), ADD INDEX ( `readonly` )"); q("ALTER TABLE `contact` ADD INDEX ( `blocked` ), ADD INDEX ( `readonly` )");
} }
@ -281,7 +281,7 @@ function update_1029() {
} }
function update_1030() { function update_1030() {
q("ALTER TABLE `contact` ADD `bdyear` CHAR( 4 ) NOT NULL COMMENT 'birthday notify flag' AFTER `profile-id` "); q("ALTER TABLE `contact` ADD `bdyear` CHAR( 4 ) NOT NULL COMMENT 'birthday notify flag' AFTER `profile_id` ");
q("CREATE TABLE IF NOT EXISTS `event` ( q("CREATE TABLE IF NOT EXISTS `event` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,