diff options
Diffstat (limited to 'application/LinkUtils.php')
-rw-r--r-- | application/LinkUtils.php | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/application/LinkUtils.php b/application/LinkUtils.php index d8dc8b5e..da04ca97 100644 --- a/application/LinkUtils.php +++ b/application/LinkUtils.php | |||
@@ -9,8 +9,8 @@ | |||
9 | */ | 9 | */ |
10 | function html_extract_title($html) | 10 | function html_extract_title($html) |
11 | { | 11 | { |
12 | if (preg_match('!<title>(.*?)</title>!is', $html, $matches)) { | 12 | if (preg_match('!<title.*?>(.*?)</title>!is', $html, $matches)) { |
13 | return trim(str_replace("\n", ' ', $matches[1])); | 13 | return trim(str_replace("\n", '', $matches[1])); |
14 | } | 14 | } |
15 | return false; | 15 | return false; |
16 | } | 16 | } |
@@ -70,10 +70,26 @@ function headers_extract_charset($headers) | |||
70 | function html_extract_charset($html) | 70 | function html_extract_charset($html) |
71 | { | 71 | { |
72 | // Get encoding specified in HTML header. | 72 | // Get encoding specified in HTML header. |
73 | preg_match('#<meta .*charset="?([^">/]+)"? */?>#Usi', $html, $enc); | 73 | preg_match('#<meta .*charset=["\']?([^";\'>/]+)["\']? */?>#Usi', $html, $enc); |
74 | if (!empty($enc[1])) { | 74 | if (!empty($enc[1])) { |
75 | return strtolower($enc[1]); | 75 | return strtolower($enc[1]); |
76 | } | 76 | } |
77 | 77 | ||
78 | return false; | 78 | return false; |
79 | } | 79 | } |
80 | |||
81 | /** | ||
82 | * Count private links in given linklist. | ||
83 | * | ||
84 | * @param array $links Linklist. | ||
85 | * | ||
86 | * @return int Number of private links. | ||
87 | */ | ||
88 | function count_private($links) | ||
89 | { | ||
90 | $cpt = 0; | ||
91 | foreach ($links as $link) { | ||
92 | $cpt = $link['private'] == true ? $cpt + 1 : $cpt; | ||
93 | } | ||
94 | return $cpt; | ||
95 | } | ||