From abbf245d1471f8038843c74541fb2f8a704dc8a4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 10 Sep 2017 16:10:56 -0700 Subject: [PATCH 01/12] remove item_thread_top from simple_update query - we're already fetching distinct(parent) and this prevented comments from displaying after submission when remote-authed. --- Zotlabs/Module/Channel.php | 2 +- Zotlabs/Module/Network.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index d82ed8e5d..4ffc9ffc6 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -194,7 +194,7 @@ class Channel extends \Zotlabs\Web\Controller { $simple_update = ''; if($static && $simple_update) - $simple_update .= " and item_thread_top = 1 and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' "; + $simple_update .= " and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' "; if(($update) && (! $load)) { diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index db90e235f..2b5584c35 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -478,6 +478,7 @@ class Network extends \Zotlabs\Web\Controller { } else { + // this is an update $r = q("SELECT item.parent AS item_id FROM item left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) @@ -510,7 +511,7 @@ class Network extends \Zotlabs\Web\Controller { else { $items = array(); } - + if($page_mode === 'list') { /** From 187fc9a51b4549659925a6c0c5c5bbb474c6bcf5 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 10 Sep 2017 17:40:40 -0700 Subject: [PATCH 02/12] fix regex --- include/oembed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/oembed.php b/include/oembed.php index f662d84c7..390fcba94 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -231,7 +231,7 @@ function oembed_fetch_url($embedurl){ // So if we see this, grab the frame src url and use that // as the embed content - which will still need to be purified. - if(preg_match('# Date: Sun, 10 Sep 2017 22:59:26 -0700 Subject: [PATCH 03/12] regex was still broken --- include/oembed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/oembed.php b/include/oembed.php index 390fcba94..c2bf0a0ed 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -231,7 +231,7 @@ function oembed_fetch_url($embedurl){ // So if we see this, grab the frame src url and use that // as the embed content - which will still need to be purified. - if(preg_match('# Date: Mon, 11 Sep 2017 18:56:17 -0700 Subject: [PATCH 04/12] typo in ldsigs --- Zotlabs/Lib/ActivityStreams.php | 12 +++++++++++- Zotlabs/Lib/LDSignatures.php | 4 +++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 686f4a140..2846ea476 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -13,7 +13,9 @@ class ActivityStreams { public $tgt = null; public $origin = null; public $owner = null; - + public $signer = null; + public $ldsig = null; + public $sigok = false; public $recips = null; function __construct($string) { @@ -32,6 +34,14 @@ class ActivityStreams { $this->origin = $this->get_compound_property('origin'); $this->recips = $this->collect_recips(); + $this->ldsig = $this->get_compound_property('signature'); + if($this->ldsig) { + $this->signer = $this->get_compound_property('creator',$this->ldsig); + if($this->signer && $this->signer['publicKey'] && $this->signer['publicKey']['publicKeyPem']) { + $this->sigok = \Zotlabs\Lib\LDSignatures::verify($this->data,$this->signer['publicKey']['publicKeyPem']); + } + } + if(($this->type === 'Note') && (! $this->obj)) { $this->obj = $this->data; $this->type = 'Create'; diff --git a/Zotlabs/Lib/LDSignatures.php b/Zotlabs/Lib/LDSignatures.php index 88dfe80c0..7d468782a 100644 --- a/Zotlabs/Lib/LDSignatures.php +++ b/Zotlabs/Lib/LDSignatures.php @@ -21,6 +21,7 @@ class LDSignatures { } static function sign($data,$channel) { + $options = [ 'type' => 'RsaSignature2017', 'nonce' => random_string(64), @@ -46,7 +47,7 @@ class LDSignatures { if($data) { foreach($data as $k => $v) { if(! in_array($k,[ 'signature' ])) { - $newopts[$k] = $v; + $newdata[$k] = $v; } } } @@ -68,6 +69,7 @@ class LDSignatures { } static function hash($obj) { + return hash('sha256',self::normalise($obj)); } From 4c121aff30a9481a8eb5a6ca75d2e8e664195a0b Mon Sep 17 00:00:00 2001 From: Sergey Lukin Date: Wed, 13 Sep 2017 04:00:59 +1000 Subject: [PATCH 05/12] hubzilla issue #855: fix for some problems with displaying selected theme after panel Settings->Display loading --- Zotlabs/Module/Settings/Display.php | 72 +++++++++++++++-------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/Zotlabs/Module/Settings/Display.php b/Zotlabs/Module/Settings/Display.php index eae44e82c..a444d28a2 100644 --- a/Zotlabs/Module/Settings/Display.php +++ b/Zotlabs/Module/Settings/Display.php @@ -24,34 +24,34 @@ class Display { $mobile_theme = ((x($_POST,'mobile_theme')) ? notags(trim($_POST['mobile_theme'])) : ''); $preload_images = ((x($_POST,'preload_images')) ? intval($_POST['preload_images']) : 0); $user_scalable = ((x($_POST,'user_scalable')) ? intval($_POST['user_scalable']) : 0); - $nosmile = ((x($_POST,'nosmile')) ? intval($_POST['nosmile']) : 0); - $title_tosource = ((x($_POST,'title_tosource')) ? intval($_POST['title_tosource']) : 0); + $nosmile = ((x($_POST,'nosmile')) ? intval($_POST['nosmile']) : 0); + $title_tosource = ((x($_POST,'title_tosource')) ? intval($_POST['title_tosource']) : 0); $channel_list_mode = ((x($_POST,'channel_list_mode')) ? intval($_POST['channel_list_mode']) : 0); $network_list_mode = ((x($_POST,'network_list_mode')) ? intval($_POST['network_list_mode']) : 0); $manual_update = ((array_key_exists('manual_update',$_POST)) ? intval($_POST['manual_update']) : 0); - + $channel_divmore_height = ((x($_POST,'channel_divmore_height')) ? intval($_POST['channel_divmore_height']) : 400); if($channel_divmore_height < 50) $channel_divmore_height = 50; $network_divmore_height = ((x($_POST,'network_divmore_height')) ? intval($_POST['network_divmore_height']) : 400); if($network_divmore_height < 50) $network_divmore_height = 50; - + $browser_update = ((x($_POST,'browser_update')) ? intval($_POST['browser_update']) : 0); $browser_update = $browser_update * 1000; if($browser_update < 10000) $browser_update = 10000; - + $itemspage = ((x($_POST,'itemspage')) ? intval($_POST['itemspage']) : 20); if($itemspage > 100) $itemspage = 100; - - if ($mobile_theme == "---") + + if ($mobile_theme == "---") del_pconfig(local_channel(),'system','mobile_theme'); else { set_pconfig(local_channel(),'system','mobile_theme',$mobile_theme); } - + set_pconfig(local_channel(),'system','preload_images',$preload_images); set_pconfig(local_channel(),'system','user_scalable',$user_scalable); set_pconfig(local_channel(),'system','update_interval', $browser_update); @@ -63,7 +63,7 @@ class Display { set_pconfig(local_channel(),'system','channel_divmore_height', $channel_divmore_height); set_pconfig(local_channel(),'system','network_divmore_height', $network_divmore_height); set_pconfig(local_channel(),'system','manual_conversation_update', $manual_update); - + $newschema = ''; if($theme){ // call theme_post only if theme has not been changed @@ -76,7 +76,7 @@ class Display { if(array_key_exists($_POST['schema'],$schemas)) $newschema = $_POST['schema']; if($newschema === '---') - $newschema = ''; + $newschema = ''; $theme_config->post(); } } @@ -85,18 +85,18 @@ class Display { logger('theme: ' . $theme . (($newschema) ? ':' . $newschema : '')); $_SESSION['theme'] = $theme . (($newschema) ? ':' . $newschema : ''); - + $r = q("UPDATE channel SET channel_theme = '%s' WHERE channel_id = %d", dbesc($theme . (($newschema) ? ':' . $newschema : '')), intval(local_channel()) ); - + call_hooks('display_settings_post', $_POST); build_sync_packet(); goaway(z_root() . '/settings/display' ); return; // NOTREACHED } - + function get() { @@ -115,16 +115,16 @@ class Display { $default_mobile_theme = get_config('system','mobile_theme'); if(! $mobile_default_theme) $mobile_default_theme = 'none'; - + $allowed_themes_str = get_config('system','allowed_themes'); $allowed_themes_raw = explode(',',$allowed_themes_str); $allowed_themes = array(); if(count($allowed_themes_raw)) - foreach($allowed_themes_raw as $x) + foreach($allowed_themes_raw as $x) if(strlen(trim($x)) && is_dir("view/theme/$x")) $allowed_themes[] = trim($x); - + $themes = array(); $files = glob('view/theme/*'); if($allowed_themes) { @@ -144,7 +144,7 @@ class Display { $is_library = file_exists('view/theme/'. $th . '/library'); $mobile_themes['---'] = t("No special theme for mobile devices"); - if (!$is_experimental or ($is_experimental && (get_config('experimentals','exp_themes')==1 or get_config('experimentals','exp_themes')===false))){ + if (!$is_experimental or ($is_experimental && (get_config('experimentals','exp_themes')==1 or get_config('experimentals','exp_themes')===false))){ $theme_name = (($is_experimental) ? sprintf(t('%s - (Experimental)'), $f) : $f); if (! $is_library) { if($is_mobile) { @@ -160,26 +160,30 @@ class Display { $theme_selected = ((array_key_exists('theme',$_SESSION) && $_SESSION['theme']) ? $_SESSION['theme'] : $theme); + if (strpos($theme_selected, ':')) { + $theme_selected = explode(':', $theme_selected)[0]; + } + $mobile_theme_selected = (!x($_SESSION,'mobile_theme')? $default_mobile_theme : $_SESSION['mobile_theme']); - + $preload_images = get_pconfig(local_channel(),'system','preload_images'); $preload_images = (($preload_images===false)? '0': $preload_images); // default if not set: 0 - + $user_scalable = get_pconfig(local_channel(),'system','user_scalable'); $user_scalable = (($user_scalable===false)? '0': $user_scalable); // default if not set: 0 - + $browser_update = intval(get_pconfig(local_channel(), 'system','update_interval')); $browser_update = (($browser_update == 0) ? 80 : $browser_update / 1000); // default if not set: 40 seconds - + $itemspage = intval(get_pconfig(local_channel(), 'system','itemspage')); $itemspage = (($itemspage > 0 && $itemspage < 101) ? $itemspage : 20); // default if not set: 20 items - + $nosmile = get_pconfig(local_channel(),'system','no_smilies'); $nosmile = (($nosmile===false)? '0': $nosmile); // default if not set: 0 - + $title_tosource = get_pconfig(local_channel(),'system','title_tosource'); $title_tosource = (($title_tosource===false)? '0': $title_tosource); // default if not set: 0 - + $theme_config = ""; if(($themeconfigfile = $this->get_theme_config_file($theme)) != null){ require_once($themeconfigfile); @@ -192,18 +196,18 @@ class Display { } // logger('schemas: ' . print_r($schemas,true)); - + $tpl = get_markup_template("settings_display.tpl"); $o = replace_macros($tpl, array( '$ptitle' => t('Display Settings'), - '$d_tset' => t('Theme Settings'), - '$d_ctset' => t('Custom Theme Settings'), + '$d_tset' => t('Theme Settings'), + '$d_ctset' => t('Custom Theme Settings'), '$d_cset' => t('Content Settings'), '$form_security_token' => get_form_security_token("settings_display"), '$submit' => t('Submit'), '$baseurl' => z_root(), '$uid' => local_channel(), - + '$theme' => (($themes) ? array('theme', t('Display Theme:'), $theme_selected, '', $themes, 'preview') : false), '$schema' => array('schema', t('Select scheme'), $existing_schema, '' , $schemas), @@ -222,11 +226,11 @@ class Display { '$network_list_mode' => array('network_list_mode', t('Use blog/list mode on grid page'), get_pconfig(local_channel(),'system','network_list_mode'), t('(comments displayed separately)'), $yes_no), '$channel_divmore_height' => array('channel_divmore_height', t('Channel page max height of content (in pixels)'), ((get_pconfig(local_channel(),'system','channel_divmore_height')) ? get_pconfig(local_channel(),'system','channel_divmore_height') : 400), t('click to expand content exceeding this height')), '$network_divmore_height' => array('network_divmore_height', t('Grid page max height of content (in pixels)'), ((get_pconfig(local_channel(),'system','network_divmore_height')) ? get_pconfig(local_channel(),'system','network_divmore_height') : 400) , t('click to expand content exceeding this height')), - - + + )); - call_hooks('display_settings',$o); + call_hooks('display_settings',$o); return $o; } @@ -234,10 +238,10 @@ class Display { function get_theme_config_file($theme){ $base_theme = \App::$theme_info['extends']; - + if (file_exists("view/theme/$theme/php/config.php")){ return "view/theme/$theme/php/config.php"; - } + } if (file_exists("view/theme/$base_theme/php/config.php")){ return "view/theme/$base_theme/php/config.php"; } @@ -246,5 +250,5 @@ class Display { - + } From 525d554a3530376a7a61e1c9e83fb2591c2b126b Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 12 Sep 2017 21:34:14 +0200 Subject: [PATCH 06/12] rename activity notifications links --- include/nav.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/nav.php b/include/nav.php index f5a1236a8..a2aab06f6 100644 --- a/include/nav.php +++ b/include/nav.php @@ -171,8 +171,8 @@ EOT; if(local_channel()) { $nav['network'] = array('network', t('Grid'), "", t('Your grid'),'network_nav_btn'); - $nav['network']['all'] = [ 'network', t('View your network/grid'), '','' ]; - $nav['network']['mark'] = array('', t('Mark all grid notifications seen'), '',''); + $nav['network']['all'] = [ 'network', t('View your network activity'), '','' ]; + $nav['network']['mark'] = array('', t('Mark all activity notifications seen'), '',''); $nav['home'] = array('channel/' . $channel['channel_address'], t('Channel Home'), "", t('Channel home'),'home_nav_btn'); $nav['home']['all'] = [ 'channel/' . $channel['channel_address'], t('View your channel home'), '' , '' ]; From 87ca60b0b128bf12b611146264159377baca71a3 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 12 Sep 2017 21:38:36 +0200 Subject: [PATCH 07/12] rename activity notifications links - one more --- include/nav.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nav.php b/include/nav.php index a2aab06f6..01decb2bf 100644 --- a/include/nav.php +++ b/include/nav.php @@ -170,7 +170,7 @@ EOT; if(local_channel()) { - $nav['network'] = array('network', t('Grid'), "", t('Your grid'),'network_nav_btn'); + $nav['network'] = array('network', t('Activity'), "", t('Network Activity'),'network_nav_btn'); $nav['network']['all'] = [ 'network', t('View your network activity'), '','' ]; $nav['network']['mark'] = array('', t('Mark all activity notifications seen'), '',''); From 4ff89a58625e647ee74087dfab79ac6dd76cbe6c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 12 Sep 2017 20:24:57 -0700 Subject: [PATCH 08/12] drop salmon until we improve performance --- Zotlabs/Lib/LDSignatures.php | 3 ++- include/network.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Lib/LDSignatures.php b/Zotlabs/Lib/LDSignatures.php index 7d468782a..fa2758044 100644 --- a/Zotlabs/Lib/LDSignatures.php +++ b/Zotlabs/Lib/LDSignatures.php @@ -16,7 +16,8 @@ class LDSignatures { } static function dopplesign(&$data,$channel) { - $data['magicEnv'] = self::salmon_sign($data,$channel); + // remove for the time being - performance issues + // $data['magicEnv'] = self::salmon_sign($data,$channel); return self::sign($data,$channel); } diff --git a/include/network.php b/include/network.php index 96cea4b6f..da1afc3ac 100644 --- a/include/network.php +++ b/include/network.php @@ -411,7 +411,7 @@ function http_status($val, $msg = '') { if ($val >= 200 && $val < 300) $msg = (($msg) ? $msg : 'OK'); - logger('' . $val . ' ' . $msg); + logger(\App::$query_string . ':' . $val . ' ' . $msg); header($_SERVER['SERVER_PROTOCOL'] . ' ' . $val . ' ' . $msg); } From 5e99295bf6f85e7a6d50e0c8f0701a9b37f03332 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 12 Sep 2017 22:32:31 -0700 Subject: [PATCH 09/12] wiki mimetype selection --- Zotlabs/Lib/NativeWikiPage.php | 8 +++++++- Zotlabs/Module/Wiki.php | 10 ++++++---- Zotlabs/Widget/Wiki_pages.php | 1 + include/text.php | 6 +++--- view/tpl/wiki_page_list.tpl | 3 ++- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index 78b54ebda..97dad5813 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -55,7 +55,12 @@ class NativeWikiPage { } - static public function create_page($channel_id, $observer_hash, $name, $resource_id) { + static public function create_page($channel_id, $observer_hash, $name, $resource_id, $mimetype = 'text/bbcode') { + + logger('mimetype: ' . $mimetype); + + if(! in_array($mimetype,[ 'text/markdown','text/bbcode','text/plain','text/html'])) + $mimetype = 'text/markdown; $w = Zlib\NativeWiki::get_wiki($channel_id, $observer_hash, $resource_id); @@ -68,6 +73,7 @@ class NativeWikiPage { $arr = []; $arr['uid'] = $channel_id; $arr['author_xchan'] = $observer_hash; + $arr['mimetype'] = $mimetype; $arr['resource_type'] = 'nwikipage'; $arr['resource_id'] = $resource_id; $arr['allow_cid'] = $w['wiki']['allow_cid']; diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index 4dc11c683..3fb980955 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -406,7 +406,7 @@ class Wiki extends \Zotlabs\Web\Controller { $r = Zlib\NativeWiki::create_wiki($owner, $observer_hash, $wiki, $acl); if($r['success']) { Zlib\NativeWiki::sync_a_wiki_item($owner['channel_id'],$r['item_id'],$r['item']['resource_id']); - $homePage = Zlib\NativeWikiPage::create_page($owner['channel_id'],$observer_hash,'Home', $r['item']['resource_id']); + $homePage = Zlib\NativeWikiPage::create_page($owner['channel_id'],$observer_hash,'Home', $r['item']['resource_id'], $wiki['mimeType']); if(! $homePage['success']) { notice( t('Wiki created, but error creating Home page.')); goaway(z_root() . '/wiki/' . $nick . '/' . $wiki['urlName']); @@ -445,11 +445,13 @@ class Wiki extends \Zotlabs\Web\Controller { // Create a page if ((argc() === 4) && (argv(2) === 'create') && (argv(3) === 'page')) { + $mimetype = $_POST['mimetype']; + $resource_id = $_POST['resource_id']; // Determine if observer has permission to create a page + - - $perms = Zlib\NativeWiki::get_permissions($resource_id, intval($owner['channel_id']), $observer_hash); + $perms = Zlib\NativeWiki::get_permissions($resource_id, intval($owner['channel_id']), $observer_hash, $mimetype); if(! $perms['write']) { logger('Wiki write permission denied. ' . EOL); json_return_and_die(array('success' => false)); @@ -459,7 +461,7 @@ class Wiki extends \Zotlabs\Web\Controller { if(urlencode(escape_tags($_POST['pageName'])) === '') { json_return_and_die(array('message' => 'Error creating page. Invalid name.', 'success' => false)); } - $page = Zlib\NativeWikiPage::create_page($owner['channel_id'],$observer_hash, $name, $resource_id); + $page = Zlib\NativeWikiPage::create_page($owner['channel_id'],$observer_hash, $name, $resource_id, $mimetype); if($page['item_id']) { $commit = Zlib\NativeWikiPage::commit(array( diff --git a/Zotlabs/Widget/Wiki_pages.php b/Zotlabs/Widget/Wiki_pages.php index 7285e2b42..ac6549ffd 100644 --- a/Zotlabs/Widget/Wiki_pages.php +++ b/Zotlabs/Widget/Wiki_pages.php @@ -50,6 +50,7 @@ class Wiki_pages { '$canadd' => $can_create, '$candel' => $can_delete, '$addnew' => t('Add new page'), + '$mimetype' => mimetype_select(0,$p['mimeType'], [ 'text/markdown','text/bbcode' ]), '$pageName' => array('pageName', t('Page name')), '$refresh' => $arr['refresh'] )); diff --git a/include/text.php b/include/text.php index 51d711021..58e2b8256 100644 --- a/include/text.php +++ b/include/text.php @@ -1786,15 +1786,15 @@ function layout_select($channel_id, $current = '') { } -function mimetype_select($channel_id, $current = 'text/bbcode') { +function mimetype_select($channel_id, $current = 'text/bbcode', $choices = null) { - $x = array( + $x = (($choices) ? $choices : [ 'text/bbcode', 'text/html', 'text/markdown', 'text/plain', 'application/x-pdl' - ); + ]); if((App::$is_sys) || (channel_codeallowed($channel_id) && $channel_id == local_channel())){ diff --git a/view/tpl/wiki_page_list.tpl b/view/tpl/wiki_page_list.tpl index 6d09fcd5d..2e7fb8b9e 100644 --- a/view/tpl/wiki_page_list.tpl +++ b/view/tpl/wiki_page_list.tpl @@ -21,6 +21,7 @@