From 1a49f0d164ce94bc3fce227a68aa3796e22347e1 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 9 Mar 2017 18:54:10 -0800 Subject: one role. --- Zotlabs/Module/Setup.php | 7 ------- 1 file changed, 7 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Setup.php b/Zotlabs/Module/Setup.php index 9c688af01..e114dfc0b 100644 --- a/Zotlabs/Module/Setup.php +++ b/Zotlabs/Module/Setup.php @@ -324,11 +324,6 @@ class Setup extends \Zotlabs\Web\Controller { $siteurl = trim($_POST['siteurl']); $timezone = ((x($_POST,'timezone')) ? ($_POST['timezone']) : 'America/Los_Angeles'); - $server_roles = [ - 'basic' => t('Basic/Minimal Social Networking'), - 'standard' => t('Standard Configuration (default)'), - 'pro' => t('Professional') - ]; $tpl = get_markup_template('install_settings.tpl'); $o .= replace_macros($tpl, array( @@ -348,8 +343,6 @@ class Setup extends \Zotlabs\Web\Controller { '$siteurl' => array('siteurl', t('Website URL'), z_root(), t('Please use SSL (https) URL if available.')), - '$server_role' => array('server_role', t("Server Configuration/Role"), 'standard','',$server_roles), - '$timezone' => array('timezone', t('Please select a default timezone for your website'), $timezone, '', get_timezones()), '$baseurl' => z_root(), -- cgit v1.2.3 From fc533107ed49735aad5ba39bf02b87ed7ac870b6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 12 Mar 2017 21:55:24 -0700 Subject: better handling of mimetype security --- Zotlabs/Module/Editwebpage.php | 2 -- Zotlabs/Module/Item.php | 23 +++++++---------------- 2 files changed, 7 insertions(+), 18 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Editwebpage.php b/Zotlabs/Module/Editwebpage.php index 3d4af107d..97f4a32ff 100644 --- a/Zotlabs/Module/Editwebpage.php +++ b/Zotlabs/Module/Editwebpage.php @@ -130,8 +130,6 @@ class Editwebpage extends \Zotlabs\Web\Controller { $layout = $itm[0]['layout_mid']; - $tpl = get_markup_template("jot.tpl"); - $rp = 'webpages/' . $which; $x = array( diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 4725ecb38..afac1542d 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -480,22 +480,13 @@ class Item extends \Zotlabs\Web\Controller { $execflag = false; - if($mimetype !== 'text/bbcode') { - $z = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id where channel_id = %d limit 1", - intval($profile_uid) - ); - if($z && (($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($z[0]['channel_pageflags'] & PAGE_ALLOWCODE))) { - if($uid && (get_account_id() == $z[0]['account_id'])) { - $execflag = true; - } - else { - notice( t('Executable content type not permitted to this channel.') . EOL); - if($api_source) - return ( [ 'success' => false, 'message' => 'forbidden content type' ] ); - if(x($_REQUEST,'return')) - goaway(z_root() . "/" . $return_path ); - killme(); - } + $z = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id + where channel_id = %d limit 1", + intval($profile_uid) + ); + if($z && (($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($z[0]['channel_pageflags'] & PAGE_ALLOWCODE))) { + if($uid && (intval(get_account_id()) == intval($z[0]['account_id']))) { + $execflag = true; } } -- cgit v1.2.3 From 58aa0f3e1a52a0c20016a4330100231ad505e6e4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 13 Mar 2017 16:19:47 -0700 Subject: code_allowed is a real mess. Start the cleanup by remving the account level code allow and limiting to specific channels only. This reduces the possibility of cross channel security issues coming into play. Then provide a single function for checking the code permission. This is only partially done as we often need to check against the observer or logged in channel as well as the resource owner to ensure that this only returns true for local channels which also own the requested resource. --- Zotlabs/Module/Impel.php | 14 ++------------ Zotlabs/Module/Item.php | 14 ++------------ 2 files changed, 4 insertions(+), 24 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Impel.php b/Zotlabs/Module/Impel.php index 197d9f859..77f488d26 100644 --- a/Zotlabs/Module/Impel.php +++ b/Zotlabs/Module/Impel.php @@ -144,18 +144,8 @@ class Impel extends \Zotlabs\Web\Controller { // Verify ability to use html or php!!! - $execflag = false; - - if($arr['mimetype'] === 'application/x-php') { - $z = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id where channel_id = %d limit 1", - intval(local_channel()) - ); - - if($z && (($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($z[0]['channel_pageflags'] & PAGE_ALLOWCODE))) { - $execflag = true; - } - } - + $execflag = ((intval($channel['channel_id']) == intval(local_channel()) && ($channel['channel_pageflags'] & PAGE_ALLOWCODE)) ? true : false); + $i = q("select id, edited, item_deleted from item where mid = '%s' and uid = %d limit 1", dbesc($arr['mid']), intval(local_channel()) diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index afac1542d..43cf535a4 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -478,18 +478,8 @@ class Item extends \Zotlabs\Web\Controller { // Verify ability to use html or php!!! - $execflag = false; - - $z = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id - where channel_id = %d limit 1", - intval($profile_uid) - ); - if($z && (($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($z[0]['channel_pageflags'] & PAGE_ALLOWCODE))) { - if($uid && (intval(get_account_id()) == intval($z[0]['account_id']))) { - $execflag = true; - } - } - + $execflag = ((intval($channel['channel_id']) == intval($profile_uid) && ($channel['channel_pageflags'] & PAGE_ALLOWCODE)) ? true : false); + $gacl = $acl->get(); $str_contact_allow = $gacl['allow_cid']; $str_group_allow = $gacl['allow_gid']; -- cgit v1.2.3 From 2c73b457ef0943d46804480a0aa016f64c11edbf Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 14 Mar 2017 17:07:29 -0700 Subject: input filter updates --- Zotlabs/Module/Item.php | 21 +++++---------------- Zotlabs/Module/Wiki.php | 1 + 2 files changed, 6 insertions(+), 16 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 43cf535a4..71f410b2a 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -471,15 +471,16 @@ class Item extends \Zotlabs\Web\Controller { if(! $mimetype) $mimetype = 'text/bbcode'; + + $execflag = ((intval($uid) == intval($profile_uid) + && ($channel['channel_pageflags'] & PAGE_ALLOWCODE)) ? true : false); + if($preview) { - $body = z_input_filter($profile_uid,$body,$mimetype); + $body = z_input_filter($body,$mimetype,$execflag); } - // Verify ability to use html or php!!! - $execflag = ((intval($channel['channel_id']) == intval($profile_uid) && ($channel['channel_pageflags'] & PAGE_ALLOWCODE)) ? true : false); - $gacl = $acl->get(); $str_contact_allow = $gacl['allow_cid']; $str_group_allow = $gacl['allow_gid']; @@ -843,18 +844,6 @@ class Item extends \Zotlabs\Web\Controller { if(mb_strlen($datarray['title']) > 255) $datarray['title'] = mb_substr($datarray['title'],0,255); - if(array_key_exists('item_private',$datarray) && $datarray['item_private']) { - - $datarray['body'] = trim(z_input_filter($datarray['uid'],$datarray['body'],$datarray['mimetype'])); - - if($uid) { - if($channel['channel_hash'] === $datarray['author_xchan']) { - $datarray['sig'] = base64url_encode(rsa_sign($datarray['body'],$channel['channel_prvkey'])); - $datarray['item_verified'] = 1; - } - } - } - if($webpage) { Zlib\IConfig::Set($datarray,'system', webpage_to_namespace($webpage), (($pagetitle) ? $pagetitle : substr($datarray['mid'],0,16)),true); diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index 5e7307c7b..79ec5ba25 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -243,6 +243,7 @@ class Wiki extends \Zotlabs\Web\Controller { $renderedContent = Zlib\NativeWikiPage::convert_links(zidify_links(smilies(bbcode($content))), argv(0) . '/' . argv(1) . '/' . $wikiUrlName); } else { + $content = Zlib\MarkdownSoap::unescape($content); $html = Zlib\NativeWikiPage::generate_toc(zidify_text(purify_html(MarkdownExtra::defaultTransform(Zlib\NativeWikiPage::bbcode($content))))); $renderedContent = Zlib\NativeWikiPage::convert_links($html, argv(0) . '/' . argv(1) . '/' . $wikiUrlName); } -- cgit v1.2.3 From 6078d02c3ac8ead59dbbecab2eb5de88ad7a1efc Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 15 Mar 2017 01:20:21 -0700 Subject: more work related to attach/photo and os_path, display_path and general code cleanup --- Zotlabs/Module/Cover_photo.php | 64 +++++++++++++++++++++------------------- Zotlabs/Module/Profile_photo.php | 12 ++++---- 2 files changed, 40 insertions(+), 36 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index 72ec1020d..47bce6c2b 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -23,19 +23,17 @@ require_once('include/channel.php'); class Cover_photo extends \Zotlabs\Web\Controller { function init() { - if(! local_channel()) { return; } $channel = \App::get_channel(); - profile_load($channel['channel_address']); - + profile_load($channel['channel_address']); } - /* @brief Evaluate posted values + /** + * @brief Evaluate posted values * - * @param $a Current application * @return void * */ @@ -130,8 +128,15 @@ class Cover_photo extends \Zotlabs\Web\Controller { $aid = get_account_id(); - $p = array('aid' => $aid, 'uid' => local_channel(), 'resource_id' => $base_image['resource_id'], - 'filename' => $base_image['filename'], 'album' => t('Cover Photos')); + $p = [ + 'aid' => $aid, + 'uid' => local_channel(), + 'resource_id' => $base_image['resource_id'], + 'filename' => $base_image['filename'], + 'album' => t('Cover Photos'), + 'os_path' => $base_image['os_path'], + 'display_path' => $base_image['display_path'] + ]; $p['imgscale'] = 7; $p['photo_usage'] = PHOTO_COVER; @@ -195,11 +200,10 @@ class Cover_photo extends \Zotlabs\Web\Controller { $os_storage = false; foreach($i as $ii) { - $smallest = intval($ii['imgscale']); + $smallest = intval($ii['imgscale']); $os_storage = intval($ii['os_storage']); - $imagedata = $ii['content']; - $filetype = $ii['mimetype']; - + $imagedata = $ii['content']; + $filetype = $ii['mimetype']; } } @@ -263,10 +267,10 @@ class Cover_photo extends \Zotlabs\Web\Controller { } - /* @brief Generate content of profile-photo view + /** + * @brief Generate content of profile-photo view * - * @param $a Current application - * @return void + * @return string * */ @@ -350,15 +354,15 @@ class Cover_photo extends \Zotlabs\Web\Controller { $tpl = get_markup_template('cover_photo.tpl'); $o .= replace_macros($tpl,array( - '$user' => \App::$channel['channel_address'], - '$lbl_upfile' => t('Upload File:'), - '$lbl_profiles' => t('Select a profile:'), - '$title' => t('Upload Cover Photo'), - '$submit' => t('Upload'), - '$profiles' => $profiles, + '$user' => \App::$channel['channel_address'], + '$lbl_upfile' => t('Upload File:'), + '$lbl_profiles' => t('Select a profile:'), + '$title' => t('Upload Cover Photo'), + '$submit' => t('Upload'), + '$profiles' => $profiles, '$form_security_token' => get_form_security_token("cover_photo"), - // FIXME - yuk - '$select' => sprintf('%s %s', t('or'), ($newuser) ? '' . t('skip this step') . '' : '' . t('select a photo from your photo albums') . '') + /// @FIXME - yuk + '$select' => sprintf('%s %s', t('or'), ($newuser) ? '' . t('skip this step') . '' : '' . t('select a photo from your photo albums') . '') )); call_hooks('cover_photo_content_end', $o); @@ -370,14 +374,14 @@ class Cover_photo extends \Zotlabs\Web\Controller { $resolution = 3; $tpl = get_markup_template("cropcover.tpl"); $o .= replace_macros($tpl,array( - '$filename' => $filename, - '$profile' => intval($_REQUEST['profile']), - '$resource' => \App::$data['imagecrop'] . '-3', - '$image_url' => z_root() . '/photo/' . $filename, - '$title' => t('Crop Image'), - '$desc' => t('Please adjust the image cropping for optimum viewing.'), + '$filename' => $filename, + '$profile' => intval($_REQUEST['profile']), + '$resource' => \App::$data['imagecrop'] . '-3', + '$image_url' => z_root() . '/photo/' . $filename, + '$title' => t('Crop Image'), + '$desc' => t('Please adjust the image cropping for optimum viewing.'), '$form_security_token' => get_form_security_token("cover_photo"), - '$done' => t('Done Editing') + '$done' => t('Done Editing') )); return $o; } @@ -393,8 +397,6 @@ class Cover_photo extends \Zotlabs\Web\Controller { * */ - - function cover_photo_crop_ui_head(&$a, $ph, $hash, $smallest){ $max_length = get_config('system','max_image_length'); diff --git a/Zotlabs/Module/Profile_photo.php b/Zotlabs/Module/Profile_photo.php index 438580917..e8f0e5186 100644 --- a/Zotlabs/Module/Profile_photo.php +++ b/Zotlabs/Module/Profile_photo.php @@ -108,11 +108,13 @@ class Profile_photo extends \Zotlabs\Web\Controller { $aid = get_account_id(); $p = [ - 'aid' => $aid, - 'uid' => local_channel(), - 'resource_id' => $base_image['resource_id'], - 'filename' => $base_image['filename'], - 'album' => t('Profile Photos') + 'aid' => $aid, + 'uid' => local_channel(), + 'resource_id' => $base_image['resource_id'], + 'filename' => $base_image['filename'], + 'album' => t('Profile Photos'), + 'os_path' => $base_image['os_path'], + 'display_path' => $base_image['display_path'] ]; $p['imgscale'] = PHOTO_RES_PROFILE_300; -- cgit v1.2.3 From d9037589407162f51578856b084baaa5353a8a04 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 16 Mar 2017 18:36:58 -0700 Subject: remove include/widgets.php --- Zotlabs/Module/Connections.php | 4 ---- Zotlabs/Module/Connedit.php | 3 --- Zotlabs/Module/Directory.php | 1 - Zotlabs/Module/Suggest.php | 4 +--- 4 files changed, 1 insertion(+), 11 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index e8a92e8b7..b079ae860 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -5,10 +5,6 @@ namespace Zotlabs\Module; require_once('include/socgraph.php'); require_once('include/selectors.php'); require_once('include/group.php'); -require_once('include/contact_widgets.php'); -require_once('include/zot.php'); -require_once('include/widgets.php'); - class Connections extends \Zotlabs\Web\Controller { diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php index 5b7c23028..72bd3e86e 100644 --- a/Zotlabs/Module/Connedit.php +++ b/Zotlabs/Module/Connedit.php @@ -11,9 +11,6 @@ namespace Zotlabs\Module; require_once('include/socgraph.php'); require_once('include/selectors.php'); require_once('include/group.php'); -require_once('include/contact_widgets.php'); -require_once('include/zot.php'); -require_once('include/widgets.php'); require_once('include/photos.php'); diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php index 59ae88857..edcf43cd6 100644 --- a/Zotlabs/Module/Directory.php +++ b/Zotlabs/Module/Directory.php @@ -4,7 +4,6 @@ namespace Zotlabs\Module; require_once('include/socgraph.php'); require_once('include/dir_fns.php'); -require_once('include/widgets.php'); require_once('include/bbcode.php'); diff --git a/Zotlabs/Module/Suggest.php b/Zotlabs/Module/Suggest.php index 367308d90..2a69145ed 100644 --- a/Zotlabs/Module/Suggest.php +++ b/Zotlabs/Module/Suggest.php @@ -3,8 +3,6 @@ namespace Zotlabs\Module; require_once('include/socgraph.php'); require_once('include/contact_widgets.php'); -require_once('include/widgets.php'); - class Suggest extends \Zotlabs\Web\Controller { @@ -23,7 +21,7 @@ class Suggest extends \Zotlabs\Web\Controller { } - function get() { + function get() { $o = ''; if(! local_channel()) { -- cgit v1.2.3 From 4afeefb5ce2119541a6d2a0a0b332c7a9a59a2b4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 18 Mar 2017 16:41:43 -0700 Subject: various input filter fixes --- Zotlabs/Module/Editblock.php | 7 ++++++- Zotlabs/Module/Editlayout.php | 1 + Zotlabs/Module/Editwebpage.php | 6 +++++- Zotlabs/Module/Hcard.php | 10 ++++------ Zotlabs/Module/Layouts.php | 1 + Zotlabs/Module/Settings/Permcats.php | 4 +--- Zotlabs/Module/Wiki.php | 23 ++++++++++++++++------- 7 files changed, 34 insertions(+), 18 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Editblock.php b/Zotlabs/Module/Editblock.php index 654e2251d..8a7e87a09 100644 --- a/Zotlabs/Module/Editblock.php +++ b/Zotlabs/Module/Editblock.php @@ -98,6 +98,11 @@ class Editblock extends \Zotlabs\Web\Controller { $mimetype = $itm[0]['mimetype']; + $content = $itm[0]['body']; + if($itm[0]['mimetype'] === 'text/markdown') + $content = \Zotlabs\Lib\MarkdownSoap::unescape($itm[0]['body']); + + $rp = 'blocks/' . $channel['channel_address']; $x = array( @@ -117,7 +122,7 @@ class Editblock extends \Zotlabs\Web\Controller { 'ptyp' => $itm[0]['type'], 'mimeselect' => true, 'mimetype' => $itm[0]['mimetype'], - 'body' => undo_post_tagging($itm[0]['body']), + 'body' => undo_post_tagging($content), 'post_id' => $post_id, 'visitor' => true, 'title' => htmlspecialchars($itm[0]['title'],ENT_COMPAT,'UTF-8'), diff --git a/Zotlabs/Module/Editlayout.php b/Zotlabs/Module/Editlayout.php index ea637fcba..3d6a79507 100644 --- a/Zotlabs/Module/Editlayout.php +++ b/Zotlabs/Module/Editlayout.php @@ -119,6 +119,7 @@ class Editlayout extends \Zotlabs\Web\Controller { 'hide_weblink' => true, 'hide_attach' => true, 'hide_preview' => true, + 'disable_comments' => true, 'ptyp' => $itm[0]['obj_type'], 'body' => undo_post_tagging($itm[0]['body']), 'post_id' => $post_id, diff --git a/Zotlabs/Module/Editwebpage.php b/Zotlabs/Module/Editwebpage.php index 97f4a32ff..03b2aeab9 100644 --- a/Zotlabs/Module/Editwebpage.php +++ b/Zotlabs/Module/Editwebpage.php @@ -129,6 +129,10 @@ class Editwebpage extends \Zotlabs\Web\Controller { } $layout = $itm[0]['layout_mid']; + + $content = $itm[0]['body']; + if($itm[0]['mimetype'] === 'text/markdown') + $content = \Zotlabs\Lib\MarkdownSoap::unescape($itm[0]['body']); $rp = 'webpages/' . $which; @@ -145,7 +149,7 @@ class Editwebpage extends \Zotlabs\Web\Controller { 'hide_location' => true, 'hide_voting' => true, 'ptyp' => $itm[0]['type'], - 'body' => undo_post_tagging($itm[0]['body']), + 'body' => undo_post_tagging($content), 'post_id' => $post_id, 'visitor' => ($is_owner) ? true : false, 'acl' => populate_acl($itm[0],false,\Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_pages')), diff --git a/Zotlabs/Module/Hcard.php b/Zotlabs/Module/Hcard.php index ec9181f6a..13097939e 100644 --- a/Zotlabs/Module/Hcard.php +++ b/Zotlabs/Module/Hcard.php @@ -59,12 +59,10 @@ class Hcard extends \Zotlabs\Web\Controller { } - function get() { - - require_once('include/widgets.php'); - return widget_profile(array()); - - + function get() { + + $x = new \Zotlabs\Widget\Profile(); + return $x->widget(array()); } diff --git a/Zotlabs/Module/Layouts.php b/Zotlabs/Module/Layouts.php index c07f65ce1..34d754029 100644 --- a/Zotlabs/Module/Layouts.php +++ b/Zotlabs/Module/Layouts.php @@ -125,6 +125,7 @@ class Layouts extends \Zotlabs\Web\Controller { 'hide_weblink' => true, 'hide_attach' => true, 'hide_preview' => true, + 'disable_comments' => true, 'ptlabel' => t('Layout Name'), 'profile_uid' => intval($owner), 'expanded' => true, diff --git a/Zotlabs/Module/Settings/Permcats.php b/Zotlabs/Module/Settings/Permcats.php index 35d533196..771e76cbd 100644 --- a/Zotlabs/Module/Settings/Permcats.php +++ b/Zotlabs/Module/Settings/Permcats.php @@ -42,8 +42,6 @@ class Permcats { function get() { -logger('cmd: ' . \App::$cmd); - if(! local_channel()) return; @@ -85,7 +83,7 @@ logger('cmd: ' . \App::$cmd); if($existing[$k]) $thisperm = "1"; - $perms[] = array('perms_' . $k, $v, ((array_key_exists($k,$their_perms)) ? intval($their_perms[$k]) : ''),$thisperm, 1, (($checkinherited & PERMS_SPECIFIC) ? '' : '1'), '', $checkinherited); + $perms[] = array('perms_' . $k, $v, '',$thisperm, 1, (($checkinherited & PERMS_SPECIFIC) ? '' : '1'), '', $checkinherited); } diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index 79ec5ba25..d24d3f6c3 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -237,6 +237,8 @@ class Wiki extends \Zotlabs\Web\Controller { $rawContent = htmlspecialchars_decode(json_decode($p['content']),ENT_COMPAT); + $rawContent = $p['content']; + $content = ($p['content'] !== '' ? $rawContent : '"# New page\n"'); // Render the Markdown-formatted page content in HTML if($mimeType == 'text/bbcode') { @@ -244,7 +246,7 @@ class Wiki extends \Zotlabs\Web\Controller { } else { $content = Zlib\MarkdownSoap::unescape($content); - $html = Zlib\NativeWikiPage::generate_toc(zidify_text(purify_html(MarkdownExtra::defaultTransform(Zlib\NativeWikiPage::bbcode($content))))); + $html = Zlib\NativeWikiPage::generate_toc(zidify_text(MarkdownExtra::defaultTransform(Zlib\NativeWikiPage::bbcode($content)))); $renderedContent = Zlib\NativeWikiPage::convert_links($html, argv(0) . '/' . argv(1) . '/' . $wikiUrlName); } $showPageControls = $wiki_editor; @@ -328,9 +330,12 @@ class Wiki extends \Zotlabs\Web\Controller { $html = Zlib\NativeWikiPage::convert_links(zidify_links(smilies(bbcode($content))),$wikiURL); } else { - require_once('library/markdown.php'); - $content = Zlib\NativeWikiPage::bbcode($content); - $html = Zlib\NativeWikiPage::generate_toc(zidify_text(purify_html(Markdown($content)))); + $bb = Zlib\NativeWikiPage::bbcode($content); + $x = new ZLib\MarkdownSoap($bb); + $md = $x->clean(); + $md = ZLib\MarkdownSoap::unescape($md); + $html = MarkdownExtra::defaultTransform($md); + $html = Zlib\NativeWikiPage::generate_toc(zidify_text($html)); $html = Zlib\NativeWikiPage::convert_links($html,$wikiURL); } json_return_and_die(array('html' => $html, 'success' => true)); @@ -455,7 +460,11 @@ class Wiki extends \Zotlabs\Web\Controller { json_return_and_die(array('pages' => null, 'message' => 'Permission denied.', 'success' => false)); } - $page_list_html = widget_wiki_pages(array( + // @FIXME - we shouldn't invoke this if it isn't in the PDL or has been over-ridden + + $x = new \Zotlabs\Widget\Wiki_pages(); + + $page_list_html = $x->widget(array( 'resource_id' => $resource_id, 'refresh' => true, 'channel' => argv(1))); @@ -513,7 +522,6 @@ class Wiki extends \Zotlabs\Web\Controller { $resource_id = $_POST['resource_id']; $pageUrlName = $_POST['name']; - // Determine if observer has permission to read content $perms = Zlib\NativeWiki::get_permissions($resource_id, intval($owner['channel_id']), $observer_hash); @@ -522,11 +530,12 @@ class Wiki extends \Zotlabs\Web\Controller { json_return_and_die(array('historyHTML' => '', 'message' => 'Permission denied.', 'success' => false)); } - $historyHTML = widget_wiki_page_history(array( + $historyHTML = \Zotlabs\Lib\NativeWikiPage::render_page_history(array( 'resource_id' => $resource_id, 'pageUrlName' => $pageUrlName, 'permsWrite' => $perms['write'] )); + json_return_and_die(array('historyHTML' => $historyHTML, 'message' => '', 'success' => true)); } -- cgit v1.2.3 From 35fc7328de3237ef9727e6f729ffe4df4697a421 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 20 Mar 2017 19:41:03 -0700 Subject: even more fine tuning of the markdown purifier - especially when used with the wiki --- Zotlabs/Module/Wiki.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index 28e8fe328..b5801c3d7 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -255,6 +255,7 @@ class Wiki extends \Zotlabs\Web\Controller { goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/' . $pageUrlName); } + $wikiModalID = random_string(3); $wikiModal = replace_macros(get_markup_template('generic_modal.tpl'), array( -- cgit v1.2.3 From bedc39342514a37d311274210f30a4abd14284fa Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 21 Mar 2017 20:11:48 -0700 Subject: begin the process of using the relevant attach directory/path for photo albums instead of an album basename which may not be unique. Created an 'ellipsify()' function to shorten long names and keep the beginning and end intact --- Zotlabs/Module/Photos.php | 45 ++++++++++++++------------------------------- 1 file changed, 14 insertions(+), 31 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index 582174d0e..598f1782d 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -92,13 +92,9 @@ class Photos extends \Zotlabs\Web\Controller { if((argc() > 3) && (argv(2) === 'album')) { - $album = hex2bin(argv(3)); - - if($album === t('Profile Photos')) { - // not allowed - goaway(z_root() . '/' . $_SESSION['photo_return']); - } - + $album = argv(3); + + if(! photos_album_exists($page_owner_uid,$album)) { notice( t('Album not found.') . EOL); goaway(z_root() . '/' . $_SESSION['photo_return']); @@ -680,29 +676,16 @@ class Photos extends \Zotlabs\Web\Controller { if($datatype === 'album') { - if(strlen($datum)) { - if((strlen($datum) & 1) || (! ctype_xdigit($datum))) { - notice( t('Album name could not be decoded') . EOL); - logger('mod_photos: illegal album encoding: ' . $datum); - $datum = ''; - goaway(z_root() . '/photos/' . \App::$data['channel']['channel_address']); - } - } - $album = (($datum) ? hex2bin($datum) : ''); + $album = $datum; \App::$page['htmlhead'] .= "\r\n" . '' . "\r\n"; - //check if the album exists and if we have perms - $r = q("SELECT album FROM photo WHERE uid = %d AND album = '%s' and is_nsfw = %d $sql_extra LIMIT 1", - intval($owner_uid), - dbesc($album), - intval($unsafe) - ); - - if($r) { + if($x = photos_album_exists($owner_uid,$datum)) { \App::set_pager_itemspage(60); - } else { + $album = $x['display_path']; + } + else { goaway(z_root() . '/photos/' . \App::$data['channel']['channel_address']); } @@ -712,19 +695,19 @@ class Photos extends \Zotlabs\Web\Controller { $order = 'DESC'; $r = q("SELECT p.resource_id, p.id, p.filename, p.mimetype, p.imgscale, p.description, p.created FROM photo p INNER JOIN - (SELECT resource_id, max(imgscale) imgscale FROM photo WHERE uid = %d AND album = '%s' AND imgscale <= 4 AND photo_usage IN ( %d, %d ) and is_nsfw = %d $sql_extra GROUP BY resource_id) ph + (SELECT resource_id, max(imgscale) imgscale FROM photo left join attach on folder = '%s' and photo.resource_id = attach.hash WHERE attach.uid = %d AND imgscale <= 4 AND photo_usage IN ( %d, %d ) and is_nsfw = %d $sql_extra GROUP BY resource_id) ph ON (p.resource_id = ph.resource_id AND p.imgscale = ph.imgscale) ORDER BY created $order LIMIT %d OFFSET %d", + dbesc($datum), intval($owner_uid), - dbesc($album), intval(PHOTO_NORMAL), intval(PHOTO_PROFILE), intval($unsafe), intval(\App::$pager['itemspage']), intval(\App::$pager['start']) ); - - //edit album name + + // edit album name $album_edit = null; if(($album !== t('Profile Photos')) && ($album !== 'Profile Photos') && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) { if($can_post) { @@ -749,9 +732,9 @@ class Photos extends \Zotlabs\Web\Controller { } if($_GET['order'] === 'posted') - $order = array(t('Show Newest First'), z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . bin2hex($album)); + $order = array(t('Show Newest First'), z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . $datum); else - $order = array(t('Show Oldest First'), z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . bin2hex($album) . '?f=&order=posted'); + $order = array(t('Show Oldest First'), z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . $datum . '?f=&order=posted'); $photos = array(); if(count($r)) { -- cgit v1.2.3 From 83a78a949d67dbbe3294f7f02ffeb45b6f96423d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 21 Mar 2017 21:13:14 -0700 Subject: photos_album_exists() requires an observer to work correctly; provide it. --- Zotlabs/Module/Photos.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index 598f1782d..cf622d657 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -95,7 +95,7 @@ class Photos extends \Zotlabs\Web\Controller { $album = argv(3); - if(! photos_album_exists($page_owner_uid,$album)) { + if(! photos_album_exists($page_owner_uid, get_observer_hash(), $album)) { notice( t('Album not found.') . EOL); goaway(z_root() . '/' . $_SESSION['photo_return']); } @@ -681,7 +681,7 @@ class Photos extends \Zotlabs\Web\Controller { \App::$page['htmlhead'] .= "\r\n" . '' . "\r\n"; - if($x = photos_album_exists($owner_uid,$datum)) { + if($x = photos_album_exists($owner_uid, get_observer_hash(), $datum)) { \App::set_pager_itemspage(60); $album = $x['display_path']; } -- cgit v1.2.3 From 65ecc5ae15757b41bda8e0aed23a17d5e258cdc7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 21 Mar 2017 22:05:36 -0700 Subject: more work on the photo album mess --- Zotlabs/Module/Photos.php | 157 +++++++++++++++++++--------------------------- 1 file changed, 65 insertions(+), 92 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index cf622d657..a0e230ac8 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -15,13 +15,10 @@ class Photos extends \Zotlabs\Web\Controller { function init() { - if(observer_prohibited()) { return; } - $o = ''; - if(argc() > 1) { $nick = argv(1); @@ -54,7 +51,6 @@ class Photos extends \Zotlabs\Web\Controller { logger('mod-photos: photos_post: begin' , LOGGER_DEBUG); - logger('mod_photos: REQUEST ' . print_r($_REQUEST,true), LOGGER_DATA); logger('mod_photos: FILES ' . print_r($_FILES,true), LOGGER_DATA); @@ -94,7 +90,6 @@ class Photos extends \Zotlabs\Web\Controller { $album = argv(3); - if(! photos_album_exists($page_owner_uid, get_observer_hash(), $album)) { notice( t('Album not found.') . EOL); goaway(z_root() . '/' . $_SESSION['photo_return']); @@ -117,7 +112,7 @@ class Photos extends \Zotlabs\Web\Controller { $folder_hash = ''; - $r = q("select * from attach where is_dir = 1 and uid = %d and filename = '%s'", + $r = q("select * from attach where is_dir = 1 and uid = %d and hash = '%s'", intval($page_owner_uid), dbesc($album) ); @@ -125,14 +120,7 @@ class Photos extends \Zotlabs\Web\Controller { notice( t('Album not found.') . EOL); return; } - if(count($r) > 1) { - notice( t('Multiple storage folders exist with this album name, but within different directories. Please remove the desired folder or folders using the Files manager') . EOL); - return; - } - else { - $folder_hash = $r[0]['hash']; - } - + $folder_hash = $r[0]['hash']; $res = array(); @@ -464,7 +452,7 @@ class Photos extends \Zotlabs\Web\Controller { * default post action - upload a photo */ - $channel = \App::$data['channel']; + $channel = \App::$data['channel']; $observer = \App::$data['observer']; $_REQUEST['source'] = 'photos'; @@ -481,12 +469,10 @@ class Photos extends \Zotlabs\Web\Controller { if(! $r['success']) { notice($r['message'] . EOL); + goaway(z_root() . '/photos/' . \App::$data['channel']['channel_address']); } - - if($_REQUEST['newalbum']) - goaway(z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . bin2hex($_REQUEST['newalbum'])); - else - goaway(z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . bin2hex(datetime_convert('UTC',date_default_timezone_get(),'now', 'Y'))); + + goaway(z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . $r['data']['folder']); } @@ -565,7 +551,9 @@ class Photos extends \Zotlabs\Web\Controller { return; } - $sql_extra = permissions_sql($owner_uid); + $sql_item = item_permissions_sql($owner_uid,get_observer_hash()); + $sql_extra = permissions_sql($owner_uid,get_observer_hash(),'photo'); + $sql_attach = permissions_sql($owner_uid,get_observer_hash(),'attach'); $o = ""; @@ -676,9 +664,6 @@ class Photos extends \Zotlabs\Web\Controller { if($datatype === 'album') { - - $album = $datum; - \App::$page['htmlhead'] .= "\r\n" . '' . "\r\n"; if($x = photos_album_exists($owner_uid, get_observer_hash(), $datum)) { @@ -788,10 +773,10 @@ class Photos extends \Zotlabs\Web\Controller { $o .= replace_macros($tpl, array( '$photos' => $photos, '$album' => $album, - '$album_id' => bin2hex($album), + '$album_id' => $datum), '$album_edit' => array(t('Edit Album'), $album_edit), '$can_post' => $can_post, - '$upload' => array(t('Upload'), z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/upload/' . bin2hex($album)), + '$upload' => array(t('Upload'), z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/upload/' . $datum), '$order' => $order, '$upload_form' => $upload_form, '$usage' => $usage_message @@ -805,8 +790,6 @@ class Photos extends \Zotlabs\Web\Controller { killme(); } - // $o .= paginate($a); - return $o; } @@ -819,6 +802,11 @@ class Photos extends \Zotlabs\Web\Controller { \App::$page['htmlhead'] .= "\r\n" . '' . "\r\n"; + $x = q("select folder from attach where hash = '%s' and uid = %d $sql_attach limit 1", + dbesc($datum), + intval($owner_uid) + ); + // fetch image, item containing image, then comments $ph = q("SELECT id,aid,uid,xchan,resource_id,created,edited,title,description,album,filename,mimetype,height,width,filesize,imgscale,photo_usage,is_nsfw,allow_cid,allow_gid,deny_cid,deny_gid FROM photo WHERE uid = %d AND resource_id = '%s' @@ -827,7 +815,7 @@ class Photos extends \Zotlabs\Web\Controller { dbesc($datum) ); - if(! $ph) { + if(! ($ph && $x)) { /* Check again - this time without specifying permissions */ @@ -852,16 +840,17 @@ class Photos extends \Zotlabs\Web\Controller { else $order = 'DESC'; - - $prvnxt = q("SELECT resource_id FROM photo WHERE album = '%s' AND uid = %d AND imgscale = 0 - $sql_extra ORDER BY created $order ", - dbesc($ph[0]['album']), + + + $prvnxt = q("SELECT hash FROM attach WHERE folder = '%s' AND uid = %d AND is_photo = 1 + $sql_attach ORDER BY created $order ", + dbesc($x[0]['folder']), intval($owner_uid) ); if(count($prvnxt)) { for($z = 0; $z < count($prvnxt); $z++) { - if($prvnxt[$z]['resource_id'] == $ph[0]['resource_id']) { + if($prvnxt[$z]['hash'] == $ph[0]['hash']) { $prv = $z - 1; $nxt = $z + 1; if($prv < 0) @@ -890,7 +879,7 @@ class Photos extends \Zotlabs\Web\Controller { } } - $album_link = z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . bin2hex($ph[0]['album']); + $album_link = z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . $x[0]['folder']; $tools = Null; $lock = Null; @@ -930,7 +919,7 @@ class Photos extends \Zotlabs\Web\Controller { // Do we have an item for this photo? $linked_items = q("SELECT * FROM item WHERE resource_id = '%s' and resource_type = 'photo' - $sql_extra LIMIT 1", + $sql_item LIMIT 1", dbesc($datum) ); @@ -945,7 +934,7 @@ class Photos extends \Zotlabs\Web\Controller { $item_normal = item_normal(); $r = q("select * from item where parent_mid = '%s' - $item_normal and uid = %d $sql_extra ", + $item_normal and uid = %d $sql_item ", dbesc($link_item['mid']), intval($link_item['uid']) @@ -991,13 +980,6 @@ class Photos extends \Zotlabs\Web\Controller { $edit = null; if($can_post) { - $m = q("select folder from attach where hash = '%s' and uid = %d limit 1", - dbesc($ph[0]['resource_id']), - intval($ph[0]['uid']) - ); - if($m) - $album_hash = $m[0]['folder']; - $album_e = $ph[0]['album']; $caption_e = $ph[0]['description']; $aclselect_e = (($_is_owner) ? populate_acl($ph[0], true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_storage')) : ''); @@ -1007,35 +989,35 @@ class Photos extends \Zotlabs\Web\Controller { $folder_list = attach_folder_select_list($ph[0]['uid']); - $edit = array( + $edit = [ 'edit' => t('Edit photo'), 'id' => $link_item['id'], - 'rotatecw' => t('Rotate CW (right)'), - 'rotateccw' => t('Rotate CCW (left)'), - 'albums' => $albums['albums'], - 'album' => $album_e, - 'album_select' => [ 'move_to_album', t('Move photo to album'), $album_hash, '', $folder_list ], - 'newalbum_label' => t('Enter a new album name'), + 'rotatecw' => t('Rotate CW (right)'), + 'rotateccw' => t('Rotate CCW (left)'), + 'albums' => $albums['albums'], + 'album' => $album_e, + 'album_select' => [ 'move_to_album', t('Move photo to album'), $x[0]['folder'], '', $folder_list ], + 'newalbum_label' => t('Enter a new album name'), 'newalbum_placeholder' => t('or select an existing one (doubleclick)'), - 'nickname' => \App::$data['channel']['channel_address'], - 'resource_id' => $ph[0]['resource_id'], - 'capt_label' => t('Caption'), - 'caption' => $caption_e, - 'tag_label' => t('Add a Tag'), - 'permissions' => t('Permissions'), - 'aclselect' => $aclselect_e, - 'allow_cid' => acl2json($ph[0]['allow_cid']), - 'allow_gid' => acl2json($ph[0]['allow_gid']), - 'deny_cid' => acl2json($ph[0]['deny_cid']), - 'deny_gid' => acl2json($ph[0]['deny_gid']), - 'lockstate' => $lockstate[0], - 'help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com'), - 'item_id' => ((count($linked_items)) ? $link_item['id'] : 0), - 'adult_enabled' => feature_enabled($owner_uid,'adult_photo_flagging'), - 'adult' => array('adult',t('Flag as adult in album view'), intval($ph[0]['is_nsfw']),''), - 'submit' => t('Submit'), - 'delete' => t('Delete Photo') - ); + 'nickname' => \App::$data['channel']['channel_address'], + 'resource_id' => $ph[0]['resource_id'], + 'capt_label' => t('Caption'), + 'caption' => $caption_e, + 'tag_label' => t('Add a Tag'), + 'permissions' => t('Permissions'), + 'aclselect' => $aclselect_e, + 'allow_cid' => acl2json($ph[0]['allow_cid']), + 'allow_gid' => acl2json($ph[0]['allow_gid']), + 'deny_cid' => acl2json($ph[0]['deny_cid']), + 'deny_gid' => acl2json($ph[0]['deny_gid']), + 'lockstate' => $lockstate[0], + 'help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com'), + 'item_id' => ((count($linked_items)) ? $link_item['id'] : 0), + 'adult_enabled' => feature_enabled($owner_uid,'adult_photo_flagging'), + 'adult' => array('adult',t('Flag as adult in album view'), intval($ph[0]['is_nsfw']),''), + 'submit' => t('Submit'), + 'delete' => t('Delete Photo') + ]; } if(count($linked_items)) { @@ -1049,13 +1031,13 @@ class Photos extends \Zotlabs\Web\Controller { $likebuttons = ''; if($can_post || $can_comment) { - $likebuttons = array( - 'id' => $link_item['id'], + $likebuttons = [ + 'id' => $link_item['id'], 'likethis' => t("I like this \x28toggle\x29"), - 'nolike' => t("I don't like this \x28toggle\x29"), - 'share' => t('Share'), - 'wait' => t('Please wait') - ); + 'nolike' => t("I don't like this \x28toggle\x29"), + 'share' => t('Share'), + 'wait' => t('Please wait') + ]; } $comments = ''; @@ -1260,25 +1242,13 @@ class Photos extends \Zotlabs\Web\Controller { \App::$page['htmlhead'] .= "\r\n" . '' . "\r\n"; - /* - $r = q("SELECT resource_id, max(imgscale) AS imgscale FROM photo WHERE uid = %d - and photo_usage in ( %d, %d ) and is_nsfw = %d $sql_extra GROUP BY resource_id", - intval(\App::$data['channel']['channel_id']), - intval(PHOTO_NORMAL), - intval(PHOTO_PROFILE), - intval($unsafe) - ); - if($r) { - \App::set_pager_total(count($r)); - \App::set_pager_itemspage(60); - } - */ \App::set_pager_itemspage(60); $r = q("SELECT p.resource_id, p.id, p.filename, p.mimetype, p.album, p.imgscale, p.created FROM photo p - INNER JOIN ( SELECT resource_id, max(imgscale) imgscale FROM photo - WHERE uid = %d AND photo_usage IN ( %d, %d ) + INNER JOIN ( SELECT resource_id, attach.folder as folder, max(imgscale) imgscale FROM photo left join attach on + photo.resource_id = attach.hash + WHERE photo.uid = %d AND photo_usage IN ( %d, %d ) AND is_nsfw = %d $sql_extra group by resource_id ) ph ON (p.resource_id = ph.resource_id and p.imgscale = ph.imgscale) ORDER by p.created DESC LIMIT %d OFFSET %d", @@ -1310,7 +1280,10 @@ class Photos extends \Zotlabs\Web\Controller { $alt_e = $rr['filename']; $name_e = $rr['album']; } - + + + + $photos[] = array( 'id' => $rr['id'], 'twist' => ' ' . $twist . rand(2,4), -- cgit v1.2.3 From 24b55bbc9ba157f5f3b22c49b36ee9cced10b0e2 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 22 Mar 2017 12:41:16 -0700 Subject: fix photo prvnxt after all the changes yesterday --- Zotlabs/Module/Photos.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index a0e230ac8..f423440ed 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -773,7 +773,7 @@ class Photos extends \Zotlabs\Web\Controller { $o .= replace_macros($tpl, array( '$photos' => $photos, '$album' => $album, - '$album_id' => $datum), + '$album_id' => $datum, '$album_edit' => array(t('Edit Album'), $album_edit), '$can_post' => $can_post, '$upload' => array(t('Upload'), z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/upload/' . $datum), @@ -840,17 +840,16 @@ class Photos extends \Zotlabs\Web\Controller { else $order = 'DESC'; - $prvnxt = q("SELECT hash FROM attach WHERE folder = '%s' AND uid = %d AND is_photo = 1 $sql_attach ORDER BY created $order ", dbesc($x[0]['folder']), intval($owner_uid) ); - + if(count($prvnxt)) { for($z = 0; $z < count($prvnxt); $z++) { - if($prvnxt[$z]['hash'] == $ph[0]['hash']) { + if($prvnxt[$z]['hash'] == $ph[0]['resource_id']) { $prv = $z - 1; $nxt = $z + 1; if($prv < 0) @@ -861,8 +860,8 @@ class Photos extends \Zotlabs\Web\Controller { } } - $prevlink = z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/image/' . $prvnxt[$prv]['resource_id'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); - $nextlink = z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/image/' . $prvnxt[$nxt]['resource_id'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); + $prevlink = z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/image/' . $prvnxt[$prv]['hash'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); + $nextlink = z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/image/' . $prvnxt[$nxt]['hash'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); } -- cgit v1.2.3 From 0fb024190192c92e542bceb486e8875ddabfdeb6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 22 Mar 2017 16:11:38 -0700 Subject: some more photo issues --- Zotlabs/Module/Photos.php | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index f423440ed..975c527ef 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -612,8 +612,14 @@ class Photos extends \Zotlabs\Web\Controller { if(! $aclselect) { $aclselect = ''; } - - $selname = (($datum) ? hex2bin($datum) : ''); + + $selname = ''; + + if($datum) { + $h = attach_by_hash_nodata($datum,get_observer_hash()); + $selname = $h['data']['display_path']; + } + $albums = ((array_key_exists('albums', \App::$data)) ? \App::$data['albums'] : photos_albums_list(\App::$data['channel'],\App::$data['observer'])); @@ -694,12 +700,12 @@ class Photos extends \Zotlabs\Web\Controller { // edit album name $album_edit = null; - if(($album !== t('Profile Photos')) && ($album !== 'Profile Photos') && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) { - if($can_post) { - $album_e = $album; - $albums = ((array_key_exists('albums', \App::$data)) ? \App::$data['albums'] : photos_albums_list(\App::$data['channel'],\App::$data['observer'])); + + if($can_post) { + $album_e = $album; + $albums = ((array_key_exists('albums', \App::$data)) ? \App::$data['albums'] : photos_albums_list(\App::$data['channel'],\App::$data['observer'])); - // @fixme - syncronise actions with DAV + // @fixme - syncronise actions with DAV // $edit_tpl = get_markup_template('album_edit.tpl'); // $album_edit = replace_macros($edit_tpl,array( @@ -713,7 +719,6 @@ class Photos extends \Zotlabs\Web\Controller { // '$dropsubmit' => t('Delete Album') // )); - } } if($_GET['order'] === 'posted') @@ -1244,9 +1249,9 @@ class Photos extends \Zotlabs\Web\Controller { \App::set_pager_itemspage(60); - $r = q("SELECT p.resource_id, p.id, p.filename, p.mimetype, p.album, p.imgscale, p.created FROM photo p - INNER JOIN ( SELECT resource_id, attach.folder as folder, max(imgscale) imgscale FROM photo left join attach on - photo.resource_id = attach.hash + $r = q("SELECT p.resource_id, p.id, p.filename, p.mimetype, p.album, p.imgscale, p.created, p.display_path + FROM photo p + INNER JOIN ( SELECT resource_id, max(imgscale) imgscale FROM photo WHERE photo.uid = %d AND photo_usage IN ( %d, %d ) AND is_nsfw = %d $sql_extra group by resource_id ) ph ON (p.resource_id = ph.resource_id and p.imgscale = ph.imgscale) @@ -1265,23 +1270,18 @@ class Photos extends \Zotlabs\Web\Controller { if($r) { $twist = 'rotright'; foreach($r as $rr) { + + if(! attach_can_view_folder(\App::$data['channel']['channel_id'],get_observer_hash(),$rr['resource_id'])) + continue; + if($twist == 'rotright') $twist = 'rotleft'; else $twist = 'rotright'; $ext = $phototypes[$rr['mimetype']]; - if(\App::get_template_engine() === 'internal') { - $alt_e = template_escape($rr['filename']); - $name_e = template_escape($rr['album']); - } - else { - $alt_e = $rr['filename']; - $name_e = $rr['album']; - } - - - + $alt_e = $rr['filename']; + $name_e = dirname($rr['display_path']); $photos[] = array( 'id' => $rr['id'], @@ -1291,9 +1291,7 @@ class Photos extends \Zotlabs\Web\Controller { 'src' => z_root() . '/photo/' . $rr['resource_id'] . '-' . ((($rr['imgscale']) == 6) ? 4 : $rr['imgscale']) . '.' . $ext, 'alt' => $alt_e, 'album' => array( - 'link' => z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . bin2hex($rr['album']), 'name' => $name_e, - 'alt' => t('View Album'), ), ); -- cgit v1.2.3 From c3c1572683be325a2cc8a357125cb98ebd68d11e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 22 Mar 2017 21:40:43 -0700 Subject: allow setting the system email name/address/reply --- Zotlabs/Module/Admin/Site.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php index b71e63030..d05e70aa9 100644 --- a/Zotlabs/Module/Admin/Site.php +++ b/Zotlabs/Module/Admin/Site.php @@ -48,6 +48,10 @@ class Site { $no_community_page = !((x($_POST,'no_community_page')) ? True : False); $default_expire_days = ((array_key_exists('default_expire_days',$_POST)) ? intval($_POST['default_expire_days']) : 0); + $reply_address = ((array_key_exists('reply_address',$_POST) && trim($_POST['reply_address'])) ? trim($_POST['reply_address']) : 'noreply@' . \App::get_hostname()); + $from_email = ((array_key_exists('from_email',$_POST) && trim($_POST['from_email'])) ? trim($_POST['from_email']) : 'Administrator@' . \App::get_hostname()); + $from_email_name = ((array_key_exists('from_email_name',$_POST) && trim($_POST['from_email_name'])) ? trim($_POST['from_email_name']) : \Zotlabs\Lib\System::get_site_name()); + $verifyssl = ((x($_POST,'verifyssl')) ? True : False); $proxyuser = ((x($_POST,'proxyuser')) ? notags(trim($_POST['proxyuser'])) : ''); $proxy = ((x($_POST,'proxy')) ? notags(trim($_POST['proxy'])) : ''); @@ -77,8 +81,15 @@ class Site { set_config('system', 'enable_context_help', $enable_context_help); set_config('system', 'verify_email', $verify_email); set_config('system', 'default_expire_days', $default_expire_days); + set_config('system', 'reply_address', $reply_address); + set_config('system', 'from_email', $from_email); + set_config('system', 'from_email_name' , $from_email_name); + + set_config('system', 'techlevel_lock', $techlevel_lock); + + if(! is_null($techlevel)) set_config('system', 'techlevel', $techlevel); @@ -304,6 +315,10 @@ class Site { '$login_on_homepage' => array('login_on_homepage', t("Login on Homepage"),((intval($homelogin) || $homelogin === false) ? 1 : '') , t("Present a login box to visitors on the home page if no other content has been configured.")), '$enable_context_help' => array('enable_context_help', t("Enable context help"),((intval($enable_context_help) === 1 || $enable_context_help === false) ? 1 : 0) , t("Display contextual help for the current page when the help button is pressed.")), + '$reply_address' => [ 'reply_address', t('Reply-to email address for system generated email.'), get_config('system','reply_address','noreply@' . \App::get_hostname()),'' ], + '$from_email' => [ 'from_email', t('Sender (From) email address for system generated email.'), get_config('system','from_email','Administrator@' . \App::get_hostname()),'' ], + '$from_email_name' => [ 'from_email_name', t('Name of email sender for system generated email.'), get_config('system','from_email_name',\Zotlabs\Lib\System::get_site_name()),'' ], + '$directory_server' => (($dir_choices) ? array('directory_server', t("Directory Server URL"), get_config('system','directory_server'), t("Default directory server"), $dir_choices) : null), '$proxyuser' => array('proxyuser', t("Proxy user"), get_config('system','proxyuser'), ""), -- cgit v1.2.3 From 878614f97a9f8dc5e9f8ad2b5b10a85003084938 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 25 Mar 2017 13:07:46 -0700 Subject: get rid of 'davguest' and allow for project specific DB updates (currently db updates are common between all possible projects/subprojects/forks). --- Zotlabs/Module/Cloud.php | 2 -- Zotlabs/Module/Filestorage.php | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Cloud.php b/Zotlabs/Module/Cloud.php index 2b6d7bcbe..7370eeda3 100644 --- a/Zotlabs/Module/Cloud.php +++ b/Zotlabs/Module/Cloud.php @@ -60,11 +60,9 @@ class Cloud extends \Zotlabs\Web\Controller { $_SERVER['QUERY_STRING'] = str_replace(array('?f=', '&f='), array('', ''), $_SERVER['QUERY_STRING']); $_SERVER['QUERY_STRING'] = strip_zids($_SERVER['QUERY_STRING']); - $_SERVER['QUERY_STRING'] = preg_replace('/[\?&]davguest=(.*?)([\?&]|$)/ism', '', $_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'] = preg_replace('/[\?&]davguest=(.*?)([\?&]|$)/ism', '', $_SERVER['REQUEST_URI']); $rootDirectory = new \Zotlabs\Storage\Directory('/', $auth); diff --git a/Zotlabs/Module/Filestorage.php b/Zotlabs/Module/Filestorage.php index 874445145..785dff394 100644 --- a/Zotlabs/Module/Filestorage.php +++ b/Zotlabs/Module/Filestorage.php @@ -130,7 +130,7 @@ class Filestorage extends \Zotlabs\Web\Controller { $f = $r[0]; $channel = \App::get_channel(); - $cloudpath = get_cloudpath($f) . (intval($f['is_dir']) ? '?f=&davguest=1' : ''); + $cloudpath = get_cloudpath($f); $parentpath = get_parent_cloudpath($channel['channel_id'], $channel['channel_address'], $f['hash']); $aclselect_e = populate_acl($f, false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_storage')); -- cgit v1.2.3 From c5828fecc1fadb4db705bbf94edfa7ff873b491a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 28 Mar 2017 16:02:47 -0700 Subject: get rid of get_app() --- Zotlabs/Module/Setup.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Setup.php b/Zotlabs/Module/Setup.php index e114dfc0b..d6d7eeb05 100644 --- a/Zotlabs/Module/Setup.php +++ b/Zotlabs/Module/Setup.php @@ -617,7 +617,6 @@ class Setup extends \Zotlabs\Web\Controller { * @param[out] array &$checks */ function check_htaccess(&$checks) { - $a = get_app(); $status = true; $help = ''; $ssl_error = false; @@ -711,7 +710,6 @@ class Setup extends \Zotlabs\Web\Controller { * @return string with parsed HTML */ function what_next() { - $a = get_app(); // install the standard theme set_config('system', 'allowed_themes', 'redbasic'); -- cgit v1.2.3 From 198d2ab607a609b5265dcbed5e41e62d431b19c2 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 29 Mar 2017 16:41:27 -0700 Subject: when clicking a notification to view a private mail message, actually view that message instead of the most recent. --- Zotlabs/Module/Mail.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index 459ce5acf..53303816b 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -296,6 +296,10 @@ class Mail extends \Zotlabs\Web\Controller { return $o; } + + $last_message = private_messages_list(local_channel(), $mailbox, 0, 1); + + $mid = ((argc() > 2) && (intval(argv(2)))) ? argv(2) : $last_message[0]['id']; switch(argv(1)) { case 'combined': @@ -309,12 +313,15 @@ class Mail extends \Zotlabs\Web\Controller { break; default: $mailbox = 'combined'; + + // notifications direct to mail/nn + + if(intval(argv(1))) + $mid = intval(argv(1)); break; } - $last_message = private_messages_list(local_channel(), $mailbox, 0, 1); - $mid = ((argc() > 2) && (intval(argv(2)))) ? argv(2) : $last_message[0]['id']; $plaintext = true; -- cgit v1.2.3 From b51ca4c8d3a36ed49582c4fe894944869b0d42a2 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 29 Mar 2017 17:42:31 -0700 Subject: circular logic - we need the mailbox to find the last message so move the code block back where it was, and only set a direct mid if one was specified. --- Zotlabs/Module/Mail.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index 53303816b..2fb89fed5 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -297,10 +297,8 @@ class Mail extends \Zotlabs\Web\Controller { return $o; } - $last_message = private_messages_list(local_channel(), $mailbox, 0, 1); + $direct_mid = 0; - $mid = ((argc() > 2) && (intval(argv(2)))) ? argv(2) : $last_message[0]['id']; - switch(argv(1)) { case 'combined': $mailbox = 'combined'; @@ -317,10 +315,17 @@ class Mail extends \Zotlabs\Web\Controller { // notifications direct to mail/nn if(intval(argv(1))) - $mid = intval(argv(1)); + $direct_mid = intval(argv(1)); break; } + + $last_message = private_messages_list(local_channel(), $mailbox, 0, 1); + + $mid = ((argc() > 2) && (intval(argv(2)))) ? argv(2) : $last_message[0]['id']; + + if($direct_mid) + $mid = $direct_mid; $plaintext = true; -- cgit v1.2.3 From f25f5aeaaae106cc995fb3d42393fbe5813e8760 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 2 Apr 2017 20:35:45 -0700 Subject: fix connectDefaultShare generated js function, though it isn't obvious if we still use it. --- Zotlabs/Module/Connedit.php | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php index 72bd3e86e..484e69b52 100644 --- a/Zotlabs/Module/Connedit.php +++ b/Zotlabs/Module/Connedit.php @@ -388,30 +388,22 @@ class Connedit extends \Zotlabs\Web\Controller { $section = ((array_key_exists('section',$_REQUEST)) ? $_REQUEST['section'] : ''); $channel = \App::get_channel(); - $my_perms = get_channel_default_perms(local_channel()); - $role = get_pconfig(local_channel(),'system','permissions_role'); - if($role) { - $x = \Zotlabs\Access\PermissionRoles::role_perms($role); - if($x['perms_connect']) - $my_perms = $x['perms_connect']; - } $yes_no = array(t('No'),t('Yes')); - if($my_perms) { - $o .= "\n"; } + $o .= " }\n\n"; if(argc() == 3) { -- cgit v1.2.3 From 940534e3031d8f57784d47f9c7c6d7e80a256dd4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 11 Apr 2017 22:02:29 -0700 Subject: webfinger cleanup --- Zotlabs/Module/Wfinger.php | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Wfinger.php b/Zotlabs/Module/Wfinger.php index 04eed47c3..5c22772c4 100644 --- a/Zotlabs/Module/Wfinger.php +++ b/Zotlabs/Module/Wfinger.php @@ -38,6 +38,9 @@ class Wfinger extends \Zotlabs\Web\Controller { $channel = str_replace('acct:','',$resource); if(strpos($channel,'@') !== false) { $host = substr($channel,strpos($channel,'@')+1); + + // If the webfinger address points off site, redirect to the correct site + if(strcasecmp($host,\App::get_hostname())) { goaway('https://' . $host . '/.well-known/webfinger?f=&resource=' . $resource . (($zot) ? '&zot=' . $zot : '')); } @@ -77,54 +80,54 @@ class Wfinger extends \Zotlabs\Web\Controller { } } - $result['aliases'] = array(); + $result['aliases'] = []; - $result['properties'] = array( - 'http://webfinger.net/ns/name' => $r[0]['channel_name'], + $result['properties'] = [ + 'http://webfinger.net/ns/name' => $r[0]['channel_name'], 'http://xmlns.com/foaf/0.1/name' => $r[0]['channel_name'] - ); + ]; foreach($aliases as $alias) if($alias != $resource) $result['aliases'][] = $alias; - $result['links'] = array( + $result['links'] = [ - array( + [ 'rel' => 'http://webfinger.net/rel/avatar', 'type' => $r[0]['xchan_photo_mimetype'], 'href' => $r[0]['xchan_photo_l'] - ), + ], - array( + [ 'rel' => 'http://webfinger.net/rel/profile-page', 'href' => z_root() . '/profile/' . $r[0]['channel_address'], - ), + ], - array( + [ 'rel' => 'http://webfinger.net/rel/blog', 'href' => z_root() . '/channel/' . $r[0]['channel_address'], - ), + ], - array( + [ 'rel' => 'http://ostatus.org/schema/1.0/subscribe', 'template' => z_root() . '/follow/url={uri}', - ), + ], - array( + [ 'rel' => 'http://purl.org/zot/protocol', 'href' => z_root() . '/.well-known/zot-info' . '?address=' . $r[0]['xchan_addr'], - ), + ], - array( + [ 'rel' => 'magic-public-key', 'href' => 'data:application/magic-public-key,' . salmon_key($r[0]['channel_pubkey']), - ) - ); + ] + ]; if($zot) { // get a zotinfo packet and return it with webfinger - $result['zot'] = zotinfo(array('address' => $r[0]['xchan_addr'])); + $result['zot'] = zotinfo( [ 'address' => $r[0]['xchan_addr'] ]); } } else { @@ -132,7 +135,7 @@ class Wfinger extends \Zotlabs\Web\Controller { killme(); } - $arr = array('channel' => $r[0], 'request' => $_REQUEST, 'result' => $result); + $arr = [ 'channel' => $r[0], 'request' => $_REQUEST, 'result' => $result ]; call_hooks('webfinger',$arr); json_return_and_die($arr['result'],'application/jrd+json'); -- cgit v1.2.3 From e3dc242a3c86482e2516e21d74f1fd6f5d25e6e9 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 17 Apr 2017 20:45:53 -0700 Subject: allow downloading via viewsrc to support client side e2ee --- Zotlabs/Module/Viewsrc.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Viewsrc.php b/Zotlabs/Module/Viewsrc.php index cb305efc6..f84eddc69 100644 --- a/Zotlabs/Module/Viewsrc.php +++ b/Zotlabs/Module/Viewsrc.php @@ -13,6 +13,7 @@ class Viewsrc extends \Zotlabs\Web\Controller { $item_id = ((argc() > 1) ? intval(argv(1)) : 0); $json = ((argc() > 2 && argv(2) === 'json') ? true : false); + $dload = ((argc() > 2 && argv(2) === 'download') ? true : false); if(! local_channel()) { notice( t('Permission denied.') . EOL); @@ -27,7 +28,7 @@ class Viewsrc extends \Zotlabs\Web\Controller { $item_normal = item_normal(); if(local_channel() && $item_id) { - $r = q("select id, item_flags, item_obscured, body from item where uid in (%d , %d) and id = %d $item_normal limit 1", + $r = q("select id, item_flags, mimetype, item_obscured, body from item where uid in (%d , %d) and id = %d $item_normal limit 1", intval(local_channel()), intval($sys['channel_id']), intval($item_id) @@ -37,6 +38,14 @@ class Viewsrc extends \Zotlabs\Web\Controller { if(intval($r[0]['item_obscured'])) $r[0]['body'] = crypto_unencapsulate(json_decode($r[0]['body'],true),get_config('system','prvkey')); + if($dload) { + header('Content-type: ' . $r[0]['mimetype']); + header('Content-disposition: attachment; filename="' . t('item') . '-' . $item_id . '"' ); + echo $r[0]['body']; + killme(); + } + + $content = escape_tags($r[0]['body']); $o = (($json) ? json_encode($content) : str_replace("\n",'
',$content)); } -- cgit v1.2.3 From 2d90b831f0af1c276cc590a5fcec427de3eb32f8 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 20 Apr 2017 19:52:50 -0700 Subject: In the rare case where a default channel is not selected but channels actually exist, you should be able to visit /manage and set a default channel. Originally I believe this may have been possible but the ability was lost when delegation was added to the interface - which requires an active channel. Remove the active channel restriction so that the rest of the interface works (channel selections can be made and the ability to set a default is provided) however delegation info isn't presented unless there is an active channel. --- Zotlabs/Module/Manage.php | 160 ++++++++++++++++++++++++---------------------- 1 file changed, 82 insertions(+), 78 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Manage.php b/Zotlabs/Module/Manage.php index 3b7b3c3dd..e541ee077 100644 --- a/Zotlabs/Module/Manage.php +++ b/Zotlabs/Module/Manage.php @@ -46,107 +46,111 @@ class Manage extends \Zotlabs\Web\Controller { $channels = null; - if(local_channel()) { - $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel.channel_account_id = %d and channel_removed = 0 order by channel_name ", - intval(get_account_id()) - ); + $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel.channel_account_id = %d and channel_removed = 0 order by channel_name ", + intval(get_account_id()) + ); - $account = \App::get_account(); + $account = \App::get_account(); - if($r && count($r)) { - $channels = $r; - for($x = 0; $x < count($channels); $x ++) { - $channels[$x]['link'] = 'manage/' . intval($channels[$x]['channel_id']); - $channels[$x]['default'] = (($channels[$x]['channel_id'] == $account['account_default_channel']) ? "1" : ''); - $channels[$x]['default_links'] = '1'; + if($r && count($r)) { + $channels = $r; + for($x = 0; $x < count($channels); $x ++) { + $channels[$x]['link'] = 'manage/' . intval($channels[$x]['channel_id']); + $channels[$x]['default'] = (($channels[$x]['channel_id'] == $account['account_default_channel']) ? "1" : ''); + $channels[$x]['default_links'] = '1'; - $c = q("SELECT id, item_wall FROM item - WHERE item_unseen = 1 and uid = %d " . item_normal(), - intval($channels[$x]['channel_id']) - ); + $c = q("SELECT id, item_wall FROM item + WHERE item_unseen = 1 and uid = %d " . item_normal(), + intval($channels[$x]['channel_id']) + ); - if($c) { - foreach ($c as $it) { - if(intval($it['item_wall'])) - $channels[$x]['home'] ++; - else - $channels[$x]['network'] ++; - } + if($c) { + foreach ($c as $it) { + if(intval($it['item_wall'])) + $channels[$x]['home'] ++; + else + $channels[$x]['network'] ++; } + } - $intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ", - intval($channels[$x]['channel_id']) - ); + $intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ", + intval($channels[$x]['channel_id']) + ); - if($intr) - $channels[$x]['intros'] = intval($intr[0]['total']); + if($intr) + $channels[$x]['intros'] = intval($intr[0]['total']); - $mails = q("SELECT count(id) as total from mail WHERE channel_id = %d AND mail_seen = 0 and from_xchan != '%s' ", - intval($channels[$x]['channel_id']), - dbesc($channels[$x]['channel_hash']) - ); + $mails = q("SELECT count(id) as total from mail WHERE channel_id = %d AND mail_seen = 0 and from_xchan != '%s' ", + intval($channels[$x]['channel_id']), + dbesc($channels[$x]['channel_hash']) + ); - if($mails) - $channels[$x]['mail'] = intval($mails[0]['total']); + if($mails) + $channels[$x]['mail'] = intval($mails[0]['total']); - $events = q("SELECT etype, dtstart, adjust FROM event - WHERE event.uid = %d AND dtstart < '%s' AND dtstart > '%s' and dismissed = 0 - ORDER BY dtstart ASC ", - intval($channels[$x]['channel_id']), - dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + 7 days')), - dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) - ); - - if($events) { - $channels[$x]['all_events'] = count($events); - - if($channels[$x]['all_events']) { - $str_now = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d'); - foreach($events as $e) { - $bd = false; - if($e['etype'] === 'birthday') { - $channels[$x]['birthdays'] ++; - $bd = true; - } - else { - $channels[$x]['events'] ++; - } - if(datetime_convert('UTC', ((intval($e['adjust'])) ? date_default_timezone_get() : 'UTC'), $e['dtstart'], 'Y-m-d') === $str_now) { - $channels[$x]['all_events_today'] ++; - if($bd) - $channels[$x]['birthdays_today'] ++; - else - $channels[$x]['events_today'] ++; - } + $events = q("SELECT etype, dtstart, adjust FROM event + WHERE event.uid = %d AND dtstart < '%s' AND dtstart > '%s' and dismissed = 0 + ORDER BY dtstart ASC ", + intval($channels[$x]['channel_id']), + dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + 7 days')), + dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) + ); + + if($events) { + $channels[$x]['all_events'] = count($events); + + if($channels[$x]['all_events']) { + $str_now = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d'); + foreach($events as $e) { + $bd = false; + if($e['etype'] === 'birthday') { + $channels[$x]['birthdays'] ++; + $bd = true; + } + else { + $channels[$x]['events'] ++; + } + if(datetime_convert('UTC', ((intval($e['adjust'])) ? date_default_timezone_get() : 'UTC'), $e['dtstart'], 'Y-m-d') === $str_now) { + $channels[$x]['all_events_today'] ++; + if($bd) + $channels[$x]['birthdays_today'] ++; + else + $channels[$x]['events_today'] ++; } } } } } - - $r = q("select count(channel_id) as total from channel where channel_account_id = %d and channel_removed = 0", - intval(get_account_id()) - ); - $limit = account_service_class_fetch(get_account_id(),'total_identities'); - if($limit !== false) { - $channel_usage_message = sprintf( t("You have created %1$.0f of %2$.0f allowed channels."), $r[0]['total'], $limit); - } - else { - $channel_usage_message = ''; - } + + } + + $r = q("select count(channel_id) as total from channel where channel_account_id = %d and channel_removed = 0", + intval(get_account_id()) + ); + $limit = account_service_class_fetch(get_account_id(),'total_identities'); + if($limit !== false) { + $channel_usage_message = sprintf( t("You have created %1$.0f of %2$.0f allowed channels."), $r[0]['total'], $limit); } + else { + $channel_usage_message = ''; + } + $create = array( 'new_channel', t('Create a new channel'), t('Create New')); - $delegates = q("select * from abook left join xchan on abook_xchan = xchan_hash where - abook_channel = %d and abook_xchan in ( select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'delegate' and v = '1' )", - intval(local_channel()), - intval(local_channel()) - ); + $delegates = null; + + if(local_channel()) { + $delegates = q("select * from abook left join xchan on abook_xchan = xchan_hash where + abook_channel = %d and abook_xchan in ( select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'delegate' and v = '1' )", + intval(local_channel()), + intval(local_channel()) + ); + } if($delegates) { for($x = 0; $x < count($delegates); $x ++) { -- cgit v1.2.3 From 94f15e355166f0abd3698414948abff2397a7ad0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 20 Apr 2017 20:19:15 -0700 Subject: The rest of the library and backend changes to support client-side e2ee and deprecate previous uses of item_obscured. --- Zotlabs/Module/Editpost.php | 13 ++++--------- Zotlabs/Module/Editwebpage.php | 13 ++++--------- Zotlabs/Module/Item.php | 1 + Zotlabs/Module/Viewsrc.php | 2 +- 4 files changed, 10 insertions(+), 19 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Editpost.php b/Zotlabs/Module/Editpost.php index d7612b165..629bdd3fd 100644 --- a/Zotlabs/Module/Editpost.php +++ b/Zotlabs/Module/Editpost.php @@ -31,7 +31,10 @@ class Editpost extends \Zotlabs\Web\Controller { dbesc(get_observer_hash()) ); - if(! count($itm)) { + // don't allow web editing of potentially binary content (item_obscured = 1) + // @FIXME how do we do it instead? + + if((! $itm) || intval($itm[0]['item_obscured'])) { notice( t('Item is not editable') . EOL); return; } @@ -44,14 +47,6 @@ class Editpost extends \Zotlabs\Web\Controller { $channel = \App::get_channel(); - if(intval($itm[0]['item_obscured'])) { - $key = get_config('system','prvkey'); - if($itm[0]['title']) - $itm[0]['title'] = crypto_unencapsulate(json_decode($itm[0]['title'],true),$key); - if($itm[0]['body']) - $itm[0]['body'] = crypto_unencapsulate(json_decode($itm[0]['body'],true),$key); - } - $category = ''; $catsenabled = ((feature_enabled($owner_uid,'categories')) ? 'categories' : ''); diff --git a/Zotlabs/Module/Editwebpage.php b/Zotlabs/Module/Editwebpage.php index 03b2aeab9..db33cd1db 100644 --- a/Zotlabs/Module/Editwebpage.php +++ b/Zotlabs/Module/Editwebpage.php @@ -100,19 +100,14 @@ class Editwebpage extends \Zotlabs\Web\Controller { intval($owner) ); - if(! $itm) { + // don't allow web editing of potentially binary content (item_obscured = 1) + // @FIXME how do we do it instead? + + if((! $itm) || intval($itm[0]['item_obscured'])) { notice( t('Permission denied.') . EOL); return; } - if(intval($itm[0]['item_obscured'])) { - $key = get_config('system','prvkey'); - if($itm[0]['title']) - $itm[0]['title'] = crypto_unencapsulate(json_decode($itm[0]['title'],true),$key); - if($itm[0]['body']) - $itm[0]['body'] = crypto_unencapsulate(json_decode($itm[0]['body'],true),$key); - } - $item_id = q("select * from iconfig where cat = 'system' and k = 'WEBPAGE' and iid = %d limit 1", intval($itm[0]['id']) ); diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 71f410b2a..9fddafee6 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -110,6 +110,7 @@ class Item extends \Zotlabs\Web\Controller { $preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0); $categories = ((x($_REQUEST,'category')) ? escape_tags($_REQUEST['category']) : ''); $webpage = ((x($_REQUEST,'webpage')) ? intval($_REQUEST['webpage']) : 0); + $item_obscured = ((x($_REQUEST,'obscured')) ? intval($_REQUEST['obscured']) : 0); $pagetitle = ((x($_REQUEST,'pagetitle')) ? escape_tags(urlencode($_REQUEST['pagetitle'])) : ''); $layout_mid = ((x($_REQUEST,'layout_mid')) ? escape_tags($_REQUEST['layout_mid']): ''); $plink = ((x($_REQUEST,'permalink')) ? escape_tags($_REQUEST['permalink']) : ''); diff --git a/Zotlabs/Module/Viewsrc.php b/Zotlabs/Module/Viewsrc.php index f84eddc69..54ab89e81 100644 --- a/Zotlabs/Module/Viewsrc.php +++ b/Zotlabs/Module/Viewsrc.php @@ -36,7 +36,7 @@ class Viewsrc extends \Zotlabs\Web\Controller { if($r) { if(intval($r[0]['item_obscured'])) - $r[0]['body'] = crypto_unencapsulate(json_decode($r[0]['body'],true),get_config('system','prvkey')); + $dload = true; if($dload) { header('Content-type: ' . $r[0]['mimetype']); -- cgit v1.2.3 From b88be137ca68c6b52e13ce1738fbc55651f37138 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 25 Apr 2017 20:48:38 -0700 Subject: provide a broken feed for services which require a broken feed --- Zotlabs/Module/Feed.php | 49 +++++++++++++++++++++++----------------------- Zotlabs/Module/Wfinger.php | 18 +++++++++++------ Zotlabs/Module/Xrd.php | 2 +- 3 files changed, 37 insertions(+), 32 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Feed.php b/Zotlabs/Module/Feed.php index 47871eafb..06637b6d2 100644 --- a/Zotlabs/Module/Feed.php +++ b/Zotlabs/Module/Feed.php @@ -1,40 +1,41 @@ 1) { - $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_address = '%s' limit 1", - dbesc(argv(1)) - ); - if(!($r && count($r))) + + if(observer_prohibited(true)) { killme(); - - $channel = $r[0]; - - if(observer_prohibited(true)) + } + + $channel = channelx_by_nick(argv(1)); + if(! $channel) { killme(); + } + - logger('mod_feed: public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $channel['channel_address']); + logger('public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $channel['channel_address']); echo get_public_feed($channel,$params); @@ -43,6 +44,4 @@ class Feed extends \Zotlabs\Web\Controller { } - - } diff --git a/Zotlabs/Module/Wfinger.php b/Zotlabs/Module/Wfinger.php index 5c22772c4..3fdff691b 100644 --- a/Zotlabs/Module/Wfinger.php +++ b/Zotlabs/Module/Wfinger.php @@ -94,33 +94,39 @@ class Wfinger extends \Zotlabs\Web\Controller { $result['links'] = [ [ - 'rel' => 'http://webfinger.net/rel/avatar', + 'rel' => 'http://webfinger.net/rel/avatar', 'type' => $r[0]['xchan_photo_mimetype'], 'href' => $r[0]['xchan_photo_l'] ], [ - 'rel' => 'http://webfinger.net/rel/profile-page', + 'rel' => 'http://webfinger.net/rel/profile-page', 'href' => z_root() . '/profile/' . $r[0]['channel_address'], ], [ - 'rel' => 'http://webfinger.net/rel/blog', + 'rel' => 'http://schemas.google.com/g/2010#updates-from', + 'type' => 'application/atom+xml', + 'href' => z_root() . '/feed/' . $r[0]['channel_address'] . '?f=&compat=1' + ], + + [ + 'rel' => 'http://webfinger.net/rel/blog', 'href' => z_root() . '/channel/' . $r[0]['channel_address'], ], [ - 'rel' => 'http://ostatus.org/schema/1.0/subscribe', + 'rel' => 'http://ostatus.org/schema/1.0/subscribe', 'template' => z_root() . '/follow/url={uri}', ], [ - 'rel' => 'http://purl.org/zot/protocol', + 'rel' => 'http://purl.org/zot/protocol', 'href' => z_root() . '/.well-known/zot-info' . '?address=' . $r[0]['xchan_addr'], ], [ - 'rel' => 'magic-public-key', + 'rel' => 'magic-public-key', 'href' => 'data:application/magic-public-key,' . salmon_key($r[0]['channel_pubkey']), ] ]; diff --git a/Zotlabs/Module/Xrd.php b/Zotlabs/Module/Xrd.php index 3ed19962b..ba650be55 100644 --- a/Zotlabs/Module/Xrd.php +++ b/Zotlabs/Module/Xrd.php @@ -57,7 +57,7 @@ class Xrd extends \Zotlabs\Web\Controller { '$aliases' => $aliases, '$profile_url' => z_root() . '/channel/' . $r[0]['channel_address'], '$hcard_url' => z_root() . '/hcard/' . $r[0]['channel_address'], - '$atom' => z_root() . '/feed/' . $r[0]['channel_address'], + '$atom' => z_root() . '/feed/' . $r[0]['channel_address'] . '?f=&compat=1', '$zot_post' => z_root() . '/post/' . $r[0]['channel_address'], '$poco_url' => z_root() . '/poco/' . $r[0]['channel_address'], '$photo' => z_root() . '/photo/profile/l/' . $r[0]['channel_id'], -- cgit v1.2.3 From ac670856f67d5ff2b6a61e76103e331039dbf6b1 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 26 Apr 2017 13:26:50 -0700 Subject: provide a broken feed as a separate module --- Zotlabs/Module/Ofeed.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++ Zotlabs/Module/Wfinger.php | 2 +- Zotlabs/Module/Xrd.php | 2 +- 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 Zotlabs/Module/Ofeed.php (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Ofeed.php b/Zotlabs/Module/Ofeed.php new file mode 100644 index 000000000..2b7acff99 --- /dev/null +++ b/Zotlabs/Module/Ofeed.php @@ -0,0 +1,48 @@ + 1) { + + if(observer_prohibited(true)) { + killme(); + } + + $channel = channelx_by_nick(argv(1)); + if(! $channel) { + killme(); + } + + + logger('public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $channel['channel_address']); + + echo get_public_feed($channel,$params); + + killme(); + } + + } + +} diff --git a/Zotlabs/Module/Wfinger.php b/Zotlabs/Module/Wfinger.php index 118ec5e7c..9623a676b 100644 --- a/Zotlabs/Module/Wfinger.php +++ b/Zotlabs/Module/Wfinger.php @@ -107,7 +107,7 @@ class Wfinger extends \Zotlabs\Web\Controller { [ 'rel' => 'http://schemas.google.com/g/2010#updates-from', 'type' => 'application/atom+xml', - 'href' => z_root() . '/feed/' . $r[0]['channel_address'] . '/?compat=1' + 'href' => z_root() . '/ofeed/' . $r[0]['channel_address'] ], [ diff --git a/Zotlabs/Module/Xrd.php b/Zotlabs/Module/Xrd.php index 7fd81e490..7b36576e0 100644 --- a/Zotlabs/Module/Xrd.php +++ b/Zotlabs/Module/Xrd.php @@ -57,7 +57,7 @@ class Xrd extends \Zotlabs\Web\Controller { '$aliases' => $aliases, '$profile_url' => z_root() . '/channel/' . $r[0]['channel_address'], '$hcard_url' => z_root() . '/hcard/' . $r[0]['channel_address'], - '$atom' => z_root() . '/feed/' . $r[0]['channel_address'] . '/?compat=1', + '$atom' => z_root() . '/ofeed/' . $r[0]['channel_address'], '$zot_post' => z_root() . '/post/' . $r[0]['channel_address'], '$poco_url' => z_root() . '/poco/' . $r[0]['channel_address'], '$photo' => z_root() . '/photo/profile/l/' . $r[0]['channel_id'], -- cgit v1.2.3 From e8ea8d203db5bdf62995f1831b1503ac11556435 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 26 Apr 2017 23:05:30 -0700 Subject: more client-side mail privacy work --- Zotlabs/Module/Mail.php | 74 +++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 46 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index 52f1ddf32..a240ccdae 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -22,32 +22,40 @@ class Mail extends \Zotlabs\Web\Controller { $recipient = ((x($_REQUEST,'messageto')) ? notags(trim($_REQUEST['messageto'])) : ''); $rstr = ((x($_REQUEST,'messagerecip')) ? notags(trim($_REQUEST['messagerecip'])) : ''); $preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0); - $expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE); + $expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE); + $raw = ((x($_REQUEST,'raw')) ? intval($_REQUEST['raw']) : 0); + $mimetype = ((x($_REQUEST,'mimetype')) ? notags(trim($_REQUEST['mimetype'])) : 'text/bbcode'); if($preview) { - $body = cleanup_bbcode($body); - $results = linkify_tags($a, $body, local_channel()); + if($raw) { + $body = mail_prepare_binary(['id' => 'M0']); + echo json_encode(['preview' => $body]); + } + else { + $body = cleanup_bbcode($body); + $results = linkify_tags($a, $body, local_channel()); - if(preg_match_all('/(\[attachment\](.*?)\[\/attachment\])/',$body,$match)) { - $attachments = array(); - foreach($match[2] as $mtch) { - $hash = substr($mtch,0,strpos($mtch,',')); - $rev = intval(substr($mtch,strpos($mtch,','))); - $r = attach_by_hash_nodata($hash,get_observer_hash(),$rev); - if($r['success']) { - $attachments[] = array( - 'href' => z_root() . '/attach/' . $r['data']['hash'], - 'length' => $r['data']['filesize'], - 'type' => $r['data']['filetype'], - 'title' => urlencode($r['data']['filename']), - 'revision' => $r['data']['revision'] - ); + if(preg_match_all('/(\[attachment\](.*?)\[\/attachment\])/',$body,$match)) { + $attachments = array(); + foreach($match[2] as $mtch) { + $hash = substr($mtch,0,strpos($mtch,',')); + $rev = intval(substr($mtch,strpos($mtch,','))); + $r = attach_by_hash_nodata($hash,get_observer_hash(),$rev); + if($r['success']) { + $attachments[] = array( + 'href' => z_root() . '/attach/' . $r['data']['hash'], + 'length' => $r['data']['filesize'], + 'type' => $r['data']['filetype'], + 'title' => urlencode($r['data']['filename']), + 'revision' => $r['data']['revision'] + ); + } + $body = trim(str_replace($match[1],'',$body)); } - $body = trim(str_replace($match[1],'',$body)); + echo json_encode(['preview' => zidify_links(smilies(bbcode($body)))]); } } - echo json_encode(['preview' => zidify_links(smilies(bbcode($body)))]); killme(); } @@ -102,36 +110,10 @@ class Mail extends \Zotlabs\Web\Controller { } } - // if(feature_enabled(local_channel(),'richtext')) { - // $body = fix_mce_lf($body); - // } - require_once('include/text.php'); linkify_tags($a, $body, local_channel()); - // I don't think this is used any more. - - if($preview) { - $mail = [ - 'mailbox' => 'outbox', - 'id' => 0, - 'mid' => 'M0', - 'from_name' => $channel['xchan_name'], - 'from_url' => $channel['xchan_url'], - 'from_photo' => $channel['xchan_photo_s'], - 'subject' => zidify_links(smilies(bbcode($subject))), - 'body' => zidify_links(smilies(bbcode($body))), - 'attachments' => '', - 'can_recall' => false, - 'is_recalled' => '', - 'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'], 'c') - ]; - - echo replace_macros(get_markup_template('mail_conv.tpl'), [ '$mail' => $mail ] ); - killme(); - } - if(! $recipient) { notice('No recipient found.'); \App::$argc = 2; @@ -141,7 +123,7 @@ class Mail extends \Zotlabs\Web\Controller { // We have a local_channel, let send_message use the session channel and save a lookup - $ret = send_message(0, $recipient, $body, $subject, $replyto, $expires); + $ret = send_message(0, $recipient, $body, $subject, $replyto, $expires, $mimetype, $raw); if($ret['success']) { xchan_mail_query($ret['mail']); -- cgit v1.2.3 From 230617208ba4ba81a7c9a289ba44da7319500397 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 29 Apr 2017 16:30:11 -0700 Subject: more work on client side e2ee --- Zotlabs/Module/Mail.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index a240ccdae..f6add7778 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -160,6 +160,25 @@ class Mail extends \Zotlabs\Web\Controller { '$header' => t('Messages'), )); + if(argc() == 3 && intval(argv(1)) && argv(2) === 'download') { + + $r = q("select * from mail where id = %d and channel_id = %d", + intval(argv(1)), + intval(local_channel()) + ); + + if($r) { + + header('Content-type: ' . $r[0]['mail_mimetype']); + header('Content-disposition: attachment; filename="' . t('message') . '-' . $r[0]['id'] . '"' ); + $body = (($r[0]['mail_obscured']) ? base64url_decode(str_rot47($r[0]['body'])) : $r[0]['body']); + echo $body; + killme(); + } + + } + + if((argc() == 4) && (argv(2) === 'drop')) { if(! intval(argv(3))) return; @@ -352,6 +371,11 @@ class Mail extends \Zotlabs\Web\Controller { foreach($messages as $message) { $s = theme_attachments($message); + + if($message['mail_raw']) + $message['body'] = mail_prepare_binary([ 'id' => $message['id'] ]); + else + $message['body'] = zidify_links(smilies(bbcode($message['body']))); $mails[] = array( 'mailbox' => $mailbox, @@ -364,7 +388,7 @@ class Mail extends \Zotlabs\Web\Controller { 'to_url' => chanlink_hash($message['to_xchan']), 'to_photo' => $message['to']['xchan_photo_s'], 'subject' => $message['title'], - 'body' => zidify_links(smilies(bbcode($message['body']))), + 'body' => $message['body'], 'attachments' => $s, 'delete' => t('Delete message'), 'dreport' => t('Delivery report'), -- cgit v1.2.3 From 968209471ef807ed8d89ecc8cc2f0e3425509a19 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 30 Apr 2017 18:24:48 -0700 Subject: authenticate onepoll so we can receive private posts/comments in zotfeed; if local server bypass the network access and invoke zotfeed directly. --- Zotlabs/Module/Zotfeed.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Zotfeed.php b/Zotlabs/Module/Zotfeed.php index 6b505c890..381e3acb2 100644 --- a/Zotlabs/Module/Zotfeed.php +++ b/Zotlabs/Module/Zotfeed.php @@ -22,7 +22,8 @@ class Zotfeed extends \Zotlabs\Web\Controller { $observer = \App::get_observer(); - + logger('observer: ' . get_observer_hash(), LOGGER_DEBUG); + $channel_address = ((argc() > 1) ? argv(1) : ''); if($channel_address) { $r = q("select channel_id, channel_name from channel where channel_address = '%s' and channel_removed = 0 limit 1", -- cgit v1.2.3 From 519aef7ff52013170b08eb89c0a95072fe8047e1 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 3 May 2017 18:50:32 -0700 Subject: abook_not_here flag created to indicate singleton connections which are connected to this channel but not on this hub. abook_instance enumerates which hubs the connections is valid, but we ultimately need something more efficiently searchable to decide what operations are supported w/r/t this connection in the context of this hub. This flag is ignored during sync to clones although the code to set it correctly during channel creation, import, and sync has not yet been implemented. --- Zotlabs/Module/Import.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index 54bc7de81..ce3fd469a 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -318,6 +318,7 @@ class Import extends \Zotlabs\Web\Controller { unset($abook['abconfig']); unset($abook['abook_their_perms']); unset($abook['abook_my_perms']); + unset($abook['abook_not_here']); $abook['abook_account'] = $account_id; $abook['abook_channel'] = $channel['channel_id']; @@ -347,7 +348,7 @@ class Import extends \Zotlabs\Web\Controller { continue; } - create_table_from_array('abook',$abook); + abook_store_lowlevel($abook); $friends ++; if(intval($abook['abook_feed'])) -- cgit v1.2.3 From b08af13872a698c85bb2cf9abd6651bc5c98f7bd Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 3 May 2017 22:37:06 -0700 Subject: oauth2/oidc testing (please do not port - this requires several extra DB tables to work) --- Zotlabs/Module/Authorize.php | 71 ++++++++++++++++++++++++++++++++++++++++++++ Zotlabs/Module/Token.php | 40 +++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 Zotlabs/Module/Authorize.php create mode 100644 Zotlabs/Module/Token.php (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Authorize.php b/Zotlabs/Module/Authorize.php new file mode 100644 index 000000000..06f66c456 --- /dev/null +++ b/Zotlabs/Module/Authorize.php @@ -0,0 +1,71 @@ +validateAuthorizeRequest($request, $response)) { + $response->send(); + killme(); + } + + // display an authorization form + if (empty($_POST)) { + + return ' +
+
+ + +
'; + } + + // print the authorization code if the user has authorized your client + $is_authorized = ($_POST['authorized'] === 'yes'); + $oauth2_server->handleAuthorizeRequest($request, $response, $is_authorized); + if ($is_authorized) { + // this is only here so that you get to see your code in the cURL request. Otherwise, + // we'd redirect back to the client + $code = substr($response->getHttpHeader('Location'), strpos($response->getHttpHeader('Location'), 'code=')+5, 40); + echo("SUCCESS! Authorization Code: $code"); + + } + + $response->send(); + killme(); + } + +} \ No newline at end of file diff --git a/Zotlabs/Module/Token.php b/Zotlabs/Module/Token.php new file mode 100644 index 000000000..e0d9d74d7 --- /dev/null +++ b/Zotlabs/Module/Token.php @@ -0,0 +1,40 @@ +handleTokenRequest(\OAuth2\Request::createFromGlobals())->send(); + + killme(); + } + +} \ No newline at end of file -- cgit v1.2.3 From 2c2ee706ac84926ceca21f5a4522034eb1b67d54 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 7 May 2017 14:40:11 -0700 Subject: get rid of edit activities --- Zotlabs/Module/Item.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 9fddafee6..ec36c22d8 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -860,7 +860,17 @@ class Item extends \Zotlabs\Web\Controller { $x = item_store_update($datarray,$execflag); - item_create_edit_activity($x); + // We only need edit activities for other federated protocols + // which do not support edits natively. While this does federate + // edits, it presents a number of issues locally - such as #757 and #758. + // The SQL check for an edit activity would not perform that well so to fix these issues + // requires an additional item flag (perhaps 'item_edit_activity') that we can add to the + // query for searches and notifications. + + // For now we'll just forget about trying to make edits work on network protocols that + // don't support them. + + // item_create_edit_activity($x); if(! $parent) { $r = q("select * from item where id = %d", -- cgit v1.2.3 From acb8e85b6108610f927811c52c9304b207963015 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 7 May 2017 17:25:38 -0700 Subject: cover photo was unintentionally disabled when block_public in effect --- Zotlabs/Module/Photo.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 256a51e71..dc4ae670e 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -127,7 +127,6 @@ class Photo extends \Zotlabs\Web\Controller { } } - $r = q("SELECT uid FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1", dbesc($photo), intval($resolution) @@ -150,12 +149,14 @@ class Photo extends \Zotlabs\Web\Controller { $channel = channelx_by_n($r[0]['uid']); // Now we'll see if we can access the photo - $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND imgscale = %d $sql_extra LIMIT 1", dbesc($photo), intval($resolution) ); - + + if($r && $r[0]['photo_usage'] == PHOTO_COVER) + $allowed = 1; + $d = [ 'imgscale' => $resolution, 'resource_id' => $photo, 'photo' => $r, 'allowed' => $allowed ]; call_hooks('get_photo',$d); -- cgit v1.2.3 From 1a05939e0bde75d251612c10e49aa7a3b61de64c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 7 May 2017 18:05:29 -0700 Subject: cleanup of last checkin --- Zotlabs/Module/Photo.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index dc4ae670e..8963480e6 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -154,10 +154,12 @@ class Photo extends \Zotlabs\Web\Controller { intval($resolution) ); - if($r && $r[0]['photo_usage'] == PHOTO_COVER) + // viewing cover photos is allowed unless a plugin chooses to block it. + + if($r && intval($r[0]['photo_usage']) === PHOTO_COVER && $resolution >= PHOTO_RES_COVER_1200) $allowed = 1; - $d = [ 'imgscale' => $resolution, 'resource_id' => $photo, 'photo' => $r, 'allowed' => $allowed ]; + $d = [ 'imgscale' => $resolution, 'resource_id' => $photo, 'photo' => $r[0], 'allowed' => $allowed ]; call_hooks('get_photo',$d); $resolution = $d['imgscale']; -- cgit v1.2.3 From 2e531c103f33e798d979bd9dcda168cc6cb5d3e0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 8 May 2017 02:00:00 -0700 Subject: error --- Zotlabs/Module/Photo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 8963480e6..8a110f925 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -159,7 +159,7 @@ class Photo extends \Zotlabs\Web\Controller { if($r && intval($r[0]['photo_usage']) === PHOTO_COVER && $resolution >= PHOTO_RES_COVER_1200) $allowed = 1; - $d = [ 'imgscale' => $resolution, 'resource_id' => $photo, 'photo' => $r[0], 'allowed' => $allowed ]; + $d = [ 'imgscale' => $resolution, 'resource_id' => $photo, 'photo' => $r, 'allowed' => $allowed ]; call_hooks('get_photo',$d); $resolution = $d['imgscale']; -- cgit v1.2.3 From a7ea370ec3c18b102a6a6a70b770adc16fdb0aa2 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 7 May 2017 17:25:38 -0700 Subject: cover photo was unintentionally disabled when block_public in effect --- Zotlabs/Module/Photo.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 256a51e71..dc4ae670e 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -127,7 +127,6 @@ class Photo extends \Zotlabs\Web\Controller { } } - $r = q("SELECT uid FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1", dbesc($photo), intval($resolution) @@ -150,12 +149,14 @@ class Photo extends \Zotlabs\Web\Controller { $channel = channelx_by_n($r[0]['uid']); // Now we'll see if we can access the photo - $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND imgscale = %d $sql_extra LIMIT 1", dbesc($photo), intval($resolution) ); - + + if($r && $r[0]['photo_usage'] == PHOTO_COVER) + $allowed = 1; + $d = [ 'imgscale' => $resolution, 'resource_id' => $photo, 'photo' => $r, 'allowed' => $allowed ]; call_hooks('get_photo',$d); -- cgit v1.2.3 From 40c8549cf5438aa12db68c6ec2c98493f6707bda Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 7 May 2017 14:40:11 -0700 Subject: get rid of edit activities --- Zotlabs/Module/Item.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 9fddafee6..ec36c22d8 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -860,7 +860,17 @@ class Item extends \Zotlabs\Web\Controller { $x = item_store_update($datarray,$execflag); - item_create_edit_activity($x); + // We only need edit activities for other federated protocols + // which do not support edits natively. While this does federate + // edits, it presents a number of issues locally - such as #757 and #758. + // The SQL check for an edit activity would not perform that well so to fix these issues + // requires an additional item flag (perhaps 'item_edit_activity') that we can add to the + // query for searches and notifications. + + // For now we'll just forget about trying to make edits work on network protocols that + // don't support them. + + // item_create_edit_activity($x); if(! $parent) { $r = q("select * from item where id = %d", -- cgit v1.2.3 From 1077686bdaacd12912ec325f69349cb333420069 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 10 May 2017 17:02:56 -0700 Subject: send directory realm_token for navbar autocomplete searches - if configured --- Zotlabs/Module/Acl.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php index c3c50cac2..83fafbdff 100644 --- a/Zotlabs/Module/Acl.php +++ b/Zotlabs/Module/Acl.php @@ -412,10 +412,12 @@ class Acl extends \Zotlabs\Web\Controller { $directory = find_upstream_directory($dirmode); $url = $directory['url'] . '/dirsearch'; } + + $token = get_config('system','realm_token'); $count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 100); if($url) { - $query = $url . '?f=' ; + $query = $url . '?f=' . (($token) ? '&t=' . urlencode($token) : ''); $query .= '&name=' . urlencode($search) . "&limit=$count" . (($address) ? '&address=' . urlencode($search) : ''); $x = z_fetch_url($query); -- cgit v1.2.3 From 1ebc9de1e6c7e242cfe6e39ab3c4b82d53e1539b Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 11 May 2017 13:31:36 +0200 Subject: Empty ACL should not result in no ACL when uploading a file --- Zotlabs/Module/File_upload.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/File_upload.php b/Zotlabs/Module/File_upload.php index 769134808..29a7bd137 100644 --- a/Zotlabs/Module/File_upload.php +++ b/Zotlabs/Module/File_upload.php @@ -28,11 +28,12 @@ class File_upload extends \Zotlabs\Web\Controller { $_REQUEST['group_deny'] = expand_acl($channel['channel_deny_gid']); } + $_REQUEST['allow_cid'] = perms2str($_REQUEST['contact_allow']); + $_REQUEST['allow_gid'] = perms2str($_REQUEST['group_allow']); + $_REQUEST['deny_cid'] = perms2str($_REQUEST['contact_deny']); + $_REQUEST['deny_gid'] = perms2str($_REQUEST['group_deny']); + if($_REQUEST['filename']) { - $_REQUEST['allow_cid'] = perms2str($_REQUEST['contact_allow']); - $_REQUEST['allow_gid'] = perms2str($_REQUEST['group_allow']); - $_REQUEST['deny_cid'] = perms2str($_REQUEST['contact_deny']); - $_REQUEST['deny_gid'] = perms2str($_REQUEST['group_deny']); $r = attach_mkdir($channel,get_observer_hash(),$_REQUEST); } else { -- cgit v1.2.3 From e501289a5544823eed3834a831770c07159664ff Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 11 May 2017 17:39:26 -0700 Subject: consolidate and simplify the generation of activitystreams persons, add a couple more fields hoping eventually Mastodon will accept legal follow activities without choking on them. Requires an update of plugins also. --- Zotlabs/Module/Profile_photo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Profile_photo.php b/Zotlabs/Module/Profile_photo.php index e8f0e5186..47b627015 100644 --- a/Zotlabs/Module/Profile_photo.php +++ b/Zotlabs/Module/Profile_photo.php @@ -190,7 +190,7 @@ class Profile_photo extends \Zotlabs\Web\Controller { build_sync_packet($channel['channel_id'],array('file' => array($sync))); - // Similarly, tell the nav bar to bypass the cache and update the avater image. + // Similarly, tell the nav bar to bypass the cache and update the avatar image. $_SESSION['reload_avatar'] = true; info( t('Shift-reload the page or clear browser cache if the new photo does not display immediately.') . EOL); -- cgit v1.2.3 From 1de1b58a087afbadb55b7f18b93fb0b502a2de3a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 11 May 2017 19:01:04 -0700 Subject: consolidate email validation checks --- Zotlabs/Module/Invite.php | 2 +- Zotlabs/Module/Settings/Account.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Invite.php b/Zotlabs/Module/Invite.php index 6b6f80a31..927e7beae 100644 --- a/Zotlabs/Module/Invite.php +++ b/Zotlabs/Module/Invite.php @@ -49,7 +49,7 @@ class Invite extends \Zotlabs\Web\Controller { if(! $recip) continue; - if(! valid_email($recip)) { + if(! validate_email($recip)) { notice( sprintf( t('%s : Not a valid email address.'), $recip) . EOL); continue; } diff --git a/Zotlabs/Module/Settings/Account.php b/Zotlabs/Module/Settings/Account.php index ec176797d..18890e89f 100644 --- a/Zotlabs/Module/Settings/Account.php +++ b/Zotlabs/Module/Settings/Account.php @@ -16,7 +16,7 @@ class Account { $account = \App::get_account(); if($email != $account['account_email']) { - if(! valid_email($email)) + if(! validate_email($email)) $errs[] = t('Not valid email.'); $adm = trim(get_config('system','admin_email')); if(($adm) && (strcasecmp($email,$adm) == 0)) { -- cgit v1.2.3 From 3fad69e5cad9aab1cb31969253919198e551b048 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 18 May 2017 14:57:10 +0200 Subject: some styling for system notifications --- Zotlabs/Module/Notifications.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Notifications.php b/Zotlabs/Module/Notifications.php index e0313dd8b..652648701 100644 --- a/Zotlabs/Module/Notifications.php +++ b/Zotlabs/Module/Notifications.php @@ -40,7 +40,7 @@ class Notifications extends \Zotlabs\Web\Controller { $o .= replace_macros(get_markup_template('notifications.tpl'),array( '$notif_header' => t('System Notifications'), - '$notif_link_mark_seen' => t('Mark all system notifications seen'), + '$notif_link_mark_seen' => t('Mark all seen'), '$notif_content' => $notif_content, '$notifications_available' => $notifications_available, )); -- cgit v1.2.3 From e4448423fbcee4e685b410a62844a245601d2e0b Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 21 May 2017 22:23:36 -0700 Subject: apporder module and all the associated backend stuff to make it work; probably needs a bit of UI cleanup and a link to it from somewhere --- Zotlabs/Module/Appman.php | 14 ++++++++++++++ Zotlabs/Module/Apporder.php | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 Zotlabs/Module/Apporder.php (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Appman.php b/Zotlabs/Module/Appman.php index 70cc7e44b..5c0667357 100644 --- a/Zotlabs/Module/Appman.php +++ b/Zotlabs/Module/Appman.php @@ -84,6 +84,20 @@ class Appman extends \Zotlabs\Web\Controller { } $channel = \App::get_channel(); + + if(argc() > 2) { + if(argv(2) === 'moveup') { + Zlib\Apps::moveup(local_channel(),argv(1)); + } + if(argv(2) === 'movedown') { + Zlib\Apps::movedown(local_channel(),argv(1)); + } + goaway(z_root() . '/apporder'); + } + + + + $app = null; $embed = null; if($_REQUEST['appid']) { diff --git a/Zotlabs/Module/Apporder.php b/Zotlabs/Module/Apporder.php new file mode 100644 index 000000000..1097a01eb --- /dev/null +++ b/Zotlabs/Module/Apporder.php @@ -0,0 +1,40 @@ + t('Change Order of Navigation Apps'), + '$desc' => t('Use arrows to move the corresponding app up or down in the display list'), + '$nav_apps' => $nav_apps + ] + ); + } +} -- cgit v1.2.3 From 36a960adec9f216463890640340324d6d37a65d0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 22 May 2017 00:57:56 -0700 Subject: schema fixes --- Zotlabs/Module/Like.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index 5ce8ec7f0..71336e8f3 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -373,6 +373,10 @@ class Like extends \Zotlabs\Web\Controller { $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $item['plink'])); $objtype = (($item['resource_type'] === 'photo') ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE ); + + if($objtype === ACTIVITY_OBJ_NOTE && (! intval($item['item_thread_top']))) + $objtype = ACTIVITY_OBJ_COMMENT; + $body = $item['body']; -- cgit v1.2.3 From 7ae0317b6a2bed323492ef987ddbaaf4f2a1a9b9 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 22 May 2017 17:07:34 -0700 Subject: apporder style improvement and add to nav menu, also add language awareness to webpages --- Zotlabs/Module/Editwebpage.php | 2 +- Zotlabs/Module/Page.php | 59 +++++++++++++++++++++++++++++++++--------- Zotlabs/Module/Webpages.php | 4 +-- 3 files changed, 50 insertions(+), 15 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Editwebpage.php b/Zotlabs/Module/Editwebpage.php index db33cd1db..3effe7ff5 100644 --- a/Zotlabs/Module/Editwebpage.php +++ b/Zotlabs/Module/Editwebpage.php @@ -112,7 +112,7 @@ class Editwebpage extends \Zotlabs\Web\Controller { intval($itm[0]['id']) ); if($item_id) - $page_title = $item_id[0]['v']; + $page_title = str_replace('%2f','/',$item_id[0]['v']); $mimetype = $itm[0]['mimetype']; diff --git a/Zotlabs/Module/Page.php b/Zotlabs/Module/Page.php index 6ef285dd0..7bc90c091 100644 --- a/Zotlabs/Module/Page.php +++ b/Zotlabs/Module/Page.php @@ -43,11 +43,31 @@ class Page extends \Zotlabs\Web\Controller { $channel_address = argv(1); + // Always look first for the page name prefixed by the observer language; for instance page/nickname/de/foo + // followed by page/nickname/foo if that is not found. + // If your browser language is de and you want to access the default in this case, + // use page/nickname/-/foo to over-ride the language and access only the page with pagelink of 'foo' + + $page_name = ''; + $ignore_language = false; + + for($x = 2; $x < argc(); $x ++) { + if($page_name === '' && argv($x) === '-') { + $ignore_language = true; + continue; + } + if($page_name) + $page_name .= '/'; + $page_name .= argv($x); + } + + // The page link title was stored in a urlencoded format // php or the browser may/will have decoded it, so re-encode it for our search - $page_id = urlencode(argv(2)); - + $page_id = urlencode($page_name); + $lang_page_id = urlencode(\App::$language . '/' . $page_name); + $u = q("select channel_id from channel where channel_address = '%s' limit 1", dbesc($channel_address) ); @@ -64,16 +84,31 @@ class Page extends \Zotlabs\Web\Controller { require_once('include/security.php'); $sql_options = item_permissions_sql($u[0]['channel_id']); - - $r = q("select item.* from item left join iconfig on item.id = iconfig.iid - where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s' and item.item_delayed = 0 - and (( iconfig.k = 'WEBPAGE' and item_type = %d ) - OR ( iconfig.k = 'PDL' AND item_type = %d )) $sql_options $revision limit 1", - intval($u[0]['channel_id']), - dbesc($page_id), - intval(ITEM_TYPE_WEBPAGE), - intval(ITEM_TYPE_PDL) - ); + + $r = null; + + if(! $ignore_language) { + $r = q("select item.* from item left join iconfig on item.id = iconfig.iid + where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s' and item.item_delayed = 0 + and (( iconfig.k = 'WEBPAGE' and item_type = %d ) + OR ( iconfig.k = 'PDL' AND item_type = %d )) $sql_options $revision limit 1", + intval($u[0]['channel_id']), + dbesc($lang_page_id), + intval(ITEM_TYPE_WEBPAGE), + intval(ITEM_TYPE_PDL) + ); + } + if(! $r) { + $r = q("select item.* from item left join iconfig on item.id = iconfig.iid + where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s' and item.item_delayed = 0 + and (( iconfig.k = 'WEBPAGE' and item_type = %d ) + OR ( iconfig.k = 'PDL' AND item_type = %d )) $sql_options $revision limit 1", + intval($u[0]['channel_id']), + dbesc($page_id), + intval(ITEM_TYPE_WEBPAGE), + intval(ITEM_TYPE_PDL) + ); + } if(! $r) { // Check again with no permissions clause to see if it is a permissions issue diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php index effe92614..be697ba2c 100644 --- a/Zotlabs/Module/Webpages.php +++ b/Zotlabs/Module/Webpages.php @@ -218,13 +218,13 @@ class Webpages extends \Zotlabs\Web\Controller { 'created' => $rr['created'], 'edited' => $rr['edited'], 'mimetype' => $rr['mimetype'], - 'pagetitle' => $rr['v'], + 'pagetitle' => str_replace('%2f','/',$rr['v']), 'mid' => $rr['mid'], 'layout_mid' => $rr['layout_mid'] ); $pages[$rr['iid']][] = array( 'url' => $rr['iid'], - 'pagetitle' => $rr['v'], + 'pagetitle' => str_replace('%2f','/',$rr['v']), 'title' => $rr['title'], 'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']), 'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited']), -- cgit v1.2.3 From 53057830e0388e0888cca925a99aa62cda0168cf Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 22 May 2017 20:18:47 -0700 Subject: wiki auto language select to match webpages implementation --- Zotlabs/Module/Wiki.php | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index d577226dc..5a93046e3 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -192,12 +192,28 @@ class Wiki extends \Zotlabs\Web\Controller { goaway(z_root() . '/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/Home'); case 4: + default: // GET /wiki/channel/wiki/page // Fetch the wiki info and determine observer permissions $wikiUrlName = urldecode(argv(2)); - $pageUrlName = urldecode(argv(3)); + + $page_name = ''; + $ignore_language = false; + + for($x = 3; $x < argc(); $x ++) { + if($page_name === '' && argv($x) === '-') { + $ignore_language = true; + continue; + } + if($page_name) + $page_name .= '/'; + $page_name .= argv($x); + } + + $pageUrlName = urldecode($page_name); + $langPageUrlName = urldecode(\App::$language . '/' . $page_name); $w = Zlib\NativeWiki::exists_by_name($owner['channel_id'], $wikiUrlName); @@ -227,9 +243,15 @@ class Wiki extends \Zotlabs\Web\Controller { $wikiheaderPage = urldecode($pageUrlName); $renamePage = (($wikiheaderPage === 'Home') ? '' : t('Rename page')); + $p = []; - $p = Zlib\NativeWikiPage::get_page_content(array('channel_id' => $owner['channel_id'], 'observer_hash' => $observer_hash, 'resource_id' => $resource_id, 'pageUrlName' => $pageUrlName)); - if(! $p['success']) { + if(! $ignore_language) { + $p = Zlib\NativeWikiPage::get_page_content(array('channel_id' => $owner['channel_id'], 'observer_hash' => $observer_hash, 'resource_id' => $resource_id, 'pageUrlName' => $langPageUrlName)); + } + if(! ($p && $p['success'])) { + $p = Zlib\NativeWikiPage::get_page_content(array('channel_id' => $owner['channel_id'], 'observer_hash' => $observer_hash, 'resource_id' => $resource_id, 'pageUrlName' => $pageUrlName)); + } + if(! ($p && $p['success'])) { notice( t('Error retrieving page content') . EOL); goaway(z_root() . '/' . argv(0) . '/' . argv(1) ); } @@ -251,8 +273,8 @@ class Wiki extends \Zotlabs\Web\Controller { } $showPageControls = $wiki_editor; break; - default: // Strip the extraneous URL components - goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/' . $pageUrlName); +// default: // Strip the extraneous URL components +// goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/' . $pageUrlName); } -- cgit v1.2.3 From ec7ecc285ec10a7990db09bda436fd498e05245a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 21 May 2017 22:23:36 -0700 Subject: apporder module and all the associated backend stuff to make it work; probably needs a bit of UI cleanup and a link to it from somewhere --- Zotlabs/Module/Appman.php | 14 ++++++++++++++ Zotlabs/Module/Apporder.php | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 Zotlabs/Module/Apporder.php (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Appman.php b/Zotlabs/Module/Appman.php index 70cc7e44b..5c0667357 100644 --- a/Zotlabs/Module/Appman.php +++ b/Zotlabs/Module/Appman.php @@ -84,6 +84,20 @@ class Appman extends \Zotlabs\Web\Controller { } $channel = \App::get_channel(); + + if(argc() > 2) { + if(argv(2) === 'moveup') { + Zlib\Apps::moveup(local_channel(),argv(1)); + } + if(argv(2) === 'movedown') { + Zlib\Apps::movedown(local_channel(),argv(1)); + } + goaway(z_root() . '/apporder'); + } + + + + $app = null; $embed = null; if($_REQUEST['appid']) { diff --git a/Zotlabs/Module/Apporder.php b/Zotlabs/Module/Apporder.php new file mode 100644 index 000000000..1097a01eb --- /dev/null +++ b/Zotlabs/Module/Apporder.php @@ -0,0 +1,40 @@ + t('Change Order of Navigation Apps'), + '$desc' => t('Use arrows to move the corresponding app up or down in the display list'), + '$nav_apps' => $nav_apps + ] + ); + } +} -- cgit v1.2.3 From 3a9e5f0f98d28959ecc73539a56c66ec2ff10016 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 22 May 2017 00:57:56 -0700 Subject: schema fixes --- Zotlabs/Module/Like.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index 5ce8ec7f0..71336e8f3 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -373,6 +373,10 @@ class Like extends \Zotlabs\Web\Controller { $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $item['plink'])); $objtype = (($item['resource_type'] === 'photo') ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE ); + + if($objtype === ACTIVITY_OBJ_NOTE && (! intval($item['item_thread_top']))) + $objtype = ACTIVITY_OBJ_COMMENT; + $body = $item['body']; -- cgit v1.2.3 From 647b5d098f0985a12acbaf6fc1d3d89c2a758129 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 22 May 2017 17:07:34 -0700 Subject: apporder style improvement and add to nav menu, also add language awareness to webpages --- Zotlabs/Module/Editwebpage.php | 2 +- Zotlabs/Module/Page.php | 59 +++++++++++++++++++++++++++++++++--------- Zotlabs/Module/Webpages.php | 4 +-- 3 files changed, 50 insertions(+), 15 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Editwebpage.php b/Zotlabs/Module/Editwebpage.php index db33cd1db..3effe7ff5 100644 --- a/Zotlabs/Module/Editwebpage.php +++ b/Zotlabs/Module/Editwebpage.php @@ -112,7 +112,7 @@ class Editwebpage extends \Zotlabs\Web\Controller { intval($itm[0]['id']) ); if($item_id) - $page_title = $item_id[0]['v']; + $page_title = str_replace('%2f','/',$item_id[0]['v']); $mimetype = $itm[0]['mimetype']; diff --git a/Zotlabs/Module/Page.php b/Zotlabs/Module/Page.php index 6ef285dd0..7bc90c091 100644 --- a/Zotlabs/Module/Page.php +++ b/Zotlabs/Module/Page.php @@ -43,11 +43,31 @@ class Page extends \Zotlabs\Web\Controller { $channel_address = argv(1); + // Always look first for the page name prefixed by the observer language; for instance page/nickname/de/foo + // followed by page/nickname/foo if that is not found. + // If your browser language is de and you want to access the default in this case, + // use page/nickname/-/foo to over-ride the language and access only the page with pagelink of 'foo' + + $page_name = ''; + $ignore_language = false; + + for($x = 2; $x < argc(); $x ++) { + if($page_name === '' && argv($x) === '-') { + $ignore_language = true; + continue; + } + if($page_name) + $page_name .= '/'; + $page_name .= argv($x); + } + + // The page link title was stored in a urlencoded format // php or the browser may/will have decoded it, so re-encode it for our search - $page_id = urlencode(argv(2)); - + $page_id = urlencode($page_name); + $lang_page_id = urlencode(\App::$language . '/' . $page_name); + $u = q("select channel_id from channel where channel_address = '%s' limit 1", dbesc($channel_address) ); @@ -64,16 +84,31 @@ class Page extends \Zotlabs\Web\Controller { require_once('include/security.php'); $sql_options = item_permissions_sql($u[0]['channel_id']); - - $r = q("select item.* from item left join iconfig on item.id = iconfig.iid - where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s' and item.item_delayed = 0 - and (( iconfig.k = 'WEBPAGE' and item_type = %d ) - OR ( iconfig.k = 'PDL' AND item_type = %d )) $sql_options $revision limit 1", - intval($u[0]['channel_id']), - dbesc($page_id), - intval(ITEM_TYPE_WEBPAGE), - intval(ITEM_TYPE_PDL) - ); + + $r = null; + + if(! $ignore_language) { + $r = q("select item.* from item left join iconfig on item.id = iconfig.iid + where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s' and item.item_delayed = 0 + and (( iconfig.k = 'WEBPAGE' and item_type = %d ) + OR ( iconfig.k = 'PDL' AND item_type = %d )) $sql_options $revision limit 1", + intval($u[0]['channel_id']), + dbesc($lang_page_id), + intval(ITEM_TYPE_WEBPAGE), + intval(ITEM_TYPE_PDL) + ); + } + if(! $r) { + $r = q("select item.* from item left join iconfig on item.id = iconfig.iid + where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s' and item.item_delayed = 0 + and (( iconfig.k = 'WEBPAGE' and item_type = %d ) + OR ( iconfig.k = 'PDL' AND item_type = %d )) $sql_options $revision limit 1", + intval($u[0]['channel_id']), + dbesc($page_id), + intval(ITEM_TYPE_WEBPAGE), + intval(ITEM_TYPE_PDL) + ); + } if(! $r) { // Check again with no permissions clause to see if it is a permissions issue diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php index effe92614..be697ba2c 100644 --- a/Zotlabs/Module/Webpages.php +++ b/Zotlabs/Module/Webpages.php @@ -218,13 +218,13 @@ class Webpages extends \Zotlabs\Web\Controller { 'created' => $rr['created'], 'edited' => $rr['edited'], 'mimetype' => $rr['mimetype'], - 'pagetitle' => $rr['v'], + 'pagetitle' => str_replace('%2f','/',$rr['v']), 'mid' => $rr['mid'], 'layout_mid' => $rr['layout_mid'] ); $pages[$rr['iid']][] = array( 'url' => $rr['iid'], - 'pagetitle' => $rr['v'], + 'pagetitle' => str_replace('%2f','/',$rr['v']), 'title' => $rr['title'], 'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']), 'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited']), -- cgit v1.2.3 From da682717ab6b37f87e2620a4305fa78131d57063 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 22 May 2017 20:18:47 -0700 Subject: wiki auto language select to match webpages implementation --- Zotlabs/Module/Wiki.php | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index a1e377e68..f3b34401d 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -192,12 +192,28 @@ class Wiki extends \Zotlabs\Web\Controller { goaway(z_root() . '/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/Home'); case 4: + default: // GET /wiki/channel/wiki/page // Fetch the wiki info and determine observer permissions $wikiUrlName = urldecode(argv(2)); - $pageUrlName = urldecode(argv(3)); + + $page_name = ''; + $ignore_language = false; + + for($x = 3; $x < argc(); $x ++) { + if($page_name === '' && argv($x) === '-') { + $ignore_language = true; + continue; + } + if($page_name) + $page_name .= '/'; + $page_name .= argv($x); + } + + $pageUrlName = urldecode($page_name); + $langPageUrlName = urldecode(\App::$language . '/' . $page_name); $w = Zlib\NativeWiki::exists_by_name($owner['channel_id'], $wikiUrlName); @@ -227,9 +243,15 @@ class Wiki extends \Zotlabs\Web\Controller { $wikiheaderPage = urldecode($pageUrlName); $renamePage = (($wikiheaderPage === 'Home') ? '' : t('Rename page')); + $p = []; - $p = Zlib\NativeWikiPage::get_page_content(array('channel_id' => $owner['channel_id'], 'observer_hash' => $observer_hash, 'resource_id' => $resource_id, 'pageUrlName' => $pageUrlName)); - if(! $p['success']) { + if(! $ignore_language) { + $p = Zlib\NativeWikiPage::get_page_content(array('channel_id' => $owner['channel_id'], 'observer_hash' => $observer_hash, 'resource_id' => $resource_id, 'pageUrlName' => $langPageUrlName)); + } + if(! ($p && $p['success'])) { + $p = Zlib\NativeWikiPage::get_page_content(array('channel_id' => $owner['channel_id'], 'observer_hash' => $observer_hash, 'resource_id' => $resource_id, 'pageUrlName' => $pageUrlName)); + } + if(! ($p && $p['success'])) { notice( t('Error retrieving page content') . EOL); goaway(z_root() . '/' . argv(0) . '/' . argv(1) ); } @@ -251,8 +273,8 @@ class Wiki extends \Zotlabs\Web\Controller { } $showPageControls = $wiki_editor; break; - default: // Strip the extraneous URL components - goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/' . $pageUrlName); +// default: // Strip the extraneous URL components +// goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/' . $pageUrlName); } -- cgit v1.2.3 From 3a00140797fa0d557db2434402ce20258b4ce570 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 23 May 2017 21:20:40 -0700 Subject: remove php version checks for older ( < 5.4) code incompatibilities --- Zotlabs/Module/Admin.php | 6 ------ 1 file changed, 6 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Admin.php b/Zotlabs/Module/Admin.php index 536d85dde..65ce363c0 100644 --- a/Zotlabs/Module/Admin.php +++ b/Zotlabs/Module/Admin.php @@ -120,12 +120,6 @@ class Admin extends \Zotlabs\Web\Controller { // Could be extended to provide also other alerts to the admin $alertmsg = ''; - // annoy admin about upcoming unsupported PHP version - if (version_compare(PHP_VERSION, '5.4', '<')) { - $alertmsg = 'Your PHP version ' . PHP_VERSION . ' will not be supported with the next major release of $Projectname. You are strongly urged to upgrade to a current version.' - . '
PHP 5.3 has reached its End of Life (EOL) in August 2014.' - . ' A list about current PHP versions can be found here.'; - } $vmaster = get_repository_version('master'); $vdev = get_repository_version('dev'); -- cgit v1.2.3 From df8c69f73b54d33ba2bec7d227f6e6f948f4b451 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 24 May 2017 22:24:45 -0700 Subject: some minor help cleanup - add '-/foo' override of language detection --- Zotlabs/Module/Help.php | 74 ++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Help.php b/Zotlabs/Module/Help.php index e247416d9..0373a4aab 100644 --- a/Zotlabs/Module/Help.php +++ b/Zotlabs/Module/Help.php @@ -44,42 +44,42 @@ class Help extends \Zotlabs\Web\Controller { return $o; } - - - if(argc() > 2 && argv(argc()-2) === 'assets') { - $path = ''; - for($x = 1; $x < argc(); $x ++) { - if(strlen($path)) - $path .= '/'; - $path .= argv($x); - } - $realpath = 'doc/' . $path; - //Set the content-type header as appropriate - $imageInfo = getimagesize($realpath); - switch ($imageInfo[2]) { - case IMAGETYPE_JPEG: - header("Content-Type: image/jpeg"); - break; - case IMAGETYPE_GIF: - header("Content-Type: image/gif"); - break; - case IMAGETYPE_PNG: - header("Content-Type: image/png"); - break; - default: - break; - } - header("Content-Length: " . filesize($realpath)); + + + if(argc() > 2 && argv(argc()-2) === 'assets') { + $path = ''; + for($x = 1; $x < argc(); $x ++) { + if(strlen($path)) + $path .= '/'; + $path .= argv($x); + } + $realpath = 'doc/' . $path; + //Set the content-type header as appropriate + $imageInfo = getimagesize($realpath); + switch ($imageInfo[2]) { + case IMAGETYPE_JPEG: + header("Content-Type: image/jpeg"); + break; + case IMAGETYPE_GIF: + header("Content-Type: image/gif"); + break; + case IMAGETYPE_PNG: + header("Content-Type: image/png"); + break; + default: + break; + } + header("Content-Length: " . filesize($realpath)); - // dump the picture and stop the script - readfile($realpath); - killme(); - } + // dump the picture and stop the script + readfile($realpath); + killme(); + } $headings = [ - 'about' => t('About'), - 'member' => t('Members'), - 'admin' => t('Administrators'), + 'about' => t('About'), + 'member' => t('Members'), + 'admin' => t('Administrators'), 'developer' => t('Developers'), 'tutorials' => t('Tutorials') ]; @@ -87,13 +87,13 @@ class Help extends \Zotlabs\Web\Controller { if(array_key_exists(argv(1), $headings)) $heading = $headings[argv(1)]; - $content = get_help_content(); + $content = get_help_content(); return replace_macros(get_markup_template('help.tpl'), array( - '$title' => t('$Projectname Documentation'), + '$title' => t('$Projectname Documentation'), '$tocHeading' => t('Contents'), - '$content' => $content, - '$heading' => $heading + '$content' => $content, + '$heading' => $heading )); } -- cgit v1.2.3 From b4da2d35bf8084da812be0716917a0f88cf68f91 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 25 May 2017 13:37:13 -0700 Subject: start using the abook_not_here flag (requires changes in addons, not easily portable to hubzilla) --- Zotlabs/Module/Import.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index ce3fd469a..a2f83e1cb 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -333,6 +333,10 @@ class Import extends \Zotlabs\Web\Controller { $abook['abook_feed'] = (($abook['abook_flags'] & 0x0100 ) ? 1 : 0); } + if(array_key_exists('abook_instance',$abook) && $abook['abook_instance'] && strpos($abook['abook_instance'],z_root()) === false) { + $abook['abook_not_here'] = 1; + } + if($abook['abook_self']) { $role = get_pconfig($channel['channel_id'],'system','permissions_role'); if(($role === 'forum') || ($abook['abook_my_perms'] & PERMS_W_TAGWALL)) { -- cgit v1.2.3 From 938a6218104d08e44dc2daf2a3884f96a4c6aa31 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 25 May 2017 23:02:48 -0700 Subject: update the link to account roles help on register page --- Zotlabs/Module/Register.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php index 1d8944d8e..d1986bea5 100644 --- a/Zotlabs/Module/Register.php +++ b/Zotlabs/Module/Register.php @@ -237,7 +237,7 @@ class Register extends \Zotlabs\Web\Controller { $name = array('name', t('Name or caption'), ((x($_REQUEST,'name')) ? $_REQUEST['name'] : ''), t('Examples: "Bob Jameson", "Lisa and her Horses", "Soccer", "Aviation Group"')); $nickhub = '@' . str_replace(array('http://','https://','/'), '', get_config('system','baseurl')); $nickname = array('nickname', t('Choose a short nickname'), ((x($_REQUEST,'nickname')) ? $_REQUEST['nickname'] : ''), sprintf( t('Your nickname will be used to create an easy to remember channel address e.g. nickname%s'), $nickhub)); - $role = array('permissions_role' , t('Channel role and privacy'), ($privacy_role) ? $privacy_role : 'social', t('Select a channel role with your privacy requirements.') . ' ' . t('Read more about roles') . '',$perm_roles); + $role = array('permissions_role' , t('Channel role and privacy'), ($privacy_role) ? $privacy_role : 'social', t('Select a channel role with your privacy requirements.') . ' ' . t('Read more about roles') . '',$perm_roles); $tos = array('tos', $label_tos, '', '', array(t('no'),t('yes'))); $server_role = get_config('system','server_role'); -- cgit v1.2.3 From 2deafa0deab1dc8696cd1e1c2d93aece8ac24338 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 25 May 2017 23:03:55 -0700 Subject: update link to account roles help on new_channel page --- Zotlabs/Module/New_channel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/New_channel.php b/Zotlabs/Module/New_channel.php index 8e6fd1d37..cfd45e909 100644 --- a/Zotlabs/Module/New_channel.php +++ b/Zotlabs/Module/New_channel.php @@ -134,7 +134,7 @@ class New_channel extends \Zotlabs\Web\Controller { $name = array('name', t('Name or caption'), ((x($_REQUEST,'name')) ? $_REQUEST['name'] : ''), t('Examples: "Bob Jameson", "Lisa and her Horses", "Soccer", "Aviation Group"'), "*"); $nickhub = '@' . \App::get_hostname(); $nickname = array('nickname', t('Choose a short nickname'), ((x($_REQUEST,'nickname')) ? $_REQUEST['nickname'] : ''), sprintf( t('Your nickname will be used to create an easy to remember channel address e.g. nickname%s'), $nickhub), "*"); - $role = array('permissions_role' , t('Channel role and privacy'), ($privacy_role) ? $privacy_role : 'social', t('Select a channel role with your privacy requirements.') . ' ' . t('Read more about roles') . '',$perm_roles); + $role = array('permissions_role' , t('Channel role and privacy'), ($privacy_role) ? $privacy_role : 'social', t('Select a channel role with your privacy requirements.') . ' ' . t('Read more about roles') . '',$perm_roles); $o = replace_macros(get_markup_template('new_channel.tpl'), array( '$title' => t('Create Channel'), -- cgit v1.2.3 From 1b75e4de0db02389108aba2b89830f7804f289f4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 26 May 2017 14:52:45 -0700 Subject: hubzilla issue #795 --- Zotlabs/Module/Editwebpage.php | 2 +- Zotlabs/Module/Webpages.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Editwebpage.php b/Zotlabs/Module/Editwebpage.php index 3effe7ff5..da536a729 100644 --- a/Zotlabs/Module/Editwebpage.php +++ b/Zotlabs/Module/Editwebpage.php @@ -112,7 +112,7 @@ class Editwebpage extends \Zotlabs\Web\Controller { intval($itm[0]['id']) ); if($item_id) - $page_title = str_replace('%2f','/',$item_id[0]['v']); + $page_title = urldecode($item_id[0]['v']); $mimetype = $itm[0]['mimetype']; diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php index be697ba2c..a8fd5222b 100644 --- a/Zotlabs/Module/Webpages.php +++ b/Zotlabs/Module/Webpages.php @@ -218,13 +218,15 @@ class Webpages extends \Zotlabs\Web\Controller { 'created' => $rr['created'], 'edited' => $rr['edited'], 'mimetype' => $rr['mimetype'], - 'pagetitle' => str_replace('%2f','/',$rr['v']), + 'pageurl' => str_replace('%2f','/',$rr['v']), + 'pagetitle' => urldecode($rr['v']), 'mid' => $rr['mid'], 'layout_mid' => $rr['layout_mid'] ); $pages[$rr['iid']][] = array( 'url' => $rr['iid'], - 'pagetitle' => str_replace('%2f','/',$rr['v']), + 'pageurl' => str_replace('%2f','/',$rr['v']), + 'pagetitle' => urldecode($rr['v']), 'title' => $rr['title'], 'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']), 'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited']), -- cgit v1.2.3 From 184f522d5f6b03267f4fdf59f382408f91f44439 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 26 May 2017 14:52:45 -0700 Subject: hubzilla issue #795 --- Zotlabs/Module/Editwebpage.php | 2 +- Zotlabs/Module/Webpages.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Editwebpage.php b/Zotlabs/Module/Editwebpage.php index 3effe7ff5..da536a729 100644 --- a/Zotlabs/Module/Editwebpage.php +++ b/Zotlabs/Module/Editwebpage.php @@ -112,7 +112,7 @@ class Editwebpage extends \Zotlabs\Web\Controller { intval($itm[0]['id']) ); if($item_id) - $page_title = str_replace('%2f','/',$item_id[0]['v']); + $page_title = urldecode($item_id[0]['v']); $mimetype = $itm[0]['mimetype']; diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php index be697ba2c..a8fd5222b 100644 --- a/Zotlabs/Module/Webpages.php +++ b/Zotlabs/Module/Webpages.php @@ -218,13 +218,15 @@ class Webpages extends \Zotlabs\Web\Controller { 'created' => $rr['created'], 'edited' => $rr['edited'], 'mimetype' => $rr['mimetype'], - 'pagetitle' => str_replace('%2f','/',$rr['v']), + 'pageurl' => str_replace('%2f','/',$rr['v']), + 'pagetitle' => urldecode($rr['v']), 'mid' => $rr['mid'], 'layout_mid' => $rr['layout_mid'] ); $pages[$rr['iid']][] = array( 'url' => $rr['iid'], - 'pagetitle' => str_replace('%2f','/',$rr['v']), + 'pageurl' => str_replace('%2f','/',$rr['v']), + 'pagetitle' => urldecode($rr['v']), 'title' => $rr['title'], 'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']), 'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited']), -- cgit v1.2.3 From 4fcfcc81172ebdfa4a27d3bca94bffe97356f600 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 29 May 2017 13:50:02 -0700 Subject: start deprecation of server_role --- Zotlabs/Module/Admin/Site.php | 10 ---------- Zotlabs/Module/Chanview.php | 6 +----- Zotlabs/Module/Import.php | 3 +-- Zotlabs/Module/Register.php | 8 +++----- Zotlabs/Module/Settings/Channel.php | 1 - Zotlabs/Module/Setup.php | 8 +------- 6 files changed, 6 insertions(+), 30 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php index d05e70aa9..4c5b82e78 100644 --- a/Zotlabs/Module/Admin/Site.php +++ b/Zotlabs/Module/Admin/Site.php @@ -17,7 +17,6 @@ class Site { check_form_security_token_redirectOnErr('/admin/site', 'admin_site'); $sitename = ((x($_POST,'sitename')) ? notags(trim($_POST['sitename'])) : ''); - $server_role = ((x($_POST,'server_role')) ? notags(trim($_POST['server_role'])) : 'standard'); $banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false); @@ -68,7 +67,6 @@ class Site { if(array_key_exists('techlevel', $_POST)) $techlevel = intval($_POST['techlevel']); - set_config('system', 'server_role', $server_role); set_config('system', 'feed_contacts', $feed_contacts); set_config('system', 'delivery_interval', $delivery_interval); set_config('system', 'delivery_batch_count', $delivery_batch_count); @@ -254,12 +252,6 @@ class Site { // now invert the logic for the setting. $discover_tab = (1 - $discover_tab); - $server_roles = [ - 'basic' => t('Basic/Minimal Social Networking'), - 'standard' => t('Standard Configuration (default)'), - 'pro' => t('Professional') - ]; - $techlevels = [ '0' => t('Beginner/Basic'), '1' => t('Novice - not skilled but willing to learn'), @@ -286,8 +278,6 @@ class Site { // name, label, value, help string, extra data... '$sitename' => array('sitename', t("Site name"), htmlspecialchars(get_config('system','sitename'), ENT_QUOTES, 'UTF-8'),''), - '$server_role' => array('server_role', t("Server Configuration/Role"), get_config('system','server_role'),'',$server_roles), - '$techlevel' => [ 'techlevel', t('Site default technical skill level'), get_config('system','techlevel'), t('Used to provide a member experience matched to technical comfort level'), $techlevels ], '$techlock' => [ 'techlock', t('Lock the technical skill level setting'), get_config('system','techlevel_lock'), t('Members can set their own technical comfort level by default') ], diff --git a/Zotlabs/Module/Chanview.php b/Zotlabs/Module/Chanview.php index 01ee74d5a..c3194184a 100644 --- a/Zotlabs/Module/Chanview.php +++ b/Zotlabs/Module/Chanview.php @@ -117,12 +117,8 @@ class Chanview extends \Zotlabs\Web\Controller { // the remote profile. // Zot channels will usually have a connect link. - // If it isn't zot, 'pro' members won't be able to use the connect - // button as it is a foreign network so just send them to the remote - // profile. - - if($is_zot || \Zotlabs\Lib\System::get_server_role() === 'pro') { + if($is_zot) { if($is_zot && $observer) { $url = zid($url); } diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index a2f83e1cb..40ce8f6d1 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -121,8 +121,7 @@ class Import extends \Zotlabs\Web\Controller { $t = sprintf( t('Warning: Database versions differ by %1$d updates.'), $v2 - $v1 ); notice($t); } - if(array_key_exists('server_role',$data['compatibility']) && $data['compatibility']['server_role'] == 'basic') - $moving = true; + } if($moving) diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php index d1986bea5..d4573156c 100644 --- a/Zotlabs/Module/Register.php +++ b/Zotlabs/Module/Register.php @@ -151,7 +151,7 @@ class Register extends \Zotlabs\Web\Controller { $new_channel = false; $next_page = 'new_channel'; - if(get_config('system','auto_channel_create') || get_config('system','server_role') == 'basic') { + if(get_config('system','auto_channel_create')) { $new_channel = auto_channel_create($result['account']['account_id']); if($new_channel['success']) { $channel_id = $new_channel['channel']['channel_id']; @@ -240,11 +240,9 @@ class Register extends \Zotlabs\Web\Controller { $role = array('permissions_role' , t('Channel role and privacy'), ($privacy_role) ? $privacy_role : 'social', t('Select a channel role with your privacy requirements.') . ' ' . t('Read more about roles') . '',$perm_roles); $tos = array('tos', $label_tos, '', '', array(t('no'),t('yes'))); - $server_role = get_config('system','server_role'); - - $auto_create = (($server_role == 'basic') || (get_config('system','auto_channel_create')) ? true : false); - $default_role = (($server_role == 'basic') ? 'social' : get_config('system','default_permissions_role')); + $auto_create = (get_config('system','auto_channel_create') ? true : false); + $default_role = get_config('system','default_permissions_role'); require_once('include/bbcode.php'); diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index 56a7d0d8e..7c30ef93e 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -489,7 +489,6 @@ class Channel { '$h_prv' => t('Security and Privacy Settings'), '$permissions_set' => $permissions_set, - '$server_role' => \Zotlabs\Lib\System::get_server_role(), '$perms_set_msg' => t('Your permissions are already configured. Click to view/adjust'), '$hide_presence' => array('hide_presence', t('Hide my online presence'),$hide_presence, t('Prevents displaying in your profile that you are online'), $yes_no), diff --git a/Zotlabs/Module/Setup.php b/Zotlabs/Module/Setup.php index aa28204d3..e5b54cc5f 100644 --- a/Zotlabs/Module/Setup.php +++ b/Zotlabs/Module/Setup.php @@ -73,9 +73,6 @@ class Setup extends \Zotlabs\Web\Controller { $phpath = trim($_POST['phpath']); $adminmail = trim($_POST['adminmail']); $siteurl = trim($_POST['siteurl']); - $server_role = trim($_POST['server_role']); - if(! $server_role) - $server_role = 'standard'; // $siteurl should not have a trailing slash @@ -103,9 +100,6 @@ class Setup extends \Zotlabs\Web\Controller { $timezone = trim($_POST['timezone']); $adminmail = trim($_POST['adminmail']); $siteurl = trim($_POST['siteurl']); - $server_role = trim($_POST['server_role']); - if(! $server_role) - $server_role = 'standard'; if($siteurl != z_root()) { $test = z_fetch_url($siteurl."/setup/testrewrite"); @@ -134,7 +128,7 @@ class Setup extends \Zotlabs\Web\Controller { '$dbpass' => $dbpass, '$dbdata' => $dbdata, '$dbtype' => $dbtype, - '$server_role' => $server_role, + '$server_role' => 'pro', '$timezone' => $timezone, '$siteurl' => $siteurl, '$site_id' => random_string(), -- cgit v1.2.3 From fd915138322b920036a2a21c56fdfb6a56749303 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 29 May 2017 16:25:27 -0700 Subject: more deprecate server_role --- Zotlabs/Module/Editpost.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Editpost.php b/Zotlabs/Module/Editpost.php index 629bdd3fd..a54c42e7f 100644 --- a/Zotlabs/Module/Editpost.php +++ b/Zotlabs/Module/Editpost.php @@ -39,6 +39,11 @@ class Editpost extends \Zotlabs\Web\Controller { return; } + if($itm[0]['resource_type'] === 'photo' && $itm[0]['resource_id']) { + notice( t('Item is not editable') . EOL); + return; + } + if($itm[0]['resource_type'] === 'event' && $itm[0]['resource_id']) { goaway(z_root() . '/events/' . $itm[0]['resource_id'] . '?expandform=1'); } -- cgit v1.2.3 From 2b5d19924b33bb75ad7ed1504f441bec4db60a7e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 30 May 2017 15:15:00 +0200 Subject: fix issue #790 - zip->open returned error 19 (not a valid zip archive). in case there are further issues we should probably also put a ob_end_clean() right before readfile() --- Zotlabs/Module/Webpages.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php index a8fd5222b..641e84b70 100644 --- a/Zotlabs/Module/Webpages.php +++ b/Zotlabs/Module/Webpages.php @@ -696,7 +696,8 @@ class Webpages extends \Zotlabs\Web\Controller { } rrmdir($zip_folderpath); rrmdir($tmp_folderpath); // delete temporary files - + killme(); + break; default : break; -- cgit v1.2.3 From e48d5383cec4f5e7bd40bbac005819d60f38c970 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 30 May 2017 16:50:57 -0700 Subject: move disapora xrd stuff to plugin --- Zotlabs/Module/Xrd.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Xrd.php b/Zotlabs/Module/Xrd.php index 7b36576e0..17c0faa78 100644 --- a/Zotlabs/Module/Xrd.php +++ b/Zotlabs/Module/Xrd.php @@ -30,13 +30,7 @@ class Xrd extends \Zotlabs\Web\Controller { ); if(! $r) killme(); - - $dspr = replace_macros(get_markup_template('xrd_diaspora.tpl'),array( - '$baseurl' => z_root(), - '$dspr_guid' => $r[0]['channel_guid'] . str_replace('.','',\App::get_hostname()), - '$dspr_key' => base64_encode(pemtorsa($r[0]['channel_pubkey'])) - )); - + $salmon_key = salmon_key($r[0]['channel_pubkey']); header('Access-Control-Allow-Origin: *'); @@ -49,8 +43,7 @@ class Xrd extends \Zotlabs\Web\Controller { if($aliases[$x] === $resource) unset($aliases[$x]); } - - + $o = replace_macros(get_markup_template('xrd_person.tpl'), array( '$nick' => $r[0]['channel_address'], '$accturi' => $resource, @@ -61,12 +54,8 @@ class Xrd extends \Zotlabs\Web\Controller { '$zot_post' => z_root() . '/post/' . $r[0]['channel_address'], '$poco_url' => z_root() . '/poco/' . $r[0]['channel_address'], '$photo' => z_root() . '/photo/profile/l/' . $r[0]['channel_id'], - '$dspr' => $dspr, - // '$salmon' => z_root() . '/salmon/' . $r[0]['channel_address'], - // '$salmen' => z_root() . '/salmon/' . $r[0]['channel_address'] . '/mention', '$modexp' => 'data:application/magic-public-key,' . $salmon_key, '$subscribe' => z_root() . '/follow?url={uri}', - '$bigkey' => salmon_key($r[0]['channel_pubkey']) )); -- cgit v1.2.3 From 893ae17b99d1a1a720a58879e8075fc9bb1de087 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 30 May 2017 17:06:50 -0700 Subject: provide ability to search webpages (either public or which contain the observer in the acl) in addition to conversations --- Zotlabs/Module/Search.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index aacdc88e7..a78a023ff 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -15,7 +15,7 @@ class Search extends \Zotlabs\Web\Controller { if((get_config('system','block_public')) || (get_config('system','block_public_search'))) { if ((! local_channel()) && (! remote_channel())) { notice( t('Public access denied.') . EOL); - return; + return; } } @@ -144,7 +144,7 @@ class Search extends \Zotlabs\Web\Controller { } - $item_normal = item_normal(); + $item_normal = item_normal_search(); $pub_sql = public_permissions_sql($observer_hash); require_once('include/channel.php'); -- cgit v1.2.3 From a7ecf519156c1110acbb0eadd13dee63b7adaabd Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 30 May 2017 17:06:50 -0700 Subject: provide ability to search webpages (either public or which contain the observer in the acl) in addition to conversations --- Zotlabs/Module/Search.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index aacdc88e7..a78a023ff 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -15,7 +15,7 @@ class Search extends \Zotlabs\Web\Controller { if((get_config('system','block_public')) || (get_config('system','block_public_search'))) { if ((! local_channel()) && (! remote_channel())) { notice( t('Public access denied.') . EOL); - return; + return; } } @@ -144,7 +144,7 @@ class Search extends \Zotlabs\Web\Controller { } - $item_normal = item_normal(); + $item_normal = item_normal_search(); $pub_sql = public_permissions_sql($observer_hash); require_once('include/channel.php'); -- cgit v1.2.3 From 7ccf47f4c69e6deecf33f982ae3ea7497ac10ee6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 31 May 2017 20:08:35 -0700 Subject: don't allow negative age in directory listings --- Zotlabs/Module/Directory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php index edcf43cd6..92c1e0245 100644 --- a/Zotlabs/Module/Directory.php +++ b/Zotlabs/Module/Directory.php @@ -233,7 +233,7 @@ class Directory extends \Zotlabs\Web\Controller { $age = ''; if(strlen($rr['birthday'])) { - if(($years = age($rr['birthday'],'UTC','')) != 0) + if(($years = age($rr['birthday'],'UTC','')) > 0) $age = $years; } -- cgit v1.2.3 From c4ed04fc827ec5a1039959e260702141083836c8 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Sat, 3 Jun 2017 10:13:42 +0200 Subject: convert randprof to use chanlink_hash() instead of chanlink_url() and filter sys channels by xchan.xchan_system instead of xchan_addr != sys@% --- Zotlabs/Module/Randprof.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Randprof.php b/Zotlabs/Module/Randprof.php index dc2e925fe..94ec095cb 100644 --- a/Zotlabs/Module/Randprof.php +++ b/Zotlabs/Module/Randprof.php @@ -8,7 +8,7 @@ class Randprof extends \Zotlabs\Web\Controller { function init() { $x = random_profile(); if($x) - goaway(chanlink_url($x)); + goaway(chanlink_hash($x)); /** FIXME this doesn't work at the moment as a fallback */ goaway(z_root() . '/profile'); -- cgit v1.2.3 From 7562f77bdf7040d5cc63473a3c6ff7c499600f13 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Sat, 3 Jun 2017 17:23:53 +0200 Subject: rewrite wiki pages widget - no need for ajax on pageload, show the pages to not authenticated people. --- Zotlabs/Module/Wiki.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index f3b34401d..2f1fa01b7 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -207,9 +207,10 @@ class Wiki extends \Zotlabs\Web\Controller { $ignore_language = true; continue; } - if($page_name) + if($page_name) { $page_name .= '/'; - $page_name .= argv($x); + } + $page_name .= argv($x); } $pageUrlName = urldecode($page_name); @@ -296,7 +297,8 @@ class Wiki extends \Zotlabs\Web\Controller { '$showPageControls' => $showPageControls, '$editOrSourceLabel' => (($showPageControls) ? t('Edit') : t('Source')), '$tools_label' => 'Page Tools', - '$channel' => $owner['channel_address'], + '$channel_address' => $owner['channel_address'], + '$channel_id' => $owner['channel_id'], '$resource_id' => $resource_id, '$page' => $pageUrlName, '$mimeType' => $mimeType, @@ -495,10 +497,12 @@ class Wiki extends \Zotlabs\Web\Controller { $x = new \Zotlabs\Widget\Wiki_pages(); - $page_list_html = $x->widget(array( - 'resource_id' => $resource_id, - 'refresh' => true, - 'channel' => argv(1))); + $page_list_html = $x->widget([ + 'resource_id' => $resource_id, + 'channel_id' => $owner['channel_id'], + 'channel_address' => $owner['channel_address'], + 'refresh' => true + ]); json_return_and_die(array('pages' => $page_list_html, 'message' => '', 'success' => true)); } -- cgit v1.2.3 From 43914852e5214421a0c5c2256e61344617c4fd22 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 3 Jun 2017 16:08:08 -0700 Subject: oembed: ensure that width and height are returned as type int and not float --- Zotlabs/Module/Oep.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Oep.php b/Zotlabs/Module/Oep.php index dc0547a42..9c05f5e3f 100644 --- a/Zotlabs/Module/Oep.php +++ b/Zotlabs/Module/Oep.php @@ -108,7 +108,7 @@ class Oep extends \Zotlabs\Web\Controller { $ret['type'] = 'rich'; $w = (($maxwidth) ? $maxwidth : 640); - $h = (($maxheight) ? $maxheight : $w * 2 / 3); + $h = (($maxheight) ? $maxheight : intval($w * 2 / 3)); $ret['html'] = '
' . $o . '
'; @@ -167,7 +167,7 @@ class Oep extends \Zotlabs\Web\Controller { $ret['type'] = 'rich'; $w = (($maxwidth) ? $maxwidth : 640); - $h = (($maxheight) ? $maxheight : $w * 2 / 3); + $h = (($maxheight) ? $maxheight : intval($w * 2 / 3)); $ret['html'] = '
' . $o . '
'; -- cgit v1.2.3 From e917b949292fc83edb22d955251f8887544b772a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 6 Jun 2017 17:38:34 -0700 Subject: hubzilla issue #810 --- Zotlabs/Module/Channel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 61df35a60..98a1e6c88 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -217,10 +217,10 @@ class Channel extends \Zotlabs\Web\Controller { else { if(x($category)) { - $sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY)); + $sql_extra2 .= protect_sprintf(term_item_parent_query(\App::$profile['profile_uid'],'item', $category, TERM_CATEGORY)); } if(x($hashtags)) { - $sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG)); + $sql_extra2 .= protect_sprintf(term_item_parent_query(\App::$profile['profile_uid'],'item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG)); } if($datequery) { -- cgit v1.2.3 From 8a11dc0c900e48d3625ad500290d862d5fa64667 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 31 May 2017 20:08:35 -0700 Subject: don't allow negative age in directory listings --- Zotlabs/Module/Directory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php index edcf43cd6..92c1e0245 100644 --- a/Zotlabs/Module/Directory.php +++ b/Zotlabs/Module/Directory.php @@ -233,7 +233,7 @@ class Directory extends \Zotlabs\Web\Controller { $age = ''; if(strlen($rr['birthday'])) { - if(($years = age($rr['birthday'],'UTC','')) != 0) + if(($years = age($rr['birthday'],'UTC','')) > 0) $age = $years; } -- cgit v1.2.3 From 01b541d8b04e93de8f90c420610c656f6d3e2fb0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 3 Jun 2017 16:08:08 -0700 Subject: oembed: ensure that width and height are returned as type int and not float --- Zotlabs/Module/Oep.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Oep.php b/Zotlabs/Module/Oep.php index dc0547a42..9c05f5e3f 100644 --- a/Zotlabs/Module/Oep.php +++ b/Zotlabs/Module/Oep.php @@ -108,7 +108,7 @@ class Oep extends \Zotlabs\Web\Controller { $ret['type'] = 'rich'; $w = (($maxwidth) ? $maxwidth : 640); - $h = (($maxheight) ? $maxheight : $w * 2 / 3); + $h = (($maxheight) ? $maxheight : intval($w * 2 / 3)); $ret['html'] = '
' . $o . '
'; @@ -167,7 +167,7 @@ class Oep extends \Zotlabs\Web\Controller { $ret['type'] = 'rich'; $w = (($maxwidth) ? $maxwidth : 640); - $h = (($maxheight) ? $maxheight : $w * 2 / 3); + $h = (($maxheight) ? $maxheight : intval($w * 2 / 3)); $ret['html'] = '
' . $o . '
'; -- cgit v1.2.3 From 108b052e4eedc8d0002c34802d4a96faee4a7cd6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 6 Jun 2017 17:38:34 -0700 Subject: hubzilla issue #810 --- Zotlabs/Module/Channel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 61df35a60..98a1e6c88 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -217,10 +217,10 @@ class Channel extends \Zotlabs\Web\Controller { else { if(x($category)) { - $sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY)); + $sql_extra2 .= protect_sprintf(term_item_parent_query(\App::$profile['profile_uid'],'item', $category, TERM_CATEGORY)); } if(x($hashtags)) { - $sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG)); + $sql_extra2 .= protect_sprintf(term_item_parent_query(\App::$profile['profile_uid'],'item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG)); } if($datequery) { -- cgit v1.2.3 From 2e692fca93158748f99eab651bd0782b27044b8d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 7 Jun 2017 20:28:59 -0700 Subject: partial fix for failure to sync photos - appears to be memory exhaustion and dependent on filesize although an unrelated issue was found with directory creation during file sync (we didn't check ownership when looking for duplicates). This checkin provides the means for a sync process to fetch the contents for various photo scales from the original server just as is done for the attach data now. It is still missing the bit for the sync process to spawn a mob of children to fetch these suckers and update the photo table with the results. --- Zotlabs/Module/Getfile.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Getfile.php b/Zotlabs/Module/Getfile.php index 3d859d94b..0b05d78a4 100644 --- a/Zotlabs/Module/Getfile.php +++ b/Zotlabs/Module/Getfile.php @@ -35,6 +35,7 @@ class Getfile extends \Zotlabs\Web\Controller { $sig = $_POST['signature']; $resource = $_POST['resource']; $revision = intval($_POST['revision']); + $resolution = (-1); if(! $hash) killme(); @@ -46,6 +47,11 @@ class Getfile extends \Zotlabs\Web\Controller { killme(); } + if(substr($resource,-2,1) == '-') { + $resolution = intval(substr($resource,-1,1)); + $resource = substr($resource,0,-2); + } + $slop = intval(get_pconfig($channel['channel_id'],'system','getfile_time_slop')); if($slop < 1) $slop = 3; @@ -63,6 +69,35 @@ class Getfile extends \Zotlabs\Web\Controller { killme(); } + + if($resolution > 0) { + $r = q("select * from photo where resource_id = '%s' and uid = %d limit 1", + dbesc($resource), + intval($channel['channel_id']) + ); + if($r) { + header('Content-type: ' . $r[0]['mimetype']); + + if(intval($r[0]['os_storage'])) { + $fname = dbunescbin($r[0]['content']); + if(strpos($fname,'store') !== false) + $istream = fopen($fname,'rb'); + else + $istream = fopen('store/' . $channel['channel_address'] . '/' . $fname,'rb'); + $ostream = fopen('php://output','wb'); + if($istream && $ostream) { + pipe_streams($istream,$ostream); + fclose($istream); + fclose($ostream); + } + } + else { + echo dbunescbin($r[0]['content']); + } + } + killme(); + } + $r = attach_by_hash($resource,$channel['channel_hash'],$revision); if(! $r['success']) { -- cgit v1.2.3 From 30358100ab729e7ce7bd3f05cc64a391239906e0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 7 Jun 2017 20:28:59 -0700 Subject: partial fix for failure to sync photos - appears to be memory exhaustion and dependent on filesize although an unrelated issue was found with directory creation during file sync (we didn't check ownership when looking for duplicates). This checkin provides the means for a sync process to fetch the contents for various photo scales from the original server just as is done for the attach data now. It is still missing the bit for the sync process to spawn a mob of children to fetch these suckers and update the photo table with the results. --- Zotlabs/Module/Getfile.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Getfile.php b/Zotlabs/Module/Getfile.php index 3d859d94b..0b05d78a4 100644 --- a/Zotlabs/Module/Getfile.php +++ b/Zotlabs/Module/Getfile.php @@ -35,6 +35,7 @@ class Getfile extends \Zotlabs\Web\Controller { $sig = $_POST['signature']; $resource = $_POST['resource']; $revision = intval($_POST['revision']); + $resolution = (-1); if(! $hash) killme(); @@ -46,6 +47,11 @@ class Getfile extends \Zotlabs\Web\Controller { killme(); } + if(substr($resource,-2,1) == '-') { + $resolution = intval(substr($resource,-1,1)); + $resource = substr($resource,0,-2); + } + $slop = intval(get_pconfig($channel['channel_id'],'system','getfile_time_slop')); if($slop < 1) $slop = 3; @@ -63,6 +69,35 @@ class Getfile extends \Zotlabs\Web\Controller { killme(); } + + if($resolution > 0) { + $r = q("select * from photo where resource_id = '%s' and uid = %d limit 1", + dbesc($resource), + intval($channel['channel_id']) + ); + if($r) { + header('Content-type: ' . $r[0]['mimetype']); + + if(intval($r[0]['os_storage'])) { + $fname = dbunescbin($r[0]['content']); + if(strpos($fname,'store') !== false) + $istream = fopen($fname,'rb'); + else + $istream = fopen('store/' . $channel['channel_address'] . '/' . $fname,'rb'); + $ostream = fopen('php://output','wb'); + if($istream && $ostream) { + pipe_streams($istream,$ostream); + fclose($istream); + fclose($ostream); + } + } + else { + echo dbunescbin($r[0]['content']); + } + } + killme(); + } + $r = attach_by_hash($resource,$channel['channel_hash'],$revision); if(! $r['success']) { -- cgit v1.2.3 From 236b5285521cb4dbe207a11c0adb005b2ef05c87 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 8 Jun 2017 16:38:07 -0700 Subject: indicate on connections page if a federated connection from another network is unavailable from the current location --- Zotlabs/Module/Connections.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index b079ae860..bb223fb01 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -243,7 +243,8 @@ class Connections extends \Zotlabs\Web\Controller { ((intval($rr['abook_archived'])) ? t('Archived') : ''), ((intval($rr['abook_hidden'])) ? t('Hidden') : ''), ((intval($rr['abook_ignored'])) ? t('Ignored') : ''), - ((intval($rr['abook_blocked'])) ? t('Blocked') : '') + ((intval($rr['abook_blocked'])) ? t('Blocked') : ''), + ((intval($rr['abook_not_here'])) ? t('Not connected at this location') : '') ); foreach($status as $str) { @@ -261,7 +262,7 @@ class Connections extends \Zotlabs\Web\Controller { 'id' => $rr['abook_id'], 'thumb' => $rr['xchan_photo_m'], 'name' => $rr['xchan_name'], - 'classes' => (intval($rr['abook_archived']) ? 'archived' : ''), + 'classes' => ((intval($rr['abook_archived']) || intval($rr['abook_not_here'])) ? 'archived' : ''), 'link' => z_root() . '/connedit/' . $rr['abook_id'], 'deletelink' => z_root() . '/connedit/' . intval($rr['abook_id']) . '/drop', 'delete' => t('Delete'), -- cgit v1.2.3 From cf583168dd1b3ea461e07918eda404546d8136f4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 8 Jun 2017 19:15:55 -0700 Subject: put unreachable federated connections in the archived tab of the connections list page --- Zotlabs/Module/Connections.php | 8 ++++---- Zotlabs/Module/Connedit.php | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index bb223fb01..a880fc643 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -19,7 +19,7 @@ class Connections extends \Zotlabs\Web\Controller { } - function get() { + function get() { $sort_type = 0; $o = ''; @@ -63,8 +63,8 @@ class Connections extends \Zotlabs\Web\Controller { $hidden = true; break; case 'archived': - $search_flags = " and abook_archived = 1 "; - $head = t('Archived'); + $search_flags = " and ( abook_archived = 1 OR abook_not_here = 1) "; + $head = t('Archived/Unreachable'); $archived = true; break; case 'pending': @@ -171,7 +171,7 @@ class Connections extends \Zotlabs\Web\Controller { 'label' => t('Archived'), 'url' => z_root() . '/connections/archived', 'sel' => ($archived) ? 'active' : '', - 'title' => t('Only show archived connections'), + 'title' => t('Only show archived/unreachable connections'), ), 'hidden' => array( diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php index 484e69b52..a42987fcf 100644 --- a/Zotlabs/Module/Connedit.php +++ b/Zotlabs/Module/Connedit.php @@ -856,6 +856,7 @@ class Connedit extends \Zotlabs\Web\Controller { '$addr_text' => t('This connection\'s primary address is'), '$loc_text' => t('Available locations:'), '$locstr' => $locstr, + '$not_here' => ((intval($contact['abook_not_here'])) ? t('Not connected at this location') : ''), '$notself' => (($self) ? '' : '1'), '$self' => (($self) ? '1' : ''), '$autolbl' => t('The permissions indicated on this page will be applied to all new connections.'), -- cgit v1.2.3 From 97732f70063325ac875498a413e9ac1b6fca51f5 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 26 Apr 2017 23:05:30 -0700 Subject: more client-side mail privacy work --- Zotlabs/Module/Mail.php | 74 +++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 46 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index d605a78a9..f6add7778 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -22,32 +22,40 @@ class Mail extends \Zotlabs\Web\Controller { $recipient = ((x($_REQUEST,'messageto')) ? notags(trim($_REQUEST['messageto'])) : ''); $rstr = ((x($_REQUEST,'messagerecip')) ? notags(trim($_REQUEST['messagerecip'])) : ''); $preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0); - $expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE); + $expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE); + $raw = ((x($_REQUEST,'raw')) ? intval($_REQUEST['raw']) : 0); + $mimetype = ((x($_REQUEST,'mimetype')) ? notags(trim($_REQUEST['mimetype'])) : 'text/bbcode'); if($preview) { - $body = cleanup_bbcode($body); - $results = linkify_tags($a, $body, local_channel()); + if($raw) { + $body = mail_prepare_binary(['id' => 'M0']); + echo json_encode(['preview' => $body]); + } + else { + $body = cleanup_bbcode($body); + $results = linkify_tags($a, $body, local_channel()); - if(preg_match_all('/(\[attachment\](.*?)\[\/attachment\])/',$body,$match)) { - $attachments = array(); - foreach($match[2] as $mtch) { - $hash = substr($mtch,0,strpos($mtch,',')); - $rev = intval(substr($mtch,strpos($mtch,','))); - $r = attach_by_hash_nodata($hash,get_observer_hash(),$rev); - if($r['success']) { - $attachments[] = array( - 'href' => z_root() . '/attach/' . $r['data']['hash'], - 'length' => $r['data']['filesize'], - 'type' => $r['data']['filetype'], - 'title' => urlencode($r['data']['filename']), - 'revision' => $r['data']['revision'] - ); + if(preg_match_all('/(\[attachment\](.*?)\[\/attachment\])/',$body,$match)) { + $attachments = array(); + foreach($match[2] as $mtch) { + $hash = substr($mtch,0,strpos($mtch,',')); + $rev = intval(substr($mtch,strpos($mtch,','))); + $r = attach_by_hash_nodata($hash,get_observer_hash(),$rev); + if($r['success']) { + $attachments[] = array( + 'href' => z_root() . '/attach/' . $r['data']['hash'], + 'length' => $r['data']['filesize'], + 'type' => $r['data']['filetype'], + 'title' => urlencode($r['data']['filename']), + 'revision' => $r['data']['revision'] + ); + } + $body = trim(str_replace($match[1],'',$body)); } - $body = trim(str_replace($match[1],'',$body)); + echo json_encode(['preview' => zidify_links(smilies(bbcode($body)))]); } } - echo json_encode(['preview' => zidify_links(smilies(bbcode($body)))]); killme(); } @@ -102,36 +110,10 @@ class Mail extends \Zotlabs\Web\Controller { } } - // if(feature_enabled(local_channel(),'richtext')) { - // $body = fix_mce_lf($body); - // } - require_once('include/text.php'); linkify_tags($a, $body, local_channel()); - // I don't think this is used any more. - - if($preview) { - $mail = [ - 'mailbox' => 'outbox', - 'id' => 0, - 'mid' => 'M0', - 'from_name' => $channel['xchan_name'], - 'from_url' => $channel['xchan_url'], - 'from_photo' => $channel['xchan_photo_s'], - 'subject' => zidify_links(smilies(bbcode($subject))), - 'body' => zidify_links(smilies(bbcode($body))), - 'attachments' => '', - 'can_recall' => false, - 'is_recalled' => '', - 'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'], 'c') - ]; - - echo replace_macros(get_markup_template('mail_conv.tpl'), [ '$mail' => $mail ] ); - killme(); - } - if(! $recipient) { notice('No recipient found.'); \App::$argc = 2; @@ -141,7 +123,7 @@ class Mail extends \Zotlabs\Web\Controller { // We have a local_channel, let send_message use the session channel and save a lookup - $ret = send_message(0, $recipient, $body, $subject, $replyto, $expires); + $ret = send_message(0, $recipient, $body, $subject, $replyto, $expires, $mimetype, $raw); if($ret['success']) { xchan_mail_query($ret['mail']); -- cgit v1.2.3 From 42c9f853a7d878fef7f545b58a744c134baabc02 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 9 Jun 2017 15:24:37 -0700 Subject: auto inline embed ostatus image attachments --- Zotlabs/Module/Connections.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index a880fc643..60b798c13 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -168,7 +168,7 @@ class Connections extends \Zotlabs\Web\Controller { ), 'archived' => array( - 'label' => t('Archived'), + 'label' => t('Archived/Unreachable'), 'url' => z_root() . '/connections/archived', 'sel' => ($archived) ? 'active' : '', 'title' => t('Only show archived/unreachable connections'), -- cgit v1.2.3 From 2a4032d71aaa8934ce948f549e55e53d14cdfc93 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 9 Jun 2017 16:26:30 -0700 Subject: clean up the warnings about connections on unclonable networks --- Zotlabs/Module/Connedit.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php index a42987fcf..d301c2d45 100644 --- a/Zotlabs/Module/Connedit.php +++ b/Zotlabs/Module/Connedit.php @@ -842,6 +842,22 @@ class Connedit extends \Zotlabs\Web\Controller { } else $locstr = t('none'); + + $clone_warn = ''; + $clonable = (in_array($contact['xchan_network'],['zot','rss']) ? true : false); + if(! $clonable) { + $clone_warn = ''; + $clone_warn .= ((intval($contact['abook_not_here'])) + ? t('This connection is unreachable from this location.') + : t('This connection may be unreachable from other channel locations.') + ); + $clone_warn .= '
' . t('Location independence is not supported by their network.'); + } + + + + if(intval($contact['abook_not_here']) && $unclonable) + $not_here = t('This connection is unreachable from this location. Location independence is not supported by their network.'); $o .= replace_macros($tpl, [ '$header' => (($self) ? t('Connection Default Permissions') : sprintf( t('Connection: %s'),$contact['xchan_name'])), @@ -856,7 +872,7 @@ class Connedit extends \Zotlabs\Web\Controller { '$addr_text' => t('This connection\'s primary address is'), '$loc_text' => t('Available locations:'), '$locstr' => $locstr, - '$not_here' => ((intval($contact['abook_not_here'])) ? t('Not connected at this location') : ''), + '$unclonable' => $clone_warn, '$notself' => (($self) ? '' : '1'), '$self' => (($self) ? '1' : ''), '$autolbl' => t('The permissions indicated on this page will be applied to all new connections.'), -- cgit v1.2.3 From fce68f1a39c73246ad449aee1bf7a4b9aba9837f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 13 Jun 2017 18:29:08 -0700 Subject: add rel=noopener to all external target _blank links --- Zotlabs/Module/Oembed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Oembed.php b/Zotlabs/Module/Oembed.php index 9394e5942..aee5ea079 100644 --- a/Zotlabs/Module/Oembed.php +++ b/Zotlabs/Module/Oembed.php @@ -22,7 +22,7 @@ class Oembed extends \Zotlabs\Web\Controller { } else { - echo ""; + echo ""; $src = base64url_decode(argv(1)); $j = oembed_fetch_url($src); echo $j['html']; -- cgit v1.2.3 From dcbc65a796facf17d2194f0c6a738f43bfe2cc40 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 13 Jun 2017 18:29:08 -0700 Subject: add rel=noopener to all external target _blank links --- Zotlabs/Module/Oembed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Oembed.php b/Zotlabs/Module/Oembed.php index 9394e5942..aee5ea079 100644 --- a/Zotlabs/Module/Oembed.php +++ b/Zotlabs/Module/Oembed.php @@ -22,7 +22,7 @@ class Oembed extends \Zotlabs\Web\Controller { } else { - echo ""; + echo ""; $src = base64url_decode(argv(1)); $j = oembed_fetch_url($src); echo $j['html']; -- cgit v1.2.3 From b917cf1eccc62f5f533c0a61ffd699764b39e404 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 18 Jun 2017 22:25:41 -0700 Subject: allow moderated comments like wordpress if permissions are compatible --- Zotlabs/Module/Item.php | 31 +++++++++++++-- Zotlabs/Module/Moderate.php | 77 +++++++++++++++++++++++++++++++++++++ Zotlabs/Module/Settings/Channel.php | 2 +- 3 files changed, 105 insertions(+), 5 deletions(-) create mode 100644 Zotlabs/Module/Moderate.php (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index ec36c22d8..952ecf487 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -33,7 +33,7 @@ class Item extends \Zotlabs\Web\Controller { // This will change. Figure out who the observer is and whether or not // they have permission to post here. Else ignore the post. - if((! local_channel()) && (! remote_channel()) && (! x($_REQUEST,'commenter'))) + if((! local_channel()) && (! remote_channel()) && (! x($_REQUEST,'anonname'))) return; $uid = local_channel(); @@ -77,7 +77,7 @@ class Item extends \Zotlabs\Web\Controller { call_hooks('post_local_start', $_REQUEST); - // logger('postvars ' . print_r($_REQUEST,true), LOGGER_DATA); + // logger('postvars ' . print_r($_REQUEST,true), LOGGER_DATA); $api_source = ((x($_REQUEST,'api_source') && $_REQUEST['api_source']) ? true : false); @@ -205,10 +205,29 @@ class Item extends \Zotlabs\Web\Controller { $route = $parent_item['route']; } + + $moderated = false; - if(! $observer) + if(! $observer) { $observer = \App::get_observer(); + if(! $observer) { + $observer = anon_identity_init($_REQUEST); + if($observer) { + $moderated = true; + $remote_xchan = $remote_observer = $observer; + } + } + } + if(! $observer) { + notice( t('Permission denied.') . EOL) ; + if($api_source) + return ( [ 'success' => false, 'message' => 'permission denied' ] ); + if(x($_REQUEST,'return')) + goaway(z_root() . "/" . $return_path ); + killme(); + } + if($parent) { logger('mod_item: item_post parent=' . $parent); $can_comment = false; @@ -312,7 +331,7 @@ class Item extends \Zotlabs\Web\Controller { $walltowall = false; $walltowall_comment = false; - if($remote_xchan) + if($remote_xchan && ! $moderated) $observer = $remote_observer; if($observer) { @@ -996,6 +1015,10 @@ class Item extends \Zotlabs\Web\Controller { \Zotlabs\Daemon\Master::Summon(array('Notifier', $notify_type, $post_id)); logger('post_complete'); + + if($moderated) { + info(t('Your comment is awaiting approval.') . EOL); + } // figure out how to return, depending on from whence we came diff --git a/Zotlabs/Module/Moderate.php b/Zotlabs/Module/Moderate.php new file mode 100644 index 000000000..b7f05e4b2 --- /dev/null +++ b/Zotlabs/Module/Moderate.php @@ -0,0 +1,77 @@ + 2) { + $post_id = intval(argv(1)); + if(! $post_id) + goaway(z_root() . '/moderate'); + + $action = argv(2); + + $r = q("select * from item where uid = %d and id = %d and item_blocked = %d limit 1", + intval(local_channel()), + intval($post_id), + intval(ITEM_MODERATED) + ); + + + + if($r) { + if($action === 'approve') { + q("update item set item_blocked = 0 where uid = %d and id = %d", + intval(local_channel()), + intval($post_id) + ); + notice( t('Comment approved') . EOL); + } + elseif($action === 'drop') { + drop_item($post_id,false); + notice( t('Comment deleted') . EOL); + } + } + + $r = q("select * from item where id = %d", + intval($post_id) + ); + if($r) { + xchan_query($r); + $sync_item = fetch_post_tags($r); + build_sync_packet(local_channel(),array('item' => array(encode_item($sync_item[0],true)))); + } + goaway(z_root() . '/moderate'); + } + + $r = q("select item.id as item_id, item.* from item where item.uid = %d and item_blocked = %d and item_deleted = 0 order by created desc limit 60", + intval(local_channel()), + intval(ITEM_MODERATED) + ); + + if($r) { + xchan_query($r); + $items = fetch_post_tags($r,true); + } + else { + $items = array(); + } + + $o = conversation($a,$items,'moderate',false,'traditional'); + + return $o; + + } + +} \ No newline at end of file diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index 7c30ef93e..3e6adcf8d 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -324,7 +324,7 @@ class Channel { foreach($global_perms as $k => $perm) { $options = array(); foreach($perm_opts as $opt) { - if((! strstr($k,'view')) && $opt[1] == PERMS_PUBLIC) + if(((! strstr($k,'view')) && $k !== 'post_comments') && $opt[1] == PERMS_PUBLIC) continue; $options[$opt[1]] = $opt[0]; } -- cgit v1.2.3 From 1472f85b162ea6f1ab9e19e94b86fc4a8ef074be Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 18 Jun 2017 22:25:41 -0700 Subject: allow moderated comments like wordpress if permissions are compatible --- Zotlabs/Module/Item.php | 31 +++++++++++++-- Zotlabs/Module/Moderate.php | 77 +++++++++++++++++++++++++++++++++++++ Zotlabs/Module/Settings/Channel.php | 2 +- 3 files changed, 105 insertions(+), 5 deletions(-) create mode 100644 Zotlabs/Module/Moderate.php (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index ec36c22d8..952ecf487 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -33,7 +33,7 @@ class Item extends \Zotlabs\Web\Controller { // This will change. Figure out who the observer is and whether or not // they have permission to post here. Else ignore the post. - if((! local_channel()) && (! remote_channel()) && (! x($_REQUEST,'commenter'))) + if((! local_channel()) && (! remote_channel()) && (! x($_REQUEST,'anonname'))) return; $uid = local_channel(); @@ -77,7 +77,7 @@ class Item extends \Zotlabs\Web\Controller { call_hooks('post_local_start', $_REQUEST); - // logger('postvars ' . print_r($_REQUEST,true), LOGGER_DATA); + // logger('postvars ' . print_r($_REQUEST,true), LOGGER_DATA); $api_source = ((x($_REQUEST,'api_source') && $_REQUEST['api_source']) ? true : false); @@ -205,10 +205,29 @@ class Item extends \Zotlabs\Web\Controller { $route = $parent_item['route']; } + + $moderated = false; - if(! $observer) + if(! $observer) { $observer = \App::get_observer(); + if(! $observer) { + $observer = anon_identity_init($_REQUEST); + if($observer) { + $moderated = true; + $remote_xchan = $remote_observer = $observer; + } + } + } + if(! $observer) { + notice( t('Permission denied.') . EOL) ; + if($api_source) + return ( [ 'success' => false, 'message' => 'permission denied' ] ); + if(x($_REQUEST,'return')) + goaway(z_root() . "/" . $return_path ); + killme(); + } + if($parent) { logger('mod_item: item_post parent=' . $parent); $can_comment = false; @@ -312,7 +331,7 @@ class Item extends \Zotlabs\Web\Controller { $walltowall = false; $walltowall_comment = false; - if($remote_xchan) + if($remote_xchan && ! $moderated) $observer = $remote_observer; if($observer) { @@ -996,6 +1015,10 @@ class Item extends \Zotlabs\Web\Controller { \Zotlabs\Daemon\Master::Summon(array('Notifier', $notify_type, $post_id)); logger('post_complete'); + + if($moderated) { + info(t('Your comment is awaiting approval.') . EOL); + } // figure out how to return, depending on from whence we came diff --git a/Zotlabs/Module/Moderate.php b/Zotlabs/Module/Moderate.php new file mode 100644 index 000000000..b7f05e4b2 --- /dev/null +++ b/Zotlabs/Module/Moderate.php @@ -0,0 +1,77 @@ + 2) { + $post_id = intval(argv(1)); + if(! $post_id) + goaway(z_root() . '/moderate'); + + $action = argv(2); + + $r = q("select * from item where uid = %d and id = %d and item_blocked = %d limit 1", + intval(local_channel()), + intval($post_id), + intval(ITEM_MODERATED) + ); + + + + if($r) { + if($action === 'approve') { + q("update item set item_blocked = 0 where uid = %d and id = %d", + intval(local_channel()), + intval($post_id) + ); + notice( t('Comment approved') . EOL); + } + elseif($action === 'drop') { + drop_item($post_id,false); + notice( t('Comment deleted') . EOL); + } + } + + $r = q("select * from item where id = %d", + intval($post_id) + ); + if($r) { + xchan_query($r); + $sync_item = fetch_post_tags($r); + build_sync_packet(local_channel(),array('item' => array(encode_item($sync_item[0],true)))); + } + goaway(z_root() . '/moderate'); + } + + $r = q("select item.id as item_id, item.* from item where item.uid = %d and item_blocked = %d and item_deleted = 0 order by created desc limit 60", + intval(local_channel()), + intval(ITEM_MODERATED) + ); + + if($r) { + xchan_query($r); + $items = fetch_post_tags($r,true); + } + else { + $items = array(); + } + + $o = conversation($a,$items,'moderate',false,'traditional'); + + return $o; + + } + +} \ No newline at end of file diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index 56a7d0d8e..12ad25d51 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -324,7 +324,7 @@ class Channel { foreach($global_perms as $k => $perm) { $options = array(); foreach($perm_opts as $opt) { - if((! strstr($k,'view')) && $opt[1] == PERMS_PUBLIC) + if(((! strstr($k,'view')) && $k !== 'post_comments') && $opt[1] == PERMS_PUBLIC) continue; $options[$opt[1]] = $opt[0]; } -- cgit v1.2.3 From 07a8151ae66f1ccf00017f521219afdc2f5370ec Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 20 Jun 2017 12:45:05 -0700 Subject: more anon comment fixes --- Zotlabs/Module/Moderate.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Moderate.php b/Zotlabs/Module/Moderate.php index b7f05e4b2..92df58858 100644 --- a/Zotlabs/Module/Moderate.php +++ b/Zotlabs/Module/Moderate.php @@ -28,8 +28,6 @@ class Moderate extends \Zotlabs\Web\Controller { intval(ITEM_MODERATED) ); - - if($r) { if($action === 'approve') { q("update item set item_blocked = 0 where uid = %d and id = %d", @@ -42,19 +40,21 @@ class Moderate extends \Zotlabs\Web\Controller { drop_item($post_id,false); notice( t('Comment deleted') . EOL); } + + $r = q("select * from item where id = %d", + intval($post_id) + ); + if($r) { + xchan_query($r); + $sync_item = fetch_post_tags($r); + build_sync_packet(local_channel(),array('item' => array(encode_item($sync_item[0],true)))); + } + if($action === 'approve') { + \Zotlabs\Daemon\Master::Summon(array('Notifier', 'comment-new', $post_id)); + } + goaway(z_root() . '/moderate'); } - - $r = q("select * from item where id = %d", - intval($post_id) - ); - if($r) { - xchan_query($r); - $sync_item = fetch_post_tags($r); - build_sync_packet(local_channel(),array('item' => array(encode_item($sync_item[0],true)))); - } - goaway(z_root() . '/moderate'); } - $r = q("select item.id as item_id, item.* from item where item.uid = %d and item_blocked = %d and item_deleted = 0 order by created desc limit 60", intval(local_channel()), intval(ITEM_MODERATED) -- cgit v1.2.3 From 76e98091690cf5f2726bf7cefea217d49b23a5b4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 20 Jun 2017 12:45:05 -0700 Subject: more anon comment fixes --- Zotlabs/Module/Moderate.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Moderate.php b/Zotlabs/Module/Moderate.php index b7f05e4b2..92df58858 100644 --- a/Zotlabs/Module/Moderate.php +++ b/Zotlabs/Module/Moderate.php @@ -28,8 +28,6 @@ class Moderate extends \Zotlabs\Web\Controller { intval(ITEM_MODERATED) ); - - if($r) { if($action === 'approve') { q("update item set item_blocked = 0 where uid = %d and id = %d", @@ -42,19 +40,21 @@ class Moderate extends \Zotlabs\Web\Controller { drop_item($post_id,false); notice( t('Comment deleted') . EOL); } + + $r = q("select * from item where id = %d", + intval($post_id) + ); + if($r) { + xchan_query($r); + $sync_item = fetch_post_tags($r); + build_sync_packet(local_channel(),array('item' => array(encode_item($sync_item[0],true)))); + } + if($action === 'approve') { + \Zotlabs\Daemon\Master::Summon(array('Notifier', 'comment-new', $post_id)); + } + goaway(z_root() . '/moderate'); } - - $r = q("select * from item where id = %d", - intval($post_id) - ); - if($r) { - xchan_query($r); - $sync_item = fetch_post_tags($r); - build_sync_packet(local_channel(),array('item' => array(encode_item($sync_item[0],true)))); - } - goaway(z_root() . '/moderate'); } - $r = q("select item.id as item_id, item.* from item where item.uid = %d and item_blocked = %d and item_deleted = 0 order by created desc limit 60", intval(local_channel()), intval(ITEM_MODERATED) -- cgit v1.2.3 From 31e08127118b81ef223c13966e80f6d448d385d3 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 20 Jun 2017 15:53:01 -0700 Subject: remove deprecated app parameter from conversation() --- Zotlabs/Module/Channel.php | 4 ++-- Zotlabs/Module/Display.php | 4 ++-- Zotlabs/Module/Item.php | 2 +- Zotlabs/Module/Moderate.php | 2 +- Zotlabs/Module/Network.php | 2 +- Zotlabs/Module/Pubstream.php | 2 +- Zotlabs/Module/Search.php | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 98a1e6c88..51c937270 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -365,10 +365,10 @@ class Channel extends \Zotlabs\Web\Controller { if($checkjs->disabled()) { - $o .= conversation($a,$items,'channel',$update,'traditional'); + $o .= conversation($items,'channel',$update,'traditional'); } else { - $o .= conversation($a,$items,'channel',$update,$page_mode); + $o .= conversation($items,'channel',$update,$page_mode); } if((! $update) || ($checkjs->disabled())) { diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 815672091..df3cb1e2b 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -308,12 +308,12 @@ class Display extends \Zotlabs\Web\Controller { if ($checkjs->disabled()) { - $o .= conversation($a, $items, 'display', $update, 'traditional'); + $o .= conversation($items, 'display', $update, 'traditional'); if ($items[0]['title']) \App::$page['title'] = $items[0]['title'] . " - " . \App::$page['title']; } else { - $o .= conversation($a, $items, 'display', $update, 'client'); + $o .= conversation($items, 'display', $update, 'client'); } if($updateable) { diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 952ecf487..e96d4c669 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -818,7 +818,7 @@ class Item extends \Zotlabs\Web\Controller { $datarray['owner'] = $owner_xchan; $datarray['author'] = $observer; $datarray['attach'] = json_encode($datarray['attach']); - $o = conversation($a,array($datarray),'search',false,'preview'); + $o = conversation(array($datarray),'search',false,'preview'); // logger('preview: ' . $o, LOGGER_DEBUG); echo json_encode(array('preview' => $o)); killme(); diff --git a/Zotlabs/Module/Moderate.php b/Zotlabs/Module/Moderate.php index 92df58858..47c373d28 100644 --- a/Zotlabs/Module/Moderate.php +++ b/Zotlabs/Module/Moderate.php @@ -68,7 +68,7 @@ class Moderate extends \Zotlabs\Web\Controller { $items = array(); } - $o = conversation($a,$items,'moderate',false,'traditional'); + $o = conversation($items,'moderate',false,'traditional'); return $o; diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 1c7c70019..f2ad77dd7 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -551,7 +551,7 @@ class Network extends \Zotlabs\Web\Controller { $mode = (($nouveau) ? 'network-new' : 'network'); - $o .= conversation($a,$items,$mode,$update,$page_mode); + $o .= conversation($items,$mode,$update,$page_mode); if(($items) && (! $update)) $o .= alt_pager($a,count($items)); diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 46210abb1..28c34425c 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -167,7 +167,7 @@ class Pubstream extends \Zotlabs\Web\Controller { // fake it $mode = ('network'); - $o .= conversation($a,$items,$mode,$update,$page_mode); + $o .= conversation($items,$mode,$update,$page_mode); if(($items) && (! $update)) $o .= alt_pager($a,count($items)); diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index a78a023ff..2b949ebc7 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -225,7 +225,7 @@ class Search extends \Zotlabs\Web\Controller { else $o .= '

' . sprintf( t('Search results for: %s'),htmlspecialchars($search, ENT_COMPAT,'UTF-8')) . '

'; - $o .= conversation($a,$items,'search',$update,'client'); + $o .= conversation($items,'search',$update,'client'); $o .= ''; -- cgit v1.2.3 From 5f1a1db30fa4eae7c36d73b19e2e725a371138fb Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 21 Jun 2017 17:46:28 -0700 Subject: oopsy --- Zotlabs/Module/Share.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Share.php b/Zotlabs/Module/Share.php index fcc2486ba..5c4811c59 100644 --- a/Zotlabs/Module/Share.php +++ b/Zotlabs/Module/Share.php @@ -76,7 +76,7 @@ class Share extends \Zotlabs\Web\Controller { $observer = \App::get_observer(); $parsed = $observer['xchan_url']; if($parsed) { - $post_url = $parsed['scheme'] . ':' . $parsed['host'] . (($parsed['port']) ? ':' . $parsed['port'] : '') + $post_url = $parsed['scheme'] . '://' . $parsed['host'] . (($parsed['port']) ? ':' . $parsed['port'] : '') . '/rpost'; /** -- cgit v1.2.3 From 37b9a809a600e6bb28b210a2d4dfee986fb28fc9 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 21 Jun 2017 22:11:21 -0700 Subject: start porting cdav proper to core --- Zotlabs/Module/Cdav.php | 1201 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1201 insertions(+) create mode 100644 Zotlabs/Module/Cdav.php (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php new file mode 100644 index 000000000..856956b5b --- /dev/null +++ b/Zotlabs/Module/Cdav.php @@ -0,0 +1,1201 @@ +db; + + // Autoloader + require_once 'vendor/autoload.php'; + + /** + * The backends. Yes we do really need all of them. + * + * This allows any developer to subclass just any of them and hook into their + * own backend systems. + */ + + $auth = new \Zotlabs\Storage\BasicAuth(); + $auth->setRealm(ucfirst(\Zotlabs\Lib\System::get_platform_name()) . 'CalDAV/CardDAV'); + + if (local_channel()) { + logger('loggedin'); + $channel = \App::get_channel(); + $auth->setCurrentUser($channel['channel_address']); + $auth->channel_id = $channel['channel_id']; + $auth->channel_hash = $channel['channel_hash']; + $auth->channel_account_id = $channel['channel_account_id']; + if($channel['channel_timezone']) + $auth->setTimezone($channel['channel_timezone']); + $auth->observer = $channel['channel_hash']; + } + + + $principalBackend = new \Sabre\DAVACL\PrincipalBackend\PDO($pdo); + $carddavBackend = new \Sabre\CardDAV\Backend\PDO($pdo); + $caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo); + + /** + * The directory tree + * + * Basically this is an array which contains the 'top-level' directories in the + * WebDAV server. + */ + + $nodes = [ + // /principals + new \Sabre\CalDAV\Principal\Collection($principalBackend), + // /calendars + new \Sabre\CalDAV\CalendarRoot($principalBackend, $caldavBackend), + // /addressbook + new \Sabre\CardDAV\AddressBookRoot($principalBackend, $carddavBackend), + ]; + + // The object tree needs in turn to be passed to the server class + + $server = new \Sabre\DAV\Server($nodes); + + if(isset($baseUri)) + $server->setBaseUri($baseUri); + + // Plugins + $server->addPlugin(new \Sabre\DAV\Auth\Plugin($auth)); + //$server->addPlugin(new \Sabre\DAV\Browser\Plugin()); + $server->addPlugin(new \Sabre\DAV\Sync\Plugin()); + $server->addPlugin(new \Sabre\DAV\Sharing\Plugin()); + $server->addPlugin(new \Sabre\DAVACL\Plugin()); + + // CalDAV plugins + $server->addPlugin(new \Sabre\CalDAV\Plugin()); + $server->addPlugin(new \Sabre\CalDAV\SharingPlugin()); + //$server->addPlugin(new \Sabre\CalDAV\Schedule\Plugin()); + $server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); + + // CardDAV plugins + $server->addPlugin(new \Sabre\CardDAV\Plugin()); + $server->addPlugin(new \Sabre\CardDAV\VCFExportPlugin()); + + // And off we go! + $server->exec(); + + killme(); + + } + + } + + function post() { + if(! local_channel()) + return; + + $channel = \App::get_channel(); + $principalUri = 'principals/' . $channel['channel_hash']; + + if(!cdav_principal($principalUri)) + return; + + $pdo = \DBA::$dba->db; + + require_once 'vendor/autoload.php'; + + if(argc() == 2 && argv(1) === 'calendar') { + + $caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo); + $calendars = $caldavBackend->getCalendarsForUser($principalUri); + + //create new calendar + if($_REQUEST['{DAV:}displayname'] && $_REQUEST['create']) { + do { + $duplicate = false; + $calendarUri = random_string(40); + + $r = q("SELECT uri FROM calendarinstances WHERE principaluri = '%s' AND uri = '%s' LIMIT 1", + dbesc($principalUri), + dbesc($calendarUri) + ); + + if (count($r)) + $duplicate = true; + } while ($duplicate == true); + + $properties = [ + '{DAV:}displayname' => $_REQUEST['{DAV:}displayname'], + '{http://apple.com/ns/ical/}calendar-color' => $_REQUEST['color'], + '{urn:ietf:params:xml:ns:caldav}calendar-description' => $channel['channel_name'] + ]; + + $id = $caldavBackend->createCalendar($principalUri, $calendarUri, $properties); + + // set new calendar to be visible + set_pconfig(local_channel(), 'cdav_calendar' , $id[0], 1); + } + + //create new calendar object via ajax request + if($_REQUEST['submit'] === 'create_event' && $_REQUEST['title'] && $_REQUEST['target'] && $_REQUEST['dtstart']) { + + $id = explode(':', $_REQUEST['target']); + + if(!cdav_perms($id[0],$calendars,true)) + return; + + $title = $_REQUEST['title']; + $dtstart = new \DateTime($_REQUEST['dtstart']); + if($_REQUEST['dtend']) + $dtend = new \DateTime($_REQUEST['dtend']); + $description = $_REQUEST['description']; + $location = $_REQUEST['location']; + + do { + $duplicate = false; + $objectUri = random_string(40) . '.ics'; + + $r = q("SELECT uri FROM calendarobjects WHERE calendarid = %s AND uri = '%s' LIMIT 1", + intval($id[0]), + dbesc($objectUri) + ); + + if (count($r)) + $duplicate = true; + } while ($duplicate == true); + + + $vcalendar = new \Sabre\VObject\Component\VCalendar([ + 'VEVENT' => [ + 'SUMMARY' => $title, + 'DTSTART' => $dtstart + ] + ]); + if($dtend) + $vcalendar->VEVENT->add('DTEND', $dtend); + if($description) + $vcalendar->VEVENT->add('DESCRIPTION', $description); + if($location) + $vcalendar->VEVENT->add('LOCATION', $location); + + $calendarData = $vcalendar->serialize(); + + $caldavBackend->createCalendarObject($id, $objectUri, $calendarData); + + killme(); + } + + //edit calendar name and color + if($_REQUEST['{DAV:}displayname'] && $_REQUEST['edit'] && $_REQUEST['id']) { + + $id = explode(':', $_REQUEST['id']); + + if(! cdav_perms($id[0],$calendars)) + return; + + $mutations = [ + '{DAV:}displayname' => $_REQUEST['{DAV:}displayname'], + '{http://apple.com/ns/ical/}calendar-color' => $_REQUEST['color'] + ]; + + $patch = new \Sabre\DAV\PropPatch($mutations); + + $caldavBackend->updateCalendar($id, $patch); + + $patch->commit(); + + } + + //edit calendar object via ajax request + if($_REQUEST['submit'] === 'update_event' && $_REQUEST['uri'] && $_REQUEST['title'] && $_REQUEST['target'] && $_REQUEST['dtstart']) { + + $id = explode(':', $_REQUEST['target']); + + if(!cdav_perms($id[0],$calendars,true)) + return; + + $uri = $_REQUEST['uri']; + $title = $_REQUEST['title']; + $dtstart = new \DateTime($_REQUEST['dtstart']); + $dtend = $_REQUEST['dtend'] ? new \DateTime($_REQUEST['dtend']) : ''; + $description = $_REQUEST['description']; + $location = $_REQUEST['location']; + + $object = $caldavBackend->getCalendarObject($id, $uri); + + $vcalendar = \Sabre\VObject\Reader::read($object['calendardata']); + + if($title) + $vcalendar->VEVENT->SUMMARY = $title; + if($dtstart) + $vcalendar->VEVENT->DTSTART = $dtstart; + if($dtend) + $vcalendar->VEVENT->DTEND = $dtend; + else + unset($vcalendar->VEVENT->DTEND); + if($description) + $vcalendar->VEVENT->DESCRIPTION = $description; + if($location) + $vcalendar->VEVENT->LOCATION = $location; + + $calendarData = $vcalendar->serialize(); + + $caldavBackend->updateCalendarObject($id, $uri, $calendarData); + + killme(); + } + + //delete calendar object via ajax request + if($_REQUEST['delete'] && $_REQUEST['uri'] && $_REQUEST['target']) { + + $id = explode(':', $_REQUEST['target']); + + if(!cdav_perms($id[0],$calendars,true)) + return; + + $uri = $_REQUEST['uri']; + + $caldavBackend->deleteCalendarObject($id, $uri); + + killme(); + } + + //edit calendar object date/timeme via ajax request (drag and drop) + if($_REQUEST['update'] && $_REQUEST['id'] && $_REQUEST['uri']) { + + $id = [$_REQUEST['id'][0], $_REQUEST['id'][1]]; + + if(!cdav_perms($id[0],$calendars,true)) + return; + + $uri = $_REQUEST['uri']; + $dtstart = new \DateTime($_REQUEST['dtstart']); + $dtend = $_REQUEST['dtend'] ? new \DateTime($_REQUEST['dtend']) : ''; + + $object = $caldavBackend->getCalendarObject($id, $uri); + + $vcalendar = \Sabre\VObject\Reader::read($object['calendardata']); + + if($dtstart) { + $vcalendar->VEVENT->DTSTART = $dtstart; + } + if($dtend) { + $vcalendar->VEVENT->DTEND = $dtend; + } + else { + unset($vcalendar->VEVENT->DTEND); + } + + $calendarData = $vcalendar->serialize(); + + $caldavBackend->updateCalendarObject($id, $uri, $calendarData); + + killme(); + } + + //share a calendar - this only works on local system (with channels on the same server) + if($_REQUEST['sharee'] && $_REQUEST['share']) { + + $id = [intval($_REQUEST['calendarid']), intval($_REQUEST['instanceid'])]; + + if(! cdav_perms($id[0],$calendars)) + return; + + $hash = $_REQUEST['sharee']; + + $sharee_arr = channelx_by_hash($hash); + + $sharee = new \Sabre\DAV\Xml\Element\Sharee(); + + $sharee->href = 'mailto:' . $sharee_arr['channel_hash']; + $sharee->principal = 'principals/' . $sharee_arr['channel_address']; + $sharee->access = intval($_REQUEST['access']); + $sharee->properties = ['{DAV:}displayname' => $channel['channel_name']]; + + $caldavBackend->updateInvites($id, [$sharee]); + } + } + + if(argc() >= 2 && argv(1) === 'addressbook') { + + $carddavBackend = new \Sabre\CardDAV\Backend\PDO($pdo); + $addressbooks = $carddavBackend->getAddressBooksForUser($principalUri); + + //create new addressbook + if($_REQUEST['{DAV:}displayname'] && $_REQUEST['create']) { + do { + $duplicate = false; + $addressbookUri = random_string(20); + + $r = q("SELECT uri FROM addressbooks WHERE principaluri = '%s' AND uri = '%s' LIMIT 1", + dbesc($principalUri), + dbesc($addressbookUri) + ); + + if (count($r)) + $duplicate = true; + } while ($duplicate == true); + + $properties = ['{DAV:}displayname' => $_REQUEST['{DAV:}displayname']]; + + $carddavBackend->createAddressBook($principalUri, $addressbookUri, $properties); + } + + //edit addressbook + if($_REQUEST['{DAV:}displayname'] && $_REQUEST['edit'] && intval($_REQUEST['id'])) { + + $id = $_REQUEST['id']; + + if(! cdav_perms($id,$addressbooks)) + return; + + $mutations = [ + '{DAV:}displayname' => $_REQUEST['{DAV:}displayname'] + ]; + + $patch = new \Sabre\DAV\PropPatch($mutations); + + $carddavBackend->updateAddressBook($id, $patch); + + $patch->commit(); + } + + //create addressbook card + if($_REQUEST['create'] && $_REQUEST['target'] && $_REQUEST['fn']) { + $id = $_REQUEST['target']; + + do { + $duplicate = false; + $uri = random_string(40) . '.vcf'; + + $r = q("SELECT uri FROM cards WHERE addressbookid = %s AND uri = '%s' LIMIT 1", + intval($id), + dbesc($uri) + ); + + if (count($r)) + $duplicate = true; + } while ($duplicate == true); + + //TODO: this mostly duplictes the procedure in update addressbook card. should move this part to a function to avoid duplication + $fn = $_REQUEST['fn']; + + $vcard = new \Sabre\VObject\Component\VCard([ + 'FN' => $fn, + 'N' => array_reverse(explode(' ', $fn)) + ]); + + $org = $_REQUEST['org']; + if($org) { + $vcard->ORG = $org; + } + + $title = $_REQUEST['title']; + if($title) { + $vcard->TITLE = $title; + } + + $tel = $_REQUEST['tel']; + $tel_type = $_REQUEST['tel_type']; + if($tel) { + $i = 0; + foreach($tel as $item) { + if($item) { + $vcard->add('TEL', $item, ['type' => $tel_type[$i]]); + } + $i++; + } + } + + $email = $_REQUEST['email']; + $email_type = $_REQUEST['email_type']; + if($email) { + $i = 0; + foreach($email as $item) { + if($item) { + $vcard->add('EMAIL', $item, ['type' => $email_type[$i]]); + } + $i++; + } + } + + $impp = $_REQUEST['impp']; + $impp_type = $_REQUEST['impp_type']; + if($impp) { + $i = 0; + foreach($impp as $item) { + if($item) { + $vcard->add('IMPP', $item, ['type' => $impp_type[$i]]); + } + $i++; + } + } + + $url = $_REQUEST['url']; + $url_type = $_REQUEST['url_type']; + if($url) { + $i = 0; + foreach($url as $item) { + if($item) { + $vcard->add('URL', $item, ['type' => $url_type[$i]]); + } + $i++; + } + } + + $adr = $_REQUEST['adr']; + $adr_type = $_REQUEST['adr_type']; + + if($adr) { + $i = 0; + foreach($adr as $item) { + if($item) { + $vcard->add('ADR', $item, ['type' => $adr_type[$i]]); + } + $i++; + } + } + + $note = $_REQUEST['note']; + if($note) { + $vcard->NOTE = $note; + } + + $cardData = $vcard->serialize(); + + $carddavBackend->createCard($id, $uri, $cardData); + + } + + //edit addressbook card + if($_REQUEST['update'] && $_REQUEST['uri'] && $_REQUEST['target']) { + + $id = $_REQUEST['target']; + + if(!cdav_perms($id,$addressbooks)) + return; + + $uri = $_REQUEST['uri']; + + $object = $carddavBackend->getCard($id, $uri); + $vcard = \Sabre\VObject\Reader::read($object['carddata']); + + $fn = $_REQUEST['fn']; + if($fn) { + $vcard->FN = $fn; + $vcard->N = array_reverse(explode(' ', $fn)); + } + + $org = $_REQUEST['org']; + if($org) { + $vcard->ORG = $org; + } + else { + unset($vcard->ORG); + } + + $title = $_REQUEST['title']; + if($title) { + $vcard->TITLE = $title; + } + else { + unset($vcard->TITLE); + } + + $tel = $_REQUEST['tel']; + $tel_type = $_REQUEST['tel_type']; + if($tel) { + $i = 0; + unset($vcard->TEL); + foreach($tel as $item) { + if($item) { + $vcard->add('TEL', $item, ['type' => $tel_type[$i]]); + } + $i++; + } + } + else { + unset($vcard->TEL); + } + + $email = $_REQUEST['email']; + $email_type = $_REQUEST['email_type']; + if($email) { + $i = 0; + unset($vcard->EMAIL); + foreach($email as $item) { + if($item) { + $vcard->add('EMAIL', $item, ['type' => $email_type[$i]]); + } + $i++; + } + } + else { + unset($vcard->EMAIL); + } + + $impp = $_REQUEST['impp']; + $impp_type = $_REQUEST['impp_type']; + if($impp) { + $i = 0; + unset($vcard->IMPP); + foreach($impp as $item) { + if($item) { + $vcard->add('IMPP', $item, ['type' => $impp_type[$i]]); + } + $i++; + } + } + else { + unset($vcard->IMPP); + } + + $url = $_REQUEST['url']; + $url_type = $_REQUEST['url_type']; + if($url) { + $i = 0; + unset($vcard->URL); + foreach($url as $item) { + if($item) { + $vcard->add('URL', $item, ['type' => $url_type[$i]]); + } + $i++; + } + } + else { + unset($vcard->URL); + } + + $adr = $_REQUEST['adr']; + $adr_type = $_REQUEST['adr_type']; + if($adr) { + $i = 0; + unset($vcard->ADR); + foreach($adr as $item) { + if($item) { + $vcard->add('ADR', $item, ['type' => $adr_type[$i]]); + } + $i++; + } + } + else { + unset($vcard->ADR); + } + + $note = $_REQUEST['note']; + if($note) { + $vcard->NOTE = $note; + } + else { + unset($vcard->NOTE); + } + + $cardData = $vcard->serialize(); + + $carddavBackend->updateCard($id, $uri, $cardData); + } + + //delete addressbook card + if($_REQUEST['delete'] && $_REQUEST['uri'] && $_REQUEST['target']) { + + $id = $_REQUEST['target']; + + if(!cdav_perms($id,$addressbooks)) + return; + + $uri = $_REQUEST['uri']; + + $carddavBackend->deleteCard($id, $uri); + } + } + + //Import calendar or addressbook + if(($_FILES) && array_key_exists('userfile',$_FILES) && intval($_FILES['userfile']['size']) && $_REQUEST['target']) { + + $src = @file_get_contents($_FILES['userfile']['tmp_name']); + + if($src) { + + if($_REQUEST['c_upload']) { + $id = explode(':', $_REQUEST['target']); + $ext = 'ics'; + $table = 'calendarobjects'; + $column = 'calendarid'; + $objects = new \Sabre\VObject\Splitter\ICalendar($src); + $profile = \Sabre\VObject\Node::PROFILE_CALDAV; + $backend = new \Sabre\CalDAV\Backend\PDO($pdo); + } + + if($_REQUEST['a_upload']) { + $id[] = intval($_REQUEST['target']); + $ext = 'vcf'; + $table = 'cards'; + $column = 'addressbookid'; + $objects = new \Sabre\VObject\Splitter\VCard($src); + $profile = \Sabre\VObject\Node::PROFILE_CARDDAV; + $backend = new \Sabre\CardDAV\Backend\PDO($pdo); + } + + while ($object = $objects->getNext()) { + + if($_REQUEST['a_upload']) { + $object = $object->convert(\Sabre\VObject\Document::VCARD40); + } + + $ret = $object->validate($profile & \Sabre\VObject\Node::REPAIR); + + //level 3 Means that the document is invalid, + //level 2 means a warning. A warning means it's valid but it could cause interopability issues, + //level 1 means that there was a problem earlier, but the problem was automatically repaired. + + if($ret[0]['level'] < 3) { + do { + $duplicate = false; + $objectUri = random_string(40) . '.' . $ext; + + $r = q("SELECT uri FROM $table WHERE $column = %d AND uri = '%s' LIMIT 1", + dbesc($id[0]), + dbesc($objectUri) + ); + + if (count($r)) + $duplicate = true; + } while ($duplicate == true); + + if($_REQUEST['c_upload']) { + $backend->createCalendarObject($id, $objectUri, $object->serialize()); + } + + if($_REQUEST['a_upload']) { + $backend->createCard($id[0], $objectUri, $object->serialize()); + } + } + else { + if($_REQUEST['c_upload']) { + notice( '' . t('INVALID EVENT DISMISSED!') . '' . EOL . + '' . t('Summary: ') . '' . (($object->VEVENT->SUMMARY) ? $object->VEVENT->SUMMARY : t('Unknown')) . EOL . + '' . t('Date: ') . '' . (($object->VEVENT->DTSTART) ? $object->VEVENT->DTSTART : t('Unknown')) . EOL . + '' . t('Reason: ') . '' . $ret[0]['message'] . EOL + ); + } + + if($_REQUEST['a_upload']) { + notice( '' . t('INVALID CARD DISMISSED!') . '' . EOL . + '' . t('Name: ') . '' . (($object->FN) ? $object->FN : t('Unknown')) . EOL . + '' . t('Reason: ') . '' . $ret[0]['message'] . EOL + ); + } + } + } + } + @unlink($src); + } + } + + function get() { + + if(!local_channel()) + return; + + $channel = \App::get_channel(); + $principalUri = 'principals/' . $channel['channel_hash']; + + + if(!cdav_principal($principalUri)) { + $this->activate($channel); + if(!cdav_principal($principalUri)) { + return; + } + } + + $pdo = \DBA::$dba->db; + + require_once 'vendor/autoload.php'; + + head_add_css('/addon/cdav/view/css/cdav.css'); + + if(argv(1) === 'calendar') { + $caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo); + $calendars = $caldavBackend->getCalendarsForUser($principalUri); + } + + //Display calendar(s) here + if(argc() == 2 && argv(1) === 'calendar') { + + head_add_css('/library/fullcalendar/fullcalendar.css'); + head_add_css('/addon/cdav/view/css/cdav_calendar.css'); + + head_add_js('/library/moment/moment.min.js', 1); + head_add_js('/library/fullcalendar/fullcalendar.min.js', 1); + head_add_js('/library/fullcalendar/locale-all.js', 1); + + foreach($calendars as $calendar) { + $editable = (($calendar['share-access'] == 2) ? 'false' : 'true'); // false/true must be string since we're passing it to javascript + $color = (($calendar['{http://apple.com/ns/ical/}calendar-color']) ? $calendar['{http://apple.com/ns/ical/}calendar-color'] : '#3a87ad'); + $sharer = (($calendar['share-access'] == 3) ? $calendar['{urn:ietf:params:xml:ns:caldav}calendar-description'] : ''); + $switch = get_pconfig(local_channel(), 'cdav_calendar', $calendar['id'][0]); + if($switch) { + $sources .= '{ + url: \'/cdav/calendar/json/' . $calendar['id'][0] . '/' . $calendar['id'][1] . '\', + color: \'' . $color . '\' + }, '; + } + + if($calendar['share-access'] != 2) { + $writable_calendars[] = [ + 'displayname' => $calendar['{DAV:}displayname'], + 'sharer' => $sharer, + 'id' => $calendar['id'] + ]; + } + } + + $sources = rtrim($sources, ', '); + + $first_day = get_pconfig(local_channel(),'system','cal_first_day'); + $first_day = (($first_day) ? $first_day : 0); + + $title = ['title', t('Event title')]; + $dtstart = ['dtstart', t('Start date and time'), '', t('Example: YYYY-MM-DD HH:mm')]; + $dtend = ['dtend', t('End date and time'), '', t('Example: YYYY-MM-DD HH:mm')]; + $description = ['description', t('Description')]; + $location = ['location', t('Location')]; + + $o .= replace_macros(get_markup_template('cdav_calendar.tpl', 'addon/cdav'), [ + '$sources' => $sources, + '$color' => $color, + '$lang' => \App::$language, + '$first_day' => $first_day, + '$prev' => t('Previous'), + '$next' => t('Next'), + '$today' => t('Today'), + '$month' => t('Month'), + '$week' => t('Week'), + '$day' => t('Day'), + '$list_month' => t('List month'), + '$list_week' => t('List week'), + '$list_day' => t('List day'), + '$title' => $title, + '$writable_calendars' => $writable_calendars, + '$dtstart' => $dtstart, + '$dtend' => $dtend, + '$description' => $description, + '$location' => $location, + '$more' => t('More'), + '$less' => t('Less'), + '$calendar_select_label' => t('Select calendar'), + '$delete' => t('Delete'), + '$delete_all' => t('Delete all'), + '$cancel' => t('Cancel'), + '$recurrence_warning' => t('Sorry! Editing of recurrent events is not yet implemented.') + ]); + + return $o; + + } + + //Provide json data for calendar + if(argc() == 5 && argv(1) === 'calendar' && argv(2) === 'json' && intval(argv(3)) && intval(argv(4))) { + + $id = [argv(3), argv(4)]; + + if(! cdav_perms($id[0],$calendars)) + killme(); + + if (x($_GET,'start')) + $start = new \DateTime($_GET['start']); + if (x($_GET,'end')) + $end = new \DateTime($_GET['end']); + + $filters['name'] = 'VCALENDAR'; + $filters['prop-filters'][0]['name'] = 'VEVENT'; + $filters['comp-filters'][0]['name'] = 'VEVENT'; + $filters['comp-filters'][0]['time-range']['start'] = $start; + $filters['comp-filters'][0]['time-range']['end'] = $end; + + $uris = $caldavBackend->calendarQuery($id, $filters); + if($uris) { + + $objects = $caldavBackend->getMultipleCalendarObjects($id, $uris); + + foreach($objects as $object) { + + $vcalendar = \Sabre\VObject\Reader::read($object['calendardata']); + + if(isset($vcalendar->VEVENT->RRULE)) + $vcalendar = $vcalendar->expand($start, $end); + + foreach($vcalendar->VEVENT as $vevent) { + $title = (string)$vevent->SUMMARY; + $dtstart = (string)$vevent->DTSTART; + $dtend = (string)$vevent->DTEND; + $description = (string)$vevent->DESCRIPTION; + $location = (string)$vevent->LOCATION; + + $rw = ((cdav_perms($id[0],$calendars,true)) ? true : false); + $recurrent = ((isset($vevent->{'RECURRENCE-ID'})) ? true : false); + + $editable = $rw ? true : false; + + if($recurrent) + $editable = false; + + $allDay = false; + + // allDay event rules + if(!strpos($dtstart, 'T') && !strpos($dtend, 'T')) + $allDay = true; + if(strpos($dtstart, 'T000000') && strpos($dtend, 'T000000')) + $allDay = true; + + $events[] = [ + 'calendar_id' => $id, + 'uri' => $object['uri'], + 'title' => $title, + 'start' => $dtstart, + 'end' => $dtend, + 'description' => $description, + 'location' => $location, + 'allDay' => $allDay, + 'editable' => $editable, + 'recurrent' => $recurrent, + 'rw' => $rw + ]; + } + } + json_return_and_die($events); + } + else { + killme(); + } + } + + //enable/disable calendars + if(argc() == 5 && argv(1) === 'calendar' && argv(2) === 'switch' && intval(argv(3)) && (argv(4) == 1 || argv(4) == 0)) { + $id = argv(3); + + if(! cdav_perms($id,$calendars)) + killme(); + + set_pconfig(local_channel(), 'cdav_calendar' , argv(3), argv(4)); + killme(); + } + + //drop calendar + if(argc() == 5 && argv(1) === 'calendar' && argv(2) === 'drop' && intval(argv(3)) && intval(argv(4))) { + $id = [argv(3), argv(4)]; + + if(! cdav_perms($id[0],$calendars)) + killme(); + + $caldavBackend->deleteCalendar($id); + killme(); + } + + //drop sharee + if(argc() == 6 && argv(1) === 'calendar' && argv(2) === 'dropsharee' && intval(argv(3)) && intval(argv(4))) { + + $id = [argv(3), argv(4)]; + $hash = argv(5); + + if(! cdav_perms($id[0],$calendars)) + killme(); + + $sharee_arr = channelx_by_hash($hash); + + $sharee = new \Sabre\DAV\Xml\Element\Sharee(); + + $sharee->href = 'mailto:' . $sharee_arr['channel_hash']; + $sharee->principal = 'principals/' . $sharee_arr['channel_address']; + $sharee->access = 4; + $caldavBackend->updateInvites($id, [$sharee]); + + killme(); + } + + + if(argv(1) === 'addressbook') { + $carddavBackend = new \Sabre\CardDAV\Backend\PDO($pdo); + $addressbooks = $carddavBackend->getAddressBooksForUser($principalUri); + } + + //Display Adressbook here + if(argc() == 3 && argv(1) === 'addressbook' && intval(argv(2))) { + + $id = argv(2); + + $displayname = cdav_perms($id,$addressbooks); + + if(!$displayname) + return; + + head_add_css('/addon/cdav/view/css/cdav_addressbook.css'); + + $o = ''; + + $sabrecards = $carddavBackend->getCards($id); + foreach($sabrecards as $sabrecard) { + $uris[] = $sabrecard['uri']; + } + + if($uris) { + $objects = $carddavBackend->getMultipleCards($id, $uris); + + foreach($objects as $object) { + $vcard = \Sabre\VObject\Reader::read($object['carddata']); + + $photo = ''; + if($vcard->PHOTO) { + $photo_value = strtolower($vcard->PHOTO->getValueType()); // binary or uri + if($photo_value === 'binary') { + $photo_type = strtolower($vcard->PHOTO['TYPE']); // mime jpeg, png or gif + $photo = 'data:image/' . $photo_type . ';base64,' . base64_encode((string)$vcard->PHOTO); + } + else { + $url = parse_url((string)$vcard->PHOTO); + $photo = 'data:' . $url['path']; + } + } + + $fn = ''; + if($vcard->FN) { + $fn = (string)$vcard->FN; + } + + $org = ''; + if($vcard->ORG) { + $org = (string)$vcard->ORG; + } + + $title = ''; + if($vcard->TITLE) { + $title = (string)$vcard->TITLE; + } + + $tels = []; + if($vcard->TEL) { + foreach($vcard->TEL as $tel) { + $type = (($tel['TYPE']) ? translate_type((string)$tel['TYPE']) : ''); + $tels[] = [ + 'type' => $type, + 'nr' => (string)$tel + ]; + } + } + + $emails = []; + if($vcard->EMAIL) { + foreach($vcard->EMAIL as $email) { + $type = (($email['TYPE']) ? translate_type((string)$email['TYPE']) : ''); + $emails[] = [ + 'type' => $type, + 'address' => (string)$email + ]; + } + } + + $impps = []; + if($vcard->IMPP) { + foreach($vcard->IMPP as $impp) { + $type = (($impp['TYPE']) ? translate_type((string)$impp['TYPE']) : ''); + $impps[] = [ + 'type' => $type, + 'address' => (string)$impp + ]; + } + } + + $urls = []; + if($vcard->URL) { + foreach($vcard->URL as $url) { + $type = (($url['TYPE']) ? translate_type((string)$url['TYPE']) : ''); + $urls[] = [ + 'type' => $type, + 'address' => (string)$url + ]; + } + } + + $adrs = []; + if($vcard->ADR) { + foreach($vcard->ADR as $adr) { + $type = (($adr['TYPE']) ? translate_type((string)$adr['TYPE']) : ''); + $adrs[] = [ + 'type' => $type, + 'address' => $adr->getParts() + ]; + } + } + + $note = ''; + if($vcard->NOTE) { + $note = (string)$vcard->NOTE; + } + + $cards[] = [ + 'id' => $object['id'], + 'uri' => $object['uri'], + + 'photo' => $photo, + 'fn' => $fn, + 'org' => $org, + 'title' => $title, + 'tels' => $tels, + 'emails' => $emails, + 'impps' => $impps, + 'urls' => $urls, + 'adrs' => $adrs, + 'note' => $note + ]; + } + + usort($cards, function($a, $b) { return strcasecmp($a['fn'], $b['fn']); }); + } + + $o .= replace_macros(get_markup_template('cdav_addressbook.tpl', 'addon/cdav'), [ + '$id' => $id, + '$cards' => $cards, + '$displayname' => $displayname, + '$name_label' => t('Name'), + '$org_label' => t('Organisation'), + '$title_label' => t('Title'), + '$tel_label' => t('Phone'), + '$email_label' => t('Email'), + '$impp_label' => t('Instant messenger'), + '$url_label' => t('Website'), + '$adr_label' => t('Address'), + '$note_label' => t('Note'), + '$mobile' => t('Mobile'), + '$home' => t('Home'), + '$work' => t('Work'), + '$other' => t('Other'), + '$add_card' => t('Add Contact'), + '$add_field' => t('Add Field'), + '$create' => t('Create'), + '$update' => t('Update'), + '$delete' => t('Delete'), + '$cancel' => t('Cancel'), + '$po_box' => t('P.O. Box'), + '$extra' => t('Additional'), + '$street' => t('Street'), + '$locality' => t('Locality'), + '$region' => t('Region'), + '$zip_code' => t('ZIP Code'), + '$country' => t('Country') + ]); + + return $o; + } + + //delete addressbook + if(argc() > 3 && argv(1) === 'addressbook' && argv(2) === 'drop' && intval(argv(3))) { + $id = argv(3); + + if(! cdav_perms($id,$addressbooks)) + return; + + $carddavBackend->deleteAddressBook($id); + killme(); + } + + } + + function activate($channel) { + + if(! $channel) + return; + + $uri = 'principals/' . $channel['channel_hash']; + + + $r = q("select * from principals where uri = '%s' limit 1", + dbesc($uri) + ); + if($r) { + $r = q("update principals set email = '%s', displayname = '%s' where uri = '%s' ", + dbesc($channel['xchan_addr']), + dbesc($channel['channel_name']), + dbesc($uri) + ); + } + else { + $r = q("insert into principals ( uri, email, displayname ) values('%s','%s','%s') ", + dbesc($uri), + dbesc($channel['xchan_addr']), + dbesc($channel['channel_name']) + ); + + //create default calendar + $r = q("insert into calendars (components) values('%s') ", + dbesc('VEVENT,VTODO') + ); + + $r = q("insert into calendarinstances (principaluri, displayname, uri, description, calendarcolor) values( '%s', '%s', '%s', '%s', '%s') ", + dbesc($uri), + dbesc(t('Default Calendar')), + dbesc('default'), + dbesc($channel['channel_name']), + dbesc('#3a87ad') + ); + + //create default addressbook + $r = q("insert into addressbooks (principaluri, displayname, uri) values('%s', '%s', '%s') ", + dbesc($uri), + dbesc(t('Default Addressbook')), + dbesc('default') + ); + } + } + + +} -- cgit v1.2.3 From 02b7bc08033b21ea5438aa667e8dbb1fd72022bb Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 22 Jun 2017 20:16:54 -0700 Subject: cdav migration to core --- Zotlabs/Module/Cdav.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php index 856956b5b..f91dead04 100644 --- a/Zotlabs/Module/Cdav.php +++ b/Zotlabs/Module/Cdav.php @@ -1,7 +1,8 @@ $sources, '$color' => $color, '$lang' => \App::$language, @@ -979,7 +980,7 @@ class Cdav extends \Zotlabs\Web\Controller { if(!$displayname) return; - head_add_css('/addon/cdav/view/css/cdav_addressbook.css'); + head_add_css('cdav_addressbook.css'); $o = ''; @@ -1102,7 +1103,7 @@ class Cdav extends \Zotlabs\Web\Controller { usort($cards, function($a, $b) { return strcasecmp($a['fn'], $b['fn']); }); } - $o .= replace_macros(get_markup_template('cdav_addressbook.tpl', 'addon/cdav'), [ + $o .= replace_macros(get_markup_template('cdav_addressbook.tpl'), [ '$id' => $id, '$cards' => $cards, '$displayname' => $displayname, -- cgit v1.2.3 From 6c771f84cedc71e7ffeecebe3e2fd7f912de3e7b Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 22 Jun 2017 22:43:08 -0700 Subject: remove unused page_widgets.php include and provide a general function for loading sql from file to use in the cdav migration --- Zotlabs/Module/Block.php | 2 -- Zotlabs/Module/Page.php | 1 - Zotlabs/Module/Webpages.php | 9 --------- 3 files changed, 12 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Block.php b/Zotlabs/Module/Block.php index e671730f6..d0fed44fe 100644 --- a/Zotlabs/Module/Block.php +++ b/Zotlabs/Module/Block.php @@ -3,8 +3,6 @@ namespace Zotlabs\Module; require_once('include/items.php'); require_once('include/conversation.php'); -require_once('include/page_widgets.php'); - class Block extends \Zotlabs\Web\Controller { diff --git a/Zotlabs/Module/Page.php b/Zotlabs/Module/Page.php index 7bc90c091..c142afe77 100644 --- a/Zotlabs/Module/Page.php +++ b/Zotlabs/Module/Page.php @@ -3,7 +3,6 @@ namespace Zotlabs\Module; require_once('include/items.php'); require_once('include/conversation.php'); -require_once('include/page_widgets.php'); class Page extends \Zotlabs\Web\Controller { diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php index 641e84b70..d59fcdb9f 100644 --- a/Zotlabs/Module/Webpages.php +++ b/Zotlabs/Module/Webpages.php @@ -179,11 +179,8 @@ class Webpages extends \Zotlabs\Web\Controller { // so just list titles and an edit link. - /** @TODO - this should be replaced with pagelist_widget */ - $sql_extra = item_permissions_sql($owner); - $r = q("select * from iconfig left join item on iconfig.iid = item.id where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'WEBPAGE' and item_type = %d $sql_extra order by item.created desc", @@ -191,12 +188,6 @@ class Webpages extends \Zotlabs\Web\Controller { intval(ITEM_TYPE_WEBPAGE) ); -// $r = q("select * from item_id left join item on item_id.iid = item.id -// where item_id.uid = %d and service = 'WEBPAGE' and item_type = %d $sql_extra order by item.created desc", -// intval($owner), -// intval(ITEM_TYPE_WEBPAGE) -// ); - if(! $r) $x['pagetitle'] = 'home'; -- cgit v1.2.3 From ef53db0b91c09c0446a706222dd4922520b008ef Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 25 Jun 2017 18:30:22 -0700 Subject: allow poke by xchan_hash --- Zotlabs/Module/Poke.php | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Poke.php b/Zotlabs/Module/Poke.php index cf8d83023..ea50e821a 100644 --- a/Zotlabs/Module/Poke.php +++ b/Zotlabs/Module/Poke.php @@ -41,7 +41,10 @@ class Poke extends \Zotlabs\Web\Controller { $activity = ACTIVITY_POKE . '#' . urlencode($verbs[$verb][0]); $contact_id = intval($_REQUEST['cid']); - if(! $contact_id) + + $xchan = trim($_REQUEST['xchan']); + + if(! ($contact_id || $xchan)) return; $parent = ((x($_REQUEST,'parent')) ? intval($_REQUEST['parent']) : 0); @@ -49,13 +52,20 @@ class Poke extends \Zotlabs\Web\Controller { logger('poke: verb ' . $verb . ' contact ' . $contact_id, LOGGER_DEBUG); - $r = q("SELECT * FROM abook left join xchan on xchan_hash = abook_xchan where abook_id = %d and abook_channel = %d LIMIT 1", - intval($contact_id), - intval($uid) - ); - + if($contact_id) { + $r = q("SELECT * FROM abook left join xchan on xchan_hash = abook_xchan where abook_id = %d and abook_channel = %d LIMIT 1", + intval($contact_id), + intval($uid) + ); + } + if($xchan) { + $r = q("SELECT * FROM xchan where xchan_hash like ( '%s' ) LIMIT 1", + dbesc($xchan . '%') + ); + } + if(! $r) { - logger('poke: no target ' . $contact_id); + logger('poke: no target.'); return; } @@ -79,7 +89,7 @@ class Poke extends \Zotlabs\Web\Controller { $deny_gid = $r[0]['deny_gid']; } } - else { + elseif($contact_id) { $item_private = ((x($_GET,'private')) ? intval($_GET['private']) : 0); @@ -92,9 +102,11 @@ class Poke extends \Zotlabs\Web\Controller { $arr = array(); + + $arr['item_wall'] = 1; $arr['owner_xchan'] = (($parent_item) ? $parent_item['owner_xchan'] : $channel['channel_hash']); - $arr['parent_mid'] = (($parent_mid) ? $parent_mid : $mid); + $arr['parent_mid'] = (($parent_mid) ? $parent_mid : ''); $arr['title'] = ''; $arr['allow_cid'] = $allow_cid; $arr['allow_gid'] = $allow_gid; -- cgit v1.2.3 From c456e01219bf535582744d5210b2b096985aa05d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 25 Jun 2017 18:49:50 -0700 Subject: chanview - if already connected, bypass the chanview intermediary page and go straight to the remote profile. The chanview page is only there to present a connect link since the remote profile may not have one. --- Zotlabs/Module/Chanview.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Chanview.php b/Zotlabs/Module/Chanview.php index c3194184a..245e71bec 100644 --- a/Zotlabs/Module/Chanview.php +++ b/Zotlabs/Module/Chanview.php @@ -102,23 +102,32 @@ class Chanview extends \Zotlabs\Web\Controller { } $is_zot = false; + $connected = false; if (\App::$poi) { $url = \App::$poi['xchan_url']; if(\App::$poi['xchan_network'] === 'zot') { $is_zot = true; } - } + if(local_channel()) { + $c = q("select abook_id from abook where abook_channel = %d and abook_xchan = '%s' limit 1", + intval(local_channel()), + dbesc(\App::$poi['xchan_hash']) + ); + if($c) + $connected = true; + } + // We will load the chanview template if it's a foreign network, // just so that we can provide a connect button along with a profile // photo. Chances are we can't load the remote profile into an iframe // because of cross-domain security headers. So provide a link to // the remote profile. - + // If we are already connected, just go to the profile. // Zot channels will usually have a connect link. - if($is_zot) { + if($is_zot || $connected) { if($is_zot && $observer) { $url = zid($url); } -- cgit v1.2.3 From 28a1be4d36bf0ec54d053bb9decbe619361682cb Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 25 Jun 2017 19:17:05 -0700 Subject: typo in chanview, remove output buffering in mod_cloud which is preventing large files from being downloaded. IIRC this was put there to avoid a SAML warning in SabreDAV but I'm not seeing that currently. --- Zotlabs/Module/Chanview.php | 2 +- Zotlabs/Module/Cloud.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Chanview.php b/Zotlabs/Module/Chanview.php index 245e71bec..24ab9b022 100644 --- a/Zotlabs/Module/Chanview.php +++ b/Zotlabs/Module/Chanview.php @@ -116,7 +116,7 @@ class Chanview extends \Zotlabs\Web\Controller { ); if($c) $connected = true; - + } } // We will load the chanview template if it's a foreign network, diff --git a/Zotlabs/Module/Cloud.php b/Zotlabs/Module/Cloud.php index 7370eeda3..01f1061df 100644 --- a/Zotlabs/Module/Cloud.php +++ b/Zotlabs/Module/Cloud.php @@ -86,11 +86,11 @@ class Cloud extends \Zotlabs\Web\Controller { // require_once('\Zotlabs\Storage/QuotaPlugin.php'); // $server->addPlugin(new \Zotlabs\Storage\\QuotaPlugin($auth)); - ob_start(); +// ob_start(); // All we need to do now, is to fire up the server $server->exec(); - ob_end_flush(); +// ob_end_flush(); killme(); } -- cgit v1.2.3 From 7f982a07781f09756d852f423bba37dc11abf2a5 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 25 Jun 2017 20:03:26 -0700 Subject: minor usability enhancements with the connections list - label the edit icon so it's more obvious; the intuitive action is to click the photo or name which isn't what we usually want. Also move the Delete button over just a bit more so it's harder to accidentally click on small screens with big thumbs. --- Zotlabs/Module/Connections.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index 60b798c13..b3c5e8ee9 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -258,6 +258,7 @@ class Connections extends \Zotlabs\Web\Controller { $contacts[] = array( 'img_hover' => sprintf( t('%1$s [%2$s]'),$rr['xchan_name'],$rr['xchan_url']), 'edit_hover' => t('Edit connection'), + 'edit' => t('Edit'), 'delete_hover' => t('Delete connection'), 'id' => $rr['abook_id'], 'thumb' => $rr['xchan_photo_m'], -- cgit v1.2.3 From 5dc638c5b38883934221b3575b7d21e32502512b Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 26 Jun 2017 01:36:33 -0700 Subject: better fix for dav headers already sent issue --- Zotlabs/Module/Cloud.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Cloud.php b/Zotlabs/Module/Cloud.php index 01f1061df..75191a279 100644 --- a/Zotlabs/Module/Cloud.php +++ b/Zotlabs/Module/Cloud.php @@ -91,7 +91,8 @@ class Cloud extends \Zotlabs\Web\Controller { $server->exec(); // ob_end_flush(); - + if($browser->build_page) + construct_page(); killme(); } -- cgit v1.2.3 From 54c5e03b4f94e07fccf1d67078a534d2e7da99b4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 26 Jun 2017 22:42:01 -0700 Subject: provide more comprehensible information on the admin summary page --- Zotlabs/Module/Admin.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Admin.php b/Zotlabs/Module/Admin.php index 65ce363c0..f2918dffc 100644 --- a/Zotlabs/Module/Admin.php +++ b/Zotlabs/Module/Admin.php @@ -91,10 +91,10 @@ class Admin extends \Zotlabs\Web\Controller { intval(ACCOUNT_BLOCKED) ); if ($r) { - $accounts['total'] = array('label' => t('# Accounts'), 'val' => $r[0]['total']); - $accounts['blocked'] = array('label' => t('# blocked accounts'), 'val' => $r[0]['blocked']); - $accounts['expired'] = array('label' => t('# expired accounts'), 'val' => $r[0]['expired']); - $accounts['expiring'] = array('label' => t('# expiring accounts'), 'val' => $r[0]['expiring']); + $accounts['total'] = array('label' => t('Accounts'), 'val' => $r[0]['total']); + $accounts['blocked'] = array('label' => t('Blocked accounts'), 'val' => $r[0]['blocked']); + $accounts['expired'] = array('label' => t('Expired accounts'), 'val' => $r[0]['expired']); + $accounts['expiring'] = array('label' => t('Expiring accounts'), 'val' => $r[0]['expiring']); } // pending registrations @@ -105,9 +105,9 @@ class Admin extends \Zotlabs\Web\Controller { $channels = array(); $r = q("SELECT COUNT(*) AS total, COUNT(CASE WHEN channel_primary = 1 THEN 1 ELSE NULL END) AS main, COUNT(CASE WHEN channel_primary = 0 THEN 1 ELSE NULL END) AS clones FROM channel WHERE channel_removed = 0"); if ($r) { - $channels['total'] = array('label' => t('# Channels'), 'val' => $r[0]['total']); - $channels['main'] = array('label' => t('# primary'), 'val' => $r[0]['main']); - $channels['clones'] = array('label' => t('# clones'), 'val' => $r[0]['clones']); + $channels['total'] = array('label' => t('Channels'), 'val' => $r[0]['total']); + $channels['main'] = array('label' => t('Primary'), 'val' => $r[0]['main']); + $channels['clones'] = array('label' => t('Clones'), 'val' => $r[0]['clones']); } // We can do better, but this is a quick queue status @@ -118,6 +118,9 @@ class Admin extends \Zotlabs\Web\Controller { // If no plugins active return 0, otherwise list of plugin names $plugins = (count(\App::$plugins) == 0) ? count(\App::$plugins) : \App::$plugins; + if(is_array($plugins)) + sort($plugins); + // Could be extended to provide also other alerts to the admin $alertmsg = ''; -- cgit v1.2.3 From 34c4775916f824755b4545f8d6f0ec2b8a653a88 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 28 Jun 2017 16:45:48 -0700 Subject: missing space in nav tpl --- Zotlabs/Module/Hcard.php | 2 ++ Zotlabs/Module/Xrd.php | 2 ++ 2 files changed, 4 insertions(+) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Hcard.php b/Zotlabs/Module/Hcard.php index 13097939e..912c84fd2 100644 --- a/Zotlabs/Module/Hcard.php +++ b/Zotlabs/Module/Hcard.php @@ -14,6 +14,8 @@ class Hcard extends \Zotlabs\Web\Controller { return; } + logger('hcard_request: ' . $which, LOGGER_DEBUG); + $profile = ''; $channel = \App::get_channel(); diff --git a/Zotlabs/Module/Xrd.php b/Zotlabs/Module/Xrd.php index 17c0faa78..9630e9ab4 100644 --- a/Zotlabs/Module/Xrd.php +++ b/Zotlabs/Module/Xrd.php @@ -9,6 +9,7 @@ class Xrd extends \Zotlabs\Web\Controller { function init() { $uri = urldecode(notags(trim($_GET['uri']))); + $subject = $uri; logger('xrd: ' . $uri,LOGGER_DEBUG); $resource = $uri; @@ -47,6 +48,7 @@ class Xrd extends \Zotlabs\Web\Controller { $o = replace_macros(get_markup_template('xrd_person.tpl'), array( '$nick' => $r[0]['channel_address'], '$accturi' => $resource, + '$subject' => $subject, '$aliases' => $aliases, '$profile_url' => z_root() . '/channel/' . $r[0]['channel_address'], '$hcard_url' => z_root() . '/hcard/' . $r[0]['channel_address'], -- cgit v1.2.3 From d18427a522a212dceae85a95c304fef8bca721b2 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 3 Jul 2017 21:20:22 -0700 Subject: revert using channel_hash for cdav until we figure out how to do so cleanly --- Zotlabs/Module/Cdav.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php index f91dead04..068ad2450 100644 --- a/Zotlabs/Module/Cdav.php +++ b/Zotlabs/Module/Cdav.php @@ -146,7 +146,7 @@ class Cdav extends \Zotlabs\Web\Controller { return; $channel = \App::get_channel(); - $principalUri = 'principals/' . $channel['channel_hash']; + $principalUri = 'principals/' . $channel['channel_address']; if(!cdav_principal($principalUri)) return; @@ -358,7 +358,7 @@ class Cdav extends \Zotlabs\Web\Controller { $sharee = new \Sabre\DAV\Xml\Element\Sharee(); - $sharee->href = 'mailto:' . $sharee_arr['channel_hash']; + $sharee->href = 'mailto:' . $sharee_arr['xchan_addr']; $sharee->principal = 'principals/' . $sharee_arr['channel_address']; $sharee->access = intval($_REQUEST['access']); $sharee->properties = ['{DAV:}displayname' => $channel['channel_name']]; @@ -749,7 +749,7 @@ class Cdav extends \Zotlabs\Web\Controller { return; $channel = \App::get_channel(); - $principalUri = 'principals/' . $channel['channel_hash']; + $principalUri = 'principals/' . $channel['channel_address']; if(!cdav_principal($principalUri)) { @@ -956,7 +956,7 @@ class Cdav extends \Zotlabs\Web\Controller { $sharee = new \Sabre\DAV\Xml\Element\Sharee(); - $sharee->href = 'mailto:' . $sharee_arr['channel_hash']; + $sharee->href = 'mailto:' . $sharee_arr['xchan_addr']; $sharee->principal = 'principals/' . $sharee_arr['channel_address']; $sharee->access = 4; $caldavBackend->updateInvites($id, [$sharee]); @@ -1156,7 +1156,7 @@ class Cdav extends \Zotlabs\Web\Controller { if(! $channel) return; - $uri = 'principals/' . $channel['channel_hash']; + $uri = 'principals/' . $channel['channel_address']; $r = q("select * from principals where uri = '%s' limit 1", -- cgit v1.2.3 From fbf868e97619374206a109ff17d8f6c51c13aeb6 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 4 Jul 2017 12:07:11 +0200 Subject: reimplement creation of default calendar and default addressbook using sabre classes --- Zotlabs/Module/Cdav.php | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php index 068ad2450..b1d99620b 100644 --- a/Zotlabs/Module/Cdav.php +++ b/Zotlabs/Module/Cdav.php @@ -751,20 +751,19 @@ class Cdav extends \Zotlabs\Web\Controller { $channel = \App::get_channel(); $principalUri = 'principals/' . $channel['channel_address']; + $pdo = \DBA::$dba->db; + + require_once 'vendor/autoload.php'; + + head_add_css('cdav.css'); if(!cdav_principal($principalUri)) { - $this->activate($channel); + $this->activate($pdo, $channel); if(!cdav_principal($principalUri)) { return; } } - $pdo = \DBA::$dba->db; - - require_once 'vendor/autoload.php'; - - head_add_css('cdav.css'); - if(argv(1) === 'calendar') { $caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo); $calendars = $caldavBackend->getCalendarsForUser($principalUri); @@ -1151,7 +1150,7 @@ class Cdav extends \Zotlabs\Web\Controller { } - function activate($channel) { + function activate($pdo, $channel) { if(! $channel) return; @@ -1177,24 +1176,21 @@ class Cdav extends \Zotlabs\Web\Controller { ); //create default calendar - $r = q("insert into calendars (components) values('%s') ", - dbesc('VEVENT,VTODO') - ); + $caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo); + $properties = [ + '{DAV:}displayname' => t('Default Calendar'), + '{http://apple.com/ns/ical/}calendar-color' => '#3a87ad', + '{urn:ietf:params:xml:ns:caldav}calendar-description' => $channel['channel_name'] + ]; - $r = q("insert into calendarinstances (principaluri, displayname, uri, description, calendarcolor) values( '%s', '%s', '%s', '%s', '%s') ", - dbesc($uri), - dbesc(t('Default Calendar')), - dbesc('default'), - dbesc($channel['channel_name']), - dbesc('#3a87ad') - ); + $id = $caldavBackend->createCalendar($uri, 'default', $properties); + set_pconfig(local_channel(), 'cdav_calendar' , $id[0], 1); //create default addressbook - $r = q("insert into addressbooks (principaluri, displayname, uri) values('%s', '%s', '%s') ", - dbesc($uri), - dbesc(t('Default Addressbook')), - dbesc('default') - ); + $carddavBackend = new \Sabre\CardDAV\Backend\PDO($pdo); + $properties = ['{DAV:}displayname' => t('Default Addressbook')]; + $carddavBackend->createAddressBook($uri, $default, $properties); + } } -- cgit v1.2.3 From b2e5b6c977c8f8af9bfd49dac3ce41a2183025da Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 5 Jul 2017 20:16:40 -0700 Subject: affinitiy slider settings were being updated on any submit of of settings/featured, plus minor non-code changes --- Zotlabs/Module/Settings/Featured.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Settings/Featured.php b/Zotlabs/Module/Settings/Featured.php index 4885abd1d..ebe2996d3 100644 --- a/Zotlabs/Module/Settings/Featured.php +++ b/Zotlabs/Module/Settings/Featured.php @@ -10,14 +10,16 @@ class Featured { call_hooks('feature_settings_post', $_POST); - if(intval($_POST['affinity_cmax'])) { - set_pconfig(local_channel(),'affinity','cmax',intval($_POST['affinity_cmax'])); - } - if(intval($_POST['affinity_cmin'])) { - set_pconfig(local_channel(),'affinity','cmin',intval($_POST['affinity_cmin'])); - } - if(intval($_POST['affinity_cmax']) || intval($_POST['affinity_cmin'])) { - info( t('Affinity Slider settings updated.') . EOL); + if($_POST['affinity_slider-submit']) { + if(intval($_POST['affinity_cmax'])) { + set_pconfig(local_channel(),'affinity','cmax',intval($_POST['affinity_cmax'])); + } + if(intval($_POST['affinity_cmin'])) { + set_pconfig(local_channel(),'affinity','cmin',intval($_POST['affinity_cmin'])); + } + if(intval($_POST['affinity_cmax']) || intval($_POST['affinity_cmin'])) { + info( t('Affinity Slider settings updated.') . EOL); + } } build_sync_packet(); -- cgit v1.2.3 From 2d63bbb91e97d3a54440564620ef3093ecbe71fb Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 10 Jul 2017 20:18:33 -0700 Subject: prevent expiration of conversations you are involved with - allows you to find your own comments months from now --- Zotlabs/Module/Item.php | 9 +++++++-- Zotlabs/Module/Like.php | 5 +++++ Zotlabs/Module/React.php | 4 ++++ 3 files changed, 16 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index e96d4c669..9e64528fa 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -861,8 +861,8 @@ class Item extends \Zotlabs\Web\Controller { } - if(mb_strlen($datarray['title']) > 255) - $datarray['title'] = mb_substr($datarray['title'],0,255); + if(mb_strlen($datarray['title']) > 191) + $datarray['title'] = mb_substr($datarray['title'],0,191); if($webpage) { Zlib\IConfig::Set($datarray,'system', webpage_to_namespace($webpage), @@ -928,6 +928,11 @@ class Item extends \Zotlabs\Web\Controller { if($parent) { + // prevent conversations which you are involved from being expired + + if(local_channel()) + retain_item($parent); + // only send comment notification if this is a wall-to-wall comment, // otherwise it will happen during delivery diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index 71336e8f3..c995079ce 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -504,6 +504,11 @@ class Like extends \Zotlabs\Web\Controller { $post = item_store($arr); $post_id = $post['item_id']; + + // save the conversation from expiration + + if(local_channel() && array_key_exists('item',$post) && (intval($post['item']['id']) != intval($post['item']['parent']))) + retain_item($post['item']['parent']); $arr['id'] = $post_id; diff --git a/Zotlabs/Module/React.php b/Zotlabs/Module/React.php index ed4f87e7e..6cd79c952 100644 --- a/Zotlabs/Module/React.php +++ b/Zotlabs/Module/React.php @@ -39,6 +39,10 @@ class React extends \Zotlabs\Web\Controller { $n['author_xchan'] = $channel['channel_hash']; $x = item_store($n); + + if(local_channel()) + retain_item($postid); + if($x['success']) { $nid = $x['item_id']; \Zotlabs\Daemon\Master::Summon(array('Notifier','like',$nid)); -- cgit v1.2.3 From c940d8d7ca25691519d400ad19aa22b5611fc2e7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 13 Jul 2017 17:04:58 -0700 Subject: implement chunked uploads on the wall; making it work painlessly on /cloud was attempted but will not be implemented today. That presents some interesting dragons to slay. --- Zotlabs/Module/Wall_attach.php | 64 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 6 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Wall_attach.php b/Zotlabs/Module/Wall_attach.php index c6fe7518e..5b3768da9 100644 --- a/Zotlabs/Module/Wall_attach.php +++ b/Zotlabs/Module/Wall_attach.php @@ -8,10 +8,21 @@ require_once('include/photos.php'); class Wall_attach extends \Zotlabs\Web\Controller { + function init() { + logger('request_method: ' . $_SERVER['REQUEST_METHOD'],LOGGER_DATA,LOG_INFO); + logger('wall_attach: ' . print_r($_REQUEST,true),LOGGER_DEBUG,LOG_INFO); + logger('wall_attach files: ' . print_r($_FILES,true),LOGGER_DEBUG,LOG_INFO); + // for testing without actually storing anything + // http_status_exit(200,'OK'); + } + + function post() { $using_api = false; - + + $result = []; + if($_REQUEST['api_source'] && array_key_exists('media',$_FILES)) { $using_api = true; } @@ -28,7 +39,44 @@ class Wall_attach extends \Zotlabs\Web\Controller { if(! $channel) killme(); - + + $matches = []; + $partial = false; + + $x = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches); + if($x) { + // logger('Content-Range: ' . print_r($matches,true)); + $partial = true; + } + + if($partial) { + $x = save_chunk($channel,$matches[1],$matches[2],$matches[3]); + if($x['partial']) { + header('Range: bytes=0-' . (($x['length']) ? $x['length'] - 1 : 0)); + json_return_and_die($result); + } + else { + $_FILES['userfile'] = [ + 'name' => $x['name'], + 'type' => $x['type'], + 'tmp_name' => $x['tmp_name'], + 'error' => $x['error'], + 'size' => $x['size'] + ]; + } + } + else { + if(! array_key_exists('userfile',$_FILES)) { + $_FILES['userfile'] = [ + 'name' => $_FILES['files']['name'], + 'type' => $_FILES['files']['type'], + 'tmp_name' => $_FILES['files']['tmp_name'], + 'error' => $_FILES['files']['error'], + 'size' => $_FILES['files']['size'] + ]; + } + } + $observer = \App::get_observer(); @@ -51,10 +99,14 @@ class Wall_attach extends \Zotlabs\Web\Controller { if($using_api) return $s; - - echo $s; - killme(); - + + + if($partial) + header('Range: bytes=0-' . (($x['length']) ? $x['length'] - 1 : 0)); + $result['message'] = $s; + json_return_and_die($result); + } + } -- cgit v1.2.3 From 266dab1b593a93d49ad97ab0cad9022486ba4c7f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 13 Jul 2017 20:53:05 -0700 Subject: turn url requests where argv[0] is something.xyz into module='something' and $_REQUEST['module_format'] = 'xyz'; But leave modules beginning with . (like .well_known) alone (convert the initial . to _ and then strip it). This really only affects Siteinfo_json at this time. --- Zotlabs/Module/Siteinfo.php | 7 +++---- Zotlabs/Module/Siteinfo_json.php | 14 -------------- 2 files changed, 3 insertions(+), 18 deletions(-) delete mode 100644 Zotlabs/Module/Siteinfo_json.php (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Siteinfo.php b/Zotlabs/Module/Siteinfo.php index 7c3918425..fafd51f65 100644 --- a/Zotlabs/Module/Siteinfo.php +++ b/Zotlabs/Module/Siteinfo.php @@ -5,14 +5,13 @@ namespace Zotlabs\Module; class Siteinfo extends \Zotlabs\Web\Controller { function init() { - if (argv(1) === 'json') { +logger(print_r($_REQUEST,true)); + if (argv(1) === 'json' || $_REQUEST['module_format'] === 'json') { $data = get_site_info(); json_return_and_die($data); } } - - - + function get() { $siteinfo = replace_macros(get_markup_template('siteinfo.tpl'), diff --git a/Zotlabs/Module/Siteinfo_json.php b/Zotlabs/Module/Siteinfo_json.php deleted file mode 100644 index 99c22610f..000000000 --- a/Zotlabs/Module/Siteinfo_json.php +++ /dev/null @@ -1,14 +0,0 @@ - Date: Thu, 13 Jul 2017 22:29:15 -0700 Subject: minor optimisation --- Zotlabs/Module/Wall_attach.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Wall_attach.php b/Zotlabs/Module/Wall_attach.php index 5b3768da9..03d4cb37b 100644 --- a/Zotlabs/Module/Wall_attach.php +++ b/Zotlabs/Module/Wall_attach.php @@ -2,10 +2,8 @@ namespace Zotlabs\Module; require_once('include/attach.php'); -require_once('include/channel.php'); require_once('include/photos.php'); - class Wall_attach extends \Zotlabs\Web\Controller { function init() { @@ -56,6 +54,8 @@ class Wall_attach extends \Zotlabs\Web\Controller { json_return_and_die($result); } else { + header('Range: bytes=0-' . (($x['size']) ? $x['size'] - 1 : 0)); + $_FILES['userfile'] = [ 'name' => $x['name'], 'type' => $x['type'], @@ -100,9 +100,6 @@ class Wall_attach extends \Zotlabs\Web\Controller { if($using_api) return $s; - - if($partial) - header('Range: bytes=0-' . (($x['length']) ? $x['length'] - 1 : 0)); $result['message'] = $s; json_return_and_die($result); -- cgit v1.2.3 From b1d4e97699133020fcdb6e9a38f39a48afb1bfa5 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 14 Jul 2017 14:03:56 -0700 Subject: incorrect follow url in webfinger --- Zotlabs/Module/Wfinger.php | 2 +- Zotlabs/Module/Xrd.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Wfinger.php b/Zotlabs/Module/Wfinger.php index 9623a676b..07a7b7735 100644 --- a/Zotlabs/Module/Wfinger.php +++ b/Zotlabs/Module/Wfinger.php @@ -117,7 +117,7 @@ class Wfinger extends \Zotlabs\Web\Controller { [ 'rel' => 'http://ostatus.org/schema/1.0/subscribe', - 'template' => z_root() . '/follow/url={uri}', + 'template' => z_root() . '/follow?f=&url={uri}', ], [ diff --git a/Zotlabs/Module/Xrd.php b/Zotlabs/Module/Xrd.php index 9630e9ab4..64e5042cb 100644 --- a/Zotlabs/Module/Xrd.php +++ b/Zotlabs/Module/Xrd.php @@ -57,7 +57,7 @@ class Xrd extends \Zotlabs\Web\Controller { '$poco_url' => z_root() . '/poco/' . $r[0]['channel_address'], '$photo' => z_root() . '/photo/profile/l/' . $r[0]['channel_id'], '$modexp' => 'data:application/magic-public-key,' . $salmon_key, - '$subscribe' => z_root() . '/follow?url={uri}', + '$subscribe' => z_root() . '/follow?f=&url={uri}', )); -- cgit v1.2.3 From 4728e72d182f78dc2f5768fdb55d1e142fc92129 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Mon, 17 Jul 2017 16:19:19 +0200 Subject: some love for the installer --- Zotlabs/Module/Setup.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Setup.php b/Zotlabs/Module/Setup.php index e5b54cc5f..2134288d6 100644 --- a/Zotlabs/Module/Setup.php +++ b/Zotlabs/Module/Setup.php @@ -186,14 +186,17 @@ class Setup extends \Zotlabs\Web\Controller { } $db_return_text = ''; if(x(\App::$data, 'db_installed')) { - $txt = '

'; - $txt .= t('Your site database has been installed.') . EOL; + $pass = 'Installation succeeded!'; + $icon = 'check'; + $txt = t('Your site database has been installed.') . EOL; $db_return_text .= $txt; } if(x(\App::$data, 'db_failed')) { + $pass = 'Database install failed!'; + $icon = 'exclamation-triangle'; $txt = t('You may need to import the file "install/schema_xxx.sql" manually using a database client.') . EOL; $txt .= t('Please see the file "install/INSTALL.txt".') . EOL ."


" ; - $txt .= "
".\App::$data['db_failed'] . "
". EOL ; + $txt .= "
" . \App::$data['db_failed'] . "
". EOL ; $db_return_text .= $txt; } if(\DBA::$dba && \DBA::$dba->connected) { @@ -217,8 +220,10 @@ class Setup extends \Zotlabs\Web\Controller { $tpl = get_markup_template('install.tpl'); return replace_macros($tpl, array( '$title' => $install_title, - '$pass' => '', - '$text' => $db_return_text . $this->what_next(), + '$icon' => $icon, + '$pass' => $pass, + '$text' => $db_return_text, + '$what_next' => $this->what_next() )); } @@ -395,7 +400,7 @@ class Setup extends \Zotlabs\Web\Controller { if(!$passed) { $help .= t('Could not find a command line version of PHP in the web server PATH.'). EOL; $help .= t('If you don\'t have a command line version of PHP installed on server, you will not be able to run background polling via cron.') . EOL; - $help .= EOL . EOL ; + $help .= EOL; $tpl = get_markup_template('field_input.tpl'); $help .= replace_macros($tpl, array( '$field' => array('phpath', t('PHP executable path'), $phpath, t('Enter full path to php executable. You can leave this blank to continue the installation.')), @@ -443,7 +448,7 @@ class Setup extends \Zotlabs\Web\Controller { userReadableSize($result['max_upload_filesize']), $result['max_file_uploads'] ); - $help .= '
' . t('You can adjust these settings in the server php.ini file.'); + $help .= '

' . t('You can adjust these settings in the server php.ini file.'); $this->check_add($checks, t('PHP upload limits'), true, false, $help); } @@ -735,12 +740,12 @@ class Setup extends \Zotlabs\Web\Controller { $baseurl = z_root(); return - t('

What next

') - ."

".t('IMPORTANT: You will need to [manually] setup a scheduled task for the poller.') + t('

What next?

') + ."
".t('IMPORTANT: You will need to [manually] setup a scheduled task for the poller.').EOL .t('Please see the file "install/INSTALL.txt".') - ."

" + ."

" .t("Go to your new hub registration page and register as new member. Remember to use the same email you have entered as administrator email. This will allow you to enter the site admin panel.") - ."

"; + ."
"; } /** -- cgit v1.2.3 From d8c93c0d13133d336e2cc3dbf3c48e0a6350c2d6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 17 Jul 2017 22:17:40 -0700 Subject: activitypub, cont. --- Zotlabs/Module/Ap_probe.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Zotlabs/Module/Ap_probe.php (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Ap_probe.php b/Zotlabs/Module/Ap_probe.php new file mode 100644 index 000000000..4649914d5 --- /dev/null +++ b/Zotlabs/Module/Ap_probe.php @@ -0,0 +1,33 @@ +ActivityPub Probe Diagnostic'; + + $o .= '
'; + $o .= 'Lookup URI: '; + $o .= '
'; + + $o .= '

'; + + if(x($_GET,'addr')) { + $addr = $_GET['addr']; + + $redirects = 0; + $x = z_fetch_url($addr,true,$redirects, + [ 'headers' => [ 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"']]); +logger('fetch: ' . print_r($x,true)); + + if($x['success']) + $o .= '
' . str_replace('\\','',jindent($x['body'])) . '
'; + } + return $o; + } + +} -- cgit v1.2.3 From 08c0d78296d4518a5ece4d6a2c05b9be83580aa8 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Tue, 18 Jul 2017 13:56:09 +0200 Subject: issue #827 provide backward compatibility for album links generated in earlier times before the ambiguity of photo album names was solved. This may provide incorrect results if two or more photo albums with the same basename exist in different directories of the file tree; but there is no easy way to solve that ambiguity - which is why the link format changed. --- Zotlabs/Module/Photos.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index d993c481e..18d7abc48 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -689,7 +689,7 @@ class Photos extends \Zotlabs\Web\Controller { (SELECT resource_id, max(imgscale) imgscale FROM photo left join attach on folder = '%s' and photo.resource_id = attach.hash WHERE attach.uid = %d AND imgscale <= 4 AND photo_usage IN ( %d, %d ) and is_nsfw = %d $sql_extra GROUP BY resource_id) ph ON (p.resource_id = ph.resource_id AND p.imgscale = ph.imgscale) ORDER BY created $order LIMIT %d OFFSET %d", - dbesc($datum), + dbesc($x['hash']), intval($owner_uid), intval(PHOTO_NORMAL), intval(PHOTO_PROFILE), -- cgit v1.2.3 From 82aa87c190e65b16bbf3656cdae7260ff11c780f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 18 Jul 2017 17:02:50 -0700 Subject: ability to use a portion of the message-id to display a message wasn't honoured in all cases. --- Zotlabs/Module/Channel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 51c937270..98c1e1d61 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -236,9 +236,9 @@ class Channel extends \Zotlabs\Web\Controller { if($load || ($checkjs->disabled())) { 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 from item where mid like '%s' and uid = %d $item_normal AND item_wall = 1 $sql_extra limit 1", - dbesc($mid), + dbesc($mid . '%'), intval(\App::$profile['profile_uid']) ); if (! $r) { -- cgit v1.2.3 From 6103c301848105a3bca3de81e9982276b2c38d76 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 18 Jul 2017 21:16:18 -0700 Subject: provide optional salmon signatures for AP entities --- Zotlabs/Module/Ap_probe.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Ap_probe.php b/Zotlabs/Module/Ap_probe.php index 4649914d5..f788fa73a 100644 --- a/Zotlabs/Module/Ap_probe.php +++ b/Zotlabs/Module/Ap_probe.php @@ -11,7 +11,8 @@ class Ap_probe extends \Zotlabs\Web\Controller { $o .= '

ActivityPub Probe Diagnostic

'; $o .= '
'; - $o .= 'Lookup URI: '; + $o .= 'Lookup URI:
'; + $o .= 'Request Signed version:
'; $o .= '
'; $o .= '

'; @@ -19,11 +20,15 @@ class Ap_probe extends \Zotlabs\Web\Controller { if(x($_GET,'addr')) { $addr = $_GET['addr']; - $redirects = 0; - $x = z_fetch_url($addr,true,$redirects, - [ 'headers' => [ 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"']]); -logger('fetch: ' . print_r($x,true)); + if($_GET['magenv']) { + $headers = 'Accept: application/magic-envelope+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"'; + } + else { + $headers = 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"'; + } + $redirects = 0; + $x = z_fetch_url($addr,true,$redirects, [ 'headers' => [ $headers ]]); if($x['success']) $o .= '
' . str_replace('\\','',jindent($x['body'])) . '
'; } -- cgit v1.2.3 From df7f0eb9a4eb42aebd94cbdf8288f0fa8c9b3782 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 19 Jul 2017 18:32:16 -0700 Subject: hubzilla issue #832 --- Zotlabs/Module/Group.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Group.php b/Zotlabs/Module/Group.php index 646310356..93a089d02 100644 --- a/Zotlabs/Module/Group.php +++ b/Zotlabs/Module/Group.php @@ -56,6 +56,7 @@ class Group extends \Zotlabs\Web\Controller { ); if($r) info( t('Privacy group updated.') . EOL ); + build_sync_packet(local_channel(),null,true); } goaway(z_root() . '/group/' . argv(1) . '/' . argv(2)); @@ -63,7 +64,8 @@ class Group extends \Zotlabs\Web\Controller { return; } - function get() { + function get() { + $change = false; logger('mod_group: ' . \App::$cmd,LOGGER_DEBUG); -- cgit v1.2.3 From a346399fe6d35f9f2b3c854f515a7f302cda421b Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 20 Jul 2017 18:11:47 -0700 Subject: allow wildcard tag and category searches --- Zotlabs/Module/Channel.php | 4 ++-- Zotlabs/Module/Network.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 98c1e1d61..430589579 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -325,8 +325,8 @@ class Channel extends \Zotlabs\Web\Controller { '$order' => '', '$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0), '$file' => '', - '$cats' => (($category) ? $category : ''), - '$tags' => (($hashtags) ? $hashtags : ''), + '$cats' => (($category) ? urlencode($category) : ''), + '$tags' => (($hashtags) ? urlencode($hashtags) : ''), '$mid' => $mid, '$verb' => '', '$dend' => $datequery, diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index f2ad77dd7..3a7123a12 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -325,8 +325,8 @@ class Network extends \Zotlabs\Web\Controller { '$xchan' => $xchan, '$order' => $order, '$file' => $file, - '$cats' => $category, - '$tags' => $hashtags, + '$cats' => urlencode($category), + '$tags' => urlencode($hashtags), '$dend' => $datequery, '$mid' => '', '$verb' => $verb, -- cgit v1.2.3 From 23e2b3be096772d579d15d988a4410c76e90ed9d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 20 Jul 2017 18:30:48 -0700 Subject: allow wildcard tag searches in search module also --- Zotlabs/Module/Search.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 2b949ebc7..de6725bb5 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -81,11 +81,12 @@ class Search extends \Zotlabs\Web\Controller { return $o; if($tag) { - $sql_extra = sprintf(" AND item.id IN (select oid from term where otype = %d and ttype in ( %d , %d) and term = '%s') ", + $wildtag = str_replace('*','%',$search); + $sql_extra = sprintf(" AND item.id IN (select oid from term where otype = %d and ttype in ( %d , %d) and term like '%s') ", intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval(TERM_COMMUNITYTAG), - dbesc(protect_sprintf($search)) + dbesc(protect_sprintf($wildtag)) ); } else { -- cgit v1.2.3 From 1bdcfe5219c810758ae255427513a7a0c09ce8e1 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Fri, 21 Jul 2017 10:32:21 +0200 Subject: provide a mechanism to mark apps active in the bin --- Zotlabs/Module/Admin.php | 2 ++ Zotlabs/Module/Channel.php | 2 +- Zotlabs/Module/Mail.php | 2 +- Zotlabs/Module/Manage.php | 2 ++ Zotlabs/Module/Network.php | 2 +- Zotlabs/Module/Profile.php | 2 ++ Zotlabs/Module/Profiles.php | 2 +- Zotlabs/Module/Settings.php | 2 +- Zotlabs/Module/Wiki.php | 4 +++- 9 files changed, 14 insertions(+), 6 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Admin.php b/Zotlabs/Module/Admin.php index f2918dffc..30f3dfa48 100644 --- a/Zotlabs/Module/Admin.php +++ b/Zotlabs/Module/Admin.php @@ -52,6 +52,8 @@ class Admin extends \Zotlabs\Web\Controller { * Page content */ + nav_set_selected('Admin'); + $o = ''; if(argc() > 1) { diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 98c1e1d61..bc4b3f782 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -94,7 +94,7 @@ class Channel extends \Zotlabs\Web\Controller { } else { if(\App::$profile['profile_uid'] == local_channel()) { - nav_set_selected('home'); + nav_set_selected(t('Channel Home')); } } diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index f6add7778..7e6ec0cf9 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -140,7 +140,7 @@ class Mail extends \Zotlabs\Web\Controller { function get() { $o = ''; - nav_set_selected('messages'); + nav_set_selected(t('Mail')); if(! local_channel()) { notice( t('Permission denied.') . EOL); diff --git a/Zotlabs/Module/Manage.php b/Zotlabs/Module/Manage.php index e541ee077..2d8f39ded 100644 --- a/Zotlabs/Module/Manage.php +++ b/Zotlabs/Module/Manage.php @@ -10,6 +10,8 @@ class Manage extends \Zotlabs\Web\Controller { notice( t('Permission denied.') . EOL); return; } + + nav_set_selected('Manage'); require_once('include/security.php'); diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index f2ad77dd7..68e906c0e 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -154,7 +154,7 @@ class Network extends \Zotlabs\Web\Controller { )); } - nav_set_selected('network'); + nav_set_selected(t('Activity')); $channel_acl = array( 'allow_cid' => $channel['channel_allow_cid'], diff --git a/Zotlabs/Module/Profile.php b/Zotlabs/Module/Profile.php index ab349b05d..6930d50ca 100644 --- a/Zotlabs/Module/Profile.php +++ b/Zotlabs/Module/Profile.php @@ -21,6 +21,8 @@ class Profile extends \Zotlabs\Web\Controller { \App::$error = 404; return; } + + nav_set_selected('Profile'); $profile = ''; $channel = \App::get_channel(); diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php index f6e8b11ed..b1cf9596c 100644 --- a/Zotlabs/Module/Profiles.php +++ b/Zotlabs/Module/Profiles.php @@ -9,7 +9,7 @@ class Profiles extends \Zotlabs\Web\Controller { function init() { - nav_set_selected('profiles'); + nav_set_selected('Profiles'); if(! local_channel()) { return; diff --git a/Zotlabs/Module/Settings.php b/Zotlabs/Module/Settings.php index 76794e21c..79031c98f 100644 --- a/Zotlabs/Module/Settings.php +++ b/Zotlabs/Module/Settings.php @@ -53,7 +53,7 @@ class Settings extends \Zotlabs\Web\Controller { function get() { - nav_set_selected('settings'); + nav_set_selected('Settings'); if((! local_channel()) || ($_SESSION['delegate'])) { notice( t('Permission denied.') . EOL ); diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index 85481754f..4dc11c683 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -42,7 +42,7 @@ class Wiki extends \Zotlabs\Web\Controller { if(! feature_enabled(\App::$profile_uid,'wiki')) { notice( t('Not found') . EOL); - return; + return; } @@ -76,6 +76,8 @@ class Wiki extends \Zotlabs\Web\Controller { $wiki_owner = true; + nav_set_selected(t('Wiki')); + // Obtain the default permission settings of the channel $owner_acl = array( 'allow_cid' => $owner['channel_allow_cid'], -- cgit v1.2.3 From 27678a523c4c02bf4e3b31bf4ac01413feaf3759 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Fri, 21 Jul 2017 22:36:47 +0200 Subject: more nav_set_selected apps --- Zotlabs/Module/Connections.php | 5 ++--- Zotlabs/Module/Directory.php | 2 +- Zotlabs/Module/Events.php | 2 +- Zotlabs/Module/Help.php | 2 +- Zotlabs/Module/Photos.php | 2 ++ 5 files changed, 7 insertions(+), 6 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index b3c5e8ee9..6ad1e9528 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -29,6 +29,8 @@ class Connections extends \Zotlabs\Web\Controller { notice( t('Permission denied.') . EOL); return login(); } + + nav_set_selected(t('Connections')); $blocked = false; $hidden = false; @@ -71,7 +73,6 @@ class Connections extends \Zotlabs\Web\Controller { $search_flags = " and abook_pending = 1 "; $head = t('New'); $pending = true; - nav_set_selected('intros'); break; case 'ifpending': $r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ", @@ -81,7 +82,6 @@ class Connections extends \Zotlabs\Web\Controller { $search_flags = " and abook_pending = 1 "; $head = t('New'); $pending = true; - nav_set_selected('intros'); \App::$argv[1] = 'pending'; } else { @@ -91,7 +91,6 @@ class Connections extends \Zotlabs\Web\Controller { \App::$argc = 1; unset(\App::$argv[1]); } - nav_set_selected('intros'); break; // case 'unconnected': // $search_flags = " and abook_unconnected = 1 "; diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php index 92c1e0245..6268e99c6 100644 --- a/Zotlabs/Module/Directory.php +++ b/Zotlabs/Module/Directory.php @@ -77,7 +77,7 @@ class Directory extends \Zotlabs\Web\Controller { $pubforums = get_directory_setting($observer, 'pubforums'); $o = ''; - nav_set_selected('directory'); + nav_set_selected(t('Directory')); if(x($_POST,'search')) $search = notags(trim($_POST['search'])); diff --git a/Zotlabs/Module/Events.php b/Zotlabs/Module/Events.php index edc6dd3f0..0541f5e9b 100644 --- a/Zotlabs/Module/Events.php +++ b/Zotlabs/Module/Events.php @@ -272,7 +272,7 @@ class Events extends \Zotlabs\Web\Controller { return; } - nav_set_selected('all_events'); + nav_set_selected(t('Events')); if((argc() > 2) && (argv(1) === 'ignore') && intval(argv(2))) { $r = q("update event set dismissed = 1 where id = %d and uid = %d", diff --git a/Zotlabs/Module/Help.php b/Zotlabs/Module/Help.php index 0373a4aab..e98cb9d4d 100644 --- a/Zotlabs/Module/Help.php +++ b/Zotlabs/Module/Help.php @@ -15,7 +15,7 @@ require_once('include/help.php'); class Help extends \Zotlabs\Web\Controller { function get() { - nav_set_selected('help'); + nav_set_selected(t('Help')); if($_REQUEST['search']) { $o .= '
'; diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index 18d7abc48..0f80f46a5 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -554,6 +554,8 @@ class Photos extends \Zotlabs\Web\Controller { $sql_item = item_permissions_sql($owner_uid,get_observer_hash()); $sql_extra = permissions_sql($owner_uid,get_observer_hash(),'photo'); $sql_attach = permissions_sql($owner_uid,get_observer_hash(),'attach'); + + nav_set_selected(t('Photos')); $o = ""; -- cgit v1.2.3 From 4335e49381a766bc59b3ccd3df9c4981afab7603 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Sat, 22 Jul 2017 11:04:18 +0200 Subject: more nav_set_selected --- Zotlabs/Module/Bookmarks.php | 3 +++ Zotlabs/Module/Cdav.php | 2 ++ Zotlabs/Module/Chat.php | 6 ++++-- Zotlabs/Module/Invite.php | 4 +++- Zotlabs/Module/Lang.php | 1 + Zotlabs/Module/Mood.php | 8 ++++---- Zotlabs/Module/Poke.php | 4 +++- Zotlabs/Module/Probe.php | 4 +++- Zotlabs/Module/Rpost.php | 2 ++ Zotlabs/Module/Search.php | 2 +- Zotlabs/Module/Suggest.php | 2 ++ Zotlabs/Module/Webpages.php | 4 +++- 12 files changed, 31 insertions(+), 11 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Bookmarks.php b/Zotlabs/Module/Bookmarks.php index 682f8e76c..e62f5ce96 100644 --- a/Zotlabs/Module/Bookmarks.php +++ b/Zotlabs/Module/Bookmarks.php @@ -7,6 +7,9 @@ class Bookmarks extends \Zotlabs\Web\Controller { function init() { if(! local_channel()) return; + + nav_set_selected(t('View Bookmarks')); + $item_id = intval($_REQUEST['item']); $burl = trim($_REQUEST['burl']); diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php index b1d99620b..bc563ab43 100644 --- a/Zotlabs/Module/Cdav.php +++ b/Zotlabs/Module/Cdav.php @@ -765,6 +765,7 @@ class Cdav extends \Zotlabs\Web\Controller { } if(argv(1) === 'calendar') { + nav_set_selected(t('CalDAV')); $caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo); $calendars = $caldavBackend->getCalendarsForUser($principalUri); } @@ -965,6 +966,7 @@ class Cdav extends \Zotlabs\Web\Controller { if(argv(1) === 'addressbook') { + nav_set_selected(t('CardDAV')); $carddavBackend = new \Sabre\CardDAV\Backend\PDO($pdo); $addressbooks = $carddavBackend->getAddressBooksForUser($principalUri); } diff --git a/Zotlabs/Module/Chat.php b/Zotlabs/Module/Chat.php index 23a3e65da..138ca1cb5 100644 --- a/Zotlabs/Module/Chat.php +++ b/Zotlabs/Module/Chat.php @@ -89,9 +89,11 @@ class Chat extends \Zotlabs\Web\Controller { function get() { - if(local_channel()) + if(local_channel()) { $channel = \App::get_channel(); - + nav_set_selected(t('My Chatrooms')); + } + $ob = \App::get_observer(); $observer = get_observer_hash(); if(! $observer) { diff --git a/Zotlabs/Module/Invite.php b/Zotlabs/Module/Invite.php index 927e7beae..bbd98150d 100644 --- a/Zotlabs/Module/Invite.php +++ b/Zotlabs/Module/Invite.php @@ -88,12 +88,14 @@ class Invite extends \Zotlabs\Web\Controller { } - function get() { + function get() { if(! local_channel()) { notice( t('Permission denied.') . EOL); return; } + + nav_set_selected(t('Invite')); $tpl = get_markup_template('invite.tpl'); $invonly = false; diff --git a/Zotlabs/Module/Lang.php b/Zotlabs/Module/Lang.php index 69f10fe6d..84776c3ea 100644 --- a/Zotlabs/Module/Lang.php +++ b/Zotlabs/Module/Lang.php @@ -5,6 +5,7 @@ namespace Zotlabs\Module; class Lang extends \Zotlabs\Web\Controller { function get() { + nav_set_selected(t('Language')); return lang_selector(); } diff --git a/Zotlabs/Module/Mood.php b/Zotlabs/Module/Mood.php index eeb050040..85c8a3042 100644 --- a/Zotlabs/Module/Mood.php +++ b/Zotlabs/Module/Mood.php @@ -110,17 +110,17 @@ class Mood extends \Zotlabs\Web\Controller { - function get() { + function get() { if(! local_channel()) { notice( t('Permission denied.') . EOL); return; } - + + nav_set_selected(t('Mood')); + $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : '0'); - - $verbs = get_mood_verbs(); $shortlist = array(); diff --git a/Zotlabs/Module/Poke.php b/Zotlabs/Module/Poke.php index ea50e821a..0bd1187c7 100644 --- a/Zotlabs/Module/Poke.php +++ b/Zotlabs/Module/Poke.php @@ -143,12 +143,14 @@ class Poke extends \Zotlabs\Web\Controller { - function get() { + function get() { if(! local_channel()) { notice( t('Permission denied.') . EOL); return; } + + nav_set_selected(t('Poke')); $name = ''; $id = ''; diff --git a/Zotlabs/Module/Probe.php b/Zotlabs/Module/Probe.php index 7fc0e8ff5..859bed315 100644 --- a/Zotlabs/Module/Probe.php +++ b/Zotlabs/Module/Probe.php @@ -7,7 +7,9 @@ require_once('include/zot.php'); class Probe extends \Zotlabs\Web\Controller { function get() { - + + nav_set_selected(t('Remote Diagnostics')); + $o .= '

Probe Diagnostic

'; $o .= '
'; diff --git a/Zotlabs/Module/Rpost.php b/Zotlabs/Module/Rpost.php index 1349cd1c5..731eab82e 100644 --- a/Zotlabs/Module/Rpost.php +++ b/Zotlabs/Module/Rpost.php @@ -59,6 +59,8 @@ class Rpost extends \Zotlabs\Web\Controller { } return login(); } + + nav_set_selected(t('Post')); // If we have saved rpost session variables, but nothing in the current $_REQUEST, recover the saved variables diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 2b949ebc7..f95ae5e68 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -22,7 +22,7 @@ class Search extends \Zotlabs\Web\Controller { if($load) $_SESSION['loadtime'] = datetime_convert(); - nav_set_selected('search'); + nav_set_selected(t('Search')); require_once("include/bbcode.php"); require_once('include/security.php'); diff --git a/Zotlabs/Module/Suggest.php b/Zotlabs/Module/Suggest.php index 2a69145ed..c3f4a6d5a 100644 --- a/Zotlabs/Module/Suggest.php +++ b/Zotlabs/Module/Suggest.php @@ -28,6 +28,8 @@ class Suggest extends \Zotlabs\Web\Controller { notice( t('Permission denied.') . EOL); return; } + + nav_set_selected(t('Suggest Channels')); $_SESSION['return_url'] = z_root() . '/' . \App::$cmd; diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php index d59fcdb9f..e449a790f 100644 --- a/Zotlabs/Module/Webpages.php +++ b/Zotlabs/Module/Webpages.php @@ -34,7 +34,9 @@ class Webpages extends \Zotlabs\Web\Controller { \App::$error = 404; return; } - + + nav_set_selected(t('Webpages')); + $which = argv(1); $_SESSION['return_url'] = \App::$query_string; -- cgit v1.2.3 From 2095937c600c1770f656ac6354340815b4fde73e Mon Sep 17 00:00:00 2001 From: git-marijus Date: Mon, 31 Jul 2017 16:59:43 +0200 Subject: improve file_activity() a little --- Zotlabs/Module/Filestorage.php | 10 +--------- Zotlabs/Module/Sharedwithme.php | 5 +++++ 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Filestorage.php b/Zotlabs/Module/Filestorage.php index 785dff394..d6f363e77 100644 --- a/Zotlabs/Module/Filestorage.php +++ b/Zotlabs/Module/Filestorage.php @@ -5,14 +5,6 @@ namespace Zotlabs\Module; * */ -require_once('include/attach.php'); - - -/** - * - * @param object &$a - */ - class Filestorage extends \Zotlabs\Web\Controller { function post() { @@ -36,7 +28,7 @@ class Filestorage extends \Zotlabs\Web\Controller { $channel = \App::get_channel(); $acl = new \Zotlabs\Access\AccessList($channel); - $acl->set_from_array($_REQUEST); + $acl->set_from_array($_POST); $x = $acl->get(); $cloudPath = get_parent_cloudpath($channel_id, $channel['channel_address'], $resource); diff --git a/Zotlabs/Module/Sharedwithme.php b/Zotlabs/Module/Sharedwithme.php index 5d6d0f7da..2c97e9726 100644 --- a/Zotlabs/Module/Sharedwithme.php +++ b/Zotlabs/Module/Sharedwithme.php @@ -4,6 +4,11 @@ require_once('include/conversation.php'); require_once('include/text.php'); +/** + * @file Zotlabs/Module/Sharedwithme.php + * + */ + class Sharedwithme extends \Zotlabs\Web\Controller { function get() { -- cgit v1.2.3 From d183e47dc9b06825fd7e6c43b28a38b64cb6e0b8 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Thu, 3 Aug 2017 14:08:34 +0200 Subject: return preview also if we have no attachment --- Zotlabs/Module/Mail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index 7e6ec0cf9..e5509961a 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -53,8 +53,8 @@ class Mail extends \Zotlabs\Web\Controller { } $body = trim(str_replace($match[1],'',$body)); } - echo json_encode(['preview' => zidify_links(smilies(bbcode($body)))]); } + echo json_encode(['preview' => zidify_links(smilies(bbcode($body)))]); } killme(); } -- cgit v1.2.3 From 05444f92f98967841bfde9a3a88115cc13d09a92 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Thu, 3 Aug 2017 21:36:26 +0200 Subject: missing observer hash --- Zotlabs/Module/Item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 9e64528fa..5e7a3fbc0 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -634,7 +634,7 @@ class Item extends \Zotlabs\Web\Controller { $attach_link = ''; $hash = substr($mtch,0,strpos($mtch,',')); $rev = intval(substr($mtch,strpos($mtch,','))); - $r = attach_by_hash_nodata($hash,$rev); + $r = attach_by_hash_nodata($hash, $observer['xchan_hash'], $rev); if($r['success']) { $attachments[] = array( 'href' => z_root() . '/attach/' . $r['data']['hash'], -- cgit v1.2.3 From b4707705f15bda8c3bc4e21b7dd53ddcece69064 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 2 Aug 2017 22:11:46 -0700 Subject: minor activitypub rendering stuff --- Zotlabs/Module/Ap_probe.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Ap_probe.php b/Zotlabs/Module/Ap_probe.php index f788fa73a..769cd4c4e 100644 --- a/Zotlabs/Module/Ap_probe.php +++ b/Zotlabs/Module/Ap_probe.php @@ -30,7 +30,7 @@ class Ap_probe extends \Zotlabs\Web\Controller { $redirects = 0; $x = z_fetch_url($addr,true,$redirects, [ 'headers' => [ $headers ]]); if($x['success']) - $o .= '
' . str_replace('\\','',jindent($x['body'])) . '
'; + $o .= '
' . str_replace(['\\n','\\'],["\n",''],jindent($x['body'])) . '
'; } return $o; } -- cgit v1.2.3 From 0085b64b2bb22cf463ec66376d06d64d5b5b5730 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Sun, 6 Aug 2017 21:40:39 +0200 Subject: consolidate disable_discover_tab config if it was not yet set to either 1 or 0 in DB --- Zotlabs/Module/Network.php | 5 +++-- Zotlabs/Module/Pubstream.php | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 45623c7b0..e5c059af5 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -409,8 +409,9 @@ class Network extends \Zotlabs\Web\Controller { } $abook_uids = " and abook.abook_channel = " . local_channel() . " "; - - if($firehose && (! get_config('system','disable_discover_tab'))) { + + $disable_discover_tab = get_config('system','disable_discover_tab') || get_config('system','disable_discover_tab') === false; + if($firehose && (! $disable_discover_tab)) { require_once('include/channel.php'); $sys = get_sys_channel(); $uids = " and item.uid = " . intval($sys['channel_id']) . " "; diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 28c34425c..42aa2b51b 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -16,8 +16,8 @@ class Pubstream extends \Zotlabs\Web\Controller { return login(); } - - if(get_config('system','disable_discover_tab')) + $disable_discover_tab = get_config('system','disable_discover_tab') || get_config('system','disable_discover_tab') === false; + if($disable_discover_tab) return; $item_normal = item_normal(); -- cgit v1.2.3 From 80ff7fa35378da13dbfe57549963dc7b88080918 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 10 Aug 2017 21:58:44 +0200 Subject: create cdav principal also on client access and remove redundant pconfig check in authentication process --- Zotlabs/Module/Cdav.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php index bc563ab43..d0619ef0b 100644 --- a/Zotlabs/Module/Cdav.php +++ b/Zotlabs/Module/Cdav.php @@ -85,6 +85,15 @@ class Cdav extends \Zotlabs\Web\Controller { if($channel['channel_timezone']) $auth->setTimezone($channel['channel_timezone']); $auth->observer = $channel['channel_hash']; + + $principalUri = 'principals/' . $channel['channel_address']; + if(!cdav_principal($principalUri)) { + $this->activate($pdo, $channel); + if(!cdav_principal($principalUri)) { + return; + } + } + } -- cgit v1.2.3