- //$list = $xpath->query("head/title");
- $list = $xpath->query("//title");
- foreach ($list as $node)
- $siteinfo["title"] = html_entity_decode($node->nodeValue, ENT_QUOTES, "UTF-8");
-
- //$list = $xpath->query("head/meta[@name]");
- $list = $xpath->query("//meta[@name]");
- foreach ($list as $node) {
- $attr = array();
- if ($node->attributes->length)
- foreach ($node->attributes as $attribute)
- $attr[$attribute->name] = $attribute->value;
-
- $attr["content"] = trim(html_entity_decode($attr["content"], ENT_QUOTES, "UTF-8"));
-
- if ($attr["content"] != "")
- switch (strtolower($attr["name"])) {
- case "fulltitle":
- $siteinfo["title"] = $attr["content"];
- break;
- case "description":
- $siteinfo["text"] = $attr["content"];
- break;
- case "thumbnail":
- $siteinfo["image"] = $attr["content"];
- break;
- case "twitter:image":
- $siteinfo["image"] = $attr["content"];
- break;
- case "twitter:image:src":
- $siteinfo["image"] = $attr["content"];
- break;
- case "twitter:card":
- if (($siteinfo["type"] == "") OR ($attr["content"] == "photo"))
- $siteinfo["type"] = $attr["content"];
- break;
- case "twitter:description":
- $siteinfo["text"] = $attr["content"];
- break;
- case "twitter:title":
- $siteinfo["title"] = $attr["content"];
- break;
- case "dc.title":
- $siteinfo["title"] = $attr["content"];
- break;
- case "dc.description":
- $siteinfo["text"] = $attr["content"];
- break;
- case "keywords":
- $keywords = explode(",", $attr["content"]);
- break;
- case "news_keywords":
- $keywords = explode(",", $attr["content"]);
- break;
- }
- if ($siteinfo["type"] == "summary")
- $siteinfo["type"] = "link";
- }
-
- if (isset($keywords)) {
- $siteinfo["keywords"] = array();
- foreach ($keywords as $keyword)
- if (!in_array(trim($keyword), $siteinfo["keywords"]))
- $siteinfo["keywords"][] = trim($keyword);
- }