From 9d51318c53e1adc2e4d4c8586f8783819516991e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 19 Oct 2017 17:24:11 -0700 Subject: table structure for pseudo or proxy channels (pchan) --- Zotlabs/Module/Wfinger.php | 139 +++++++++++++++++++++++++++++---------------- 1 file changed, 90 insertions(+), 49 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Wfinger.php b/Zotlabs/Module/Wfinger.php index d0c4d73d2..9db95f181 100644 --- a/Zotlabs/Module/Wfinger.php +++ b/Zotlabs/Module/Wfinger.php @@ -32,6 +32,7 @@ class Wfinger extends \Zotlabs\Web\Controller { $root_resource = false; + $pchan = false; if(strcasecmp(rtrim($resource,'/'),z_root()) === 0) $root_resource = true; @@ -57,11 +58,24 @@ class Wfinger extends \Zotlabs\Web\Controller { $channel = str_replace('~','',basename($resource)); } - $r = q("select * from channel left join xchan on channel_hash = xchan_hash - where channel_address = '%s' limit 1", - dbesc($channel) - ); - + if(substr($channel,0,1) === '[' ) { + $channel = substr($channel,1); + $channel = substr($channel,0,-1); + $pchan = true; + $r = q("select * from pchan left join xchan on pchan_hash = xchan_hash + where pchan_guid = '%s' limit 1", + dbesc($channel) + ); + if($r) { + $r[0] = pchan_to_chan($r[0]); + } + } + else { + $r = q("select * from channel left join xchan on channel_hash = xchan_hash + where channel_address = '%s' limit 1", + dbesc($channel) + ); + } } header('Access-Control-Allow-Origin: *'); @@ -94,7 +108,7 @@ class Wfinger extends \Zotlabs\Web\Controller { $result['subject'] = $resource; $aliases = array( - z_root() . '/channel/' . $r[0]['channel_address'], + z_root() . (($pchan) ? '/pchan/' : '/channel/') . $r[0]['channel_address'], z_root() . '/~' . $r[0]['channel_address'] ); @@ -116,53 +130,80 @@ class Wfinger extends \Zotlabs\Web\Controller { if($alias != $resource) $result['aliases'][] = $alias; - $result['links'] = [ - - [ - 'rel' => 'http://webfinger.net/rel/avatar', - 'type' => $r[0]['xchan_photo_mimetype'], - 'href' => $r[0]['xchan_photo_l'] - ], - - [ - 'rel' => 'http://webfinger.net/rel/profile-page', - 'href' => z_root() . '/profile/' . $r[0]['channel_address'], - ], - - [ - 'rel' => 'http://schemas.google.com/g/2010#updates-from', - 'type' => 'application/atom+xml', - 'href' => z_root() . '/ofeed/' . $r[0]['channel_address'] - ], - [ - 'rel' => 'http://webfinger.net/rel/blog', - 'href' => z_root() . '/channel/' . $r[0]['channel_address'], - ], + if($pchan) { + $result['links'] = [ - [ - 'rel' => 'http://ostatus.org/schema/1.0/subscribe', - 'template' => z_root() . '/follow?f=&url={uri}', - ], + [ + 'rel' => 'http://webfinger.net/rel/avatar', + 'type' => $r[0]['xchan_photo_mimetype'], + 'href' => $r[0]['xchan_photo_l'] + ], - [ - 'rel' => 'http://purl.org/zot/protocol', - 'href' => z_root() . '/.well-known/zot-info' . '?address=' . $r[0]['xchan_addr'], - ], + [ + 'rel' => 'http://webfinger.net/rel/profile-page', + 'href' => $r[0]['xchan_url'], + ], - [ - 'rel' => 'http://purl.org/openwebauth/v1', - 'type' => 'application/x-zot+json', - 'href' => z_root() . '/owa', - ], + [ + 'rel' => 'magic-public-key', + 'href' => 'data:application/magic-public-key,' . salmon_key($r[0]['channel_pubkey']), + ] + + ]; + + + } + else { + + $result['links'] = [ + + [ + 'rel' => 'http://webfinger.net/rel/avatar', + 'type' => $r[0]['xchan_photo_mimetype'], + 'href' => $r[0]['xchan_photo_l'] + ], + + [ + 'rel' => 'http://webfinger.net/rel/profile-page', + 'href' => z_root() . '/profile/' . $r[0]['channel_address'], + ], + + [ + 'rel' => 'http://schemas.google.com/g/2010#updates-from', + 'type' => 'application/atom+xml', + 'href' => z_root() . '/ofeed/' . $r[0]['channel_address'] + ], + + [ + 'rel' => 'http://webfinger.net/rel/blog', + 'href' => z_root() . '/channel/' . $r[0]['channel_address'], + ], + + [ + 'rel' => 'http://ostatus.org/schema/1.0/subscribe', + 'template' => z_root() . '/follow?f=&url={uri}', + ], + + [ + 'rel' => 'http://purl.org/zot/protocol', + 'href' => z_root() . '/.well-known/zot-info' . '?address=' . $r[0]['xchan_addr'], + ], + + [ + 'rel' => 'http://purl.org/openwebauth/v1', + 'type' => 'application/x-zot+json', + 'href' => z_root() . '/owa', + ], + + + [ + 'rel' => 'magic-public-key', + 'href' => 'data:application/magic-public-key,' . salmon_key($r[0]['channel_pubkey']), + ] + ]; + } - - [ - 'rel' => 'magic-public-key', - 'href' => 'data:application/magic-public-key,' . salmon_key($r[0]['channel_pubkey']), - ] - ]; - if($zot) { // get a zotinfo packet and return it with webfinger $result['zot'] = zotinfo( [ 'address' => $r[0]['xchan_addr'] ]); @@ -174,7 +215,7 @@ class Wfinger extends \Zotlabs\Web\Controller { killme(); } - $arr = [ 'channel' => $r[0], 'request' => $_REQUEST, 'result' => $result ]; + $arr = [ 'channel' => $r[0], 'pchan' => $pchan, 'request' => $_REQUEST, 'result' => $result ]; call_hooks('webfinger',$arr); -- cgit v1.2.3 From 42416aad226ddd34a0e2fb691382320a3c9c9606 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Thu, 19 Oct 2017 21:09:12 -0400 Subject: Display different info message if using invite code --- Zotlabs/Module/Register.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php index 9a364e154..b026dc4c6 100644 --- a/Zotlabs/Module/Register.php +++ b/Zotlabs/Module/Register.php @@ -128,7 +128,11 @@ class Register extends \Zotlabs\Web\Controller { $res = send_register_success_email($result['email'],$result['password']); } if($res) { - info( t('Registration successful. Please check your email for validation instructions.') . EOL ) ; + if($invite_code) { + info( t('Registration successful. Continue to create your first channel...') . EOL ) ; + } else { + info( t('Registration successful. Please check your email for validation instructions.') . EOL ) ; + } } } elseif($policy == REGISTER_APPROVE) { -- cgit v1.2.3 From 400441d56b21e69663ea7213ccf63fe0ee6a6bab Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 19 Oct 2017 18:48:11 -0700 Subject: register workflow was getting over-ridden in include/security --- Zotlabs/Module/New_channel.php | 2 +- Zotlabs/Module/Register.php | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/New_channel.php b/Zotlabs/Module/New_channel.php index cfd45e909..2b73fa191 100644 --- a/Zotlabs/Module/New_channel.php +++ b/Zotlabs/Module/New_channel.php @@ -9,7 +9,7 @@ require_once('include/permissions.php'); class New_channel extends \Zotlabs\Web\Controller { function init() { - + $cmd = ((argc() > 1) ? argv(1) : ''); if($cmd === 'autofill.json') { diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php index 9a364e154..9cf0960c0 100644 --- a/Zotlabs/Module/Register.php +++ b/Zotlabs/Module/Register.php @@ -123,13 +123,13 @@ class Register extends \Zotlabs\Web\Controller { if($policy == REGISTER_OPEN ) { if($email_verify) { $res = verify_email_address($result); + if($res) { + info( t('Registration successful. Please check your email for validation instructions.') . EOL ) ; + } } else { $res = send_register_success_email($result['email'],$result['password']); } - if($res) { - info( t('Registration successful. Please check your email for validation instructions.') . EOL ) ; - } } elseif($policy == REGISTER_APPROVE) { $res = send_reg_approval_email($result); @@ -167,7 +167,8 @@ class Register extends \Zotlabs\Web\Controller { $next_page = $x; $_SESSION['workflow'] = true; } - + + unset($_SESSION['login_return_url']); goaway(z_root() . '/' . $next_page); } -- cgit v1.2.3 From 0061ac8584feb6d18962518263ab18617dbf8dc5 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 22 Oct 2017 21:01:58 +0200 Subject: do not show seen notifys in notifications - show them in mod notifications instead. Update notifications count also on notifications updates --- Zotlabs/Module/Notifications.php | 35 +++++++++++++++++++++++++++-------- Zotlabs/Module/Ping.php | 37 ++++++++++--------------------------- 2 files changed, 37 insertions(+), 35 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Notifications.php b/Zotlabs/Module/Notifications.php index 652648701..dfa007548 100644 --- a/Zotlabs/Module/Notifications.php +++ b/Zotlabs/Module/Notifications.php @@ -12,25 +12,44 @@ class Notifications extends \Zotlabs\Web\Controller { return; } - nav_set_selected('notifications'); + nav_set_selected('Notifications'); $o = ''; - - $r = q("SELECT * from notify where uid = %d and seen = 0 order by created desc", + + $r = q("select count(*) as total from notify where uid = %d and seen = 0", intval(local_channel()) ); + if($r && intval($t[0]['total']) > 49) { + $r = q("select * from notify where uid = %d + and seen = 0 order by created desc limit 50", + intval(local_channel()) + ); + } else { + $r1 = q("select * from notify where uid = %d + and seen = 0 order by created desc limit 50", + intval(local_channel()) + ); + $r2 = q("select * from notify where uid = %d + and seen = 1 order by created desc limit %d", + intval(local_channel()), + intval(50 - intval($t[0]['total'])) + ); + $r = array_merge($r1,$r2); + } if($r) { $notifications_available = 1; - foreach ($r as $it) { - $x = strip_tags(bbcode($it['msg'])); + foreach ($r as $rr) { + $x = strip_tags(bbcode($rr['msg'])); if(strpos($x,',')) $x = substr($x,strpos($x,',')+1); $notif_content .= replace_macros(get_markup_template('notify.tpl'),array( - '$item_link' => z_root().'/notify/view/'. $it['id'], - '$item_image' => $it['photo'], + '$item_link' => z_root().'/notify/view/'. $rr['id'], + '$item_image' => $rr['photo'], '$item_text' => $x, - '$item_when' => relative_date($it['created']) + '$item_when' => relative_date($rr['created']), + '$item_seen' => (($rr['seen']) ? true : false), + '$new' => t('New') )); } } diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 5f44b3c20..c91659f2f 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -258,37 +258,20 @@ class Ping extends \Zotlabs\Web\Controller { * dropdown menu. */ if(argc() > 1 && argv(1) === 'notify') { - $t = q("select count(*) as total from notify where uid = %d and seen = 0", + $t = q("select * from notify where uid = %d and seen = 0 order by created desc", intval(local_channel()) ); - if($t && intval($t[0]['total']) > 49) { - $z = q("select * from notify where uid = %d - and seen = 0 order by created desc limit 50", - intval(local_channel()) - ); - } else { - $z1 = q("select * from notify where uid = %d - and seen = 0 order by created desc limit 50", - intval(local_channel()) - ); - $z2 = q("select * from notify where uid = %d - and seen = 1 order by created desc limit %d", - intval(local_channel()), - intval(50 - intval($t[0]['total'])) - ); - $z = array_merge($z1,$z2); - } - if(count($z)) { - foreach($z as $zz) { + if($t) { + foreach($t as $tt) { $notifs[] = array( - 'notify_link' => z_root() . '/notify/view/' . $zz['id'], - 'name' => $zz['xname'], - 'url' => $zz['url'], - 'photo' => $zz['photo'], - 'when' => relative_date($zz['created']), - 'hclass' => (($zz['seen']) ? 'notify-seen' : 'notify-unseen'), - 'message' => strip_tags(bbcode($zz['msg'])) + 'notify_link' => z_root() . '/notify/view/' . $tt['id'], + 'name' => $tt['xname'], + 'url' => $tt['url'], + 'photo' => $tt['photo'], + 'when' => relative_date($tt['created']), + 'hclass' => (($tt['seen']) ? 'notify-seen' : 'notify-unseen'), + 'message' => strip_tags(bbcode($tt['msg'])) ); } } -- cgit v1.2.3 From a4fdf3fbbb5f2cfecbfed2eb6e563b240cb11c91 Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Mon, 23 Oct 2017 01:34:37 +0200 Subject: We call Theme:url() statically, make it also static. --- Zotlabs/Render/Theme.php | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Render/Theme.php b/Zotlabs/Render/Theme.php index 3a0116abe..09cc7a4d4 100644 --- a/Zotlabs/Render/Theme.php +++ b/Zotlabs/Render/Theme.php @@ -2,6 +2,8 @@ namespace Zotlabs\Render; +use App; + class Theme { @@ -11,17 +13,28 @@ class Theme { static $session_theme = null; static $session_mobile_theme = null; - static $base_themes = array('redbasic'); + /** + * @brief Array with base or fallback themes. + */ + static $base_themes = array('redbasic'); + + /** + * @brief Figure out the best matching theme and return it. + * + * The theme will depend on channel settings, mobile, session, core compatibility, etc. + * + * @return array + */ static public function current(){ - self::$system_theme = ((isset(\App::$config['system']['theme'])) + self::$system_theme = ((isset(\App::$config['system']['theme'])) ? \App::$config['system']['theme'] : ''); - self::$session_theme = ((isset($_SESSION) && x($_SESSION,'theme')) + self::$session_theme = ((isset($_SESSION) && x($_SESSION, 'theme')) ? $_SESSION['theme'] : self::$system_theme); - self::$system_mobile_theme = ((isset(\App::$config['system']['mobile_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')) + self::$session_mobile_theme = ((isset($_SESSION) && x($_SESSION, 'mobile_theme')) ? $_SESSION['mobile_theme'] : self::$system_mobile_theme); $page_theme = null; @@ -66,7 +79,7 @@ class Theme { $chosen_theme = $page_theme; } } - if(array_key_exists('theme_preview',$_GET)) + if(array_key_exists('theme_preview', $_GET)) $chosen_theme = $_GET['theme_preview']; // Allow theme selection of the form 'theme_name:schema_name' @@ -91,14 +104,12 @@ class Theme { } // Worst case scenario, the default base theme or themes don't exist; perhaps somebody renamed it/them. - - // Find any theme at all and use it. - - $fallback = array_merge(glob('view/theme/*/css/style.css'),glob('view/theme/*/php/style.php')); - if(count($fallback)) - return(array(str_replace('view/theme/','', substr($fallback[0],0,-14)))); + // Find any theme at all and use it. + $fallback = array_merge(glob('view/theme/*/css/style.css'), glob('view/theme/*/php/style.php')); + if(count($fallback)) + return(array(str_replace('view/theme/', '', substr($fallback[0], 0, -14)))); } @@ -107,12 +118,11 @@ class Theme { * * Provide a sane default if nothing is chosen or the specified theme does not exist. * - * @param bool $installing default false + * @param bool $installing (optional) default false, if true return the name of the first base theme * * @return string */ - - function url($installing = false) { + static public function url($installing = false) { if($installing) return self::$base_themes[0]; @@ -125,9 +135,10 @@ class Theme { $opts = ''; $opts = ((\App::$profile_uid) ? '?f=&puid=' . \App::$profile_uid : ''); - $schema_str = ((x(\App::$layout,'schema')) ? '&schema=' . App::$layout['schema'] : ''); + $schema_str = ((x(\App::$layout,'schema')) ? '&schema=' . App::$layout['schema'] : ''); if(($s) && (! $schema_str)) $schema_str = '&schema=' . $s; + $opts .= $schema_str; if(file_exists('view/theme/' . $t . '/php/style.php')) @@ -139,7 +150,6 @@ class Theme { function debug() { logger('system_theme: ' . self::$system_theme); logger('session_theme: ' . self::$session_theme); - } } -- cgit v1.2.3 From 812d904c98d6fb3a4124f6e2415de5a139f954ce Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 22 Oct 2017 18:23:37 -0700 Subject: bring back the markdown post feature (after investing some effort to make it work) --- Zotlabs/Module/Item.php | 46 +++++++++------------------------------------- 1 file changed, 9 insertions(+), 37 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 9e5dcfaff..b54de0fb9 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -511,48 +511,20 @@ class Item extends \Zotlabs\Web\Controller { require_once('include/text.php'); - // Markdown doesn't work correctly. Do not re-enable unless you're willing to fix it and support it. - - // Sample that will probably give you grief - you must preserve the linebreaks - // and provide the correct markdown interpretation and you cannot allow unfiltered HTML - - // Markdown - // ======== - // - // **bold** abcde - // fghijkl - // *italic* - // - - // if($uid && $uid == $profile_uid && feature_enabled($uid,'markdown')) { - // require_once('include/markdown.php'); - // $body = escape_tags(trim($body)); - // $body = str_replace("\n",'
', $body); - // $body = preg_replace_callback('/\[share(.*?)\]/ism','\share_shield',$body); - // $body = markdown_to_bb($body,true); - // $body = preg_replace_callback('/\[share(.*?)\]/ism','\share_unshield',$body); - // } + if($uid && $uid == $profile_uid && feature_enabled($uid,'markdown')) { + require_once('include/markdown.php'); + $body = preg_replace_callback('/\[share(.*?)\]/ism','\share_shield',$body); + $body = markdown_to_bb($body,true,['preserve_lf' => true]); + $body = preg_replace_callback('/\[share(.*?)\]/ism','\share_unshield',$body); + + } // BBCODE alert: the following functions assume bbcode input // and will require alternatives for alternative content-types (text/html, text/markdown, text/plain, etc.) // we may need virtual or template classes to implement the possible alternatives - - // Work around doubled linefeeds in Tinymce 3.5b2 - // First figure out if it's a status post that would've been - // created using tinymce. Otherwise leave it alone. - - $plaintext = true; - - // $plaintext = ((feature_enabled($profile_uid,'richtext')) ? false : true); - // if((! $parent) && (! $api_source) && (! $plaintext)) { - // $body = fix_mce_lf($body); - // } - - - + // If we're sending a private top-level message with a single @-taggable channel as a recipient, @-tag it, if our pconfig is set. - - + if((! $parent) && (get_pconfig($profile_uid,'system','tagifonlyrecip')) && (substr_count($str_contact_allow,'<') == 1) && ($str_group_allow == '') && ($str_contact_deny == '') && ($str_group_deny == '')) { $x = q("select abook_id, abconfig.v from abook left join abconfig on abook_xchan = abconfig.xchan and abook_channel = abconfig.chan and cat= 'their_perms' and abconfig.k = 'tag_deliver' and abconfig.v = 1 and abook_xchan = '%s' and abook_channel = %d limit 1", dbesc(str_replace(array('<','>'),array('',''),$str_contact_allow)), -- cgit v1.2.3 From 37b7b2f1a8712f9541becba54f8b7fa88aaa9bc4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 22 Oct 2017 21:44:39 -0700 Subject: mod_display: provide alternate serialisations (starting with atom) --- Zotlabs/Module/Display.php | 167 ++++++++++++++++++++++++++++++--------------- 1 file changed, 113 insertions(+), 54 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index d5afdd787..785274105 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -12,6 +12,12 @@ class Display extends \Zotlabs\Web\Controller { function get($update = 0, $load = false) { + if(argc() > 1) { + $module_format = substr(argv(1),strrpos(argv(1),'.') + 1); + if(! in_array($module_format,['atom','zot','json'])) + $module_format = 'html'; + } + $checkjs = new \Zotlabs\Web\CheckJS(1); if($load) @@ -22,8 +28,12 @@ class Display extends \Zotlabs\Web\Controller { return; } - if(argc() > 1 && argv(1) !== 'load') + if(argc() > 1 && argv(1) !== 'load') { $item_hash = argv(1); + if($module_format !== 'html') { + $item_hash = substr($item_hash,0,strrpos($item_hash,'.')); + } + } if($_REQUEST['mid']) $item_hash = $_REQUEST['mid']; @@ -44,28 +54,28 @@ class Display extends \Zotlabs\Web\Controller { $channel_acl = array( 'allow_cid' => $channel['channel_allow_cid'], 'allow_gid' => $channel['channel_allow_gid'], - 'deny_cid' => $channel['channel_deny_cid'], - 'deny_gid' => $channel['channel_deny_gid'] + 'deny_cid' => $channel['channel_deny_cid'], + 'deny_gid' => $channel['channel_deny_gid'] ); $x = array( - 'is_owner' => true, - 'allow_location' => ((intval(get_pconfig($channel['channel_id'],'system','use_browser_location'))) ? '1' : ''), - 'default_location' => $channel['channel_location'], - 'nickname' => $channel['channel_address'], - 'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), + 'is_owner' => true, + 'allow_location' => ((intval(get_pconfig($channel['channel_id'],'system','use_browser_location'))) ? '1' : ''), + 'default_location' => $channel['channel_location'], + 'nickname' => $channel['channel_address'], + 'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), - 'acl' => populate_acl($channel_acl), - 'permissions' => $channel_acl, - 'bang' => '', - 'visitor' => true, - 'profile_uid' => local_channel(), - 'return_path' => 'channel/' . $channel['channel_address'], - 'expanded' => true, + 'acl' => populate_acl($channel_acl), + 'permissions' => $channel_acl, + 'bang' => '', + 'visitor' => true, + 'profile_uid' => local_channel(), + 'return_path' => 'channel/' . $channel['channel_address'], + 'expanded' => true, 'editor_autocomplete' => true, - 'bbco_autocomplete' => 'bbcode', - 'bbcode' => true, - 'jotnets' => true + 'bbco_autocomplete' => 'bbcode', + 'bbcode' => true, + 'jotnets' => true ); $o = '
'; @@ -139,10 +149,11 @@ class Display extends \Zotlabs\Web\Controller { $static = ((local_channel()) ? channel_manual_conv_update(local_channel()) : 1); - //if the target item is not a post (eg a like) we want to address its thread parent + // if the target item is not a post (eg a like) we want to address its thread parent + $mid = ((($target_item['verb'] == ACTIVITY_LIKE) || ($target_item['verb'] == ACTIVITY_DISLIKE)) ? $target_item['thr_parent'] : $target_item['mid']); - //if we got a decoded hash we must encode it again before handing to javascript + // if we got a decoded hash we must encode it again before handing to javascript if($decoded) $mid = 'b64.' . base64url_encode($mid); @@ -152,32 +163,32 @@ class Display extends \Zotlabs\Web\Controller { \App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array( '$baseurl' => z_root(), - '$pgtype' => 'display', - '$uid' => '0', - '$gid' => '0', - '$cid' => '0', - '$cmin' => '0', - '$cmax' => '99', - '$star' => '0', - '$liked' => '0', - '$conv' => '0', - '$spam' => '0', - '$fh' => '0', + '$pgtype' => 'display', + '$uid' => '0', + '$gid' => '0', + '$cid' => '0', + '$cmin' => '0', + '$cmax' => '99', + '$star' => '0', + '$liked' => '0', + '$conv' => '0', + '$spam' => '0', + '$fh' => '0', '$nouveau' => '0', - '$wall' => '0', - '$static' => $static, - '$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1), - '$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0), - '$search' => '', - '$xchan' => '', - '$order' => '', - '$file' => '', - '$cats' => '', - '$tags' => '', - '$dend' => '', - '$dbegin' => '', - '$verb' => '', - '$mid' => $mid + '$wall' => '0', + '$static' => $static, + '$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1), + '$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0), + '$search' => '', + '$xchan' => '', + '$order' => '', + '$file' => '', + '$cats' => '', + '$tags' => '', + '$dend' => '', + '$dbegin' => '', + '$verb' => '', + '$mid' => $mid )); head_add_link([ @@ -195,11 +206,11 @@ class Display extends \Zotlabs\Web\Controller { $sql_extra = public_permissions_sql($observer_hash); - if(($update && $load) || ($checkjs->disabled())) { + if(($update && $load) || ($checkjs->disabled()) || ($module_format !== 'html')) { $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']),intval(\App::$pager['start'])); - if($load || ($checkjs->disabled())) { + if($load || ($checkjs->disabled()) || ($module_format !== 'html')) { $r = null; require_once('include/channel.php'); @@ -311,13 +322,61 @@ class Display extends \Zotlabs\Web\Controller { $items = array(); } - if ($checkjs->disabled()) { - $o .= conversation($items, 'display', $update, 'traditional'); - if ($items[0]['title']) - \App::$page['title'] = $items[0]['title'] . " - " . \App::$page['title']; - } - else { - $o .= conversation($items, 'display', $update, 'client'); + + switch($module_format) { + + case 'html': + + if ($checkjs->disabled()) { + $o .= conversation($items, 'display', $update, 'traditional'); + if ($items[0]['title']) + \App::$page['title'] = $items[0]['title'] . " - " . \App::$page['title']; + } + else { + $o .= conversation($items, 'display', $update, 'client'); + } + + break; + + case 'atom': + + $atom = replace_macros(get_markup_template('atom_feed.tpl'), array( + '$version' => xmlify(\Zotlabs\Lib\System::get_project_version()), + '$red' => xmlify(\Zotlabs\Lib\System::get_platform_name()), + '$feed_id' => xmlify(\App::$cmd), + '$feed_title' => xmlify(t('Article')), + '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', 'now', ATOM_TIME)), + '$author' => '', + '$owner' => '', + '$profile_page' => xmlify(z_root() . '/display/' . $target_item['mid']), + )); + + $x = [ 'xml' => $atom, 'channel' => $channel, 'observer_hash' => $observer_hash, 'params' => $params ]; + call_hooks('atom_feed_top',$x); + + $atom = $x['xml']; + + // a much simpler interface + call_hooks('atom_feed', $atom); + + + if($items) { + $type = 'html'; + foreach($items as $item) { + if($item['item_private']) + continue; + $atom .= atom_entry($item, $type, null, '', true, '', false); + } + } + + call_hooks('atom_feed_end', $atom); + + $atom .= '' . "\r\n"; + + header('Content-type: application/atom+xml'); + echo $atom; + killme(); + } if($updateable) { -- cgit v1.2.3 From 52c1f79f2ec2ac4c417e8cca2008565891a5a0f6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 23 Oct 2017 17:52:17 -0700 Subject: acl encoding issues --- 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 84212270f..d0175549b 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -433,7 +433,7 @@ class Notifier { $env_recips = (($private) ? array() : null); - $details = q("select xchan_hash, xchan_instance_url, xchan_network, xchan_addr, xchan_guid, xchan_guid_sig from xchan where xchan_hash in (" . implode(',',$recipients) . ")"); + $details = q("select xchan_hash, xchan_instance_url, xchan_network, xchan_addr, xchan_guid, xchan_guid_sig from xchan where xchan_hash in (" . protect_sprintf(implode(',',$recipients)) . ")"); $recip_list = array(); @@ -500,7 +500,7 @@ class Notifier { // Now we have collected recipients (except for external mentions, FIXME) // Let's reduce this to a set of hubs; checking that the site is not dead. - $r = q("select hubloc.*, site.site_crypto, site.site_flags from hubloc left join site on site_url = hubloc_url where hubloc_hash in (" . implode(',',$recipients) . ") + $r = q("select hubloc.*, site.site_crypto, site.site_flags from hubloc left join site on site_url = hubloc_url where hubloc_hash in (" . protect_sprintf(implode(',',$recipients)) . ") and hubloc_error = 0 and hubloc_deleted = 0 and ( site_dead = 0 OR site_dead is null ) " ); -- cgit v1.2.3 From 2aff3a1a05d7249a69115938c239a91658777e39 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 23 Oct 2017 21:03:18 -0700 Subject: not sure when but the hcard went missing in webfinger --- Zotlabs/Module/Wfinger.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Wfinger.php b/Zotlabs/Module/Wfinger.php index 9db95f181..753721d27 100644 --- a/Zotlabs/Module/Wfinger.php +++ b/Zotlabs/Module/Wfinger.php @@ -164,6 +164,13 @@ class Wfinger extends \Zotlabs\Web\Controller { 'href' => $r[0]['xchan_photo_l'] ], + [ + 'rel' => 'http://microformats.org/profile/hcard', + 'type' => 'text/html', + 'href' => z_root() . '/hcard/' . $r[0]['channel_address'] + ], + + [ 'rel' => 'http://webfinger.net/rel/profile-page', 'href' => z_root() . '/profile/' . $r[0]['channel_address'], -- cgit v1.2.3 From 60a54e9aacaf6833067ea932d56b59c6630d18bc Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 24 Oct 2017 18:21:19 +0200 Subject: comment out statistics link in mod pubsites until we have something functional again --- Zotlabs/Module/Pubsites.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Pubsites.php b/Zotlabs/Module/Pubsites.php index ef02cf099..daec5dde3 100644 --- a/Zotlabs/Module/Pubsites.php +++ b/Zotlabs/Module/Pubsites.php @@ -30,7 +30,7 @@ class Pubsites extends \Zotlabs\Web\Controller { if($ret['success']) { $j = json_decode($ret['body'],true); if($j) { - $o .= ''; + $o .= '
' . t('Hub URL') . '' . t('Access Type') . '' . t('Registration Policy') . '' . t('Stats') . '' . t('Software') . '
'; if($rating_enabled) $o .= ''; $o .= ''; @@ -55,7 +55,7 @@ class Pubsites extends \Zotlabs\Web\Controller { $location = '
 '; } $urltext = str_replace(array('https://'), '', $jj['url']); - $o .= ''; + $o .= ''; if($rating_enabled) $o .= '' . $rate_links ; $o .= ''; -- cgit v1.2.3 From 4a3149d1ba9ad08c4603b727c1e9411eaa1bbde0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 25 Oct 2017 22:33:03 -0700 Subject: hubzilla issue #890, separate the pdl preview feature from the mod_page webpage query so that the webpage will always win if a webpage and pdl have the same name. --- Zotlabs/Module/Page.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Page.php b/Zotlabs/Module/Page.php index c142afe77..d794a43a1 100644 --- a/Zotlabs/Module/Page.php +++ b/Zotlabs/Module/Page.php @@ -89,22 +89,30 @@ class Page extends \Zotlabs\Web\Controller { if(! $ignore_language) { $r = q("select item.* from item left join iconfig on item.id = iconfig.iid where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s' and item.item_delayed = 0 - and (( iconfig.k = 'WEBPAGE' and item_type = %d ) - OR ( iconfig.k = 'PDL' AND item_type = %d )) $sql_options $revision limit 1", + and iconfig.k = 'WEBPAGE' and item_type = %d + $sql_options $revision limit 1", intval($u[0]['channel_id']), dbesc($lang_page_id), - intval(ITEM_TYPE_WEBPAGE), - intval(ITEM_TYPE_PDL) + intval(ITEM_TYPE_WEBPAGE) ); } if(! $r) { $r = q("select item.* from item left join iconfig on item.id = iconfig.iid where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s' and item.item_delayed = 0 - and (( iconfig.k = 'WEBPAGE' and item_type = %d ) + and iconfig.k = 'WEBPAGE' and item_type = %d OR ( iconfig.k = 'PDL' AND item_type = %d )) $sql_options $revision limit 1", intval($u[0]['channel_id']), dbesc($page_id), - intval(ITEM_TYPE_WEBPAGE), + intval(ITEM_TYPE_WEBPAGE) + ); + } + if(! $r) { + // no webpage by that name, but we do allow you to load/preview a layout using this module. Try that. + $r = q("select item.* from item left join iconfig on item.id = iconfig.iid + where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s' and item.item_delayed = 0 + and iconfig.k = 'PDL' AND item_type = %d $sql_options $revision limit 1", + intval($u[0]['channel_id']), + dbesc($page_id), intval(ITEM_TYPE_PDL) ); } @@ -129,7 +137,7 @@ class Page extends \Zotlabs\Web\Controller { } return; } - + if($r[0]['title']) \App::$page['title'] = escape_tags($r[0]['title']); -- cgit v1.2.3 From e5cfb8a0cdef56498aabb75fb52600ae07c4bcbe Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 26 Oct 2017 15:23:04 -0700 Subject: encrypt the owa token --- Zotlabs/Module/Magic.php | 13 ++++++++++--- Zotlabs/Module/Owa.php | 4 +++- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Magic.php b/Zotlabs/Module/Magic.php index 879085f96..9ad9c951c 100644 --- a/Zotlabs/Module/Magic.php +++ b/Zotlabs/Module/Magic.php @@ -146,10 +146,17 @@ class Magic extends \Zotlabs\Web\Controller { if($x['success']) { $j = json_decode($x['body'],true); - if($j['success'] && $j['token']) { - $x = strpbrk($dest,'?&'); - $args = (($x) ? '&owt=' . $j['token'] : '?f=&owt=' . $j['token']) . (($delegate) ? '&delegate=1' : ''); + if($j['success']) { + $token = ''; + if($j['encrypted_token']) { + openssl_private_decrypt(base64url_decode($j['encrypted_token']),$token,$channel['channel_prvkey']); + } + else { + $token = $j['token']; + } + $x = strpbrk($dest,'?&'); + $args = (($x) ? '&owt=' . $token : '?f=&owt=' . $token) . (($delegate) ? '&delegate=1' : ''); goaway($dest . $args); } } diff --git a/Zotlabs/Module/Owa.php b/Zotlabs/Module/Owa.php index 4b0d855c5..d58fd7a41 100644 --- a/Zotlabs/Module/Owa.php +++ b/Zotlabs/Module/Owa.php @@ -41,7 +41,9 @@ class Owa extends \Zotlabs\Web\Controller { $ret['success'] = true; $token = random_string(32); \Zotlabs\Zot\Verify::create('owt',0,$token,$r[0]['hubloc_addr']); - $ret['token'] = $token; + $result = ''; + openssl_public_encrypt($token,$result,$hubloc['xchan_pubkey']); + $ret['encrypted_token'] = base64url_encode($result); } } } -- cgit v1.2.3 From fe2a937cf2e2cc723d930eaae885a4f8bbabe53c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 28 Oct 2017 15:24:37 -0700 Subject: fix "unstar" --- Zotlabs/Module/Starred.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Starred.php b/Zotlabs/Module/Starred.php index 4f1d99ec6..8349ae25c 100644 --- a/Zotlabs/Module/Starred.php +++ b/Zotlabs/Module/Starred.php @@ -16,7 +16,7 @@ class Starred extends \Zotlabs\Web\Controller { if(! $message_id) killme(); - $r = q("SELECT item_flags FROM item WHERE uid = %d AND id = %d LIMIT 1", + $r = q("SELECT item_starred FROM item WHERE uid = %d AND id = %d LIMIT 1", intval(local_channel()), intval($message_id) ); -- cgit v1.2.3 From 1dc3253d4a8bac7c3186c4b5083b612e643d8694 Mon Sep 17 00:00:00 2001 From: Haakon Meland Eriksen Date: Sun, 29 Oct 2017 16:41:49 +0100 Subject: Added mode to Portfolio widget --- Zotlabs/Widget/Portfolio.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Portfolio.php b/Zotlabs/Widget/Portfolio.php index 216ca952c..0cd043246 100644 --- a/Zotlabs/Widget/Portfolio.php +++ b/Zotlabs/Widget/Portfolio.php @@ -20,6 +20,15 @@ class Portfolio { $album = $args['album']; if($args['title']) $title = $args['title']; + if(array_key_exists('mode', $args) && isset($args['mode'])) + $mode = $args['mode']; + else + $mode = ''; + if(array_key_exists('count', $args) && isset($args['count'])) + $count = $args['count']; + else + $count = ''; + /** * This may return incorrect permissions if you have multiple directories of the same name. @@ -92,6 +101,8 @@ class Portfolio { $tpl = get_markup_template('photo_album_portfolio.tpl'); $o .= replace_macros($tpl, array( '$photos' => $photos, + '$mode' => $mode, + '$count' => $count, '$album' => (($title) ? $title : $album), '$album_id' => rand(), '$album_edit' => array(t('Edit Album'), $album_edit), @@ -106,3 +117,4 @@ class Portfolio { } } + -- cgit v1.2.3 From ceed0f7a1b6d7ee713c23937a9449bd84324caf6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 29 Oct 2017 19:52:00 -0700 Subject: allow plugin class widgets, fix sql error in page module --- Zotlabs/Module/Page.php | 2 +- Zotlabs/Render/Comanche.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Page.php b/Zotlabs/Module/Page.php index d794a43a1..5fdd32825 100644 --- a/Zotlabs/Module/Page.php +++ b/Zotlabs/Module/Page.php @@ -100,7 +100,7 @@ class Page extends \Zotlabs\Web\Controller { $r = q("select item.* from item left join iconfig on item.id = iconfig.iid where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s' and item.item_delayed = 0 and iconfig.k = 'WEBPAGE' and item_type = %d - OR ( iconfig.k = 'PDL' AND item_type = %d )) $sql_options $revision limit 1", + $sql_options $revision limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_TYPE_WEBPAGE) diff --git a/Zotlabs/Render/Comanche.php b/Zotlabs/Render/Comanche.php index 8831bd117..78ca870a7 100644 --- a/Zotlabs/Render/Comanche.php +++ b/Zotlabs/Render/Comanche.php @@ -469,8 +469,11 @@ class Comanche { if(file_exists('Zotlabs/SiteWidget/' . $clsname . '.php')) require_once('Zotlabs/SiteWidget/' . $clsname . '.php'); + elseif(file_exists('widget/' . $clsname . '/' . $clsname . '.php')) + require_once('widget/' . $clsname . '/' . $clsname . '.php'); elseif(file_exists('Zotlabs/Widget/' . $clsname . '.php')) require_once('Zotlabs/Widget/' . $clsname . '.php'); + if(class_exists($nsname)) { $x = new $nsname; $f = 'widget'; -- cgit v1.2.3 From 71e0e55b0b5bc1746cb481056b027e76c1821ef7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 30 Oct 2017 18:49:18 -0700 Subject: provide a 'tile' view (view only) mode to mod_cloud --- Zotlabs/Module/Cloud_tiles.php | 17 +++++++++++++++++ Zotlabs/Storage/Browser.php | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 Zotlabs/Module/Cloud_tiles.php (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Cloud_tiles.php b/Zotlabs/Module/Cloud_tiles.php new file mode 100644 index 000000000..45124cdfa --- /dev/null +++ b/Zotlabs/Module/Cloud_tiles.php @@ -0,0 +1,17 @@ +escapeHTML($displayName); $type = $this->escapeHTML($type); + $icon = ''; if ($this->enableAssets) { @@ -196,12 +197,28 @@ class Browser extends DAV\Browser\Plugin { } } + $photo_icon = ''; + + if(strpos($type,'image/') === 0 && $attachHash) { + $r = q("select resource_id, imgscale from photo where resource_id = '%s' and imgscale in ( %d, %d ) order by imgscale asc limit 1", + dbesc($attachHash), + intval(PHOTO_RES_320), + intval(PHOTO_RES_PROFILE_80) + ); + if($r) { + $photo_icon = $r[0]['resource_id'] . '-' . $r[0]['imgscale']; + } + } + + + $attachIcon = ""; // ""; // put the array for this file together $ft['attachId'] = $this->findAttachIdByHash($attachHash); $ft['fileStorageUrl'] = substr($fullPath, 0, strpos($fullPath, "cloud/")) . "filestorage/" . $this->auth->getCurrentUser(); $ft['icon'] = $icon; + $ft['photo_icon'] = $photo_icon; $ft['attachIcon'] = (($size) ? $attachIcon : ''); // @todo Should this be an item value, not a global one? $ft['is_owner'] = $is_owner; @@ -221,6 +238,7 @@ class Browser extends DAV\Browser\Plugin { $this->server->emit('onHTMLActionsPanel', array($parent, &$output, $path)); } + $html .= replace_macros(get_markup_template('cloud.tpl'), array( '$header' => t('Files') . ": " . $this->escapeHTML($path) . "/", '$total' => t('Total'), @@ -230,6 +248,8 @@ class Browser extends DAV\Browser\Plugin { '$upload' => t('Upload'), '$is_owner' => $is_owner, '$parentpath' => $parentpath, + '$cpath' => bin2hex(\App::$query_string), + '$tiles' => intval($_SESSION['cloud_tiles']), '$entries' => $f, '$name' => t('Name'), '$type' => t('Type'), -- cgit v1.2.3 From 6efef3922b9fe6864c0855e6407b77ca54af70c5 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 31 Oct 2017 15:41:44 -0700 Subject: add another delivery control parameter (force queue threshold) --- Zotlabs/Module/Admin/Site.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php index d3d058c53..2df8b9908 100644 --- a/Zotlabs/Module/Admin/Site.php +++ b/Zotlabs/Module/Admin/Site.php @@ -61,8 +61,9 @@ class Site { $maxloadavg = ((x($_POST,'maxloadavg')) ? intval(trim($_POST['maxloadavg'])) : 50); $feed_contacts = ((x($_POST,'feed_contacts')) ? intval($_POST['feed_contacts']) : 0); $verify_email = ((x($_POST,'verify_email')) ? 1 : 0); - $techlevel_lock = ((x($_POST,'techlock')) ? intval($_POST['techlock']) : 0); - $imagick_path = ((x($_POST,'imagick_path')) ? trim($_POST['imagick_path']) : ''); + $techlevel_lock = ((x($_POST,'techlock')) ? intval($_POST['techlock']) : 0); + $imagick_path = ((x($_POST,'imagick_path')) ? trim($_POST['imagick_path']) : ''); + $force_queue = ((intval($_POST['force_queue']) > 0) ? intval($_POST['force_queue']) : 300); $techlevel = null; if(array_key_exists('techlevel', $_POST)) @@ -128,6 +129,7 @@ class Site { set_config('system','allowed_sites', $allowed_sites); set_config('system','publish_all', $force_publish); set_config('system','disable_discover_tab', $disable_discover_tab); + set_config('system','force_queue_threshold', $force_queue); if ($global_directory == '') { del_config('system', 'directory_submit_url'); } else { @@ -318,6 +320,7 @@ class Site { '$timeout' => array('timeout', t("Network timeout"), (x(get_config('system','curl_timeout'))?get_config('system','curl_timeout'):60), t("Value is in seconds. Set to 0 for unlimited (not recommended).")), '$delivery_interval' => array('delivery_interval', t("Delivery interval"), (x(get_config('system','delivery_interval'))?get_config('system','delivery_interval'):2), t("Delay background delivery processes by this many seconds to reduce system load. Recommend: 4-5 for shared hosts, 2-3 for virtual private servers. 0-1 for large dedicated servers.")), '$delivery_batch_count' => array('delivery_batch_count', t('Deliveries per process'),(x(get_config('system','delivery_batch_count'))?get_config('system','delivery_batch_count'):1), t("Number of deliveries to attempt in a single operating system process. Adjust if necessary to tune system performance. Recommend: 1-5.")), + '$force_queue' => array('force_queue', t("Queue Threshold"), get_config('system','force_queue_threshold',300), t("Always defer immediate delivery if queue contains more than this number of entries.")), '$poll_interval' => array('poll_interval', t("Poll interval"), (x(get_config('system','poll_interval'))?get_config('system','poll_interval'):2), t("Delay background polling processes by this many seconds to reduce system load. If 0, use delivery interval.")), '$imagick_path' => array('imagick_path', t("Path to ImageMagick convert program"), get_config('system','imagick_convert_path'), t("If set, use this program to generate photo thumbnails for huge images ( > 4000 pixels in either dimension), otherwise memory exhaustion may occur. Example: /usr/bin/convert")), '$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")), -- cgit v1.2.3 From bff1e215cce27706fabe9f1764bce5c5a5b3b434 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 31 Oct 2017 18:04:01 -0700 Subject: pdledit - show original/system layout text for comparison --- Zotlabs/Module/Pdledit.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Pdledit.php b/Zotlabs/Module/Pdledit.php index f8af470ac..9b86b599b 100644 --- a/Zotlabs/Module/Pdledit.php +++ b/Zotlabs/Module/Pdledit.php @@ -77,8 +77,10 @@ class Pdledit extends \Zotlabs\Web\Controller { } $t = get_pconfig(local_channel(),'system',$module); - if(! $t) - $t = file_get_contents(theme_include($module)); + $s = file_get_contents(theme_include($module)); + if(! $t) { + $t = $s; + } if(! $t) { notice( t('Layout not found.') . EOL); return ''; @@ -89,7 +91,9 @@ class Pdledit extends \Zotlabs\Web\Controller { '$mname' => t('Module Name:'), '$help' => t('Layout Help'), '$another' => t('Edit another layout'), + '$original' => t('System layout'), '$module' => argv(1), + '$src' => $s, '$content' => htmlspecialchars($t,ENT_COMPAT,'UTF-8'), '$submit' => t('Submit') )); -- cgit v1.2.3 From 98b53801e062f1fe1b5ae16c6e30635b21ebef91 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 31 Oct 2017 19:56:14 -0700 Subject: provide personal config for channel_menu; the site can set an initial site-wide value but this but there isn't a corresponding admin setting currently and can only be set by manual config --- Zotlabs/Module/Settings/Display.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Settings/Display.php b/Zotlabs/Module/Settings/Display.php index a444d28a2..e1ea0e3e5 100644 --- a/Zotlabs/Module/Settings/Display.php +++ b/Zotlabs/Module/Settings/Display.php @@ -23,6 +23,7 @@ class Display { $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); $nosmile = ((x($_POST,'nosmile')) ? intval($_POST['nosmile']) : 0); $title_tosource = ((x($_POST,'title_tosource')) ? intval($_POST['title_tosource']) : 0); @@ -63,6 +64,7 @@ class Display { set_pconfig(local_channel(),'system','channel_divmore_height', $channel_divmore_height); set_pconfig(local_channel(),'system','network_divmore_height', $network_divmore_height); set_pconfig(local_channel(),'system','manual_conversation_update', $manual_update); + set_pconfig(local_channel(),'system','channel_menu', $channel_menu); $newschema = ''; if($theme){ @@ -217,6 +219,7 @@ class Display { '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')), '$itemspage' => array('itemspage', t("Maximum number of conversations to load at any time:"), $itemspage, t('Maximum of 100 items')), '$nosmile' => array('nosmile', t("Show emoticons (smilies) as images"), 1-intval($nosmile), '', $yes_no), + '$channel_menu' => [ 'channel_menu', t('Provide channel menu in navigation bar'), get_pconfig(local_channel(),'system','channel_menu',get_config('system','channel_menu',0)), t('Default: channel menu located in app menu'),$yes_no ], '$manual_update' => array('manual_update', t('Manual conversation updates'), channel_manual_conv_update(local_channel()), t('Default is on, turning this off may increase screen jumping'), $yes_no), '$title_tosource' => array('title_tosource', t("Link post titles to source"), $title_tosource, '', $yes_no), '$layout_editor' => t('System Page Layout Editor - (advanced)'), -- cgit v1.2.3 From 7d9d1e0cdb21e47aec20b64148a0714323383914 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 1 Nov 2017 02:15:40 -0700 Subject: Maria's profile photo issue, please push to master. --- Zotlabs/Module/Profile_photo.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Profile_photo.php b/Zotlabs/Module/Profile_photo.php index 27e6bc445..411518c61 100644 --- a/Zotlabs/Module/Profile_photo.php +++ b/Zotlabs/Module/Profile_photo.php @@ -150,6 +150,14 @@ class Profile_photo extends \Zotlabs\Web\Controller { // If setting for the default profile, unset the profile photo flag from any other photos I own if($is_default_profile) { + + $r = q("update profile set photo = '%s', thumb = '%s' where is_default = 1 and uid = %d", + dbesc(z_root() . '/photo/profile/l/' . local_channel()), + dbesc(z_root() . '/photo/profile/m/' . local_channel()), + intval(local_channel()) + ); + + $r = q("UPDATE photo SET photo_usage = %d WHERE photo_usage = %d AND resource_id != '%s' AND uid = %d", intval(PHOTO_NORMAL), @@ -159,8 +167,6 @@ class Profile_photo extends \Zotlabs\Web\Controller { ); - - send_profile_photo_activity($channel,$base_image,$profile); } -- cgit v1.2.3 From 22d45a8d1ecfa0a0a2b8429ec3233e7099e84b66 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 1 Nov 2017 02:53:12 -0700 Subject: support for netselect query --- Zotlabs/Module/Channel.php | 1 + Zotlabs/Module/Display.php | 1 + Zotlabs/Module/Network.php | 16 +++++++++++++--- Zotlabs/Module/Pubstream.php | 20 +++++++++++++++----- Zotlabs/Module/Search.php | 1 + 5 files changed, 31 insertions(+), 8 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 14d02d873..7c4c900a1 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -332,6 +332,7 @@ class Channel extends \Zotlabs\Web\Controller { '$tags' => (($hashtags) ? urlencode($hashtags) : ''), '$mid' => $mid, '$verb' => '', + '$net' => '', '$dend' => $datequery, '$dbegin' => $datequery2 )); diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 785274105..85f08fd08 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -188,6 +188,7 @@ class Display extends \Zotlabs\Web\Controller { '$dend' => '', '$dbegin' => '', '$verb' => '', + '$net' => '', '$mid' => $mid )); diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index ee736ff42..66032aada 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -119,6 +119,7 @@ class Network extends \Zotlabs\Web\Controller { $cmax = ((x($_GET,'cmax')) ? intval($_GET['cmax']) : 99); $file = ((x($_GET,'file')) ? $_GET['file'] : ''); $xchan = ((x($_GET,'xchan')) ? $_GET['xchan'] : ''); + $net = ((x($_GET,'net')) ? $_GET['net'] : ''); $deftag = ''; @@ -326,7 +327,8 @@ class Network extends \Zotlabs\Web\Controller { '$tags' => urlencode($hashtags), '$dend' => $datequery, '$mid' => '', - '$verb' => $verb, + '$verb' => $verb, + '$net' => $net, '$dbegin' => $datequery2 )); } @@ -404,7 +406,10 @@ class Network 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 = " . local_channel() . " "; $uids = " and item.uid = " . local_channel() . " "; @@ -441,10 +446,12 @@ class Network extends \Zotlabs\Web\Controller { $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 and (abook.abook_blocked = 0 or abook.abook_flags is null) $simple_update $sql_extra $sql_nets + $net_query2 ORDER BY item.received DESC $pager_sql " ); @@ -469,10 +476,12 @@ class Network extends \Zotlabs\Web\Controller { $r = q("SELECT distinct item.id AS item_id, $ordering 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 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 " ); @@ -482,9 +491,10 @@ class Network extends \Zotlabs\Web\Controller { // this is an update $r = q("SELECT item.parent AS item_id FROM item left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) + $net_query WHERE true $uids $item_normal_update $simple_update and (abook.abook_blocked = 0 or abook.abook_flags is null) - $sql_extra3 $sql_extra $sql_nets " + $sql_extra3 $sql_extra $sql_nets $net_query2" ); $_SESSION['loadtime'] = datetime_convert(); } diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 15e2d8a74..e83de6bc0 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -31,6 +31,7 @@ class Pubstream extends \Zotlabs\Web\Controller { $item_normal_update = item_normal_update(); $static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0); + $net = ((array_key_exists('net',$_REQUEST)) ? escape_tags($_REQUEST['net']) : ''); if(! $update && !$load) { @@ -81,7 +82,8 @@ class Pubstream extends \Zotlabs\Web\Controller { '$tags' => '', '$dend' => '', '$mid' => $mid, - '$verb' => '', + '$verb' => '', + '$net' => $net, '$dbegin' => '' )); } @@ -112,6 +114,10 @@ class Pubstream extends \Zotlabs\Web\Controller { $page_mode = 'list'; else $page_mode = 'client'; + + + $net_query = (($net) ? " left join xchan on xchan_hash = author_xchan " : ''); + $net_query2 = (($net) ? " and xchan_network = '" . protect_sprintf(dbesc($net)) . "' " : ''); $simple_update = (($update) ? " and item.item_unseen = 1 " : ''); @@ -134,9 +140,10 @@ class Pubstream extends \Zotlabs\Web\Controller { if($mid) { $r = q("SELECT parent AS item_id FROM item 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) - $sql_extra3 $sql_extra $sql_nets LIMIT 1", + $sql_extra3 $sql_extra $sql_nets $net_query2 LIMIT 1", dbesc($mid . '%') ); } @@ -144,10 +151,11 @@ class Pubstream extends \Zotlabs\Web\Controller { // Fetch a page full of parent items for this page $r = q("SELECT distinct item.id AS item_id, $ordering FROM item left join abook on item.author_xchan = abook.abook_xchan + $net_query WHERE true $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 + $sql_extra3 $sql_extra $sql_nets $net_query2 ORDER BY $ordering DESC $pager_sql " ); } @@ -156,19 +164,21 @@ class Pubstream extends \Zotlabs\Web\Controller { if($mid) { $r = q("SELECT parent AS item_id FROM item left join abook on item.author_xchan = abook.abook_xchan + $net_query WHERE mid like '%s' $uids $item_normal_update $simple_update and (abook.abook_blocked = 0 or abook.abook_flags is null) - $sql_extra3 $sql_extra $sql_nets LIMIT 1", + $sql_extra3 $sql_extra $sql_nets $net_query2 LIMIT 1", dbesc($mid . '%') ); } else { $r = q("SELECT distinct item.id AS item_id, $ordering FROM item left join abook on item.author_xchan = abook.abook_xchan + $net_query WHERE true $uids $item_normal_update AND item.parent = item.id $simple_update and (abook.abook_blocked = 0 or abook.abook_flags is null) - $sql_extra3 $sql_extra $sql_nets" + $sql_extra3 $sql_extra $sql_nets $net_query2" ); } $_SESSION['loadtime'] = datetime_convert(); diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 37e9a336f..7bc3429b1 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -138,6 +138,7 @@ class Search extends \Zotlabs\Web\Controller { '$tags' => '', '$mid' => '', '$verb' => '', + '$net' => '', '$dend' => '', '$dbegin' => '' )); -- cgit v1.2.3 From cdaf5f3fc0756157863008df185f6b344241c147 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 2 Nov 2017 08:44:46 +0100 Subject: fix issues with diaspora xchans --- Zotlabs/Module/Mail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index 12f3b8152..b58b169d0 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -19,7 +19,7 @@ class Mail extends \Zotlabs\Web\Controller { $replyto = ((x($_REQUEST,'replyto')) ? notags(trim($_REQUEST['replyto'])) : ''); $subject = ((x($_REQUEST,'subject')) ? notags(trim($_REQUEST['subject'])) : ''); $body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : ''); - $recipient = ((x($_REQUEST,'messageto')) ? notags(trim($_REQUEST['messageto'])) : ''); + $recipient = ((x($_REQUEST,'messageto')) ? notags(trim(urldecode($_REQUEST['messageto']))) : ''); $rstr = ((x($_REQUEST,'messagerecip')) ? notags(trim($_REQUEST['messagerecip'])) : ''); $preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0); $expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE); @@ -124,7 +124,7 @@ class Mail extends \Zotlabs\Web\Controller { // We have a local_channel, let send_message use the session channel and save a lookup $ret = send_message(0, $recipient, $body, $subject, $replyto, $expires, $mimetype, $raw); - + if($ret['success']) { xchan_mail_query($ret['mail']); build_sync_packet(0,array('conv' => array($ret['conv']),'mail' => array(encode_mail($ret['mail'],true)))); -- cgit v1.2.3 From 1b290f573acdd4f003b6ffcce6c0705ea461bd9d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 2 Nov 2017 03:13:30 -0700 Subject: put deferred queue logic every place we create a delivery process (except for protocol 'friend requests' which aren't likely to swamp the delivery system). Remove it from the queue_delivery function which was too late to do anything. --- Zotlabs/Daemon/Ratenotif.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Ratenotif.php b/Zotlabs/Daemon/Ratenotif.php index a94b89004..c7bf79854 100644 --- a/Zotlabs/Daemon/Ratenotif.php +++ b/Zotlabs/Daemon/Ratenotif.php @@ -88,6 +88,14 @@ class Ratenotif { 'msg' => json_encode($encoded_item) )); + + $x = q("select count(outq_hash) as total from outq where outq_delivered = 0"); + if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',300))) { + logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO); + update_queue_item($hash); + continue; + } + $deliver[] = $hash; if(count($deliver) >= $deliveries_per_process) { -- cgit v1.2.3 From 0d7062ffdf018287c14f09666cc0e0f82997ccca Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 2 Nov 2017 15:43:14 -0700 Subject: more queue work --- Zotlabs/Daemon/Queue.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Queue.php b/Zotlabs/Daemon/Queue.php index 11cbe4494..17d150250 100644 --- a/Zotlabs/Daemon/Queue.php +++ b/Zotlabs/Daemon/Queue.php @@ -12,6 +12,7 @@ class Queue { require_once('include/items.php'); require_once('include/bbcode.php'); + if(argc() > 1) $queue_id = argv(1); else -- cgit v1.2.3 From e70bd0054c4ffb8aadeec8ee7c14dccdb34ab934 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 2 Nov 2017 18:25:34 -0700 Subject: hubzilla issue #896 --- Zotlabs/Module/Pubstream.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index e83de6bc0..4224fa3c8 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -2,6 +2,7 @@ namespace Zotlabs\Module; require_once('include/conversation.php'); +require_once('include/acl_selectors.php'); class Pubstream extends \Zotlabs\Web\Controller { @@ -33,6 +34,47 @@ class Pubstream extends \Zotlabs\Web\Controller { $static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0); $net = ((array_key_exists('net',$_REQUEST)) ? escape_tags($_REQUEST['net']) : ''); + + if(local_channel() && (! $update)) { + + $channel = \App::get_channel(); + + $channel_acl = array( + 'allow_cid' => $channel['channel_allow_cid'], + 'allow_gid' => $channel['channel_allow_gid'], + 'deny_cid' => $channel['channel_deny_cid'], + 'deny_gid' => $channel['channel_deny_gid'] + ); + + $x = array( + 'is_owner' => true, + 'allow_location' => ((intval(get_pconfig($channel['channel_id'],'system','use_browser_location'))) ? '1' : ''), + 'default_location' => $channel['channel_location'], + 'nickname' => $channel['channel_address'], + 'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), + + 'acl' => populate_acl($channel_acl), + 'permissions' => $channel_acl, + 'bang' => '', + 'visitor' => true, + 'profile_uid' => local_channel(), + 'return_path' => 'channel/' . $channel['channel_address'], + 'expanded' => true, + 'editor_autocomplete' => true, + 'bbco_autocomplete' => 'bbcode', + 'bbcode' => true, + 'jotnets' => true + ); + + $o = '
'; + $o .= status_editor($a,$x); + $o .= '
'; + } + + + + + if(! $update && !$load) { -- cgit v1.2.3 From 1567b7b383c56eec5998450a3b709963d5026570 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 3 Nov 2017 10:04:25 +0100 Subject: set $module_format to html to not break updates. it will be set to something else later if appropriate --- Zotlabs/Module/Display.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 85f08fd08..266a5b6bf 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -12,6 +12,8 @@ class Display extends \Zotlabs\Web\Controller { function get($update = 0, $load = false) { + $module_format = 'html'; + if(argc() > 1) { $module_format = substr(argv(1),strrpos(argv(1),'.') + 1); if(! in_array($module_format,['atom','zot','json'])) -- cgit v1.2.3 From 0ce7358f0f00cb000562dc34be13459eb5779c18 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 3 Nov 2017 13:49:58 +0100 Subject: update item_normal() to not include ACTIVITY_OBJ_FILE obj_type --- Zotlabs/Module/Network.php | 3 +-- Zotlabs/Module/Ping.php | 14 ++++---------- 2 files changed, 5 insertions(+), 12 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 66032aada..4deb7c9e8 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -533,13 +533,12 @@ class Network extends \Zotlabs\Web\Controller { if($parents_str) { $update_unseen = " AND ( id IN ( " . dbesc($parents_str) . " )"; - $update_unseen .= " AND obj_type != '" . dbesc(ACTIVITY_OBJ_FILE) . "'"; $update_unseen .= " OR ( parent IN ( " . dbesc($parents_str) . " ) AND verb in ( '" . dbesc(ACTIVITY_LIKE) . "','" . dbesc(ACTIVITY_DISLIKE) . "' ))) "; } } else { if($parents_str) { - $update_unseen = " AND parent IN ( " . dbesc($parents_str) . " ) AND obj_type != '" . dbesc(ACTIVITY_OBJ_FILE) . "'"; + $update_unseen = " AND parent IN ( " . dbesc($parents_str) . " )"; } } } diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index c91659f2f..5e2d04c1f 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -169,15 +169,13 @@ class Ping extends \Zotlabs\Web\Controller { $r = q("SELECT * 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 ORDER BY created DESC LIMIT 300", intval($sys['channel_id']), - dbesc(get_observer_hash()), - dbesc(ACTIVITY_OBJ_FILE) + dbesc(get_observer_hash()) ); if($r) { @@ -313,11 +311,9 @@ class Ping extends \Zotlabs\Web\Controller { $r = q("SELECT * FROM item WHERE item_unseen = 1 and uid = %d $item_normal AND author_xchan != '%s' - AND obj_type != '%s' ORDER BY created DESC limit 300", intval(local_channel()), - dbesc($ob_hash), - dbesc(ACTIVITY_OBJ_FILE) + dbesc($ob_hash) ); if($r) { @@ -487,11 +483,9 @@ class Ping extends \Zotlabs\Web\Controller { $r = q("SELECT id, item_wall FROM item WHERE item_unseen = 1 and uid = %d $item_normal - AND author_xchan != '%s' - AND obj_type != '%s'", + AND author_xchan != '%s'", intval(local_channel()), - dbesc($ob_hash), - dbesc(ACTIVITY_OBJ_FILE) + dbesc($ob_hash) ); if($r) { -- cgit v1.2.3 From 1159dd59edc40b753b9f4fe55165b4ee3c22285d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 3 Nov 2017 14:07:00 -0700 Subject: fix cloud redirects with owt tokens --- Zotlabs/Module/Cloud.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Cloud.php b/Zotlabs/Module/Cloud.php index 75191a279..d2264092b 100644 --- a/Zotlabs/Module/Cloud.php +++ b/Zotlabs/Module/Cloud.php @@ -57,12 +57,21 @@ class Cloud extends \Zotlabs\Web\Controller { $auth->observer = $ob_hash; } + // if we arrived at this path with any query parameters in the url, build a clean url without + // them and redirect. + // @fixme if the filename has an ampersand in it AND there are query parameters, + // this may not do the right thing. + + if((strpos($_SERVER['QUERY_STRING'],'?') !== false) || (strpos($_SERVER['QUERY_STRING'],'&') !== false && strpos($_SERVER['QUERY_STRING'],'&') === false)) { + $path = z_root(); + if(argc()) { + foreach(\App::$argv as $a) { + $path .= '/' . $a; + } + } + goaway($path); + } - $_SERVER['QUERY_STRING'] = str_replace(array('?f=', '&f='), array('', ''), $_SERVER['QUERY_STRING']); - $_SERVER['QUERY_STRING'] = strip_zids($_SERVER['QUERY_STRING']); - - $_SERVER['REQUEST_URI'] = str_replace(array('?f=', '&f='), array('', ''), $_SERVER['REQUEST_URI']); - $_SERVER['REQUEST_URI'] = strip_zids($_SERVER['REQUEST_URI']); $rootDirectory = new \Zotlabs\Storage\Directory('/', $auth); -- cgit v1.2.3 From 1a737be2b408135177a9e94dcffd0f68c0aca90b Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Tue, 5 Sep 2017 00:23:42 +0200 Subject: :bulb: Improving Doxygen documentation. Fix some Doxygen parsing errors. Improve hooks documentation. --- Zotlabs/Access/PermissionRoles.php | 128 ++++++++++++++------------ Zotlabs/Access/Permissions.php | 33 ++++--- Zotlabs/Extend/Hook.php | 18 ++-- Zotlabs/Lib/ActivityStreams.php | 124 +++++++++++++++++++------ Zotlabs/Lib/Chatroom.php | 40 +++++---- Zotlabs/Lib/Config.php | 29 +++--- Zotlabs/Lib/PConfig.php | 46 +++++----- Zotlabs/Lib/SConfig.php | 7 +- Zotlabs/Lib/XConfig.php | 33 +++++-- Zotlabs/Render/Comanche.php | 179 ++++++++++++++++++++++++------------- Zotlabs/Web/Router.php | 40 +++++---- Zotlabs/Zot/Verify.php | 13 ++- 12 files changed, 451 insertions(+), 239 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Access/PermissionRoles.php b/Zotlabs/Access/PermissionRoles.php index 49d478c5c..b335bf825 100644 --- a/Zotlabs/Access/PermissionRoles.php +++ b/Zotlabs/Access/PermissionRoles.php @@ -1,12 +1,21 @@ [ - 'social' => t('Social - Mostly Public'), - 'social_restricted' => t('Social - Restricted'), + 'social' => t('Social - Mostly Public'), + 'social_restricted' => t('Social - Restricted'), 'social_private' => t('Social - Private') ], t('Community Forum') => [ - 'forum' => t('Forum - Mostly Public'), - 'forum_restricted' => t('Forum - Restricted'), + 'forum' => t('Forum - Mostly Public'), + 'forum_restricted' => t('Forum - Restricted'), 'forum_private' => t('Forum - Private') ], t('Feed Republish') => [ - 'feed' => t('Feed - Mostly Public'), + 'feed' => t('Feed - Mostly Public'), 'feed_restricted' => t('Feed - Restricted') ], t('Special Purpose') => [ - 'soapbox' => t('Special - Celebrity/Soapbox'), + 'soapbox' => t('Special - Celebrity/Soapbox'), 'repository' => t('Special - Group Repository') ], t('Other') => [ 'custom' => t('Custom/Expert Mode') ] - ]; - return $roles; + return $roles; } } \ No newline at end of file diff --git a/Zotlabs/Access/Permissions.php b/Zotlabs/Access/Permissions.php index 62c4af0ff..20ce21238 100644 --- a/Zotlabs/Access/Permissions.php +++ b/Zotlabs/Access/Permissions.php @@ -33,19 +33,22 @@ use Zotlabs\Lib as Zlib; */ class Permissions { + /** + * @brief Permissions version. + * + * This must match the version in PermissionRoles.php before permission updates can run. + * + * @return number + */ static public function version() { - // This must match the version in PermissionRoles.php before permission updates can run. return 2; } /** * @brief Return an array with Permissions. * - * @hooks permissions_list - * * \e array \b permissions - * * \e string \b filter - * @param string $filter (optional) only passed to hook permission_list - * @return Associative array with permissions and short description. + * @param string $filter (optional) only passed to hook permissions_list + * @return array Associative array with permissions and short description. */ static public function Perms($filter = '') { @@ -74,6 +77,11 @@ class Permissions { 'permissions' => $perms, 'filter' => $filter ]; + /** + * @hooks permissions_list + * * \e array \b permissions + * * \e string \b filter + */ call_hooks('permissions_list', $x); return($x['permissions']); @@ -84,9 +92,7 @@ class Permissions { * * e.g. you must be authenticated. * - * @hooks write_perms - * * \e array \b permissions - * @return Associative array with permissions and short description. + * @return array Associative array with permissions and short description. */ static public function BlockedAnonPerms() { @@ -99,6 +105,10 @@ class Permissions { } $x = ['permissions' => $res]; + /** + * @hooks write_perms + * * \e array \b permissions + */ call_hooks('write_perms', $x); return($x['permissions']); @@ -138,7 +148,7 @@ class Permissions { * to [ 0 => ['name' => 'view_stream', 'value' => 1], ... ] * * @param array $arr associative perms array 'view_stream' => 1 - * @return Indexed array with elements that look like + * @return array Indexed array with elements that look like * * \e string \b name the perm name (e.g. view_stream) * * \e int \b value the value of the perm (e.g. 1) */ @@ -197,11 +207,10 @@ class Permissions { * @brief * * @param int $channel_id A channel id - * @return associative array + * @return array Associative array with * * \e array \b perms Permission array * * \e int \b automatic 0 or 1 */ - static public function connect_perms($channel_id) { $my_perms = []; diff --git a/Zotlabs/Extend/Hook.php b/Zotlabs/Extend/Hook.php index c6f9ea850..81260ead6 100644 --- a/Zotlabs/Extend/Hook.php +++ b/Zotlabs/Extend/Hook.php @@ -2,7 +2,12 @@ namespace Zotlabs\Extend; +use App; +/** + * @brief Hook class. + * + */ class Hook { static public function register($hook,$file,$function,$version = 1,$priority = 0) { @@ -64,11 +69,14 @@ class Hook { return $r; } - // unregister all hooks with this file component. - // Useful for addon upgrades where you want to clean out old interfaces. - + /** + * @brief Unregister all hooks with this file component. + * + * Useful for addon upgrades where you want to clean out old interfaces. + * + * @param string $file + */ static public function unregister_by_file($file) { - $r = q("DELETE FROM hook WHERE file = '%s' ", dbesc($file) ); @@ -76,7 +84,6 @@ class Hook { return $r; } - /** * @brief Inserts a hook into a page request. * @@ -98,7 +105,6 @@ class Hook { * @param int $priority * currently not implemented in this function, would require the hook array to be resorted */ - static public function insert($hook, $fn, $version = 0, $priority = 0) { if(is_array($fn)) { $fn = serialize($fn); diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 379e78a59..2e9bb0703 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -2,6 +2,11 @@ namespace Zotlabs\Lib; +/** + * @brief ActivityStreams class. + * + * Parses an ActivityStream JSON string. + */ class ActivityStreams { public $data; @@ -19,9 +24,16 @@ class ActivityStreams { public $recips = null; public $raw_recips = null; + /** + * @brief Constructor for ActivityStreams. + * + * Takes a JSON string as parameter, decodes it and sets up this object. + * + * @param string $string + */ function __construct($string) { - $this->data = json_decode($string,true); + $this->data = json_decode($string, true); if($this->data) { $this->valid = true; } @@ -50,6 +62,11 @@ class ActivityStreams { } } + /** + * @brief Return if instantiated ActivityStream is valid. + * + * @return boolean Return true if the JSON string could be decoded. + */ function is_valid() { return $this->valid; } @@ -58,18 +75,26 @@ class ActivityStreams { $this->saved_recips = $arr; } - function collect_recips($base = '',$namespace = '') { + /** + * @brief Collects all recipients. + * + * @param string $base + * @param string $namespace (optional) default empty + * @return array + */ + function collect_recips($base = '', $namespace = '') { $x = []; - $fields = [ 'to','cc','bto','bcc','audience']; + $fields = [ 'to', 'cc', 'bto', 'bcc', 'audience']; foreach($fields as $f) { - $y = $this->get_compound_property($f,$base,$namespace); + $y = $this->get_compound_property($f, $base, $namespace); if($y) { - $x = array_merge($x,$y); + $x = array_merge($x, $y); if(! is_array($this->raw_recips)) $this->raw_recips = []; + $this->raw_recips[$f] = $x; } - } + } // not yet ready for prime time // $x = $this->expand($x,$base,$namespace); return $x; @@ -96,23 +121,30 @@ class ActivityStreams { } } - // @fixme de-duplicate + /// @fixme de-duplicate return $ret; } - function get_namespace($base,$namespace) { + /** + * @brief + * + * @param array $base + * @param string $namespace if not set return empty string + * @return string|NULL + */ + function get_namespace($base, $namespace) { if(! $namespace) return ''; $key = null; - foreach( [ $this->data, $base ] as $b ) { if(! $b) continue; - if(array_key_exists('@context',$b)) { + + if(array_key_exists('@context', $b)) { if(is_array($b['@context'])) { foreach($b['@context'] as $ns) { if(is_array($ns)) { @@ -135,19 +167,35 @@ class ActivityStreams { } } } + return $key; } - - function get_property_obj($property,$base = '',$namespace = '' ) { - $prefix = $this->get_namespace($base,$namespace); + /** + * @brief + * + * @param string $property + * @param array $base (optional) + * @param string $namespace (optional) default empty + * @return NULL|mixed + */ + function get_property_obj($property, $base = '', $namespace = '') { + $prefix = $this->get_namespace($base, $namespace); if($prefix === null) - return null; + return null; + $base = (($base) ? $base : $this->data); $propname = (($prefix) ? $prefix . ':' : '') . $property; - return ((array_key_exists($propname,$base)) ? $base[$propname] : null); + + return ((array_key_exists($propname, $base)) ? $base[$propname] : null); } + /** + * @brief Fetches a property from an URL. + * + * @param string $url + * @return NULL|mixed + */ function fetch_property($url) { $redirects = 0; if(! check_siteallowed($url)) { @@ -155,44 +203,70 @@ class ActivityStreams { return null; } - $x = z_fetch_url($url,true,$redirects, + $x = z_fetch_url($url, true, $redirects, ['headers' => [ 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams", application/activity+json' ]]); if($x['success']) - return json_decode($x['body'],true); + return json_decode($x['body'], true); + return null; } - function get_compound_property($property,$base = '',$namespace = '') { - $x = $this->get_property_obj($property,$base,$namespace); + /** + * @brief + * + * @param string $property + * @param array $base + * @param string $namespace (optional) default empty + * @return NULL|mixed + */ + function get_compound_property($property, $base = '', $namespace = '') { + $x = $this->get_property_obj($property, $base, $namespace); if($this->is_url($x)) { - $x = $this->fetch_property($x); + $x = $this->fetch_property($x); } + return $x; } + /** + * @brief Check if string starts with http. + * + * @param string $url + * @return boolean + */ function is_url($url) { - if(($url) && (! is_array($url)) && (strpos($url,'http') === 0)) { + if(($url) && (! is_array($url)) && (strpos($url, 'http') === 0)) { return true; } + return false; } - function get_primary_type($base = '',$namespace = '') { + /** + * @brief Gets the type property. + * + * @param array $base + * @param string $namespace (optional) default empty + * @return NULL|mixed + */ + function get_primary_type($base = '', $namespace = '') { if(! $base) $base = $this->data; - $x = $this->get_property_obj('type',$base,$namespace); + + $x = $this->get_property_obj('type', $base, $namespace); if(is_array($x)) { foreach($x as $y) { - if(strpos($y,':') === false) { + if(strpos($y, ':') === false) { return $y; } } } + return $x; } function debug() { - $x = var_export($this,true); + $x = var_export($this, true); return $x; } diff --git a/Zotlabs/Lib/Chatroom.php b/Zotlabs/Lib/Chatroom.php index e1a9a10b3..e762620ae 100644 --- a/Zotlabs/Lib/Chatroom.php +++ b/Zotlabs/Lib/Chatroom.php @@ -2,22 +2,18 @@ namespace Zotlabs\Lib; /** - * @brief Chat related functions. + * @brief A class with chatroom related static methods. */ - - - class Chatroom { /** * @brief Creates a chatroom. * * @param array $channel * @param array $arr - * @return An associative array containing: - * - success: A boolean - * - message: (optional) A string + * @return array An associative array containing: + * * \e boolean \b success - A boolean success status + * * \e string \b message - (optional) A string */ - static public function create($channel, $arr) { $ret = array('success' => false); @@ -150,8 +146,8 @@ class Chatroom { } if(intval($x[0]['cr_expire'])) { - $r = q("delete from chat where created < %s - INTERVAL %s and chat_room = %d", - db_utcnow(), + $r = q("delete from chat where created < %s - INTERVAL %s and chat_room = %d", + db_utcnow(), db_quoteinterval( intval($x[0]['cr_expire']) . ' MINUTE' ), intval($x[0]['cr_id']) ); @@ -225,10 +221,16 @@ class Chatroom { } /** - * create a chat message via API. + * @brief Create a chat message via API. + * * It is the caller's responsibility to enter the room. - */ - + * + * @param int $uid + * @param int $room_id + * @param string $xchan + * @param string $text + * @return array + */ static public function message($uid, $room_id, $xchan, $text) { $ret = array('success' => false); @@ -245,12 +247,18 @@ class Chatroom { if(! $r) return $ret; - $arr = array( + $arr = [ 'chat_room' => $room_id, 'chat_xchan' => $xchan, 'chat_text' => $text - ); - + ]; + /** + * @hooks chat_message + * Called to create a chat message. + * * \e int \b chat_room + * * \e string \b chat_xchan + * * \e string \b chat_text + */ call_hooks('chat_message', $arr); $x = q("insert into chat ( chat_room, chat_xchan, created, chat_text ) diff --git a/Zotlabs/Lib/Config.php b/Zotlabs/Lib/Config.php index 6e042feba..f9f22ba3a 100644 --- a/Zotlabs/Lib/Config.php +++ b/Zotlabs/Lib/Config.php @@ -1,4 +1,4 @@ -PConfig is used for channel specific configurations and takes a + * channel_id as identifier. It stores for example which features are + * enabled per channel. The storage is of size MEDIUMTEXT. + * + * @code{.php}$var = Zotlabs\Lib\PConfig::Get('uid', 'category', 'key'); + * // with default value for non existent key + * $var = Zotlabs\Lib\PConfig::Get('uid', 'category', 'unsetkey', 'defaultvalue');@endcode + * + * The old (deprecated?) way to access a PConfig value is: + * @code{.php}$var = get_pconfig(local_channel(), 'category', 'key');@endcode + */ class PConfig { /** @@ -13,9 +26,8 @@ class PConfig { * * @param string $uid * The channel_id - * @return void|false Nothing or false if $uid is false + * @return void|false Nothing or false if $uid is null or false */ - static public function Load($uid) { if(is_null($uid) || $uid === false) return false; @@ -64,11 +76,11 @@ class PConfig { * The category of the configuration value * @param string $key * The configuration key to query - * @param boolean $instore (deprecated, without function) + * @param mixed $default (optional, default false) + * Default value to return if key does not exist * @return mixed Stored value or false if it does not exist */ - - static public function Get($uid,$family,$key,$default = false) { + static public function Get($uid, $family, $key, $default = false) { if(is_null($uid) || $uid === false) return $default; @@ -79,11 +91,10 @@ class PConfig { if((! array_key_exists($family, \App::$config[$uid])) || (! array_key_exists($key, \App::$config[$uid][$family]))) return $default; - return ((! is_array(\App::$config[$uid][$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', \App::$config[$uid][$family][$key])) + return ((! is_array(\App::$config[$uid][$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', \App::$config[$uid][$family][$key])) ? unserialize(\App::$config[$uid][$family][$key]) : \App::$config[$uid][$family][$key] ); - } /** @@ -102,12 +113,11 @@ class PConfig { * The value to store * @return mixed Stored $value or false */ - static public function Set($uid, $family, $key, $value) { - // this catches subtle errors where this function has been called + // this catches subtle errors where this function has been called // with local_channel() when not logged in (which returns false) - // and throws an error in array_key_exists below. + // and throws an error in array_key_exists below. // we provide a function backtrace in the logs so that we can find // and fix the calling function. @@ -132,7 +142,6 @@ class PConfig { dbesc($key), dbesc($dbvalue) ); - } else { @@ -142,7 +151,6 @@ class PConfig { dbesc($family), dbesc($key) ); - } // keep a separate copy for all variables which were @@ -178,7 +186,6 @@ class PConfig { * The configuration key to delete * @return mixed */ - static public function Delete($uid, $family, $key) { if(is_null($uid) || $uid === false) @@ -186,12 +193,12 @@ class PConfig { $ret = false; - if(array_key_exists($uid,\App::$config) - && is_array(\App::$config['uid']) - && array_key_exists($family,\App::$config['uid']) + if(array_key_exists($uid,\App::$config) + && is_array(\App::$config['uid']) + && array_key_exists($family,\App::$config['uid']) && array_key_exists($key, \App::$config[$uid][$family])) unset(\App::$config[$uid][$family][$key]); - + $ret = q("DELETE FROM pconfig WHERE uid = %d AND cat = '%s' AND k = '%s'", intval($uid), dbesc($family), @@ -202,4 +209,3 @@ class PConfig { } } - \ No newline at end of file diff --git a/Zotlabs/Lib/SConfig.php b/Zotlabs/Lib/SConfig.php index ca0d133b2..ab6f49025 100644 --- a/Zotlabs/Lib/SConfig.php +++ b/Zotlabs/Lib/SConfig.php @@ -2,8 +2,11 @@ namespace Zotlabs\Lib; -// account configuration storage is built on top of the under-utilised xconfig - +/** + * @brief Account configuration storage is built on top of the under-utilised xconfig. + * + * @see XConfig + */ class SConfig { static public function Load($server_id) { diff --git a/Zotlabs/Lib/XConfig.php b/Zotlabs/Lib/XConfig.php index bf78c360f..c5a108ac9 100644 --- a/Zotlabs/Lib/XConfig.php +++ b/Zotlabs/Lib/XConfig.php @@ -2,7 +2,26 @@ namespace Zotlabs\Lib; - +/** + * @brief Class for handling observer's config. + * + * XConfig is comparable to PConfig, except that it uses xchan + * (an observer hash) as an identifier. + * + * XConfig is used for observer specific configurations and takes a + * xchan as identifier. + * The storage is of size MEDIUMTEXT. + * + * @code{.php}$var = Zotlabs\Lib\XConfig::Get('xchan', 'category', 'key'); + * // with default value for non existent key + * $var = Zotlabs\Lib\XConfig::Get('xchan', 'category', 'unsetkey', 'defaultvalue');@endcode + * + * The old (deprecated?) way to access a XConfig value is: + * @code{.php}$observer = App::get_observer_hash(); + * if ($observer) { + * $var = get_xconfig($observer, 'category', 'key'); + * }@endcode + */ class XConfig { /** @@ -15,7 +34,6 @@ class XConfig { * The observer's hash * @return void|false Returns false if xchan is not set */ - static public function Load($xchan) { if(! $xchan) @@ -56,9 +74,9 @@ class XConfig { * The category of the configuration value * @param string $key * The configuration key to query + * @param boolean $default (optional) default false * @return mixed Stored $value or false if it does not exist */ - static public function Get($xchan, $family, $key, $default = false) { if(! $xchan) @@ -70,7 +88,7 @@ class XConfig { if((! array_key_exists($family, \App::$config[$xchan])) || (! array_key_exists($key, \App::$config[$xchan][$family]))) return $default; - return ((! is_array(\App::$config[$xchan][$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', \App::$config[$xchan][$family][$key])) + return ((! is_array(\App::$config[$xchan][$family][$key])) && (preg_match('|^a:[0-9]+:{.*}$|s', \App::$config[$xchan][$family][$key])) ? unserialize(\App::$config[$xchan][$family][$key]) : \App::$config[$xchan][$family][$key] ); @@ -82,7 +100,6 @@ class XConfig { * Stores a config value ($value) in the category ($family) under the key ($key) * for the observer's $xchan hash. * - * * @param string $xchan * The observer's hash * @param string $family @@ -93,7 +110,6 @@ class XConfig { * The value to store * @return mixed Stored $value or false */ - static public function Set($xchan, $family, $key, $value) { // manage array value @@ -106,7 +122,7 @@ class XConfig { if(! array_key_exists($family, \App::$config[$xchan])) \App::$config[$xchan][$family] = array(); - $ret = q("INSERT INTO xconfig ( xchan, cat, k, v ) VALUES ( '%s', '%s', '%s', '%s' ) ", + $ret = q("INSERT INTO xconfig ( xchan, cat, k, v ) VALUES ( '%s', '%s', '%s', '%s' )", dbesc($xchan), dbesc($family), dbesc($key), @@ -126,6 +142,7 @@ class XConfig { if($ret) return $value; + return $ret; } @@ -143,11 +160,11 @@ class XConfig { * The configuration key to delete * @return mixed */ - static public function Delete($xchan, $family, $key) { if(x(\App::$config[$xchan][$family], $key)) unset(\App::$config[$xchan][$family][$key]); + $ret = q("DELETE FROM xconfig WHERE xchan = '%s' AND cat = '%s' AND k = '%s'", dbesc($xchan), dbesc($family), diff --git a/Zotlabs/Render/Comanche.php b/Zotlabs/Render/Comanche.php index 78ca870a7..cd06e11a8 100644 --- a/Zotlabs/Render/Comanche.php +++ b/Zotlabs/Render/Comanche.php @@ -5,10 +5,20 @@ namespace Zotlabs\Render; require_once('include/security.php'); require_once('include/menu.php'); - +/** + * @brief Comanche Page Description Language. + * + * Comanche is a markup language similar to bbcode with which to create elaborate + * and complex web pages by assembling them from a series of components - some of + * which are pre-built and others which can be defined on the fly. Comanche uses + * a Page Decription Language to create these pages. + * + * Comanche primarily chooses what content will appear in various regions of the + * page. The various regions have names and these names can change depending on + * what layout template you choose. + */ class Comanche { - function parse($s, $pass = 0) { $matches = array(); @@ -18,13 +28,13 @@ class Comanche { $s = str_replace($mtch[0], '', $s); } } - + /* - * This section supports the "switch" statement of the form given by the following - * example. The [default][/default] block must be the last in the arbitrary + * This section supports the "switch" statement of the form given by the following + * example. The [default][/default] block must be the last in the arbitrary * list of cases. The first case that matches the switch variable is used * and the rest are not evaluated. - * + * * [switch observer.language] * [case de] * [block]german-content[/block] @@ -37,7 +47,7 @@ class Comanche { * [/default] * [/switch] */ - + $cnt = preg_match_all("/\[switch (.*?)\](.*?)\[default\](.*?)\[\/default\]\s*\[\/switch\]/ism", $s, $matches, PREG_SET_ORDER); if($cnt) { foreach($matches as $mtch) { @@ -60,7 +70,7 @@ class Comanche { } } } - + $cnt = preg_match_all("/\[if (.*?)\](.*?)\[else\](.*?)\[\/if\]/ism", $s, $matches, PREG_SET_ORDER); if($cnt) { foreach($matches as $mtch) { @@ -89,7 +99,6 @@ class Comanche { $this->parse_pass0($s); else $this->parse_pass1($s); - } function parse_pass0($s) { @@ -103,7 +112,7 @@ class Comanche { $cnt = preg_match("/\[template=(.*?)\](.*?)\[\/template\]/ism", $s, $matches); if($cnt) { \App::$page['template'] = trim($matches[2]); - \App::$page['template_style'] = trim($matches[2]) . '_' . $matches[1]; + \App::$page['template_style'] = trim($matches[2]) . '_' . $matches[1]; } $cnt = preg_match("/\[template\](.*?)\[\/template\]/ism", $s, $matches); @@ -145,20 +154,23 @@ class Comanche { } /** + * @brief Replace conditional variables with real values. + * * Currently supported condition variables: + * * $config.xxx.yyy - get_config with cat = xxx and k = yyy + * * $request - request uri for this page + * * $observer.language - viewer's preferred language (closest match) + * * $observer.address - xchan_addr or false + * * $observer.name - xchan_name or false + * * $observer - xchan_hash of observer or empty string + * * $local_channel - logged in channel_id or false * - * $config.xxx.yyy - get_config with cat = xxx and k = yyy - * $request - request uri for this page - * $observer.language - viewer's preferred language (closest match) - * $observer.address - xchan_addr or false - * $observer.name - xchan_name or false - * $observer - xchan_hash of observer or empty string - * $local_channel - logged in channel_id or false + * @param string $v The conditional variable name + * @return string|boolean */ - function get_condition_var($v) { if($v) { - $x = explode('.',$v); + $x = explode('.', $v); if($x[0] == 'config') return get_config($x[1],$x[2]); elseif($x[0] === 'request') @@ -179,6 +191,7 @@ class Comanche { return $y['xchan_name']; elseif($x[1] == 'webname') return substr($y['xchan_addr'],0,strpos($y['xchan_addr'],'@')); + return false; } return get_observer_hash(); @@ -186,30 +199,39 @@ class Comanche { else return false; } + return false; } + /** + * @brief Test for Conditional Execution conditions. + * + * This is extensible. The first version of variable testing supports tests of the forms: + * + * - [if $config.system.foo ~= baz] which will check if get_config('system','foo') contains the string 'baz'; + * - [if $config.system.foo == baz] which will check if get_config('system','foo') is the string 'baz'; + * - [if $config.system.foo != baz] which will check if get_config('system','foo') is not the string 'baz'; + * - [if $config.system.foo >= 3] which will check if get_config('system','foo') is greater than or equal to 3; + * - [if $config.system.foo > 3] which will check if get_config('system','foo') is greater than 3; + * - [if $config.system.foo <= 3] which will check if get_config('system','foo') is less than or equal to 3; + * - [if $config.system.foo < 3] which will check if get_config('system','foo') is less than 3; + * + * - [if $config.system.foo {} baz] which will check if 'baz' is an array element in get_config('system','foo') + * - [if $config.system.foo {*} baz] which will check if 'baz' is an array key in get_config('system','foo') + * - [if $config.system.foo] which will check for a return of a true condition for get_config('system','foo'); + * + * The values 0, '', an empty array, and an unset value will all evaluate to false. + * + * @param int|string $s + * @return boolean + */ function test_condition($s) { - // This is extensible. The first version of variable testing supports tests of the forms: - - // [if $config.system.foo ~= baz] which will check if get_config('system','foo') contains the string 'baz'; - // [if $config.system.foo == baz] which will check if get_config('system','foo') is the string 'baz'; - // [if $config.system.foo != baz] which will check if get_config('system','foo') is not the string 'baz'; - // [if $config.system.foo >= 3] which will check if get_config('system','foo') is greater than or equal to 3; - // [if $config.system.foo > 3] which will check if get_config('system','foo') is greater than 3; - - // [if $config.system.foo <= 3] which will check if get_config('system','foo') is less than or equal to 3; - // [if $config.system.foo < 3] which will check if get_config('system','foo') is less than 3; - - // [if $config.system.foo {} baz] which will check if 'baz' is an array element in get_config('system','foo') - // [if $config.system.foo {*} baz] which will check if 'baz' is an array key in get_config('system','foo') - // [if $config.system.foo] which will check for a return of a true condition for get_config('system','foo'); - // The values 0, '', an empty array, and an unset value will all evaluate to false. if(preg_match('/[\$](.*?)\s\~\=\s(.*?)$/',$s,$matches)) { $x = $this->get_condition_var($matches[1]); if(stripos($x,trim($matches[2])) !== false) return true; + return false; } @@ -217,6 +239,7 @@ class Comanche { $x = $this->get_condition_var($matches[1]); if($x == trim($matches[2])) return true; + return false; } @@ -224,6 +247,7 @@ class Comanche { $x = $this->get_condition_var($matches[1]); if($x != trim($matches[2])) return true; + return false; } @@ -231,24 +255,31 @@ class Comanche { $x = $this->get_condition_var($matches[1]); if($x >= trim($matches[2])) return true; + return false; } + if(preg_match('/[\$](.*?)\s\<\=\s(.*?)$/',$s,$matches)) { $x = $this->get_condition_var($matches[1]); if($x <= trim($matches[2])) return true; + return false; } + if(preg_match('/[\$](.*?)\s\>\s(.*?)$/',$s,$matches)) { $x = $this->get_condition_var($matches[1]); if($x > trim($matches[2])) return true; + return false; } + if(preg_match('/[\$](.*?)\s\>\s(.*?)$/',$s,$matches)) { $x = $this->get_condition_var($matches[1]); if($x < trim($matches[2])) return true; + return false; } @@ -256,6 +287,7 @@ class Comanche { $x = $this->get_condition_var($matches[1]); if(is_array($x) && in_array(trim($matches[2]),$x)) return true; + return false; } @@ -263,6 +295,7 @@ class Comanche { $x = $this->get_condition_var($matches[1]); if(is_array($x) && array_key_exists(trim($matches[2]),$x)) return true; + return false; } @@ -270,13 +303,21 @@ class Comanche { $x = $this->get_condition_var($matches[1]); if($x) return true; + return false; } - return false; + return false; } - + /** + * @brief Return rendered menu for current channel_id. + * + * @see menu_render() + * @param string $s + * @param string $class (optional) default empty + * @return string + */ function menu($s, $class = '') { $channel_id = $this->get_channel_id(); @@ -291,7 +332,7 @@ class Comanche { } if($channel_id) { - $m = menu_fetch($name,$channel_id, get_observer_hash()); + $m = menu_fetch($name, $channel_id, get_observer_hash()); return menu_render($m, $class, $edit = false, $var); } } @@ -309,9 +350,8 @@ class Comanche { * Returns the channel_id of the profile owner of the page, or the local_channel * if there is no profile owner. Otherwise returns 0. * - * @return channel_id + * @return int channel_id */ - function get_channel_id() { $channel_id = ((is_array(\App::$profile)) ? \App::$profile['profile_uid'] : 0); @@ -321,6 +361,13 @@ class Comanche { return $channel_id; } + /** + * @brief Returns a parsed block. + * + * @param string $s + * @param string $class (optional) default empty + * @return string parsed HTML of block + */ function block($s, $class = '') { $var = array(); $matches = array(); @@ -339,7 +386,7 @@ class Comanche { $channel_id = $this->get_channel_id(); if($channel_id) { - $r = q("select * from item inner join iconfig on iconfig.iid = item.id and item.uid = %d + $r = q("select * from item inner join iconfig on iconfig.iid = item.id and item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'BUILDBLOCK' and iconfig.v = '%s' limit 1", intval($channel_id), dbesc($name) @@ -381,6 +428,12 @@ class Comanche { return $o; } + /** + * @brief Include JS depending on framework. + * + * @param string $s + * @return string + */ function js($s) { switch($s) { @@ -401,9 +454,14 @@ class Comanche { $ret .= $init; return $ret; - } + /** + * @brief Include CSS depending on framework. + * + * @param string $s + * @return string + */ function css($s) { switch($s) { @@ -418,17 +476,22 @@ class Comanche { $ret = ''; return $ret; - } - // This doesn't really belong in Comanche, but it could also be argued that it is the perfect place. - // We need to be able to select what kind of template and decoration to use for the webpage at the heart of our content. - // For now we'll allow an '[authored]' element which defaults to name and date, or 'none' to remove these, and perhaps - // 'full' to provide a social network style profile photo. - // But leave it open to have richer templating options and perhaps ultimately discard this one, once we have a better idea - // of what template and webpage options we might desire. - - function webpage(&$a,$s) { + /** + * This doesn't really belong in Comanche, but it could also be argued that it is the perfect place. + * We need to be able to select what kind of template and decoration to use for the webpage at the heart of our content. + * For now we'll allow an '[authored]' element which defaults to name and date, or 'none' to remove these, and perhaps + * 'full' to provide a social network style profile photo. + * + * But leave it open to have richer templating options and perhaps ultimately discard this one, once we have a better idea + * of what template and webpage options we might desire. + * + * @param[in,out] array $a + * @param string $s + * @return array + */ + function webpage(&$a, $s) { $ret = array(); $matches = array(); @@ -438,22 +501,20 @@ class Comanche { $ret['authored'] = $mtch[1]; } } + return $ret; } - /** - * Render a widget + * @brief Render a widget. * * @param string $name * @param string $text */ - function widget($name, $text) { $vars = array(); $matches = array(); - $cnt = preg_match_all("/\[var=(.*?)\](.*?)\[\/var\]/ism", $text, $matches, PREG_SET_ORDER); if ($cnt) { foreach ($matches as $mtch) { @@ -480,7 +541,7 @@ class Comanche { if(method_exists($x,$f)) { return $x->$f($vars); } - } + } $func = 'widget_' . trim($name); @@ -563,9 +624,9 @@ class Comanche { } - /* - * @function register_page_template($arr) - * Registers a page template/variant for use by Comanche selectors + /** + * @brief Registers a page template/variant for use by Comanche selectors. + * * @param array $arr * 'template' => template name * 'variant' => array( @@ -577,8 +638,6 @@ class Comanche { * ) * ) */ - - function register_page_template($arr) { \App::$page_layouts[$arr['template']] = array($arr['variant']); return; diff --git a/Zotlabs/Web/Router.php b/Zotlabs/Web/Router.php index 9486130cb..12ef315d4 100644 --- a/Zotlabs/Web/Router.php +++ b/Zotlabs/Web/Router.php @@ -2,6 +2,8 @@ namespace Zotlabs\Web; +use Exception; + /** * * We have already parsed the server path into App::$argc and App::$argv @@ -34,7 +36,7 @@ class Router { private $controller = null; /** - * @brief Router constructor + * @brief Router constructor. * * @param[in,out] App &$a * @throws Exception module not found @@ -98,15 +100,23 @@ class Router { } } - /* - * This provides a place for plugins to register module handlers which don't otherwise exist - * on the system, or to completely over-ride an existing module. - * If the plugin sets 'installed' to true we won't throw a 404 error for the specified module even if - * there is no specific module file or matching plugin name. - * The plugin should catch at least one of the module hooks for this URL. + $x = [ + 'module' => $module, + 'installed' => \App::$module_loaded, + 'controller' => $this->controller + ]; + /** + * @hooks module_loaded + * Called when a module has been successfully locate to server a URL request. + * This provides a place for plugins to register module handlers which don't otherwise exist + * on the system, or to completely over-ride an existing module. + * If the plugin sets 'installed' to true we won't throw a 404 error for the specified module even if + * there is no specific module file or matching plugin name. + * The plugin should catch at least one of the module hooks for this URL. + * * \e string \b module + * * \e boolean \b installed + * * \e mixed \b controller - The initialized module object */ - - $x = array('module' => $module, 'installed' => \App::$module_loaded, 'controller' => $this->controller); call_hooks('module_loaded', $x); if($x['installed']) { \App::$module_loaded = true; @@ -131,14 +141,14 @@ class Router { } } - $x = [ - 'module' => $module, - 'installed' => \App::$module_loaded, + $x = [ + 'module' => $module, + 'installed' => \App::$module_loaded, 'controller' => $this->controller ]; call_hooks('page_not_found',$x); - // Stupid browser tried to pre-fetch our Javascript img template. + // Stupid browser tried to pre-fetch our Javascript img template. // Don't log the event or return anything - just quietly exit. if((x($_SERVER, 'QUERY_STRING')) && preg_match('/{[0-9]}/', $_SERVER['QUERY_STRING']) !== 0) { @@ -147,8 +157,8 @@ class Router { if(get_config('system','log_404',true)) { logger("Module {$module} not found.", LOGGER_DEBUG, LOG_WARNING); - logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] - . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' + logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] + . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG); } diff --git a/Zotlabs/Zot/Verify.php b/Zotlabs/Zot/Verify.php index 1d9e6de3f..7abe38d17 100644 --- a/Zotlabs/Zot/Verify.php +++ b/Zotlabs/Zot/Verify.php @@ -26,12 +26,11 @@ class Verify { q("delete from verify where id = %d", intval($r[0]['id']) ); - return true; + return true; } return false; } - function get_meta($type,$channel_id,$token) { $r = q("select id, meta from verify where vtype = '%s' and channel = %d and token = '%s' limit 1", dbesc($type), @@ -42,12 +41,18 @@ class Verify { q("delete from verify where id = %d", intval($r[0]['id']) ); - return $r[0]['meta']; + return $r[0]['meta']; } return false; } - function purge($type,$interval) { + /** + * @brief Purge entries of a verify-type older than interval. + * + * @param string $type Verify type + * @param string $interval SQL compatible time interval + */ + function purge($type, $interval) { q("delete from verify where vtype = '%s' and created < %s - INTERVAL %s", dbesc($type), db_utcnow(), -- cgit v1.2.3 From d450fc61c41d44c0acf60522001e7d5ebd451c46 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 3 Nov 2017 15:08:56 -0700 Subject: more search work --- Zotlabs/Module/Search.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 7bc3429b1..a572a5a42 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -56,8 +56,7 @@ class Search extends \Zotlabs\Web\Controller { $static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0); - if((! local_channel()) || (! feature_enabled(local_channel(),'savedsearch'))) - $o .= search($search,'search-box','/search',((local_channel()) ? true : false)); + $o .= search($search,'search-box','/search',((local_channel()) ? true : false)); if(strpos($search,'#') === 0) { $tag = true; -- cgit v1.2.3 From 9abb061e7185a29cb85ebbad04deba715e1a6a06 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 3 Nov 2017 16:47:05 -0700 Subject: provide short localised summary for likes that will end up in displayed notifications --- Zotlabs/Lib/Enotify.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index e82c11a35..d5798e671 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -778,10 +778,14 @@ class Enotify { // Call localize_item to get a one line status for activities. // This should set $item['localized'] to indicate we have a brief summary. + // and perhaps $item['shortlocalized'] for an even briefer summary localize_item($item); - if($item['localize']) { + if($item['shortlocalize']) { + $itemem_text = $item['shortlocalize']; + } + elseif($item['localize']) { $itemem_text = $item['localize']; } else { -- cgit v1.2.3 From 359bfb76f66efd585b0cba1b2f81494859931d61 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 5 Nov 2017 16:29:01 -0800 Subject: common connections on suggestion page showing wildly different results than remote profile, and is consistently off by one --- Zotlabs/Module/Directory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php index caf0190ae..256667ef3 100644 --- a/Zotlabs/Module/Directory.php +++ b/Zotlabs/Module/Directory.php @@ -102,7 +102,7 @@ class Directory extends \Zotlabs\Web\Controller { $common = array(); $index = 0; foreach($r as $rr) { - $common[$rr['xchan_addr']] = $rr['total']; + $common[$rr['xchan_addr']] = ((intval($rr['total']) > 0) ? intval($rr['total']) - 1 : 0); $addresses[$rr['xchan_addr']] = $index++; } @@ -334,7 +334,7 @@ class Directory extends \Zotlabs\Web\Controller { 'ignlink' => $suggest ? z_root() . '/directory?ignore=' . $rr['hash'] : '', 'ignore_label' => t('Don\'t suggest'), 'common_friends' => (($common[$rr['address']]) ? intval($common[$rr['address']]) : ''), - 'common_label' => t('Common connections:'), + 'common_label' => t('Common connections (estimated):'), 'common_count' => intval($common[$rr['address']]), 'safe' => $safe_mode ); -- cgit v1.2.3 From 7efcb3c75f08c8d974f13cd8b5f32f14749d8b6e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 5 Nov 2017 19:47:44 -0800 Subject: allow cloud filenames to include ampersands without messing up auth tokens (zid, owt, and zat, and the constant placeholder 'f=') --- Zotlabs/Module/Cloud.php | 24 ++++++++---------------- Zotlabs/Storage/Browser.php | 1 + 2 files changed, 9 insertions(+), 16 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Cloud.php b/Zotlabs/Module/Cloud.php index d2264092b..0f7f9c47a 100644 --- a/Zotlabs/Module/Cloud.php +++ b/Zotlabs/Module/Cloud.php @@ -59,19 +59,10 @@ class Cloud extends \Zotlabs\Web\Controller { // if we arrived at this path with any query parameters in the url, build a clean url without // them and redirect. - // @fixme if the filename has an ampersand in it AND there are query parameters, - // this may not do the right thing. - - if((strpos($_SERVER['QUERY_STRING'],'?') !== false) || (strpos($_SERVER['QUERY_STRING'],'&') !== false && strpos($_SERVER['QUERY_STRING'],'&') === false)) { - $path = z_root(); - if(argc()) { - foreach(\App::$argv as $a) { - $path .= '/' . $a; - } - } - goaway($path); - } + $x = clean_query_string(); + if($x !== \App::$query_string) + goaway(z_root() . '/' . $x); $rootDirectory = new \Zotlabs\Storage\Directory('/', $auth); @@ -92,16 +83,17 @@ class Cloud extends \Zotlabs\Web\Controller { $server->addPlugin($browser); // Experimental QuotaPlugin - // require_once('\Zotlabs\Storage/QuotaPlugin.php'); - // $server->addPlugin(new \Zotlabs\Storage\\QuotaPlugin($auth)); + // require_once('\Zotlabs\Storage/QuotaPlugin.php'); + // $server->addPlugin(new \Zotlabs\Storage\\QuotaPlugin($auth)); + -// ob_start(); // All we need to do now, is to fire up the server + $server->exec(); -// ob_end_flush(); if($browser->build_page) construct_page(); + killme(); } diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index b5c3ac1cf..77201f387 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -233,6 +233,7 @@ class Browser extends DAV\Browser\Plugin { $f[] = $ft; } + $output = ''; if ($this->enablePost) { $this->server->emit('onHTMLActionsPanel', array($parent, &$output, $path)); -- cgit v1.2.3 From 9cd715bbbf8b02fad21b1f4982c8de7c0e575154 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 6 Nov 2017 09:34:20 +0100 Subject: fix unable to mark all messages read --- Zotlabs/Module/Ping.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 5e2d04c1f..3c6dda1e9 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -219,7 +219,7 @@ class Ping extends \Zotlabs\Web\Controller { intval(local_channel()) ); break; - case 'messages': + case 'mail': $r = q("update mail set mail_seen = 1 where mail_seen = 0 and channel_id = %d ", intval(local_channel()) ); -- cgit v1.2.3 From 3f1a4b655900d64ad2c13f1906eb77eaf15d11b5 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 6 Nov 2017 20:13:14 -0800 Subject: second half of issue #893 - move channel default permissions to its own module so we can apply different page/widget layouts than for connedit; the relevant functionality is abandoned on mod_connedit but still intact. Trying a slightly different look/behaviour for inherited settings and the associated checkboxes. This may need a bit more tweaking but overall looks a lot cleaner. --- Zotlabs/Module/Defperms.php | 267 +++++++++++++++++++++++++++++++++++++++ Zotlabs/Widget/Settings_menu.php | 2 +- 2 files changed, 268 insertions(+), 1 deletion(-) create mode 100644 Zotlabs/Module/Defperms.php (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Defperms.php b/Zotlabs/Module/Defperms.php new file mode 100644 index 000000000..4e7ddb55a --- /dev/null +++ b/Zotlabs/Module/Defperms.php @@ -0,0 +1,267 @@ + $desc) { + + $checkinherited = \Zotlabs\Access\PermissionLimits::Get(local_channel(),$perm); + $inherited = (($checkinherited & PERMS_SPECIFIC) ? false : true); + + if(array_key_exists('perms_' . $perm, $_POST)) { + set_abconfig($channel['channel_id'],$orig_record[0]['abook_xchan'],'my_perms',$perm, + intval($_POST['perms_' . $perm])); + if($autoperms) { + set_pconfig($channel['channel_id'],'autoperms',$perm,intval($_POST['perms_' . $perm])); + } + } + else { + set_abconfig($channel['channel_id'],$orig_record[0]['abook_xchan'],'my_perms',$perm,0); + if($autoperms) { + set_pconfig($channel['channel_id'],'autoperms',$perm,0); + } + } + } + } + + if(! is_null($autoperms)) + set_pconfig($channel['channel_id'],'system','autoperms',$autoperms); + + + notice( t('Settings updated.') . EOL); + + + // Refresh the structure in memory with the new data + + $r = q("SELECT abook.*, xchan.* + FROM abook left join xchan on abook_xchan = xchan_hash + WHERE abook_channel = %d and abook_id = %d LIMIT 1", + intval(local_channel()), + intval($contact_id) + ); + if($r) { + \App::$poi = $r[0]; + } + + + $this->defperms_clone($a); + + goaway(z_root() . '/defperms'); + + return; + + } + + /* @brief Clone connection + * + * + */ + + function defperms_clone(&$a) { + + if(! \App::$poi) + return; + + $channel = \App::get_channel(); + + $r = q("SELECT abook.*, xchan.* + FROM abook left join xchan on abook_xchan = xchan_hash + WHERE abook_channel = %d and abook_id = %d LIMIT 1", + intval(local_channel()), + intval(\App::$poi['abook_id']) + ); + if($r) { + \App::$poi = array_shift($r); + } + + $clone = \App::$poi; + + unset($clone['abook_id']); + unset($clone['abook_account']); + unset($clone['abook_channel']); + + $abconfig = load_abconfig($channel['channel_id'],$clone['abook_xchan']); + if($abconfig) + $clone['abconfig'] = $abconfig; + + build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone))); + } + + /* @brief Generate content of connection edit page + * + * + */ + + function get() { + + $sort_type = 0; + $o = ''; + + if(! local_channel()) { + notice( t('Permission denied.') . EOL); + return login(); + } + + $section = ((array_key_exists('section',$_REQUEST)) ? $_REQUEST['section'] : ''); + $channel = \App::get_channel(); + + $yes_no = array(t('No'),t('Yes')); + + $connect_perms = \Zotlabs\Access\Permissions::connect_perms(local_channel()); + + $o .= "\n"; + + if(\App::$poi) { + + $sections = []; + + $self = false; + + $tpl = get_markup_template('defperms.tpl'); + + + $perms = array(); + $channel = \App::get_channel(); + + $contact = \App::$poi; + + $global_perms = \Zotlabs\Access\Permissions::Perms(); + + $existing = get_all_perms(local_channel(),$contact['abook_xchan']); + $hidden_perms = []; + + foreach($global_perms as $k => $v) { + $thisperm = get_abconfig(local_channel(),$contact['abook_xchan'],'my_perms',$k); + + $checkinherited = \Zotlabs\Access\PermissionLimits::Get(local_channel(),$k); + + $inherited = (($checkinherited & PERMS_SPECIFIC) ? false : true); + + $perms[] = [ 'perms_' . $k, $v, intval($thisperm), '', $yes_no, (($inherited) ? ' disabled="disabled" ' : '') ]; + if($inherited) { + $hidden_perms[] = [ 'perms_' . $k, intval($thisperm) ]; + } + } + + $pcat = new \Zotlabs\Lib\Permcat(local_channel()); + $pcatlist = $pcat->listing(); + $permcats = []; + if($pcatlist) { + foreach($pcatlist as $pc) { + $permcats[$pc['name']] = $pc['localname']; + } + } + + $o .= replace_macros($tpl, [ + '$header' => t('Connection Default Permissions'), + '$autoperms' => array('autoperms',t('Apply these permissions automatically'), ((get_pconfig(local_channel(),'system','autoperms')) ? 1 : 0), t('If enabled, connection requests will be approved without your interaction'), $yes_no), + '$permcat' => [ 'permcat', t('Permission role'), '', '',$permcats ], + '$permcat_new' => t('Add permission role'), + '$permcat_enable' => feature_enabled(local_channel(),'permcats'), + '$section' => $section, + '$sections' => $sections, + '$autolbl' => t('The permissions indicated on this page will be applied to all new connections.'), + '$autoapprove' => t('Automatic approval settings'), + '$unapproved' => $unapproved, + '$inherited' => t('inherited'), + '$submit' => t('Submit'), + '$me' => t('My Settings'), + '$perms' => $perms, + '$hidden_perms' => $hidden_perms, + '$permlbl' => t('Individual Permissions'), + '$permnote_self' => t('Some individual permissions may have been preset or locked based on your channel type and privacy settings.'), + '$contact_id' => $contact['abook_id'], + '$name' => $contact['xchan_name'], + ]); + + $arr = array('contact' => $contact,'output' => $o); + + call_hooks('contact_edit', $arr); + + return $arr['output']; + + } + } +} diff --git a/Zotlabs/Widget/Settings_menu.php b/Zotlabs/Widget/Settings_menu.php index c15ad0980..e15ed96a5 100644 --- a/Zotlabs/Widget/Settings_menu.php +++ b/Zotlabs/Widget/Settings_menu.php @@ -107,7 +107,7 @@ class Settings_menu { if($role === false || $role === 'custom') { $tabs[] = array( 'label' => t('Connection Default Permissions'), - 'url' => z_root() . '/connedit/' . $abook_self_id, + 'url' => z_root() . '/defperms', 'selected' => '' ); } -- cgit v1.2.3 From 5376a734d45554fafacb674a725dc2831db1bf14 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 6 Nov 2017 21:55:36 -0800 Subject: .htignore update --- 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 4e7ddb55a..9214331e4 100644 --- a/Zotlabs/Module/Defperms.php +++ b/Zotlabs/Module/Defperms.php @@ -159,7 +159,7 @@ class Defperms extends \Zotlabs\Web\Controller { build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone))); } - /* @brief Generate content of connection edit page + /* @brief Generate content of connection default permissions page * * */ -- cgit v1.2.3 From 47fbdda40951be5109c739f63331e2bb95ebd64a Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 7 Nov 2017 11:22:11 +0100 Subject: rename channel app events to calendar and add nav_set_selected() to /cal --- Zotlabs/Module/Cal.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Cal.php b/Zotlabs/Module/Cal.php index 41676ce02..c8403e979 100644 --- a/Zotlabs/Module/Cal.php +++ b/Zotlabs/Module/Cal.php @@ -69,6 +69,8 @@ class Cal extends \Zotlabs\Web\Controller { notice( t('Permissions denied.') . EOL); return; } + + nav_set_selected('Calendar'); $sql_extra = permissions_sql($channel['channel_id'],get_observer_hash(),'event'); -- cgit v1.2.3 From 92e0c502f76f5a3acc0498f45a0fe836973c554c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 7 Nov 2017 19:34:00 -0800 Subject: make most recent cloud_tiles setting for local channels persistent across logins --- Zotlabs/Module/Cloud_tiles.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Cloud_tiles.php b/Zotlabs/Module/Cloud_tiles.php index 45124cdfa..da551904f 100644 --- a/Zotlabs/Module/Cloud_tiles.php +++ b/Zotlabs/Module/Cloud_tiles.php @@ -11,6 +11,10 @@ class Cloud_tiles extends \Zotlabs\Web\Controller { else $_SESSION['cloud_tiles'] = 1; + if(local_channel()) { + set_pconfig(local_channel(),'system','cloud_tiles',$_SESSION['cloud_tiles']); + } + goaway(z_root() . '/' . hex2bin(argv(1))); } -- cgit v1.2.3 From 40c625158f879c51bac8c1e2271eb0505dff991d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 8 Nov 2017 21:19:03 -0800 Subject: unable to change permissions on wiki with space in name --- Zotlabs/Module/Wiki.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index d6a01af11..2d2d8e2b7 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -494,7 +494,7 @@ class Wiki extends \Zotlabs\Web\Controller { return; //not reached } - $wiki = Zlib\NativeWiki::exists_by_name($owner['channel_id'], $arr['urlName']); + $wiki = Zlib\NativeWiki::exists_by_name($owner['channel_id'], urldecode($arr['urlName'])); if($wiki['resource_id']) { -- cgit v1.2.3 From fc96cd371042a92ed180635b91924413392d3972 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 9 Nov 2017 11:34:41 +0100 Subject: load notifications links to /display via ajax if we are already in /display --- Zotlabs/Lib/Enotify.php | 1 + Zotlabs/Widget/Notifications.php | 1 + 2 files changed, 2 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index d5798e671..fffe4ffe7 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -803,6 +803,7 @@ class Enotify { 'photo' => $item['author']['xchan_photo_s'], 'when' => relative_date($item['created']), 'class' => (intval($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'), + 'b64mid' => 'b64.' . base64url_encode($item['mid']), 'message' => strip_tags(bbcode($itemem_text)) ); diff --git a/Zotlabs/Widget/Notifications.php b/Zotlabs/Widget/Notifications.php index a857f1ad9..191f2afb6 100644 --- a/Zotlabs/Widget/Notifications.php +++ b/Zotlabs/Widget/Notifications.php @@ -139,6 +139,7 @@ class Notifications { } $o = replace_macros(get_markup_template('notifications_widget.tpl'), array( + '$module' => \App::$module, '$notifications' => $notifications, '$loading' => t('Loading...') )); -- cgit v1.2.3 From 40a7446e3e1d52fa015ac9f2ce45b0c2b8df520f Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 9 Nov 2017 12:41:57 +0100 Subject: get the path infos from pathname instead of seperate data attribute --- Zotlabs/Lib/Enotify.php | 1 - 1 file changed, 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index fffe4ffe7..d5798e671 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -803,7 +803,6 @@ class Enotify { 'photo' => $item['author']['xchan_photo_s'], 'when' => relative_date($item['created']), 'class' => (intval($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'), - 'b64mid' => 'b64.' . base64url_encode($item['mid']), 'message' => strip_tags(bbcode($itemem_text)) ); -- cgit v1.2.3 From 3a17225546c9cd8f74bd1b2701e974fdda5929a2 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 10 Nov 2017 20:30:55 +0100 Subject: revert back to get the mid from enotify - otherwise we can not distinct between posts and likes --- Zotlabs/Lib/Enotify.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index d5798e671..697b57b6a 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -802,7 +802,8 @@ class Enotify { 'url' => $item['author']['xchan_url'], 'photo' => $item['author']['xchan_photo_s'], 'when' => relative_date($item['created']), - 'class' => (intval($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'), + 'class' => (intval($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'), + 'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])), 'message' => strip_tags(bbcode($itemem_text)) ); -- cgit v1.2.3 From 6cf3ebb7dbf813d92342d0350078edbcd5050e9c Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Mon, 6 Nov 2017 23:28:44 +0100 Subject: :ok_hand: Fix a PHP warning in Permissions::FilledPerms(). When NULL is passed as parameter there is a PHP warning when testing against it in the function in_array(). --- Zotlabs/Access/Permissions.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Access/Permissions.php b/Zotlabs/Access/Permissions.php index 20ce21238..bca40a9c1 100644 --- a/Zotlabs/Access/Permissions.php +++ b/Zotlabs/Access/Permissions.php @@ -127,6 +127,7 @@ class Permissions { static public function FilledPerms($arr) { if(is_null($arr)) { btlogger('FilledPerms: null'); + $arr = []; } $everything = self::Perms(); -- cgit v1.2.3 From 988028577b19d2cf2825eec65e398d447d8d4056 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 10 Nov 2017 13:50:52 -0800 Subject: set os_syspath in DAV file put operation so that photos will scale correctly. --- Zotlabs/Storage/File.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Storage/File.php b/Zotlabs/Storage/File.php index 332bf6896..947a9fde3 100644 --- a/Zotlabs/Storage/File.php +++ b/Zotlabs/Storage/File.php @@ -127,12 +127,15 @@ class File extends DAV\Node implements DAV\IFile { $is_photo = false; $album = ''; + $os_path = ''; - $r = q("SELECT flags, folder, os_storage, filename, is_photo FROM attach WHERE hash = '%s' AND uid = %d LIMIT 1", + $r = q("SELECT flags, folder, os_storage, os_path, filename, is_photo FROM attach WHERE hash = '%s' AND uid = %d LIMIT 1", dbesc($this->data['hash']), intval($c[0]['channel_id']) ); if ($r) { + $os_path = $r[0]['os_path']; + if (intval($r[0]['os_storage'])) { $d = q("select folder, content from attach where hash = '%s' and uid = %d limit 1", dbesc($this->data['hash']), @@ -150,7 +153,7 @@ class File extends DAV\Node implements DAV\IFile { } } $fname = dbunescbin($d[0]['content']); - if(strpos($fname,'store') === false) + if(strpos($fname,'store/') === false) $f = 'store/' . $this->auth->owner_nick . '/' . $fname ; else $f = $fname; @@ -196,7 +199,7 @@ class File extends DAV\Node implements DAV\IFile { if($is_photo) { require_once('include/photos.php'); - $args = array( 'resource_id' => $this->data['hash'], 'album' => $album, 'os_path' => $f, 'filename' => $r[0]['filename'], 'getimagesize' => $gis, 'directory' => $direct ); + $args = array( 'resource_id' => $this->data['hash'], 'album' => $album, 'os_syspath' => $f, 'os_path' => $os_path, 'filename' => $r[0]['filename'], 'getimagesize' => $gis, 'directory' => $direct ); $p = photo_upload($c[0],\App::get_observer(),$args); } -- cgit v1.2.3 From 55995b0494843ef826dc38f862e9dced34ae0d96 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 11 Nov 2017 20:01:03 +0100 Subject: fix wiki pages not updating after creating new page --- Zotlabs/Widget/Wiki_pages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Wiki_pages.php b/Zotlabs/Widget/Wiki_pages.php index ac44b8d88..39d4b1717 100644 --- a/Zotlabs/Widget/Wiki_pages.php +++ b/Zotlabs/Widget/Wiki_pages.php @@ -12,7 +12,7 @@ class Wiki_pages { if(! $arr['resource_id']) { $c = channelx_by_nick(argv(1)); - $w = \Zotlabs\Lib\NativeWiki::exists_by_name($c['channel_id'],argv(2)); + $w = \Zotlabs\Lib\NativeWiki::exists_by_name($c['channel_id'],urldecode(argv(2))); $arr = array( 'resource_id' => $w['resource_id'], 'channel_id' => $c['channel_id'], -- cgit v1.2.3 From 458f2e748de22448206ce12c9961e9cce80c796d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 12 Nov 2017 14:14:20 -0800 Subject: cleanup of upload_to_comments test; we actually don't care about the profile owner. We only care that we're logged in locally and our storage is public by default. --- Zotlabs/Module/Item.php | 9 --------- 1 file changed, 9 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index b54de0fb9..f2b850ffc 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -577,15 +577,6 @@ class Item extends \Zotlabs\Web\Controller { * so we'll set the permissions regardless and realise that the media may not be * referenced in the post. * - * What is preventing us from being able to upload photos into comments is dealing with - * the photo and attachment permissions, since we don't always know who was in the - * distribution for the top level post. - * - * We might be able to provide this functionality with a lot of fiddling: - * - if the top level post is public (make the photo public) - * - if the top level post was written by us or a wall post that belongs to us (match the top level post) - * - if the top level post has privacy mentions, add those to the permissions. - * - otherwise disallow the photo *or* make the photo public. This is the part that gets messy. */ if(! $preview) { -- cgit v1.2.3 From b12dc89bb1fbdc29f82fffee3587360d618ef603 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 12 Nov 2017 21:36:25 -0800 Subject: improve removed_channel final cleanup. Hubzilla issue #386 --- Zotlabs/Daemon/Cron.php | 2 +- Zotlabs/Daemon/Cron_weekly.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php index 65edbedfa..01c43262a 100644 --- a/Zotlabs/Daemon/Cron.php +++ b/Zotlabs/Daemon/Cron.php @@ -78,7 +78,7 @@ class Cron { // channels and sites that quietly vanished and prevent the directory from accumulating stale // or dead entries. - $r = q("select channel_id from channel where channel_dirdate < %s - INTERVAL %s", + $r = q("select channel_id from channel where channel_dirdate < %s - INTERVAL %s and channel_removed = 0", db_utcnow(), db_quoteinterval('30 DAY') ); diff --git a/Zotlabs/Daemon/Cron_weekly.php b/Zotlabs/Daemon/Cron_weekly.php index 5b185f475..d44400767 100644 --- a/Zotlabs/Daemon/Cron_weekly.php +++ b/Zotlabs/Daemon/Cron_weekly.php @@ -21,6 +21,21 @@ class Cron_weekly { mark_orphan_hubsxchans(); + // Find channels that were removed in the last three weeks, but + // haven't been finally cleaned up. These should be older than 10 + // days to ensure that "purgeall" messages have gone out or bounced + // or timed out. + + $r = q("select channel_id from channel where channel_removed = 1 and + channel_deleted > %s - INTERVAL %s and channel_deleted < %s - INTERVAL %s", + db_utcnow(), db_quoteinterval('21 DAY'), + db_utcnow(), db_quoteinterval('10 DAY') + ); + if($r) { + foreach($r as $rv) { + channel_remove_final($rv['channel_id']); + } + } // get rid of really old poco records -- cgit v1.2.3 From 7b6ddeb859288a87573b922dcce086de21189f8c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 12 Nov 2017 21:43:46 -0800 Subject: allow a site to block (public) the directory separately from other resources. --- Zotlabs/Module/Directory.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php index 256667ef3..b1552a694 100644 --- a/Zotlabs/Module/Directory.php +++ b/Zotlabs/Module/Directory.php @@ -64,6 +64,11 @@ class Directory extends \Zotlabs\Web\Controller { return; } + if(get_config('system','block_public_directory',false) && (! get_observer_hash())) { + notice( t('Public access denied.') . EOL); + return; + } + $observer = get_observer_hash(); $globaldir = get_directory_setting($observer, 'globaldir'); -- cgit v1.2.3 From 217a684e5f0399683b191e7fa9b1a3781fb21196 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 13 Nov 2017 10:08:51 +0100 Subject: also filter atokens on acl search --- Zotlabs/Module/Acl.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php index e164875e8..ad1c8b8cd 100644 --- a/Zotlabs/Module/Acl.php +++ b/Zotlabs/Module/Acl.php @@ -176,11 +176,18 @@ class Acl extends \Zotlabs\Web\Controller { $extra_channels_sql = " OR (abook_channel IN ($extra_channels_sql)) and abook_hidden = 0 "; - // Add atokens belonging to the local channel @TODO restrict by search + // Add atokens belonging to the local channel + + if($search) { + $sql_extra_atoken = "AND ( atoken_name LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . ") "; + } + else { + $sql_extra_atoken = ''; + } $r2 = null; - $r1 = q("select * from atoken where atoken_uid = %d", + $r1 = q("select * from atoken where atoken_uid = %d $sql_extra_atoken", intval(local_channel()) ); -- cgit v1.2.3 From c8dbcf8a2af7ac3b1a9e26c4c293574f919bd554 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 13 Nov 2017 22:01:37 +0100 Subject: sort combined private mail conversations by latest updated conversation instead of created parent --- Zotlabs/Widget/Conversations.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Conversations.php b/Zotlabs/Widget/Conversations.php index 56510750f..267d50fa0 100644 --- a/Zotlabs/Widget/Conversations.php +++ b/Zotlabs/Widget/Conversations.php @@ -28,6 +28,8 @@ class Conversations { require_once('include/message.php'); + $o = ''; + // private_messages_list() can do other more complicated stuff, for now keep it simple $r = private_messages_list(local_channel(), $mailbox, \App::$pager['start'], \App::$pager['itemspage']); @@ -36,13 +38,13 @@ class Conversations { return $o; } - $messages = array(); + $messages = []; foreach($r as $rr) { $selected = ((argc() == 3) ? intval(argv(2)) == intval($rr['id']) : $r[0]['id'] == $rr['id']); - $messages[] = array( + $messages[] = [ 'mailbox' => $mailbox, 'id' => $rr['id'], 'from_name' => $rr['from']['xchan_name'], @@ -57,14 +59,14 @@ class Conversations { 'date' => datetime_convert('UTC',date_default_timezone_get(),$rr['created'], 'c'), 'seen' => $rr['seen'], 'selected' => ((argv(1) != 'new') ? $selected : '') - ); + ]; } $tpl = get_markup_template('mail_head.tpl'); - $o .= replace_macros($tpl, array( + $o .= replace_macros($tpl, [ '$header' => $header, '$messages' => $messages - )); + ]); } return $o; -- cgit v1.2.3 From aff476d0d457f6debe21dfa1e2a0c3ccdcf71443 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 13 Nov 2017 15:21:49 -0800 Subject: move mailhost settings from plugin to core --- Zotlabs/Module/Settings/Channel.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index 41e23b717..63370a141 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -148,6 +148,8 @@ class Channel { $defpermcat = ((x($_POST,'defpermcat')) ? notags(trim($_POST['defpermcat'])) : 'default'); $cal_first_day = (((x($_POST,'first_day')) && (intval($_POST['first_day']) == 1)) ? 1: 0); + $mailhost = ((array_key_exists('mailhost',$_POST)) ? notags(trim($_POST['mailhost'])) : ''); + $pageflags = $channel['channel_pageflags']; $existing_adult = (($pageflags & PAGE_ADULT) ? 1 : 0); @@ -239,6 +241,7 @@ class Channel { set_pconfig(local_channel(),'system','attach_path',$attach_path); set_pconfig(local_channel(),'system','cal_first_day',$cal_first_day); set_pconfig(local_channel(),'system','default_permcat',$defpermcat); + set_pconfig(local_channel(),'system','email_notify_host',$mailhost); $r = q("update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d $set_perms where channel_id = %d", dbesc($username), @@ -561,6 +564,7 @@ class Channel { '$vnotify11' => array('vnotify11', t('System Registrations'), ($vnotify & VNOTIFY_REGISTER), VNOTIFY_REGISTER, '', $yes_no), '$vnotify12' => array('vnotify12', t('Unseen shared files'), ($vnotify & VNOTIFY_FILES), VNOTIFY_FILES, '', $yes_no), '$vnotify13' => ((get_config('system', 'disable_discover_tab') != 1) ? array('vnotify13', t('Unseen public activity'), ($vnotify & VNOTIFY_PUBS), VNOTIFY_PUBS, '', $yes_no) : array()), + '$mailhost' => [ 'mailhost', t('Email notification hub (hostname)'), get_pconfig(local_channel(),'system','email_notify_host',\App::get_hostname()), sprintf( t('If your channel is mirrored to multiple hubs, set this to your preferred location. This will prevent duplicate email notifications. Example: %s'),\App::get_hostname()) ], '$always_show_in_notices' => array('always_show_in_notices', t('Also show new wall posts, private messages and connections under Notices'), $always_show_in_notices, 1, '', $yes_no), '$evdays' => array('evdays', t('Notify me of events this many days in advance'), $evdays, t('Must be greater than 0')), -- cgit v1.2.3 From 8e534918672c2ccf3614623b8bd368d18318f453 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 14 Nov 2017 17:39:33 -0800 Subject: sort out a few more large image upload issues --- Zotlabs/Storage/Browser.php | 2 -- Zotlabs/Storage/Directory.php | 11 +++++++++++ Zotlabs/Storage/File.php | 11 +++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index 77201f387..b5440aacf 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -210,8 +210,6 @@ class Browser extends DAV\Browser\Plugin { } } - - $attachIcon = ""; // ""; // put the array for this file together diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index 0ed7a3c68..27df3569f 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -299,6 +299,17 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { $is_photo = 1; } + // If we know it's a photo, over-ride the type in case the source system could not determine what it was + + if($is_photo) { + q("update attach set filetype = '%s' where hash = '%s' and uid = %d", + dbesc($gis['mime']), + dbesc($hash), + intval($c[0]['channel_id']) + ); + } + + // updates entry with filesize and timestamp $d = q("UPDATE attach SET filesize = '%s', os_path = '%s', display_path = '%s', is_photo = %d, edited = '%s' WHERE hash = '%s' AND uid = %d", dbesc($size), diff --git a/Zotlabs/Storage/File.php b/Zotlabs/Storage/File.php index 947a9fde3..8bf9997ed 100644 --- a/Zotlabs/Storage/File.php +++ b/Zotlabs/Storage/File.php @@ -168,6 +168,17 @@ class File extends DAV\Node implements DAV\IFile { if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG)) { $is_photo = 1; } + + // If we know it's a photo, over-ride the type in case the source system could not determine what it was + + if($is_photo) { + q("update attach set filetype = '%s' where hash = '%s' and uid = %d", + dbesc($gis['mime']), + dbesc($this->data['hash']), + intval($this->data['uid']) + ); + } + } else { // this shouldn't happen any more -- cgit v1.2.3 From 67b6d41d57b20a223a0cb6f33cbf81473b0936ab Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 15 Nov 2017 11:26:14 -0800 Subject: This should sort out hubzilla issue #826 but requires a bit more testing. It may also sort out some reported issues with commenting and liking items in the public stream. --- Zotlabs/Module/Like.php | 15 +++++++++++---- Zotlabs/Module/Pubstream.php | 5 ++++- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index b104a5f5f..0abf111e0 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -12,7 +12,10 @@ class Like extends \Zotlabs\Web\Controller { function get() { $o = ''; - + + $sys_channel = get_sys_channel(); + $sys_channel_id = (($sys_channel) ? $sys_channel['channel_id'] : 0); + $observer = \App::get_observer(); $interactive = $_REQUEST['interactive']; if($interactive) { @@ -253,20 +256,22 @@ class Like extends \Zotlabs\Web\Controller { logger('like: verb ' . $verb . ' item ' . $item_id, LOGGER_DEBUG); // get the item. Allow linked photos (which are normally hidden) to be liked - + $r = q("SELECT * FROM item WHERE id = %d and (item_type = 0 or item_type = 6) and item_deleted = 0 and item_unpublished = 0 and item_delayed = 0 and item_pending_remove = 0 and item_blocked = 0 LIMIT 1", intval($item_id) ); - + if(! $item_id || (! $r)) { logger('like: no item ' . $item_id); killme(); } + // Use the $effective_uid option of xchan_query to sort out comment permission + // for public stream items - xchan_query($r,true,(($r[0]['uid'] == local_channel()) ? 0 : local_channel())); + xchan_query($r,true,(($r[0]['uid'] == $sys_channel_id) ? local_channel() : 0)); $item = $r[0]; @@ -464,6 +469,8 @@ class Like extends \Zotlabs\Web\Controller { $arr['mid'] = $mid; $arr['aid'] = (($extended_like) ? $ch[0]['channel_account_id'] : $owner_aid); $arr['uid'] = $owner_uid; + + $arr['item_flags'] = $item_flags; $arr['item_wall'] = $item_wall; $arr['parent_mid'] = (($extended_like) ? $mid : $item['mid']); diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 4224fa3c8..0e6c2360f 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -240,7 +240,10 @@ class Pubstream extends \Zotlabs\Web\Controller { dbesc($parents_str) ); - xchan_query($items,true,(-1)); + // use effective_uid param of xchan_query to help sort out comment permission + // for sys_channel owned items. + + xchan_query($items,true,(($sys) ? local_channel() : 0)); $items = fetch_post_tags($items,true); $items = conv_sort($items,$ordering); } -- cgit v1.2.3 From d13a6180be310cb184f891fa2b969542691c1863 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 15 Nov 2017 20:16:51 -0800 Subject: Add private forums to forum widget. The link redirects to the remote channel page rather than a filtered view of your network page because you cannot post to a private forum from your own site. --- Zotlabs/Widget/Forums.php | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Forums.php b/Zotlabs/Widget/Forums.php index 002c0ee21..91b987746 100644 --- a/Zotlabs/Widget/Forums.php +++ b/Zotlabs/Widget/Forums.php @@ -29,18 +29,32 @@ class Forums { ); if($x1) { $xc = ids_to_querystr($x1,'xchan',true); + $x2 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'tag_deliver' and v = '1' and xchan in (" . $xc . ") ", intval(local_channel()) ); - if($x2) + + if($x2) { $xf = ids_to_querystr($x2,'xchan',true); + + // private forums + $x3 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'post_wall' and v = '1' and xchan in (" . $xc . ") and not xchan in (" . $xf . ") ", + intval(local_channel()) + ); + if($x3) { + $xf = ids_to_querystr(array_merge($x2,$x3),'xchan',true); + } + } } $sql_extra = (($xf) ? " and ( xchan_hash in (" . $xf . ") or xchan_pubforum = 1 ) " : " and xchan_pubforum = 1 "); - $r1 = q("select abook_id, xchan_hash, xchan_name, xchan_url, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash where xchan_deleted = 0 and abook_channel = %d $sql_extra order by xchan_name $limit ", + + + $r1 = q("select abook_id, xchan_hash, xchan_name, xchan_url, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash where xchan_deleted = 0 and abook_channel = %d and abook_pending = 0 and abook_ignored = 0 and abook_blocked = 0 $sql_extra order by xchan_name $limit ", intval(local_channel()) ); + if(! $r1) return $o; @@ -85,9 +99,21 @@ class Forums { $o .= '

' . t('Forums') . '

'; } -- cgit v1.2.3 From 78c9f752af8db5db290a57224fa1d0239a36a34d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 16 Nov 2017 11:11:06 +0100 Subject: provide ability to pin apps to navbar from /apps. this removes the ability to have per custom navbar pinned apps - this can be added later if desired --- Zotlabs/Lib/Apps.php | 41 ++++++++++++++++++++++++++++------------ Zotlabs/Module/Appman.php | 6 +++++- Zotlabs/Widget/Appcategories.php | 1 + 3 files changed, 35 insertions(+), 13 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index f13fbe362..bd271e860 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -401,11 +401,15 @@ class Apps { '$undelete' => ((local_channel() && $installed && $mode == 'edit') ? t('Undelete') : ''), '$deleted' => $papp['deleted'], '$feature' => (($papp['embed']) ? false : true), + '$pin' => (($papp['embed']) ? false : true), '$featured' => ((strpos($papp['categories'], 'nav_featured_app') === false) ? false : true), + '$pinned' => ((strpos($papp['categories'], 'nav_pinned_app') === false) ? false : true), '$navapps' => (($mode == 'nav') ? true : false), '$order' => (($mode == 'nav-order') ? true : false), '$add' => t('Add to app-tray'), - '$remove' => t('Remove from app-tray') + '$remove' => t('Remove from app-tray'), + '$add_nav' => t('Add to navbar'), + '$remove_nav' => t('Remove from navbar') )); } @@ -498,25 +502,27 @@ class Apps { } } - static public function app_feature($uid,$app) { + static public function app_feature($uid,$app,$term) { $r = q("select id from app where app_id = '%s' and app_channel = %d limit 1", dbesc($app['guid']), intval($uid) ); - $x = q("select * from term where otype = %d and oid = %d and term = 'nav_featured_app' limit 1", + $x = q("select * from term where otype = %d and oid = %d and term = '%s' limit 1", intval(TERM_OBJ_APP), - intval($r[0]['id']) + intval($r[0]['id']), + dbesc($term) ); if($x) { - q("delete from term where otype = %d and oid = %d and term = 'nav_featured_app'", + q("delete from term where otype = %d and oid = %d and term = '%s'", intval(TERM_OBJ_APP), - intval($x[0]['oid']) + intval($x[0]['oid']), + dbesc($term) ); } else { - store_item_tag($uid,$r[0]['id'],TERM_OBJ_APP,TERM_CATEGORY,'nav_featured_app',escape_tags(z_root() . '/apps/?f=&cat=nav_featured_app')); + store_item_tag($uid, $r[0]['id'], TERM_OBJ_APP, TERM_CATEGORY, $term, escape_tags(z_root() . '/apps/?f=&cat=' . $term)); } } @@ -531,16 +537,27 @@ class Apps { } - static public function app_list($uid, $deleted = false, $cat = '') { + static public function app_list($uid, $deleted = false, $cats = []) { if($deleted) $sql_extra = ""; else $sql_extra = " and app_deleted = 0 "; - if($cat) { - $r = q("select oid from term where otype = %d and term = '%s'", - intval(TERM_OBJ_APP), - dbesc($cat) + if($cats) { + + $cat_sql_extra = " and ( "; + + foreach($cats as $cat) { + if(strpos($cat_sql_extra, 'term')) + $cat_sql_extra .= "or "; + + $cat_sql_extra .= "term = '" . dbesc($cat) . "' "; + } + + $cat_sql_extra .= ") "; + + $r = q("select oid from term where otype = %d $cat_sql_extra", + intval(TERM_OBJ_APP) ); if(! $r) return $r; diff --git a/Zotlabs/Module/Appman.php b/Zotlabs/Module/Appman.php index 5c0667357..64d4628ae 100644 --- a/Zotlabs/Module/Appman.php +++ b/Zotlabs/Module/Appman.php @@ -64,7 +64,11 @@ class Appman extends \Zotlabs\Web\Controller { } if($_POST['feature']) { - Zlib\Apps::app_feature(local_channel(),$papp); + Zlib\Apps::app_feature(local_channel(), $papp, $_POST['feature']); + } + + if($_POST['pin']) { + Zlib\Apps::app_feature(local_channel(), $papp, $_POST['pin']); } if($_SESSION['return_url']) diff --git a/Zotlabs/Widget/Appcategories.php b/Zotlabs/Widget/Appcategories.php index 490ec1abc..8ff14230f 100644 --- a/Zotlabs/Widget/Appcategories.php +++ b/Zotlabs/Widget/Appcategories.php @@ -26,6 +26,7 @@ class Appcategories { and term.uid = app_channel and term.otype = %d and term.term != 'nav_featured_app' + and term.term != 'nav_pinned_app' order by term.term asc", intval(local_channel()), intval(TERM_OBJ_APP) -- cgit v1.2.3 From 3f2b7d756c2bcffef675770d28d5b65b380fc8f5 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 16 Nov 2017 21:42:39 +0100 Subject: add > pin and remove > unpin --- Zotlabs/Lib/Apps.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index bd271e860..bbf777b18 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -408,8 +408,8 @@ class Apps { '$order' => (($mode == 'nav-order') ? true : false), '$add' => t('Add to app-tray'), '$remove' => t('Remove from app-tray'), - '$add_nav' => t('Add to navbar'), - '$remove_nav' => t('Remove from navbar') + '$add_nav' => t('Pin to navbar'), + '$remove_nav' => t('Unpin from navbar') )); } -- cgit v1.2.3 From 7c655c8d61c1210815d024f7945bedf2ae7279fd Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 16 Nov 2017 19:26:56 -0800 Subject: allow svg image previews in cloud browser when using tile mode. --- Zotlabs/Storage/Browser.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index b5440aacf..ee5a9fef4 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -197,6 +197,11 @@ class Browser extends DAV\Browser\Plugin { } } + + // generate preview icons for tile view. + // Currently we only handle images, but this could potentially be extended with plugins + // to provide document and video thumbnails + $photo_icon = ''; if(strpos($type,'image/') === 0 && $attachHash) { @@ -206,8 +211,12 @@ class Browser extends DAV\Browser\Plugin { intval(PHOTO_RES_PROFILE_80) ); if($r) { - $photo_icon = $r[0]['resource_id'] . '-' . $r[0]['imgscale']; + $photo_icon = 'photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale']; } + if($type === 'image/svg+xml') { + $photo_icon = $fullPath; + } + } $attachIcon = ""; // ""; -- cgit v1.2.3 From 601ebee9692c3bb552100f08f789824c68bdd5e0 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 17 Nov 2017 10:40:34 +0100 Subject: strip author name from notify messages in notifications - fix issue #911 --- Zotlabs/Module/Ping.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 3c6dda1e9..b18ff84b8 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -262,6 +262,13 @@ class Ping extends \Zotlabs\Web\Controller { if($t) { foreach($t as $tt) { + + $message = trim(strip_tags(bbcode($tt['msg']))); + $count = 1; + + if(strpos($message, $tt['xname']) === 0) + $message = str_replace($tt['xname'], '', $message, $count); + $notifs[] = array( 'notify_link' => z_root() . '/notify/view/' . $tt['id'], 'name' => $tt['xname'], @@ -269,7 +276,7 @@ class Ping extends \Zotlabs\Web\Controller { 'photo' => $tt['photo'], 'when' => relative_date($tt['created']), 'hclass' => (($tt['seen']) ? 'notify-seen' : 'notify-unseen'), - 'message' => strip_tags(bbcode($tt['msg'])) + 'message' => $message ); } } -- cgit v1.2.3 From 76af8fa754467e13bcd8c83620ac1c174e777170 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 17 Nov 2017 13:54:53 +0100 Subject: inroduce the HQ module - a module with the potential to become a nice landing page for hubzilla. It is nothing more than a downgraded mod display atm. --- Zotlabs/Module/Hq.php | 300 ++++++++++++++++++++++++++++++++++++++++++++++++ Zotlabs/Module/Ping.php | 1 - 2 files changed, 300 insertions(+), 1 deletion(-) create mode 100644 Zotlabs/Module/Hq.php (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php new file mode 100644 index 000000000..1438d2764 --- /dev/null +++ b/Zotlabs/Module/Hq.php @@ -0,0 +1,300 @@ + 1 && argv(1) !== 'load') { + $item_hash = argv(1); + } + + if($_REQUEST['mid']) + $item_hash = $_REQUEST['mid']; + + require_once('include/channel.php'); + $sys = get_sys_channel(); + $sysid = $sys['channel_id']; + + if(! $item_hash) { + + $r = q("SELECT mid FROM item + WHERE uid = %d + AND mid = parent_mid + $item_normal + ORDER BY id DESC + limit 1", + local_channel() ? intval(local_channel()) : intval($sysid) + ); + $item_hash = 'b64.' . base64url_encode($r[0]['mid']); + + if(!$item_hash) { + \App::$error = 404; + notice( t('Item not found.') . EOL); + return; + } + } + + $observer_is_owner = false; + $updateable = false; + + if(local_channel() && (! $update)) { + + $channel = \App::get_channel(); + + $channel_acl = [ + 'allow_cid' => $channel['channel_allow_cid'], + 'allow_gid' => $channel['channel_allow_gid'], + 'deny_cid' => $channel['channel_deny_cid'], + 'deny_gid' => $channel['channel_deny_gid'] + ]; + + $x = [ + 'is_owner' => true, + 'allow_location' => ((intval(get_pconfig($channel['channel_id'],'system','use_browser_location'))) ? '1' : ''), + 'default_location' => $channel['channel_location'], + 'nickname' => $channel['channel_address'], + 'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), + + 'acl' => populate_acl($channel_acl), + 'permissions' => $channel_acl, + 'bang' => '', + 'visitor' => true, + 'profile_uid' => local_channel(), + 'return_path' => 'channel/' . $channel['channel_address'], + 'expanded' => true, + 'editor_autocomplete' => true, + 'bbco_autocomplete' => 'bbcode', + 'bbcode' => true, + 'jotnets' => true + ]; + + $o = '
'; + $o .= status_editor($a,$x); + $o .= '
'; + } + + $target_item = null; + + if(strpos($item_hash,'b64.') === 0) + $decoded = @base64url_decode(substr($item_hash,4)); + if($decoded) + $item_hash = $decoded; + + $r = q("select id, uid, mid, parent_mid, thr_parent, verb, item_type, item_deleted, item_blocked from item where mid like '%s' limit 1", + dbesc($item_hash . '%') + ); + + if($r) { + $target_item = $r[0]; + } + + //if the item is to be moderated redirect to /moderate + if($target_item['item_blocked'] == ITEM_MODERATED) { + goaway(z_root() . '/moderate/' . $target_item['id']); + } + + $r = null; + + if($target_item['item_type'] == ITEM_TYPE_WEBPAGE) { + $x = q("select * from channel where channel_id = %d limit 1", + intval($target_item['uid']) + ); + $y = q("select * from iconfig left join item on iconfig.iid = item.id + where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'WEBPAGE' and item.id = %d limit 1", + intval($target_item['uid']), + intval($target_item['id']) + ); + if($x && $y) { + goaway(z_root() . '/page/' . $x[0]['channel_address'] . '/' . $y[0]['v']); + } + else { + notice( t('Page not found.') . EOL); + return ''; + } + } + + $static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0); + + + $simple_update = (($update) ? " AND item_unseen = 1 " : ''); + + if($update && $_SESSION['loadtime']) + $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; + if($load) + $simple_update = ''; + + if($static && $simple_update) + $simple_update .= " and item_thread_top = 0 and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' "; + + if((! $update) && (! $load)) { + + $static = ((local_channel()) ? channel_manual_conv_update(local_channel()) : 1); + + // if the target item is not a post (eg a like) we want to address its thread parent + + $mid = ((($target_item['verb'] == ACTIVITY_LIKE) || ($target_item['verb'] == ACTIVITY_DISLIKE)) ? $target_item['thr_parent'] : $target_item['mid']); + + // if we got a decoded hash we must encode it again before handing to javascript + if($decoded) + $mid = 'b64.' . base64url_encode($mid); + + $o .= '
' . "\r\n"; + $o .= "\r\n"; + + \App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),[ + '$baseurl' => z_root(), + '$pgtype' => 'display', + '$uid' => '0', + '$gid' => '0', + '$cid' => '0', + '$cmin' => '0', + '$cmax' => '99', + '$star' => '0', + '$liked' => '0', + '$conv' => '0', + '$spam' => '0', + '$fh' => '0', + '$nouveau' => '0', + '$wall' => '0', + '$static' => $static, + '$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1), + '$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0), + '$search' => '', + '$xchan' => '', + '$order' => '', + '$file' => '', + '$cats' => '', + '$tags' => '', + '$dend' => '', + '$dbegin' => '', + '$verb' => '', + '$net' => '', + '$mid' => $mid + ]); + + head_add_link([ + 'rel' => 'alternate', + 'type' => 'application/json+oembed', + 'href' => z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$query_string), + 'title' => 'oembed' + ]); + + } + + $item_normal = item_normal(); + $item_normal_update = item_normal_update(); + + $sql_extra = ''; //public_permissions_sql($observer_hash); + + if(($update && $load) || ($checkjs->disabled())) { + + $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']),intval(\App::$pager['start'])); + + if($load || ($checkjs->disabled())) { + $r = null; + + $r = q("SELECT item.id as item_id from item + WHERE uid = %d + and mid = '%s' + $item_normal + limit 1", + intval(local_channel()), + dbesc($target_item['parent_mid']) + ); + if($r) { + $updateable = true; + } + } + } + + elseif($update && !$load) { + $r = null; + + require_once('include/channel.php'); + $sys = get_sys_channel(); + $sysid = $sys['channel_id']; + + $r = q("SELECT item.parent AS item_id from item + WHERE uid = %d + and parent_mid = '%s' + $item_normal_update + $simple_update + limit 1", + intval(local_channel()), + dbesc($target_item['parent_mid']) + ); + if($r) { + $updateable = true; + } + + $_SESSION['loadtime'] = datetime_convert(); + } + + else { + $r = []; + } + + if($r) { + $parents_str = ids_to_querystr($r,'item_id'); + if($parents_str) { + $items = q("SELECT item.*, item.id AS item_id + FROM item + WHERE parent in ( %s ) $item_normal ", + dbesc($parents_str) + ); + + xchan_query($items); + $items = fetch_post_tags($items,true); + $items = conv_sort($items,'created'); + } + } + else { + $items = []; + } + + + if ($checkjs->disabled()) { + $o .= conversation($items, 'display', $update, 'traditional'); + if ($items[0]['title']) + \App::$page['title'] = $items[0]['title'] . " - " . \App::$page['title']; + } + else { + $o .= conversation($items, 'display', $update, 'client'); + } + + if($updateable) { + $x = q("UPDATE item SET item_unseen = 0 where item_unseen = 1 AND uid = %d and parent = %d ", + intval(local_channel()), + intval($r[0]['item_id']) + ); + } + + $o .= '
'; + + return $o; + + } + +} diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index b18ff84b8..39f123d21 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -262,7 +262,6 @@ class Ping extends \Zotlabs\Web\Controller { if($t) { foreach($t as $tt) { - $message = trim(strip_tags(bbcode($tt['msg']))); $count = 1; -- cgit v1.2.3 From 8e6ebd4f7b84157dec9f4bacc997be71c990a43c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 17 Nov 2017 14:12:10 +0100 Subject: remove obsolete variable --- Zotlabs/Module/Hq.php | 1 - 1 file changed, 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index 1438d2764..65cd84b82 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -55,7 +55,6 @@ class Hq extends \Zotlabs\Web\Controller { } } - $observer_is_owner = false; $updateable = false; if(local_channel() && (! $update)) { -- cgit v1.2.3 From 8a4ee0506cf8acd61c716976fb6760504ce2e8bc Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 17 Nov 2017 21:25:18 +0100 Subject: use substr() instead of str_replace() --- Zotlabs/Module/Ping.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 39f123d21..d05acba6c 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -263,10 +263,9 @@ class Ping extends \Zotlabs\Web\Controller { if($t) { foreach($t as $tt) { $message = trim(strip_tags(bbcode($tt['msg']))); - $count = 1; if(strpos($message, $tt['xname']) === 0) - $message = str_replace($tt['xname'], '', $message, $count); + $message = substr($message, strlen($tt['xname']) + 1); $notifs[] = array( 'notify_link' => z_root() . '/notify/view/' . $tt['id'], -- cgit v1.2.3 From eb1e9edd333161ae600d91ef49ef09dc04fce473 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 17 Nov 2017 13:54:16 -0800 Subject: svg thumbnails have security concerns. Added thumbnail security setting and hook to generate other thumbnails - a plugin for text file thumbnails isn't too difficult (using imagemagick lib), however it's a tossup whether we do this at file submission time or at render time for performance reasons. Perhaps both options should be available. --- Zotlabs/Storage/Browser.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index ee5a9fef4..17b07ad82 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -200,9 +200,13 @@ class Browser extends DAV\Browser\Plugin { // generate preview icons for tile view. // Currently we only handle images, but this could potentially be extended with plugins - // to provide document and video thumbnails + // to provide document and video thumbnails. SVG, PDF and office documents have some + // security concerns and should only be allowed on single-user sites with tightly controlled + // upload access. system.thumbnail_security should be set to 1 if you want to include these + // types $photo_icon = ''; + $preview_style = intval(get_config('system','thumbnail_security',0)); if(strpos($type,'image/') === 0 && $attachHash) { $r = q("select resource_id, imgscale from photo where resource_id = '%s' and imgscale in ( %d, %d ) order by imgscale asc limit 1", @@ -213,12 +217,17 @@ class Browser extends DAV\Browser\Plugin { if($r) { $photo_icon = 'photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale']; } - if($type === 'image/svg+xml') { + if($type === 'image/svg+xml' && $preview_style > 0) { $photo_icon = $fullPath; } } + $g = [ 'resource_id' => $attachHash, 'thumbnail' => $photo_icon, 'security' => $preview_style ]; + call_hooks('file_thumbnail', $g); + $photo_icon = $g['photo_icon']; + + $attachIcon = ""; // ""; // put the array for this file together -- cgit v1.2.3 From fbc57fa8e36e468abe81e4f3d72b3115cbdd794c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 18 Nov 2017 22:16:06 +0100 Subject: some more work on mod hq --- Zotlabs/Module/Hq.php | 117 ++++++++++++++++------------------------------ Zotlabs/Module/Notify.php | 2 +- Zotlabs/Module/Ping.php | 2 + 3 files changed, 42 insertions(+), 79 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index 65cd84b82..a3b2e7a6d 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -10,21 +10,28 @@ require_once('include/items.php'); class Hq extends \Zotlabs\Web\Controller { + function post() { + + if(!local_channel()) + return; + + if($_REQUEST['notify_id']) { + q("update notify set seen = 1 where id = %d and uid = %d", + intval($_REQUEST['notify_id']), + intval(local_channel()) + ); + } + + } + function get($update = 0, $load = false) { if(!local_channel()) return; - $checkjs = new \Zotlabs\Web\CheckJS(1); - if($load) $_SESSION['loadtime'] = datetime_convert(); - if(observer_prohibited()) { - notice( t('Public access denied.') . EOL); - return; - } - if(argc() > 1 && argv(1) !== 'load') { $item_hash = argv(1); } @@ -32,10 +39,6 @@ class Hq extends \Zotlabs\Web\Controller { if($_REQUEST['mid']) $item_hash = $_REQUEST['mid']; - require_once('include/channel.php'); - $sys = get_sys_channel(); - $sysid = $sys['channel_id']; - if(! $item_hash) { $r = q("SELECT mid FROM item @@ -44,7 +47,7 @@ class Hq extends \Zotlabs\Web\Controller { $item_normal ORDER BY id DESC limit 1", - local_channel() ? intval(local_channel()) : intval($sysid) + local_channel() ); $item_hash = 'b64.' . base64url_encode($r[0]['mid']); @@ -57,7 +60,7 @@ class Hq extends \Zotlabs\Web\Controller { $updateable = false; - if(local_channel() && (! $update)) { + if(! $update) { $channel = \App::get_channel(); @@ -113,29 +116,8 @@ class Hq extends \Zotlabs\Web\Controller { goaway(z_root() . '/moderate/' . $target_item['id']); } - $r = null; - - if($target_item['item_type'] == ITEM_TYPE_WEBPAGE) { - $x = q("select * from channel where channel_id = %d limit 1", - intval($target_item['uid']) - ); - $y = q("select * from iconfig left join item on iconfig.iid = item.id - where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'WEBPAGE' and item.id = %d limit 1", - intval($target_item['uid']), - intval($target_item['id']) - ); - if($x && $y) { - goaway(z_root() . '/page/' . $x[0]['channel_address'] . '/' . $y[0]['v']); - } - else { - notice( t('Page not found.') . EOL); - return ''; - } - } - $static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0); - - + $simple_update = (($update) ? " AND item_unseen = 1 " : ''); if($update && $_SESSION['loadtime']) @@ -146,7 +128,7 @@ class Hq extends \Zotlabs\Web\Controller { if($static && $simple_update) $simple_update .= " and item_thread_top = 0 and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' "; - if((! $update) && (! $load)) { + if(! $update && ! $load) { $static = ((local_channel()) ? channel_manual_conv_update(local_channel()) : 1); @@ -159,7 +141,7 @@ class Hq extends \Zotlabs\Web\Controller { $mid = 'b64.' . base64url_encode($mid); $o .= '
' . "\r\n"; - $o .= "\r\n"; \App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),[ @@ -178,7 +160,7 @@ class Hq extends \Zotlabs\Web\Controller { '$nouveau' => '0', '$wall' => '0', '$static' => $static, - '$page' => ((\App::$pager['page'] != 1) ? \App::$pager['page'] : 1), + '$page' => 1, '$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0), '$search' => '', '$xchan' => '', @@ -193,47 +175,30 @@ class Hq extends \Zotlabs\Web\Controller { '$mid' => $mid ]); - head_add_link([ - 'rel' => 'alternate', - 'type' => 'application/json+oembed', - 'href' => z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$query_string), - 'title' => 'oembed' - ]); - } $item_normal = item_normal(); $item_normal_update = item_normal_update(); - $sql_extra = ''; //public_permissions_sql($observer_hash); - - if(($update && $load) || ($checkjs->disabled())) { - - $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']),intval(\App::$pager['start'])); - - if($load || ($checkjs->disabled())) { - $r = null; + if($load) { + $r = null; - $r = q("SELECT item.id as item_id from item - WHERE uid = %d - and mid = '%s' - $item_normal - limit 1", - intval(local_channel()), - dbesc($target_item['parent_mid']) - ); - if($r) { - $updateable = true; - } + $r = q("SELECT item.id as item_id from item + WHERE uid = %d + and mid = '%s' + $item_normal + limit 1", + intval(local_channel()), + dbesc($target_item['parent_mid']) + ); + if($r) { + $updateable = true; } + } - elseif($update && !$load) { + elseif($update) { $r = null; - - require_once('include/channel.php'); - $sys = get_sys_channel(); - $sysid = $sys['channel_id']; $r = q("SELECT item.parent AS item_id from item WHERE uid = %d @@ -273,15 +238,7 @@ class Hq extends \Zotlabs\Web\Controller { $items = []; } - - if ($checkjs->disabled()) { - $o .= conversation($items, 'display', $update, 'traditional'); - if ($items[0]['title']) - \App::$page['title'] = $items[0]['title'] . " - " . \App::$page['title']; - } - else { - $o .= conversation($items, 'display', $update, 'client'); - } + $o .= conversation($items, 'display', $update, 'client'); if($updateable) { $x = q("UPDATE item SET item_unseen = 0 where item_unseen = 1 AND uid = %d and parent = %d ", @@ -292,6 +249,10 @@ class Hq extends \Zotlabs\Web\Controller { $o .= '
'; + if(($update && $load) && (! $items)) { + notice( t('Something went wrong.') . EOL ); + } + return $o; } diff --git a/Zotlabs/Module/Notify.php b/Zotlabs/Module/Notify.php index 3d6e1c2e7..cffcc8099 100644 --- a/Zotlabs/Module/Notify.php +++ b/Zotlabs/Module/Notify.php @@ -34,7 +34,7 @@ class Notify extends \Zotlabs\Web\Controller { } - function get() { + function get() { if(! local_channel()) return login(); diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index d05acba6c..a6df1d3a6 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -274,6 +274,8 @@ class Ping extends \Zotlabs\Web\Controller { 'photo' => $tt['photo'], 'when' => relative_date($tt['created']), 'hclass' => (($tt['seen']) ? 'notify-seen' : 'notify-unseen'), + 'b64mid' => 'b64.' . base64url_encode(basename($tt['link'])), + 'notify_id' => $tt['id'], 'message' => $message ); } -- cgit v1.2.3 From 727b49c8aba0997212b0c4adeb064bd5706a0b2c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 19 Nov 2017 20:37:58 +0100 Subject: do not double encode already encoded mid --- Zotlabs/Module/Ping.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index a6df1d3a6..f98626ffb 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -267,6 +267,11 @@ class Ping extends \Zotlabs\Web\Controller { if(strpos($message, $tt['xname']) === 0) $message = substr($message, strlen($tt['xname']) + 1); + + $mid = basename($tt['link']); + + $b64mid = ((strpos($mid, 'b64.' === 0)) ? $mid : 'b64.' . base64url_encode($mid)); + $notifs[] = array( 'notify_link' => z_root() . '/notify/view/' . $tt['id'], 'name' => $tt['xname'], @@ -274,7 +279,7 @@ class Ping extends \Zotlabs\Web\Controller { 'photo' => $tt['photo'], 'when' => relative_date($tt['created']), 'hclass' => (($tt['seen']) ? 'notify-seen' : 'notify-unseen'), - 'b64mid' => 'b64.' . base64url_encode(basename($tt['link'])), + 'b64mid' => $b64mid, 'notify_id' => $tt['id'], 'message' => $message ); -- cgit v1.2.3 From 744960d36d636f8840f8bcea13283ea7f97cc4e6 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 19 Nov 2017 20:40:50 +0100 Subject: only provide notify id if otype == item --- Zotlabs/Module/Ping.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index f98626ffb..8644b8326 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -280,7 +280,7 @@ class Ping extends \Zotlabs\Web\Controller { 'when' => relative_date($tt['created']), 'hclass' => (($tt['seen']) ? 'notify-seen' : 'notify-unseen'), 'b64mid' => $b64mid, - 'notify_id' => $tt['id'], + 'notify_id' => (($tt['otype'] == 'item') ? $tt['id'] : ''), 'message' => $message ); } -- cgit v1.2.3 From 241a0829dc59c9c4376c10bc2f4ca833510f29eb Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 19 Nov 2017 22:42:16 +0100 Subject: fix issues with apporder related to recent pinned apps changes --- Zotlabs/Lib/Apps.php | 4 ++-- Zotlabs/Module/Apporder.php | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index bbf777b18..9271cee85 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -633,7 +633,7 @@ class Apps { static function moveup($uid,$guid) { $syslist = array(); - $list = self::app_list($uid, false, 'nav_featured_app'); + $list = self::app_list($uid, false, ['nav_featured_app', 'nav_pinned_app']); if($list) { foreach($list as $li) { $syslist[] = self::app_encode($li); @@ -674,7 +674,7 @@ class Apps { static function movedown($uid,$guid) { $syslist = array(); - $list = self::app_list($uid, false, 'nav_featured_app'); + $list = self::app_list($uid, false, ['nav_featured_app', 'nav_pinned_app']); if($list) { foreach($list as $li) { $syslist[] = self::app_encode($li); diff --git a/Zotlabs/Module/Apporder.php b/Zotlabs/Module/Apporder.php index 956548d1f..a9f66ba69 100644 --- a/Zotlabs/Module/Apporder.php +++ b/Zotlabs/Module/Apporder.php @@ -18,7 +18,7 @@ class Apporder extends \Zotlabs\Web\Controller { nav_set_selected('Order Apps'); $syslist = array(); - $list = Zlib\Apps::app_list(local_channel(), false, 'nav_featured_app'); + $list = Zlib\Apps::app_list(local_channel(), false, ['nav_featured_app', 'nav_pinned_app']); if($list) { foreach($list as $li) { $syslist[] = Zlib\Apps::app_encode($li); @@ -31,14 +31,20 @@ class Apporder extends \Zotlabs\Web\Controller { $syslist = Zlib\Apps::app_order(local_channel(),$syslist); foreach($syslist as $app) { - $nav_apps[] = Zlib\Apps::app_render($app,'nav-order'); + if(strpos($app['categories'],'nav_pinned_app') !== false) { + $navbar_apps[] = Zlib\Apps::app_render($app,'nav-order'); + } + else { + $nav_apps[] = Zlib\Apps::app_render($app,'nav-order'); + } } return replace_macros(get_markup_template('apporder.tpl'), [ - '$header' => t('Change Order of Navigation Apps'), - '$desc' => t('Use arrows to move the corresponding app up or down in the display list'), - '$nav_apps' => $nav_apps + '$header' => [t('Change Order of Pinned Navbar Apps'), t('Change Order of App Tray Apps')], + '$desc' => [t('Use arrows to move the corresponding app left (top) or right (bottom) in the navbar'), t('Use arrows to move the corresponding app up or down in the app tray')], + '$nav_apps' => $nav_apps, + '$navbar_apps' => $navbar_apps ] ); } -- cgit v1.2.3 From 88d0bf94d89ac739469528bdab7905d0c00cf8a9 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 19 Nov 2017 23:09:15 +0100 Subject: hq: $item_normal was defined to late --- Zotlabs/Module/Hq.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index a3b2e7a6d..41e9d40ca 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -39,6 +39,9 @@ class Hq extends \Zotlabs\Web\Controller { if($_REQUEST['mid']) $item_hash = $_REQUEST['mid']; + $item_normal = item_normal(); + $item_normal_update = item_normal_update(); + if(! $item_hash) { $r = q("SELECT mid FROM item @@ -177,9 +180,6 @@ class Hq extends \Zotlabs\Web\Controller { } - $item_normal = item_normal(); - $item_normal_update = item_normal_update(); - if($load) { $r = null; -- cgit v1.2.3 From 16f584608f8147a58bfe295ff3295aae0f85b38a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 19 Nov 2017 16:56:59 -0800 Subject: text thumbnails in cloud tile mode --- Zotlabs/Daemon/Thumbnail.php | 62 +++++++++++++++++++++++++++++++++++++++++++ Zotlabs/Storage/Browser.php | 13 +++++++-- Zotlabs/Storage/Directory.php | 2 ++ Zotlabs/Storage/File.php | 3 +++ 4 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 Zotlabs/Daemon/Thumbnail.php (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Thumbnail.php b/Zotlabs/Daemon/Thumbnail.php new file mode 100644 index 000000000..aeea07410 --- /dev/null +++ b/Zotlabs/Daemon/Thumbnail.php @@ -0,0 +1,62 @@ + $t) { + $l = $l + 1; + $x = 3; + $y = ($l * $lsize) + 3 - $fsize; + imagestring($image,1,$x,$y,$t,$colour); + if(($l * $lsize) >= $isize) { + break; + } + } + imagejpeg($image,$attach['content'] . '.thumb'); + } + } + } +} \ No newline at end of file diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index 17b07ad82..dd3067cf8 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -208,6 +208,16 @@ class Browser extends DAV\Browser\Plugin { $photo_icon = ''; $preview_style = intval(get_config('system','thumbnail_security',0)); + $r = q("select content from attach where hash = '%s' and uid = %d limit 1", + dbesc($attachHash), + intval($owner) + ); + + if($r && file_exists(dbunescbin($r[0]['content']) . '.thumb')) { + $photo_icon = 'data:image/jpeg;base64,' . base64_encode(file_get_contents(dbunescbin($r[0]['content']) . '.thumb')); +// logger('found thumb: ' . $photo_icon); + } + if(strpos($type,'image/') === 0 && $attachHash) { $r = q("select resource_id, imgscale from photo where resource_id = '%s' and imgscale in ( %d, %d ) order by imgscale asc limit 1", dbesc($attachHash), @@ -220,12 +230,11 @@ class Browser extends DAV\Browser\Plugin { if($type === 'image/svg+xml' && $preview_style > 0) { $photo_icon = $fullPath; } - } $g = [ 'resource_id' => $attachHash, 'thumbnail' => $photo_icon, 'security' => $preview_style ]; call_hooks('file_thumbnail', $g); - $photo_icon = $g['photo_icon']; + $photo_icon = $g['thumbnail']; $attachIcon = ""; // ""; diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index 27df3569f..45df9ddd5 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -362,6 +362,8 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { $args = array( 'resource_id' => $hash, 'album' => $album, 'os_syspath' => $f, 'os_path' => $xpath['os_path'], 'display_path' => $xpath['path'], 'filename' => $name, 'getimagesize' => $gis, 'directory' => $direct); $p = photo_upload($c[0], \App::get_observer(), $args); } + + \Zotlabs\Daemon\Master::Summon([ 'Thumbnail' , $this->folder_hash ]); $sync = attach_export_data($c[0], $hash); diff --git a/Zotlabs/Storage/File.php b/Zotlabs/Storage/File.php index 8bf9997ed..37376c177 100644 --- a/Zotlabs/Storage/File.php +++ b/Zotlabs/Storage/File.php @@ -244,6 +244,9 @@ class File extends DAV\Node implements DAV\IFile { } } + \Zotlabs\Daemon\Master::Summon([ 'Thumbnail' , $this->data['hash'] ]); + + $sync = attach_export_data($c[0],$this->data['hash']); if($sync) -- cgit v1.2.3 From 250d947667b1500633d80b043ac3760be21446fc Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 19 Nov 2017 21:51:21 -0800 Subject: cloud tiles: use folder-o for folders and set the icon colour to something a bit less harsh than the link colour for system icons. Dark solid blue folders are a bit overwhelming, as is the default text_colour (black) --- Zotlabs/Module/Ping.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 8644b8326..406e554d1 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -492,10 +492,11 @@ class Ping extends \Zotlabs\Web\Controller { $t3 = dba_timer(); if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) { + $r = q("SELECT id, item_wall FROM item WHERE item_unseen = 1 and uid = %d $item_normal - AND author_xchan != '%s'", + AND author_xchan != '%s' $sql_extra ", intval(local_channel()), dbesc($ob_hash) ); -- cgit v1.2.3 From 624196711242cb5bf398ff2d368e73a10e65b67e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 20 Nov 2017 09:57:07 +0100 Subject: speed up initial query if no mid is provided --- Zotlabs/Module/Hq.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index 41e9d40ca..ad39768f4 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -46,6 +46,7 @@ class Hq extends \Zotlabs\Web\Controller { $r = q("SELECT mid FROM item WHERE uid = %d + AND item_unseen = 1 AND mid = parent_mid $item_normal ORDER BY id DESC -- cgit v1.2.3 From 66c0ac591cd342a31348ad54723fd269659251c6 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 20 Nov 2017 10:00:13 +0100 Subject: order by created instead of id --- Zotlabs/Module/Hq.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index ad39768f4..e2efc6a0d 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -49,7 +49,7 @@ class Hq extends \Zotlabs\Web\Controller { AND item_unseen = 1 AND mid = parent_mid $item_normal - ORDER BY id DESC + ORDER BY created DESC limit 1", local_channel() ); -- cgit v1.2.3 From 9ab33f1e134e6e7694a42b92fc9d73c2e6dcffd1 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 20 Nov 2017 11:05:08 +0100 Subject: we need a mid also if there is no unseen items --- Zotlabs/Module/Hq.php | 1 - 1 file changed, 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index e2efc6a0d..92dfc8587 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -46,7 +46,6 @@ class Hq extends \Zotlabs\Web\Controller { $r = q("SELECT mid FROM item WHERE uid = %d - AND item_unseen = 1 AND mid = parent_mid $item_normal ORDER BY created DESC -- cgit v1.2.3 From 56d981c8ef0680d5124214b4cd8849b9a42feeb7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 20 Nov 2017 14:48:29 -0800 Subject: provide a generalised interface for thumbnail generators to support various content types --- Zotlabs/Daemon/Thumbnail.php | 60 ++++++++++++++++++-------------------------- Zotlabs/Thumbs/Text.php | 49 ++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 35 deletions(-) create mode 100644 Zotlabs/Thumbs/Text.php (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Thumbnail.php b/Zotlabs/Daemon/Thumbnail.php index aeea07410..caf5dd3ae 100644 --- a/Zotlabs/Daemon/Thumbnail.php +++ b/Zotlabs/Daemon/Thumbnail.php @@ -17,46 +17,36 @@ class Thumbnail { if(! $c) return; - $preview_style = intval(get_config('system','thumbnail_security',0)); + $preview_style = intval(get_config('system','thumbnail_security',0)); + $preview_width = intval(get_config('system','thumbnail_width',300)); + $preview_height = intval(get_config('system','thumbnail_height',300)); $attach = $c[0]; - $isize = 300; + $default_controller = null; - if(strpos($attach['filetype'],'text/') !== false) { - $stream = @fopen($attach['content'],'rb'); - if($stream) { - $content = trim(stream_get_contents($stream,4096)); - $content = str_replace("\r",'',$content); - $content_a = explode("\n",$content); - } - if($content_a) { - $fsize = 4; - $lsize = 8; - $image = imagecreate($isize,$isize); - imagecolorallocate($image,255,255,255); - $colour = imagecolorallocate($image,0,0,0); - $border = imagecolorallocate($image,64,64,64); - - $x1 = 0; - $y1 = 0; - $x2 = ImageSX($image) - 1; - $y2 = ImageSY($image) - 1; - - for($i = 0; $i < 2; $i++) { - ImageRectangle($image, $x1++, $y1++, $x2--, $y2--, $border); - } - - foreach($content_a as $l => $t) { - $l = $l + 1; - $x = 3; - $y = ($l * $lsize) + 3 - $fsize; - imagestring($image,1,$x,$y,$t,$colour); - if(($l * $lsize) >= $isize) { - break; + $files = glob('Zotlabs/Thumbs/*.php'); + if($files) { + foreach($files as $f) { + $clsname = '\\Zotlabs\\Thumbs\\' . ucfirst(basename($f,'.php')); + if(class_exists($clsname)) { + $x = new $clsname(); + if(method_exists($x,'Match')) { + $matched = $x->Match($attach['filetype']); + if($matched) { + $x->Thumb($attach,$preview_style,$preview_width,$preview_height); + } + } + if(method_exists($x,'MatchDefault')) { + $default_matched = $x->MatchDefault(substr($attach['filetype'],0,strpos($attach['filetype'],'/'))); + if($default_matched) { + $default_controller = $x; + } } } - imagejpeg($image,$attach['content'] . '.thumb'); } } + if(($default_controller) && (! file_exists(dbunescbin($attach['content']) . '.thumb'))) { + $default_controller->Thumb($attach,$preview_style,$preview_width,$preview_height); + } } -} \ No newline at end of file +} diff --git a/Zotlabs/Thumbs/Text.php b/Zotlabs/Thumbs/Text.php new file mode 100644 index 000000000..86d788992 --- /dev/null +++ b/Zotlabs/Thumbs/Text.php @@ -0,0 +1,49 @@ + $t) { + $l = $l + 1; + $x = 3; + $y = ($l * $lsize) + 3 - $fsize; + imagestring($image,1,$x,$y,$t,$colour); + if(($l * $lsize) >= $height) { + break; + } + } + imagejpeg($image,dbunescbin($attach['content']) . '.thumb'); + } + } +} \ No newline at end of file -- cgit v1.2.3 From d2e3e3003a4291416bc97ee6b23903a70c08bf5f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 20 Nov 2017 15:02:23 -0800 Subject: set display_path for photo_upload from the DAV File interface --- Zotlabs/Storage/File.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Storage/File.php b/Zotlabs/Storage/File.php index 37376c177..53d5d3476 100644 --- a/Zotlabs/Storage/File.php +++ b/Zotlabs/Storage/File.php @@ -129,12 +129,16 @@ class File extends DAV\Node implements DAV\IFile { $album = ''; $os_path = ''; - $r = q("SELECT flags, folder, os_storage, os_path, filename, is_photo FROM attach WHERE hash = '%s' AND uid = %d LIMIT 1", + $r = q("SELECT flags, folder, os_storage, os_path, display_path, filename, is_photo FROM attach WHERE hash = '%s' AND uid = %d LIMIT 1", dbesc($this->data['hash']), intval($c[0]['channel_id']) ); if ($r) { + $os_path = $r[0]['os_path']; + $display_path = $r[0]['display_path']; + $filename = $r[0]['filename']; + if (intval($r[0]['os_storage'])) { $d = q("select folder, content from attach where hash = '%s' and uid = %d limit 1", @@ -210,7 +214,7 @@ class File extends DAV\Node implements DAV\IFile { if($is_photo) { require_once('include/photos.php'); - $args = array( 'resource_id' => $this->data['hash'], 'album' => $album, 'os_syspath' => $f, 'os_path' => $os_path, 'filename' => $r[0]['filename'], 'getimagesize' => $gis, 'directory' => $direct ); + $args = array( 'resource_id' => $this->data['hash'], 'album' => $album, 'os_syspath' => $f, 'os_path' => $os_path, 'display_path' => $display_path, 'filename' => $filename, 'getimagesize' => $gis, 'directory' => $direct ); $p = photo_upload($c[0],\App::get_observer(),$args); } -- cgit v1.2.3 From 7f9ab491f29a71387bbbb066b9f6cea083d8813c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 20 Nov 2017 15:44:25 -0800 Subject: add mp3 audio thumbnail generator --- Zotlabs/Thumbs/Mp3audio.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Zotlabs/Thumbs/Mp3audio.php (limited to 'Zotlabs') diff --git a/Zotlabs/Thumbs/Mp3audio.php b/Zotlabs/Thumbs/Mp3audio.php new file mode 100644 index 000000000..d2e660cf8 --- /dev/null +++ b/Zotlabs/Thumbs/Mp3audio.php @@ -0,0 +1,37 @@ +analyze(dbunescbin($attach['content'])); + + $photo = isset($id['id3v2']['APIC'][0]['data']) ? $id['id3v2']['APIC'][0]['data'] : null; + if(is_null($photo) && isset($id['id3v2']['PIC'][0]['data'])) { + $photo = $id['id3v2']['PIC'][0]['data']; + } + + if($photo) { + $image = imagecreatefromstring($photo); + $dest = imagecreatetruecolor( $width, $height ); + $srcwidth = imagesx($image); + $srcheight = imagesy($image); + + imagealphablending($dest, false); + imagesavealpha($dest, true); + imagecopyresampled($dest, $image, 0, 0, 0, 0, $width, $height, $srcwidth, $srcheight); + imagedestroy($image); + imagejpeg($dest,dbunescbin($attach['content']) . '.thumb'); + } + } +} + -- cgit v1.2.3 From 1810edae93565d5340e724b4411520ea18e2b7e0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 20 Nov 2017 16:05:24 -0800 Subject: more work theming the tile view --- Zotlabs/Thumbs/Text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Thumbs/Text.php b/Zotlabs/Thumbs/Text.php index 86d788992..3ee7819bd 100644 --- a/Zotlabs/Thumbs/Text.php +++ b/Zotlabs/Thumbs/Text.php @@ -23,7 +23,7 @@ class Text { $image = imagecreate($width,$height); imagecolorallocate($image,255,255,255); $colour = imagecolorallocate($image,0,0,0); - $border = imagecolorallocate($image,64,64,64); + $border = imagecolorallocate($image,208,208,208); $x1 = 0; $y1 = 0; -- cgit v1.2.3 From 53445ba6bdd1cde780f4a3d84cbb061cb6b72df9 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 20 Nov 2017 18:14:44 -0800 Subject: fix album cover thumb generator --- Zotlabs/Thumbs/Mp3audio.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Thumbs/Mp3audio.php b/Zotlabs/Thumbs/Mp3audio.php index d2e660cf8..000d65b22 100644 --- a/Zotlabs/Thumbs/Mp3audio.php +++ b/Zotlabs/Thumbs/Mp3audio.php @@ -2,7 +2,7 @@ namespace Zotlabs\Thumbs; -use ID3Parser\ID3Parser; +use \ID3Parser\ID3Parser; class Mp3audio { @@ -11,7 +11,7 @@ class Mp3audio { } function Thumb($attach,$preview_style,$height = 300, $width = 300) { - $p = newID3Parser(); + $p = new ID3Parser(); $id = $p->analyze(dbunescbin($attach['content'])); -- cgit v1.2.3 From 159d6469fd45818dd24137894ce1792531753417 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 21 Nov 2017 10:19:50 +0100 Subject: make browser history buttons work with ajax calls in /display and /hq --- Zotlabs/Module/Hq.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index 92dfc8587..71008b6d2 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -47,19 +47,24 @@ class Hq extends \Zotlabs\Web\Controller { $r = q("SELECT mid FROM item WHERE uid = %d AND mid = parent_mid - $item_normal ORDER BY created DESC limit 1", local_channel() ); - $item_hash = 'b64.' . base64url_encode($r[0]['mid']); - if(!$item_hash) { + if(!$r[0]['mid']) { \App::$error = 404; notice( t('Item not found.') . EOL); return; } + + $item_hash = 'b64.' . base64url_encode($r[0]['mid']); } + + if(strpos($item_hash,'b64.') === 0) + $decoded = @base64url_decode(substr($item_hash,4)); + if($decoded) + $item_hash = $decoded; $updateable = false; @@ -101,11 +106,6 @@ class Hq extends \Zotlabs\Web\Controller { $target_item = null; - if(strpos($item_hash,'b64.') === 0) - $decoded = @base64url_decode(substr($item_hash,4)); - if($decoded) - $item_hash = $decoded; - $r = q("select id, uid, mid, parent_mid, thr_parent, verb, item_type, item_deleted, item_blocked from item where mid like '%s' limit 1", dbesc($item_hash . '%') ); -- cgit v1.2.3 From d942818bd9d9e90db7a3083bfe33a54732f6184d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 21 Nov 2017 22:10:09 +0100 Subject: use item_thread_top = 1 instead of mid = parent_mid and make sure local_channel is intval --- Zotlabs/Module/Hq.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index 71008b6d2..78087c0f9 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -45,11 +45,11 @@ class Hq extends \Zotlabs\Web\Controller { if(! $item_hash) { $r = q("SELECT mid FROM item - WHERE uid = %d - AND mid = parent_mid + WHERE uid = %d + AND item_thread_top = 1 ORDER BY created DESC limit 1", - local_channel() + intval(local_channel()) ); if(!$r[0]['mid']) { -- cgit v1.2.3 From 8dceb8e3a75282540d7dbe9dc6e26091dad71fe0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 21 Nov 2017 14:30:26 -0800 Subject: thumbnail generator for epubs --- Zotlabs/Daemon/Thumbnail.php | 4 +++- Zotlabs/Thumbs/Epubthumb.php | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 Zotlabs/Thumbs/Epubthumb.php (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Thumbnail.php b/Zotlabs/Daemon/Thumbnail.php index caf5dd3ae..b3e539086 100644 --- a/Zotlabs/Daemon/Thumbnail.php +++ b/Zotlabs/Daemon/Thumbnail.php @@ -45,7 +45,9 @@ class Thumbnail { } } } - if(($default_controller) && (! file_exists(dbunescbin($attach['content']) . '.thumb'))) { + if(($default_controller) + && ((! file_exists(dbunescbin($attach['content']) . '.thumb')) + || (filectime(dbunescbin($attach['content']) . 'thumb') < (time() - 60)))) { $default_controller->Thumb($attach,$preview_style,$preview_width,$preview_height); } } diff --git a/Zotlabs/Thumbs/Epubthumb.php b/Zotlabs/Thumbs/Epubthumb.php new file mode 100644 index 000000000..4213b5267 --- /dev/null +++ b/Zotlabs/Thumbs/Epubthumb.php @@ -0,0 +1,38 @@ +Cover(); + + if($data['found']) { + $photo = $data['data']; + } + + if($photo) { + $image = imagecreatefromstring($photo); + $dest = imagecreatetruecolor( $width, $height ); + $srcwidth = imagesx($image); + $srcheight = imagesy($image); + + imagealphablending($dest, false); + imagesavealpha($dest, true); + imagecopyresampled($dest, $image, 0, 0, 0, 0, $width, $height, $srcwidth, $srcheight); + imagedestroy($image); + imagejpeg($dest,dbunescbin($attach['content']) . '.thumb'); + } + } +} + -- cgit v1.2.3 From 09f1e4bdfbc7659cfb9f8db9b6c3278a66e08db7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 21 Nov 2017 15:10:23 -0800 Subject: pdf thumbnails --- Zotlabs/Thumbs/Pdf.php | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Zotlabs/Thumbs/Pdf.php (limited to 'Zotlabs') diff --git a/Zotlabs/Thumbs/Pdf.php b/Zotlabs/Thumbs/Pdf.php new file mode 100644 index 000000000..5d413140f --- /dev/null +++ b/Zotlabs/Thumbs/Pdf.php @@ -0,0 +1,49 @@ + Date: Tue, 21 Nov 2017 16:06:03 -0800 Subject: Video thumbnail generator --- Zotlabs/Thumbs/Pdf.php | 10 ++++----- Zotlabs/Thumbs/Video.php | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 Zotlabs/Thumbs/Video.php (limited to 'Zotlabs') diff --git a/Zotlabs/Thumbs/Pdf.php b/Zotlabs/Thumbs/Pdf.php index 5d413140f..98bcf11b5 100644 --- a/Zotlabs/Thumbs/Pdf.php +++ b/Zotlabs/Thumbs/Pdf.php @@ -19,10 +19,10 @@ class Pdf { $istream = fopen($file,'rb'); $ostream = fopen($tmpfile,'wb'); - if($istream && $ostream) { - pipe_streams($istream,$ostream); - fclose($istream); - fclose($ostream); + if($istream && $ostream) { + pipe_streams($istream,$ostream); + fclose($istream); + fclose($ostream); } $imagick_path = get_config('system','imagick_convert_path'); @@ -42,8 +42,8 @@ class Pdf { else { @rename($outfile,$file . '.thumb'); } - @unlink($tmpfile); } + @unlink($tmpfile); } } diff --git a/Zotlabs/Thumbs/Video.php b/Zotlabs/Thumbs/Video.php new file mode 100644 index 000000000..5e09ef9a3 --- /dev/null +++ b/Zotlabs/Thumbs/Video.php @@ -0,0 +1,53 @@ + Date: Tue, 21 Nov 2017 16:22:17 -0800 Subject: expose the security setting for SVG thumbnails --- Zotlabs/Module/Admin/Site.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php index 2df8b9908..eda97b591 100644 --- a/Zotlabs/Module/Admin/Site.php +++ b/Zotlabs/Module/Admin/Site.php @@ -63,6 +63,7 @@ class Site { $verify_email = ((x($_POST,'verify_email')) ? 1 : 0); $techlevel_lock = ((x($_POST,'techlock')) ? intval($_POST['techlock']) : 0); $imagick_path = ((x($_POST,'imagick_path')) ? trim($_POST['imagick_path']) : ''); + $thumbnail_security = ((x($_POST,'thumbnail_security')) ? intval($_POST['thumbnail_security']) : 0); $force_queue = ((intval($_POST['force_queue']) > 0) ? intval($_POST['force_queue']) : 300); $techlevel = null; @@ -85,7 +86,7 @@ class Site { set_config('system', 'from_email', $from_email); set_config('system', 'from_email_name' , $from_email_name); set_config('system', 'imagick_convert_path' , $imagick_path); - + set_config('system', 'thumbnail_security' , $thumbnail_security); set_config('system', 'techlevel_lock', $techlevel_lock); @@ -323,6 +324,7 @@ class Site { '$force_queue' => array('force_queue', t("Queue Threshold"), get_config('system','force_queue_threshold',300), t("Always defer immediate delivery if queue contains more than this number of entries.")), '$poll_interval' => array('poll_interval', t("Poll interval"), (x(get_config('system','poll_interval'))?get_config('system','poll_interval'):2), t("Delay background polling processes by this many seconds to reduce system load. If 0, use delivery interval.")), '$imagick_path' => array('imagick_path', t("Path to ImageMagick convert program"), get_config('system','imagick_convert_path'), t("If set, use this program to generate photo thumbnails for huge images ( > 4000 pixels in either dimension), otherwise memory exhaustion may occur. Example: /usr/bin/convert")), + '$thumbnail_security' => array('thumbnail_security', t("Allow SVG thumbnails in file browser"), get_config('system','thumbnail_security',0), t("WARNING: SVG images may contain malicious code.")), '$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")), '$default_expire_days' => array('default_expire_days', t('Expiration period in days for imported (grid/network) content'), intval(get_config('system','default_expire_days')), t('0 for no expiration of imported content')), '$form_security_token' => get_form_security_token("admin_site"), -- cgit v1.2.3 From eb69f6c346af5775471f0bd57a5ed8709f6ff2a4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 21 Nov 2017 17:56:23 -0800 Subject: add thumbnail hook --- Zotlabs/Daemon/Thumbnail.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Thumbnail.php b/Zotlabs/Daemon/Thumbnail.php index b3e539086..e1f17c304 100644 --- a/Zotlabs/Daemon/Thumbnail.php +++ b/Zotlabs/Daemon/Thumbnail.php @@ -17,11 +17,35 @@ class Thumbnail { if(! $c) return; + $attach = $c[0]; + $preview_style = intval(get_config('system','thumbnail_security',0)); $preview_width = intval(get_config('system','thumbnail_width',300)); $preview_height = intval(get_config('system','thumbnail_height',300)); - $attach = $c[0]; + $p = [ + 'attach' => $attach, + 'preview_style' => $preview_style, + 'preview_width' => $preview_width, + 'preview_height' => $preview_height, + 'thumbnail' => null + ]; + + /** + * @hooks thumbnail + * * \e array \b attach + * * \e int \b preview_style + * * \e int \b preview_width + * * \e int \b preview_height + * * \e string \b thumbnail + */ + + call_hooks('thumbnail',$p); + if($p['thumbnail']) { + return; + } + + $default_controller = null; $files = glob('Zotlabs/Thumbs/*.php'); -- cgit v1.2.3 From 8bd8af7d16d6b4fb40680bd33b99bbfd582a1208 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 22 Nov 2017 11:49:28 -0800 Subject: initial articles feature --- Zotlabs/Module/Articles.php | 187 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 Zotlabs/Module/Articles.php (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Articles.php b/Zotlabs/Module/Articles.php new file mode 100644 index 000000000..bebbd5139 --- /dev/null +++ b/Zotlabs/Module/Articles.php @@ -0,0 +1,187 @@ + 1) + $which = argv(1); + else + return; + + profile_load($which); + + } + + function get($update = 0, $load = false) { + + if(observer_prohibited(true)) { + return login(); + } + + if(! \App::$profile) { + notice( t('Requested profile is not available.') . EOL ); + \App::$error = 404; + return; + } + + if(! feature_enabled(\App::$profile_uid,'articles')) { + return; + } + + nav_set_selected(t('Cards')); + + head_add_link([ + 'rel' => 'alternate', + 'type' => 'application/json+oembed', + 'href' => z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$query_string), + 'title' => 'oembed' + ]); + + + $category = (($_REQUEST['cat']) ? escape_tags(trim($_REQUEST['cat'])) : ''); + + if($category) { + $sql_extra2 .= protect_sprintf(term_item_parent_query(\App::$profile['profile_uid'],'item', $category, TERM_CATEGORY)); + } + + + $which = argv(1); + + $selected_card = ((argc() > 2) ? argv(2) : ''); + + $_SESSION['return_url'] = \App::$query_string; + + $uid = local_channel(); + $owner = \App::$profile_uid; + $observer = \App::get_observer(); + + $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); + + if(! perm_is_allowed($owner,$ob_hash,'view_pages')) { + notice( t('Permission denied.') . EOL); + return; + } + + $is_owner = ($uid && $uid == $owner); + + $channel = channelx_by_n($owner); + + if($channel) { + $channel_acl = array( + 'allow_cid' => $channel['channel_allow_cid'], + 'allow_gid' => $channel['channel_allow_gid'], + 'deny_cid' => $channel['channel_deny_cid'], + 'deny_gid' => $channel['channel_deny_gid'] + ); + } + else { + $channel_acl = [ 'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; + } + + + + if(perm_is_allowed($owner,$ob_hash,'write_pages')) { + + $x = [ + 'webpage' => ITEM_TYPE_ARTICLE, + 'is_owner' => true, + 'content_label' => t('Add Article'), + 'button' => t('Create'), + 'nickname' => $channel['channel_address'], + 'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] + || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), + 'acl' => (($is_owner) ? populate_acl($channel_acl, false, + \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_pages')) : ''), + 'permissions' => $channel_acl, + 'showacl' => (($is_owner) ? true : false), + 'visitor' => true, + 'hide_location' => false, + 'hide_voting' => false, + 'profile_uid' => intval($owner), + 'mimetype' => 'text/bbcode', + 'mimeselect' => false, + 'layoutselect' => false, + 'expanded' => false, + 'novoting' => false, + 'catsenabled' => feature_enabled($owner,'categories'), + 'bbco_autocomplete' => 'bbcode', + 'bbcode' => true + ]; + + if($_REQUEST['title']) + $x['title'] = $_REQUEST['title']; + if($_REQUEST['body']) + $x['body'] = $_REQUEST['body']; + $editor = status_editor($a,$x); + + } + else { + $editor = ''; + } + + + $sql_extra = item_permissions_sql($owner); + + if($selected_card) { + $r = q("select * from iconfig where iconfig.cat = 'system' and iconfig.k = 'ARTICLE' and iconfig.v = '%s' limit 1", + dbesc($selected_card) + ); + if($r) { + $sql_extra .= "and item.id = " . intval($r[0]['iid']) . " "; + } + } + + $r = q("select * from item + where item.uid = %d and item_type = %d + $sql_extra order by item.created desc", + intval($owner), + intval(ITEM_TYPE_ARTICLE) + ); + + $item_normal = " and item.item_hidden = 0 and item.item_type in (0,7) and item.item_deleted = 0 + and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0 + and item.item_blocked = 0 "; + + if($r) { + + $parents_str = ids_to_querystr($r,'id'); + + $items = q("SELECT item.*, item.id AS item_id + FROM item + WHERE item.uid = %d $item_normal + AND item.parent IN ( %s ) + $sql_extra $sql_extra2 ", + intval(\App::$profile['profile_uid']), + dbesc($parents_str) + ); + if($items) { + xchan_query($items); + $items = fetch_post_tags($items, true); + $items = conv_sort($items,'updated'); + } + else + $items = []; + } + + $mode = 'cards'; + + $content = conversation($items,$mode,false,'traditional'); + + $o = replace_macros(get_markup_template('cards.tpl'), [ + '$title' => t('Articles'), + '$editor' => $editor, + '$content' => $content, + '$pager' => alt_pager($a,count($items)) + ]); + + return $o; + } + +} -- cgit v1.2.3 From 6c178d44858bbdfd582d09eb4568d32292c0b2c2 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 22 Nov 2017 15:39:06 -0800 Subject: article feature --- Zotlabs/Lib/ThreadItem.php | 12 +++- Zotlabs/Lib/ThreadStream.php | 5 ++ Zotlabs/Module/Article_edit.php | 138 +++++++++++++++++++++++++++++++++++++ Zotlabs/Module/Articles.php | 2 +- Zotlabs/Module/Item.php | 15 ++++ Zotlabs/Module/Oep.php | 85 +++++++++++++++++++++++ Zotlabs/Module/Update_articles.php | 39 +++++++++++ Zotlabs/Widget/Categories.php | 10 ++- 8 files changed, 303 insertions(+), 3 deletions(-) create mode 100644 Zotlabs/Module/Article_edit.php create mode 100644 Zotlabs/Module/Update_articles.php (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 67a507025..143cc4cc7 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -105,7 +105,17 @@ class ThreadItem { $mode = $conv->get_mode(); - $edlink = (($item['item_type'] == ITEM_TYPE_CARD) ? 'card_edit' : 'editpost'); + switch($item['item_type']) { + case ITEM_TYPE_CARD: + $edlink = 'card_edit'; + break; + case ITEM_TYPE_ARTICLE: + $edlink = 'article_edit'; + break; + default: + $edlink = 'editpost'; + break; + } if(local_channel() && $observer['xchan_hash'] === $item['author_xchan']) $edpost = array(z_root() . '/' . $edlink . '/' . $item['id'], t('Edit')); diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php index 436723f8c..9eebb929c 100644 --- a/Zotlabs/Lib/ThreadStream.php +++ b/Zotlabs/Lib/ThreadStream.php @@ -63,6 +63,11 @@ class ThreadStream { $this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments'); $this->reload = $_SESSION['return_url']; break; + case 'articles': + $this->profile_owner = \App::$profile['profile_uid']; + $this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments'); + $this->reload = $_SESSION['return_url']; + break; case 'display': // in this mode we set profile_owner after initialisation (from conversation()) and then // pull some trickery which allows us to re-invoke this function afterward diff --git a/Zotlabs/Module/Article_edit.php b/Zotlabs/Module/Article_edit.php new file mode 100644 index 000000000..758c1db2e --- /dev/null +++ b/Zotlabs/Module/Article_edit.php @@ -0,0 +1,138 @@ + 1) ? intval(argv(1)) : 0); + + if(! $post_id) { + notice( t('Item not found') . EOL); + return; + } + + $itm = q("SELECT * FROM item WHERE id = %d and item_type = %d LIMIT 1", + intval($post_id), + intval(ITEM_TYPE_ARTICLE) + ); + if($itm) { + $item_id = q("select * from iconfig where cat = 'system' and k = 'ARTICLE' and iid = %d limit 1", + intval($itm[0]['id']) + ); + if($item_id) + $card_title = $item_id[0]['v']; + } + else { + notice( t('Item not found') . EOL); + return; + } + + $owner = $itm[0]['uid']; + $uid = local_channel(); + + $observer = \App::get_observer(); + + $channel = channelx_by_n($owner); + if(! $channel) { + notice( t('Channel not found.') . EOL); + return; + } + + $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); + + if(! perm_is_allowed($owner,$ob_hash,'write_pages')) { + notice( t('Permission denied.') . EOL); + return; + } + + $is_owner = (($uid && $uid == $owner) ? true : false); + + $o = ''; + + + + $category = ''; + $catsenabled = ((feature_enabled($owner,'categories')) ? 'categories' : ''); + + if ($catsenabled){ + $itm = fetch_post_tags($itm); + + $cats = get_terms_oftype($itm[0]['term'], TERM_CATEGORY); + + foreach ($cats as $cat) { + if (strlen($category)) + $category .= ', '; + $category .= $cat['term']; + } + } + + if($itm[0]['attach']) { + $j = json_decode($itm[0]['attach'],true); + if($j) { + foreach($j as $jj) { + $itm[0]['body'] .= "\n" . '[attachment]' . basename($jj['href']) . ',' . $jj['revision'] . '[/attachment]' . "\n"; + } + } + } + + + $mimetype = $itm[0]['mimetype']; + + $content = $itm[0]['body']; + + + + $rp = 'articles/' . $channel['channel_address']; + + $x = array( + 'nickname' => $channel['channel_address'], + 'bbco_autocomplete'=> 'bbcode', + 'return_path' => $rp, + 'webpage' => ITEM_TYPE_ARTICLE, + 'button' => t('Edit'), + 'writefiles' => perm_is_allowed($owner, get_observer_hash(), 'write_pages'), + 'weblink' => t('Insert web link'), + 'hide_voting' => false, + 'hide_future' => false, + 'hide_location' => false, + 'hide_expire' => false, + 'showacl' => true, + 'acl' => populate_acl($itm[0],false,\Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_pages')), + 'permissions' => $itm[0], + 'lockstate' => (($itm[0]['allow_cid'] || $itm[0]['allow_gid'] || $itm[0]['deny_cid'] || $itm[0]['deny_gid']) ? 'lock' : 'unlock'), + 'ptyp' => $itm[0]['type'], + 'mimeselect' => false, + 'mimetype' => $itm[0]['mimetype'], + 'body' => undo_post_tagging($content), + 'post_id' => $post_id, + 'visitor' => true, + 'title' => htmlspecialchars($itm[0]['title'],ENT_COMPAT,'UTF-8'), + 'placeholdertitle' => t('Title (optional)'), + 'pagetitle' => $card_title, + 'profile_uid' => (intval($channel['channel_id'])), + 'catsenabled' => $catsenabled, + 'category' => $category, + 'bbcode' => (($mimetype == 'text/bbcode') ? true : false) + ); + + $editor = status_editor($a, $x); + + $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( + '$title' => t('Edit Article'), + '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false), + '$id' => $itm[0]['id'], + '$editor' => $editor + )); + + return $o; + + } + +} diff --git a/Zotlabs/Module/Articles.php b/Zotlabs/Module/Articles.php index bebbd5139..25daca81d 100644 --- a/Zotlabs/Module/Articles.php +++ b/Zotlabs/Module/Articles.php @@ -170,7 +170,7 @@ class Articles extends \Zotlabs\Web\Controller { $items = []; } - $mode = 'cards'; + $mode = 'articles'; $content = conversation($items,$mode,false,'traditional'); diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index f2b850ffc..ecbefa1c2 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -629,6 +629,9 @@ class Item extends \Zotlabs\Web\Controller { if($webpage == ITEM_TYPE_CARD) { $catlink = z_root() . '/cards/' . $channel['channel_address'] . '?f=&cat=' . urlencode(trim($cat)); } + elseif($webpage == ITEM_TYPE_ARTICLE) { + $catlink = z_root() . '/articles/' . $channel['channel_address'] . '?f=&cat=' . urlencode(trim($cat)); + } else { $catlink = $owner_xchan['xchan_url'] . '?f=&cat=' . urlencode(trim($cat)); } @@ -733,6 +736,18 @@ class Item extends \Zotlabs\Web\Controller { } } + if($webpage == ITEM_TYPE_ARTICLE) { + $plink = z_root() . '/articles/' . $channel['channel_address'] . '/' . (($pagetitle) ? $pagetitle : substr($mid,0,16)); + } + if(($parent_item) && ($parent_item['item_type'] == ITEM_TYPE_ARTICLE)) { + $r = q("select v from iconfig where iconfig.cat = 'system' and iconfig.k = 'ARTICLE' and iconfig.iid = %d limit 1", + intval($parent_item['id']) + ); + if($r) { + $plink = z_root() . '/articles/' . $channel['channel_address'] . '/' . $r[0]['v']; + } + } + if ((! $plink) && ($item_thread_top)) { $plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $mid; } diff --git a/Zotlabs/Module/Oep.php b/Zotlabs/Module/Oep.php index 5e06d3540..bb3a13b56 100644 --- a/Zotlabs/Module/Oep.php +++ b/Zotlabs/Module/Oep.php @@ -45,6 +45,8 @@ class Oep extends \Zotlabs\Web\Controller { $arr = $this->oep_profile_reply($_REQUEST); elseif(fnmatch('*/cards/*',$url)) $arr = $this->oep_cards_reply($_REQUEST); + elseif(fnmatch('*/articles/*',$url)) + $arr = $this->oep_articles_reply($_REQUEST); if($arr) { if($html) { @@ -232,6 +234,89 @@ class Oep extends \Zotlabs\Web\Controller { } + function oep_articles_reply($args) { + + $ret = []; + $url = $args['url']; + $maxwidth = intval($args['maxwidth']); + $maxheight = intval($args['maxheight']); + + if(preg_match('#//(.*?)/articles/(.*?)/(.*?)(&|\?|$)#',$url,$matches)) { + $nick = $matches[2]; + $res = $matches[3]; + } + if(! ($nick && $res)) + return $ret; + + $channel = channelx_by_nick($nick); + + if(! $channel) + return $ret; + + + if(! perm_is_allowed($channel['channel_id'],get_observer_hash(),'view_pages')) + return $ret; + + $sql_extra = item_permissions_sql($channel['channel_id'],get_observer_hash()); + + $r = q("select * from iconfig where iconfig.cat = 'system' and iconfig.k = 'ARTICLE' and iconfig.v = '%s' limit 1", + dbesc($res) + ); + if($r) { + $sql_extra = "and item.id = " . intval($r[0]['iid']) . " "; + } + else { + return $ret; + } + + $r = q("select * from item + where item.uid = %d and item_type = %d + $sql_extra order by item.created desc", + intval($channel['channel_id']), + intval(ITEM_TYPE_ARTICLE) + ); + + $item_normal = " and item.item_hidden = 0 and item.item_type in (0,7) and item.item_deleted = 0 + and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0 + and item.item_blocked = 0 "; + + if($r) { + xchan_query($r); + $p = fetch_post_tags($r, true); + } + + $x = '2eGriplW^*Jmf4'; + + + $o = "[share author='".urlencode($p[0]['author']['xchan_name']). + "' profile='".$p[0]['author']['xchan_url'] . + "' avatar='".$p[0]['author']['xchan_photo_s']. + "' link='".$p[0]['plink']. + "' posted='".$p[0]['created']. + "' message_id='".$p[0]['mid']."']"; + if($p[0]['title']) + $o .= '[b]'.$p[0]['title'].'[/b]'."\r\n"; + + $o .= $x; + $o .= "[/share]"; + $o = bbcode($o); + + $o = str_replace($x,bbcode($p[0]['body']),$o); + + $ret['type'] = 'rich'; + + $w = (($maxwidth) ? $maxwidth : 640); + $h = (($maxheight) ? $maxheight : intval($w * 2 / 3)); + + $ret['html'] = '
' . $o . '
'; + + $ret['width'] = $w; + $ret['height'] = $h; + + return $ret; + + } + function oep_mid_reply($args) { diff --git a/Zotlabs/Module/Update_articles.php b/Zotlabs/Module/Update_articles.php new file mode 100644 index 000000000..280904f67 --- /dev/null +++ b/Zotlabs/Module/Update_articles.php @@ -0,0 +1,39 @@ + 1) && (argv(1) == 'load')) ? 1 : 0); + + header("Content-type: text/html"); + echo "
\r\n"; + + killme(); + + + $mod = new Articles(); + + $text = $mod->get($profile_uid,$load); + + /** + * reportedly some versions of MSIE don't handle tabs in XMLHttpRequest documents very well + */ + + echo str_replace("\t",' ',$text); + echo (($_GET['msie'] == 1) ? '' : ''); + echo "\r\n"; + killme(); + +} +} diff --git a/Zotlabs/Widget/Categories.php b/Zotlabs/Widget/Categories.php index 305869706..9bfa9742a 100644 --- a/Zotlabs/Widget/Categories.php +++ b/Zotlabs/Widget/Categories.php @@ -13,8 +13,14 @@ class Categories { if(($cards) && (! feature_enabled(\App::$profile['profile_uid'],'cards'))) return ''; + $articles = ((array_key_exists('articles',$arr) && $arr['articles']) ? true : false); + + if(($articles) && (! feature_enabled(\App::$profile['profile_uid'],'articles'))) + return ''; + + if((! \App::$profile['profile_uid']) - || (! perm_is_allowed(\App::$profile['profile_uid'],get_observer_hash(),(($cards) ? 'view_pages' : 'view_stream')))) { + || (! perm_is_allowed(\App::$profile['profile_uid'],get_observer_hash(),(($cards || $articles) ? 'view_pages' : 'view_stream')))) { return ''; } @@ -25,6 +31,8 @@ class Categories { if($cards) return cardcategories_widget($srchurl, $cat); + elseif($articles) + return articlecategories_widget($srchurl, $cat); else return categories_widget($srchurl, $cat); -- cgit v1.2.3 From 8fcf16ee63c86667afe5646ea46d56dd1c96aa08 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 22 Nov 2017 18:39:23 -0800 Subject: optional divider between item header and body --- Zotlabs/Lib/ThreadItem.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 143cc4cc7..197657ab1 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -313,7 +313,7 @@ class ThreadItem { $comment_count_txt = sprintf( tt('%d comment','%d comments',$total_children),$total_children ); $list_unseen_txt = (($unseen_comments) ? sprintf('%d unseen',$unseen_comments) : ''); - + @@ -370,6 +370,7 @@ class ThreadItem { 'unverified' => $unverified, 'forged' => $forged, 'location' => $location, + 'divider' => get_pconfig($conv->get_profile_owner(),'system','item_divider'), 'attend_label' => t('Attend'), 'attend_title' => t('Attendance Options'), 'vote_label' => t('Vote'), -- cgit v1.2.3 From c96f1dbbe22edf5a71170a7a39dd7b6fcea938f5 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 22 Nov 2017 20:24:43 -0800 Subject: mod_file_upload: provide a handler for chunked uploads for when we eventually support this on the client side --- Zotlabs/Module/File_upload.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/File_upload.php b/Zotlabs/Module/File_upload.php index 5c4b9a502..e99118417 100644 --- a/Zotlabs/Module/File_upload.php +++ b/Zotlabs/Module/File_upload.php @@ -47,6 +47,46 @@ class File_upload extends \Zotlabs\Web\Controller { } } else { + + $matches = []; + $partial = false; + + $x = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches); + if($x) { + // logger('Content-Range: ' . print_r($matches,true)); + $partial = true; + } + + if($partial) { + $x = save_chunk($channel,$matches[1],$matches[2],$matches[3]); + if($x['partial']) { + header('Range: bytes=0-' . (($x['length']) ? $x['length'] - 1 : 0)); + json_return_and_die($result); + } + else { + header('Range: bytes=0-' . (($x['size']) ? $x['size'] - 1 : 0)); + + $_FILES['userfile'] = [ + 'name' => $x['name'], + 'type' => $x['type'], + 'tmp_name' => $x['tmp_name'], + 'error' => $x['error'], + 'size' => $x['size'] + ]; + } + } + else { + if(! array_key_exists('userfile',$_FILES)) { + $_FILES['userfile'] = [ + 'name' => $_FILES['files']['name'], + 'type' => $_FILES['files']['type'], + 'tmp_name' => $_FILES['files']['tmp_name'], + 'error' => $_FILES['files']['error'], + 'size' => $_FILES['files']['size'] + ]; + } + } + $r = attach_store($channel, get_observer_hash(), '', $_REQUEST); if($r['success']) { $sync = attach_export_data($channel,$r['data']['hash']); -- cgit v1.2.3 From a99ebd42ec47ea531496f8ca5c07bf2868e21467 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 23 Nov 2017 15:21:50 -0800 Subject: change to bbcode calling parameters: important: will require pulling addons; also some extra checking of server headers in upload functions --- Zotlabs/Module/File_upload.php | 16 ++++++++++------ Zotlabs/Module/Wall_attach.php | 10 ++++++---- 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/File_upload.php b/Zotlabs/Module/File_upload.php index e99118417..296dab708 100644 --- a/Zotlabs/Module/File_upload.php +++ b/Zotlabs/Module/File_upload.php @@ -30,8 +30,8 @@ class File_upload extends \Zotlabs\Web\Controller { $_REQUEST['allow_cid'] = perms2str($_REQUEST['contact_allow']); $_REQUEST['allow_gid'] = perms2str($_REQUEST['group_allow']); - $_REQUEST['deny_cid'] = perms2str($_REQUEST['contact_deny']); - $_REQUEST['deny_gid'] = perms2str($_REQUEST['group_deny']); + $_REQUEST['deny_cid'] = perms2str($_REQUEST['contact_deny']); + $_REQUEST['deny_gid'] = perms2str($_REQUEST['group_deny']); if($_REQUEST['filename']) { $r = attach_mkdir($channel, get_observer_hash(), $_REQUEST); @@ -51,10 +51,14 @@ class File_upload extends \Zotlabs\Web\Controller { $matches = []; $partial = false; - $x = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches); - if($x) { - // logger('Content-Range: ' . print_r($matches,true)); - $partial = true; + + + if(array_key_exists('HTTP_CONTENT_RANGE',$_SERVER)) { + $pm = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches); + if($pm) { + // logger('Content-Range: ' . print_r($matches,true)); + $partial = true; + } } if($partial) { diff --git a/Zotlabs/Module/Wall_attach.php b/Zotlabs/Module/Wall_attach.php index e001ad929..2250e6e44 100644 --- a/Zotlabs/Module/Wall_attach.php +++ b/Zotlabs/Module/Wall_attach.php @@ -41,10 +41,12 @@ class Wall_attach extends \Zotlabs\Web\Controller { $matches = []; $partial = false; - $x = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches); - if($x) { - // logger('Content-Range: ' . print_r($matches,true)); - $partial = true; + if(array_key_exists('HTTP_CONTENT_RANGE',$_SERVER)) { + $pm = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches); + if($pm) { + // logger('Content-Range: ' . print_r($matches,true)); + $partial = true; + } } if($partial) { -- cgit v1.2.3 From 3bb0efd2cb393decf71fc717ef7e431a9f65d374 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 23 Nov 2017 20:35:34 -0800 Subject: remove deprecated $a argument from advanced_profile() --- Zotlabs/Module/Profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Profile.php b/Zotlabs/Module/Profile.php index 43106e3af..4235f0b97 100644 --- a/Zotlabs/Module/Profile.php +++ b/Zotlabs/Module/Profile.php @@ -109,7 +109,7 @@ class Profile extends \Zotlabs\Web\Controller { 'title' => 'oembed' ]); - $o .= advanced_profile($a); + $o .= advanced_profile(); call_hooks('profile_advanced',$o); return $o; -- cgit v1.2.3 From 874cff1a873c306f4174b4910b02de5795a037ca Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 24 Nov 2017 00:12:19 -0800 Subject: sync packet not generated when deleting a file using the web browser interface --- Zotlabs/Module/Filestorage.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Filestorage.php b/Zotlabs/Module/Filestorage.php index 55713027a..5c8557e5a 100644 --- a/Zotlabs/Module/Filestorage.php +++ b/Zotlabs/Module/Filestorage.php @@ -103,6 +103,11 @@ class Filestorage extends \Zotlabs\Web\Controller { attach_delete($owner, $f['hash']); + $sync = attach_export_data($channel, $f['hash'], true); + if($sync) { + build_sync_packet($channel['channel_id'], array('file' => array($sync))); + } + goaway(dirname($url)); } -- cgit v1.2.3 From 87eaa6d8e5a5fece531a8ce191f8e89e90f673c2 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 24 Nov 2017 15:01:34 +0100 Subject: some more work on mod hq --- Zotlabs/Lib/ThreadStream.php | 4 ++++ Zotlabs/Module/Hq.php | 19 ++++++++++--------- Zotlabs/Module/Ping.php | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php index 9eebb929c..bdd2e9657 100644 --- a/Zotlabs/Lib/ThreadStream.php +++ b/Zotlabs/Lib/ThreadStream.php @@ -54,6 +54,10 @@ class ThreadStream { $this->profile_owner = local_channel(); $this->writable = true; break; + case 'hq': + $this->profile_owner = local_channel(); + $this->writable = true; + break; case 'channel': $this->profile_owner = \App::$profile['profile_uid']; $this->writable = perm_is_allowed($this->profile_owner,$ob_hash,'post_comments'); diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index 78087c0f9..2795b9086 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -61,6 +61,7 @@ class Hq extends \Zotlabs\Web\Controller { $item_hash = 'b64.' . base64url_encode($r[0]['mid']); } + if(strpos($item_hash,'b64.') === 0) $decoded = @base64url_decode(substr($item_hash,4)); if($decoded) @@ -91,7 +92,7 @@ class Hq extends \Zotlabs\Web\Controller { 'bang' => '', 'visitor' => true, 'profile_uid' => local_channel(), - 'return_path' => 'channel/' . $channel['channel_address'], + 'return_path' => 'hq', 'expanded' => true, 'editor_autocomplete' => true, 'bbco_autocomplete' => 'bbcode', @@ -133,6 +134,8 @@ class Hq extends \Zotlabs\Web\Controller { if(! $update && ! $load) { + nav_set_selected('HQ'); + $static = ((local_channel()) ? channel_manual_conv_update(local_channel()) : 1); // if the target item is not a post (eg a like) we want to address its thread parent @@ -143,14 +146,14 @@ class Hq extends \Zotlabs\Web\Controller { if($decoded) $mid = 'b64.' . base64url_encode($mid); - $o .= '
' . "\r\n"; + $o .= '
' . "\r\n"; $o .= "\r\n"; \App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),[ '$baseurl' => z_root(), - '$pgtype' => 'display', - '$uid' => '0', + '$pgtype' => 'hq', + '$uid' => local_channel(), '$gid' => '0', '$cid' => '0', '$cmin' => '0', @@ -181,6 +184,7 @@ class Hq extends \Zotlabs\Web\Controller { } if($load) { + $r = null; $r = q("SELECT item.id as item_id from item @@ -198,6 +202,7 @@ class Hq extends \Zotlabs\Web\Controller { } elseif($update) { + $r = null; $r = q("SELECT item.parent AS item_id from item @@ -238,7 +243,7 @@ class Hq extends \Zotlabs\Web\Controller { $items = []; } - $o .= conversation($items, 'display', $update, 'client'); + $o .= conversation($items, 'hq', $update, 'client'); if($updateable) { $x = q("UPDATE item SET item_unseen = 0 where item_unseen = 1 AND uid = %d and parent = %d ", @@ -249,10 +254,6 @@ class Hq extends \Zotlabs\Web\Controller { $o .= '
'; - if(($update && $load) && (! $items)) { - notice( t('Something went wrong.') . EOL ); - } - return $o; } diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 406e554d1..84f9d2a21 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -496,7 +496,7 @@ class Ping extends \Zotlabs\Web\Controller { $r = q("SELECT id, item_wall FROM item WHERE item_unseen = 1 and uid = %d $item_normal - AND author_xchan != '%s' $sql_extra ", + AND author_xchan != '%s'", intval(local_channel()), dbesc($ob_hash) ); -- cgit v1.2.3 From 64c81ed17474cfa3dfe0e84475a49089c0af0106 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 24 Nov 2017 15:12:40 +0100 Subject: missing files --- Zotlabs/Module/Update_hq.php | 31 +++++++++++++++++++++++++++++++ Zotlabs/Widget/Hq_controls.php | 26 ++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 Zotlabs/Module/Update_hq.php create mode 100644 Zotlabs/Widget/Hq_controls.php (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Update_hq.php b/Zotlabs/Module/Update_hq.php new file mode 100644 index 000000000..bb1495c64 --- /dev/null +++ b/Zotlabs/Module/Update_hq.php @@ -0,0 +1,31 @@ + 1) && (argv(1) == 'load')) ? 1 : 0); + header("Content-type: text/html"); + echo "\r\n"; + echo (($_GET['msie'] == 1) ? '
' : '
'); + + $mod = new Hq(); + $text = $mod->get($profile_uid, $load); + + echo str_replace("\t",' ',$text); + echo (($_GET['msie'] == 1) ? '
' : ''); + echo "\r\n"; + + killme(); + + } + +} diff --git a/Zotlabs/Widget/Hq_controls.php b/Zotlabs/Widget/Hq_controls.php new file mode 100644 index 000000000..0caa54a1a --- /dev/null +++ b/Zotlabs/Widget/Hq_controls.php @@ -0,0 +1,26 @@ + t('HQ Control Panel'), + '$menu' => [ + 'create' => [ + 'label' => t('Create a new post'), + 'id' => 'jot-toggle', + 'href' => '#', + 'class' => '' + ] + ] + ] + ); + } +} -- cgit v1.2.3 From e327b8cb9aa7c31975ba26f8d7bc871b4da59df9 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Fri, 24 Nov 2017 13:50:29 -0500 Subject: Provide system config option for minimum registration age. --- Zotlabs/Module/Register.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php index 95e3ca96f..deaee31bf 100644 --- a/Zotlabs/Module/Register.php +++ b/Zotlabs/Module/Register.php @@ -234,7 +234,11 @@ class Register extends \Zotlabs\Web\Controller { if(get_config('system','no_age_restriction')) $label_tos = sprintf( t('I accept the %s for this website'), $toslink); else - $label_tos = sprintf( t('I am over 13 years of age and accept the %s for this website'), $toslink); + $age = get_config('system','minimum_age'); + if(!$age) { + $age = 13; + } + $label_tos = sprintf( t('I am over %s years of age and accept the %s for this website'), $age, $toslink); $enable_tos = 1 - intval(get_config('system','no_termsofservice')); -- cgit v1.2.3 From b03545f89939ef1c13ca7f5a950d52fcb7f2313f Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 24 Nov 2017 22:48:15 +0100 Subject: mod hq: minor query change --- Zotlabs/Module/Hq.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index 2795b9086..08f4ddda5 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -43,10 +43,9 @@ class Hq extends \Zotlabs\Web\Controller { $item_normal_update = item_normal_update(); if(! $item_hash) { - $r = q("SELECT mid FROM item WHERE uid = %d - AND item_thread_top = 1 + AND mid = parent_mid ORDER BY created DESC limit 1", intval(local_channel()) @@ -64,13 +63,13 @@ class Hq extends \Zotlabs\Web\Controller { if(strpos($item_hash,'b64.') === 0) $decoded = @base64url_decode(substr($item_hash,4)); + if($decoded) $item_hash = $decoded; $updateable = false; if(! $update) { - $channel = \App::get_channel(); $channel_acl = [ @@ -139,7 +138,6 @@ class Hq extends \Zotlabs\Web\Controller { $static = ((local_channel()) ? channel_manual_conv_update(local_channel()) : 1); // if the target item is not a post (eg a like) we want to address its thread parent - $mid = ((($target_item['verb'] == ACTIVITY_LIKE) || ($target_item['verb'] == ACTIVITY_DISLIKE)) ? $target_item['thr_parent'] : $target_item['mid']); // if we got a decoded hash we must encode it again before handing to javascript @@ -180,11 +178,9 @@ class Hq extends \Zotlabs\Web\Controller { '$net' => '', '$mid' => $mid ]); - } if($load) { - $r = null; $r = q("SELECT item.id as item_id from item @@ -198,11 +194,8 @@ class Hq extends \Zotlabs\Web\Controller { if($r) { $updateable = true; } - } - elseif($update) { - $r = null; $r = q("SELECT item.parent AS item_id from item @@ -220,7 +213,6 @@ class Hq extends \Zotlabs\Web\Controller { $_SESSION['loadtime'] = datetime_convert(); } - else { $r = []; } -- cgit v1.2.3 From fda5231a719025c0e2d7cc3954ebbab5b0d53586 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 24 Nov 2017 14:55:39 -0800 Subject: default profile assign --- Zotlabs/Module/Settings/Channel.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index 63370a141..db0f79060 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -2,6 +2,8 @@ namespace Zotlabs\Module\Settings; +require_once('include/selectors.php'); + class Channel { @@ -148,7 +150,8 @@ class Channel { $defpermcat = ((x($_POST,'defpermcat')) ? notags(trim($_POST['defpermcat'])) : 'default'); $cal_first_day = (((x($_POST,'first_day')) && (intval($_POST['first_day']) == 1)) ? 1: 0); - $mailhost = ((array_key_exists('mailhost',$_POST)) ? notags(trim($_POST['mailhost'])) : ''); + $mailhost = ((array_key_exists('mailhost',$_POST)) ? notags(trim($_POST['mailhost'])) : ''); + $profile_assign = ((x($_POST,'profile_assign')) ? notags(trim($_POST['profile_assign'])) : ''); $pageflags = $channel['channel_pageflags']; @@ -242,6 +245,7 @@ class Channel { set_pconfig(local_channel(),'system','cal_first_day',$cal_first_day); set_pconfig(local_channel(),'system','default_permcat',$defpermcat); set_pconfig(local_channel(),'system','email_notify_host',$mailhost); + set_pconfig(local_channel(),'system','profile_assign',$profile_assign); $r = q("update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d $set_perms where channel_id = %d", dbesc($username), @@ -515,6 +519,9 @@ class Channel { '$permissions' => t('Default Privacy Group'), '$permdesc' => t("\x28click to open/close\x29"), '$aclselect' => populate_acl($perm_defaults, false, \Zotlabs\Lib\PermissionDescription::fromDescription(t('Use my default audience setting for the type of object published'))), + '$profseltxt' => t('Profile to assign new connections'), + '$profselect' => ((feature_enabled(local_channel(),'multi_profiles')) ? contact_profile_assign(get_pconfig(local_channel(),'system','profile_assign','')) : ''), + '$allow_cid' => acl2json($perm_defaults['allow_cid']), '$allow_gid' => acl2json($perm_defaults['allow_gid']), '$deny_cid' => acl2json($perm_defaults['deny_cid']), -- cgit v1.2.3 From 4b2bd871b765e0287f329ad398a15f20cb6a6425 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 25 Nov 2017 10:44:47 +0100 Subject: implement pubstream items in mod hq --- Zotlabs/Module/Hq.php | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index 08f4ddda5..c5b3ced3e 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -125,11 +125,12 @@ class Hq extends \Zotlabs\Web\Controller { if($update && $_SESSION['loadtime']) $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; - if($load) - $simple_update = ''; if($static && $simple_update) $simple_update .= " and item_thread_top = 0 and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' "; + + $sys = get_sys_channel(); + $sql_extra = item_permissions_sql($sys['channel_id']); if(! $update && ! $load) { @@ -183,34 +184,58 @@ class Hq extends \Zotlabs\Web\Controller { if($load) { $r = null; - $r = q("SELECT item.id as item_id from item + $r = q("SELECT item.id AS item_id FROM item WHERE uid = %d - and mid = '%s' + AND mid = '%s' $item_normal - limit 1", + LIMIT 1", intval(local_channel()), dbesc($target_item['parent_mid']) ); + if($r) { $updateable = true; } + + if(!$r) { + $r = q("SELECT item.id AS item_id FROM item + LEFT JOIN abook ON item.author_xchan = abook.abook_xchan + WHERE mid = '%s' AND item.uid = %d $item_normal + AND (abook.abook_blocked = 0 or abook.abook_flags is null) + $sql_extra LIMIT 1", + dbesc($target_item['parent_mid']), + intval($sys['channel_id']) + ); + } } elseif($update) { $r = null; - $r = q("SELECT item.parent AS item_id from item + $r = q("SELECT item.parent AS item_id FROM item WHERE uid = %d - and parent_mid = '%s' + AND parent_mid = '%s' $item_normal_update $simple_update - limit 1", + LIMIT 1", intval(local_channel()), dbesc($target_item['parent_mid']) ); + if($r) { $updateable = true; } + if(!$r) { + $r = q("SELECT item.parent AS item_id FROM item + LEFT JOIN abook ON item.author_xchan = abook.abook_xchan + WHERE mid = '%s' AND item.uid = %d $item_normal_update $simple_update + AND (abook.abook_blocked = 0 or abook.abook_flags is null) + $sql_extra LIMIT 1", + dbesc($target_item['parent_mid']), + intval($sys['channel_id']) + ); + } + $_SESSION['loadtime'] = datetime_convert(); } else { @@ -222,11 +247,11 @@ class Hq extends \Zotlabs\Web\Controller { if($parents_str) { $items = q("SELECT item.*, item.id AS item_id FROM item - WHERE parent in ( %s ) $item_normal ", + WHERE parent IN ( %s ) $item_normal ", dbesc($parents_str) ); - xchan_query($items); + xchan_query($items,true,local_channel()); $items = fetch_post_tags($items,true); $items = conv_sort($items,'created'); } @@ -238,7 +263,7 @@ class Hq extends \Zotlabs\Web\Controller { $o .= conversation($items, 'hq', $update, 'client'); if($updateable) { - $x = q("UPDATE item SET item_unseen = 0 where item_unseen = 1 AND uid = %d and parent = %d ", + $x = q("UPDATE item SET item_unseen = 0 WHERE item_unseen = 1 AND uid = %d AND parent = %d ", intval(local_channel()), intval($r[0]['item_id']) ); -- cgit v1.2.3 From fe37b037575a3de5c60c2ccd3d4e1f6bc24fce37 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 25 Nov 2017 03:01:25 -0800 Subject: blah is not author or owner --- 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 d0175549b..3f07d4ce0 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -309,7 +309,7 @@ class Notifier { if($s) $channel = $s[0]; - if($channel['channel_hash'] !== $target_item['author_xchan'] && $channel['channel_hash'] !== $target_item['owner_xchan']) { + if($channel['channel_hash'] !== $target_item['author_xchan'] && $channel['channel_hash'] !== $target_item['owner_xchan'] && ( ! intval($channel['channel_system']))) { logger("notifier: Sending channel {$channel['channel_hash']} is not owner {$target_item['owner_xchan']} or author {$target_item['author_xchan']}", LOGGER_NORMAL, LOG_WARNING); return; } -- cgit v1.2.3 From 014b629928b19dec4bfa2f12f961fd4048d71d19 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 25 Nov 2017 14:33:57 +0100 Subject: fix regression in cdav calendar widget --- Zotlabs/Widget/Cdav.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Widget/Cdav.php b/Zotlabs/Widget/Cdav.php index 60a860f93..589f915c5 100644 --- a/Zotlabs/Widget/Cdav.php +++ b/Zotlabs/Widget/Cdav.php @@ -63,9 +63,10 @@ class Cdav { $sharees = []; $share_displayname = []; + foreach($invites as $invite) { if(strpos($invite->href, 'mailto:') !== false) { - $sharee = channelx_by_hash(substr($invite->href, 7)); + $sharee = channelx_by_nick(substr($invite->principal, 11)); $sharees[] = [ 'name' => $sharee['channel_name'], 'access' => (($invite->access == 3) ? ' (RW)' : ' (R)'), @@ -173,4 +174,4 @@ class Cdav { } } -} \ No newline at end of file +} -- cgit v1.2.3 From 0e91810ed6764fbbee54e918711bfb45a1d9fd72 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 26 Nov 2017 18:29:24 -0800 Subject: pubstream comments and a few other bugfixes that were discovered along the way --- Zotlabs/Daemon/Notifier.php | 6 ++++-- Zotlabs/Lib/ThreadStream.php | 8 ++++++++ Zotlabs/Module/Item.php | 23 ++++++++++++++--------- Zotlabs/Module/Like.php | 17 ++++++++++++----- Zotlabs/Module/Pubstream.php | 15 +++++++-------- Zotlabs/Module/React.php | 25 +++++++++++++++++++++---- Zotlabs/Module/Subthread.php | 32 ++++++++++++++++++++++++++++---- Zotlabs/Module/Tagger.php | 30 ++++++++++++++++++++++++++---- Zotlabs/Module/Update_pubstream.php | 18 +----------------- 9 files changed, 121 insertions(+), 53 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 3f07d4ce0..ca6a7c08a 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -309,7 +309,7 @@ class Notifier { if($s) $channel = $s[0]; - if($channel['channel_hash'] !== $target_item['author_xchan'] && $channel['channel_hash'] !== $target_item['owner_xchan'] && ( ! intval($channel['channel_system']))) { + if($channel['channel_hash'] !== $target_item['author_xchan'] && $channel['channel_hash'] !== $target_item['owner_xchan']) { logger("notifier: Sending channel {$channel['channel_hash']} is not owner {$target_item['owner_xchan']} or author {$target_item['author_xchan']}", LOGGER_NORMAL, LOG_WARNING); return; } @@ -426,8 +426,10 @@ class Notifier { logger('notifier: encoded item: ' . print_r($x,true), LOGGER_DATA, LOG_DEBUG); stringify_array_elms($recipients); - if(! $recipients) + if(! $recipients) { + logger('no recipients'); return; + } // logger('notifier: recipients: ' . print_r($recipients,true), LOGGER_NORMAL, LOG_DEBUG); diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php index bdd2e9657..d0c964149 100644 --- a/Zotlabs/Lib/ThreadStream.php +++ b/Zotlabs/Lib/ThreadStream.php @@ -54,6 +54,10 @@ class ThreadStream { $this->profile_owner = local_channel(); $this->writable = true; break; + case 'pubstream': + $this->profile_owner = local_channel(); + $this->writable = ((local_channel()) ? true : false); + break; case 'hq': $this->profile_owner = local_channel(); $this->writable = true; @@ -188,6 +192,10 @@ class ThreadStream { $item->set_commentable(can_comment_on_post($ob_hash,$item->data)); } } + if($this->mode === 'pubstream' && (! local_channel())) { + $item->set_commentable(false); + } + require_once('include/channel.php'); $item->set_conversation($this); diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index ecbefa1c2..2528645f3 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -59,6 +59,7 @@ class Item extends \Zotlabs\Web\Controller { $profile_uid = ((x($_REQUEST,'profile_uid')) ? intval($_REQUEST['profile_uid']) : 0); require_once('include/channel.php'); + $sys = get_sys_channel(); if($sys && $profile_uid && ($sys['channel_id'] == $profile_uid) && is_site_admin()) { $uid = intval($sys['channel_id']); @@ -171,7 +172,7 @@ class Item extends \Zotlabs\Web\Controller { ); } // if this isn't the real parent of the conversation, find it - if($r !== false && count($r)) { + if($r) { $parid = $r[0]['parent']; $parent_mid = $r[0]['mid']; if($r[0]['id'] != $r[0]['parent']) { @@ -179,9 +180,16 @@ class Item extends \Zotlabs\Web\Controller { intval($parid) ); } + + // if interacting with a pubstream item, + // create a copy of the parent in your stream + + if($r[0]['uid'] === $sys['channel_id'] && local_channel()) { + $r = [ copy_of_pubitem(\App::get_channel(), $r[0]['mid']) ]; + } } - - if(($r === false) || (! count($r))) { + + if(! $r) { notice( t('Unable to locate original post.') . EOL); if($api_source) return ( [ 'success' => false, 'message' => 'invalid post id' ] ); @@ -189,15 +197,12 @@ class Item extends \Zotlabs\Web\Controller { goaway(z_root() . "/" . $return_path ); killme(); } - - // can_comment_on_post() needs info from the following xchan_query - // This may be from the discover tab which means we need to correct the effective uid - xchan_query($r,true,(($r[0]['uid'] == local_channel()) ? 0 : local_channel())); - + xchan_query($r,true); + $parent_item = $r[0]; $parent = $r[0]['id']; - + // multi-level threading - preserve the info but re-parent to our single level threading $thr_parent = $parent_mid; diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index 0abf111e0..16580e60f 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -258,20 +258,27 @@ class Like extends \Zotlabs\Web\Controller { // get the item. Allow linked photos (which are normally hidden) to be liked $r = q("SELECT * FROM item WHERE id = %d - and (item_type = 0 or item_type = 6) and item_deleted = 0 and item_unpublished = 0 + and (item_type in (0,6,7) and item_deleted = 0 and item_unpublished = 0 and item_delayed = 0 and item_pending_remove = 0 and item_blocked = 0 LIMIT 1", intval($item_id) ); + // if interacting with a pubstream item, + // create a copy of the parent in your stream. If not the conversation + // parent, copy that as well. + + if($r) { + if($r[0]['uid'] === $sys_channel['channel_id'] && local_channel()) { + $r = [ copy_of_pubitem(\App::get_channel(), $r[0]['mid']) ]; + } + } + if(! $item_id || (! $r)) { logger('like: no item ' . $item_id); killme(); } - // Use the $effective_uid option of xchan_query to sort out comment permission - // for public stream items - - xchan_query($r,true,(($r[0]['uid'] == $sys_channel_id) ? local_channel() : 0)); + xchan_query($r,true); $item = $r[0]; diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 0e6c2360f..c469a0eca 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -162,18 +162,16 @@ class Pubstream extends \Zotlabs\Web\Controller { $net_query2 = (($net) ? " and xchan_network = '" . protect_sprintf(dbesc($net)) . "' " : ''); - $simple_update = (($update) ? " and item.item_unseen = 1 " : ''); + $simple_update = (($_SESSION['loadtime']) ? " AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' " : ''); - if($update && $_SESSION['loadtime']) - $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; if($load) $simple_update = ''; if($static && $simple_update) - $simple_update .= " and item_thread_top = 0 and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' "; + $simple_update .= " and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' "; //logger('update: ' . $update . ' load: ' . $load); - + if($update) { $ordering = "commented"; @@ -214,17 +212,18 @@ class Pubstream extends \Zotlabs\Web\Controller { ); } else { - $r = q("SELECT distinct item.id AS item_id, $ordering FROM item + $r = q("SELECT distinct parent AS item_id, $ordering FROM item left join abook on item.author_xchan = abook.abook_xchan $net_query WHERE true $uids $item_normal_update - AND item.parent = item.id $simple_update + $simple_update and (abook.abook_blocked = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets $net_query2" ); } $_SESSION['loadtime'] = datetime_convert(); } + // Then fetch all the children of the parents that are on this page $parents_str = ''; $update_unseen = ''; @@ -254,7 +253,7 @@ class Pubstream extends \Zotlabs\Web\Controller { } // fake it - $mode = ('network'); + $mode = ('pubstream'); $o .= conversation($items,$mode,$update,$page_mode); diff --git a/Zotlabs/Module/React.php b/Zotlabs/Module/React.php index 6cd79c952..6473317c7 100644 --- a/Zotlabs/Module/React.php +++ b/Zotlabs/Module/React.php @@ -6,15 +6,21 @@ namespace Zotlabs\Module; class React extends \Zotlabs\Web\Controller { function get() { + if(! local_channel()) return; + $sys = get_sys_channel(); + $channel = \App::get_channel(); + $postid = $_REQUEST['postid']; if(! $postid) return; $emoji = $_REQUEST['emoji']; + + if($_REQUEST['emoji']) { $i = q("select * from item where id = %d and uid = %d", @@ -22,10 +28,22 @@ class React extends \Zotlabs\Web\Controller { intval(local_channel()) ); - if(! $i) + if(! $i) { + $i = q("select * from item where id = %d and uid = %d", + intval($postid), + intval($sys['channel_id']) + ); + + if($i) { + $i = [ copy_of_pubitem($channel, $i[0]['mid']) ]; + $postid = (($i) ? $i[0]['id'] : 0); + } + } + + if(! $i) { return; + } - $channel = \App::get_channel(); $n = array(); $n['aid'] = $channel['channel_account_id']; @@ -40,8 +58,7 @@ class React extends \Zotlabs\Web\Controller { $x = item_store($n); - if(local_channel()) - retain_item($postid); + retain_item($postid); if($x['success']) { $nid = $x['item_id']; diff --git a/Zotlabs/Module/Subthread.php b/Zotlabs/Module/Subthread.php index dae8bf020..1a9caff6c 100644 --- a/Zotlabs/Module/Subthread.php +++ b/Zotlabs/Module/Subthread.php @@ -11,10 +11,13 @@ class Subthread extends \Zotlabs\Web\Controller { function get() { - if((! local_channel()) && (! remote_channel())) { + if(! local_channel()) { return; } + $sys = get_sys_channel(); + $channel = \App::get_channel(); + $item_id = ((argc() > 2) ? notags(trim(argv(2))) : 0); if(argv(1) === 'sub') @@ -23,10 +26,31 @@ class Subthread extends \Zotlabs\Web\Controller { $activity = ACTIVITY_UNFOLLOW; - $r = q("SELECT parent FROM item WHERE id = '%s'", - dbesc($item_id) + $i = q("select * from item where id = %d and uid = %d", + intval($item_id), + intval(local_channel()) ); - + + if(! $i) { + $i = q("select * from item where id = %d and uid = %d", + intval($postid), + intval($sys['channel_id']) + ); + + if($i) { + $i = [ copy_of_pubitem($channel, $i[0]['mid']) ]; + $item_id = (($i) ? $i[0]['id'] : 0); + } + } + + if(! $i) { + return; + } + + $r = q("SELECT parent FROM item WHERE id = %d", + intval($item_id) + ); + if($r) { $r = q("select * from item where id = parent and id = %d limit 1", dbesc($r[0]['parent']) diff --git a/Zotlabs/Module/Tagger.php b/Zotlabs/Module/Tagger.php index 98e901965..603a95f2b 100644 --- a/Zotlabs/Module/Tagger.php +++ b/Zotlabs/Module/Tagger.php @@ -11,10 +11,12 @@ class Tagger extends \Zotlabs\Web\Controller { function get() { - if(! local_channel() && ! remote_channel()) { + if(! local_channel()) { return; } + $sys = get_sys_channel(); + $observer_hash = get_observer_hash(); //strip html-tags $term = notags(trim($_GET['term'])); @@ -26,9 +28,29 @@ class Tagger extends \Zotlabs\Web\Controller { logger('tagger: tag ' . $term . ' item ' . $item_id); - - $r = q("SELECT * FROM item left join xchan on xchan_hash = author_xchan WHERE id = '%s' and uid = %d LIMIT 1", - dbesc($item_id), + $r = q("select * from item where id = %d and uid = %d limit 1", + intval($item_id), + intval(local_channel()) + ); + + if(! $r) { + $r = q("select * from item where id = %d and uid = %d limit 1", + intval($item_id), + intval($sys['channel_id']) + ); + if($r) { + $r = [ copy_of_pubitem($channel, $i[0]['mid']) ]; + $item_id = (($r) ? $r[0]['id'] : 0); + } + } + + if(! $r) { + notice( t('Post not found.') . EOL); + return; + } + + $r = q("SELECT * FROM item left join xchan on xchan_hash = author_xchan WHERE id = %d and uid = %d LIMIT 1", + intval($item_id), intval(local_channel()) ); diff --git a/Zotlabs/Module/Update_pubstream.php b/Zotlabs/Module/Update_pubstream.php index 952b48df3..8bb5ebfe7 100644 --- a/Zotlabs/Module/Update_pubstream.php +++ b/Zotlabs/Module/Update_pubstream.php @@ -17,23 +17,7 @@ class Update_pubstream extends \Zotlabs\Web\Controller { $mod = new Pubstream(); $text = $mod->get($profile_uid, $load); - $pattern = "/]*) src=\"([^\"]*)\"/"; - $replace = "'; - $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i"; - $text = preg_replace($pattern, $replace, $text); - $pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i"; - $text = preg_replace($pattern, $replace, $text); - $pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i"; - $text = preg_replace($pattern, $replace, $text); - $pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i"; - $text = preg_replace($pattern, $replace, $text); - } - */ - echo str_replace("\t",' ',$text); + echo str_replace("\t",' ',$text); echo ((array_key_exists('msie',$_GET) && $_GET['msie'] == 1) ? '' : ''); echo "\r\n"; killme(); -- cgit v1.2.3 From 1ad1b745128b7c5d7a90a825077c08f5c951c604 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 27 Nov 2017 10:07:45 +0100 Subject: fix mod like after recent changes --- Zotlabs/Module/Like.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index 16580e60f..b07824363 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -258,7 +258,7 @@ class Like extends \Zotlabs\Web\Controller { // get the item. Allow linked photos (which are normally hidden) to be liked $r = q("SELECT * FROM item WHERE id = %d - and (item_type in (0,6,7) and item_deleted = 0 and item_unpublished = 0 + and item_type in (0,6,7) and item_deleted = 0 and item_unpublished = 0 and item_delayed = 0 and item_pending_remove = 0 and item_blocked = 0 LIMIT 1", intval($item_id) ); -- cgit v1.2.3 From d5c56c0f5d21649b35f11f8211b360c7b332df32 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 28 Nov 2017 11:15:19 +0100 Subject: split liveUpdateInit() out of NavUpdate() so we do not need to wait for initial ping to complete before we can init liveUpdate(). clean up main.js and bump version. --- Zotlabs/Module/Hq.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index c5b3ced3e..bebd968f4 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -147,7 +147,7 @@ class Hq extends \Zotlabs\Web\Controller { $o .= '
' . "\r\n"; $o .= "\r\n"; + . "; var netargs = '?f='; var profile_page = " . \App::$pager['page'] . ";\r\n"; \App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),[ '$baseurl' => z_root(), -- cgit v1.2.3 From 8073be87da589a1cb24a186a04ea7b7dd21ff055 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 28 Nov 2017 12:28:49 +0100 Subject: set profile_uid in mod hq --- Zotlabs/Module/Hq.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index bebd968f4..6bc65e44e 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -10,6 +10,13 @@ require_once('include/items.php'); class Hq extends \Zotlabs\Web\Controller { + function init() { + if(! local_channel()) + return; + + \App::$profile_uid = local_channel(); + } + function post() { if(!local_channel()) -- cgit v1.2.3 From 76703dee8481075a44b254a548bb29b49530d0ad Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 28 Nov 2017 17:37:18 -0800 Subject: more chunk work --- Zotlabs/Module/File_upload.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/File_upload.php b/Zotlabs/Module/File_upload.php index 296dab708..e2a6d45e5 100644 --- a/Zotlabs/Module/File_upload.php +++ b/Zotlabs/Module/File_upload.php @@ -10,7 +10,8 @@ class File_upload extends \Zotlabs\Web\Controller { function post() { - // logger('file upload: ' . print_r($_REQUEST,true)); + logger('file upload: ' . print_r($_REQUEST,true)); + logger('file upload: ' . print_r($_FILES,true)); $channel = (($_REQUEST['channick']) ? channelx_by_nick($_REQUEST['channick']) : null); @@ -56,7 +57,7 @@ class File_upload extends \Zotlabs\Web\Controller { if(array_key_exists('HTTP_CONTENT_RANGE',$_SERVER)) { $pm = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches); if($pm) { - // logger('Content-Range: ' . print_r($matches,true)); + logger('Content-Range: ' . print_r($matches,true)); $partial = true; } } -- cgit v1.2.3 From 5abcb8c97813d66b63ca697ca626347a9fd8d95c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 29 Nov 2017 13:51:54 -0800 Subject: use httpsig auth for getfile --- Zotlabs/Module/Getfile.php | 57 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 11 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Getfile.php b/Zotlabs/Module/Getfile.php index 413a68e0c..3f84b4050 100644 --- a/Zotlabs/Module/Getfile.php +++ b/Zotlabs/Module/Getfile.php @@ -28,17 +28,51 @@ class Getfile extends \Zotlabs\Web\Controller { function post() { - logger('post: ' . print_r($_POST,true),LOGGER_DEBUG,LOG_INFO); - + $header_verification = false; + $hash = $_POST['hash']; $time = $_POST['time']; $sig = $_POST['signature']; $resource = $_POST['resource']; $revision = intval($_POST['revision']); $resolution = (-1); - + if(! $hash) killme(); + + foreach([ 'REDIRECT_REMOTE_USER', 'HTTP_AUTHORIZATION' ] as $head) { + if(array_key_exists($head,$_SERVER) && substr(trim($_SERVER[$head]),0,9) === 'Signature') { + if($head !== 'HTTP_AUTHORIZATION') { + $_SERVER['HTTP_AUTHORIZATION'] = $_SERVER[$head]; + continue; + } + + $sigblock = \Zotlabs\Web\HTTPSig::parse_sigheader($_SERVER[$head]); + if($sigblock) { + $keyId = $sigblock['keyId']; + + if($keyId) { + $r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash + where hubloc_addr = '%s' limit 1", + dbesc(str_replace('acct:','',$keyId)) + ); + if($r) { + $hubloc = $r[0]; + $verified = \Zotlabs\Web\HTTPSig::verify('',$hubloc['xchan_pubkey']); + if($verified && $verified['header_signed'] && $verified['header_valid'] && $hash == $hubloc['hubloc_hash']) { + $header_verified = true; + } + } + } + } + } + } + + + logger('post: ' . print_r($_POST,true),LOGGER_DEBUG,LOG_INFO); + if($header_verified) { + logger('HTTPSig verified'); + } $channel = channelx_by_hash($hash); @@ -59,16 +93,17 @@ class Getfile extends \Zotlabs\Web\Controller { $d1 = datetime_convert('UTC','UTC',"now + $slop minutes"); $d2 = datetime_convert('UTC','UTC',"now - $slop minutes"); - if(($time > $d1) || ($time < $d2)) { - logger('time outside allowable range'); - killme(); - } + if(! $header_verified) { + if(($time > $d1) || ($time < $d2)) { + logger('time outside allowable range'); + killme(); + } - if(! rsa_verify($hash . '.' . $time,base64url_decode($sig),$channel['channel_pubkey'])) { - logger('verify failed.'); - killme(); + if(! rsa_verify($hash . '.' . $time,base64url_decode($sig),$channel['channel_pubkey'])) { + logger('verify failed.'); + killme(); + } } - if($resolution > 0) { $r = q("select * from photo where resource_id = '%s' and uid = %d limit 1", -- cgit v1.2.3 From 6a4050cc9386effc86d2b0279c33ae1a1925a5ab Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 29 Nov 2017 14:08:30 -0800 Subject: use the same variable name consistently --- Zotlabs/Module/Getfile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Getfile.php b/Zotlabs/Module/Getfile.php index 3f84b4050..abc9f50d9 100644 --- a/Zotlabs/Module/Getfile.php +++ b/Zotlabs/Module/Getfile.php @@ -28,7 +28,7 @@ class Getfile extends \Zotlabs\Web\Controller { function post() { - $header_verification = false; + $header_verified = false; $hash = $_POST['hash']; $time = $_POST['time']; -- cgit v1.2.3 From fc5b6887168a25992fb089ed7da7ac917e7aaf6b Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 30 Nov 2017 13:40:36 +0100 Subject: fix issue #921 - default addressbook has no name --- Zotlabs/Module/Cdav.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php index 77052f97c..91d279f7a 100644 --- a/Zotlabs/Module/Cdav.php +++ b/Zotlabs/Module/Cdav.php @@ -1250,7 +1250,7 @@ class Cdav extends \Zotlabs\Web\Controller { //create default addressbook $carddavBackend = new \Sabre\CardDAV\Backend\PDO($pdo); $properties = ['{DAV:}displayname' => t('Default Addressbook')]; - $carddavBackend->createAddressBook($uri, $default, $properties); + $carddavBackend->createAddressBook($uri, 'default', $properties); } } -- cgit v1.2.3 From 0e8e0b48b3fd6f4d6d0dd60039743371930af08d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 30 Nov 2017 19:05:24 -0800 Subject: more or less working chunked uploads on /cloud now. --- Zotlabs/Module/File_upload.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/File_upload.php b/Zotlabs/Module/File_upload.php index e2a6d45e5..90761fa9c 100644 --- a/Zotlabs/Module/File_upload.php +++ b/Zotlabs/Module/File_upload.php @@ -64,6 +64,8 @@ class File_upload extends \Zotlabs\Web\Controller { if($partial) { $x = save_chunk($channel,$matches[1],$matches[2],$matches[3]); + +logger('save_chunk: ' . print_r($x,true)); if($x['partial']) { header('Range: bytes=0-' . (($x['length']) ? $x['length'] - 1 : 0)); json_return_and_die($result); -- cgit v1.2.3 From 3d8de8cf0af99e1f2b263667a96e8185c055fb82 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 30 Nov 2017 19:11:26 -0800 Subject: remove logging line --- Zotlabs/Module/File_upload.php | 1 - 1 file changed, 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/File_upload.php b/Zotlabs/Module/File_upload.php index 90761fa9c..4d1cc4cda 100644 --- a/Zotlabs/Module/File_upload.php +++ b/Zotlabs/Module/File_upload.php @@ -65,7 +65,6 @@ class File_upload extends \Zotlabs\Web\Controller { if($partial) { $x = save_chunk($channel,$matches[1],$matches[2],$matches[3]); -logger('save_chunk: ' . print_r($x,true)); if($x['partial']) { header('Range: bytes=0-' . (($x['length']) ? $x['length'] - 1 : 0)); json_return_and_die($result); -- cgit v1.2.3 From dcad9ce26a0de72ba3ad5b86ddb62298598ac380 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 1 Dec 2017 21:00:39 +0100 Subject: add a filter for notification to show new posts only --- Zotlabs/Lib/Enotify.php | 2 ++ Zotlabs/Widget/Notifications.php | 15 +++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 697b57b6a..a7b4f28e8 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -804,6 +804,8 @@ class Enotify { 'when' => relative_date($item['created']), 'class' => (intval($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'), 'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])), + 'notify_id' => 'undefined', + 'thread_top' => (($item['item_thread_top']) ? true : false), 'message' => strip_tags(bbcode($itemem_text)) ); diff --git a/Zotlabs/Widget/Notifications.php b/Zotlabs/Widget/Notifications.php index 191f2afb6..450d3565e 100644 --- a/Zotlabs/Widget/Notifications.php +++ b/Zotlabs/Widget/Notifications.php @@ -20,8 +20,10 @@ class Notifications { 'label' => t('View your network activity') ], 'markall' => [ - 'url' => '#', 'label' => t('Mark all notifications read') + ], + 'filter' => [ + 'label' => t('Show new posts only') ] ]; @@ -36,8 +38,10 @@ class Notifications { 'label' => t('View your home activity') ], 'markall' => [ - 'url' => '#', 'label' => t('Mark all notifications seen') + ], + 'filter' => [ + 'label' => t('Show new posts only') ] ]; @@ -52,7 +56,6 @@ class Notifications { 'label' => t('View your private mails') ], 'markall' => [ - 'url' => '#', 'label' => t('Mark all messages seen') ] ]; @@ -68,7 +71,6 @@ class Notifications { 'label' => t('View events') ], 'markall' => [ - 'url' => '#', 'label' => t('Mark all events seen') ] ]; @@ -104,7 +106,6 @@ class Notifications { 'label' => t('View all notices') ], 'markall' => [ - 'url' => '#', 'label' => t('Mark all notices seen') ] ]; @@ -132,8 +133,10 @@ class Notifications { 'label' => t('View the public stream') ], 'markall' => [ - 'url' => '#', 'label' => t('Mark all notifications seen') + ], + 'filter' => [ + 'label' => t('Show new posts only') ] ]; } -- cgit v1.2.3 From 8a8689c19139f075145001b46a15dea56ff21c77 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 2 Dec 2017 17:31:18 -0800 Subject: remove warning for large files on cloud upload --- Zotlabs/Storage/Browser.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index dd3067cf8..26abf27b5 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -373,8 +373,6 @@ class Browser extends DAV\Browser\Plugin { if(strpos($path,$special) === 0) $path = trim(substr($path,$count),'/'); - $info = t('Please use DAV to upload large (video, audio) files.
See Cloud Desktop Clients'); - $output .= replace_macros(get_markup_template('cloud_actionspanel.tpl'), array( '$folder_header' => t('Create new folder'), @@ -382,7 +380,6 @@ class Browser extends DAV\Browser\Plugin { '$upload_header' => t('Upload file'), '$upload_submit' => t('Upload'), '$quota' => $quota, - '$info' => $info, '$channick' => $this->auth->owner_nick, '$aclselect' => $aclselect, '$allow_cid' => acl2json($channel_acl['allow_cid']), -- cgit v1.2.3 From dae0107dd0e1caa460866b5debdc6de912bfd819 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 3 Dec 2017 12:31:41 +0100 Subject: fix some pubstream on/off weirdness --- Zotlabs/Lib/Apps.php | 2 +- Zotlabs/Module/Admin/Site.php | 1 + Zotlabs/Module/Ping.php | 2 +- Zotlabs/Module/Settings/Channel.php | 6 ++++-- 4 files changed, 7 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 9271cee85..457b85b62 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -352,7 +352,7 @@ class Apps { break; default: if($config) - $unset = ((get_config('system', $require[0]) == $require[1]) ? false : true); + $unset = ((get_config('system', $require[0]) === $require[1]) ? false : true); else $unset = ((local_channel() && feature_enabled(local_channel(),$require)) ? false : true); if($unset) diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php index eda97b591..a9db1ad55 100644 --- a/Zotlabs/Module/Admin/Site.php +++ b/Zotlabs/Module/Admin/Site.php @@ -251,6 +251,7 @@ class Site { ); $discover_tab = get_config('system','disable_discover_tab'); + // $disable public streams by default if($discover_tab === false) $discover_tab = 1; diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 84f9d2a21..c1bce0d51 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -140,7 +140,7 @@ class Ping extends \Zotlabs\Web\Controller { db_utcnow(), db_quoteinterval('3 MINUTE') ); - $discover_tab_on = ((get_config('system','disable_discover_tab') != 1) ? true : false); + $discover_tab_on = ((get_config('system','disable_discover_tab') || get_config('system','disable_discover_tab') === false) ? false : true); $notify_pubs = ((local_channel()) ? ($vnotify & VNOTIFY_PUBS) && $discover_tab_on : $discover_tab_on); if($notify_pubs) { diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index db0f79060..5e9e88a6d 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -206,7 +206,7 @@ class Channel { $vnotify += intval($_POST['vnotify11']); if(x($_POST,'vnotify12')) $vnotify += intval($_POST['vnotify12']); - if(x($_POST,'vnotify13') && (get_config('system', 'disable_discover_tab') != 1)) + if(x($_POST,'vnotify13')) $vnotify += intval($_POST['vnotify13']); $always_show_in_notices = x($_POST,'always_show_in_notices') ? 1 : 0; @@ -481,6 +481,8 @@ class Channel { $plugin = [ 'basic' => '', 'security' => '', 'notify' => '', 'misc' => '' ]; call_hooks('channel_settings',$plugin); + $disable_discover_tab = get_config('system','disable_discover_tab') || get_config('system','disable_discover_tab') === false; + $o .= replace_macros($stpl,array( '$ptitle' => t('Channel Settings'), @@ -570,7 +572,7 @@ class Channel { '$vnotify10' => array('vnotify10', t('New connections'), ($vnotify & VNOTIFY_INTRO), VNOTIFY_INTRO, t('Recommended'), $yes_no), '$vnotify11' => array('vnotify11', t('System Registrations'), ($vnotify & VNOTIFY_REGISTER), VNOTIFY_REGISTER, '', $yes_no), '$vnotify12' => array('vnotify12', t('Unseen shared files'), ($vnotify & VNOTIFY_FILES), VNOTIFY_FILES, '', $yes_no), - '$vnotify13' => ((get_config('system', 'disable_discover_tab') != 1) ? array('vnotify13', t('Unseen public activity'), ($vnotify & VNOTIFY_PUBS), VNOTIFY_PUBS, '', $yes_no) : array()), + '$vnotify13' => (($disable_discover_tab) ? array() : array('vnotify13', t('Unseen public activity'), ($vnotify & VNOTIFY_PUBS), VNOTIFY_PUBS, '', $yes_no)), '$mailhost' => [ 'mailhost', t('Email notification hub (hostname)'), get_pconfig(local_channel(),'system','email_notify_host',\App::get_hostname()), sprintf( t('If your channel is mirrored to multiple hubs, set this to your preferred location. This will prevent duplicate email notifications. Example: %s'),\App::get_hostname()) ], '$always_show_in_notices' => array('always_show_in_notices', t('Also show new wall posts, private messages and connections under Notices'), $always_show_in_notices, 1, '', $yes_no), -- cgit v1.2.3 From ba547c22571d90bc8757e45643463d53d9cae2e6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 3 Dec 2017 17:22:18 -0800 Subject: chunked uploads for photos page --- Zotlabs/Module/Photos.php | 52 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index caef45d98..279c393aa 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -465,6 +465,51 @@ class Photos extends \Zotlabs\Web\Controller { $_REQUEST['group_deny'] = expand_acl($channel['channel_deny_gid']); } + + $matches = []; + $partial = false; + + + + if(array_key_exists('HTTP_CONTENT_RANGE',$_SERVER)) { + $pm = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches); + if($pm) { + logger('Content-Range: ' . print_r($matches,true)); + $partial = true; + } + } + + if($partial) { + $x = save_chunk($channel,$matches[1],$matches[2],$matches[3]); + + if($x['partial']) { + header('Range: bytes=0-' . (($x['length']) ? $x['length'] - 1 : 0)); + json_return_and_die($result); + } + else { + header('Range: bytes=0-' . (($x['size']) ? $x['size'] - 1 : 0)); + + $_FILES['userfile'] = [ + 'name' => $x['name'], + 'type' => $x['type'], + 'tmp_name' => $x['tmp_name'], + 'error' => $x['error'], + 'size' => $x['size'] + ]; + } + } + else { + if(! array_key_exists('userfile',$_FILES)) { + $_FILES['userfile'] = [ + 'name' => $_FILES['files']['name'], + 'type' => $_FILES['files']['type'], + 'tmp_name' => $_FILES['files']['tmp_name'], + 'error' => $_FILES['files']['error'], + 'size' => $_FILES['files']['size'] + ]; + } + } + $r = attach_store($channel,get_observer_hash(), '', $_REQUEST); if(! $r['success']) { @@ -557,8 +602,11 @@ class Photos extends \Zotlabs\Web\Controller { nav_set_selected('Photos'); - $o = ""; - + $o = ' + + '; + + $o .= "\r\n"; -- cgit v1.2.3 From 1c32c5fd2ad2185ce2ea53f94edac1de1c178f7b Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 3 Dec 2017 17:25:00 -0800 Subject: rename button --- Zotlabs/Module/Photos.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index 279c393aa..6aece0ed6 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -704,7 +704,7 @@ class Photos extends \Zotlabs\Web\Controller { '$uploader' => $ret['addon_text'], '$default' => (($ret['default_upload']) ? true : false), '$uploadurl' => $ret['post_url'], - '$submit' => t('Submit') + '$submit' => t('Upload') )); -- cgit v1.2.3 From 1c821640cec383ab3ac02834cd560edd48111c08 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 3 Dec 2017 19:12:55 -0800 Subject: pagetitle lost importing a pdl element from conversation --- Zotlabs/Module/Impel.php | 2 ++ Zotlabs/Module/Layouts.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Impel.php b/Zotlabs/Module/Impel.php index 77f488d26..0c372bd96 100644 --- a/Zotlabs/Module/Impel.php +++ b/Zotlabs/Module/Impel.php @@ -26,6 +26,8 @@ class Impel extends \Zotlabs\Web\Controller { if(! $j) json_return_and_die($ret); + // logger('element: ' . print_r($j,true)); + $channel = \App::get_channel(); $arr = array(); diff --git a/Zotlabs/Module/Layouts.php b/Zotlabs/Module/Layouts.php index 34d754029..19efb37fd 100644 --- a/Zotlabs/Module/Layouts.php +++ b/Zotlabs/Module/Layouts.php @@ -162,12 +162,12 @@ class Layouts extends \Zotlabs\Web\Controller { 'created' => $rr['created'], 'edited' => $rr['edited'], 'mimetype' => $rr['mimetype'], - 'pagetitle' => $rr['sid'], + 'pagetitle' => urldecode($rr['v']), 'mid' => $rr['mid'] ); $pages[$rr['iid']][] = array( 'url' => $rr['iid'], - 'title' => $rr['v'], + 'title' => urldecode($rr['v']), 'descr' => $rr['title'], 'mid' => $rr['mid'], 'created' => $rr['created'], -- cgit v1.2.3 From 11b03ca4d287b85c6094a343e917e2f561cc10ba Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 4 Dec 2017 08:54:56 +0100 Subject: mod hq: do not 404 if we have no item --- Zotlabs/Module/Hq.php | 108 +++++++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 49 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index 6bc65e44e..073b67b92 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -53,29 +53,53 @@ class Hq extends \Zotlabs\Web\Controller { $r = q("SELECT mid FROM item WHERE uid = %d AND mid = parent_mid - ORDER BY created DESC - limit 1", + ORDER BY created DESC LIMIT 1", intval(local_channel()) ); - if(!$r[0]['mid']) { - \App::$error = 404; - notice( t('Item not found.') . EOL); - return; + if($r[0]['mid']) { + $item_hash = 'b64.' . base64url_encode($r[0]['mid']); } - - $item_hash = 'b64.' . base64url_encode($r[0]['mid']); } + if($item_hash) { - if(strpos($item_hash,'b64.') === 0) - $decoded = @base64url_decode(substr($item_hash,4)); + if(strpos($item_hash,'b64.') === 0) + $decoded = @base64url_decode(substr($item_hash,4)); - if($decoded) - $item_hash = $decoded; - - $updateable = false; + if($decoded) + $item_hash = $decoded; + + $target_item = null; + + $r = q("select id, uid, mid, parent_mid, thr_parent, verb, item_type, item_deleted, item_blocked from item where mid like '%s' limit 1", + dbesc($item_hash . '%') + ); + + if($r) { + $target_item = $r[0]; + } + //if the item is to be moderated redirect to /moderate + if($target_item['item_blocked'] == ITEM_MODERATED) { + goaway(z_root() . '/moderate/' . $target_item['id']); + } + + $static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0); + + $simple_update = (($update) ? " AND item_unseen = 1 " : ''); + + if($update && $_SESSION['loadtime']) + $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; + + if($static && $simple_update) + $simple_update .= " and item_thread_top = 0 and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' "; + + $sys = get_sys_channel(); + $sql_extra = item_permissions_sql($sys['channel_id']); + + } + if(! $update) { $channel = \App::get_channel(); @@ -105,52 +129,36 @@ class Hq extends \Zotlabs\Web\Controller { 'bbcode' => true, 'jotnets' => true ]; + + $o = replace_macros(get_markup_template("hq.tpl"), + [ + '$no_messages' => (($target_item) ? false : true), + '$no_messages_label' => t('Welcome to hubzilla!') + ] + ); $o = '
'; $o .= status_editor($a,$x); $o .= '
'; } - - $target_item = null; - - $r = q("select id, uid, mid, parent_mid, thr_parent, verb, item_type, item_deleted, item_blocked from item where mid like '%s' limit 1", - dbesc($item_hash . '%') - ); - - if($r) { - $target_item = $r[0]; - } - - //if the item is to be moderated redirect to /moderate - if($target_item['item_blocked'] == ITEM_MODERATED) { - goaway(z_root() . '/moderate/' . $target_item['id']); - } - - $static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0); - $simple_update = (($update) ? " AND item_unseen = 1 " : ''); - - if($update && $_SESSION['loadtime']) - $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; - - if($static && $simple_update) - $simple_update .= " and item_thread_top = 0 and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' "; - - $sys = get_sys_channel(); - $sql_extra = item_permissions_sql($sys['channel_id']); - if(! $update && ! $load) { nav_set_selected('HQ'); $static = ((local_channel()) ? channel_manual_conv_update(local_channel()) : 1); - // if the target item is not a post (eg a like) we want to address its thread parent - $mid = ((($target_item['verb'] == ACTIVITY_LIKE) || ($target_item['verb'] == ACTIVITY_DISLIKE)) ? $target_item['thr_parent'] : $target_item['mid']); + if($target_item) { + // if the target item is not a post (eg a like) we want to address its thread parent + $mid = ((($target_item['verb'] == ACTIVITY_LIKE) || ($target_item['verb'] == ACTIVITY_DISLIKE)) ? $target_item['thr_parent'] : $target_item['mid']); - // if we got a decoded hash we must encode it again before handing to javascript - if($decoded) - $mid = 'b64.' . base64url_encode($mid); + // if we got a decoded hash we must encode it again before handing to javascript + if($decoded) + $mid = 'b64.' . base64url_encode($mid); + } + else { + $mid = ''; + } $o .= '
' . "\r\n"; $o .= "
' . t('Hub URL') . '' . t('Access Type') . '' . t('Registration Policy') . '' . t('Software') . '' . t('Ratings') . '
' . $urltext . '' . $location . '' . $jj['access'] . '' . $jj['register'] . '' . '' . ucwords($jj['project']) . (($jj['version']) ? ' ' . $jj['version'] : '') . '
' . $urltext . '' . $location . '' . $jj['access'] . '' . $jj['register'] . '' . ucwords($jj['project']) . (($jj['version']) ? ' ' . $jj['version'] : '') . ' ' . t('View') . '