diff options
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r-- | Zotlabs/Module/Channel.php | 50 | ||||
-rw-r--r-- | Zotlabs/Module/Display.php | 20 | ||||
-rw-r--r-- | Zotlabs/Module/Dreport.php | 5 | ||||
-rw-r--r-- | Zotlabs/Module/Hq.php | 15 | ||||
-rw-r--r-- | Zotlabs/Module/Item.php | 12 | ||||
-rw-r--r-- | Zotlabs/Module/Like.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Pin.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Pubstream.php | 19 | ||||
-rw-r--r-- | Zotlabs/Module/Search.php | 4 | ||||
-rw-r--r-- | Zotlabs/Module/Sse_bs.php | 4 | ||||
-rw-r--r-- | Zotlabs/Module/Subthread.php | 5 | ||||
-rw-r--r-- | Zotlabs/Module/Tagger.php | 2 |
12 files changed, 71 insertions, 69 deletions
diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index e8c3316e9..4e6811a10 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -101,16 +101,23 @@ class Channel extends Controller { App::$meta->set('robots', 'noindex, noarchive'); } + $identifier = 'uuid'; + $mid = $_REQUEST['mid'] ?? ''; + + if (str_starts_with($mid, 'b64.')) { + $mid = unpack_link_id($mid); + $identifier = 'mid'; + } + + if ($mid === false) { + http_status_exit(404, 'Not found'); + } + if (ActivityStreams::is_as_request($channel)) { // Somebody may attempt an ActivityStreams fetch on one of our message permalinks // Make it do the right thing. - $mid = ((x($_REQUEST, 'mid')) ? unpack_link_id($_REQUEST['mid']) : ''); - if ($mid === false) { - http_status_exit(404, 'Not found'); - } - if ($mid) { $obj = null; if (strpos($mid, z_root() . '/item/') === 0) { @@ -127,6 +134,7 @@ class Channel extends Controller { $obj->init(); } } + as_return_and_die(Activity::encode_person($channel, true), $channel); } @@ -155,15 +163,9 @@ class Channel extends Controller { profile_load($which, $profile); // Add Opengraph markup - $mid = ((x($_REQUEST, 'mid')) ? unpack_link_id($_REQUEST['mid']) : ''); - - if ($mid === false) { - notice(t('Malformed message id.') . EOL); - return; - } if ($mid) { - $r = q("SELECT * FROM item WHERE mid = '%s' AND uid = %d AND item_private = 0 LIMIT 1", + $r = q("SELECT * FROM item WHERE $identifier = '%s' AND uid = %d AND item_private = 0 LIMIT 1", dbesc($mid), intval($channel['channel_id']) ); @@ -178,7 +180,16 @@ class Channel extends Controller { $category = $datequery = $datequery2 = ''; - $mid = ((x($_REQUEST, 'mid')) ? unpack_link_id($_REQUEST['mid']) : ''); + $mid = $_REQUEST['mid'] ?? ''; + $identifier = 'uuid'; + $encoded_mid = null; + + if (str_starts_with($mid, 'b64.')) { + $encoded_mid = $mid; + $mid = unpack_link_id($mid); + $identifier = 'mid'; + } + if ($mid === false) { notice(t('Malformed message id.') . EOL); return; @@ -322,7 +333,7 @@ class Channel extends Controller { if (($update) && (!$load)) { if ($mid) { - $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d $item_normal_update + $r = q("SELECT parent AS item_id, uuid from item where $identifier = '%s' and uid = %d $item_normal_update AND item_wall = 1 $simple_update $sql_extra limit 1", dbesc($mid), intval(App::$profile['profile_uid']) @@ -370,7 +381,7 @@ class Channel extends Controller { if ($noscript_content || $load) { if ($mid) { - $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d $item_normal + $r = q("SELECT parent AS item_id, uuid from item where $identifier = '%s' and uid = %d $item_normal AND item_wall = 1 $sql_extra limit 1", dbesc($mid), intval(App::$profile['profile_uid']) @@ -396,7 +407,6 @@ class Channel extends Controller { } } if ($r) { - $parents_str = ids_to_querystr($r, 'item_id'); $r = q("SELECT item.*, item.id AS item_id @@ -427,12 +437,8 @@ class Channel extends Controller { $mode = (($search) ? 'search' : 'channel'); - if ((!$update) && (!$load)) { - - - //if we got a decoded hash we must encode it again before handing to javascript - $mid = gen_link_id($mid); + if ((!$update) && (!$load)) { // This is ugly, but we can't pass the profile_uid through the session to the ajax updater, // because browser prefetching might change it on us. We have to deliver it with the page. @@ -470,7 +476,7 @@ class Channel extends Controller { '$file' => '', '$cats' => (($category) ? urlencode($category) : ''), '$tags' => (($hashtags) ? urlencode($hashtags) : ''), - '$mid' => (($mid) ? urlencode($mid) : ''), + '$mid' => $encoded_mid ?? $mid, '$verb' => '', '$net' => '', '$dend' => $datequery, diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 9e46d7620..a1e8d0d1d 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -38,7 +38,14 @@ class Display extends Controller { $item_hash = $_REQUEST['mid']; } - $item_hash = unpack_link_id($item_hash); + $identifier = 'uuid'; + $encoded_item_hash = null; + + if (str_starts_with($item_hash, 'b64.')) { + $encoded_item_hash = $item_hash; + $item_hash = unpack_link_id($item_hash); + $identifier = 'mid'; + } if ($item_hash === false) { App::$error = 400; @@ -104,7 +111,7 @@ class Display extends Controller { $target_item = null; - $r = q("select id, uid, mid, parent, parent_mid, thr_parent, verb, item_type, item_deleted, author_xchan, item_blocked from item where mid = '%s' limit 1", + $r = q("select id, uid, mid, parent, parent_mid, thr_parent, verb, item_type, item_deleted, author_xchan, item_blocked from item where $identifier = '%s' limit 1", dbesc($item_hash) ); @@ -157,13 +164,6 @@ class Display extends Controller { if((! $update) && (! $load)) { - // if the target item is not a post (eg a like) we want to address its thread parent - - //$mid = ((($target_item['verb'] == ACTIVITY_LIKE) || ($target_item['verb'] == ACTIVITY_DISLIKE)) ? $target_item['thr_parent'] : $target_item['mid']); - - // if we got a decoded hash we must encode it again before handing to javascript - $mid = gen_link_id($target_item['mid']); - $o .= '<div id="live-display"></div>' . "\r\n"; $o .= "<script> var profile_uid = " . ((intval(local_channel())) ? local_channel() : (-1)) . "; var netargs = '?f='; var profile_page = " . App::$pager['page'] . "; </script>\r\n"; @@ -196,7 +196,7 @@ class Display extends Controller { '$dbegin' => '', '$verb' => '', '$net' => '', - '$mid' => (($mid) ? urlencode($mid) : '') + '$mid' => $encoded_item_hash ?? $item_hash )); head_add_link([ diff --git a/Zotlabs/Module/Dreport.php b/Zotlabs/Module/Dreport.php index f5ad80eef..4a0ba4bbe 100644 --- a/Zotlabs/Module/Dreport.php +++ b/Zotlabs/Module/Dreport.php @@ -13,11 +13,10 @@ class Dreport extends \Zotlabs\Web\Controller { $table = 'item'; $channel = \App::get_channel(); - $mid = ((argc() > 1) ? unpack_link_id(argv(1)) : ''); + $mid = $_REQUEST['mid'] ?? ''; - if($mid === 'push') { + if(argv(1) === 'push') { $table = 'push'; - $mid = ((argc() > 2) ? unpack_link_id(argv(2)) : ''); if($mid) { $i = q("select id from item where mid = '%s' and uid = %d and ( author_xchan = '%s' or ( owner_xchan = '%s' and item_wall = 1 )) ", diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index 5c3ae9273..36ab8e410 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -30,16 +30,11 @@ class Hq extends \Zotlabs\Web\Controller { $item_hash = ''; if(argc() > 1 && argv(1) !== 'load') { - $item_hash = unpack_link_id(argv(1)); + $item_hash = argv(1); } if(isset($_REQUEST['mid'])) { - $item_hash = unpack_link_id($_REQUEST['mid']); - } - - if($item_hash === false) { - notice(t('Malformed message id.') . EOL); - return; + $item_hash = $_REQUEST['mid']; } $item_normal = item_normal(); @@ -54,7 +49,7 @@ class Hq extends \Zotlabs\Web\Controller { // select the target item with a bias to our own item $sql_order = ((local_channel() > $sys['channel_id']) ? 'DESC' : 'ASC'); - $r = q("select id, uid, mid, parent_mid, thr_parent, verb, item_type, item_deleted, item_blocked from item where uid in (%d, %d) and mid = '%s' order by uid $sql_order limit 2", + $r = q("select id, uid, mid, parent_mid, thr_parent, verb, item_type, item_deleted, item_blocked from item where uid in (%d, %d) and uuid = '%s' order by uid $sql_order limit 2", intval(local_channel()), intval($sys['channel_id']), dbesc($item_hash) @@ -118,7 +113,7 @@ class Hq extends \Zotlabs\Web\Controller { //$mid = ((($target_item['verb'] == ACTIVITY_LIKE) || ($target_item['verb'] == ACTIVITY_DISLIKE)) ? $target_item['thr_parent'] : $target_item['mid']); // if we got a decoded hash we must encode it again before handing to javascript - $mid = gen_link_id($target_item['mid']); + // $mid = gen_link_id($target_item['mid']); } else { $mid = ''; @@ -156,7 +151,7 @@ class Hq extends \Zotlabs\Web\Controller { '$dbegin' => '', '$verb' => '', '$net' => '', - '$mid' => (($mid) ? urlencode($mid) : '') + '$mid' => $item_hash ]); } diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 25ccb0cbf..09e4904c1 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -275,7 +275,7 @@ class Item extends Controller { if (argc() > 1 && argv(1) !== 'drop') { - $x = q("select uid, item_wall, llink, mid from item where mid = '%s' or mid = '%s' or uuid = '%s'", + $x = q("select uid, item_wall, llink, mid, uuid from item where mid = '%s' or mid = '%s' or uuid = '%s'", dbesc(z_root() . '/item/' . argv(1)), dbesc(z_root() . '/activity/' . argv(1)), dbesc(argv(1)) @@ -285,7 +285,7 @@ class Item extends Controller { if (intval($xv['item_wall'])) { $c = channelx_by_n($xv['uid']); if ($c) { - goaway(z_root() . '/channel/' . $c['channel_address'] . '?mid=' . gen_link_id($xv['mid'])); + goaway(z_root() . '/channel/' . $c['channel_address'] . '?mid=' . $xv['uuid']); } } } @@ -1285,7 +1285,7 @@ class Item extends Controller { 'from_xchan' => $datarray['author_xchan'], 'to_xchan' => $datarray['owner_xchan'], 'item' => $datarray, - 'link' => z_root() . '/display/' . gen_link_id($datarray['mid']), + 'link' => z_root() . '/display/' . $datarray['uuid'], 'verb' => ACTIVITY_POST, 'otype' => 'item', 'parent' => $parent, @@ -1303,7 +1303,7 @@ class Item extends Controller { 'from_xchan' => $datarray['author_xchan'], 'to_xchan' => $datarray['owner_xchan'], 'item' => $datarray, - 'link' => z_root() . '/display/' . gen_link_id($datarray['mid']), + 'link' => z_root() . '/display/' . $datarray['uuid'], 'verb' => ACTIVITY_POST, 'otype' => 'item' ]); @@ -1349,7 +1349,7 @@ class Item extends Controller { } $datarray['id'] = $post_id; - $datarray['llink'] = z_root() . '/display/' . gen_link_id($datarray['mid']); + $datarray['llink'] = z_root() . '/display/' . $datarray['uuid']; call_hooks('post_local_end', $datarray); @@ -1373,7 +1373,7 @@ class Item extends Controller { if ($return_path) { if ($return_path === 'hq') { - goaway(z_root() . '/hq/' . gen_link_id($datarray['mid'])); + goaway(z_root() . '/hq/' . $datarray['uuid']); } goaway(z_root() . "/" . $return_path); diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index 4dd43b682..68234eb93 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -513,7 +513,7 @@ class Like extends Controller { $arr['thr_parent'] = $item['mid']; $ulink = '[zrl=' . $item_author['xchan_url'] . '][bdi]' . $item_author['xchan_name'] . '[/bdi][/zrl]'; $alink = '[zrl=' . $observer['xchan_url'] . '][bdi]' . $observer['xchan_name'] . '[/bdi][/zrl]'; - $plink = '[zrl=' . z_root() . '/display/' . gen_link_id($item['mid']) . ']' . $post_type . '[/zrl]'; + $plink = '[zrl=' . z_root() . '/display/' . $item['uuid'] . ']' . $post_type . '[/zrl]'; $allow_cid = $item['allow_cid']; $allow_gid = $item['allow_gid']; $deny_cid = $item['deny_cid']; diff --git a/Zotlabs/Module/Pin.php b/Zotlabs/Module/Pin.php index f82327ce6..de3c75622 100644 --- a/Zotlabs/Module/Pin.php +++ b/Zotlabs/Module/Pin.php @@ -37,7 +37,7 @@ class Pin extends \Zotlabs\Web\Controller { http_status_exit(404, 'Not found'); } - $midb64 = gen_link_id($r[0]['mid']); + $midb64 = $r[0]['uuid']; $pinned = (in_array($midb64, get_pconfig($r[0]['uid'], 'pinned', $r[0]['item_type'], [])) ? true : false); switch(argv(1)) { diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 08de168cb..c40751fdc 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -40,7 +40,15 @@ class Pubstream extends \Zotlabs\Web\Controller { $site_firehose = ((intval(get_config('system','site_firehose',0))) ? true : false); - $mid = ((isset($_REQUEST['mid'])) ? unpack_link_id($_REQUEST['mid']) : ''); + $mid = $_REQUEST['mid'] ?? ''; + $identifier = 'uuid'; + $encoded_mid = null; + + if (str_starts_with($mid, 'b64.')) { + $encoded_mid = $mid; + $mid = unpack_link_id($mid); + $identifier = 'mid'; + } if ($mid === false) { notice(t('Malformed message id.') . EOL); @@ -108,9 +116,6 @@ class Pubstream extends \Zotlabs\Web\Controller { . "; var profile_page = " . \App::$pager['page'] . "; divmore_height = " . intval($maxheight) . "; </script>\r\n"; - //if we got a decoded hash we must encode it again before handing to javascript - $mid = gen_link_id($mid); - \App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array( '$baseurl' => z_root(), '$pgtype' => 'pubstream', @@ -136,7 +141,7 @@ class Pubstream extends \Zotlabs\Web\Controller { '$cats' => '', '$tags' => (($hashtags) ? urlencode($hashtags) : ''), '$dend' => '', - '$mid' => (($mid) ? urlencode($mid) : ''), + '$mid' => $encoded_mid ?? $mid, '$verb' => '', '$net' => (($net) ? urlencode($net) : ''), '$dbegin' => '' @@ -198,7 +203,7 @@ class Pubstream extends \Zotlabs\Web\Controller { $r = q("SELECT parent AS item_id FROM item left join abook on item.author_xchan = abook.abook_xchan $net_query - WHERE item.mid = '%s' and item.item_private = 0 + WHERE item.$identifier = '%s' and item.item_private = 0 $uids $site_firehose_sql $item_normal and (abook.abook_blocked = 0 or abook.abook_flags is null) @@ -225,7 +230,7 @@ class Pubstream extends \Zotlabs\Web\Controller { $r = q("SELECT parent AS item_id FROM item left join abook on item.author_xchan = abook.abook_xchan $net_query - WHERE item.mid = '%s' and item.item_private = 0 + WHERE item.$identifier = '%s' and item.item_private = 0 $uids $site_firehose_sql $item_normal_update $simple_update and (abook.abook_blocked = 0 or abook.abook_flags is null) $sql_extra $net_query2", diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 6b1060570..335dcc6e7 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -75,13 +75,13 @@ class Search extends Controller { if ($f) { $mid = $f[0]['message_id']; foreach ($f as $m) { - if (str_starts_with($url, $m['message_id'])) { + if (basename($url) === $m['message_id']) { $mid = $m['message_id']; break; } } - goaway(z_root() . '/hq/' . gen_link_id($mid)); + goaway(z_root() . '/hq/' . $mid); } else { // try other fetch providers (e.g. diaspora, pubcrawl) diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index f335a9ada..1f56d8033 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -153,7 +153,7 @@ class Sse_bs extends Controller { call_hooks('update_unseen',$x); if($x['update'] === 'unset' || intval($x['update'])) { - q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND mid in (%s) AND item_unseen = 1", + q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND uuid in (%s) AND item_unseen = 1", intval(self::$uid), $str // this is dbesc() in the above foreach loop ); @@ -454,7 +454,7 @@ class Sse_bs extends Controller { $sql_extra3 = ''; $sse_mids_all = unserialise($_SESSION['sse_mids_all']) ?? []; if ($sse_mids_all) { - $sql_extra3 = " AND mid NOT IN (" . protect_sprintf(implode(',', $sse_mids_all)) . ") "; + $sql_extra3 = " AND uuid NOT IN (" . protect_sprintf(implode(',', $sse_mids_all)) . ") "; } $uids = " AND uid IN ( " . $sys['channel_id'] . " ) "; diff --git a/Zotlabs/Module/Subthread.php b/Zotlabs/Module/Subthread.php index a796d85cb..e8181dde3 100644 --- a/Zotlabs/Module/Subthread.php +++ b/Zotlabs/Module/Subthread.php @@ -106,9 +106,6 @@ class Subthread extends \Zotlabs\Web\Controller { else killme(); - - - $uuid = item_message_id(); $mid = z_root() . '/item/' . $uuid; @@ -149,7 +146,7 @@ class Subthread extends \Zotlabs\Web\Controller { $ulink = '[zrl=' . $item_author['xchan_url'] . ']' . $item_author['xchan_name'] . '[/zrl]'; $alink = '[zrl=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/zrl]'; - $plink = '[zrl=' . z_root() . '/display/' . gen_link_id($item['mid']) . ']' . $post_type . '[/zrl]'; + $plink = '[zrl=' . z_root() . '/display/' . $item['uuid'] . ']' . $post_type . '[/zrl]'; $arr['body'] = sprintf( $bodyverb, $alink, $ulink, $plink ); diff --git a/Zotlabs/Module/Tagger.php b/Zotlabs/Module/Tagger.php index 4aaae5885..ebe28c444 100644 --- a/Zotlabs/Module/Tagger.php +++ b/Zotlabs/Module/Tagger.php @@ -86,7 +86,7 @@ class Tagger extends \Zotlabs\Web\Controller { $clean_term = trim($term,'"\' '); $links = array(array('rel' => 'alternate','type' => 'text/html', - 'href' => z_root() . '/display/' . gen_link_id($item['mid']))); + 'href' => z_root() . '/display/' . $item['uuid'])); $target = json_encode(array( 'type' => $targettype, |