From 2de1285121b5f0260699a93249bab11dc74edec5 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 16 Jan 2018 18:15:58 -0800 Subject: z6 deliver --- Zotlabs/Web/HTTPSig.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Web/HTTPSig.php b/Zotlabs/Web/HTTPSig.php index 63033ce5e..ef03dac94 100644 --- a/Zotlabs/Web/HTTPSig.php +++ b/Zotlabs/Web/HTTPSig.php @@ -137,6 +137,21 @@ class HTTPSig { } } + + if(in_array('x-zot-digest',$signed_headers)) { + $result['content_signed'] = true; + $digest = explode('=', $headers['x-zot-digest']); + if($digest[0] === 'SHA-256') + $hashalg = 'sha256'; + if($digest[0] === 'SHA-512') + $hashalg = 'sha512'; + + // The explode operation will have stripped the '=' padding, so compare against unpadded base64 + if(rtrim(base64_encode(hash($hashalg,$_POST['data'],true)),'=') === $digest[1]) { + $result['content_valid'] = true; + } + } + logger('Content_Valid: ' . $result['content_valid']); return $result; -- cgit v1.2.3 From 05de59d4ad174cb106c3a5b5890732af51730384 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 16 Jan 2018 20:08:10 -0800 Subject: initial z6 delivery --- Zotlabs/Daemon/Queue.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Queue.php b/Zotlabs/Daemon/Queue.php index 17d150250..1bab582bc 100644 --- a/Zotlabs/Daemon/Queue.php +++ b/Zotlabs/Daemon/Queue.php @@ -13,8 +13,8 @@ class Queue { require_once('include/bbcode.php'); - if(argc() > 1) - $queue_id = argv(1); + if($argc > 1) + $queue_id = $argv[1]; else $queue_id = 0; -- cgit v1.2.3 From 3cc756f3029e5f3b02008dac94a90e168d398c9a Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 4 Feb 2018 20:42:40 +0100 Subject: remove some never used indices which prevented our item queries to find the right query execution plan in mysql and adjust some queries to optimze the result --- Zotlabs/Module/Channel.php | 6 +++--- Zotlabs/Module/Hq.php | 4 +--- Zotlabs/Module/Network.php | 36 +++++++++++++++++++++++------------- Zotlabs/Module/Ping.php | 19 ++++++++----------- Zotlabs/Module/Pubstream.php | 4 ++-- Zotlabs/Widget/Forums.php | 3 ++- 6 files changed, 39 insertions(+), 33 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 7c4c900a1..b7e18f954 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -239,7 +239,7 @@ class Channel extends \Zotlabs\Web\Controller { if($load || ($checkjs->disabled())) { if($mid) { - $r = q("SELECT distinct parent AS item_id from item where mid like '%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 . '%'), intval(\App::$profile['profile_uid']) @@ -249,13 +249,13 @@ class Channel extends \Zotlabs\Web\Controller { } } else { - $r = q("SELECT distinct id AS item_id, created FROM item + $r = q("SELECT id AS item_id FROM item left join abook on item.author_xchan = abook.abook_xchan WHERE uid = %d $item_normal AND item_wall = 1 and item_thread_top = 1 AND (abook_blocked = 0 or abook.abook_flags is null) $sql_extra $sql_extra2 - ORDER BY created DESC $pager_sql ", + ORDER BY created DESC, id $pager_sql ", intval(\App::$profile['profile_uid']) ); } diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index c46695b65..baeba82e8 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -51,10 +51,8 @@ class Hq extends \Zotlabs\Web\Controller { $item_normal = item_normal(); $item_normal_update = item_normal_update(); - $use_index = db_use_index('created'); - if(! $item_hash) { - $r = q("SELECT mid FROM item $use_index + $r = q("SELECT mid FROM item WHERE uid = %d $item_normal AND mid = parent_mid ORDER BY created DESC LIMIT 1", diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 551303984..70e0048fb 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -209,8 +209,11 @@ class Network extends \Zotlabs\Web\Controller { : ''); $sql_nets = ''; + + $distinct = ''; + $item_thread_top = ' AND item_thread_top = 1 '; - $sql_extra = " AND item.parent IN ( SELECT parent FROM item WHERE item_thread_top = 1 $sql_options ) "; + $sql_extra = $sql_options; if($group) { $contact_str = ''; @@ -226,7 +229,8 @@ class Network extends \Zotlabs\Web\Controller { $contact_str = ' 0 '; info( t('Privacy group is empty')); } - + $distinct = ' distinct '; + $item_thread_top = ''; $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str )) or allow_gid like '" . protect_sprintf('%<' . dbesc($group_hash) . '>%') . "' ) and id = parent $item_normal ) "; $x = group_rec_byhash(local_channel(), $group_hash); @@ -250,6 +254,8 @@ class Network extends \Zotlabs\Web\Controller { intval(local_channel()) ); if($r) { + $distinct = ' distinct '; + $item_thread_top = ''; $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) $item_normal ) "; $title = replace_macros(get_markup_template("section_title.tpl"),array( '$title' => '' . urlencode($r[0]['xchan_name']) . ' ' . $r[0]['xchan_name'] . '' @@ -264,13 +270,15 @@ class Network extends \Zotlabs\Web\Controller { } } elseif($xchan) { - $r = q("select * from xchan where xchan_hash = '%s'", - dbesc($xchan) - ); - if($r) { - $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($xchan) . "' or owner_xchan = '" . dbesc($xchan) . "' ) $item_normal ) "; - $title = replace_macros(get_markup_template("section_title.tpl"),array( - '$title' => '' . urlencode($r[0]['xchan_name']) . ' ' . $r[0]['xchan_name'] . '' + $r = q("select * from xchan where xchan_hash = '%s'", + dbesc($xchan) + ); + if($r) { + $distinct = ' distinct '; + $item_thread_top = ''; + $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($xchan) . "' or owner_xchan = '" . dbesc($xchan) . "' ) $item_normal ) "; + $title = replace_macros(get_markup_template("section_title.tpl"),array( + '$title' => '' . urlencode($r[0]['xchan_name']) . ' ' . $r[0]['xchan_name'] . '' )); $o = $tabs; $o .= $title; @@ -373,6 +381,8 @@ class Network extends \Zotlabs\Web\Controller { } if($conv) { + $distinct = ' distinct '; + $item_thread_top = ''; $sql_extra .= sprintf(" AND parent IN (SELECT distinct(parent) from item where ( author_xchan like '%s' or item_mentionsme = 1 )) ", dbesc(protect_sprintf($channel['channel_hash'])) ); @@ -448,7 +458,7 @@ class Network extends \Zotlabs\Web\Controller { if($nouveau && $load) { // "New Item View" - show all items unthreaded in reverse created date order - $items = q("SELECT item.*, item.id AS item_id, received FROM item + $items = q("SELECT item.*, item.id AS item_id, received FROM item left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) $net_query WHERE true $uids $item_normal @@ -477,11 +487,11 @@ class Network extends \Zotlabs\Web\Controller { if($load) { // Fetch a page full of parent items for this page - $r = q("SELECT distinct item.id AS item_id, $ordering FROM item + $r = q("SELECT $distinct item.parent AS item_id FROM item left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) $net_query - WHERE true $uids $item_normal - AND item.parent = item.id + WHERE true $uids $item_thread_top $item_normal + AND item.mid = item.parent_mid and (abook.abook_blocked = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets $net_query2 diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index f8399d871..2e86804ac 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -149,13 +149,11 @@ class Ping extends \Zotlabs\Web\Controller { $pubs = q("SELECT count(id) as total from item WHERE uid = %d AND author_xchan != '%s' - AND obj_type != '%s' AND item_unseen = 1 AND created > '" . datetime_convert('UTC','UTC',$_SESSION['static_loadtime']) . "' $item_normal", intval($sys['channel_id']), - dbesc(get_observer_hash()), - dbesc(ACTIVITY_OBJ_FILE) + dbesc(get_observer_hash()) ); if($pubs) @@ -320,12 +318,13 @@ class Ping extends \Zotlabs\Web\Controller { if(argc() > 1 && (argv(1) === 'network' || argv(1) === 'home')) { $result = array(); - $use_index = db_use_index('uid_item_unseen'); - - $r = q("SELECT * FROM item $use_index - WHERE item_unseen = 1 and uid = %d $item_normal + $r = q("SELECT * FROM item + WHERE uid = %d AND author_xchan != '%s' - ORDER BY created DESC limit 300", + AND item_unseen = 1 + $item_normal + ORDER BY created DESC, id + LIMIT 300", intval(local_channel()), dbesc($ob_hash) ); @@ -495,9 +494,7 @@ class Ping extends \Zotlabs\Web\Controller { if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) { - $use_index = db_use_index('uid_item_unseen'); - - $r = q("SELECT id, item_wall FROM item $use_index + $r = q("SELECT id, item_wall FROM item WHERE item_unseen = 1 and uid = %d $item_normal AND author_xchan != '%s'", diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 2c25e2ce0..16a5fdbba 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -196,10 +196,10 @@ class Pubstream extends \Zotlabs\Web\Controller { } else { // Fetch a page full of parent items for this page - $r = q("SELECT distinct item.id AS item_id, $ordering FROM item + $r = q("SELECT item.id AS item_id FROM item left join abook on item.author_xchan = abook.abook_xchan $net_query - WHERE true $uids $item_normal + WHERE item_thread_top = 1 $uids $item_normal AND item.parent = item.id and (abook.abook_blocked = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets $net_query2 diff --git a/Zotlabs/Widget/Forums.php b/Zotlabs/Widget/Forums.php index 44d95012f..b572444e3 100644 --- a/Zotlabs/Widget/Forums.php +++ b/Zotlabs/Widget/Forums.php @@ -64,7 +64,8 @@ class Forums { // There also should be a way to update this via ajax. for($x = 0; $x < count($r1); $x ++) { - $r = q("select sum(item_unseen) as unseen from item where owner_xchan = '%s' and uid = %d and item_unseen = 1 $perms_sql ", + $r = q("select sum(item_unseen) as unseen from item + where owner_xchan = '%s' and uid = %d and item_unseen = 1 $perms_sql ", dbesc($r1[$x]['xchan_hash']), intval(local_channel()) ); -- cgit v1.2.3 From 9d55a254dcd39e2a77a1c24625adba69d16acb7a Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 4 Feb 2018 22:37:30 +0100 Subject: this will fix the cards query and keep the rest intact --- Zotlabs/Module/Cards.php | 2 +- Zotlabs/Widget/Forums.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Cards.php b/Zotlabs/Module/Cards.php index 8eff6c80d..f87988183 100644 --- a/Zotlabs/Module/Cards.php +++ b/Zotlabs/Module/Cards.php @@ -143,7 +143,7 @@ class Cards extends \Zotlabs\Web\Controller { } $r = q("select * from item - where item.uid = %d and item_type = %d + where uid = %d and item_type = %d $sql_extra order by item.created desc", intval($owner), intval(ITEM_TYPE_CARD) diff --git a/Zotlabs/Widget/Forums.php b/Zotlabs/Widget/Forums.php index b572444e3..f65a639ff 100644 --- a/Zotlabs/Widget/Forums.php +++ b/Zotlabs/Widget/Forums.php @@ -65,7 +65,7 @@ class Forums { for($x = 0; $x < count($r1); $x ++) { $r = q("select sum(item_unseen) as unseen from item - where owner_xchan = '%s' and uid = %d and item_unseen = 1 $perms_sql ", + where uid = %d and owner_xchan = '%s' and item_unseen = 1 $perms_sql ", dbesc($r1[$x]['xchan_hash']), intval(local_channel()) ); -- cgit v1.2.3 From f15fd93f905520fa7f58e7365c838edd382b227c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 4 Feb 2018 17:01:59 -0800 Subject: implode can take its arguments in either order, but let's try to be consistent --- Zotlabs/Module/Admin/Security.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Admin/Security.php b/Zotlabs/Module/Admin/Security.php index a1e4bf537..49e1ccf42 100644 --- a/Zotlabs/Module/Admin/Security.php +++ b/Zotlabs/Module/Admin/Security.php @@ -52,24 +52,24 @@ class Security { function get() { $whitesites = get_config('system','whitelisted_sites'); - $whitesites_str = ((is_array($whitesites)) ? implode($whitesites,"\n") : ''); + $whitesites_str = ((is_array($whitesites)) ? implode("\n",$whitesites) : ''); $blacksites = get_config('system','blacklisted_sites'); - $blacksites_str = ((is_array($blacksites)) ? implode($blacksites,"\n") : ''); + $blacksites_str = ((is_array($blacksites)) ? implode("\n",$blacksites) : ''); $whitechannels = get_config('system','whitelisted_channels'); - $whitechannels_str = ((is_array($whitechannels)) ? implode($whitechannels,"\n") : ''); + $whitechannels_str = ((is_array($whitechannels)) ? implode("\n",$whitechannels) : ''); $blackchannels = get_config('system','blacklisted_channels'); - $blackchannels_str = ((is_array($blackchannels)) ? implode($blackchannels,"\n") : ''); + $blackchannels_str = ((is_array($blackchannels)) ? implode("\n",$blackchannels) : ''); $whiteembeds = get_config('system','embed_allow'); - $whiteembeds_str = ((is_array($whiteembeds)) ? implode($whiteembeds,"\n") : ''); + $whiteembeds_str = ((is_array($whiteembeds)) ? implode("\n",$whiteembeds) : ''); $blackembeds = get_config('system','embed_deny'); - $blackembeds_str = ((is_array($blackembeds)) ? implode($blackembeds,"\n") : ''); + $blackembeds_str = ((is_array($blackembeds)) ? implode("\n",$blackembeds) : ''); $embed_coop = intval(get_config('system','embed_coop')); -- cgit v1.2.3 From b06c52553d1fee69062b533a46b80190d9b4b350 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 5 Feb 2018 16:08:01 -0800 Subject: fix manual queue invocation (was using the web argc/argv from the cli) --- Zotlabs/Daemon/Queue.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Queue.php b/Zotlabs/Daemon/Queue.php index 17d150250..8f529ff13 100644 --- a/Zotlabs/Daemon/Queue.php +++ b/Zotlabs/Daemon/Queue.php @@ -13,10 +13,10 @@ class Queue { require_once('include/bbcode.php'); - if(argc() > 1) - $queue_id = argv(1); + if($argc > 1) + $queue_id = $argv[1]; else - $queue_id = 0; + $queue_id = EMPTY_STR; logger('queue: start'); -- cgit v1.2.3 From cadd958339323f5fcf4c2b438f7a5e311e477d52 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 5 Feb 2018 18:06:25 -0800 Subject: remove mobile_detect (outdated and unmaintainable) --- Zotlabs/Module/Connections.php | 2 +- Zotlabs/Module/Connedit.php | 1 - Zotlabs/Module/Settings/Display.php | 26 ++++---------------------- Zotlabs/Render/Theme.php | 30 +++--------------------------- 4 files changed, 8 insertions(+), 51 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index f42ff9b84..255731c9c 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -232,7 +232,7 @@ class Connections extends \Zotlabs\Web\Controller { if($rr['xchan_url']) { if(($rr['vcard']) && is_array($rr['vcard']['tels']) && $rr['vcard']['tels'][0]['nr']) - $phone = ((\App::$is_mobile || \App::$is_tablet) ? $rr['vcard']['tels'][0]['nr'] : ''); + $phone = $rr['vcard']['tels'][0]['nr']; else $phone = ''; diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php index e23a751d9..f359175c1 100644 --- a/Zotlabs/Module/Connedit.php +++ b/Zotlabs/Module/Connedit.php @@ -895,7 +895,6 @@ class Connedit extends \Zotlabs\Web\Controller { '$permnote_self' => t('Some permissions may be inherited from your channel\'s privacy settings, which have higher priority than individual settings. You can change those settings here but they wont have any impact unless the inherited setting changes.'), '$lastupdtext' => t('Last update:'), '$last_update' => relative_date($contact['abook_connected']), - '$is_mobile' => ((\App::$is_mobile || \App::$is_tablet) ? true : false), '$profile_select' => contact_profile_assign($contact['abook_profile']), '$multiprofs' => $multiprofs, '$contact_id' => $contact['abook_id'], diff --git a/Zotlabs/Module/Settings/Display.php b/Zotlabs/Module/Settings/Display.php index e1ea0e3e5..340b3c0bb 100644 --- a/Zotlabs/Module/Settings/Display.php +++ b/Zotlabs/Module/Settings/Display.php @@ -21,7 +21,7 @@ class Display { if(! $theme) $theme = 'redbasic'; - $mobile_theme = ((x($_POST,'mobile_theme')) ? notags(trim($_POST['mobile_theme'])) : ''); + $preload_images = ((x($_POST,'preload_images')) ? intval($_POST['preload_images']) : 0); $channel_menu = ((x($_POST,'channel_menu')) ? intval($_POST['channel_menu']) : 0); $user_scalable = ((x($_POST,'user_scalable')) ? intval($_POST['user_scalable']) : 0); @@ -47,11 +47,6 @@ class Display { if($itemspage > 100) $itemspage = 100; - 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); @@ -114,10 +109,6 @@ class Display { $theme = (($existing_theme) ? $existing_theme : $default_theme); - $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(); @@ -135,26 +126,19 @@ class Display { $info = get_theme_info($th); $compatible = check_plugin_versions($info); - if(!$compatible) { - $mobile_themes[$f] = $themes[$f] = sprintf(t('%s - (Incompatible)'), $f); + if(! $compatible) { + $themes[$f] = sprintf(t('%s - (Incompatible)'), $f); continue; } $is_experimental = file_exists('view/theme/' . $th . '/experimental'); $unsupported = file_exists('view/theme/' . $th . '/unsupported'); - $is_mobile = file_exists('view/theme/' . $th . '/mobile'); $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))){ $theme_name = (($is_experimental) ? sprintf(t('%s - (Experimental)'), $f) : $f); if (! $is_library) { - if($is_mobile) { - $mobile_themes[$f] = $themes[$f] = $theme_name . ' (' . t('mobile') . ')'; - } - else { - $mobile_themes[$f] = $themes[$f] = $theme_name; - } + $themes[$f] = $theme_name; } } } @@ -166,7 +150,6 @@ class Display { $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 @@ -213,7 +196,6 @@ class Display { '$theme' => (($themes) ? array('theme', t('Display Theme:'), $theme_selected, '', $themes, 'preview') : false), '$schema' => array('schema', t('Select scheme'), $existing_schema, '' , $schemas), - '$mobile_theme' => (($mobile_themes) ? array('mobile_theme', t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, '') : false), '$preload_images' => array('preload_images', t("Preload images before rendering the page"), $preload_images, t("The subjective page load time will be longer but the page will be ready when displayed"), $yes_no), '$user_scalable' => array('user_scalable', t("Enable user zoom on mobile devices"), $user_scalable, '', $yes_no), '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')), diff --git a/Zotlabs/Render/Theme.php b/Zotlabs/Render/Theme.php index 09cc7a4d4..0eebba1ba 100644 --- a/Zotlabs/Render/Theme.php +++ b/Zotlabs/Render/Theme.php @@ -8,10 +8,8 @@ use App; class Theme { static $system_theme = null; - static $system_mobile_theme = null; static $session_theme = null; - static $session_mobile_theme = null; /** * @brief Array with base or fallback themes. @@ -32,10 +30,6 @@ class Theme { ? \App::$config['system']['theme'] : ''); self::$session_theme = ((isset($_SESSION) && x($_SESSION, 'theme')) ? $_SESSION['theme'] : self::$system_theme); - self::$system_mobile_theme = ((isset(\App::$config['system']['mobile_theme'])) - ? \App::$config['system']['mobile_theme'] : ''); - self::$session_mobile_theme = ((isset($_SESSION) && x($_SESSION, 'mobile_theme')) - ? $_SESSION['mobile_theme'] : self::$system_mobile_theme); $page_theme = null; @@ -55,30 +49,12 @@ class Theme { if(array_key_exists('theme', \App::$layout) && \App::$layout['theme']) $page_theme = \App::$layout['theme']; - // If the viewer is on a mobile device, ensure that we're using a mobile - // theme of some kind or whatever the viewer's preference is for mobile - // viewing (if applicable) + $chosen_theme = self::$session_theme; - if(\App::$is_mobile || \App::$is_tablet) { - if(isset($_SESSION['show_mobile']) && (! $_SESSION['show_mobile'])) { - $chosen_theme = self::$session_theme; - } - else { - $chosen_theme = self::$session_mobile_theme; - - if($chosen_theme === '' || $chosen_theme === '---' ) { - // user has selected to have the mobile theme be the same as the normal one - $chosen_theme = self::$session_theme; - } - } + if($page_theme) { + $chosen_theme = $page_theme; } - else { - $chosen_theme = self::$session_theme; - if($page_theme) { - $chosen_theme = $page_theme; - } - } if(array_key_exists('theme_preview', $_GET)) $chosen_theme = $_GET['theme_preview']; -- cgit v1.2.3 From 3a0db39fa05668831e7661ac6edaabfd09d864e2 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 7 Feb 2018 18:38:10 -0800 Subject: more zot6 delivery work --- Zotlabs/Daemon/Notifier.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index b168db5ae..957b859af 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -618,8 +618,8 @@ class Notifier { $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null)); } if($packet_type === 'keychange') { - $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null)); $pmsg = get_pconfig($channel['channel_id'],'system','keychange'); + $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null)); } elseif($packet_type === 'request') { $env = (($hub_env && $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']]) ? $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']] : ''); @@ -640,7 +640,7 @@ class Notifier { } else { $env = (($hub_env && $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']]) ? $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']] : ''); - $packet = zot_build_packet($channel,'notify',$env,(($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); + $packet = zot6_build_packet($channel,'notify',$env, json_encode($encoded_item), (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); queue_insert( [ 'hash' => $hash, -- cgit v1.2.3 From 4c27fa5c37fbe4fc6debaadeaf3b4b134bc9068b Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 7 Feb 2018 22:04:53 -0800 Subject: debug the crypto function --- Zotlabs/Web/HTTPSig.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Web/HTTPSig.php b/Zotlabs/Web/HTTPSig.php index ef03dac94..8c94a4ff0 100644 --- a/Zotlabs/Web/HTTPSig.php +++ b/Zotlabs/Web/HTTPSig.php @@ -210,6 +210,9 @@ class HTTPSig { if($crypt_key) { $x = crypto_encapsulate($headerval,$crypt_key,$crypt_alg); + +logger(cryptosig: ' . print_r($x,true)); + $headerval = 'iv="' . $x['iv'] . '",key="' . $x['key'] . '",alg="' . $x['alg'] . '",data="' . $x['data']; } -- cgit v1.2.3 From 661c20e452255754bbccadc3b29dc3c598c07ed0 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 8 Feb 2018 09:47:49 +0100 Subject: more db and queries finetuning --- Zotlabs/Module/Ping.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 2e86804ac..96ade22c0 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -148,8 +148,8 @@ class Ping extends \Zotlabs\Web\Controller { $pubs = q("SELECT count(id) as total from item WHERE uid = %d - AND author_xchan != '%s' AND item_unseen = 1 + AND author_xchan != '%s' AND created > '" . datetime_convert('UTC','UTC',$_SESSION['static_loadtime']) . "' $item_normal", intval($sys['channel_id']), @@ -166,8 +166,8 @@ class Ping extends \Zotlabs\Web\Controller { $r = q("SELECT * FROM item WHERE uid = %d - AND author_xchan != '%s' AND item_unseen = 1 + AND author_xchan != '%s' AND created > '" . datetime_convert('UTC','UTC',$_SESSION['static_loadtime']) . "' $item_normal ORDER BY created DESC @@ -208,22 +208,22 @@ class Ping extends \Zotlabs\Web\Controller { if(x($_REQUEST, 'markRead') && local_channel()) { switch($_REQUEST['markRead']) { case 'network': - $r = q("update item set item_unseen = 0 where item_unseen = 1 and uid = %d", + $r = q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND item_unseen = 1", intval(local_channel()) ); break; case 'home': - $r = q("update item set item_unseen = 0 where item_unseen = 1 and item_wall = 1 and uid = %d", + $r = q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND item_unseen = 1 AND item_wall = 1", intval(local_channel()) ); break; case 'mail': - $r = q("update mail set mail_seen = 1 where mail_seen = 0 and channel_id = %d ", + $r = q("UPDATE mail SET mail_seen = 1 WHERE channel_id = %d AND mail_seen = 0", intval(local_channel()) ); break; case 'all_events': - $r = q("update event set dismissed = 1 where dismissed = 0 and uid = %d AND dtstart < '%s' AND dtstart > '%s' ", + $r = q("UPDATE event SET dismissed = 1 WHERE uid = %d AND dismissed = 0 AND dtstart < '%s' AND dtstart > '%s' ", intval(local_channel()), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) @@ -243,9 +243,9 @@ class Ping extends \Zotlabs\Web\Controller { } if(x($_REQUEST, 'markItemRead') && local_channel()) { - $r = q("update item set item_unseen = 0 where parent = %d and uid = %d", - intval($_REQUEST['markItemRead']), - intval(local_channel()) + $r = q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND parent = %d", + intval(local_channel()), + intval($_REQUEST['markItemRead']) ); } @@ -254,7 +254,7 @@ class Ping extends \Zotlabs\Web\Controller { * dropdown menu. */ if(argc() > 1 && argv(1) === 'notify') { - $t = q("select * from notify where uid = %d and seen = 0 order by created desc", + $t = q("SELECT * FROM notify WHERE uid = %d AND seen = 0 ORDER BY CREATED DESC", intval(local_channel()) ); @@ -320,10 +320,10 @@ class Ping extends \Zotlabs\Web\Controller { $r = q("SELECT * FROM item WHERE uid = %d - AND author_xchan != '%s' AND item_unseen = 1 + AND author_xchan != '%s' $item_normal - ORDER BY created DESC, id + ORDER BY created DESC LIMIT 300", intval(local_channel()), dbesc($ob_hash) @@ -495,7 +495,7 @@ class Ping extends \Zotlabs\Web\Controller { if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) { $r = q("SELECT id, item_wall FROM item - WHERE item_unseen = 1 and uid = %d + WHERE uid = %d and item_unseen = 1 $item_normal AND author_xchan != '%s'", intval(local_channel()), -- cgit v1.2.3 From 384cb215beebb2cbd7ad5b32da551ebde1f3a6e0 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 8 Feb 2018 10:26:49 +0100 Subject: wrong link --- Zotlabs/Widget/Notifications.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Notifications.php b/Zotlabs/Widget/Notifications.php index 322a7b60a..d51cb0113 100644 --- a/Zotlabs/Widget/Notifications.php +++ b/Zotlabs/Widget/Notifications.php @@ -67,7 +67,7 @@ class Notifications { 'label' => t('New Events'), 'title' => t('New Events Notifications'), 'viewall' => [ - 'url' => 'mail/combined', + 'url' => 'events', 'label' => t('View events') ], 'markall' => [ -- cgit v1.2.3 From 635c5e532bd945fe50dc3fae73e4da005158e3de Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 8 Feb 2018 15:32:54 -0800 Subject: z6 testing --- Zotlabs/Web/HTTPSig.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Web/HTTPSig.php b/Zotlabs/Web/HTTPSig.php index 8c94a4ff0..dba5c4687 100644 --- a/Zotlabs/Web/HTTPSig.php +++ b/Zotlabs/Web/HTTPSig.php @@ -209,7 +209,7 @@ class HTTPSig { . '",headers="' . $x['headers'] . '",signature="' . $x['signature'] . '"'; if($crypt_key) { - $x = crypto_encapsulate($headerval,$crypt_key,$crypt_alg); + $x = crypto_encapsulate($headerval,$crypt_key,$crypt_algo); logger(cryptosig: ' . print_r($x,true)); -- cgit v1.2.3 From e4503f743e0a51ebb91401746bcfa800dd890dc9 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 8 Feb 2018 15:36:22 -0800 Subject: logging --- Zotlabs/Web/HTTPSig.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Web/HTTPSig.php b/Zotlabs/Web/HTTPSig.php index dba5c4687..a6b8d67a4 100644 --- a/Zotlabs/Web/HTTPSig.php +++ b/Zotlabs/Web/HTTPSig.php @@ -194,6 +194,8 @@ class HTTPSig { static function create_sig($request,$head,$prvkey,$keyid = 'Key',$send_headers = false,$auth = false,$alg = 'sha256', $crypt_key = null, $crypt_algo = 'aes256ctr') { +logger('cryptkey' . $crypt_key); + $return_headers = []; if($alg === 'sha256') { @@ -211,7 +213,7 @@ class HTTPSig { if($crypt_key) { $x = crypto_encapsulate($headerval,$crypt_key,$crypt_algo); -logger(cryptosig: ' . print_r($x,true)); +logger('cryptosig: ' . print_r($x,true)); $headerval = 'iv="' . $x['iv'] . '",key="' . $x['key'] . '",alg="' . $x['alg'] . '",data="' . $x['data']; } -- cgit v1.2.3 From beec49847f54d89f15b205482cbf375782553527 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 8 Feb 2018 15:45:33 -0800 Subject: missing quote --- Zotlabs/Web/HTTPSig.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Web/HTTPSig.php b/Zotlabs/Web/HTTPSig.php index a6b8d67a4..0b264ca7a 100644 --- a/Zotlabs/Web/HTTPSig.php +++ b/Zotlabs/Web/HTTPSig.php @@ -215,7 +215,7 @@ logger('cryptkey' . $crypt_key); logger('cryptosig: ' . print_r($x,true)); - $headerval = 'iv="' . $x['iv'] . '",key="' . $x['key'] . '",alg="' . $x['alg'] . '",data="' . $x['data']; + $headerval = 'iv="' . $x['iv'] . '",key="' . $x['key'] . '",alg="' . $x['alg'] . '",data="' . $x['data'] . '"'; } if($auth) { -- cgit v1.2.3 From cd1e5d417167836ee5ac64d042815b377c22b694 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 8 Feb 2018 16:22:10 -0800 Subject: zot6 testing --- Zotlabs/Web/HTTPSig.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Web/HTTPSig.php b/Zotlabs/Web/HTTPSig.php index 0b264ca7a..a27edb73d 100644 --- a/Zotlabs/Web/HTTPSig.php +++ b/Zotlabs/Web/HTTPSig.php @@ -152,7 +152,7 @@ class HTTPSig { } } - logger('Content_Valid: ' . $result['content_valid']); + logger('Content_Valid: ' . (($result['content_valid']) ? 'true' : 'false')); return $result; @@ -194,8 +194,6 @@ class HTTPSig { static function create_sig($request,$head,$prvkey,$keyid = 'Key',$send_headers = false,$auth = false,$alg = 'sha256', $crypt_key = null, $crypt_algo = 'aes256ctr') { -logger('cryptkey' . $crypt_key); - $return_headers = []; if($alg === 'sha256') { @@ -212,9 +210,6 @@ logger('cryptkey' . $crypt_key); if($crypt_key) { $x = crypto_encapsulate($headerval,$crypt_key,$crypt_algo); - -logger('cryptosig: ' . print_r($x,true)); - $headerval = 'iv="' . $x['iv'] . '",key="' . $x['key'] . '",alg="' . $x['alg'] . '",data="' . $x['data'] . '"'; } -- cgit v1.2.3 From 5f229d81e9aaac0e0d82091d2d9089f5fb34bfe8 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 9 Feb 2018 14:06:59 +0100 Subject: use distinct in channel item query and minor notification cache improvement --- Zotlabs/Module/Channel.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index b7e18f954..dddca16b4 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -249,13 +249,13 @@ class Channel extends \Zotlabs\Web\Controller { } } else { - $r = q("SELECT id AS item_id FROM item + $r = q("SELECT DISTINCT item.parent AS item_id FROM item left join abook on item.author_xchan = abook.abook_xchan - WHERE uid = %d $item_normal - AND item_wall = 1 and item_thread_top = 1 - AND (abook_blocked = 0 or abook.abook_flags is null) + WHERE true and uid = %d $item_normal + AND (abook.abook_blocked = 0 or abook.abook_flags is null) + AND item.item_wall = 1 AND item.item_thread_top AND item.mid = item.parent_mid $sql_extra $sql_extra2 - ORDER BY created DESC, id $pager_sql ", + ORDER BY created DESC $pager_sql ", intval(\App::$profile['profile_uid']) ); } -- cgit v1.2.3 From 6cc32943954124739023751eb377d398a54772d9 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 9 Feb 2018 20:36:14 +0100 Subject: finally fix channel query --- Zotlabs/Module/Channel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index dddca16b4..3dab85410 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -204,7 +204,7 @@ class Channel extends \Zotlabs\Web\Controller { $_SESSION['loadtime'] = datetime_convert(); } else { - $r = q("SELECT distinct parent AS item_id, created from item + $r = q("SELECT distinct parent AS item_id from item left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) WHERE uid = %d $item_normal_update AND item_wall = 1 $simple_update @@ -249,11 +249,11 @@ class Channel extends \Zotlabs\Web\Controller { } } else { - $r = q("SELECT DISTINCT item.parent AS item_id FROM item - left join abook on item.author_xchan = abook.abook_xchan + $r = q("SELECT item.parent AS item_id FROM item + left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) WHERE true and uid = %d $item_normal AND (abook.abook_blocked = 0 or abook.abook_flags is null) - AND item.item_wall = 1 AND item.item_thread_top AND item.mid = item.parent_mid + AND item.item_wall = 1 AND item.item_thread_top = 1 $sql_extra $sql_extra2 ORDER BY created DESC $pager_sql ", intval(\App::$profile['profile_uid']) -- cgit v1.2.3 From 5a9ea29614b8620c10d84f67a1a7c93fe537a037 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 9 Feb 2018 14:08:29 -0800 Subject: hubzilla issue #975 (searching for title as well as body could present a performance issue, so perhaps the tradeoffs should be debated) --- Zotlabs/Module/Search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 4d35b59f3..55e0e746f 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -90,7 +90,7 @@ class Search extends \Zotlabs\Web\Controller { } else { $regstr = db_getfunc('REGEXP'); - $sql_extra = sprintf(" AND item.body $regstr '%s' ", dbesc(protect_sprintf(preg_quote($search)))); + $sql_extra = sprintf(" AND (item.title $regstr '%s' OR item.body $regstr '%s') ", dbesc(protect_sprintf(preg_quote($search))), dbesc(protect_sprintf(preg_quote($search)))); } // Here is the way permissions work in the search module... -- cgit v1.2.3 From 07d33a11830e52499842b99ded964b0a934116d7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 11 Feb 2018 15:34:34 -0800 Subject: use new forum tag style in forum search postings --- Zotlabs/Module/Network.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 70e0048fb..6e961dc36 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -144,7 +144,7 @@ class Network extends \Zotlabs\Web\Controller { // NOTREACHED } if($_GET['pf'] === '1') - $deftag = '@' . t('forum') . '+' . intval($cid) . '+'; + $deftag = '!' . t('forum') . '+' . intval($cid); else $def_acl = [ 'allow_cid' => '<' . $r[0]['abook_xchan'] . '>', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; } -- cgit v1.2.3 From a31331bfd9500ad7dab117692b2c118d99c5c2f0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 11 Feb 2018 18:02:28 -0800 Subject: hubzilla issue #972 - provide system toggle to allow/disallow anonymous comments --- Zotlabs/Access/PermissionLimits.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Access/PermissionLimits.php b/Zotlabs/Access/PermissionLimits.php index 9ee0656b1..1d15098fc 100644 --- a/Zotlabs/Access/PermissionLimits.php +++ b/Zotlabs/Access/PermissionLimits.php @@ -41,8 +41,10 @@ class PermissionLimits { $limits = []; $perms = Permissions::Perms(); + $anon_comments = get_config('system','anonymous_comments',true); + foreach($perms as $k => $v) { - if(strstr($k, 'view') || $k === 'post_comments') + if(strstr($k, 'view') || ($k === 'post_comments' && $anon_comments)) $limits[$k] = PERMS_PUBLIC; else $limits[$k] = PERMS_SPECIFIC; -- cgit v1.2.3 From 63107f5b2f5031a7cc971063b9344592cc2257e3 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 11 Feb 2018 18:17:17 -0800 Subject: second part of hubzilla issue #972 --- Zotlabs/Module/Settings/Channel.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index 5e9e88a6d..fb8284d2e 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -331,22 +331,21 @@ class Channel { ); $limits = \Zotlabs\Access\PermissionLimits::Get(local_channel()); + $anon_comments = get_config('system','anonymous_comments',true); foreach($global_perms as $k => $perm) { $options = array(); + $can_be_public = ((strstr($k,'view') || ($k === 'post_comments' && $anon_comments)) ? true : false); foreach($perm_opts as $opt) { - if(((! strstr($k,'view')) && $k !== 'post_comments') && $opt[1] == PERMS_PUBLIC) + if($opt[1] == PERMS_PUBLIC && (! $can_be_public)) continue; $options[$opt[1]] = $opt[0]; } $permiss[] = array($k,$perm,$limits[$k],'',$options); } - - + // logger('permiss: ' . print_r($permiss,true)); - - $username = $channel['channel_name']; $nickname = $channel['channel_address']; $timezone = $channel['channel_timezone']; -- cgit v1.2.3 From b7fb78245aca724248cc721134a360276a9f6d9c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 12 Feb 2018 22:48:53 +0100 Subject: if always_show_in_notices is set to 1 also show likes and dislikes --- Zotlabs/Lib/Enotify.php | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 5cf4ec31d..5820c8b0c 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -112,6 +112,8 @@ class Enotify { } + $always_show_in_notices = get_pconfig($recip['channel_id'],'system','always_show_in_notices'); + // e.g. "your post", "David's photo", etc. $possess_desc = t('%s '); @@ -134,12 +136,22 @@ class Enotify { $itemlink = $params['link']; - // ignore like/unlike activity on posts - they probably require a separate notification preference + $action = 'commented on'; + + if(array_key_exists('item',$params) && (! visible_activity($params['item']))) { + + if(! $always_show_in_notices) { + logger('notification: not a visible activity. Ignoring.'); + pop_lang(); + return; + } + + if(activity_match($params['item']['verb'], ACTIVITY_LIKE)) + $action = 'liked'; + + if(activity_match($params['item']['verb'], ACTIVITY_DISLIKE)) + $action = 'disliked'; - if (array_key_exists('item',$params) && (! visible_activity($params['item']))) { - logger('notification: not a visible activity. Ignoring.'); - pop_lang(); - return; } $parent_mid = $params['parent_mid']; @@ -181,26 +193,29 @@ class Enotify { //$possess_desc = str_replace('',$possess_desc); // "a post" - $dest_str = sprintf(t('%1$s, %2$s commented on [zrl=%3$s]a %4$s[/zrl]'), + $dest_str = sprintf(t('%1$s, %2$s %3$s [zrl=%4$s]a %5$s[/zrl]'), $recip['channel_name'], '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', + $action, $itemlink, $item_post_type); // "George Bull's post" if($p) - $dest_str = sprintf(t('%1$s, %2$s commented on [zrl=%3$s]%4$s\'s %5$s[/zrl]'), + $dest_str = sprintf(t('%1$s, %2$s %3$s [zrl=%4$s]%5$s\'s %6$s[/zrl]'), $recip['channel_name'], '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', + $action, $itemlink, $p[0]['author']['xchan_name'], $item_post_type); // "your post" if($p[0]['owner']['xchan_name'] == $p[0]['author']['xchan_name'] && intval($p[0]['item_wall'])) - $dest_str = sprintf(t('%1$s, %2$s commented on [zrl=%3$s]your %4$s[/zrl]'), + $dest_str = sprintf(t('%1$s, %2$s %3$s [zrl=%3$s]your %5$s[/zrl]'), $recip['channel_name'], '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', + $action, $itemlink, $item_post_type); @@ -231,12 +246,12 @@ class Enotify { $itemlink = $params['link']; - // ignore like/unlike activity on posts - they probably require a separate notification preference - if (array_key_exists('item',$params) && (! activity_match($params['item']['verb'],ACTIVITY_LIKE))) { - logger('notification: not a like activity. Ignoring.'); - pop_lang(); - return; + if(! $always_show_in_notices) { + logger('notification: not a visible activity. Ignoring.'); + pop_lang(); + return; + } } $parent_mid = $params['parent_mid']; @@ -496,8 +511,6 @@ class Enotify { // Another option would be to not add them to the DB, and change how emails are handled // (probably would be better that way) - $always_show_in_notices = get_pconfig($recip['channel_id'],'system','always_show_in_notices'); - if (!$always_show_in_notices) { if (($params['type'] == NOTIFY_WALL) || ($params['type'] == NOTIFY_MAIL) || ($params['type'] == NOTIFY_INTRO)) { $seen = 1; -- cgit v1.2.3 From fd81a4bdc4f1c80d9dd73358452f50bc6422afef Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 12 Feb 2018 21:43:04 -0800 Subject: initial share refactor --- Zotlabs/Module/Item.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index db2d64d70..73730bc99 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -39,6 +39,7 @@ class Item extends \Zotlabs\Web\Controller { $uid = local_channel(); $channel = null; $observer = null; + $datarray = []; /** @@ -619,6 +620,21 @@ class Item extends \Zotlabs\Web\Controller { $i++; } } + + + if(preg_match_all('/(\[share=(.*?)\](.*?)\[\/share\])/',$body,$match)) { + // process share by id + + $verb = ACTIVITY_SHARE; + $i = 0; + foreach($match[2] as $mtch) { +// $obj = get_share_activity($mtch); + $datarray['obj'] = $obj['obj']; + $datarray['obj_type'] = $obj['obj']['type']; + $body = str_replace($match[1][$i],$obj['body'],$body); + $i++; + } + } } @@ -720,7 +736,6 @@ class Item extends \Zotlabs\Web\Controller { if(!$thr_parent) $thr_parent = $mid; - $datarray = array(); $item_thread_top = ((! $parent) ? 1 : 0); -- cgit v1.2.3 From d826515ba8d2d1d78abed6701df3c2c3550e87df Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 13 Feb 2018 11:01:58 +0100 Subject: since we only save the parent mid in notify we must look for thr_parent when dealing with likes --- Zotlabs/Module/Ping.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 96ade22c0..eab49d69e 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -268,7 +268,18 @@ class Ping extends \Zotlabs\Web\Controller { $mid = basename($tt['link']); - $b64mid = ((strpos($mid, 'b64.' === 0)) ? $mid : 'b64.' . base64url_encode($mid)); + if(in_array($tt['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) { + // we need the thread parent + $r = q("select thr_parent from item where mid = '%s' and uid = %d limit 1", + dbesc($mid), + intval(local_channel()) + ); + + $b64mid = ((strpos($r[0]['thr_parent'], 'b64.' === 0)) ? $r[0]['thr_parent'] : 'b64.' . base64url_encode($r[0]['thr_parent'])); + } + else { + $b64mid = ((strpos($mid, 'b64.' === 0)) ? $mid : 'b64.' . base64url_encode($mid)); + } $notifs[] = array( 'notify_link' => z_root() . '/notify/view/' . $tt['id'], -- cgit v1.2.3 From d2dcb93866ea659ac6fabc34b301656d8d5def8c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 13 Feb 2018 12:04:48 +0100 Subject: match against item verb --- Zotlabs/Lib/Enotify.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 5820c8b0c..f48b694fc 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -130,7 +130,7 @@ class Enotify { } if ($params['type'] == NOTIFY_COMMENT) { -// logger("notification: params = " . print_r($params, true), LOGGER_DEBUG); + //logger("notification: params = " . print_r($params, true), LOGGER_DEBUG); $moderated = (($params['item']['item_blocked'] == ITEM_MODERATED) ? true : false); @@ -138,7 +138,7 @@ class Enotify { $action = 'commented on'; - if(array_key_exists('item',$params) && (! visible_activity($params['item']))) { + if(array_key_exists('item',$params) && in_array($params['item']['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) { if(! $always_show_in_notices) { logger('notification: not a visible activity. Ignoring.'); @@ -146,10 +146,10 @@ class Enotify { return; } - if(activity_match($params['item']['verb'], ACTIVITY_LIKE)) + if(activity_match($params['verb'], ACTIVITY_LIKE)) $action = 'liked'; - if(activity_match($params['item']['verb'], ACTIVITY_DISLIKE)) + if(activity_match($params['verb'], ACTIVITY_DISLIKE)) $action = 'disliked'; } -- cgit v1.2.3 From 27baf46eb576002511f188268574aaff9ad16a6b Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 13 Feb 2018 12:33:49 +0100 Subject: fix item link in fsprint --- Zotlabs/Lib/Enotify.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index f48b694fc..c5bc706c2 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -212,7 +212,7 @@ class Enotify { // "your post" if($p[0]['owner']['xchan_name'] == $p[0]['author']['xchan_name'] && intval($p[0]['item_wall'])) - $dest_str = sprintf(t('%1$s, %2$s %3$s [zrl=%3$s]your %5$s[/zrl]'), + $dest_str = sprintf(t('%1$s, %2$s %3$s [zrl=%4$s]your %5$s[/zrl]'), $recip['channel_name'], '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', $action, -- cgit v1.2.3 From 6ca3442ba381a3c5b98cd04f4f9e87e48c55b072 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 13 Feb 2018 12:13:37 -0800 Subject: defperms: bad query --- Zotlabs/Module/Defperms.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Defperms.php b/Zotlabs/Module/Defperms.php index 422333a50..97d9cfd1d 100644 --- a/Zotlabs/Module/Defperms.php +++ b/Zotlabs/Module/Defperms.php @@ -22,7 +22,7 @@ class Defperms extends \Zotlabs\Web\Controller { $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash - WHERE abook_self = 1 and abook_id = %d LIMIT 1", + WHERE abook_self = 1 and abook_channel = %d LIMIT 1", intval(local_channel()) ); if($r) { -- cgit v1.2.3 From 64809dd2777ae0064addaff765450cf3f05c3bc4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 13 Feb 2018 20:07:57 -0800 Subject: turn shares into activities - make certain to pull addons or JSON-LD will chuck a wobbly --- Zotlabs/Lib/Share.php | 141 +++++++++++++++++++++++++++++++++++++++++++++++ Zotlabs/Module/Item.php | 8 +-- Zotlabs/Module/Share.php | 4 ++ 3 files changed, 149 insertions(+), 4 deletions(-) create mode 100644 Zotlabs/Lib/Share.php (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Share.php b/Zotlabs/Lib/Share.php new file mode 100644 index 000000000..b5341e662 --- /dev/null +++ b/Zotlabs/Lib/Share.php @@ -0,0 +1,141 @@ +item = $r[0]; + return; + } + + public function obj() { + $obj = []; + + if(! $this->item) + return $obj; + + $obj['type'] = $this->item['obj_type']; + $obj['id'] = $this->item['mid']; + $obj['content'] = $this->item['body']; + $obj['content_type'] = $this->item['mimetype']; + $obj['title'] = $this->item['title']; + $obj['created'] = $this->item['created']; + $obj['edited'] = $this->item['edited']; + $obj['author'] = [ + 'name' => $this->item['author']['xchan_name'], + 'address' => $this->item['author']['xchan_addr'], + 'network' => $this->item['author']['xchan_network'], + 'link' => [ + [ + 'rel' => 'alternate', + 'type' => 'text/html', + 'href' => $this->item['author']['xchan_url'] + ], + [ + 'rel' => 'photo', + 'type' => $this->item['author']['xchan_photo_mimetype'], + 'href' => $this->item['author']['xchan_photo_m'] + ] + ] + ]; + + $obj['owner'] = [ + 'name' => $this->item['owner']['xchan_name'], + 'address' => $this->item['owner']['xchan_addr'], + 'network' => $this->item['owner']['xchan_network'], + 'link' => [ + [ + 'rel' => 'alternate', + 'type' => 'text/html', + 'href' => $this->item['owner']['xchan_url'] + ], + [ + 'rel' => 'photo', + 'type' => $this->item['owner']['xchan_photo_mimetype'], + 'href' => $this->item['owner']['xchan_photo_m'] + ] + ] + ]; + + $obj['link'] = [ + 'rel' => 'alternate', + 'type' => 'text/html', + 'href' => $this->item['plink'] + ]; + + return $obj; + } + + public function bbcode() { + $bb = NULL_STR; + + if(! $this->item) + return $bb; + + $is_photo = (($this->item['obj_type'] === ACTIVITY_OBJ_PHOTO) ? true : false); + if($is_photo) { + $object = json_decode($this->item['obj'],true); + $photo_bb = $object['body']; + } + + if (strpos($this->item['body'], "[/share]") !== false) { + $pos = strpos($this->item['body'], "[share"); + $bb = substr($this->item['body'], $pos); + } else { + $bb = "[share author='".urlencode($this->item['author']['xchan_name']). + "' profile='".$this->item['author']['xchan_url'] . + "' avatar='".$this->item['author']['xchan_photo_s']. + "' link='".$this->item['plink']. + "' posted='".$this->item['created']. + "' message_id='".$this->item['mid']."']"; + if($this->item['title']) + $bb .= '[b]'.$this->item['title'].'[/b]'."\r\n"; + $bb .= (($is_photo) ? $photo_bb . "\r\n" . $this->item['body'] : $this->item['body']); + $bb .= "[/share]"; + } + + return $bb; + + } + +} \ No newline at end of file diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 73730bc99..3f857030b 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -628,10 +628,10 @@ class Item extends \Zotlabs\Web\Controller { $verb = ACTIVITY_SHARE; $i = 0; foreach($match[2] as $mtch) { -// $obj = get_share_activity($mtch); - $datarray['obj'] = $obj['obj']; - $datarray['obj_type'] = $obj['obj']['type']; - $body = str_replace($match[1][$i],$obj['body'],$body); + $reshare = new \Zotlabs\Lib\Share($mtch); + $datarray['obj'] = $reshare->obj(); + $datarray['obj_type'] = $datarray['obj']['type']; + $body = str_replace($match[1][$i],$reshare->bbcode(),$body); $i++; } } diff --git a/Zotlabs/Module/Share.php b/Zotlabs/Module/Share.php index 5c4811c59..7f4d8b1eb 100644 --- a/Zotlabs/Module/Share.php +++ b/Zotlabs/Module/Share.php @@ -14,6 +14,10 @@ class Share extends \Zotlabs\Web\Controller { if(! $post_id) killme(); + + echo '[share=' . $post_id . '][/share]'; + killme(); + if(! (local_channel() || remote_channel())) killme(); -- cgit v1.2.3 From 465d89129caaaa0240229f8d6f81d68f26eb60b0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 14 Feb 2018 15:32:33 -0800 Subject: provide option to block the public stream unless authenticated, since there could be legal issues with unmoderated content --- Zotlabs/Lib/Apps.php | 9 +++++++++ Zotlabs/Module/Admin/Site.php | 4 +++- Zotlabs/Module/Pubstream.php | 7 +++---- 3 files changed, 15 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index d2a307fd5..f91dc8e49 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -119,6 +119,7 @@ class Apps { static public function parse_app_description($f,$translate = true) { + $ret = array(); $baseurl = z_root(); @@ -194,6 +195,10 @@ class Apps { if(! is_public_profile()) unset($ret); break; + case 'public_stream': + if(! can_view_public_stream()) + unset($ret); + break; case 'observer': if(! $observer) unset($ret); @@ -346,6 +351,10 @@ class Apps { if(! is_public_profile()) return ''; break; + case 'public_stream': + if(! can_view_public_stream()) + return ''; + break; case 'observer': $observer = \App::get_observer(); if(! $observer) diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php index 52b36e03e..ca181d5f8 100644 --- a/Zotlabs/Module/Admin/Site.php +++ b/Zotlabs/Module/Admin/Site.php @@ -45,6 +45,7 @@ class Site { $force_publish = ((x($_POST,'publish_all')) ? True : False); $disable_discover_tab = ((x($_POST,'disable_discover_tab')) ? False : True); $site_firehose = ((x($_POST,'site_firehose')) ? True : False); + $open_pubstream = ((x($_POST,'open_pubstream')) ? True : False); $login_on_homepage = ((x($_POST,'login_on_homepage')) ? True : False); $enable_context_help = ((x($_POST,'enable_context_help')) ? True : False); $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : ''); @@ -139,6 +140,7 @@ class Site { set_config('system','publish_all', $force_publish); set_config('system','disable_discover_tab', $disable_discover_tab); set_config('system','site_firehose', $site_firehose); + set_config('system','open_pubstream', $open_pubstream); set_config('system','force_queue_threshold', $force_queue); if ($global_directory == '') { del_config('system', 'directory_submit_url'); @@ -319,7 +321,7 @@ class Site { '$force_publish' => array('publish_all', t("Force publish"), get_config('system','publish_all'), t("Check to force all profiles on this site to be listed in the site directory.")), '$disable_discover_tab' => array('disable_discover_tab', t('Import Public Streams'), $discover_tab, t('Import and allow access to public content pulled from other sites. Warning: this content is unmoderated.')), '$site_firehose' => array('site_firehose', t('Site only Public Streams'), get_config('system','site_firehose'), t('Allow access to public content originating only from this site if Imported Public Streams are disabled.')), - + '$open_pubstream' => array('open_pubstream', t('Allow anybody on the internet to access the Public streams'), get_config('system','open_pubstream',1), t('Disable to require authentication before viewing. Warning: this content is unmoderated.')), '$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.")), diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 16a5fdbba..afe53eca7 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -12,11 +12,10 @@ class Pubstream extends \Zotlabs\Web\Controller { if($load) $_SESSION['loadtime'] = datetime_convert(); - - if(observer_prohibited(true)) { - return login(); + if((observer_prohibited(true)) || (! (intval(get_config('system','open_pubstream',1))) && get_observer_hash())) { + return login(); } - + $site_firehose = ((intval(get_config('system','site_firehose',0))) ? true : false); $net_firehose = ((get_config('system','disable_discover_tab',1)) ? false : true); -- cgit v1.2.3 From 9e251a1abcc50af0f678a17d3a688f4ba9e4a4fc Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 15 Feb 2018 19:24:15 +0100 Subject: some more DB tuning. --- Zotlabs/Module/Channel.php | 4 ++-- Zotlabs/Module/Pubstream.php | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 3dab85410..231146999 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -251,9 +251,9 @@ class Channel extends \Zotlabs\Web\Controller { else { $r = q("SELECT item.parent AS item_id FROM item left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) - WHERE true and uid = %d $item_normal + WHERE true and item.uid = %d AND item.item_thread_top = 1 $item_normal AND (abook.abook_blocked = 0 or abook.abook_flags is null) - AND item.item_wall = 1 AND item.item_thread_top = 1 + AND item.item_wall = 1 $sql_extra $sql_extra2 ORDER BY created DESC $pager_sql ", intval(\App::$profile['profile_uid']) diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index afe53eca7..af7bc7658 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -166,7 +166,8 @@ class Pubstream extends \Zotlabs\Web\Controller { $net_query = (($net) ? " left join xchan on xchan_hash = author_xchan " : ''); $net_query2 = (($net) ? " and xchan_network = '" . protect_sprintf(dbesc($net)) . "' " : ''); - + + $abook_uids = " and abook.abook_channel = " . intval(\App::$profile['profile_uid']) . " "; $simple_update = (($_SESSION['loadtime']) ? " AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' " : ''); @@ -185,7 +186,7 @@ class Pubstream extends \Zotlabs\Web\Controller { if($load) { if($mid) { $r = q("SELECT parent AS item_id FROM item - left join abook on item.author_xchan = abook.abook_xchan + left join abook on item.author_xchan = abook.abook_xchan $net_query WHERE mid like '%s' $uids $item_normal and (abook.abook_blocked = 0 or abook.abook_flags is null) @@ -196,10 +197,9 @@ class Pubstream extends \Zotlabs\Web\Controller { else { // Fetch a page full of parent items for this page $r = q("SELECT item.id AS item_id FROM item - left join abook on item.author_xchan = abook.abook_xchan + left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) $net_query - WHERE item_thread_top = 1 $uids $item_normal - AND item.parent = item.id + WHERE true $uids and item.item_thread_top = 1 $item_normal and (abook.abook_blocked = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets $net_query2 ORDER BY $ordering DESC $pager_sql " -- cgit v1.2.3 From 27cd26ec1e26b6c389a623395687af5052f0b5a1 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 15 Feb 2018 18:47:56 -0800 Subject: extend the oauth2 storage driver so that we can use our own channel table --- Zotlabs/Identity/OAuth2Server.php | 43 ++++++++++++++++++++ Zotlabs/Identity/OAuth2Storage.php | 81 ++++++++++++++++++++++++++++++++++++++ Zotlabs/Module/Authorize.php | 55 ++++++++++++-------------- Zotlabs/Module/Token.php | 46 ++++++++++------------ 4 files changed, 171 insertions(+), 54 deletions(-) create mode 100644 Zotlabs/Identity/OAuth2Server.php create mode 100644 Zotlabs/Identity/OAuth2Storage.php (limited to 'Zotlabs') diff --git a/Zotlabs/Identity/OAuth2Server.php b/Zotlabs/Identity/OAuth2Server.php new file mode 100644 index 000000000..3d7d5efb2 --- /dev/null +++ b/Zotlabs/Identity/OAuth2Server.php @@ -0,0 +1,43 @@ +db); + + $config = [ + 'use_openid_connect' => true, + 'issuer' => \Zotlabs\Lib\System::get_site_name() + ]; + + // Pass a storage object or array of storage objects to the OAuth2 server class + $this->server = new \OAuth2\Server($storage,$config); + + // Add the "Client Credentials" grant type (it is the simplest of the grant types) + $this->server->addGrantType(new \OAuth2\GrantType\ClientCredentials($storage)); + + // Add the "Authorization Code" grant type (this is where the oauth magic happens) + $this->server->addGrantType(new \OAuth2\GrantType\AuthorizationCode($storage)); + + $keyStorage = new \OAuth2\Storage\Memory( [ + 'keys' => [ + 'public_key' => get_config('system','pubkey'), + 'private_key' => get_config('system','prvkey') + ] + ]); + + $this->server->addStorage($keyStorage,'public_key'); + + } + + public function get_server() { + return $this->server; + } + + +} \ No newline at end of file diff --git a/Zotlabs/Identity/OAuth2Storage.php b/Zotlabs/Identity/OAuth2Storage.php new file mode 100644 index 000000000..bc6db565c --- /dev/null +++ b/Zotlabs/Identity/OAuth2Storage.php @@ -0,0 +1,81 @@ +getUser($username)) { + return $this->checkPassword($user, $password); + } + + return false; + } + + /** + * @param string $username + * @return array|bool + */ + public function getUserDetails($username) + { + return $this->getUser($username); + } + + + /** + * + * @param array $user + * @param string $password + * @return bool + */ + protected function checkPassword($user, $password) + { + + $x = account_verify_password($user,$password); + return((array_key_exists('channel',$x) && ! empty($x['channel'])) ? true : false); + + } + + /** + * @param string $username + * @return array|bool + */ + public function getUser($username) + { + + $x = channelx_by_nick($username); + if(! $x) { + return false; + } + + return( [ + 'username' => $x['channel_address'], + 'user_id' => $x['channel_id'], + 'firstName' => $x['channel_name'], + 'lastName' => '', + 'password' => 'NotARealPassword' + ] ); + } + + /** + * plaintext passwords are bad! Override this for your application + * + * @param string $username + * @param string $password + * @param string $firstName + * @param string $lastName + * @return bool + */ + public function setUser($username, $password, $firstName = null, $lastName = null) + { + return true; + } + +} \ No newline at end of file diff --git a/Zotlabs/Module/Authorize.php b/Zotlabs/Module/Authorize.php index 06f66c456..7676b0855 100644 --- a/Zotlabs/Module/Authorize.php +++ b/Zotlabs/Module/Authorize.php @@ -6,41 +6,38 @@ namespace Zotlabs\Module; class Authorize extends \Zotlabs\Web\Controller { - function get() { + function init() { - // workaround for HTTP-auth in CGI mode - if (x($_SERVER, 'REDIRECT_REMOTE_USER')) { - $userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"], 6)) ; - if(strlen($userpass)) { - list($name, $password) = explode(':', $userpass); - $_SERVER['PHP_AUTH_USER'] = $name; - $_SERVER['PHP_AUTH_PW'] = $password; - } + // workaround for HTTP-auth in CGI mode + if (x($_SERVER, 'REDIRECT_REMOTE_USER')) { + $userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"], 6)) ; + if(strlen($userpass)) { + list($name, $password) = explode(':', $userpass); + $_SERVER['PHP_AUTH_USER'] = $name; + $_SERVER['PHP_AUTH_PW'] = $password; } - - if (x($_SERVER, 'HTTP_AUTHORIZATION')) { - $userpass = base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)) ; - if(strlen($userpass)) { - list($name, $password) = explode(':', $userpass); - $_SERVER['PHP_AUTH_USER'] = $name; - $_SERVER['PHP_AUTH_PW'] = $password; - } + } + + if (x($_SERVER, 'HTTP_AUTHORIZATION')) { + $userpass = base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)) ; + if(strlen($userpass)) { + list($name, $password) = explode(':', $userpass); + $_SERVER['PHP_AUTH_USER'] = $name; + $_SERVER['PHP_AUTH_PW'] = $password; } + } + $s = new \Zotlabs\Identity\OAuth2Server(); + $request = \OAuth2\Request::createFromGlobals(); + $response = new \OAuth2\Response(); - - require_once('include/oauth2.php'); - - $request = \OAuth2\Request::createFromGlobals(); - $response = new \OAuth2\Response(); - - // validate the authorize request - if (! $oauth2_server->validateAuthorizeRequest($request, $response)) { - $response->send(); - killme(); - } + // validate the authorize request + if (! $s->server->validateAuthorizeRequest($request, $response)) { + $response->send(); + killme(); + } // display an authorization form if (empty($_POST)) { @@ -55,7 +52,7 @@ class Authorize extends \Zotlabs\Web\Controller { // print the authorization code if the user has authorized your client $is_authorized = ($_POST['authorized'] === 'yes'); - $oauth2_server->handleAuthorizeRequest($request, $response, $is_authorized); + $s->server->handleAuthorizeRequest($request, $response, $is_authorized, local_channel()); 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 diff --git a/Zotlabs/Module/Token.php b/Zotlabs/Module/Token.php index e0d9d74d7..5cde58895 100644 --- a/Zotlabs/Module/Token.php +++ b/Zotlabs/Module/Token.php @@ -5,36 +5,32 @@ namespace Zotlabs\Module; class Token extends \Zotlabs\Web\Controller { - - function get() { - - - // workaround for HTTP-auth in CGI mode - if (x($_SERVER, 'REDIRECT_REMOTE_USER')) { - $userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"], 6)) ; - if(strlen($userpass)) { - list($name, $password) = explode(':', $userpass); - $_SERVER['PHP_AUTH_USER'] = $name; - $_SERVER['PHP_AUTH_PW'] = $password; - } + function init() { + + // workaround for HTTP-auth in CGI mode + if (x($_SERVER, 'REDIRECT_REMOTE_USER')) { + $userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"], 6)) ; + if(strlen($userpass)) { + list($name, $password) = explode(':', $userpass); + $_SERVER['PHP_AUTH_USER'] = $name; + $_SERVER['PHP_AUTH_PW'] = $password; } - - if (x($_SERVER, 'HTTP_AUTHORIZATION')) { - $userpass = base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)) ; - if(strlen($userpass)) { - list($name, $password) = explode(':', $userpass); - $_SERVER['PHP_AUTH_USER'] = $name; - $_SERVER['PHP_AUTH_PW'] = $password; - } + } + + if (x($_SERVER, 'HTTP_AUTHORIZATION')) { + $userpass = base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)) ; + if(strlen($userpass)) { + list($name, $password) = explode(':', $userpass); + $_SERVER['PHP_AUTH_USER'] = $name; + $_SERVER['PHP_AUTH_PW'] = $password; } + } + $s = new \Zotlabs\Identity\OAuth2Server(); + $s->server->handleTokenRequest(\OAuth2\Request::createFromGlobals())->send(); - - require_once('include/oauth2.php'); - $oauth2_server->handleTokenRequest(\OAuth2\Request::createFromGlobals())->send(); - - killme(); + killme(); } } \ No newline at end of file -- cgit v1.2.3 From f492f808f4861ae9937dcaf3bf8476513ae1c091 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 16 Feb 2018 12:42:02 -0800 Subject: refactor of the DB update system. Updates are now stored individually in Zotlabs/Update/_nnnn.php and are objects; so only the pending updates need to be loaded and executed rather than all historical updates. There is one single number (DB_UPDATE_VERSION) representing the current version and it is EQUAL TO the last known update. A dummy update _1201 was created to address the difference in counting behaviour; it will be executed on the next change of DB_UPDATE_VERSION as well as the next update. The database config values are also loaded from disk on every update immediately before setting the update lock in order to reduce timing conflicts and race conditions. --- Zotlabs/Lib/DB_Upgrade.php | 134 ++++++------- Zotlabs/Module/Admin/Dbsync.php | 54 ++--- Zotlabs/Update/_1000.php | 15 ++ Zotlabs/Update/_1001.php | 27 +++ Zotlabs/Update/_1002.php | 20 ++ Zotlabs/Update/_1003.php | 15 ++ Zotlabs/Update/_1004.php | 24 +++ Zotlabs/Update/_1005.php | 13 ++ Zotlabs/Update/_1006.php | 45 +++++ Zotlabs/Update/_1007.php | 15 ++ Zotlabs/Update/_1008.php | 15 ++ Zotlabs/Update/_1009.php | 15 ++ Zotlabs/Update/_1010.php | 18 ++ Zotlabs/Update/_1011.php | 16 ++ Zotlabs/Update/_1012.php | 16 ++ Zotlabs/Update/_1013.php | 21 ++ Zotlabs/Update/_1014.php | 14 ++ Zotlabs/Update/_1015.php | 19 ++ Zotlabs/Update/_1016.php | 39 ++++ Zotlabs/Update/_1017.php | 14 ++ Zotlabs/Update/_1018.php | 16 ++ Zotlabs/Update/_1019.php | 14 ++ Zotlabs/Update/_1020.php | 14 ++ Zotlabs/Update/_1021.php | 17 ++ Zotlabs/Update/_1022.php | 14 ++ Zotlabs/Update/_1023.php | 14 ++ Zotlabs/Update/_1024.php | 15 ++ Zotlabs/Update/_1025.php | 15 ++ Zotlabs/Update/_1026.php | 16 ++ Zotlabs/Update/_1027.php | 15 ++ Zotlabs/Update/_1028.php | 15 ++ Zotlabs/Update/_1029.php | 15 ++ Zotlabs/Update/_1030.php | 29 +++ Zotlabs/Update/_1031.php | 16 ++ Zotlabs/Update/_1032.php | 21 ++ Zotlabs/Update/_1033.php | 29 +++ Zotlabs/Update/_1034.php | 20 ++ Zotlabs/Update/_1035.php | 24 +++ Zotlabs/Update/_1036.php | 16 ++ Zotlabs/Update/_1037.php | 30 +++ Zotlabs/Update/_1038.php | 17 ++ Zotlabs/Update/_1039.php | 16 ++ Zotlabs/Update/_1040.php | 16 ++ Zotlabs/Update/_1041.php | 16 ++ Zotlabs/Update/_1042.php | 16 ++ Zotlabs/Update/_1043.php | 15 ++ Zotlabs/Update/_1044.php | 15 ++ Zotlabs/Update/_1045.php | 15 ++ Zotlabs/Update/_1046.php | 15 ++ Zotlabs/Update/_1047.php | 15 ++ Zotlabs/Update/_1048.php | 29 +++ Zotlabs/Update/_1049.php | 15 ++ Zotlabs/Update/_1050.php | 15 ++ Zotlabs/Update/_1051.php | 16 ++ Zotlabs/Update/_1052.php | 14 ++ Zotlabs/Update/_1053.php | 14 ++ Zotlabs/Update/_1054.php | 14 ++ Zotlabs/Update/_1055.php | 14 ++ Zotlabs/Update/_1056.php | 15 ++ Zotlabs/Update/_1057.php | 14 ++ Zotlabs/Update/_1058.php | 19 ++ Zotlabs/Update/_1059.php | 14 ++ Zotlabs/Update/_1060.php | 24 +++ Zotlabs/Update/_1061.php | 15 ++ Zotlabs/Update/_1062.php | 34 ++++ Zotlabs/Update/_1063.php | 16 ++ Zotlabs/Update/_1064.php | 15 ++ Zotlabs/Update/_1065.php | 15 ++ Zotlabs/Update/_1066.php | 15 ++ Zotlabs/Update/_1067.php | 14 ++ Zotlabs/Update/_1068.php | 14 ++ Zotlabs/Update/_1069.php | 15 ++ Zotlabs/Update/_1070.php | 15 ++ Zotlabs/Update/_1071.php | 15 ++ Zotlabs/Update/_1072.php | 17 ++ Zotlabs/Update/_1073.php | 23 +++ Zotlabs/Update/_1074.php | 19 ++ Zotlabs/Update/_1075.php | 16 ++ Zotlabs/Update/_1076.php | 14 ++ Zotlabs/Update/_1077.php | 14 ++ Zotlabs/Update/_1078.php | 15 ++ Zotlabs/Update/_1079.php | 14 ++ Zotlabs/Update/_1080.php | 15 ++ Zotlabs/Update/_1081.php | 14 ++ Zotlabs/Update/_1082.php | 14 ++ Zotlabs/Update/_1083.php | 15 ++ Zotlabs/Update/_1084.php | 24 +++ Zotlabs/Update/_1085.php | 20 ++ Zotlabs/Update/_1086.php | 15 ++ Zotlabs/Update/_1087.php | 17 ++ Zotlabs/Update/_1088.php | 17 ++ Zotlabs/Update/_1089.php | 16 ++ Zotlabs/Update/_1090.php | 15 ++ Zotlabs/Update/_1091.php | 13 ++ Zotlabs/Update/_1092.php | 61 ++++++ Zotlabs/Update/_1093.php | 14 ++ Zotlabs/Update/_1094.php | 15 ++ Zotlabs/Update/_1095.php | 15 ++ Zotlabs/Update/_1096.php | 14 ++ Zotlabs/Update/_1097.php | 24 +++ Zotlabs/Update/_1098.php | 25 +++ Zotlabs/Update/_1099.php | 24 +++ Zotlabs/Update/_1100.php | 16 ++ Zotlabs/Update/_1101.php | 13 ++ Zotlabs/Update/_1102.php | 16 ++ Zotlabs/Update/_1103.php | 14 ++ Zotlabs/Update/_1104.php | 14 ++ Zotlabs/Update/_1105.php | 15 ++ Zotlabs/Update/_1106.php | 14 ++ Zotlabs/Update/_1107.php | 34 ++++ Zotlabs/Update/_1108.php | 17 ++ Zotlabs/Update/_1109.php | 16 ++ Zotlabs/Update/_1110.php | 17 ++ Zotlabs/Update/_1111.php | 14 ++ Zotlabs/Update/_1112.php | 29 +++ Zotlabs/Update/_1113.php | 16 ++ Zotlabs/Update/_1114.php | 15 ++ Zotlabs/Update/_1115.php | 16 ++ Zotlabs/Update/_1116.php | 12 ++ Zotlabs/Update/_1117.php | 16 ++ Zotlabs/Update/_1118.php | 16 ++ Zotlabs/Update/_1119.php | 35 ++++ Zotlabs/Update/_1120.php | 16 ++ Zotlabs/Update/_1121.php | 16 ++ Zotlabs/Update/_1122.php | 16 ++ Zotlabs/Update/_1123.php | 17 ++ Zotlabs/Update/_1124.php | 41 ++++ Zotlabs/Update/_1125.php | 16 ++ Zotlabs/Update/_1126.php | 16 ++ Zotlabs/Update/_1127.php | 16 ++ Zotlabs/Update/_1128.php | 15 ++ Zotlabs/Update/_1129.php | 14 ++ Zotlabs/Update/_1130.php | 28 +++ Zotlabs/Update/_1131.php | 20 ++ Zotlabs/Update/_1132.php | 17 ++ Zotlabs/Update/_1133.php | 38 ++++ Zotlabs/Update/_1134.php | 20 ++ Zotlabs/Update/_1135.php | 14 ++ Zotlabs/Update/_1136.php | 17 ++ Zotlabs/Update/_1137.php | 16 ++ Zotlabs/Update/_1138.php | 15 ++ Zotlabs/Update/_1139.php | 21 ++ Zotlabs/Update/_1140.php | 27 +++ Zotlabs/Update/_1141.php | 30 +++ Zotlabs/Update/_1142.php | 18 ++ Zotlabs/Update/_1143.php | 17 ++ Zotlabs/Update/_1144.php | 27 +++ Zotlabs/Update/_1145.php | 30 +++ Zotlabs/Update/_1146.php | 16 ++ Zotlabs/Update/_1147.php | 16 ++ Zotlabs/Update/_1148.php | 17 ++ Zotlabs/Update/_1149.php | 35 ++++ Zotlabs/Update/_1150.php | 28 +++ Zotlabs/Update/_1151.php | 24 +++ Zotlabs/Update/_1152.php | 57 ++++++ Zotlabs/Update/_1153.php | 18 ++ Zotlabs/Update/_1154.php | 17 ++ Zotlabs/Update/_1155.php | 17 ++ Zotlabs/Update/_1156.php | 28 +++ Zotlabs/Update/_1157.php | 17 ++ Zotlabs/Update/_1158.php | 22 +++ Zotlabs/Update/_1159.php | 25 +++ Zotlabs/Update/_1160.php | 14 ++ Zotlabs/Update/_1161.php | 43 ++++ Zotlabs/Update/_1162.php | 19 ++ Zotlabs/Update/_1163.php | 22 +++ Zotlabs/Update/_1164.php | 45 +++++ Zotlabs/Update/_1165.php | 20 ++ Zotlabs/Update/_1166.php | 15 ++ Zotlabs/Update/_1167.php | 26 +++ Zotlabs/Update/_1168.php | 23 +++ Zotlabs/Update/_1169.php | 27 +++ Zotlabs/Update/_1170.php | 21 ++ Zotlabs/Update/_1171.php | 24 +++ Zotlabs/Update/_1172.php | 29 +++ Zotlabs/Update/_1173.php | 27 +++ Zotlabs/Update/_1174.php | 32 +++ Zotlabs/Update/_1175.php | 31 +++ Zotlabs/Update/_1176.php | 19 ++ Zotlabs/Update/_1177.php | 66 +++++++ Zotlabs/Update/_1178.php | 42 ++++ Zotlabs/Update/_1179.php | 49 +++++ Zotlabs/Update/_1180.php | 32 +++ Zotlabs/Update/_1181.php | 14 ++ Zotlabs/Update/_1182.php | 17 ++ Zotlabs/Update/_1183.php | 25 +++ Zotlabs/Update/_1184.php | 16 ++ Zotlabs/Update/_1185.php | 16 ++ Zotlabs/Update/_1186.php | 18 ++ Zotlabs/Update/_1187.php | 24 +++ Zotlabs/Update/_1188.php | 18 ++ Zotlabs/Update/_1189.php | 23 +++ Zotlabs/Update/_1190.php | 17 ++ Zotlabs/Update/_1191.php | 425 ++++++++++++++++++++++++++++++++++++++++ Zotlabs/Update/_1192.php | 21 ++ Zotlabs/Update/_1193.php | 22 +++ Zotlabs/Update/_1194.php | 22 +++ Zotlabs/Update/_1195.php | 21 ++ Zotlabs/Update/_1196.php | 45 +++++ Zotlabs/Update/_1197.php | 17 ++ Zotlabs/Update/_1198.php | 24 +++ Zotlabs/Update/_1199.php | 19 ++ Zotlabs/Update/_1200.php | 20 ++ Zotlabs/Update/_1201.php | 15 ++ 204 files changed, 4585 insertions(+), 99 deletions(-) create mode 100644 Zotlabs/Update/_1000.php create mode 100644 Zotlabs/Update/_1001.php create mode 100644 Zotlabs/Update/_1002.php create mode 100644 Zotlabs/Update/_1003.php create mode 100644 Zotlabs/Update/_1004.php create mode 100644 Zotlabs/Update/_1005.php create mode 100644 Zotlabs/Update/_1006.php create mode 100644 Zotlabs/Update/_1007.php create mode 100644 Zotlabs/Update/_1008.php create mode 100644 Zotlabs/Update/_1009.php create mode 100644 Zotlabs/Update/_1010.php create mode 100644 Zotlabs/Update/_1011.php create mode 100644 Zotlabs/Update/_1012.php create mode 100644 Zotlabs/Update/_1013.php create mode 100644 Zotlabs/Update/_1014.php create mode 100644 Zotlabs/Update/_1015.php create mode 100644 Zotlabs/Update/_1016.php create mode 100644 Zotlabs/Update/_1017.php create mode 100644 Zotlabs/Update/_1018.php create mode 100644 Zotlabs/Update/_1019.php create mode 100644 Zotlabs/Update/_1020.php create mode 100644 Zotlabs/Update/_1021.php create mode 100644 Zotlabs/Update/_1022.php create mode 100644 Zotlabs/Update/_1023.php create mode 100644 Zotlabs/Update/_1024.php create mode 100644 Zotlabs/Update/_1025.php create mode 100644 Zotlabs/Update/_1026.php create mode 100644 Zotlabs/Update/_1027.php create mode 100644 Zotlabs/Update/_1028.php create mode 100644 Zotlabs/Update/_1029.php create mode 100644 Zotlabs/Update/_1030.php create mode 100644 Zotlabs/Update/_1031.php create mode 100644 Zotlabs/Update/_1032.php create mode 100644 Zotlabs/Update/_1033.php create mode 100644 Zotlabs/Update/_1034.php create mode 100644 Zotlabs/Update/_1035.php create mode 100644 Zotlabs/Update/_1036.php create mode 100644 Zotlabs/Update/_1037.php create mode 100644 Zotlabs/Update/_1038.php create mode 100644 Zotlabs/Update/_1039.php create mode 100644 Zotlabs/Update/_1040.php create mode 100644 Zotlabs/Update/_1041.php create mode 100644 Zotlabs/Update/_1042.php create mode 100644 Zotlabs/Update/_1043.php create mode 100644 Zotlabs/Update/_1044.php create mode 100644 Zotlabs/Update/_1045.php create mode 100644 Zotlabs/Update/_1046.php create mode 100644 Zotlabs/Update/_1047.php create mode 100644 Zotlabs/Update/_1048.php create mode 100644 Zotlabs/Update/_1049.php create mode 100644 Zotlabs/Update/_1050.php create mode 100644 Zotlabs/Update/_1051.php create mode 100644 Zotlabs/Update/_1052.php create mode 100644 Zotlabs/Update/_1053.php create mode 100644 Zotlabs/Update/_1054.php create mode 100644 Zotlabs/Update/_1055.php create mode 100644 Zotlabs/Update/_1056.php create mode 100644 Zotlabs/Update/_1057.php create mode 100644 Zotlabs/Update/_1058.php create mode 100644 Zotlabs/Update/_1059.php create mode 100644 Zotlabs/Update/_1060.php create mode 100644 Zotlabs/Update/_1061.php create mode 100644 Zotlabs/Update/_1062.php create mode 100644 Zotlabs/Update/_1063.php create mode 100644 Zotlabs/Update/_1064.php create mode 100644 Zotlabs/Update/_1065.php create mode 100644 Zotlabs/Update/_1066.php create mode 100644 Zotlabs/Update/_1067.php create mode 100644 Zotlabs/Update/_1068.php create mode 100644 Zotlabs/Update/_1069.php create mode 100644 Zotlabs/Update/_1070.php create mode 100644 Zotlabs/Update/_1071.php create mode 100644 Zotlabs/Update/_1072.php create mode 100644 Zotlabs/Update/_1073.php create mode 100644 Zotlabs/Update/_1074.php create mode 100644 Zotlabs/Update/_1075.php create mode 100644 Zotlabs/Update/_1076.php create mode 100644 Zotlabs/Update/_1077.php create mode 100644 Zotlabs/Update/_1078.php create mode 100644 Zotlabs/Update/_1079.php create mode 100644 Zotlabs/Update/_1080.php create mode 100644 Zotlabs/Update/_1081.php create mode 100644 Zotlabs/Update/_1082.php create mode 100644 Zotlabs/Update/_1083.php create mode 100644 Zotlabs/Update/_1084.php create mode 100644 Zotlabs/Update/_1085.php create mode 100644 Zotlabs/Update/_1086.php create mode 100644 Zotlabs/Update/_1087.php create mode 100644 Zotlabs/Update/_1088.php create mode 100644 Zotlabs/Update/_1089.php create mode 100644 Zotlabs/Update/_1090.php create mode 100644 Zotlabs/Update/_1091.php create mode 100644 Zotlabs/Update/_1092.php create mode 100644 Zotlabs/Update/_1093.php create mode 100644 Zotlabs/Update/_1094.php create mode 100644 Zotlabs/Update/_1095.php create mode 100644 Zotlabs/Update/_1096.php create mode 100644 Zotlabs/Update/_1097.php create mode 100644 Zotlabs/Update/_1098.php create mode 100644 Zotlabs/Update/_1099.php create mode 100644 Zotlabs/Update/_1100.php create mode 100644 Zotlabs/Update/_1101.php create mode 100644 Zotlabs/Update/_1102.php create mode 100644 Zotlabs/Update/_1103.php create mode 100644 Zotlabs/Update/_1104.php create mode 100644 Zotlabs/Update/_1105.php create mode 100644 Zotlabs/Update/_1106.php create mode 100644 Zotlabs/Update/_1107.php create mode 100644 Zotlabs/Update/_1108.php create mode 100644 Zotlabs/Update/_1109.php create mode 100644 Zotlabs/Update/_1110.php create mode 100644 Zotlabs/Update/_1111.php create mode 100644 Zotlabs/Update/_1112.php create mode 100644 Zotlabs/Update/_1113.php create mode 100644 Zotlabs/Update/_1114.php create mode 100644 Zotlabs/Update/_1115.php create mode 100644 Zotlabs/Update/_1116.php create mode 100644 Zotlabs/Update/_1117.php create mode 100644 Zotlabs/Update/_1118.php create mode 100644 Zotlabs/Update/_1119.php create mode 100644 Zotlabs/Update/_1120.php create mode 100644 Zotlabs/Update/_1121.php create mode 100644 Zotlabs/Update/_1122.php create mode 100644 Zotlabs/Update/_1123.php create mode 100644 Zotlabs/Update/_1124.php create mode 100644 Zotlabs/Update/_1125.php create mode 100644 Zotlabs/Update/_1126.php create mode 100644 Zotlabs/Update/_1127.php create mode 100644 Zotlabs/Update/_1128.php create mode 100644 Zotlabs/Update/_1129.php create mode 100644 Zotlabs/Update/_1130.php create mode 100644 Zotlabs/Update/_1131.php create mode 100644 Zotlabs/Update/_1132.php create mode 100644 Zotlabs/Update/_1133.php create mode 100644 Zotlabs/Update/_1134.php create mode 100644 Zotlabs/Update/_1135.php create mode 100644 Zotlabs/Update/_1136.php create mode 100644 Zotlabs/Update/_1137.php create mode 100644 Zotlabs/Update/_1138.php create mode 100644 Zotlabs/Update/_1139.php create mode 100644 Zotlabs/Update/_1140.php create mode 100644 Zotlabs/Update/_1141.php create mode 100644 Zotlabs/Update/_1142.php create mode 100644 Zotlabs/Update/_1143.php create mode 100644 Zotlabs/Update/_1144.php create mode 100644 Zotlabs/Update/_1145.php create mode 100644 Zotlabs/Update/_1146.php create mode 100644 Zotlabs/Update/_1147.php create mode 100644 Zotlabs/Update/_1148.php create mode 100644 Zotlabs/Update/_1149.php create mode 100644 Zotlabs/Update/_1150.php create mode 100644 Zotlabs/Update/_1151.php create mode 100644 Zotlabs/Update/_1152.php create mode 100644 Zotlabs/Update/_1153.php create mode 100644 Zotlabs/Update/_1154.php create mode 100644 Zotlabs/Update/_1155.php create mode 100644 Zotlabs/Update/_1156.php create mode 100644 Zotlabs/Update/_1157.php create mode 100644 Zotlabs/Update/_1158.php create mode 100644 Zotlabs/Update/_1159.php create mode 100644 Zotlabs/Update/_1160.php create mode 100644 Zotlabs/Update/_1161.php create mode 100644 Zotlabs/Update/_1162.php create mode 100644 Zotlabs/Update/_1163.php create mode 100644 Zotlabs/Update/_1164.php create mode 100644 Zotlabs/Update/_1165.php create mode 100644 Zotlabs/Update/_1166.php create mode 100644 Zotlabs/Update/_1167.php create mode 100644 Zotlabs/Update/_1168.php create mode 100644 Zotlabs/Update/_1169.php create mode 100644 Zotlabs/Update/_1170.php create mode 100644 Zotlabs/Update/_1171.php create mode 100644 Zotlabs/Update/_1172.php create mode 100644 Zotlabs/Update/_1173.php create mode 100644 Zotlabs/Update/_1174.php create mode 100644 Zotlabs/Update/_1175.php create mode 100644 Zotlabs/Update/_1176.php create mode 100644 Zotlabs/Update/_1177.php create mode 100644 Zotlabs/Update/_1178.php create mode 100644 Zotlabs/Update/_1179.php create mode 100644 Zotlabs/Update/_1180.php create mode 100644 Zotlabs/Update/_1181.php create mode 100644 Zotlabs/Update/_1182.php create mode 100644 Zotlabs/Update/_1183.php create mode 100644 Zotlabs/Update/_1184.php create mode 100644 Zotlabs/Update/_1185.php create mode 100644 Zotlabs/Update/_1186.php create mode 100644 Zotlabs/Update/_1187.php create mode 100644 Zotlabs/Update/_1188.php create mode 100644 Zotlabs/Update/_1189.php create mode 100644 Zotlabs/Update/_1190.php create mode 100644 Zotlabs/Update/_1191.php create mode 100644 Zotlabs/Update/_1192.php create mode 100644 Zotlabs/Update/_1193.php create mode 100644 Zotlabs/Update/_1194.php create mode 100644 Zotlabs/Update/_1195.php create mode 100644 Zotlabs/Update/_1196.php create mode 100644 Zotlabs/Update/_1197.php create mode 100644 Zotlabs/Update/_1198.php create mode 100644 Zotlabs/Update/_1199.php create mode 100644 Zotlabs/Update/_1200.php create mode 100644 Zotlabs/Update/_1201.php (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/DB_Upgrade.php b/Zotlabs/Lib/DB_Upgrade.php index 8f0488f6f..4038a2d53 100644 --- a/Zotlabs/Lib/DB_Upgrade.php +++ b/Zotlabs/Lib/DB_Upgrade.php @@ -10,22 +10,12 @@ class DB_Upgrade { function __construct($db_revision) { - $platform_name = System::get_platform_name(); + $this->config_name = 'db_version'; + $this->func_prefix = '_'; - $update_file = 'install/' . $platform_name . '/update.php'; - if(! file_exists($update_file)) { - $update_file = 'install/update.php'; - $this->config_name = 'db_version'; - $this->func_prefix = 'update_r'; - } - else { - $this->config_name = $platform_name . '_db_version'; - $this->func_prefix = $platform_name . '_update_'; - } - - $build = get_config('system', $this->config_name, 0); + $build = get_config('system', 'db_version', 0); if(! intval($build)) - $build = set_config('system', $this->config_name, $db_revision); + $build = set_config('system', 'db_version', $db_revision); if($build == $db_revision) { // Nothing to be done. @@ -40,82 +30,78 @@ class DB_Upgrade { $current = intval($db_revision); - if(($stored < $current) && file_exists($update_file)) { + if($stored < $current) { - Config::Load('database'); + // The last update we performed was $stored. + // Start at $stored + 1 and continue until we have completed $current - // We're reporting a different version than what is currently installed. - // Run any existing update scripts to bring the database up to current. - - require_once($update_file); + for($x = $stored + 1; $x <= $current; $x ++) { + $s = '_' . $x; + $cls = '\\Zotlabs\Update\\' . $s ; + if(! class_exists($cls)) { + return; + } - // make sure that boot.php and update.php are the same release, we might be - // updating from git right this very second and the correct version of the update.php - // file may not be here yet. This can happen on a very busy site. + // There could be a lot of processes running or about to run. + // We want exactly one process to run the update command. + // So store the fact that we're taking responsibility + // after first checking to see if somebody else already has. - if($db_revision == UPDATE_VERSION) { - for($x = $stored; $x < $current; $x ++) { - $func = $this->func_prefix . $x; - if(function_exists($func)) { - // There could be a lot of processes running or about to run. - // We want exactly one process to run the update command. - // So store the fact that we're taking responsibility - // after first checking to see if somebody else already has. + // If the update fails or times-out completely you may need to + // delete the config entry to try again. - // If the update fails or times-out completely you may need to - // delete the config entry to try again. + Config::Load('database'); - if(get_config('database', $func)) - break; - set_config('database',$func, '1'); - // call the specific update + if(get_config('database', $s)) + break; + set_config('database',$s, '1'); + - $retval = $func(); - if($retval) { + $c = new $cls(); + $retval = $c->run(); - // Prevent sending hundreds of thousands of emails by creating - // a lockfile. + if($retval != UPDATE_SUCCESS) { - $lockfile = 'store/[data]/mailsent'; + // Prevent sending hundreds of thousands of emails by creating + // a lockfile. - if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 86400))) - return; - @unlink($lockfile); - //send the administrator an e-mail - file_put_contents($lockfile, $x); - - $r = q("select account_language from account where account_email = '%s' limit 1", - dbesc(\App::$config['system']['admin_email']) - ); - push_lang(($r) ? $r[0]['account_language'] : 'en'); + $lockfile = 'store/[data]/mailsent'; - z_mail( + if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 86400))) + return; + @unlink($lockfile); + //send the administrator an e-mail + file_put_contents($lockfile, $x); + + $r = q("select account_language from account where account_email = '%s' limit 1", + dbesc(\App::$config['system']['admin_email']) + ); + push_lang(($r) ? $r[0]['account_language'] : 'en'); + z_mail( + [ + 'toEmail' => \App::$config['system']['admin_email'], + 'messageSubject' => sprintf( t('Update Error at %s'), z_root()), + 'textVersion' => replace_macros(get_intltext_template('update_fail_eml.tpl'), [ - 'toEmail' => \App::$config['system']['admin_email'], - 'messageSubject' => sprintf( t('Update Error at %s'), z_root()), - 'textVersion' => replace_macros(get_intltext_template('update_fail_eml.tpl'), - [ - '$sitename' => \App::$config['system']['sitename'], - '$siteurl' => z_root(), - '$update' => $x, - '$error' => sprintf( t('Update %s failed. See error logs.'), $x) - ] - ) + '$sitename' => \App::$config['system']['sitename'], + '$siteurl' => z_root(), + '$update' => $x, + '$error' => sprintf( t('Update %s failed. See error logs.'), $x) ] - ); - - //try the logger - logger('CRITICAL: Update Failed: ' . $x); - pop_lang(); - } - else { - set_config('database',$func, 'success'); - } - } + ) + ] + ); + + //try the logger + logger('CRITICAL: Update Failed: ' . $x); + pop_lang(); + } + else { + set_config('database',$s, 'success'); } - set_config('system', $this->config_name, $db_revision); } } + set_config('system', 'db_version', $db_revision); } } } \ No newline at end of file diff --git a/Zotlabs/Module/Admin/Dbsync.php b/Zotlabs/Module/Admin/Dbsync.php index cff8a2484..469af2aa5 100644 --- a/Zotlabs/Module/Admin/Dbsync.php +++ b/Zotlabs/Module/Admin/Dbsync.php @@ -7,36 +7,38 @@ namespace Zotlabs\Module\Admin; class Dbsync { - - function get() { $o = ''; if(argc() > 3 && intval(argv(3)) && argv(2) === 'mark') { - set_config('database', 'update_r' . intval(argv(3)), 'success'); - if(intval(get_config('system','db_version')) <= intval(argv(3))) - set_config('system','db_version',intval(argv(3)) + 1); + // remove the old style config if it exists + del_config('database', 'update_r' . intval(argv(3))); + set_config('database', '_' . intval(argv(3)), 'success'); + if(intval(get_config('system','db_version')) < intval(argv(3))) + set_config('system','db_version',intval(argv(3))); info( t('Update has been marked successful') . EOL); goaway(z_root() . '/admin/dbsync'); } if(argc() > 2 && intval(argv(2))) { - require_once('install/update.php'); - $func = 'update_r' . intval(argv(2)); - if(function_exists($func)) { - $retval = $func(); + $x = intval(argv(2)); + $s = '_' . $x; + $cls = '\\Zotlabs\Update\\' . $s ; + if(class_exists($cls)) { + $c = new $cls(); + $retval = $c->run(); if($retval === UPDATE_FAILED) { - $o .= sprintf( t('Executing %s failed. Check system logs.'), $func); + $o .= sprintf( t('Executing %s failed. Check system logs.'), $s); } elseif($retval === UPDATE_SUCCESS) { - $o .= sprintf( t('Update %s was successfully applied.'), $func); - set_config('database',$func, 'success'); + $o .= sprintf( t('Update %s was successfully applied.'), $s); + set_config('database',$s, 'success'); } else - $o .= sprintf( t('Update %s did not return a status. Unknown if it succeeded.'), $func); + $o .= sprintf( t('Update %s did not return a status. Unknown if it succeeded.'), $s); } else - $o .= sprintf( t('Update function %s could not be found.'), $func); + $o .= sprintf( t('Update function %s could not be found.'), $s); return $o; } @@ -45,23 +47,25 @@ class Dbsync { $r = q("select * from config where cat = 'database' "); if(count($r)) { foreach($r as $rr) { - $upd = intval(substr($rr['k'],8)); + $upd = intval(substr($rr['k'],-4)); if($rr['v'] === 'success') continue; $failed[] = $upd; } } - if(! count($failed)) - return '

' . t('No failed updates.') . '

'; - - $o = replace_macros(get_markup_template('failed_updates.tpl'),array( - '$base' => z_root(), - '$banner' => t('Failed Updates'), - '$desc' => '', - '$mark' => t('Mark success (if update was manually applied)'), - '$apply' => t('Attempt to execute this update step automatically'), - '$failed' => $failed + if(count($failed)) { + $o = replace_macros(get_markup_template('failed_updates.tpl'),array( + '$base' => z_root(), + '$banner' => t('Failed Updates'), + '$desc' => '', + '$mark' => t('Mark success (if update was manually applied)'), + '$apply' => t('Attempt to execute this update step automatically'), + '$failed' => $failed )); + } + else { + return '

' . t('No failed updates.') . '

'; + } return $o; } diff --git a/Zotlabs/Update/_1000.php b/Zotlabs/Update/_1000.php new file mode 100644 index 000000000..02787db38 --- /dev/null +++ b/Zotlabs/Update/_1000.php @@ -0,0 +1,15 @@ + 0 "); + + if($r1 && $r2 && $r3) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +} \ No newline at end of file diff --git a/Zotlabs/Update/_1137.php b/Zotlabs/Update/_1137.php new file mode 100644 index 000000000..ab11fe3db --- /dev/null +++ b/Zotlabs/Update/_1137.php @@ -0,0 +1,16 @@ + Date: Sat, 17 Feb 2018 01:49:01 +0100 Subject: Refactor OAuth2Server a bit. --- Zotlabs/Identity/OAuth2Server.php | 43 +++++++++++++++---------------------- Zotlabs/Module/Authorize.php | 45 +++++++++++++++++++-------------------- Zotlabs/Module/Token.php | 9 ++++---- 3 files changed, 44 insertions(+), 53 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Identity/OAuth2Server.php b/Zotlabs/Identity/OAuth2Server.php index 3d7d5efb2..cbb4748fe 100644 --- a/Zotlabs/Identity/OAuth2Server.php +++ b/Zotlabs/Identity/OAuth2Server.php @@ -2,42 +2,33 @@ namespace Zotlabs\Identity; -class OAuth2Server { +class OAuth2Server extends \OAuth2\Server { - public $server; + public function __construct(OAuth2Storage $storage, $config = []) { - public function __construct() { + if(! is_array($config)) { + $config = [ + 'use_openid_connect' => true, + 'issuer' => \Zotlabs\Lib\System::get_site_name() + ]; + } - $storage = new OAuth2Storage(\DBA::$dba->db); - - $config = [ - 'use_openid_connect' => true, - 'issuer' => \Zotlabs\Lib\System::get_site_name() - ]; - - // Pass a storage object or array of storage objects to the OAuth2 server class - $this->server = new \OAuth2\Server($storage,$config); + parent::__construct($storage, $config); // Add the "Client Credentials" grant type (it is the simplest of the grant types) - $this->server->addGrantType(new \OAuth2\GrantType\ClientCredentials($storage)); + $this->addGrantType(new \OAuth2\GrantType\ClientCredentials($storage)); // Add the "Authorization Code" grant type (this is where the oauth magic happens) - $this->server->addGrantType(new \OAuth2\GrantType\AuthorizationCode($storage)); + $this->addGrantType(new \OAuth2\GrantType\AuthorizationCode($storage)); - $keyStorage = new \OAuth2\Storage\Memory( [ - 'keys' => [ - 'public_key' => get_config('system','pubkey'), - 'private_key' => get_config('system','prvkey') + $keyStorage = new \OAuth2\Storage\Memory( [ + 'keys' => [ + 'public_key' => get_config('system', 'pubkey'), + 'private_key' => get_config('system', 'prvkey') ] ]); - $this->server->addStorage($keyStorage,'public_key'); - + $this->addStorage($keyStorage, 'public_key'); } - public function get_server() { - return $this->server; - } - - -} \ No newline at end of file +} diff --git a/Zotlabs/Module/Authorize.php b/Zotlabs/Module/Authorize.php index 7676b0855..254700b4e 100644 --- a/Zotlabs/Module/Authorize.php +++ b/Zotlabs/Module/Authorize.php @@ -2,13 +2,13 @@ namespace Zotlabs\Module; +use Zotlabs\Identity\OAuth2Storage; -class Authorize extends \Zotlabs\Web\Controller { +class Authorize extends \Zotlabs\Web\Controller { function init() { - // workaround for HTTP-auth in CGI mode if (x($_SERVER, 'REDIRECT_REMOTE_USER')) { $userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"], 6)) ; @@ -28,41 +28,40 @@ class Authorize extends \Zotlabs\Web\Controller { } } - $s = new \Zotlabs\Identity\OAuth2Server(); + $s = new \Zotlabs\Identity\OAuth2Server(new OAuth2Storage(\DBA::$dba->db)); $request = \OAuth2\Request::createFromGlobals(); $response = new \OAuth2\Response(); // validate the authorize request - if (! $s->server->validateAuthorizeRequest($request, $response)) { - $response->send(); - killme(); + if (! $s->validateAuthorizeRequest($request, $response)) { + $response->send(); + killme(); } - // display an authorization form - if (empty($_POST)) { + // display an authorization form + if (empty($_POST)) { - return ' + return '

'; - } + } - // print the authorization code if the user has authorized your client - $is_authorized = ($_POST['authorized'] === 'yes'); - $s->server->handleAuthorizeRequest($request, $response, $is_authorized, local_channel()); - 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"); - - } + // print the authorization code if the user has authorized your client + $is_authorized = ($_POST['authorized'] === 'yes'); + $s->handleAuthorizeRequest($request, $response, $is_authorized, local_channel()); + 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(); + $response->send(); + killme(); } -} \ No newline at end of file +} diff --git a/Zotlabs/Module/Token.php b/Zotlabs/Module/Token.php index 5cde58895..f7c074233 100644 --- a/Zotlabs/Module/Token.php +++ b/Zotlabs/Module/Token.php @@ -2,6 +2,8 @@ namespace Zotlabs\Module; +use Zotlabs\Identity\OAuth2Storage; + class Token extends \Zotlabs\Web\Controller { @@ -26,11 +28,10 @@ class Token extends \Zotlabs\Web\Controller { } } - - $s = new \Zotlabs\Identity\OAuth2Server(); - $s->server->handleTokenRequest(\OAuth2\Request::createFromGlobals())->send(); + $s = new \Zotlabs\Identity\OAuth2Server(new OAuth2Storage(\DBA::$dba->db)); + $s->handleTokenRequest(\OAuth2\Request::createFromGlobals())->send(); killme(); } -} \ No newline at end of file +} -- cgit v1.2.3 From 1732ffed7a3a9c1ab8811baef3a36f70a64bce7a Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 19 Feb 2018 10:59:21 +0100 Subject: backport update 1201 to the new update system and move dummy update to 1202 --- Zotlabs/Update/_1201.php | 18 +++++++++++++----- Zotlabs/Update/_1202.php | 15 +++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 Zotlabs/Update/_1202.php (limited to 'Zotlabs') diff --git a/Zotlabs/Update/_1201.php b/Zotlabs/Update/_1201.php index c12797377..416d35ad6 100644 --- a/Zotlabs/Update/_1201.php +++ b/Zotlabs/Update/_1201.php @@ -6,10 +6,18 @@ class _1201 { function run() { - // empty update in order to make the DB_UPDATE_VERSION equal to the current maximum update function - // rather than being one greater than the last known update - - return UPDATE_SUCCESS; + if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { + $r = q("ALTER TABLE item + DROP INDEX item_thread_top, + ADD INDEX uid_item_thread_top (uid, item_thread_top), + ADD INDEX uid_item_blocked (uid, item_blocked), + ADD INDEX item_deleted_pending_remove_changed (item_deleted, item_pending_remove, changed) + "); + } + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; } -} \ No newline at end of file + +} diff --git a/Zotlabs/Update/_1202.php b/Zotlabs/Update/_1202.php new file mode 100644 index 000000000..c9ccd157b --- /dev/null +++ b/Zotlabs/Update/_1202.php @@ -0,0 +1,15 @@ + Date: Mon, 19 Feb 2018 20:23:13 +0100 Subject: updates 1201 and 1200 should return success for postgres. notifications: remove class show and session storage entry when we mark all notifications seen --- Zotlabs/Update/_1198.php | 2 +- Zotlabs/Update/_1200.php | 12 ++++++++---- Zotlabs/Update/_1201.php | 10 +++++++--- 3 files changed, 16 insertions(+), 8 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Update/_1198.php b/Zotlabs/Update/_1198.php index 0713bb6ce..d188c94f6 100644 --- a/Zotlabs/Update/_1198.php +++ b/Zotlabs/Update/_1198.php @@ -21,4 +21,4 @@ function run() { } -} \ No newline at end of file +} diff --git a/Zotlabs/Update/_1200.php b/Zotlabs/Update/_1200.php index 00c742593..9f7bfb152 100644 --- a/Zotlabs/Update/_1200.php +++ b/Zotlabs/Update/_1200.php @@ -10,11 +10,15 @@ function run() { DROP INDEX item_type, ADD INDEX uid_item_type (uid, item_type) "); - } - if($r) + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + } + else { return UPDATE_SUCCESS; - return UPDATE_FAILED; + } + } -} \ No newline at end of file +} diff --git a/Zotlabs/Update/_1201.php b/Zotlabs/Update/_1201.php index 416d35ad6..920a7401e 100644 --- a/Zotlabs/Update/_1201.php +++ b/Zotlabs/Update/_1201.php @@ -13,11 +13,15 @@ class _1201 { ADD INDEX uid_item_blocked (uid, item_blocked), ADD INDEX item_deleted_pending_remove_changed (item_deleted, item_pending_remove, changed) "); - } - if($r) + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + } + else { return UPDATE_SUCCESS; - return UPDATE_FAILED; + } + } } -- cgit v1.2.3 From 04185b05ab141cdb8b96f5fa9e4106b4a2cde732 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 19 Feb 2018 11:57:47 -0800 Subject: target zot6 deliveries with more precision to ensure we handle a very precise type of content until the mechanism is extended to other types in the future --- Zotlabs/Daemon/Notifier.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 957b859af..47db32206 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -640,7 +640,21 @@ class Notifier { } else { $env = (($hub_env && $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']]) ? $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']] : ''); - $packet = zot6_build_packet($channel,'notify',$env, json_encode($encoded_item), (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); + + // currently zot6 delivery is only performed on normal items and not sync items or mail or anything else + // Eventually we will do this for all deliveries, but for now ensure this is precisely what we are dealing + // with before switching to zot6 as the primary zot6 handler checks for the existence of a message delivery report + // to trigger dequeue'ing + + $z6 = (($encoded_item && $encoded_item['type'] === 'activity' && (! $encoded_item['allow_cid'])) ? true : false); + if($z6) { + $packet = zot6_build_packet($channel,'notify',$env, json_encode($encoded_item), (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); + } + else { + $packet = zot6_build_packet($channel,'notify',$env, (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); + + } + queue_insert( [ 'hash' => $hash, -- cgit v1.2.3 From f0d68a1a250c6bd8bf5bdcce6334d5dffcba50cd Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 19 Feb 2018 14:13:44 -0800 Subject: fix the fix for precision --- Zotlabs/Daemon/Notifier.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 47db32206..b7f2a384d 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -646,7 +646,7 @@ class Notifier { // with before switching to zot6 as the primary zot6 handler checks for the existence of a message delivery report // to trigger dequeue'ing - $z6 = (($encoded_item && $encoded_item['type'] === 'activity' && (! $encoded_item['allow_cid'])) ? true : false); + $z6 = (($encoded_item && $encoded_item['type'] === 'activity' && (! array_key_exists('allow_cid',$encoded_item)) ? true : false); if($z6) { $packet = zot6_build_packet($channel,'notify',$env, json_encode($encoded_item), (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); } -- cgit v1.2.3 From 331fe92b9e5e7ecd1db0d0582278bf7b95789570 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 19 Feb 2018 14:14:45 -0800 Subject: and fix the typo --- Zotlabs/Daemon/Notifier.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index b7f2a384d..af561c702 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -646,7 +646,7 @@ class Notifier { // with before switching to zot6 as the primary zot6 handler checks for the existence of a message delivery report // to trigger dequeue'ing - $z6 = (($encoded_item && $encoded_item['type'] === 'activity' && (! array_key_exists('allow_cid',$encoded_item)) ? true : false); + $z6 = (($encoded_item && $encoded_item['type'] === 'activity' && (! array_key_exists('allow_cid',$encoded_item))) ? true : false); if($z6) { $packet = zot6_build_packet($channel,'notify',$env, json_encode($encoded_item), (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); } -- cgit v1.2.3 From 93d4a16017b792570323db31f438a9ee3870378d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 20 Feb 2018 10:29:22 +0100 Subject: missing file --- Zotlabs/Update/_1203.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Zotlabs/Update/_1203.php (limited to 'Zotlabs') diff --git a/Zotlabs/Update/_1203.php b/Zotlabs/Update/_1203.php new file mode 100644 index 000000000..2968d209d --- /dev/null +++ b/Zotlabs/Update/_1203.php @@ -0,0 +1,29 @@ + Date: Tue, 20 Feb 2018 14:41:46 -0800 Subject: copy/paste error resulting in bad behaviour --- Zotlabs/Daemon/Notifier.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index af561c702..fa2368a92 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -651,7 +651,7 @@ class Notifier { $packet = zot6_build_packet($channel,'notify',$env, json_encode($encoded_item), (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); } else { - $packet = zot6_build_packet($channel,'notify',$env, (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); + $packet = zot_build_packet($channel,'notify',$env, (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); } -- cgit v1.2.3 From ce8349662d8c9e309f3faf57114acddb67eb11b7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 19 Feb 2018 20:12:58 -0800 Subject: Add 'Validate' button to new_channel page and disable submit until validated. This is to get around the issue that clicking submit without ever focusing and blurring the nickname field won't actually submit the form but only provide validation. It needs to be clicked again to submit. The first click processed the blur but remained on the page with no feedback. If somebody has better workarounds, please provide. The goal is to ensure that the name and the nickname are both validated before we can submit. --- Zotlabs/Module/New_channel.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/New_channel.php b/Zotlabs/Module/New_channel.php index 9f2fea802..548f28c4f 100644 --- a/Zotlabs/Module/New_channel.php +++ b/Zotlabs/Module/New_channel.php @@ -142,6 +142,7 @@ class New_channel extends \Zotlabs\Web\Controller { '$role' => $role, '$default_role' => $default_role, '$nickname' => $nickname, + '$validate' => t('Validate'), '$submit' => t('Create'), '$channel_usage_message' => $channel_usage_message )); -- cgit v1.2.3