-function gpluspost_original_url($url, $depth=1) {
-
- if ($depth > 10)
- return($url);
-
- $siteinfo = array();
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HEADER, 1);
- curl_setopt($ch, CURLOPT_NOBODY, 0);
- curl_setopt($ch, CURLOPT_TIMEOUT, 3);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch,CURLOPT_USERAGENT,'Opera/9.64(Windows NT 5.1; U; de) Presto/2.1.1');
-
- $header = curl_exec($ch);
- $curl_info = @curl_getinfo($ch);
- $http_code = $curl_info['http_code'];
- curl_close($ch);
-
- if ((($curl_info['http_code'] == "301") OR ($curl_info['http_code'] == "302"))
- AND (($curl_info['redirect_url'] != "") OR ($curl_info['location'] != ""))) {
- if ($curl_info['redirect_url'] != "")
- return(gpluspost_original_url($curl_info['redirect_url'], ++$depth));
- else
- return(gpluspost_original_url($curl_info['location'], ++$depth));
- }
-
- $pos = strpos($header, "\r\n\r\n");
-
- if ($pos)
- $body = trim(substr($header, $pos));
- else
- $body = $header;
-
- $doc = new DOMDocument();
- @$doc->loadHTML($body);
-
- $xpath = new DomXPath($doc);
-
- $list = $xpath->query("//meta[@content]");
- foreach ($list as $node) {
- $attr = array();
- if ($node->attributes->length)
- foreach ($node->attributes as $attribute)
- $attr[$attribute->name] = $attribute->value;
-
- if (@$attr["http-equiv"] == 'refresh') {
- $path = $attr["content"];
- $pathinfo = explode(";", $path);
- $content = "";
- foreach ($pathinfo AS $value)
- if (substr(strtolower($value), 0, 4) == "url=")
- return(gpluspost_original_url(substr($value, 4), ++$depth));
- }
- }
-
- return($url);
-}
-
-function gpluspost_ShareAttributes($match) {
-
- $attributes = $match[1];
-
- $author = "";
- preg_match("/author='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $author = $matches[1];
-
- preg_match('/author="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
- $author = $matches[1];
-
- $headline = '<div class="shared_header">';
-
- $headline .= sprintf(t('%s:'), $author);
-
- $headline .= "</div>";
-
- //$text = "<br />".$headline."</strong><blockquote>".$match[2]."</blockquote>";
- //$text = "\n\t".$match[2].":\t";
- $text = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').$author.": ".$match[2];
-
- return($text);
-}
-