diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/acl_selectors.php | 2 | ||||
-rw-r--r-- | include/attach.php | 40 | ||||
-rw-r--r-- | include/conversation.php | 64 | ||||
-rw-r--r-- | include/event.php | 2 | ||||
-rw-r--r-- | include/html2bbcode.php | 7 | ||||
-rw-r--r-- | include/items.php | 62 | ||||
-rw-r--r-- | include/js_strings.php | 8 | ||||
-rw-r--r-- | include/markdown.php | 16 | ||||
-rw-r--r-- | include/nav.php | 25 | ||||
-rw-r--r-- | include/security.php | 107 | ||||
-rw-r--r-- | include/text.php | 87 |
11 files changed, 200 insertions, 220 deletions
diff --git a/include/acl_selectors.php b/include/acl_selectors.php index f158a439b..f0e0140dc 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -26,7 +26,7 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti $allow_cid = $allow_gid = $deny_cid = $deny_gid = false; $showall_origin = ''; - $showall_icon = 'fa-globe'; + $showall_icon = 'bi-globe'; $role = get_pconfig(local_channel(), 'system', 'permissions_role'); if(! $emptyACL_description) { diff --git a/include/attach.php b/include/attach.php index 449721793..654c9990d 100644 --- a/include/attach.php +++ b/include/attach.php @@ -2599,33 +2599,31 @@ function attach_move($channel_id, $resource_id, $new_folder_hash, $newname = '', intval($r[0]['id']) ); - if($r[0]['is_photo']) { - q("update photo set album = '%s', filename = '%s', os_path = '%s', display_path = '%s' - where resource_id = '%s' and uid = %d", - dbesc($newalbumname), - dbesc($filename), - dbesc($x['os_path']), - dbesc($x['path']), - dbesc($resource_id), - intval($channel_id) - ); - - q("update photo set content = CASE imgscale WHEN 0 THEN %s ELSE CONCAT(%s, '-', imgscale) END where resource_id = '%s' and uid = %d and os_storage = 1", - dbescbin($newstorepath), - dbescbin($newstorepath), - dbesc($resource_id), - intval($channel_id) - ); - - // now rename the thumbnails in os_storage - the original should have been copied before already - $ps = q("SELECT content, imgscale FROM photo WHERE uid = %d AND resource_id = '%s' and imgscale > 0 and os_storage = 1", + if ($r[0]['is_photo']) { + // update the photo DB entries and copy the thumbnails + $ps = q("SELECT imgscale FROM photo WHERE uid = %d AND resource_id = '%s' and os_storage = 1", intval($channel_id), dbesc($resource_id) ); if ($recurse) { foreach($ps as $p) { - rename($oldstorepath . '-' . $p['imgscale'], $p['content']); + q("update photo set album = '%s', filename = '%s', os_path = '%s', display_path = '%s', content = '%s' + where resource_id = '%s' and imgscale = %d and uid = %d", + dbesc($newalbumname), + dbesc($filename), + dbesc($x['os_path']), + dbesc($x['path']), + dbescbin($newstorepath . ((intval($p['imgscale']) > 0) ? '-' . $p['imgscale'] : '')), + dbesc($resource_id), + intval($p['imgscale']), + intval($channel_id) + ); + + // the original should have been copied already + if (intval($p['imgscale']) > 0) { + rename($oldstorepath . '-' . $p['imgscale'], $newstorepath . '-' . $p['imgscale']); + } } } } diff --git a/include/conversation.php b/include/conversation.php index c631d53a2..ee599c28d 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -3,6 +3,7 @@ use Zotlabs\Lib\Activity; use Zotlabs\Lib\Apps; use Zotlabs\Lib\Config; +use Zotlabs\Lib\PConfig; require_once('include/items.php'); @@ -438,17 +439,22 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa $uploading = false; - if(local_channel()) { - $cur_channel = App::get_channel(); - if($cur_channel['channel_allow_cid'] === '' && $cur_channel['channel_allow_gid'] === '' - && $cur_channel['channel_deny_cid'] === '' && $cur_channel['channel_deny_gid'] === '' + $channel = App::get_channel(); + $observer = App::get_observer(); + + if (local_channel()) { + // Allow uploading if there is no default privacy and the view_storage permission is set to PERMS_PUBLIC + if ($channel['channel_allow_cid'] === '' && $channel['channel_allow_gid'] === '' + && $channel['channel_deny_cid'] === '' && $channel['channel_deny_gid'] === '' && intval(\Zotlabs\Access\PermissionLimits::Get(local_channel(),'view_storage')) === PERMS_PUBLIC) { $uploading = true; } - } - $channel = App::get_channel(); - $observer = App::get_observer(); + // Allow uploading if OCAP tokens are enabled + if (PConfig::Get(local_channel(), 'system', 'ocap_enabled')) { + $uploading = true; + } + } if (!$update) { $_SESSION['return_url'] = App::$query_string; @@ -817,7 +823,7 @@ function thread_action_menu($item,$mode = '') { $menu[] = [ 'menu' => 'unfollow_thread', 'title' => t('Unfollow Thread'), - 'icon' => 'minus', + 'icon' => 'dash', 'action' => 'dounsubthread(' . $item['id'] . '); return false;', 'href' => '#' ]; @@ -999,7 +1005,7 @@ function builtin_activity_puller($item, &$conv_responses) { $name = (($item['author']['xchan_name']) ? $item['author']['xchan_name'] : t('Unknown')); - $moderate = ((intval($item['item_blocked']) === ITEM_MODERATED) ? '<a href="moderate/' . $item['id'] . '/approve" onclick="moderate_approve(' . $item['id'] . '); return false;" class="text-success pe-2" title="' . t('Approve this item') . '"><i class="fa fa-check" ></i></a><a href="moderate/' . $item['id'] . '/drop" onclick="moderate_drop(' . $item['id'] . '); return false;" class="text-danger pe-2" title="' . t('Delete this item') . '"><i class="fa fa-trash-o" ></i></a>' : ''); + $moderate = ((intval($item['item_blocked']) === ITEM_MODERATED) ? '<a href="moderate/' . $item['id'] . '/approve" onclick="moderate_approve(' . $item['id'] . '); return false;" class="text-success pe-2" title="' . t('Approve this item') . '"><i class="bi bi-check-lg" ></i></a><a href="moderate/' . $item['id'] . '/drop" onclick="moderate_drop(' . $item['id'] . '); return false;" class="text-danger pe-2" title="' . t('Delete this item') . '"><i class="bi bi-trash" ></i></a>' : ''); $url = (($item['author_xchan'] && $item['author']['xchan_photo_s']) ? '<div class="dropdown-item">' . $moderate . '<a href="' . chanlink_hash($item['author_xchan']) . '" class="text-reset">' . '<img class="menu-img-1" src="' . zid($item['author']['xchan_photo_s']) . '" alt="' . urlencode($name) . '" /> ' . $name . '</a></div>' @@ -1467,14 +1473,18 @@ function render_location_default($item) { $location = $item['location']; $coord = $item['coord']; - if($coord) { + if ($coord) { if($location) - $location .= ' <span class="smalltext">(' . $coord . ')</span>'; + $location .= ' (' . $coord . ')'; else - $location = '<span class="smalltext">' . $coord . '</span>'; + $location = $coord; } - return $location; + if (!$location) { + return ''; + } + + return '<i class="bi bi-geo-alt" title="' . $location . '"></i>'; } @@ -1525,6 +1535,12 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) { $ret = array(); foreach($response_verbs as $v) { + if ($v === 'answer') { + // we require the structure to collect the response hashes + // but we do not use them for display - do not collect them. + continue; + } + $ret[$v] = []; $ret[$v]['count'] = $conv_responses[$v][$item['mid']] ?? 0; $ret[$v]['list'] = ((isset($conv_responses[$v][$item['mid']])) ? $conv_responses[$v][$item['mid'] . '-l'] : ''); @@ -1533,14 +1549,6 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) { $ret[$v]['modal'] = (($ret[$v]['count'] > MAX_LIKERS) ? true : false); } - $count = 0; - foreach ($ret as $key) { - if ($key['count'] == true) - $count++; - } - - $ret['count'] = $count; - //logger('ret: ' . print_r($ret,true)); return $ret; @@ -1549,25 +1557,25 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) { function get_response_button_text($v,$count) { switch($v) { case 'like': - return ['label' => tt('Like','Likes',$count,'noun'), 'icon' => 'thumbs-o-up', 'class' => 'like']; + return ['label' => tt('Like','Likes',$count,'noun'), 'icon' => 'hand-thumbs-up', 'class' => 'like', 'onclick' => 'dolike']; break; case 'announce': - return ['label' => tt('Repeat','Repeats',$count,'noun'), 'icon' => 'retweet', 'class' => 'announce']; + return ['label' => tt('Repeat','Repeats',$count,'noun'), 'icon' => 'repeat', 'class' => 'announce', 'onclick' => 'jotShare']; break; case 'dislike': - return ['label' => tt('Dislike','Dislikes',$count,'noun'), 'icon' => 'thumbs-o-down', 'class' => 'dislike']; + return ['label' => tt('Dislike','Dislikes',$count,'noun'), 'icon' => 'hand-thumbs-down', 'class' => 'dislike', 'onclick' => 'dolike']; break; case 'attendyes': - return ['label' => tt('Attending','Attending',$count,'noun'), 'icon' => 'calendar-check-o', 'class' => 'attendyes']; + return ['label' => tt('Attending','Attending',$count,'noun'), 'icon' => 'calendar-check', 'class' => 'attendyes', 'onclick' => 'dolike']; break; case 'attendno': - return ['label' => tt('Not Attending','Not Attending',$count,'noun'), 'icon' => 'calendar-times-o', 'class' => 'attendno']; + return ['label' => tt('Not Attending','Not Attending',$count,'noun'), 'icon' => 'calendar-x', 'class' => 'attendno', 'onclick' => 'dolike']; break; case 'attendmaybe': - return ['label' => tt('Undecided','Undecided',$count,'noun'), 'icon' => 'calendar-o', 'class' => 'attendmaybe']; + return ['label' => tt('Undecided','Undecided',$count,'noun'), 'icon' => 'calendar', 'class' => 'attendmaybe', 'onclick' => 'dolike']; break; default: - return ''; + return []; break; } } diff --git a/include/event.php b/include/event.php index f8511cbe2..af27c45b0 100644 --- a/include/event.php +++ b/include/event.php @@ -38,7 +38,7 @@ function format_event_html($ev) { $o = '<div class="vevent">' . "\r\n"; - $o .= '<div class="event-title"><h3><i class="fa fa-calendar"></i> ' . zidify_links(smilies(bbcode($ev['summary']))) . '</h3></div>' . "\r\n"; + $o .= '<div class="event-title"><h3><i class="bi bi-calendar-date"></i> ' . zidify_links(smilies(bbcode($ev['summary']))) . '</h3></div>' . "\r\n"; $o .= '<div class="event-start"><span class="event-label">' . t('Starts:') . '</span> <span class="dtstart" title="' . datetime_convert('UTC', 'UTC', $ev['dtstart'], ((isset($ev['adjust']) && $ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )) diff --git a/include/html2bbcode.php b/include/html2bbcode.php index 8c35cdf03..277b0e640 100644 --- a/include/html2bbcode.php +++ b/include/html2bbcode.php @@ -217,14 +217,11 @@ function html2bbcode($message) node2bbcode($doc, 'hr', array(), "[hr]", ""); -// node2bbcode($doc, 'table', array(), "", ""); -// node2bbcode($doc, 'tr', array(), "\n", ""); -// node2bbcode($doc, 'td', array(), "\t", ""); - - node2bbcode($doc, 'table', array(), "[table]", "[/table]"); node2bbcode($doc, 'th', array(), "[th]", "[/th]"); node2bbcode($doc, 'tr', array(), "[tr]", "[/tr]"); node2bbcode($doc, 'td', array(), "[td]", "[/td]"); + node2bbcode($doc, 'table', array(), "[table]", "[/table]"); + node2bbcode($doc, 'h1', array(), "[h1]", "[/h1]"); node2bbcode($doc, 'h2', array(), "[h2]", "[/h2]"); diff --git a/include/items.php b/include/items.php index dc9e9a7d9..423d626ad 100644 --- a/include/items.php +++ b/include/items.php @@ -2951,35 +2951,32 @@ function tgroup_check($uid, $item) { // post to group via DM if ($is_group) { - if (intval($item['item_private']) === 2 && $item['mid'] === $item['parent_mid']) { + if (intval($item['item_private']) === 2 && $item['mid'] === $item['parent_mid'] && perm_is_allowed($uid, $item['owner_xchan'], 'post_wall')) { return true; } } - // see if we already have this item. Maybe it is being updated. $r = q("select id from item where mid = '%s' and uid = %d limit 1", dbesc($item['mid']), intval($uid) ); - if($r) + + if ($r) { return true; + } - if(! perm_is_allowed($uid,$item['author_xchan'],'tag_deliver')) - return false; + $u = channelx_by_n($uid); - $u = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d limit 1", - intval($uid) - ); - - if(! $u) + if (!$u) { return false; + } $max_forums = Config::Get('system','max_tagged_forums',2); $matched_forums = 0; - $link = normalise_link($u[0]['xchan_url']); + $link = normalise_link($u['xchan_url']); $terms = []; @@ -2996,7 +2993,7 @@ function tgroup_check($uid, $item) { } $mention = true; - logger('tgroup_check: mention found for ' . $u[0]['channel_name']); + logger('tgroup_check: mention found for ' . $u['channel_name']); // At this point we've determined that the person receiving this post was mentioned in it. // Now let's check if this mention was inside a reshare so we don't spam a forum @@ -3199,7 +3196,9 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false } else { - $arr['uuid'] = item_message_id(); + // To prevent duplicates from possible clones of the forum/group, + // will create a v5 UUID of the source item mid. + $arr['uuid'] = uuid_from_url($item['mid']); $arr['mid'] = z_root() . '/item/' . $arr['uuid']; $arr['parent_mid'] = $arr['mid']; } @@ -5008,7 +5007,7 @@ function fix_attached_permissions($uid, $body, $str_contact_allow, $str_group_al $attach = array_shift($attach_q); - $new_public = !(($str_contact_allow || $str_group_allow || $str_contact_deny || $str_group_deny)); + //$new_public = !(($str_contact_allow || $str_group_allow || $str_contact_deny || $str_group_deny)); $existing_public = !(($attach['allow_cid'] || $attach['allow_gid'] || $attach['deny_cid'] || $attach['deny_gid'])); if ($existing_public) { @@ -5023,10 +5022,11 @@ function fix_attached_permissions($uid, $body, $str_contact_allow, $str_group_al continue; } - $item_private = 0; - - if ($new_public === false) { - $item_private = (($str_group_allow || ($str_contact_allow && substr_count($str_contact_allow,'<') > 2)) ? 1 : 2); + if ($token) { + $str_contact_allow = $attach['allow_cid']; + $str_group_allow = $attach['allow_gid']; + $str_contact_deny = $attach['deny_cid']; + $str_group_deny = $attach['deny_gid']; // preserve any existing tokens that may have been set for this file $token_matches = null; @@ -5054,7 +5054,7 @@ function fix_attached_permissions($uid, $body, $str_contact_allow, $str_group_al ); if ($attach['is_photo']) { - $r = q("UPDATE photo SET allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s' + q("UPDATE photo SET allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s' WHERE resource_id = '%s' AND uid = %d ", dbesc($str_contact_allow), dbesc($str_group_allow), @@ -5064,7 +5064,16 @@ function fix_attached_permissions($uid, $body, $str_contact_allow, $str_group_al intval($uid) ); - $r = q("UPDATE item SET allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', item_private = %d + $item_private = 0; + + if ($str_group_allow || $str_contact_deny || $str_group_deny) { + $item_private = 1; + } + elseif ($str_contact_allow) { + $item_private = 2; + } + + q("UPDATE item SET allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', item_private = %d WHERE resource_id = '%s' AND 'resource_type' = 'photo' AND uid = %d", dbesc($str_contact_allow), dbesc($str_group_allow), @@ -5103,25 +5112,19 @@ function copy_of_pubitem($channel,$mid) { return $item[0]; } - - $r = q("select * from item where parent_mid = (select parent_mid from item where mid = '%s' and uid = %d ) order by id ", + $r = q("select * from item where parent_mid = (select parent_mid from item where mid = '%s' and uid = %d) and uid = %d order by id ", dbesc($mid), + intval($syschan['channel_id']), intval($syschan['channel_id']) ); if($r) { $items = fetch_post_tags($r,true); foreach($items as $rv) { - $d = q("select id from item where mid = '%s' and uid = %d limit 1", - dbesc($rv['mid']), - intval($channel['channel_id']) - ); - if($d) { - continue; - } unset($rv['id']); unset($rv['parent']); + $rv['aid'] = $channel['channel_account_id']; $rv['uid'] = $channel['channel_id']; $rv['item_wall'] = 0; @@ -5134,5 +5137,6 @@ function copy_of_pubitem($channel,$mid) { } } + return $result; } diff --git a/include/js_strings.php b/include/js_strings.php index 090d28ce3..0142bad28 100644 --- a/include/js_strings.php +++ b/include/js_strings.php @@ -5,10 +5,10 @@ function js_strings() { '$delitem' => t('Delete this item?'), '$itemdel' => t('Item deleted'), '$comment' => t('Comment'), - '$showmore' => sprintf( t('%s show all'), '<i class=\'fa fa-chevron-down\'></i>'), - '$showfewer' => sprintf( t('%s show less'), '<i class=\'fa fa-chevron-up\'></i>'), - '$divgrowmore' => sprintf( t('%s expand'), '<i class=\'fa fa-chevron-down\'></i>'), - '$divgrowless' => sprintf( t('%s collapse'),'<i class=\'fa fa-chevron-up\'></i>'), + '$showmore' => t('show all'), + '$showfewer' => t('show less'), + '$divgrowmore' => t('expand'), + '$divgrowless' => t('collapse'), '$pwshort' => t("Password too short"), '$pwnomatch' => t("Passwords do not match"), '$everybody' => t('everybody'), diff --git a/include/markdown.php b/include/markdown.php index b2adcd0d5..90d671fe4 100644 --- a/include/markdown.php +++ b/include/markdown.php @@ -80,22 +80,6 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) { $s = html2bbcode($s); - // $s = bb_code_protect($s); - - // Convert everything that looks like a link to a link - if($use_zrl) { - if (strpos($s,'[/img]') !== false) { - $s = preg_replace_callback("/\[img\](.*?)\[\/img\]/ism", 'use_zrl_cb_img', $s); - $s = preg_replace_callback("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", 'use_zrl_cb_img_x', $s); - } - $s = preg_replace_callback("/([^\]\=\{\/]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)([\,\.\:\;]\s|$)/ismu", 'use_zrl_cb_link',$s); - } - else { - $s = preg_replace("/([^\]\=\{\/]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)([\,\.\:\;]\s|$)/ismu", '$1[url=$2$3]$2$3[/url]$4',$s); - } - - // $s = bb_code_unprotect($s); - // remove duplicate adjacent code tags $s = preg_replace("/(\[code\])+(.*?)(\[\/code\])+/ism","[code]$2[/code]", $s); diff --git a/include/nav.php b/include/nav.php index a68d564a0..f8cd6101f 100644 --- a/include/nav.php +++ b/include/nav.php @@ -449,7 +449,7 @@ function channel_apps($is_owner = false, $nickname = null) { 'sel' => ((argv(0) == 'channel') ? 'active' : ''), 'title' => t('Status Messages and Posts'), 'id' => 'status-tab', - 'icon' => 'home' + 'icon' => 'house' ], ]; @@ -462,7 +462,7 @@ function channel_apps($is_owner = false, $nickname = null) { 'sel' => ((argv(0) == 'profile') ? 'active' : ''), 'title' => t('Profile Details'), 'id' => 'profile-tab', - 'icon' => 'user' + 'icon' => 'person' ]; } if ($p['view_storage']) { @@ -472,7 +472,7 @@ function channel_apps($is_owner = false, $nickname = null) { 'sel' => ((argv(0) == 'photos') ? 'active' : ''), 'title' => t('Photo Albums'), 'id' => 'photo-tab', - 'icon' => 'photo' + 'icon' => 'image' ]; $tabs[] = [ 'label' => t('Files'), @@ -480,7 +480,7 @@ function channel_apps($is_owner = false, $nickname = null) { 'sel' => ((argv(0) == 'cloud' || argv(0) == 'sharedwithme') ? 'active' : ''), 'title' => t('Files and Storage'), 'id' => 'files-tab', - 'icon' => 'folder-open' + 'icon' => 'folder' ]; } @@ -491,7 +491,7 @@ function channel_apps($is_owner = false, $nickname = null) { 'sel' => ((argv(0) == 'cal') ? 'active' : ''), 'title' => t('Calendar'), 'id' => 'event-tab', - 'icon' => 'calendar' + 'icon' => 'calendar-date' ]; } @@ -505,7 +505,7 @@ function channel_apps($is_owner = false, $nickname = null) { 'sel' => ((argv(0) == 'chat') ? 'active' : ''), 'title' => t('Chatrooms'), 'id' => 'chat-tab', - 'icon' => 'comments-o' + 'icon' => 'chat' ]; } } @@ -529,18 +529,7 @@ function channel_apps($is_owner = false, $nickname = null) { 'sel' => ((argv(0) == 'webpages') ? 'active' : ''), 'title' => t('View Webpages'), 'id' => 'webpages-tab', - 'icon' => 'newspaper-o' - ]; - } - - if ($p['view_wiki'] && Apps::system_app_installed($uid, 'Wiki')) { - $tabs[] = [ - 'label' => t('Wikis'), - 'url' => z_root() . '/wiki/' . $nickname, - 'sel' => ((argv(0) == 'wiki') ? 'active' : ''), - 'title' => t('Wiki'), - 'id' => 'wiki-tab', - 'icon' => 'pencil-square-o' + 'icon' => 'layout-text-sidebar' ]; } diff --git a/include/security.php b/include/security.php index 545788bcd..4b072cf92 100644 --- a/include/security.php +++ b/include/security.php @@ -321,6 +321,7 @@ function change_channel($change_channel) { function permissions_sql($owner_id, $remote_observer = null, $table = '', $token = EMPTY_STR) { $local_channel = local_channel(); + $observer = $remote_observer ?? get_observer_hash(); /** * Construct permissions @@ -344,15 +345,22 @@ function permissions_sql($owner_id, $remote_observer = null, $table = '', $token if (($local_channel) && ($local_channel == $owner_id)) { return EMPTY_STR; } - /** - * Authenticated visitor. - */ - else { - $observer = ((!is_null($remote_observer)) ? $remote_observer : get_observer_hash()); + /* + * OCAP token access + */ + + if ($token) { + $sql = " AND ( {$table}allow_cid like '" . protect_sprintf('%<token:' . $token . '>%') . + "' OR ( {$table}allow_cid = '' AND {$table}allow_gid = '' AND {$table}deny_cid = '' AND {$table}deny_gid = '' ) )"; + } - if ($observer) { + /** + * Authenticated visitor. + */ + + elseif ($observer) { $sec = get_security_ids($owner_id, $observer); @@ -400,16 +408,6 @@ function permissions_sql($owner_id, $remote_observer = null, $table = '', $token dbesc($gs) ); } - - /* - * OCAP token access - */ - - elseif ($token) { - $sql = " AND ( {$table}allow_cid like '" . protect_sprintf('%<token:' . $token . '>%') . - "' OR ( {$table}allow_cid = '' AND {$table}allow_gid = '' AND {$table}deny_cid = '' AND {$table}deny_gid = '' ) )"; - } - } return $sql; @@ -497,7 +495,7 @@ function item_permissions_sql($owner_id, $remote_observer = null) { " AND ( author_xchan = '%s' OR owner_xchan = '%s' OR (( NOT (deny_cid $regexop '%s' OR deny_gid $regexop '%s') AND ( allow_cid $regexop '%s' OR allow_gid $regexop '%s' OR ( allow_cid = '' AND allow_gid = '' AND item_private = 0 )) - ))) + )) OR ( item_private = 1 $scope )) ", dbesc($observer), dbesc($observer), @@ -708,56 +706,61 @@ function get_security_ids($channel_id, $ob_hash) { 'allow_gid' => [] ]; - if ($channel_id) { - $ch = q("select channel_hash from channel where channel_id = %d", - intval($channel_id) - ); - if ($ch) { - $ret['channel_id'][] = $ch[0]['channel_hash']; - } - } - - $groups = []; - - $x = q("select * from xchan where xchan_hash = '%s'", + $x = q("select xchan_hash from xchan where xchan_hash = '%s'", dbesc($ob_hash) ); - if ($x) { + if (!$x) { + return $ret; + } - // include xchans for all zot-like networks + $ret['allow_cid'][] = $x[0]['xchan_hash']; - $xchans = q("select xchan_hash from xchan where xchan_hash = '%s' OR ( xchan_guid = '%s' AND xchan_pubkey = '%s' ) ", - dbesc($ob_hash), - dbesc($x[0]['xchan_guid']), - dbesc($x[0]['xchan_pubkey']) - ); + if (!$channel_id) { + return $ret; + } + + $ch = q("select channel_hash from channel where channel_id = %d", + intval($channel_id) + ); + if ($ch) { + $ret['channel_id'][] = $ch[0]['channel_hash']; + } - if ($xchans) { - $ret['allow_cid'] = ids_to_array($xchans, 'xchan_hash'); - $hashes = ids_to_querystr($xchans, 'xchan_hash', true); + $groups = []; - // private profiles are treated as a virtual group + // private profiles are treated as a virtual group - $r = q("SELECT abook_profile from abook where abook_xchan in ( " . protect_sprintf($hashes) . " ) and abook_profile != '' "); - if ($r) { - foreach ($r as $rv) { - $groups[] = 'vp.' . $rv['abook_profile']; - } + $r = q("SELECT abook_profile from abook where abook_channel = %d and abook_xchan = '%s' and abook_profile != ''", + intval($channel_id), + dbesc(protect_sprintf($x[0]['xchan_hash'])) + ); + + if ($r) { + foreach ($r as $rv) { + if (!in_array('vp.' . $rv['abook_profile'], $groups)) { + $groups[] = 'vp.' . $rv['abook_profile']; } + } + } - // physical groups this identity is a member of + // physical groups this identity is a member of - $r = q("SELECT hash FROM pgrp left join pgrp_member on pgrp.id = pgrp_member.gid WHERE xchan in ( " . protect_sprintf($hashes) . " ) "); - if ($r) { - foreach ($r as $rv) { - $groups[] = $rv['hash']; - } + $r = q("SELECT hash FROM pgrp left join pgrp_member on pgrp.id = pgrp_member.gid WHERE pgrp.uid = %d and pgrp_member.xchan = '%s'", + intval($channel_id), + dbesc(protect_sprintf($x[0]['xchan_hash'])) + ); + + if ($r) { + foreach ($r as $rv) { + if (!in_array($rv['hash'], $groups)) { + $groups[] = $rv['hash']; } - $ret['allow_gid'] = $groups; } } + $ret['allow_gid'] = $groups; + return $ret; } diff --git a/include/text.php b/include/text.php index b03e2d1a9..e69ce7d10 100644 --- a/include/text.php +++ b/include/text.php @@ -1652,7 +1652,7 @@ function format_hashtags(&$item) { if($s) $s .= ' '; - $s .= '<span class="badge rounded-pill bg-info"><i class="fa fa-hashtag"></i> <a class="text-white" href="' . zid($t['url']) . '" >' . $term . '</a></span>'; + $s .= '<span class="badge rounded-pill bg-info"><i class="bi bi-hash"></i> <a class="text-white" href="' . zid($t['url']) . '" >' . $term . '</a></span>'; } } @@ -1675,7 +1675,7 @@ function format_mentions(&$item) { continue; if($s) $s .= ' '; - $s .= '<span class="badge rounded-pill bg-success"><i class="fa fa-at"></i> <a class="text-white" href="' . zid($t['url']) . '" >' . $term . '</a></span>'; + $s .= '<span class="badge rounded-pill bg-success"><i class="bi bi-at"></i> <a class="text-white" href="' . zid($t['url']) . '" >' . $term . '</a></span>'; } } @@ -3203,53 +3203,53 @@ function linkify_tags(&$body, $uid, $in_network = true) { function getIconFromType($type) { $iconMap = array( //Folder - 'Collection' => 'fa-folder-o', - 'multipart/mixed' => 'fa-folder-o', //dirs in attach use this mime type + 'Collection' => 'bi-folder', + 'multipart/mixed' => 'bi-folder', //dirs in attach use this mime type //Common file - 'application/octet-stream' => 'fa-file-o', + 'application/octet-stream' => 'bi-file-earmark', //Text - 'text/plain' => 'fa-file-text-o', - 'text/markdown' => 'fa-file-text-o', - 'text/bbcode' => 'fa-file-text-o', - 'text/html' => 'fa-file-text-o', - 'application/msword' => 'fa-file-word-o', - 'application/pdf' => 'fa-file-pdf-o', - 'application/vnd.oasis.opendocument.text' => 'fa-file-word-o', - 'application/epub+zip' => 'fa-book', + 'text/plain' => 'bi-earmark-text', + 'text/markdown' => 'bi-filetype-md', + 'text/bbcode' => 'bi-file-earmark-text', + 'text/html' => 'bi-filetype-html', + 'application/msword' => 'bi-file-earmark-word', + 'application/pdf' => 'bi-file-earmark-pdf', + 'application/vnd.oasis.opendocument.text' => 'bifile--earmark-text', + 'application/epub+zip' => 'bi-file-earmark-text', //Spreadsheet - 'application/vnd.oasis.opendocument.spreadsheet' => 'fa-file-excel-o', - 'application/vnd.ms-excel' => 'fa-file-excel-o', + 'application/vnd.oasis.opendocument.spreadsheet' => 'bi-file-earmark-spreadsheet', + 'application/vnd.ms-excel' => 'bi-file-earmark-spreadsheet', //Image - 'image/jpeg' => 'fa-picture-o', - 'image/png' => 'fa-picture-o', - 'image/gif' => 'fa-picture-o', - 'image/webp' => 'fa-picture-o', - 'image/svg+xml' => 'fa-picture-o', + 'image/jpeg' => 'bi-file-earmark-image', + 'image/png' => 'bi-file-earmark-image', + 'image/gif' => 'bi-file-earmark-image', + 'image/webp' => 'bi-file-earmark-image', + 'image/svg+xml' => 'bi-filetype-svg', //Archive - 'application/zip' => 'fa-file-archive-o', - 'application/x-rar-compressed' => 'fa-file-archive-o', + 'application/zip' => 'bi-file-earmark-zip', + 'application/x-rar-compressed' => 'bi-file-earmark-zip', //Audio - 'audio/mpeg' => 'fa-file-audio-o', - 'audio/wav' => 'fa-file-audio-o', - 'application/ogg' => 'fa-file-audio-o', - 'audio/ogg' => 'fa-file-audio-o', - 'audio/webm' => 'fa-file-audio-o', - 'audio/mp4' => 'fa-file-audio-o', + 'audio/mpeg' => 'bi-file-earmark-music', + 'audio/wav' => 'bi-file-earmark-music', + 'application/ogg' => 'bi-file-earmark-music', + 'audio/ogg' => 'bi-file-earmark-music', + 'audio/webm' => 'bi-file-earmark-music', + 'audio/mp4' => 'bi-file-earmark-music', //Video - 'video/quicktime' => 'fa-file-video-o', - 'video/webm' => 'fa-file-video-o', - 'video/mp4' => 'fa-file-video-o', - 'video/x-matroska' => 'fa-file-video-o' + 'video/quicktime' => 'bi-file-earmark-play', + 'video/webm' => 'bi-file-earmark-play', + 'video/mp4' => 'bi-file-earmark-play', + 'video/x-matroska' => 'bi-file-earmark-play' ); $catMap = [ - 'application' => 'fa-file-code-o', - 'multipart' => 'fa-folder', - 'audio' => 'fa-file-audio-o', - 'video' => 'fa-file-video-o', - 'text' => 'fa-file-text-o', - 'image' => 'fa=file-picture-o', - 'message' => 'fa-file-text-o' + 'application' => 'bi-file-earmark', + 'multipart' => 'bi-folder', + 'audio' => 'bi-file-earmark-music', + 'video' => 'bi-file-earmark-play', + 'text' => 'bi-file-earmark-text', + 'image' => 'bi-file-earmark-image', + 'message' => 'bi-file-earmark-text' ]; @@ -3266,7 +3266,7 @@ function getIconFromType($type) { } if(! $iconFromType) { - $iconFromType = 'fa-file-o'; + $iconFromType = 'bi-file-earmark'; } @@ -3755,12 +3755,9 @@ function cleanup_bbcode($body) { $body = preg_replace_callback('/\[img(.*?)\[\/(img)\]/ism','\red_escape_codeblock',$body); $body = preg_replace_callback('/\[zmg(.*?)\[\/(zmg)\]/ism','\red_escape_codeblock',$body); - $body = preg_replace_callback("/([^\]\='".'"'."\;\/\{]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\\ -+\,\(\)]+)/ismu", '\nakedoembed', $body); - - $body = preg_replace_callback("/([^\]\='".'"'."\;\/\{]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\\ -+\,\(\)]+)/ismu", '\red_zrl_callback', $body); + $body = preg_replace_callback("/([^\]\='".'"'."\;\/\{]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\\+\,\(\)]+)/ismu", '\nakedoembed', $body); + $body = preg_replace_callback("/([^\]\='".'"'."\;\/\{]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\\+\,\(\)]+)/ismu", '\red_zrl_callback', $body); $body = preg_replace_callback('/\[\$b64code(.*?)\[\/(code)\]/ism','\red_unescape_codeblock',$body); $body = preg_replace_callback('/\[\$b64summary(.*?)\[\/(summary)\]/ism','\red_unescape_codeblock',$body); |