X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FLinkUtils.php;h=da04ca9743870f555b5feea64ea9501eb4cbde30;hb=51def0d84955c7a951bd091eb5eeb3fce9deabd4;hp=26dd6b6794c402464c007b647a5cd5dbe9a9b19f;hpb=92ba7b573f2833bd35c7eb2fc7fdbeb1a0ac7b44;p=github%2Fshaarli%2FShaarli.git
diff --git a/application/LinkUtils.php b/application/LinkUtils.php
old mode 100755
new mode 100644
index 26dd6b67..da04ca97
--- a/application/LinkUtils.php
+++ b/application/LinkUtils.php
@@ -9,8 +9,8 @@
*/
function html_extract_title($html)
{
- if (preg_match('!
(.*)!is', $html, $matches)) {
- return trim(str_replace("\n", ' ', $matches[1]));
+ if (preg_match('!(.*?)!is', $html, $matches)) {
+ return trim(str_replace("\n", '', $matches[1]));
}
return false;
}
@@ -70,10 +70,26 @@ function headers_extract_charset($headers)
function html_extract_charset($html)
{
// Get encoding specified in HTML header.
- preg_match('#/]+)"? */?>#Usi', $html, $enc);
+ preg_match('#/]+)["\']? */?>#Usi', $html, $enc);
if (!empty($enc[1])) {
return strtolower($enc[1]);
}
return false;
}
+
+/**
+ * Count private links in given linklist.
+ *
+ * @param array $links Linklist.
+ *
+ * @return int Number of private links.
+ */
+function count_private($links)
+{
+ $cpt = 0;
+ foreach ($links as $link) {
+ $cpt = $link['private'] == true ? $cpt + 1 : $cpt;
+ }
+ return $cpt;
+}