function diaspora2bb($s) { $s = html_entity_decode($s, ENT_COMPAT, 'UTF-8'); $s = preg_replace('/\\@\\{(.+?)\\; (.+?)\\@(.+?)\\}/', '@[url=https://$3/u/$2]$1[/url]', $s); $s = Markdown($s); $s = html2bbcode($s); // $s = str_replace('*','*',$s); $s = preg_replace("/\\[url\\=?(.*?)\\]https?:\\/\\/www.youtube.com\\/watch\\?v\\=(.*?)\\[\\/url\\]/ism", '[youtube]$2[/youtube]', $s); $s = preg_replace("/\\[url\\=https?:\\/\\/www.youtube.com\\/watch\\?v\\=(.*?)\\].*?\\[\\/url\\]/ism", '[youtube]$1[/youtube]', $s); $s = preg_replace("/\\[url\\=?(.*?)\\]https?:\\/\\/vimeo.com\\/([0-9]+)(.*?)\\[\\/url\\]/ism", '[vimeo]$2[/vimeo]', $s); $s = preg_replace("/\\[url\\=https?:\\/\\/vimeo.com\\/([0-9]+)\\](.*?)\\[\\/url\\]/ism", '[vimeo]$1[/vimeo]', $s); $s = preg_replace("/([^\\]\\=]|^)(https?\\:\\/\\/)(vimeo|youtu|www\\.youtube|soundcloud)([a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", '$1[url]$2$3$4[/url]', $s); // remove duplicate adjacent code tags $s = preg_replace("/(\\[code\\])+(.*?)(\\[\\/code\\])+/ism", "[code]\$2[/code]", $s); $s = scale_diaspora_images($s); return $s; }
function diaspora_photo($importer, $xml, $msg) { $a = get_app(); $remote_photo_path = notags(unxmlify($xml->remote_photo_path)); $remote_photo_name = notags(unxmlify($xml->remote_photo_name)); $status_message_guid = notags(unxmlify($xml->status_message_guid)); $guid = notags(unxmlify($xml->guid)); $diaspora_handle = notags(unxmlify($xml->diaspora_handle)); $public = notags(unxmlify($xml->public)); $created_at = notags(unxmlify($xml_created_at)); $contact = diaspora_get_contact_by_handle($importer['uid'], $msg['author']); if (!$contact) { return; } if ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['blocked'] || $contact['readonly']) { logger('diaspora_photo: Ignoring this author.'); return 202; } $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1", intval($importer['uid']), dbesc($status_message_guid)); if (!count($r)) { logger('diaspora_photo: parent item not found: parent: ' . $parent_guid . ' item: ' . $guid); return; } $parent_item = $r[0]; $link_text = '[img]' . $remote_photo_path . $remote_photo_name . '[/img]' . "\n"; $link_text = scale_diaspora_images($link_text); if (strpos($parent_item['body'], $link_text) === false) { $r = q("update item set `body` = '%s', `visible` = 1 where `id` = %d and `uid` = %d limit 1", dbesc($link_text . $parent_item['body']), intval($parent_item['id']), intval($parent_item['uid'])); } return; }