diff options
author | Max Kostikov <max@kostikov.co> | 2021-03-10 11:14:02 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2021-03-10 11:14:02 +0000 |
commit | 11d831e4d7bd4163ea518892f541252ce1acea2e (patch) | |
tree | 2971e2626503b972b5051d6f26689166e07f4d4c /include/html2plain.php | |
parent | 7ee495624e71125074a4eb9f5533a7af2db2f6b6 (diff) | |
download | volse-hubzilla-11d831e4d7bd4163ea518892f541252ce1acea2e.tar.gz volse-hubzilla-11d831e4d7bd4163ea518892f541252ce1acea2e.tar.bz2 volse-hubzilla-11d831e4d7bd4163ea518892f541252ce1acea2e.zip |
More PHP 8 fixes
Diffstat (limited to 'include/html2plain.php')
-rw-r--r-- | include/html2plain.php | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/include/html2plain.php b/include/html2plain.php index 91a1f14cb..bf8581bdb 100644 --- a/include/html2plain.php +++ b/include/html2plain.php @@ -76,28 +76,47 @@ function quotelevel($message, $wraplength = 75) return(implode("\n", $newlines)); } + function collecturls($message) { + $pattern = '/<a.*?href="(.*?)".*?>(.*?)<\/a>/is'; preg_match_all($pattern, $message, $result, PREG_SET_ORDER); - - $urls = array(); - foreach ($result as $treffer) { - // A list of some links that should be ignored - $list = array("/user/", "/tag/", "/group/", "/profile/", "/channel/", "/search?search=", "/search?tag=", "mailto:", "/u/", "/node/", - "//facebook.com/profile.php?id=", "//plus.google.com/"); - 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)) + + $urls = []; + if ($result) { + $ignore = false; + foreach ($result as $treffer) { + // A list of some links that should be ignored + $list = [ + "/user/", + "/tag/", + "/group/", + "/profile/", + "/channel/", + "/search?search=", + "/search?tag=", + "mailto:", + "/u/", + "/node/", + "//facebook.com/profile.php?id=", + "//plus.google.com/" + ]; + 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]; + + if (! $ignore) + $urls[$treffer[1]] = $treffer[1]; + } } + return($urls); } + function html2plain($html, $wraplength = 75, $compact = false) { |