diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/bbcode.php | 21 | ||||
-rw-r--r-- | include/html2plain.php | 10 | ||||
-rw-r--r-- | include/items.php | 2 | ||||
-rw-r--r-- | include/text.php | 27 |
4 files changed, 54 insertions, 6 deletions
diff --git a/include/bbcode.php b/include/bbcode.php index a362e9ce9..87a7e6af6 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -1099,6 +1099,27 @@ function bbcode($Text, $options = []) { call_hooks('bbcode_filter', $Text); + if(isset($options['drop_media'])) { + if (strpos($Text,'[/img]') !== false) { + $Text = preg_replace('/\[img(.*?)\[\/(img)\]/ism', '', $Text); + } + if (strpos($Text,'[/audio]') !== false) { + $Text = preg_replace('/\[audio(.*?)\[\/(audio)\]/ism', '', $Text); + } + if (strpos($Text,'[/video]') !== false) { + $Text = preg_replace('/\[video(.*?)\[\/(video)\]/ism', '', $Text); + } + if (strpos($Text,'[/zmg]') !== false) { + $Text = preg_replace('/\[zmg(.*?)\[\/(zmg)\]/ism', '', $Text); + } + if (strpos($Text,'[/zaudio]') !== false) { + $Text = preg_replace('/\[zaudio(.*?)\[\/(zaudio)\]/ism', '', $Text); + } + if (strpos($Text,'[/zvideo]') !== false) { + $Text = preg_replace('/\[zvideo(.*?)\[\/(zvideo)\]/ism', '', $Text); + } + } + // Hide all [noparse] contained bbtags by spacefying them if (strpos($Text,'[noparse]') !== false) { $Text = preg_replace_callback("/\[noparse\](.*?)\[\/noparse\]/ism", 'bb_spacefy',$Text); diff --git a/include/html2plain.php b/include/html2plain.php index bf8581bdb..48bbe3d9e 100644 --- a/include/html2plain.php +++ b/include/html2plain.php @@ -78,10 +78,10 @@ function quotelevel($message, $wraplength = 75) function collecturls($message) { - + $pattern = '/<a.*?href="(.*?)".*?>(.*?)<\/a>/is'; preg_match_all($pattern, $message, $result, PREG_SET_ORDER); - + $urls = []; if ($result) { $ignore = false; @@ -104,15 +104,15 @@ function collecturls($message) { foreach ($list as $listitem) if (strpos($treffer[1], $listitem) !== false) $ignore = true; - + if ((strpos($treffer[1], "//plus.google.com/") !== false) and (strpos($treffer[1], "/posts") !== false)) $ignore = false; - + if (! $ignore) $urls[$treffer[1]] = $treffer[1]; } } - + return($urls); } diff --git a/include/items.php b/include/items.php index 15de6c730..7fa3a8e71 100644 --- a/include/items.php +++ b/include/items.php @@ -2494,7 +2494,7 @@ function send_status_notifications($post_id,$item) { Enotify::submit(array( - 'type' => NOTIFY_COMMENT, + 'type' => ((intval($item['item_private']) === 2) ? NOTIFY_MAIL : NOTIFY_COMMENT), 'from_xchan' => $item['author_xchan'], 'to_xchan' => $r[0]['channel_hash'], 'item' => $item, diff --git a/include/text.php b/include/text.php index 8dc5ee188..a0c2689af 100644 --- a/include/text.php +++ b/include/text.php @@ -3880,3 +3880,30 @@ function sanitize_text_field($str) { return preg_replace('/\s+/S', ' ', $str); } +/** + * @brief shortens a string to $max_length without cutting off words + * @param string $str + * @param intval $max_length + * @param string $suffix (optional) + + * @return string + */ +function substr_words($str, $max_length, $suffix = '...') { + + if (strlen($str) > $max_length) { + $words = preg_split('/\s/', $str); + $ret = ''; + $i = 0; + while (true) { + $length = (strlen($ret) + strlen($words[$i])); + if ($length > $max_length) { + break; + } + $ret .= " " . $words[$i]; + ++$i; + } + $ret .= $suffix; + } + + return (($ret) ? $ret : $str); +} |