diff options
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r-- | Zotlabs/Module/Channel.php | 44 | ||||
-rw-r--r-- | Zotlabs/Module/Connedit.php | 5 | ||||
-rw-r--r-- | Zotlabs/Module/Dreport.php | 20 | ||||
-rw-r--r-- | Zotlabs/Module/Impel.php | 8 | ||||
-rw-r--r-- | Zotlabs/Module/Item.php | 64 | ||||
-rw-r--r-- | Zotlabs/Module/Like.php | 6 | ||||
-rw-r--r-- | Zotlabs/Module/Mood.php | 4 | ||||
-rw-r--r-- | Zotlabs/Module/Nojs.php | 15 | ||||
-rw-r--r-- | Zotlabs/Module/React.php | 4 | ||||
-rw-r--r-- | Zotlabs/Module/Subthread.php | 6 | ||||
-rw-r--r-- | Zotlabs/Module/Wfinger.php | 6 |
11 files changed, 134 insertions, 48 deletions
diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index f1537ed15..12d87885f 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -6,6 +6,8 @@ namespace Zotlabs\Module; use App; use Zotlabs\Web\Controller; use Zotlabs\Lib\PermissionDescription; +use Zotlabs\Zot6\HTTPSig; +use Zotlabs\Lib\Libzot; require_once('include/items.php'); require_once('include/security.php'); @@ -44,6 +46,48 @@ class Channel extends Controller { $channel = App::get_channel(); if((local_channel()) && (argc() > 2) && (argv(2) === 'view')) { + $which = $channel['channel_address']; + $profile = argv(1); + } + + $channel = channelx_by_nick($which); + if(! $channel) { + http_status_exit(404, 'Not found'); + } + + // handle zot6 channel discovery + + if(Libzot::is_zot_request()) { + + $sigdata = HTTPSig::verify(file_get_contents('php://input')); + + if($sigdata && $sigdata['signer'] && $sigdata['header_valid']) { + $data = json_encode(Libzot::zotinfo([ 'address' => $channel['channel_address'], 'target_url' => $sigdata['signer'] ])); + $s = q("select site_crypto, hubloc_sitekey from site left join hubloc on hubloc_url = site_url where hubloc_id_url = '%s' and hubloc_network = 'zot6' limit 1", + dbesc($sigdata['signer']) + ); + + if($s) { + $data = json_encode(crypto_encapsulate($data,$s[0]['hubloc_sitekey'],Libzot::best_algorithm($s[0]['site_crypto']))); + } + } + else { + $data = json_encode(Libzot::zotinfo([ 'address' => $channel['channel_address'] ])); + } + + $headers = [ + 'Content-Type' => 'application/x-zot+json', + 'Digest' => HTTPSig::generate_digest_header($data), + '(request-target)' => strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI'] + ]; + $h = HTTPSig::create_sig($headers,$channel['channel_prvkey'],channel_url($channel)); + HTTPSig::set_headers($h); + echo $data; + killme(); + } + + + if((local_channel()) && (argc() > 2) && (argv(2) === 'view')) { $which = $channel['channel_address']; $profile = argv(1); } diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php index 3d7ee449a..a9f643306 100644 --- a/Zotlabs/Module/Connedit.php +++ b/Zotlabs/Module/Connedit.php @@ -8,6 +8,7 @@ namespace Zotlabs\Module; */ use Zotlabs\Lib\Apps; +use Zotlabs\Lib\Libzot; require_once('include/socgraph.php'); require_once('include/selectors.php'); @@ -475,6 +476,10 @@ class Connedit extends \Zotlabs\Web\Controller { if(! zot_refresh($orig_record[0],\App::get_channel())) notice( t('Refresh failed - channel is currently unavailable.') ); } + elseif($orig_record[0]['xchan_network'] === 'zot6') { + if(! Libzot::refresh($orig_record[0],\App::get_channel())) + notice( t('Refresh failed - channel is currently unavailable.') ); + } else { // if you are on a different network we'll force a refresh of the connection basic info diff --git a/Zotlabs/Module/Dreport.php b/Zotlabs/Module/Dreport.php index 76e07b147..16ae7941f 100644 --- a/Zotlabs/Module/Dreport.php +++ b/Zotlabs/Module/Dreport.php @@ -17,9 +17,17 @@ class Dreport extends \Zotlabs\Web\Controller { $mid = ((argc() > 1) ? argv(1) : ''); + if(strpos($mid,'b64.') === 0) + $mid = @base64url_decode(substr($mid,4)); + + if($mid === 'push') { $table = 'push'; $mid = ((argc() > 2) ? argv(2) : ''); + + if(strpos($mid,'b64.') === 0) + $mid = @base64url_decode(substr($mid,4)); + 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 )) ", dbesc($mid), @@ -38,6 +46,9 @@ class Dreport extends \Zotlabs\Web\Controller { if($mid === 'mail') { $table = 'mail'; $mid = ((argc() > 2) ? argv(2) : ''); + if(strpos($mid,'b64.') === 0) + $mid = @base64url_decode(substr($mid,4)); + } @@ -80,7 +91,6 @@ class Dreport extends \Zotlabs\Web\Controller { } for($x = 0; $x < count($r); $x++ ) { - $r[$x]['name'] = escape_tags(substr($r[$x]['dreport_recip'],strpos($r[$x]['dreport_recip'],' '))); // This has two purposes: 1. make the delivery report strings translateable, and // 2. assign an ordering to item delivery results so we can group them and provide @@ -138,14 +148,14 @@ class Dreport extends \Zotlabs\Web\Controller { $entries = array(); foreach($r as $rr) { $entries[] = [ - 'name' => $rr['name'], + 'name' => escape_tags($rr['dreport_name'] ?: $rr['dreport_recip']), 'result' => escape_tags($rr['dreport_result']), 'time' => escape_tags(datetime_convert('UTC',date_default_timezone_get(),$rr['dreport_time'])) ]; } $o = replace_macros(get_markup_template('dreport.tpl'), array( - '$title' => sprintf( t('Delivery report for %1$s'),substr($mid,0,32)) . '...', + '$title' => sprintf( t('Delivery report for %1$s'),basename($mid)) . '...', '$table' => $table, '$mid' => urlencode($mid), '$options' => t('Options'), @@ -162,9 +172,9 @@ class Dreport extends \Zotlabs\Web\Controller { private static function dreport_gravity_sort($a,$b) { if($a['gravity'] == $b['gravity']) { - if($a['name'] === $b['name']) + if($a['dreport_name'] === $b['dreport_name']) return strcmp($a['dreport_time'],$b['dreport_time']); - return strcmp($a['name'],$b['name']); + return strcmp($a['dreport_name'],$b['dreport_name']); } return (($a['gravity'] > $b['gravity']) ? 1 : (-1)); } diff --git a/Zotlabs/Module/Impel.php b/Zotlabs/Module/Impel.php index 0c372bd96..e05027d9f 100644 --- a/Zotlabs/Module/Impel.php +++ b/Zotlabs/Module/Impel.php @@ -133,9 +133,11 @@ class Impel extends \Zotlabs\Web\Controller { $arr['author_xchan'] = (($j['author_xchan']) ? $j['author_xchan'] : get_observer_hash()); $arr['mimetype'] = (($j['mimetype']) ? $j['mimetype'] : 'text/bbcode'); - if(! $j['mid']) - $j['mid'] = item_message_id(); - + if(! $j['mid']) { + $j['uuid'] = item_message_id(); + $j['mid'] = z_root() . '/item/' . $j['uuid']; + } + $arr['uuid'] = $j['uuid']; $arr['mid'] = $arr['parent_mid'] = $j['mid']; diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 2ee639874..1d64ef60c 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -2,6 +2,16 @@ namespace Zotlabs\Module; +use Zotlabs\Lib\IConfig; +use Zotlabs\Lib\Enotify; +use Zotlabs\Web\Controller; +use Zotlabs\Daemon\Master; + +require_once('include/crypto.php'); +require_once('include/items.php'); +require_once('include/security.php'); + + /** * * This is the POST destination for most all locally posted @@ -17,16 +27,8 @@ namespace Zotlabs\Module; * */ -require_once('include/crypto.php'); -require_once('include/items.php'); -require_once('include/attach.php'); -require_once('include/bbcode.php'); -require_once('include/security.php'); - -use \Zotlabs\Lib as Zlib; - -class Item extends \Zotlabs\Web\Controller { +class Item extends Controller { function post() { @@ -392,6 +394,7 @@ class Item extends \Zotlabs\Web\Controller { $verb = $orig_post['verb']; $app = $orig_post['app']; $title = escape_tags(trim($_REQUEST['title'])); + $summary = trim($_REQUEST['summary']); $body = trim($_REQUEST['body']); $item_flags = $orig_post['item_flags']; @@ -454,6 +457,7 @@ class Item extends \Zotlabs\Web\Controller { $coord = notags(trim($_REQUEST['coord'])); $verb = notags(trim($_REQUEST['verb'])); $title = escape_tags(trim($_REQUEST['title'])); + $summary = trim($_REQUEST['summary']); $body = trim($_REQUEST['body']); $body .= trim($_REQUEST['attachment']); $postopts = ''; @@ -505,12 +509,14 @@ class Item extends \Zotlabs\Web\Controller { && ($channel['channel_pageflags'] & PAGE_ALLOWCODE)) ? true : false); if($preview) { + $summary = z_input_filter($summary,$mimetype,$execflag); $body = z_input_filter($body,$mimetype,$execflag); } - $arr = [ 'profile_uid' => $profile_uid, 'content' => $body, 'mimetype' => $mimetype ]; + $arr = [ 'profile_uid' => $profile_uid, 'summary' => $summary, 'content' => $body, 'mimetype' => $mimetype ]; call_hooks('post_content',$arr); + $summary = $arr['summary']; $body = $arr['content']; $mimetype = $arr['mimetype']; @@ -531,9 +537,23 @@ class Item extends \Zotlabs\Web\Controller { // we may need virtual or template classes to implement the possible alternatives + if(strpos($body,'[/summary]') !== false) { + $match = ''; + $cnt = preg_match("/\[summary\](.*?)\[\/summary\]/ism",$body,$match); + if($cnt) { + $summary .= $match[1]; + } + $body_content = preg_replace("/^(.*?)\[summary\](.*?)\[\/summary\](.*?)$/ism", '',$body); + $body = trim($body_content); + } + + $summary = cleanup_bbcode($summary); + $body = cleanup_bbcode($body); // Look for tags and linkify them + + $results = linkify_tags($a, $summary, ($uid) ? $uid : $profile_uid); $results = linkify_tags($a, $body, ($uid) ? $uid : $profile_uid); if($results) { @@ -579,6 +599,9 @@ class Item extends \Zotlabs\Web\Controller { if(! $preview) { fix_attached_photo_permissions($profile_uid,$owner_xchan['xchan_hash'],((strpos($body,'[/crypt]')) ? $_POST['media_str'] : $body),$str_contact_allow,$str_group_allow,$str_contact_deny,$str_group_deny); + fix_attached_photo_permissions($profile_uid,$owner_xchan['xchan_hash'],((strpos($summary,'[/crypt]')) ? $_POST['media_str'] : $summary),$str_contact_allow,$str_group_allow,$str_contact_deny,$str_group_deny); + + fix_attached_file_permissions($channel,$observer['xchan_hash'],((strpos($body,'[/crypt]')) ? $_POST['media_str'] : $body),$str_contact_allow,$str_group_allow,$str_contact_deny,$str_group_deny); } @@ -711,7 +734,8 @@ class Item extends \Zotlabs\Web\Controller { $notify_type = (($parent) ? 'comment-new' : 'wall-new' ); if(! $mid) { - $mid = (($message_id) ? $message_id : item_message_id()); + $uuid = (($message_id) ? $message_id : item_message_id()); + $mid = z_root() . '/item/' . $uuid; } @@ -766,6 +790,7 @@ class Item extends \Zotlabs\Web\Controller { $datarray['aid'] = $channel['channel_account_id']; $datarray['uid'] = $profile_uid; + $datarray['uuid'] = $uuid; $datarray['owner_xchan'] = (($owner_hash) ? $owner_hash : $owner_xchan['xchan_hash']); $datarray['author_xchan'] = $observer['xchan_hash']; $datarray['created'] = $created; @@ -778,6 +803,7 @@ class Item extends \Zotlabs\Web\Controller { $datarray['parent_mid'] = $parent_mid; $datarray['mimetype'] = $mimetype; $datarray['title'] = $title; + $datarray['summary'] = $summary; $datarray['body'] = $body; $datarray['app'] = $app; $datarray['location'] = $location; @@ -887,12 +913,12 @@ class Item extends \Zotlabs\Web\Controller { $datarray['title'] = mb_substr($datarray['title'],0,191); if($webpage) { - Zlib\IConfig::Set($datarray,'system', webpage_to_namespace($webpage), - (($pagetitle) ? $pagetitle : substr($datarray['mid'],0,16)),true); + IConfig::Set($datarray,'system', webpage_to_namespace($webpage), + (($pagetitle) ? $pagetitle : basename($datarray['mid'])), true); } elseif($namespace) { - Zlib\IConfig::Set($datarray,'system', $namespace, - (($remote_id) ? $remote_id : substr($datarray['mid'],0,16)),true); + IConfig::Set($datarray,'system', $namespace, + (($remote_id) ? $remote_id : basename($datarray['mid'])), true); } @@ -924,7 +950,7 @@ class Item extends \Zotlabs\Web\Controller { } } if(! $nopush) - \Zotlabs\Daemon\Master::Summon(array('Notifier', 'edit_post', $post_id)); + Master::Summon([ 'Notifier', 'edit_post', $post_id ]); if($api_source) @@ -959,7 +985,7 @@ class Item extends \Zotlabs\Web\Controller { // otherwise it will happen during delivery if(($datarray['owner_xchan'] != $datarray['author_xchan']) && (intval($parent_item['item_wall']))) { - Zlib\Enotify::submit(array( + Enotify::submit(array( 'type' => NOTIFY_COMMENT, 'from_xchan' => $datarray['author_xchan'], 'to_xchan' => $datarray['owner_xchan'], @@ -977,7 +1003,7 @@ class Item extends \Zotlabs\Web\Controller { $parent = $post_id; if(($datarray['owner_xchan'] != $datarray['author_xchan']) && ($datarray['item_type'] == ITEM_TYPE_POST)) { - Zlib\Enotify::submit(array( + Enotify::submit(array( 'type' => NOTIFY_WALL, 'from_xchan' => $datarray['author_xchan'], 'to_xchan' => $datarray['owner_xchan'], @@ -1039,7 +1065,7 @@ class Item extends \Zotlabs\Web\Controller { call_hooks('post_local_end', $datarray); if(! $nopush) - \Zotlabs\Daemon\Master::Summon(array('Notifier', $notify_type, $post_id)); + Master::Summon([ 'Notifier', $notify_type, $post_id ]); logger('post_complete'); diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index 4e216f08b..c39726b88 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -371,10 +371,13 @@ class Like extends \Zotlabs\Web\Controller { } } - $mid = item_message_id(); + $uuid = item_message_id(); $arr = array(); + $arr['uuid'] = $uuid; + $arr['mid'] = z_root() . '/item/' . $uuid; + if($extended_like) { $arr['item_thread_top'] = 1; $arr['item_origin'] = 1; @@ -476,7 +479,6 @@ class Like extends \Zotlabs\Web\Controller { } - $arr['mid'] = $mid; $arr['aid'] = (($extended_like) ? $ch[0]['channel_account_id'] : $owner_aid); $arr['uid'] = $owner_uid; diff --git a/Zotlabs/Module/Mood.php b/Zotlabs/Module/Mood.php index 16ef0b171..453f08f9f 100644 --- a/Zotlabs/Module/Mood.php +++ b/Zotlabs/Module/Mood.php @@ -70,7 +70,8 @@ class Mood extends Controller { $poster = App::get_observer(); - $mid = item_message_id(); + $uuid = item_message_id(); + $mid = z_root() . '/item/' . $uuid; $action = sprintf( t('%1$s is %2$s','mood'), '[zrl=' . $poster['xchan_url'] . ']' . $poster['xchan_name'] . '[/zrl]' , $verbs[$verb]); @@ -78,6 +79,7 @@ class Mood extends Controller { $arr['aid'] = get_account_id(); $arr['uid'] = $uid; + $arr['uuid'] = $uuid; $arr['mid'] = $mid; $arr['parent_mid'] = (($parent_mid) ? $parent_mid : $mid); $arr['author_xchan'] = $poster['xchan_hash']; diff --git a/Zotlabs/Module/Nojs.php b/Zotlabs/Module/Nojs.php deleted file mode 100644 index 5f3d80ecd..000000000 --- a/Zotlabs/Module/Nojs.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php -namespace Zotlabs\Module; - - -class Nojs extends \Zotlabs\Web\Controller { - - function init() { - $n = ((argc() > 1) ? intval(argv(1)) : 1); - setcookie('jsdisabled', $n, 0, '/'); - $p = hex2bin($_GET['redir']); - $hasq = strpbrk($p,'?&'); - goaway(z_root() . (($p) ? '/' . $p : '') . (($hasq) ? '' : '?f=' ) . '&jsdisabled=' . $n); - - } -} diff --git a/Zotlabs/Module/React.php b/Zotlabs/Module/React.php index fbb760786..3920301f5 100644 --- a/Zotlabs/Module/React.php +++ b/Zotlabs/Module/React.php @@ -44,6 +44,7 @@ class React extends \Zotlabs\Web\Controller { return; } + $uuid = item_message_id(); $n = array(); $n['aid'] = $channel['channel_account_id']; @@ -52,7 +53,8 @@ class React extends \Zotlabs\Web\Controller { $n['item_type'] = $i[0]['item_type']; $n['parent'] = $postid; $n['parent_mid'] = $i[0]['mid']; - $n['mid'] = item_message_id(); + $n['uuid'] = $uuid; + $n['mid'] = z_root() . '/item/' . $uuid; $n['verb'] = ACTIVITY_REACT . '#' . $emoji; $n['body'] = "\n\n[zmg=32x32]" . z_root() . '/images/emoji/' . $emoji . '.png[/zmg]' . "\n\n"; $n['author_xchan'] = $channel['channel_hash']; diff --git a/Zotlabs/Module/Subthread.php b/Zotlabs/Module/Subthread.php index 1a9caff6c..54343fdfa 100644 --- a/Zotlabs/Module/Subthread.php +++ b/Zotlabs/Module/Subthread.php @@ -106,8 +106,9 @@ class Subthread extends \Zotlabs\Web\Controller { - $mid = item_message_id(); - + $uuid = item_message_id(); + $mid = z_root() . '/item/' . $uuid; + $post_type = (($item['resource_type'] === 'photo') ? t('photo') : t('status')); $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $item['plink'])); @@ -145,6 +146,7 @@ class Subthread extends \Zotlabs\Web\Controller { $arr = array(); + $arr['uuid'] = $uuid; $arr['mid'] = $mid; $arr['aid'] = $owner_aid; $arr['uid'] = $owner_uid; diff --git a/Zotlabs/Module/Wfinger.php b/Zotlabs/Module/Wfinger.php index 1866bce40..e4591df12 100644 --- a/Zotlabs/Module/Wfinger.php +++ b/Zotlabs/Module/Wfinger.php @@ -205,6 +205,12 @@ class Wfinger extends \Zotlabs\Web\Controller { ], [ + 'rel' => 'http://purl.org/zot/protocol/6.0', + 'type' => 'application/x-zot+json', + 'href' => channel_url($r[0]) + ], + + [ 'rel' => 'http://purl.org/openwebauth/v1', 'type' => 'application/x-zot+json', 'href' => z_root() . '/owa', |