mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-12-23 01:40:15 +00:00
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
16 changed files with 1398 additions and 798 deletions
|
@ -53,11 +53,11 @@ function appnetpost_settings(&$a,&$s) {
|
|||
$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 .= '<h3>' . t('App.net') . '</h3>';
|
||||
$s .= '<h3>' . t('App.net Export') . '</h3>';
|
||||
$s .= '</span>';
|
||||
$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 .= '<h3>' . t('App.net') . '</h3>';
|
||||
$s .= '<h3>' . t('App.net Export') . '</h3>';
|
||||
$s .= '</span>';
|
||||
|
||||
$s .= '<div id="appnetpost-enable-wrapper">';
|
||||
|
@ -196,65 +196,6 @@ function appnetpost_init() {
|
|||
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' )) {
|
||||
function short_link($url) {
|
||||
require_once('library/slinky.php');
|
||||
|
@ -387,7 +328,7 @@ function appnetpost_feeditem($pid, $uid) {
|
|||
if ($title == "")
|
||||
continue;
|
||||
|
||||
//$origlink = appnetpost_original_url($origlink);
|
||||
//$origlink = original_url($origlink);
|
||||
|
||||
$html = nl2br($title);
|
||||
|
||||
|
|
|
@ -71,11 +71,11 @@ function blogger_settings(&$a,&$s) {
|
|||
/* 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 .= '<h3>' . t('Blogger') . '</h3>';
|
||||
$s .= '<h3>' . t('Blogger Export') . '</h3>';
|
||||
$s .= '</span>';
|
||||
$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 .= '<h3>' . t('Blogger') . '</h3>';
|
||||
$s .= '<h3>' . t('Blogger Export') . '</h3>';
|
||||
$s .= '</span>';
|
||||
|
||||
$s .= '<div id="blogger-enable-wrapper">';
|
||||
|
|
|
@ -61,11 +61,12 @@ class Diasphp {
|
|||
return $this;
|
||||
}
|
||||
|
||||
function post($text) {
|
||||
function post($text, $provider = "diasphp") {
|
||||
// post-daten vorbereiten
|
||||
$datatopost = json_encode(array(
|
||||
'aspect_ids' => 'public',
|
||||
'status_message' => array('text' => $text)
|
||||
'status_message' => array('text' => $text,
|
||||
'provider_display_name' => $provider)
|
||||
));
|
||||
|
||||
// header vorbereiten
|
||||
|
|
|
@ -39,6 +39,8 @@ function diaspora_jot_nets(&$a,&$b) {
|
|||
}
|
||||
|
||||
function diaspora_queue_hook(&$a,&$b) {
|
||||
$hostname = $a->get_hostname();
|
||||
|
||||
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
|
||||
dbesc(NETWORK_DIASPORA2)
|
||||
);
|
||||
|
@ -85,7 +87,7 @@ function diaspora_queue_hook(&$a,&$b) {
|
|||
logger('diaspora_queue: try to log in '.$diaspora_username, LOGGER_DEBUG);
|
||||
$conn->login($diaspora_username, $diaspora_password);
|
||||
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);
|
||||
|
||||
|
@ -144,11 +146,11 @@ function diaspora_settings(&$a,&$s) {
|
|||
/* 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 .= '<h3>' . t('Diaspora') . '</h3>';
|
||||
$s .= '<h3>' . t('Diaspora Export') . '</h3>';
|
||||
$s .= '</span>';
|
||||
$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 .= '<h3>' . t('Diaspora') . '</h3>';
|
||||
$s .= '<h3>' . t('Diaspora Export') . '</h3>';
|
||||
$s .= '</span>';
|
||||
|
||||
if ($status) {
|
||||
|
@ -233,6 +235,7 @@ function diaspora_post_local(&$a,&$b) {
|
|||
|
||||
|
||||
function diaspora_send(&$a,&$b) {
|
||||
$hostname = $a->get_hostname();
|
||||
|
||||
logger('diaspora_send: invoked');
|
||||
|
||||
|
@ -303,7 +306,7 @@ function diaspora_send(&$a,&$b) {
|
|||
logger('diaspora_send: try to send '.$body, LOGGER_DEBUG);
|
||||
|
||||
//throw new Exception('Test');
|
||||
$conn->post($body);
|
||||
$conn->post($body, $hostname);
|
||||
|
||||
logger('diaspora_send: success');
|
||||
} catch (Exception $e) {
|
||||
|
|
|
@ -96,7 +96,7 @@ function fbpost_init(&$a) {
|
|||
|
||||
if(strpos($x,'access_token=') !== false) {
|
||||
$token = str_replace('access_token=', '', $x);
|
||||
if(strpos($token,'&') !== false)
|
||||
if(strpos($token,'&') !== false)
|
||||
$token = substr($token,0,strpos($token,'&'));
|
||||
set_pconfig($uid,'facebook','access_token',$token);
|
||||
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->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) {
|
||||
$o .= '<div id="fbpost-enable-wrapper">';
|
||||
|
@ -293,7 +293,7 @@ function fbpost_content(&$a) {
|
|||
function fbpost_plugin_settings(&$a,&$b) {
|
||||
|
||||
$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>';
|
||||
|
||||
}
|
||||
|
@ -571,6 +571,7 @@ function fbpost_post_hook(&$a,&$b) {
|
|||
|
||||
$allow_str = dbesc(implode(', ',$recipients));
|
||||
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'");
|
||||
if(count($r))
|
||||
foreach($r as $rr)
|
||||
|
@ -633,22 +634,32 @@ function fbpost_post_hook(&$a,&$b) {
|
|||
|
||||
logger('fbpost_post_hook: original msg=' . $msg, LOGGER_DATA);
|
||||
|
||||
// To-Do: if it is a reply, then only do a simple bbcode2plain conversion
|
||||
$msgarr = fbpost_createmsg($b);
|
||||
$msg = $msgarr["msg"];
|
||||
$link = $msgarr["link"];
|
||||
$image = $msgarr["image"];
|
||||
$linkname = $msgarr["linkname"];
|
||||
if ($toplevel) {
|
||||
$msgarr = fbpost_createmsg($b);
|
||||
$msg = $msgarr["msg"];
|
||||
$link = $msgarr["link"];
|
||||
$image = $msgarr["image"];
|
||||
$linkname = $msgarr["linkname"];
|
||||
|
||||
// Fallback - if message is empty
|
||||
if(!strlen($msg))
|
||||
$msg = $linkname;
|
||||
// Fallback - if message is empty
|
||||
if(!strlen($msg))
|
||||
$msg = $linkname;
|
||||
|
||||
if(!strlen($msg))
|
||||
$msg = $link;
|
||||
if(!strlen($msg))
|
||||
$msg = $link;
|
||||
|
||||
if(!strlen($msg))
|
||||
$msg = $image;
|
||||
if(!strlen($msg))
|
||||
$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(!strlen($msg))
|
||||
|
@ -962,7 +973,7 @@ function fbpost_get_app_access_token() {
|
|||
logger('fb_get_app_access_token: returned access token: ' . $x, LOGGER_DATA);
|
||||
|
||||
$token = str_replace('access_token=', '', $x);
|
||||
if(strpos($token,'&') !== false)
|
||||
if(strpos($token,'&') !== false)
|
||||
$token = substr($token,0,strpos($token,'&'));
|
||||
|
||||
if ($token == "") {
|
||||
|
@ -1105,7 +1116,7 @@ function fbpost_fetchwall($a, $uid) {
|
|||
}
|
||||
|
||||
if ($content)
|
||||
$_REQUEST["body"] .= "\n\n";
|
||||
$_REQUEST["body"] .= "\n";
|
||||
|
||||
if ($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());
|
||||
}
|
||||
|
@ -322,7 +322,7 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
|
|||
}
|
||||
|
||||
if ($content)
|
||||
$postarray["body"] .= "\n\n";
|
||||
$postarray["body"] .= "\n";
|
||||
|
||||
if ($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
|
||||
if ($parent_contact > 0) {
|
||||
$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
|
||||
if(!count($r)) {
|
||||
logger("fbsync_createcomment: UID ".$uid." - Contact ".$parent_contact." doesn't seem to exist.", LOGGER_DEBUG);
|
||||
return;
|
||||
if(!count($r)) {
|
||||
logger("fbsync_createcomment: UID ".$uid." - Contact ".$parent_contact." doesn't seem to exist.", LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
|
||||
// Is blocked? Then return
|
||||
if ($r[0]["readonly"] OR $r[0]["blocked"]) {
|
||||
logger("fbsync_createcomment: UID ".$uid." - Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
|
||||
return;
|
||||
if ($r[0]["readonly"] OR $r[0]["blocked"]) {
|
||||
logger("fbsync_createcomment: UID ".$uid." - Contact '".$r[0]["nick"]."' is blocked or readonly.", LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
|
||||
$parent_nick = $r[0]["nick"];
|
||||
|
@ -522,8 +522,8 @@ function fbsync_createcomment($a, $uid, $self_id, $self, $user, $contacts, $appl
|
|||
if(count($myconv)) {
|
||||
$importer_url = $a->get_baseurl() . '/profile/' . $user[0]['nickname'];
|
||||
|
||||
$own_contact = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||
intval($uid), dbesc("facebook::".$self_id));
|
||||
$own_contact = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||
intval($uid), dbesc("facebook::".$self_id));
|
||||
|
||||
if (!count($own_contact))
|
||||
return;
|
||||
|
@ -570,8 +570,8 @@ function fbsync_createlike($a, $uid, $self_id, $self, $contacts, $like) {
|
|||
intval($uid)
|
||||
);
|
||||
|
||||
if (count($r))
|
||||
$orig_post = $r[0];
|
||||
if (count($r))
|
||||
$orig_post = $r[0];
|
||||
else
|
||||
return;
|
||||
|
||||
|
@ -597,15 +597,15 @@ function fbsync_createlike($a, $uid, $self_id, $self, $contacts, $like) {
|
|||
$contact_id = $self[0]["id"];
|
||||
|
||||
$likedata = array();
|
||||
$likedata['parent'] = $orig_post['id'];
|
||||
$likedata['verb'] = ACTIVITY_LIKE;
|
||||
$likedata['parent'] = $orig_post['id'];
|
||||
$likedata['verb'] = ACTIVITY_LIKE;
|
||||
$likedate['network'] = dbesc(NETWORK_FACEBOOK);
|
||||
$likedata['gravity'] = 3;
|
||||
$likedata['uid'] = $uid;
|
||||
$likedata['wall'] = 0;
|
||||
$likedata['uri'] = item_new_uri($a->get_baseurl(), $uid);
|
||||
$likedata['parent-uri'] = $orig_post["uri"];
|
||||
$likedata['app'] = "Facebook";
|
||||
$likedata['gravity'] = 3;
|
||||
$likedata['uid'] = $uid;
|
||||
$likedata['wall'] = 0;
|
||||
$likedata['uri'] = item_new_uri($a->get_baseurl(), $uid);
|
||||
$likedata['parent-uri'] = $orig_post["uri"];
|
||||
$likedata['app'] = "Facebook";
|
||||
|
||||
if ($like->user_id != $self_id) {
|
||||
$likedata['contact-id'] = $contact_id;
|
||||
|
@ -625,12 +625,12 @@ function fbsync_createlike($a, $uid, $self_id, $self, $contacts, $like) {
|
|||
$post_type = t('status');
|
||||
|
||||
$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>' .
|
||||
'<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>';
|
||||
$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>';
|
||||
|
||||
|
||||
$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)
|
||||
);
|
||||
|
||||
if (count($r))
|
||||
if (count($r))
|
||||
return;
|
||||
|
||||
$item = item_store($likedata);
|
||||
|
@ -657,131 +657,133 @@ function fbsync_fetch_contact($uid, $contact, $create_user) {
|
|||
if (count($r) == 0)
|
||||
q("INSERT INTO unique_contacts (url, name, nick, avatar) VALUES ('%s', '%s', '%s', '%s')",
|
||||
dbesc(normalise_link($contact->url)),
|
||||
dbesc($contact->name),
|
||||
dbesc($contact->username),
|
||||
dbesc($contact->name),
|
||||
dbesc($contact->username),
|
||||
dbesc($contact->pic_square));
|
||||
else
|
||||
q("UPDATE unique_contacts SET name = '%s', nick = '%s', avatar = '%s' WHERE url = '%s'",
|
||||
dbesc($contact->name),
|
||||
dbesc($contact->username),
|
||||
dbesc($contact->name),
|
||||
dbesc($contact->username),
|
||||
dbesc($contact->pic_square),
|
||||
dbesc(normalise_link($contact->url)));
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||
intval($uid), dbesc("facebook::".$contact->id));
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||
intval($uid), dbesc("facebook::".$contact->id));
|
||||
|
||||
if(!count($r) AND !$create_user)
|
||||
return(0);
|
||||
if(!count($r) AND !$create_user)
|
||||
return(0);
|
||||
|
||||
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);
|
||||
return(-1);
|
||||
}
|
||||
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);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
$avatarpicture = $contact->pic_square;
|
||||
|
||||
if(!count($r)) {
|
||||
// create contact record
|
||||
q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
|
||||
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
|
||||
`writable`, `blocked`, `readonly`, `pending`)
|
||||
VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0)",
|
||||
intval($uid),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($contact->url),
|
||||
dbesc(normalise_link($contact->url)),
|
||||
dbesc($contact->username."@facebook.com"),
|
||||
dbesc("facebook::".$contact->id),
|
||||
dbesc(''),
|
||||
dbesc("facebook::".$contact->id),
|
||||
dbesc($contact->name),
|
||||
dbesc($contact->username),
|
||||
dbesc($avatarpicture),
|
||||
dbesc(NETWORK_FACEBOOK),
|
||||
intval(CONTACT_IS_FRIEND),
|
||||
intval(1),
|
||||
intval(1)
|
||||
);
|
||||
if(!count($r)) {
|
||||
// create contact record
|
||||
q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,
|
||||
`name`, `nick`, `photo`, `network`, `rel`, `priority`,
|
||||
`writable`, `blocked`, `readonly`, `pending`)
|
||||
VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0)",
|
||||
intval($uid),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($contact->url),
|
||||
dbesc(normalise_link($contact->url)),
|
||||
dbesc($contact->username."@facebook.com"),
|
||||
dbesc("facebook::".$contact->id),
|
||||
dbesc($contact->id),
|
||||
dbesc("facebook::".$contact->id),
|
||||
dbesc($contact->name),
|
||||
dbesc($contact->username),
|
||||
dbesc($avatarpicture),
|
||||
dbesc(NETWORK_FACEBOOK),
|
||||
intval(CONTACT_IS_FRIEND),
|
||||
intval(1),
|
||||
intval(1)
|
||||
);
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE `alias` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc("facebook::".$contact->id),
|
||||
intval($uid)
|
||||
);
|
||||
$r = q("SELECT * FROM `contact` WHERE `alias` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc("facebook::".$contact->id),
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
if(! count($r))
|
||||
return(false);
|
||||
if(! count($r))
|
||||
return(false);
|
||||
|
||||
$contact_id = $r[0]['id'];
|
||||
$contact_id = $r[0]['id'];
|
||||
|
||||
$g = q("SELECT def_gid FROM user WHERE uid = %d LIMIT 1",
|
||||
intval($uid)
|
||||
);
|
||||
$g = q("SELECT def_gid FROM user WHERE uid = %d LIMIT 1",
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
if($g && intval($g[0]['def_gid'])) {
|
||||
require_once('include/group.php');
|
||||
group_add_member($uid,'',$contact_id,$g[0]['def_gid']);
|
||||
}
|
||||
if($g && intval($g[0]['def_gid'])) {
|
||||
require_once('include/group.php');
|
||||
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',
|
||||
`thumb` = '%s',
|
||||
`micro` = '%s',
|
||||
`name-date` = '%s',
|
||||
`uri-date` = '%s',
|
||||
`avatar-date` = '%s'
|
||||
WHERE `id` = %d",
|
||||
dbesc($photos[0]),
|
||||
dbesc($photos[1]),
|
||||
dbesc($photos[2]),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
intval($contact_id)
|
||||
);
|
||||
} else {
|
||||
// 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'));
|
||||
q("UPDATE `contact` SET `photo` = '%s',
|
||||
`thumb` = '%s',
|
||||
`micro` = '%s',
|
||||
`name-date` = '%s',
|
||||
`uri-date` = '%s',
|
||||
`avatar-date` = '%s'
|
||||
WHERE `id` = %d",
|
||||
dbesc($photos[0]),
|
||||
dbesc($photos[1]),
|
||||
dbesc($photos[2]),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
intval($contact_id)
|
||||
);
|
||||
} else {
|
||||
// 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'));
|
||||
|
||||
// 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)) {
|
||||
// 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)) {
|
||||
|
||||
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',
|
||||
`thumb` = '%s',
|
||||
`micro` = '%s',
|
||||
`name-date` = '%s',
|
||||
`uri-date` = '%s',
|
||||
`avatar-date` = '%s',
|
||||
`url` = '%s',
|
||||
`nurl` = '%s',
|
||||
`addr` = '%s',
|
||||
`name` = '%s',
|
||||
`nick` = '%s'
|
||||
WHERE `id` = %d",
|
||||
dbesc($photos[0]),
|
||||
dbesc($photos[1]),
|
||||
dbesc($photos[2]),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($contact->url),
|
||||
dbesc(normalise_link($contact->url)),
|
||||
dbesc($contact->username."@facebook.com"),
|
||||
dbesc($contact->name),
|
||||
dbesc($contact->username),
|
||||
intval($r[0]['id'])
|
||||
);
|
||||
}
|
||||
}
|
||||
return($r[0]["id"]);
|
||||
q("UPDATE `contact` SET `photo` = '%s',
|
||||
`thumb` = '%s',
|
||||
`micro` = '%s',
|
||||
`name-date` = '%s',
|
||||
`uri-date` = '%s',
|
||||
`avatar-date` = '%s',
|
||||
`url` = '%s',
|
||||
`nurl` = '%s',
|
||||
`addr` = '%s',
|
||||
`name` = '%s',
|
||||
`nick` = '%s',
|
||||
`notify` = '%s'
|
||||
WHERE `id` = %d",
|
||||
dbesc($photos[0]),
|
||||
dbesc($photos[1]),
|
||||
dbesc($photos[2]),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($contact->url),
|
||||
dbesc(normalise_link($contact->url)),
|
||||
dbesc($contact->username."@facebook.com"),
|
||||
dbesc($contact->name),
|
||||
dbesc($contact->username),
|
||||
dbesc($contact->id),
|
||||
intval($r[0]['id'])
|
||||
);
|
||||
}
|
||||
}
|
||||
return($r[0]["id"]);
|
||||
}
|
||||
|
||||
function fbsync_get_self($uid) {
|
||||
|
@ -854,9 +856,9 @@ function fbsync_fetchuser($a, $uid, $id) {
|
|||
|
||||
if (count($contact)) {
|
||||
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;
|
||||
} else
|
||||
} else
|
||||
$user["contact-id"] = $contact[0]["id"];
|
||||
|
||||
$user["name"] = $contact[0]["name"];
|
||||
|
|
|
@ -34,11 +34,11 @@ function fromgplus_addon_settings(&$a,&$s) {
|
|||
$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 .= '<h3>' . t('Google+ Mirroring').'</h3>';
|
||||
$s .= '<h3>' . t('Google+ Mirror').'</h3>';
|
||||
$s .= '</span>';
|
||||
$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 .= '<h3>' . t('Google+ Mirroring').'</h3>';
|
||||
$s .= '<h3>' . t('Google+ Mirror').'</h3>';
|
||||
$s .= '</span>';
|
||||
|
||||
$s .= '<div id="fromgplus-wrapper">';
|
||||
|
@ -263,7 +263,7 @@ function fromgplus_handleattachments($item, $displaytext) {
|
|||
break;
|
||||
|
||||
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);
|
||||
//if ($images["preview"] != "")
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -64,11 +64,11 @@ function libertree_settings(&$a,&$s) {
|
|||
/* 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 .= '<h3>' . t('libertree') . '</h3>';
|
||||
$s .= '<h3>' . t('libertree Export') . '</h3>';
|
||||
$s .= '</span>';
|
||||
$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 .= '<h3>' . t('libertree') . '</h3>';
|
||||
$s .= '<h3>' . t('libertree Export') . '</h3>';
|
||||
$s .= '</span>';
|
||||
|
||||
$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
|
||||
$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']);
|
||||
|
||||
// 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";
|
||||
|
||||
// following line changed per bug #431
|
||||
|
|
|
@ -219,11 +219,11 @@ function pumpio_settings(&$a,&$s) {
|
|||
/* 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 .= '<h3>' . t('Pump.io') . '</h3>';
|
||||
$s .= '<h3>' . t('Pump.io Import/Export/Mirror') . '</h3>';
|
||||
$s .= '</span>';
|
||||
$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 .= '<h3>' . t('Pump.io') . '</h3>';
|
||||
$s .= '<h3>' . t('Pump.io Import/Export/Mirror') . '</h3>';
|
||||
$s .= '</span>';
|
||||
|
||||
$s .= '<div id="pumpio-username-wrapper">';
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#statusnet-sendtaglinks-label,
|
||||
#statusnet-shortening-label,
|
||||
#statusnet-mirror-label,
|
||||
#statusnet-import-label,
|
||||
#statusnet-create_user-label,
|
||||
#statusnet-pin-label,
|
||||
#statusnet-enable-label {
|
||||
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 */
|
||||
|
||||
$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 .= '<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 .= '<h3>' . t('Tumblr') . '</h3>';
|
||||
$s .= '<h3>' . t('Tumblr Export') . '</h3>';
|
||||
$s .= '</span>';
|
||||
|
||||
$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_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 .= '<h3>'. t('Twitter') .'</h3>';
|
||||
$s .= '<h3>'. t('Twitter Import/Export/Mirror') .'</h3>';
|
||||
$s .= '</span>';
|
||||
$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 .= '<h3>'. t('Twitter') .'</h3>';
|
||||
$s .= '<h3>'. t('Twitter Import/Export/Mirror') .'</h3>';
|
||||
$s .= '</span>';
|
||||
|
||||
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 .= '<div class="clear"></div>';
|
||||
|
||||
$s .= '<label id="twitter-shortening-label" for="twitter-shortening">'.t('Shortening method that optimizes the tweet').'</label>';
|
||||
$s .= '<input id="twitter-shortening" type="checkbox" name="twitter-shortening" value="1" '. $shorteningchecked . '/>';
|
||||
$s .= '<div class="clear"></div>';
|
||||
if (!$globalshortening) {
|
||||
$s .= '<label id="twitter-shortening-label" for="twitter-shortening">'.t('Shortening method that optimizes the tweet').'</label>';
|
||||
$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 .= '<input id="twitter-sendtaglinks" type="checkbox" name="twitter-sendtaglinks" value="1" '. $linkschecked . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
$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 .= '<div class="clear"></div>';
|
||||
}
|
||||
$s .= '</div>';
|
||||
|
||||
$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 . '/>';
|
||||
|
@ -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);
|
||||
$_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);
|
||||
$_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) {
|
||||
require_once("include/oembed.php");
|
||||
require_once("include/network.php");
|
||||
|
||||
$tags = "";
|
||||
|
||||
|
@ -1317,7 +1321,7 @@ function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontinclud
|
|||
foreach ($item->entities->urls AS $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);
|
||||
|
||||
|
@ -1341,7 +1345,6 @@ function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontinclud
|
|||
$body = str_replace($url->url,
|
||||
"[url=".$expanded_url."]".$expanded_url."[/url]",
|
||||
$body);
|
||||
//"[url=".$expanded_url."]".$url->display_url."[/url]",
|
||||
else {
|
||||
$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;
|
||||
$footerurl = $expanded_url;
|
||||
$footerlink = "[url=".$expanded_url."]".$expanded_url."[/url]";
|
||||
//$footerlink = "[url=".$expanded_url."]".$url->display_url."[/url]";
|
||||
|
||||
$body = str_replace($url->url, $footerlink, $body);
|
||||
}
|
||||
|
@ -1367,7 +1369,7 @@ function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontinclud
|
|||
}
|
||||
|
||||
if ($footerurl != "")
|
||||
$footer = twitter_siteinfo($footerurl, $dontincludemedia);
|
||||
$footer = add_page_info($footerurl);
|
||||
|
||||
if (($footerlink != "") AND (trim($footer) != "")) {
|
||||
$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))
|
||||
$body = $removedlink;
|
||||
|
||||
$body .= "\n\n[class=type-".$type."]".$footer."[/class]";
|
||||
$body .= $footer;
|
||||
}
|
||||
|
||||
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);
|
||||
$postarray['body'] = $converted["body"];
|
||||
$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);
|
||||
$postarray['body'] = $converted["body"];
|
||||
$postarray['tag'] = $converted["tags"];
|
||||
|
@ -1839,213 +1839,6 @@ function twitter_fetchhometimeline($a, $uid) {
|
|||
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) {
|
||||
$ckey = get_config('twitter', 'consumerkey');
|
||||
$csecret = get_config('twitter', 'consumersecret');
|
||||
|
|
|
@ -73,11 +73,11 @@ function wppost_settings(&$a,&$s) {
|
|||
/* 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 .= '<h3>' . t('WordPress') . '</h3>';
|
||||
$s .= '<h3>' . t('WordPress Export') . '</h3>';
|
||||
$s .= '</span>';
|
||||
$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 .= '<h3>' . t('WordPress') . '</h3>';
|
||||
$s .= '<h3>' . t('WordPress Export') . '</h3>';
|
||||
$s .= '</span>';
|
||||
$s .= '<div id="wppost-enable-wrapper">';
|
||||
$s .= '<label id="wppost-enable-label" for="wppost-checkbox">' . t('Enable WordPress Post Plugin') . '</label>';
|
||||
|
|
Loading…
Reference in a new issue