Merge pull request #927 from annando/master

Massive SQL stuff
This commit is contained in:
fabrixxm 2014-04-04 07:28:06 +00:00
commit 29092ace44
74 changed files with 1376 additions and 892 deletions

View File

@ -14,7 +14,7 @@ require_once('include/features.php');
define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_VERSION', '3.2.1748' ); define ( 'FRIENDICA_VERSION', '3.2.1748' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
define ( 'DB_UPDATE_VERSION', 1169 ); define ( 'DB_UPDATE_VERSION', 1170 );
define ( 'EOL', "<br />\r\n" ); define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
@ -739,7 +739,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;
@ -1328,7 +1328,7 @@ if(! function_exists('profile_load')) {
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, `user`.* FROM `profile` $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid` INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d and `contact`.`self` = 1 LIMIT 1", WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d and `contact`.`self` = 1 LIMIT 1",
dbesc($nickname), dbesc($nickname),
intval($profile_int) intval($profile_int)
@ -1336,7 +1336,7 @@ if(! function_exists('profile_load')) {
} }
if((! $r) && (! count($r))) { if((! $r) && (! count($r))) {
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile` $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid` INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 and `contact`.`self` = 1 LIMIT 1", WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 and `contact`.`self` = 1 LIMIT 1",
dbesc($nickname) dbesc($nickname)
); );
@ -1591,7 +1591,7 @@ if(! function_exists('get_birthdays')) {
$bd_short = t('F d'); $bd_short = t('F d');
$r = q("SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event` $r = q("SELECT `event`.*, `event`.`id` AS `eid`, `contact`.* FROM `event`
LEFT JOIN `contact` ON `contact`.`id` = `event`.`cid` INNER JOIN `contact` ON `contact`.`id` = `event`.`cid`
WHERE `event`.`uid` = %d AND `type` = 'birthday' AND `start` < '%s' AND `finish` > '%s' WHERE `event`.`uid` = %d AND `type` = 'birthday' AND `start` < '%s' AND `finish` > '%s'
ORDER BY `start` ASC ", ORDER BY `start` ASC ",
intval(local_user()), intval(local_user()),

View File

@ -1192,3 +1192,44 @@ CREATE TABLE IF NOT EXISTS `unique_contacts` (
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `url` (`url`) KEY `url` (`url`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `thread`
--
CREATE TABLE IF NOT EXISTS `thread` (
`iid` int(10) unsigned NOT NULL DEFAULT '0',
`uid` int(10) unsigned NOT NULL DEFAULT '0',
`contact-id` int(11) unsigned NOT NULL DEFAULT '0',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`commented` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`received` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`changed` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`wall` tinyint(1) NOT NULL DEFAULT '0',
`private` tinyint(1) NOT NULL DEFAULT '0',
`pubmail` tinyint(1) NOT NULL DEFAULT '0',
`moderated` tinyint(1) NOT NULL DEFAULT '0',
`visible` tinyint(1) NOT NULL DEFAULT '0',
`spam` tinyint(1) NOT NULL DEFAULT '0',
`starred` tinyint(1) NOT NULL DEFAULT '0',
`bookmark` tinyint(1) NOT NULL DEFAULT '0',
`unseen` tinyint(1) NOT NULL DEFAULT '1',
`deleted` tinyint(1) NOT NULL DEFAULT '0',
`origin` tinyint(1) NOT NULL DEFAULT '0',
`forum_mode` tinyint(1) NOT NULL DEFAULT '0',
`mention` tinyint(1) NOT NULL DEFAULT '0',
`network` char(32) NOT NULL,
PRIMARY KEY (`iid`),
KEY `created` (`created`),
KEY `commented` (`commented`),
KEY `uid_network_commented` (`uid`,`network`,`commented`),
KEY `uid_network_created` (`uid`,`network`,`created`),
KEY `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
KEY `uid_contactid_created` (`uid`,`contact-id`,`created`),
KEY `wall_private_received` (`wall`,`private`,`received`),
KEY `uid_created` (`uid`,`created`),
KEY `uid_commented` (`uid`,`commented`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

View File

@ -64,13 +64,13 @@ function contact_remove($id) {
$archive = get_pconfig($r[0]['uid'], 'system','archive_removed_contacts'); $archive = get_pconfig($r[0]['uid'], 'system','archive_removed_contacts');
if($archive) { if($archive) {
q("update contact set `archive` = 1, `network` = 'none', `writable` = 0 where id = %d limit 1", q("update contact set `archive` = 1, `network` = 'none', `writable` = 0 where id = %d",
intval($id) intval($id)
); );
return; return;
} }
q("DELETE FROM `contact` WHERE `id` = %d LIMIT 1", q("DELETE FROM `contact` WHERE `id` = %d",
intval($id) intval($id)
); );
q("DELETE FROM `item` WHERE `contact-id` = %d ", q("DELETE FROM `item` WHERE `contact-id` = %d ",
@ -148,7 +148,7 @@ function mark_for_death($contact) {
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",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($contact['id']) intval($contact['id'])
); );
@ -166,7 +166,7 @@ function mark_for_death($contact) {
// archive them rather than delete // archive them rather than delete
// though if the owner tries to unarchive them we'll start the whole process over again // though if the owner tries to unarchive them we'll start the whole process over again
q("update contact set `archive` = 1 where id = %d limit 1", q("update contact set `archive` = 1 where id = %d",
intval($contact['id']) intval($contact['id'])
); );
q("UPDATE `item` SET `private` = 2 WHERE `contact-id` = %d AND `uid` = %d", intval($contact['id']), intval($contact['uid'])); q("UPDATE `item` SET `private` = 2 WHERE `contact-id` = %d AND `uid` = %d", intval($contact['id']), intval($contact['uid']));
@ -181,7 +181,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",
dbesc('0000-00-00 00:00:00'), dbesc('0000-00-00 00:00:00'),
intval($contact['id']) intval($contact['id'])
); );

View File

@ -595,7 +595,7 @@ class Photo {
`allow_gid` = '%s', `allow_gid` = '%s',
`deny_cid` = '%s', `deny_cid` = '%s',
`deny_gid` = '%s' `deny_gid` = '%s'
where id = %d limit 1", where id = %d",
intval($uid), intval($uid),
intval($cid), intval($cid),

View File

@ -402,7 +402,7 @@ function acl_lookup(&$a, $out_type = 'json') {
// count groups and contacts // count groups and contacts
if ($type=='' || $type=='g'){ if ($type=='' || $type=='g'){
$r = q("SELECT COUNT(`id`) AS g FROM `group` WHERE `deleted` = 0 AND `uid` = %d $sql_extra", $r = q("SELECT COUNT(*) AS g FROM `group` WHERE `deleted` = 0 AND `uid` = %d $sql_extra",
intval(local_user()) intval(local_user())
); );
$group_count = (int)$r[0]['g']; $group_count = (int)$r[0]['g'];
@ -411,7 +411,7 @@ function acl_lookup(&$a, $out_type = 'json') {
} }
if ($type=='' || $type=='c'){ if ($type=='' || $type=='c'){
$r = q("SELECT COUNT(`id`) AS c FROM `contact` $r = q("SELECT COUNT(*) AS c FROM `contact`
WHERE `uid` = %d AND `self` = 0 WHERE `uid` = %d AND `self` = 0
AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0
AND `notify` != '' $sql_extra2" , AND `notify` != '' $sql_extra2" ,
@ -423,7 +423,7 @@ function acl_lookup(&$a, $out_type = 'json') {
// autocomplete for Private Messages // autocomplete for Private Messages
$r = q("SELECT COUNT(`id`) AS c FROM `contact` $r = q("SELECT COUNT(*) AS c FROM `contact`
WHERE `uid` = %d AND `self` = 0 WHERE `uid` = %d AND `self` = 0
AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0
AND `network` IN ('%s','%s','%s') $sql_extra2" , AND `network` IN ('%s','%s','%s') $sql_extra2" ,
@ -439,7 +439,7 @@ function acl_lookup(&$a, $out_type = 'json') {
// autocomplete for Contacts // autocomplete for Contacts
$r = q("SELECT COUNT(`id`) AS c FROM `contact` $r = q("SELECT COUNT(*) AS c FROM `contact`
WHERE `uid` = %d AND `self` = 0 WHERE `uid` = %d AND `self` = 0
AND `pending` = 0 $sql_extra2" , AND `pending` = 0 $sql_extra2" ,
intval(local_user()) intval(local_user())

View File

@ -384,26 +384,26 @@
intval(api_user()) intval(api_user())
); );
//AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''",
// count public wall messages // count public wall messages
$r = q("SELECT COUNT(`id`) as `count` FROM `item` $r = q("SELECT count(*) as `count` FROM `item`
WHERE `uid` = %d WHERE `uid` = %d
AND `type`='wall' AND `type`='wall'",
AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''",
intval($uinfo[0]['uid']) intval($uinfo[0]['uid'])
); );
$countitms = $r[0]['count']; $countitms = $r[0]['count'];
} }
else { else {
$r = q("SELECT COUNT(`id`) as `count` FROM `item` //AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''",
WHERE `contact-id` = %d $r = q("SELECT count(*) as `count` FROM `item`
AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''", WHERE `contact-id` = %d",
intval($uinfo[0]['id']) intval($uinfo[0]['id'])
); );
$countitms = $r[0]['count']; $countitms = $r[0]['count'];
} }
// count friends // count friends
$r = q("SELECT COUNT(`id`) as `count` FROM `contact` $r = q("SELECT count(*) as `count` FROM `contact`
WHERE `uid` = %d AND `rel` IN ( %d, %d ) WHERE `uid` = %d AND `rel` IN ( %d, %d )
AND `self`=0 AND `blocked`=0 AND `pending`=0 AND `hidden`=0", AND `self`=0 AND `blocked`=0 AND `pending`=0 AND `hidden`=0",
intval($uinfo[0]['uid']), intval($uinfo[0]['uid']),
@ -412,7 +412,7 @@
); );
$countfriends = $r[0]['count']; $countfriends = $r[0]['count'];
$r = q("SELECT COUNT(`id`) as `count` FROM `contact` $r = q("SELECT count(*) as `count` FROM `contact`
WHERE `uid` = %d AND `rel` IN ( %d, %d ) WHERE `uid` = %d AND `rel` IN ( %d, %d )
AND `self`=0 AND `blocked`=0 AND `pending`=0 AND `hidden`=0", AND `self`=0 AND `blocked`=0 AND `pending`=0 AND `hidden`=0",
intval($uinfo[0]['uid']), intval($uinfo[0]['uid']),
@ -421,7 +421,7 @@
); );
$countfollowers = $r[0]['count']; $countfollowers = $r[0]['count'];
$r = q("SELECT count(`id`) as `count` FROM item where starred = 1 and uid = %d and deleted = 0", $r = q("SELECT count(*) as `count` FROM item where starred = 1 and uid = %d and deleted = 0",
intval($uinfo[0]['uid']) intval($uinfo[0]['uid'])
); );
$starred = $r[0]['count']; $starred = $r[0]['count'];
@ -528,7 +528,8 @@
$status_user["protected"] = (($item["allow_cid"] != "") OR $status_user["protected"] = (($item["allow_cid"] != "") OR
($item["allow_gid"] != "") OR ($item["allow_gid"] != "") OR
($item["deny_cid"] != "") OR ($item["deny_cid"] != "") OR
($item["deny_gid"] != "")); ($item["deny_gid"] != "") OR
$item["private"]);
return ($status_user); return ($status_user);
} }
@ -745,12 +746,27 @@
logger('api_status_show: user_info: '.print_r($user_info, true), LOGGER_DEBUG); logger('api_status_show: user_info: '.print_r($user_info, true), LOGGER_DEBUG);
// get last public wall message // get last public wall message
$lastwall = q("SELECT `item`.*, `i`.`contact-id` as `reply_uid`, `c`.`nick` as `reply_author`, `i`.`author-link` AS `item-author` //$lastwall = q("SELECT `item`.*, `i`.`contact-id` as `reply_uid`, `c`.`nick` as `reply_author`, `i`.`author-link` AS `item-author`
FROM `item`, `contact`, `item` as `i`, `contact` as `c` // FROM `item`, `contact`, `item` as `i`, `contact` as `c`
// WHERE `item`.`contact-id` = %d
// AND ((`item`.`author-link` IN ('%s', '%s')) OR (`item`.`owner-link` IN ('%s', '%s')))
// AND `i`.`id` = `item`.`parent`
// AND `contact`.`id`=`item`.`contact-id` AND `c`.`id`=`i`.`contact-id` AND `contact`.`self`=1
// AND `item`.`type`!='activity'
// AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`=''
// ORDER BY `item`.`created` DESC
// LIMIT 1",
// intval($user_info['cid']),
// dbesc($user_info['url']),
// dbesc(normalise_link($user_info['url'])),
// dbesc($user_info['url']),
// dbesc(normalise_link($user_info['url']))
//);
$lastwall = q("SELECT `item`.*, `i`.`contact-id` as `reply_uid`, `i`.`author-link` AS `item-author`
FROM `item`, `item` as `i`
WHERE `item`.`contact-id` = %d WHERE `item`.`contact-id` = %d
AND ((`item`.`author-link` IN ('%s', '%s')) OR (`item`.`owner-link` IN ('%s', '%s'))) AND ((`item`.`author-link` IN ('%s', '%s')) OR (`item`.`owner-link` IN ('%s', '%s')))
AND `i`.`id` = `item`.`parent` AND `i`.`id` = `item`.`parent`
AND `contact`.`id`=`item`.`contact-id` AND `c`.`id`=`i`.`contact-id` AND `contact`.`self`=1
AND `item`.`type`!='activity' AND `item`.`type`!='activity'
AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`='' AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`=''
ORDER BY `item`.`created` DESC ORDER BY `item`.`created` DESC
@ -773,8 +789,6 @@
if ($lastwall['parent']!=$lastwall['id']) { if ($lastwall['parent']!=$lastwall['id']) {
$in_reply_to_status_id= intval($lastwall['parent']); $in_reply_to_status_id= intval($lastwall['parent']);
$in_reply_to_status_id_str = (string) intval($lastwall['parent']); $in_reply_to_status_id_str = (string) intval($lastwall['parent']);
//$in_reply_to_user_id = $lastwall['reply_uid'];
//$in_reply_to_screen_name = $lastwall['reply_author'];
$r = q("SELECT * FROM unique_contacts WHERE `url` = '%s'", dbesc(normalise_link($lastwall['item-author']))); $r = q("SELECT * FROM unique_contacts WHERE `url` = '%s'", dbesc(normalise_link($lastwall['item-author'])));
if ($r) { if ($r) {
@ -807,6 +821,9 @@
'statusnet_conversation_id' => $lastwall['parent'], 'statusnet_conversation_id' => $lastwall['parent'],
); );
if ($lastwall['title'] != "")
$status_info['statusnet_html'] = "<h4>".bbcode($lastwall['title'])."</h4>\n".$status_info['statusnet_html'];
$entities = api_get_entitities($status_info['text'], $lastwall['body']); $entities = api_get_entitities($status_info['text'], $lastwall['body']);
if (count($entities) > 0) if (count($entities) > 0)
$status_info['entities'] = $entities; $status_info['entities'] = $entities;
@ -842,13 +859,14 @@
$lastwall = q("SELECT `item`.* $lastwall = q("SELECT `item`.*
FROM `item`, `contact` FROM `item`, `contact`
WHERE `item`.`contact-id` = %d WHERE `item`.`uid` = %d AND `item`.`contact-id` = %d
AND ((`item`.`author-link` IN ('%s', '%s')) OR (`item`.`owner-link` IN ('%s', '%s'))) AND ((`item`.`author-link` IN ('%s', '%s')) OR (`item`.`owner-link` IN ('%s', '%s')))
AND `contact`.`id`=`item`.`contact-id` AND `contact`.`id`=`item`.`contact-id`
AND `type`!='activity' AND `type`!='activity'
AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`='' AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`=''
ORDER BY `created` DESC ORDER BY `created` DESC
LIMIT 1", LIMIT 1",
intval(api_user()),
intval($user_info['cid']), intval($user_info['cid']),
dbesc($user_info['url']), dbesc($user_info['url']),
dbesc(normalise_link($user_info['url'])), dbesc(normalise_link($user_info['url'])),
@ -900,6 +918,9 @@
'statusnet_conversation_id' => $lastwall['parent'], 'statusnet_conversation_id' => $lastwall['parent'],
); );
if ($lastwall['title'] != "")
$user_info['statusnet_html'] = "<h4>".bbcode($lastwall['title'])."</h4>\n".$user_info['statusnet_html'];
$entities = api_get_entitities($user_info['text'], $lastwall['body']); $entities = api_get_entitities($user_info['text'], $lastwall['body']);
if (count($entities) > 0) if (count($entities) > 0)
$user_info['entities'] = $entities; $user_info['entities'] = $entities;
@ -1041,8 +1062,8 @@
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
`user`.`nickname`, `user`.`hidewall` `user`.`nickname`, `user`.`hidewall`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
@ -1827,6 +1848,9 @@
'statusnet_conversation_id' => $item['parent'], 'statusnet_conversation_id' => $item['parent'],
); );
if ($item['title'] != "")
$status['statusnet_html'] = "<h4>".bbcode($item['title'])."</h4>\n".$status['statusnet_html'];
$entities = api_get_entitities($status['text'], $item['body']); $entities = api_get_entitities($status['text'], $item['body']);
if (count($entities) > 0) if (count($entities) > 0)
$status['entities'] = $entities; $status['entities'] = $entities;

View File

@ -2,6 +2,35 @@
require_once("include/oembed.php"); require_once("include/oembed.php");
require_once('include/event.php'); require_once('include/event.php');
function bb_rearrange_link($shared) {
if ($shared[1] != "type-link")
return($shared[0]);
$newshare = trim($shared[2]);
$newshare = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $newshare);
if (!strpos($shared[0], "[bookmark"))
$newshare = preg_replace("/\[url\=(.*?)\](.*?)\[\/url\]/ism", '[bookmark=$1]$2[/bookmark]', $newshare, 1);
preg_match("/\[img\](.*?)\[\/img\]/ism", $newshare, $matches);
if ($matches) {
$newshare = str_replace($matches[0], '', $newshare);
$newshare = "[img]".$matches[1]."[/img]\n".$newshare;
}
$search = array("\n\n", "\n ", " \n");
$replace = array("\n", "\n", "\n");
do {
$oldtext = $newshare;
$newshare = str_replace($search, $replace, $newshare);
} while ($oldtext != $newshare);
$newshare = "[class=type-link]".$newshare."[/class]";
return($newshare);
}
function bb_remove_share_information($Text) { function bb_remove_share_information($Text) {
$Text = preg_replace_callback("((.*?)\[class=(.*?)\](.*?)\[\/class\])ism","bb_cleanup_share",$Text); $Text = preg_replace_callback("((.*?)\[class=(.*?)\](.*?)\[\/class\])ism","bb_cleanup_share",$Text);
return($Text); return($Text);
@ -670,6 +699,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
$Text = preg_replace("/\n\[code\]/ism", "[code]", $Text); $Text = preg_replace("/\n\[code\]/ism", "[code]", $Text);
$Text = preg_replace("/\[\/code\]\n/ism", "[/code]", $Text); $Text = preg_replace("/\[\/code\]\n/ism", "[/code]", $Text);
// Rearrange shared links
if (get_config("system", "rearrange_shared_links") AND (!$simplehtml OR $tryoembed))
$Text = preg_replace_callback("(\[class=(.*?)\](.*?)\[\/class\])ism","bb_rearrange_link",$Text);
// when the content is meant exporting to other systems then remove the avatar picture since this doesn't really look good on these systems // when the content is meant exporting to other systems then remove the avatar picture since this doesn't really look good on these systems
if (!$tryoembed) if (!$tryoembed)
$Text = preg_replace("/\[share(.*?)avatar\s?=\s?'.*?'\s?(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","\n[share$1$2]$3[/share]",$Text); $Text = preg_replace("/\[share(.*?)avatar\s?=\s?'.*?'\s?(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","\n[share$1$2]$3[/share]",$Text);

View File

@ -47,7 +47,7 @@
* dbesc($key) * dbesc($key)
* ); * );
* if(count($r)) { * if(count($r)) {
* q("UPDATE `cache` SET `v` = '%s', `updated = '%s' WHERE `k` = '%s' limit 1", * q("UPDATE `cache` SET `v` = '%s', `updated = '%s' WHERE `k` = '%s'",
* dbesc($value), * dbesc($value),
* dbesc(datetime_convert()), * dbesc(datetime_convert()),
* dbesc($key)); * dbesc($key));

View File

@ -66,12 +66,22 @@ function get_config($family, $key, $instore = false) {
} }
} }
// If APC is enabled then fetch the data from there // If APC is enabled then fetch the data from there, else try XCache
if (function_exists("apc_fetch") AND function_exists("apc_exists")) if (function_exists("apc_fetch") AND function_exists("apc_exists"))
if (apc_exists($family."|".$key)) { if (apc_exists($family."|".$key)) {
$val = apc_fetch($family."|".$key); $val = apc_fetch($family."|".$key);
$a->config[$family][$key] = $val; $a->config[$family][$key] = $val;
if ($val === '!<unset>!')
return false;
else
return $val;
}
elseif (function_exists("xcache_fetch") AND function_exists("xcache_isset"))
if (xcache_isset($family."|".$key)) {
$val = xcache_fetch($family."|".$key);
$a->config[$family][$key] = $val;
if ($val === '!<unset>!') if ($val === '!<unset>!')
return false; return false;
else else
@ -87,18 +97,22 @@ function get_config($family, $key, $instore = false) {
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']); $val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']);
$a->config[$family][$key] = $val; $a->config[$family][$key] = $val;
// If APC is enabled then store the data there // If APC is enabled then store the data there, else try XCache
if (function_exists("apc_store")) if (function_exists("apc_store"))
apc_store($family."|".$key, $val, 600); apc_store($family."|".$key, $val, 600);
elseif (function_exists("xcache_set"))
xcache_set($family."|".$key, $val, 600);
return $val; return $val;
} }
else { else {
$a->config[$family][$key] = '!<unset>!'; $a->config[$family][$key] = '!<unset>!';
// If APC is enabled then store the data there // If APC is enabled then store the data there, else try XCache
if (function_exists("apc_store")) if (function_exists("apc_store"))
apc_store($family."|".$key, '!<unset>!', 600); apc_store($family."|".$key, '!<unset>!', 600);
elseif (function_exists("xcache_set"))
xcache_set($family."|".$key, '!<unset>!', 600);
} }
return false; return false;
}} }}
@ -134,7 +148,7 @@ function set_config($family,$key,$value) {
return $ret; return $ret;
} }
$ret = q("UPDATE `config` SET `v` = '%s' WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1", $ret = q("UPDATE `config` SET `v` = '%s' WHERE `cat` = '%s' AND `k` = '%s'",
dbesc($dbvalue), dbesc($dbvalue),
dbesc($family), dbesc($family),
dbesc($key) dbesc($key)
@ -142,9 +156,11 @@ function set_config($family,$key,$value) {
$a->config[$family][$key] = $value; $a->config[$family][$key] = $value;
// If APC is enabled then store the data there // If APC is enabled then store the data there, else try XCache
if (function_exists("apc_store")) if (function_exists("apc_store"))
apc_store($family."|".$key, $value, 600); apc_store($family."|".$key, $value, 600);
elseif (function_exists("xcache_set"))
xcache_set($family."|".$key, $value, 600);
if($ret) if($ret)
return $value; return $value;
@ -193,7 +209,7 @@ function get_pconfig($uid,$family, $key, $instore = false) {
} }
} }
// If APC is enabled then fetch the data from there // If APC is enabled then fetch the data from there, else try XCache
if (function_exists("apc_fetch") AND function_exists("apc_exists")) if (function_exists("apc_fetch") AND function_exists("apc_exists"))
if (apc_exists($uid."|".$family."|".$key)) { if (apc_exists($uid."|".$family."|".$key)) {
$val = apc_fetch($uid."|".$family."|".$key); $val = apc_fetch($uid."|".$family."|".$key);
@ -204,6 +220,16 @@ function get_pconfig($uid,$family, $key, $instore = false) {
else else
return $val; return $val;
} }
elseif (function_exists("xcache_get") AND function_exists("xcache_isset"))
if (xcache_isset($uid."|".$family."|".$key)) {
$val = xcache_get($uid."|".$family."|".$key);
$a->config[$uid][$family][$key] = $val;
if ($val === '!<unset>!')
return false;
else
return $val;
}
$ret = q("SELECT `v` FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1", $ret = q("SELECT `v` FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1",
@ -216,18 +242,22 @@ function get_pconfig($uid,$family, $key, $instore = false) {
$val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']); $val = (preg_match("|^a:[0-9]+:{.*}$|s", $ret[0]['v'])?unserialize( $ret[0]['v']):$ret[0]['v']);
$a->config[$uid][$family][$key] = $val; $a->config[$uid][$family][$key] = $val;
// If APC is enabled then store the data there // If APC is enabled then store the data there, else try XCache
if (function_exists("apc_store")) if (function_exists("apc_store"))
apc_store($uid."|".$family."|".$key, $val, 600); apc_store($uid."|".$family."|".$key, $val, 600);
elseif (function_exists("xcache_set"))
xcache_set($uid."|".$family."|".$key, $val, 600);
return $val; return $val;
} }
else { else {
$a->config[$uid][$family][$key] = '!<unset>!'; $a->config[$uid][$family][$key] = '!<unset>!';
// If APC is enabled then store the data there // If APC is enabled then store the data there, else try XCache
if (function_exists("apc_store")) if (function_exists("apc_store"))
apc_store($uid."|".$family."|".$key, '!<unset>!', 600); apc_store($uid."|".$family."|".$key, '!<unset>!', 600);
elseif (function_exists("xcache_set"))
xcache_set($uid."|".$family."|".$key, '!<unset>!', 600);
} }
return false; return false;
}} }}
@ -238,13 +268,15 @@ function del_config($family,$key) {
global $a; global $a;
if(x($a->config[$family],$key)) if(x($a->config[$family],$key))
unset($a->config[$family][$key]); unset($a->config[$family][$key]);
$ret = q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1", $ret = q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s'",
dbesc($family), dbesc($family),
dbesc($key) dbesc($key)
); );
// If APC is enabled then store the data there // If APC is enabled then delete the data from there, else try XCache
if (function_exists("apc_delete")) if (function_exists("apc_delete"))
apc_delete($family."|".$key); apc_delete($family."|".$key);
elseif (function_exists("xcache_unset"))
xcache_unset($family."|".$key);
return $ret; return $ret;
}} }}
@ -274,7 +306,7 @@ function set_pconfig($uid,$family,$key,$value) {
return $value; return $value;
return $ret; return $ret;
} }
$ret = q("UPDATE `pconfig` SET `v` = '%s' WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1", $ret = q("UPDATE `pconfig` SET `v` = '%s' WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s'",
dbesc($dbvalue), dbesc($dbvalue),
intval($uid), intval($uid),
dbesc($family), dbesc($family),
@ -283,9 +315,11 @@ function set_pconfig($uid,$family,$key,$value) {
$a->config[$uid][$family][$key] = $value; $a->config[$uid][$family][$key] = $value;
// If APC is enabled then store the data there // If APC is enabled then store the data there, else try XCache
if (function_exists("apc_store")) if (function_exists("apc_store"))
apc_store($uid."|".$family."|".$key, $value, 600); apc_store($uid."|".$family."|".$key, $value, 600);
elseif (function_exists("xcache_set"))
xcache_set($uid."|".$family."|".$key, $value, 600);
if($ret) if($ret)
@ -299,7 +333,7 @@ function del_pconfig($uid,$family,$key) {
global $a; global $a;
if(x($a->config[$uid][$family],$key)) if(x($a->config[$uid][$family],$key))
unset($a->config[$uid][$family][$key]); unset($a->config[$uid][$family][$key]);
$ret = q("DELETE FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1", $ret = q("DELETE FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s'",
intval($uid), intval($uid),
dbesc($family), dbesc($family),
dbesc($key) dbesc($key)

View File

@ -491,7 +491,7 @@ function update_contact_birthdays() {
// update bdyear // update bdyear
q("UPDATE `contact` SET `bdyear` = '%s', `bd` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1", q("UPDATE `contact` SET `bdyear` = '%s', `bd` = '%s' WHERE `uid` = %d AND `id` = %d",
dbesc(substr($nextbd,0,4)), dbesc(substr($nextbd,0,4)),
dbesc($nextbd), dbesc($nextbd),
intval($rr['uid']), intval($rr['uid']),

View File

@ -18,6 +18,7 @@ class dba {
private $debug = 0; private $debug = 0;
private $db; private $db;
private $result;
public $mysqli = true; public $mysqli = true;
public $connected = false; public $connected = false;
public $error = false; public $error = false;
@ -75,7 +76,7 @@ class dba {
return $this->db; return $this->db;
} }
public function q($sql) { public function q($sql, $onlyquery = false) {
global $a; global $a;
if((! $this->db) || (! $this->connected)) if((! $this->db) || (! $this->connected))
@ -154,6 +155,11 @@ class dba {
if(($result === true) || ($result === false)) if(($result === true) || ($result === false))
return $result; return $result;
if ($onlyquery) {
$this->result = $result;
return true;
}
$r = array(); $r = array();
if($this->mysqli) { if($this->mysqli) {
if($result->num_rows) { if($result->num_rows) {
@ -177,6 +183,30 @@ class dba {
return($r); return($r);
} }
public function qfetch() {
$x = false;
if ($this->result)
if($this->mysqli) {
if($this->result->num_rows)
$x = $this->result->fetch_array(MYSQLI_ASSOC);
} else {
if(mysql_num_rows($this->result))
$x = mysql_fetch_array($this->result, MYSQL_ASSOC);
}
return($x);
}
public function qclose() {
if ($this->result)
if($this->mysqli) {
$this->result->free_result();
} else {
mysql_free_result($this->result);
}
}
public function dbg($dbg) { public function dbg($dbg) {
$this->debug = $dbg; $this->debug = $dbg;
} }

View File

@ -157,7 +157,7 @@ function delivery_run(&$argv, &$argc){
$r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`, $r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
`user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, `user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`,
`user`.`page-flags`, `user`.`prvnets` `user`.`page-flags`, `user`.`prvnets`
FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1", WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
intval($uid) intval($uid)
); );
@ -319,7 +319,7 @@ function delivery_run(&$argv, &$argc){
`contact`.`name` as `senderName`, `contact`.`name` as `senderName`,
`user`.* `user`.*
FROM `contact` FROM `contact`
LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`
WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0 WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `contact`.`network` = '%s' AND `user`.`nickname` = '%s' AND `contact`.`network` = '%s' AND `user`.`nickname` = '%s'
$sql_extra $sql_extra
@ -366,7 +366,6 @@ function delivery_run(&$argv, &$argc){
break; break;
case NETWORK_OSTATUS : case NETWORK_OSTATUS :
// Do not send to otatus if we are not configured to send to public networks // Do not send to otatus if we are not configured to send to public networks
if($owner['prvnets']) if($owner['prvnets'])
break; break;

View File

@ -7,6 +7,46 @@ require_once('include/contact_selectors.php');
require_once('include/queue_fn.php'); require_once('include/queue_fn.php');
require_once('include/lock.php'); require_once('include/lock.php');
function diaspora_add_page_info($url) {
require_once("mod/parse_url.php");
$data = parseurl_getsiteinfo($url, true);
logger('diaspora_add_page_info: fetch page info for '.$url.' '.print_r($data, true), LOGGER_DATA);
if (($data["type"] != "link") OR ($data["title"] == $url))
return("");
if (is_string($data["title"]))
$text .= "[bookmark=".$url."]".trim($data["title"])."[/bookmark]";
if (sizeof($data["images"]) > 0) {
$imagedata = $data["images"][0];
$text .= '[img]'.$imagedata["src"].'[/img]';
}
if (is_string($data["text"]))
$text .= "[quote]".$data["text"]."[/quote]";
return("\n[class=type-".$data["type"]."]".$text."[/class]");
}
function diaspora_add_page_info_to_body($body) {
logger('diaspora_add_page_info_to_body: fetch page info for body '.$body, LOGGER_DATA);
$URLSearchString = "^\[\]";
// Adding these spaces is a quick hack due to my problems with regular expressions :)
preg_match("/[^@#]\[url\]([$URLSearchString]*)\[\/url\]/ism", " ".$body, $matches);
if (!$matches)
preg_match("/[^@#]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", " ".$body, $matches);
if ($matches)
$body .= diaspora_add_page_info($matches[1]);
return $body;
}
function diaspora_dispatch_public($msg) { function diaspora_dispatch_public($msg) {
@ -578,7 +618,7 @@ function diaspora_request($importer,$xml) {
// That makes us friends. // That makes us friends.
if($contact['rel'] == CONTACT_IS_FOLLOWER && $importer['page-flags'] != PAGE_COMMUNITY) { if($contact['rel'] == CONTACT_IS_FOLLOWER && $importer['page-flags'] != PAGE_COMMUNITY) {
q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1", q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d",
intval(CONTACT_IS_FRIEND), intval(CONTACT_IS_FRIEND),
intval($contact['id']), intval($contact['id']),
intval($importer['uid']) intval($importer['uid'])
@ -733,7 +773,7 @@ function diaspora_request($importer,$xml) {
`avatar-date` = '%s', `avatar-date` = '%s',
`blocked` = 0, `blocked` = 0,
`pending` = 0 `pending` = 0
WHERE `id` = %d LIMIT 1 WHERE `id` = %d
", ",
dbesc($photos[0]), dbesc($photos[0]),
dbesc($photos[1]), dbesc($photos[1]),
@ -759,7 +799,7 @@ function diaspora_post_allow($importer,$contact) {
// That makes us friends. // That makes us friends.
// Normally this should have handled by getting a request - but this could get lost // Normally this should have handled by getting a request - but this could get lost
if($contact['rel'] == CONTACT_IS_FOLLOWER && $importer['page-flags'] != PAGE_COMMUNITY) { if($contact['rel'] == CONTACT_IS_FOLLOWER && $importer['page-flags'] != PAGE_COMMUNITY) {
q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1", q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d",
intval(CONTACT_IS_FRIEND), intval(CONTACT_IS_FRIEND),
intval($contact['id']), intval($contact['id']),
intval($importer['uid']) intval($importer['uid'])
@ -827,6 +867,9 @@ function diaspora_post($importer,$xml,$msg) {
$body = diaspora2bb($xml->raw_message); $body = diaspora2bb($xml->raw_message);
// Add OEmbed and other information to the body
$body = diaspora_add_page_info_to_body($body);
$datarray = array(); $datarray = array();
$str_tags = ''; $str_tags = '';
@ -873,7 +916,7 @@ function diaspora_post($importer,$xml,$msg) {
$datarray['network'] = NETWORK_DIASPORA; $datarray['network'] = NETWORK_DIASPORA;
$datarray['guid'] = $guid; $datarray['guid'] = $guid;
$datarray['uri'] = $datarray['parent-uri'] = $message_id; $datarray['uri'] = $datarray['parent-uri'] = $message_id;
$datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created); $datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created);
$datarray['private'] = $private; $datarray['private'] = $private;
$datarray['parent'] = 0; $datarray['parent'] = 0;
$datarray['plink'] = $plink; $datarray['plink'] = $plink;
@ -895,7 +938,7 @@ function diaspora_post($importer,$xml,$msg) {
$message_id = item_store($datarray); $message_id = item_store($datarray);
//if($message_id) { //if($message_id) {
// q("update item set plink = '%s' where id = %d limit 1", // q("update item set plink = '%s' where id = %d",
// dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id), // dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
// intval($message_id) // intval($message_id)
// ); // );
@ -966,18 +1009,36 @@ function diaspora_reshare($importer,$xml,$msg) {
} }
elseif($source_xml->post->status_message) { elseif($source_xml->post->status_message) {
$body = diaspora2bb($source_xml->post->status_message->raw_message); $body = diaspora2bb($source_xml->post->status_message->raw_message);
// Checking for embedded pictures
if($source_xml->post->status_message->photo->remote_photo_path AND
$source_xml->post->status_message->photo->remote_photo_name) {
$remote_photo_path = notags(unxmlify($source_xml->post->status_message->photo->remote_photo_path));
$remote_photo_name = notags(unxmlify($source_xml->post->status_message->photo->remote_photo_name));
$body = '[img]'.$remote_photo_path.$remote_photo_name.'[/img]'."\n".$body;
logger('diaspora_reshare: embedded picture link found: '.$body, LOGGER_DEBUG);
}
$body = scale_external_images($body); $body = scale_external_images($body);
// Add OEmbed and other information to the body
$body = diaspora_add_page_info_to_body($body);
} }
else { else {
// Maybe it is a reshare of a photo that will be delivered at a later time (testing)
logger('diaspora_reshare: no reshare content found: ' . print_r($source_xml,true)); logger('diaspora_reshare: no reshare content found: ' . print_r($source_xml,true));
return; $body = "";
} //return;
if(! $body) {
logger('diaspora_reshare: empty body: source= ' . $x);
return;
} }
//if(! $body) {
// logger('diaspora_reshare: empty body: source= ' . $x);
// return;
//}
$person = find_diaspora_person_by_handle($orig_author); $person = find_diaspora_person_by_handle($orig_author);
/*if(is_array($person) && x($person,'name') && x($person,'url')) /*if(is_array($person) && x($person,'name') && x($person,'url'))
@ -1041,7 +1102,7 @@ function diaspora_reshare($importer,$xml,$msg) {
$datarray['network'] = NETWORK_DIASPORA; $datarray['network'] = NETWORK_DIASPORA;
$datarray['guid'] = $guid; $datarray['guid'] = $guid;
$datarray['uri'] = $datarray['parent-uri'] = $message_id; $datarray['uri'] = $datarray['parent-uri'] = $message_id;
$datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created); $datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created);
$datarray['private'] = $private; $datarray['private'] = $private;
$datarray['parent'] = 0; $datarray['parent'] = 0;
$datarray['plink'] = $plink; $datarray['plink'] = $plink;
@ -1068,10 +1129,13 @@ function diaspora_reshare($importer,$xml,$msg) {
$datarray['tag'] = $str_tags; $datarray['tag'] = $str_tags;
$datarray['app'] = 'Diaspora'; $datarray['app'] = 'Diaspora';
// if empty content it might be a photo that hasn't arrived yet. If a photo arrives, we'll make it visible. (testing)
$datarray['visible'] = ((strlen($body)) ? 1 : 0);
$message_id = item_store($datarray); $message_id = item_store($datarray);
//if($message_id) { //if($message_id) {
// q("update item set plink = '%s' where id = %d limit 1", // q("update item set plink = '%s' where id = %d",
// dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id), // dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
// intval($message_id) // intval($message_id)
// ); // );
@ -1152,7 +1216,7 @@ function diaspora_asphoto($importer,$xml,$msg) {
$datarray['network'] = NETWORK_DIASPORA; $datarray['network'] = NETWORK_DIASPORA;
$datarray['guid'] = $guid; $datarray['guid'] = $guid;
$datarray['uri'] = $datarray['parent-uri'] = $message_id; $datarray['uri'] = $datarray['parent-uri'] = $message_id;
$datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created); $datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created);
$datarray['private'] = $private; $datarray['private'] = $private;
$datarray['parent'] = 0; $datarray['parent'] = 0;
$datarray['plink'] = $plink; $datarray['plink'] = $plink;
@ -1170,7 +1234,7 @@ function diaspora_asphoto($importer,$xml,$msg) {
$message_id = item_store($datarray); $message_id = item_store($datarray);
//if($message_id) { //if($message_id) {
// q("update item set plink = '%s' where id = %d limit 1", // q("update item set plink = '%s' where id = %d",
// dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id), // dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
// intval($message_id) // intval($message_id)
// ); // );
@ -1286,7 +1350,6 @@ function diaspora_comment($importer,$xml,$msg) {
} }
$body = diaspora2bb($text); $body = diaspora2bb($text);
$message_id = $diaspora_handle . ':' . $guid; $message_id = $diaspora_handle . ':' . $guid;
$datarray = array(); $datarray = array();
@ -1330,7 +1393,7 @@ function diaspora_comment($importer,$xml,$msg) {
$datarray['parent-uri'] = $parent_item['uri']; $datarray['parent-uri'] = $parent_item['uri'];
// No timestamps for comments? OK, we'll the use current time. // No timestamps for comments? OK, we'll the use current time.
$datarray['created'] = $datarray['edited'] = datetime_convert(); $datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert();
$datarray['private'] = $parent_item['private']; $datarray['private'] = $parent_item['private'];
$datarray['owner-name'] = $parent_item['owner-name']; $datarray['owner-name'] = $parent_item['owner-name'];
@ -1350,7 +1413,7 @@ function diaspora_comment($importer,$xml,$msg) {
$message_id = item_store($datarray); $message_id = item_store($datarray);
if($message_id) { if($message_id) {
q("update item set plink = '%s' where id = %d limit 1", q("update item set plink = '%s' where id = %d",
dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id), dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
intval($message_id) intval($message_id)
); );
@ -1561,7 +1624,7 @@ function diaspora_conversation($importer,$xml,$msg) {
dbesc($msg_created_at) dbesc($msg_created_at)
); );
q("update conv set updated = '%s' where id = %d limit 1", q("update conv set updated = '%s' where id = %d",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($conversation['id']) intval($conversation['id'])
); );
@ -1674,7 +1737,7 @@ function diaspora_message($importer,$xml,$msg) {
dbesc($msg_created_at) dbesc($msg_created_at)
); );
q("update conv set updated = '%s' where id = %d limit 1", q("update conv set updated = '%s' where id = %d",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($conversation['id']) intval($conversation['id'])
); );
@ -1740,7 +1803,7 @@ function diaspora_photo($importer,$xml,$msg,$attempt=1) {
array($remote_photo_name, 'scaled_full_' . $remote_photo_name)); array($remote_photo_name, 'scaled_full_' . $remote_photo_name));
if(strpos($parent_item['body'],$link_text) === false) { if(strpos($parent_item['body'],$link_text) === false) {
$r = q("update item set `body` = '%s', `visible` = 1 where `id` = %d and `uid` = %d limit 1", $r = q("update item set `body` = '%s', `visible` = 1 where `id` = %d and `uid` = %d",
dbesc($link_text . $parent_item['body']), dbesc($link_text . $parent_item['body']),
intval($parent_item['id']), intval($parent_item['id']),
intval($parent_item['uid']) intval($parent_item['uid'])
@ -1805,7 +1868,7 @@ function diaspora_like($importer,$xml,$msg) {
// It looks like "RelayableRetractions" are used for "unlike" instead // It looks like "RelayableRetractions" are used for "unlike" instead
if($positive === 'false') { if($positive === 'false') {
logger('diaspora_like: received a like with positive set to "false"...ignoring'); logger('diaspora_like: received a like with positive set to "false"...ignoring');
/* q("UPDATE `item` SET `deleted` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1", /* q("UPDATE `item` SET `deleted` = 1 WHERE `id` = %d AND `uid` = %d",
intval($r[0]['id']), intval($r[0]['id']),
intval($importer['uid']) intval($importer['uid'])
);*/ );*/
@ -1942,7 +2005,7 @@ EOT;
if($message_id) { if($message_id) {
q("update item set plink = '%s' where id = %d limit 1", q("update item set plink = '%s' where id = %d",
dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id), dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
intval($message_id) intval($message_id)
); );
@ -1989,7 +2052,7 @@ function diaspora_retraction($importer,$xml) {
); );
if(count($r)) { if(count($r)) {
if(link_compare($r[0]['author-link'],$contact['url'])) { if(link_compare($r[0]['author-link'],$contact['url'])) {
q("update item set `deleted` = 1, `changed` = '%s' where `id` = %d limit 1", q("update item set `deleted` = 1, `changed` = '%s' where `id` = %d",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($r[0]['id']) intval($r[0]['id'])
); );
@ -2060,7 +2123,7 @@ function diaspora_signed_retraction($importer,$xml,$msg) {
); );
if(count($r)) { if(count($r)) {
if(link_compare($r[0]['author-link'],$contact['url'])) { if(link_compare($r[0]['author-link'],$contact['url'])) {
q("update item set `deleted` = 1, `edited` = '%s', `changed` = '%s', `body` = '' , `title` = '' where `id` = %d limit 1", q("update item set `deleted` = 1, `edited` = '%s', `changed` = '%s', `body` = '' , `title` = '' where `id` = %d",
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($r[0]['id']) intval($r[0]['id'])
@ -2161,7 +2224,7 @@ function diaspora_profile($importer,$xml,$msg) {
// TODO: update name on item['author-name'] if the name changed. See consume_feed() // TODO: update name on item['author-name'] if the name changed. See consume_feed()
// Not doing this currently because D* protocol is scheduled for revision soon. // Not doing this currently because D* protocol is scheduled for revision soon.
$r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' , `bd` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' , `bd` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc($name), dbesc($name),
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc($images[0]), dbesc($images[0]),

View File

@ -331,7 +331,7 @@ function notification($params) {
); );
if($p && (count($p) > 1)) { if($p && (count($p) > 1)) {
for ($d = 1; $d < count($p); $d ++) { for ($d = 1; $d < count($p); $d ++) {
q("delete from notify where id = %d limit 1", q("delete from notify where id = %d",
intval($p[$d]['id']) intval($p[$d]['id'])
); );
} }
@ -353,7 +353,7 @@ function notification($params) {
$itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id; $itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id;
$msg = replace_macros($epreamble,array('$itemlink' => $itemlink)); $msg = replace_macros($epreamble,array('$itemlink' => $itemlink));
$r = q("update notify set msg = '%s' where id = %d and uid = %d limit 1", $r = q("update notify set msg = '%s' where id = %d and uid = %d",
dbesc($msg), dbesc($msg),
intval($notify_id), intval($notify_id),
intval($params['uid']) intval($params['uid'])

View File

@ -263,7 +263,7 @@ function event_store($arr) {
`allow_gid` = '%s', `allow_gid` = '%s',
`deny_cid` = '%s', `deny_cid` = '%s',
`deny_gid` = '%s' `deny_gid` = '%s'
WHERE `id` = %d AND `uid` = %d LIMIT 1", WHERE `id` = %d AND `uid` = %d",
dbesc($arr['edited']), dbesc($arr['edited']),
dbesc($arr['start']), dbesc($arr['start']),
@ -291,7 +291,7 @@ function event_store($arr) {
$object .= '</object>' . "\n"; $object .= '</object>' . "\n";
q("UPDATE `item` SET `body` = '%s', `object` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `edited` = '%s', `private` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", q("UPDATE `item` SET `body` = '%s', `object` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `edited` = '%s', `private` = %d WHERE `id` = %d AND `uid` = %d",
dbesc(format_event_bbcode($arr)), dbesc(format_event_bbcode($arr)),
dbesc($object), dbesc($object),
dbesc($arr['allow_cid']), dbesc($arr['allow_cid']),
@ -390,7 +390,7 @@ function event_store($arr) {
if($item_id) { if($item_id) {
q("UPDATE `item` SET `plink` = '%s', `event-id` = %d WHERE `uid` = %d AND `id` = %d LIMIT 1", q("UPDATE `item` SET `plink` = '%s', `event-id` = %d WHERE `uid` = %d AND `id` = %d",
dbesc($plink), dbesc($plink),
intval($event['id']), intval($event['id']),
intval($arr['uid']), intval($arr['uid']),

50
include/files.php Normal file
View File

@ -0,0 +1,50 @@
<?php
function create_files_from_item($itemid) {
global $a;
$messages = q("SELECT `guid`, `uid`, `id`, `edited`, `deleted`, `file`, `parent` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));
if (!$messages)
return;
$message = $messages[0];
// Clean up all tags
q("DELETE FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d)",
intval(TERM_OBJ_POST),
intval($itemid),
intval(TERM_FILE),
intval(TERM_CATEGORY));
if ($message["deleted"])
return;
if (preg_match_all("/\[(.*?)\]/ism", $message["file"], $files))
foreach ($files[1] as $file)
$r = q("INSERT INTO `term` (`uid`, `oid`, `otype`, `type`, `term`) VALUES (%d, %d, %d, %d, '%s')",
intval($message["uid"]), intval($itemid), intval(TERM_OBJ_POST), intval(TERM_FILE), dbesc($file));
if (preg_match_all("/\<(.*?)\>/ism", $message["file"], $files))
foreach ($files[1] as $file)
$r = q("INSERT INTO `term` (`uid`, `oid`, `otype`, `type`, `term`) VALUES (%d, %d, %d, %d, '%s')",
intval($message["uid"]), intval($itemid), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), dbesc($file));
}
function create_files_from_itemuri($itemuri, $uid) {
$messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
if(count($messages)) {
foreach ($messages as $message)
create_files_from_item($message["id"]);
}
}
function update_files_for_items() {
$messages = q("SELECT `id` FROM `item` where file !=''");
foreach ($messages as $message) {
echo $message["id"]."\n";
create_files_from_item($message["id"]);
}
}
?>

View File

@ -129,7 +129,7 @@ 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 , `subhub` = %d, `readonly` = 0 WHERE `id` = %d AND `uid` = %d",
intval(CONTACT_IS_FRIEND), intval(CONTACT_IS_FRIEND),
intval($subhub), intval($subhub),
intval($r[0]['id']), intval($r[0]['id']),
@ -228,7 +228,7 @@ function new_contact($uid,$url,$interactive = false) {
`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
", ",
dbesc($photos[0]), dbesc($photos[0]),
dbesc($photos[1]), dbesc($photos[1]),
@ -262,7 +262,7 @@ function new_contact($uid,$url,$interactive = false) {
'$ostat_follow' => '' '$ostat_follow' => ''
)); ));
$r = q("SELECT `contact`.*, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid` $r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`
WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1", WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
intval($uid) intval($uid)
); );

View File

@ -18,7 +18,7 @@ function group_add($uid,$name) {
intval($r) intval($r)
); );
if(count($z) && $z[0]['deleted']) { if(count($z) && $z[0]['deleted']) {
$r = q("UPDATE `group` SET `deleted` = 0 WHERE `uid` = %d AND `name` = '%s' LIMIT 1", $r = q("UPDATE `group` SET `deleted` = 0 WHERE `uid` = %d AND `name` = '%s'",
intval($uid), intval($uid),
dbesc($name) dbesc($name)
); );
@ -87,7 +87,7 @@ function group_rmv($uid,$name) {
); );
// remove group // remove group
$r = q("UPDATE `group` SET `deleted` = 1 WHERE `uid` = %d AND `name` = '%s' LIMIT 1", $r = q("UPDATE `group` SET `deleted` = 1 WHERE `uid` = %d AND `name` = '%s'",
intval($uid), intval($uid),
dbesc($name) dbesc($name)
); );
@ -117,7 +117,7 @@ function group_rmv_member($uid,$name,$member) {
return false; return false;
if(! ( $uid && $gid && $member)) if(! ( $uid && $gid && $member))
return false; return false;
$r = q("DELETE FROM `group_member` WHERE `uid` = %d AND `gid` = %d AND `contact-id` = %d LIMIT 1 ", $r = q("DELETE FROM `group_member` WHERE `uid` = %d AND `gid` = %d AND `contact-id` = %d",
intval($uid), intval($uid),
intval($gid), intval($gid),
intval($member) intval($member)
@ -157,7 +157,7 @@ function group_get_members($gid) {
$ret = array(); $ret = array();
if(intval($gid)) { if(intval($gid)) {
$r = q("SELECT `group_member`.`contact-id`, `contact`.* FROM `group_member` $r = q("SELECT `group_member`.`contact-id`, `contact`.* FROM `group_member`
LEFT JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id`
WHERE `gid` = %d AND `group_member`.`uid` = %d ORDER BY `contact`.`name` ASC ", WHERE `gid` = %d AND `group_member`.`uid` = %d ORDER BY `contact`.`name` ASC ",
intval($gid), intval($gid),
intval(local_user()) intval(local_user())
@ -172,7 +172,7 @@ function group_public_members($gid) {
$ret = 0; $ret = 0;
if(intval($gid)) { if(intval($gid)) {
$r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member` $r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member`
LEFT JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id`
WHERE `gid` = %d AND `group_member`.`uid` = %d WHERE `gid` = %d AND `group_member`.`uid` = %d
AND `contact`.`network` = '%s' AND `contact`.`notify` != '' ", AND `contact`.`network` = '%s' AND `contact`.`notify` != '' ",
intval($gid), intval($gid),
@ -299,7 +299,7 @@ function expand_groups($a,$check_dead = false) {
function member_of($c) { function member_of($c) {
$r = q("SELECT `group`.`name`, `group`.`id` FROM `group` LEFT JOIN `group_member` ON `group_member`.`gid` = `group`.`id` WHERE `group_member`.`contact-id` = %d AND `group`.`deleted` = 0 ORDER BY `group`.`name` ASC ", $r = q("SELECT `group`.`name`, `group`.`id` FROM `group` INNER JOIN `group_member` ON `group_member`.`gid` = `group`.`id` WHERE `group_member`.`contact-id` = %d AND `group`.`deleted` = 0 ORDER BY `group`.`name` ASC ",
intval($c) intval($c)
); );

View File

@ -221,9 +221,10 @@ function html2plain($html, $wraplength = 75, $compact = false)
if (!$compact AND ($message != "")) { if (!$compact AND ($message != "")) {
$counter = 1; $counter = 1;
foreach ($urls as $id=>$url) foreach ($urls as $id=>$url)
if (strpos($message, $url) === false) if ($url != "")
$message .= "\n".$url." "; if (strpos($message, $url) === false)
//$message .= "\n[".($counter++)."] ".$url; $message .= "\n".$url." ";
//$message .= "\n[".($counter++)."] ".$url;
} }
$message = str_replace("\n«", "«\n", $message); $message = str_replace("\n«", "«\n", $message);

View File

@ -6,9 +6,11 @@ require_once('include/salmon.php');
require_once('include/crypto.php'); require_once('include/crypto.php');
require_once('include/Photo.php'); require_once('include/Photo.php');
require_once('include/tags.php'); require_once('include/tags.php');
require_once('include/files.php');
require_once('include/text.php'); require_once('include/text.php');
require_once('include/email.php'); require_once('include/email.php');
require_once('include/ostatus_conversation.php'); require_once('include/ostatus_conversation.php');
require_once('include/threads.php');
function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) { function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) {
@ -36,7 +38,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
$sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' "; $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' ";
$r = q("SELECT `contact`.*, `user`.`uid` AS `user_uid`, `user`.`nickname`, `user`.`timezone`, `user`.`page-flags` $r = q("SELECT `contact`.*, `user`.`uid` AS `user_uid`, `user`.`nickname`, `user`.`timezone`, `user`.`page-flags`
FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
WHERE `contact`.`self` = 1 AND `user`.`nickname` = '%s' LIMIT 1", WHERE `contact`.`self` = 1 AND `user`.`nickname` = '%s' LIMIT 1",
dbesc($owner_nick) dbesc($owner_nick)
); );
@ -50,6 +52,8 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
$birthday = feed_birthday($owner_id,$owner['timezone']); $birthday = feed_birthday($owner_id,$owner['timezone']);
$sql_post_table = "";
if(! $public_feed) { if(! $public_feed) {
$sql_extra = ''; $sql_extra = '';
@ -112,7 +116,9 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
$last_update = 'now -30 days'; $last_update = 'now -30 days';
if(isset($category)) { if(isset($category)) {
$sql_extra .= file_tag_file_query('item',$category,'category'); $sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
dbesc(protect_sprintf($category)), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), intval($owner_id));
//$sql_extra .= file_tag_file_query('item',$category,'category');
} }
if($public_feed) { if($public_feed) {
@ -122,22 +128,25 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
$check_date = datetime_convert('UTC','UTC',$last_update,'Y-m-d H:i:s'); $check_date = datetime_convert('UTC','UTC',$last_update,'Y-m-d H:i:s');
// AND ( `item`.`edited` > '%s' OR `item`.`changed` > '%s' )
// dbesc($check_date),
$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` $sql_post_table
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`parent` != 0 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`parent` != 0
AND `item`.`wall` = 1 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `item`.`wall` = 1 AND `item`.`changed` > '%s'
AND ( `item`.`edited` > '%s' OR `item`.`changed` > '%s' )
$sql_extra $sql_extra
ORDER BY `parent` %s, `created` ASC LIMIT 0, 300", ORDER BY `parent` %s, `created` ASC LIMIT 0, 300",
intval($owner_id), intval($owner_id),
dbesc($check_date), dbesc($check_date),
dbesc($check_date),
dbesc($sort) dbesc($sort)
); );
@ -1089,6 +1098,20 @@ function item_store($arr,$force_parent = false) {
if((intval($r[0]['forum_mode']) == 1) && (! $r[0]['private'])) if((intval($r[0]['forum_mode']) == 1) && (! $r[0]['private']))
$arr['private'] = 0; $arr['private'] = 0;
// If its a post from myself then tag the thread as "mention"
logger("item_store: Checking if parent ".$parent_id." has to be tagged as mention for user ".$arr['uid'], LOGGER_DEBUG);
$u = q("select * from user where uid = %d limit 1", intval($arr['uid']));
if(count($u)) {
$a = get_app();
$self = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']);
logger("item_store: 'myself' is ".$self." for parent ".$parent_id." checking against ".$arr['author-link']." and ".$arr['owner-link'], LOGGER_DEBUG);
if ((normalise_link($arr['author-link']) == $self) OR (normalise_link($arr['owner-link']) == $self)) {
q("UPDATE `thread` SET `mention` = 1 WHERE `iid` = %d", intval($parent_id));
logger("item_store: tagged thread ".$parent_id." as mention for user ".$self, LOGGER_DEBUG);
}
}
} }
else { else {
@ -1146,10 +1169,10 @@ function item_store($arr,$force_parent = false) {
if(count($r)) { if(count($r)) {
$current_post = $r[0]['id']; $current_post = $r[0]['id'];
logger('item_store: created item ' . $current_post); logger('item_store: created item ' . $current_post);
create_tags_from_item($r[0]['id']);
// Only check for notifications on start posts // Only check for notifications on start posts
if ($arr['parent-uri'] === $arr['uri']) { if ($arr['parent-uri'] === $arr['uri']) {
add_thread($r[0]['id']);
logger('item_store: Check notification for contact '.$arr['contact-id'].' and post '.$current_post, LOGGER_DEBUG); logger('item_store: Check notification for contact '.$arr['contact-id'].' and post '.$current_post, LOGGER_DEBUG);
// Send a notification for every new post? // Send a notification for every new post?
@ -1224,7 +1247,6 @@ function item_store($arr,$force_parent = false) {
intval($parent_deleted), intval($parent_deleted),
intval($current_post) intval($current_post)
); );
create_tags_from_item($current_post);
// Complete ostatus threads // Complete ostatus threads
if ($ostatus_conversation) if ($ostatus_conversation)
@ -1246,6 +1268,7 @@ function item_store($arr,$force_parent = false) {
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($parent_id) intval($parent_id)
); );
update_thread($parent_id);
if($dsprsig) { if($dsprsig) {
q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
@ -1287,17 +1310,20 @@ function item_store($arr,$force_parent = false) {
logger('item_store: put item '.$current_post.' into cachefile '.$cachefile); logger('item_store: put item '.$current_post.' into cachefile '.$cachefile);
} }
$r = q('SELECT * FROM `item` WHERE id = %d', intval($current_post)); $r = q('SELECT * FROM `item` WHERE id = %d', intval($current_post));
if (count($r) == 1) { if (count($r) == 1) {
call_hooks('post_remote_end', $r[0]); call_hooks('post_remote_end', $r[0]);
} } else {
else { logger('item_store: new item not found in DB, id ' . $current_post);
logger('item_store: new item not found in DB, id ' . $current_post); }
}
} }
create_tags_from_item($current_post);
create_files_from_item($current_post);
return $current_post; return $current_post;
} }
// return - test
function get_item_contact($item,$contacts) { function get_item_contact($item,$contacts) {
if(! count($contacts) || (! is_array($item))) if(! count($contacts) || (! is_array($item)))
return false; return false;
@ -1448,6 +1474,7 @@ function tag_deliver($uid,$item_id) {
dbesc($u[0]['deny_gid']), dbesc($u[0]['deny_gid']),
intval($item_id) intval($item_id)
); );
update_thread($item_id);
proc_run('php','include/notifier.php','tgroup',$item_id); proc_run('php','include/notifier.php','tgroup',$item_id);
@ -1965,7 +1992,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
$when = datetime_convert('UTC','UTC','now','Y-m-d H:i:s'); $when = datetime_convert('UTC','UTC','now','Y-m-d H:i:s');
} }
if($deleted && is_array($contact)) { if($deleted && is_array($contact)) {
$r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join `contact` on `item`.`contact-id` = `contact`.`id` $r = q("SELECT `item`.*, `contact`.`self` FROM `item` INNER JOIN `contact` on `item`.`contact-id` = `contact`.`id`
WHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d AND NOT `item`.`file` LIKE '%%[%%' LIMIT 1", WHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d AND NOT `item`.`file` LIKE '%%[%%' LIMIT 1",
dbesc($uri), dbesc($uri),
intval($importer['uid']), intval($importer['uid']),
@ -2023,6 +2050,8 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
intval($importer['uid']) intval($importer['uid'])
); );
create_tags_from_itemuri($item['uri'], $importer['uid']); create_tags_from_itemuri($item['uri'], $importer['uid']);
create_files_from_itemuri($item['uri'], $importer['uid']);
update_thread_uri($item['uri'], $importer['uid']);
} }
else { else {
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s', $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
@ -2034,6 +2063,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
intval($importer['uid']) intval($importer['uid'])
); );
create_tags_from_itemuri($uri, $importer['uid']); create_tags_from_itemuri($uri, $importer['uid']);
create_files_from_itemuri($uri, $importer['uid']);
if($item['last-child']) { if($item['last-child']) {
// ensure that last-child is set in case the comment that had it just got wiped. // ensure that last-child is set in case the comment that had it just got wiped.
q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ", q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
@ -2122,6 +2152,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
intval($importer['uid']) intval($importer['uid'])
); );
$datarray['last-child'] = 1; $datarray['last-child'] = 1;
update_thread_uri($parent_uri, $importer['uid']);
} }
@ -2139,15 +2170,17 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited']) if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited'])
continue; continue;
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d", $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s', `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
dbesc($datarray['title']), dbesc($datarray['title']),
dbesc($datarray['body']), dbesc($datarray['body']),
dbesc($datarray['tag']), dbesc($datarray['tag']),
dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
dbesc(datetime_convert()),
dbesc($item_id), dbesc($item_id),
intval($importer['uid']) intval($importer['uid'])
); );
create_tags_from_itemuri($item_id, $importer['uid']); create_tags_from_itemuri($item_id, $importer['uid']);
update_thread_uri($item_id, $importer['uid']);
} }
// update last-child if it changes // update last-child if it changes
@ -2165,6 +2198,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
dbesc($item_id), dbesc($item_id),
intval($importer['uid']) intval($importer['uid'])
); );
update_thread_uri($item_id, $importer['uid']);
} }
continue; continue;
} }
@ -2297,15 +2331,17 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited']) if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited'])
continue; continue;
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d", $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s', `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
dbesc($datarray['title']), dbesc($datarray['title']),
dbesc($datarray['body']), dbesc($datarray['body']),
dbesc($datarray['tag']), dbesc($datarray['tag']),
dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
dbesc(datetime_convert()),
dbesc($item_id), dbesc($item_id),
intval($importer['uid']) intval($importer['uid'])
); );
create_tags_from_itemuri($item_id, $importer['uid']); create_tags_from_itemuri($item_id, $importer['uid']);
update_thread_uri($item_id, $importer['uid']);
} }
// update last-child if it changes // update last-child if it changes
@ -2318,6 +2354,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
dbesc($item_id), dbesc($item_id),
intval($importer['uid']) intval($importer['uid'])
); );
update_thread_uri($item_id, $importer['uid']);
} }
continue; continue;
} }
@ -2556,65 +2593,65 @@ function local_delivery($importer,$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']));*/
logger("items:relocate contact ".print_r($newloc, true).print_r($importer, true), LOGGER_DEBUG); logger("items:relocate contact ".print_r($newloc, true).print_r($importer, true), LOGGER_DEBUG);
// update contact // update contact
$r = q("SELECT photo, url FROM contact WHERE id=%d AND uid=%d;", $r = q("SELECT photo, url FROM contact WHERE id=%d AND uid=%d;",
intval($importer['id']), intval($importer['id']),
intval($importer['importer_uid'])); intval($importer['importer_uid']));
if ($r === false) if ($r === false)
return 1; return 1;
$old = $r[0]; $old = $r[0];
$x = q("UPDATE contact SET $x = q("UPDATE contact SET
name = '%s', name = '%s',
photo = '%s', photo = '%s',
thumb = '%s', thumb = '%s',
micro = '%s', micro = '%s',
url = '%s', url = '%s',
request = '%s', request = '%s',
confirm = '%s', confirm = '%s',
notify = '%s', notify = '%s',
poll = '%s', poll = '%s',
`site-pubkey` = '%s' `site-pubkey` = '%s'
WHERE id=%d AND uid=%d;", WHERE id=%d AND uid=%d;",
dbesc($newloc['name']), dbesc($newloc['name']),
dbesc($newloc['photo']), dbesc($newloc['photo']),
dbesc($newloc['thumb']), dbesc($newloc['thumb']),
dbesc($newloc['micro']), dbesc($newloc['micro']),
dbesc($newloc['url']), dbesc($newloc['url']),
dbesc($newloc['request']), dbesc($newloc['request']),
dbesc($newloc['confirm']), dbesc($newloc['confirm']),
dbesc($newloc['notify']), dbesc($newloc['notify']),
dbesc($newloc['poll']), dbesc($newloc['poll']),
dbesc($newloc['sitepubkey']), dbesc($newloc['sitepubkey']),
intval($importer['id']), intval($importer['id']),
intval($importer['importer_uid'])); intval($importer['importer_uid']));
if ($x === false) if ($x === false)
return 1; return 1;
// update items // update items
$fields = array( $fields = array(
'owner-link' => array($old['url'], $newloc['url']), 'owner-link' => array($old['url'], $newloc['url']),
'author-link' => array($old['url'], $newloc['url']), 'author-link' => array($old['url'], $newloc['url']),
'owner-avatar' => array($old['photo'], $newloc['photo']), 'owner-avatar' => array($old['photo'], $newloc['photo']),
'author-avatar' => array($old['photo'], $newloc['photo']), 'author-avatar' => array($old['photo'], $newloc['photo']),
); );
foreach ($fields as $n=>$f){ foreach ($fields as $n=>$f){
$x = q("UPDATE item SET `%s`='%s' WHERE `%s`='%s' AND uid=%d", $x = q("UPDATE `item` SET `%s`='%s' WHERE `%s`='%s' AND uid=%d",
$n, dbesc($f[1]), $n, dbesc($f[1]),
$n, dbesc($f[0]), $n, dbesc($f[0]),
intval($importer['importer_uid'])); intval($importer['importer_uid']));
if ($x === false) if ($x === false)
return 1; return 1;
} }
// TODO // TODO
// merge with current record, current contents have priority // merge with current record, current contents have priority
// update record, set url-updated // update record, set url-updated
// update profile photos // update profile photos
// schedule a scan? // schedule a scan?
return 0; return 0;
} }
@ -2832,7 +2869,7 @@ function local_delivery($importer,$data) {
// POSSIBLE CLEANUP --> Why select so many fields when only forum_mode and wall are used? // POSSIBLE CLEANUP --> Why select so many fields when only forum_mode and wall are used?
$r = q("select `item`.`id`, `item`.`uri`, `item`.`tag`, `item`.`forum_mode`,`item`.`origin`,`item`.`wall`, $r = q("select `item`.`id`, `item`.`uri`, `item`.`tag`, `item`.`forum_mode`,`item`.`origin`,`item`.`wall`,
`contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item` `contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item`
LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uri` = '%s' AND (`item`.`parent-uri` = '%s' or `item`.`thr-parent` = '%s') WHERE `item`.`uri` = '%s' AND (`item`.`parent-uri` = '%s' or `item`.`thr-parent` = '%s')
AND `item`.`uid` = %d AND `item`.`uid` = %d
$sql_extra $sql_extra
@ -2862,7 +2899,7 @@ function local_delivery($importer,$data) {
} }
} }
$r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join contact on `item`.`contact-id` = `contact`.`id` $r = q("SELECT `item`.*, `contact`.`self` FROM `item` INNER JOIN contact on `item`.`contact-id` = `contact`.`id`
WHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d AND NOT `item`.`file` LIKE '%%[%%' LIMIT 1", WHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d AND NOT `item`.`file` LIKE '%%[%%' LIMIT 1",
dbesc($uri), dbesc($uri),
intval($importer['importer_uid']), intval($importer['importer_uid']),
@ -2924,6 +2961,8 @@ function local_delivery($importer,$data) {
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
create_tags_from_itemuri($item['uri'], $importer['importer_uid']); create_tags_from_itemuri($item['uri'], $importer['importer_uid']);
create_files_from_itemuri($item['uri'], $importer['importer_uid']);
update_thread_uri($item['uri'], $importer['importer_uid']);
} }
else { else {
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s', $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
@ -2935,6 +2974,8 @@ function local_delivery($importer,$data) {
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
create_tags_from_itemuri($uri, $importer['importer_uid']); create_tags_from_itemuri($uri, $importer['importer_uid']);
create_files_from_itemuri($uri, $importer['importer_uid']);
update_thread_uri($uri, $importer['importer_uid']);
if($item['last-child']) { if($item['last-child']) {
// ensure that last-child is set in case the comment that had it just got wiped. // ensure that last-child is set in case the comment that had it just got wiped.
q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ", q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
@ -3003,7 +3044,7 @@ function local_delivery($importer,$data) {
// POSSIBLE CLEANUP --> Why select so many fields when only forum_mode and wall are used? // POSSIBLE CLEANUP --> Why select so many fields when only forum_mode and wall are used?
$r = q("select `item`.`id`, `item`.`uri`, `item`.`tag`, `item`.`forum_mode`,`item`.`origin`,`item`.`wall`, $r = q("select `item`.`id`, `item`.`uri`, `item`.`tag`, `item`.`forum_mode`,`item`.`origin`,`item`.`wall`,
`contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item` `contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item`
LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uri` = '%s' AND (`item`.`parent-uri` = '%s' or `item`.`thr-parent` = '%s') WHERE `item`.`uri` = '%s' AND (`item`.`parent-uri` = '%s' or `item`.`thr-parent` = '%s')
AND `item`.`uid` = %d AND `item`.`uid` = %d
$sql_extra $sql_extra
@ -3052,11 +3093,12 @@ function local_delivery($importer,$data) {
continue; continue;
logger('received updated comment' , LOGGER_DEBUG); logger('received updated comment' , LOGGER_DEBUG);
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d", $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s', `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
dbesc($datarray['title']), dbesc($datarray['title']),
dbesc($datarray['body']), dbesc($datarray['body']),
dbesc($datarray['tag']), dbesc($datarray['tag']),
dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
dbesc(datetime_convert()),
dbesc($item_id), dbesc($item_id),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
@ -3138,9 +3180,10 @@ function local_delivery($importer,$data) {
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
if(count($i) && ! intval($i[0]['blocktags'])) { if(count($i) && ! intval($i[0]['blocktags'])) {
q("UPDATE item SET tag = '%s', `edited` = '%s' WHERE id = %d", q("UPDATE item SET tag = '%s', `edited` = '%s', `changed` = '%s' WHERE id = %d",
dbesc($tagp[0]['tag'] . (strlen($tagp[0]['tag']) ? ',' : '') . $newtag), dbesc($tagp[0]['tag'] . (strlen($tagp[0]['tag']) ? ',' : '') . $newtag),
intval($tagp[0]['id']), intval($tagp[0]['id']),
dbesc(datetime_convert()),
dbesc(datetime_convert()) dbesc(datetime_convert())
); );
create_tags_from_item($tagp[0]['id']); create_tags_from_item($tagp[0]['id']);
@ -3236,11 +3279,12 @@ function local_delivery($importer,$data) {
if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited']) if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited'])
continue; continue;
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d", $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s', `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
dbesc($datarray['title']), dbesc($datarray['title']),
dbesc($datarray['body']), dbesc($datarray['body']),
dbesc($datarray['tag']), dbesc($datarray['tag']),
dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
dbesc(datetime_convert()),
dbesc($item_id), dbesc($item_id),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
@ -3421,15 +3465,17 @@ function local_delivery($importer,$data) {
if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited']) if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited'])
continue; continue;
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d", $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s', `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
dbesc($datarray['title']), dbesc($datarray['title']),
dbesc($datarray['body']), dbesc($datarray['body']),
dbesc($datarray['tag']), dbesc($datarray['tag']),
dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
dbesc(datetime_convert()),
dbesc($item_id), dbesc($item_id),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
create_tags_from_itemuri($item_id, $importer['importer_uid']); create_tags_from_itemuri($item_id, $importer['importer_uid']);
update_thread_uri($item_id, $importer['importer_uid']);
} }
// update last-child if it changes // update last-child if it changes
@ -4154,6 +4200,8 @@ function drop_item($id,$interactive = true) {
intval($item['id']) intval($item['id'])
); );
create_tags_from_item($item['id']); create_tags_from_item($item['id']);
create_files_from_item($item['id']);
delete_thread($item['id']);
// clean up categories and tags so they don't end up as orphans // clean up categories and tags so they don't end up as orphans
@ -4248,6 +4296,8 @@ function drop_item($id,$interactive = true) {
intval($item['uid']) intval($item['uid'])
); );
create_tags_from_item($item['parent-uri'], $item['uid']); create_tags_from_item($item['parent-uri'], $item['uid']);
create_files_from_item($item['parent-uri'], $item['uid']);
delete_thread_uri($item['parent-uri'], $item['uid']);
// ignore the result // ignore the result
} }
else { else {

View File

@ -207,7 +207,7 @@ function notifier_run(&$argv, &$argc){
$r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`, $r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
`user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, `user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`,
`user`.`page-flags`, `user`.`prvnets` `user`.`page-flags`, `user`.`prvnets`
FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1", WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
intval($uid) intval($uid)
); );
@ -643,7 +643,7 @@ function notifier_run(&$argv, &$argc){
`contact`.`name` as `senderName`, `contact`.`name` as `senderName`,
`user`.* `user`.*
FROM `contact` FROM `contact`
LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`
WHERE `contact`.`blocked` = 0 AND `contact`.`archive` = 0 WHERE `contact`.`blocked` = 0 AND `contact`.`archive` = 0
AND `contact`.`pending` = 0 AND `contact`.`pending` = 0
AND `contact`.`network` = '%s' AND `user`.`nickname` = '%s' AND `contact`.`network` = '%s' AND `user`.`nickname` = '%s'
@ -656,7 +656,7 @@ function notifier_run(&$argv, &$argc){
if($x && count($x)) { if($x && count($x)) {
$write_flag = ((($x[0]['rel']) && ($x[0]['rel'] != CONTACT_IS_SHARING)) ? true : false); $write_flag = ((($x[0]['rel']) && ($x[0]['rel'] != CONTACT_IS_SHARING)) ? true : false);
if((($owner['page-flags'] == PAGE_COMMUNITY) || ($write_flag)) && (! $x[0]['writable'])) { if((($owner['page-flags'] == PAGE_COMMUNITY) || ($write_flag)) && (! $x[0]['writable'])) {
q("update contact set writable = 1 where id = %d limit 1", q("update contact set writable = 1 where id = %d",
intval($x[0]['id']) intval($x[0]['id'])
); );
$x[0]['writable'] = 1; $x[0]['writable'] = 1;
@ -696,6 +696,7 @@ function notifier_run(&$argv, &$argc){
// Do not send to ostatus if we are not configured to send to public networks // Do not send to ostatus if we are not configured to send to public networks
if($owner['prvnets']) if($owner['prvnets'])
break; break;
if(get_config('system','ostatus_disabled') || get_config('system','dfrn_only')) if(get_config('system','ostatus_disabled') || get_config('system','dfrn_only'))
break; break;
@ -707,8 +708,7 @@ function notifier_run(&$argv, &$argc){
// queue message for redelivery // queue message for redelivery
add_to_queue($contact['id'],NETWORK_OSTATUS,$slap); add_to_queue($contact['id'],NETWORK_OSTATUS,$slap);
} }
} } else {
else {
// only send salmon if public - e.g. if it's ok to notify // only send salmon if public - e.g. if it's ok to notify
// a public hub, it's ok to send a salmon // a public hub, it's ok to send a salmon

View File

@ -167,7 +167,7 @@ class FKOAuth1 extends OAuthServer {
$a->cid = $r[0]['id']; $a->cid = $r[0]['id'];
$_SESSION['cid'] = $a->cid; $_SESSION['cid'] = $a->cid;
} }
q("UPDATE `user` SET `login_date` = '%s' WHERE `uid` = %d LIMIT 1", q("UPDATE `user` SET `login_date` = '%s' WHERE `uid` = %d",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );

View File

@ -112,7 +112,7 @@ function onepoll_run(&$argv, &$argc){
$importer_uid = $contact['uid']; $importer_uid = $contact['uid'];
$r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` LEFT JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1", $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
intval($importer_uid) intval($importer_uid)
); );
if(! count($r)) if(! count($r))

