if($parent)
$_REQUEST['type'] = 'net-comment';
else {
+// logger("api_statuses_update: upload ".print_r($_FILES, true)." ".print_r($_POST, true)." ".print_r($_GET, true), LOGGER_DEBUG);
+//die("blubb");
$_REQUEST['type'] = 'wall';
if(x($_FILES,'media')) {
// upload the image if we have one
return $ret;
}
- function api_get_entitities($text, $bbcode) {
+ function api_get_entitities(&$text, $bbcode) {
/*
To-Do:
* Links at the first character of the post
- * different sizes of pictures
- * caching picture data (using the id for that?) (See privacy_image_cache)
*/
+ $a = get_app();
+
+ $result = q("SELECT `installed` FROM `addon` WHERE `name` = 'privacy_image_cache' AND `installed`");
+ $image_cache = (count($result) > 0);
+
$include_entities = strtolower(x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:"false");
- if ($include_entities != "true")
+ if ($include_entities != "true") {
+ if ($image_cache) {
+ require_once("addon/privacy_image_cache/privacy_image_cache.php");
+
+ preg_match_all("/\[img](.*?)\[\/img\]/ism", $bbcode, $images);
+
+ foreach ($images[1] AS $image) {
+ $replace = $a->get_baseurl()."/privacy_image_cache/".privacy_image_cache_cachename($image);
+ $text = str_replace($image, $replace, $text);
+ }
+ }
return array();
+ }
$bbcode = bb_CleanPictureLinks($bbcode);
'[url=https://www.youtube.com/watch?v=$1]https://www.youtube.com/watch?v=$1[/url]', $bbcode);
$bbcode = preg_replace("/\[youtube\](.*?)\[\/youtube\]/ism",'[url=$1]$1[/url]',$bbcode);
- $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism",
+ $bbcode = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism",
'[url=https://vimeo.com/$1]https://vimeo.com/$1[/url]', $bbcode);
$bbcode = preg_replace("/\[vimeo\](.*?)\[\/vimeo\]/ism",'[url=$1]$1[/url]',$bbcode);
$start = iconv_strpos($text, $url, $offset, "UTF-8");
if (!($start === false)) {
- $redirects = 0;
- $img_str = fetch_url($url,true, $redirects, 10);
- $image = @imagecreatefromstring($img_str);
+ require_once("include/Photo.php");
+ $image = get_photo_info($url);
if ($image) {
+ // If privacy_image_cache is activated, then use the following sizes:
+ // thumb (150), small (340), medium (600) and large (1024)
+ if ($image_cache) {
+ require_once("addon/privacy_image_cache/privacy_image_cache.php");
+ $media_url = $a->get_baseurl()."/privacy_image_cache/".privacy_image_cache_cachename($url);
+
+ $sizes = array();
+ $scale = scale_image($image[0], $image[1], 150);
+ $sizes["thumb"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
+
+ if (($image[0] > 150) OR ($image[1] > 150)) {
+ $scale = scale_image($image[0], $image[1], 340);
+ $sizes["small"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
+ }
+
+ $scale = scale_image($image[0], $image[1], 600);
+ $sizes["medium"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
+
+ if (($image[0] > 600) OR ($image[1] > 600)) {
+ $scale = scale_image($image[0], $image[1], 1024);
+ $sizes["large"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
+ }
+ } else {
+ $media_url = $url;
+ $sizes["medium"] = array("w" => $image[0], "h" => $image[1], "resize" => "fit");
+ }
+
$entities["media"][] = array(
"id" => $start+1,
"id_str" => (string)$start+1,
"indices" => array($start, $start+strlen($url)),
- "media_url" => $url,
- "media_url_https" => $url,
+ "media_url" => normalise_link($media_url),
+ "media_url_https" => $media_url,
"url" => $url,
"display_url" => $display_url,
"expanded_url" => $url,
"type" => "photo",
- "sizes" => array("medium" => array(
- "w" => imagesx($image),
- "h" => imagesy($image),
- "resize" => "fit")));
+ "sizes" => $sizes);
}
$offset = $start + 1;
}
'truncated' => False,
'created_at'=> api_date($item['created']),
'in_reply_to_status_id' => $in_reply_to_status_id,
- 'in_reply_to_status_id_str' => $in_reply_to_status_id,
+ 'in_reply_to_status_id_str' => $in_reply_to_status_id_str,
'source' => (($item['app']) ? $item['app'] : 'web'),
'id' => intval($item['id']),
'id_str' => (string) intval($item['id']),
'in_reply_to_user_id' => $in_reply_to_user_id,
- 'in_reply_to_user_id_str' => $in_reply_to_user_id,
+ 'in_reply_to_user_id_str' => $in_reply_to_user_id_str,
'in_reply_to_screen_name' => $in_reply_to_screen_name,
'geo' => NULL,
'favorited' => $item['starred'] ? true : false,