From 1a49f0d164ce94bc3fce227a68aa3796e22347e1 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 9 Mar 2017 18:54:10 -0800 Subject: one role. --- Zotlabs/Lib/System.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/System.php b/Zotlabs/Lib/System.php index 306c90f4a..865cb9a30 100644 --- a/Zotlabs/Lib/System.php +++ b/Zotlabs/Lib/System.php @@ -57,9 +57,7 @@ class System { static public function get_server_role() { - if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['server_role']) - return \App::$config['system']['server_role']; - return 'standard'; + return 'pro'; } static public function get_std_version() { @@ -72,11 +70,8 @@ class System { if(get_directory_realm() != DIRECTORY_REALM) return true; - - foreach(['hubzilla','zap'] as $t) { - if(stristr($p,$t)) - return true; - } + if(in_array(strtolower($p),['hubzilla','zap','red'])) + return true; return false; } } -- cgit v1.2.3 From c39c925d8db1fd6a62033c1ece71cc4424899935 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 12 Mar 2017 17:32:45 -0700 Subject: grrr. stop making branding assumptions. --- Zotlabs/Lib/Config.php | 2 +- Zotlabs/Lib/PConfig.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Config.php b/Zotlabs/Lib/Config.php index 5625a3f79..6e042feba 100644 --- a/Zotlabs/Lib/Config.php +++ b/Zotlabs/Lib/Config.php @@ -53,7 +53,7 @@ class Config { $dbvalue = ((is_array($value)) ? serialize($value) : $value); $dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue); - if(get_config($family, $key) === false || (! self::get_from_storage($family, $key))) { + if(self::Get($family, $key) === false || (! self::get_from_storage($family, $key))) { $ret = q("INSERT INTO config ( cat, k, v ) VALUES ( '%s', '%s', '%s' ) ", dbesc($family), dbesc($key), diff --git a/Zotlabs/Lib/PConfig.php b/Zotlabs/Lib/PConfig.php index d70697fbc..25478e764 100644 --- a/Zotlabs/Lib/PConfig.php +++ b/Zotlabs/Lib/PConfig.php @@ -119,7 +119,7 @@ class PConfig { $dbvalue = ((is_array($value)) ? serialize($value) : $value); $dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue); - if(get_pconfig($uid, $family, $key) === false) { + if(self::Get($uid, $family, $key) === false) { if(! array_key_exists($uid, \App::$config)) \App::$config[$uid] = array(); if(! array_key_exists($family, \App::$config[$uid])) -- cgit v1.2.3 From fc533107ed49735aad5ba39bf02b87ed7ac870b6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 12 Mar 2017 21:55:24 -0700 Subject: better handling of mimetype security --- Zotlabs/Lib/System.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/System.php b/Zotlabs/Lib/System.php index 865cb9a30..3d5b18506 100644 --- a/Zotlabs/Lib/System.php +++ b/Zotlabs/Lib/System.php @@ -54,8 +54,6 @@ class System { return 'https://github.com/redmatrix/hubzilla'; } - - static public function get_server_role() { return 'pro'; } -- cgit v1.2.3 From 1244b0e36af95226ba22f86025d2b24ab09003e6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 14 Mar 2017 00:23:44 -0700 Subject: class MarkdownSoap to safely store markdown by purifying and preserving (escaped) what may be unsafe code in codeblocks. The stored item needs to be unescaped just prior to calling the markdown-to-html processor --- Zotlabs/Lib/MarkdownSoap.php | 86 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 Zotlabs/Lib/MarkdownSoap.php (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/MarkdownSoap.php b/Zotlabs/Lib/MarkdownSoap.php new file mode 100644 index 000000000..d0481eb4d --- /dev/null +++ b/Zotlabs/Lib/MarkdownSoap.php @@ -0,0 +1,86 @@ +clean(); + * + * What this does: + * 1. extracts code blocks and privately escapes them from processing + * 2. Run html purifier on the content + * 3. put back the code blocks + * 4. run htmlspecialchars on the entire content for safe storage + * + * At render time: + * $markdown = \Zotlabs\Lib\MarkdownSoap::unescape($text); + * $html = \Michelf\MarkdownExtra::DefaultTransform($markdown); + */ + + + +class MarkdownSoap { + + private $token; + + private $str; + + function __construct($s) { + $this->str = $s; + $this->token = random_string(20); + } + + + function clean() { + $x = $this->extract_code($this->str); + $x = $this->purify($x); + $x = $this->putback_code($x); + $x = $this->escape($x); + + return $x; + } + + function extract_code($s) { + + $text = preg_replace_callback('{ + (?:\n\n|\A\n?) + ( # $1 = the code block -- one or more lines, starting with a space/tab + (?> + [ ]{'.'4'.'} # Lines must start with a tab or a tab-width of spaces + .*\n+ + )+ + ) + ((?=^[ ]{0,'.'4'.'}\S)|\Z) # Lookahead for non-space at line-start, or end of doc + }xm', + [ $this , 'encode_code' ], $s); + + return $text; + } + + function encode_code($matches) { + return $this->token . ';' . base64_encode($matches[1]) . ';' ; + } + + function decode_code($matches) { + return base64_decode($matches[1]); + } + + function putback_code($s) { + $text = preg_replace_callback('{' . $this->token . '\;(.*?)\;}xm',[ $this, 'decode_code' ], $s); + return $text; + } + + function purify($s) { + return purify_html($s); + } + + function escape($s) { + return htmlspecialchars($s,ENT_QUOTES); + } + + static public function unescape($s) { + return htmlspecialchars_decode($s,ENT_QUOTES); + } +} -- cgit v1.2.3 From 2c73b457ef0943d46804480a0aa016f64c11edbf Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 14 Mar 2017 17:07:29 -0700 Subject: input filter updates --- Zotlabs/Lib/MarkdownSoap.php | 2 +- Zotlabs/Lib/NativeWikiPage.php | 31 ++----------------------------- 2 files changed, 3 insertions(+), 30 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/MarkdownSoap.php b/Zotlabs/Lib/MarkdownSoap.php index d0481eb4d..2dcaaec9a 100644 --- a/Zotlabs/Lib/MarkdownSoap.php +++ b/Zotlabs/Lib/MarkdownSoap.php @@ -5,7 +5,7 @@ namespace Zotlabs\Lib; /** * MarkdownSoap * Purify Markdown for storage - * $x = newMarkdownSoap($string_to_be_cleansed); + * $x = new MarkdownSoap($string_to_be_cleansed); * $text = $x->clean(); * * What this does: diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index 941ade90c..9f54081a1 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -307,34 +307,6 @@ class NativeWikiPage { return null; } - - - static public function prepare_content($s) { - - $text = preg_replace_callback('{ - (?:\n\n|\A\n?) - ( # $1 = the code block -- one or more lines, starting with a space/tab - (?> - [ ]{'.'4'.'} # Lines must start with a tab or a tab-width of spaces - .*\n+ - )+ - ) - ((?=^[ ]{0,'.'4'.'}\S)|\Z) # Lookahead for non-space at line-start, or end of doc - }xm', - 'self::nwiki_prepare_content_callback', $s); - - return $text; - } - - static public function nwiki_prepare_content_callback($matches) { - $codeblock = $matches[1]; - - $codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES, UTF8, false); - return "\n\n" . $codeblock ; - } - - - static public function save_page($arr) { $pageUrlName = ((array_key_exists('pageUrlName',$arr)) ? $arr['pageUrlName'] : ''); @@ -352,7 +324,8 @@ class NativeWikiPage { $mimetype = $w['mimeType']; if($mimetype === 'text/markdown') { - $content = purify_html(Zlib\NativeWikiPage::prepare_content($content)); + $x = new Zlib\MarkdownSoap($content); + $content = $x->clean(); } else { $content = escape_tags($content); -- cgit v1.2.3 From 4afeefb5ce2119541a6d2a0a0b332c7a9a59a2b4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 18 Mar 2017 16:41:43 -0700 Subject: various input filter fixes --- Zotlabs/Lib/MarkdownSoap.php | 14 ++++++++++++-- Zotlabs/Lib/NativeWikiPage.php | 31 ++++++++++++++++++++++++------- 2 files changed, 36 insertions(+), 9 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/MarkdownSoap.php b/Zotlabs/Lib/MarkdownSoap.php index 2dcaaec9a..8cc18d513 100644 --- a/Zotlabs/Lib/MarkdownSoap.php +++ b/Zotlabs/Lib/MarkdownSoap.php @@ -34,9 +34,13 @@ class MarkdownSoap { function clean() { + $x = $this->extract_code($this->str); + $x = $this->purify($x); + $x = $this->putback_code($x); + $x = $this->escape($x); return $x; @@ -60,7 +64,7 @@ class MarkdownSoap { } function encode_code($matches) { - return $this->token . ';' . base64_encode($matches[1]) . ';' ; + return $this->token . ';' . base64_encode($matches[0]) . ';' ; } function decode_code($matches) { @@ -73,7 +77,13 @@ class MarkdownSoap { } function purify($s) { - return purify_html($s); + $s = str_replace("\n",'
',$s); + $s = str_replace("\t",'    ',$s); + $s = str_replace(' ',' ',$s); + $s = purify_html($s); + $s = str_replace(' '," ",$s); + $s = str_replace(['
','
'],["\n","\n"],$s); + return $s; } function escape($s) { diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index 9f54081a1..3d6da7779 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -323,13 +323,6 @@ class NativeWikiPage { } $mimetype = $w['mimeType']; - if($mimetype === 'text/markdown') { - $x = new Zlib\MarkdownSoap($content); - $content = $x->clean(); - } - else { - $content = escape_tags($content); - } // fetch the most recently saved revision. @@ -348,6 +341,7 @@ class NativeWikiPage { $item['author_xchan'] = $observer_hash; $item['revision'] = (($arr['revision']) ? intval($arr['revision']) + 1 : intval($item['revision']) + 1); $item['edited'] = datetime_convert(); + $item['mimetype'] = $mimetype; if($item['iconfig'] && is_array($item['iconfig']) && count($item['iconfig'])) { for($x = 0; $x < count($item['iconfig']); $x ++) { @@ -515,6 +509,29 @@ class NativeWikiPage { } return $s; } + + static public function render_page_history($arr) { + + $pageUrlName = ((array_key_exists('pageUrlName', $arr)) ? $arr['pageUrlName'] : ''); + $resource_id = ((array_key_exists('resource_id', $arr)) ? $arr['resource_id'] : ''); + + $pageHistory = self::page_history([ + 'channel_id' => \App::$profile_uid, + 'observer_hash' => get_observer_hash(), + 'resource_id' => $resource_id, + 'pageUrlName' => $pageUrlName + ]); + + return replace_macros(get_markup_template('nwiki_page_history.tpl'), array( + '$pageHistory' => $pageHistory['history'], + '$permsWrite' => $arr['permsWrite'], + '$name_lbl' => t('Name'), + '$msg_label' => t('Message','wiki_history') + )); + + } + + /** * Replace the instances of the string [toc] with a list element that will be populated by -- cgit v1.2.3 From 35fc7328de3237ef9727e6f729ffe4df4697a421 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 20 Mar 2017 19:41:03 -0700 Subject: even more fine tuning of the markdown purifier - especially when used with the wiki --- Zotlabs/Lib/MarkdownSoap.php | 2 +- Zotlabs/Lib/NativeWikiPage.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/MarkdownSoap.php b/Zotlabs/Lib/MarkdownSoap.php index 8cc18d513..cf1446f45 100644 --- a/Zotlabs/Lib/MarkdownSoap.php +++ b/Zotlabs/Lib/MarkdownSoap.php @@ -81,7 +81,7 @@ class MarkdownSoap { $s = str_replace("\t",'    ',$s); $s = str_replace(' ',' ',$s); $s = purify_html($s); - $s = str_replace(' '," ",$s); + $s = str_replace([' ', mb_convert_encoding(' ','UTF-8','HTML-ENTITIES')], [ ' ', ' ' ],$s); $s = str_replace(['
','
'],["\n","\n"],$s); return $s; } diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index 3d6da7779..960fe014e 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -156,7 +156,7 @@ class NativeWikiPage { $content = $item['body']; return [ - 'content' => json_encode($content), + 'content' => $content, 'mimeType' => $w['mimeType'], 'message' => '', 'success' => true -- cgit v1.2.3 From 8821986d87b36b8b5ea311bcb73d348dc0bed262 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 20 Mar 2017 19:50:09 -0700 Subject: after all of this, I would be very hesitant to use any multi-user system which uses markdown and which doesn't have a large security budget. --- Zotlabs/Lib/MarkdownSoap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/MarkdownSoap.php b/Zotlabs/Lib/MarkdownSoap.php index cf1446f45..e5f3c81dd 100644 --- a/Zotlabs/Lib/MarkdownSoap.php +++ b/Zotlabs/Lib/MarkdownSoap.php @@ -82,7 +82,7 @@ class MarkdownSoap { $s = str_replace(' ',' ',$s); $s = purify_html($s); $s = str_replace([' ', mb_convert_encoding(' ','UTF-8','HTML-ENTITIES')], [ ' ', ' ' ],$s); - $s = str_replace(['
','
'],["\n","\n"],$s); + $s = str_replace(['
','
', '<', '>' ],["\n","\n", '<', '>'],$s); return $s; } -- cgit v1.2.3 From 82631c3413b7fc7025f46cd23c17d3ea292cf16c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 21 Mar 2017 00:40:19 -0700 Subject: more markdown purification --- Zotlabs/Lib/MarkdownSoap.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/MarkdownSoap.php b/Zotlabs/Lib/MarkdownSoap.php index e5f3c81dd..a0214bbe4 100644 --- a/Zotlabs/Lib/MarkdownSoap.php +++ b/Zotlabs/Lib/MarkdownSoap.php @@ -77,12 +77,12 @@ class MarkdownSoap { } function purify($s) { - $s = str_replace("\n",'
',$s); - $s = str_replace("\t",'    ',$s); - $s = str_replace(' ',' ',$s); +// $s = str_replace("\n",'
',$s); +// $s = str_replace("\t",'    ',$s); +// $s = str_replace(' ',' ',$s); $s = purify_html($s); - $s = str_replace([' ', mb_convert_encoding(' ','UTF-8','HTML-ENTITIES')], [ ' ', ' ' ],$s); - $s = str_replace(['
','
', '<', '>' ],["\n","\n", '<', '>'],$s); +// $s = str_replace([' ', mb_convert_encoding(' ','UTF-8','HTML-ENTITIES')], [ ' ', ' ' ],$s); +// $s = str_replace(['
','
', '<', '>' ],["\n","\n", '<', '>'],$s); return $s; } -- cgit v1.2.3 From a7bf4366cee5dcdabe3eb6dbcb144727d2158775 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 21 Mar 2017 21:00:48 -0700 Subject: use the same host macro for sender address as for reply_to address --- Zotlabs/Lib/Enotify.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 257687567..5db5fb42d 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -67,7 +67,7 @@ class Enotify { $sender_name = $product; $hostname = \App::get_hostname(); if(strpos($hostname,':')) - $hostname = substr($hostname,0,strpos($hostname,':')); + $hostname = substr($hostname,0,strpos($hostname,':')); // Do not translate 'noreply' as it must be a legal 7-bit email address @@ -77,7 +77,7 @@ class Enotify { $sender_email = get_config('system','from_email'); if(! $sender_email) - $sender_email = 'Administrator' . '@' . \App::get_hostname(); + $sender_email = 'Administrator' . '@' . $hostname; $sender_name = get_config('system','from_email_name'); if(! $sender_name) -- cgit v1.2.3 From a2e101997836ebd904e94aa896a1bcc2e2c70f01 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 23 Mar 2017 21:49:20 -0700 Subject: move db_upgrade to zlib --- Zotlabs/Lib/DB_Upgrade.php | 105 +++++++++++++++++++++++++++++++++++++++++++++ Zotlabs/Lib/ThreadItem.php | 1 - 2 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 Zotlabs/Lib/DB_Upgrade.php (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/DB_Upgrade.php b/Zotlabs/Lib/DB_Upgrade.php new file mode 100644 index 000000000..13adaced5 --- /dev/null +++ b/Zotlabs/Lib/DB_Upgrade.php @@ -0,0 +1,105 @@ + (time() - 86400))) + return; + @unlink($lockfile); + //send the administrator an e-mail + file_put_contents($lockfile, $x); + + $r = q("select account_language from account where account_email = '%s' limit 1", + dbesc(App::$config['system']['admin_email']) + ); + push_lang(($r) ? $r[0]['account_language'] : 'en'); + + z_mail( + [ + 'toEmail' => \App::$config['system']['admin_email'], + 'messageSubject' => sprintf( t('Update Error at %s'), z_root()), + 'textVersion' => replace_macros(get_intltext_template('update_fail_eml.tpl'), + [ + '$sitename' => \App::$config['system']['sitename'], + '$siteurl' => z_root(), + '$update' => $x, + '$error' => sprintf( t('Update %s failed. See error logs.'), $x) + ] + ) + ] + ); + + //try the logger + logger('CRITICAL: Update Failed: ' . $x); + pop_lang(); + } + else { + set_config('database','update_r' . $x, 'success'); + } + } + } + set_config('system','db_version', $db_revision); + } + } + } + } +} \ No newline at end of file diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 799a606d6..b692224b0 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -337,7 +337,6 @@ class ThreadItem { 'profile_url' => $profile_link, 'thread_action_menu' => thread_action_menu($item,$conv->get_mode()), 'thread_author_menu' => thread_author_menu($item,$conv->get_mode()), - 'item_photo_menu' => item_photo_menu($item), 'dreport' => $dreport, 'name' => $profile_name, 'thumb' => $profile_avatar, -- cgit v1.2.3 From 878614f97a9f8dc5e9f8ad2b5b10a85003084938 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 25 Mar 2017 13:07:46 -0700 Subject: get rid of 'davguest' and allow for project specific DB updates (currently db updates are common between all possible projects/subprojects/forks). --- Zotlabs/Lib/DB_Upgrade.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/DB_Upgrade.php b/Zotlabs/Lib/DB_Upgrade.php index 13adaced5..2ee29c314 100644 --- a/Zotlabs/Lib/DB_Upgrade.php +++ b/Zotlabs/Lib/DB_Upgrade.php @@ -8,9 +8,10 @@ class DB_Upgrade { function __construct($db_revision) { - $build = get_config('system','db_version',0); + + $build = get_config('system', PLATFORM_NAME . '_db_version', 0); if(! intval($build)) - $build = set_config('system','db_version',$db_revision); + $build = set_config('system', PLATFORM_NAME . '_db_version', $db_revision); if($build == $db_revision) { // Nothing to be done. @@ -24,14 +25,17 @@ class DB_Upgrade { } $current = intval($db_revision); - if(($stored < $current) && file_exists('install/update.php')) { + + $update_file = 'install/' . PLATFORM_NAME . '/update.php'; + + if(($stored < $current) && file_exists($update_file)) { Config::Load('database'); // We're reporting a different version than what is currently installed. // Run any existing update scripts to bring the database up to current. - require_once('install/update.php'); + require_once($update_file); // make sure that boot.php and update.php are the same release, we might be // updating from git right this very second and the correct version of the update.php @@ -39,7 +43,8 @@ class DB_Upgrade { if($db_revision == UPDATE_VERSION) { for($x = $stored; $x < $current; $x ++) { - if(function_exists('update_r' . $x)) { + $func = PLATFORM_NAME . '_update_' . $x; + if(function_exists($func)) { // There could be a lot of processes running or about to run. // We want exactly one process to run the update command. // So store the fact that we're taking responsibility @@ -48,12 +53,11 @@ class DB_Upgrade { // If the update fails or times-out completely you may need to // delete the config entry to try again. - if(get_config('database','update_r' . $x)) + if(get_config('database', $func)) break; - set_config('database','update_r' . $x, '1'); + set_config('database',$func, '1'); // call the specific update - $func = 'update_r' . $x; $retval = $func(); if($retval) { @@ -93,11 +97,11 @@ class DB_Upgrade { pop_lang(); } else { - set_config('database','update_r' . $x, 'success'); + set_config('database',$func, 'success'); } } } - set_config('system','db_version', $db_revision); + set_config('system', PLATFORM_NAME . '_db_version', $db_revision); } } } -- cgit v1.2.3 From b0b5db770db0bfc7d3e3913bfd77a178d78d75f3 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 25 Mar 2017 13:22:14 -0700 Subject: provide compatibility with old-style update system --- Zotlabs/Lib/DB_Upgrade.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/DB_Upgrade.php b/Zotlabs/Lib/DB_Upgrade.php index 2ee29c314..55c69bcca 100644 --- a/Zotlabs/Lib/DB_Upgrade.php +++ b/Zotlabs/Lib/DB_Upgrade.php @@ -5,13 +5,25 @@ namespace Zotlabs\Lib; class DB_Upgrade { + public $config_name = ''; + public $func_prefix = ''; function __construct($db_revision) { + $update_file = 'install/' . PLATFORM_NAME . '/update.php'; + if(! file_exists($update_file)) { + $update_file = 'install/update.php'; + $this->config_name = 'db_version'; + $this->func_prefix = 'update_r'; + } + else { + $this->config_name = PLATFORM_NAME . '_db_version'; + $this->func_prefix = PLATFORM_NAME . '_update_'; + } - $build = get_config('system', PLATFORM_NAME . '_db_version', 0); + $build = get_config('system', $this->config_name, 0); if(! intval($build)) - $build = set_config('system', PLATFORM_NAME . '_db_version', $db_revision); + $build = set_config('system', $this->config_name, $db_revision); if($build == $db_revision) { // Nothing to be done. @@ -26,8 +38,6 @@ class DB_Upgrade { $current = intval($db_revision); - $update_file = 'install/' . PLATFORM_NAME . '/update.php'; - if(($stored < $current) && file_exists($update_file)) { Config::Load('database'); @@ -43,7 +53,7 @@ class DB_Upgrade { if($db_revision == UPDATE_VERSION) { for($x = $stored; $x < $current; $x ++) { - $func = PLATFORM_NAME . '_update_' . $x; + $func = $this->func_prefix . $x; if(function_exists($func)) { // There could be a lot of processes running or about to run. // We want exactly one process to run the update command. @@ -101,7 +111,7 @@ class DB_Upgrade { } } } - set_config('system', PLATFORM_NAME . '_db_version', $db_revision); + set_config('system', $this->config_name, $db_revision); } } } -- cgit v1.2.3 From 29596d12e371cde577cdf741476698dc14ae3f14 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 2 Apr 2017 17:34:16 -0700 Subject: app sorting issue --- Zotlabs/Lib/Apps.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 0ca2f7a99..edf050b95 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -219,7 +219,7 @@ class Apps { 'Suggest Channels' => t('Suggest Channels'), 'Login' => t('Login'), 'Channel Manager' => t('Channel Manager'), - 'Grid' => t('Grid'), + 'Grid' => t('Activity'), 'Settings' => t('Settings'), 'Files' => t('Files'), 'Webpages' => t('Webpages'), @@ -245,9 +245,19 @@ class Apps { 'Profile Photo' => t('Profile Photo') ); - if(array_key_exists($arr['name'],$apps)) { - $arr['name'] = $apps[$arr['name']]; + if(array_key_exists('name',$arr)) { + if(array_key_exists($arr['name'],$apps)) { + $arr['name'] = $apps[$arr['name']]; + } + } + else { + for($x = 0; $x < count($arr); $x++) { + if(array_key_exists($arr[$x]['name'],$apps)) { + $arr[$x]['name'] = $apps[$arr[$x]['name']]; + } + } } + } -- cgit v1.2.3 From 63dd6ad01a173d640e5c49dede1246dba840aa74 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 11 Apr 2017 23:05:56 -0700 Subject: don't allow any null fields in notify creation --- Zotlabs/Lib/Enotify.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 5db5fb42d..a10675a87 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -495,13 +495,14 @@ class Enotify { } } - $r = q("insert into notify (hash,xname,url,photo,created,aid,uid,link,parent,seen,ntype,verb,otype) - values('%s','%s','%s','%s','%s',%d,%d,'%s','%s',%d,%d,'%s','%s')", + $r = q("insert into notify (hash,xname,url,photo,created,msg,aid,uid,link,parent,seen,ntype,verb,otype) + values('%s','%s','%s','%s','%s','%s',%d,%d,'%s','%s',%d,%d,'%s','%s')", dbesc($datarray['hash']), dbesc($datarray['xname']), dbesc($datarray['url']), dbesc($datarray['photo']), dbesc($datarray['created']), + dbesc(''), // will fill this in below after the record is created intval($datarray['aid']), intval($datarray['uid']), dbesc($datarray['link']), -- cgit v1.2.3 From 53bd0146bb9a924a103646db0b628ede28d294a1 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 18 Apr 2017 18:31:10 -0700 Subject: oembed cache: don't store the url (which may need to be truncated), store a hash instead. This will allow us to convert the table to utf8mb4 without running into mysql key length restrictions as well as dealing with the potential ambiguity of truncated urls. --- Zotlabs/Lib/Cache.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Cache.php b/Zotlabs/Lib/Cache.php index f211269be..cea075659 100644 --- a/Zotlabs/Lib/Cache.php +++ b/Zotlabs/Lib/Cache.php @@ -9,10 +9,10 @@ namespace Zotlabs\Lib; class Cache { public static function get($key) { - $key = substr($key,0,254); + $hash = hash('whirlpool',$key); $r = q("SELECT v FROM cache WHERE k = '%s' limit 1", - dbesc($key) + dbesc($hash) ); if ($r) @@ -22,20 +22,20 @@ class Cache { public static function set($key,$value) { - $key = substr($key,0,254); + $hash = hash('whirlpool',$key); $r = q("SELECT * FROM cache WHERE k = '%s' limit 1", - dbesc($key) + dbesc($hash) ); if($r) { q("UPDATE cache SET v = '%s', updated = '%s' WHERE k = '%s'", dbesc($value), dbesc(datetime_convert()), - dbesc($key)); + dbesc($hash)); } else { q("INSERT INTO cache ( k, v, updated) VALUES ('%s','%s','%s')", - dbesc($key), + dbesc($hash), dbesc($value), dbesc(datetime_convert())); } -- cgit v1.2.3 From 6fcfab34883e5e93e9438ed4872de304e22b0f00 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 26 Apr 2017 19:47:05 -0700 Subject: issues from hubzilla:#737 --- Zotlabs/Lib/DB_Upgrade.php | 2 +- Zotlabs/Lib/NativeWiki.php | 4 ++-- Zotlabs/Lib/NativeWikiPage.php | 15 +++++++++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/DB_Upgrade.php b/Zotlabs/Lib/DB_Upgrade.php index 55c69bcca..bb72e7a05 100644 --- a/Zotlabs/Lib/DB_Upgrade.php +++ b/Zotlabs/Lib/DB_Upgrade.php @@ -83,7 +83,7 @@ class DB_Upgrade { file_put_contents($lockfile, $x); $r = q("select account_language from account where account_email = '%s' limit 1", - dbesc(App::$config['system']['admin_email']) + dbesc(\App::$config['system']['admin_email']) ); push_lang(($r) ? $r[0]['account_language'] : 'en'); diff --git a/Zotlabs/Lib/NativeWiki.php b/Zotlabs/Lib/NativeWiki.php index 7786ec25a..4301feaa0 100644 --- a/Zotlabs/Lib/NativeWiki.php +++ b/Zotlabs/Lib/NativeWiki.php @@ -101,11 +101,11 @@ class NativeWiki { static public function sync_a_wiki_item($uid,$id,$resource_id) { - $r = q("SELECT * from item WHERE uid = %d AND ( id = %d OR ( resource_type = '%s' and resource_id = %d )) ", + $r = q("SELECT * from item WHERE uid = %d AND ( id = %d OR ( resource_type = '%s' and resource_id = '%s' )) ", intval($uid), intval($id), dbesc(NWIKI_ITEM_RESOURCE_TYPE), - intval($resource_id) + dbesc($resource_id) ); if($r) { xchan_query($r); diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index bd40367c9..ed3df436c 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -21,12 +21,23 @@ class NativeWikiPage { $sql_extra = item_permissions_sql($channel_id,$observer_hash); $r = q("select * from item where resource_type = 'nwikipage' and resource_id = '%s' and uid = %d and item_deleted = 0 - $sql_extra group by mid order by created asc", + $sql_extra order by created asc", dbesc($resource_id), intval($channel_id) ); if($r) { - $items = fetch_post_tags($r,true); + $x = []; + $y = []; + + foreach($r as $rv) { + if(! in_array($rv['mid'],$x)) { + $y[] = $rv; + $x[] = $rv['mid']; + } + } + + $items = fetch_post_tags($y,true); + foreach($items as $page_item) { $title = get_iconfig($page_item['id'],'nwikipage','pagetitle',t('(No Title)')); if(urldecode($title) !== 'Home') { -- cgit v1.2.3 From 47ebddf99f5487cbcdfbabaa367c7b09fa0a86e3 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 5 May 2017 02:27:24 -0700 Subject: markdown autolinks - hubzilla bug #752 --- Zotlabs/Lib/MarkdownSoap.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/MarkdownSoap.php b/Zotlabs/Lib/MarkdownSoap.php index a0214bbe4..534ad819f 100644 --- a/Zotlabs/Lib/MarkdownSoap.php +++ b/Zotlabs/Lib/MarkdownSoap.php @@ -77,15 +77,22 @@ class MarkdownSoap { } function purify($s) { -// $s = str_replace("\n",'
',$s); -// $s = str_replace("\t",'    ',$s); -// $s = str_replace(' ',' ',$s); + $s = $this->protect_autolinks($s); $s = purify_html($s); -// $s = str_replace([' ', mb_convert_encoding(' ','UTF-8','HTML-ENTITIES')], [ ' ', ' ' ],$s); -// $s = str_replace(['
','
', '<', '>' ],["\n","\n", '<', '>'],$s); + $s = $this->unprotect_autolinks($s); return $s; } + function protect_autolinks($s) { + $s = preg_replace('/\<(https?\:\/\/)(.*?)\>/','[$1$2]($1$2)',$s); + return $s; + } + + function unprotect_autolinks($s) { + return $s; + + } + function escape($s) { return htmlspecialchars($s,ENT_QUOTES); } -- cgit v1.2.3 From ecbba937845cbd4e8e2ed67020b977e1f19fdbd0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 5 May 2017 02:27:24 -0700 Subject: markdown autolinks - hubzilla bug #752 --- Zotlabs/Lib/MarkdownSoap.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/MarkdownSoap.php b/Zotlabs/Lib/MarkdownSoap.php index a0214bbe4..534ad819f 100644 --- a/Zotlabs/Lib/MarkdownSoap.php +++ b/Zotlabs/Lib/MarkdownSoap.php @@ -77,15 +77,22 @@ class MarkdownSoap { } function purify($s) { -// $s = str_replace("\n",'
',$s); -// $s = str_replace("\t",'    ',$s); -// $s = str_replace(' ',' ',$s); + $s = $this->protect_autolinks($s); $s = purify_html($s); -// $s = str_replace([' ', mb_convert_encoding(' ','UTF-8','HTML-ENTITIES')], [ ' ', ' ' ],$s); -// $s = str_replace(['
','
', '<', '>' ],["\n","\n", '<', '>'],$s); + $s = $this->unprotect_autolinks($s); return $s; } + function protect_autolinks($s) { + $s = preg_replace('/\<(https?\:\/\/)(.*?)\>/','[$1$2]($1$2)',$s); + return $s; + } + + function unprotect_autolinks($s) { + return $s; + + } + function escape($s) { return htmlspecialchars($s,ENT_QUOTES); } -- cgit v1.2.3 From f637faf0d28cebae7ec55e2f137e7922d2e4e266 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 14 May 2017 18:02:22 -0700 Subject: Do not yet understand why on postgres, app['plugin'] gets set to 3 linefeeds but this prevents it from rendering --- Zotlabs/Lib/Apps.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index edf050b95..2ace361ca 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -34,7 +34,7 @@ class Apps { if($files) { foreach($files as $f) { $path = explode('/',$f); - $plugin = $path[1]; + $plugin = trim($path[1]); if(plugin_is_installed($plugin)) { $x = self::parse_app_description($f,$translate); if($x) { @@ -285,7 +285,7 @@ class Apps { self::translate_system_apps($papp); - if(($papp['plugin']) && (! plugin_is_installed($papp['plugin']))) + if(trim($papp['plugin']) && (! plugin_is_installed(trim($papp['plugin'])))) return ''; $papp['papp'] = self::papp_encode($papp); @@ -575,7 +575,7 @@ class Apps { $darray['app_addr'] = ((x($arr,'addr')) ? escape_tags($arr['addr']) : ''); $darray['app_price'] = ((x($arr,'price')) ? escape_tags($arr['price']) : ''); $darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : ''); - $darray['app_plugin'] = ((x($arr,'plugin')) ? escape_tags($arr['plugin']) : ''); + $darray['app_plugin'] = ((x($arr,'plugin')) ? escape_tags(trim($arr['plugin'])) : ''); $darray['app_requires'] = ((x($arr,'requires')) ? escape_tags($arr['requires']) : ''); $darray['app_system'] = ((x($arr,'system')) ? intval($arr['system']) : 0); $darray['app_deleted'] = ((x($arr,'deleted')) ? intval($arr['deleted']) : 0); @@ -653,7 +653,7 @@ class Apps { $darray['app_addr'] = ((x($arr,'addr')) ? escape_tags($arr['addr']) : ''); $darray['app_price'] = ((x($arr,'price')) ? escape_tags($arr['price']) : ''); $darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : ''); - $darray['app_plugin'] = ((x($arr,'plugin')) ? escape_tags($arr['plugin']) : ''); + $darray['app_plugin'] = ((x($arr,'plugin')) ? escape_tags(trim($arr['plugin'])) : ''); $darray['app_requires'] = ((x($arr,'requires')) ? escape_tags($arr['requires']) : ''); $darray['app_system'] = ((x($arr,'system')) ? intval($arr['system']) : 0); $darray['app_deleted'] = ((x($arr,'deleted')) ? intval($arr['deleted']) : 0); @@ -763,7 +763,7 @@ class Apps { $ret['system'] = $app['app_system']; if($app['app_plugin']) - $ret['plugin'] = $app['app_plugin']; + $ret['plugin'] = trim($app['app_plugin']); if($app['app_deleted']) $ret['deleted'] = $app['app_deleted']; -- cgit v1.2.3 From ef51c1c2b2b598a69391f95043b9ab32616ffea8 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 14 May 2017 18:02:22 -0700 Subject: Do not yet understand why on postgres, app['plugin'] gets set to 3 linefeeds but this prevents it from rendering --- Zotlabs/Lib/Apps.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index edf050b95..2ace361ca 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -34,7 +34,7 @@ class Apps { if($files) { foreach($files as $f) { $path = explode('/',$f); - $plugin = $path[1]; + $plugin = trim($path[1]); if(plugin_is_installed($plugin)) { $x = self::parse_app_description($f,$translate); if($x) { @@ -285,7 +285,7 @@ class Apps { self::translate_system_apps($papp); - if(($papp['plugin']) && (! plugin_is_installed($papp['plugin']))) + if(trim($papp['plugin']) && (! plugin_is_installed(trim($papp['plugin'])))) return ''; $papp['papp'] = self::papp_encode($papp); @@ -575,7 +575,7 @@ class Apps { $darray['app_addr'] = ((x($arr,'addr')) ? escape_tags($arr['addr']) : ''); $darray['app_price'] = ((x($arr,'price')) ? escape_tags($arr['price']) : ''); $darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : ''); - $darray['app_plugin'] = ((x($arr,'plugin')) ? escape_tags($arr['plugin']) : ''); + $darray['app_plugin'] = ((x($arr,'plugin')) ? escape_tags(trim($arr['plugin'])) : ''); $darray['app_requires'] = ((x($arr,'requires')) ? escape_tags($arr['requires']) : ''); $darray['app_system'] = ((x($arr,'system')) ? intval($arr['system']) : 0); $darray['app_deleted'] = ((x($arr,'deleted')) ? intval($arr['deleted']) : 0); @@ -653,7 +653,7 @@ class Apps { $darray['app_addr'] = ((x($arr,'addr')) ? escape_tags($arr['addr']) : ''); $darray['app_price'] = ((x($arr,'price')) ? escape_tags($arr['price']) : ''); $darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : ''); - $darray['app_plugin'] = ((x($arr,'plugin')) ? escape_tags($arr['plugin']) : ''); + $darray['app_plugin'] = ((x($arr,'plugin')) ? escape_tags(trim($arr['plugin'])) : ''); $darray['app_requires'] = ((x($arr,'requires')) ? escape_tags($arr['requires']) : ''); $darray['app_system'] = ((x($arr,'system')) ? intval($arr['system']) : 0); $darray['app_deleted'] = ((x($arr,'deleted')) ? intval($arr['deleted']) : 0); @@ -763,7 +763,7 @@ class Apps { $ret['system'] = $app['app_system']; if($app['app_plugin']) - $ret['plugin'] = $app['app_plugin']; + $ret['plugin'] = trim($app['app_plugin']); if($app['app_deleted']) $ret['deleted'] = $app['app_deleted']; -- cgit v1.2.3 From a1ba44db720abab58d8b6b13035daa25710acd03 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 16 May 2017 22:57:34 -0700 Subject: provide mechanism to arbitrarily sort the nav tray apps, currently the preferred order list needs to be manually created --- Zotlabs/Lib/Apps.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index edf050b95..26d4b88b3 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -539,6 +539,50 @@ class Apps { return($r); } + static public function app_order($uid,$apps) { + + if(! $apps) + return $apps; + + $x = (($uid) ? get_pconfig($uid,'system','app_order') : get_config('system','app_order')); + if(($x) && (! is_array($x))) { + $y = explode(',',$x); + $y = array_map('trim',$y); + $x = $y; + } + + if(! (is_array($x) && ($x))) + return $apps; + + $ret = []; + foreach($x as $xx) { + $y = self::find_app_in_array($xx,$apps); + if($y) { + $ret[] = $y; + } + } + foreach($apps as $ap) { + if(! self::find_app_in_array($ap['name'],$ret)) { + $ret[] = $ap; + } + } + return $ret; + + } + + static function find_app_in_array($name,$arr) { + if(! $arr) + return false; + foreach($arr as $x) { + if($x['name'] === $name) { + return $x; + } + } + return false; + } + + + static public function app_decode($s) { $x = base64_decode(str_replace(array('
',"\r","\n",' '),array('','','',''),$s)); -- cgit v1.2.3 From 21103f8bc4d4a54211ba4edaefc1bce694a8fa05 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 16 May 2017 22:57:34 -0700 Subject: provide mechanism to arbitrarily sort the nav tray apps, currently the preferred order list needs to be manually created --- Zotlabs/Lib/Apps.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 2ace361ca..102ed8bd1 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -539,6 +539,50 @@ class Apps { return($r); } + static public function app_order($uid,$apps) { + + if(! $apps) + return $apps; + + $x = (($uid) ? get_pconfig($uid,'system','app_order') : get_config('system','app_order')); + if(($x) && (! is_array($x))) { + $y = explode(',',$x); + $y = array_map('trim',$y); + $x = $y; + } + + if(! (is_array($x) && ($x))) + return $apps; + + $ret = []; + foreach($x as $xx) { + $y = self::find_app_in_array($xx,$apps); + if($y) { + $ret[] = $y; + } + } + foreach($apps as $ap) { + if(! self::find_app_in_array($ap['name'],$ret)) { + $ret[] = $ap; + } + } + return $ret; + + } + + static function find_app_in_array($name,$arr) { + if(! $arr) + return false; + foreach($arr as $x) { + if($x['name'] === $name) { + return $x; + } + } + return false; + } + + + static public function app_decode($s) { $x = base64_decode(str_replace(array('
',"\r","\n",' '),array('','','',''),$s)); -- cgit v1.2.3 From e4448423fbcee4e685b410a62844a245601d2e0b Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 21 May 2017 22:23:36 -0700 Subject: apporder module and all the associated backend stuff to make it work; probably needs a bit of UI cleanup and a link to it from somewhere --- Zotlabs/Lib/Apps.php | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 102ed8bd1..a655f47b0 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -370,7 +370,8 @@ class Apps { '$deleted' => $papp['deleted'], '$feature' => (($papp['embed']) ? false : true), '$featured' => ((strpos($papp['categories'], 'nav_featured_app') === false) ? false : true), - '$navapps' => (($mode == 'nav') ? true : false), + '$navapps' => (($mode == 'nav' || $mode='nav-order') ? true : false), + '$order' => (($mode='nav-order') ? true : false), '$add' => t('Add to app-tray'), '$remove' => t('Remove from app-tray') )); @@ -581,6 +582,90 @@ class Apps { return false; } + static function moveup($uid,$guid) { + $syslist = array(); + $list = self::app_list($uid, false, 'nav_featured_app'); + if($list) { + foreach($list as $li) { + $syslist[] = self::app_encode($li); + } + } + self::translate_system_apps($syslist); + + usort($syslist,'self::app_name_compare'); + + $syslist = self::app_order($uid,$syslist); + + if(! $syslist) + return; + + $newlist = []; + + foreach($syslist as $k => $li) { + if($li['guid'] === $guid) { + $position = $k; + break; + } + } + if(! $position) + return; + $dest_position = $position - 1; + $saved = $syslist[$dest_position]; + $syslist[$dest_position] = $syslist[$position]; + $syslist[$position] = $saved; + + $narr = []; + foreach($syslist as $x) { + $narr[] = $x['name']; + } + + set_pconfig($uid,'system','app_order',implode(',',$narr)); + + } + + static function movedown($uid,$guid) { + $syslist = array(); + $list = self::app_list($uid, false, 'nav_featured_app'); + if($list) { + foreach($list as $li) { + $syslist[] = self::app_encode($li); + } + } + self::translate_system_apps($syslist); + + usort($syslist,'self::app_name_compare'); + + $syslist = self::app_order($uid,$syslist); + + if(! $syslist) + return; + + $newlist = []; + + foreach($syslist as $k => $li) { + if($li['guid'] === $guid) { + $position = $k; + break; + } + } + if($position >= count($syslist) - 1) + return; + $dest_position = $position + 1; + $saved = $syslist[$dest_position]; + $syslist[$dest_position] = $syslist[$position]; + $syslist[$position] = $saved; + + $narr = []; + foreach($syslist as $x) { + $narr[] = $x['name']; + } + + set_pconfig($uid,'system','app_order',implode(',',$narr)); + + } + + + -- cgit v1.2.3 From 07ee4984cbdb3fa59441792a23c1cf3fc4151936 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 21 May 2017 22:42:22 -0700 Subject: some issues with the app order template logic --- Zotlabs/Lib/Apps.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index a655f47b0..ed18ff3cb 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -370,8 +370,8 @@ class Apps { '$deleted' => $papp['deleted'], '$feature' => (($papp['embed']) ? false : true), '$featured' => ((strpos($papp['categories'], 'nav_featured_app') === false) ? false : true), - '$navapps' => (($mode == 'nav' || $mode='nav-order') ? true : false), - '$order' => (($mode='nav-order') ? true : false), + '$navapps' => (($mode == 'nav') ? true : false), + '$order' => (($mode == 'nav-order') ? true : false), '$add' => t('Add to app-tray'), '$remove' => t('Remove from app-tray') )); -- cgit v1.2.3 From 53057830e0388e0888cca925a99aa62cda0168cf Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 22 May 2017 20:18:47 -0700 Subject: wiki auto language select to match webpages implementation --- Zotlabs/Lib/NativeWikiPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index ed3df436c..78b54ebda 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -44,7 +44,7 @@ class NativeWikiPage { $pages[] = [ 'resource_id' => $resource_id, 'title' => escape_tags($title), - 'url' => urlencode(urlencode($title)), + 'url' => str_replace('%2F','/',urlencode(str_replace('%2F','/',urlencode($title)))), 'link_id' => 'id_' . substr($resource_id, 0, 10) . '_' . $page_item['id'] ]; } -- cgit v1.2.3 From 357e7af6adb303aa12f6506585e7d59a1250da99 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 23 May 2017 01:18:34 -0700 Subject: add 'apps' app --- Zotlabs/Lib/Apps.php | 1 + 1 file changed, 1 insertion(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 06ec7c39d..df5fb4aec 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -209,6 +209,7 @@ class Apps { static public function translate_system_apps(&$arr) { $apps = array( + 'Apps' => t('Apps'), 'Site Admin' => t('Site Admin'), 'Report Bug' => t('Report Bug'), 'View Bookmarks' => t('View Bookmarks'), -- cgit v1.2.3 From ec7ecc285ec10a7990db09bda436fd498e05245a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 21 May 2017 22:23:36 -0700 Subject: apporder module and all the associated backend stuff to make it work; probably needs a bit of UI cleanup and a link to it from somewhere --- Zotlabs/Lib/Apps.php | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 102ed8bd1..a655f47b0 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -370,7 +370,8 @@ class Apps { '$deleted' => $papp['deleted'], '$feature' => (($papp['embed']) ? false : true), '$featured' => ((strpos($papp['categories'], 'nav_featured_app') === false) ? false : true), - '$navapps' => (($mode == 'nav') ? true : false), + '$navapps' => (($mode == 'nav' || $mode='nav-order') ? true : false), + '$order' => (($mode='nav-order') ? true : false), '$add' => t('Add to app-tray'), '$remove' => t('Remove from app-tray') )); @@ -581,6 +582,90 @@ class Apps { return false; } + static function moveup($uid,$guid) { + $syslist = array(); + $list = self::app_list($uid, false, 'nav_featured_app'); + if($list) { + foreach($list as $li) { + $syslist[] = self::app_encode($li); + } + } + self::translate_system_apps($syslist); + + usort($syslist,'self::app_name_compare'); + + $syslist = self::app_order($uid,$syslist); + + if(! $syslist) + return; + + $newlist = []; + + foreach($syslist as $k => $li) { + if($li['guid'] === $guid) { + $position = $k; + break; + } + } + if(! $position) + return; + $dest_position = $position - 1; + $saved = $syslist[$dest_position]; + $syslist[$dest_position] = $syslist[$position]; + $syslist[$position] = $saved; + + $narr = []; + foreach($syslist as $x) { + $narr[] = $x['name']; + } + + set_pconfig($uid,'system','app_order',implode(',',$narr)); + + } + + static function movedown($uid,$guid) { + $syslist = array(); + $list = self::app_list($uid, false, 'nav_featured_app'); + if($list) { + foreach($list as $li) { + $syslist[] = self::app_encode($li); + } + } + self::translate_system_apps($syslist); + + usort($syslist,'self::app_name_compare'); + + $syslist = self::app_order($uid,$syslist); + + if(! $syslist) + return; + + $newlist = []; + + foreach($syslist as $k => $li) { + if($li['guid'] === $guid) { + $position = $k; + break; + } + } + if($position >= count($syslist) - 1) + return; + $dest_position = $position + 1; + $saved = $syslist[$dest_position]; + $syslist[$dest_position] = $syslist[$position]; + $syslist[$position] = $saved; + + $narr = []; + foreach($syslist as $x) { + $narr[] = $x['name']; + } + + set_pconfig($uid,'system','app_order',implode(',',$narr)); + + } + + + -- cgit v1.2.3 From 50c9aec43652726b17e0fee3b555fb1344f38dbd Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 21 May 2017 22:42:22 -0700 Subject: some issues with the app order template logic --- Zotlabs/Lib/Apps.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index a655f47b0..ed18ff3cb 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -370,8 +370,8 @@ class Apps { '$deleted' => $papp['deleted'], '$feature' => (($papp['embed']) ? false : true), '$featured' => ((strpos($papp['categories'], 'nav_featured_app') === false) ? false : true), - '$navapps' => (($mode == 'nav' || $mode='nav-order') ? true : false), - '$order' => (($mode='nav-order') ? true : false), + '$navapps' => (($mode == 'nav') ? true : false), + '$order' => (($mode == 'nav-order') ? true : false), '$add' => t('Add to app-tray'), '$remove' => t('Remove from app-tray') )); -- cgit v1.2.3 From da682717ab6b37f87e2620a4305fa78131d57063 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 22 May 2017 20:18:47 -0700 Subject: wiki auto language select to match webpages implementation --- Zotlabs/Lib/NativeWikiPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index ed3df436c..78b54ebda 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -44,7 +44,7 @@ class NativeWikiPage { $pages[] = [ 'resource_id' => $resource_id, 'title' => escape_tags($title), - 'url' => urlencode(urlencode($title)), + 'url' => str_replace('%2F','/',urlencode(str_replace('%2F','/',urlencode($title)))), 'link_id' => 'id_' . substr($resource_id, 0, 10) . '_' . $page_item['id'] ]; } -- cgit v1.2.3 From 4fcfcc81172ebdfa4a27d3bca94bffe97356f600 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 29 May 2017 13:50:02 -0700 Subject: start deprecation of server_role --- Zotlabs/Lib/ThreadItem.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 5910ea672..ff4e3205e 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -251,8 +251,6 @@ class ThreadItem { ); } - $server_role = get_config('system','server_role'); - $has_bookmarks = false; if(is_array($item['term'])) { foreach($item['term'] as $t) { -- cgit v1.2.3 From 6f78183b74bbe50a6e96dca78f6724c882a668b1 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 11 Jun 2017 18:52:00 -0700 Subject: add numbers to the techlevel descriptions because that's what we will use to indicate a minimum level in documentation --- Zotlabs/Lib/Techlevels.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Techlevels.php b/Zotlabs/Lib/Techlevels.php index 6a8c36fb3..380901678 100644 --- a/Zotlabs/Lib/Techlevels.php +++ b/Zotlabs/Lib/Techlevels.php @@ -7,12 +7,12 @@ class Techlevels { static public function levels() { $techlevels = [ - '0' => t('Beginner/Basic'), - '1' => t('Novice - not skilled but willing to learn'), - '2' => t('Intermediate - somewhat comfortable'), - '3' => t('Advanced - very comfortable'), - '4' => t('Expert - I can write computer code'), - '5' => t('Wizard - I probably know more than you do') + '0' => t('0. Beginner/Basic'), + '1' => t('1. Novice - not skilled but willing to learn'), + '2' => t('2. Intermediate - somewhat comfortable'), + '3' => t('3. Advanced - very comfortable'), + '4' => t('4. Expert - I can write computer code'), + '5' => t('5. Wizard - I probably know more than you do') ]; return $techlevels; } -- cgit v1.2.3 From b917cf1eccc62f5f533c0a61ffd699764b39e404 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 18 Jun 2017 22:25:41 -0700 Subject: allow moderated comments like wordpress if permissions are compatible --- Zotlabs/Lib/Enotify.php | 11 ++++++++++- Zotlabs/Lib/ThreadItem.php | 8 ++++++-- Zotlabs/Lib/ThreadStream.php | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index a10675a87..114021568 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -170,6 +170,7 @@ class Enotify { xchan_query($p); + $moderated = (($p[0]['item_blocked'] = ITEM_MODERATED) ? true : false); $item_post_type = item_post_type($p[0]); // $private = $p[0]['item_private']; @@ -208,13 +209,21 @@ class Enotify { // Before this we have the name of the replier on the subject rendering // differents subjects for messages on the same thread. - $subject = sprintf( t('[$Projectname:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']); + if($moderated) + $subject = sprintf( t('[$Projectname:Notify] Moderated Comment to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']); + else + $subject = sprintf( t('[$Projectname:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']); $preamble = sprintf( t('%1$s, %2$s commented on an item/conversation you have been following.'), $recip['channel_name'], $sender['xchan_name']); $epreamble = $dest_str; $sitelink = t('Please visit %s to view and/or reply to the conversation.'); $tsitelink = sprintf( $sitelink, $siteurl ); $hsitelink = sprintf( $sitelink, '' . $sitename . ''); + if($moderated) { + $tsitelink .= "\n\n" . sprintf( t('Please visit %s to approve or reject this comment.'), z_root() . '/moderate' ); + $hsitelink .= "\n\n" . sprintf( t('Please visit %s to approve or reject this comment.'), z_root() . '/moderate' ); + } + } if ($params['type'] == NOTIFY_LIKE) { diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index ff4e3205e..50c67c466 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -741,8 +741,12 @@ class ThreadItem { '$feature_encrypt' => ((feature_enabled($conv->get_profile_owner(),'content_encrypt')) ? true : false), '$encrypt' => t('Encrypt text'), '$cipher' => $conv->get_cipher(), - '$sourceapp' => \App::$sourcename - + '$sourceapp' => \App::$sourcename, + '$observer' => get_observer_hash(), + '$anoncomments' => perm_is_allowed($conv->get_profile_owner(),'','post_comments'), + '$anonname' => [ 'anonname', t('Your full name (required)'),'','' ], + '$anonmail' => [ 'anonmail', t('Your email address (required)'),'','' ], + '$anonurl' => [ 'anonurl', t('Your website URL (optional)'),'','' ] )); return $comment_box; diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php index beb626f31..1fd746c38 100644 --- a/Zotlabs/Lib/ThreadStream.php +++ b/Zotlabs/Lib/ThreadStream.php @@ -158,7 +158,7 @@ class ThreadStream { if(intval($item->get_data_value('item_nocomment'))) { $item->set_commentable(false); } - elseif(($this->observer) && (! $item->is_commentable())) { + elseif(! $item->is_commentable()) { if((array_key_exists('owner',$item->data)) && intval($item->data['owner']['abook_self'])) $item->set_commentable(perm_is_allowed($this->profile_owner,$ob_hash,'post_comments')); else -- cgit v1.2.3 From b0a6a5a91e0180c0ed3de1af324e7b9567c5e108 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 18 Jun 2017 22:51:52 -0700 Subject: minor cleanup of moderated comment feature --- Zotlabs/Lib/Enotify.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 114021568..90662ce84 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -221,7 +221,7 @@ class Enotify { $hsitelink = sprintf( $sitelink, '' . $sitename . ''); if($moderated) { $tsitelink .= "\n\n" . sprintf( t('Please visit %s to approve or reject this comment.'), z_root() . '/moderate' ); - $hsitelink .= "\n\n" . sprintf( t('Please visit %s to approve or reject this comment.'), z_root() . '/moderate' ); + $hsitelink .= "

" . sprintf( t('Please visit %s to approve or reject this comment.'), '' . z_root() . '/moderate' ); } } -- cgit v1.2.3 From 1b31c9f8a875db70154b8512b1e2f96f0a6731cd Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 20 Jun 2017 05:11:07 -0700 Subject: prevent likes/dislikes/etc. from anon commenters --- Zotlabs/Lib/ThreadItem.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 50c67c466..8ee35f988 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -153,7 +153,7 @@ class ThreadItem { $response_verbs[] = 'attendyes'; $response_verbs[] = 'attendno'; $response_verbs[] = 'attendmaybe'; - if($this->is_commentable()) { + if($this->is_commentable() && $observer) { $isevent = true; $attend = array( t('I will attend'), t('I will not attend'), t('I might attend')); } @@ -164,7 +164,7 @@ class ThreadItem { $response_verbs[] = 'agree'; $response_verbs[] = 'disagree'; $response_verbs[] = 'abstain'; - if($this->is_commentable()) { + if($this->is_commentable() && $observer) { $conlabels = array( t('I agree'), t('I disagree'), t('I abstain')); $canvote = true; } @@ -263,7 +263,7 @@ class ThreadItem { if(($item['obj_type'] === ACTIVITY_OBJ_EVENT) && $conv->get_profile_owner() == local_channel()) $has_event = true; - if($this->is_commentable()) { + if($this->is_commentable() && $observer) { $like = array( t("I like this \x28toggle\x29"), t("like")); $dislike = array( t("I don't like this \x28toggle\x29"), t("dislike")); } @@ -369,7 +369,7 @@ class ThreadItem { 'has_tags' => $has_tags, 'reactions' => $this->reactions, // Item toolbar buttons - 'emojis' => (($this->is_toplevel() && $this->is_commentable() && feature_enabled($conv->get_profile_owner(),'emojis')) ? '1' : ''), + 'emojis' => (($this->is_toplevel() && $this->is_commentable() && $observer && feature_enabled($conv->get_profile_owner(),'emojis')) ? '1' : ''), 'like' => $like, 'dislike' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike : ''), 'share' => $share, -- cgit v1.2.3 From 07a8151ae66f1ccf00017f521219afdc2f5370ec Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 20 Jun 2017 12:45:05 -0700 Subject: more anon comment fixes --- Zotlabs/Lib/ThreadItem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 8ee35f988..72d8af4dd 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -743,7 +743,7 @@ class ThreadItem { '$cipher' => $conv->get_cipher(), '$sourceapp' => \App::$sourcename, '$observer' => get_observer_hash(), - '$anoncomments' => perm_is_allowed($conv->get_profile_owner(),'','post_comments'), + '$anoncomments' => (($conv->get_mode() === 'channel' && perm_is_allowed($conv->get_profile_owner(),'','post_comments')) ? true : false), '$anonname' => [ 'anonname', t('Your full name (required)'),'','' ], '$anonmail' => [ 'anonmail', t('Your email address (required)'),'','' ], '$anonurl' => [ 'anonurl', t('Your website URL (optional)'),'','' ] -- cgit v1.2.3 From 5f1a1db30fa4eae7c36d73b19e2e725a371138fb Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 21 Jun 2017 17:46:28 -0700 Subject: oopsy --- Zotlabs/Lib/Enotify.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 90662ce84..9f3347d19 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -170,7 +170,7 @@ class Enotify { xchan_query($p); - $moderated = (($p[0]['item_blocked'] = ITEM_MODERATED) ? true : false); + $moderated = (($p[0]['item_blocked'] == ITEM_MODERATED) ? true : false); $item_post_type = item_post_type($p[0]); // $private = $p[0]['item_private']; -- cgit v1.2.3 From 2d119c81a44691773bacd9e545ce49bebd522098 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 13 Jul 2017 20:18:19 -0700 Subject: turn platform name and std_version into config variables --- Zotlabs/Lib/DB_Upgrade.php | 8 +++++--- Zotlabs/Lib/System.php | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/DB_Upgrade.php b/Zotlabs/Lib/DB_Upgrade.php index bb72e7a05..8f0488f6f 100644 --- a/Zotlabs/Lib/DB_Upgrade.php +++ b/Zotlabs/Lib/DB_Upgrade.php @@ -10,15 +10,17 @@ class DB_Upgrade { function __construct($db_revision) { - $update_file = 'install/' . PLATFORM_NAME . '/update.php'; + $platform_name = System::get_platform_name(); + + $update_file = 'install/' . $platform_name . '/update.php'; if(! file_exists($update_file)) { $update_file = 'install/update.php'; $this->config_name = 'db_version'; $this->func_prefix = 'update_r'; } else { - $this->config_name = PLATFORM_NAME . '_db_version'; - $this->func_prefix = PLATFORM_NAME . '_update_'; + $this->config_name = $platform_name . '_db_version'; + $this->func_prefix = $platform_name . '_update_'; } $build = get_config('system', $this->config_name, 0); diff --git a/Zotlabs/Lib/System.php b/Zotlabs/Lib/System.php index 3d5b18506..a5790fb07 100644 --- a/Zotlabs/Lib/System.php +++ b/Zotlabs/Lib/System.php @@ -19,6 +19,9 @@ class System { static public function get_project_version() { if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['hide_version']) return ''; + if(is_array(\App::$config) && is_array(\App::$config['system']) && array_key_exists('std_version',\App::$config['system'])) + return \App::$config['system']['std_version']; + return self::get_std_version(); } -- cgit v1.2.3 From 1aedf22228cf888468619c85901d0e29c571c60a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 16 Jul 2017 22:28:28 -0700 Subject: initial activitystreams2 parser --- Zotlabs/Lib/ActivityStreams2.php | 86 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 Zotlabs/Lib/ActivityStreams2.php (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ActivityStreams2.php b/Zotlabs/Lib/ActivityStreams2.php new file mode 100644 index 000000000..46852886b --- /dev/null +++ b/Zotlabs/Lib/ActivityStreams2.php @@ -0,0 +1,86 @@ +data = json_decode($string,true); + if($this->data) { + $this->valid = true; + } + + if($this->is_valid()) { + $this->id = $this->get_property_obj('id'); + $this->type = $this->get_primary_type(); + $this->actor = $this->get_compound_property('actor'); + $this->obj = $this->get_compound_property('object'); + $this->tgt = $this->get_compound_property('target'); + } + } + + function is_valid() { + return $this->valid; + } + + function get_property_obj($property,$base = '') { + if(! $base) { + $base = $this->data; + } + return $base[$property]; + } + + function fetch_property($url) { + $redirects = 0; + $x = z_fetch_url($url,true,$redirects, + ['headers' => [ 'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"']]); + if($x['success']) + return json_decode($x['body'],true); + return null; + } + + function get_compound_property($property,$base = '') { + $x = $this->get_property_obj($property,$base); + if($this->is_url($x)) { + $x = $this->fetch_property($x); + } + return $x; + } + + function is_url($url) { + if(($url) && (! is_array($url)) && (strpos($url,'http') === 0)) { + return true; + } + return false; + } + + function get_primary_type($base = '') { + if(! $base) + $base = $this->data; + $x = $this->get_property_obj('type',$base); + if(is_array($x)) { + foreach($x as $y) { + if(strpos($y,':') === false) { + return $y; + } + } + } + return $x; + } + + function debug() { + $x = var_export($this,true); + return $x; + } + +} \ No newline at end of file -- cgit v1.2.3 From d8c93c0d13133d336e2cc3dbf3c48e0a6350c2d6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 17 Jul 2017 22:17:40 -0700 Subject: activitypub, cont. --- Zotlabs/Lib/ActivityStreams2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ActivityStreams2.php b/Zotlabs/Lib/ActivityStreams2.php index 46852886b..904782bf7 100644 --- a/Zotlabs/Lib/ActivityStreams2.php +++ b/Zotlabs/Lib/ActivityStreams2.php @@ -43,7 +43,7 @@ class ActivityStreams2 { function fetch_property($url) { $redirects = 0; $x = z_fetch_url($url,true,$redirects, - ['headers' => [ 'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"']]); + ['headers' => [ 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"']]); if($x['success']) return json_decode($x['body'],true); return null; -- cgit v1.2.3 From 1bdcfe5219c810758ae255427513a7a0c09ce8e1 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Fri, 21 Jul 2017 10:32:21 +0200 Subject: provide a mechanism to mark apps active in the bin --- Zotlabs/Lib/Apps.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 68587df49..08f054eaf 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -284,6 +284,9 @@ class Apps { if(! $papp['photo']) $papp['photo'] = z_root() . '/' . get_default_profile_photo(80); + if(\App::$nav_sel['active'] == $papp['name']) + $papp['active'] = true; + self::translate_system_apps($papp); if(trim($papp['plugin']) && (! plugin_is_installed(trim($papp['plugin'])))) -- cgit v1.2.3 From e71cdf02a8303689c933b98185e2671f49fc5a7d Mon Sep 17 00:00:00 2001 From: git-marijus Date: Wed, 26 Jul 2017 21:42:07 +0200 Subject: move the active app code to include/nav.php - it is only relevant there --- Zotlabs/Lib/Apps.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 08f054eaf..68587df49 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -284,9 +284,6 @@ class Apps { if(! $papp['photo']) $papp['photo'] = z_root() . '/' . get_default_profile_photo(80); - if(\App::$nav_sel['active'] == $papp['name']) - $papp['active'] = true; - self::translate_system_apps($papp); if(trim($papp['plugin']) && (! plugin_is_installed(trim($papp['plugin'])))) -- cgit v1.2.3 From acb8eeb85323a94bed85f3118fe20c1b5c9e2e7f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 9 Aug 2017 17:35:03 -0700 Subject: libxml errors --- Zotlabs/Lib/ThreadItem.php | 1 - Zotlabs/Lib/ThreadStream.php | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 72d8af4dd..9a36480cc 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -712,7 +712,6 @@ class ThreadItem { call_hooks('comment_buttons',$arr); $comment_buttons = $arr['comment_buttons']; - $comment_box = replace_macros($template,array( '$return_path' => '', '$threaded' => $this->is_threaded(), diff --git a/Zotlabs/Lib/ThreadStream.php b/Zotlabs/Lib/ThreadStream.php index 1fd746c38..35ccf4fdb 100644 --- a/Zotlabs/Lib/ThreadStream.php +++ b/Zotlabs/Lib/ThreadStream.php @@ -18,6 +18,7 @@ class ThreadStream { private $observer = null; private $writable = false; private $commentable = false; + private $uploadable = false; private $profile_owner = 0; private $preview = false; private $prepared_item = ''; -- cgit v1.2.3 From 57602647efe1a3f8ae22651366eaa59b1b1334e8 Mon Sep 17 00:00:00 2001 From: git-marijus Date: Sat, 12 Aug 2017 22:29:57 +0200 Subject: minor js and css changes --- Zotlabs/Lib/ThreadItem.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Lib') diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 9a36480cc..17d65dbc7 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -743,9 +743,9 @@ class ThreadItem { '$sourceapp' => \App::$sourcename, '$observer' => get_observer_hash(), '$anoncomments' => (($conv->get_mode() === 'channel' && perm_is_allowed($conv->get_profile_owner(),'','post_comments')) ? true : false), - '$anonname' => [ 'anonname', t('Your full name (required)'),'','' ], - '$anonmail' => [ 'anonmail', t('Your email address (required)'),'','' ], - '$anonurl' => [ 'anonurl', t('Your website URL (optional)'),'','' ] + '$anonname' => [ 'anonname', t('Your full name (required)'),'','','','onBlur="commentCloseUI(this,\'' . $this->get_id() . '\')"' ], + '$anonmail' => [ 'anonmail', t('Your email address (required)'),'','','','onBlur="commentCloseUI(this,\'' . $this->get_id() . '\')"' ], + '$anonurl' => [ 'anonurl', t('Your website URL (optional)'),'','','','onBlur="commentCloseUI(this,\'' . $this->get_id() . '\')"' ] )); return $comment_box; -- cgit v1.2.3