forked from friendica/friendica-addons
Merge pull request #186 from annando/master
Bidirectional Statusnet sync, bugfix for posting facebook comments and some title improvements
This commit is contained in:
commit
02735d12ff
|
@ -53,11 +53,11 @@ function appnetpost_settings(&$a,&$s) {
|
||||||
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
|
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
|
||||||
|
|
||||||
$s .= '<span id="settings_appnetpost_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_appnetpost_expanded\'); openClose(\'settings_appnetpost_inflated\');">';
|
$s .= '<span id="settings_appnetpost_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_appnetpost_expanded\'); openClose(\'settings_appnetpost_inflated\');">';
|
||||||
$s .= '<h3>' . t('App.net') . '</h3>';
|
$s .= '<h3>' . t('App.net Export') . '</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
$s .= '<div id="settings_appnetpost_expanded" class="settings-block" style="display: none;">';
|
$s .= '<div id="settings_appnetpost_expanded" class="settings-block" style="display: none;">';
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_appnetpost_expanded\'); openClose(\'settings_appnetpost_inflated\');">';
|
$s .= '<span class="fakelink" onclick="openClose(\'settings_appnetpost_expanded\'); openClose(\'settings_appnetpost_inflated\');">';
|
||||||
$s .= '<h3>' . t('App.net') . '</h3>';
|
$s .= '<h3>' . t('App.net Export') . '</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
|
|
||||||
$s .= '<div id="appnetpost-enable-wrapper">';
|
$s .= '<div id="appnetpost-enable-wrapper">';
|
||||||
|
@ -196,65 +196,6 @@ function appnetpost_init() {
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
function appnetpost_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(appnetpost_original_url($curl_info['redirect_url'], ++$depth));
|
|
||||||
else
|
|
||||||
return(appnetpost_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(appnetpost_original_url(substr($value, 4), ++$depth));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return($url);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! function_exists( 'short_link' )) {
|
if (! function_exists( 'short_link' )) {
|
||||||
function short_link($url) {
|
function short_link($url) {
|
||||||
require_once('library/slinky.php');
|
require_once('library/slinky.php');
|
||||||
|
@ -387,7 +328,7 @@ function appnetpost_feeditem($pid, $uid) {
|
||||||
if ($title == "")
|
if ($title == "")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//$origlink = appnetpost_original_url($origlink);
|
//$origlink = original_url($origlink);
|
||||||
|
|
||||||
$html = nl2br($title);
|
$html = nl2br($title);
|
||||||
|
|
||||||
|
|
|
@ -71,11 +71,11 @@ function blogger_settings(&$a,&$s) {
|
||||||
/* Add some HTML to the existing form */
|
/* Add some HTML to the existing form */
|
||||||
|
|
||||||
$s .= '<span id="settings_blogger_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_blogger_expanded\'); openClose(\'settings_blogger_inflated\');">';
|
$s .= '<span id="settings_blogger_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_blogger_expanded\'); openClose(\'settings_blogger_inflated\');">';
|
||||||
$s .= '<h3>' . t('Blogger') . '</h3>';
|
$s .= '<h3>' . t('Blogger Export') . '</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
$s .= '<div id="settings_blogger_expanded" class="settings-block" style="display: none;">';
|
$s .= '<div id="settings_blogger_expanded" class="settings-block" style="display: none;">';
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_blogger_expanded\'); openClose(\'settings_blogger_inflated\');">';
|
$s .= '<span class="fakelink" onclick="openClose(\'settings_blogger_expanded\'); openClose(\'settings_blogger_inflated\');">';
|
||||||
$s .= '<h3>' . t('Blogger') . '</h3>';
|
$s .= '<h3>' . t('Blogger Export') . '</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
|
|
||||||
$s .= '<div id="blogger-enable-wrapper">';
|
$s .= '<div id="blogger-enable-wrapper">';
|
||||||
|
|
|
@ -61,11 +61,12 @@ class Diasphp {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
function post($text) {
|
function post($text, $provider = "diasphp") {
|
||||||
// post-daten vorbereiten
|
// post-daten vorbereiten
|
||||||
$datatopost = json_encode(array(
|
$datatopost = json_encode(array(
|
||||||
'aspect_ids' => 'public',
|
'aspect_ids' => 'public',
|
||||||
'status_message' => array('text' => $text)
|
'status_message' => array('text' => $text,
|
||||||
|
'provider_display_name' => $provider)
|
||||||
));
|
));
|
||||||
|
|
||||||
// header vorbereiten
|
// header vorbereiten
|
||||||
|
|
|
@ -39,6 +39,8 @@ function diaspora_jot_nets(&$a,&$b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function diaspora_queue_hook(&$a,&$b) {
|
function diaspora_queue_hook(&$a,&$b) {
|
||||||
|
$hostname = $a->get_hostname();
|
||||||
|
|
||||||
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
|
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
|
||||||
dbesc(NETWORK_DIASPORA2)
|
dbesc(NETWORK_DIASPORA2)
|
||||||
);
|
);
|
||||||
|
@ -85,7 +87,7 @@ function diaspora_queue_hook(&$a,&$b) {
|
||||||
logger('diaspora_queue: try to log in '.$diaspora_username, LOGGER_DEBUG);
|
logger('diaspora_queue: try to log in '.$diaspora_username, LOGGER_DEBUG);
|
||||||
$conn->login($diaspora_username, $diaspora_password);
|
$conn->login($diaspora_username, $diaspora_password);
|
||||||
logger('diaspora_queue: try to send '.$body, LOGGER_DEBUG);
|
logger('diaspora_queue: try to send '.$body, LOGGER_DEBUG);
|
||||||
$conn->post($post);
|
$conn->post($post, $hostname);
|
||||||
|
|
||||||
logger('diaspora_queue: send '.$userdata['uid'].' success', LOGGER_DEBUG);
|
logger('diaspora_queue: send '.$userdata['uid'].' success', LOGGER_DEBUG);
|
||||||
|
|
||||||
|
@ -144,11 +146,11 @@ function diaspora_settings(&$a,&$s) {
|
||||||
/* Add some HTML to the existing form */
|
/* Add some HTML to the existing form */
|
||||||
|
|
||||||
$s .= '<span id="settings_diaspora_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_diaspora_expanded\'); openClose(\'settings_diaspora_inflated\');">';
|
$s .= '<span id="settings_diaspora_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_diaspora_expanded\'); openClose(\'settings_diaspora_inflated\');">';
|
||||||
$s .= '<h3>' . t('Diaspora') . '</h3>';
|
$s .= '<h3>' . t('Diaspora Export') . '</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
$s .= '<div id="settings_diaspora_expanded" class="settings-block" style="display: none;">';
|
$s .= '<div id="settings_diaspora_expanded" class="settings-block" style="display: none;">';
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_diaspora_expanded\'); openClose(\'settings_diaspora_inflated\');">';
|
$s .= '<span class="fakelink" onclick="openClose(\'settings_diaspora_expanded\'); openClose(\'settings_diaspora_inflated\');">';
|
||||||
$s .= '<h3>' . t('Diaspora') . '</h3>';
|
$s .= '<h3>' . t('Diaspora Export') . '</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
|
|
||||||
if ($status) {
|
if ($status) {
|
||||||
|
@ -233,6 +235,7 @@ function diaspora_post_local(&$a,&$b) {
|
||||||
|
|
||||||
|
|
||||||
function diaspora_send(&$a,&$b) {
|
function diaspora_send(&$a,&$b) {
|
||||||
|
$hostname = $a->get_hostname();
|
||||||
|
|
||||||
logger('diaspora_send: invoked');
|
logger('diaspora_send: invoked');
|
||||||
|
|
||||||
|
@ -303,7 +306,7 @@ function diaspora_send(&$a,&$b) {
|
||||||
logger('diaspora_send: try to send '.$body, LOGGER_DEBUG);
|
logger('diaspora_send: try to send '.$body, LOGGER_DEBUG);
|
||||||
|
|
||||||
//throw new Exception('Test');
|
//throw new Exception('Test');
|
||||||
$conn->post($body);
|
$conn->post($body, $hostname);
|
||||||
|
|
||||||
logger('diaspora_send: success');
|
logger('diaspora_send: success');
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
|
@ -96,7 +96,7 @@ function fbpost_init(&$a) {
|
||||||
|
|
||||||
if(strpos($x,'access_token=') !== false) {
|
if(strpos($x,'access_token=') !== false) {
|
||||||
$token = str_replace('access_token=', '', $x);
|
$token = str_replace('access_token=', '', $x);
|
||||||
if(strpos($token,'&') !== false)
|
if(strpos($token,'&') !== false)
|
||||||
$token = substr($token,0,strpos($token,'&'));
|
$token = substr($token,0,strpos($token,'&'));
|
||||||
set_pconfig($uid,'facebook','access_token',$token);
|
set_pconfig($uid,'facebook','access_token',$token);
|
||||||
set_pconfig($uid,'facebook','post','1');
|
set_pconfig($uid,'facebook','post','1');
|
||||||
|
@ -207,7 +207,7 @@ function fbpost_content(&$a) {
|
||||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'
|
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="'
|
||||||
. $a->get_baseurl() . '/addon/fbpost/fbpost.css' . '" media="all" />' . "\r\n";
|
. $a->get_baseurl() . '/addon/fbpost/fbpost.css' . '" media="all" />' . "\r\n";
|
||||||
|
|
||||||
$o .= '<h3>' . t('Facebook') . '</h3>';
|
$o .= '<h3>' . t('Facebook Export/Mirror') . '</h3>';
|
||||||
|
|
||||||
if(! $fb_installed) {
|
if(! $fb_installed) {
|
||||||
$o .= '<div id="fbpost-enable-wrapper">';
|
$o .= '<div id="fbpost-enable-wrapper">';
|
||||||
|
@ -293,7 +293,7 @@ function fbpost_content(&$a) {
|
||||||
function fbpost_plugin_settings(&$a,&$b) {
|
function fbpost_plugin_settings(&$a,&$b) {
|
||||||
|
|
||||||
$b .= '<div class="settings-block">';
|
$b .= '<div class="settings-block">';
|
||||||
$b .= '<a href="fbpost"><h3>' . t('Facebook') . '</a></h3>';
|
$b .= '<a href="fbpost"><h3>' . t('Facebook Export/Mirror') . '</a></h3>';
|
||||||
$b .= '</div>';
|
$b .= '</div>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -571,6 +571,7 @@ function fbpost_post_hook(&$a,&$b) {
|
||||||
|
|
||||||
$allow_str = dbesc(implode(', ',$recipients));
|
$allow_str = dbesc(implode(', ',$recipients));
|
||||||
if($allow_str) {
|
if($allow_str) {
|
||||||
|
logger("fbpost_post_hook: private post to: ".$allow_str, LOGGER_DEBUG);
|
||||||
$r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( $allow_str ) AND `network` = 'face'");
|
$r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( $allow_str ) AND `network` = 'face'");
|
||||||
if(count($r))
|
if(count($r))
|
||||||
foreach($r as $rr)
|
foreach($r as $rr)
|
||||||
|
@ -633,22 +634,32 @@ function fbpost_post_hook(&$a,&$b) {
|
||||||
|
|
||||||
logger('fbpost_post_hook: original msg=' . $msg, LOGGER_DATA);
|
logger('fbpost_post_hook: original msg=' . $msg, LOGGER_DATA);
|
||||||
|
|
||||||
// To-Do: if it is a reply, then only do a simple bbcode2plain conversion
|
if ($toplevel) {
|
||||||
$msgarr = fbpost_createmsg($b);
|
$msgarr = fbpost_createmsg($b);
|
||||||
$msg = $msgarr["msg"];
|
$msg = $msgarr["msg"];
|
||||||
$link = $msgarr["link"];
|
$link = $msgarr["link"];
|
||||||
$image = $msgarr["image"];
|
$image = $msgarr["image"];
|
||||||
$linkname = $msgarr["linkname"];
|
$linkname = $msgarr["linkname"];
|
||||||
|
|
||||||
// Fallback - if message is empty
|
// Fallback - if message is empty
|
||||||
if(!strlen($msg))
|
if(!strlen($msg))
|
||||||
$msg = $linkname;
|
$msg = $linkname;
|
||||||
|
|
||||||
if(!strlen($msg))
|
if(!strlen($msg))
|
||||||
$msg = $link;
|
$msg = $link;
|
||||||
|
|
||||||
if(!strlen($msg))
|
if(!strlen($msg))
|
||||||
$msg = $image;
|
$msg = $image;
|
||||||
|
} else {
|
||||||
|
require_once("include/bbcode.php");
|
||||||
|
require_once("include/html2plain.php");
|
||||||
|
$msg = bb_CleanPictureLinks($msg);
|
||||||
|
$msg = bbcode($msg, false, false, 2, true);
|
||||||
|
$msg = trim(html2plain($msg, 0));
|
||||||
|
$link = "";
|
||||||
|
$image = "";
|
||||||
|
$linkname = "";
|
||||||
|
}
|
||||||
|
|
||||||
// If there is nothing to post then exit
|
// If there is nothing to post then exit
|
||||||
if(!strlen($msg))
|
if(!strlen($msg))
|
||||||
|
@ -962,7 +973,7 @@ function fbpost_get_app_access_token() {
|
||||||
logger('fb_get_app_access_token: returned access token: ' . $x, LOGGER_DATA);
|
logger('fb_get_app_access_token: returned access token: ' . $x, LOGGER_DATA);
|
||||||
|
|
||||||
$token = str_replace('access_token=', '', $x);
|
$token = str_replace('access_token=', '', $x);
|
||||||
if(strpos($token,'&') !== false)
|
if(strpos($token,'&') !== false)
|
||||||
$token = substr($token,0,strpos($token,'&'));
|
$token = substr($token,0,strpos($token,'&'));
|
||||||
|
|
||||||
if ($token == "") {
|
if ($token == "") {
|
||||||
|
@ -1105,7 +1116,7 @@ function fbpost_fetchwall($a, $uid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($content)
|
if ($content)
|
||||||
$_REQUEST["body"] .= "\n\n";
|
$_REQUEST["body"] .= "\n";
|
||||||
|
|
||||||
if ($type)
|
if ($type)
|
||||||
$_REQUEST["body"] .= "[class=type-".$type."]";
|
$_REQUEST["body"] .= "[class=type-".$type."]";
|
||||||
|
|
|
@ -177,7 +177,7 @@ function fbsync_cron($a,$b) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger('fbsync: cron_end');
|
logger('fbsync_cron: cron_end');
|
||||||
|
|
||||||
set_config('fbsync','last_poll', time());
|
set_config('fbsync','last_poll', time());
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,7 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($content)
|
if ($content)
|
||||||
$postarray["body"] .= "\n\n";
|
$postarray["body"] .= "\n";
|
||||||
|
|
||||||
if ($type)
|
if ($type)
|
||||||
$postarray["body"] .= "[class=type-".$type."]";
|
$postarray["body"] .= "[class=type-".$type."]";
|
||||||
|
@ -423,18 +423,18 @@ function fbsync_createcomment($a, $uid, $self_id, $self, $user, $contacts, $appl
|
||||||
// Check if the contact id was blocked
|
// Check if the contact id was blocked
|
||||||
if ($parent_contact > 0) {
|
if ($parent_contact > 0) {
|
||||||
$r = q("SELECT `blocked`, `readonly`, `nick` FROM `contact` WHERE `uid` = %d AND `id` = %d LIMIT 1",
|
$r = q("SELECT `blocked`, `readonly`, `nick` FROM `contact` WHERE `uid` = %d AND `id` = %d LIMIT 1",
|
||||||
intval($uid), intval($parent_contact));
|
intval($uid), intval($parent_contact));
|
||||||
|
|
||||||
// Should only happen if someone deleted the contact manually
|
// Should only happen if someone deleted the contact manually
|
||||||
if(!count($r)) {
|
if(!count($r)) {
|
||||||
logger("fbsync_createcomment: UID ".$uid." - Contact ".$parent_contact." doesn't seem to exist.", LOGGER_DEBUG);
|
logger("fbsync_createcomment: UID ".$uid." - Contact ".$parent_contact." doesn't seem to exist.", LOGGER_DEBUG);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is blocked? Then return
|
// Is blocked? Then return
|
||||||
if ($r[0]["readonly"] OR $r[0]["blocked"]) {
|
if ($r[0]["readonly"] OR $r[0]["blocked"]) {
|
||||||
logger("fbsync_createcomment: UID ".$uid." - Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
|
logger("fbsync_createcomment: UID ".$uid." - Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$parent_nick = $r[0]["nick"];
|
$parent_nick = $r[0]["nick"];
|
||||||
|
@ -522,8 +522,8 @@ function fbsync_createcomment($a, $uid, $self_id, $self, $user, $contacts, $appl
|
||||||
if(count($myconv)) {
|
if(count($myconv)) {
|
||||||
$importer_url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
|
$importer_url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
|
||||||
|
|
||||||
$own_contact = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
$own_contact = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||||
intval($uid), dbesc("facebook::".$self_id));
|
intval($uid), dbesc("facebook::".$self_id));
|
||||||
|
|
||||||
if (!count($own_contact))
|
if (!count($own_contact))
|
||||||
return;
|
return;
|
||||||
|
@ -570,8 +570,8 @@ function fbsync_createlike($a, $uid, $self_id, $self, $contacts, $like) {
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (count($r))
|
if (count($r))
|
||||||
$orig_post = $r[0];
|
$orig_post = $r[0];
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -597,15 +597,15 @@ function fbsync_createlike($a, $uid, $self_id, $self, $contacts, $like) {
|
||||||
$contact_id = $self[0]["id"];
|
$contact_id = $self[0]["id"];
|
||||||
|
|
||||||
$likedata = array();
|
$likedata = array();
|
||||||
$likedata['parent'] = $orig_post['id'];
|
$likedata['parent'] = $orig_post['id'];
|
||||||
$likedata['verb'] = ACTIVITY_LIKE;
|
$likedata['verb'] = ACTIVITY_LIKE;
|
||||||
$likedate['network'] = dbesc(NETWORK_FACEBOOK);
|
$likedate['network'] = dbesc(NETWORK_FACEBOOK);
|
||||||
$likedata['gravity'] = 3;
|
$likedata['gravity'] = 3;
|
||||||
$likedata['uid'] = $uid;
|
$likedata['uid'] = $uid;
|
||||||
$likedata['wall'] = 0;
|
$likedata['wall'] = 0;
|
||||||
$likedata['uri'] = item_new_uri($a->get_baseurl(), $uid);
|
$likedata['uri'] = item_new_uri($a->get_baseurl(), $uid);
|
||||||
$likedata['parent-uri'] = $orig_post["uri"];
|
$likedata['parent-uri'] = $orig_post["uri"];
|
||||||
$likedata['app'] = "Facebook";
|
$likedata['app'] = "Facebook";
|
||||||
|
|
||||||
if ($like->user_id != $self_id) {
|
if ($like->user_id != $self_id) {
|
||||||
$likedata['contact-id'] = $contact_id;
|
$likedata['contact-id'] = $contact_id;
|
||||||
|
@ -625,12 +625,12 @@ function fbsync_createlike($a, $uid, $self_id, $self, $contacts, $like) {
|
||||||
$post_type = t('status');
|
$post_type = t('status');
|
||||||
|
|
||||||
$plink = '[url=' . $orig_post['plink'] . ']' . $post_type . '[/url]';
|
$plink = '[url=' . $orig_post['plink'] . ']' . $post_type . '[/url]';
|
||||||
$likedata['object-type'] = ACTIVITY_OBJ_NOTE;
|
$likedata['object-type'] = ACTIVITY_OBJ_NOTE;
|
||||||
|
|
||||||
$likedata['body'] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
|
$likedata['body'] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
|
||||||
|
|
||||||
$likedata['object'] = '<object><type>' . ACTIVITY_OBJ_NOTE . '</type><local>1</local>' .
|
$likedata['object'] = '<object><type>' . ACTIVITY_OBJ_NOTE . '</type><local>1</local>' .
|
||||||
'<id>' . $orig_post['uri'] . '</id><link>' . xmlify('<link rel="alternate" type="text/html" href="' . xmlify($orig_post['plink']) . '" />') . '</link><title>' . $orig_post['title'] . '</title><content>' . $orig_post['body'] . '</content></object>';
|
'<id>' . $orig_post['uri'] . '</id><link>' . xmlify('<link rel="alternate" type="text/html" href="' . xmlify($orig_post['plink']) . '" />') . '</link><title>' . $orig_post['title'] . '</title><content>' . $orig_post['body'] . '</content></object>';
|
||||||
|
|
||||||
|
|
||||||
$r = q("SELECT * FROM `item` WHERE `parent-uri` = '%s' AND `author-link` = '%s' AND `verb` = '%s' AND `uid` = %d LIMIT 1",
|
$r = q("SELECT * FROM `item` WHERE `parent-uri` = '%s' AND `author-link` = '%s' AND `verb` = '%s' AND `uid` = %d LIMIT 1",
|
||||||
|
@ -640,7 +640,7 @@ function fbsync_createlike($a, $uid, $self_id, $self, $contacts, $like) {
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (count($r))
|
if (count($r))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$item = item_store($likedata);
|
$item = item_store($likedata);
|
||||||
|
@ -657,131 +657,133 @@ function fbsync_fetch_contact($uid, $contact, $create_user) {
|
||||||
if (count($r) == 0)
|
if (count($r) == 0)
|
||||||
q("INSERT INTO unique_contacts (url, name, nick, avatar) VALUES ('%s', '%s', '%s', '%s')",
|
q("INSERT INTO unique_contacts (url, name, nick, avatar) VALUES ('%s', '%s', '%s', '%s')",
|
||||||
dbesc(normalise_link($contact->url)),
|
dbesc(normalise_link($contact->url)),
|
||||||
dbesc($contact->name),
|
dbesc($contact->name),
|
||||||
dbesc($contact->username),
|
dbesc($contact->username),
|
||||||
dbesc($contact->pic_square));
|
dbesc($contact->pic_square));
|
||||||
else
|
else
|
||||||
q("UPDATE unique_contacts SET name = '%s', nick = '%s', avatar = '%s' WHERE url = '%s'",
|
q("UPDATE unique_contacts SET name = '%s', nick = '%s', avatar = '%s' WHERE url = '%s'",
|
||||||
dbesc($contact->name),
|
dbesc($contact->name),
|
||||||
dbesc($contact->username),
|
dbesc($contact->username),
|
||||||
dbesc($contact->pic_square),
|
dbesc($contact->pic_square),
|
||||||
dbesc(normalise_link($contact->url)));
|
dbesc(normalise_link($contact->url)));
|
||||||
|
|
||||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||||
intval($uid), dbesc("facebook::".$contact->id));
|
intval($uid), dbesc("facebook::".$contact->id));
|
||||||
|
|
||||||
if(!count($r) AND !$create_user)
|
if(!count($r) AND !$create_user)
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
if (count($r) AND ($r[0]["readonly"] OR $r[0]["blocked"])) {
|
if (count($r) AND ($r[0]["readonly"] OR $r[0]["blocked"])) {
|
||||||
logger("fbsync_fetch_contact: Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
|
logger("fbsync_fetch_contact: Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$avatarpicture = $contact->pic_square;
|
$avatarpicture = $contact->pic_square;
|
||||||
|
|
||||||
if(!count($r)) {
|
if(!count($r)) {
|
||||||
// create contact record
|
// create contact record
|
||||||
q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
|
q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
|
||||||
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
|
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
|
||||||
`writable`, `blocked`, `readonly`, `pending`)
|
`writable`, `blocked`, `readonly`, `pending`)
|
||||||
VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0)",
|
VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0)",
|
||||||
intval($uid),
|
intval($uid),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc($contact->url),
|
dbesc($contact->url),
|
||||||
dbesc(normalise_link($contact->url)),
|
dbesc(normalise_link($contact->url)),
|
||||||
dbesc($contact->username."@facebook.com"),
|
dbesc($contact->username."@facebook.com"),
|
||||||
dbesc("facebook::".$contact->id),
|
dbesc("facebook::".$contact->id),
|
||||||
dbesc(''),
|
dbesc($contact->id),
|
||||||
dbesc("facebook::".$contact->id),
|
dbesc("facebook::".$contact->id),
|
||||||
dbesc($contact->name),
|
dbesc($contact->name),
|
||||||
dbesc($contact->username),
|
dbesc($contact->username),
|
||||||
dbesc($avatarpicture),
|
dbesc($avatarpicture),
|
||||||
dbesc(NETWORK_FACEBOOK),
|
dbesc(NETWORK_FACEBOOK),
|
||||||
intval(CONTACT_IS_FRIEND),
|
intval(CONTACT_IS_FRIEND),
|
||||||
intval(1),
|
intval(1),
|
||||||
intval(1)
|
intval(1)
|
||||||
);
|
);
|
||||||
|
|
||||||
$r = q("SELECT * FROM `contact` WHERE `alias` = '%s' AND `uid` = %d LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `alias` = '%s' AND `uid` = %d LIMIT 1",
|
||||||
dbesc("facebook::".$contact->id),
|
dbesc("facebook::".$contact->id),
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
|
|
||||||
if(! count($r))
|
if(! count($r))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
$contact_id = $r[0]['id'];
|
$contact_id = $r[0]['id'];
|
||||||
|
|
||||||
$g = q("SELECT def_gid FROM user WHERE uid = %d LIMIT 1",
|
$g = q("SELECT def_gid FROM user WHERE uid = %d LIMIT 1",
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
|
|
||||||
if($g && intval($g[0]['def_gid'])) {
|
if($g && intval($g[0]['def_gid'])) {
|
||||||
require_once('include/group.php');
|
require_once('include/group.php');
|
||||||
group_add_member($uid,'',$contact_id,$g[0]['def_gid']);
|
group_add_member($uid,'',$contact_id,$g[0]['def_gid']);
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once("Photo.php");
|
require_once("Photo.php");
|
||||||
|
|
||||||
$photos = import_profile_photo($avatarpicture,$uid,$contact_id);
|
$photos = import_profile_photo($avatarpicture,$uid,$contact_id);
|
||||||
|
|
||||||
q("UPDATE `contact` SET `photo` = '%s',
|
q("UPDATE `contact` SET `photo` = '%s',
|
||||||
`thumb` = '%s',
|
`thumb` = '%s',
|
||||||
`micro` = '%s',
|
`micro` = '%s',
|
||||||
`name-date` = '%s',
|
`name-date` = '%s',
|
||||||
`uri-date` = '%s',
|
`uri-date` = '%s',
|
||||||
`avatar-date` = '%s'
|
`avatar-date` = '%s'
|
||||||
WHERE `id` = %d",
|
WHERE `id` = %d",
|
||||||
dbesc($photos[0]),
|
dbesc($photos[0]),
|
||||||
dbesc($photos[1]),
|
dbesc($photos[1]),
|
||||||
dbesc($photos[2]),
|
dbesc($photos[2]),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
intval($contact_id)
|
intval($contact_id)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// update profile photos once every 12 hours as we have no notification of when they change.
|
// update profile photos once every 12 hours as we have no notification of when they change.
|
||||||
$update_photo = ($r[0]['avatar-date'] < datetime_convert('','','now -12 hours'));
|
$update_photo = ($r[0]['avatar-date'] < datetime_convert('','','now -12 hours'));
|
||||||
|
|
||||||
// check that we have all the photos, this has been known to fail on occasion
|
// check that we have all the photos, this has been known to fail on occasion
|
||||||
if((! $r[0]['photo']) || (! $r[0]['thumb']) || (! $r[0]['micro']) || ($update_photo)) {
|
if((! $r[0]['photo']) || (! $r[0]['thumb']) || (! $r[0]['micro']) || ($update_photo)) {
|
||||||
|
|
||||||
logger("fbsync_fetch_contact: Updating contact ".$contact->username, LOGGER_DEBUG);
|
logger("fbsync_fetch_contact: Updating contact ".$contact->username, LOGGER_DEBUG);
|
||||||
|
|
||||||
require_once("Photo.php");
|
require_once("Photo.php");
|
||||||
|
|
||||||
$photos = import_profile_photo($avatarpicture, $uid, $r[0]['id']);
|
$photos = import_profile_photo($avatarpicture, $uid, $r[0]['id']);
|
||||||
|
|
||||||
q("UPDATE `contact` SET `photo` = '%s',
|
q("UPDATE `contact` SET `photo` = '%s',
|
||||||
`thumb` = '%s',
|
`thumb` = '%s',
|
||||||
`micro` = '%s',
|
`micro` = '%s',
|
||||||
`name-date` = '%s',
|
`name-date` = '%s',
|
||||||
`uri-date` = '%s',
|
`uri-date` = '%s',
|
||||||
`avatar-date` = '%s',
|
`avatar-date` = '%s',
|
||||||
`url` = '%s',
|
`url` = '%s',
|
||||||
`nurl` = '%s',
|
`nurl` = '%s',
|
||||||
`addr` = '%s',
|
`addr` = '%s',
|
||||||
`name` = '%s',
|
`name` = '%s',
|
||||||
`nick` = '%s'
|
`nick` = '%s',
|
||||||
WHERE `id` = %d",
|
`notify` = '%s'
|
||||||
dbesc($photos[0]),
|
WHERE `id` = %d",
|
||||||
dbesc($photos[1]),
|
dbesc($photos[0]),
|
||||||
dbesc($photos[2]),
|
dbesc($photos[1]),
|
||||||
dbesc(datetime_convert()),
|
dbesc($photos[2]),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc($contact->url),
|
dbesc(datetime_convert()),
|
||||||
dbesc(normalise_link($contact->url)),
|
dbesc($contact->url),
|
||||||
dbesc($contact->username."@facebook.com"),
|
dbesc(normalise_link($contact->url)),
|
||||||
dbesc($contact->name),
|
dbesc($contact->username."@facebook.com"),
|
||||||
dbesc($contact->username),
|
dbesc($contact->name),
|
||||||
intval($r[0]['id'])
|
dbesc($contact->username),
|
||||||
);
|
dbesc($contact->id),
|
||||||
}
|
intval($r[0]['id'])
|
||||||
}
|
);
|
||||||
return($r[0]["id"]);
|
}
|
||||||
|
}
|
||||||
|
return($r[0]["id"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fbsync_get_self($uid) {
|
function fbsync_get_self($uid) {
|
||||||
|
@ -854,9 +856,9 @@ function fbsync_fetchuser($a, $uid, $id) {
|
||||||
|
|
||||||
if (count($contact)) {
|
if (count($contact)) {
|
||||||
if (($contact[0]["readonly"] OR $contact[0]["blocked"])) {
|
if (($contact[0]["readonly"] OR $contact[0]["blocked"])) {
|
||||||
logger("fbsync_fetchuser: Contact '".$contact[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
|
logger("fbsync_fetchuser: Contact '".$contact[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
|
||||||
$user["contact-id"] = -1;
|
$user["contact-id"] = -1;
|
||||||
} else
|
} else
|
||||||
$user["contact-id"] = $contact[0]["id"];
|
$user["contact-id"] = $contact[0]["id"];
|
||||||
|
|
||||||
$user["name"] = $contact[0]["name"];
|
$user["name"] = $contact[0]["name"];
|
||||||
|
|
|
@ -34,11 +34,11 @@ function fromgplus_addon_settings(&$a,&$s) {
|
||||||
$account = get_pconfig(local_user(),'fromgplus','account');
|
$account = get_pconfig(local_user(),'fromgplus','account');
|
||||||
|
|
||||||
$s .= '<span id="settings_fromgplus_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_fromgplus_expanded\'); openClose(\'settings_fromgplus_inflated\');">';
|
$s .= '<span id="settings_fromgplus_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_fromgplus_expanded\'); openClose(\'settings_fromgplus_inflated\');">';
|
||||||
$s .= '<h3>' . t('Google+ Mirroring').'</h3>';
|
$s .= '<h3>' . t('Google+ Mirror').'</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
$s .= '<div id="settings_fromgplus_expanded" class="settings-block" style="display: none;">';
|
$s .= '<div id="settings_fromgplus_expanded" class="settings-block" style="display: none;">';
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_fromgplus_expanded\'); openClose(\'settings_fromgplus_inflated\');">';
|
$s .= '<span class="fakelink" onclick="openClose(\'settings_fromgplus_expanded\'); openClose(\'settings_fromgplus_inflated\');">';
|
||||||
$s .= '<h3>' . t('Google+ Mirroring').'</h3>';
|
$s .= '<h3>' . t('Google+ Mirror').'</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
|
|
||||||
$s .= '<div id="fromgplus-wrapper">';
|
$s .= '<div id="fromgplus-wrapper">';
|
||||||
|
@ -263,7 +263,7 @@ function fromgplus_handleattachments($item, $displaytext) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "article":
|
case "article":
|
||||||
$post .= "\n\n[class=type-link][bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]\n";
|
$post .= "\n[class=type-link][bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]\n";
|
||||||
|
|
||||||
$images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
|
$images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
|
||||||
//if ($images["preview"] != "")
|
//if ($images["preview"] != "")
|
||||||
|
|
|
@ -59,11 +59,11 @@ function gpluspost_settings(&$a,&$s) {
|
||||||
$skip_checked = (($skip_enabled) ? ' checked="checked" ' : '');
|
$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 .= '<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 .= '</span>';
|
||||||
$s .= '<div id="settings_gpluspost_expanded" class="settings-block" style="display: none;">';
|
$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 .= '<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 .= '</span>';
|
||||||
|
|
||||||
$s .= '<div id="gpluspost-enable-wrapper">';
|
$s .= '<div id="gpluspost-enable-wrapper">';
|
||||||
|
@ -214,70 +214,12 @@ function gpluspost_init() {
|
||||||
killme();
|
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) {
|
function gpluspost_feeditem($pid, $uid) {
|
||||||
global $a;
|
global $a;
|
||||||
|
|
||||||
require_once('include/bbcode.php');
|
require_once('include/bbcode.php');
|
||||||
require_once("include/html2plain.php");
|
require_once("include/html2plain.php");
|
||||||
|
require_once("include/network.php");
|
||||||
|
|
||||||
$skipwithoutlink = get_pconfig($uid,'gpluspost','skip_without_link');
|
$skipwithoutlink = get_pconfig($uid,'gpluspost','skip_without_link');
|
||||||
|
|
||||||
|
@ -365,7 +307,7 @@ function gpluspost_feeditem($pid, $uid) {
|
||||||
|
|
||||||
$title = trim(str_replace($msglink, "", $title));
|
$title = trim(str_replace($msglink, "", $title));
|
||||||
|
|
||||||
$msglink = gpluspost_original_url($msglink);
|
$msglink = original_url($msglink);
|
||||||
|
|
||||||
if ($uid == 0)
|
if ($uid == 0)
|
||||||
$title = $item["author-name"].": ".$title;
|
$title = $item["author-name"].": ".$title;
|
||||||
|
|
|
@ -64,11 +64,11 @@ function libertree_settings(&$a,&$s) {
|
||||||
/* Add some HTML to the existing form */
|
/* Add some HTML to the existing form */
|
||||||
|
|
||||||
$s .= '<span id="settings_libertree_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_libertree_expanded\'); openClose(\'settings_libertree_inflated\');">';
|
$s .= '<span id="settings_libertree_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_libertree_expanded\'); openClose(\'settings_libertree_inflated\');">';
|
||||||
$s .= '<h3>' . t('libertree') . '</h3>';
|
$s .= '<h3>' . t('libertree Export') . '</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
$s .= '<div id="settings_libertree_expanded" class="settings-block" style="display: none;">';
|
$s .= '<div id="settings_libertree_expanded" class="settings-block" style="display: none;">';
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_libertree_expanded\'); openClose(\'settings_libertree_inflated\');">';
|
$s .= '<span class="fakelink" onclick="openClose(\'settings_libertree_expanded\'); openClose(\'settings_libertree_inflated\');">';
|
||||||
$s .= '<h3>' . t('libertree') . '</h3>';
|
$s .= '<h3>' . t('libertree Export') . '</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
|
|
||||||
$s .= '<div id="libertree-enable-wrapper">';
|
$s .= '<div id="libertree-enable-wrapper">';
|
||||||
|
|
|
@ -288,11 +288,11 @@ function privacy_image_cache_img_cb($matches) {
|
||||||
|
|
||||||
// if the picture seems to be from another picture cache then take the original source
|
// if the picture seems to be from another picture cache then take the original source
|
||||||
$queryvar = privacy_image_cache_parse_query($matches[2]);
|
$queryvar = privacy_image_cache_parse_query($matches[2]);
|
||||||
if ($queryvar['url'] != "")
|
if (($queryvar['url'] != "") AND (substr($queryvar['url'], 0, 4) == "http"))
|
||||||
$matches[2] = urldecode($queryvar['url']);
|
$matches[2] = urldecode($queryvar['url']);
|
||||||
|
|
||||||
// if fetching facebook pictures don't fetch the thumbnail but the big one
|
// if fetching facebook pictures don't fetch the thumbnail but the big one
|
||||||
if (strpos($matches[2], ".fbcdn.net/") and (substr($matches[2], -6) == "_s.jpg"))
|
if (((strpos($matches[2], ".fbcdn.net/") OR strpos($matches[2], "/fbcdn-photos-"))) and (substr($matches[2], -6) == "_s.jpg"))
|
||||||
$matches[2] = substr($matches[2], 0, -6)."_n.jpg";
|
$matches[2] = substr($matches[2], 0, -6)."_n.jpg";
|
||||||
|
|
||||||
// following line changed per bug #431
|
// following line changed per bug #431
|
||||||
|
|
|
@ -219,11 +219,11 @@ function pumpio_settings(&$a,&$s) {
|
||||||
/* Add some HTML to the existing form */
|
/* Add some HTML to the existing form */
|
||||||
|
|
||||||
$s .= '<span id="settings_pumpio_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_pumpio_expanded\'); openClose(\'settings_pumpio_inflated\');">';
|
$s .= '<span id="settings_pumpio_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_pumpio_expanded\'); openClose(\'settings_pumpio_inflated\');">';
|
||||||
$s .= '<h3>' . t('Pump.io') . '</h3>';
|
$s .= '<h3>' . t('Pump.io Import/Export/Mirror') . '</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
$s .= '<div id="settings_pumpio_expanded" class="settings-block" style="display: none;">';
|
$s .= '<div id="settings_pumpio_expanded" class="settings-block" style="display: none;">';
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_pumpio_expanded\'); openClose(\'settings_pumpio_inflated\');">';
|
$s .= '<span class="fakelink" onclick="openClose(\'settings_pumpio_expanded\'); openClose(\'settings_pumpio_inflated\');">';
|
||||||
$s .= '<h3>' . t('Pump.io') . '</h3>';
|
$s .= '<h3>' . t('Pump.io Import/Export/Mirror') . '</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
|
|
||||||
$s .= '<div id="pumpio-username-wrapper">';
|
$s .= '<div id="pumpio-username-wrapper">';
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#statusnet-sendtaglinks-label,
|
#statusnet-sendtaglinks-label,
|
||||||
#statusnet-shortening-label,
|
#statusnet-shortening-label,
|
||||||
#statusnet-mirror-label,
|
#statusnet-mirror-label,
|
||||||
|
#statusnet-import-label,
|
||||||
|
#statusnet-create_user-label,
|
||||||
#statusnet-pin-label,
|
#statusnet-pin-label,
|
||||||
#statusnet-enable-label {
|
#statusnet-enable-label {
|
||||||
float: left;
|
float: left;
|
||||||
|
|
1449
statusnet/statusnet.php
Executable file → Normal file
1449
statusnet/statusnet.php
Executable file → Normal file
File diff suppressed because it is too large
Load diff
|
@ -182,11 +182,11 @@ function tumblr_settings(&$a,&$s) {
|
||||||
/* Add some HTML to the existing form */
|
/* Add some HTML to the existing form */
|
||||||
|
|
||||||
$s .= '<span id="settings_tumblr_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_tumblr_expanded\'); openClose(\'settings_tumblr_inflated\');">';
|
$s .= '<span id="settings_tumblr_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_tumblr_expanded\'); openClose(\'settings_tumblr_inflated\');">';
|
||||||
$s .= '<h3>' . t('Tumblr') . '</h3>';
|
$s .= '<h3>' . t('Tumblr Export') . '</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
$s .= '<div id="settings_tumblr_expanded" class="settings-block" style="display: none;">';
|
$s .= '<div id="settings_tumblr_expanded" class="settings-block" style="display: none;">';
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_tumblr_expanded\'); openClose(\'settings_tumblr_inflated\');">';
|
$s .= '<span class="fakelink" onclick="openClose(\'settings_tumblr_expanded\'); openClose(\'settings_tumblr_inflated\');">';
|
||||||
$s .= '<h3>' . t('Tumblr') . '</h3>';
|
$s .= '<h3>' . t('Tumblr Export') . '</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
|
|
||||||
$s .= '<div id="tumblr-username-wrapper">';
|
$s .= '<div id="tumblr-username-wrapper">';
|
||||||
|
|
|
@ -230,12 +230,14 @@ function twitter_settings(&$a,&$s) {
|
||||||
$create_userenabled = get_pconfig(local_user(),'twitter','create_user');
|
$create_userenabled = get_pconfig(local_user(),'twitter','create_user');
|
||||||
$create_userchecked = (($create_userenabled) ? ' checked="checked" ' : '');
|
$create_userchecked = (($create_userenabled) ? ' checked="checked" ' : '');
|
||||||
|
|
||||||
|
$globalshortening = get_config('twitter','intelligent_shortening');
|
||||||
|
|
||||||
$s .= '<span id="settings_twitter_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_twitter_expanded\'); openClose(\'settings_twitter_inflated\');">';
|
$s .= '<span id="settings_twitter_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_twitter_expanded\'); openClose(\'settings_twitter_inflated\');">';
|
||||||
$s .= '<h3>'. t('Twitter') .'</h3>';
|
$s .= '<h3>'. t('Twitter Import/Export/Mirror') .'</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
$s .= '<div id="settings_twitter_expanded" class="settings-block" style="display: none;">';
|
$s .= '<div id="settings_twitter_expanded" class="settings-block" style="display: none;">';
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_twitter_expanded\'); openClose(\'settings_twitter_inflated\');">';
|
$s .= '<span class="fakelink" onclick="openClose(\'settings_twitter_expanded\'); openClose(\'settings_twitter_inflated\');">';
|
||||||
$s .= '<h3>'. t('Twitter') .'</h3>';
|
$s .= '<h3>'. t('Twitter Import/Export/Mirror') .'</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
|
|
||||||
if ( (!$ckey) && (!$csecret) ) {
|
if ( (!$ckey) && (!$csecret) ) {
|
||||||
|
@ -296,13 +298,16 @@ function twitter_settings(&$a,&$s) {
|
||||||
$s .= '<input id="twitter-mirror" type="checkbox" name="twitter-mirror" value="1" '. $mirrorchecked . '/>';
|
$s .= '<input id="twitter-mirror" type="checkbox" name="twitter-mirror" value="1" '. $mirrorchecked . '/>';
|
||||||
$s .= '<div class="clear"></div>';
|
$s .= '<div class="clear"></div>';
|
||||||
|
|
||||||
$s .= '<label id="twitter-shortening-label" for="twitter-shortening">'.t('Shortening method that optimizes the tweet').'</label>';
|
if (!$globalshortening) {
|
||||||
$s .= '<input id="twitter-shortening" type="checkbox" name="twitter-shortening" value="1" '. $shorteningchecked . '/>';
|
$s .= '<label id="twitter-shortening-label" for="twitter-shortening">'.t('Shortening method that optimizes the tweet').'</label>';
|
||||||
$s .= '<div class="clear"></div>';
|
$s .= '<input id="twitter-shortening" type="checkbox" name="twitter-shortening" value="1" '. $shorteningchecked . '/>';
|
||||||
|
$s .= '<div class="clear"></div>';
|
||||||
|
|
||||||
$s .= '<label id="twitter-sendtaglinks-label" for="twitter-sendtaglinks">'.t('Send linked #-tags and @-names to Twitter').'</label>';
|
$s .= '<label id="twitter-sendtaglinks-label" for="twitter-sendtaglinks">'.t('Send linked #-tags and @-names to Twitter').'</label>';
|
||||||
$s .= '<input id="twitter-sendtaglinks" type="checkbox" name="twitter-sendtaglinks" value="1" '. $linkschecked . '/>';
|
$s .= '<input id="twitter-sendtaglinks" type="checkbox" name="twitter-sendtaglinks" value="1" '. $linkschecked . '/>';
|
||||||
$s .= '</div><div class="clear"></div>';
|
$s .= '<div class="clear"></div>';
|
||||||
|
}
|
||||||
|
$s .= '</div>';
|
||||||
|
|
||||||
$s .= '<label id="twitter-import-label" for="twitter-import">'.t('Import the remote timeline').'</label>';
|
$s .= '<label id="twitter-import-label" for="twitter-import">'.t('Import the remote timeline').'</label>';
|
||||||
$s .= '<input id="twitter-import" type="checkbox" name="twitter-import" value="1" '. $importchecked . '/>';
|
$s .= '<input id="twitter-import" type="checkbox" name="twitter-import" value="1" '. $importchecked . '/>';
|
||||||
|
@ -1006,7 +1011,6 @@ function twitter_fetchtimeline($a, $uid) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//$converted = twitter_convertmsg($a, $_REQUEST['body'], true, $has_picture);
|
|
||||||
$converted = twitter_expand_entities($a, $_REQUEST['body'], $post->retweeted_status, true, $has_picture);
|
$converted = twitter_expand_entities($a, $_REQUEST['body'], $post->retweeted_status, true, $has_picture);
|
||||||
$_REQUEST['body'] = $converted["body"];
|
$_REQUEST['body'] = $converted["body"];
|
||||||
|
|
||||||
|
@ -1030,7 +1034,6 @@ function twitter_fetchtimeline($a, $uid) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//$converted = twitter_convertmsg($a, $_REQUEST["body"], true, $has_picture);
|
|
||||||
$converted = twitter_expand_entities($a, $_REQUEST["body"], $post, true, $has_picture);
|
$converted = twitter_expand_entities($a, $_REQUEST["body"], $post, true, $has_picture);
|
||||||
$_REQUEST['body'] = $converted["body"];
|
$_REQUEST['body'] = $converted["body"];
|
||||||
}
|
}
|
||||||
|
@ -1305,6 +1308,7 @@ function twitter_fetchuser($a, $uid, $screen_name = "", $user_id = "") {
|
||||||
|
|
||||||
function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontincludemedia) {
|
function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontincludemedia) {
|
||||||
require_once("include/oembed.php");
|
require_once("include/oembed.php");
|
||||||
|
require_once("include/network.php");
|
||||||
|
|
||||||
$tags = "";
|
$tags = "";
|
||||||
|
|
||||||
|
@ -1317,7 +1321,7 @@ function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontinclud
|
||||||
foreach ($item->entities->urls AS $url) {
|
foreach ($item->entities->urls AS $url) {
|
||||||
if ($url->url AND $url->expanded_url AND $url->display_url) {
|
if ($url->url AND $url->expanded_url AND $url->display_url) {
|
||||||
|
|
||||||
$expanded_url = twitter_original_url($url->expanded_url);
|
$expanded_url = original_url($url->expanded_url);
|
||||||
|
|
||||||
$oembed_data = oembed_fetch_url($expanded_url);
|
$oembed_data = oembed_fetch_url($expanded_url);
|
||||||
|
|
||||||
|
@ -1341,7 +1345,6 @@ function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontinclud
|
||||||
$body = str_replace($url->url,
|
$body = str_replace($url->url,
|
||||||
"[url=".$expanded_url."]".$expanded_url."[/url]",
|
"[url=".$expanded_url."]".$expanded_url."[/url]",
|
||||||
$body);
|
$body);
|
||||||
//"[url=".$expanded_url."]".$url->display_url."[/url]",
|
|
||||||
else {
|
else {
|
||||||
$img_str = fetch_url($expanded_url, true, $redirects, 4);
|
$img_str = fetch_url($expanded_url, true, $redirects, 4);
|
||||||
|
|
||||||
|
@ -1358,7 +1361,6 @@ function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontinclud
|
||||||
$type = $oembed_data->type;
|
$type = $oembed_data->type;
|
||||||
$footerurl = $expanded_url;
|
$footerurl = $expanded_url;
|
||||||
$footerlink = "[url=".$expanded_url."]".$expanded_url."[/url]";
|
$footerlink = "[url=".$expanded_url."]".$expanded_url."[/url]";
|
||||||
//$footerlink = "[url=".$expanded_url."]".$url->display_url."[/url]";
|
|
||||||
|
|
||||||
$body = str_replace($url->url, $footerlink, $body);
|
$body = str_replace($url->url, $footerlink, $body);
|
||||||
}
|
}
|
||||||
|
@ -1367,7 +1369,7 @@ function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontinclud
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($footerurl != "")
|
if ($footerurl != "")
|
||||||
$footer = twitter_siteinfo($footerurl, $dontincludemedia);
|
$footer = add_page_info($footerurl);
|
||||||
|
|
||||||
if (($footerlink != "") AND (trim($footer) != "")) {
|
if (($footerlink != "") AND (trim($footer) != "")) {
|
||||||
$removedlink = trim(str_replace($footerlink, "", $body));
|
$removedlink = trim(str_replace($footerlink, "", $body));
|
||||||
|
@ -1375,7 +1377,7 @@ function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontinclud
|
||||||
if (strstr($body, $removedlink))
|
if (strstr($body, $removedlink))
|
||||||
$body = $removedlink;
|
$body = $removedlink;
|
||||||
|
|
||||||
$body .= "\n\n[class=type-".$type."]".$footer."[/class]";
|
$body .= $footer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($no_tags)
|
if ($no_tags)
|
||||||
|
@ -1546,7 +1548,6 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//$converted = twitter_convertmsg($a, $postarray['body'], false, $has_picture);
|
|
||||||
$converted = twitter_expand_entities($a, $postarray['body'], $post, false, $has_picture);
|
$converted = twitter_expand_entities($a, $postarray['body'], $post, false, $has_picture);
|
||||||
$postarray['body'] = $converted["body"];
|
$postarray['body'] = $converted["body"];
|
||||||
$postarray['tag'] = $converted["tags"];
|
$postarray['tag'] = $converted["tags"];
|
||||||
|
@ -1584,7 +1585,6 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//$converted = twitter_convertmsg($a, $postarray['body'], false, $has_picture);
|
|
||||||
$converted = twitter_expand_entities($a, $postarray['body'], $post->retweeted_status, false, $has_picture);
|
$converted = twitter_expand_entities($a, $postarray['body'], $post->retweeted_status, false, $has_picture);
|
||||||
$postarray['body'] = $converted["body"];
|
$postarray['body'] = $converted["body"];
|
||||||
$postarray['tag'] = $converted["tags"];
|
$postarray['tag'] = $converted["tags"];
|
||||||
|
@ -1839,213 +1839,6 @@ function twitter_fetchhometimeline($a, $uid) {
|
||||||
set_pconfig($uid, 'twitter', 'lastmentionid', $lastid);
|
set_pconfig($uid, 'twitter', 'lastmentionid', $lastid);
|
||||||
}
|
}
|
||||||
|
|
||||||
function twitter_original_url($url, $depth=1, $fetchbody = false) {
|
|
||||||
if ($depth > 10)
|
|
||||||
return($url);
|
|
||||||
|
|
||||||
$siteinfo = array();
|
|
||||||
$ch = curl_init();
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
|
||||||
curl_setopt($ch, CURLOPT_HEADER, 1);
|
|
||||||
|
|
||||||
if ($fetchbody)
|
|
||||||
curl_setopt($ch, CURLOPT_NOBODY, 0);
|
|
||||||
else
|
|
||||||
curl_setopt($ch, CURLOPT_NOBODY, 1);
|
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
|
||||||
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(twitter_original_url($curl_info['redirect_url'], ++$depth, $fetchbody));
|
|
||||||
else
|
|
||||||
return(twitter_original_url($curl_info['location'], ++$depth, $fetchbody));
|
|
||||||
}
|
|
||||||
|
|
||||||
$pos = strpos($header, "\r\n\r\n");
|
|
||||||
|
|
||||||
if ($pos)
|
|
||||||
$body = trim(substr($header, $pos));
|
|
||||||
else
|
|
||||||
$body = $header;
|
|
||||||
|
|
||||||
if (trim($body) == "")
|
|
||||||
return(twitter_original_url($url, ++$depth, true));
|
|
||||||
|
|
||||||
$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(twitter_original_url(substr($value, 4), ++$depth));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return($url);
|
|
||||||
}
|
|
||||||
|
|
||||||
function twitter_siteinfo($url, $dontincludemedia) {
|
|
||||||
require_once("mod/parse_url.php");
|
|
||||||
|
|
||||||
// Fetch site infos - but only from the meta data
|
|
||||||
$data = parseurl_getsiteinfo($url, true);
|
|
||||||
|
|
||||||
if ($dontincludemedia)
|
|
||||||
unset($data["images"]);
|
|
||||||
|
|
||||||
if (!is_string($data["text"]) AND (sizeof($data["images"]) == 0) AND ($data["title"] == $url))
|
|
||||||
return("");
|
|
||||||
|
|
||||||
if (is_string($data["title"]))
|
|
||||||
$text .= "[bookmark=".$url."]".trim($data["title"])."[/bookmark]\n";
|
|
||||||
|
|
||||||
// Add a spoiler to the extra information
|
|
||||||
//if ((sizeof($data["images"]) > 0) OR is_string($data["text"]))
|
|
||||||
// $text .= "[spoiler]";
|
|
||||||
|
|
||||||
if (sizeof($data["images"]) > 0) {
|
|
||||||
$imagedata = $data["images"][0];
|
|
||||||
//$text .= '[img='.$imagedata["width"].'x'.$imagedata["height"].']'.$imagedata["src"].'[/img]' . "\n";
|
|
||||||
$text .= '[img]'.$imagedata["src"].'[/img]'."\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_string($data["text"]))
|
|
||||||
$text .= "[quote]".$data["text"]."[/quote]";
|
|
||||||
|
|
||||||
//if ((sizeof($data["images"]) > 0) OR is_string($data["text"]))
|
|
||||||
// $text .= "[/spoiler]";
|
|
||||||
|
|
||||||
return($text);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function twitter_convertmsg($a, $body, $no_tags = false, $dontincludemedia) {
|
|
||||||
|
|
||||||
require_once("include/oembed.php");
|
|
||||||
|
|
||||||
$links = preg_match_all("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", $body,$matches,PREG_SET_ORDER);
|
|
||||||
|
|
||||||
$footer = "";
|
|
||||||
$footerurl = "";
|
|
||||||
$type = "";
|
|
||||||
|
|
||||||
if ($links) {
|
|
||||||
foreach ($matches AS $match) {
|
|
||||||
$expanded_url = twitter_original_url($match[2]);
|
|
||||||
|
|
||||||
$oembed_data = oembed_fetch_url($expanded_url);
|
|
||||||
|
|
||||||
if ($type == "")
|
|
||||||
$type = $oembed_data->type;
|
|
||||||
|
|
||||||
if ($oembed_data->type != "link")
|
|
||||||
$body = str_replace($match[2], "\n[url]".$expanded_url."[/url]\n", $body);
|
|
||||||
else {
|
|
||||||
$img_str = fetch_url($expanded_url, true, $redirects, 4);
|
|
||||||
|
|
||||||
$tempfile = tempnam(get_config("system","temppath"), "cache");
|
|
||||||
file_put_contents($tempfile, $img_str);
|
|
||||||
$mime = image_type_to_mime_type(exif_imagetype($tempfile));
|
|
||||||
unlink($tempfile);
|
|
||||||
|
|
||||||
if (substr($mime, 0, 6) == "image/") {
|
|
||||||
$type = "photo";
|
|
||||||
$body = str_replace($match[2], "[img]".$expanded_url."[/img]", $body);
|
|
||||||
$dontincludemedia = true;
|
|
||||||
} else {
|
|
||||||
$type = $oembed_data->type;
|
|
||||||
$footerurl = $expanded_url;
|
|
||||||
$footerlink = "[url=".$expanded_url."]".$expanded_url."[/url]";
|
|
||||||
|
|
||||||
$body = str_replace($match[2], $footerlink, $body);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($footerurl != "")
|
|
||||||
$footer = twitter_siteinfo($footerurl, $dontincludemedia);
|
|
||||||
|
|
||||||
if (($footerlink != "") AND (trim($footer) != "")) {
|
|
||||||
$removedlink = trim(str_replace($footerlink, "", $body));
|
|
||||||
|
|
||||||
if (strstr($body, $removedlink))
|
|
||||||
$body = $removedlink;
|
|
||||||
|
|
||||||
$body .= "\n\n[class=type-".$type."]".$footer."[/class]";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($no_tags)
|
|
||||||
return(array("body" => $body, "tags" => ""));
|
|
||||||
|
|
||||||
$str_tags = '';
|
|
||||||
|
|
||||||
$tags = get_tags($body);
|
|
||||||
|
|
||||||
if(count($tags)) {
|
|
||||||
foreach($tags as $tag) {
|
|
||||||
if (strstr(trim($tag), " "))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(strpos($tag,'#') === 0) {
|
|
||||||
if(strpos($tag,'[url='))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// don't link tags that are already embedded in links
|
|
||||||
|
|
||||||
if(preg_match('/\[(.*?)' . preg_quote($tag,'/') . '(.*?)\]/',$body))
|
|
||||||
continue;
|
|
||||||
if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag,'/') . '(.*?)\)/',$body))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
$basetag = str_replace('_',' ',substr($tag,1));
|
|
||||||
$body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
|
|
||||||
if(strlen($str_tags))
|
|
||||||
$str_tags .= ',';
|
|
||||||
$str_tags .= '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
|
|
||||||
continue;
|
|
||||||
} elseif(strpos($tag,'@') === 0) {
|
|
||||||
$basetag = substr($tag,1);
|
|
||||||
$body = str_replace($tag,'@[url=https://twitter.com/' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$cnt = preg_match_all('/@\[url=(.*?)\[\/url\]/ism',$body,$matches,PREG_SET_ORDER);
|
|
||||||
if($cnt) {
|
|
||||||
foreach($matches as $mtch) {
|
|
||||||
if(strlen($str_tags))
|
|
||||||
$str_tags .= ',';
|
|
||||||
$str_tags .= '@[url=' . $mtch[1] . '[/url]';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return(array("body"=>$body, "tags"=>$str_tags));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function twitter_fetch_own_contact($a, $uid) {
|
function twitter_fetch_own_contact($a, $uid) {
|
||||||
$ckey = get_config('twitter', 'consumerkey');
|
$ckey = get_config('twitter', 'consumerkey');
|
||||||
$csecret = get_config('twitter', 'consumersecret');
|
$csecret = get_config('twitter', 'consumersecret');
|
||||||
|
|
|
@ -73,11 +73,11 @@ function wppost_settings(&$a,&$s) {
|
||||||
/* Add some HTML to the existing form */
|
/* Add some HTML to the existing form */
|
||||||
|
|
||||||
$s .= '<span id="settings_wppost_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_wppost_expanded\'); openClose(\'settings_wppost_inflated\');">';
|
$s .= '<span id="settings_wppost_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_wppost_expanded\'); openClose(\'settings_wppost_inflated\');">';
|
||||||
$s .= '<h3>' . t('WordPress') . '</h3>';
|
$s .= '<h3>' . t('WordPress Export') . '</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
$s .= '<div id="settings_wppost_expanded" class="settings-block" style="display: none;">';
|
$s .= '<div id="settings_wppost_expanded" class="settings-block" style="display: none;">';
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_wppost_expanded\'); openClose(\'settings_wppost_inflated\');">';
|
$s .= '<span class="fakelink" onclick="openClose(\'settings_wppost_expanded\'); openClose(\'settings_wppost_inflated\');">';
|
||||||
$s .= '<h3>' . t('WordPress') . '</h3>';
|
$s .= '<h3>' . t('WordPress Export') . '</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
$s .= '<div id="wppost-enable-wrapper">';
|
$s .= '<div id="wppost-enable-wrapper">';
|
||||||
$s .= '<label id="wppost-enable-label" for="wppost-checkbox">' . t('Enable WordPress Post Plugin') . '</label>';
|
$s .= '<label id="wppost-enable-label" for="wppost-checkbox">' . t('Enable WordPress Post Plugin') . '</label>';
|
||||||
|
|
Loading…
Reference in a new issue