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/Item.php | 28 | ||||
-rw-r--r-- | Zotlabs/Module/Wfinger.php | 6 |
5 files changed, 96 insertions, 7 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/Item.php b/Zotlabs/Module/Item.php index 2ee639874..464daa516 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -392,6 +392,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 +455,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 +507,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 +535,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 +597,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 +732,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 +788,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 +801,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; 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', |