diff options
author | Mario <mario@mariovavti.com> | 2023-01-13 20:01:05 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2023-01-13 20:01:05 +0000 |
commit | 2805520d1bcb2640fc079d54f5f230f7b87d1f84 (patch) | |
tree | 43b3e5bb7c71522d04560015478765a7b763a5fe /Zotlabs/Module | |
parent | f6d940606350eb8685c278af6d87f3a0b8c0f5e5 (diff) | |
parent | fb7ca18820e7618325dded78a3c3a464dd01b391 (diff) | |
download | volse-hubzilla-8.0.tar.gz volse-hubzilla-8.0.tar.bz2 volse-hubzilla-8.0.zip |
Merge remote-tracking branch 'origin/8.0RC'8.0
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r-- | Zotlabs/Module/Admin/Queueworker.php | 121 | ||||
-rw-r--r-- | Zotlabs/Module/Admin/Site.php | 14 | ||||
-rw-r--r-- | Zotlabs/Module/Cloud.php | 9 | ||||
-rw-r--r-- | Zotlabs/Module/Follow.php | 4 | ||||
-rw-r--r-- | Zotlabs/Module/Import.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Invite.php | 13 | ||||
-rw-r--r-- | Zotlabs/Module/Item.php | 11 | ||||
-rw-r--r-- | Zotlabs/Module/Pdledit.php | 37 | ||||
-rw-r--r-- | Zotlabs/Module/Pdledit_gui.php | 59 | ||||
-rw-r--r-- | Zotlabs/Module/Pubstream.php | 56 | ||||
-rw-r--r-- | Zotlabs/Module/Settings/Account.php | 57 | ||||
-rw-r--r-- | Zotlabs/Module/Sharedwithme.php | 51 | ||||
-rw-r--r-- | Zotlabs/Module/Sse.php | 38 | ||||
-rw-r--r-- | Zotlabs/Module/Sse_bs.php | 60 | ||||
-rw-r--r-- | Zotlabs/Module/Vote.php | 6 |
15 files changed, 393 insertions, 145 deletions
diff --git a/Zotlabs/Module/Admin/Queueworker.php b/Zotlabs/Module/Admin/Queueworker.php new file mode 100644 index 000000000..45a09bf04 --- /dev/null +++ b/Zotlabs/Module/Admin/Queueworker.php @@ -0,0 +1,121 @@ +<?php + +namespace Zotlabs\Module\Admin; + +use App; +use Zotlabs\Web\Controller; + +class Queueworker extends Controller { + + function init() { + + } + + function post() { + + check_form_security_token('form_security_token', 'queueworker'); + + $maxqueueworkers = intval($_POST['queueworker_maxworkers']); + $maxqueueworkers = ($maxqueueworkers > 3) ? $maxqueueworkers : 4; + set_config('queueworker', 'max_queueworkers', $maxqueueworkers); + + $maxworkerage = intval($_POST['queueworker_max_age']); + $maxworkerage = ($maxworkerage >= 120) ? $maxworkerage : 300; + set_config('queueworker', 'queueworker_max_age', $maxworkerage); + + $queueworkersleep = intval($_POST['queue_worker_sleep']); + $queueworkersleep = ($queueworkersleep > 100) ? $queueworkersleep : 100; + set_config('queueworker', 'queue_worker_sleep', $queueworkersleep); + + $auto_queue_worker_sleep = intval($_POST['auto_queue_worker_sleep']); + set_config('queueworker', 'auto_queue_worker_sleep', $auto_queue_worker_sleep); + + goaway(z_root() . '/admin/queueworker'); + } + + function get() { + + $content = "<H1>Queue Status</H1>\n"; + + $r = q('select count(*) as total from workerq'); + + $content .= "<H4>There are " . $r[0]['total'] . " queue items to be processed.</H4>"; + + $r = dbq("select count(distinct workerq_reservationid) as qworkers from workerq where workerq_reservationid is not null"); + + $content .= "<H4>Active workers: " . $r[0]['qworkers'] . "</H4>"; + + $r = dbq("select workerq_cmd, count(*) as total from workerq where true group by workerq_cmd"); + + if ($r) { + $content .= "<H4>Work items</H4>"; + foreach($r as $rr) { + $content .= $rr['workerq_cmd'] . ': ' . $rr['total'] . '<br>'; + } + } + + $maxqueueworkers = get_config('queueworker', 'max_queueworkers', 4); + $maxqueueworkers = ($maxqueueworkers > 3) ? $maxqueueworkers : 4; + + $sc = ''; + + $sc .= replace_macros(get_markup_template('field_input.tpl'), [ + '$field' => [ + 'queueworker_maxworkers', + t('Max queueworker threads'), + $maxqueueworkers, + t('Minimum 4, default 4') + ] + ]); + + $workermaxage = get_config('queueworker', 'queueworker_max_age'); + $workermaxage = ($workermaxage >= 120) ? $workermaxage : 300; + + $sc .= replace_macros(get_markup_template('field_input.tpl'), [ + '$field' => [ + 'queueworker_max_age', + t('Assume workers dead after'), + $workermaxage, + t('Minimum 120, default 300 seconds') + ] + ]); + + $queueworkersleep = get_config('queueworker', 'queue_worker_sleep'); + $queueworkersleep = ($queueworkersleep > 100) ? $queueworkersleep : 100; + + $auto_queue_worker_sleep = get_config('queueworker', 'auto_queue_worker_sleep', 0); + + $sc .= replace_macros(get_markup_template('field_input.tpl'), [ + '$field' => [ + 'queue_worker_sleep', + t('Pause before starting next task'), + $queueworkersleep, + t('Minimum 100, default 100 microseconds'), + '', + (($auto_queue_worker_sleep) ? 'disabled' : '') + ] + ]); + + $sc .= replace_macros(get_markup_template('field_checkbox.tpl'), [ + '$field' => [ + 'auto_queue_worker_sleep', + t('Automatically adjust pause before starting next task'), + $auto_queue_worker_sleep, + ] + ]); + + $tpl = get_markup_template('settings_addon.tpl'); + $content .= replace_macros($tpl, [ + '$action_url' => 'admin/queueworker', + '$form_security_token' => get_form_security_token('queueworker'), + '$title' => t('Queueworker Settings'), + '$content' => $sc, + '$baseurl' => z_root(), + '$submit' => t('Save') + ] + ); + + return $content; + + } +} diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php index 85f81e344..42cf064c9 100644 --- a/Zotlabs/Module/Admin/Site.php +++ b/Zotlabs/Module/Admin/Site.php @@ -100,7 +100,7 @@ class Site { $reg_expire = (preg_match('/^[a-z]{1,1}$/', $regexpireu) ? $regexpiren . $regexpireu : ''); $imagick_path = ((x($_POST,'imagick_path')) ? trim($_POST['imagick_path']) : ''); - $force_queue = ((intval($_POST['force_queue']) > 0) ? intval($_POST['force_queue']) : 3000); + //$force_queue = ((intval($_POST['force_queue']) > 0) ? intval($_POST['force_queue']) : 3000); $pub_incl = escape_tags(trim($_POST['pub_incl'])); $pub_excl = escape_tags(trim($_POST['pub_excl'])); @@ -205,7 +205,7 @@ class Site { set_config('system','disable_discover_tab', $disable_discover_tab); set_config('system','site_firehose', $site_firehose); set_config('system','open_pubstream', $open_pubstream); - set_config('system','force_queue_threshold', $force_queue); + //set_config('system','force_queue_threshold', $force_queue); if ($global_directory == '') { del_config('system', 'directory_submit_url'); } else { @@ -508,10 +508,10 @@ class Site { '$frontpage' => array('frontpage', t("Site homepage to show visitors (default: login box)"), get_config('system','frontpage'), t("example: 'pubstream' to show public stream, 'page/sys/home' to show a system webpage called 'home' or 'include:home.html' to include a file.")), '$mirror_frontpage' => array('mirror_frontpage', t("Preserve site homepage URL"), get_config('system','mirror_frontpage'), t('Present the site homepage in a frame at the original location instead of redirecting')), '$allowed_sites' => array('allowed_sites', t("Allowed friend domains"), get_config('system','allowed_sites'), t("Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains")), - '$force_publish' => array('publish_all', t("Force publish"), get_config('system','publish_all'), t("Check to force all profiles on this site to be listed in the site directory.")), - '$disable_discover_tab' => array('disable_discover_tab', t('Import Public Streams'), $discover_tab, t('Import and allow access to public content pulled from other sites. Warning: this content is unmoderated.')), - '$site_firehose' => array('site_firehose', t('Site only Public Streams'), get_config('system','site_firehose'), t('Allow access to public content originating only from this site if Imported Public Streams are disabled.')), - '$open_pubstream' => array('open_pubstream', t('Allow anybody on the internet to access the Public streams'), get_config('system','open_pubstream',1), t('Disable to require authentication before viewing. Warning: this content is unmoderated.')), + '$force_publish' => array('publish_all', t("Force publish"), get_config('system','publish_all'), t("Check to force all profiles on this site to be listed in the site directory")), + '$disable_discover_tab' => array('disable_discover_tab', t('Enable public stream'), $discover_tab, t('Enable the public stream. Warning: this content is unmoderated')), + '$site_firehose' => array('site_firehose', t('Site only public stream'), get_config('system','site_firehose'), t('Restrict the public stream to content originating at this site')), + '$open_pubstream' => array('open_pubstream', t('Allow anybody on the internet to access the public streams'), get_config('system','open_pubstream',1), t('Disable to require authentication before viewing')), '$incl' => array('pub_incl',t('Only import Public stream posts with this text'), get_config('system','pubstream_incl'),t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')), '$excl' => array('pub_excl',t('Do not import Public stream posts with this text'), get_config('system','pubstream_excl'),t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')), @@ -532,7 +532,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',3000), t("Always defer immediate delivery if queue contains more than this number of entries.")), + //'$force_queue' => array('force_queue', t("Queue Threshold"), get_config('system','force_queue_threshold',3000), 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.")), diff --git a/Zotlabs/Module/Cloud.php b/Zotlabs/Module/Cloud.php index 4cc7595a1..05109247a 100644 --- a/Zotlabs/Module/Cloud.php +++ b/Zotlabs/Module/Cloud.php @@ -100,7 +100,6 @@ class Cloud extends Controller { // over-ride the default XML output on thrown exceptions - $server->on('exception', [ $this, 'DAVException' ]); // All we need to do now, is to fire up the server @@ -117,21 +116,19 @@ class Cloud extends Controller { function DAVException($err) { if($err instanceof \Sabre\DAV\Exception\NotFound) { - notice( t('Not found') . EOL); + \App::$page['content'] = '<h2>404 Not found</h2>'; } elseif($err instanceof \Sabre\DAV\Exception\Forbidden) { - notice( t('Permission denied') . EOL); + \App::$page['content'] = '<h2>403 Forbidden</h2>'; } elseif($err instanceof \Sabre\DAV\Exception\NotImplemented) { - // notice( t('Please refresh page') . EOL); goaway(z_root() . '/' . \App::$query_string); } else { - notice( t('Unknown error') . EOL); + \App::$page['content'] = '<h2>Unknown error</h2>'; } construct_page(); - killme(); } diff --git a/Zotlabs/Module/Follow.php b/Zotlabs/Module/Follow.php index 54e29c492..f8bfc11f3 100644 --- a/Zotlabs/Module/Follow.php +++ b/Zotlabs/Module/Follow.php @@ -70,12 +70,12 @@ class Follow extends Controller { } $uid = local_channel(); - $url = notags(trim(punify($_REQUEST['url']))); + $url = notags(punify(trim($_REQUEST['url']))); $return_url = $_SESSION['return_url']; $interactive = $_REQUEST['interactive'] ?? 1; $channel = App::get_channel(); - $result = Connect::connect($channel,$url); + $result = Connect::connect($channel, $url); if ($result['success'] == false) { if ($result['message']) { diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index ec47e370b..c8a9ac5ed 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -536,7 +536,7 @@ class Import extends Controller { $since = datetime_convert(date_default_timezone_get(), date_default_timezone_get(), '0001-01-01 00:00'); $until = datetime_convert(date_default_timezone_get(), date_default_timezone_get(), 'now + 1 day'); - $poll_interval = get_config('system', 'poll_interval', 3); + //$poll_interval = get_config('system', 'poll_interval', 3); $page = 0; Master::Summon(['Content_importer', sprintf('%d', $page), $since, $until, $channel['channel_address'], urlencode($hz_server)]); diff --git a/Zotlabs/Module/Invite.php b/Zotlabs/Module/Invite.php index 2a126ac27..bb552e4c7 100644 --- a/Zotlabs/Module/Invite.php +++ b/Zotlabs/Module/Invite.php @@ -43,6 +43,19 @@ class Invite extends Controller { const MYP = 'ZAI'; const VERSION = '2.0.0'; + function init() { + + if (!local_channel()) { + return; + } + + $channel = App::get_channel(); + if ($channel) { + profile_load($channel['channel_address']); + } + + } + function post() { // zai02 diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 8e6106e79..27fc62ee6 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -1518,8 +1518,9 @@ class Item extends Controller { if (preg_match_all('/\[answer\](.*?)\[\/answer\]/ism', $body, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { - $ptr[] = ['name' => $match[1], 'type' => 'Note', 'replies' => ['type' => 'Collection', 'totalItems' => 0]]; - $body = str_replace('[answer]' . $match[1] . '[/answer]', EMPTY_STR, $body); + $answer = escape_tags(trim($match[1])); + $ptr[] = ['name' => $answer, 'type' => 'Note', 'replies' => ['type' => 'Collection', 'totalItems' => 0]]; + $body = str_replace('[answer]' . $answer . '[/answer]', EMPTY_STR, $body); } } @@ -1573,8 +1574,10 @@ class Item extends Controller { $obj['content'] = bbcode($question); foreach ($answers as $answer) { - if (trim($answer)) - $ptr[] = ['name' => escape_tags($answer), 'type' => 'Note', 'replies' => ['type' => 'Collection', 'totalItems' => 0]]; + $answer = escape_tags(trim($answer)); + if ($answer) { + $ptr[] = ['name' => $answer, 'type' => 'Note', 'replies' => ['type' => 'Collection', 'totalItems' => 0]]; + } } if ($multiple) { diff --git a/Zotlabs/Module/Pdledit.php b/Zotlabs/Module/Pdledit.php index 3b94c9611..e0bbc31d0 100644 --- a/Zotlabs/Module/Pdledit.php +++ b/Zotlabs/Module/Pdledit.php @@ -78,6 +78,23 @@ class Pdledit extends Controller { } } + // addons + $o .= '<h2>Addons</h2>'; + + $addons = plugins_installed_list(); + + foreach ($addons as $addon) { + + $path = 'addon/' . $addon . '/Mod_' . ucfirst($addon) . '.php'; + + if (!file_exists($path)) + continue; + + $o .= '<a href="pdledit/' . $addon . '" >' . $addon . '</a>' . ((in_array($addon, $edited)) ? ' ' . t('(modified)') . ' <a href="pdledit/' . $addon . '/reset" >' . t('Reset') . '</a>': '' ) . '<br />'; + + } + + $o .= '</div>'; // list module pdl files @@ -85,11 +102,25 @@ class Pdledit extends Controller { } $t = get_pconfig(local_channel(),'system',$module); - $s = file_get_contents(theme_include($module)); - if(! $t) { + $s = ''; + + if(!$t) { + $sys_path = theme_include($module); + + if ($sys_path) { + $s = file_get_contents($sys_path); + } + else { + $addon_path = 'addon/' . argv(1) . '/' . $module; + if (file_exists($addon_path)) { + $s = file_get_contents($addon_path); + } + } + $t = $s; } - if(! $t) { + + if(!$t) { notice( t('Layout not found.') . EOL); return ''; } diff --git a/Zotlabs/Module/Pdledit_gui.php b/Zotlabs/Module/Pdledit_gui.php index b550b92d3..45a06c00a 100644 --- a/Zotlabs/Module/Pdledit_gui.php +++ b/Zotlabs/Module/Pdledit_gui.php @@ -6,6 +6,7 @@ use App; use Zotlabs\Web\Controller; use Zotlabs\Render\Comanche; use Zotlabs\Lib\Libsync; +use Zotlabs\Lib\Apps; class Pdledit_gui extends Controller { @@ -220,6 +221,7 @@ class Pdledit_gui extends Controller { function get_modules() { $ret = ''; + $arr = []; $files = glob('Zotlabs/Module/*.php'); if($files) { @@ -232,23 +234,61 @@ class Pdledit_gui extends Controller { $x = theme_include('mod_' . $name . '.pdl'); if($x) { - $ret .= '<div class="mb-2"><a href="pdledit_gui/' . $name . '">' . $name . '</a></div>'; + $arr[] = $name; } } } + $addons = plugins_installed_list(); + if ($addons) { + foreach ($addons as $name) { + if (!Apps::addon_app_installed(local_channel(), $name)) { + continue; + } + + $path = 'addon/' . $name . '/mod_' . $name . '.pdl'; + if (file_exists($path)) { + $arr[] = $name; + } + } + } + + sort($arr); + + foreach ($arr as $name) { + $ret .= '<div class="mb-2"><a href="pdledit_gui/' . $name . '">' . $name . '</a></div>'; + } + return $ret; + } function get_widgets($module) { $ret = []; + $checkpaths = [ 'Zotlabs/Widget/*.php' ]; + $addons = plugins_installed_list(); + + if ($addons) { + foreach ($addons as $name) { + if (!Apps::addon_app_installed(local_channel(), $name)) { + continue; + } + + $path = 'addon/' . $name . '/Widget'; + if (is_dir($path)) { + $checkpaths[] = $path . '/*.php'; + } + } + } + foreach ($checkpaths as $path) { $files = glob($path); + if($files) { foreach($files as $f) { $name = lcfirst(basename($f, '.php')); @@ -272,6 +312,8 @@ class Pdledit_gui extends Controller { } } + usort($ret, fn($a, $b) => $a['name'] <=> $b['name']); + return $ret; } @@ -536,12 +578,21 @@ class Pdledit_gui extends Controller { 'modified' => true ]; - $pdl_path = 'mod_' . $module . '.pdl'; + $pdl = 'mod_' . $module . '.pdl'; + $pdl_path = ''; - $ret['pdl'] = get_pconfig(local_channel(), 'system', $pdl_path); + $ret['pdl'] = get_pconfig(local_channel(), 'system', $pdl); if(!$ret['pdl']) { - $pdl_path = theme_include($pdl_path); + $pdl_path = theme_include($pdl); + + if (!$pdl_path) { + $addon_path = 'addon/' . $module . '/' . $pdl; + if (file_exists($addon_path)) { + $pdl_path = $addon_path; + } + } + if ($pdl_path) { $ret['pdl'] = file_get_contents($pdl_path); $ret['modified'] = false; diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 3c8dfa0a5..9d3a4f92b 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -12,6 +12,7 @@ class Pubstream extends \Zotlabs\Web\Controller { function get($update = 0, $load = false) { + if(local_channel()) { if(! Apps::system_app_installed(local_channel(), 'Public Stream')) { //Do not display any associated widgets at this point @@ -31,18 +32,16 @@ class Pubstream extends \Zotlabs\Web\Controller { } } - $site_firehose = ((intval(get_config('system','site_firehose',0))) ? true : false); $net_firehose = ((get_config('system','disable_discover_tab',1)) ? false : true); - if(! ($site_firehose || $net_firehose)) { + if(!$net_firehose) { return ''; } - if($net_firehose) { - $site_firehose = false; - } + $site_firehose = ((intval(get_config('system','site_firehose',0))) ? true : false); + + $mid = (($_REQUEST['mid']) ? unpack_link_id($_REQUEST['mid']) : ''); - $mid = ((x($_REQUEST, 'mid')) ? unpack_link_id($_REQUEST['mid']) : ''); if ($mid === false) { notice(t('Malformed message id.') . EOL); return; @@ -160,15 +159,15 @@ class Pubstream extends \Zotlabs\Web\Controller { require_once('include/security.php'); $sys = get_sys_channel(); + $uids = " and item.uid = " . intval($sys['channel_id']) . " "; $abook_uids = " and abook.abook_channel = " . intval($sys['channel_id']) . " "; + $sql_extra = item_permissions_sql($sys['channel_id']); + $sql_extra_order = ''; + $site_firehose_sql = ''; + $thread_top = " and item.item_thread_top = 1 "; if($site_firehose) { - $uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and item_wall = 1 "; - } - else { - $uids = " and item.uid = " . intval($sys['channel_id']) . " "; - $sql_extra = item_permissions_sql($sys['channel_id']); - \App::$data['firehose'] = intval($sys['channel_id']); + $site_firehose_sql = " and owner_xchan in (select channel_hash from channel where channel_system = 0 and channel_removed = 0) "; } if(get_config('system','public_list_mode')) @@ -179,6 +178,8 @@ class Pubstream extends \Zotlabs\Web\Controller { if(x($hashtags)) { $sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG)); + $sql_extra_order = " ORDER BY item.created DESC "; + $thread_top = ''; } $net_query = (($net) ? " left join xchan on xchan_hash = author_xchan " : ''); @@ -200,7 +201,9 @@ class Pubstream extends \Zotlabs\Web\Controller { $r = q("SELECT parent AS item_id FROM item left join abook on item.author_xchan = abook.abook_xchan $net_query - WHERE mid = '%s' $uids $item_normal + WHERE item.mid = '%s' and item.item_private = 0 + $uids $site_firehose_sql + $item_normal and (abook.abook_blocked = 0 or abook.abook_flags is null) $sql_extra $net_query2", dbesc($mid) @@ -208,10 +211,12 @@ class Pubstream extends \Zotlabs\Web\Controller { } else { // Fetch a page full of parent items for this page - $r = dbq("SELECT item.id AS item_id FROM item + $r = dbq("SELECT parent AS item_id FROM item left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) $net_query - WHERE true $uids and item.item_thread_top = 1 $item_normal + WHERE item.item_private = 0 $thread_top + $uids $site_firehose_sql + $item_normal and (abook.abook_blocked = 0 or abook.abook_flags is null) $sql_extra $net_query2 ORDER BY $ordering DESC $pager_sql " @@ -223,7 +228,8 @@ class Pubstream extends \Zotlabs\Web\Controller { $r = q("SELECT parent AS item_id FROM item left join abook on item.author_xchan = abook.abook_xchan $net_query - WHERE mid = '%s' $uids $item_normal_update $simple_update + WHERE item.mid = '%s' and item.item_private = 0 + $uids $site_firehose_sql $item_normal_update $simple_update and (abook.abook_blocked = 0 or abook.abook_flags is null) $sql_extra $net_query2", dbesc($mid) @@ -233,7 +239,8 @@ class Pubstream extends \Zotlabs\Web\Controller { $r = dbq("SELECT parent AS item_id FROM item left join abook on item.author_xchan = abook.abook_xchan $net_query - WHERE true $uids $item_normal_update + WHERE item.item_private = 0 $thread_top + $uids $site_firehose_sql $item_normal_update $simple_update and (abook.abook_blocked = 0 or abook.abook_flags is null) $sql_extra $net_query2" @@ -251,21 +258,26 @@ class Pubstream extends \Zotlabs\Web\Controller { $items = dbq("SELECT item.*, item.id AS item_id FROM item WHERE true $uids $item_normal AND item.parent IN ( $parents_str ) - $sql_extra" + $sql_extra $sql_extra_order" ); + // 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)); + xchan_query($items, true, local_channel()); $items = fetch_post_tags($items,true); - $items = conv_sort($items,$ordering); + + if (!$hashtags) { + $items = conv_sort($items, $ordering); + } + + } } - // fake it - $mode = (($hashtags) ? 'search' : 'pubstream'); + $mode = (($hashtags) ? 'pubstream-new' : 'pubstream'); $o .= conversation($items,$mode,$update,$page_mode); diff --git a/Zotlabs/Module/Settings/Account.php b/Zotlabs/Module/Settings/Account.php index 97cc9389a..5e1fb176e 100644 --- a/Zotlabs/Module/Settings/Account.php +++ b/Zotlabs/Module/Settings/Account.php @@ -6,11 +6,11 @@ class Account { function post() { check_form_security_token_redirectOnErr('/settings/account', 'settings_account'); - + call_hooks('account_settings_post', $_POST); - + $errs = array(); - + $email = ((x($_POST,'email')) ? trim(notags($_POST['email'])) : ''); $account = \App::get_account(); @@ -34,38 +34,38 @@ class Account { } } } - + if($errs) { foreach($errs as $err) notice($err . EOL); $errs = array(); } - - + + if((x($_POST,'npassword')) || (x($_POST,'confirm'))) { - + $origpass = trim($_POST['origpass']); - + require_once('include/auth.php'); if(! account_verify_password($email,$origpass)) { $errs[] = t('Password verification failed.'); } - + $newpass = trim($_POST['npassword']); $confirm = trim($_POST['confirm']); - + if($newpass != $confirm ) { $errs[] = t('Passwords do not match. Password unchanged.'); } - + if((! x($newpass)) || (! x($confirm))) { $errs[] = t('Empty passwords are not allowed. Password unchanged.'); } - + if(! $errs) { $salt = random_string(32); $password_encoded = hash('whirlpool', $salt . $newpass); - $r = q("update account set account_salt = '%s', account_password = '%s', account_password_changed = '%s' + $r = q("update account set account_salt = '%s', account_password = '%s', account_password_changed = '%s' where account_id = %d", dbesc($salt), dbesc($password_encoded), @@ -78,36 +78,37 @@ class Account { $errs[] = t('Password update failed. Please try again.'); } } - - + + if($errs) { foreach($errs as $err) notice($err . EOL); } goaway(z_root() . '/settings/account' ); } - - + + function get() { $account_settings = ""; - + call_hooks('account_settings', $account_settings); - + $email = \App::$account['account_email']; - $attremail = (!strpos($email, '@')) ? 'disabled="disabled"' : ''; + $attremail = ((!strpos($email, '@')) ? 'disabled="disabled"' : ''); $tpl = get_markup_template("settings_account.tpl"); $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("settings_account"), - '$title' => t('Account Settings'), - '$origpass' => array('origpass', t('Current Password'), ' ',''), - '$password1'=> array('npassword', t('Enter New Password'), '', ''), - '$password2'=> array('confirm', t('Confirm New Password'), '', t('Leave password fields blank unless changing')), - '$submit' => t('Submit'), - '$email' => array('email', t('DId2 or Email Address:'), $email, '', '', $attremail), - '$removeme' => t('Remove Account'), - '$removeaccount' => t('Remove this account including all its channels'), + '$title' => t('Account Settings'), + '$origpass' => array('origpass', t('Current Password'), ' ',''), + '$password1' => array('npassword', t('Enter New Password'), '', ''), + '$password2' => array('confirm', t('Confirm New Password'), '', t('Leave password fields blank unless changing')), + '$submit' => t('Submit'), + '$email' => array('email', t('DId2 or Email Address:'), $email, '', '', $attremail), + '$email_hidden' => (($attremail) ? $email : ''), + '$removeme' => t('Remove Account'), + '$removeaccount' => t('Remove this account including all its channels'), '$account_settings' => $account_settings )); return $o; diff --git a/Zotlabs/Module/Sharedwithme.php b/Zotlabs/Module/Sharedwithme.php index 4211a3af8..c294079d4 100644 --- a/Zotlabs/Module/Sharedwithme.php +++ b/Zotlabs/Module/Sharedwithme.php @@ -19,13 +19,13 @@ class Sharedwithme extends Controller { notice( t('Permission denied.') . EOL); return; } - + $channel = \App::get_channel(); - + $is_owner = (local_channel() && (local_channel() == $channel['channel_id'])); $item_normal = item_normal(); - + //drop single file - localuser if((argc() > 2) && (argv(2) === 'drop')) { @@ -36,7 +36,7 @@ class Sharedwithme extends Controller { goaway(z_root() . '/sharedwithme'); } - + //drop all files - localuser if((argc() > 1) && (argv(1) === 'dropall')) { @@ -62,33 +62,34 @@ class Sharedwithme extends Controller { dbesc($channel['channel_hash']) ); + $r = fetch_post_tags($r, true); + $items = []; $ids = []; if($r) { - + foreach($r as $rr) { - $object = json_decode($rr['obj'],true); - $meta = self::get_meta($object); + $meta = get_iconfig($rr, 'attach', 'meta'); $item = []; $item['id'] = $rr['id']; $item['objfiletype'] = $meta['type']; $item['objfiletypeclass'] = getIconFromType($meta['type']); $item['objurl'] = $meta['path'] . '?f=&zid=' . $channel['xchan_addr']; - $item['objfilename'] = $object['name']; + $item['objfilename'] = $meta['name']; $item['objfilesize'] = userReadableSize($meta['size']); $item['objedited'] = $meta['edited']; $item['unseen'] = $rr['item_unseen']; - + $items[] = $item; - + if($item['unseen']) { $ids[] = $rr['id']; } - + } - + } $ids = implode(',', $ids); @@ -98,9 +99,9 @@ class Sharedwithme extends Controller { intval(local_channel()) ); } - + $o = ''; - + $o .= replace_macros(get_markup_template('sharedwithme.tpl'), array( '$header' => t('Files: shared with me'), '$name' => t('Name'), @@ -111,27 +112,9 @@ class Sharedwithme extends Controller { '$drop' => t('Remove this file'), '$items' => $items )); - - return $o; - - } - - function get_meta($object) { - - $ret = []; - - if(! is_array($object['attachment'])) - return; - foreach($object['attachment'] as $a) { - if($a['name'] === 'zot.attach.meta') { - $ret = $a['value']; - break; - } - } - - return $ret; + return $o; } - + } diff --git a/Zotlabs/Module/Sse.php b/Zotlabs/Module/Sse.php index 3dab3d465..8b46dcafd 100644 --- a/Zotlabs/Module/Sse.php +++ b/Zotlabs/Module/Sse.php @@ -50,7 +50,7 @@ class Sse extends Controller { self::$vnotify = get_pconfig(self::$uid, 'system', 'vnotify'); } - $sleep_seconds = 3; + $sleep = 1000000; // microseconds self::$sse_enabled = get_config('system', 'sse_enabled', 0); @@ -63,17 +63,24 @@ class Sse extends Controller { header("Connection: keep-alive"); header("X-Accel-Buffering: no"); - while(true) { + $i = 0; - if(! self::$sse_id) { + while(true) { - // Update chat presence indication + // reset counter for updating chatpresence about every minute + if (($i * $sleep)/60 > 1000000) { + $i = 0; + } + if(!self::$sse_id && $i === 0) { + // Update chat presence indication about once per minute $r = q("select cp_id, cp_room from chatpresence where cp_xchan = '%s' and cp_client = '%s' and cp_room = 0 limit 1", dbesc(self::$ob_hash), dbesc($_SERVER['REMOTE_ADDR']) ); + $basic_presence = false; + if($r) { $basic_presence = true; q("update chatpresence set cp_last = '%s' where cp_id = %d", @@ -81,7 +88,8 @@ class Sse extends Controller { intval($r[0]['cp_id']) ); } - if(! $basic_presence) { + + if(!$basic_presence) { q("insert into chatpresence ( cp_xchan, cp_last, cp_status, cp_client) values( '%s', '%s', '%s', '%s' ) ", dbesc(self::$ob_hash), @@ -94,18 +102,23 @@ class Sse extends Controller { XConfig::Load(self::$ob_hash); - $result = XConfig::Get(self::$ob_hash, 'sse', 'notifications', []); + $result = []; $lock = XConfig::Get(self::$ob_hash, 'sse', 'lock'); + if (!$lock) { + $result = XConfig::Get(self::$ob_hash, 'sse', 'notifications', []); + } + + // We do not have the local_channel in the addon. // Reset pubs here if the app is not installed. if (self::$uid && (!(self::$vnotify & VNOTIFY_PUBS) || !Apps::system_app_installed(self::$uid, 'Public Stream'))) { - $result['pubs']['count'] = 0; - $result['pubs']['notifications'] = []; - $result['pubs']['offset'] = -1; + if (isset($result['pubs'])) { + unset($result['pubs']); + } } - if($result && !$lock) { + if($result) { echo "event: notifications\n"; echo 'data: ' . json_encode($result); echo "\n\n"; @@ -121,6 +134,7 @@ class Sse extends Controller { if(ob_get_length() > 0) ob_end_flush(); + flush(); if(connection_status() != CONNECTION_NORMAL || connection_aborted()) { @@ -129,7 +143,9 @@ class Sse extends Controller { break; } - sleep($sleep_seconds); + $i++; + + usleep($sleep); } diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index 3a4e4e09e..052870cc9 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -173,6 +173,9 @@ class Sse_bs extends Controller { $item_normal = item_normal(); + // FEP-5624 filter approvals for comments + $approvals = " AND verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject') "; + if ($notifications) { $items = q("SELECT * FROM item WHERE uid = %d @@ -181,6 +184,7 @@ class Sse_bs extends Controller { AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image') AND author_xchan != '%s' $item_normal + $approvals $sql_extra $sql_extra2 ORDER BY created DESC LIMIT $limit OFFSET $offset", @@ -205,18 +209,19 @@ class Sse_bs extends Controller { } - $r = q("SELECT count(id) as total FROM item + $r = q("SELECT id FROM item WHERE uid = %d and item_unseen = 1 AND item_wall = 0 AND item_private IN (0, 1) AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image') AND author_xchan != '%s' $item_normal - $sql_extra", + $approvals + $sql_extra LIMIT 100", intval(self::$uid), dbesc(self::$ob_hash) ); if($r) - $result['network']['count'] = intval($r[0]['total']); + $result['network']['count'] = count($r); return $result; } @@ -253,6 +258,9 @@ class Sse_bs extends Controller { $item_normal = item_normal(); + // FEP-5624 filter approvals for comments + $approvals = " AND verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject') "; + if ($notifications) { $items = q("SELECT * FROM item WHERE uid = %d @@ -261,6 +269,7 @@ class Sse_bs extends Controller { AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image') AND author_xchan != '%s' $item_normal + $approvals $sql_extra $sql_extra2 ORDER BY created DESC LIMIT $limit OFFSET $offset", @@ -285,17 +294,18 @@ class Sse_bs extends Controller { } - $r = q("SELECT count(id) as total FROM item + $r = q("SELECT id FROM item WHERE uid = %d and item_unseen = 1 AND item_private = 2 $item_normal + $approvals $sql_extra - AND author_xchan != '%s'", + AND author_xchan != '%s' LIMIT 100", intval(self::$uid), dbesc(self::$ob_hash) ); if($r) - $result['dm']['count'] = intval($r[0]['total']); + $result['dm']['count'] = count($r); return $result; } @@ -333,6 +343,9 @@ class Sse_bs extends Controller { $item_normal = item_normal(); + // FEP-5624 filter approvals for comments + $approvals = " AND verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject') "; + if ($notifications) { $items = q("SELECT * FROM item WHERE uid = %d @@ -341,6 +354,7 @@ class Sse_bs extends Controller { AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image') AND author_xchan != '%s' $item_normal + $approvals $sql_extra $sql_extra2 ORDER BY created DESC LIMIT $limit OFFSET $offset", @@ -365,17 +379,18 @@ class Sse_bs extends Controller { } - $r = q("SELECT count(id) as total FROM item + $r = q("SELECT id FROM item WHERE uid = %d and item_unseen = 1 AND item_wall = 1 AND item_private IN (0, 1) $item_normal + $approvals $sql_extra - AND author_xchan != '%s'", + AND author_xchan != '%s' LIMIT 100", intval(self::$uid), dbesc(self::$ob_hash) ); if($r) - $result['home']['count'] = intval($r[0]['total']); + $result['home']['count'] = count($r); return $result; } @@ -421,21 +436,30 @@ class Sse_bs extends Controller { if(self::$xchans) $sql_extra2 = " AND CASE WHEN verb = '" . ACTIVITY_SHARE . "' THEN owner_xchan ELSE author_xchan END IN (" . self::$xchans . ") "; + $uids = " AND uid IN ( " . $sys['channel_id'] . " ) "; + + $site_firehose = get_config('system', 'site_firehose', 0); + if($site_firehose) { + $uids = " AND uid IN ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) AND item_private = 0 AND item_wall = 1 "; + } + $item_normal = item_normal(); + // FEP-5624 filter approvals for comments + $approvals = " AND verb NOT IN ('" . dbesc(ACTIVITY_ATTEND) . "', 'Accept', '" . dbesc(ACTIVITY_ATTENDNO) . "', 'Reject') "; + if ($notifications) { $items = q("SELECT * FROM item - WHERE uid = %d + WHERE true $uids AND created <= '%s' - AND item_unseen = 1 AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image') AND author_xchan != '%s' AND created > '%s' $item_normal + $approvals $sql_extra $sql_extra2 ORDER BY created DESC LIMIT $limit OFFSET $offset", - intval($sys['channel_id']), dbescdate($_SESSION['sse_loadtime']), dbesc(self::$ob_hash), dbescdate($_SESSION['static_loadtime']) @@ -454,23 +478,21 @@ class Sse_bs extends Controller { else { $result['pubs']['offset'] = -1; } - - } - $r = q("SELECT count(id) as total FROM item - WHERE uid = %d AND item_unseen = 1 + $r = q("SELECT id FROM item + WHERE true $uids AND created > '%s' $item_normal + $approvals $sql_extra - AND author_xchan != '%s'", - intval($sys['channel_id']), + AND author_xchan != '%s' LIMIT 100", dbescdate($_SESSION['static_loadtime']), dbesc(self::$ob_hash) ); if($r) - $result['pubs']['count'] = intval($r[0]['total']); + $result['pubs']['count'] = count($r); return $result; } diff --git a/Zotlabs/Module/Vote.php b/Zotlabs/Module/Vote.php index 4f909d33d..870fd760c 100644 --- a/Zotlabs/Module/Vote.php +++ b/Zotlabs/Module/Vote.php @@ -45,9 +45,7 @@ class Vote extends Controller { if ($obj['oneOf']) { foreach($obj['oneOf'] as $selection) { - // logger('selection: ' . $selection); - // logger('response: ' . $response); - if($selection['name'] && $selection['name'] === $response) { + if($selection['name'] && htmlspecialchars_decode($selection['name']) === $response) { $valid = true; } } @@ -56,7 +54,7 @@ class Vote extends Controller { $choices = []; if ($obj['anyOf']) { foreach ($obj['anyOf'] as $selection) { - $choices[] = $selection['name']; + $choices[] = htmlspecialchars_decode($selection['name']); } foreach ($response as $res) { if (! in_array($res,$choices)) { |