aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Contact.php52
-rw-r--r--include/ConversationObject.php2
-rw-r--r--include/Import/Importer.php4
-rw-r--r--include/Import/refimport.php15
-rw-r--r--include/ItemObject.php22
-rw-r--r--include/RedDAV/RedDirectory.php12
-rw-r--r--include/activities.php5
-rw-r--r--include/api.php51
-rw-r--r--include/attach.php72
-rw-r--r--include/bb2diaspora.php2
-rw-r--r--include/bbcode.php46
-rw-r--r--include/comanche.php2
-rw-r--r--include/contact_widgets.php4
-rw-r--r--include/conversation.php17
-rwxr-xr-xinclude/diaspora.php60
-rw-r--r--include/dir_fns.php14
-rw-r--r--include/enotify.php9
-rw-r--r--include/event.php54
-rw-r--r--include/expire.php7
-rw-r--r--include/externals.php20
-rw-r--r--include/follow.php2
-rw-r--r--include/group.php5
-rw-r--r--include/hubloc.php15
-rw-r--r--include/identity.php20
-rwxr-xr-xinclude/items.php533
-rw-r--r--include/message.php22
-rw-r--r--include/network.php5
-rw-r--r--include/notifier.php42
-rw-r--r--include/notify.php5
-rw-r--r--include/onedirsync.php2
-rw-r--r--include/photo/photo_driver.php36
-rw-r--r--include/photos.php89
-rw-r--r--include/poller.php11
-rw-r--r--include/reddav.php2
-rw-r--r--include/socgraph.php25
-rw-r--r--include/statistics_fns.php9
-rw-r--r--include/taxonomy.php8
-rw-r--r--include/text.php78
-rw-r--r--include/widgets.php14
-rw-r--r--include/zot.php231
40 files changed, 823 insertions, 801 deletions
diff --git a/include/Contact.php b/include/Contact.php
index 9490fd2da..7e7649b94 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -22,9 +22,8 @@ function rconnect_url($channel_id,$xchan) {
if(($r) && ($r[0]['xchan_follow']))
return $r[0]['xchan_follow'];
- $r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and ( hubloc_flags & %d )>0 limit 1",
- dbesc($xchan),
- intval(HUBLOC_FLAGS_PRIMARY)
+ $r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and hubloc_primary = 1 limit 1",
+ dbesc($xchan)
);
if($r)
@@ -272,14 +271,12 @@ function channel_remove($channel_id, $local = true, $unset_session=true) {
);
- $r = q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_hash = '%s'",
- intval(HUBLOC_FLAGS_DELETED),
+ $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'",
dbesc($channel['channel_hash'])
);
- $r = q("update xchan set xchan_flags = (xchan_flags | %d) where xchan_hash = '%s'",
- intval(XCHAN_FLAGS_DELETED),
+ $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s'",
dbesc($channel['channel_hash'])
);
@@ -312,8 +309,7 @@ function channel_remove($channel_id, $local = true, $unset_session=true) {
intval($channel_id)
);
- $r = q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_hash = '%s' and hubloc_url = '%s' ",
- intval(HUBLOC_FLAGS_DELETED),
+ $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s' and hubloc_url = '%s' ",
dbesc($channel['channel_hash']),
dbesc(z_root())
);
@@ -322,16 +318,14 @@ function channel_remove($channel_id, $local = true, $unset_session=true) {
$hublocs = 0;
- $r = q("select hubloc_id from hubloc where hubloc_hash = '%s' and not (hubloc_flags & %d)>0",
- dbesc($channel['channel_hash']),
- intval(HUBLOC_FLAGS_DELETED)
+ $r = q("select hubloc_id from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0",
+ dbesc($channel['channel_hash'])
);
if($r)
$hublocs = count($r);
if(! $hublocs) {
- $r = q("update xchan set xchan_flags = (xchan_flags | %d) where xchan_hash = '%s' ",
- intval(XCHAN_FLAGS_DELETED),
+ $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s' ",
dbesc($channel['channel_hash'])
);
}
@@ -374,10 +368,8 @@ function mark_orphan_hubsxchans() {
if($dirmode == DIRECTORY_MODE_NORMAL)
return;
- $r = q("update hubloc set hubloc_status = (hubloc_status | %d) where (hubloc_status & %d) = 0
+ $r = q("update hubloc set hubloc_error = 1 where hubloc_error = 0
and hubloc_network = 'zot' and hubloc_connected < %s - interval %s",
- intval(HUBLOC_OFFLINE),
- intval(HUBLOC_OFFLINE),
db_utcnow(), db_quoteinterval('36 day')
);
@@ -394,27 +386,21 @@ function mark_orphan_hubsxchans() {
// }
- $r = q("select hubloc_id, hubloc_hash from hubloc where (hubloc_status & %d)>0 and not (hubloc_flags & %d)>0",
- intval(HUBLOC_OFFLINE),
- intval(HUBLOC_FLAGS_ORPHANCHECK)
- );
+ $r = q("select hubloc_id, hubloc_hash from hubloc where hubloc_error = 0 and hubloc_orphancheck = 0");
if($r) {
foreach($r as $rr) {
// see if any other hublocs are still alive for this channel
- $x = q("select * from hubloc where hubloc_hash = '%s' and not (hubloc_status & %d)>0",
- dbesc($rr['hubloc_hash']),
- intval(HUBLOC_OFFLINE)
+ $x = q("select * from hubloc where hubloc_hash = '%s' and hubloc_error = 0",
+ dbesc($rr['hubloc_hash'])
);
if($x) {
// yes - if the xchan was marked as an orphan, undo it
- $y = q("update xchan set xchan_flags = (xchan_flags & ~%d) where (xchan_flags & %d)>0 and xchan_hash = '%s'",
- intval(XCHAN_FLAGS_ORPHAN),
- intval(XCHAN_FLAGS_ORPHAN),
+ $y = q("update xchan set xchan_orphan = 0 where xchan_orphan = 1 and xchan_hash = '%s'",
dbesc($rr['hubloc_hash'])
);
@@ -423,16 +409,14 @@ function mark_orphan_hubsxchans() {
// nope - mark the xchan as an orphan
- $y = q("update xchan set xchan_flags = (xchan_flags | %d) where xchan_hash = '%s'",
- intval(XCHAN_FLAGS_ORPHAN),
+ $y = q("update xchan set xchan_orphan = 1 where xchan_hash = '%s'",
dbesc($rr['hubloc_hash'])
);
}
// mark that we've checked this entry so we don't need to do it again
- $y = q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_id = %d",
- intval(HUBLOC_FLAGS_ORPHANCHECK),
+ $y = q("update hubloc set hubloc_orphancheck = 1 where hubloc_id = %d",
dbesc($rr['hubloc_id'])
);
}
@@ -501,13 +485,11 @@ function remove_all_xchan_resources($xchan, $channel_id = 0) {
// directory servers need to keep the record around for sync purposes - mark it deleted
- $r = q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_hash = '%s'",
- intval(HUBLOC_FLAGS_DELETED),
+ $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'",
dbesc($xchan)
);
- $r = q("update xchan set xchan_flags = (xchan_flags | %d) where xchan_hash = '%s'",
- intval(XCHAN_FLAGS_DELETED),
+ $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s'",
dbesc($xchan)
);
}
diff --git a/include/ConversationObject.php b/include/ConversationObject.php
index af0bb8d2c..9598bf543 100644
--- a/include/ConversationObject.php
+++ b/include/ConversationObject.php
@@ -166,7 +166,7 @@ class Conversation extends BaseObject {
if(($item->get_data_value('author_xchan') === $ob_hash) || ($item->get_data_value('owner_xchan') === $ob_hash))
$item->set_commentable(true);
- if($item->get_data_value('item_flags') & ITEM_NOCOMMENT) {
+ if(intval($item->get_data_value('item_nocomment'))) {
$item->set_commentable(false);
}
elseif(($this->observer) && (! $item->is_commentable())) {
diff --git a/include/Import/Importer.php b/include/Import/Importer.php
index 5e684cd8e..cddfac7b5 100644
--- a/include/Import/Importer.php
+++ b/include/Import/Importer.php
@@ -1,11 +1,11 @@
<?php /** @file */
-namespace RedMatrix\Import;
+namespace Hubzilla\Import;
/**
* @brief Class Import
*
- * @package RedMatrix\Import
+ * @package Hubzilla\Import
*/
class Import {
diff --git a/include/Import/refimport.php b/include/Import/refimport.php
index b9b6bf639..7d32e143f 100644
--- a/include/Import/refimport.php
+++ b/include/Import/refimport.php
@@ -88,7 +88,11 @@ function refimport_content(&$a) {
$arr['author_xchan'] = $channel['channel_hash'];
$arr['owner_xchan'] = $channel['channel_hash'];
$arr['app'] = REFLECT_BLOGNAME;
- $arr['item_flags'] = ITEM_ORIGIN|ITEM_WALL|ITEM_THREAD_TOP;
+
+ $arr['item_origin'] = 1;
+ $arr['item_wall'] = 1;
+ $arr['item_thread_top'] = 1;
+
$arr['verb'] = ACTIVITY_POST;
// this is an assumption
@@ -205,7 +209,7 @@ function reflect_find_user($users,$name) {
function reflect_comment_store($channel,$post,$comment,$user) {
- // if the commenter was the channel owner, use their redmatrix xchan
+ // if the commenter was the channel owner, use their hubzilla xchan
if($comment['author'] === REFLECT_EXPORTUSERNAME && $comment['registered'])
$hash = $channel['xchan_hash'];
@@ -256,7 +260,12 @@ function reflect_comment_store($channel,$post,$comment,$user) {
$arr['edited'] = $comment['created'];
$arr['author_xchan'] = $hash;
$arr['owner_xchan'] = $channel['channel_hash'];
- $arr['item_flags'] = ITEM_ORIGIN|ITEM_WALL;
+<<<<<<< HEAD
+ $arr['item_origin'] = 1;
+=======
+ $arr['item_flags'] = ITEM_ORIGIN;
+>>>>>>> master
+ $arr['item_wall'] = 1;
$arr['verb'] = ACTIVITY_POST;
$arr['comment_policy'] = 'contacts';
diff --git a/include/ItemObject.php b/include/ItemObject.php
index d5601edf5..d23c1c658 100644
--- a/include/ItemObject.php
+++ b/include/ItemObject.php
@@ -152,7 +152,7 @@ class Item extends BaseObject {
}
}
- $consensus = (($item['item_flags'] & ITEM_CONSENSUS) ? true : false);
+ $consensus = (intval($item['item_consensus']) ? true : false);
if($consensus) {
$response_verbs[] = 'agree';
$response_verbs[] = 'disagree';
@@ -212,9 +212,9 @@ class Item extends BaseObject {
'do' => t("Add Star"),
'undo' => t("Remove Star"),
'toggle' => t("Toggle Star Status"),
- 'classdo' => (($item['item_flags'] & ITEM_STARRED) ? "hidden" : ""),
- 'classundo' => (($item['item_flags'] & ITEM_STARRED) ? "" : "hidden"),
- 'isstarred' => (($item['item_flags'] & ITEM_STARRED) ? "starred icon-star" : "unstarred icon-star-empty"),
+ 'classdo' => (intval($item['item_starred']) ? "hidden" : ""),
+ 'classundo' => (intval($item['item_starred']) ? "" : "hidden"),
+ 'isstarred' => (intval($item['item_starred']) ? "starred icon-star" : "unstarred icon-star-empty"),
'starred' => t('starred'),
);
@@ -224,9 +224,9 @@ class Item extends BaseObject {
}
- $verified = (($item['item_flags'] & ITEM_VERIFIED) ? t('Message signature validated') : '');
- $forged = ((($item['sig']) && (! ($item['item_flags'] & ITEM_VERIFIED))) ? t('Message signature incorrect') : '');
- $unverified = '' ; // (($this->is_wall_to_wall() && (! ($item['item_flags'] & ITEM_VERIFIED))) ? t('Message cannot be verified') : '');
+ $verified = (intval($item['item_verified']) ? t('Message signature validated') : '');
+ $forged = ((($item['sig']) && (! intval($item['item_verified']))) ? t('Message signature incorrect') : '');
+ $unverified = '' ; // (($this->is_wall_to_wall() && (! intval($item['item_verified']))) ? t('Message cannot be verified') : '');
@@ -373,12 +373,16 @@ class Item extends BaseObject {
$result['children'] = array();
$nb_children = count($children);
+ $visible_comments = get_config('system','expanded_comments');
+ if($visible_comments === false)
+ $visible_comments = 3;
+
if(($this->get_display_mode() === 'normal') && ($nb_children > 0)) {
foreach($children as $child) {
$result['children'][] = $child->get_template_data($conv_responses, $thread_level + 1);
}
// Collapse
- if(($nb_children > 2) || ($thread_level > 1)) {
+ if(($nb_children > $visible_comments) || ($thread_level > 1)) {
$result['children'][0]['comment_firstcollapsed'] = true;
$result['children'][0]['num_comments'] = $comment_count_txt;
$result['children'][0]['hide_text'] = t('[+] show all');
@@ -386,7 +390,7 @@ class Item extends BaseObject {
$result['children'][$nb_children - 1]['comment_lastcollapsed'] = true;
}
else {
- $result['children'][$nb_children - 3]['comment_lastcollapsed'] = true;
+ $result['children'][$nb_children - ($visible_comments + 1)]['comment_lastcollapsed'] = true;
}
}
}
diff --git a/include/RedDAV/RedDirectory.php b/include/RedDAV/RedDirectory.php
index 922be378d..005d81c75 100644
--- a/include/RedDAV/RedDirectory.php
+++ b/include/RedDAV/RedDirectory.php
@@ -213,8 +213,15 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
$filesize = 0;
$hash = random_string();
- $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, folder, flags, filetype, filesize, revision, data, created, edited, allow_cid, allow_gid, deny_cid, deny_gid )
- VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
+ $is_photo = 0;
+ $x = @getimagesize($src);
+ logger('getimagesize: ' . print_r($x,true), LOGGER_DATA);
+ if(($x) && ($x[2] === IMAGETYPE_GIF || $x[2] === IMAGETYPE_JPEG || $x[2] === IMAGETYPE_PNG)) {
+ $is_photo = 1;
+ }
+
+ $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, folder, flags, filetype, filesize, revision, is_photo, data, created, edited, allow_cid, allow_gid, deny_cid, deny_gid )
+ VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
intval($c[0]['channel_account_id']),
intval($c[0]['channel_id']),
dbesc($hash),
@@ -225,6 +232,7 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
dbesc($mimetype),
intval($filesize),
intval(0),
+ intval($is_photo),
dbesc($this->os_path . '/' . $hash),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
diff --git a/include/activities.php b/include/activities.php
index ca8863e51..df43f1f6f 100644
--- a/include/activities.php
+++ b/include/activities.php
@@ -21,7 +21,10 @@ function profile_activity($changed, $value) {
$arr['uid'] = local_channel();
$arr['aid'] = $self['channel_account_id'];
$arr['owner_xchan'] = $arr['author_xchan'] = $self['xchan_hash'];
- $arr['item_flags'] = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP;
+
+ $arr['item_wall'] = 1;
+ $arr['item_origin'] = 1;
+ $arr['item_thread_top'] = 1;
$arr['verb'] = ACTIVITY_UPDATE;
$arr['obj_type'] = ACTIVITY_OBJ_PROFILE;
diff --git a/include/api.php b/include/api.php
index 6eede68f4..a75aa2c32 100644
--- a/include/api.php
+++ b/include/api.php
@@ -344,13 +344,14 @@ require_once('include/items.php');
intval(api_user())
);
+ $item_normal = item_normal();
+
// count public wall messages
$r = q("SELECT COUNT(`id`) as `count` FROM `item`
WHERE `uid` = %d
- AND ( item_flags & %d )>0 and item_restrict = 0
+ AND item_wall = 1 $item_normal
AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''",
- intval($usr[0]['channel_id']),
- intval(ITEM_WALL)
+ intval($usr[0]['channel_id'])
);
$countitms = $r[0]['count'];
}
@@ -374,9 +375,8 @@ require_once('include/items.php');
$countfollowers = $r[0]['count'];
}
- $r = q("SELECT count(`id`) as `count` FROM item where ( item_flags & %d )>0 and uid = %d and item_restrict = 0",
- intval($uinfo[0]['channel_id']),
- intval(ITEM_STARRED)
+ $r = q("SELECT count(`id`) as `count` FROM item where item_starred = 1 and uid = %d " . item_normal(),
+ intval($uinfo[0]['channel_id'])
);
$starred = $r[0]['count'];
@@ -858,8 +858,10 @@ require_once('include/items.php');
function api_get_status($xchan_hash) {
require_once('include/security.php');
+ $item_normal = item_normal();
+
$lastwall = q("SELECT * from item where
- item_private = 0 and item_restrict = 0
+ item_private = 0 $item_normal
and author_xchan = '%s'
and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = ''
and verb = '%s'
@@ -921,9 +923,10 @@ require_once('include/items.php');
// get last public message
require_once('include/security.php');
+ $item_normal = item_normal();
$lastwall = q("SELECT * from item where
- item_private = 0 and item_restrict = 0
+ item_private = 0 $item_normal
and author_xchan = '%s'
and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = ''
and verb = '%s'
@@ -994,9 +997,10 @@ require_once('include/items.php');
$user_info = api_get_user($a);
require_once('include/security.php');
+ $item_normal = item_normal();
$lastwall = q("SELECT * from item where 1
- and item_private != 0 and item_restrict = 0
+ and item_private != 0 $item_normal
and author_xchan = '%s'
and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = ''
and verb = '%s'
@@ -1097,7 +1101,9 @@ require_once('include/items.php');
$sql_extra .= " and item_private = 0 ";
}
- $r = q("SELECT * from item WHERE uid = %d and item_restrict = 0
+ $item_normal = item_normal();
+
+ $r = q("SELECT * from item WHERE uid = %d $item_normal
$sql_extra
AND id > %d
ORDER BY received DESC LIMIT %d ,%d ",
@@ -1116,7 +1122,7 @@ require_once('include/items.php');
// at the network timeline just mark everything seen.
if (api_user() == $user_info['uid']) {
- $r = q("UPDATE `item` SET item_unseen = 0 where item_unseen = 1 and uid = %d",
+ $r = q("UPDATE item SET item_unseen = 0 WHERE item_unseen = 1 and uid = %d",
intval($user_info['uid'])
);
}
@@ -1163,11 +1169,12 @@ require_once('include/items.php');
if ($max_id > 0)
$sql_extra = 'AND `item`.`id` <= '.intval($max_id);
require_once('include/security.php');
+ $item_normal = item_normal();
- $r = q("select * from item where item_restrict = 0
- and allow_cid = '' and allow_gid = ''
+ $r = q("select * from item where allow_cid = '' and allow_gid = ''
and deny_cid = '' and deny_gid = ''
and item_private = 0
+ $item_normal
and uid = " . $sys['channel_id'] . "
$sql_extra
AND id > %d group by mid
@@ -1223,7 +1230,8 @@ require_once('include/items.php');
else
$sql_extra .= " AND `item`.`id` = %d";
- $r = q("select * from item where item_restrict = 0 $sql_extra",
+ $item_normal = item_normal();
+ $r = q("select * from item where true $item_normal $sql_extra",
intval($id)
);
xchan_query($r,true);
@@ -1263,7 +1271,9 @@ require_once('include/items.php');
$observer = get_app()->get_observer();
- $r = q("SELECT * from item where item_restrict = 0 and id = %d limit 1",
+ $item_normal = item_normal();
+
+ $r = q("SELECT * from item where and id = %d $item_normal limit 1",
intval($id)
);
@@ -1626,12 +1636,13 @@ require_once('include/items.php');
$sql_extra .= " and item_private = 0 ";
}
- $r = q("SELECT * from item WHERE uid = %d and item_restrict = 0
- and ( item_flags & %d ) > 0 $sql_extra
+ $item_normal = item_normal();
+
+ $r = q("SELECT * from item WHERE uid = %d $item_normal
+ and item_starred = 1 $sql_extra
AND id > %d
ORDER BY received DESC LIMIT %d ,%d ",
intval($user_info['uid']),
- intval(ITEM_STARRED),
intval($since_id),
intval($start),
intval($count)
@@ -1823,7 +1834,7 @@ require_once('include/items.php');
'in_reply_to_user_id' => $in_reply_to_user_id,
'in_reply_to_screen_name' => $in_reply_to_screen_name,
'geo' => '',
- 'favorited' => (($item['item_flags'] & ITEM_STARRED) ? true : false),
+ 'favorited' => (intval($item['item_starred']) ? true : false),
'user' => $status_user ,
'statusnet_html' => trim(prepare_text($item['body'],$item['mimetype'])),
@@ -1971,7 +1982,7 @@ require_once('include/items.php');
'broughtbyurl' => '', 'timezone' => 'UTC', 'closed' => $closed, 'inviteonly' => 'false',
'private' => $private, 'textlimit' => $textlimit, 'sslserver' => $sslserver, 'ssl' => $ssl,
'shorturllength' => '30',
- 'redmatrix' => array(
+ 'hubzilla' => array(
'PLATFORM_NAME' => PLATFORM_NAME,
'RED_VERSION' => RED_VERSION,
'ZOT_REVISION' => ZOT_REVISION,
diff --git a/include/attach.php b/include/attach.php
index 4bbda9530..946d2543a 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -202,7 +202,7 @@ function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $
// Retrieve all columns except 'data'
- $r = q("select id, aid, uid, hash, filename, filetype, filesize, revision, folder, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d $sql_extra $orderby $limit",
+ $r = q("select id, aid, uid, hash, filename, filetype, filesize, revision, folder, is_photo, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d $sql_extra $orderby $limit",
intval($channel_id)
);
@@ -310,7 +310,7 @@ function attach_by_hash_nodata($hash, $rev = 0) {
// Now we'll see if we can access the attachment
- $r = q("select id, aid, uid, hash, creator, filename, filetype, filesize, revision, folder, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d and hash = '%s' $sql_extra limit 1",
+ $r = q("select id, aid, uid, hash, creator, filename, filetype, filesize, revision, folder, is_photo, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d and hash = '%s' $sql_extra limit 1",
intval($r[0]['uid']),
dbesc($hash)
);
@@ -391,7 +391,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
if($options === 'update' && $arr && array_key_exists('revision',$arr))
$sql_options = " and revision = " . intval($arr['revision']) . " ";
- $x = q("select id, aid, uid, filename, filetype, filesize, hash, revision, folder, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where hash = '%s' and uid = %d $sql_options limit 1",
+ $x = q("select id, aid, uid, filename, filetype, filesize, hash, revision, folder, is_photo, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where hash = '%s' and uid = %d $sql_options limit 1",
dbesc($arr['hash']),
intval($channel_id)
);
@@ -430,13 +430,27 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
if(! isset($hash))
$hash = random_string();
+
+ $is_photo = 0;
+ $x = @getimagesize($src);
+ logger('getimagesize: ' . print_r($x,true), LOGGER_DATA);
+ if(($x) && ($x[2] === IMAGETYPE_GIF || $x[2] === IMAGETYPE_JPEG || $x[2] === IMAGETYPE_PNG)) {
+ $is_photo = 1;
+ }
+
+
+
+
+
+
$created = datetime_convert();
if($options === 'replace') {
- $r = q("update attach set filename = '%s', filetype = '%s', filesize = %d, data = '%s', edited = '%s' where id = %d and uid = %d",
+ $r = q("update attach set filename = '%s', filetype = '%s', filesize = %d, is_photo = %d, data = '%s', edited = '%s' where id = %d and uid = %d",
dbesc($filename),
dbesc($mimetype),
intval($filesize),
+ intval($is_photo),
dbescbin(@file_get_contents($src)),
dbesc($created),
intval($existing_id),
@@ -444,8 +458,8 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
);
}
elseif($options === 'revise') {
- $r = q("insert into attach ( aid, uid, hash, creator, filename, filetype, filesize, revision, data, created, edited, allow_cid, allow_gid, deny_cid, deny_gid )
- VALUES ( %d, %d, '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
+ $r = q("insert into attach ( aid, uid, hash, creator, filename, filetype, filesize, revision, is_photo, data, created, edited, allow_cid, allow_gid, deny_cid, deny_gid )
+ VALUES ( %d, %d, '%s', '%s', '%s', '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
intval($x[0]['aid']),
intval($channel_id),
dbesc($x[0]['hash']),
@@ -454,6 +468,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
dbesc($mimetype),
intval($filesize),
intval($x[0]['revision'] + 1),
+ intval($is_photo),
dbescbin(@file_get_contents($src)),
dbesc($created),
dbesc($created),
@@ -464,11 +479,12 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
);
}
elseif($options === 'update') {
- $r = q("update attach set filename = '%s', filetype = '%s', edited = '%s',
+ $r = q("update attach set filename = '%s', filetype = '%s', edited = '%s', is_photo = %d,
allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s' where id = %d and uid = %d",
dbesc((array_key_exists('filename',$arr)) ? $arr['filename'] : $x[0]['filename']),
dbesc((array_key_exists('filetype',$arr)) ? $arr['filetype'] : $x[0]['filetype']),
dbesc($created),
+ intval($is_photo),
dbesc((array_key_exists('allow_cid',$arr)) ? $arr['allow_cid'] : $x[0]['allow_cid']),
dbesc((array_key_exists('allow_gid',$arr)) ? $arr['allow_gid'] : $x[0]['allow_gid']),
dbesc((array_key_exists('deny_cid',$arr)) ? $arr['deny_cid'] : $x[0]['deny_cid']),
@@ -478,8 +494,8 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
);
}
else {
- $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, filesize, revision, data, created, edited, allow_cid, allow_gid,deny_cid, deny_gid )
- VALUES ( %d, %d, '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
+ $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, filesize, revision, is_photo, data, created, edited, allow_cid, allow_gid,deny_cid, deny_gid )
+ VALUES ( %d, %d, '%s', '%s', '%s', '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
intval($channel['channel_account_id']),
intval($channel_id),
dbesc($hash),
@@ -488,6 +504,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
dbesc($mimetype),
intval($filesize),
intval(0),
+ intval($is_photo),
dbescbin(@file_get_contents($src)),
dbesc($created),
dbesc($created),
@@ -508,7 +525,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
// Caution: This re-uses $sql_options set further above
- $r = q("select id, aid, uid, hash, creator, filename, filetype, filesize, revision, folder, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d and hash = '%s' $sql_options limit 1",
+ $r = q("select id, aid, uid, hash, creator, filename, filetype, filesize, revision, folder, is_photo, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d and hash = '%s' $sql_options limit 1",
intval($channel_id),
dbesc($hash)
);
@@ -568,7 +585,7 @@ function z_readdir($channel_id, $observer_hash, $pathname, $parent_hash = '') {
else
$paths = array($pathname);
- $r = q("select id, aid, uid, hash, creator, filename, filetype, filesize, revision, folder, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where id = %d and folder = '%s' and filename = '%s' and (flags & %d )>0 " . permissions_sql($channel_id),
+ $r = q("select id, aid, uid, hash, creator, filename, filetype, filesize, revision, folder, is_photo, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where id = %d and folder = '%s' and filename = '%s' and (flags & %d )>0 " . permissions_sql($channel_id),
intval($channel_id),
dbesc($parent_hash),
dbesc($paths[0]),
@@ -1036,9 +1053,13 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
$mid = item_message_id();
- $objtype = ACTIVITY_OBJ_FILE;
+ $arr = array();
- $item_flags = ITEM_WALL|ITEM_ORIGIN;
+ $arr['item_wall'] = 1;
+ $arr['item_origin'] = 1;
+ $arr['item_unseen'] = 1;
+
+ $objtype = ACTIVITY_OBJ_FILE;
$private = (($arr_allow_cid[0] || $arr_allow_gid[0] || $arr_deny_cid[0] || $arr_deny_gid[0]) ? 1 : 0);
@@ -1077,23 +1098,20 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
$u_mid = item_message_id();
- $arr = array();
-
$arr['aid'] = get_account_id();
$arr['uid'] = $channel_id;
$arr['mid'] = $u_mid;
$arr['parent_mid'] = $u_mid;
- $arr['item_flags'] = $item_flags;
- $arr['item_unseen'] = 1;
$arr['author_xchan'] = $poster['xchan_hash'];
$arr['owner_xchan'] = $poster['xchan_hash'];
$arr['title'] = '';
- $arr['allow_cid'] = perms2str($u_arr_allow_cid);
- $arr['allow_gid'] = perms2str($u_arr_allow_gid);
- $arr['deny_cid'] = perms2str($u_arr_deny_cid);
- $arr['deny_gid'] = perms2str($u_arr_deny_gid);
- $arr['item_restrict'] = ITEM_HIDDEN;
- $arr['item_private'] = $private;
+ //updates should be visible to everybody -> perms may have changed
+ $arr['allow_cid'] = '';
+ $arr['allow_gid'] = '';
+ $arr['deny_cid'] = '';
+ $arr['deny_gid'] = '';
+ $arr['item_hidden'] = 1;
+ $arr['item_private'] = 0;
$arr['verb'] = ACTIVITY_UPDATE;
$arr['obj_type'] = $objtype;
$arr['object'] = $u_jsonobject;
@@ -1124,7 +1142,8 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
$arr['uid'] = $channel_id;
$arr['mid'] = $mid;
$arr['parent_mid'] = $mid;
- $arr['item_flags'] = $item_flags;
+ $arr['item_wall'] = 1;
+ $arr['item_origin'] = 1;
$arr['item_unseen'] = 1;
$arr['author_xchan'] = $poster['xchan_hash'];
$arr['owner_xchan'] = $poster['xchan_hash'];
@@ -1133,7 +1152,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
$arr['allow_gid'] = perms2str($arr_allow_gid);
$arr['deny_cid'] = perms2str($arr_deny_cid);
$arr['deny_gid'] = perms2str($arr_deny_gid);
- $arr['item_restrict'] = ITEM_HIDDEN;
+ $arr['item_hidden'] = 1;
$arr['item_private'] = $private;
$arr['verb'] = (($update) ? ACTIVITY_UPDATE : ACTIVITY_POST);
$arr['obj_type'] = $objtype;
@@ -1165,7 +1184,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
*/
function get_file_activity_object($channel_id, $hash, $cloudpath) {
- $x = q("SELECT creator, filename, filetype, filesize, revision, folder, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid FROM attach WHERE uid = %d AND hash = '%s' LIMIT 1",
+ $x = q("SELECT creator, filename, filetype, filesize, revision, folder, is_photo, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid FROM attach WHERE uid = %d AND hash = '%s' LIMIT 1",
intval($channel_id),
dbesc($hash)
);
@@ -1193,6 +1212,7 @@ function get_file_activity_object($channel_id, $hash, $cloudpath) {
'revision' => $x[0]['revision'],
'folder' => $x[0]['folder'],
'flags' => $x[0]['flags'],
+ 'is_photo' => $x[0]['is_photo'],
'created' => $x[0]['created'],
'edited' => $x[0]['edited'],
'allow_cid' => $x[0]['allow_cid'],
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index 8129ab5e6..fc82cb48c 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -326,7 +326,7 @@ function bb2diaspora_itembody($item, $force_update = false) {
$newitem = $item;
- if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED)) {
+ if(array_key_exists('item_obscured',$item) && intval($item['item_obscured'])) {
$key = get_config('system','prvkey');
$b = json_decode($item['body'],true);
// if called from diaspora_process_outbound, this decoding has already been done.
diff --git a/include/bbcode.php b/include/bbcode.php
index e248c3771..b8a62a2f2 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -402,10 +402,49 @@ function bb_sanitize_style($input) {
return '<span style="' . $css_string_san . '">' . $input[2] . '</span>';
}
+function bb_observer($Text) {
+
+ $a = get_app();
+
+ $observer = $a->get_observer();
+
+ if ((strpos($Text,'[/observer]') !== false) || (strpos($Text,'[/rpost]') !== false)) {
+ if ($observer) {
+ $Text = preg_replace("/\[observer\=1\](.*?)\[\/observer\]/ism", '$1', $Text);
+ $Text = preg_replace("/\[observer\=0\].*?\[\/observer\]/ism", '', $Text);
+ $Text = preg_replace_callback("/\[rpost(=(.*?))?\](.*?)\[\/rpost\]/ism", 'rpost_callback', $Text);
+ } else {
+ $Text = preg_replace("/\[observer\=1\].*?\[\/observer\]/ism", '', $Text);
+ $Text = preg_replace("/\[observer\=0\](.*?)\[\/observer\]/ism", '$1', $Text);
+ $Text = preg_replace("/\[rpost(=.*?)?\](.*?)\[\/rpost\]/ism", '', $Text);
+ }
+ }
+
+ $channel = $a->get_channel();
+
+ if (strpos($Text,'[/channel]') !== false) {
+ if ($channel) {
+ $Text = preg_replace("/\[channel\=1\](.*?)\[\/channel\]/ism", '$1', $Text);
+ $Text = preg_replace("/\[channel\=0\].*?\[\/channel\]/ism", '', $Text);
+ } else {
+ $Text = preg_replace("/\[channel\=1\].*?\[\/channel\]/ism", '', $Text);
+ $Text = preg_replace("/\[channel\=0\](.*?)\[\/channel\]/ism", '$1', $Text);
+ }
+ }
+
+ return $Text;
+}
+
+
+
+
+
+
+
// BBcode 2 HTML was written by WAY2WEB.net
// extended to work with Mistpark/Friendica/Red - Mike Macgirvin
-function bbcode($Text, $preserve_nl = false, $tryoembed = true) {
+function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) {
$a = get_app();
@@ -441,7 +480,8 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true) {
// process [observer] tags before we do anything else because we might
// be stripping away stuff that then doesn't need to be worked on anymore
- if(get_config('system','item_cache'))
+
+ if($cache)
$observer = false;
else
$observer = $a->get_observer();
@@ -458,7 +498,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true) {
}
}
- if(get_config('system','item_cache'))
+ if($cache)
$channel = false;
else
$channel = $a->get_channel();
diff --git a/include/comanche.php b/include/comanche.php
index cb46985eb..57056ae2a 100644
--- a/include/comanche.php
+++ b/include/comanche.php
@@ -5,7 +5,7 @@ require_once('include/menu.php');
require_once('include/widgets.php');
// When editing a webpage - a dropdown is needed to select a page layout
-// On submit, the pdl_select value (which is the mid of an item with item_restrict = ITEM_PDL) is stored in
+// On submit, the pdl_select value (which is the mid of an item with item_type = ITEM_TYPE_PDL) is stored in
// the webpage's resource_id, with resource_type 'pdl'.
// Then when displaying a webpage, we can see if it has a pdl attached. If not we'll
diff --git a/include/contact_widgets.php b/include/contact_widgets.php
index a02fea523..2c41ea92e 100644
--- a/include/contact_widgets.php
+++ b/include/contact_widgets.php
@@ -71,6 +71,8 @@ function categories_widget($baseurl,$selected = '') {
if(! feature_enabled($a->profile['profile_uid'],'categories'))
return '';
+ $item_normal = item_normal();
+
$terms = array();
$r = q("select distinct(term.term)
from term join item on term.oid = item.id
@@ -78,7 +80,7 @@ function categories_widget($baseurl,$selected = '') {
and term.uid = item.uid
and term.type = %d
and item.author_xchan = '%s'
- and item.item_restrict = 0
+ $item_normal
order by term.term asc",
intval($a->profile['profile_uid']),
intval(TERM_CATEGORY),
diff --git a/include/conversation.php b/include/conversation.php
index fb012667e..fe48ed2f5 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -96,7 +96,7 @@ function localize_item(&$item){
if(! $item['object'])
return;
- if($item['item_flags'] & ITEM_THREAD_TOP)
+ if(intval($item['item_thread_top']))
return;
$obj = json_decode_plus($item['object']);
@@ -356,21 +356,12 @@ function localize_item(&$item){
}
}
*/
- // add sparkle links to appropriate permalinks
-
-// $x = stristr($item['plink'],'/display/');
-// if($x) {
-// $sparkle = false;
-// $y = best_link_url($item,$sparkle,true);
- // if($sparkle)
-// $item['plink'] = $y . '?f=&url=' . $item['plink'];
-// }
// if item body was obscured and we changed it, re-obscure it
// FIXME - we need a better filter than just the string 'data'; try and
// match the fact that it's json encoded
- if(($item['item_flags'] & ITEM_OBSCURED)
+ if(intval($item['item_obscured'])
&& strlen($item['body']) && (! strpos($item['body'],'data'))) {
$item['body'] = json_encode(crypto_encapsulate($item['body'],get_config('system','pubkey')));
}
@@ -671,8 +662,8 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
$likebuttons = false;
$shareable = false;
- $verified = (($item['item_flags'] & ITEM_VERIFIED) ? t('Message signature validated') : '');
- $forged = ((($item['sig']) && (! ($item['item_flags'] & ITEM_VERIFIED))) ? t('Message signature incorrect') : '');
+ $verified = (intval($item['item_verified']) ? t('Message signature validated') : '');
+ $forged = ((($item['sig']) && (! intval($item['item_verified']))) ? t('Message signature incorrect') : '');
$unverified = '';
diff --git a/include/diaspora.php b/include/diaspora.php
index 33ad4211b..71425a6f8 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -65,8 +65,6 @@ function diaspora_dispatch($importer,$msg) {
}
$allowed = get_pconfig($importer['channel_id'],'system','diaspora_allowed');
- if($allowed === false)
- $allowed = 1;
if(! intval($allowed)) {
logger('mod-diaspora: disallowed for channel ' . $importer['channel_name']);
@@ -179,8 +177,6 @@ function diaspora_process_outbound($arr) {
$allowed = get_pconfig($arr['channel']['channel_id'],'system','diaspora_allowed');
- if($allowed === false)
- $allowed = 1;
if(! intval($allowed)) {
logger('mod-diaspora: disallowed for channel ' . $arr['channel']['channel_name']);
@@ -194,7 +190,7 @@ function diaspora_process_outbound($arr) {
$target_item = $arr['target_item'];
- if($target_item && array_key_exists('item_flags',$target_item) && ($target_item['item_flags'] & ITEM_OBSCURED)) {
+ if($target_item && array_key_exists('item_obscured',$target_item) && intval($target_item['item_obscured'])) {
$key = get_config('system','prvkey');
if($target_item['title'])
$target_item['title'] = crypto_unencapsulate(json_decode($target_item['title'],true),$key);
@@ -243,7 +239,7 @@ function diaspora_process_outbound($arr) {
if(! $contact['xchan_pubkey'])
continue;
- if(($target_item['item_restrict'] & ITEM_DELETED)
+ if(intval($target_item['item_deleted'])
&& (($target_item['mid'] === $target_item['parent_mid']) || $arr['followup'])) {
// send both top-level retractions and relayable retractions for owner to relay
diaspora_send_retraction($target_item,$arr['channel'],$contact);
@@ -272,8 +268,8 @@ function diaspora_process_outbound($arr) {
$contact = $arr['hub'];
- if(($target_item['deleted'])
- && ($target_item['mid'] === $target_item['parent_mod'])) {
+ if(intval($target_item['item_deleted'])
+ && ($target_item['mid'] === $target_item['parent_mid'])) {
// top-level retraction
logger('delivery: diaspora retract: ' . $loc);
diaspora_send_retraction($target_item,$arr['channel'],$contact,true);
@@ -349,7 +345,7 @@ function find_diaspora_person_by_handle($handle) {
if(! $person) {
// try webfinger. Make sure to distinguish between diaspora,
- // redmatrix w/diaspora protocol and friendica w/diaspora protocol.
+ // hubzilla w/diaspora protocol and friendica w/diaspora protocol.
$result = discover_by_webbie($handle);
if($result) {
@@ -728,6 +724,7 @@ function diaspora_request($importer,$xml) {
$msg = t('You have started sharing with a $Projectname premium channel.');
$msg .= t('$Projectname premium channels are not available for sharing with Diaspora members. This sharing request has been blocked.') . "\r";
+
$msg .= t('Please do not reply to this message, as this channel is not sharing with you and any reply will not be seen by the recipient.') . "\r";
$created = datetime_convert('UTC','UTC',$item['created'],'Y-m-d H:i:s \U\T\C');
@@ -984,9 +981,8 @@ function diaspora_post($importer,$xml,$msg) {
$datarray['app'] = $app;
- $datarray['item_flags'] = ITEM_THREAD_TOP;
$datarray['item_unseen'] = 1;
-
+ $datarray['item_thread_top'] = 1;
$tgroup = tgroup_check($importer['channel_id'],$datarray);
@@ -995,7 +991,6 @@ function diaspora_post($importer,$xml,$msg) {
return 202;
}
-
$result = item_store($datarray);
return;
@@ -1543,7 +1538,7 @@ function diaspora_comment($importer,$xml,$msg) {
$key = get_config('system','pubkey');
$x = array('signer' => $diaspora_handle, 'body' => $text,
'signed_text' => $signed_data, 'signature' => base64_encode($author_signature));
- $datarray['diaspora_meta'] = json_encode(crypto_encapsulate(json_encode($x),$key));
+ $datarray['diaspora_meta'] = json_encode($x);
}
@@ -1567,7 +1562,7 @@ function diaspora_comment($importer,$xml,$msg) {
if($result && $result['success'])
$message_id = $result['item_id'];
- if(($parent_item['item_flags'] & ITEM_ORIGIN) && (! $parent_author_signature)) {
+ if(intval($parent_item['item_origin']) && (! $parent_author_signature)) {
// if the message isn't already being relayed, notify others
// the existence of parent_author_signature means the parent_author or owner
// is already relaying.
@@ -1724,11 +1719,10 @@ function diaspora_conversation($importer,$xml,$msg) {
continue;
}
- $key = get_config('system','pubkey');
if($subject)
- $subject = json_encode(crypto_encapsulate($subject,$key));
+ $subject = str_rot47(base64url_encode($subject));
if($body)
- $body = json_encode(crypto_encapsulate($body,$key));
+ $body = str_rot47(base64url_encode($body));
q("insert into mail ( `channel_id`, `convid`, `from_xchan`,`to_xchan`,`title`,`body`,`mail_flags`,`mid`,`parent_mid`,`created`) values ( %d, %d, '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s')",
intval($importer['channel_id']),
@@ -1858,9 +1852,9 @@ function diaspora_message($importer,$xml,$msg) {
$key = get_config('system','pubkey');
if($subject)
- $subject = json_encode(crypto_encapsulate($subject,$key));
+ $subject = str_rot47(base64url_encode($subject));
if($body)
- $body = json_encode(crypto_encapsulate($body,$key));
+ $body = str_rot47(base64url_encode($body));
q("insert into mail ( `channel_id`, `convid`, `from_xchan`,`to_xchan`,`title`,`body`,`mail_flags`,`mid`,`parent_mid`,`created`) values ( %d, %d, '%s', '%s', '%s', '%s', '%d','%s','%s','%s')",
intval($importer['channel_id']),
@@ -2157,7 +2151,7 @@ function diaspora_like($importer,$xml,$msg) {
$key = get_config('system','pubkey');
$x = array('signer' => $diaspora_handle, 'body' => $text,
'signed_text' => $signed_data, 'signature' => base64_encode($author_signature));
- $arr['diaspora_meta'] = json_encode(crypto_encapsulate(json_encode($x),$key));
+ $arr['diaspora_meta'] = json_encode($x);
}
$x = item_store($arr);
@@ -2169,7 +2163,7 @@ function diaspora_like($importer,$xml,$msg) {
// the existence of parent_author_signature means the parent_author or owner
// is already relaying. The parent_item['origin'] indicates the message was created on our system
- if(($parent_item['item_flags'] & ITEM_ORIGIN) && (! $parent_author_signature))
+ if(intval($parent_item['item_origin']) && (! $parent_author_signature))
proc_run('php','include/notifier.php','comment-import',$message_id);
return;
@@ -2278,19 +2272,12 @@ function diaspora_signed_retraction($importer,$xml,$msg) {
$r[0]['parent']
);
if($p) {
- if(($p[0]['item_flags'] & ITEM_ORIGIN) && (! $parent_author_signature)) {
-// FIXME so we can relay this
-// q("insert into sign (`retract_iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
-// $r[0]['id'],
-// dbesc($signed_data),
-// dbesc($sig),
-// dbesc($diaspora_handle)
-// );
+ if(intval($p[0]['item_origin']) && (! $parent_author_signature)) {
// the existence of parent_author_signature would have meant the parent_author or owner
// is already relaying.
- logger('diaspora_signed_retraction: relaying relayable_retraction');
+ logger('diaspora_signed_retraction: relaying relayable_retraction');
proc_run('php','include/notifier.php','drop',$r[0]['id']);
}
}
@@ -2636,7 +2623,7 @@ function diaspora_send_followup($item,$owner,$contact,$public_batch = false) {
$target_type = 'Post';
$positive = 'true';
- if(($item_['item_restrict'] & ITEM_DELETED))
+ if(intval($item['item_deleted']))
logger('diaspora_send_followup: received deleted "like". Those should go to diaspora_send_retraction');
}
else {
@@ -2732,7 +2719,7 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
$relay_retract = false;
$sql_sign_id = 'iid';
- if( $item['item_restrict'] & ITEM_DELETED) {
+ if( intval($item['item_deleted'])) {
$relay_retract = true;
$target_type = ( ($item['verb'] === ACTIVITY_LIKE) ? 'Like' : 'Comment');
@@ -2744,7 +2731,7 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
$like = true;
$target_type = ( $parent['mid'] === $parent['parent_mid'] ? 'Post' : 'Comment');
-// $positive = (($item['item_restrict'] & ITEM_DELETED) ? 'false' : 'true');
+// $positive = (intval($item['item_deleted']) ? 'false' : 'true');
$positive = 'true';
$tpl = get_markup_template('diaspora_like_relay.tpl');
@@ -2894,11 +2881,10 @@ function diaspora_send_mail($item,$owner,$contact) {
);
if(array_key_exists('mail_flags',$item) && ($item['mail_flags'] & MAIL_OBSCURED)) {
- $key = get_config('system','prvkey');
-// if($item['title'])
-// $item['title'] = crypto_unencapsulate(json_decode_plus($item['title']),$key);
+ if($item['title'])
+ $item['title'] = base64url_decode(str_rot47($item['title']));
if($item['body'])
- $item['body'] = crypto_unencapsulate(json_decode_plus($item['body']),$key);
+ $item['body'] = base64url_decode(str_rot47($item['body']));
}
diff --git a/include/dir_fns.php b/include/dir_fns.php
index 77c78558c..902a0c1a3 100644
--- a/include/dir_fns.php
+++ b/include/dir_fns.php
@@ -414,19 +414,13 @@ function local_dir_update($uid, $force) {
logger('hidden: ' . $hidden);
- $r = q("select xchan_flags from xchan where xchan_hash = '%s' limit 1",
+ $r = q("select xchan_hidden from xchan where xchan_hash = '%s' limit 1",
dbesc($p[0]['channel_hash'])
);
- // Be careful - XCHAN_FLAGS_HIDDEN should evaluate to 1
- if (($r[0]['xchan_flags'] & XCHAN_FLAGS_HIDDEN) != $hidden)
- $new_flags = $r[0]['xchan_flags'] ^ XCHAN_FLAGS_HIDDEN;
- else
- $new_flags = $r[0]['xchan_flags'];
-
- if ($new_flags != $r[0]['xchan_flags']) {
- $r = q("update xchan set xchan_flags = %d where xchan_hash = '%s'",
- intval($new_flags),
+ if(intval($r[0]['xchan_hidden']) != $hidden) {
+ $r = q("update xchan set xchan_hidden = %d where xchan_hash = '%s'",
+ intval($hidden),
dbesc($p[0]['channel_hash'])
);
}
diff --git a/include/enotify.php b/include/enotify.php
index b1aae816b..cd49a9b34 100644
--- a/include/enotify.php
+++ b/include/enotify.php
@@ -82,8 +82,9 @@ function notification($params) {
localize_item($i);
$title = $i['title'];
$body = $i['body'];
- $private = (($i['item_private']) || ($i['item_flags'] & ITEM_OBSCURED));
- } else {
+ $private = (($i['item_private']) || intval($i['item_obscured']));
+ }
+ else {
$title = $params['item']['title'];
$body = $params['item']['body'];
}
@@ -171,7 +172,7 @@ function notification($params) {
$item_post_type);
// "your post"
- if($p[0]['owner']['xchan_name'] == $p[0]['author']['xchan_name'] && ($p[0]['item_flags'] & ITEM_WALL))
+ if($p[0]['owner']['xchan_name'] == $p[0]['author']['xchan_name'] && intval($p[0]['item_wall']))
$dest_str = sprintf(t('%1$s, %2$s commented on [zrl=%3$s]your %4$s[/zrl]'),
$recip['channel_name'],
'[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]',
@@ -642,4 +643,4 @@ class enotify {
);
logger("notification: enotify::send returns " . $res, LOGGER_DEBUG);
}
-} \ No newline at end of file
+}
diff --git a/include/event.php b/include/event.php
index 0b1e56ae2..0d8b2132b 100644
--- a/include/event.php
+++ b/include/event.php
@@ -471,48 +471,50 @@ function event_store_item($arr, $event) {
$private = (($arr['allow_cid'] || $arr['allow_gid'] || $arr['deny_cid'] || $arr['deny_gid']) ? 1 : 0);
+ $item_wall = 0;
+ $item_origin = 0;
+ $item_thread_top = 0;
+
if($item) {
$item_arr['id'] = $item['id'];
}
else {
$wall = (($z[0]['channel_hash'] == $event['event_xchan']) ? true : false);
-
- $item_flags = ITEM_THREAD_TOP;
+ $item_thread_top = 1;
if($wall) {
- $item_flags |= ITEM_WALL;
- $item_flags |= ITEM_ORIGIN;
+ $item_wall = 1;
+ $item_origin = 1;
}
- $item_arr['item_flags'] = $item_flags;
}
if(! $arr['mid'])
$arr['mid'] = item_message_id();
- $item_arr['aid'] = $z[0]['channel_account_id'];
- $item_arr['uid'] = $arr['uid'];
- $item_arr['author_xchan'] = $arr['event_xchan'];
- $item_arr['mid'] = $arr['mid'];
- $item_arr['parent_mid'] = $arr['mid'];
-
- $item_arr['owner_xchan'] = (($wall) ? $z[0]['channel_hash'] : $arr['event_xchan']);
- $item_arr['author_xchan'] = $arr['event_xchan'];
- $item_arr['title'] = $arr['summary'];
- $item_arr['allow_cid'] = $arr['allow_cid'];
- $item_arr['allow_gid'] = $arr['allow_gid'];
- $item_arr['deny_cid'] = $arr['deny_cid'];
- $item_arr['deny_gid'] = $arr['deny_gid'];
- $item_arr['item_private'] = $private;
- $item_arr['verb'] = ACTIVITY_POST;
+ $item_arr['aid'] = $z[0]['channel_account_id'];
+ $item_arr['uid'] = $arr['uid'];
+ $item_arr['author_xchan'] = $arr['event_xchan'];
+ $item_arr['mid'] = $arr['mid'];
+ $item_arr['parent_mid'] = $arr['mid'];
+ $item_arr['owner_xchan'] = (($wall) ? $z[0]['channel_hash'] : $arr['event_xchan']);
+ $item_arr['author_xchan'] = $arr['event_xchan'];
+ $item_arr['title'] = $arr['summary'];
+ $item_arr['allow_cid'] = $arr['allow_cid'];
+ $item_arr['allow_gid'] = $arr['allow_gid'];
+ $item_arr['deny_cid'] = $arr['deny_cid'];
+ $item_arr['deny_gid'] = $arr['deny_gid'];
+ $item_arr['item_private'] = $private;
+ $item_arr['verb'] = ACTIVITY_POST;
+ $item_arr['item_wall'] = $item_wall;
+ $item_arr['item_origin'] = $item_origin;
+ $item_arr['item_thread_top'] = $item_thread_top;;
if(array_key_exists('term', $arr))
$item_arr['term'] = $arr['term'];
- $item_arr['resource_type'] = 'event';
- $item_arr['resource_id'] = $event['event_hash'];
-
- $item_arr['obj_type'] = ACTIVITY_OBJ_EVENT;
-
- $item_arr['body'] = $prefix . format_event_bbcode($arr);
+ $item_arr['resource_type'] = 'event';
+ $item_arr['resource_id'] = $event['event_hash'];
+ $item_arr['obj_type'] = ACTIVITY_OBJ_EVENT;
+ $item_arr['body'] = $prefix . format_event_bbcode($arr);
// if it's local send the permalink to the channel page.
// otherwise we'll fallback to /display/$message_id
diff --git a/include/expire.php b/include/expire.php
index e5d456896..1af13163d 100644
--- a/include/expire.php
+++ b/include/expire.php
@@ -12,9 +12,7 @@ function expire_run($argv, $argc){
// perform final cleanup on previously delete items
- $r = q("select id from item where (item_restrict & %d) > 0 and (item_restrict & %d) = 0
- and changed < %s - INTERVAL %s",
- intval(ITEM_DELETED),
+ $r = q("select id from item where item_deleted = 1 and item_pending_remove = 0 and changed < %s - INTERVAL %s",
intval(ITEM_PENDING_REMOVE),
db_utcnow(), db_quoteinterval('10 DAY')
);
@@ -27,8 +25,7 @@ function expire_run($argv, $argc){
// physically remove anything that has been deleted for more than two months
/** @FIXME - this is a wretchedly inefficient query */
- $r = q("delete from item where ( item_restrict & %d ) > 0 and changed < %s - INTERVAL %s",
- intval(ITEM_PENDING_REMOVE),
+ $r = q("delete from item where item_pending_remove = 1 and changed < %s - INTERVAL %s",
db_utcnow(), db_quoteinterval('36 DAY')
);
diff --git a/include/externals.php b/include/externals.php
index b0f853dc6..3b6d170d5 100644
--- a/include/externals.php
+++ b/include/externals.php
@@ -93,26 +93,6 @@ function externals_run($argv, $argc){
$results = process_delivery(array('hash' => 'undefined'), get_item_elements($message),
array(array('hash' => $sys['xchan_hash'])), false, true);
$total ++;
-// $z = q("select id from item where mid = '%s' and uid = %d limit 1",
-// dbesc($message['message_id']),
-// intval($sys['channel_id'])
-// );
-$z = null;
- if($z) {
- $flag_bits = ITEM_WALL|ITEM_ORIGIN|ITEM_UPLINK;
- // preserve the source
-
- $r = q("update item set source_xchan = owner_xchan where id = %d",
- intval($z[0]['id'])
- );
-
- $r = q("update item set item_flags = ( item_flags | %d ), owner_xchan = '%s'
- where id = %d",
- intval($flag_bits),
- dbesc($sys['xchan_hash']),
- intval($z[0]['id'])
- );
- }
}
logger('externals: import_public_posts: ' . $total . ' messages imported', LOGGER_DEBUG);
}
diff --git a/include/follow.php b/include/follow.php
index 1e5df4cd5..4710f728c 100644
--- a/include/follow.php
+++ b/include/follow.php
@@ -137,8 +137,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
}
$allowed = get_pconfig($uid,'system','diaspora_allowed');
- if($allowed === false)
- $allowed = 1;
if(! intval($allowed)) {
$result['message'] = t('Protocol blocked for this channel.');
diff --git a/include/group.php b/include/group.php
index fe55ec23f..a5e25fb76 100644
--- a/include/group.php
+++ b/include/group.php
@@ -200,11 +200,10 @@ function group_get_members($gid) {
if(intval($gid)) {
$r = q("SELECT * FROM `group_member`
LEFT JOIN abook ON abook_xchan = `group_member`.`xchan` left join xchan on xchan_hash = abook_xchan
- WHERE `gid` = %d AND abook_channel = %d and `group_member`.`uid` = %d and not ( xchan_flags & %d )>0 and not ( abook_flags & %d )>0 and not ( abook_flags & %d )>0 ORDER BY xchan_name ASC ",
+ WHERE `gid` = %d AND abook_channel = %d and `group_member`.`uid` = %d and xchan_deleted = 0 and not ( abook_flags & %d )>0 and not ( abook_flags & %d )>0 ORDER BY xchan_name ASC ",
intval($gid),
intval(local_channel()),
intval(local_channel()),
- intval(XCHAN_FLAGS_DELETED),
intval(ABOOK_FLAG_BLOCKED),
intval(ABOOK_FLAG_PENDING)
);
@@ -245,7 +244,7 @@ function group_side($every="connections",$each="group",$edit = false, $group_id
$o = '';
- if(! local_channel())
+ if(! (local_channel() && feature_enabled(local_channel(),'groups')))
return '';
$groups = array();
diff --git a/include/hubloc.php b/include/hubloc.php
index a4efe1c75..515223f53 100644
--- a/include/hubloc.php
+++ b/include/hubloc.php
@@ -96,8 +96,7 @@ function remove_obsolete_hublocs() {
? intval(get_config('system','delivery_interval')) : 2 );
foreach($r as $rr) {
- q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_id = %d",
- intval(HUBLOC_FLAGS_DELETED),
+ q("update hubloc set hubloc_deleted = 1 where hubloc_id = %d",
intval($rr['hubloc_id'])
);
@@ -121,7 +120,7 @@ function hubloc_change_primary($hubloc) {
logger('no hubloc');
return false;
}
- if(! ($hubloc['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY)) {
+ if(! (intval($hubloc['hubloc_primary']))) {
logger('not primary: ' . $hubloc['hubloc_url']);
return false;
}
@@ -206,7 +205,7 @@ function xchan_store($arr) {
if(! $arr['photo'])
$arr['photo'] = z_root() . '/' . get_default_profile_photo();
- $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_instance_url, xchan_flags, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s','%s','%s','%s',%d,'%s') ",
+ $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_instance_url, xchan_hidden, xchan_orphan, xchan_censored, xchan_selfcensored, xchan_system, xchan_pubforum, xchan_deleted, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s','%s','%s','%s',%d, %d, %d, %d, %d, %d, %d, '%s') ",
dbesc($arr['hash']),
dbesc($arr['guid']),
dbesc($arr['guid_sig']),
@@ -219,7 +218,13 @@ function xchan_store($arr) {
dbesc($arr['name']),
dbesc($arr['network']),
dbesc($arr['instance_url']),
- intval($arr['flags']),
+ intval($arr['hidden']),
+ intval($arr['orphan']),
+ intval($arr['censored']),
+ intval($arr['selfcensored']),
+ intval($arr['system']),
+ intval($arr['pubforum']),
+ intval($arr['deleted']),
dbesc(datetime_convert())
);
if(! $r)
diff --git a/include/identity.php b/include/identity.php
index 29d9ef022..8081755b1 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -100,7 +100,7 @@ function create_sys_channel() {
'name' => 'System',
'pageflags' => PAGE_SYSTEM,
'publish' => 0,
- 'xchanflags' => XCHAN_FLAGS_SYSTEM
+ 'system' => 1
));
}
@@ -201,7 +201,7 @@ function create_identity($arr) {
$name = escape_tags($arr['name']);
$pageflags = ((x($arr,'pageflags')) ? intval($arr['pageflags']) : PAGE_NORMAL);
- $xchanflags = ((x($arr,'xchanflags')) ? intval($arr['xchanflags']) : XCHAN_FLAGS_NORMAL);
+ $system = ((x($arr,'system')) ? intval($arr['system']) : 0);
$name_error = validate_channelname($arr['name']);
if($name_error) {
$ret['message'] = $name_error;
@@ -300,14 +300,14 @@ function create_identity($arr) {
// Create a verified hub location pointing to this site.
- $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_flags,
+ $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_primary,
hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey, hubloc_network )
values ( '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s' )",
dbesc($guid),
dbesc($sig),
dbesc($hash),
dbesc($ret['channel']['channel_address'] . '@' . get_app()->get_hostname()),
- intval(($primary) ? HUBLOC_FLAGS_PRIMARY : 0),
+ intval($primary),
dbesc(z_root()),
dbesc(base64url_encode(rsa_sign(z_root(),$ret['channel']['channel_prvkey']))),
dbesc(get_app()->get_hostname()),
@@ -320,7 +320,7 @@ function create_identity($arr) {
$newuid = $ret['channel']['channel_id'];
- $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_follow, xchan_connurl, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_flags ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)",
+ $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_follow, xchan_connurl, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_system ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)",
dbesc($hash),
dbesc($guid),
dbesc($sig),
@@ -336,7 +336,7 @@ function create_identity($arr) {
dbesc('zot'),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
- intval($xchanflags)
+ intval($system)
);
// Not checking return value.
@@ -583,9 +583,7 @@ function identity_basic_export($channel_id, $items = false) {
/** @warning this may run into memory limits on smaller systems */
- $r = q("select * from item where (item_flags & %d)>0 and not (item_restrict & %d)>0 and uid = %d",
- intval(ITEM_WALL),
- intval(ITEM_DELETED),
+ $r = q("select * from item where item_wall = 1 and item_deleted = 0 and uid = %d",
intval($channel_id)
);
if($r) {
@@ -1376,7 +1374,7 @@ function get_default_profile_photo($size = 175) {
}
/**
- * @brief Test whether a given identity is NOT a member of the Red Matrix.
+ * @brief Test whether a given identity is NOT a member of the Hubzilla.
*
* @param string $s;
* xchan_hash of the identity in question
@@ -1387,7 +1385,7 @@ function is_foreigner($s) {
}
/**
- * @brief Test whether a given identity is a member of the Red Matrix.
+ * @brief Test whether a given identity is a member of the Hubzilla.
*
* @param string $s;
* xchan_hash of the identity in question
diff --git a/include/items.php b/include/items.php
index 0dc6d6ed6..23561ef46 100755
--- a/include/items.php
+++ b/include/items.php
@@ -192,20 +192,30 @@ function comments_are_now_closed($item) {
return false;
}
+function item_normal() {
+ return " and item.item_hidden = 0 and item.item_type = 0 and item.item_deleted = 0
+ and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
+ and item.item_blocked = 0 ";
+}
+
/**
* @brief
*
* This is a compatibility function primarily for plugins, because
- * in future hubzilla (and later) DB schemas the definition of a
- * normal item gets a bit more complicated.
+ * in earlier DB schemas this was a much simpler single integer compare
*
*/
function is_item_normal($item) {
- return((intval($item['item_restrict'])) ? false : true);
-}
+ if(intval($item['item_hidden']) || intval($item['item_type']) || intval($item['item_deleted'])
+ || intval($item['item_unpublished']) || intval($item['item_delayed']) || intval($item['item_pending_remove'])
+ || intval($item['item_blocked']))
+ return false;
+ return true;
+
+}
/**
* @brief
@@ -396,12 +406,12 @@ function post_activity_item($arr) {
if((($arr['parent']) && $arr['parent'] != $arr['id']) || (($arr['parent_mid']) && $arr['parent_mid'] != $arr['mid']))
$is_comment = true;
- if(! x($arr,'item_flags')) {
- if($is_comment)
- $arr['item_flags'] = ITEM_ORIGIN;
- else
- $arr['item_flags'] = ITEM_ORIGIN | ITEM_WALL | ITEM_THREAD_TOP;
- }
+ if(! array_key_exists('item_origin',$arr))
+ $arr['item_origin'] = 1;
+ if(! array_key_exists('item_wall',$arr) && (! $is_comment))
+ $arr['item_wall'] = 1;
+ if(! array_key_exists('item_thread_top',$arr) && (! $is_comment))
+ $arr['item_thread_top'] = 1;
$channel = get_app()->get_channel();
$observer = get_app()->get_observer();
@@ -428,17 +438,9 @@ function post_activity_item($arr) {
if($channel) {
if($channel['channel_hash'] === $arr['author_xchan']) {
$arr['sig'] = base64url_encode(rsa_sign($arr['body'],$channel['channel_prvkey']));
- $arr['item_flags'] = $arr['item_flags'] | ITEM_VERIFIED;
+ $arr['item_verified'] = 1;
}
}
-
- logger('Encrypting local storage');
- $key = get_config('system','pubkey');
- $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED;
- if($arr['title'])
- $arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key));
- if($arr['body'])
- $arr['body'] = json_encode(crypto_encapsulate($arr['body'],$key));
}
$arr['mid'] = ((x($arr,'mid')) ? $arr['mid'] : item_message_id());
@@ -460,7 +462,7 @@ function post_activity_item($arr) {
$arr['comment_policy'] = map_scope($channel['channel_w_comment']);
- if ((! $arr['plink']) && ($arr['item_flags'] & ITEM_THREAD_TOP)) {
+ if ((! $arr['plink']) && (intval($arr['item_thread_top']))) {
$arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
}
@@ -866,7 +868,7 @@ function get_item_elements($x) {
$arr['sig'] = (($x['signature']) ? htmlspecialchars($x['signature'], ENT_COMPAT,'UTF-8',false) : '');
- $arr['diaspora_meta'] = (($x['diaspora_signature']) ? json_encode(crypto_encapsulate($x['diaspora_signature'],$key)) : '');
+ $arr['diaspora_meta'] = (($x['diaspora_signature']) ? json_encode($x['diaspora_signature']) : '');
$arr['object'] = activity_sanitise($x['object']);
$arr['target'] = activity_sanitise($x['target']);
@@ -878,11 +880,12 @@ function get_item_elements($x) {
$arr['item_flags'] = 0;
if(array_key_exists('flags',$x) && in_array('consensus',$x['flags']))
- $arr['item_flags'] |= ITEM_CONSENSUS;
+ $arr['item_consensus'] = 1;
+
if(array_key_exists('flags',$x) && in_array('deleted',$x['flags']))
- $arr['item_restrict'] |= ITEM_DELETED;
+ $arr['item_deleted'] = 1;
if(array_key_exists('flags',$x) && in_array('hidden',$x['flags']))
- $arr['item_restrict'] |= ITEM_HIDDEN;
+ $arr['item_hidden'] = 1;
// Here's the deal - the site might be down or whatever but if there's a new person you've never
// seen before sending stuff to your stream, we MUST be able to look them up and import their data from their
@@ -910,27 +913,13 @@ function get_item_elements($x) {
dbesc($arr['author_xchan'])
);
if($r && rsa_verify($x['body'],base64url_decode($arr['sig']),$r[0]['xchan_pubkey']))
- $arr['item_flags'] |= ITEM_VERIFIED;
+ $arr['item_verified'] = 1;
else
logger('get_item_elements: message verification failed.');
}
-
- // if it's a private post, encrypt it in the DB.
- // We have to do that here because we need to cleanse the input and prevent bad stuff from getting in,
- // and we need plaintext to do that.
-
-
- if(intval($arr['item_private'])) {
- $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED;
- if($arr['title'])
- $arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key));
- if($arr['body'])
- $arr['body'] = json_encode(crypto_encapsulate($arr['body'],$key));
- }
-
-
if(array_key_exists('revision',$x)) {
+
// extended export encoding
$arr['revision'] = $x['revision'];
@@ -942,9 +931,30 @@ function get_item_elements($x) {
$arr['postopts'] = $x['postopts'];
$arr['resource_id'] = $x['resource_id'];
$arr['resource_type'] = $x['resource_type'];
- $arr['item_restrict'] = $x['item_restrict'];
- $arr['item_flags'] = $x['item_flags'];
$arr['attach'] = $x['attach'];
+ $arr['item_origin'] = $x['item_origin'];
+ $arr['item_unseen'] = $x['item_unseen'];
+ $arr['item_starred'] = $x['item_starred'];
+ $arr['item_uplink'] = $x['item_uplink'];
+ $arr['item_consensus'] = $x['item_consensus'];
+ $arr['item_wall'] = $x['item_wall'];
+ $arr['item_thread_top'] = $x['item_thread_top'];
+ $arr['item_notshown'] = $x['item_notshown'];
+ $arr['item_nsfw'] = $x['item_nsfw'];
+ $arr['item_relay'] = $x['item_relay'];
+ $arr['item_mentionsme'] = $x['item_mentionsme'];
+ $arr['item_nocomment'] = $x['item_nocomment'];
+ $arr['item_obscured'] = $x['item_obscured'];
+ $arr['item_verified'] = $x['item_verified'];
+ $arr['item_retained'] = $x['item_retained'];
+ $arr['item_rss'] = $x['item_rss'];
+ $arr['item_deleted'] = $x['item_deleted'];
+ $arr['item_type'] = $x['item_type'];
+ $arr['item_hidden'] = $x['item_hidden'];
+ $arr['item_unpublished'] = $x['item_unpublished'];
+ $arr['item_delayed'] = $x['item_delayed'];
+ $arr['item_pending_remove'] = $x['item_pending_remove'];
+ $arr['item_blocked'] = $x['item_blocked'];
}
return $arr;
@@ -1127,7 +1137,7 @@ function encode_item($item,$mirror = false) {
$key = get_config('system','prvkey');
- if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED)) {
+ if(array_key_exists('item_obscured',$item) && intval($item['item_obscured'])) {
if($item['title'])
$item['title'] = crypto_unencapsulate(json_decode_plus($item['title']),$key);
if($item['body'])
@@ -1150,9 +1160,31 @@ function encode_item($item,$mirror = false) {
$x['postopts'] = $item['postopts'];
$x['resource_id'] = $item['resource_id'];
$x['resource_type'] = $item['resource_type'];
- $x['item_restrict'] = $item['item_restrict'];
- $x['item_flags'] = $item['item_flags'];
$x['attach'] = $item['attach'];
+ $x['item_origin'] = $item['item_origin'];
+ $x['item_unseen'] = $item['item_unseen'];
+ $x['item_starred'] = $item['item_starred'];
+ $x['item_uplink'] = $item['item_uplink'];
+ $x['item_consensus'] = $item['item_consensus'];
+ $x['item_wall'] = $item['item_wall'];
+ $x['item_thread_top'] = $item['item_thread_top'];
+ $x['item_notshown'] = $item['item_notshown'];
+ $x['item_nsfw'] = $item['item_nsfw'];
+ $x['item_relay'] = $item['item_relay'];
+ $x['item_mentionsme'] = $item['item_mentionsme'];
+ $x['item_nocomment'] = $item['item_nocomment'];
+ $x['item_obscured'] = $item['item_obscured'];
+ $x['item_verified'] = $item['item_verified'];
+ $x['item_retained'] = $item['item_retained'];
+ $x['item_rss'] = $item['item_rss'];
+ $x['item_deleted'] = $item['item_deleted'];
+ $x['item_type'] = $item['item_type'];
+ $x['item_hidden'] = $item['item_hidden'];
+ $x['item_unpublished'] = $item['item_unpublished'];
+ $x['item_delayed'] = $item['item_delayed'];
+ $x['item_pending_remove'] = $item['item_pending_remove'];
+ $x['item_blocked'] = $item['item_blocked'];
+
}
@@ -1193,7 +1225,7 @@ function encode_item($item,$mirror = false) {
$x['public_scope'] = $scope;
- if($item['item_flags'] & ITEM_NOCOMMENT)
+ if($item['item_nocomment'])
$x['comment_scope'] = 'none';
else
$x['comment_scope'] = $c_scope;
@@ -1201,9 +1233,15 @@ function encode_item($item,$mirror = false) {
if($item['term'])
$x['tags'] = encode_item_terms($item['term']);
- if($item['diaspora_meta'])
- $x['diaspora_signature'] = crypto_unencapsulate(json_decode($item['diaspora_meta'],true),$key);
-
+ if($item['diaspora_meta']) {
+ $z = json_decode($item['diaspora_meta'],true);
+ if($z) {
+ if(array_key_exists('iv',$z))
+ $x['diaspora_signature'] = crypto_unencapsulate($z,$key);
+ else
+ $x['diaspora_signature'] = $z;
+ }
+ }
logger('encode_item: ' . print_r($x,true), LOGGER_DATA);
return $x;
@@ -1416,17 +1454,17 @@ function encode_item_flags($item) {
$ret = array();
- if($item['item_restrict'] & ITEM_DELETED)
+ if(intval($item['item_deleted']))
$ret[] = 'deleted';
- if($item['item_restrict'] & ITEM_HIDDEN)
+ if(intval($item['item_hidden']))
$ret[] = 'hidden';
- if($item['item_flags'] & ITEM_THREAD_TOP)
+ if(intval($item['item_thread_top']))
$ret[] = 'thread_parent';
- if($item['item_flags'] & ITEM_NSFW)
+ if(intval($item['item_nsfw']))
$ret[] = 'nsfw';
- if($item['item_flags'] & ITEM_CONSENSUS)
+ if(intval($item['item_consensus']))
$ret[] = 'consensus';
- if($item['item_private'])
+ if(intval($item['item_private']))
$ret[] = 'private';
return $ret;
@@ -1438,11 +1476,10 @@ function encode_mail($item) {
$x['encoding'] = 'zot';
if(array_key_exists('mail_flags',$item) && ($item['mail_flags'] & MAIL_OBSCURED)) {
- $key = get_config('system','prvkey');
if($item['title'])
- $item['title'] = crypto_unencapsulate(json_decode_plus($item['title']),$key);
+ $item['title'] = base64url_decode(str_rot47($item['title']));
if($item['body'])
- $item['body'] = crypto_unencapsulate(json_decode_plus($item['body']),$key);
+ $item['body'] = base64url_decode(str_rot47($item['body']));
}
$x['message_id'] = $item['mid'];
@@ -1494,13 +1531,15 @@ function get_mail_elements($x) {
$key = get_config('system','pubkey');
$arr['mail_flags'] |= MAIL_OBSCURED;
- $arr['body'] = htmlspecialchars($arr['body'],ENT_COMPAT,'UTF-8',false);
- if($arr['body'])
- $arr['body'] = json_encode(crypto_encapsulate($arr['body'],$key));
- $arr['title'] = htmlspecialchars($arr['title'],ENT_COMPAT,'UTF-8',false);
- if($arr['title'])
- $arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key));
+ if($arr['body']) {
+ $arr['body'] = str_rot47(base64url_encode($arr['body']));
+ $arr['body'] = htmlspecialchars($arr['body'],ENT_COMPAT,'UTF-8',false);
+ }
+ if($arr['title']) {
+ $arr['title'] = str_rot47(base64url_encode($arr['title']));
+ $arr['title'] = htmlspecialchars($arr['title'],ENT_COMPAT,'UTF-8',false);
+ }
if($arr['created'] > datetime_convert())
$arr['created'] = datetime_convert();
@@ -1582,7 +1621,7 @@ function get_atom_elements($feed, $item, &$author) {
$res['title'] = unxmlify($item->get_title());
$res['body'] = unxmlify($item->get_content());
$res['plink'] = unxmlify($item->get_link(0));
- $res['item_flags'] = ITEM_RSS;
+ $res['item_rss'] = 1;
// removing the content of the title if its identically to the body
@@ -2022,11 +2061,11 @@ function item_store($arr, $allow_exec = false) {
// If a page layout is provided, ensure it exists and belongs to us.
if(array_key_exists('layout_mid',$arr) && $arr['layout_mid']) {
- $l = q("select item_restrict from item where mid = '%s' and uid = %d limit 1",
+ $l = q("select item_type from item where mid = '%s' and uid = %d limit 1",
dbesc($arr['layout_mid']),
intval($arr['uid'])
);
- if((! $l) || (! ($l[0]['item_restrict'] & ITEM_PDL)))
+ if((! $l) || (! ($l[0]['item_type'] != ITEM_TYPE_PDL)))
unset($arr['layout_mid']);
}
@@ -2055,12 +2094,13 @@ function item_store($arr, $allow_exec = false) {
$arr['deny_cid'] = ((x($arr,'deny_cid')) ? trim($arr['deny_cid']) : '');
$arr['deny_gid'] = ((x($arr,'deny_gid')) ? trim($arr['deny_gid']) : '');
$arr['item_private'] = ((x($arr,'item_private')) ? intval($arr['item_private']) : 0 );
- $arr['item_flags'] = ((x($arr,'item_flags')) ? intval($arr['item_flags']) : 0 );
+ $arr['item_wall'] = ((x($arr,'item_wall')) ? intval($arr['item_wall']) : 0 );
+ $arr['item_type'] = ((x($arr,'item_type')) ? intval($arr['item_type']) : 0 );
// only detect language if we have text content, and if the post is private but not yet
// obscured, make it so.
- if(! ($arr['item_flags'] & ITEM_OBSCURED)) {
+ if((! array_key_exists('item_obscured',$arr)) || $arr['item_obscured'] == 0) {
$arr['lang'] = detect_language($arr['body']);
// apply the input filter here - if it is obscured it has been filtered already
@@ -2070,7 +2110,7 @@ function item_store($arr, $allow_exec = false) {
$channel = get_app()->get_channel();
if($channel['channel_hash'] === $arr['author_xchan']) {
$arr['sig'] = base64url_encode(rsa_sign($arr['body'],$channel['channel_prvkey']));
- $arr['item_flags'] |= ITEM_VERIFIED;
+ $arr['item_verified'] = 1;
}
}
@@ -2086,14 +2126,6 @@ function item_store($arr, $allow_exec = false) {
}
$arr = $translate['item'];
}
- if($arr['item_private']) {
- $key = get_config('system','pubkey');
- $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED;
- if($arr['title'])
- $arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key));
- if($arr['body'])
- $arr['body'] = json_encode(crypto_encapsulate($arr['body'],$key));
- }
}
if((x($arr,'object')) && is_array($arr['object'])) {
@@ -2135,16 +2167,16 @@ function item_store($arr, $allow_exec = false) {
$arr['plink'] = ((x($arr,'plink')) ? notags(trim($arr['plink'])) : '');
$arr['attach'] = ((x($arr,'attach')) ? notags(trim($arr['attach'])) : '');
$arr['app'] = ((x($arr,'app')) ? notags(trim($arr['app'])) : '');
- $arr['item_restrict'] = ((x($arr,'item_restrict')) ? intval($arr['item_restrict']) : 0 );
$arr['public_policy'] = ((x($arr,'public_policy')) ? notags(trim($arr['public_policy'])) : '' );
$arr['comment_policy'] = ((x($arr,'comment_policy')) ? notags(trim($arr['comment_policy'])) : 'contacts' );
+
+ if(! array_key_exists('item_unseen',$arr))
+ $arr['item_unseen'] = 1;
- $arr['item_unseen'] = ((array_key_exists('item_unseen',$arr)) ? intval($arr['item_unseen']) : 1);
-
- if($arr['comment_policy'] == 'none')
- $arr['item_flags'] = $arr['item_flags'] | ITEM_NOCOMMENT;
+ if((! array_key_exists('item_nocomment',$arr)) && ($arr['comment_policy'] == 'none'))
+ $arr['item_nocomment'] = 1;
// handle time travelers
// Allow a bit of fudge in case somebody just has a slightly slow/fast clock
@@ -2152,7 +2184,7 @@ function item_store($arr, $allow_exec = false) {
$d1 = new DateTime('now +10 minutes', new DateTimeZone('UTC'));
$d2 = new DateTime($arr['created'] . '+00:00');
if($d2 > $d1)
- $arr['item_restrict'] = $arr['item_restrict'] | ITEM_DELAYED_PUBLISH;
+ $arr['item_delayed'] = 1;
$arr['llink'] = z_root() . '/display/' . $arr['mid'];
@@ -2168,7 +2200,7 @@ function item_store($arr, $allow_exec = false) {
$deny_gid = $arr['deny_gid'];
$public_policy = $arr['public_policy'];
$comments_closed = $arr['comments_closed'];
- $arr['item_flags'] = $arr['item_flags'] | ITEM_THREAD_TOP;
+ $arr['item_thread_top'] = 1;
}
else {
@@ -2218,7 +2250,7 @@ function item_store($arr, $allow_exec = false) {
}
$parent_id = $r[0]['id'];
- $parent_deleted = $r[0]['item_restrict'] & ITEM_DELETED;
+ $parent_deleted = $r[0]['item_deleted'];
$allow_cid = $r[0]['allow_cid'];
$allow_gid = $r[0]['allow_gid'];
$deny_cid = $r[0]['deny_cid'];
@@ -2226,8 +2258,8 @@ function item_store($arr, $allow_exec = false) {
$public_policy = $r[0]['public_policy'];
$comments_closed = $r[0]['comments_closed'];
- if($r[0]['item_flags'] & ITEM_WALL)
- $arr['item_flags'] = $arr['item_flags'] | ITEM_WALL;
+ if(intval($r[0]['item_wall']))
+ $arr['item_wall'] = 1;
// An uplinked comment might arrive with a downstream owner.
// Fix it.
@@ -2246,7 +2278,7 @@ function item_store($arr, $allow_exec = false) {
// The original author commented, but as this is a comment, the permissions
// weren't fixed up so it will still show the comment as private unless we fix it here.
- if((intval($r[0]['item_flags']) & ITEM_UPLINK) && (! $r[0]['item_private']))
+ if(intval($r[0]['item_uplink']) && (! $r[0]['item_private']))
$arr['item_private'] = 0;
}
else {
@@ -2257,7 +2289,7 @@ function item_store($arr, $allow_exec = false) {
}
if($parent_deleted)
- $arr['item_restrict'] = $arr['item_restrict'] | ITEM_DELETED;
+ $arr['item_deleted'] = 1;
$r = q("SELECT `id` FROM `item` WHERE `mid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($arr['mid']),
@@ -2369,10 +2401,9 @@ function item_store($arr, $allow_exec = false) {
// update the commented timestamp on the parent
- $z = q("select max(created) as commented from item where parent_mid = '%s' and uid = %d and not ( item_restrict & %d )>0 ",
+ $z = q("select max(created) as commented from item where parent_mid = '%s' and uid = %d and item_delayed = 0 ",
dbesc($arr['parent_mid']),
- intval($arr['uid']),
- intval(ITEM_DELAYED_PUBLISH)
+ intval($arr['uid'])
);
q("UPDATE item set commented = '%s', changed = '%s' WHERE id = %d",
@@ -2387,7 +2418,7 @@ function item_store($arr, $allow_exec = false) {
// so that we have an item in the DB that's marked deleted and won't store a fresh post
// that isn't aware that we were already told to delete it.
- if(! ($arr['item_restrict'] & ITEM_DELETED)) {
+ if(! intval($arr['item_deleted'])) {
send_status_notifications($current_post,$arr);
tag_deliver($arr['uid'],$current_post);
}
@@ -2434,17 +2465,8 @@ function item_store_update($arr,$allow_exec = false) {
// override the unseen flag with the original
- if(intval($arr['item_flags']))
- $arr['item_unseen'] = 0;
-
- if($orig[0]['item_flags'] & ITEM_VERIFIED)
- $orig[0]['item_flags'] = $orig[0]['item_flags'] ^ ITEM_VERIFIED;
+ $arr['item_unseen'] = $orig[0]['item_unseen'];
- if($orig[0]['item_flags'] & ITEM_OBSCURED)
- $orig[0]['item_flags'] = $orig[0]['item_flags'] ^ ITEM_OBSCURED;
-
- $arr['item_flags'] = intval($arr['item_flags']) | $orig[0]['item_flags'];
- $arr['item_restrict'] = intval($arr['item_restrict']) | $orig[0]['item_restrict'];
if(array_key_exists('edit',$arr))
unset($arr['edit']);
@@ -2457,19 +2479,19 @@ function item_store_update($arr,$allow_exec = false) {
return $ret;
}
- if(! ($arr['item_flags'] & ITEM_OBSCURED)) {
+ if((! array_key_exists('item_obscured', $arr)) || $arr['item_obscured'] == 0) {
$arr['lang'] = detect_language($arr['body']);
- // apply the input filter here - if it is obscured it has been filtered already
- $arr['body'] = z_input_filter($arr['uid'],$arr['body'],$arr['mimetype']);
-
- if(local_channel() && (! $arr['sig'])) {
- $channel = get_app()->get_channel();
- if($channel['channel_hash'] === $arr['author_xchan']) {
- $arr['sig'] = base64url_encode(rsa_sign($arr['body'],$channel['channel_prvkey']));
- $arr['item_flags'] |= ITEM_VERIFIED;
- }
- }
+ // apply the input filter here - if it is obscured it has been filtered already
+ $arr['body'] = z_input_filter($arr['uid'],$arr['body'],$arr['mimetype']);
+
+ if(local_channel() && (! $arr['sig'])) {
+ $channel = get_app()->get_channel();
+ if($channel['channel_hash'] === $arr['author_xchan']) {
+ $arr['sig'] = base64url_encode(rsa_sign($arr['body'],$channel['channel_prvkey']));
+ $arr['item_verified'] = 1;
+ }
+ }
$allowed_languages = get_pconfig($arr['uid'],'system','allowed_languages');
@@ -2483,14 +2505,6 @@ function item_store_update($arr,$allow_exec = false) {
}
$arr = $translate['item'];
}
- if($arr['item_private']) {
- $key = get_config('system','pubkey');
- $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED;
- if($arr['title'])
- $arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key));
- if($arr['body'])
- $arr['body'] = json_encode(crypto_encapsulate($arr['body'],$key));
- }
}
if((x($arr,'object')) && is_array($arr['object'])) {
@@ -2550,11 +2564,35 @@ function item_store_update($arr,$allow_exec = false) {
$arr['title'] = ((array_key_exists('title',$arr) && strlen($arr['title'])) ? trim($arr['title']) : '');
$arr['body'] = ((array_key_exists('body',$arr) && strlen($arr['body'])) ? trim($arr['body']) : '');
+ $arr['html'] = ((array_key_exists('html',$arr) && strlen($arr['html'])) ? trim($arr['html']) : '');
+
+ $arr['attach'] = ((array_key_exists('attach',$arr)) ? notags(trim($arr['attach'])) : $orig[0]['attach']);
+ $arr['app'] = ((array_key_exists('app',$arr)) ? notags(trim($arr['app'])) : $orig[0]['app']);
+
+ $arr['item_origin'] = ((array_key_exists('item_origin',$arr)) ? intval($arr['item_origin']) : $orig[0]['item_origin'] );
+ $arr['item_unseen'] = ((array_key_exists('item_unseen',$arr)) ? intval($arr['item_unseen']) : $orig[0]['item_unseen'] );
+ $arr['item_starred'] = ((array_key_exists('item_starred',$arr)) ? intval($arr['item_starred']) : $orig[0]['item_starred'] );
+ $arr['item_uplink'] = ((array_key_exists('item_uplink',$arr)) ? intval($arr['item_uplink']) : $orig[0]['item_uplink'] );
+ $arr['item_consensus'] = ((array_key_exists('item_consensus',$arr)) ? intval($arr['item_consensus']) : $orig[0]['item_consensus'] );
+ $arr['item_wall'] = ((array_key_exists('item_wall',$arr)) ? intval($arr['item_wall']) : $orig[0]['item_wall'] );
+ $arr['item_thread_top'] = ((array_key_exists('item_thread_top',$arr)) ? intval($arr['item_thread_top']) : $orig[0]['item_thread_top'] );
+ $arr['item_notshown'] = ((array_key_exists('item_notshown',$arr)) ? intval($arr['item_notshown']) : $orig[0]['item_notshown'] );
+ $arr['item_nsfw'] = ((array_key_exists('item_nsfw',$arr)) ? intval($arr['item_nsfw']) : $orig[0]['item_nsfw'] );
+ $arr['item_relay'] = ((array_key_exists('item_relay',$arr)) ? intval($arr['item_relay']) : $orig[0]['item_relay'] );
+ $arr['item_mentionsme'] = ((array_key_exists('item_mentionsme',$arr)) ? intval($arr['item_mentionsme']) : $orig[0]['item_mentionsme'] );
+ $arr['item_nocomment'] = ((array_key_exists('item_nocomment',$arr)) ? intval($arr['item_nocomment']) : $orig[0]['item_nocomment'] );
+ $arr['item_obscured'] = ((array_key_exists('item_obscured',$arr)) ? intval($arr['item_obscured']) : $orig[0]['item_obscured'] );
+ $arr['item_verified'] = ((array_key_exists('item_verified',$arr)) ? intval($arr['item_verified']) : $orig[0]['item_verified'] );
+ $arr['item_retained'] = ((array_key_exists('item_retained',$arr)) ? intval($arr['item_retained']) : $orig[0]['item_retained'] );
+ $arr['item_rss'] = ((array_key_exists('item_rss',$arr)) ? intval($arr['item_rss']) : $orig[0]['item_rss'] );
+ $arr['item_deleted'] = ((array_key_exists('item_deleted',$arr)) ? intval($arr['item_deleted']) : $orig[0]['item_deleted'] );
+ $arr['item_type'] = ((array_key_exists('item_type',$arr)) ? intval($arr['item_type']) : $orig[0]['item_type'] );
+ $arr['item_hidden'] = ((array_key_exists('item_hidden',$arr)) ? intval($arr['item_hidden']) : $orig[0]['item_hidden'] );
+ $arr['item_unpublished'] = ((array_key_exists('item_unpublished',$arr)) ? intval($arr['item_unpublished']) : $orig[0]['item_unpublished'] );
+ $arr['item_delayed'] = ((array_key_exists('item_delayed',$arr)) ? intval($arr['item_delayed']) : $orig[0]['item_delayed'] );
+ $arr['item_pending_remove'] = ((array_key_exists('item_pending_remove',$arr)) ? intval($arr['item_pending_remove']) : $orig[0]['item_pending_remove'] );
+ $arr['item_blocked'] = ((array_key_exists('item_blocked',$arr)) ? intval($arr['item_blocked']) : $orig[0]['item_blocked'] );
- $arr['attach'] = ((x($arr,'attach')) ? notags(trim($arr['attach'])) : $orig[0]['attach']);
- $arr['app'] = ((x($arr,'app')) ? notags(trim($arr['app'])) : $orig[0]['app']);
-// $arr['item_restrict'] = ((x($arr,'item_restrict')) ? intval($arr['item_restrict']) : $orig[0]['item_restrict'] );
-// $arr['item_flags'] = ((x($arr,'item_flags')) ? intval($arr['item_flags']) : $orig[0]['item_flags'] );
$arr['sig'] = ((x($arr,'sig')) ? $arr['sig'] : '');
$arr['layout_mid'] = ((array_key_exists('layout_mid',$arr)) ? dbesc($arr['layout_mid']) : $orig[0]['layout_mid'] );
@@ -2664,11 +2702,10 @@ function store_diaspora_comment_sig($datarray, $channel, $parent_item, $post_id,
$x = array('signer' => $diaspora_handle, 'body' => $signed_body, 'signed_text' => $signed_text, 'signature' => base64_encode($authorsig));
- $key = get_config('system','pubkey');
- $y = crypto_encapsulate(json_encode($x),$key);
+ $y = json_encode($x);
$r = q("update item set diaspora_meta = '%s' where id = %d",
- dbesc(json_encode($y)),
+ dbesc($y),
intval($post_id)
);
@@ -2793,8 +2830,8 @@ function tag_deliver($uid, $item_id) {
$item = $i[0];
- if(($item['source_xchan']) && ($item['item_flags'] & ITEM_UPLINK)
- && ($item['item_flags'] & ITEM_THREAD_TOP) && ($item['edited'] != $item['created'])) {
+ if(($item['source_xchan']) && intval($item['item_uplink'])
+ && intval($item['item_thread_top']) && ($item['edited'] != $item['created'])) {
// this is an update (edit) to a post which was already processed by us and has a second delivery chain
// Just start the second delivery chain to deliver the updated post
proc_run('php','include/notifier.php','tgroup',$item['id']);
@@ -2816,7 +2853,7 @@ function tag_deliver($uid, $item_id) {
if($obj['id'] !== $u[0]['channel_hash'])
$poke_notify = false;
}
- if($item['item_restrict'] & ITEM_DELETED)
+ if(intval($item['item_deleted']))
$poke_notify = false;
$verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
@@ -2893,13 +2930,13 @@ function tag_deliver($uid, $item_id) {
// This might be a followup (e.g. comment) by the original post author to a tagged forum
// If so setup a second delivery chain
- if( ! ($item['item_flags'] & ITEM_THREAD_TOP)) {
+ if( ! intval($item['item_thread_top'])) {
$x = q("select * from item where id = parent and parent = %d and uid = %d limit 1",
intval($item['parent']),
intval($uid)
);
- if(($x) && ($x[0]['item_flags'] & ITEM_UPLINK)) {
+ if(($x) && intval($x[0]['item_uplink'])) {
start_delivery_chain($u[0],$item,$item_id,$x[0]);
}
}
@@ -2927,9 +2964,8 @@ function tag_deliver($uid, $item_id) {
if($mention) {
logger('tag_deliver: mention found for ' . $u[0]['channel_name']);
-
- $r = q("update item set item_flags = ( item_flags | %d ) where id = %d",
- intval(ITEM_MENTIONSME),
+
+ $r = q("update item set item_mentionsme = 1 where id = %d",
intval($item_id)
);
@@ -2939,7 +2975,7 @@ function tag_deliver($uid, $item_id) {
$body = '';
- if($item['item_flags'] & ITEM_OBSCURED) {
+ if(intval($item['item_obscured'])) {
$key = get_config('system','prvkey');
if($item['body'])
$body = crypto_unencapsulate(json_decode_plus($item['body']),$key);
@@ -3023,10 +3059,8 @@ function tag_deliver($uid, $item_id) {
// prevent delivery looping - only proceed
// if the message originated elsewhere and is a top-level post
- if(($item['item_flags'] & ITEM_WALL)
- || ($item['item_flags'] & ITEM_ORIGIN)
- || (!($item['item_flags'] & ITEM_THREAD_TOP))
- || ($item['id'] != $item['parent'])) {
+
+ if(intval($item['item_wall']) || intval($item['item_origin']) || (! intval($item['item_thread_top'])) || ($item['id'] != $item['parent'])) {
logger('tag_deliver: item was local or a comment. rejected.');
return;
}
@@ -3051,10 +3085,9 @@ function tgroup_check($uid,$item) {
// or is a followup and we have already accepted the top level post as an uplink
if($item['mid'] != $item['parent_mid']) {
- $r = q("select id from item where mid = '%s' and uid = %d and ( item_flags & %d )>0 limit 1",
+ $r = q("select id from item where mid = '%s' and uid = %d and item_uplink = 1 limit 1",
dbesc($item['parent_mid']),
- intval($uid),
- intval(ITEM_UPLINK)
+ intval($uid)
);
if($r)
return true;
@@ -3100,7 +3133,7 @@ function tgroup_check($uid,$item) {
$body = $item['body'];
- if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED) && $body) {
+ if(array_key_exists('item_obscured',$item) && intval($item['item_obscured']) && $body) {
$key = get_config('system','prvkey');
$body = crypto_unencapsulate(json_decode($body,true),$key);
}
@@ -3163,20 +3196,14 @@ function start_delivery_chain($channel, $item, $item_id, $parent) {
if((! $private) && $new_public_policy)
$private = 1;
- $flag_bits = $item['item_flags'] | ITEM_WALL;
-
- // The message didn't necessarily originate on this site, (we'll honour it if it did),
- // but the parent post of this thread will be reset as a local post, as it is the top of
- // this delivery chain and is coming from this site, regardless of where the original
- // originated.
-
- if(! $parent)
- $flag_bits = $flag_bits | ITEM_ORIGIN;
- // unset the nocomment bit if it's there.
+ $item_wall = 1;
+ $item_origin = 1;
+ $item_uplink = 0;
+ $item_nocomment = 0;
+ $item_obscured = 0;
- if($flag_bits & ITEM_NOCOMMENT)
- $flag_bits = $flag_bits ^ ITEM_NOCOMMENT;
+ $flag_bits = $item['item_flags'];
// maintain the original source, which will be the original item owner and was stored in source_xchan
// when we created the delivery fork
@@ -3188,7 +3215,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent) {
);
}
else {
- $flag_bits = $flag_bits | ITEM_UPLINK;
+ $item_uplink = 1;
$r = q("update item set source_xchan = owner_xchan where id = %d",
intval($item_id)
);
@@ -3197,29 +3224,22 @@ function start_delivery_chain($channel, $item, $item_id, $parent) {
$title = $item['title'];
$body = $item['body'];
- if($private) {
- if(!($flag_bits & ITEM_OBSCURED)) {
- $key = get_config('system','pubkey');
- $flag_bits = $flag_bits|ITEM_OBSCURED;
- if($title)
- $title = json_encode(crypto_encapsulate($title,$key));
- if($body)
- $body = json_encode(crypto_encapsulate($body,$key));
- }
- }
- else {
+ if(! $private) {
if($flag_bits & ITEM_OBSCURED) {
$key = get_config('system','prvkey');
- $flag_bits = $flag_bits ^ ITEM_OBSCURED;
if($title)
$title = crypto_unencapsulate(json_decode($title,true),$key);
if($body)
$body = crypto_unencapsulate(json_decode($body,true),$key);
+ $item_obscured = 0;
}
}
- $r = q("update item set item_flags = %d, owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s',
- deny_cid = '%s', deny_gid = '%s', item_private = %d, public_policy = '%s', comment_policy = '%s', title = '%s', body = '%s' where id = %d",
+ $r = q("update item set item_uplink = %d, item_nocomment = %d, item_obscured = %d, item_flags = %d, owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s',
+ deny_cid = '%s', deny_gid = '%s', item_private = %d, public_policy = '%s', comment_policy = '%s', title = '%s', body = '%s', item_wall = %d, item_origin = %d where id = %d",
+ intval($item_uplink),
+ intval($item_nocomment),
+ intval($item_obscured),
intval($flag_bits),
dbesc($channel['channel_hash']),
dbesc($channel['channel_allow_cid']),
@@ -3231,6 +3251,8 @@ function start_delivery_chain($channel, $item, $item_id, $parent) {
dbesc(map_scope($channel['channel_w_comment'])),
dbesc($title),
dbesc($body),
+ intval($item_wall),
+ $intval($item_origin),
intval($item_id)
);
@@ -3477,7 +3499,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
if($r) {
$item = $r[0];
- if(! ($item['item_restrict'] & ITEM_DELETED)) {
+ if(! intval($item['item_deleted'])) {
logger('consume_feed: deleting item ' . $item['id'] . ' mid=' . base64url_decode($item['mid']), LOGGER_DEBUG);
drop_item($item['id'],false);
}
@@ -3972,22 +3994,23 @@ function item_expire($uid,$days) {
$expire_network_only = 1;
+ $sql_extra = ((intval($expire_network_only)) ? " AND item_wall = 0 " : "");
+
$expire_limit = get_config('system','expire_limit');
if(! intval($expire_limit))
$expire_limit = 5000;
- $sql_extra = ((intval($expire_network_only)) ? " AND (item_flags & " . intval(ITEM_WALL) . ") = 0 " : "");
+ $item_normal = item_normal();
$r = q("SELECT * FROM `item`
WHERE `uid` = %d
AND `created` < %s - INTERVAL %s
AND `id` = `parent`
$sql_extra
- AND ( item_flags & %d ) = 0
- AND ( item_restrict = 0 ) LIMIT $expire_limit ",
+ AND item_retained = 0
+ $item_normal LIMIT $expire_limit ",
intval($uid),
- db_utcnow(), db_quoteinterval(intval($days).' DAY'),
- intval(ITEM_RETAINED)
+ db_utcnow(), db_quoteinterval(intval($days).' DAY')
);
if(! $r)
@@ -4011,7 +4034,7 @@ function item_expire($uid,$days) {
retain_item($item['id']);
continue;
}
- if($item['item_flags'] & ITEM_STARRED) {
+ if(intval($item['item_starred'])) {
retain_item($item['id']);
continue;
}
@@ -4023,8 +4046,7 @@ function item_expire($uid,$days) {
}
function retain_item($id) {
- $r = q("update item set item_flags = (item_flags | %d ) where id = %d",
- intval(ITEM_RETAINED),
+ $r = q("update item set item_retained = 1 where id = %d",
intval($id)
);
}
@@ -4069,7 +4091,7 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
intval($id)
);
- if((! $r) || (($r[0]['item_restrict'] & ITEM_DELETED) && ($stage === DROPITEM_NORMAL))) {
+ if((! $r) || (intval($r[0]['item_deleted']) && ($stage === DROPITEM_NORMAL))) {
if(! $interactive)
return 0;
notice( t('Item not found.') . EOL);
@@ -4105,10 +4127,16 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
// set the deleted flag immediately on this item just in case the
// hook calls a remote process which loops. We'll delete it properly in a second.
- $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ) WHERE id = %d",
- intval(($linked_item && ! $force) ? ITEM_HIDDEN : ITEM_DELETED),
- intval($item['id'])
- );
+ if(($linked_item) && (! $force)) {
+ $r = q("UPDATE item SET item_hidden = 1 WHERE id = %d",
+ intval($item['id'])
+ );
+ }
+ else {
+ $r = q("UPDATE item SET item_deleted = 1 WHERE id = %d",
+ intval($item['id'])
+ );
+ }
$arr = array('item' => $item, 'interactive' => $interactive, 'stage' => $stage);
call_hooks('drop_item', $arr );
@@ -4137,7 +4165,7 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
// We'll rely on the undocumented behaviour that DROPITEM_PHASE1 is (hopefully) only
// set if we know we're going to send delete notifications out to others.
- if((($item['item_flags'] & ITEM_WALL) && ($stage != DROPITEM_PHASE2)) || ($stage == DROPITEM_PHASE1))
+ if((intval($item['item_wall']) && ($stage != DROPITEM_PHASE2)) || ($stage == DROPITEM_PHASE1))
proc_run('php','include/notifier.php','drop',$notify_id);
goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
@@ -4169,9 +4197,8 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
switch($stage) {
case DROPITEM_PHASE2:
- $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), body = '', title = '',
+ $r = q("UPDATE item SET item_pending_remove = 1, body = '', title = '',
changed = '%s', edited = '%s' WHERE id = %d",
- intval(ITEM_PENDING_REMOVE),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($item['id'])
@@ -4179,30 +4206,37 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
break;
case DROPITEM_PHASE1:
- $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ),
- changed = '%s', edited = '%s' WHERE id = %d",
- intval(($linked_item && ! $force) ? ITEM_HIDDEN : ITEM_DELETED),
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- intval($item['id'])
- );
+ if($linked_item && ! $force) {
+ $r = q("UPDATE item SET item_hidden = 1,
+ changed = '%s', edited = '%s' WHERE id = %d",
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ intval($item['id'])
+ );
+ }
+ else {
+ $r = q("UPDATE item set item_deleted = 1, changed = '%s', edited = '%s' where if = %d",
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ intval($item['id'])
+ );
+ }
+
break;
case DROPITEM_NORMAL:
default:
if($linked_item && ! $force) {
- $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ),
+ $r = q("UPDATE item SET item_hidden = 1,
changed = '%s', edited = '%s' WHERE id = %d",
- intval(ITEM_HIDDEN),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($item['id'])
);
}
else {
- $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), body = '', title = '',
+ $r = q("UPDATE item SET item_deleted = 1, body = '', title = '',
changed = '%s', edited = '%s' WHERE id = %d",
- intval(ITEM_DELETED),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($item['id'])
@@ -4247,10 +4281,11 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
function first_post_date($uid,$wall = false) {
- $wall_sql = (($wall) ? sprintf(" and (item_flags & %d)>0 ", ITEM_WALL) : "" );
+ $wall_sql = (($wall) ? " and item_wall = 1 " : "" );
+ $item_normal = item_normal();
$r = q("select id, created from item
- where item_restrict = %d and uid = %d and id = parent $wall_sql
+ where uid = %d and id = parent $item_normal $wall_sql
order by created asc limit 1",
intval(ITEM_VISIBLE),
intval($uid)
@@ -4451,23 +4486,23 @@ function zot_feed($uid,$observer_hash,$arr) {
return array();
}
+ $item_normal = item_normal();
+
if(is_sys_channel($uid)) {
$r = q("SELECT parent, created, postopts from item
WHERE uid != %d
- AND item_private = 0 AND item_restrict = 0 AND uid in (" . stream_perms_api_uids(PERMS_PUBLIC,10,1) . ")
- AND (item_flags & %d) > 0
- $sql_extra GROUP BY parent ORDER BY created ASC $limit",
- intval($uid),
- intval(ITEM_WALL)
+ and uid in (" . stream_perms_api_uids(PERMS_PUBLIC,10,1) . ") $item_normal
+ AND item_wall = 1
+ and item_private = 0 $sql_extra GROUP BY parent ORDER BY created ASC $limit",
+ intval($uid)
);
}
else {
$r = q("SELECT parent, created, postopts from item
- WHERE uid = %d AND item_restrict = 0
- AND (item_flags & %d) > 0
+ WHERE uid = %d $item_normal
+ AND item_wall = 1
$sql_extra GROUP BY parent ORDER BY created ASC $limit",
- intval($uid),
- intval(ITEM_WALL)
+ intval($uid)
);
}
@@ -4480,10 +4515,10 @@ function zot_feed($uid,$observer_hash,$arr) {
$parents_str = ids_to_querystr($r,'parent');
$sys_query = ((is_sys_channel($uid)) ? $sql_extra : '');
+ $item_normal = item_normal();
$items = q("SELECT `item`.*, `item`.`id` AS `item_id` FROM `item`
- WHERE `item`.`item_restrict` = 0
- AND `item`.`parent` IN ( %s ) $sys_query ",
+ WHERE `item`.`parent` IN ( %s ) $item_normal $sys_query ",
dbesc($parents_str)
);
}
@@ -4521,6 +4556,8 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
$def_acl = '';
$item_uids = ' true ';
+ $item_normal = item_normal();
+
if ($arr['uid']) $uid= $arr['uid'];
@@ -4531,13 +4568,13 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
}
if($arr['star'])
- $sql_options .= " and (item_flags & " . intval(ITEM_STARRED) . ")>0 ";
+ $sql_options .= " and item_starred = 1 ";
if($arr['wall'])
- $sql_options .= " and (item_flags & " . intval(ITEM_WALL) . ")>0 ";
-
- $sql_extra = " AND item.parent IN ( SELECT parent FROM item WHERE (item_flags & " . intval(ITEM_THREAD_TOP) . ")>0 $sql_options ) ";
-
+ $sql_options .= " and item_wall = 1 ";
+
+ $sql_extra = " AND item.parent IN ( SELECT parent FROM item WHERE item_thread_top = 1 $sql_options ) ";
+
if($arr['since_id'])
$sql_extra .= " and item.id > " . $since_id . " ";
@@ -4567,7 +4604,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
return $result;
}
- $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str)) or allow_gid like '" . protect_sprintf('%<' . dbesc($r[0]['hash']) . '>%') . "' ) and id = parent and item_restrict = 0 ) ";
+ $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str)) or allow_gid like '" . protect_sprintf('%<' . dbesc($r[0]['hash']) . '>%') . "' ) and id = parent $item_normal ) ";
$x = group_rec_byhash($uid,$r[0]['hash']);
$result['headline'] = sprintf( t('Collection: %s'),$x['name']);
@@ -4579,7 +4616,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
intval(local_channel())
);
if ($r) {
- $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval($arr['uid']) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) and item_restrict = 0 ) ";
+ $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval($arr['uid']) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) $item_normal ) ";
$result['headline'] = sprintf( t('Connection: %s'),$r[0]['xchan_name']);
} else {
$result['message'] = t('Connection not found.');
@@ -4600,24 +4637,24 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
}
if($arr['search']) {
- if(strpos($arr['search'],'#') === 0)
- $sql_extra .= term_query('item',substr($arr['search'],1),TERM_HASHTAG);
- else
- $sql_extra .= sprintf(" AND item.body like '%s' ",
- dbesc(protect_sprintf('%' . $arr['search'] . '%'))
- );
- }
- if (strlen($arr['file'])) {
- $sql_extra .= term_query('item',$arr['files'],TERM_FILE);
- }
+ if(strpos($arr['search'],'#') === 0)
+ $sql_extra .= term_query('item',substr($arr['search'],1),TERM_HASHTAG);
+ else
+ $sql_extra .= sprintf(" AND item.body like '%s' ",
+ dbesc(protect_sprintf('%' . $arr['search'] . '%'))
+ );
+ }
- if ($arr['conv'] && $channel) {
- $sql_extra .= sprintf(" AND parent IN (SELECT distinct parent from item where ( author_xchan like '%s' or ( item_flags & %d )>0)) ",
- dbesc(protect_sprintf($uidhash)),
- intval(ITEM_MENTIONSME)
- );
- }
+ if(strlen($arr['file'])) {
+ $sql_extra .= term_query('item',$arr['files'],TERM_FILE);
+ }
+
+ if($arr['conv'] && $channel) {
+ $sql_extra .= sprintf(" AND parent IN (SELECT distinct parent from item where ( author_xchan like '%s' or item_mentionsme = 1 )) ",
+ dbesc(protect_sprintf($uidhash))
+ );
+ }
if (($client_mode & CLIENT_MODE_UPDATE) && (! ($client_mode & CLIENT_MODE_LOAD))) {
// only setup pagination on initial page view
@@ -4652,19 +4689,19 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
}
}
- $simple_update = (($client_mode & CLIENT_MODE_UPDATE) ? " and ( item.item_unseen = 1 ) " : '');
- if ($client_mode & CLIENT_MODE_LOAD)
- $simple_update = '';
+ $simple_update = (($client_mode & CLIENT_MODE_UPDATE) ? " and item.item_unseen = 1 " : '');
+ if($client_mode & CLIENT_MODE_LOAD)
+ $simple_update = '';
//$start = dba_timer();
require_once('include/security.php');
$sql_extra .= item_permissions_sql($channel['channel_id'],$observer_hash);
- if ($arr['pages'])
- $item_restrict = " AND (item_restrict & " . ITEM_WEBPAGE . ") ";
+ if($arr['pages'])
+ $item_restrict = " AND item_type = " . ITEM_TYPE_WEBPAGE . " ";
else
- $item_restrict = " AND item_restrict = 0 ";
+ $item_restrict = " AND item_type = 0 ";
if ($arr['nouveau'] && ($client_mode & CLIENT_MODE_LOAD) && $channel) {
// "New Item View" - show all items unthreaded in reverse created date order
@@ -4768,11 +4805,11 @@ function update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remo
if(! $post_id)
return;
- if($webpage & ITEM_WEBPAGE)
+ if($webpage == ITEM_TYPE_WEBPAGE)
$page_type = 'WEBPAGE';
- elseif($webpage & ITEM_BUILDBLOCK)
+ elseif($webpage == ITEM_TYPE_BLOCK)
$page_type = 'BUILDBLOCK';
- elseif($webpage & ITEM_PDL)
+ elseif($webpage == ITEM_TYPE_PDL)
$page_type = 'PDL';
elseif($namespace && $remote_id) {
$page_type = $namespace;
@@ -4981,4 +5018,4 @@ function asencode_person($p) {
);
return $ret;
-} \ No newline at end of file
+}
diff --git a/include/message.php b/include/message.php
index bfc92cd6d..8f1430e64 100644
--- a/include/message.php
+++ b/include/message.php
@@ -163,11 +163,10 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto='
$jattach = (($attachments) ? json_encode($attachments) : '');
- $key = get_config('system','pubkey');
if($subject)
- $subject = json_encode(crypto_encapsulate($subject,$key));
+ $subject = str_rot47(base64url_encode($subject));
if($body)
- $body = json_encode(crypto_encapsulate($body,$key));
+ $body = str_rot47(base64url_encode($body));
@@ -242,6 +241,8 @@ function private_messages_list($uid, $mailbox = '', $start = 0, $numitems = 0) {
$where = '';
$limit = '';
+ $t0 = dba_timer();
+
if($numitems)
$limit = " LIMIT " . intval($numitems) . " OFFSET " . intval($start);
@@ -284,11 +285,10 @@ function private_messages_list($uid, $mailbox = '', $start = 0, $numitems = 0) {
$r[$k]['to'] = find_xchan_in_array($rr['to_xchan'],$c);
$r[$k]['seen'] = (($rr['mail_flags'] & MAIL_SEEN) ? 1 : 0);
if($r[$k]['mail_flags'] & MAIL_OBSCURED) {
- $key = get_config('system','prvkey');
if($r[$k]['title'])
- $r[$k]['title'] = crypto_unencapsulate(json_decode_plus($r[$k]['title']),$key);
+ $r[$k]['title'] = base64url_decode(str_rot47($r[$k]['title']));
if($r[$k]['body'])
- $r[$k]['body'] = crypto_unencapsulate(json_decode_plus($r[$k]['body']),$key);
+ $r[$k]['body'] = base64url_decode(str_rot47($r[$k]['body']));
}
}
@@ -323,11 +323,10 @@ function private_messages_fetch_message($channel_id, $messageitem_id, $updatesee
$messages[$k]['from'] = find_xchan_in_array($message['from_xchan'],$c);
$messages[$k]['to'] = find_xchan_in_array($message['to_xchan'],$c);
if($messages[$k]['mail_flags'] & MAIL_OBSCURED) {
- $key = get_config('system','prvkey');
if($messages[$k]['title'])
- $messages[$k]['title'] = crypto_unencapsulate(json_decode_plus($messages[$k]['title']),$key);
+ $messages[$k]['title'] = base64url_decode(str_rot47($messages[$k]['title']));
if($messages[$k]['body'])
- $messages[$k]['body'] = crypto_unencapsulate(json_decode_plus($messages[$k]['body']),$key);
+ $messages[$k]['body'] = base64url_decode(str_rot47($messages[$k]['body']));
}
}
@@ -411,11 +410,10 @@ function private_messages_fetch_conversation($channel_id, $messageitem_id, $upda
$messages[$k]['from'] = find_xchan_in_array($message['from_xchan'],$c);
$messages[$k]['to'] = find_xchan_in_array($message['to_xchan'],$c);
if($messages[$k]['mail_flags'] & MAIL_OBSCURED) {
- $key = get_config('system','prvkey');
if($messages[$k]['title'])
- $messages[$k]['title'] = crypto_unencapsulate(json_decode_plus($messages[$k]['title']),$key);
+ $messages[$k]['title'] = base64url_decode(str_rot47($messages[$k]['title']));
if($messages[$k]['body'])
- $messages[$k]['body'] = crypto_unencapsulate(json_decode_plus($messages[$k]['body']),$key);
+ $messages[$k]['body'] = base64url_decode(str_rot47($messages[$k]['body']));
}
}
diff --git a/include/network.php b/include/network.php
index e0c8885fd..fb336fbb4 100644
--- a/include/network.php
+++ b/include/network.php
@@ -1158,7 +1158,7 @@ function discover_by_webbie($webbie) {
if(! $r) {
- $r = q("insert into hubloc ( hubloc_guid, hubloc_hash, hubloc_addr, hubloc_network, hubloc_url, hubloc_host, hubloc_callback, hubloc_updated, hubloc_flags ) values ('%s','%s','%s','%s','%s','%s','%s','%s', %d)",
+ $r = q("insert into hubloc ( hubloc_guid, hubloc_hash, hubloc_addr, hubloc_network, hubloc_url, hubloc_host, hubloc_callback, hubloc_updated, hubloc_primary ) values ('%s','%s','%s','%s','%s','%s','%s','%s', 1)",
dbesc($guid),
dbesc($addr),
dbesc($addr),
@@ -1166,8 +1166,7 @@ function discover_by_webbie($webbie) {
dbesc(trim($diaspora_base,'/')),
dbesc($hostname),
dbesc($notify),
- dbescdate(datetime_convert()),
- intval(HUBLOC_FLAGS_PRIMARY)
+ dbescdate(datetime_convert())
);
}
$photos = import_profile_photo($vcard['photo'],$addr);
diff --git a/include/notifier.php b/include/notifier.php
index 46f9eb1de..ffdd80403 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -228,11 +228,9 @@ function notifier_run($argv, $argc){
$normal_mode = false;
$expire = true;
- $items = q("SELECT * FROM item WHERE uid = %d AND ( item_flags & %d )>0
- AND ( item_restrict & %d )>0 AND `changed` > %s - INTERVAL %s",
+ $items = q("SELECT * FROM item WHERE uid = %d AND item_wall = 1
+ AND item_deleted = 1 AND `changed` > %s - INTERVAL %s",
intval($item_id),
- intval(ITEM_WALL),
- intval(ITEM_DELETED),
db_utcnow(), db_quoteinterval('10 MINUTE')
);
$uid = $item_id;
@@ -338,19 +336,22 @@ function notifier_run($argv, $argc){
$target_item = $r[0];
$deleted_item = false;
- if($target_item['item_restrict'] & ITEM_DELETED) {
+ if(intval($target_item['item_deleted'])) {
logger('notifier: target item ITEM_DELETED', LOGGER_DEBUG);
$deleted_item = true;
}
- if(strpos($target_item['postopts'],'nodeliver') !== false) {
- logger('notifier: target item is undeliverable', LOGGER_DEBUG);
+ if(intval($target_item['item_type']) != ITEM_TYPE_POST) {
+ logger('notifier: target item not forwardable: type ' . $target_item['item_type'], LOGGER_DEBUG);
+ return;
+ }
+ if(intval($target_item['item_unpublished']) || intval($target_item['item_delayed_publish'])) {
+ logger('notifier: target item not published, so not forwardable', LOGGER_DEBUG);
return;
}
- $unforwardable = ITEM_UNPUBLISHED|ITEM_DELAYED_PUBLISH|ITEM_WEBPAGE|ITEM_BUILDBLOCK|ITEM_PDL;
- if($target_item['item_restrict'] & $unforwardable) {
- logger('notifier: target item not forwardable: flags ' . $target_item['item_restrict'], LOGGER_DEBUG);
+ if(strpos($target_item['postopts'],'nodeliver') !== false) {
+ logger('notifier: target item is undeliverable', LOGGER_DEBUG);
return;
}
@@ -407,10 +408,7 @@ function notifier_run($argv, $argc){
// flag on comments for an extended period. So we'll also call comment_local_origin() which looks at
// the hostname in the message_id and provides a second (fallback) opinion.
- $relay_to_owner = (((! $top_level_post) && ($target_item['item_flags'] & ITEM_ORIGIN) && comment_local_origin($target_item))
- ? true
- : false
- );
+ $relay_to_owner = (((! $top_level_post) && (intval($target_item['item_origin'])) && comment_local_origin($target_item)) ? true : false);
@@ -421,11 +419,10 @@ function notifier_run($argv, $argc){
logger('notifier: relay_to_owner: ' . (($relay_to_owner) ? 'true' : 'false'), LOGGER_DATA);
logger('notifier: top_level_post: ' . (($top_level_post) ? 'true' : 'false'), LOGGER_DATA);
- logger('notifier: target_item_flags: ' . $target_item['item_flags'] . ' ' . (($target_item['item_flags'] & ITEM_ORIGIN ) ? 'true' : 'false'), LOGGER_DATA);
// tag_deliver'd post which needs to be sent back to the original author
- if(($cmd === 'uplink') && ($parent_item['item_flags'] & ITEM_UPLINK) && (! $top_level_post)) {
+ if(($cmd === 'uplink') && intval($parent_item['item_uplink']) && (! $top_level_post)) {
logger('notifier: uplink');
$uplink = true;
}
@@ -446,7 +443,7 @@ function notifier_run($argv, $argc){
// if our parent is a tag_delivery recipient, uplink to the original author causing
// a delivery fork.
- if(($parent_item['item_flags'] & ITEM_UPLINK) && (! $top_level_post) && ($cmd !== 'uplink')) {
+ if(intval($parent_item['item_uplink']) && (! $top_level_post) && ($cmd !== 'uplink')) {
logger('notifier: uplinking this item');
proc_run('php','include/notifier.php','uplink',$item_id);
}
@@ -459,7 +456,7 @@ function notifier_run($argv, $argc){
// don't send deletions onward for other people's stuff
// TODO verify this is needed - copied logic from same place in old code
- if(($target_item['item_restrict'] & ITEM_DELETED) && (!($target_item['item_flags'] & ITEM_WALL))) {
+ if(intval($target_item['item_deleted']) && (! intval($target_item['item_wall']))) {
logger('notifier: ignoring delete notification for non-wall item');
return;
}
@@ -541,15 +538,12 @@ function notifier_run($argv, $argc){
// aren't the owner or author.
- $r = q("select hubloc_guid, hubloc_url, hubloc_sitekey, hubloc_network, hubloc_flags, hubloc_callback, hubloc_host from hubloc
+ $r = q("select * from hubloc
where hubloc_hash in (" . implode(',',$recipients) . ") order by hubloc_connected desc limit 1");
}
else {
- $r = q("select hubloc_guid, hubloc_url, hubloc_sitekey, hubloc_network, hubloc_flags, hubloc_callback, hubloc_host from hubloc
- where hubloc_hash in (" . implode(',',$recipients) . ") and not (hubloc_flags & %d) > 0 and not (hubloc_status & %d) > 0",
- intval(HUBLOC_FLAGS_DELETED),
- intval(HUBLOC_OFFLINE)
- );
+ $r = q("select * from hubloc where hubloc_hash in (" . implode(',',$recipients) . ")
+ and hubloc_error = 0 and hubloc_deleted = 0");
}
if(! $r) {
diff --git a/include/notify.php b/include/notify.php
index eef838664..2b032b56b 100644
--- a/include/notify.php
+++ b/include/notify.php
@@ -5,9 +5,6 @@ function format_notification($item) {
$ret = '';
-// return array();
-
-
require_once('include/conversation.php');
// Call localize_item with the "brief" flag to get a one line status for activities.
@@ -19,7 +16,7 @@ function format_notification($item) {
$itemem_text = $item['localize'];
}
else {
- $itemem_text = (($item['item_flags'] & ITEM_THREAD_TOP)
+ $itemem_text = (($item['item_thread_top'])
? t('created a new post')
: sprintf( t('commented on %s\'s post'), $item['owner']['xchan_name']));
}
diff --git a/include/onedirsync.php b/include/onedirsync.php
index de8dab92d..ce516da9d 100644
--- a/include/onedirsync.php
+++ b/include/onedirsync.php
@@ -41,7 +41,7 @@ function onedirsync_run($argv, $argc){
intval(UPDATE_FLAGS_UPDATED)
);
if($x) {
- $y = q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and ( ud_flags & %d ) = 0 and ud_date < '%s' ",
+ $y = q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and ( ud_flags & %d ) = 0 and ud_date != '%s'",
intval(UPDATE_FLAGS_UPDATED),
dbesc($r[0]['ud_addr']),
intval(UPDATE_FLAGS_UPDATED),
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index 6f508bf72..1ec031a1a 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -302,7 +302,6 @@ abstract class photo_driver {
$p['filename'] = (($arr['filename']) ? $arr['filename'] : '');
$p['album'] = (($arr['album']) ? $arr['album'] : '');
$p['scale'] = ((intval($arr['scale'])) ? intval($arr['scale']) : 0);
- $p['photo_flags'] = ((intval($arr['photo_flags'])) ? intval($arr['photo_flags']) : 0);
$p['allow_cid'] = (($arr['allow_cid']) ? $arr['allow_cid'] : '');
$p['allow_gid'] = (($arr['allow_gid']) ? $arr['allow_gid'] : '');
$p['deny_cid'] = (($arr['deny_cid']) ? $arr['deny_cid'] : '');
@@ -311,11 +310,7 @@ abstract class photo_driver {
$p['edited'] = (($arr['edited']) ? $arr['edited'] : $p['created']);
$p['title'] = (($arr['title']) ? $arr['title'] : '');
$p['description'] = (($arr['description']) ? $arr['description'] : '');
-
- // temporary until we get rid of photo['profile'] and just use photo['photo_flags']
- // but this will require updating all existing photos in the DB.
-
- $p['profile'] = (($p['photo_flags'] & PHOTO_PROFILE) ? 1 : 0);
+ $p['photo_usage'] = intval($arr['photo_usage']);
$x = q("select id from photo where resource_id = '%s' and uid = %d and xchan = '%s' and `scale` = %d limit 1",
@@ -340,8 +335,7 @@ abstract class photo_driver {
`data` = '%s',
`size` = %d,
`scale` = %d,
- `profile` = %d,
- `photo_flags` = %d,
+ `photo_usage` = %d,
`title` = '%s',
`description` = '%s',
`allow_cid` = '%s',
@@ -364,8 +358,7 @@ abstract class photo_driver {
dbescbin($this->imageString()),
intval(strlen($this->imageString())),
intval($p['scale']),
- intval($p['profile']),
- intval($p['photo_flags']),
+ intval($p['photo_usage']),
dbesc($p['title']),
dbesc($p['description']),
dbesc($p['allow_cid']),
@@ -377,8 +370,8 @@ abstract class photo_driver {
}
else {
$r = q("INSERT INTO `photo`
- ( `aid`, `uid`, `xchan`, `resource_id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `data`, `size`, `scale`, `profile`, `photo_flags`, `title`, `description`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
- VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s' )",
+ ( `aid`, `uid`, `xchan`, `resource_id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `data`, `size`, `scale`, `photo_usage`, `title`, `description`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
+ VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s' )",
intval($p['aid']),
intval($p['uid']),
dbesc($p['xchan']),
@@ -393,8 +386,7 @@ abstract class photo_driver {
dbescbin($this->imageString()),
intval(strlen($this->imageString())),
intval($p['scale']),
- intval($p['profile']),
- intval($p['photo_flags']),
+ intval($p['photo_usage']),
dbesc($p['title']),
dbesc($p['description']),
dbesc($p['allow_cid']),
@@ -406,7 +398,7 @@ abstract class photo_driver {
return $r;
}
- public function store($aid, $uid, $xchan, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '') {
+ public function store($aid, $uid, $xchan, $rid, $filename, $album, $scale, $usage = PHOTO_NORMAL, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '') {
$x = q("select id from photo where `resource_id` = '%s' and uid = %d and `xchan` = '%s' and `scale` = %d limit 1",
dbesc($rid),
@@ -430,7 +422,7 @@ abstract class photo_driver {
`data` = '%s',
`size` = %d,
`scale` = %d,
- `profile` = %d,
+ `photo_usage` = %d,
`allow_cid` = '%s',
`allow_gid` = '%s',
`deny_cid` = '%s',
@@ -451,7 +443,7 @@ abstract class photo_driver {
dbescbin($this->imageString()),
intval(strlen($this->imageString())),
intval($scale),
- intval($profile),
+ intval($photo_usage),
dbesc($allow_cid),
dbesc($allow_gid),
dbesc($deny_cid),
@@ -461,7 +453,7 @@ abstract class photo_driver {
}
else {
$r = q("INSERT INTO `photo`
- ( `aid`, `uid`, `xchan`, `resource_id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `data`, `size`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
+ ( `aid`, `uid`, `xchan`, `resource_id`, `created`, `edited`, `filename`, type, `album`, `height`, `width`, `data`, `size`, `scale`, `photo_usage`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s' )",
intval($aid),
intval($uid),
@@ -477,7 +469,7 @@ abstract class photo_driver {
dbescbin($this->imageString()),
intval(strlen($this->imageString())),
intval($scale),
- intval($profile),
+ intval($photo_usage),
dbesc($allow_cid),
dbesc($allow_gid),
dbesc($deny_cid),
@@ -569,7 +561,7 @@ function import_profile_photo($photo,$xchan,$thing = false) {
if($thing)
$hash = photo_new_resource();
else {
- $r = q("select resource_id from photo where xchan = '%s' and (photo_flags & %d )>0 and scale = 4 limit 1",
+ $r = q("select resource_id from photo where xchan = '%s' and photo_usage = %d and scale = 4 limit 1",
dbesc($xchan),
intval(PHOTO_XCHAN)
);
@@ -622,7 +614,7 @@ function import_profile_photo($photo,$xchan,$thing = false) {
else
$photo_failure = true;
- $p = array('xchan' => $xchan,'resource_id' => $hash, 'filename' => basename($photo), 'album' => $album, 'photo_flags' => $flags, 'scale' => 4);
+ $p = array('xchan' => $xchan,'resource_id' => $hash, 'filename' => basename($photo), 'album' => $album, 'photo_usage' => $flags, 'scale' => 4);
$r = $img->save($p);
@@ -684,7 +676,7 @@ function import_channel_photo($photo,$type,$aid,$uid) {
$img->scaleImageSquare(175);
- $p = array('aid' => $aid, 'uid' => $uid, 'resource_id' => $hash, 'filename' => $filename, 'album' => t('Profile Photos'), 'photo_flags' => PHOTO_PROFILE, 'scale' => 4);
+ $p = array('aid' => $aid, 'uid' => $uid, 'resource_id' => $hash, 'filename' => $filename, 'album' => t('Profile Photos'), 'photo_usage' => PHOTO_PROFILE, 'scale' => 4);
$r = $img->save($p);
diff --git a/include/photos.php b/include/photos.php
index 1672e310a..dcf2978bb 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -156,7 +156,7 @@ function photo_upload($channel, $observer, $args) {
$errors = false;
$p = array('aid' => $account_id, 'uid' => $channel_id, 'xchan' => $visitor, 'resource_id' => $photo_hash,
- 'filename' => $filename, 'album' => $album, 'scale' => 0, 'photo_flags' => PHOTO_NORMAL,
+ 'filename' => $filename, 'album' => $album, 'scale' => 0, 'photo_usage' => PHOTO_NORMAL,
'allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow,
'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny
);
@@ -210,6 +210,9 @@ function photo_upload($channel, $observer, $args) {
// Create item container
+
+ $item_hidden = (($visible) ? 0 : 1 );
+
$lat = $lon = null;
if($exif && $exif['GPS']) {
@@ -219,8 +222,6 @@ function photo_upload($channel, $observer, $args) {
}
}
- $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP;
- $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN);
$title = '';
$mid = item_message_id();
@@ -229,22 +230,24 @@ function photo_upload($channel, $observer, $args) {
if($lat && $lon)
$arr['coord'] = $lat . ' ' . $lon;
- $arr['aid'] = $account_id;
- $arr['uid'] = $channel_id;
- $arr['mid'] = $mid;
- $arr['parent_mid'] = $mid;
- $arr['item_flags'] = $item_flags;
- $arr['item_restrict'] = $item_restrict;
- $arr['resource_type'] = 'photo';
- $arr['resource_id'] = $photo_hash;
- $arr['owner_xchan'] = $channel['channel_hash'];
- $arr['author_xchan'] = $observer['xchan_hash'];
- $arr['title'] = $title;
- $arr['allow_cid'] = $str_contact_allow;
- $arr['allow_gid'] = $str_group_allow;
- $arr['deny_cid'] = $str_contact_deny;
- $arr['deny_gid'] = $str_group_deny;
- $arr['verb'] = ACTIVITY_POST;
+ $arr['aid'] = $account_id;
+ $arr['uid'] = $channel_id;
+ $arr['mid'] = $mid;
+ $arr['parent_mid'] = $mid;
+ $arr['item_hidden'] = $item_hidden;
+ $arr['resource_type'] = 'photo';
+ $arr['resource_id'] = $photo_hash;
+ $arr['owner_xchan'] = $channel['channel_hash'];
+ $arr['author_xchan'] = $observer['xchan_hash'];
+ $arr['title'] = $title;
+ $arr['allow_cid'] = $str_contact_allow;
+ $arr['allow_gid'] = $str_group_allow;
+ $arr['deny_cid'] = $str_contact_deny;
+ $arr['deny_gid'] = $str_group_deny;
+ $arr['verb'] = ACTIVITY_POST;
+ $arr['item_wall'] = 1;
+ $arr['item_origin'] = 1;
+ $arr['item_thread_top'] = 1;
$arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
@@ -310,7 +313,7 @@ function photos_albums_list($channel, $observer) {
$sql_extra = permissions_sql($channel_id);
- $albums = q("SELECT count( distinct resource_id ) as total, album from photo where uid = %d and ( photo_flags = %d or photo_flags = %d ) $sql_extra group by album order by max(created) desc",
+ $albums = q("SELECT count( distinct resource_id ) as total, album from photo where uid = %d and photo_usage IN ( %d, %d ) $sql_extra group by album order by max(created) desc",
intval($channel_id),
intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE)
@@ -390,7 +393,7 @@ function photos_list_photos($channel, $observer, $album = '') {
$ret = array('success' => false);
- $r = q("select resource_id, created, edited, title, description, album, filename, type, height, width, size, scale, profile, photo_flags, allow_cid, allow_gid, deny_cid, deny_gid from photo where uid = %d and ( photo_flags = %d or photo_flags = %d ) $sql_extra ",
+ $r = q("select resource_id, created, edited, title, description, album, filename, type, height, width, size, scale, photo_usage, allow_cid, allow_gid, deny_cid, deny_gid from photo where uid = %d and photo_usage in ( %d, %d ) $sql_extra ",
intval($channel_id),
intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE)
@@ -488,32 +491,34 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) {
// Create item container
- $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP;
- $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN);
+
+ $item_hidden = (($visible) ? 0 : 1 );
$mid = item_message_id();
$arr = array();
- $arr['aid'] = $channel['channel_account_id'];
- $arr['uid'] = $channel['channel_id'];
- $arr['mid'] = $mid;
- $arr['parent_mid'] = $mid;
- $arr['item_flags'] = $item_flags;
- $arr['item_restrict'] = $item_restrict;
- $arr['resource_type'] = 'photo';
- $arr['resource_id'] = $photo['resource_id'];
- $arr['owner_xchan'] = $channel['channel_hash'];
- $arr['author_xchan'] = $creator_hash;
-
- $arr['allow_cid'] = $photo['allow_cid'];
- $arr['allow_gid'] = $photo['allow_gid'];
- $arr['deny_cid'] = $photo['deny_cid'];
- $arr['deny_gid'] = $photo['deny_gid'];
-
- $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
-
- $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']'
+ $arr['aid'] = $channel['channel_account_id'];
+ $arr['uid'] = $channel['channel_id'];
+ $arr['mid'] = $mid;
+ $arr['parent_mid'] = $mid;
+ $arr['item_wall'] = 1;
+ $arr['item_origin'] = 1;
+ $arr['item_thread_top'] = 1;
+ $arr['item_hidden'] = $item_hidden;
+ $arr['resource_type'] = 'photo';
+ $arr['resource_id'] = $photo['resource_id'];
+ $arr['owner_xchan'] = $channel['channel_hash'];
+ $arr['author_xchan'] = $creator_hash;
+
+ $arr['allow_cid'] = $photo['allow_cid'];
+ $arr['allow_gid'] = $photo['allow_gid'];
+ $arr['deny_cid'] = $photo['deny_cid'];
+ $arr['deny_gid'] = $photo['deny_gid'];
+
+ $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
+
+ $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']'
. '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-' . $photo['scale'] . '[/zmg]'
. '[/zrl]';
diff --git a/include/poller.php b/include/poller.php
index bc48c3f00..09c642f6a 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -59,10 +59,9 @@ function poller_run($argv, $argc){
// expire any expired items
$r = q("select id from item where expires != '%s' and expires < %s
- and ( item_restrict & %d ) = 0 ",
+ and item_deleted = 0 ",
dbesc(NULL_DATE),
- db_utcnow(),
- intval(ITEM_DELETED)
+ db_utcnow()
);
if($r) {
require_once('include/items.php');
@@ -91,15 +90,13 @@ function poller_run($argv, $argc){
// (time travel posts). Restrict to items that have come of age in the last
// couple of days to limit the query to something reasonable.
- $r = q("select id from item where ( item_restrict & %d ) > 0 and created <= %s and created > '%s' ",
- intval(ITEM_DELAYED_PUBLISH),
+ $r = q("select id from item where item_delayed = 1 and created <= %s and created > '%s' ",
db_utcnow(),
dbesc(datetime_convert('UTC','UTC','now - 2 days'))
);
if($r) {
foreach($r as $rr) {
- $x = q("update item set item_restrict = ( item_restrict & ~%d ) where id = %d",
- intval(ITEM_DELAYED_PUBLISH),
+ $x = q("update item set item_delayed = 0 where id = %d",
intval($rr['id'])
);
if($x) {
diff --git a/include/reddav.php b/include/reddav.php
index 750ca1b24..e90543e27 100644
--- a/include/reddav.php
+++ b/include/reddav.php
@@ -1,7 +1,7 @@
<?php
/**
* @file include/reddav.php
- * @brief some DAV related functions for RedMatrix.
+ * @brief some DAV related functions for Hubzilla.
*
* This file contains some functions which did not fit into one of the RedDAV
* classes.
diff --git a/include/socgraph.php b/include/socgraph.php
index 0ad7c4034..45ab9a366 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -40,7 +40,7 @@ function poco_load($xchan = '', $url = null) {
return;
}
- $url = $url . '?f=&fields=displayName,hash,urls,photos,rating' ;
+ $url = $url . '?f=&fields=displayName,hash,urls,photos' ;
logger('poco_load: ' . $url, LOGGER_DEBUG);
@@ -115,8 +115,6 @@ function poco_load($xchan = '', $url = null) {
$name = $entry['displayName'];
$hash = $entry['hash'];
- $rating = ((array_key_exists('rating',$entry) && (! is_array($entry['rating']))) ? intval($entry['rating']) : 0);
- $rating_text = ((array_key_exists('rating_text',$entry)) ? escape_tags($entry['rating_text']) :'');
if(x($entry,'urls') && is_array($entry['urls'])) {
foreach($entry['urls'] as $url) {
@@ -329,15 +327,13 @@ function suggestion_query($uid, $myxchan, $start = 0, $limit = 80) {
and not xlink_link in ( select abook_xchan from abook where abook_channel = %d )
and not xlink_link in ( select xchan from xign where uid = %d )
and xlink_xchan != ''
+ and xchan_hidden = 0
+ and xchan_deleted = 0
and xlink_static = 0
- and not ( xchan_flags & %d )>0
- and not ( xchan_flags & %d )>0
group by xchan_hash order by total desc limit %d offset %d ",
intval($uid),
intval($uid),
intval($uid),
- intval(XCHAN_FLAGS_HIDDEN),
- intval(XCHAN_FLAGS_DELETED),
intval($limit),
intval($start)
);
@@ -350,14 +346,12 @@ function suggestion_query($uid, $myxchan, $start = 0, $limit = 80) {
where xlink_xchan = ''
and not xlink_link in ( select abook_xchan from abook where abook_channel = %d )
and not xlink_link in ( select xchan from xign where uid = %d )
+ and xchan_hidden = 0
+ and xchan_deleted = 0
and xlink_static = 0
- and not ( xchan_flags & %d )>0
- and not ( xchan_flags & %d )>0
group by xchan_hash order by total desc limit %d offset %d ",
intval($uid),
intval($uid),
- intval(XCHAN_FLAGS_HIDDEN),
- intval(XCHAN_FLAGS_DELETED),
intval($limit),
intval($start)
);
@@ -580,13 +574,6 @@ function poco($a,$extended = false) {
$entry['preferredUsername'] = substr($rr['xchan_addr'],0,strpos($rr['xchan_addr'],'@'));
if($fields_ret['photos'])
$entry['photos'] = array(array('value' => $rr['xchan_photo_l'], 'mimetype' => $rr['xchan_photo_mimetype'], 'type' => 'profile'));
- if($fields_ret['rating']) {
- $entry['rating'] = ((array_key_exists('abook_rating',$rr)) ? intval($rr['abook_rating']) : 0);
- $entry['rating_text'] = ((array_key_exists('abook_rating_text',$rr)) ? $rr['abook_rating_text'] : '');
- // maybe this should be a composite calculated rating in $system_mode
- if($system_mode)
- $entry['rating'] = 0;
- }
$ret['entry'][] = $entry;
}
}
@@ -609,4 +596,4 @@ function poco($a,$extended = false) {
else
http_status_exit(500);
-} \ No newline at end of file
+}
diff --git a/include/statistics_fns.php b/include/statistics_fns.php
index 288925a2c..ce2eee5e7 100644
--- a/include/statistics_fns.php
+++ b/include/statistics_fns.php
@@ -23,8 +23,7 @@ function update_channels_active_halfyear_stat() {
$s .= ',';
$s .= intval($rr['channel_id']);
}
- $x = q("select uid from item where uid in ( $s ) and (item_flags & %d)>0 and created > %s - INTERVAL %s group by uid",
- intval(ITEM_WALL),
+ $x = q("select uid from item where uid in ( $s ) and item_wall = 1 and created > %s - INTERVAL %s group by uid",
db_utcnow(), db_quoteinterval('6 MONTH')
);
if($x) {
@@ -50,8 +49,7 @@ function update_channels_active_monthly_stat() {
$s .= ',';
$s .= intval($rr['channel_id']);
}
- $x = q("select uid from item where uid in ( $s ) and ( item_flags & %d )>0 and created > %s - INTERVAL %s group by uid",
- intval(ITEM_WALL),
+ $x = q("select uid from item where uid in ( $s ) and item_wall = 1 and created > %s - INTERVAL %s group by uid",
db_utcnow(), db_quoteinterval('1 MONTH')
);
if($x) {
@@ -66,8 +64,7 @@ function update_channels_active_monthly_stat() {
}
function update_local_posts_stat() {
- $posts = q("SELECT COUNT(*) AS local_posts FROM `item` WHERE (item_flags & %d)>0 ",
- intval(ITEM_WALL) );
+ $posts = q("SELECT COUNT(*) AS local_posts FROM `item` WHERE item_wall = 1 ");
if (is_array($posts)) {
$local_posts_stat = intval($posts[0]["local_posts"]);
set_config('system','local_posts_stat',$local_posts_stat);
diff --git a/include/taxonomy.php b/include/taxonomy.php
index fa540ac56..ea41369ad 100644
--- a/include/taxonomy.php
+++ b/include/taxonomy.php
@@ -111,8 +111,10 @@ function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $restrict = 0, $
$sql_options = item_permissions_sql($uid);
$count = intval($count);
- if($flags)
- $sql_options .= " and ((item_flags & " . intval($flags) . ") = " . intval($flags) . ") ";
+ if($flags) {
+ if($flags === 'wall')
+ $sql_options .= " and item_wall = 1 ";
+ }
if($authors) {
if(! is_array($authors))
@@ -125,7 +127,7 @@ function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $restrict = 0, $
// Fetch tags
$r = q("select term, count(term) as total from term left join item on term.oid = item.id
where term.uid = %d and term.type = %d
- and otype = %d and item_restrict = %d
+ and otype = %d and item_type = %d and item_private = 0
$sql_options
group by term order by total desc %s",
intval($uid),
diff --git a/include/text.php b/include/text.php
index 9c6fe3622..e1923aed6 100644
--- a/include/text.php
+++ b/include/text.php
@@ -579,9 +579,9 @@ function attribute_contains($attr, $s) {
}
/**
- * @brief Logging function for RedMatrix.
+ * @brief Logging function for Hubzilla.
*
- * Logging output is configured through RedMatrix's system config. The log file
+ * Logging output is configured through Hubzilla's system config. The log file
* is set in system logfile, log level in system loglevel and to enable logging
* set system debugging.
*
@@ -747,7 +747,7 @@ function get_tags($s) {
// make sure the longer tags are returned first so that if two or more have common substrings
// we'll replace the longest ones first. Otherwise the common substring would be found in
// both strings and the string replacement would link both to the shorter strings and
- // fail to link the longer string. RedMatrix github issue #378
+ // fail to link the longer string. Hubzilla github issue #378
usort($ret,'tag_sort_length');
@@ -812,20 +812,21 @@ function contact_block() {
return;
$is_owner = ((local_channel() && local_channel() == $a->profile['uid']) ? true : false);
+ $sql_extra = '';
$abook_flags = ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF;
- $xchan_flags = XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED;
+
if(! $is_owner) {
$abook_flags = $abook_flags | ABOOK_FLAG_HIDDEN;
- $xchan_flags = $xchan_flags | XCHAN_FLAGS_HIDDEN;
+ $sql_extra = " and xchan_hidden = 0 ";
}
if((! is_array($a->profile)) || ($a->profile['hide_friends']))
return $o;
- $r = q("SELECT COUNT(abook_id) AS total FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and ( abook_flags & %d ) = 0 and ( xchan_flags & %d ) = 0",
+
+ $r = q("SELECT COUNT(abook_id) AS total FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and not ( abook_flags & %d )>0 and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra",
intval($a->profile['uid']),
- intval($abook_flags),
- intval($xchan_flags)
+ intval($abook_flags)
);
if(count($r)) {
$total = intval($r[0]['total']);
@@ -834,14 +835,13 @@ function contact_block() {
$contacts = t('No connections');
$micropro = null;
} else {
-
+
$randfunc = db_getfunc('RAND');
-
- $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash WHERE abook_channel = %d AND ( abook_flags & %d ) = 0 and ( xchan_flags & %d ) = 0 ORDER BY $randfunc LIMIT %d",
- intval($a->profile['uid']),
- intval($abook_flags|ABOOK_FLAG_ARCHIVED),
- intval($xchan_flags),
- intval($shown)
+
+ $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash WHERE abook_channel = %d AND not ( abook_flags & %d)>0 and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra ORDER BY $randfunc LIMIT %d",
+ intval($a->profile['uid']),
+ intval($abook_flags|ABOOK_FLAG_ARCHIVED),
+ intval($shown)
);
if(count($r)) {
@@ -1245,7 +1245,7 @@ function link_compare($a, $b) {
function unobscure(&$item) {
- if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED)) {
+ if(array_key_exists('item_obscured',$item) && intval($item['item_obscured'])) {
$key = get_config('system','prvkey');
if($item['title'])
$item['title'] = crypto_unencapsulate(json_decode_plus($item['title']),$key);
@@ -1264,11 +1264,10 @@ function unobscure(&$item) {
function unobscure_mail(&$item) {
if(array_key_exists('mail_flags',$item) && ($item['mail_flags'] & MAIL_OBSCURED)) {
- $key = get_config('system','prvkey');
if($item['title'])
- $item['title'] = crypto_unencapsulate(json_decode_plus($item['title']),$key);
+ $item['title'] = base64url_decode(str_rot47($item['title']));
if($item['body'])
- $item['body'] = crypto_unencapsulate(json_decode_plus($item['body']),$key);
+ $item['body'] = base64url_decode(str_rot47($item['body']));
}
}
@@ -1445,16 +1444,24 @@ function generate_named_map($location) {
function prepare_body(&$item,$attach = false) {
- call_hooks('prepare_body_init', $item);
-
- unobscure($item);
-
- $s = prepare_text($item['body'],$item['mimetype']);
+ if($item['html']) {
+ $s = bb_observer($item['html']);
+ }
+ else {
+ call_hooks('prepare_body_init', $item);
+ unobscure($item);
+ $s = prepare_text($item['body'],$item['mimetype'], true);
+ }
$prep_arr = array('item' => $item, 'html' => $s);
call_hooks('prepare_body', $prep_arr);
$s = $prep_arr['html'];
+ q("update item set html = '%s' where id = %d",
+ dbesc($s),
+ intval($item['id'])
+ );
+
if(! $attach) {
return $s;
}
@@ -1513,7 +1520,6 @@ function prepare_body(&$item,$attach = false) {
$prep_arr = array('item' => $item, 'html' => $s);
call_hooks('prepare_body_final', $prep_arr);
-
return $prep_arr['html'];
}
@@ -1524,7 +1530,7 @@ function prepare_body(&$item,$attach = false) {
* @param sting $content_type
* @return string
*/
-function prepare_text($text, $content_type = 'text/bbcode') {
+function prepare_text($text, $content_type = 'text/bbcode', $cache = false) {
switch($content_type) {
case 'text/plain':
@@ -1562,9 +1568,9 @@ function prepare_text($text, $content_type = 'text/bbcode') {
require_once('include/bbcode.php');
if(stristr($text,'[nosmile]'))
- $s = bbcode($text);
+ $s = bbcode($text,false,true,$cache);
else
- $s = smilies(bbcode($text));
+ $s = smilies(bbcode($text,false,true,$cache));
$s = zidify_links($s);
break;
}
@@ -1676,9 +1682,9 @@ function unamp($s) {
}
function layout_select($channel_id, $current = '') {
- $r = q("select mid,sid from item left join item_id on iid = item.id where service = 'PDL' and item.uid = item_id.uid and item_id.uid = %d and (item_restrict & %d)>0",
+ $r = q("select mid,sid from item left join item_id on iid = item.id where service = 'PDL' and item.uid = item_id.uid and item_id.uid = %d and item_type = %d ",
intval($channel_id),
- intval(ITEM_PDL)
+ intval(ITEM_TYPE_PDL)
);
if($r) {
@@ -2031,13 +2037,13 @@ function xchan_query(&$items,$abook = true,$effective_uid = 0) {
if(count($arr)) {
if($abook) {
$chans = q("select * from xchan left join hubloc on hubloc_hash = xchan_hash left join abook on abook_xchan = xchan_hash and abook_channel = %d
- where xchan_hash in (" . implode(',', $arr) . ") and ( hubloc_flags & " . intval(HUBLOC_FLAGS_PRIMARY) . " )>0",
+ where xchan_hash in (" . implode(',', $arr) . ") and hubloc_primary = 1",
intval($item['uid'])
);
}
else {
$chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash
- where xchan_hash in (" . implode(',', $arr) . ") and ( hubloc_flags & " . intval(HUBLOC_FLAGS_PRIMARY) . " )>0");
+ where xchan_hash in (" . implode(',', $arr) . ") and hubloc_primary = 1");
}
$xchans = q("select * from xchan where xchan_hash in (" . implode(',',$arr) . ") and xchan_network in ('rss','unknown')");
if(! $chans)
@@ -2065,7 +2071,7 @@ function xchan_mail_query(&$item) {
if(count($arr)) {
$chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash
- where xchan_hash in (" . implode(',', $arr) . ") and ( hubloc_flags & " . intval(HUBLOC_FLAGS_PRIMARY) . " )>0");
+ where xchan_hash in (" . implode(',', $arr) . ") and hubloc_primary = 1");
}
if($chans) {
$item['from'] = find_xchan_in_array($item['from_xchan'],$chans);
@@ -2614,3 +2620,9 @@ function userReadableSize($size) {
return $ret;
}
+
+function str_rot47($str) {
+ return strtr($str,
+ '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~',
+ 'PQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO');
+}
diff --git a/include/widgets.php b/include/widgets.php
index 4a9032a21..86f65cdee 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -29,7 +29,7 @@ function widget_tagcloud($args) {
$type = TERM_CATEGORY;
// FIXME there exists no $authors variable
- $r = tagadelic($uid, $count, $authors, $flags, ITEM_WEBPAGE, $type);
+ $r = tagadelic($uid, $count, $authors, $flags, ITEM_TYPE_WEBPAGE, $type);
if($r) {
$o = '<div class="tagblock widget"><h3>' . t('Categories') . '</h3><div class="tags" align="center">';
@@ -393,7 +393,7 @@ function widget_tagcloud_wall($arr) {
$limit = ((array_key_exists('limit', $arr)) ? intval($arr['limit']) : 50);
if(feature_enabled($a->profile['profile_uid'], 'tagadelic'))
- return wtagblock($a->profile['profile_uid'], $limit, $a->profile['channel_hash'], ITEM_WALL);
+ return wtagblock($a->profile['profile_uid'], $limit, $a->profile['channel_hash'], 'wall');
return '';
}
@@ -408,7 +408,7 @@ function widget_catcloud_wall($arr) {
$limit = ((array_key_exists('limit',$arr)) ? intval($arr['limit']) : 50);
- return catblock($a->profile['profile_uid'], $limit, $a->profile['channel_hash'], ITEM_WALL);
+ return catblock($a->profile['profile_uid'], $limit, $a->profile['channel_hash'], 'wall');
}
@@ -704,7 +704,7 @@ function widget_item($arr) {
require_once('include/security.php');
$sql_extra = item_permissions_sql($uid);
- $r = q("select * from item where mid = '%s' and uid = %d and item_restrict = " . intval(ITEM_WEBPAGE) . " $sql_extra limit 1",
+ $r = q("select * from item where mid = '%s' and uid = %d and item_type = " . intval(ITEM_TYPE_WEBPAGE) . " $sql_extra limit 1",
dbesc($arr['mid']),
intval($uid)
);
@@ -902,10 +902,10 @@ function widget_random_block($arr) {
$r = q("select item.* from item left join item_id on item.id = item_id.iid
where item.uid = %d and sid like '%s' and service = 'BUILDBLOCK' and
- item_restrict = %d $sql_options order by $randfunc limit 1",
+ item_type = %d $sql_options order by $randfunc limit 1",
intval($channel_id),
dbesc('%' . $contains . '%'),
- intval(ITEM_BUILDBLOCK)
+ intval(ITEM_TYPE_BUILDBLOCK)
);
if($r) {
@@ -986,3 +986,5 @@ function widget_pubsites() {
return;
return '<div class="widget"><ul class="nav nav-pills"><li><a href="pubsites">' . t('Public Hubs') . '</a></li></ul></div>';
}
+
+
diff --git a/include/zot.php b/include/zot.php
index 02ac1301b..5f93ba75b 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -1,7 +1,7 @@
<?php
/**
* @file include/zot.php
- * @brief RedMatrix implementation of zot protocol.
+ * @brief Hubzilla implementation of zot protocol.
*
* https://github.com/friendica/red/wiki/zot
* https://github.com/friendica/red/wiki/Zot---A-High-Level-Overview
@@ -80,9 +80,8 @@ function zot_get_hublocs($hash) {
/* Only search for active hublocs - e.g. those that haven't been marked deleted */
- $ret = q("select * from hubloc where hubloc_hash = '%s' and not ( hubloc_flags & %d )>0 order by hubloc_url ",
- dbesc($hash),
- intval(HUBLOC_FLAGS_DELETED)
+ $ret = q("select * from hubloc where hubloc_hash = '%s' and hubloc_deleted != 0 order by hubloc_url ",
+ dbesc($hash)
);
return $ret;
@@ -200,9 +199,8 @@ function zot_finger($webbie, $channel = null, $autofallback = true) {
$r = q("select xchan.*, hubloc.* from xchan
left join hubloc on xchan_hash = hubloc_hash
- where xchan_addr = '%s' and (hubloc_flags & %d) > 0 limit 1",
- dbesc($xchan_addr),
- intval(HUBLOC_FLAGS_PRIMARY)
+ where xchan_addr = '%s' and hubloc_primary = 1 limit 1",
+ dbesc($xchan_addr)
);
if ($r) {
@@ -709,43 +707,36 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) {
$hidden = (1 - intval($arr['searchable']));
- // Be careful - XCHAN_FLAGS_HIDDEN should evaluate to 1
- if(($r[0]['xchan_flags'] & XCHAN_FLAGS_HIDDEN) != $hidden)
- $new_flags = $r[0]['xchan_flags'] ^ XCHAN_FLAGS_HIDDEN;
- else
- $new_flags = $r[0]['xchan_flags'];
-
- $adult = (($r[0]['xchan_flags'] & XCHAN_FLAGS_SELFCENSORED) ? true : false);
- $adult_changed = ((intval($adult) != intval($arr['adult_content'])) ? true : false);
- if($adult_changed)
- $new_flags = $new_flags ^ XCHAN_FLAGS_SELFCENSORED;
-
- $deleted = (($r[0]['xchan_flags'] & XCHAN_FLAGS_DELETED) ? true : false);
- $deleted_changed = ((intval($deleted) != intval($arr['deleted'])) ? true : false);
- if($deleted_changed)
- $new_flags = $new_flags ^ XCHAN_FLAGS_DELETED;
-
- $public_forum = (($r[0]['xchan_flags'] & XCHAN_FLAGS_PUBFORUM) ? true : false);
- $pubforum_changed = ((intval($public_forum) != intval($arr['public_forum'])) ? true : false);
- if($pubforum_changed)
- $new_flags = $r[0]['xchan_flags'] ^ XCHAN_FLAGS_PUBFORUM;
-
- if(($r[0]['xchan_name_date'] != $arr['name_updated'])
- || ($r[0]['xchan_connurl'] != $arr['connections_url'])
- || ($r[0]['xchan_flags'] != $new_flags)
+ $hidden_changed = $adult_changed = $deleted_changed = $pubforum_changed = 0;
+
+ if(intval($r[0]['xchan_hidden']) != (1 - intval($arr['searchable'])))
+ $hidden_changed = 1;
+ if(intval($r[0]['xchan_selfcensored']) != intval($arr['adult_content']))
+ $adult_changed = 1;
+ if(intval($r[0]['xchan_deleted']) != intval($arr['deleted']))
+ $deleted_changed = 1;
+ if(intval($r[0]['xchan_pubforum']) != intval($arr['public_forum']))
+ $pubforum_changed = 1;
+
+ if(($r[0]['xchan_name_date'] != $arr['name_updated'])
+ || ($r[0]['xchan_connurl'] != $arr['connections_url'])
|| ($r[0]['xchan_addr'] != $arr['address'])
|| ($r[0]['xchan_follow'] != $arr['follow_url'])
- || ($r[0]['xchan_connpage'] != $arr['connect_url'])
- || ($r[0]['xchan_url'] != $arr['url'])) {
- $r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_connurl = '%s', xchan_follow = '%s',
- xchan_connpage = '%s', xchan_flags = %d,
+ || ($r[0]['xchan_connpage'] != $arr['connect_url'])
+ || ($r[0]['xchan_url'] != $arr['url'])
+ || $hidden_changed || adult_changed || deleted_changed || $pubforum_changed ) {
+ $r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_connurl = '%s', xchan_follow = '%s',
+ xchan_connpage = '%s', xchan_hidden = %d, xchan_selfcensored = %d, xchan_deleted = %d, xchan_pubforum = %d,
xchan_addr = '%s', xchan_url = '%s' where xchan_hash = '%s'",
dbesc(($arr['name']) ? $arr['name'] : '-'),
dbesc($arr['name_updated']),
dbesc($arr['connections_url']),
dbesc($arr['follow_url']),
dbesc($arr['connect_url']),
- intval($new_flags),
+ intval(1 - intval($arr['searchable'])),
+ intval($arr['adult_content']),
+ intval($arr['deleted']),
+ intval($arr['public_forum']),
dbesc($arr['address']),
dbesc($arr['url']),
dbesc($xchan_hash)
@@ -764,20 +755,9 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) {
&& ($arr['site']['url'] != z_root()))
$arr['searchable'] = false;
- $hidden = (1 - intval($arr['searchable']));
-
- if($hidden)
- $new_flags = XCHAN_FLAGS_HIDDEN;
- else
- $new_flags = 0;
- if($arr['adult_content'])
- $new_flags |= XCHAN_FLAGS_SELFCENSORED;
- if(array_key_exists('deleted',$arr) && $arr['deleted'])
- $new_flags |= XCHAN_FLAGS_DELETED;
-
$x = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_mimetype,
- xchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_flags)
- values ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d) ",
+ xchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_hidden, xchan_selfcensored, xchan_deleted, xchan_pubforum )
+ values ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d) ",
dbesc($xchan_hash),
dbesc($arr['guid']),
dbesc($arr['guid_sig']),
@@ -793,7 +773,10 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) {
dbesc('zot'),
dbescdate($arr['photo_updated']),
dbescdate($arr['name_updated']),
- intval($new_flags)
+ intval(1 - intval($arr['searchable'])),
+ intval($arr['adult_content']),
+ intval($arr['deleted']),
+ intval($arr['public_forum'])
);
$what .= 'new_xchan';
@@ -1542,11 +1525,11 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
if(($channel['channel_pageflags'] & PAGE_SYSTEM) && (! $arr['item_private']) && (! $relay)) {
$local_public = true;
- $r = q("select xchan_flags from xchan where xchan_hash = '%s' limit 1",
+ $r = q("select xchan_selfcensored from xchan where xchan_hash = '%s' limit 1",
dbesc($sender['hash'])
);
// don't import sys channel posts from selfcensored authors
- if($r && ($r[0]['xchan_flags'] & XCHAN_FLAGS_SELFCENSORED)) {
+ if($r && (intval($r[0]['xchan_selfcensored']))) {
$local_public = false;
continue;
}
@@ -1560,13 +1543,10 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
// This is our own post, possibly coming from a channel clone
if($arr['owner_xchan'] == $d['hash']) {
- $arr['item_flags'] = $arr['item_flags'] | ITEM_WALL;
+ $arr['item_wall'] = 1;
}
else {
- // clear the wall flag if it is set
- if($arr['item_flags'] & ITEM_WALL) {
- $arr['item_flags'] = ($arr['item_flags'] ^ ITEM_WALL);
- }
+ $arr['item_wall'] = 0;
}
if((! perm_is_allowed($channel['channel_id'],$sender['hash'],$perm)) && (! $tag_delivery) && (! $local_public)) {
@@ -1654,7 +1634,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
}
}
- if($arr['item_restrict'] & ITEM_DELETED) {
+ if(intval($arr['item_deleted'])) {
// remove_community_tag is a no-op if this isn't a community tag activity
remove_community_tag($sender,$arr,$channel['channel_id']);
@@ -1677,15 +1657,16 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
continue;
}
- $r = q("select id, edited, item_restrict, item_flags, mid, parent_mid from item where mid = '%s' and uid = %d limit 1",
+ $r = q("select * from item where mid = '%s' and uid = %d limit 1",
dbesc($arr['mid']),
intval($channel['channel_id'])
);
if($r) {
// We already have this post.
$item_id = $r[0]['id'];
- if($r[0]['item_restrict'] & ITEM_DELETED) {
- // It was deleted locally.
+
+ if(intval($r[0]['item_deleted'])) {
+ // It was deleted locally.
$result[] = array($d['hash'],'update ignored',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
continue;
}
@@ -1700,9 +1681,10 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
}
else {
$result[] = array($d['hash'],'update ignored',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
- // We need this line to ensure wall-to-wall comments are relayed (by falling through to the relay bit),
- // and at the same time not relay any other relayable posts more than once, because to do so is very wasteful.
- if(! ($r[0]['item_flags'] & ITEM_ORIGIN))
+
+ // We need this line to ensure wall-to-wall comments are relayed (by falling through to the relay bit),
+ // and at the same time not relay any other relayable posts more than once, because to do so is very wasteful.
+ if(! intval($r[0]['item_origin']))
continue;
}
}
@@ -1849,7 +1831,12 @@ function delete_imported_item($sender, $item, $uid, $relay) {
$item_found = false;
$post_id = 0;
- $r = q("select id, item_restrict, author_xchan, owner_xchan, source_xchan from item where mid = '%s' and uid = %d limit 1",
+
+ $r = q("select id, item_deleted from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' )
+ and mid = '%s' and uid = %d limit 1",
+ dbesc($sender['hash']),
+ dbesc($sender['hash']),
+ dbesc($sender['hash']),
dbesc($item['mid']),
intval($uid)
);
@@ -1881,8 +1868,10 @@ function delete_imported_item($sender, $item, $uid, $relay) {
return false;
}
+ require_once('include/items.php');
+
if ($item_found) {
- if ($r[0]['item_restrict'] & ITEM_DELETED) {
+ if (intval($r[0]['item_deleted'])) {
logger('delete_imported_item: item was already deleted');
if (! $relay)
return false;
@@ -1894,9 +1883,8 @@ function delete_imported_item($sender, $item, $uid, $relay) {
// back, and we aren't going to (or shouldn't at any rate) delete it again in the future - so losing
// this information from the metadata should have no other discernible impact.
- if (($r[0]['id'] != $r[0]['parent']) && ($r[0]['item_flags'] & ITEM_ORIGIN)) {
- q("update item set item_flags = %d where id = %d and uid = %d",
- intval($r[0]['item_flags'] ^ ITEM_ORIGIN),
+ if (($r[0]['id'] != $r[0]['parent']) && intval($r[0]['item_origin'])) {
+ q("update item set item_origin = 0 where id = %d and uid = %d",
intval($r[0]['id']),
intval($r[0]['uid'])
);
@@ -2157,23 +2145,16 @@ function sync_locations($sender, $arr, $absolute = false) {
$current_site = true;
}
- // If it is the site we're currently talking to, and it's marked offline,
- // either we have some bad information - or the thing came back to life.
-
- if(($current_site) && ($r[0]['hubloc_status'] & HUBLOC_OFFLINE)) {
- q("update hubloc set hubloc_status = (hubloc_status & ~%d) where hubloc_id = %d",
- intval(HUBLOC_OFFLINE),
+ if($current_site && intval($r[0]['hubloc_error'])) {
+ q("update hubloc set hubloc_error = 0 where hubloc_id = %d",
intval($r[0]['hubloc_id'])
);
- if($r[0]['hubloc_flags'] & HUBLOC_FLAGS_ORPHANCHECK) {
- q("update hubloc set hubloc_flags = (hubloc_flags & ~%d) where hubloc_id = %d",
- intval(HUBLOC_FLAGS_ORPHANCHECK),
+ if(intval($r[0]['hubloc_orphancheck'])) {
+ q("update hubloc set hubloc_orphancheck = 0 where hubloc_id = %d",
intval($r[0]['hubloc_id'])
);
}
- q("update xchan set xchan_flags = (xchan_flags & ~%d) where (xchan_flags & %d)>0 and xchan_hash = '%s'",
- intval(XCHAN_FLAGS_ORPHAN),
- intval(XCHAN_FLAGS_ORPHAN),
+ q("update xchan set xchan_orphan = 0 where xchan_orphan = 1 and xchan_hash = '%s'",
dbesc($sender['hash'])
);
}
@@ -2189,9 +2170,8 @@ function sync_locations($sender, $arr, $absolute = false) {
}
}
- if(($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) && (! $location['primary'])) {
- $m = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_id = %d",
- intval(HUBLOC_FLAGS_PRIMARY),
+ if(intval($r[0]['hubloc_primary']) && (! $location['primary'])) {
+ $m = q("update hubloc set hubloc_primary = 0, hubloc_updated = '%s' where hubloc_id = %d",
dbesc(datetime_convert()),
intval($r[0]['hubloc_id'])
);
@@ -2200,14 +2180,13 @@ function sync_locations($sender, $arr, $absolute = false) {
$what .= 'primary_hub ';
$changed = true;
}
- elseif((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY)) && ($location['primary'])) {
- $m = q("update hubloc set hubloc_flags = (hubloc_flags | %d), hubloc_updated = '%s' where hubloc_id = %d",
- intval(HUBLOC_FLAGS_PRIMARY),
+ elseif((! intval($r[0]['hubloc_primary'])) && ($location['primary'])) {
+ $m = q("update hubloc set hubloc_primary = 1, hubloc_updated = '%s' where hubloc_id = %d",
dbesc(datetime_convert()),
intval($r[0]['hubloc_id'])
);
// make sure hubloc_change_primary() has current data
- $r[0]['hubloc_flags'] = $r[0]['hubloc_flags'] ^ HUBLOC_FLAGS_PRIMARY;
+ $r[0]['hubloc_primary'] = intval($location['primary']);
hubloc_change_primary($r[0]);
$what .= 'primary_hub ';
$changed = true;
@@ -2220,18 +2199,17 @@ function sync_locations($sender, $arr, $absolute = false) {
$changed = true;
}
}
- if(($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED) && (! $location['deleted'])) {
- $n = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_id = %d",
- intval(HUBLOC_FLAGS_DELETED),
+ if((intval($r[0]['hubloc_deleted']) && (! $location['deleted']))
+ || ((! (intval($r[0]['hubloc_deleted']))) && ($location['deleted']))) {
+ $n = q("update hubloc set hubloc_deleted = 0, hubloc_updated = '%s' where hubloc_id = %d",
dbesc(datetime_convert()),
intval($r[0]['hubloc_id'])
);
$what .= 'delete_hub ';
$changed = true;
}
- elseif((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED)) && ($location['deleted'])) {
- $n = q("update hubloc set hubloc_flags = (hubloc_flags | %d), hubloc_updated = '%s' where hubloc_id = %d",
- intval(HUBLOC_FLAGS_DELETED),
+ elseif((! intval($r[0]['hubloc_deleted'])) && ($location['deleted'])) {
+ $n = q("update hubloc set hubloc_deleted = 1, hubloc_updated = '%s' where hubloc_id = %d",
dbesc(datetime_convert()),
intval($r[0]['hubloc_id'])
);
@@ -2245,22 +2223,20 @@ function sync_locations($sender, $arr, $absolute = false) {
// New hub claiming to be primary. Make it so by removing any existing primaries.
if(intval($location['primary'])) {
- $r = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_hash = '%s' and (hubloc_flags & %d )>0",
- intval(HUBLOC_FLAGS_PRIMARY),
+ $r = q("update hubloc set hubloc_primary = 0, hubloc_updated = '%s' where hubloc_hash = '%s' and hubloc_primary = 1",
dbesc(datetime_convert()),
- dbesc($sender['hash']),
- intval(HUBLOC_FLAGS_PRIMARY)
+ dbesc($sender['hash'])
);
}
logger('sync_locations: new hub: ' . $location['url']);
- $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_network, hubloc_flags, hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey, hubloc_updated, hubloc_connected)
+ $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_network, hubloc_primary, hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey, hubloc_updated, hubloc_connected)
values ( '%s','%s','%s','%s', '%s', %d ,'%s','%s','%s','%s','%s','%s','%s')",
dbesc($sender['guid']),
dbesc($sender['guid_sig']),
dbesc($sender['hash']),
dbesc($location['address']),
dbesc('zot'),
- intval((intval($location['primary'])) ? HUBLOC_FLAGS_PRIMARY : 0),
+ intval($location['primary']),
dbesc($location['url']),
dbesc($location['url_sig']),
dbesc($location['host']),
@@ -2288,8 +2264,7 @@ function sync_locations($sender, $arr, $absolute = false) {
foreach($xisting as $x) {
if(! array_key_exists('updated',$x)) {
logger('sync_locations: deleting unreferenced hub location ' . $x['hubloc_url']);
- $r = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_id = %d",
- intval(HUBLOC_FLAGS_DELETED),
+ $r = q("update hubloc set hubloc_deleted = 1, hubloc_updated = '%s' where hubloc_id = %d",
dbesc(datetime_convert()),
intval($x['hubloc_id'])
);
@@ -2318,20 +2293,19 @@ function zot_encode_locations($channel) {
$ret = array();
$x = zot_get_hublocs($channel['channel_hash']);
- if ($x && count($x)) {
- foreach ($x as $hub) {
- if (! ($hub['hubloc_flags'] & HUBLOC_FLAGS_UNVERIFIED)) {
- $ret[] = array(
- 'host' => $hub['hubloc_host'],
- 'address' => $hub['hubloc_addr'],
- 'primary' => (($hub['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) ? true : false),
- 'url' => $hub['hubloc_url'],
- 'url_sig' => $hub['hubloc_url_sig'],
- 'callback' => $hub['hubloc_callback'],
- 'sitekey' => $hub['hubloc_sitekey'],
- 'deleted' => (($hub['hubloc_flags'] & HUBLOC_FLAGS_DELETED) ? true : false)
- );
- }
+
+ if($x && count($x)) {
+ foreach($x as $hub) {
+ $ret[] = array(
+ 'host' => $hub['hubloc_host'],
+ 'address' => $hub['hubloc_addr'],
+ 'primary' => (intval($hub['hubloc_primary']) ? true : false),
+ 'url' => $hub['hubloc_url'],
+ 'url_sig' => $hub['hubloc_url_sig'],
+ 'callback' => $hub['hubloc_callback'],
+ 'sitekey' => $hub['hubloc_sitekey'],
+ 'deleted' => (intval($hub['hubloc_deleted']) ? true : false)
+ );
}
}
@@ -2387,9 +2361,8 @@ function import_directory_profile($hash, $profile, $addr, $ud_flags = UPDATE_FLA
// These are not translated, so the German "erwachsenen" keyword will not censor the directory profile. Only the English form - "adult".
- if (in_arrayi('nsfw', $clean) || in_arrayi('adult', $clean)) {
- q("update xchan set xchan_flags = (xchan_flags | %d) where xchan_hash = '%s'",
- intval(XCHAN_FLAGS_SELFCENSORED),
+ if(in_arrayi('nsfw',$clean) || in_arrayi('adult',$clean)) {
+ q("update xchan set xchan_selfcensored = 1 where xchan_hash = '%s'",
dbesc($hash)
);
}
@@ -2983,6 +2956,9 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
. "' where abook_xchan = '" . dbesc($clean['abook_xchan']) . "' and abook_channel = " . intval($channel['channel_id']));
}
}
+
+
+
}
}
@@ -3199,11 +3175,11 @@ function get_rpost_path($observer) {
* @return boolean|string return false or a hash
*/
function import_author_zot($x) {
- $hash = make_xchan_hash($x['guid'], $x['guid_sig']);
- $r = q("select hubloc_url from hubloc where hubloc_guid = '%s' and hubloc_guid_sig = '%s' and (hubloc_flags & %d)>0 limit 1",
+
+ $hash = make_xchan_hash($x['guid'],$x['guid_sig']);
+ $r = q("select hubloc_url from hubloc where hubloc_guid = '%s' and hubloc_guid_sig = '%s' and hubloc_primary = 1 limit 1",
dbesc($x['guid']),
- dbesc($x['guid_sig']),
- intval(HUBLOC_FLAGS_PRIMARY)
+ dbesc($x['guid_sig'])
);
if ($r) {
@@ -3273,12 +3249,9 @@ function zot_process_message_request($data) {
if ($messages) {
$env_recips = null;
- $r = q("select hubloc_guid, hubloc_url, hubloc_sitekey, hubloc_network, hubloc_flags, hubloc_callback, hubloc_host
- from hubloc where hubloc_hash = '%s' and not (hubloc_flags & %d)>0
- and not (hubloc_status & %d)>0 ",
- dbesc($sender_hash),
- intval(HUBLOC_FLAGS_DELETED),
- intval(HUBLOC_OFFLINE)
+ $r = q("select * from hubloc where hubloc_hash = '%s' and not hubloc_error and not hubloc_deleted
+ group by hubloc_sitekey",
+ dbesc($sender_hash)
);
if (! $r) {
logger('no hubs');