aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorThomas Willingham <founder@kakste.com>2013-08-24 17:05:18 +0100
committerThomas Willingham <founder@kakste.com>2013-08-24 17:05:18 +0100
commitc803fb90df3bbbd8bb88df09a271b5a9214e8c1d (patch)
tree0ad021580411798fc0ab025f1b1c302fe8afd3f6 /include
parent6999fb586ba90e9f1c79e9f09f4035f63fb925fd (diff)
parentb0dd38b30949f907265eda757bfa14aa1f38b38f (diff)
downloadvolse-hubzilla-c803fb90df3bbbd8bb88df09a271b5a9214e8c1d.tar.gz
volse-hubzilla-c803fb90df3bbbd8bb88df09a271b5a9214e8c1d.tar.bz2
volse-hubzilla-c803fb90df3bbbd8bb88df09a271b5a9214e8c1d.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'include')
-rw-r--r--include/Contact.php13
-rw-r--r--include/ItemObject.php4
-rw-r--r--include/auth.php2
-rw-r--r--include/conversation.php19
-rw-r--r--include/features.php6
-rw-r--r--include/follow.php12
-rw-r--r--include/identity.php18
-rwxr-xr-xinclude/items.php43
-rw-r--r--include/message.php49
-rw-r--r--include/notifier.php19
-rw-r--r--include/oauth.php2
-rw-r--r--include/permissions.php35
-rw-r--r--include/poller.php32
-rw-r--r--include/security.php2
-rw-r--r--include/socgraph.php1
-rw-r--r--include/zot.php44
16 files changed, 246 insertions, 55 deletions
diff --git a/include/Contact.php b/include/Contact.php
index 992ed27e2..46d356f3f 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -15,13 +15,20 @@ function rconnect_url($channel_id,$xchan) {
if($r)
return '';
+ $r = q("select * from xchan where xchan_hash = '%s' limit 1",
+ dbesc($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 ) limit 1",
dbesc($xchan),
intval(HUBLOC_FLAGS_PRIMARY)
);
if($r)
- return $r[0]['hubloc_url'];
+ return $r[0]['hubloc_url'] . '/follow?f=&url=%s';
return '';
}
@@ -295,8 +302,8 @@ function contact_remove($channel_id, $abook_id) {
$archive = get_pconfig($channel_id, 'system','archive_removed_contacts');
if($archive) {
- q("update abook set abook_flags = abook_flags | %d where abook_id = %d and abook_channel = %d limit 1",
- intval(ABOOK_FLAG_ARCHIVE),
+ q("update abook set abook_flags = ( abook_flags | %d ) where abook_id = %d and abook_channel = %d limit 1",
+ intval(ABOOK_FLAG_ARCHIVED),
intval($abook_id),
intval($channel_id)
);
diff --git a/include/ItemObject.php b/include/ItemObject.php
index 8c8c0ee2a..22b191e79 100644
--- a/include/ItemObject.php
+++ b/include/ItemObject.php
@@ -39,10 +39,10 @@ class Item extends BaseObject {
foreach($data['children'] as $item) {
/*
- * Only add thos that will be displayed
+ * Only add those that will be displayed
*/
- if(! visible_activity($item)) {
+ if((! visible_activity($item)) || array_key_exists('author_blocked',$item)) {
continue;
}
diff --git a/include/auth.php b/include/auth.php
index c86a54fb1..143a16de8 100644
--- a/include/auth.php
+++ b/include/auth.php
@@ -14,7 +14,7 @@ function nuke_session() {
unset($_SESSION['administrator']);
unset($_SESSION['cid']);
unset($_SESSION['theme']);
- unset($_SESSION['mobile-theme']);
+ unset($_SESSION['mobile_theme']);
unset($_SESSION['page_flags']);
unset($_SESSION['submanage']);
unset($_SESSION['my_url']);
diff --git a/include/conversation.php b/include/conversation.php
index 6d551a5c9..6e6ffef94 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -137,7 +137,7 @@ function localize_item(&$item){
case ACTIVITY_OBJ_NOTE:
default:
$post_type = t('status');
- if($obj['id'] != $item['mid'])
+ if($obj['mid'] != $obj['parent_mid'])
$post_type = t('comment');
break;
}
@@ -162,6 +162,9 @@ function localize_item(&$item){
$item['body'] .= "\n\n\n" . '[zrl=' . chanlink_url($author_link) . '][zmg=80x80]' . $Bphoto . '[/zmg][/zrl]';
}
+ else {
+ logger('localize_item like failed: link ' . $author_link . ' name ' . $author_name . ' url ' . $item_url);
+ }
}
@@ -712,6 +715,8 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') {
$threads = array();
foreach($items as $item) {
+ // Check for any blocked authors
+
if($arr_blocked) {
$blocked = false;
foreach($arr_blocked as $b) {
@@ -724,6 +729,18 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') {
continue;
}
+ // Check all the kids too
+
+ if($arr_blocked && $item['children']) {
+ for($d = 0; $d < count($item['children']); $d ++) {
+ foreach($arr_blocked as $b) {
+ if(($b) && ($item['children'][$d]['author_xchan'] == $b))
+ $item['children'][$d]['author_blocked'] = true;
+ }
+ }
+ }
+
+
// Can we put this after the visibility check?
like_puller($a,$item,$alike,'like');
diff --git a/include/features.php b/include/features.php
index da1322a14..6272b33ea 100644
--- a/include/features.php
+++ b/include/features.php
@@ -19,15 +19,15 @@ function get_features() {
// General
'general' => array(
t('General Features'),
- array('expire', t('Content Expiration'), t('Remove old posts/comments after a period of time')),
+// uncomment when expire is fixed
+// array('expire', t('Content Expiration'), t('Remove old posts/comments after a period of time')),
array('multi_profiles', t('Multiple Profiles'), t('Ability to create multiple profiles')),
array('webpages', t('Web Pages'), t('Provide managed web pages on your channel')),
array('prettyphoto', t('Enhanced Photo Albums'), t('Enable photo album with enhanced features')),
//FIXME - needs a description, but how the hell do we explain this to normals?
array('sendzid', t('Extended Identity Sharing'), t(' ')),
array('expert', t('Expert Mode'), t('Enable Expert Mode to provide advanced configuration options')),
-
-
+ array('premium_channel', t('Premium Channel'), t('Allows you to set restrictions and terms on those that connect with your channel')),
),
// Post composition
diff --git a/include/follow.php b/include/follow.php
index 6b192234c..10bcddf2b 100644
--- a/include/follow.php
+++ b/include/follow.php
@@ -11,7 +11,7 @@
require_once('include/zot.php');
-function new_contact($uid,$url,$channel,$interactive = false) {
+function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) {
$result = array('success' => false,'message' => '');
@@ -60,6 +60,11 @@ function new_contact($uid,$url,$channel,$interactive = false) {
return $result;
}
+ // Premium channel, set confirm before callback to avoid recursion
+
+ if(array_key_exists('connect_url',$j) && (! $confirm))
+ goaway(zid($j['connect_url']));
+
// check service class limits
@@ -145,12 +150,13 @@ function new_contact($uid,$url,$channel,$interactive = false) {
);
}
else {
- $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_their_perms, abook_created, abook_updated )
- values( %d, %d, '%s', %d, '%s', '%s' ) ",
+ $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_their_perms, abook_my_perms, abook_created, abook_updated )
+ values( %d, %d, '%s', %d, %d, '%s', '%s' ) ",
intval($aid),
intval($uid),
dbesc($xchan_hash),
intval($their_perms),
+ intval(PERMS_W_STREAM|PERMS_W_MAIL),
dbesc(datetime_convert()),
dbesc(datetime_convert())
);
diff --git a/include/identity.php b/include/identity.php
index 99b90cc8b..1658669d6 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -115,11 +115,19 @@ function create_identity($arr) {
if(array_key_exists('primary', $arr))
$primary = intval($arr['primary']);
+ $perms_sql = '';
+
+ $defperms = site_default_perms();
+ $global_perms = get_perms();
+ foreach($defperms as $p => $v) {
+ $perms_keys .= ', ' . $global_perms[$p][0];
+ $perms_vals .= ', ' . intval($v);
+ }
$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 )
- values ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d ) ",
+ channel_hash, channel_prvkey, channel_pubkey, channel_pageflags $perms_keys )
+ values ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d $perms_vals ) ",
intval($arr['account_id']),
intval($primary),
@@ -133,6 +141,9 @@ function create_identity($arr) {
intval($pageflags)
);
+
+
+
$r = q("select * from channel where channel_account_id = %d
and channel_guid = '%s' limit 1",
intval($arr['account_id']),
@@ -171,7 +182,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_name, xchan_network, xchan_photo_date, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
+ $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_name, xchan_network, xchan_photo_date, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
dbesc($hash),
dbesc($guid),
dbesc($sig),
@@ -181,6 +192,7 @@ function create_identity($arr) {
dbesc($a->get_baseurl() . "/photo/profile/s/{$newuid}"),
dbesc($ret['channel']['channel_address'] . '@' . get_app()->get_hostname()),
dbesc(z_root() . '/channel/' . $ret['channel']['channel_address']),
+ dbesc(z_root() . '/follow?f=&url=%s'),
dbesc($ret['channel']['channel_name']),
dbesc('zot'),
dbesc(datetime_convert()),
diff --git a/include/items.php b/include/items.php
index 6d853323f..10bdcb38f 100755
--- a/include/items.php
+++ b/include/items.php
@@ -31,10 +31,11 @@ function collect_recipients($item,&$private) {
}
else {
$recipients = array();
- $r = q("select * from abook where abook_channel = %d and not (abook_flags & %d) and not (abook_flags & %d)",
+ $r = q("select * from abook where abook_channel = %d and not (abook_flags & %d) and not (abook_flags & %d) and not (abook_flags & %d)",
intval($item['uid']),
intval(ABOOK_FLAG_SELF),
- intval(ABOOK_FLAG_PENDING)
+ intval(ABOOK_FLAG_PENDING),
+ intval(ABOOK_FLAG_ARCHIVED)
);
if($r) {
foreach($r as $rr) {
@@ -772,14 +773,19 @@ function decode_tags($t) {
function activity_sanitise($arr) {
if($arr) {
- $ret = array();
- foreach($arr as $k => $x) {
- if(is_array($x))
- $ret[$k] = activity_sanitise($x);
- else
- $ret[$k] = htmlentities($x, ENT_COMPAT,'UTF-8',false);
+ if(is_array($arr)) {
+ $ret = array();
+ foreach($arr as $k => $x) {
+ if(is_array($x))
+ $ret[$k] = activity_sanitise($x);
+ else
+ $ret[$k] = htmlentities($x, ENT_COMPAT,'UTF-8',false);
+ }
+ return $ret;
+ }
+ else {
+ return htmlentities($arr, ENT_COMPAT,'UTF-8', false);
}
- return $ret;
}
return '';
}
@@ -834,6 +840,9 @@ function encode_mail($item) {
$x['from'] = encode_item_xchan($item['from']);
$x['to'] = encode_item_xchan($item['to']);
+ if($item['attach'])
+ $x['attach'] = json_decode_plus($item['attach']);
+
$x['flags'] = array();
if($item['mail_flags'] & MAIL_RECALLED) {
@@ -879,6 +888,9 @@ function get_mail_elements($x) {
$arr['mid'] = (($x['message_id']) ? htmlentities($x['message_id'], ENT_COMPAT,'UTF-8',false) : '');
$arr['parent_mid'] = (($x['message_parent']) ? htmlentities($x['message_parent'], ENT_COMPAT,'UTF-8',false) : '');
+ if($x['attach'])
+ $arr['attach'] = activity_sanitise($x['attach']);
+
if(import_author_xchan($x['from']))
$arr['from_xchan'] = base64url_encode(hash('whirlpool',$x['from']['guid'] . $x['from']['guid_sig'], true));
@@ -1411,12 +1423,15 @@ function item_store($arr,$allow_exec = false) {
}
-
+ if($arr['object'])
+ logger('item_store: input object: ' . print_r($arr['object'],true), LOGGER_DATA);
if((x($arr,'object')) && is_array($arr['object'])) {
activity_sanitise($arr['object']);
+ logger('item_store: sanitised object: ' . print_r($arr['object'],true), LOGGER_DATA);
$arr['object'] = json_encode($arr['object']);
+ logger('item_store: encoded object: ' . print_r($arr['object'],true), LOGGER_DATA);
}
if((x($arr,'target')) && is_array($arr['target'])) {
@@ -1571,10 +1586,10 @@ function item_store($arr,$allow_exec = false) {
unset($arr['term']);
}
- dbesc_array($arr);
-
logger('item_store: ' . print_r($arr,true), LOGGER_DATA);
+ dbesc_array($arr);
+
$r = dbq("INSERT INTO `item` (`"
. implode("`, `", array_keys($arr))
. "`) VALUES ('"
@@ -2193,6 +2208,9 @@ function mail_store($arr) {
if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false))
$arr['body'] = escape_tags($arr['body']);
+ if(array_key_exists('attach',$arr) && is_array($arr['attach']))
+ $arr['attach'] = json_encode($arr['attach']);
+
$arr['account_id'] = ((x($arr,'account_id')) ? intval($arr['account_id']) : 0);
$arr['mid'] = ((x($arr,'mid')) ? notags(trim($arr['mid'])) : random_string());
$arr['from_xchan'] = ((x($arr,'from_xchan')) ? notags(trim($arr['from_xchan'])) : '');
@@ -2201,6 +2219,7 @@ function mail_store($arr) {
$arr['title'] = ((x($arr,'title')) ? notags(trim($arr['title'])) : '');
$arr['parent_mid'] = ((x($arr,'parent_mid')) ? notags(trim($arr['parent_mid'])) : '');
$arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : '');
+
$arr['mail_flags'] = ((x($arr,'mail_flags')) ? intval($arr['mail_flags']) : 0 );
diff --git a/include/message.php b/include/message.php
index fc0d5f2b3..e54a6cd83 100644
--- a/include/message.php
+++ b/include/message.php
@@ -3,6 +3,7 @@
/* Private Message backend API */
require_once('include/crypto.php');
+require_once('include/attach.php');
// send a private message
@@ -74,14 +75,44 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto='
if(preg_match_all("/\[img\](.*?)\[\/img\]/",$body,$match))
$images = $match[1];
+ $match = false;
+
+ if(preg_match_all("/\[attachment\](.*?)\[\/attachment\]/",$body,$match))
+ $attaches = $match[1];
+
+ $attachments = '';
+
+ if(preg_match_all('/(\[attachment\](.*?)\[\/attachment\])/',$body,$match)) {
+ $attachments = array();
+ foreach($match[2] as $mtch) {
+ $hash = substr($mtch,0,strpos($mtch,','));
+ $rev = intval(substr($mtch,strpos($mtch,',')));
+ $r = attach_by_hash_nodata($hash,$rev);
+ if($r['success']) {
+ $attachments[] = array(
+ 'href' => $a->get_baseurl() . '/attach/' . $r['data']['hash'],
+ 'length' => $r['data']['filesize'],
+ 'type' => $r['data']['filetype'],
+ 'title' => urlencode($r['data']['filename']),
+ 'revision' => $r['data']['revision']
+ );
+ }
+ $body = str_replace($match[1],'',$body);
+ }
+ }
+
+ $jattach = (($attachments) ? json_encode($attachments) : '');
+
$key = get_config('system','pubkey');
if($subject)
$subject = json_encode(aes_encapsulate($subject,$key));
if($body)
$body = json_encode(aes_encapsulate($body,$key));
- $r = q("INSERT INTO mail ( account_id, mail_flags, channel_id, from_xchan, to_xchan, title, body, mid, parent_mid, created )
- VALUES ( %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
+
+
+ $r = q("INSERT INTO mail ( account_id, mail_flags, channel_id, from_xchan, to_xchan, title, body, attach, mid, parent_mid, created )
+ VALUES ( %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
intval($channel['channel_account_id']),
intval(MAIL_OBSCURED),
intval($channel['channel_id']),
@@ -89,6 +120,7 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto='
dbesc($recipient),
dbesc($subject),
dbesc($body),
+ dbesc($jattach),
dbesc($mid),
dbesc($replyto),
dbesc(datetime_convert())
@@ -122,6 +154,19 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto='
}
}
+ if($attaches) {
+ foreach($attaches as $attach) {
+ $hash = substr($attach,0,strpos($attach,','));
+ $rev = intval(substr($attach,strpos($attach,',')));
+ attach_store($channel,$observer_hash,$options = 'update', array(
+ 'hash' => $hash,
+ 'revision' => $rev,
+ 'allow_cid' => '<' . $recipient . '>',
+
+ ));
+ }
+ }
+
proc_run('php','include/notifier.php','mail',$post_id);
$ret['success'] = true;
diff --git a/include/notifier.php b/include/notifier.php
index a0c07200a..2a0301357 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -54,6 +54,7 @@ require_once('include/html2plain.php');
* ZOT
* permission_update abook_id
* refresh_all channel_id
+ * expire channel_id
* relay item_id (item was relayed to owner, we will deliver it as owner)
*
*/
@@ -166,14 +167,24 @@ function notifier_run($argv, $argc){
elseif($cmd === 'expire') {
$normal_mode = false;
$expire = true;
- $items = q("SELECT * FROM `item` WHERE `uid` = %d AND `wall` = 1
- AND `deleted` = 1 AND `changed` > UTC_TIMESTAMP() - INTERVAL 10 MINUTE",
- intval($item_id)
+ $items = q("SELECT * FROM item WHERE uid = %d AND ( item_flags & %d )
+ AND ( item_restrict & %d ) AND `changed` > UTC_TIMESTAMP() - INTERVAL 10 MINUTE",
+ intval($item_id),
+ intval(ITEM_WALL),
+ intval(ITEM_DELETED)
);
$uid = $item_id;
$item_id = 0;
- if(! count($items))
+ if(! $items)
return;
+
+// FIXME
+// This will require a special zot packet containing a list of item message_id's to be expired.
+// This packet will be public, since we cannot selectively deliver here.
+// We need the handling on this end to create the array, and the handling on the remote end
+// to verify permissions (for each item) and process it. Until this is complete, the expire feature will be disabled.
+
+ return;
}
elseif($cmd === 'suggest') {
$normal_mode = false;
diff --git a/include/oauth.php b/include/oauth.php
index 2f70f21fb..6ec5285e4 100644
--- a/include/oauth.php
+++ b/include/oauth.php
@@ -145,7 +145,7 @@ class FKOAuth1 extends OAuthServer {
}
$_SESSION['uid'] = $record['uid'];
$_SESSION['theme'] = $record['theme'];
- $_SESSION['mobile-theme'] = get_pconfig($record['uid'], 'system', 'mobile_theme');
+ $_SESSION['mobile_theme'] = get_pconfig($record['uid'], 'system', 'mobile_theme');
$_SESSION['authenticated'] = 1;
$_SESSION['page_flags'] = $record['page-flags'];
$_SESSION['my_url'] = $a->get_baseurl() . '/channel/' . $record['nickname'];
diff --git a/include/permissions.php b/include/permissions.php
index e7f50ceeb..bf50ebdd1 100644
--- a/include/permissions.php
+++ b/include/permissions.php
@@ -328,3 +328,38 @@ function check_list_permissions($uid,$arr,$perm) {
return($result);
}
+
+
+function site_default_perms() {
+
+ $typical = array(
+ 'view_stream' => PERMS_PUBLIC,
+ 'view_profile' => PERMS_PUBLIC,
+ 'view_photos' => PERMS_PUBLIC,
+ 'view_contacts' => PERMS_PUBLIC,
+ 'view_storage' => PERMS_PUBLIC,
+ 'view_pages' => PERMS_PUBLIC,
+ 'send_stream' => PERMS_SPECIFIC,
+ 'post_wall' => PERMS_SPECIFIC,
+ 'post_comments' => PERMS_SPECIFIC,
+ 'post_mail' => PERMS_SPECIFIC,
+ 'post_photos' => 0,
+ 'tag_deliver' => PERMS_SPECIFIC,
+ 'chat' => PERMS_SPECIFIC,
+ 'write_storage' => 0,
+ 'write_pages' => 0,
+ 'delegate' => 0,
+ );
+
+
+ $global_perms = get_perms();
+ $ret = array();
+
+ foreach($global_perms as $perm => $v) {
+ $x = get_config('default_perms',$perm);
+ if($x === false)
+ $x = $typical[$perm];
+ $ret[$perm] = $x;
+ }
+ return $ret;
+}
diff --git a/include/poller.php b/include/poller.php
index 00914a712..7a6aaeb22 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -84,7 +84,8 @@ function poller_run($argv, $argc){
set_config('system','last_expire_day',$d2);
- proc_run('php','include/expire.php');
+// Uncomment when expire protocol component is working
+// proc_run('php','include/expire.php');
proc_run('php','include/cli_suggest.php');
@@ -117,18 +118,18 @@ function poller_run($argv, $argc){
$force = false;
$restart = false;
- if((argc() > 1) && (argv(1) == 'force'))
+ if(($argc > 1) && ($argv[1] == 'force'))
$force = true;
- if((argc() > 1) && (argv(1) == 'restart')) {
+ if(($argc > 1) && ($argv[1] == 'restart')) {
$restart = true;
- $generation = intval(argv(2));
+ $generation = intval($argv[2]);
if(! $generation)
killme();
}
- if((argc() > 1) && intval(argv(1))) {
- $manual_id = intval(argv(1));
+ if(($argc > 1) && intval($argv[1])) {
+ $manual_id = intval($argv[1]);
$force = true;
}
@@ -156,7 +157,8 @@ function poller_run($argv, $argc){
: ''
);
- $contacts = q("SELECT abook_id, abook_updated, abook_closeness, abook_channel
+
+ $contacts = q("SELECT abook_id, abook_updated, abook_connected, abook_closeness, abook_channel
FROM abook LEFT JOIN account on abook_account = account_id where 1
$sql_extra
AND (( abook_flags = %d ) OR ( abook_flags = %d ))
@@ -188,10 +190,10 @@ function poller_run($argv, $argc){
else {
// if we've never connected with them, start the mark for death countdown from now
- if($c === '0000-00-00 00:00:00') {
+ if($c == '0000-00-00 00:00:00') {
$r = q("update abook set abook_connected = '%s' where abook_id = %d limit 1",
dbesc(datetime_convert()),
- intval($abook['abook_id'])
+ intval($contact['abook_id'])
);
$c = datetime_convert();
$update = true;
@@ -199,8 +201,8 @@ function poller_run($argv, $argc){
// He's dead, Jim
- if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $c . " + 30 day")) {
- $r = q("update abook set abook_flags = (abook_flags & %d) where abook_id = %d limit 1",
+ if(strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $c . " + 30 day")) > 0) {
+ $r = q("update abook set abook_flags = (abook_flags | %d) where abook_id = %d limit 1",
intval(ABOOK_FLAG_ARCHIVED),
intval($contact['abook_id'])
);
@@ -212,17 +214,17 @@ function poller_run($argv, $argc){
// recently deceased, so keep up the regular schedule for 3 days
- if((datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $c . " + 3 day"))
- && (datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day")))
+ if((strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $c . " + 3 day")) > 0)
+ && (strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $t . " + 1 day")) > 0))
$update = true;
// After that back off and put them on a morphine drip
- if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 2 day")) {
+ if(strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $t . " + 2 day")) > 0) {
$update = true;
}
}
-
+dbg(0);
if((! $update) && (! $force))
continue;
diff --git a/include/security.php b/include/security.php
index ef4d5a313..4738e473b 100644
--- a/include/security.php
+++ b/include/security.php
@@ -34,6 +34,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
else {
$_SESSION['uid'] = $user_record['uid'];
$_SESSION['theme'] = $user_record['theme'];
+ $_SESSION['mobile_theme'] = get_pconfig($user_record['uid'], 'system', 'mobile_theme');
$_SESSION['authenticated'] = 1;
$_SESSION['page_flags'] = $user_record['page-flags'];
$_SESSION['my_url'] = $a->get_baseurl() . '/channel/' . $user_record['nickname'];
@@ -148,6 +149,7 @@ function change_channel($change_channel) {
$_SESSION['uid'] = intval($r[0]['channel_id']);
get_app()->set_channel($r[0]);
$_SESSION['theme'] = $r[0]['channel_theme'];
+ $_SESSION['mobile_theme'] = get_pconfig(local_user(),'system', 'mobile_theme');
date_default_timezone_set($r[0]['channel_timezone']);
$ret = $r[0];
}
diff --git a/include/socgraph.php b/include/socgraph.php
index 177ed0f3a..b34d5142c 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -1,5 +1,6 @@
<?php /** @file */
+require_once('include/dir_fns.php');
require_once('include/zot.php');
/*
diff --git a/include/zot.php b/include/zot.php
index bddbc9bee..c7049dee6 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -441,6 +441,9 @@ function import_xchan($arr) {
dbesc($xchan_hash)
);
+ if(! array_key_exists('connect_url', $arr))
+ $arr['connect_url'] = '';
+
if($r) {
if($r[0]['xchan_photo_date'] != $arr['photo_updated'])
@@ -462,18 +465,22 @@ function import_xchan($arr) {
$new_flags = $r[0]['xchan_flags'] ^ XCHAN_FLAGS_HIDDEN;
else
$new_flags = $r[0]['xchan_flags'];
-
-
+
if(($r[0]['xchan_name_date'] != $arr['name_updated'])
|| ($r[0]['xchan_connurl'] != $arr['connections_url'])
|| ($r[0]['xchan_flags'] != $new_flags)
|| ($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_flags = %d,
+ $r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_connurl = '%s', xchan_follow = '%s',
+ xchan_connpage = '%s', xchan_flags = %d,
xchan_addr = '%s', xchan_url = '%s' where xchan_hash = '%s' limit 1",
dbesc($arr['name']),
dbesc($arr['name_updated']),
dbesc($arr['connections_url']),
+ dbesc($arr['follow_url']),
+ dbesc($arr['connect_url']),
intval($new_flags),
dbesc($arr['address']),
dbesc($arr['url']),
@@ -503,8 +510,8 @@ function import_xchan($arr) {
$new_flags = 0;
$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_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', %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_flags)
+ values ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d) ",
dbesc($xchan_hash),
dbesc($arr['guid']),
dbesc($arr['guid_sig']),
@@ -514,6 +521,8 @@ function import_xchan($arr) {
dbesc($arr['address']),
dbesc($arr['url']),
dbesc($arr['connections_url']),
+ dbesc($arr['follow_url']),
+ dbesc($arr['connect_url']),
dbesc($arr['name']),
dbesc('zot'),
dbesc($arr['photo_updated']),
@@ -829,6 +838,7 @@ function zot_import($arr) {
// and who are allowed to see them based on the sender's permissions
$deliveries = allowed_public_recips($i);
+
}
if(! $deliveries) {
logger('zot_import: no deliveries on this site');
@@ -901,10 +911,12 @@ function zot_import($arr) {
function public_recips($msg) {
+ $check_mentions = false;
if($msg['message']['type'] === 'activity') {
if(array_key_exists('flags',$msg['message']) && in_array('thread_parent', $msg['message']['flags'])) {
$col = 'channel_w_stream';
$field = PERMS_W_STREAM;
+ $check_mentions = true;
}
else {
$col = 'channel_w_comment';
@@ -919,6 +931,7 @@ function public_recips($msg) {
if(! $col)
return NULL;
+
if($msg['notify']['sender']['url'] === z_root())
$sql = " where (( " . $col . " & " . PERMS_NETWORK . " ) or ( " . $col . " & " . PERMS_SITE . " )) ";
else
@@ -938,6 +951,27 @@ function public_recips($msg) {
$x = array();
$r = array_merge($r,$x);
+
+ // look for any public mentions on this site
+ // They will get filtered by tgroup_check() so we don't need to check permissions now
+
+ if($check_mentions && $msg['message']['tags']) {
+ if(is_array($msg['message']['tags']) && $msg['message']['tags']) {
+ foreach($msg['message']['tags'] as $tag) {
+ if(($tag['type'] === 'mention') && (strpos($tag['url'],z_root()) !== false)) {
+ $address = basename($tag['url']);
+ if($address) {
+ $z = q("select channel_hash as hash from channel where channel_address = '%s' limit 1",
+ dbesc($address)
+ );
+ if($z)
+ $r = array_merge($r,$z);
+ }
+ }
+ }
+ }
+ }
+
logger('public_recips: ' . print_r($r,true), LOGGER_DATA);
return $r;
}