From a62b9742ee5e28bcec6872d88f50f25b820914f6 Mon Sep 17 00:00:00 2001 From: mensonge Date: Wed, 22 Oct 2008 14:05:59 +0000 Subject: git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@150 b3834d28-1941-0410-a4f8-b48e95affb8f --- ajaxGetTitle.php | 92 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 48 insertions(+), 44 deletions(-) (limited to 'ajaxGetTitle.php') diff --git a/ajaxGetTitle.php b/ajaxGetTitle.php index 0bc142d..d440802 100644 --- a/ajaxGetTitle.php +++ b/ajaxGetTitle.php @@ -1,23 +1,23 @@ (.*)<\/title>/si', $html, $matches); - $title = $matches[1][0]; + // Get title from title tag + preg_match_all('/(.*)<\/title>/si', $html, $matches); + $title = $matches[1][0]; - // Get encoding from charset attribute - preg_match_all('/<meta.*charset=([^;"]*)">/i', $html, $matches); - $encoding = strtoupper($matches[1][0]); + // Get encoding from charset attribute + preg_match_all('/<meta.*charset=([^;"]*)">/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); - } + // 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); + 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; - } + return $filename; + } + } else { + return false; + } } echo '<?xml version="1.0" encoding="utf-8"?>'; ?> <response> - <method>getTitle</method> - <result><?php echo getTitle($_GET['url']); ?></result> -</response> \ No newline at end of file +<method> +getTitle +</method> +<result> +<?php echo getTitle($_GET['url']); ?> +</result> +</response> -- cgit v1.2.3-54-g00ecf