From f5315ed6a2bf0ac3fa4e6e5dac8671ec7abafd76 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 14 Oct 2020 14:25:22 +0000 Subject: use logger for logging --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 4fa8bf14c..8a2177de7 100644 --- a/include/zot.php +++ b/include/zot.php @@ -5385,7 +5385,7 @@ function find_best_zot_identity($xchan) { ); if ($r) { $r = Libzot::zot_record_preferred($r); - hz_syslog('find_best_zot_identity: ' . $xchan . ' > ' . $r['hubloc_hash']); + logger('find_best_zot_identity: ' . $xchan . ' > ' . $r['hubloc_hash']); return $r['hubloc_hash']; } } -- cgit v1.2.3 From 3b252d98b89b884be995f6f90e31d7e6612cf522 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 15 Oct 2020 10:51:58 +0000 Subject: add forums to acl selector where appropriate --- include/acl_selectors.php | 47 ++++++++++++++++++++++++++++++++++------------- include/xchan.php | 2 +- 2 files changed, 35 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 35e385058..30219a476 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -79,24 +79,44 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti $custom = false; } - $r = q("SELECT id, profile_guid, profile_name from profile where is_default = 0 and uid = %d order by profile_name", + $r = q("SELECT id, hash, gname FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", intval(local_channel()) ); + if($r) { - foreach($r as $rv) { - $selected = (($single_group && 'vp.' . $rv['profile_guid'] === $allow_gid[0]) ? ' selected = "selected" ' : ''); - $groups .= '' . "\r\n"; + $groups .= ''; + foreach($r as $rr) { + $selected = (($single_group && $rr['hash'] === $allow_gid[0]) ? ' selected = "selected" ' : ''); + $groups .= '' . "\r\n"; } + $groups .= ''; } - $r = q("SELECT id, hash, gname FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", + $r = q("SELECT id, profile_guid, profile_name from profile where is_default = 0 and uid = %d order by profile_name", intval(local_channel()) ); if($r) { - foreach($r as $rr) { - $selected = (($single_group && $rr['hash'] === $allow_gid[0]) ? ' selected = "selected" ' : ''); - $groups .= '' . "\r\n"; + $groups .= ''; + foreach($r as $rv) { + $selected = (($single_group && 'vp.' . $rv['profile_guid'] === $allow_gid[0]) ? ' selected = "selected" ' : ''); + $groups .= '' . "\r\n"; + } + $groups .= ''; + } + + // $dialog_description is only set in places where we set permissions for a post. + // Abuse this fact to decide if forums should be displayed or not. + if($dialog_description) { + $forums = get_forum_channels(local_channel(),1); + + if($forums) { + $groups .= ''; + foreach($forums as $f) { + $selected = (($single_group && $f['hash'] === $allow_cid[0]) ? ' selected = "selected" ' : ''); + $groups .= '' . "\r\n"; + } + $groups .= ''; } } @@ -104,17 +124,18 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti $o = replace_macros($tpl, array( '$showall' => $showall_caption, '$onlyme' => t('Only me'), - '$groups' => $groups, + '$groups' => $groups, '$public_selected' => (($has_acl) ? false : true), '$justme_selected' => $just_me, '$custom_selected' => $custom, '$showallOrigin' => $showall_origin, '$showallIcon' => $showall_icon, - '$select_label' => t('Who can see this?'), + '$select_label' => t('Share with'), '$custom' => t('Custom selection'), - '$showlimitedDesc' => t('Select "Show" to allow viewing. "Don\'t show" lets you override and limit the scope of "Show".'), - '$show' => t('Show'), - '$hide' => t("Don't show"), + '$custom_label' => t('Advanced'), + '$showlimitedDesc' => t('Select "Allow" to allow viewing. "Don\'t allow" lets you override and limit the scope of "Allow".'), + '$show' => t('Allow'), + '$hide' => t("Don't allow"), '$search' => t('Search'), '$allowcid' => json_encode($allow_cid), '$allowgid' => json_encode($allow_gid), diff --git a/include/xchan.php b/include/xchan.php index d69d707aa..8032dae2f 100644 --- a/include/xchan.php +++ b/include/xchan.php @@ -264,4 +264,4 @@ function xchan_change_key($oldx,$newx,$data) { foreach($acls as $k => $v) { xchan_keychange_acl($k,$v,$oldx,$newx); } -} \ No newline at end of file +} -- cgit v1.2.3 From 61f554e0d7820b19f7ecb7b6d216f3012dc23acf Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 15 Oct 2020 10:54:59 +0000 Subject: remove new lines and tabs from xchan_name --- include/text.php | 9 +++++++++ include/xchan.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 8bad8337f..af1473713 100644 --- a/include/text.php +++ b/include/text.php @@ -3816,3 +3816,12 @@ function unserialise($x) { return ((is_array($y)) ? $y : $x); } +/** + * @brief Remove new lines and tabs from strings. + * + * @return string + */ +function sanitize_text_field($str) { + return preg_replace('/\s+/S', ' ', $str); +} + diff --git a/include/xchan.php b/include/xchan.php index 8032dae2f..5de828e7f 100644 --- a/include/xchan.php +++ b/include/xchan.php @@ -25,7 +25,7 @@ function xchan_store_lowlevel($arr) { 'xchan_connurl' => ((array_key_exists('xchan_connurl',$arr)) ? $arr['xchan_connurl'] : ''), 'xchan_follow' => ((array_key_exists('xchan_follow',$arr)) ? $arr['xchan_follow'] : ''), 'xchan_connpage' => ((array_key_exists('xchan_connpage',$arr)) ? $arr['xchan_connpage'] : ''), - 'xchan_name' => ((array_key_exists('xchan_name',$arr)) ? $arr['xchan_name'] : ''), + 'xchan_name' => ((array_key_exists('xchan_name',$arr)) ? sanitize_text_field($arr['xchan_name']) : ''), 'xchan_network' => ((array_key_exists('xchan_network',$arr)) ? $arr['xchan_network'] : ''), 'xchan_instance_url' => ((array_key_exists('xchan_instance_url',$arr)) ? $arr['xchan_instance_url'] : ''), 'xchan_flags' => ((array_key_exists('xchan_flags',$arr)) ? intval($arr['xchan_flags']) : 0), -- cgit v1.2.3 From b6ca9b6020e2eae0b5389148ce45bc2f7a81f999 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 16 Oct 2020 10:32:07 +0000 Subject: make acl selector work correctly if we provide a cid in mod network --- include/text.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index af1473713..0a54ddd2f 100644 --- a/include/text.php +++ b/include/text.php @@ -3661,11 +3661,15 @@ function get_forum_channels($uid) { if(! $uid) return; - $xf = false; + if(App::$data['forum_channels']) + return App::$data['forum_channels']; + + $xf = ''; $x1 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'send_stream' and v = '0'", intval($uid) ); + if($x1) { $xc = ids_to_querystr($x1,'xchan',true); @@ -3702,6 +3706,8 @@ function get_forum_channels($uid) { } } + App::$data['forum_channels'] = $r; + return $r; } -- cgit v1.2.3 From f0acb9f01e0e2e130121dff435dea4a29f460d8e Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 16 Oct 2020 11:43:21 +0000 Subject: get_forum_channels(): fix an issue where we would not look for private forums in case we did not have any channels where tag_deliver is set --- include/text.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 0a54ddd2f..ec397910d 100644 --- a/include/text.php +++ b/include/text.php @@ -3677,22 +3677,21 @@ function get_forum_channels($uid) { intval($uid) ); - if($x2) { - $xf = ids_to_querystr($x2,'xchan',true); + $xf = ids_to_querystr($x2,'xchan',true); + $sql_extra = (($xf) ? ' and not xchan in (' . $xf . ')' : ''); - // private forums - $x3 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'post_wall' and v = '1' and xchan in (" . $xc . ") and not xchan in (" . $xf . ") ", - intval(local_channel()) - ); - if($x3) { - $xf = ids_to_querystr(array_merge($x2,$x3),'xchan',true); - } + // private forums + $x3 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'post_wall' and v = '1' and xchan in (" . $xc . ") $sql_extra ", + intval(local_channel()) + ); + if($x3) { + $xf = ids_to_querystr(array_merge($x2,$x3),'xchan',true); } } - $sql_extra = (($xf) ? " and ( xchan_hash in (" . $xf . ") or xchan_pubforum = 1 ) " : " and xchan_pubforum = 1 "); + $sql_extra_1 = (($xf) ? " and ( xchan_hash in (" . $xf . ") or xchan_pubforum = 1 ) " : " and xchan_pubforum = 1 "); - $r = q("select abook_id, xchan_hash, xchan_name, xchan_url, xchan_addr, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash where xchan_deleted = 0 and abook_channel = %d and abook_pending = 0 and abook_ignored = 0 and abook_blocked = 0 and abook_archived = 0 $sql_extra order by xchan_name", + $r = q("select abook_id, xchan_hash, xchan_name, xchan_url, xchan_addr, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash where xchan_deleted = 0 and abook_channel = %d and abook_pending = 0 and abook_ignored = 0 and abook_blocked = 0 and abook_archived = 0 $sql_extra_1 order by xchan_name", intval($uid) ); -- cgit v1.2.3 From 5dc2f43d1d38d190cadbd8eb53227570277e69b1 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 16 Oct 2020 11:54:14 +0000 Subject: mark private forums in acl selector --- include/acl_selectors.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 30219a476..a3476439a 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -109,12 +109,12 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti // Abuse this fact to decide if forums should be displayed or not. if($dialog_description) { $forums = get_forum_channels(local_channel(),1); - if($forums) { $groups .= ''; foreach($forums as $f) { + $private = (($f['private_forum']) ? ' (' . t('Private Forum') . ')' : ''); $selected = (($single_group && $f['hash'] === $allow_cid[0]) ? ' selected = "selected" ' : ''); - $groups .= '' . "\r\n"; + $groups .= '' . "\r\n"; } $groups .= ''; } -- cgit v1.2.3 From 5e0f5460f2ee92aecc53fd900e55d54fa5326fc5 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 19 Oct 2020 07:25:30 +0000 Subject: provide info about dead sites in delivery report and set site_dead when marking a hubloc down. --- include/hubloc.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/hubloc.php b/include/hubloc.php index 059a4dadc..6b896c627 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -247,6 +247,7 @@ function hubloc_change_primary($hubloc) { * * We use the post url to distinguish between http and https hublocs. * The https might be alive, and the http dead. + * Also set site_dead for the corresponding entry in the site table. * * @param string $posturl Hubloc callback url which to disable */ @@ -255,6 +256,13 @@ function hubloc_mark_as_down($posturl) { intval(HUBLOC_OFFLINE), dbesc($posturl) ); + + // extract the baseurl and set site.site_dead to match + $m = parse_url($posturl); + $h = $m['scheme'] . '://' . $m['host']; + $r = q("update site set site_dead = 1 where site_url = '%s'", + dbesc($h) + ); } -- cgit v1.2.3 From 75a73be60c97597f93a67a4ecd412daed06cd744 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 22 Oct 2020 18:54:21 +0000 Subject: lazy/eager loading and minor css fixes --- include/bbcode.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index e5b2a068a..d79429719 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -218,7 +218,7 @@ function bb_replace_images($body, $images) { // We're depending on the property of 'foreach' (specified on the PHP website) that // it loops over the array starting from the first element and going sequentially // to the last element - $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '' . t('Image/photo') . '', $newbody); + $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '' . t('Image/photo') . '', $newbody); $cnt++; } // logger('replace_images: ' . $newbody); @@ -513,7 +513,7 @@ function bb_ShareAttributes($match) { $headline = '
'; if ($avatar != "") - $headline .= '' . $author . ''; + $headline .= '' . $author . ''; if(strpos($link,'/cards/')) $type = t('card'); @@ -881,7 +881,7 @@ function bb_imgoptions($match) { // now assemble the resulting img tag from these components - $output = '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); } // [img=pathtoimage]image description[/img] if (strpos($Text,'[/img]') !== false) { - $Text = preg_replace("/\[img=http(.*?)\](.*?)\[\/img\]/ism", '$2', $Text); + $Text = preg_replace("/\[img=http(.*?)\](.*?)\[\/img\]/ism", '$2', $Text); } // [zmg]pathtoimage[/zmg] if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); } // [zmg=pathtoimage]image description[/zmg] if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg=http(.*?)\](.*?)\[\/zmg\]/ism", '$2', $Text); + $Text = preg_replace("/\[zmg=http(.*?)\](.*?)\[\/zmg\]/ism", '$2', $Text); } $Text = preg_replace_callback("/\[([zi])mg([ \=])(.*?)\](.*?)\[\/[zi]mg\]/ism",'bb_imgoptions',$Text); -- cgit v1.2.3 From 78f655f877d2d2b7afd6d606edabc5b0df638738 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 22 Oct 2020 19:11:03 +0000 Subject: more lazy, less eager --- include/bbcode.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index d79429719..c5d58e80d 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -218,7 +218,7 @@ function bb_replace_images($body, $images) { // We're depending on the property of 'foreach' (specified on the PHP website) that // it loops over the array starting from the first element and going sequentially // to the last element - $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '' . t('Image/photo') . '', $newbody); + $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '' . t('Image/photo') . '', $newbody); $cnt++; } // logger('replace_images: ' . $newbody); @@ -881,7 +881,7 @@ function bb_imgoptions($match) { // now assemble the resulting img tag from these components - $output = '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); } // [img=pathtoimage]image description[/img] if (strpos($Text,'[/img]') !== false) { - $Text = preg_replace("/\[img=http(.*?)\](.*?)\[\/img\]/ism", '$2', $Text); + $Text = preg_replace("/\[img=http(.*?)\](.*?)\[\/img\]/ism", '$2', $Text); } // [zmg]pathtoimage[/zmg] if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); } // [zmg=pathtoimage]image description[/zmg] if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg=http(.*?)\](.*?)\[\/zmg\]/ism", '$2', $Text); + $Text = preg_replace("/\[zmg=http(.*?)\](.*?)\[\/zmg\]/ism", '$2', $Text); } $Text = preg_replace_callback("/\[([zi])mg([ \=])(.*?)\](.*?)\[\/[zi]mg\]/ism",'bb_imgoptions',$Text); -- cgit v1.2.3 From 2772c335635aa5248a4509e0976432707b3e716e Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 22 Oct 2020 19:22:52 +0000 Subject: load eager in items - lazy breaks collapsing of long items with images --- include/bbcode.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index c5d58e80d..d79429719 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -218,7 +218,7 @@ function bb_replace_images($body, $images) { // We're depending on the property of 'foreach' (specified on the PHP website) that // it loops over the array starting from the first element and going sequentially // to the last element - $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '' . t('Image/photo') . '', $newbody); + $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '' . t('Image/photo') . '', $newbody); $cnt++; } // logger('replace_images: ' . $newbody); @@ -881,7 +881,7 @@ function bb_imgoptions($match) { // now assemble the resulting img tag from these components - $output = '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); } // [img=pathtoimage]image description[/img] if (strpos($Text,'[/img]') !== false) { - $Text = preg_replace("/\[img=http(.*?)\](.*?)\[\/img\]/ism", '$2', $Text); + $Text = preg_replace("/\[img=http(.*?)\](.*?)\[\/img\]/ism", '$2', $Text); } // [zmg]pathtoimage[/zmg] if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); } // [zmg=pathtoimage]image description[/zmg] if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg=http(.*?)\](.*?)\[\/zmg\]/ism", '$2', $Text); + $Text = preg_replace("/\[zmg=http(.*?)\](.*?)\[\/zmg\]/ism", '$2', $Text); } $Text = preg_replace_callback("/\[([zi])mg([ \=])(.*?)\](.*?)\[\/[zi]mg\]/ism",'bb_imgoptions',$Text); -- cgit v1.2.3