aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Contact.php21
-rw-r--r--include/RedDAV/RedDirectory.php20
-rw-r--r--include/RedDAV/RedFile.php5
-rwxr-xr-xinclude/diaspora.php5
-rw-r--r--include/enotify.php5
-rw-r--r--include/expire.php2
-rw-r--r--include/identity.php41
-rw-r--r--include/nav.php9
-rw-r--r--include/reddav.php3
-rw-r--r--include/security.php24
-rw-r--r--include/zot.php29
11 files changed, 66 insertions, 98 deletions
diff --git a/include/Contact.php b/include/Contact.php
index 7f02f04e4..e7aa4f861 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -49,25 +49,22 @@ function abook_self($channel_id) {
}
function channelx_by_nick($nick) {
- $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_address = '%s' and not ( channel_pageflags & %d )>0 LIMIT 1",
- dbesc($nick),
- intval(PAGE_REMOVED)
+ $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_address = '%s' and channel_removed = 0 LIMIT 1",
+ dbesc($nick)
);
return(($r) ? $r[0] : false);
}
function channelx_by_hash($hash) {
- $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_hash = '%s' and not ( channel_pageflags & %d )>0 LIMIT 1",
- dbesc($hash),
- intval(PAGE_REMOVED)
+ $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_hash = '%s' and channel_removed = 0 LIMIT 1",
+ dbesc($hash)
);
return(($r) ? $r[0] : false);
}
function channelx_by_n($id) {
- $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_id = %d and not ( channel_pageflags & %d )>0 LIMIT 1",
- dbesc($id),
- intval(PAGE_REMOVED)
+ $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_id = %d and channel_removed = 0 LIMIT 1",
+ dbesc($id)
);
return(($r) ? $r[0] : false);
}
@@ -289,13 +286,12 @@ function channel_remove($channel_id, $local = true, $unset_session=true) {
if(! $local) {
- $r = q("update channel set channel_deleted = '%s', channel_pageflags = (channel_pageflags | %d), channel_r_stream = 0, channel_r_profile = 0,
+ $r = q("update channel set channel_deleted = '%s', channel_removed = 1, channel_r_stream = 0, channel_r_profile = 0,
channel_r_photos = 0, channel_r_abook = 0, channel_w_stream = 0, channel_w_wall = 0, channel_w_tagwall = 0,
channel_w_comment = 0, channel_w_mail = 0, channel_w_photos = 0, channel_w_chat = 0, channel_a_delegate = 0,
channel_r_storage = 0, channel_w_storage = 0, channel_r_pages = 0, channel_w_pages = 0, channel_a_republish = 0
where channel_id = %d",
dbesc(datetime_convert()),
- intval(PAGE_REMOVED),
intval($channel_id)
);
@@ -331,9 +327,8 @@ function channel_remove($channel_id, $local = true, $unset_session=true) {
dbesc($channel['channel_hash'])
);
- $r = q("update channel set channel_deleted = '%s', channel_pageflags = (channel_pageflags | %d) where channel_id = %d",
+ $r = q("update channel set channel_deleted = '%s', channel_removed = 1 where channel_id = %d",
dbesc(datetime_convert()),
- intval(PAGE_REMOVED),
intval($channel_id)
);
diff --git a/include/RedDAV/RedDirectory.php b/include/RedDAV/RedDirectory.php
index 88a4647a4..dba857cdc 100644
--- a/include/RedDAV/RedDirectory.php
+++ b/include/RedDAV/RedDirectory.php
@@ -200,9 +200,8 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
$mimetype = z_mime_content_type($name);
- $c = q("SELECT * FROM channel WHERE channel_id = %d AND NOT (channel_pageflags & %d)>0 LIMIT 1",
- intval($this->auth->owner_id),
- intval(PAGE_REMOVED)
+ $c = q("SELECT * FROM channel WHERE channel_id = %d AND channel_removed = 0 LIMIT 1",
+ intval($this->auth->owner_id)
);
if (! $c) {
@@ -318,9 +317,8 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
throw new DAV\Exception\Forbidden('Permission denied.');
}
- $r = q("SELECT * FROM channel WHERE channel_id = %d AND NOT (channel_pageflags & %d)>0 LIMIT 1",
- intval($this->auth->owner_id),
- intval(PAGE_REMOVED)
+ $r = q("SELECT * FROM channel WHERE channel_id = %d AND channel_removed = 0 LIMIT 1",
+ intval($this->auth->owner_id)
);
if ($r) {
@@ -389,9 +387,8 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
$channel_name = $path_arr[0];
- $r = q("SELECT channel_id FROM channel WHERE channel_address = '%s' AND NOT ( channel_pageflags & %d )>0 LIMIT 1",
- dbesc($channel_name),
- intval(PAGE_REMOVED)
+ $r = q("SELECT channel_id FROM channel WHERE channel_address = '%s' AND channel_removed = 0 LIMIT 1",
+ dbesc($channel_name)
);
if (! $r) {
@@ -467,9 +464,8 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
$free = disk_free_space('store');
if ($this->auth->owner_id) {
- $c = q("select * from channel where channel_id = %d and not (channel_pageflags & %d)>0 limit 1",
- intval($this->auth->owner_id),
- intval(PAGE_REMOVED)
+ $c = q("select * from channel where channel_id = %d and channel_removed = 0 limit 1",
+ intval($this->auth->owner_id)
);
$ulimit = service_class_fetch($c[0]['channel_id'], 'attach_upload_limit');
diff --git a/include/RedDAV/RedFile.php b/include/RedDAV/RedFile.php
index 164498676..1fd2dab8f 100644
--- a/include/RedDAV/RedFile.php
+++ b/include/RedDAV/RedFile.php
@@ -97,9 +97,8 @@ class RedFile extends DAV\Node implements DAV\IFile {
$size = 0;
// @todo only 3 values are needed
- $c = q("SELECT * FROM channel WHERE channel_id = %d AND (channel_pageflags & %d) = 0 LIMIT 1",
- intval($this->auth->owner_id),
- intval(PAGE_REMOVED)
+ $c = q("SELECT * FROM channel WHERE channel_id = %d AND channel_removed = 0 LIMIT 1",
+ intval($this->auth->owner_id)
);
$is_photo = false;
diff --git a/include/diaspora.php b/include/diaspora.php
index fc3c6c2ce..18e131f8f 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -24,9 +24,8 @@ function diaspora_dispatch_public($msg) {
// find everybody following or allowing this author
- $r = q("SELECT * from channel where channel_id in ( SELECT abook_channel from abook left join xchan on abook_xchan = xchan_hash WHERE xchan_network like '%%diaspora%%' and xchan_addr = '%s' ) and ( channel_pageflags & %d ) = 0 ",
- dbesc($msg['author']),
- intval(PAGE_REMOVED)
+ $r = q("SELECT * from channel where channel_id in ( SELECT abook_channel from abook left join xchan on abook_xchan = xchan_hash WHERE xchan_network like '%%diaspora%%' and xchan_addr = '%s' ) and channel_removed = 0 ",
+ dbesc($msg['author'])
);
// also need to look for those following public streams
diff --git a/include/enotify.php b/include/enotify.php
index cd49a9b34..d0228bf50 100644
--- a/include/enotify.php
+++ b/include/enotify.php
@@ -36,9 +36,8 @@ function notification($params) {
}
if ($params['to_xchan']) {
$y = q("select channel.*, account.* from channel left join account on channel_account_id = account_id
- where channel_hash = '%s' and not (channel_pageflags & %d)>0 limit 1",
- dbesc($params['to_xchan']),
- intval(PAGE_REMOVED)
+ where channel_hash = '%s' and channel_removed = 0 limit 1",
+ dbesc($params['to_xchan'])
);
}
if ($x & $y) {
diff --git a/include/expire.php b/include/expire.php
index 47cc04829..e75594b5f 100644
--- a/include/expire.php
+++ b/include/expire.php
@@ -45,7 +45,7 @@ function expire_run($argv, $argc){
foreach ($r as $rr) {
// expire the sys channel separately
- if ($rr['channel_pageflags'] & PAGE_SYSTEM)
+ if (intval($rr['channel_system']))
continue;
// service class default (if non-zero) over-rides the site default
diff --git a/include/identity.php b/include/identity.php
index 0555cf21d..184e9c308 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -24,9 +24,8 @@ require_once('include/crypto.php');
function identity_check_service_class($account_id) {
$ret = array('success' => false, 'message' => '');
- $r = q("select count(channel_id) as total from channel where channel_account_id = %d and not ( channel_pageflags & %d )>0 ",
- intval($account_id),
- intval(PAGE_REMOVED)
+ $r = q("select count(channel_id) as total from channel where channel_account_id = %d and channel_removed = 0 ",
+ intval($account_id)
);
if(! ($r && count($r))) {
$ret['total_identities'] = 0;
@@ -98,7 +97,7 @@ function create_sys_channel() {
'account_id' => 'xxx', // This will create an identity with an (integer) account_id of 0, but account_id is required
'nickname' => 'sys',
'name' => 'System',
- 'pageflags' => PAGE_SYSTEM,
+ 'pageflags' => 0,
'publish' => 0,
'system' => 1
));
@@ -111,9 +110,7 @@ function create_sys_channel() {
* @return array|boolean
*/
function get_sys_channel() {
- $r = q("select * from channel left join xchan on channel_hash = xchan_hash where (channel_pageflags & %d)>0 limit 1",
- intval(PAGE_SYSTEM)
- );
+ $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_system = 1 limit 1");
if ($r)
return $r[0];
@@ -129,11 +126,11 @@ function get_sys_channel() {
* @return boolean
*/
function is_sys_channel($channel_id) {
- $r = q("select channel_pageflags from channel where channel_id = %d limit 1",
+ $r = q("select channel_system from channel where channel_id = %d and channel_system = 1 limit 1",
intval($channel_id)
);
- if (($r) && ($r[0]['channel_pageflags'] & PAGE_SYSTEM))
+ if($r)
return true;
return false;
@@ -149,9 +146,7 @@ function is_sys_channel($channel_id) {
* on error returns boolean false
*/
function channel_total() {
- $r = q("select channel_id from channel where not ( channel_pageflags & %d )>0",
- intval(PAGE_REMOVED)
- );
+ $r = q("select channel_id from channel where channel_removed = 0");
if (is_array($r))
return count($r);
@@ -208,7 +203,7 @@ function create_identity($arr) {
return $ret;
}
- if($nick === 'sys' && (! ($pageflags & PAGE_SYSTEM))) {
+ if($nick === 'sys' && (! $system)) {
$ret['message'] = t('Reserved nickname. Please choose another.');
return $ret;
}
@@ -265,8 +260,8 @@ function create_identity($arr) {
$r = q("insert into channel ( channel_account_id, channel_primary,
channel_name, channel_address, channel_guid, channel_guid_sig,
- channel_hash, channel_prvkey, channel_pubkey, channel_pageflags, channel_expire_days, channel_timezone $perms_keys )
- values ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s' $perms_vals ) ",
+ channel_hash, channel_prvkey, channel_pubkey, channel_pageflags, channel_system, channel_expire_days, channel_timezone $perms_keys )
+ values ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s' $perms_vals ) ",
intval($arr['account_id']),
intval($primary),
@@ -278,6 +273,7 @@ function create_identity($arr) {
dbesc($key['prvkey']),
dbesc($key['pubkey']),
intval($pageflags),
+ intval($system),
intval($expire),
dbesc($a->timezone)
);
@@ -619,9 +615,8 @@ function profile_load(&$a, $nickname, $profile = '') {
logger('profile_load: ' . $nickname . (($profile) ? ' profile: ' . $profile : ''));
- $user = q("select channel_id from channel where channel_address = '%s' and not ( channel_pageflags & %d ) > 0 limit 1",
- dbesc($nickname),
- intval(PAGE_REMOVED)
+ $user = q("select channel_id from channel where channel_address = '%s' and channel_removed = 0 limit 1",
+ dbesc($nickname)
);
if(! $user) {
@@ -664,10 +659,9 @@ function profile_load(&$a, $nickname, $profile = '') {
if(! $p) {
$p = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile
LEFT JOIN channel ON profile.uid = channel.channel_id
- WHERE channel.channel_address = '%s' and not ( channel_pageflags & %d )>0
+ WHERE channel.channel_address = '%s' and channel_removed = 0
AND profile.is_default = 1 LIMIT 1",
- dbesc($nickname),
- intval(PAGE_REMOVED)
+ dbesc($nickname)
);
}
@@ -1457,9 +1451,8 @@ function get_channel_by_nick($nick) {
*/
function identity_selector() {
if (local_channel()) {
- $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel.channel_account_id = %d and (channel_pageflags & %d) = 0 order by channel_name ",
- intval(get_account_id()),
- intval(PAGE_REMOVED)
+ $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel.channel_account_id = %d and channel_removed = 0 order by channel_name ",
+ intval(get_account_id())
);
if (count($r) > 1) {
//$account = get_app()->get_account();
diff --git a/include/nav.php b/include/nav.php
index 77287c021..0ca554897 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -30,14 +30,9 @@ EOT;
intval($channel['channel_id'])
);
- $chans = q("select channel_name, channel_id from channel where channel_account_id = %d and not ( channel_pageflags & %d )>0 order by channel_name ",
- intval(get_account_id()),
- intval(PAGE_REMOVED)
+ $chans = q("select channel_name, channel_id from channel where channel_account_id = %d and channel_removed = 0 order by channel_name ",
+ intval(get_account_id())
);
-
-
-
-
}
elseif(remote_channel())
$observer = $a->get_observer();
diff --git a/include/reddav.php b/include/reddav.php
index e90543e27..5ecb10fb4 100644
--- a/include/reddav.php
+++ b/include/reddav.php
@@ -42,8 +42,7 @@ require_once('include/RedDAV/RedBasicAuth.php');
function RedChannelList(&$auth) {
$ret = array();
- $r = q("SELECT channel_id, channel_address FROM channel WHERE NOT (channel_pageflags & %d)>0 AND NOT (channel_pageflags & %d)>0",
- intval(PAGE_REMOVED),
+ $r = q("SELECT channel_id, channel_address FROM channel WHERE channel_removed = 0 AND channel_system = 0 AND NOT (channel_pageflags & %d)>0",
intval(PAGE_HIDDEN)
);
diff --git a/include/security.php b/include/security.php
index 91683cc98..e1f6cd556 100644
--- a/include/security.php
+++ b/include/security.php
@@ -71,9 +71,8 @@ function authenticate_success($user_record, $login_initial = false, $interactive
/* This account has never created a channel. Send them to new_channel by default */
if($a->module === 'login') {
- $r = q("select count(channel_id) as total from channel where channel_account_id = %d and not ( channel_pageflags & %d)>0",
- intval($a->account['account_id']),
- intval(PAGE_REMOVED)
+ $r = q("select count(channel_id) as total from channel where channel_account_id = %d and channel_removed = 0 ",
+ intval($a->account['account_id'])
);
if(($r) && (! $r[0]['total']))
goaway(z_root() . '/new_channel');
@@ -94,20 +93,17 @@ function change_channel($change_channel) {
$ret = false;
if($change_channel) {
- $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel_id = %d and channel_account_id = %d and not ( channel_pageflags & %d)>0 limit 1",
+ $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel_id = %d and channel_account_id = %d and channel_removed = 0 limit 1",
intval($change_channel),
- intval(get_account_id()),
- intval(PAGE_REMOVED)
+ intval(get_account_id())
);
// It's not there. Is this an administrator, and is this the sys channel?
if (is_developer()) {
if (! $r) {
if (is_site_admin()) {
- $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel_id = %d and ( channel_pageflags & %d) and not (channel_pageflags & %d )>0 limit 1",
- intval($change_channel),
- intval(PAGE_SYSTEM),
- intval(PAGE_REMOVED)
+ $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel_id = %d and channel_system = 1 and channel_removed = 0 limit 1",
+ intval($change_channel)
);
}
}
@@ -404,9 +400,9 @@ function stream_perms_api_uids($perms = NULL, $limit = 0, $rand = 0 ) {
$random_sql = (($rand) ? " ORDER BY " . db_getfunc('RAND') . " " : '');
if(local_channel())
$ret[] = local_channel();
- $r = q("select channel_id from channel where channel_r_stream > 0 and ( channel_r_stream & %d )>0 and ( channel_pageflags & %d ) = 0 $random_sql $limit_sql ",
+ $r = q("select channel_id from channel where channel_r_stream > 0 and ( channel_r_stream & %d )>0 and ( channel_pageflags & %d ) = 0 and channel_system = 0 and channel_removed = 0 $random_sql $limit_sql ",
intval($perms),
- intval(PAGE_ADULT|PAGE_CENSORED|PAGE_SYSTEM|PAGE_REMOVED)
+ intval(PAGE_ADULT|PAGE_CENSORED)
);
if($r) {
foreach($r as $rr)
@@ -434,9 +430,9 @@ function stream_perms_xchans($perms = NULL ) {
if(local_channel())
$ret[] = get_observer_hash();
- $r = q("select channel_hash from channel where channel_r_stream > 0 and (channel_r_stream & %d)>0 and not (channel_pageflags & %d)>0",
+ $r = q("select channel_hash from channel where channel_r_stream > 0 and (channel_r_stream & %d)>0 and not (channel_pageflags & %d)>0 and channel_system = 0 and channel_removed = 0 ",
intval($perms),
- intval(PAGE_ADULT|PAGE_CENSORED|PAGE_SYSTEM|PAGE_REMOVED)
+ intval(PAGE_ADULT|PAGE_CENSORED)
);
if($r) {
foreach($r as $rr)
diff --git a/include/zot.php b/include/zot.php
index afa60c92c..309df252d 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -1092,9 +1092,7 @@ function zot_import($arr, $sender_url) {
}
stringify_array_elms($recip_arr);
$recips = implode(',',$recip_arr);
- $r = q("select channel_hash as hash from channel where channel_hash in ( " . $recips . " ) and not ( channel_pageflags & %d ) > 0 ",
- intval(PAGE_REMOVED)
- );
+ $r = q("select channel_hash as hash from channel where channel_hash in ( " . $recips . " ) and channel_removed = 0 ");
if(! $r) {
logger('recips: no recipients on this site');
continue;
@@ -1308,13 +1306,13 @@ function public_recips($msg) {
or ( " . $col . " & " . intval(PERMS_PUBLIC) . ") > 0
or ( " . $col . " & " . intval(PERMS_AUTHED) . ") > 0 ) ";
} else {
- $sql = " where (( " . $col . " & " . intval(PERMS_NETWORK) . " ) > 0
- or ( " . $col . " & " . intval(PERMS_PUBLIC) . ") > 0
- or ( " . $col . " & " . intval(PERMS_AUTHED) . ") > 0 ) ";
+ $sql = " where ( " . $col . " = " . intval(PERMS_NETWORK) . "
+ or " . $col . " = " . intval(PERMS_PUBLIC) . "
+ or " . $col . " = " . intval(PERMS_AUTHED) . " ) ";
}
$r = q("select channel_hash as hash from channel $sql or channel_hash = '%s'
- and ( channel_pageflags & " . intval(PAGE_REMOVED) . " ) = 0 ",
+ and channel_removed = 0 ",
dbesc($msg['notify']['sender']['hash'])
);
@@ -1325,10 +1323,10 @@ function public_recips($msg) {
// and is allowing this sender at least at a high level.
$x = q("select channel_hash as hash from channel left join abook on abook_channel = channel_id
- where abook_xchan = '%s' and ( channel_pageflags & " . intval(PAGE_REMOVED) . " ) = 0
- and (( " . $col . " & " . intval(PERMS_SPECIFIC) . " ) > 0 and ( abook_my_perms & " . intval($field) . " ) > 0 )
- OR ( " . $col . " & " . intval(PERMS_PENDING) . " ) > 0
- OR (( " . $col . " & " . intval(PERMS_CONTACTS) . " ) > 0 and abook_pending = 0 )) ",
+ where abook_xchan = '%s' and channel_removed = 0
+ and (( " . $col . " = " . intval(PERMS_SPECIFIC) . " and ( abook_my_perms & " . intval($field) . " ) > 0 )
+ OR " . $col . " = " . intval(PERMS_PENDING) . "
+ OR ( " . $col . " = " . intval(PERMS_CONTACTS) . " and abook_pending = 0 )) ",
dbesc($msg['notify']['sender']['hash'])
);
@@ -1357,7 +1355,7 @@ function public_recips($msg) {
$address = basename($tag['url']);
if($address) {
$z = q("select channel_hash as hash from channel where channel_address = '%s'
- and ( channel_pageflags & " . intval(PAGE_REMOVED) . " ) = 0 limit 1",
+ and channel_removed = 0 limit 1",
dbesc($address)
);
if($z)
@@ -1461,9 +1459,8 @@ function allowed_public_recips($msg) {
$condensed_recips[] = $rr['hash'];
$results = array();
- $r = q("select channel_hash as hash from channel left join abook on abook_channel = channel_id where abook_xchan = '%s' and ( channel_pageflags & %d ) = 0 ",
- dbesc($hash),
- intval(PAGE_REMOVED)
+ $r = q("select channel_hash as hash from channel left join abook on abook_channel = channel_id where abook_xchan = '%s' and channel_removed = 0 ",
+ dbesc($hash)
);
if($r) {
foreach($r as $rr)
@@ -1517,7 +1514,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
// for comments travelling upstream. Wait and catch them on the way down.
// They may have been blocked by the owner.
- if(($channel['channel_pageflags'] & PAGE_SYSTEM) && (! $arr['item_private']) && (! $relay)) {
+ if(intval($channel['channel_system']) && (! $arr['item_private']) && (! $relay)) {
$local_public = true;
$r = q("select xchan_selfcensored from xchan where xchan_hash = '%s' limit 1",