diff --git a/facebook/facebook.php b/facebook/facebook.php
index a59036dd6..6ff2a2ef0 100644
--- a/facebook/facebook.php
+++ b/facebook/facebook.php
@@ -79,38 +79,38 @@ function facebook_init(&$a) {
if (x($_REQUEST, "realtime_cb") && x($_REQUEST, "realtime_cb")) {
logger("facebook_init: Facebook Real-Time callback called", LOGGER_DEBUG);
-
+
if (x($_REQUEST, "hub_verify_token")) {
// this is the verification callback while registering for real time updates
-
+
$verify_token = get_config('facebook', 'cb_verify_token');
if ($verify_token != $_REQUEST["hub_verify_token"]) {
logger('facebook_init: Wrong Facebook Callback Verifier - expected ' . $verify_token . ', got ' . $_REQUEST["hub_verify_token"]);
return;
}
-
+
if (x($_REQUEST, "hub_challenge")) {
logger('facebook_init: Answering Challenge: ' . $_REQUEST["hub_challenge"], LOGGER_DATA);
echo $_REQUEST["hub_challenge"];
die();
}
}
-
+
require_once('include/items.php');
-
+
// this is a status update
$content = file_get_contents("php://input");
if (is_numeric($content)) $content = file_get_contents("php://input");
$js = json_decode($content);
logger(print_r($js, true), LOGGER_DATA);
-
+
if (!isset($js->object) || $js->object != "user" || !isset($js->entry)) {
logger('facebook_init: Could not parse Real-Time Update data', LOGGER_DEBUG);
return;
}
-
+
$affected_users = array("feed" => array(), "friends" => array());
-
+
foreach ($js->entry as $entry) {
$fbuser = $entry->uid;
foreach ($entry->changed_fields as $field) {
@@ -119,20 +119,20 @@ function facebook_init(&$a) {
continue;
}
if (in_array($fbuser, $affected_users[$field])) continue;
-
+
$r = q("SELECT `uid` FROM `pconfig` WHERE `cat` = 'facebook' AND `k` = 'self_id' AND `v` = '%s' LIMIT 1", dbesc($fbuser));
if(! count($r))
continue;
$uid = $r[0]['uid'];
-
+
$access_token = get_pconfig($uid,'facebook','access_token');
if(! $access_token)
return;
-
+
switch ($field) {
case "feed":
logger('facebook_init: FB-User ' . $fbuser . ' / feed', LOGGER_DEBUG);
-
+
if(! get_pconfig($uid,'facebook','no_wall')) {
$private_wall = intval(get_pconfig($uid,'facebook','private_wall'));
$s = fetch_url('https://graph.facebook.com/me/feed?access_token=' . $access_token);
@@ -146,11 +146,11 @@ function facebook_init(&$a) {
}
}
}
-
+
break;
case "friends":
logger('facebook_init: FB-User ' . $fbuser . ' / friends', LOGGER_DEBUG);
-
+
fb_get_friends($uid, false);
set_pconfig($uid,'facebook','friend_check',time());
break;
@@ -162,7 +162,7 @@ function facebook_init(&$a) {
}
}
-
+
if($a->argc != 2)
return;
$nick = $a->argv[1];
@@ -188,7 +188,7 @@ function facebook_init(&$a) {
$x = fetch_url('https://graph.facebook.com/oauth/access_token?client_id='
. $appid . '&client_secret=' . $appsecret . '&redirect_uri='
- . urlencode($a->get_baseurl() . '/facebook/' . $nick)
+ . urlencode($a->get_baseurl() . '/facebook/' . $nick)
. '&code=' . $auth_code);
logger('facebook_init: returned access token: ' . $x, LOGGER_DATA);
@@ -408,6 +408,7 @@ function fb_get_friends($uid, $fullsync = true) {
$access_token = get_pconfig($uid,'facebook','access_token');
$no_linking = get_pconfig($uid,'facebook','no_linking');
+
if($no_linking)
return;
@@ -432,7 +433,7 @@ function fb_get_friends($uid, $fullsync = true) {
}
// This is the POST method to the facebook settings page
-// Content is posted to Facebook in the function facebook_post_hook()
+// Content is posted to Facebook in the function facebook_post_hook()
/**
* @param App $a
@@ -443,7 +444,7 @@ function facebook_post(&$a) {
if($uid){
- $fb_limited = get_config('facebook','restrict');
+ $fb_limited = get_config('facebook','crestrict');
$value = ((x($_POST,'post_by_default')) ? intval($_POST['post_by_default']) : 0);
@@ -456,7 +457,7 @@ function facebook_post(&$a) {
$private_wall = ((x($_POST,'facebook_private_wall')) ? intval($_POST['facebook_private_wall']) : 0);
set_pconfig($uid,'facebook','private_wall',$private_wall);
-
+
set_pconfig($uid,'facebook','blocked_apps',escape_tags(trim($_POST['blocked_apps'])));
@@ -466,7 +467,7 @@ function facebook_post(&$a) {
if($linkvalue == 0)
set_pconfig($uid,'facebook','no_linking', 1);
}
- else
+ else
set_pconfig($uid,'facebook','no_linking', (($linkvalue) ? 0 : 1));
// FB linkage was allowed but has just been turned off - remove all FB contacts and posts
@@ -940,7 +941,7 @@ function facebook_post_hook(&$a,&$b) {
if($fb_token && ($toplevel || $b['private'] || $reply)) {
logger('facebook: able to post');
require_once('library/facebook.php');
- require_once('include/bbcode.php');
+ require_once('include/bbcode.php');
$msg = $b['body'];
@@ -1015,7 +1016,7 @@ function facebook_post_hook(&$a,&$b) {
}
// At first convert the text to html
- $html = bbcode($body);
+ $html = bbcode($body, false, false);
// Then convert it to plain text
$msg = trim($b['title']." \n\n".html2plain($html, 0, true));
@@ -1132,8 +1133,8 @@ function facebook_post_hook(&$a,&$b) {
} else {
// if its only a message and a subject and the message is larger than 500 characters then post it as note
$postvars = array(
- 'access_token' => $fb_token,
- 'message' => bbcode($b['body']),
+ 'access_token' => $fb_token,
+ 'message' => bbcode($b['body'], false, false),
'subject' => $b['title'],
);
$url = 'https://graph.facebook.com/me/notes';
diff --git a/fromgplus/README b/fromgplus/README
new file mode 100644
index 000000000..cecbb2b9d
--- /dev/null
+++ b/fromgplus/README
@@ -0,0 +1 @@
+This extension is a preparation of the upcoming import of items via Google+
diff --git a/fromgplus/fromgplus.php b/fromgplus/fromgplus.php
new file mode 100644
index 000000000..88d2622ff
--- /dev/null
+++ b/fromgplus/fromgplus.php
@@ -0,0 +1,183 @@
+
+ *
+ */
+
+function fromgplus_install() {
+ register_hook('plugin_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings');
+ register_hook('plugin_settings_post', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings_post');
+}
+
+function fromgplus_uninstall() {
+ unregister_hook('plugin_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings');
+ unregister_hook('plugin_settings_post', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings_post');
+}
+
+function fromgplus_addon_settings(&$a,&$s) {
+
+ if(! local_user())
+ return;
+
+ $enable_checked = (intval(get_pconfig(local_user(),'fromgplus','enable')) ? ' checked="checked"' : '');
+ $account = get_pconfig(local_user(),'fromgplus','account');
+
+ $s .= '
';
+ $s .= '
' . t('Google+ Import Settings').' ';
+ $s .= '
';
+
+ $s .= '
'.t('Enable Google+ Import').' ';
+ $s .= '
';
+ $s .= '
';
+ $s .= '
'.t('Google Account ID').' ';
+ $s .= '
';
+ $s .= '
';
+
+ $s .= '
';
+ $s .= '
';
+
+ return;
+}
+
+function fromgplus_addon_settings_post(&$a,&$b) {
+
+ if(! local_user())
+ return;
+
+ if($_POST['fromgplus-submit']) {
+ set_pconfig(local_user(),'fromgplus','account',trim($_POST['fromgplus-account']));
+ $enable = ((x($_POST,'fromgplus-enable')) ? intval($_POST['fromgplus-enable']) : 0);
+ set_pconfig(local_user(),'fromgplus','enable', $enable);
+ info( t('Google+ Import Settings saved.') . EOL);
+ }
+}
+/*
+function html2bbcode($html) {
+
+ $bbcode = html_entity_decode($html, ENT_QUOTES, 'UTF-8');
+
+ $bbcode = str_replace(array("\n"), array(""), $bbcode);
+ $bbcode = str_replace(array("", " "), array("[b]", "[/b]"), $bbcode);
+ $bbcode = str_replace(array("", " "), array("[i]", "[/i]"), $bbcode);
+ $bbcode = str_replace(array("", " "), array("[s]", "[/s]"), $bbcode);
+ $bbcode = str_replace(array(" "), array("\n"), $bbcode);
+
+ $bbcode = trim(strip_tags($bbcode));
+ return($bbcode);
+}
+
+function friendicapost($post) {
+ global $friendica;
+
+ $api = new Statusnet($friendica["user"], $friendica["pw"], "GooglePlus", $friendica["server"]);
+ $ret = $api->updateStatus($post);
+ $api->endSession();
+}
+
+function handleattachments($item) {
+ $post = "";
+
+ foreach ($item->object->attachments as $attachment) {
+ switch($attachment->objectType) {
+ case "video":
+ //$post .= "\n\n[url=".$attachment->url."]".
+ // "[size=large][b]".html2bbcode($attachment->displayName)."[/b][/size][/url]\n";
+ $post .= "\n\n[bookmark=".$attachment->url."]".html2bbcode($attachment->displayName)."[/bookmark]\n";
+
+ //if (strpos($attachment->embed->url, "youtube.com"))
+ // $post .= "[youtube]".$attachment->url."[/youtube]\n";
+ //else
+ /// $post .= "[url=".$attachment->url."][img]".$attachment->image->url."[/img][/url]\n";
+
+ ///$post .= "[quote]".trim(html2bbcode($attachment->content))."[/quote]";
+ break;
+
+ case "article":
+ //$post .= "\n\n[url=".$attachment->url."]".
+ // "[size=large][b]".html2bbcode($attachment->displayName)."[/b][/size][/url]\n";
+ $post .= "\n\n[bookmark=".$attachment->url."]".html2bbcode($attachment->displayName)."[/bookmark]\n";
+ $post .= "[quote]".trim(html2bbcode($attachment->content))."[/quote]";
+ break;
+
+ case "photo":
+ //$post .= "\n\n[url=".$attachment->fullImage->url."]".
+ // "[img]".$attachment->fullImage->url."[/img][/url]\n";
+ $post .= "\n\n[img]".$attachment->fullImage->url."[/img]\n";
+ if ($attachment->displayName != "")
+ $post .= html2bbcode($attachment->displayName)."\n";
+ break;
+
+ case "photo-album":
+ $post .= "\n\n[url=".$attachment->url."]".
+ "[size=large][b]".html2bbcode($attachment->displayName)."[/b][/size][/url]\n";
+ break;
+
+ default:
+ print_r($attachment);
+ die();
+ break;
+ }
+ }
+ return($post);
+}
+
+$result =
+file_get_contents("https://www.googleapis.com/plus/v1/people/".$google["id"]."/activities/public?alt=json&pp=1&key=".$google["key"]."&maxResults=".$google["maxfetch"]);
+$activities = json_decode($result);
+
+$state = array("lastid"=>'');
+if (file_exists($statefile))
+ $state = unserialize(file_get_contents($statefile));
+
+$lastid = "";
+
+foreach($activities->items as $item) {
+ if ($item->id == $state["lastid"])
+ break;
+
+ if ($lastid == "")
+ $lastid = $item->id;
+
+ switch($item->object->objectType) {
+ case "note":
+ $post = html2bbcode($item->object->content);
+
+ if (is_array($item->object->attachments))
+ $post .= handleattachments($item);
+ friendicapost($post);
+ break;
+
+ case "activity":
+ $post = html2bbcode($item->annotation)."\n";
+ //$post .= html2bbcode("♲ ");
+ $post .= html2bbcode("♻ ");
+ $post .= "[url=".$item->object->actor->url."]".$item->object->actor->displayName."[/url]";
+ $post .= " \n";
+ //$post .= "[quote]";
+
+ $post .= html2bbcode($item->object->content);
+
+ if (is_array($item->object->attachments))
+ $post .= "\n".trim(handleattachments($item));
+
+ //$post .= "[/quote]";
+
+ friendicapost($post);
+ break;
+
+ default:
+ print_r($item);
+ die();
+ break;
+ }
+}
+
+if ($lastid != "") {
+ $state['lastid'] = $lastid;
+ file_put_contents($statefile, serialize($state));
+}
+*/
diff --git a/libertree/libertree.php b/libertree/libertree.php
index 4f0c814d2..c117fa811 100755
--- a/libertree/libertree.php
+++ b/libertree/libertree.php
@@ -118,7 +118,7 @@ function libertree_post_local(&$a,&$b) {
if($b['private'] || $b['parent'])
return;
- $ltree_post = intval(get_pconfig(local_user(),'libertree','post'));
+ $ltree_post = intval(get_pconfig(local_user(),'libertree','post'));
$ltree_enable = (($ltree_post && x($_REQUEST,'libertree_enable')) ? intval($_REQUEST['libertree_enable']) : 0);
@@ -167,16 +167,41 @@ function libertree_send(&$a,&$b) {
}
}
if(count($tag_arr))
- $tags = implode(',',$tag_arr);
+ $tags = implode(',',$tag_arr);
+ $title = $b['title'];
+ $body = $b['body'];
+
+ // Insert a newline before and after a quote
+ $body = str_ireplace("[quote", "\n\n[quote", $body);
+ $body = str_ireplace("[/quote]", "[/quote]\n\n", $body);
+
+ // Removal of tags and mentions
+ // #-tags
+ $body = preg_replace('/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $body);
+ // @-mentions
+ $body = preg_replace('/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $body);
+
+ // remove multiple newlines
+ do {
+ $oldbody = $body;
+ $body = str_replace("\n\n\n", "\n\n", $body);
+ } while ($oldbody != $body);
+
+ // convert to markdown
+ $body = bb2diaspora($body);
+
+ // Adding the title
+ if(strlen($title))
+ $body = "## ".html_entity_decode($title)."\n\n".$body;
$params = array(
- 'text' => bb2diaspora($b['body'])
+ 'text' => $body
// 'token' => $ltree_api_token
);
$result = post_url($ltree_blog,$params);
- logger('libertree: ' . $result);
+ logger('libertree: ' . $result);
}
}
diff --git a/privacy_image_cache/privacy_image_cache.php b/privacy_image_cache/privacy_image_cache.php
index d3202c4d7..b7236d09d 100644
--- a/privacy_image_cache/privacy_image_cache.php
+++ b/privacy_image_cache/privacy_image_cache.php
@@ -36,16 +36,18 @@ function privacy_image_cache_init() {
}
$urlhash = 'pic:' . sha1($_REQUEST['url']);
- $r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash );
- if (count($r)) {
- $img_str = $r[0]['data'];
+ // Double encoded url - happens with Diaspora
+ $urlhash2 = 'pic:' . sha1(urldecode($_REQUEST['url']));
+
+ $r = q("SELECT * FROM `photo` WHERE `resource-id` in ('%s', '%s') LIMIT 1", $urlhash, $urlhash2);
+ if (count($r)) {
+ $img_str = $r[0]['data'];
$mime = $r[0]["desc"];
if ($mime == "") $mime = "image/jpeg";
- }
- else {
- require_once("Photo.php");
+ } else {
+ require_once("Photo.php");
- $img_str = fetch_url($_REQUEST['url'],true);
+ $img_str = fetch_url($_REQUEST['url'],true);
if (substr($img_str, 0, 6) == "GIF89a") {
$mime = "image/gif";
$image = @imagecreatefromstring($img_str);
@@ -77,16 +79,16 @@ function privacy_image_cache_init() {
}
$mime = "image/jpeg";
}
- }
+ }
- header("Content-type: $mime");
- header("Expires: " . gmdate("D, d M Y H:i:s", time() + (3600*24)) . " GMT");
- header("Cache-Control: max-age=" . (3600*24));
+ header("Content-type: $mime");
+ header("Expires: " . gmdate("D, d M Y H:i:s", time() + (3600*24)) . " GMT");
+ header("Cache-Control: max-age=" . (3600*24));
- echo $img_str;
+ echo $img_str;
- killme();
+ killme();
}
/**
@@ -210,4 +212,4 @@ function privacy_image_cache_plugin_admin_post(&$a = null, &$o = null){
if (isset($_REQUEST['delete_all'])) {
q('DELETE FROM `photo` WHERE `uid` = 0 AND `resource-id` LIKE "pic:%%"');
}
-}
\ No newline at end of file
+}
diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php
index dd8761680..99e844752 100755
--- a/statusnet/statusnet.php
+++ b/statusnet/statusnet.php
@@ -426,15 +426,15 @@ function statusnet_post_hook(&$a,&$b) {
if($ckey && $csecret && $otoken && $osecret) {
- require_once('include/bbcode.php');
+ require_once('include/bbcode.php');
$dent = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret);
$max_char = $dent->get_maxlength(); // max. length for a dent
// we will only work with up to two times the length of the dent
- // we can later send to StatusNet. This way we can "gain" some
- // information during shortening of potential links but do not
+ // we can later send to StatusNet. This way we can "gain" some
+ // information during shortening of potential links but do not
// shorten all the links in a 200000 character long essay.
if (! $b['title']=='') {
- $tmp = $b['title'] . ' : '. $b['body'];
+ $tmp = $b['title'].": \n".$b['body'];
// $tmp = substr($tmp, 0, 4*$max_char);
} else {
$tmp = $b['body']; // substr($b['body'], 0, 3*$max_char);
@@ -453,10 +453,16 @@ function statusnet_post_hook(&$a,&$b) {
// that is, don't send if the option is not set in the
// connector settings
if ($linksenabled=='0') {
- // #-tags
- $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp);
- // @-mentions
- $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp);
+ // #-tags
+ $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp);
+ // @-mentions
+ $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp);
+ // recycle 1
+ $recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
+ $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp);
+ // recycle 2
+ //$recycle = html_entity_decode("♻ ", ENT_QUOTES, 'UTF-8');
+ //$tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', 'RT @$2:', $tmp);
}
// preserve links to webpages
$tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/url\]/i', '$2 $1', $tmp);
@@ -476,7 +482,7 @@ function statusnet_post_hook(&$a,&$b) {
}
// ok, all the links we want to send out are save, now strip
// away the remaining bbcode
- $msg = strip_tags(bbcode($tmp));
+ $msg = strip_tags(bbcode($tmp, false, false));
// quotes not working - let's try this
$msg = html_entity_decode($msg);
if (( strlen($msg) > $max_char) && $max_char > 0) {
diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php
index 723bdef0b..03a67949b 100755
--- a/tumblr/tumblr.php
+++ b/tumblr/tumblr.php
@@ -166,19 +166,58 @@ function tumblr_send(&$a,&$b) {
}
}
if(count($tag_arr))
- $tags = implode(',',$tag_arr);
+ $tags = implode(',',$tag_arr);
+ $link = "";
+ $video = false;
+ $title = trim($b['title']);
+
+ // Checking for a bookmark
+ if(preg_match("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/is",$b['body'],$matches)) {
+ $link = $matches[1];
+ if ($title == '')
+ $title = html_entity_decode($matches[2],ENT_QUOTES,'UTF-8');
+
+ $body = $b['body'];
+ // splitting the text in two parts:
+ // before and after the bookmark
+ $pos = strpos($body, "[bookmark");
+ $body1 = substr($body, 0, $pos);
+ $body2 = substr($body, $pos);
+
+ // Removing the bookmark
+ $body2 = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",'',$body2);
+ $body = $body1.$body2;
+
+ $video = ((stristr($link,'youtube')) || (stristr($link,'youtu.be')) || (stristr($mtch[1],'vimeo')));
+ }
$params = array(
'email' => $tmbl_username,
'password' => $tmbl_password,
- 'title' => $b['title'],
- 'type' => 'regular',
'format' => 'html',
'generator' => 'Friendica',
- 'tags' => $tags,
- 'body' => bbcode($b['body'])
- );
+ 'tags' => $tags);
+
+ if (($link != '') and $video) {
+ $params['type'] = "video";
+ $params['embed'] = $link;
+ if ($title != '')
+ $params['caption'] = '".bbcode($body)."
";
+ else
+ $params['caption'] = bbcode($body);
+ } else if (($link != '') and !$video) {
+ $params['type'] = "link";
+ $params['name'] = $title;
+ $params['url'] = $link;
+ //$params['description'] = bbcode($body);
+ $params['description'] = bbcode($b["body"]);
+ } else {
+ $params['type'] = "regular";
+ $params['title'] = $title;
+ $params['body'] = bbcode($b['body']);
+ }
$x = post_url($tmbl_blog,$params);
$ret_code = $a->get_curl_code();
@@ -187,7 +226,7 @@ function tumblr_send(&$a,&$b) {
elseif($ret_code == 403)
logger('tumblr_send: authentication failure');
else
- logger('tumblr_send: general error: ' . print_r($x,true));
+ logger('tumblr_send: general error: ' . print_r($x,true));
}
}
diff --git a/twitter/twitter.php b/twitter/twitter.php
index 0ac9396df..9984f3695 100755
--- a/twitter/twitter.php
+++ b/twitter/twitter.php
@@ -290,7 +290,7 @@ function twitter_post_hook(&$a,&$b) {
logger('twitter: we have customer key and oauth stuff, going to send.', LOGGER_DEBUG);
require_once('library/twitteroauth.php');
- require_once('include/bbcode.php');
+ require_once('include/bbcode.php');
$tweet = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
// in theory max char is 140 but T. uses t.co to make links
// longer so we give them 10 characters extra
@@ -316,18 +316,24 @@ function twitter_post_hook(&$a,&$b) {
$tmp = preg_replace( '/\[\\/?audio(\\s+.*?\]|\])/i', '', $tmp);
$linksenabled = get_pconfig($b['uid'],'twitter','post_taglinks');
// if a #tag is linked, don't send the [url] over to SN
- // that is, don't send if the option is not set in the
+ // that is, don't send if the option is not set in the
// connector settings
if ($linksenabled=='0') {
- // #-tags
- $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp);
- // @-mentions
- $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp);
+ // #-tags
+ $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp);
+ // @-mentions
+ $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp);
+ // recycle 1
+ $recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
+ $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp);
+ // recycle 2
+ //$recycle = html_entity_decode("♻ ", ENT_QUOTES, 'UTF-8');
+ //$tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', 'RT @$2:', $tmp);
}
$tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/url\]/i', '$2 $1', $tmp);
$tmp = preg_replace( '/\[bookmark\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/bookmark\]/i', '$2 $1', $tmp);
- // find all http or https links in the body of the entry and
- // apply the shortener if the link is longer then 20 characters
+ // find all http or https links in the body of the entry and
+ // apply the shortener if the link is longer then 20 characters
if (( strlen($tmp)>$max_char ) && ( $max_char > 0 )) {
preg_match_all ( '/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/i', $tmp, $allurls );
foreach ($allurls as $url) {
@@ -341,7 +347,7 @@ function twitter_post_hook(&$a,&$b) {
}
// ok, all the links we want to send out are save, now strip
// away the remaining bbcode
- $msg = strip_tags(bbcode($tmp));
+ $msg = strip_tags(bbcode($tmp, false, false));
// quotes not working - let's try this
$msg = html_entity_decode($msg);
if (( strlen($msg) > $max_char) && $max_char > 0) {
diff --git a/wppost/wppost.php b/wppost/wppost.php
index ee9acb0d4..e8b6fc6d5 100755
--- a/wppost/wppost.php
+++ b/wppost/wppost.php
@@ -179,24 +179,26 @@ function wppost_send(&$a,&$b) {
require_once('include/bbcode.php');
require_once('include/html2plain.php');
+ $wptitle = trim($b['title']);
+
// If the title is empty then try to guess
- if ($b['title'] == '') {
+ if ($wptitle == '') {
// Take the description from the bookmark
if(preg_match("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/is",$b['body'],$matches))
- $b['title'] = $matches[2];
+ $wptitle = $matches[2];
// If no bookmark is found then take the first line
- if ($b['title'] == '') {
+ if ($wptitle == '') {
$title = html2plain(bbcode($b['body']), 0, true);
$pos = strpos($title, "\n");
if (($pos == 0) or ($pos > 60))
$pos = 60;
- $b['title'] = substr($title, 0, $pos);
+ $wptitle = substr($title, 0, $pos);
}
}
- $title = '' . (($b['title']) ? $b['title'] : t('Post from Friendica')) . ' ';
+ $title = '' . (($wptitle) ? $wptitle : t('Post from Friendica')) . ' ';
$post = $title . bbcode($b['body']);
$wp_backlink = intval(get_pconfig($b['uid'],'wppost','backlink'));