- //$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)
- $siteinfo["keywords"][] = trim($keyword);
- }
-
- //$list = $xpath->query("head/meta[@property]");
- $list = $xpath->query("//meta[@property]");
- 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["property"])) {
- case "og:image":
- $siteinfo["image"] = $attr["content"];
- break;
- case "og:title":
- $siteinfo["title"] = $attr["content"];
- break;
- case "og:description":
- $siteinfo["text"] = $attr["content"];
- break;
- }
- }
-
- if ((@$siteinfo["image"] == "") AND !$no_guessing) {
- $list = $xpath->query("//img[@src]");
- foreach ($list as $node) {
- $attr = array();
- if ($node->attributes->length)
- foreach ($node->attributes as $attribute)
- $attr[$attribute->name] = $attribute->value;
-
- $src = completeurl($attr["src"], $url);
- $photodata = @getimagesize($src);
-
- if (($photodata) && ($photodata[0] > 150) and ($photodata[1] > 150)) {
- if ($photodata[0] > 300) {
- $photodata[1] = round($photodata[1] * (300 / $photodata[0]));
- $photodata[0] = 300;
- }
- if ($photodata[1] > 300) {
- $photodata[0] = round($photodata[0] * (300 / $photodata[1]));
- $photodata[1] = 300;
- }
- $siteinfo["images"][] = array("src"=>$src,
- "width"=>$photodata[0],
- "height"=>$photodata[1]);
- }
-