Merge branch 'origin' into 'master'
Update 4.4.1 See merge request harukin/core!63
This commit is contained in:
@@ -672,6 +672,8 @@ function service_class_allows($uid, $property, $usage = false) {
|
||||
return true; // No service class set => everything is allowed
|
||||
|
||||
$limit = engr_units_to_bytes($limit);
|
||||
if($limit == 0)
|
||||
return true; // 0 means no limits
|
||||
if($usage === false) {
|
||||
// We use negative values for not allowed properties in a subscriber plan
|
||||
return ((x($limit)) ? (bool) $limit : true);
|
||||
@@ -759,7 +761,7 @@ function service_class_fetch($uid, $property) {
|
||||
if(! is_array($arr) || (! count($arr)))
|
||||
return false;
|
||||
|
||||
return((array_key_exists($property, $arr)) ? $arr[$property] : false);
|
||||
return((array_key_exists($property, $arr) && $arr[$property] != 0) ? $arr[$property] : false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -96,11 +96,15 @@ function api_login(&$a){
|
||||
if($sigblock) {
|
||||
$keyId = str_replace('acct:','',$sigblock['keyId']);
|
||||
if($keyId) {
|
||||
$r = q("select * from hubloc where hubloc_addr = '%s' limit 1",
|
||||
$r = q("select * from hubloc where ( hubloc_addr = '%s' or hubloc_id_url = '%s' ) limit 1",
|
||||
dbesc($keyId),
|
||||
dbesc($keyId)
|
||||
);
|
||||
if($r) {
|
||||
$c = channelx_by_hash($r[0]['hubloc_hash']);
|
||||
if (! $c) {
|
||||
$c = channelx_by_portid($r[0]['hubloc_hash']);
|
||||
}
|
||||
if($c) {
|
||||
$a = q("select * from account where account_id = %d limit 1",
|
||||
intval($c['channel_account_id'])
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
api_register_func('api/export/basic','api_export_basic', true);
|
||||
api_register_func('api/red/channel/export/basic','api_export_basic', true);
|
||||
api_register_func('api/z/1.0/channel/export/basic','api_export_basic', true);
|
||||
api_register_func('api/red/item/export/page','api_item_export_page', true);
|
||||
api_register_func('api/z/1.0/item/export/page','api_item_export_page', true);
|
||||
api_register_func('api/red/item/export_page','api_item_export_page', true);
|
||||
api_register_func('api/z/1.0/item/export_page','api_item_export_page', true);
|
||||
api_register_func('api/red/channel/list','api_channel_list', true);
|
||||
api_register_func('api/z/1.0/channel/list','api_channel_list', true);
|
||||
api_register_func('api/red/channel/stream','api_channel_stream', true);
|
||||
|
||||
@@ -1514,12 +1514,15 @@ function attach_delete($channel_id, $resource, $is_photo = 0) {
|
||||
|
||||
function attach_drop_photo($channel_id,$resource) {
|
||||
|
||||
$x = q("select id, item_hidden from item where resource_id = '%s' and resource_type = 'photo' and uid = %d",
|
||||
$x = q("select id, item_hidden from item where resource_id = '%s' and resource_type = 'photo' and uid = %d and item_deleted = 0",
|
||||
dbesc($resource),
|
||||
intval($channel_id)
|
||||
);
|
||||
|
||||
if($x) {
|
||||
drop_item($x[0]['id'],false,(($x[0]['item_hidden']) ? DROPITEM_NORMAL : DROPITEM_PHASE1),true);
|
||||
$stage = (($x[0]['item_hidden']) ? DROPITEM_NORMAL : DROPITEM_PHASE1);
|
||||
$interactive = (($x[0]['item_hidden']) ? false : true);
|
||||
drop_item($x[0]['id'], $interactive, $stage);
|
||||
}
|
||||
|
||||
$r = q("SELECT content FROM photo WHERE resource_id = '%s' AND uid = %d AND os_storage = 1",
|
||||
|
||||
@@ -1161,7 +1161,7 @@ function channel_export_items_date($channel_id, $start, $finish) {
|
||||
$ret['relocate'] = [ 'channel_address' => $ch['channel_address'], 'url' => z_root()];
|
||||
}
|
||||
|
||||
$r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and created >= '%s' and created <= '%s' and resource_type = '' order by created",
|
||||
$r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and created >= '%s' and created <= '%s' and resource_type != 'photo' order by created",
|
||||
intval(ITEM_TYPE_POST),
|
||||
intval($channel_id),
|
||||
dbesc($start),
|
||||
@@ -1223,7 +1223,7 @@ function channel_export_items_page($channel_id, $start, $finish, $page = 0, $lim
|
||||
$ret['relocate'] = [ 'channel_address' => $ch['channel_address'], 'url' => z_root()];
|
||||
}
|
||||
|
||||
$r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and resource_type = '' and created >= '%s' and created <= '%s' order by created limit %d offset %d",
|
||||
$r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and resource_type != 'photo' and created >= '%s' and created <= '%s' order by created limit %d offset %d",
|
||||
intval(ITEM_TYPE_POST),
|
||||
intval($channel_id),
|
||||
dbesc($start),
|
||||
@@ -1262,7 +1262,7 @@ function channel_export_items_page($channel_id, $start, $finish, $page = 0, $lim
|
||||
*/
|
||||
function profile_load($nickname, $profile = '') {
|
||||
|
||||
// logger('profile_load: ' . $nickname . (($profile) ? ' profile: ' . $profile : ''));
|
||||
//logger('profile_load: ' . $nickname . (($profile) ? ' profile: ' . $profile : ''));
|
||||
|
||||
$user = q("select channel_id from channel where channel_address = '%s' and channel_removed = 0 limit 1",
|
||||
dbesc($nickname)
|
||||
@@ -1303,6 +1303,14 @@ function profile_load($nickname, $profile = '') {
|
||||
dbesc($nickname),
|
||||
dbesc($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 profile.id = %d LIMIT 1",
|
||||
dbesc($nickname),
|
||||
intval($profile)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if(! $p) {
|
||||
|
||||
@@ -329,13 +329,36 @@ function update_directory_entry($ud) {
|
||||
|
||||
if ($ud['ud_addr'] && (! ($ud['ud_flags'] & UPDATE_FLAGS_DELETED))) {
|
||||
$success = false;
|
||||
$x = zot_finger($ud['ud_addr'], '');
|
||||
if ($x['success']) {
|
||||
$j = json_decode($x['body'], true);
|
||||
if ($j)
|
||||
$success = true;
|
||||
|
||||
$y = import_xchan($j, 0, $ud);
|
||||
// directory migration phase 1 (Macgirvin - 29-JUNE-2019)
|
||||
// fetch zot6 info (if available) as well as historical zot info (if available)
|
||||
// Once this has been running for > 1 month on the primary directory we can deprecate the historical info and
|
||||
// modify the directory search to only return zot6 entries, and also modify this function
|
||||
// to *only* fetch the zot6 entries.
|
||||
// Otherwise we'll be showing duplicates or have a mostly empty directory for a good chunk of
|
||||
// the transition period. Directory server load will likely increase "moderately" during this transition.
|
||||
// The one month counter begins when the primary directory has upgraded to a release which uses this code.
|
||||
// Hubzilla channels running traditional zot which have not upgraded can or will be dropped from the directory or
|
||||
// "not found" at the end of the transition period as the directory will only serve zot6 entries at that time.
|
||||
|
||||
$uri = \Zotlabs\Lib\Webfinger::zot_url($ud['ud_addr']);
|
||||
if($uri) {
|
||||
$record = \Zotlabs\Lib\Zotfinger::exec($uri);
|
||||
|
||||
// Check the HTTP signature
|
||||
|
||||
$hsig = $record['signature'];
|
||||
if($hsig && $hsig['signer'] === $url && $hsig['header_valid'] === true && $hsig['content_valid'] === true) {
|
||||
$x = \Zotlabs\Zot\Libzot::import_xchan($record['data'], 0, $ud);
|
||||
if($x['success']) {
|
||||
$success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$x = \Zotlabs\Zot\Finger::run($ud['ud_addr'], '');
|
||||
if ($x['success']) {
|
||||
import_xchan($x, 0, $ud);
|
||||
$success = true;
|
||||
}
|
||||
if (! $success) {
|
||||
q("update updates set ud_last = '%s' where ud_addr = '%s'",
|
||||
|
||||
@@ -280,20 +280,6 @@ function get_features($filtered = true, $level = (-1)) {
|
||||
|
||||
],
|
||||
|
||||
'events' => [
|
||||
|
||||
t('Events'),
|
||||
|
||||
[
|
||||
'events_cal_first_day',
|
||||
t('Start calendar week on Monday'),
|
||||
t('Default is Sunday'),
|
||||
false,
|
||||
get_config('feature_lock','events_cal_first_day')
|
||||
]
|
||||
|
||||
],
|
||||
|
||||
'manage' => [
|
||||
|
||||
t('Manage'),
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
use Zotlabs\Lib\IConfig;
|
||||
|
||||
use Zotlabs\Web\HTTPSig;
|
||||
|
||||
require_once('include/menu.php');
|
||||
require_once('include/perm_upgrade.php');
|
||||
|
||||
@@ -1177,7 +1179,7 @@ function sync_files($channel, $files) {
|
||||
convert_oldfields($att,'data','content');
|
||||
|
||||
if($att['deleted']) {
|
||||
attach_delete($channel,$att['hash']);
|
||||
attach_delete($channel['channel_id'],$att['hash']);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1329,7 +1331,7 @@ function sync_files($channel, $files) {
|
||||
$headers = [];
|
||||
$headers['Accept'] = 'application/x-zot+json' ;
|
||||
$headers['Sigtoken'] = random_string();
|
||||
$headers = \Zotlabs\Web\HTTPSig::create_sig('',$headers,$channel['channel_prvkey'], 'acct:' . $channel['channel_address'] . '@' . \App::get_hostname(),false,true,'sha512');
|
||||
$headers = HTTPSig::create_sig($headers,$channel['channel_prvkey'], 'acct:' . channel_reddress($channel),true,'sha512');
|
||||
|
||||
$x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]);
|
||||
fclose($fp);
|
||||
@@ -1383,12 +1385,14 @@ function sync_files($channel, $files) {
|
||||
);
|
||||
}
|
||||
|
||||
if(intval($p['imgscale']) === 0 && $p['os_storage'])
|
||||
$p['content'] = $store_path;
|
||||
else
|
||||
if(intval($p['os_storage'])) {
|
||||
$p['content'] = $store_path . ((intval($p['imgscale'])) ? '-' . $p['imgscale'] : '');
|
||||
}
|
||||
else {
|
||||
$p['content'] = (($p['content'])? base64_decode($p['content']) : '');
|
||||
}
|
||||
|
||||
if(intval($p['imgscale']) && (! empty($p['content']))) {
|
||||
if(intval($p['imgscale'])) {
|
||||
|
||||
$time = datetime_convert();
|
||||
|
||||
@@ -1413,7 +1417,7 @@ function sync_files($channel, $files) {
|
||||
$headers = [];
|
||||
$headers['Accept'] = 'application/x-zot+json' ;
|
||||
$headers['Sigtoken'] = random_string();
|
||||
$headers = \Zotlabs\Web\HTTPSig::create_sig('',$headers,$channel['channel_prvkey'], 'acct:' . $channel['channel_address'] . '@' . \App::get_hostname(),false,true,'sha512');
|
||||
$headers = HTTPSig::create_sig($headers,$channel['channel_prvkey'],'acct:' . channel_reddress($channel),true,'sha512');
|
||||
|
||||
$x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]);
|
||||
fclose($fp);
|
||||
|
||||
@@ -1457,6 +1457,7 @@ function encode_mail($item,$extended = false) {
|
||||
$x['to'] = encode_item_xchan($item['to']);
|
||||
$x['raw'] = $item['mail_raw'];
|
||||
$x['mimetype'] = $item['mail_mimetype'];
|
||||
$x['sig'] = $item['sig'];
|
||||
|
||||
if($item['attach'])
|
||||
$x['attach'] = json_decode($item['attach'],true);
|
||||
@@ -1516,6 +1517,9 @@ function get_mail_elements($x) {
|
||||
$arr['expires'] = datetime_convert('UTC','UTC',$x['expires']);
|
||||
|
||||
$arr['mail_flags'] = 0;
|
||||
|
||||
if(array_key_exists('sig',$x))
|
||||
$arr['sig'] = $x['sig'];
|
||||
|
||||
if($x['flags'] && is_array($x['flags'])) {
|
||||
if(in_array('recalled',$x['flags'])) {
|
||||
@@ -1984,11 +1988,12 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
|
||||
unset($arr['iconfig']);
|
||||
}
|
||||
|
||||
|
||||
if(strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid) || strlen($public_policy))
|
||||
$private = 1;
|
||||
else
|
||||
$private = $arr['item_private'];
|
||||
$private = intval($arr['item_private']);
|
||||
if (! $private) {
|
||||
if (strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid)) {
|
||||
$private = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$arr['parent'] = $parent_id;
|
||||
$arr['allow_cid'] = $allow_cid;
|
||||
@@ -2007,7 +2012,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
|
||||
// find the item we just created
|
||||
|
||||
$r = q("SELECT * FROM item WHERE mid = '%s' AND uid = %d and revision = %d ORDER BY id ASC ",
|
||||
$arr['mid'], // already dbesc'd
|
||||
dbesc($arr['mid']),
|
||||
intval($arr['uid']),
|
||||
intval($arr['revision'])
|
||||
);
|
||||
@@ -2028,7 +2033,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
|
||||
if(count($r) > 1) {
|
||||
logger('item_store: duplicated post occurred. Removing duplicates.');
|
||||
q("DELETE FROM item WHERE mid = '%s' AND uid = %d AND id != %d ",
|
||||
$arr['mid'],
|
||||
dbesc($arr['mid']),
|
||||
intval($arr['uid']),
|
||||
intval($current_post)
|
||||
);
|
||||
@@ -3663,7 +3668,7 @@ function retain_item($id) {
|
||||
);
|
||||
}
|
||||
|
||||
function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force = false) {
|
||||
function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL) {
|
||||
$uid = 0;
|
||||
|
||||
if(! local_channel() && ! remote_channel())
|
||||
@@ -3671,7 +3676,7 @@ function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force
|
||||
|
||||
if(count($items)) {
|
||||
foreach($items as $item) {
|
||||
$owner = drop_item($item,$interactive,$stage,$force);
|
||||
$owner = drop_item($item,$interactive,$stage);
|
||||
if($owner && ! $uid)
|
||||
$uid = $owner;
|
||||
}
|
||||
@@ -3694,12 +3699,7 @@ function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force
|
||||
// $stage = 1 => set deleted flag on the item and perform intial notifications
|
||||
// $stage = 2 => perform low level delete at a later stage
|
||||
|
||||
function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = false) {
|
||||
|
||||
// These resource types have linked items that should only be removed at the same time
|
||||
// as the linked resource; if we encounter one set it to item_hidden rather than item_deleted.
|
||||
|
||||
$linked_resource_types = [ 'photo' ];
|
||||
function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) {
|
||||
|
||||
// locate item to be deleted
|
||||
|
||||
@@ -3711,26 +3711,23 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
|
||||
if(! $interactive)
|
||||
return 0;
|
||||
notice( t('Item not found.') . EOL);
|
||||
goaway(z_root() . '/' . $_SESSION['return_url']);
|
||||
//goaway(z_root() . '/' . $_SESSION['return_url']);
|
||||
}
|
||||
|
||||
$item = $r[0];
|
||||
|
||||
$linked_item = (($item['resource_id'] && $item['resource_type'] && in_array($item['resource_type'], $linked_resource_types)) ? true : false);
|
||||
|
||||
$ok_to_delete = false;
|
||||
|
||||
// system deletion
|
||||
if(! $interactive)
|
||||
$ok_to_delete = true;
|
||||
|
||||
// owner deletion
|
||||
if(local_channel() && local_channel() == $item['uid'])
|
||||
// admin deletion
|
||||
if(is_site_admin())
|
||||
$ok_to_delete = true;
|
||||
|
||||
// sys owned item, requires site admin to delete
|
||||
$sys = get_sys_channel();
|
||||
if(is_site_admin() && $sys['channel_id'] == $item['uid'])
|
||||
// owner deletion
|
||||
if(local_channel() && local_channel() == $item['uid'])
|
||||
$ok_to_delete = true;
|
||||
|
||||
// author deletion
|
||||
@@ -3743,16 +3740,9 @@ 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.
|
||||
|
||||
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'])
|
||||
);
|
||||
}
|
||||
$r = q("UPDATE item SET item_deleted = 1 WHERE id = %d",
|
||||
intval($item['id'])
|
||||
);
|
||||
|
||||
$arr = [
|
||||
'item' => $item,
|
||||
@@ -3792,14 +3782,13 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
|
||||
if((intval($item['item_wall']) && ($stage != DROPITEM_PHASE2)) || ($stage == DROPITEM_PHASE1)) {
|
||||
Master::Summon([ 'Notifier','drop',$notify_id ]);
|
||||
}
|
||||
|
||||
goaway(z_root() . '/' . $_SESSION['return_url']);
|
||||
//goaway(z_root() . '/' . $_SESSION['return_url']);
|
||||
}
|
||||
else {
|
||||
if(! $interactive)
|
||||
return 0;
|
||||
notice( t('Permission denied.') . EOL);
|
||||
goaway(z_root() . '/' . $_SESSION['return_url']);
|
||||
//goaway(z_root() . '/' . $_SESSION['return_url']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3814,11 +3803,9 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
|
||||
* @param boolean $force
|
||||
* @return boolean
|
||||
*/
|
||||
function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
|
||||
function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL) {
|
||||
|
||||
$linked_item = (($item['resource_id']) ? true : false);
|
||||
|
||||
logger('item: ' . $item['id'] . ' stage: ' . $stage . ' force: ' . $force, LOGGER_DATA);
|
||||
logger('item: ' . $item['id'] . ' stage: ' . $stage, LOGGER_DATA);
|
||||
|
||||
switch($stage) {
|
||||
case DROPITEM_PHASE2:
|
||||
@@ -3831,42 +3818,50 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
|
||||
break;
|
||||
|
||||
case DROPITEM_PHASE1:
|
||||
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 id = %d",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
intval($item['id'])
|
||||
);
|
||||
}
|
||||
|
||||
$r = q("UPDATE item set item_deleted = 1, changed = '%s', edited = '%s' where id = %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_hidden = 1,
|
||||
changed = '%s', edited = '%s' WHERE id = %d",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
intval($item['id'])
|
||||
);
|
||||
}
|
||||
else {
|
||||
$r = q("DELETE FROM item WHERE id = %d",
|
||||
intval($item['id'])
|
||||
);
|
||||
}
|
||||
$r = q("DELETE FROM item WHERE id = %d",
|
||||
intval($item['id'])
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
// immediately remove local linked resources
|
||||
|
||||
if($item['resource_type'] === 'event') {
|
||||
$r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
|
||||
dbesc($item['resource_id']),
|
||||
intval($item['uid'])
|
||||
);
|
||||
|
||||
$sync_data = $r[0];
|
||||
|
||||
$x = q("delete from event where event_hash = '%s' and uid = %d",
|
||||
dbesc($item['resource_id']),
|
||||
intval($item['uid'])
|
||||
);
|
||||
|
||||
if($x) {
|
||||
$sync_data['event_deleted'] = 1;
|
||||
build_sync_packet($item['uid'], ['event' => [$sync_data]]);
|
||||
}
|
||||
}
|
||||
|
||||
if($item['resource_type'] === 'photo') {
|
||||
attach_delete($item['uid'], $item['resource_id'], true );
|
||||
$channel = channelx_by_n($item['uid']);
|
||||
$sync_data = attach_export_data($channel, $item['resource_id'], true);
|
||||
if($sync_data)
|
||||
build_sync_packet($item['uid'], ['file' => [$sync_data]]);
|
||||
}
|
||||
|
||||
// immediately remove any undesired profile likes.
|
||||
|
||||
q("delete from likes where iid = %d and channel_id = %d",
|
||||
@@ -4620,12 +4615,12 @@ function set_linkified_perms($linkified, &$str_contact_allow, &$str_group_allow,
|
||||
if(strpos($access_tag,'cid:') === 0) {
|
||||
$str_contact_allow .= '<' . substr($access_tag,4) . '>';
|
||||
$access_tag = '';
|
||||
$private = 1;
|
||||
$private = 2;
|
||||
}
|
||||
elseif(strpos($access_tag,'gid:') === 0) {
|
||||
$str_group_allow .= '<' . substr($access_tag,4) . '>';
|
||||
$access_tag = '';
|
||||
$private = 1;
|
||||
$private = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ function mail_prepare_binary($item) {
|
||||
// send a private message
|
||||
|
||||
|
||||
function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $replyto = '', $expires = NULL_DATE, $mimetype = 'text/bbcode', $raw = false) {
|
||||
function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $replyto = '', $expires = NULL_DATE, $mimetype = 'text/bbcode', $raw = false, $sig = '') {
|
||||
|
||||
$ret = array('success' => false);
|
||||
$is_reply = false;
|
||||
@@ -175,8 +175,7 @@ function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $rep
|
||||
$subject = str_rot47(base64url_encode($subject));
|
||||
if(($body )&& (! $raw))
|
||||
$body = str_rot47(base64url_encode($body));
|
||||
|
||||
$sig = ''; // placeholder
|
||||
|
||||
$mimetype = ''; //placeholder
|
||||
|
||||
$r = q("INSERT INTO mail ( account_id, conv_guid, mail_obscured, channel_id, from_xchan, to_xchan, mail_mimetype, title, body, sig, attach, mid, parent_mid, created, expires, mail_isreply, mail_raw )
|
||||
|
||||
@@ -1183,12 +1183,12 @@ function discover_by_webbie($webbie, $protocol = '') {
|
||||
*/
|
||||
function webfinger_rfc7033($webbie, $zot = false) {
|
||||
|
||||
if(strpos($webbie,'@')) {
|
||||
if(filter_var($webbie, FILTER_VALIDATE_EMAIL)) {
|
||||
$lhs = substr($webbie,0,strpos($webbie,'@'));
|
||||
$rhs = substr($webbie,strpos($webbie,'@')+1);
|
||||
$resource = urlencode('acct:' . $webbie);
|
||||
}
|
||||
else {
|
||||
elseif(filter_var($webbie, FILTER_VALIDATE_URL)) {
|
||||
$m = parse_url($webbie);
|
||||
if($m) {
|
||||
if($m['scheme'] !== 'https')
|
||||
@@ -1197,9 +1197,10 @@ function webfinger_rfc7033($webbie, $zot = false) {
|
||||
$rhs = $m['host'] . (($m['port']) ? ':' . $m['port'] : '');
|
||||
$resource = urlencode($webbie);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
logger('fetching url from resource: ' . $rhs . ':' . $webbie);
|
||||
|
||||
$counter = 0;
|
||||
@@ -1217,7 +1218,7 @@ function webfinger_rfc7033($webbie, $zot = false) {
|
||||
function old_webfinger($webbie) {
|
||||
|
||||
$host = '';
|
||||
if(strstr($webbie,'@'))
|
||||
if(filter_var($webbie, FILTER_VALIDATE_EMAIL))
|
||||
$host = substr($webbie,strpos($webbie,'@') + 1);
|
||||
|
||||
if(strlen($host)) {
|
||||
|
||||
@@ -261,7 +261,7 @@ function photo_upload($channel, $observer, $args) {
|
||||
$r0 = $ph->save($p);
|
||||
$link[0] = array(
|
||||
'rel' => 'alternate',
|
||||
'type' => 'text/html',
|
||||
'type' => $type,
|
||||
'href' => z_root() . '/photo/' . $photo_hash . '-0.' . $ph->getExt(),
|
||||
'width' => $width,
|
||||
'height' => $height
|
||||
@@ -280,7 +280,7 @@ function photo_upload($channel, $observer, $args) {
|
||||
$r1 = $ph->storeThumbnail($p, PHOTO_RES_1024);
|
||||
$link[1] = array(
|
||||
'rel' => 'alternate',
|
||||
'type' => 'text/html',
|
||||
'type' => $type,
|
||||
'href' => z_root() . '/photo/' . $photo_hash . '-1.' . $ph->getExt(),
|
||||
'width' => $ph->getWidth(),
|
||||
'height' => $ph->getHeight()
|
||||
@@ -294,7 +294,7 @@ function photo_upload($channel, $observer, $args) {
|
||||
$r2 = $ph->storeThumbnail($p, PHOTO_RES_640);
|
||||
$link[2] = array(
|
||||
'rel' => 'alternate',
|
||||
'type' => 'text/html',
|
||||
'type' => $type,
|
||||
'href' => z_root() . '/photo/' . $photo_hash . '-2.' . $ph->getExt(),
|
||||
'width' => $ph->getWidth(),
|
||||
'height' => $ph->getHeight()
|
||||
@@ -308,7 +308,7 @@ function photo_upload($channel, $observer, $args) {
|
||||
$r3 = $ph->storeThumbnail($p, PHOTO_RES_320);
|
||||
$link[3] = array(
|
||||
'rel' => 'alternate',
|
||||
'type' => 'text/html',
|
||||
'type' => $type,
|
||||
'href' => z_root() . '/photo/' . $photo_hash . '-3.' . $ph->getExt(),
|
||||
'width' => $ph->getWidth(),
|
||||
'height' => $ph->getHeight()
|
||||
@@ -390,7 +390,7 @@ function photo_upload($channel, $observer, $args) {
|
||||
'edited' => $p['edited'],
|
||||
'id' => z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash,
|
||||
'link' => $link,
|
||||
'body' => $obj_body
|
||||
'body' => $summary
|
||||
);
|
||||
|
||||
$target = array(
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<?php /** @file */
|
||||
|
||||
|
||||
use Zotlabs\Lib\Libzot;
|
||||
use Zotlabs\Lib\Libzotdir;
|
||||
use Zotlabs\Lib\Zotfinger;
|
||||
|
||||
require_once('include/dir_fns.php');
|
||||
require_once('include/zot.php');
|
||||
|
||||
@@ -122,7 +127,7 @@ function poco_load($xchan = '', $url = null) {
|
||||
$profile_url = $url['value'];
|
||||
continue;
|
||||
}
|
||||
if($url['type'] == 'zot') {
|
||||
if(in_array($url['type'], ['zot','zot6'] )) {
|
||||
$network = $url['type'];
|
||||
$address = str_replace('acct:' , '', $url['value']);
|
||||
continue;
|
||||
@@ -151,6 +156,18 @@ function poco_load($xchan = '', $url = null) {
|
||||
|
||||
if(($x !== false) && (! count($x))) {
|
||||
if($address) {
|
||||
if($network === 'zot6') {
|
||||
$j = Zotfinger::exec($profile_url);
|
||||
if(is_array($j) && array_path_exists('signature/signer',$j) && $j['signature']['signer'] === $profile_url && intval($j['signature']['header_valid'])) {
|
||||
Libzot::import_xchan($j['data']);
|
||||
}
|
||||
$x = q("select xchan_hash from xchan where xchan_hash = '%s' limit 1",
|
||||
dbesc($hash)
|
||||
);
|
||||
if(! $x) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if($network === 'zot') {
|
||||
$j = Zotlabs\Zot\Finger::run($address,null);
|
||||
if($j['success']) {
|
||||
@@ -402,7 +419,7 @@ function poco($a,$extended = false) {
|
||||
$sql_extra ",
|
||||
intval($channel_id)
|
||||
);
|
||||
$rooms = q("select * from menu_item where ( mitem_flags & " . intval(MENU_ITEM_CHATROOM) . " )>0 and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = '' and mitem_channel_id = %d",
|
||||
$rooms = q("select * from menu_item where ( mitem_flags & " . intval(MENU_ITEM_CHATROOM) . " ) > 0 and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = '' and mitem_channel_id = %d",
|
||||
intval($channel_id)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1580,7 +1580,9 @@ function format_hashtags(&$item) {
|
||||
$term = htmlspecialchars($t['term'], ENT_COMPAT, 'UTF-8', false) ;
|
||||
if(! trim($term))
|
||||
continue;
|
||||
if($t['url'] && strpos($item['body'], $t['url']))
|
||||
if(empty($t['url']))
|
||||
continue;
|
||||
if(strpos($item['body'], $t['url']) || stripos($item['body'], '#' . $t['term']))
|
||||
continue;
|
||||
if($s)
|
||||
$s .= ' ';
|
||||
@@ -2464,8 +2466,8 @@ function magic_link($s) {
|
||||
* @param boolean $escape (optional) default false
|
||||
*/
|
||||
function stringify_array_elms(&$arr, $escape = false) {
|
||||
for($x = 0; $x < count($arr); $x ++)
|
||||
$arr[$x] = "'" . (($escape) ? dbesc($arr[$x]) : $arr[$x]) . "'";
|
||||
foreach($arr as $k => $v)
|
||||
$arr[$k] = "'" . (($escape) ? dbesc($v) : $v) . "'";
|
||||
}
|
||||
|
||||
|
||||
@@ -3113,6 +3115,15 @@ function item_url_replace($channel,&$item,$old,$new,$oldnick = '') {
|
||||
if($oldnick)
|
||||
$item['llink'] = str_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['llink']);
|
||||
|
||||
if($item['term']) {
|
||||
for($x = 0; $x < count($item['term']); $x ++) {
|
||||
$item['term'][$x]['url'] = str_replace($old,$new,$item['term'][$x]['url']);
|
||||
if ($oldnick) {
|
||||
$item['term'][$x]['url'] = str_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['term'][$x]['url']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Zotlabs\Zot6\HTTPSig;
|
||||
use Zotlabs\Web\HTTPSig;
|
||||
use Zotlabs\Lib\Libzot;
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ function is_matrix_url($url) {
|
||||
if(array_key_exists($m['host'],$remembered))
|
||||
return $remembered[$m['host']];
|
||||
|
||||
$r = q("select hubloc_url from hubloc where hubloc_host = '%s' and hubloc_network = 'zot' limit 1",
|
||||
$r = q("select hubloc_url from hubloc where hubloc_host = '%s' and hubloc_network in ('zot', 'zot6') limit 1",
|
||||
dbesc($m['host'])
|
||||
);
|
||||
if($r) {
|
||||
@@ -205,20 +205,25 @@ function zidify_text($s) {
|
||||
*/
|
||||
function red_zrl_callback($matches) {
|
||||
|
||||
$zrl = is_matrix_url($matches[2]);
|
||||
|
||||
$t = strip_zids($matches[2]);
|
||||
if($t !== $matches[2]) {
|
||||
$zrl = true;
|
||||
$matches[2] = $t;
|
||||
}
|
||||
|
||||
if($matches[1] === '#^')
|
||||
$matches[1] = '';
|
||||
if($zrl)
|
||||
return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]';
|
||||
|
||||
return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]';
|
||||
// Catch and exclude trailing punctuation
|
||||
preg_match("/[.,;:!?)]*$/i", $matches[2], $pts);
|
||||
$matches[2] = substr($matches[2], 0, strlen($matches[2])-strlen($pts[0]));
|
||||
|
||||
$zrl = is_matrix_url($matches[2]);
|
||||
|
||||
$t = strip_zids($matches[2]);
|
||||
if($t !== $matches[2]) {
|
||||
$zrl = true;
|
||||
$matches[2] = $t;
|
||||
}
|
||||
|
||||
if($matches[1] === '#^')
|
||||
$matches[1] = '';
|
||||
|
||||
if($zrl)
|
||||
return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]' . $pts[0];
|
||||
|
||||
return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]' . $pts[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -303,9 +303,8 @@ function zot_zot($url, $data, $channel = null,$crypto = null) {
|
||||
|
||||
if($channel) {
|
||||
$headers['X-Zot-Token'] = random_string();
|
||||
$hash = \Zotlabs\Web\HTTPSig::generate_digest($data,false);
|
||||
$headers['X-Zot-Digest'] = 'SHA-256=' . $hash;
|
||||
$h = \Zotlabs\Web\HTTPSig::create_sig('',$headers,$channel['channel_prvkey'],'acct:' . $channel['channel_address'] . '@' . \App::get_hostname(),false,false,'sha512',(($crypto) ? $crypto['hubloc_sitekey'] : ''), (($crypto) ? zot_best_algorithm($crypto['site_crypto']) : ''));
|
||||
$headers['X-Zot-Digest'] = \Zotlabs\Web\HTTPSig::generate_digest_header($data);
|
||||
$h = \Zotlabs\Web\HTTPSig::create_sig($headers,$channel['channel_prvkey'],'acct:' . channel_reddress($channel),false,'sha512',(($crypto) ? [ 'key' => $crypto['hubloc_sitekey'], 'algorithm' => $crypto['site_crypto'] ] : false));
|
||||
}
|
||||
|
||||
$redirects = 0;
|
||||
@@ -2241,7 +2240,7 @@ function delete_imported_item($sender, $item, $uid, $relay) {
|
||||
$item_found = false;
|
||||
$post_id = 0;
|
||||
|
||||
$r = q("select id, author_xchan, owner_xchan, source_xchan, item_deleted from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' )
|
||||
$r = q("select * 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']),
|
||||
@@ -2251,10 +2250,13 @@ function delete_imported_item($sender, $item, $uid, $relay) {
|
||||
);
|
||||
|
||||
if($r) {
|
||||
if($r[0]['author_xchan'] === $sender['hash'] || $r[0]['owner_xchan'] === $sender['hash'] || $r[0]['source_xchan'] === $sender['hash'])
|
||||
|
||||
$stored = $r[0];
|
||||
|
||||
if($stored['author_xchan'] === $sender['hash'] || $stored['owner_xchan'] === $sender['hash'] || $stored['source_xchan'] === $sender['hash'])
|
||||
$ownership_valid = true;
|
||||
|
||||
$post_id = $r[0]['id'];
|
||||
$post_id = $stored['id'];
|
||||
$item_found = true;
|
||||
}
|
||||
else {
|
||||
@@ -2278,10 +2280,29 @@ function delete_imported_item($sender, $item, $uid, $relay) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($stored['resource_type'] === 'event') {
|
||||
$i = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
|
||||
dbesc($stored['resource_id']),
|
||||
intval($uid)
|
||||
);
|
||||
if ($i) {
|
||||
if ($i[0]['event_xchan'] === $sender['hash']) {
|
||||
q("delete from event where event_hash = '%s' and uid = %d",
|
||||
dbesc($stored['resource_id']),
|
||||
intval($uid)
|
||||
);
|
||||
}
|
||||
else {
|
||||
logger('delete linked event: not owner');
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
require_once('include/items.php');
|
||||
|
||||
if($item_found) {
|
||||
if(intval($r[0]['item_deleted'])) {
|
||||
if(intval($stored['item_deleted'])) {
|
||||
logger('delete_imported_item: item was already deleted');
|
||||
if(! $relay)
|
||||
return false;
|
||||
@@ -2293,10 +2314,10 @@ 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']) && intval($r[0]['item_origin'])) {
|
||||
if (($stored['id'] != $stored['parent']) && intval($stored['item_origin'])) {
|
||||
q("update item set item_origin = 0 where id = %d and uid = %d",
|
||||
intval($r[0]['id']),
|
||||
intval($r[0]['uid'])
|
||||
intval($stored['id']),
|
||||
intval($stored['uid'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user