From d582054c77b22daeb08d2bff17794b9a69a20dd4 Mon Sep 17 00:00:00 2001 From: mensonge Date: Wed, 12 Dec 2007 16:29:16 +0000 Subject: import of scuttle 0.7.2 git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@1 b3834d28-1941-0410-a4f8-b48e95affb8f --- ajaxGetTitle.php | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 ajaxGetTitle.php (limited to 'ajaxGetTitle.php') diff --git a/ajaxGetTitle.php b/ajaxGetTitle.php new file mode 100644 index 0000000..0bc142d --- /dev/null +++ b/ajaxGetTitle.php @@ -0,0 +1,66 @@ +(.*)<\/title>/si', $html, $matches); + $title = $matches[1][0]; + + // Get encoding from charset attribute + preg_match_all('//i', $html, $matches); + $encoding = strtoupper($matches[1][0]); + + // Convert to UTF-8 from the original encoding + if (function_exists('mb_convert_encoding') { + $title = @mb_convert_encoding($title, 'UTF-8', $encoding); + } + + if (utf8_strlen($title) > 0) { + return $title; + } else { + // No title, so return filename + $uriparts = explode('/', $url); + $filename = end($uriparts); + unset($uriparts); + + return $filename; + } + } else { + return false; + } +} +echo ''; +?> + + getTitle + + \ No newline at end of file -- cgit v1.2.3