The function for fetching the original url is removed from the addons and added to the core.

This commit is contained in:
Michael Vogel 2014-04-04 11:13:39 +02:00
parent 76fac5069c
commit 7f37e843c7
3 changed files with 24 additions and 348 deletions

View file

@ -59,11 +59,11 @@ function gpluspost_settings(&$a,&$s) {
$skip_checked = (($skip_enabled) ? ' checked="checked" ' : '');
$s .= '<span id="settings_gpluspost_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_gpluspost_expanded\'); openClose(\'settings_gpluspost_inflated\');">';
$s .= '<h3>' . t('Google+') . '</h3>';
$s .= '<h3>' . t('Google+ Export') . '</h3>';
$s .= '</span>';
$s .= '<div id="settings_gpluspost_expanded" class="settings-block" style="display: none;">';
$s .= '<span class="fakelink" onclick="openClose(\'settings_gpluspost_expanded\'); openClose(\'settings_gpluspost_inflated\');">';
$s .= '<h3>' . t('Google+') . '</h3>';
$s .= '<h3>' . t('Google+ Export') . '</h3>';
$s .= '</span>';
$s .= '<div id="gpluspost-enable-wrapper">';
@ -214,70 +214,12 @@ function gpluspost_init() {
killme();
}
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,'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0');
$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_feeditem($pid, $uid) {
global $a;
require_once('include/bbcode.php');
require_once("include/html2plain.php");
require_once("include/network.php");
$skipwithoutlink = get_pconfig($uid,'gpluspost','skip_without_link');
@ -365,7 +307,7 @@ function gpluspost_feeditem($pid, $uid) {
$title = trim(str_replace($msglink, "", $title));
$msglink = gpluspost_original_url($msglink);
$msglink = original_url($msglink);
if ($uid == 0)
$title = $item["author-name"].": ".$title;