aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/connections.php2
-rw-r--r--include/conversation.php12
-rwxr-xr-xinclude/items.php8
-rw-r--r--include/message.php6
-rw-r--r--include/nav.php2
-rw-r--r--include/network.php18
-rw-r--r--include/photos.php3
-rw-r--r--include/queue_fn.php9
-rw-r--r--include/text.php2
-rw-r--r--include/zid.php25
-rw-r--r--include/zot.php33
11 files changed, 105 insertions, 15 deletions
diff --git a/include/connections.php b/include/connections.php
index 60bce018e..e9d7daa2d 100644
--- a/include/connections.php
+++ b/include/connections.php
@@ -369,7 +369,7 @@ function contact_remove($channel_id, $abook_id) {
return false;
- $r = q("select * from item where (owner_xchan = '%s' or author_xchan = '%s') and uid = %d",
+ $r = q("select id from item where (owner_xchan = '%s' or author_xchan = '%s') and uid = %d",
dbesc($abook['abook_xchan']),
dbesc($abook['abook_xchan']),
intval($channel_id)
diff --git a/include/conversation.php b/include/conversation.php
index f395b2cbe..5ff8b3864 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -162,6 +162,18 @@ function localize_item(&$item){
elseif(activity_match($item['verb'],ACTIVITY_DISLIKE)) {
$bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
}
+
+ // short version, in notification strings the author will be displayed separately
+
+ if(activity_match($item['verb'],ACTIVITY_LIKE)) {
+ $shortbodyverb = t('likes %1$s\'s %2$s');
+ }
+ elseif(activity_match($item['verb'],ACTIVITY_DISLIKE)) {
+ $shortbodyverb = t('doesn\'t like %1$s\'s %2$s');
+ }
+
+ $item['shortlocalize'] = sprintf($bodyverb, $objauthor, $plink);
+
$item['body'] = $item['localize'] = sprintf($bodyverb, $author, $objauthor, $plink);
if($Bphoto != "")
$item['body'] .= "\n\n\n" . '[zrl=' . chanlink_url($author_link) . '][zmg=80x80]' . $Bphoto . '[/zmg][/zrl]';
diff --git a/include/items.php b/include/items.php
index dd8b394d3..08e53553b 100755
--- a/include/items.php
+++ b/include/items.php
@@ -173,19 +173,19 @@ function comments_are_now_closed($item) {
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 ";
+ and item.item_blocked = 0 and item.obj_type != '" . ACTIVITY_OBJ_FILE . "' ";
}
function item_normal_search() {
return " and item.item_hidden = 0 and item.item_type in (0,3,6) 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 ";
+ and item.item_blocked = 0 and item.obj_type != '" . ACTIVITY_OBJ_FILE . "' ";
}
function item_normal_update() {
return " and item.item_hidden = 0 and item.item_type = 0
and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
- and item.item_blocked = 0 ";
+ and item.item_blocked = 0 and item.obj_type != '" . ACTIVITY_OBJ_FILE . "' ";
}
@@ -201,7 +201,7 @@ function is_item_normal($item) {
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']))
+ || intval($item['item_blocked']) || ($item['obj_type'] == ACTIVITY_OBJ_FILE))
return false;
return true;
diff --git a/include/message.php b/include/message.php
index 3f003e020..477c7172c 100644
--- a/include/message.php
+++ b/include/message.php
@@ -381,7 +381,7 @@ function private_messages_list($uid, $mailbox = '', $start = 0, $numitems = 0) {
$chans[] = $s;
}
- $c = q("select * from xchan where xchan_hash in (" . implode(',',$chans) . ")");
+ $c = q("select * from xchan where xchan_hash in (" . protect_sprintf(implode(',',$chans)) . ")");
foreach($r as $k => $rr) {
$r[$k]['from'] = find_xchan_in_array($rr['from_xchan'],$c);
@@ -420,7 +420,7 @@ function private_messages_fetch_message($channel_id, $messageitem_id, $updatesee
$chans[] = $s;
}
- $c = q("select * from xchan where xchan_hash in (" . implode(',',$chans) . ")");
+ $c = q("select * from xchan where xchan_hash in (" . protect_sprintf(implode(',',$chans)) . ")");
foreach($messages as $k => $message) {
$messages[$k]['from'] = find_xchan_in_array($message['from_xchan'],$c);
@@ -545,7 +545,7 @@ function private_messages_fetch_conversation($channel_id, $messageitem_id, $upda
}
- $c = q("select * from xchan where xchan_hash in (" . implode(',',$chans) . ")");
+ $c = q("select * from xchan where xchan_hash in (" . protect_sprintf(implode(',',$chans)) . ")");
foreach($messages as $k => $message) {
$messages[$k]['from'] = find_xchan_in_array($message['from_xchan'],$c);
diff --git a/include/nav.php b/include/nav.php
index 89947e270..af0ebbae2 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -312,7 +312,7 @@ EOT;
'$pleasewait' => t('Please wait...'),
'$nav_apps' => $nav_apps,
'$navbar_apps' => $navbar_apps,
- '$channel_menu' => get_config('system','channel_menu'),
+ '$channel_menu' => get_pconfig(App::$profile_uid,'system','channel_menu',get_config('system','channel_menu')),
'$channel_thumb' => ((App::$profile) ? App::$profile['thumb'] : ''),
'$channel_apps' => $channel_apps,
'$addapps' => t('Add Apps'),
diff --git a/include/network.php b/include/network.php
index 2f29a70c4..2caf29ab5 100644
--- a/include/network.php
+++ b/include/network.php
@@ -1433,11 +1433,27 @@ function scrape_feed($url) {
-function do_delivery($deliveries) {
+
+
+function do_delivery($deliveries, $force = false) {
+
+ // $force is set if a site that wasn't responding suddenly returns to life.
+ // Try and shove through everything going to that site while it's responding.
if(! (is_array($deliveries) && count($deliveries)))
return;
+
+ $x = q("select count(outq_hash) as total from outq where outq_delivered = 0");
+ if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',300)) && (! $force)) {
+ logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO);
+ foreach($deliveries as $d) {
+ update_queue_item($d);
+ }
+ return;
+ }
+
+
$interval = ((get_config('system','delivery_interval') !== false)
? intval(get_config('system','delivery_interval')) : 2 );
diff --git a/include/photos.php b/include/photos.php
index 5de68f162..503a725cd 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -75,6 +75,9 @@ function photo_upload($channel, $observer, $args) {
$imagedata = @file_get_contents($tmp_name);
@unlink($tmp_name);
}
+ else {
+ $imagedata = @file_get_contents($args['os_syspath']);
+ }
}
else {
$imagedata = @file_get_contents($args['os_syspath']);
diff --git a/include/queue_fn.php b/include/queue_fn.php
index c9179b953..5fb0d5f1e 100644
--- a/include/queue_fn.php
+++ b/include/queue_fn.php
@@ -42,7 +42,7 @@ function update_queue_item($id, $add_priority = 0) {
$next = datetime_convert('UTC','UTC','now + 1 hour');
}
else {
- $next = datetime_convert('UTC','UTC','now + 15 minutes');
+ $next = datetime_convert('UTC','UTC','now + ' . intval($add_priority) . ' minutes');
}
q("UPDATE outq SET outq_updated = '%s',
@@ -158,6 +158,8 @@ function queue_deliver($outq, $immediate = false) {
}
}
+
+
$arr = array('outq' => $outq, 'base' => $base, 'handled' => false, 'immediate' => $immediate);
call_hooks('queue_deliver',$arr);
if($arr['handled'])
@@ -198,14 +200,15 @@ function queue_deliver($outq, $immediate = false) {
}
}
if($piled_up) {
- do_delivery($piled_up);
+ // call do_delivery() with the force flag
+ do_delivery($piled_up, true);
}
}
}
else {
logger('deliver: queue post returned ' . $result['return_code']
. ' from ' . $outq['outq_posturl'],LOGGER_DEBUG);
- update_queue_item($outq['outq_posturl']);
+ update_queue_item($outq['outq_hash'],10);
}
return;
}
diff --git a/include/text.php b/include/text.php
index d81b59d75..746c35679 100644
--- a/include/text.php
+++ b/include/text.php
@@ -2160,7 +2160,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_primary = 1");
+ where xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and hubloc_primary = 1");
}
if($chans) {
$item['from'] = find_xchan_in_array($item['from_xchan'],$chans);
diff --git a/include/zid.php b/include/zid.php
index ce9f70385..5ade6b0f8 100644
--- a/include/zid.php
+++ b/include/zid.php
@@ -89,10 +89,35 @@ function strip_zids($s) {
return preg_replace('/[\?&]zid=(.*?)(&|$)/ism','$2',$s);
}
+function strip_owt($s) {
+ return preg_replace('/[\?&]owt=(.*?)(&|$)/ism','$2',$s);
+}
+
function strip_zats($s) {
return preg_replace('/[\?&]zat=(.*?)(&|$)/ism','$2',$s);
}
+function strip_auth_query_params() {
+
+ $_SERVER['QUERY_STRING'] = str_replace(array('?f=', '&f='), array('', ''), $_SERVER['QUERY_STRING']);
+ $_SERVER['QUERY_STRING'] = strip_zids($_SERVER['QUERY_STRING']);
+ $_SERVER['QUERY_STRING'] = strip_owt($_SERVER['QUERY_STRING']);
+
+ $_SERVER['REQUEST_URI'] = str_replace(array('?f=', '&f='), array('', ''), $_SERVER['REQUEST_URI']);
+ $_SERVER['REQUEST_URI'] = strip_zids($_SERVER['REQUEST_URI']);
+ $_SERVER['REQUEST_URI'] = strip_owt($_SERVER['REQUEST_URI']);
+
+
+ $_ENV['QUERY_STRING'] = str_replace(array('?f=', '&f='), array('', ''), $_ENV['QUERY_STRING']);
+ $_ENV['QUERY_STRING'] = strip_zids($_ENV['QUERY_STRING']);
+ $_ENV['QUERY_STRING'] = strip_owt($_ENV['QUERY_STRING']);
+
+ $_ENV['REQUEST_URI'] = str_replace(array('?f=', '&f='), array('', ''), $_ENV['REQUEST_URI']);
+ $_ENV['REQUEST_URI'] = strip_zids($_ENV['REQUEST_URI']);
+ $_ENV['REQUEST_URI'] = strip_owt($_ENV['REQUEST_URI']);
+
+}
+
/**
* zidify_callback() and zidify_links() work together to turn any HTML a tags with class="zrl" into zid links
diff --git a/include/zot.php b/include/zot.php
index dad30dbb0..5764bb99a 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -285,6 +285,16 @@ function zot_refresh($them, $channel = null, $force = false) {
return false;
}
+ $s = q("select site_dead from site where site_url = '%s' limit 1",
+ dbesc($url)
+ );
+
+ if($s && intval($s[0]['site_dead']) && (! $force)) {
+ logger('zot_refresh: site ' . $url . ' is marked dead and force flag is not set. Cancelling operation.');
+ return false;
+ }
+
+
$token = random_string();
$postvars = [];
@@ -3138,6 +3148,15 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
'msg' => json_encode($info)
));
+
+ $x = q("select count(outq_hash) as total from outq where outq_delivered = 0");
+ if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',300))) {
+ logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO);
+ update_queue_item($hash);
+ continue;
+ }
+
+
Zotlabs\Daemon\Master::Summon(array('Deliver', $hash));
$total = $total - 1;
@@ -3649,6 +3668,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
$disallowed = array('id','aid','uid','guid');
foreach($arr['profile'] as $profile) {
+
$x = q("select * from profile where profile_guid = '%s' and uid = %d limit 1",
dbesc($profile['profile_guid']),
intval($channel['channel_id'])
@@ -3671,6 +3691,9 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
if(in_array($k,$disallowed))
continue;
+ if($profile['is_default'] && in_array($k,['photo','thumb']))
+ continue;
+
if($k === 'name')
$clean['fullname'] = $v;
elseif($k === 'with')
@@ -3868,7 +3891,7 @@ function zot_reply_message_request($data) {
if ($messages) {
$env_recips = null;
- $r = q("select hubloc.*, site.site_crypto from hubloc left join site on hubloc_url = site_url where hubloc_hash = '%s' and hubloc_error = 0 and hubloc_deleted = 0",
+ $r = q("select hubloc.*, site.site_crypto from hubloc left join site on hubloc_url = site_url where hubloc_hash = '%s' and hubloc_error = 0 and hubloc_deleted = 0 and site.site_dead = 0 ",
dbesc($sender_hash)
);
if (! $r) {
@@ -3901,6 +3924,14 @@ function zot_reply_message_request($data) {
'msg' => $data_packet
));
+
+ $x = q("select count(outq_hash) as total from outq where outq_delivered = 0");
+ if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',300))) {
+ logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO);
+ update_queue_item($hash);
+ continue;
+ }
+
/*
* invoke delivery to send out the notify packet
*/