return;
$s = fetch_url('https://graph.facebook.com/me/friends?access_token=' . $access_token);
if($s) {
- logger('facebook: fb_get_friends: ' . $s, LOGGER_DATA);
+ logger('facebook: fb_gwet_friends: ' . $s, LOGGER_DATA);
$j = json_decode($s);
logger('facebook: fb_get_friends: json: ' . print_r($j,true), LOGGER_DATA);
if(! $j->data)
if(preg_match("/\[img\](.*?)\[\/img\]/is",$b['body'],$matches))
$image = $matches[1];
+ // When saved into the database the content is sent through htmlspecialchars
+ // That means that we have to decode all image-urls
+ $image = htmlspecialchars_decode($image);
+
// Checking for a bookmark element
$body = $b['body'];
if (strpos($body, "[bookmark") !== false) {
// Fallback - if message is empty
if(!strlen($msg))
- $msg = $link;
+ $msg = $linkname;
if(!strlen($msg))
- $msg = $image;
+ $msg = $link;
if(!strlen($msg))
- $msg = $linkname;
+ $msg = $image;
// If there is nothing to post then exit
if(!strlen($msg))
logger('Facebook post: msg=' . $msg, LOGGER_DATA);
- if($likes) {
+ if($likes) {
$postvars = array('access_token' => $fb_token);
}
else {
+ // message, picture, link, name, caption, description, source, place, tags
$postvars = array(
- 'access_token' => $fb_token,
+ 'access_token' => $fb_token,
'message' => $msg
);
- if(isset($image)) {
+ if(trim($image) != "") {
$postvars['picture'] = $image;
- //$postvars['type'] = "photo";
}
- if(isset($link)) {
+ if(trim($link) != "") {
$postvars['link'] = $link;
- //$postvars['type'] = "link";
+
+ // The following doesn't work - why?
+ if ((stristr($link,'youtube')) || (stristr($link,'youtu.be')) || (stristr($link,'vimeo'))) {
+ $postvars['source'] = $link;
+ }
}
- if(isset($linkname))
+ if(trim($linkname) != "")
$postvars['name'] = $linkname;
}
if($reply) {
$url = 'https://graph.facebook.com/' . $reply . '/' . (($likes) ? 'likes' : 'comments');
- } else if (($link != "") or ($image != "") or ($b['title'] == '') or (strlen($msg) < 500)) {
+ } else if (($link != "") or ($image != "") or ($b['title'] == '') or (strlen($msg) < 500)) {
$url = 'https://graph.facebook.com/me/feed';
if($b['plink'])
$postvars['actions'] = '{"name": "' . t('View on Friendica') . '", "link": "' . $b['plink'] . '"}';
// oembed display a picture of the video as well
if ($entry->type != "video") {
if(isset($entry->picture) && isset($entry->link)) {
- $datarray['body'] .= "\n" . '[url=' . $entry->link . '][img]'.$entry->picture.'[/img][/url]';
+ $datarray['body'] .= "\n" . '[url=' . $entry->link . '][img]'.$entry->picture.'[/img][/url]';
}
else {
if(isset($entry->picture))
// Adding the title
if(strlen($title))
$body = "## ".html_entity_decode($title)."\n\n".$body;
-
+
$params = array(
'text' => $body,
require_once('include/security.php');
function privacy_image_cache_install() {
- register_hook('bbcode', 'addon/privacy_image_cache/privacy_image_cache.php', 'privacy_image_cache_bbcode_hook');
+ register_hook('prepare_body', 'addon/privacy_image_cache/privacy_image_cache.php', 'privacy_image_cache_prepare_body_hook');
+ // register_hook('bbcode', 'addon/privacy_image_cache/privacy_image_cache.php', 'privacy_image_cache_bbcode_hook');
register_hook('display_item', 'addon/privacy_image_cache/privacy_image_cache.php', 'privacy_image_cache_display_item_hook');
register_hook('ping_xmlize', 'addon/privacy_image_cache/privacy_image_cache.php', 'privacy_image_cache_ping_xmlize_hook');
register_hook('cron', 'addon/privacy_image_cache/privacy_image_cache.php', 'privacy_image_cache_cron');
function privacy_image_cache_uninstall() {
+ unregister_hook('prepare_body', 'addon/privacy_image_cache/privacy_image_cache.php', 'privacy_image_cache_prepare_body_hook');
unregister_hook('bbcode', 'addon/privacy_image_cache/privacy_image_cache.php', 'privacy_image_cache_bbcode_hook');
unregister_hook('display_item', 'addon/privacy_image_cache/privacy_image_cache.php', 'privacy_image_cache_display_item_hook');
unregister_hook('ping_xmlize', 'addon/privacy_image_cache/privacy_image_cache.php', 'privacy_image_cache_ping_xmlize_hook');
function privacy_image_cache_init() {
+ global $a;
+
if(function_exists('header_remove')) {
header_remove('Pragma');
header_remove('pragma');
} else {
require_once("Photo.php");
+ // It shouldn't happen but it does - spaces in URL
+ $_REQUEST['url'] = str_replace(" ", "+", $_REQUEST['url']);
+
$img_str = fetch_url($_REQUEST['url'],true);
- if (substr($img_str, 0, 6) == "GIF89a") {
- $mime = "image/gif";
+
+ $tempfile = tempnam("", "cache");
+ file_put_contents($tempfile, $img_str);
+ $mime = image_type_to_mime_type(exif_imagetype($tempfile));
+ unlink($tempfile);
+
+ // If there is an error then return a blank image
+ if ((substr($a->get_curl_code(), 0, 1) == "4") or (!$img_str)) {
+ $img_str = file_get_contents("images/blank.png");
+ $mime = "image/png";
+ //} else if (substr($img_str, 0, 6) == "GIF89a") {
+ } else if ($mime != "image/jpeg") {
$image = @imagecreatefromstring($img_str);
if($image === FALSE) die();
dbesc(''),
intval(imagesy($image)),
intval(imagesx($image)),
- 'image/gif',
+ $mime,
dbesc($img_str),
100,
intval(0),
}
}
-
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));
*/
function privacy_image_cache_img_cb($matches) {
// following line changed per bug #431
- if (privacy_image_cache_is_local_image($matches[2])) return $matches[1] . $matches[2] . $matches[3];
- return $matches[1] . get_app()->get_baseurl() . "/privacy_image_cache/?url=" . escape_tags(addslashes(rawurlencode($matches[2]))) . $matches[3];
+ if (privacy_image_cache_is_local_image($matches[2]))
+ return $matches[1] . $matches[2] . $matches[3];
+
+ return $matches[1] . get_app()->get_baseurl() . "/privacy_image_cache/?url=" . addslashes(rawurlencode(htmlspecialchars_decode($matches[2]))) . $matches[3];
+}
+
+/**
+ * @param App $a
+ * @param string $o
+ */
+function privacy_image_cache_prepare_body_hook(&$a, &$o) {
+ $o["html"] = preg_replace_callback("/(<img [^>]*src *= *[\"'])([^\"']+)([\"'][^>]*>)/siU", "privacy_image_cache_img_cb", $o["html"]);
}
/**
* @param App $a
* @param string $o
+ * Function disabled because the plugin moved
*/
function privacy_image_cache_bbcode_hook(&$a, &$o) {
- $o = preg_replace_callback("/(<img [^>]*src *= *[\"'])([^\"']+)([\"'][^>]*>)/siU", "privacy_image_cache_img_cb", $o);
+ //$o = preg_replace_callback("/(<img [^>]*src *= *[\"'])([^\"']+)([\"'][^>]*>)/siU", "privacy_image_cache_img_cb", $o);
}
}
// ok, all the links we want to send out are save, now strip
// away the remaining bbcode
- $msg = strip_tags(bbcode($tmp, false, false));
+ //$msg = strip_tags(bbcode($tmp, false, false));
+ $msg = bbcode($tmp, false, false);
+ $msg = str_replace(array('<br>','<br />'),"\n",$msg);
+ $msg = strip_tags($msg);
+
// quotes not working - let's try this
$msg = html_entity_decode($msg);
+
if (( strlen($msg) > $max_char) && $max_char > 0) {
$shortlink = short_link( $b['plink'] );
// the new message will be shortened such that "... $shortlink"
$msg = implode(' ', $e);
$msg .= '... ' . $shortlink;
}
+
+ $msg = trim($msg);
+
// and now dent it :-)
if(strlen($msg)) {
$result = $dent->post('statuses/update', array('status' => $msg));
- logger('statusnet_post send, result: ' . print_r($result, true), LOGGER_DEBUG);
+ logger('statusnet_post send, result: ' . print_r($result, true).
+ "\nmessage: ".$msg, LOGGER_DEBUG."\nOriginal post: ".print_r($b));
if ($result->error) {
logger('Send to StatusNet failed: "' . $result->error . '"');
}
$params['embed'] = $link;
if ($title != '')
$params['caption'] = '<h1><a href="'.$link.'">'.$title.
- "</a></h1><p>".bbcode($body)."</p>";
+ "</a></h1><p>".bbcode($body, false, false)."</p>";
else
- $params['caption'] = bbcode($body);
+ $params['caption'] = bbcode($body, false, false);
} else if (($link != '') and !$video) {
$params['type'] = "link";
$params['name'] = $title;
$params['url'] = $link;
- //$params['description'] = bbcode($body);
- $params['description'] = bbcode($b["body"]);
+ $params['description'] = bbcode($b["body"], false, false);
} else {
$params['type'] = "regular";
$params['title'] = $title;
- $params['body'] = bbcode($b['body']);
+ $params['body'] = bbcode($b['body'], false, false);
}
$x = post_url($tmbl_blog,$params);
}
// ok, all the links we want to send out are save, now strip
// away the remaining bbcode
- $msg = strip_tags(bbcode($tmp, false, false));
+ //$msg = strip_tags(bbcode($tmp, false, false));
+ $msg = bbcode($tmp, false, false);
+ $msg = str_replace(array('<br>','<br />'),"\n",$msg);
+ $msg = strip_tags($msg);
+
// quotes not working - let's try this
$msg = html_entity_decode($msg);
if (( strlen($msg) > $max_char) && $max_char > 0) {
$msg = implode(' ', $e);
$msg .= '... ' . $shortlink;
}
+
+ $msg = trim($msg);
+
// and now tweet it :-)
if(strlen($msg)) {
$result = $tweet->post('statuses/update', array('status' => $msg));