View File

@ -44,6 +44,9 @@ function check_conversations() {
function complete_conversation($itemid, $conversation_url, $only_add_conversation = false) { function complete_conversation($itemid, $conversation_url, $only_add_conversation = false) {
global $a; global $a;
if (intval(get_config('system','ostatus_poll_interval')) == -2)
return;
if ($a->last_ostatus_conversation_url == $conversation_url) if ($a->last_ostatus_conversation_url == $conversation_url)
return; return;
@ -141,7 +144,7 @@ function complete_conversation($itemid, $conversation_url, $only_add_conversatio
if ($message_exists) { if ($message_exists) {
if ($parent["id"] != 0) { if ($parent["id"] != 0) {
$existing_message = $message_exists[0]; $existing_message = $message_exists[0];
$r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s', `thr-parent` = '%s' WHERE `id` = %d LIMIT 1", $r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s', `thr-parent` = '%s' WHERE `id` = %d",
intval($parent["id"]), intval($parent["id"]),
dbesc($parent["uri"]), dbesc($parent["uri"]),
dbesc($parent_uri), dbesc($parent_uri),

View File

@ -174,7 +174,7 @@ function poller_run(&$argv, &$argc){
: '' : ''
); );
$contacts = q("SELECT `contact`.`id` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` $contacts = q("SELECT `contact`.`id` FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != '' WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != ''
AND NOT `network` IN ( '%s', '%s', '%s' ) AND NOT `network` IN ( '%s', '%s', '%s' )
$sql_extra $sql_extra

View File

@ -25,7 +25,7 @@ function profile_change() {
return; return;
$r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile` $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `user`.* FROM `profile`
LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
WHERE `user`.`uid` = %d AND `profile`.`is-default` = 1 LIMIT 1", WHERE `user`.`uid` = %d AND `profile`.`is-default` = 1 LIMIT 1",
intval(local_user()) intval(local_user())
); );

View File

@ -79,10 +79,20 @@ function queue_run(&$argv, &$argc){
require_once("include/datetime.php"); require_once("include/datetime.php");
require_once('include/items.php'); require_once('include/items.php');
require_once('include/bbcode.php'); require_once('include/bbcode.php');
require_once('include/pidfile.php');
load_config('config'); load_config('config');
load_config('system'); load_config('system');
$lockpath = get_config('system','lockpath');
if ($lockpath != '') {
$pidfile = new pidfile($lockpath, 'queue.lck');
if($pidfile->is_already_running()) {
logger("queue: Already running");
return;
}
}
$a->set_baseurl(get_config('system','url')); $a->set_baseurl(get_config('system','url'));
load_hooks(); load_hooks();
@ -111,7 +121,7 @@ function queue_run(&$argv, &$argc){
} }
$r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue` $r = q("SELECT `queue`.*, `contact`.`name`, `contact`.`uid` FROM `queue`
LEFT JOIN `contact` ON `queue`.`cid` = `contact`.`id` INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY"); WHERE `queue`.`created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
if($r) { if($r) {
foreach($r as $rr) { foreach($r as $rr) {

View File

@ -2,7 +2,7 @@
function update_queue_time($id) { function update_queue_time($id) {
logger('queue: requeue item ' . $id); logger('queue: requeue item ' . $id);
q("UPDATE `queue` SET `last` = '%s' WHERE `id` = %d LIMIT 1", q("UPDATE `queue` SET `last` = '%s' WHERE `id` = %d",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($id) intval($id)
); );
@ -10,7 +10,7 @@ function update_queue_time($id) {
function remove_queue_item($id) { function remove_queue_item($id) {
logger('queue: remove queue item ' . $id); logger('queue: remove queue item ' . $id);
q("DELETE FROM `queue` WHERE `id` = %d LIMIT 1", q("DELETE FROM `queue` WHERE `id` = %d",
intval($id) intval($id)
); );
} }
@ -44,7 +44,7 @@ function add_to_queue($cid,$network,$msg,$batch = false) {
if($batch_queue < 1) if($batch_queue < 1)
$batch_queue = 1000; $batch_queue = 1000;
$r = q("SELECT COUNT(*) AS `total` FROM `queue` left join `contact` ON `queue`.`cid` = `contact`.`id` $r = q("SELECT COUNT(*) AS `total` FROM `queue` INNER JOIN `contact` ON `queue`.`cid` = `contact`.`id`
WHERE `queue`.`cid` = %d AND `contact`.`self` = 0 ", WHERE `queue`.`cid` = %d AND `contact`.`self` = 0 ",
intval($cid) intval($cid)
); );

View File

@ -56,7 +56,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
$a->identities = array(); $a->identities = array();
$r = q("select `user`.`uid`, `user`.`username`, `user`.`nickname` $r = q("select `user`.`uid`, `user`.`username`, `user`.`nickname`
from manage left join user on manage.mid = user.uid where `user`.`account_removed` = 0 from manage INNER JOIN user on manage.mid = user.uid where `user`.`account_removed` = 0
and `manage`.`uid` = %d", and `manage`.`uid` = %d",
intval($master_record['uid']) intval($master_record['uid'])
); );
@ -81,7 +81,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
if($login_initial || $login_refresh) { if($login_initial || $login_refresh) {
$l = get_browser_language(); $l = get_browser_language();
q("UPDATE `user` SET `login_date` = '%s', `language` = '%s' WHERE `uid` = %d LIMIT 1", q("UPDATE `user` SET `login_date` = '%s', `language` = '%s' WHERE `uid` = %d",
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc($l), dbesc($l),
intval($_SESSION['uid']) intval($_SESSION['uid'])
@ -139,7 +139,7 @@ function can_write_wall(&$a,$owner) {
return false; return false;
$r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` LEFT JOIN `user` on `user`.`uid` = `contact`.`uid` $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` INNER JOIN `user` on `user`.`uid` = `contact`.`uid`
WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `user`.`blockwall` = 0 AND `readonly` = 0 AND ( `contact`.`rel` IN ( %d , %d ) OR `user`.`page-flags` = %d ) LIMIT 1", AND `user`.`blockwall` = 0 AND `readonly` = 0 AND ( `contact`.`rel` IN ( %d , %d ) OR `user`.`page-flags` = %d ) LIMIT 1",
intval($owner), intval($owner),
@ -255,11 +255,11 @@ function item_permissions_sql($owner_id,$remote_verified = false,$groups = null)
* default permissions - anonymous user * default permissions - anonymous user
*/ */
$sql = " AND allow_cid = '' $sql = " AND `item`.allow_cid = ''
AND allow_gid = '' AND `item`.allow_gid = ''
AND deny_cid = '' AND `item`.deny_cid = ''
AND deny_gid = '' AND `item`.deny_gid = ''
AND private = 0 AND `item`.private = 0
"; ";
/** /**
@ -310,9 +310,9 @@ function item_permissions_sql($owner_id,$remote_verified = false,$groups = null)
dbesc($gs), dbesc($gs),
dbesc($gs) dbesc($gs)
*/ */
" AND ( private = 0 OR ( private in (1,2) AND wall = 1 " AND ( `item`.private = 0 OR ( `item`.private in (1,2) AND `item`.`wall` = 1
AND ( NOT (deny_cid REGEXP '<%d>' OR deny_gid REGEXP '%s') AND ( NOT (`item`.deny_cid REGEXP '<%d>' OR `item`.deny_gid REGEXP '%s')
AND ( allow_cid REGEXP '<%d>' OR allow_gid REGEXP '%s' OR ( allow_cid = '' AND allow_gid = ''))))) AND ( `item`.allow_cid REGEXP '<%d>' OR `item`.allow_gid REGEXP '%s' OR ( `item`.allow_cid = '' AND `item`.allow_gid = '')))))
", ",
intval($remote_user), intval($remote_user),
dbesc($gs), dbesc($gs),

View File

@ -170,7 +170,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
function count_common_friends($uid,$cid) { function count_common_friends($uid,$cid) {
$r = q("SELECT count(*) as `total` $r = q("SELECT count(*) as `total`
FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id` FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
where `glink`.`cid` = %d and `glink`.`uid` = %d where `glink`.`cid` = %d and `glink`.`uid` = %d
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 and id != %d ) ", and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 and id != %d ) ",
intval($cid), intval($cid),
@ -195,7 +195,7 @@ function common_friends($uid,$cid,$start = 0,$limit=9999,$shuffle = false) {
$sql_extra = " order by `gcontact`.`name` asc "; $sql_extra = " order by `gcontact`.`name` asc ";
$r = q("SELECT `gcontact`.* $r = q("SELECT `gcontact`.*
FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id` FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
where `glink`.`cid` = %d and `glink`.`uid` = %d where `glink`.`cid` = %d and `glink`.`uid` = %d
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 and id != %d ) and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 and id != %d )
$sql_extra limit %d, %d", $sql_extra limit %d, %d",
@ -215,7 +215,7 @@ function common_friends($uid,$cid,$start = 0,$limit=9999,$shuffle = false) {
function count_common_friends_zcid($uid,$zcid) { function count_common_friends_zcid($uid,$zcid) {
$r = q("SELECT count(*) as `total` $r = q("SELECT count(*) as `total`
FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id` FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
where `glink`.`zcid` = %d where `glink`.`zcid` = %d
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 ) ", and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 ) ",
intval($zcid), intval($zcid),
@ -236,7 +236,7 @@ function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle = fal
$sql_extra = " order by `gcontact`.`name` asc "; $sql_extra = " order by `gcontact`.`name` asc ";
$r = q("SELECT `gcontact`.* $r = q("SELECT `gcontact`.*
FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id` FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
where `glink`.`zcid` = %d where `glink`.`zcid` = %d
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 ) and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 )
$sql_extra limit %d, %d", $sql_extra limit %d, %d",
@ -254,7 +254,7 @@ function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle = fal
function count_all_friends($uid,$cid) { function count_all_friends($uid,$cid) {
$r = q("SELECT count(*) as `total` $r = q("SELECT count(*) as `total`
FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id` FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
where `glink`.`cid` = %d and `glink`.`uid` = %d ", where `glink`.`cid` = %d and `glink`.`uid` = %d ",
intval($cid), intval($cid),
intval($uid) intval($uid)
@ -270,7 +270,7 @@ function count_all_friends($uid,$cid) {
function all_friends($uid,$cid,$start = 0, $limit = 80) { function all_friends($uid,$cid,$start = 0, $limit = 80) {
$r = q("SELECT `gcontact`.* $r = q("SELECT `gcontact`.*
FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id` FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
where `glink`.`cid` = %d and `glink`.`uid` = %d where `glink`.`cid` = %d and `glink`.`uid` = %d
order by `gcontact`.`name` asc LIMIT %d, %d ", order by `gcontact`.`name` asc LIMIT %d, %d ",
intval($cid), intval($cid),
@ -290,7 +290,7 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
return array(); return array();
$r = q("SELECT count(glink.gcid) as `total`, gcontact.* from gcontact $r = q("SELECT count(glink.gcid) as `total`, gcontact.* from gcontact
left join glink on glink.gcid = gcontact.id INNER JOIN glink on glink.gcid = gcontact.id
where uid = %d and not gcontact.nurl in ( select nurl from contact where uid = %d ) where uid = %d and not gcontact.nurl in ( select nurl from contact where uid = %d )
and not gcontact.name in ( select name from contact where uid = %d ) and not gcontact.name in ( select name from contact where uid = %d )
and not gcontact.id in ( select gcid from gcign where uid = %d ) and not gcontact.id in ( select gcid from gcign where uid = %d )
@ -307,7 +307,7 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
return $r; return $r;
$r2 = q("SELECT gcontact.* from gcontact $r2 = q("SELECT gcontact.* from gcontact
left join glink on glink.gcid = gcontact.id INNER JOIN glink on glink.gcid = gcontact.id
where glink.uid = 0 and glink.cid = 0 and glink.zcid = 0 and not gcontact.nurl in ( select nurl from contact where uid = %d ) where glink.uid = 0 and glink.cid = 0 and glink.zcid = 0 and not gcontact.nurl in ( select nurl from contact where uid = %d )
and not gcontact.name in ( select name from contact where uid = %d ) and not gcontact.name in ( select name from contact where uid = %d )
and not gcontact.id in ( select gcid from gcign where uid = %d ) and not gcontact.id in ( select gcid from gcign where uid = %d )

View File

@ -1,20 +1,4 @@
<?php <?php
/*
require_once("boot.php");
if(@is_null($a)) {
$a = new App;
}
if(is_null($db)) {
@include(".htconfig.php");
require_once("dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
};
$a->set_baseurl("https://pirati.ca");
*/
function create_tags_from_item($itemid) { function create_tags_from_item($itemid) {
global $a; global $a;
@ -25,7 +9,7 @@ function create_tags_from_item($itemid) {
$searchpath = $a->get_baseurl()."/search?tag="; $searchpath = $a->get_baseurl()."/search?tag=";
$messages = q("SELECT `guid`, `uid`, `id`, `edited`, `deleted`, `title`, `body`, `tag` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid)); $messages = q("SELECT `guid`, `uid`, `id`, `edited`, `deleted`, `title`, `body`, `tag`, `parent` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));
if (!$messages) if (!$messages)
return; return;
@ -102,8 +86,11 @@ function create_tags_from_item($itemid) {
if ((substr($tag, 0, 1) == '@') AND (strpos($link, $profile_base_friendica) OR strpos($link, $profile_base_diaspora))) { if ((substr($tag, 0, 1) == '@') AND (strpos($link, $profile_base_friendica) OR strpos($link, $profile_base_diaspora))) {
$users = q("SELECT `uid` FROM `contact` WHERE self AND (`url` = '%s' OR `nurl` = '%s')", $link, $link); $users = q("SELECT `uid` FROM `contact` WHERE self AND (`url` = '%s' OR `nurl` = '%s')", $link, $link);
foreach ($users AS $user) { foreach ($users AS $user) {
if ($user["uid"] == $message["uid"]) if ($user["uid"] == $message["uid"]) {
q("UPDATE `item` SET `mention` = 1 WHERE `id` = %d", intval($itemid)); q("UPDATE `item` SET `mention` = 1 WHERE `id` = %d", intval($itemid));
q("UPDATE `thread` SET `mention` = 1 WHERE `iid` = %d", intval($message["parent"]));
}
} }
} }
} }
@ -125,11 +112,4 @@ function update_items() {
foreach ($messages as $message) foreach ($messages as $message)
create_tags_from_item($message["id"]); create_tags_from_item($message["id"]);
} }
//print_r($tags);
//print_r($hashtags);
//print_r($mentions);
//update_items();
//create_tags_from_item(265194);
//create_tags_from_itemuri("infoagent@diasp.org:cce94abd104c06e8", 2);
?> ?>

View File

@ -1613,16 +1613,27 @@ if(! function_exists('get_plink')) {
*/ */
function get_plink($item) { function get_plink($item) {
$a = get_app(); $a = get_app();
$ret = array(
'href' => $a->get_baseurl()."/display/".$a->user['nickname']."/".$item['id'],
'title' => t('link to source'),
);
$ret["orig"] = $ret["href"]; if ($a->user['nickname'] != "") {
$ret = array(
'href' => $a->get_baseurl()."/display/".$a->user['nickname']."/".$item['id'],
'title' => t('link to source'),
);
$ret["orig"] = $ret["href"];
if (x($item,'plink'))
$ret["href"] = $item['plink'];
} elseif (x($item,'plink') && ($item['private'] != 1))
$ret = array(
'href' => $item['plink'],
'orig' => $item['plink'],
'title' => t('link to source'),
);
else
$ret = array();
//if (x($item,'plink') && ($item['private'] != 1)) //if (x($item,'plink') && ($item['private'] != 1))
if (x($item,'plink'))
$ret["href"] = $item['plink'];
return($ret); return($ret);
}} }}
@ -2017,10 +2028,12 @@ function file_tag_update_pconfig($uid,$file_old,$file_new,$type = 'file') {
if($type == 'file') { if($type == 'file') {
$lbracket = '['; $lbracket = '[';
$rbracket = ']'; $rbracket = ']';
$termtype = TERM_FILE;
} }
else { else {
$lbracket = '<'; $lbracket = '<';
$rbracket = '>'; $rbracket = '>';
$termtype = TERM_CATEGORY;
} }
$filetags_updated = $saved; $filetags_updated = $saved;
@ -2046,9 +2059,15 @@ function file_tag_update_pconfig($uid,$file_old,$file_new,$type = 'file') {
} }
foreach($deleted_tags as $key => $tag) { foreach($deleted_tags as $key => $tag) {
$r = q("select file from item where uid = %d " . file_tag_file_query('item',$tag,$type), $r = q("SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d",
intval($uid) dbesc($tag),
); intval(TERM_OBJ_POST),
intval($termtype),
intval($uid));
//$r = q("select file from item where uid = %d " . file_tag_file_query('item',$tag,$type),
// intval($uid)
//);
if(count($r)) { if(count($r)) {
unset($deleted_tags[$key]); unset($deleted_tags[$key]);
@ -2071,6 +2090,8 @@ function file_tag_update_pconfig($uid,$file_old,$file_new,$type = 'file') {
} }
function file_tag_save_file($uid,$item,$file) { function file_tag_save_file($uid,$item,$file) {
require_once("include/files.php");
$result = false; $result = false;
if(! intval($uid)) if(! intval($uid))
return false; return false;
@ -2080,11 +2101,14 @@ function file_tag_save_file($uid,$item,$file) {
); );
if(count($r)) { if(count($r)) {
if(! stristr($r[0]['file'],'[' . file_tag_encode($file) . ']')) if(! stristr($r[0]['file'],'[' . file_tag_encode($file) . ']'))
q("update item set file = '%s' where id = %d and uid = %d limit 1", q("update item set file = '%s' where id = %d and uid = %d",
dbesc($r[0]['file'] . '[' . file_tag_encode($file) . ']'), dbesc($r[0]['file'] . '[' . file_tag_encode($file) . ']'),
intval($item), intval($item),
intval($uid) intval($uid)
); );
create_files_from_item($item);
$saved = get_pconfig($uid,'system','filetags'); $saved = get_pconfig($uid,'system','filetags');
if((! strlen($saved)) || (! stristr($saved,'[' . file_tag_encode($file) . ']'))) if((! strlen($saved)) || (! stristr($saved,'[' . file_tag_encode($file) . ']')))
set_pconfig($uid,'system','filetags',$saved . '[' . file_tag_encode($file) . ']'); set_pconfig($uid,'system','filetags',$saved . '[' . file_tag_encode($file) . ']');
@ -2094,14 +2118,19 @@ function file_tag_save_file($uid,$item,$file) {
} }
function file_tag_unsave_file($uid,$item,$file,$cat = false) { function file_tag_unsave_file($uid,$item,$file,$cat = false) {
require_once("include/files.php");
$result = false; $result = false;
if(! intval($uid)) if(! intval($uid))
return false; return false;
if($cat == true) if($cat == true) {
$pattern = '<' . file_tag_encode($file) . '>' ; $pattern = '<' . file_tag_encode($file) . '>' ;
else $termtype = TERM_CATEGORY;
} else {
$pattern = '[' . file_tag_encode($file) . ']' ; $pattern = '[' . file_tag_encode($file) . ']' ;
$termtype = TERM_FILE;
}
$r = q("select file from item where id = %d and uid = %d limit 1", $r = q("select file from item where id = %d and uid = %d limit 1",
@ -2111,15 +2140,22 @@ function file_tag_unsave_file($uid,$item,$file,$cat = false) {
if(! count($r)) if(! count($r))
return false; return false;
q("update item set file = '%s' where id = %d and uid = %d limit 1", q("update item set file = '%s' where id = %d and uid = %d",
dbesc(str_replace($pattern,'',$r[0]['file'])), dbesc(str_replace($pattern,'',$r[0]['file'])),
intval($item), intval($item),
intval($uid) intval($uid)
); );
$r = q("select file from item where uid = %d and deleted = 0 " . file_tag_file_query('item',$file,(($cat) ? 'category' : 'file')), create_files_from_item($item);
intval($uid)
); $r = q("SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d",
dbesc($file),
intval(TERM_OBJ_POST),
intval($termtype),
intval($uid));
//$r = q("select file from item where uid = %d and deleted = 0 " . file_tag_file_query('item',$file,(($cat) ? 'category' : 'file')),
//);
if(! count($r)) { if(! count($r)) {
$saved = get_pconfig($uid,'system','filetags'); $saved = get_pconfig($uid,'system','filetags');

99
include/threads.php Normal file
View File

@ -0,0 +1,99 @@
<?php
function add_thread($itemid) {
$items = q("SELECT `uid`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`, `moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`,
`deleted`, `origin`, `forum_mode`, `mention`, `network` FROM `item` WHERE `id` = %d AND (`parent` = %d OR `parent` = 0) LIMIT 1", intval($itemid), intval($itemid));
if (!$items)
return;
$item = $items[0];
$item['iid'] = $itemid;
$result = dbq("INSERT INTO `thread` (`"
.implode("`, `", array_keys($item))
."`) VALUES ('"
.implode("', '", array_values($item))
."')" );
logger("add_thread: Add thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG);
}
function update_thread_uri($itemuri, $uid) {
$messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
if(count($messages))
foreach ($messages as $message)
update_thread($message["id"]);
}
function update_thread($itemid, $setmention = false) {
$items = q("SELECT `uid`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`, `moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`,
`deleted`, `origin`, `forum_mode`, `network` FROM `item` WHERE `id` = %d AND (`parent` = %d OR `parent` = 0) LIMIT 1", intval($itemid), intval($itemid));
if (!$items)
return;
$item = $items[0];
if ($setmention)
$item["mention"] = 1;
$sql = "";
foreach ($item AS $field => $data) {
if ($sql != "")
$sql .= ", ";
$sql .= "`".$field."` = '".$data."'";
}
$result = q("UPDATE `thread` SET ".$sql." WHERE `iid` = %d", $itemid);
logger("update_thread: Update thread for item ".$itemid." - ".print_r($result, true)." ".print_r($item, true), LOGGER_DEBUG);
}
function delete_thread_uri($itemuri, $uid) {
$messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
if(count($messages))
foreach ($messages as $message)
delete_thread($message["id"]);
}
function delete_thread($itemid) {
$result = q("DELETE FROM `thread` WHERE `iid` = %d", intval($itemid));
logger("delete_thread: Deleted thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG);
}
function update_threads() {
global $db;
logger("update_threads: start");
$messages = $db->q("SELECT `id` FROM `item` WHERE `id` = `parent`", true);
logger("update_threads: fetched messages: ".count($messages));
while ($message = $db->qfetch())
add_thread($message["id"]);
$db->qclose();
}
function update_threads_mention() {
$a = get_app();
$users = q("SELECT `uid`, `nickname` FROM `user` ORDER BY `uid`");
foreach ($users AS $user) {
$self = normalise_link($a->get_baseurl() . '/profile/' . $user['nickname']);
$selfhttps = str_replace("http://", "https://", $self);
$parents = q("SELECT DISTINCT(`parent`) FROM `item` WHERE `uid` = %d AND
((`owner-link` IN ('%s', '%s')) OR (`author-link` IN ('%s', '%s')))",
$user["uid"], $self, $selfhttps, $self, $selfhttps);
foreach ($parents AS $parent)
q("UPDATE `thread` SET `mention` = 1 WHERE `iid` = %d", $parent["parent"]);
}
}
?>

23
include/threadupdate.php Normal file
View File

@ -0,0 +1,23 @@
<?php
require_once("boot.php");
require_once("include/threads.php");
global $a, $db;
if(is_null($a))
$a = new App;
if(is_null($db)) {
@include(".htconfig.php");
require_once("include/dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
}
load_config('config');
load_config('system');
update_threads();
update_threads_mention();
killme();
?>

View File

@ -233,7 +233,7 @@ function create_user($arr) {
); );
if((count($r) > 1) && $newuid) { if((count($r) > 1) && $newuid) {
$result['message'] .= t('Nickname is already registered. Please choose another.') . EOL; $result['message'] .= t('Nickname is already registered. Please choose another.') . EOL;
q("DELETE FROM `user` WHERE `uid` = %d LIMIT 1", q("DELETE FROM `user` WHERE `uid` = %d",
intval($newuid) intval($newuid)
); );
return $result; return $result;

View File

@ -526,11 +526,12 @@ function admin_page_site(&$a) {
/* OStatus conversation poll choices */ /* OStatus conversation poll choices */
$ostatus_poll_choices = array( $ostatus_poll_choices = array(
"-1" => t("Never"), "-2" => t("Never"),
"0" => t("Frequently"), "-1" => t("At post arrival"),
"60" => t("Hourly"), "0" => t("Frequently"),
"720" => t("Twice daily"), "60" => t("Hourly"),
"1440" => t("Daily") "720" => t("Twice daily"),
"1440" => t("Daily")
); );
/* get user names to make the install a personal install of X */ /* get user names to make the install a personal install of X */

View File

@ -46,12 +46,13 @@ function community_content(&$a, $update = 0) {
if( (! get_config('alt_pager', 'global')) && (! get_pconfig(local_user(),'system','alt_pager')) ) { if( (! get_config('alt_pager', 'global')) && (! get_pconfig(local_user(),'system','alt_pager')) ) {
$r = q("SELECT COUNT(distinct(`item`.`uri`)) AS `total` $r = q("SELECT COUNT(distinct(`item`.`uri`)) AS `total`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
INNER JOIN `user` ON `user`.`uid` = `item`.`uid` AND `user`.`hidewall` = 0
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0 AND `item`.`private` = 0 AND `item`.`wall` = 1"
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0"
); );
if(count($r)) if(count($r))
@ -64,28 +65,25 @@ function community_content(&$a, $update = 0) {
} }
//$r = q("SELECT distinct(`item`.`uri`)
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`, $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
`user`.`nickname`, `user`.`hidewall` `user`.`nickname`, `user`.`hidewall`
FROM `item` FORCE INDEX (`received`, `wall`) LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM `thread` FORCE INDEX (`wall_private_received`)
LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND `user`.`hidewall` = 0
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `item`.`id` = `item`.`parent` INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
AND `user`.`hidewall` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self`
ORDER BY `received` DESC LIMIT %d, %d ", WHERE `thread`.`visible` = 1 AND `thread`.`deleted` = 0 and `thread`.`moderated` = 0
AND `thread`.`private` = 0 AND `thread`.`wall` = 1
ORDER BY `thread`.`received` DESC LIMIT %d, %d ",
intval($a->pager['start']), intval($a->pager['start']),
intval($a->pager['itemspage']) intval($a->pager['itemspage'])
); );
// group by `item`.`uri`
// AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `item`.`id` = `item`.`parent`
// AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self`
if(! count($r)) { if(! count($r)) {
info( t('No results.') . EOL); info( t('No results.') . EOL);

View File

@ -164,7 +164,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, `notify_new_posts` = %d, `fetch_further_information` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", `hidden` = %d, `notify_new_posts` = %d, `fetch_further_information` = %d WHERE `id` = %d AND `uid` = %d",
intval($profile_id), intval($profile_id),
intval($priority), intval($priority),
dbesc($info), dbesc($info),
@ -197,7 +197,7 @@ function _contact_update($contact_id) {
} }
function _contact_block($contact_id, $orig_record) { function _contact_block($contact_id, $orig_record) {
$blocked = (($orig_record['blocked']) ? 0 : 1); $blocked = (($orig_record['blocked']) ? 0 : 1);
$r = q("UPDATE `contact` SET `blocked` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("UPDATE `contact` SET `blocked` = %d WHERE `id` = %d AND `uid` = %d",
intval($blocked), intval($blocked),
intval($contact_id), intval($contact_id),
intval(local_user()) intval(local_user())
@ -207,7 +207,7 @@ function _contact_block($contact_id, $orig_record) {
} }
function _contact_ignore($contact_id, $orig_record) { function _contact_ignore($contact_id, $orig_record) {
$readonly = (($orig_record['readonly']) ? 0 : 1); $readonly = (($orig_record['readonly']) ? 0 : 1);
$r = q("UPDATE `contact` SET `readonly` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("UPDATE `contact` SET `readonly` = %d WHERE `id` = %d AND `uid` = %d",
intval($readonly), intval($readonly),
intval($contact_id), intval($contact_id),
intval(local_user()) intval(local_user())
@ -216,7 +216,7 @@ function _contact_ignore($contact_id, $orig_record) {
} }
function _contact_archive($contact_id, $orig_record) { function _contact_archive($contact_id, $orig_record) {
$archived = (($orig_record['archive']) ? 0 : 1); $archived = (($orig_record['archive']) ? 0 : 1);
$r = q("UPDATE `contact` SET `archive` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("UPDATE `contact` SET `archive` = %d WHERE `id` = %d AND `uid` = %d",
intval($archived), intval($archived),
intval($contact_id), intval($contact_id),
intval(local_user()) intval(local_user())

View File

@ -176,7 +176,7 @@ function content_content(&$a, $update = 0) {
if($tag) { if($tag) {
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ", //$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ",
// dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG)); // dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
//$sql_table = "`term` LEFT JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` "; //$sql_table = "`term` INNER JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
$sql_extra = ""; $sql_extra = "";
$sql_table = sprintf("`item` INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ", $sql_table = sprintf("`item` INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
@ -216,7 +216,7 @@ function content_content(&$a, $update = 0) {
`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 $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM $sql_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 WHERE `item`.`uid` = %d AND `item`.`visible` = 1
AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
$simple_update $simple_update
@ -240,7 +240,7 @@ function content_content(&$a, $update = 0) {
$start = dba_timer(); $start = dba_timer();
$r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid` $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid`
FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM $sql_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
AND `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`parent` = `item`.`id` AND `item`.`parent` = `item`.`id`
@ -267,7 +267,7 @@ function content_content(&$a, $update = 0) {
`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 $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM $sql_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
AND `item`.`moderated` = 0 AND `item`.`moderated` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0

View File

@ -62,7 +62,7 @@ function crepair_post(&$a) {
$remote_self = ((x($_POST,'remote_self')) ? $_POST['remote_self'] : false); $remote_self = ((x($_POST,'remote_self')) ? $_POST['remote_self'] : false);
$r = q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `url` = '%s', `request` = '%s', `confirm` = '%s', `notify` = '%s', `poll` = '%s', `attag` = '%s' , `remote_self` = %d $r = q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `url` = '%s', `request` = '%s', `confirm` = '%s', `notify` = '%s', `poll` = '%s', `attag` = '%s' , `remote_self` = %d
WHERE `id` = %d AND `uid` = %d LIMIT 1", WHERE `id` = %d AND `uid` = %d",
dbesc($name), dbesc($name),
dbesc($nick), dbesc($nick),
dbesc($url), dbesc($url),
@ -88,7 +88,7 @@ function crepair_post(&$a) {
`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
", ",
dbesc($photos[0]), dbesc($photos[0]),
dbesc($photos[1]), dbesc($photos[1]),

View File

@ -153,7 +153,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
// Save the private key. Send them the public key. // Save the private key. Send them the public key.
$r = q("UPDATE `contact` SET `prvkey` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("UPDATE `contact` SET `prvkey` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc($private_key), dbesc($private_key),
intval($contact_id), intval($contact_id),
intval($uid) intval($uid)
@ -258,7 +258,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
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",
dbesc($new_dfrn_id), dbesc($new_dfrn_id),
intval($contact_id), intval($contact_id),
intval($uid) intval($uid)
@ -282,7 +282,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
// Success. Delete the notification. // Success. Delete the notification.
$r = q("DELETE FROM `intro` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("DELETE FROM `intro` WHERE `id` = %d AND `uid` = %d",
intval($intro_id), intval($intro_id),
intval($uid) intval($uid)
); );
@ -331,7 +331,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
`pending` = 0, `pending` = 0,
`duplex` = %d, `duplex` = %d,
`hidden` = %d, `hidden` = %d,
`network` = 'dfrn' WHERE `id` = %d LIMIT 1 `network` = 'dfrn' WHERE `id` = %d
", ",
dbesc($photos[0]), dbesc($photos[0]),
dbesc($photos[1]), dbesc($photos[1]),
@ -378,7 +378,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
$writable = 1; $writable = 1;
} }
$r = q("DELETE FROM `intro` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("DELETE FROM `intro` WHERE `id` = %d AND `uid` = %d",
intval($intro_id), intval($intro_id),
intval($uid) intval($uid)
); );
@ -398,7 +398,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
`writable` = %d, `writable` = %d,
`hidden` = %d, `hidden` = %d,
`rel` = %d `rel` = %d
WHERE `id` = %d LIMIT 1 WHERE `id` = %d
", ",
dbesc($photos[0]), dbesc($photos[0]),
dbesc($photos[1]), dbesc($photos[1]),
@ -640,7 +640,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
// 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",
dbesc($decrypted_dfrn_id), dbesc($decrypted_dfrn_id),
dbesc($dfrn_pubkey), dbesc($dfrn_pubkey),
intval($dfrn_record) intval($dfrn_record)
@ -654,7 +654,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
// 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",
intval($dfrn_record) intval($dfrn_record)
); );
} }
@ -697,7 +697,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) {
`duplex` = %d, `duplex` = %d,
`forum` = %d, `forum` = %d,
`prv` = %d, `prv` = %d,
`network` = '%s' WHERE `id` = %d LIMIT 1 `network` = '%s' WHERE `id` = %d
", ",
dbesc($photos[0]), dbesc($photos[0]),
dbesc($photos[1]), dbesc($photos[1]),

View File

@ -283,11 +283,11 @@ function dfrn_request_post(&$a) {
if(count($r)) { if(count($r)) {
foreach($r as $rr) { foreach($r as $rr) {
if(! $rr['rel']) { if(! $rr['rel']) {
q("DELETE FROM `contact` WHERE `id` = %d LIMIT 1", q("DELETE FROM `contact` WHERE `id` = %d",
intval($rr['cid']) intval($rr['cid'])
); );
} }
q("DELETE FROM `intro` WHERE `id` = %d LIMIT 1", q("DELETE FROM `intro` WHERE `id` = %d",
intval($rr['iid']) intval($rr['iid'])
); );
} }
@ -308,11 +308,11 @@ function dfrn_request_post(&$a) {
if(count($r)) { if(count($r)) {
foreach($r as $rr) { foreach($r as $rr) {
if(! $rr['rel']) { if(! $rr['rel']) {
q("DELETE FROM `contact` WHERE `id` = %d LIMIT 1", q("DELETE FROM `contact` WHERE `id` = %d",
intval($rr['cid']) intval($rr['cid'])
); );
} }
q("DELETE FROM `intro` WHERE `id` = %d LIMIT 1", q("DELETE FROM `intro` WHERE `id` = %d",
intval($rr['iid']) intval($rr['iid'])
); );
} }

View File

@ -120,10 +120,12 @@ function display_content(&$a, $update = 0) {
$sql_extra = item_permissions_sql($a->profile['uid'],$remote_contact,$groups); $sql_extra = item_permissions_sql($a->profile['uid'],$remote_contact,$groups);
// AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE ( `id` = '%s' OR `uri` = '%s' ))
if($update) { if($update) {
$r = q("SELECT id FROM item WHERE item.uid = %d $r = q("SELECT id FROM item WHERE item.uid = %d
AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE ( `id` = '%s' OR `uri` = '%s' )) AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE (`id` = '%s' OR `uri` = '%s'))
$sql_extra AND unseen = 1", $sql_extra AND unseen = 1",
intval($a->profile['uid']), intval($a->profile['uid']),
dbesc($item_id), dbesc($item_id),
@ -134,18 +136,20 @@ function display_content(&$a, $update = 0) {
return ''; return '';
} }
// AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE ( `id` = '%s' OR `uri` = '%s' )
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
and `item`.`moderated` = 0 and `item`.`moderated` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE (`id` = '%s' OR `uri` = '%s')
AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE ( `id` = '%s' OR `uri` = '%s' ) AND uid = %d)
AND uid = %d )
$sql_extra $sql_extra
ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ", ORDER BY `parent` DESC, `gravity` ASC, `id` ASC",
intval($a->profile['uid']), intval($a->profile['uid']),
dbesc($item_id), dbesc($item_id),
dbesc($item_id), dbesc($item_id),
@ -162,16 +166,17 @@ function display_content(&$a, $update = 0) {
); );
if($r) { if($r) {
$item_uri = $r[0]['uri']; $item_uri = $r[0]['uri'];
// AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE `uri` = '%s' AND uid = %d )
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
and `item`.`moderated` = 0 and `item`.`moderated` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `uri` = '%s' AND uid = %d)
AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE `uri` = '%s' AND uid = %d )
ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ", ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ",
intval(local_user()), intval(local_user()),
dbesc($item_uri), dbesc($item_uri),

View File

@ -142,14 +142,14 @@ function events_content(&$a) {
} }
if(($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) { if(($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) {
$r = q("update event set ignore = 1 where id = %d and uid = %d limit 1", $r = q("update event set ignore = 1 where id = %d and uid = %d",
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
} }
if(($a->argc > 2) && ($a->argv[1] === 'unignore') && intval($a->argv[2])) { if(($a->argc > 2) && ($a->argv[1] === 'unignore') && intval($a->argv[2])) {
$r = q("update event set ignore = 0 where id = %d and uid = %d limit 1", $r = q("update event set ignore = 0 where id = %d and uid = %d",
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );

View File

@ -52,7 +52,7 @@ function fsuggest_post(&$a) {
); );
if(count($r)) { if(count($r)) {
$fsuggest_id = $r[0]['id']; $fsuggest_id = $r[0]['id'];
q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc($note), dbesc($note),
intval($fsuggest_id), intval($fsuggest_id),
intval(local_user()) intval(local_user())

View File

@ -51,7 +51,7 @@ function group_post(&$a) {
$group = $r[0]; $group = $r[0];
$groupname = notags(trim($_POST['groupname'])); $groupname = notags(trim($_POST['groupname']));
if((strlen($groupname)) && ($groupname != $group['name'])) { if((strlen($groupname)) && ($groupname != $group['name'])) {
$r = q("UPDATE `group` SET `name` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1", $r = q("UPDATE `group` SET `name` = '%s' WHERE `uid` = %d AND `id` = %d",
dbesc($groupname), dbesc($groupname),
intval(local_user()), intval(local_user()),
intval($group['id']) intval($group['id'])

View File

@ -20,6 +20,8 @@ require_once('include/enotify.php');
require_once('include/email.php'); require_once('include/email.php');
require_once('library/langdet/Text/LanguageDetect.php'); require_once('library/langdet/Text/LanguageDetect.php');
require_once('include/tags.php'); require_once('include/tags.php');
require_once('include/files.php');
require_once('include/threads.php');
function item_post(&$a) { function item_post(&$a) {
@ -694,17 +696,21 @@ function item_post(&$a) {
if($orig_post) { if($orig_post) {
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `attach` = '%s', `file` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d", $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `attach` = '%s', `file` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc($datarray['title']), dbesc($datarray['title']),
dbesc($datarray['body']), dbesc($datarray['body']),
dbesc($datarray['tag']), dbesc($datarray['tag']),
dbesc($datarray['attach']), dbesc($datarray['attach']),
dbesc($datarray['file']), dbesc($datarray['file']),
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($post_id), intval($post_id),
intval($profile_uid) intval($profile_uid)
); );
create_tags_from_itemuri($post_id, $profile_uid);
create_tags_from_item($post_id);
create_files_from_item($post_id);
update_thread($post_id);
// update filetags in pconfig // update filetags in pconfig
file_tag_update_pconfig($uid,$categories_old,$categories_new,'category'); file_tag_update_pconfig($uid,$categories_old,$categories_new,'category');
@ -771,7 +777,7 @@ function item_post(&$a) {
if(count($r)) { if(count($r)) {
$post_id = $r[0]['id']; $post_id = $r[0]['id'];
logger('mod_item: saved item ' . $post_id); logger('mod_item: saved item ' . $post_id);
create_tags_from_item($post_id); add_thread($post_id);
// update filetags in pconfig // update filetags in pconfig
file_tag_update_pconfig($uid,$categories_old,$categories_new,'category'); file_tag_update_pconfig($uid,$categories_old,$categories_new,'category');
@ -794,8 +800,9 @@ function item_post(&$a) {
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($parent) intval($parent)
); );
update_thread($parent, true);
// Inherit ACL's from the parent item. // Inherit ACLs from the parent item.
$r = q("UPDATE `item` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `private` = %d $r = q("UPDATE `item` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `private` = %d
WHERE `id` = %d", WHERE `id` = %d",
@ -832,8 +839,7 @@ function item_post(&$a) {
// Store the comment signature information in case we need to relay to Diaspora // Store the comment signature information in case we need to relay to Diaspora
store_diaspora_comment_sig($datarray, $author, ($self ? $a->user['prvkey'] : false), $parent_item, $post_id); store_diaspora_comment_sig($datarray, $author, ($self ? $a->user['prvkey'] : false), $parent_item, $post_id);
} } else {
else {
$parent = $post_id; $parent = $post_id;
if($contact_record != $author) { if($contact_record != $author) {
@ -877,6 +883,7 @@ function item_post(&$a) {
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d", $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d",
intval($parent_item['id']) intval($parent_item['id'])
); );
update_thread($parent_item['id']);
} }
} }
else { else {
@ -893,6 +900,7 @@ function item_post(&$a) {
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($parent) intval($parent)
); );
update_thread($parent);
$datarray['id'] = $post_id; $datarray['id'] = $post_id;
$datarray['plink'] = $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id; $datarray['plink'] = $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id;
@ -933,6 +941,10 @@ function item_post(&$a) {
} }
} }
create_tags_from_item($post_id);
create_files_from_item($post_id);
update_thread($post_id);
// This is a real juggling act on shared hosting services which kill your processes // This is a real juggling act on shared hosting services which kill your processes
// e.g. dreamhost. We used to start delivery to our native delivery agents in the background // e.g. dreamhost. We used to start delivery to our native delivery agents in the background
// and then run our plugin delivery from the foreground. We're now doing plugin delivery first, // and then run our plugin delivery from the foreground. We're now doing plugin delivery first,

View File

@ -121,7 +121,7 @@ function like_content(&$a) {
$like_item = $r[0]; $like_item = $r[0];
// Already voted, undo it // Already voted, undo it
$r = q("UPDATE `item` SET `deleted` = 1, `unseen` = 1, `changed` = '%s' WHERE `id` = %d LIMIT 1", $r = q("UPDATE `item` SET `deleted` = 1, `unseen` = 1, `changed` = '%s' WHERE `id` = %d",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($like_item['id']) intval($like_item['id'])
); );
@ -210,7 +210,7 @@ EOT;
$post_id = item_store($arr); $post_id = item_store($arr);
if(! $item['visible']) { if(! $item['visible']) {
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
intval($item['id']), intval($item['id']),
intval($owner_uid) intval($owner_uid)
); );

View File

@ -25,7 +25,7 @@ function lostpass_post(&$a) {
$new_password = autoname(12) . mt_rand(100,9999); $new_password = autoname(12) . mt_rand(100,9999);
$new_password_encoded = hash('whirlpool',$new_password); $new_password_encoded = hash('whirlpool',$new_password);
$r = q("UPDATE `user` SET `pwdreset` = '%s' WHERE `uid` = %d LIMIT 1", $r = q("UPDATE `user` SET `pwdreset` = '%s' WHERE `uid` = %d",
dbesc($new_password_encoded), dbesc($new_password_encoded),
intval($uid) intval($uid)
); );
@ -74,7 +74,7 @@ function lostpass_content(&$a) {
$new_password = autoname(6) . mt_rand(100,9999); $new_password = autoname(6) . mt_rand(100,9999);
$new_password_encoded = hash('whirlpool',$new_password); $new_password_encoded = hash('whirlpool',$new_password);
$r = q("UPDATE `user` SET `password` = '%s', `pwdreset` = '' WHERE `uid` = %d LIMIT 1", $r = q("UPDATE `user` SET `password` = '%s', `pwdreset` = '' WHERE `uid` = %d",
dbesc($new_password_encoded), dbesc($new_password_encoded),
intval($uid) intval($uid)
); );

View File

@ -90,7 +90,7 @@ function mood_init(&$a) {
$item_id = item_store($arr); $item_id = item_store($arr);
if($item_id) { if($item_id) {
q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1", q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id), dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
intval($uid), intval($uid),
intval($item_id) intval($item_id)

View File

@ -1,6 +1,4 @@
<?php <?php
function network_init(&$a) { function network_init(&$a) {
if(! local_user()) { if(! local_user()) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
@ -90,55 +88,14 @@ function network_init(&$a) {
} }
if($remember_tab || $remember_net || $remember_group) { if($remember_tab || $remember_net || $remember_group) {
$net_args = array_merge($query_array, $net_args); $net_args = array_merge($query_array, $net_args);
$net_queries = build_querystring($net_args); $net_queries = build_querystring($net_args);
// groups filter is in form of "network/nnn". Add it to $dest_url, if it's possible
//if ($a->argc==2 && is_numeric($a->argv[1]) && strpos($net_baseurl, "/",1)===false){
// $net_baseurl .= "/".$a->argv[1];
//}
$redir_url = ($net_queries ? $net_baseurl."?".$net_queries : $net_baseurl); $redir_url = ($net_queries ? $net_baseurl."?".$net_queries : $net_baseurl);
goaway($a->get_baseurl() . $redir_url); goaway($a->get_baseurl() . $redir_url);
} }
} }
/* $sel_tabs = network_query_get_sel_tab($a);
$last_sel_tabs = get_pconfig(local_user(), 'network.view','tab.selected');
if (is_array($last_sel_tabs)){
$tab_urls = array(
'/network?f=&order=comment',//all
'/network?f=&order=post', //postord
'/network?f=&conv=1', //conv
'/network/new', //new
'/network?f=&star=1', //starred
'/network?f=&bmark=1', //bookmarked
'/network?f=&spam=1', //spam
);
// redirect if current selected tab is 'no_active' and
// last selected tab is _not_ 'all_active'.
// and this isn't a date query
if ($sel_tabs[0] == 'active' && $last_sel_tabs[0]!='active' && (! $is_a_date_query)) {
$k = array_search('active', $last_sel_tabs);
// merge tab querystring with request querystring
$dest_qa = array();
list($dest_url,$dest_qs) = explode("?", $tab_urls[$k]);
parse_str( $dest_qs, $dest_qa);
$dest_qa = array_merge($query_array, $dest_qa);
$dest_qs = build_querystring($dest_qa);
// groups filter is in form of "network/nnn". Add it to $dest_url, if it's possible
if ($a->argc==2 && is_numeric($a->argv[1]) && strpos($dest_url, "/",1)===false){
$dest_url .= "/".$a->argv[1];
}
goaway($a->get_baseurl() . $dest_url."?".$dest_qs);
}
}*/
if(x($_GET['nets']) && $_GET['nets'] === 'all') if(x($_GET['nets']) && $_GET['nets'] === 'all')
unset($_GET['nets']); unset($_GET['nets']);
@ -383,7 +340,6 @@ function network_content(&$a, $update = 0) {
list($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) = network_query_get_sel_tab($a); list($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) = network_query_get_sel_tab($a);
// if no tabs are selected, defaults to comments // if no tabs are selected, defaults to comments
if ($no_active=='active') $all_active='active'; if ($no_active=='active') $all_active='active';
//echo "<pre>"; var_dump($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active); killme();
$cmd = (($datequery) ? '' : $a->cmd); $cmd = (($datequery) ? '' : $a->cmd);
$len_naked_cmd = strlen(str_replace('/new','',$cmd)); $len_naked_cmd = strlen(str_replace('/new','',$cmd));
@ -402,38 +358,6 @@ function network_content(&$a, $update = 0) {
'sel'=>$postord_active, 'sel'=>$postord_active,
'title' => t('Sort by Post Date'), 'title' => t('Sort by Post Date'),
), ),
/* array(
'label' => t('Personal'),
'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&conv=1',
'sel' => $conv_active,
'title' => t('Posts that mention or involve you'),
),*/
/* array(
'label' => t('New'),
'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ($len_naked_cmd ? '/' : '') . 'new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''),
'sel' => $new_active,
'title' => t('Activity Stream - by date'),
),*/
/* array(
'label' => t('Starred'),
'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&star=1',
'sel'=>$starred_active,
'title' => t('Favourite Posts'),
),*/
/* array(
'label' => t('Shared Links'),
'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&bmark=1',
'sel'=>$bookmarked_active,
'title'=> t('Interesting Links'),
), */
// array(
// 'label' => t('Spam'),
// 'url'=>$a->get_baseurl(true) . '/network?f=&spam=1'
// 'sel'=> $spam_active,
// 'title' => t('Posts flagged as SPAM'),
// ),
); );
if(feature_enabled(local_user(),'personal_tab')) { if(feature_enabled(local_user(),'personal_tab')) {
@ -472,17 +396,6 @@ function network_content(&$a, $update = 0) {
); );
} }
// Not yet implemented
/* if(feature_enabled(local_user(),'spam_filter')) {
$tabs[] = array(
'label' => t('Spam'),
'url'=>$a->get_baseurl(true) . '/network?f=&spam=1',
'sel'=> $spam_active,
'title' => t('Posts flagged as SPAM'),
);
}*/
// save selected tab, but only if not in search or file mode // save selected tab, but only if not in search or file mode
if(!x($_GET,'search') && !x($_GET,'file')) { if(!x($_GET,'search') && !x($_GET,'file')) {
set_pconfig( local_user(), 'network.view','tab.selected',array($all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) ); set_pconfig( local_user(), 'network.view','tab.selected',array($all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) );
@ -533,6 +446,11 @@ function network_content(&$a, $update = 0) {
} }
set_pconfig(local_user(), 'network.view', 'net.selected', ($nets ? $nets : 'all')); set_pconfig(local_user(), 'network.view', 'net.selected', ($nets ? $nets : 'all'));
/*if ($update) {
print_r($_GET);
die("ss");
}*/
if(! $update) { if(! $update) {
if($group) { if($group) {
if(($t = group_public_members($group)) && (! get_pconfig(local_user(),'system','nowarn_insecure'))) { if(($t = group_public_members($group)) && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
@ -569,17 +487,21 @@ function network_content(&$a, $update = 0) {
// that belongs to you, hence you can see all of it. We will filter by group if // that belongs to you, hence you can see all of it. We will filter by group if
// desired. // desired.
$sql_post_table = "";
$sql_options = (($star) ? " and starred = 1 " : ''); $sql_options = (($star) ? " and starred = 1 " : '');
$sql_options .= (($bmark) ? " and bookmark = 1 " : ''); $sql_options .= (($bmark) ? " and bookmark = 1 " : '');
$sql_extra = $sql_options;
$sql_extra2 = "";
$sql_extra3 = "";
$sql_table = "`thread`";
$sql_parent = "`iid`";
//$sql_nets = (($nets) ? sprintf(" and `contact`.`network` = '%s' ", dbesc($nets)) : ''); if ($nouveau OR strlen($file) OR $update) {
$sql_nets = (($nets) ? sprintf(" and `item`.`network` = '%s' ", dbesc($nets)) : ''); $sql_table = "`item`";
$sql_parent = "`parent`";
}
if ($star OR $bmark) { $sql_nets = (($nets) ? sprintf(" and $sql_table.`network` = '%s' ", dbesc($nets)) : '');
$sql_table = "`item` INNER JOIN (SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options and deleted = 0 ORDER BY `commented` DESC) AS `temp1` ON item.parent = `temp1`.parent ";
$sql_extra = "";
} else
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $sql_options ) ";
if($group) { if($group) {
$r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
@ -595,29 +517,34 @@ function network_content(&$a, $update = 0) {
} }
$contacts = expand_groups(array($group)); $contacts = expand_groups(array($group));
$contact_str_self = "";
if((is_array($contacts)) && count($contacts)) { if((is_array($contacts)) && count($contacts)) {
$contact_str = implode(',',$contacts); $contact_str = implode(',',$contacts);
$self = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($_SESSION['uid']));
if (count($self))
$contact_str_self = ",".$self[0]["id"];
} }
else { else {
$contact_str = ' 0 '; $contact_str = ' 0 ';
info( t('Group is empty')); info( t('Group is empty'));
} }
$sql_table = "`item` INNER JOIN (SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND (`contact-id` IN ($contact_str) OR `allow_gid` like '".protect_sprintf('%<'.intval($group).'>%')."') and deleted = 0 ORDER BY `created` DESC) AS `temp1` ON item.parent = `temp1`.parent "; //$sql_post_table = " INNER JOIN (SELECT DISTINCT(`parent`) FROM `item` WHERE (`contact-id` IN ($contact_str) OR `allow_gid` like '".protect_sprintf('%<'.intval($group).'>%')."') and deleted = 0 ORDER BY `created` DESC) AS `temp1` ON $sql_table.$sql_parent = `temp1`.`parent` ";
$sql_extra = "";
//$sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND ( `contact-id` IN ( $contact_str ) OR `allow_gid` like '" . protect_sprintf('%<' . intval($group) . '>%') . "' ) and deleted = 0 ) "; $sql_extra3 .= " AND `contact-id` IN ($contact_str$contact_str_self) ";
$sql_extra3 .= " AND EXISTS (SELECT id FROM `item` WHERE (`contact-id` IN ($contact_str) OR `allow_gid` like '".protect_sprintf('%<'.intval($group).'>%')."') and deleted = 0 AND parent = $sql_table.$sql_parent) ";
$o = '<h2>' . t('Group: ') . $r[0]['name'] . '</h2>' . $o; $o = '<h2>' . t('Group: ') . $r[0]['name'] . '</h2>' . $o;
} } elseif($cid) {
elseif($cid) {
$r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d $r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d
AND `blocked` = 0 AND `pending` = 0 LIMIT 1", AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
intval($cid) intval($cid)
); );
if(count($r)) { if(count($r)) {
$sql_table = "`item` INNER JOIN (SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND `contact-id` = ".intval($cid)." and deleted = 0 ORDER BY `item`.`received` DESC) AS `temp1` ON item.parent = `temp1`.parent "; $sql_post_table = " INNER JOIN (SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND `contact-id` = ".intval($cid)." and deleted = 0 ORDER BY `item`.`received` DESC) AS `temp1` ON $sql_table.$sql_parent = `temp1`.`parent` ";
$sql_extra = ""; $sql_extra = "";
//$sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND `contact-id` = " . intval($cid) . " and deleted = 0 ) ";
$o = '<h2>' . t('Contact: ') . $r[0]['name'] . '</h2>' . $o; $o = '<h2>' . t('Contact: ') . $r[0]['name'] . '</h2>' . $o;
if($r[0]['network'] === NETWORK_OSTATUS && $r[0]['writable'] && (! get_pconfig(local_user(),'system','nowarn_insecure'))) { if($r[0]['network'] === NETWORK_OSTATUS && $r[0]['writable'] && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
notice( t('Private messages to this person are at risk of public disclosure.') . EOL); notice( t('Private messages to this person are at risk of public disclosure.') . EOL);
@ -636,23 +563,19 @@ function network_content(&$a, $update = 0) {
$o .= get_events(); $o .= get_events();
} }
$sql_extra3 = '';
if($datequery) { if($datequery) {
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery)))); $sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery))));
} }
if($datequery2) { if($datequery2) {
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2)))); $sql_extra3 .= protect_sprintf(sprintf(" AND $sql_table.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
} }
$sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` "); //$sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` ");
$sql_extra2 = (($nouveau) ? '' : $sql_extra2);
$sql_extra3 = (($nouveau) ? '' : $sql_extra3); $sql_extra3 = (($nouveau) ? '' : $sql_extra3);
//$sql_order = "`item`.`received`";
$sql_order = ""; $sql_order = "";
$order_mode = "received"; $order_mode = "received";
$tag = false;
if ($sql_table == "")
$sql_table = "`item`";
if(x($_GET,'search')) { if(x($_GET,'search')) {
$search = escape_tags($_GET['search']); $search = escape_tags($_GET['search']);
@ -666,44 +589,30 @@ function network_content(&$a, $update = 0) {
$tag = true; $tag = true;
if($tag) { if($tag) {
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ",
// dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
//$sql_table = "`term` LEFT JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
//$sql_order = "`term`.`tid`";
$sql_extra = ""; $sql_extra = "";
$sql_table = sprintf("`item` INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ", $sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval(local_user())); dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval(local_user()));
$sql_order = "`item`.`id`";
$sql_order = "`item`.`received`"; $order_mode = "id";
$order_mode = "received";
} else { } else {
if (get_config('system','use_fulltext_engine')) if (get_config('system','use_fulltext_engine'))
$sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search))); $sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
else else
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search)))); $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
$sql_order = "`item`.`received`"; $sql_order = "`item`.`received`";
$order_mode = "received"; $order_mode = "received";
} }
} }
if(strlen($file)) { if(strlen($file)) {
$sql_extra .= file_tag_file_query('item',unxmlify($file)); $sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
dbesc(protect_sprintf($file)), intval(TERM_OBJ_POST), intval(TERM_FILE), intval(local_user()));
$sql_order = "`item`.`id`";
$order_mode = "id";
} }
if($conv) { if($conv)
$myurl = $a->get_baseurl() . '/profile/'. $a->user['nickname']; $sql_extra3 .= " AND `mention`";
$myurl = substr($myurl,strpos($myurl,'://')+3);
$myurl = str_replace('www.','',$myurl);
$diasp_url = str_replace('/profile/','/u/',$myurl);
$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)",
dbesc(protect_sprintf($myurl)),
dbesc(protect_sprintf($myurl))
);
}
if($update) { if($update) {
@ -714,9 +623,9 @@ function network_content(&$a, $update = 0) {
else { else {
if( (! get_config('alt_pager', 'global')) && (! get_pconfig(local_user(),'system','alt_pager')) ) { if( (! get_config('alt_pager', 'global')) && (! get_pconfig(local_user(),'system','alt_pager')) ) {
$r = q("SELECT COUNT(*) AS `total` $r = q("SELECT COUNT(*) AS `total`
FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = $sql_table.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
WHERE $sql_table.`uid` = %d AND $sql_table.`visible` = 1 AND $sql_table.`deleted` = 0
$sql_extra2 $sql_extra3 $sql_extra2 $sql_extra3
$sql_extra $sql_nets ", $sql_extra $sql_nets ",
intval($_SESSION['uid']) intval($_SESSION['uid'])
@ -745,28 +654,29 @@ function network_content(&$a, $update = 0) {
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage'])); $pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
} }
$simple_update = (($update) ? " and `item`.`unseen` = 1 " : '');
if($nouveau) { if($nouveau) {
// "New Item View" - show all items unthreaded in reverse created date order $simple_update = (($update) ? " and `item`.`unseen` = 1 " : '');
if ($sql_order == "")
$sql_order = "`item`.`received`";
// "New Item View" - show all items unthreaded in reverse created date order
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`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 $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 WHERE `item`.`uid` = %d AND `item`.`visible` = 1
AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
$simple_update $simple_update
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
$sql_extra $sql_nets $sql_extra $sql_nets
ORDER BY `item`.`received` DESC $pager_sql ", ORDER BY $sql_order DESC $pager_sql ",
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );
$update_unseen = ' WHERE uid = ' . intval($_SESSION['uid']) . " AND unseen = 1 $sql_extra $sql_nets"; $update_unseen = ' WHERE uid = ' . intval($_SESSION['uid']) . " AND unseen = 1 $sql_extra $sql_nets";
} } else {
else {
// Normal conversation view // Normal conversation view
@ -782,31 +692,29 @@ function network_content(&$a, $update = 0) {
} }
if ($sql_order == "") if ($sql_order == "")
$sql_order = "`item`.$ordering"; $sql_order = "$sql_table.$ordering";
if (($_GET["offset"] != "")) if (($_GET["offset"] != ""))
$sql_extra3 .= sprintf(" AND $sql_order <= '%s'", dbesc($_GET["offset"])); $sql_extra3 .= sprintf(" AND $sql_order <= '%s'", dbesc($_GET["offset"]));
// Fetch a page full of parent items for this page // Fetch a page full of parent items for this page
if($update) { if($update) {
$r = q("SELECT `item`.`parent` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` $r = q("SELECT `item`.`parent` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid`
FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND
(`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' OR item.verb = '" . ACTIVITY_DISLIKE . "')
and `item`.`moderated` = 0 and `item`.`unseen` = 1
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
$sql_extra3 $sql_extra $sql_nets ", WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND
(`item`.`deleted` = 0 OR `item`.`verb` = '" . ACTIVITY_LIKE ."' OR `item`.`verb` = '" . ACTIVITY_DISLIKE . "')
and `item`.`moderated` = 0 and `item`.`unseen` = 1
$sql_extra3 $sql_extra $sql_nets ORDER BY `item_id` DESC LIMIT 100",
intval(local_user()) intval(local_user())
); );
} } else {
else { $r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid`
$r = q("SELECT `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 WHERE `thread`.`uid` = %d AND `thread`.`visible` = 1 AND `thread`.`deleted` = 0
AND `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `thread`.`moderated` = 0
AND `item`.`parent` = `item`.`id` $sql_extra2 $sql_extra3 $sql_extra $sql_nets
$sql_extra3 $sql_extra $sql_nets
ORDER BY $sql_order DESC $pager_sql ", ORDER BY $sql_order DESC $pager_sql ",
intval(local_user()) intval(local_user())
); );
@ -823,7 +731,7 @@ function network_content(&$a, $update = 0) {
if(! in_array($rr['item_id'],$parents_arr)) if(! in_array($rr['item_id'],$parents_arr))
$parents_arr[] = $rr['item_id']; $parents_arr[] = $rr['item_id'];
//$parents_str = implode(', ', $parents_arr); $parents_str = implode(", ", $parents_arr);
// splitted into separate queries to avoid the problem with very long threads // splitted into separate queries to avoid the problem with very long threads
// so always the last X comments are loaded // so always the last X comments are loaded
@ -834,26 +742,25 @@ function network_content(&$a, $update = 0) {
$items = array(); $items = array();
foreach ($parents_arr AS $parents_str) { foreach ($parents_arr AS $parents) {
// $sql_extra ORDER BY `item`.`commented` DESC LIMIT %d",
$thread_items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, $thread_items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`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 $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
AND `item`.`moderated` = 0 AND `item`.`moderated` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `item`.`parent` = %d
AND `item`.`parent` IN ( %s ) ORDER BY `item`.`commented` DESC LIMIT %d",
$sql_extra ORDER BY `item`.`commented` DESC LIMIT %d",
intval(local_user()), intval(local_user()),
dbesc($parents_str), intval($parents),
intval($max_comments + 1) intval($max_comments + 1)
); );
$items = array_merge($items, $thread_items); $items = array_merge($items, $thread_items);
} }
$items = conv_sort($items,$ordering); $items = conv_sort($items,$ordering);
} else { } else {
$items = array(); $items = array();
} }
@ -882,6 +789,7 @@ function network_content(&$a, $update = 0) {
// Several people are complaining because there are unseen messages they can't find and as time goes // Several people are complaining because there are unseen messages they can't find and as time goes
// on they just get buried deeper. It has happened to me a couple of times also. // on they just get buried deeper. It has happened to me a couple of times also.
if((! $group) && (! $cid) && (! $star)) { if((! $group) && (! $cid) && (! $star)) {
$r = q("UPDATE `item` SET `unseen` = 0 $r = q("UPDATE `item` SET `unseen` = 0
WHERE `unseen` = 1 AND `uid` = %d", WHERE `unseen` = 1 AND `uid` = %d",

View File

@ -33,7 +33,7 @@ function notifications_post(&$a) {
$fid = $r[0]['fid']; $fid = $r[0]['fid'];
if($_POST['submit'] == t('Discard')) { if($_POST['submit'] == t('Discard')) {
$r = q("DELETE FROM `intro` WHERE `id` = %d LIMIT 1", $r = q("DELETE FROM `intro` WHERE `id` = %d",
intval($intro_id) intval($intro_id)
); );
if(! $fid) { if(! $fid) {
@ -41,7 +41,7 @@ function notifications_post(&$a) {
// The check for blocked and pending is in case the friendship was already approved // The check for blocked and pending is in case the friendship was already approved
// and we just want to get rid of the now pointless notification // and we just want to get rid of the now pointless notification
$r = q("DELETE FROM `contact` WHERE `id` = %d AND `uid` = %d AND `self` = 0 AND `blocked` = 1 AND `pending` = 1 LIMIT 1", $r = q("DELETE FROM `contact` WHERE `id` = %d AND `uid` = %d AND `self` = 0 AND `blocked` = 1 AND `pending` = 1",
intval($contact_id), intval($contact_id),
intval(local_user()) intval(local_user())
); );

View File

@ -82,6 +82,9 @@ function parseurl_getsiteinfo($url, $no_guessing = false) {
$oembed_data = oembed_fetch_url($url); $oembed_data = oembed_fetch_url($url);
if ($oembed_data->type != "error")
$siteinfo["type"] = $oembed_data->type;
if ($oembed_data->type == "link") { if ($oembed_data->type == "link") {
if (isset($oembed_data->title)) if (isset($oembed_data->title))
$siteinfo["title"] = $oembed_data->title; $siteinfo["title"] = $oembed_data->title;
@ -172,7 +175,8 @@ function parseurl_getsiteinfo($url, $no_guessing = false) {
$siteinfo["image"] = $attr["content"]; $siteinfo["image"] = $attr["content"];
break; break;
case "twitter:card": case "twitter:card":
$siteinfo["type"] = $attr["content"]; if ($siteinfo["type"] == "")
$siteinfo["type"] = $attr["content"];
break; break;
case "twitter:description": case "twitter:description":
$siteinfo["text"] = $attr["content"]; $siteinfo["text"] = $attr["content"];
@ -187,6 +191,8 @@ function parseurl_getsiteinfo($url, $no_guessing = false) {
$siteinfo["text"] = $attr["content"]; $siteinfo["text"] = $attr["content"];
break; break;
} }
if ($siteinfo["type"] == "summary")
$siteinfo["type"] = "link";
} }
//$list = $xpath->query("head/meta[@property]"); //$list = $xpath->query("head/meta[@property]");
@ -391,7 +397,7 @@ function parse_url_content(&$a) {
$total_images ++; $total_images ++;
if($max_images && $max_images >= $total_images) if($max_images && $max_images >= $total_images)
break; break;
} }
} }
if(strlen($text)) { if(strlen($text)) {
@ -414,7 +420,9 @@ function parse_url_content(&$a) {
$sitedata .= trim($result); $sitedata .= trim($result);
if (($siteinfo["type"] != "photo")) if (($siteinfo["type"] == "video") AND ($url != ""))
echo "[video]".$url."[/video]";
elseif (($siteinfo["type"] != "photo"))
echo "[class=type-link]".$sitedata."[/class]"; echo "[class=type-link]".$sitedata."[/class]";
else else
echo "[class=type-photo]".$title.$br.$image."[/class]"; echo "[class=type-photo]".$title.$br.$image."[/class]";

View File

@ -206,9 +206,15 @@ function photo_init(&$a) {
echo $data; echo $data;
// If the photo is public and there is an existing photo directory store the photo there // If the photo is public and there is an existing photo directory store the photo there
if ($public and ($file != "")) if ($public and ($file != "")) {
// If the photo path isn't there, try to create it
if (!is_dir($_SERVER["DOCUMENT_ROOT"]."/photo"))
if (is_writable($_SERVER["DOCUMENT_ROOT"]))
mkdir($_SERVER["DOCUMENT_ROOT"]."/photo");
if (is_dir($_SERVER["DOCUMENT_ROOT"]."/photo")) if (is_dir($_SERVER["DOCUMENT_ROOT"]."/photo"))
file_put_contents($_SERVER["DOCUMENT_ROOT"]."/photo/".$file, $data); file_put_contents($_SERVER["DOCUMENT_ROOT"]."/photo/".$file, $data);
}
killme(); killme();
// NOTREACHED // NOTREACHED

View File

@ -6,6 +6,7 @@ require_once('include/bbcode.php');
require_once('include/security.php'); require_once('include/security.php');
require_once('include/redir.php'); require_once('include/redir.php');
require_once('include/tags.php'); require_once('include/tags.php');
require_once('include/threads.php');
function photos_init(&$a) { function photos_init(&$a) {
@ -253,6 +254,7 @@ function photos_post(&$a) {
intval($page_owner_uid) intval($page_owner_uid)
); );
create_tags_from_itemuri($rr['parent-uri'], $page_owner_uid); create_tags_from_itemuri($rr['parent-uri'], $page_owner_uid);
delete_thread_uri($rr['parent-uri'], $page_owner_uid);
$drop_id = intval($rr['id']); $drop_id = intval($rr['id']);
@ -323,6 +325,7 @@ function photos_post(&$a) {
intval($page_owner_uid) intval($page_owner_uid)
); );
create_tags_from_itemuri($i[0]['uri'], $page_owner_uid); create_tags_from_itemuri($i[0]['uri'], $page_owner_uid);
delete_thread_uri($i[0]['uri'], $page_owner_uid);
$url = $a->get_baseurl(); $url = $a->get_baseurl();
$drop_id = intval($i[0]['id']); $drop_id = intval($i[0]['id']);
@ -371,7 +374,7 @@ function photos_post(&$a) {
$width = $ph->getWidth(); $width = $ph->getWidth();
$height = $ph->getHeight(); $height = $ph->getHeight();
$x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 0 limit 1", $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 0",
dbesc($ph->imageString()), dbesc($ph->imageString()),
intval($height), intval($height),
intval($width), intval($width),
@ -384,7 +387,7 @@ function photos_post(&$a) {
$width = $ph->getWidth(); $width = $ph->getWidth();
$height = $ph->getHeight(); $height = $ph->getHeight();
$x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 1 limit 1", $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 1",
dbesc($ph->imageString()), dbesc($ph->imageString()),
intval($height), intval($height),
intval($width), intval($width),
@ -398,7 +401,7 @@ function photos_post(&$a) {
$width = $ph->getWidth(); $width = $ph->getWidth();
$height = $ph->getHeight(); $height = $ph->getHeight();
$x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 2 limit 1", $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 2",
dbesc($ph->imageString()), dbesc($ph->imageString()),
intval($height), intval($height),
intval($width), intval($width),
@ -599,7 +602,7 @@ function photos_post(&$a) {
$newinform .= ','; $newinform .= ',';
$newinform .= $inform; $newinform .= $inform;
$r = q("UPDATE `item` SET `tag` = '%s', `inform` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("UPDATE `item` SET `tag` = '%s', `inform` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc($newtag), dbesc($newtag),
dbesc($newinform), dbesc($newinform),
dbesc(datetime_convert()), dbesc(datetime_convert()),
@ -608,6 +611,7 @@ function photos_post(&$a) {
intval($page_owner_uid) intval($page_owner_uid)
); );
create_tags_from_item($item_id); create_tags_from_item($item_id);
update_thread($item_id);
$best = 0; $best = 0;
foreach($p as $scales) { foreach($p as $scales) {
@ -668,7 +672,7 @@ function photos_post(&$a) {
$item_id = item_store($arr); $item_id = item_store($arr);
if($item_id) { if($item_id) {
q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1", q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
dbesc($a->get_baseurl() . '/display/' . $owner_record['nickname'] . '/' . $item_id), dbesc($a->get_baseurl() . '/display/' . $owner_record['nickname'] . '/' . $item_id),
intval($page_owner_uid), intval($page_owner_uid),
intval($item_id) intval($item_id)
@ -877,7 +881,7 @@ function photos_post(&$a) {
$item_id = item_store($arr); $item_id = item_store($arr);
if($item_id) { if($item_id) {
q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1", q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
dbesc($a->get_baseurl() . '/display/' . $owner_record['nickname'] . '/' . $item_id), dbesc($a->get_baseurl() . '/display/' . $owner_record['nickname'] . '/' . $item_id),
intval($page_owner_uid), intval($page_owner_uid),
intval($item_id) intval($item_id)
@ -1431,6 +1435,7 @@ function photos_content(&$a) {
intval($link_item['parent']), intval($link_item['parent']),
intval(local_user()) intval(local_user())
); );
update_thread($link_item['parent']);
} }
} }

View File

@ -111,7 +111,7 @@ function poke_init(&$a) {
$item_id = item_store($arr); $item_id = item_store($arr);
if($item_id) { if($item_id) {
q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1", q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id), dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
intval($uid), intval($uid),
intval($item_id) intval($item_id)

View File

@ -219,37 +219,41 @@ function profile_content(&$a, $update = 0) {
$r = q("SELECT distinct(parent) AS `item_id`, `item`.`network` AS `item_network`, $r = q("SELECT distinct(parent) AS `item_id`, `item`.`network` AS `item_network`,
`contact`.`uid` AS `contact-uid` `contact`.`uid` AS `contact-uid`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND
(`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' OR item.verb = '" . ACTIVITY_DISLIKE . "') (`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' OR item.verb = '" . ACTIVITY_DISLIKE . "')
and `item`.`moderated` = 0 and `item`.`unseen` = 1 and `item`.`moderated` = 0 and `item`.`unseen` = 1
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`wall` = 1 AND `item`.`wall` = 1
$sql_extra $sql_extra
ORDER BY `item`.`created` DESC", ORDER BY `item`.`created` DESC",
intval($a->profile['profile_uid']) intval($a->profile['profile_uid'])
); );
} } else {
else { $sql_post_table = "";
if(x($category)) { if(x($category)) {
$sql_extra .= protect_sprintf(file_tag_file_query('item',$category,'category')); $sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
dbesc(protect_sprintf($category)), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), intval($a->profile['profile_uid']));
//$sql_extra .= protect_sprintf(file_tag_file_query('item',$category,'category'));
} }
if($datequery) { if($datequery) {
$sql_extra2 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery)))); $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery))));
} }
if($datequery2) { if($datequery2) {
$sql_extra2 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2)))); $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
} }
if( (! get_config('alt_pager', 'global')) && (! get_pconfig($a->profile['profile_uid'],'system','alt_pager')) ) { if( (! get_config('alt_pager', 'global')) && (! get_pconfig($a->profile['profile_uid'],'system','alt_pager')) ) {
$r = q("SELECT COUNT(*) AS `total` $r = q("SELECT COUNT(*) AS `total`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM `thread` INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 $sql_post_table INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
and `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1 WHERE `thread`.`uid` = %d AND `thread`.`visible` = 1 AND `thread`.`deleted` = 0
and `thread`.`moderated` = 0
AND `thread`.`wall` = 1
$sql_extra $sql_extra2 ", $sql_extra $sql_extra2 ",
intval($a->profile['profile_uid']) intval($a->profile['profile_uid'])
); );
@ -277,20 +281,19 @@ function profile_content(&$a, $update = 0) {
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage'])); $pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
// FROM `item` FORCE INDEX (created, uid) LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` $r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`,
`thread`.`uid` AS `contact-uid`
$r = q("SELECT `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, FROM `thread` INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
`contact`.`uid` AS `contact-uid` $sql_post_table INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 WHERE `thread`.`uid` = %d AND `thread`.`visible` = 1 AND `thread`.`deleted` = 0
and `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 and `thread`.`moderated` = 0
AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1 AND `thread`.`wall` = 1
$sql_extra $sql_extra2 $sql_extra $sql_extra2
ORDER BY `item`.`created` DESC $pager_sql ", ORDER BY `thread`.`created` DESC $pager_sql ",
intval($a->profile['profile_uid']) intval($a->profile['profile_uid'])
); );
} }
$parents_arr = array(); $parents_arr = array();

View File

@ -99,7 +99,7 @@ function profile_photo_post(&$a) {
); );
} }
else { else {
$r = q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d limit 1", $r = q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d",
dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4'), dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-4'),
dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5'), dbesc($a->get_baseurl() . '/photo/' . $base_image['resource-id'] . '-5'),
intval($_REQUEST['profile']), intval($_REQUEST['profile']),
@ -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",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval(local_user()) intval(local_user())
); );
@ -210,7 +210,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",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval(local_user()) intval(local_user())
); );

View File

@ -29,7 +29,7 @@ function profiles_init(&$a) {
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
$r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d",
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
@ -412,7 +412,7 @@ function profiles_post(&$a) {
`work` = '%s', `work` = '%s',
`education` = '%s', `education` = '%s',
`hide-friends` = %d `hide-friends` = %d
WHERE `id` = %d AND `uid` = %d LIMIT 1", WHERE `id` = %d AND `uid` = %d",
dbesc($profile_name), dbesc($profile_name),
dbesc($name), dbesc($name),
dbesc($pdesc), dbesc($pdesc),
@ -455,11 +455,11 @@ 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",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval(local_user()) intval(local_user())
); );
$r = q("UPDATE `user` set `username` = '%s' where `uid` = %d limit 1", $r = q("UPDATE `user` set `username` = '%s' where `uid` = %d",
dbesc($name), dbesc($name),
intval(local_user()) intval(local_user())
); );
@ -558,7 +558,7 @@ function profile_activity($changed, $value) {
if($i) { if($i) {
// give it a permanent link // give it a permanent link
q("update item set plink = '%s' where id = %d limit 1", q("update item set plink = '%s' where id = %d",
dbesc($a->get_baseurl() . '/display/' . $a->user['nickname'] . '/' . $i), dbesc($a->get_baseurl() . '/display/' . $a->user['nickname'] . '/' . $i),
intval($i) intval($i)
); );

View File

@ -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",
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",
intval($a->argv[1]), intval($a->argv[1]),
intval($change), intval($change),
intval(local_user()) intval(local_user())

View File

@ -85,7 +85,7 @@ function pubsub_init(&$a) {
logger('pubsub: unsubscribe success'); logger('pubsub: unsubscribe success');
} }
$r = q("UPDATE `contact` SET `subhub` = %d WHERE `id` = %d LIMIT 1", $r = q("UPDATE `contact` SET `subhub` = %d WHERE `id` = %d",
intval($subscribe), intval($subscribe),
intval($contact['id']) intval($contact['id'])
); );

View File

@ -128,23 +128,12 @@ function search_content(&$a) {
$tag = true; $tag = true;
if($tag) { if($tag) {
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d",
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d group by `item`.`uri` ",
// dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
//$sql_table = "`term` LEFT JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
//$sql_order = "`term`.`tid`";
//$sql_order = "`item`.`received`";
//$sql_extra = sprintf(" AND EXISTS (SELECT * FROM `term` WHERE `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d) GROUP BY `item`.`uri` ",
// dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
//$sql_table = "`item` FORCE INDEX (`uri`) ";
$sql_extra = ""; $sql_extra = "";
$sql_table = sprintf("`item` INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ", $sql_table = sprintf("`item` INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d) AS `term` ON `item`.`id` = `term`.`oid` ",
dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval(local_user())); dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
$sql_order = "`item`.`received`"; $sql_order = "`item`.`id`";
} else { } else {
if (get_config('system','use_fulltext_engine')) { if (get_config('system','use_fulltext_engine')) {
$sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search))); $sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
@ -152,7 +141,8 @@ function search_content(&$a) {
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search)))); $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
} }
$sql_table = "`item`"; $sql_table = "`item`";
$sql_order = "`item`.`received`"; $sql_order = "`item`.`id`";
//$sql_order = "`item`.`received`";
} }
// Here is the way permissions work in the search module... // Here is the way permissions work in the search module...
@ -162,11 +152,12 @@ function search_content(&$a) {
if( (! get_config('alt_pager', 'global')) && (! get_pconfig(local_user(),'system','alt_pager')) ) { if( (! get_config('alt_pager', 'global')) && (! get_pconfig(local_user(),'system','alt_pager')) ) {
$r = q("SELECT distinct(`item`.`uri`) as `total` $r = q("SELECT distinct(`item`.`uri`) as `total`
FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` FROM $sql_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0) AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0)
OR ( `item`.`uid` = %d )) OR ( `item`.`uid` = %d ))
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
$sql_extra ", $sql_extra ",
intval(local_user()) intval(local_user())
); );
@ -186,13 +177,13 @@ function search_content(&$a) {
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
`user`.`nickname`, `user`.`uid`, `user`.`hidewall` `user`.`nickname`, `user`.`uid`, `user`.`hidewall`
FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM $sql_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0 ) AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0 )
OR ( `item`.`uid` = %d )) OR ( `item`.`uid` = %d ))
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $sql_extra GROUP BY `item`.`uri`
$sql_extra
ORDER BY $sql_order DESC LIMIT %d , %d ", ORDER BY $sql_order DESC LIMIT %d , %d ",
intval(local_user()), intval(local_user()),
intval($a->pager['start']), intval($a->pager['start']),

View File

@ -196,14 +196,14 @@ function settings_post(&$a) {
if(strlen($mail_pass)) { if(strlen($mail_pass)) {
$pass = ''; $pass = '';
openssl_public_encrypt($mail_pass,$pass,$a->user['pubkey']); openssl_public_encrypt($mail_pass,$pass,$a->user['pubkey']);
q("UPDATE `mailacct` SET `pass` = '%s' WHERE `uid` = %d LIMIT 1", q("UPDATE `mailacct` SET `pass` = '%s' WHERE `uid` = %d",
dbesc(bin2hex($pass)), dbesc(bin2hex($pass)),
intval(local_user()) intval(local_user())
); );
} }
$r = q("UPDATE `mailacct` SET `server` = '%s', `port` = %d, `ssltype` = '%s', `user` = '%s', $r = q("UPDATE `mailacct` SET `server` = '%s', `port` = %d, `ssltype` = '%s', `user` = '%s',
`action` = %d, `movetofolder` = '%s', `action` = %d, `movetofolder` = '%s',
`mailbox` = 'INBOX', `reply_to` = '%s', `pubmail` = %d WHERE `uid` = %d LIMIT 1", `mailbox` = 'INBOX', `reply_to` = '%s', `pubmail` = %d WHERE `uid` = %d",
dbesc($mail_server), dbesc($mail_server),
intval($mail_port), intval($mail_port),
dbesc($mail_ssl), dbesc($mail_ssl),
@ -294,7 +294,7 @@ function settings_post(&$a) {
} }
$r = q("UPDATE `user` SET `theme` = '%s' WHERE `uid` = %d LIMIT 1", $r = q("UPDATE `user` SET `theme` = '%s' WHERE `uid` = %d",
dbesc($theme), dbesc($theme),
intval(local_user()) intval(local_user())
); );
@ -341,7 +341,7 @@ function settings_post(&$a) {
if(! $err) { if(! $err) {
$password = hash('whirlpool',$newpass); $password = hash('whirlpool',$newpass);
$r = q("UPDATE `user` SET `password` = '%s' WHERE `uid` = %d LIMIT 1", $r = q("UPDATE `user` SET `password` = '%s' WHERE `uid` = %d",
dbesc($password), dbesc($password),
intval(local_user()) intval(local_user())
); );
@ -499,7 +499,7 @@ function settings_post(&$a) {
} }
} }
$r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `maxreq` = %d, `expire` = %d, `openidserver` = '%s', `def_gid` = %d, `blockwall` = %d, `hidewall` = %d, `blocktags` = %d, `unkmail` = %d, `cntunkmail` = %d WHERE `uid` = %d LIMIT 1", $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `maxreq` = %d, `expire` = %d, `openidserver` = '%s', `def_gid` = %d, `blockwall` = %d, `hidewall` = %d, `blocktags` = %d, `unkmail` = %d, `cntunkmail` = %d WHERE `uid` = %d",
dbesc($username), dbesc($username),
dbesc($email), dbesc($email),
dbesc($openid), dbesc($openid),
@ -531,7 +531,7 @@ function settings_post(&$a) {
`name` = '%s', `name` = '%s',
`net-publish` = %d, `net-publish` = %d,
`hide-friends` = %d `hide-friends` = %d
WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", WHERE `is-default` = 1 AND `uid` = %d",
intval($publish), intval($publish),
dbesc($username), dbesc($username),
intval($net_publish), intval($net_publish),
@ -541,7 +541,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",
dbesc($username), dbesc($username),
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval(local_user()) intval(local_user())

View File

@ -9,7 +9,7 @@ function share_init(&$a) {
killme(); killme();
$r = q("SELECT item.*, contact.network FROM `item` $r = q("SELECT item.*, contact.network FROM `item`
left join contact on `item`.`contact-id` = `contact`.`id` inner join contact on `item`.`contact-id` = `contact`.`id`
WHERE `item`.`id` = %d AND `item`.`uid` = %d LIMIT 1", WHERE `item`.`id` = %d AND `item`.`uid` = %d LIMIT 1",
intval($post_id), intval($post_id),

View File

@ -22,7 +22,7 @@ function starred_init(&$a) {
if(! intval($r[0]['starred'])) if(! intval($r[0]['starred']))
$starred = 1; $starred = 1;
$r = q("UPDATE item SET starred = %d WHERE uid = %d and id = %d LIMIT 1", $r = q("UPDATE item SET starred = %d WHERE uid = %d and id = %d",
intval($starred), intval($starred),
intval(local_user()), intval(local_user()),
intval($message_id) intval($message_id)

View File

@ -143,7 +143,7 @@ EOT;
$post_id = item_store($arr); $post_id = item_store($arr);
if(! $item['visible']) { if(! $item['visible']) {
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
intval($item['id']), intval($item['id']),
intval($owner_uid) intval($owner_uid)
); );

View File

@ -138,14 +138,14 @@ EOT;
$post_id = item_store($arr); $post_id = item_store($arr);
q("UPDATE `item` set plink = '%s' where id = %d limit 1", q("UPDATE `item` set plink = '%s' where id = %d",
dbesc($a->get_baseurl() . '/display/' . $owner_nick . '/' . $post_id), dbesc($a->get_baseurl() . '/display/' . $owner_nick . '/' . $post_id),
intval($post_id) intval($post_id)
); );
if(! $item['visible']) { if(! $item['visible']) {
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
intval($item['id']), intval($item['id']),
intval($owner_uid) intval($owner_uid)
); );
@ -157,7 +157,7 @@ EOT;
dbesc($term) dbesc($term)
); );
if((! $blocktags) && $t[0]['tcount']==0 ) { if((! $blocktags) && $t[0]['tcount']==0 ) {
/*q("update item set tag = '%s' where id = %d limit 1", /*q("update item set tag = '%s' where id = %d",
dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'), dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
intval($item['id']) intval($item['id'])
);*/ );*/
@ -197,7 +197,7 @@ EOT;
} }
/*if(count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) { /*if(count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) {
q("update item set tag = '%s' where id = %d limit 1", q("update item set tag = '%s' where id = %d",
dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'), dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
intval($r[0]['id']) intval($r[0]['id'])
); );

View File

@ -32,7 +32,7 @@ function tagrm_post(&$a) {
$tag_str = implode(',',$arr); $tag_str = implode(',',$arr);
q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc($tag_str), dbesc($tag_str),
intval($item), intval($item),
intval(local_user()) intval(local_user())

View File

@ -9,7 +9,7 @@ function wall_upload_post(&$a) {
if($a->argc > 1) { if($a->argc > 1) {
if(! x($_FILES,'media')) { if(! x($_FILES,'media')) {
$nick = $a->argv[1]; $nick = $a->argv[1];
$r = q("SELECT `user`.*, `contact`.`id` FROM `user` LEFT JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1", $r = q("SELECT `user`.*, `contact`.`id` FROM `user` INNER JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1",
dbesc($nick) dbesc($nick)
); );
@ -18,7 +18,7 @@ function wall_upload_post(&$a) {
} }
else { else {
$user_info = api_get_user($a); $user_info = api_get_user($a);
$r = q("SELECT `user`.*, `contact`.`id` FROM `user` LEFT JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1", $r = q("SELECT `user`.*, `contact`.`id` FROM `user` INNER JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1",
dbesc($user_info['screen_name']) dbesc($user_info['screen_name'])
); );
} }

View File

@ -269,22 +269,22 @@ class Item extends BaseObject {
} }
// Disable features that aren't available in several networks // Disable features that aren't available in several networks
if ($item["item_network"] != "dfrn") { if (($item["item_network"] != "dfrn") AND isset($buttons["dislike"])) {
unset($buttons["dislike"]); unset($buttons["dislike"]);
$tagger = ''; $tagger = '';
} }
if ($item["item_network"] == "feed") if (($item["item_network"] == "feed") AND isset($buttons["like"]))
unset($buttons["like"]); unset($buttons["like"]);
if ($item["item_network"] == "mail") if (($item["item_network"] == "mail") AND isset($buttons["like"]))
unset($buttons["like"]); unset($buttons["like"]);
if (($item["item_network"] == "dspr") AND ($indent == 'comment')) if (($item["item_network"] == "dspr") AND ($indent == 'comment') AND isset($buttons["like"]))
unset($buttons["like"]); unset($buttons["like"]);
// Facebook can like comments - but it isn't programmed in the connector yet. // Facebook can like comments - but it isn't programmed in the connector yet.
if (($item["item_network"] == "face") AND ($indent == 'comment')) if (($item["item_network"] == "face") AND ($indent == 'comment') AND isset($buttons["like"]))
unset($buttons["like"]); unset($buttons["like"]);

View File

@ -1,6 +1,6 @@
<?php <?php
define( 'UPDATE_VERSION' , 1169 ); define( 'UPDATE_VERSION' , 1170 );
/** /**
* *
@ -92,7 +92,7 @@ function update_1006() {
$spkey = openssl_pkey_get_details($sres); $spkey = openssl_pkey_get_details($sres);
$spubkey = $spkey["key"]; $spubkey = $spkey["key"];
$r = q("UPDATE `user` SET `spubkey` = '%s', `sprvkey` = '%s' $r = q("UPDATE `user` SET `spubkey` = '%s', `sprvkey` = '%s'
WHERE `uid` = %d LIMIT 1", WHERE `uid` = %d",
dbesc($spubkey), dbesc($spubkey),
dbesc($sprvkey), dbesc($sprvkey),
intval($rr['uid']) intval($rr['uid'])
@ -123,7 +123,7 @@ function update_1011() {
$r = q("SELECT * FROM `contact` WHERE 1"); $r = q("SELECT * FROM `contact` WHERE 1");
if(count($r)) { if(count($r)) {
foreach($r as $rr) { foreach($r as $rr) {
q("UPDATE `contact` SET `nick` = '%s' WHERE `id` = %d LIMIT 1", q("UPDATE `contact` SET `nick` = '%s' WHERE `id` = %d",
dbesc(basename($rr['url'])), dbesc(basename($rr['url'])),
intval($rr['id']) intval($rr['id'])
); );
@ -157,11 +157,11 @@ function update_1014() {
if(count($r)) { if(count($r)) {
foreach($r as $rr) { foreach($r as $rr) {
if(stristr($rr['thumb'],'avatar')) if(stristr($rr['thumb'],'avatar'))
q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d LIMIT 1", q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d",
dbesc(str_replace('avatar','micro',$rr['thumb'])), dbesc(str_replace('avatar','micro',$rr['thumb'])),
intval($rr['id'])); intval($rr['id']));
else else
q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d LIMIT 1", q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d",
dbesc(str_replace('5.jpg','6.jpg',$rr['thumb'])), dbesc(str_replace('5.jpg','6.jpg',$rr['thumb'])),
intval($rr['id'])); intval($rr['id']));
} }
@ -310,7 +310,7 @@ function update_1031() {
if($r && count($r)) { if($r && count($r)) {
foreach($r as $rr) { foreach($r as $rr) {
if(strstr($rr['object'],'type=&quot;http')) { if(strstr($rr['object'],'type=&quot;http')) {
q("UPDATE `item` SET `object` = '%s' WHERE `id` = %d LIMIT 1", q("UPDATE `item` SET `object` = '%s' WHERE `id` = %d",
dbesc(str_replace('type=&quot;http','href=&quot;http',$rr['object'])), dbesc(str_replace('type=&quot;http','href=&quot;http',$rr['object'])),
intval($rr['id']) intval($rr['id'])
); );
@ -357,7 +357,7 @@ function update_1036() {
$r = dbq("SELECT * FROM `contact` WHERE `network` = 'dfrn' && `photo` LIKE '%include/photo%' "); $r = dbq("SELECT * FROM `contact` WHERE `network` = 'dfrn' && `photo` LIKE '%include/photo%' ");
if(count($r)) { if(count($r)) {
foreach($r as $rr) { foreach($r as $rr) {
q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d LIMIT 1", q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d",
dbesc(str_replace('include/photo','photo',$rr['photo'])), dbesc(str_replace('include/photo','photo',$rr['photo'])),
dbesc(str_replace('include/photo','photo',$rr['thumb'])), dbesc(str_replace('include/photo','photo',$rr['thumb'])),
dbesc(str_replace('include/photo','photo',$rr['micro'])), dbesc(str_replace('include/photo','photo',$rr['micro'])),
@ -595,7 +595,7 @@ function update_1074() {
$r = q("SELECT `uid` FROM `profile` WHERE `is-default` = 1 AND `hidewall` = 1"); $r = q("SELECT `uid` FROM `profile` WHERE `is-default` = 1 AND `hidewall` = 1");
if(count($r)) { if(count($r)) {
foreach($r as $rr) foreach($r as $rr)
q("UPDATE `user` SET `hidewall` = 1 WHERE `uid` = %d LIMIT 1", q("UPDATE `user` SET `hidewall` = 1 WHERE `uid` = %d",
intval($rr['uid']) intval($rr['uid'])
); );
} }
@ -617,7 +617,7 @@ function update_1075() {
$found = false; $found = false;
} while ($found == true ); } while ($found == true );
q("UPDATE `user` SET `guid` = '%s' WHERE `uid` = %d LIMIT 1", q("UPDATE `user` SET `guid` = '%s' WHERE `uid` = %d",
dbesc($guid), dbesc($guid),
intval($rr['uid']) intval($rr['uid'])
); );
@ -736,7 +736,7 @@ function update_1087() {
intval($rr['id']) intval($rr['id'])
); );
if(count($x)) if(count($x))
q("UPDATE `item` SET `commented` = '%s' WHERE `id` = %d LIMIT 1", q("UPDATE `item` SET `commented` = '%s' WHERE `id` = %d",
dbesc($x[0]['cdate']), dbesc($x[0]['cdate']),
intval($rr['id']) intval($rr['id'])
); );
@ -855,7 +855,7 @@ function update_1100() {
$r = q("select id, url from contact where url != '' and nurl = '' "); $r = q("select id, url from contact where url != '' and nurl = '' ");
if(count($r)) { if(count($r)) {
foreach($r as $rr) { foreach($r as $rr) {
q("update contact set nurl = '%s' where id = %d limit 1", q("update contact set nurl = '%s' where id = %d",
dbesc(normalise_link($rr['url'])), dbesc(normalise_link($rr['url'])),
intval($rr['id']) intval($rr['id'])
); );
@ -1173,7 +1173,7 @@ function update_1136() {
foreach($arr as $x) { foreach($arr as $x) {
if($x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) { if($x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) {
$found = true; $found = true;
q("delete from config where id = %d limit 1", q("delete from config where id = %d",
intval($rr['id']) intval($rr['id'])
); );
} }
@ -1192,7 +1192,7 @@ function update_1136() {
foreach($arr as $x) { foreach($arr as $x) {
if($x['uid'] == $rr['uid'] && $x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) { if($x['uid'] == $rr['uid'] && $x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) {
$found = true; $found = true;
q("delete from pconfig where id = %d limit 1", q("delete from pconfig where id = %d",
intval($rr['id']) intval($rr['id'])
); );
} }
@ -1557,3 +1557,46 @@ function update_1168() {
return UPDATE_SUCCESS; return UPDATE_SUCCESS;
} }
function update_1169() {
$r = q("CREATE TABLE IF NOT EXISTS `thread` (
`iid` int(10) unsigned NOT NULL DEFAULT '0',
`uid` int(10) unsigned NOT NULL DEFAULT '0',
`contact-id` int(11) unsigned NOT NULL DEFAULT '0',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`commented` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`received` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`changed` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`wall` tinyint(1) NOT NULL DEFAULT '0',
`private` tinyint(1) NOT NULL DEFAULT '0',
`pubmail` tinyint(1) NOT NULL DEFAULT '0',
`moderated` tinyint(1) NOT NULL DEFAULT '0',
`visible` tinyint(1) NOT NULL DEFAULT '0',
`spam` tinyint(1) NOT NULL DEFAULT '0',
`starred` tinyint(1) NOT NULL DEFAULT '0',
`bookmark` tinyint(1) NOT NULL DEFAULT '0',
`unseen` tinyint(1) NOT NULL DEFAULT '1',
`deleted` tinyint(1) NOT NULL DEFAULT '0',
`origin` tinyint(1) NOT NULL DEFAULT '0',
`forum_mode` tinyint(1) NOT NULL DEFAULT '0',
`mention` tinyint(1) NOT NULL DEFAULT '0',
`network` char(32) NOT NULL,
PRIMARY KEY (`iid`),
KEY `created` (`created`),
KEY `commented` (`commented`),
KEY `uid_network_commented` (`uid`,`network`,`commented`),
KEY `uid_network_created` (`uid`,`network`,`created`),
KEY `uid_contactid_commented` (`uid`,`contact-id`,`commented`),
KEY `uid_contactid_created` (`uid`,`contact-id`,`created`),
KEY `wall_private_received` (`wall`,`private`,`received`),
KEY `uid_created` (`uid`,`created`),
KEY `uid_commented` (`uid`,`commented`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
if (!$r)
return UPDATE_FAILED;
proc_run('php',"include/threadupdate.php");
return UPDATE_SUCCESS;
}

View File

@ -130,6 +130,7 @@ img {
overflow: hidden; overflow: hidden;
padding: 1px; padding: 1px;
color: #999; color: #999;
vertical-align: text-top;
} }
.icon:hover { .icon:hover {
@ -144,8 +145,9 @@ img {
text-indent: 0px; text-indent: 0px;
} }
.icon.s10 { .icon.s10 {
min-width: 10px; /* min-width: 10px;
height: 10px; height: 10px; */
/* font-size: 10px; */
} }
.icon.s10.text { .icon.s10.text {
padding: 2px 0px 0px 15px; padding: 2px 0px 0px 15px;
@ -293,9 +295,10 @@ body {
/* font-family: 'Lato', "Helvetica Neue", Helvetica, Arial, sans-serif; */ /* font-family: 'Lato', "Helvetica Neue", Helvetica, Arial, sans-serif; */
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px; font-size: 14px;
/* font-size: 13px; */ /* font-size: 13px;
/* line-height: 19.5px; */ line-height: 19.5px; */
font-weight: 400; font-weight: 400;
font-style: normal;
/* background-color: #ffffff; */ /* background-color: #ffffff; */
/* background-color: #FAFAFA; */ /* background-color: #FAFAFA; */
background-color: rgb(229, 229, 229); background-color: rgb(229, 229, 229);
@ -378,8 +381,6 @@ code {
list-style: none; list-style: none;
border: 3px solid #364e59; border: 3px solid #364e59;
z-index: 100000; z-index: 100000;
-webkit-box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.7);
-moz-box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.7);
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.7); box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.7);
} }
/* tool */ /* tool */
@ -446,11 +447,11 @@ code {
a.nets-link, .side-link a, #sidebar-new-group a, a.savedsearchterm, a.fileas-link, aside h4 a { a.nets-link, .side-link a, #sidebar-new-group a, a.savedsearchterm, a.fileas-link, aside h4 a {
display: block; display: block;
color: black; color: #737373;
} }
a.sidebar-group-element { a.sidebar-group-element {
color: black; color: #737373;
} }
#follow-sidebar form, #peoplefind-sidebar form, #netsearch-box form, #posted-date-selector { #follow-sidebar form, #peoplefind-sidebar form, #netsearch-box form, #posted-date-selector {
@ -468,7 +469,7 @@ a.sidebar-group-element {
} }
#forum-list a, .tool a, .admin.link a { #forum-list a, .tool a, .admin.link a {
color: black; color: #737373;
} }
#forum-list { #forum-list {
@ -553,9 +554,6 @@ nav {
background: linear-gradient(top, #516499 0%,#364a84 100%); */ background: linear-gradient(top, #516499 0%,#364a84 100%); */
color: #ffffff; color: #ffffff;
z-index: 100; z-index: 100;
/*-webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.7);
-moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.7);
border-bottom: 5px solid #F80; */
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.7); box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.7);
} }
@ -772,8 +770,6 @@ ul.menu-popup {
list-style: none; list-style: none;
border: 3px solid #364e59; border: 3px solid #364e59;
z-index: 100000; z-index: 100000;
-webkit-box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.7);
-moz-box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.7);
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.7); box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.7);
} }
ul.menu-popup a { ul.menu-popup a {
@ -814,8 +810,6 @@ ul.menu-popup .empty {
border: 1px solid #MenuBorder; border: 1px solid #MenuBorder;
overflow: auto; overflow: auto;
z-index: 100000; z-index: 100000;
-webkit-box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.7);
-moz-box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.7);
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.7); box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.7);
} }
.acpopupitem { .acpopupitem {
@ -878,7 +872,8 @@ aside {
padding: 10px 10px 0px 20px; padding: 10px 10px 0px 20px;
/* border-right: 1px solid #D2D2D2; */ /* border-right: 1px solid #D2D2D2; */
/* background-color: #ECECF2; */ /* background-color: #ECECF2; */
background-color: #F2F2F2; /* background-color: #F2F2F2; */
background-color: #FFFFFF;
font-size: 13px; font-size: 13px;
/* background: #F1F1F1; */ /* background: #F1F1F1; */
/* top: 0px; */ /* top: 0px; */
@ -891,7 +886,8 @@ aside {
height: 100%; height: 100%;
height: calc(100% - 42px); height: calc(100% - 42px);
/* overflow: scroll; */ /* overflow: scroll; */
box-shadow: 1px 1px 6px -3px #666; box-shadow: 1px 2px 0px 0px #D8D8D8;
color: #737373;
} }
aside .vcard .fn { aside .vcard .fn {
font-size: 18px; font-size: 18px;
@ -1090,6 +1086,11 @@ aside h4 {
} }
/* section */ /* section */
section { section {
/*font-size: 13px;
line-height: 19.5px;*/
font-size: 14.95px;
line-height: 21px;
/* font-family: Quodana,Verdana,DejaVu Sans,Bitstream Vera Sans,Helvetica,sans-serif; */
display: table-cell; display: table-cell;
vertical-align: top; vertical-align: top;
top: 32px; top: 32px;
@ -1121,7 +1122,7 @@ section.minimal {
position: relative; position: relative;
padding: 5px; padding: 5px;
margin-bottom: 10px; margin-bottom: 10px;
box-shadow: 1px 1px 6px -3px rgba(0, 0, 0, 0.7); box-shadow: 1px 2px 0px 0px #D8D8D8;
background-color: #FFFFFF; background-color: #FFFFFF;
/* width: 755px; */ /* width: 755px; */
} }
@ -1158,7 +1159,7 @@ section.minimal {
.wall-item-bottom { .wall-item-bottom {
/* font-size: 14px; */ /* font-size: 14px; */
} }
/* .wall-item-container .wall-item-bottom { */ .wall-item-container .wall-item-tags,
.wall-item-container .wall-item-links, .wall-item-container .wall-item-links,
.wall-item-container .wall-item-actions { .wall-item-container .wall-item-actions {
opacity: 0.2; opacity: 0.2;
@ -1168,7 +1169,7 @@ section.minimal {
-ms-transition: all 0.2s ease-in-out; -ms-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out;
} }
/* .wall-item-container:hover .wall-item-bottom { */ .wall-item-container:hover .wall-item-tags,
.wall-item-container:hover .wall-item-links, .wall-item-container:hover .wall-item-links,
.wall-item-container:hover .wall-item-actions { .wall-item-container:hover .wall-item-actions {
opacity: 1; opacity: 1;
@ -1209,6 +1210,25 @@ section.minimal {
font-size: 12px; font-size: 12px;
} }
.type-link {
border-top: 1px solid #D2D2D2;
border-bottom: 1px solid #D2D2D2;
display: block;
padding-top: 5px;
padding-bottom: 5px;
/*
padding-left: 170px;
min-height: 90px;
position: relative;
*/
}
.type-link:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.wall-item-container .wall-item-content .type-link img, .wall-item-container .wall-item-content .type-link img,
.type-link img { .type-link img {
max-width: 160px; max-width: 160px;
@ -1217,13 +1237,23 @@ section.minimal {
margin-right: 10px; margin-right: 10px;
} }
.type-link blockquote { .type-link blockquote {
margin-left: 160px; /* margin-left: 160px; */
margin-left: 0px;
max-height: 160px; max-height: 160px;
overflow: hidden; overflow: hidden;
border-left: 0px;
padding-left: 0px;
} }
.type-link .oembed { .type-link .oembed {
font-size: inherit;
} }
.type-link img {
/* position: absolute;
left: 0;
top: 0; */
}
.type-link span.oembed + br,
.type-link a + br,
.type-link img + br{ .type-link img + br{
display: none; display: none;
} }
@ -1454,7 +1484,7 @@ section.minimal {
} }
#profile-jot-form { #profile-jot-form {
box-shadow: 1px 1px 6px -3px #666; box-shadow: 1px 2px 0px 0px #D8D8D8;
background-color: #fafafa; background-color: #fafafa;
padding: 10px; padding: 10px;
} }
@ -1536,8 +1566,6 @@ section.minimal {
position: absolute !important; position: absolute !important;
top: 40px; top: 40px;
left: 30px; left: 30px;
-webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.7);
-moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.7);
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.7); box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.7);
} }
.wwto .contact-photo { .wwto .contact-photo {
@ -1923,18 +1951,18 @@ ul.tabs a {
} }
ul.tabs a { ul.tabs a {
box-shadow: 1px 1px 6px -3px #666; box-shadow: 1px 2px 0px 0px #D8D8D8;
margin-right: 5px; margin-right: 5px;
} }
#birthday-notice, #event-notice { #birthday-notice, #event-notice {
box-shadow: 1px 1px 6px -3px #666; box-shadow: 1px 2px 0px 0px #D8D8D8;
margin-bottom: 5px; margin-bottom: 5px;
} }
#birthday-wrapper, #event-wrapper { #birthday-wrapper, #event-wrapper {
background-color: #FAFAFA; background-color: #FAFAFA;
box-shadow: 1px 1px 6px -3px #666; box-shadow: 1px 2px 0px 0px #D8D8D8;
padding-left: 10px; padding-left: 10px;
padding-right: 10px; padding-right: 10px;
padding-top: 5px; padding-top: 5px;