当前位置: 首页>>代码示例>>PHP>>正文


PHP scale_external_images函数代码示例

本文整理汇总了PHP中scale_external_images函数的典型用法代码示例。如果您正苦于以下问题:PHP scale_external_images函数的具体用法?PHP scale_external_images怎么用?PHP scale_external_images使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了scale_external_images函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: diaspora2bb

function diaspora2bb($s)
{
    $s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
    // Remove CR to avoid problems with following code
    $s = str_replace("\r", "", $s);
    $s = str_replace("\n", " \n", $s);
    // The parser cannot handle paragraphs correctly
    $s = str_replace(array("</p>", "<p>", '<p dir="ltr">'), array("<br>", "<br>", "<br>"), $s);
    // Escaping the hash tags
    $s = preg_replace('/\\#([^\\s\\#])/', '&#35;$1', $s);
    $s = Markdown($s);
    $s = preg_replace('/\\@\\{(.+?)\\; (.+?)\\@(.+?)\\}/', '@[url=https://$3/u/$2]$1[/url]', $s);
    $s = str_replace('&#35;', '#', $s);
    $s = html2bbcode($s);
    // protect the recycle symbol from turning into a tag, but without unescaping angles and naked ampersands
    $s = str_replace('&#x2672;', html_entity_decode('&#x2672;', ENT_QUOTES, 'UTF-8'), $s);
    // Convert everything that looks like a link to a link
    $s = preg_replace("/([^\\]\\=]|^)(https?\\:\\/\\/)([a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", '$1[url=$2$3]$2$3[/url]', $s);
    //$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3$4]$2$3$4[/url]',$s);
    $s = bb_tag_preg_replace("/\\[url\\=?(.*?)\\]https?:\\/\\/www.youtube.com\\/watch\\?v\\=(.*?)\\[\\/url\\]/ism", '[youtube]$2[/youtube]', 'url', $s);
    $s = bb_tag_preg_replace("/\\[url\\=https?:\\/\\/www.youtube.com\\/watch\\?v\\=(.*?)\\].*?\\[\\/url\\]/ism", '[youtube]$1[/youtube]', 'url', $s);
    $s = bb_tag_preg_replace("/\\[url\\=?(.*?)\\]https?:\\/\\/vimeo.com\\/([0-9]+)(.*?)\\[\\/url\\]/ism", '[vimeo]$2[/vimeo]', 'url', $s);
    $s = bb_tag_preg_replace("/\\[url\\=https?:\\/\\/vimeo.com\\/([0-9]+)\\](.*?)\\[\\/url\\]/ism", '[vimeo]$1[/vimeo]', 'url', $s);
    // remove duplicate adjacent code tags
    $s = preg_replace("/(\\[code\\])+(.*?)(\\[\\/code\\])+/ism", "[code]\$2[/code]", $s);
    // Don't show link to full picture (until it is fixed)
    $s = scale_external_images($s, false);
    return $s;
}
开发者ID:strk,项目名称:friendica,代码行数:29,代码来源:bb2diaspora.php

示例2: diaspora2bb

function diaspora2bb($s)
{
    // for testing purposes: Collect raw markdown articles
    // $file = tempnam("/tmp/friendica/", "markdown");
    // file_put_contents($file, $s);
    $s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
    // Too many new lines. So deactivated the following line
    // $s = str_replace("\r","\n",$s);
    // Simply remove cr.
    $s = str_replace("\r", "", $s);
    // <br/> is invalid. Replace it with the valid expression
    $s = str_replace("<br/>", "<br />", $s);
    $s = preg_replace('/\\@\\{(.+?)\\; (.+?)\\@(.+?)\\}/', '@[url=https://$3/u/$2]$1[/url]', $s);
    // Escaping the hash tags - doesn't always seem to work
    // $s = preg_replace('/\#([^\s\#])/','\\#$1',$s);
    // This seems to work
    $s = preg_replace('/\\#([^\\s\\#])/', '&#35;$1', $s);
    $s = Markdown($s);
    $s = str_replace('&#35;', '#', $s);
    $s = str_replace("\n", '<br />', $s);
    $s = html2bbcode($s);
    //	$s = str_replace('&#42;','*',$s);
    // Convert everything that looks like a link to a link
    $s = preg_replace("/([^\\]\\=]|^)(https?\\:\\/\\/)([a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", '$1[url=$2$3]$2$3[/url]', $s);
    //$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3$4]$2$3$4[/url]',$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);
    // remove duplicate adjacent code tags
    $s = preg_replace("/(\\[code\\])+(.*?)(\\[\\/code\\])+/ism", "[code]\$2[/code]", $s);
    // Don't show link to full picture (until it is fixed)
    $s = scale_external_images($s, false);
    return $s;
}
开发者ID:robhell,项目名称:friendica,代码行数:35,代码来源:bb2diaspora.php

示例3: diaspora_photo

function diaspora_photo($importer, $xml, $msg, $attempt = 1)
{
    $a = get_app();
    logger('diaspora_photo: init', LOGGER_DEBUG);
    $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));
    logger('diaspora_photo: status_message_guid: ' . $status_message_guid, LOGGER_DEBUG);
    $contact = diaspora_get_contact_by_handle($importer['uid'], $msg['author']);
    if (!$contact) {
        logger('diaspora_photo: contact record not found: ' . $msg['author'] . ' handle: ' . $diaspora_handle);
        return;
    }
    if (!diaspora_post_allow($importer, $contact, false)) {
        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));
    /*	deactivated by now since it can lead to multiplicated pictures in posts.
    	if(!count($r)) {
    		$result = diaspora_store_by_guid($status_message_guid, $contact['url'], $importer['uid']);
    
    		if (!$result) {
    			$person = find_diaspora_person_by_handle($diaspora_handle);
    			$result = diaspora_store_by_guid($status_message_guid, $person['url'], $importer['uid']);
    		}
    
    		if ($result) {
    			logger("Fetched missing item ".$status_message_guid." - result: ".$result, LOGGER_DEBUG);
    
    			$r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
    				intval($importer['uid']),
    				dbesc($status_message_guid)
    			);
    		}
    	}
    */
    if (!count($r)) {
        if ($attempt <= 3) {
            q("INSERT INTO dsprphotoq (uid, msg, attempt) VALUES (%d, '%s', %d)", intval($importer['uid']), dbesc(serialize($msg)), intval($attempt + 1));
        }
        logger('diaspora_photo: attempt = ' . $attempt . '; status message not found: ' . $status_message_guid . ' for photo: ' . $guid);
        return;
    }
    $parent_item = $r[0];
    $link_text = '[img]' . $remote_photo_path . $remote_photo_name . '[/img]' . "\n";
    $link_text = scale_external_images($link_text, true, array($remote_photo_name, 'scaled_full_' . $remote_photo_name));
    if (strpos($parent_item['body'], $link_text) === false) {
        $r = q("UPDATE `item` SET `body` = '%s', `visible` = 1 WHERE `id` = %d AND `uid` = %d", dbesc($link_text . $parent_item['body']), intval($parent_item['id']), intval($parent_item['uid']));
        update_thread($parent_item['id']);
    }
    return;
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:57,代码来源:diaspora.php

示例4: diaspora_asphoto

function diaspora_asphoto($importer, $xml, $msg)
{
    logger('diaspora_asphoto called');
    $a = get_app();
    $guid = notags(unxmlify($xml->guid));
    $diaspora_handle = notags(unxmlify($xml->diaspora_handle));
    if ($diaspora_handle != $msg['author']) {
        logger('diaspora_post: Potential forgery. Message handle is not the same as envelope sender.');
        return 202;
    }
    $contact = diaspora_get_contact_by_handle($importer['channel_id'], $diaspora_handle);
    if (!$contact) {
        return;
    }
    if (!perm_is_allowed($importer['channel_id'], $contact['xchan_hash'], 'send_stream')) {
        logger('diaspora_asphoto: Ignoring this author.');
        return 202;
    }
    $message_id = $diaspora_handle . ':' . $guid;
    $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `guid` = '%s' LIMIT 1", intval($importer['channel_id']), dbesc($message_id), dbesc($guid));
    if (count($r)) {
        logger('diaspora_asphoto: message exists: ' . $guid);
        return;
    }
    // allocate a guid on our system - we aren't fixing any collisions.
    // we're ignoring them
    $g = q("select * from guid where guid = '%s' limit 1", dbesc($guid));
    if (!count($g)) {
        q("insert into guid ( guid ) values ( '%s' )", dbesc($guid));
    }
    $created = unxmlify($xml->created_at);
    $private = unxmlify($xml->public) == 'false' ? 1 : 0;
    if (strlen($xml->objectId) && $xml->objectId != 0 && $xml->image_url) {
        $body = '[url=' . notags(unxmlify($xml->image_url)) . '][img]' . notags(unxmlify($xml->objectId)) . '[/img][/url]' . "\n";
        $body = scale_external_images($body, false);
    } elseif ($xml->image_url) {
        $body = '[img]' . notags(unxmlify($xml->image_url)) . '[/img]' . "\n";
        $body = scale_external_images($body);
    } else {
        logger('diaspora_asphoto: no photo url found.');
        return;
    }
    $plink = 'https://' . substr($diaspora_handle, strpos($diaspora_handle, '@') + 1) . '/posts/' . $guid;
    $datarray = array();
    $datarray['uid'] = $importer['channel_id'];
    $datarray['contact-id'] = $contact['id'];
    $datarray['wall'] = 0;
    $datarray['network'] = NETWORK_DIASPORA;
    $datarray['guid'] = $guid;
    $datarray['uri'] = $datarray['parent-uri'] = $message_id;
    $datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert('UTC', 'UTC', $created);
    $datarray['private'] = $private;
    $datarray['parent'] = 0;
    $datarray['plink'] = $plink;
    $datarray['owner-name'] = $contact['name'];
    $datarray['owner-link'] = $contact['url'];
    //$datarray['owner-avatar'] = $contact['thumb'];
    $datarray['owner-avatar'] = x($contact, 'thumb') ? $contact['thumb'] : $contact['photo'];
    $datarray['author-name'] = $contact['name'];
    $datarray['author-link'] = $contact['url'];
    $datarray['author-avatar'] = $contact['thumb'];
    $datarray['body'] = $body;
    $datarray['app'] = 'Diaspora/Cubbi.es';
    $message_id = item_store($datarray);
    //if($message_id) {
    //	q("update item set plink = '%s' where id = %d",
    //		dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
    //		intval($message_id)
    //	);
    //}
    return;
}
开发者ID:Mauru,项目名称:red,代码行数:72,代码来源:diaspora.php

示例5: item_post


//.........这里部分代码省略.........
        // First figure out if it's a status post that would've been
        // created using tinymce. Otherwise leave it alone.
        $plaintext = true;
        //		$plaintext = ((feature_enabled($profile_uid,'richtext')) ? false : true);
        //		if((! $parent) && (! $api_source) && (! $plaintext)) {
        //			$body = fix_mce_lf($body);
        //		}
        // If we're sending a private top-level message with a single @-taggable channel as a recipient, @-tag it, if our pconfig is set.
        if (!$parent && get_pconfig($profile_uid, 'system', 'tagifonlyrecip') && substr_count($str_contact_allow, '<') == 1 && $str_group_allow == '' && $str_contact_deny == '' && $str_group_deny == '') {
            $x = q("select abook_id, abook_their_perms from abook where abook_xchan = '%s' and abook_channel = %d limit 1", dbesc(str_replace(array('<', '>'), array('', ''), $str_contact_allow)), intval($profile_uid));
            if ($x && $x[0]['abook_their_perms'] & PERMS_W_TAGWALL) {
                $body .= "\n\n@group+" . $x[0]['abook_id'] . "\n";
            }
        }
        /**
         * fix naked links by passing through a callback to see if this is a red site
         * (already known to us) which will get a zrl, otherwise link with url, add bookmark tag to both.
         * First protect any url inside certain bbcode tags so we don't double link it.
         */
        $body = preg_replace_callback('/\\[code(.*?)\\[\\/(code)\\]/ism', 'red_escape_codeblock', $body);
        $body = preg_replace_callback('/\\[url(.*?)\\[\\/(url)\\]/ism', 'red_escape_codeblock', $body);
        $body = preg_replace_callback('/\\[zrl(.*?)\\[\\/(zrl)\\]/ism', 'red_escape_codeblock', $body);
        $body = preg_replace_callback("/([^\\]\\='" . '"' . "\\/]|^|\\#\\^)(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\@\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", 'red_zrl_callback', $body);
        $body = preg_replace_callback('/\\[\\$b64zrl(.*?)\\[\\/(zrl)\\]/ism', 'red_unescape_codeblock', $body);
        $body = preg_replace_callback('/\\[\\$b64url(.*?)\\[\\/(url)\\]/ism', 'red_unescape_codeblock', $body);
        $body = preg_replace_callback('/\\[\\$b64code(.*?)\\[\\/(code)\\]/ism', 'red_unescape_codeblock', $body);
        // fix any img tags that should be zmg
        $body = preg_replace_callback('/\\[img(.*?)\\](.*?)\\[\\/img\\]/ism', 'red_zrlify_img_callback', $body);
        $body = bb_translate_video($body);
        /**
         * Fold multi-line [code] sequences
         */
        $body = preg_replace('/\\[\\/code\\]\\s*\\[code\\]/ism', "\n", $body);
        $body = scale_external_images($body, false);
        // Look for tags and linkify them
        $results = linkify_tags($a, $body, $uid ? $uid : $profile_uid);
        if ($results) {
            // Set permissions based on tag replacements
            set_linkified_perms($results, $str_contact_allow, $str_group_allow, $profile_uid, $parent_item, $private);
            $post_tags = array();
            foreach ($results as $result) {
                $success = $result['success'];
                if ($success['replaced']) {
                    $post_tags[] = array('uid' => $profile_uid, 'type' => $success['termtype'], 'otype' => TERM_OBJ_POST, 'term' => $success['term'], 'url' => $success['url']);
                }
            }
        }
        /**
         *
         * When a photo was uploaded into the message using the (profile wall) ajax 
         * uploader, The permissions are initially set to disallow anybody but the
         * owner from seeing it. This is because the permissions may not yet have been
         * set for the post. If it's private, the photo permissions should be set
         * appropriately. But we didn't know the final permissions on the post until
         * now. So now we'll look for links of uploaded photos and attachments that are in the
         * post and set them to the same permissions as the post itself.
         *
         * If the post was end-to-end encrypted we can't find images and attachments in the body,
         * use our media_str input instead which only contains these elements - but only do this
         * when encrypted content exists because the photo/attachment may have been removed from 
         * the post and we should keep it private. If it's encrypted we have no way of knowing
         * so we'll set the permissions regardless and realise that the media may not be 
         * referenced in the post. 
         *
         * What is preventing us from being able to upload photos into comments is dealing with
         * the photo and attachment permissions, since we don't always know who was in the 
开发者ID:einervonvielen,项目名称:redmatrix,代码行数:67,代码来源:item.php

示例6: item_post


//.........这里部分代码省略.........
                if (!count($r)) {
                    continue;
                }
                $r = q("UPDATE `photo` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'\n\t\t\t\t\tWHERE `resource-id` = '%s' AND `uid` = %d AND `album` = '%s' ", dbesc($str_contact_allow), dbesc($str_group_allow), dbesc($str_contact_deny), dbesc($str_group_deny), dbesc($image_uri), intval($profile_uid), dbesc(t('Wall Photos')));
            }
        }
    }
    /**
     * Next link in any attachment references we find in the post.
     */
    $match = false;
    if (!$preview && preg_match_all("/\\[attachment\\](.*?)\\[\\/attachment\\]/", $body, $match)) {
        $attaches = $match[1];
        if (count($attaches)) {
            foreach ($attaches as $attach) {
                $r = q("SELECT * FROM `attach` WHERE `uid` = %d AND `id` = %d LIMIT 1", intval($profile_uid), intval($attach));
                if (count($r)) {
                    $r = q("UPDATE `attach` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'\n\t\t\t\t\t\tWHERE `uid` = %d AND `id` = %d", dbesc($str_contact_allow), dbesc($str_group_allow), dbesc($str_contact_deny), dbesc($str_group_deny), intval($profile_uid), intval($attach));
                }
            }
        }
    }
    // embedded bookmark in post? set bookmark flag
    $bookmark = 0;
    if (preg_match_all("/\\[bookmark\\=([^\\]]*)\\](.*?)\\[\\/bookmark\\]/ism", $body, $match, PREG_SET_ORDER)) {
        $objecttype = ACTIVITY_OBJ_BOOKMARK;
        $bookmark = 1;
    }
    $body = bb_translate_video($body);
    /**
     * Fold multi-line [code] sequences
     */
    $body = preg_replace('/\\[\\/code\\]\\s*\\[code\\]/ism', "\n", $body);
    $body = scale_external_images($body, false);
    // Setting the object type if not defined before
    if (!$objecttype) {
        $objecttype = ACTIVITY_OBJ_NOTE;
        // Default value
        require_once "include/plaintext.php";
        $objectdata = get_attached_data($body);
        if ($post["type"] == "link") {
            $objecttype = ACTIVITY_OBJ_BOOKMARK;
        } elseif ($post["type"] == "video") {
            $objecttype = ACTIVITY_OBJ_VIDEO;
        } elseif ($post["type"] == "photo") {
            $objecttype = ACTIVITY_OBJ_IMAGE;
        }
    }
    /**
     * Look for any tags and linkify them
     */
    $str_tags = '';
    $inform = '';
    $tags = get_tags($body);
    /**
     * add a statusnet style reply tag if the original post was from there
     * and we are replying, and there isn't one already
     */
    if ($parent_contact && $parent_contact['network'] === NETWORK_OSTATUS && $parent_contact['nick'] && !in_array('@' . $parent_contact['nick'], $tags)) {
        $body = '@' . $parent_contact['nick'] . ' ' . $body;
        $tags[] = '@' . $parent_contact['nick'];
    }
    $tagged = array();
    $private_forum = false;
    if (count($tags)) {
        foreach ($tags as $tag) {
开发者ID:strk,项目名称:friendica,代码行数:67,代码来源:item.php

示例7: diaspora2bb

function diaspora2bb($s, $use_zrl = false)
{
    $s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
    // Too many new lines. So deactivated the following line
    // $s = str_replace("\r","\n",$s);
    // Simply remove cr.
    $s = str_replace("\r", "", $s);
    // <br/> is invalid. Replace it with the valid expression
    $s = str_replace("<br/>", "<br />", $s);
    $s = str_replace("\n", "<br />", $s);
    //	$s = preg_replace('/\@\{(.+?)\; (.+?)\@(.+?)\}/','@[url=https://$3/u/$2]$1[/url]',$s);
    // first try plustags
    $s = preg_replace_callback('/\\@\\{(.+?)\\; (.+?)\\@(.+?)\\}\\+/', 'diaspora_mention_callback', $s);
    $s = preg_replace_callback('/\\@\\{(.+?)\\; (.+?)\\@(.+?)\\}/', 'diaspora_mention_callback', $s);
    // Escaping the hash tags - doesn't always seem to work
    // $s = preg_replace('/\#([^\s\#])/','\\#$1',$s);
    // This seems to work
    $s = preg_replace('/\\#([^\\s\\#])/', '&#35;$1', $s);
    $s = preg_replace_callback('/\\[share(.*?)\\]/ism', 'share_shield', $s);
    $s = Markdown($s);
    $s = str_replace('&#35;', '#', $s);
    // we seem to have double linebreaks
    //	$s = str_replace("\n",'<br />',$s);
    $s = html2bbcode($s);
    //	$s = str_replace('&#42;','*',$s);
    // protect the recycle symbol from turning into a tag, but without unescaping angles and naked ampersands
    $s = str_replace('&#x2672;', html_entity_decode('&#x2672;', ENT_QUOTES, 'UTF-8'), $s);
    // Convert everything that looks like a link to a link
    if ($use_zrl) {
        $s = str_replace(array('[img', '/img]'), array('[zmg', '/zmg]'), $s);
        $s = preg_replace("/([^\\]\\=]|^)(https?\\:\\/\\/)([a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", '$1[zrl=$2$3]$2$3[/zrl]', $s);
    } else {
        $s = preg_replace("/([^\\]\\=]|^)(https?\\:\\/\\/)([a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", '$1[url=$2$3]$2$3[/url]', $s);
    }
    //$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3$4]$2$3$4[/url]',$s);
    $s = bb_tag_preg_replace("/\\[url\\=?(.*?)\\]https?:\\/\\/www.youtube.com\\/watch\\?v\\=(.*?)\\[\\/url\\]/ism", '[youtube]$2[/youtube]', 'url', $s);
    $s = bb_tag_preg_replace("/\\[url\\=https?:\\/\\/www.youtube.com\\/watch\\?v\\=(.*?)\\].*?\\[\\/url\\]/ism", '[youtube]$1[/youtube]', 'url', $s);
    $s = bb_tag_preg_replace("/\\[url\\=?(.*?)\\]https?:\\/\t\\/vimeo.com\\/([0-9]+)(.*?)\\[\\/url\\]/ism", '[vimeo]$2[/vimeo]', 'url', $s);
    $s = bb_tag_preg_replace("/\\[url\\=https?:\\/\\/vimeo.com\\/([0-9]+)\\](.*?)\\[\\/url\\]/ism", '[vimeo]$1[/vimeo]', 'url', $s);
    // remove duplicate adjacent code tags
    $s = preg_replace("/(\\[code\\])+(.*?)(\\[\\/code\\])+/ism", "[code]\$2[/code]", $s);
    $s = preg_replace_callback('/\\[share(.*?)\\]/ism', 'share_unshield', $s);
    // Don't show link to full picture (until it is fixed)
    $s = scale_external_images($s, false);
    return $s;
}
开发者ID:Mauru,项目名称:red,代码行数:46,代码来源:bb2diaspora.php

示例8: diaspora_photo

function diaspora_photo($importer, $xml, $msg)
{
    $a = get_app();
    logger('diaspora_photo: init', LOGGER_DEBUG);
    $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));
    logger('diaspora_photo: status_message_guid: ' . $status_message_guid, LOGGER_DEBUG);
    $contact = diaspora_get_contact_by_handle($importer['uid'], $msg['author']);
    if (!$contact) {
        logger('diaspora_photo: contact record not found: ' . $msg['author'] . ' handle: ' . $diaspora_handle);
        return;
    }
    if (!diaspora_post_allow($importer, $contact)) {
        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_external_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;
}
开发者ID:robhell,项目名称:friendica,代码行数:34,代码来源:diaspora.php

示例9: diaspora_asphoto

function diaspora_asphoto($importer, $xml, $msg)
{
    // This call is believed to be obsolete since 2011-2012 and has not been ported
    // from the original Friendica implementation. The code remains in case it is
    // ever reimplemented in Diaspora, though it is unlikely that will occur in the
    // same context.
    logger('diaspora_asphoto called');
    $a = get_app();
    $guid = notags(unxmlify($xml['guid']));
    $diaspora_handle = notags(diaspora_get_author($xml));
    if ($diaspora_handle != $msg['author']) {
        logger('diaspora_post: Potential forgery. Message handle is not the same as envelope sender.');
        return 202;
    }
    $contact = diaspora_get_contact_by_handle($importer['channel_id'], $diaspora_handle);
    if (!$contact) {
        return;
    }
    if (!$importer['system'] && !perm_is_allowed($importer['channel_id'], $contact['xchan_hash'], 'send_stream')) {
        logger('diaspora_asphoto: Ignoring this author.');
        return 202;
    }
    $message_id = $diaspora_handle . ':' . $guid;
    $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `guid` = '%s' LIMIT 1", intval($importer['channel_id']), dbesc($message_id), dbesc($guid));
    if (count($r)) {
        logger('diaspora_asphoto: message exists: ' . $guid);
        return;
    }
    // allocate a guid on our system - we aren't fixing any collisions.
    // we're ignoring them
    $g = q("select * from guid where guid = '%s' limit 1", dbesc($guid));
    if (!count($g)) {
        q("insert into guid ( guid ) values ( '%s' )", dbesc($guid));
    }
    $created = unxmlify($xml['created_at']);
    $private = unxmlify($xml['public']) == 'false' ? 1 : 0;
    if (strlen($xml['objectId']) && $xml['objectId'] != 0 && $xml['image_url']) {
        $body = '[url=' . notags(unxmlify($xml['image_url'])) . '][img]' . notags(unxmlify($xml['objectId'])) . '[/img][/url]' . "\n";
        $body = scale_external_images($body, false);
    } elseif ($xml['image_url']) {
        $body = '[img]' . notags(unxmlify($xml['image_url'])) . '[/img]' . "\n";
        $body = scale_external_images($body);
    } else {
        logger('diaspora_asphoto: no photo url found.');
        return;
    }
    $plink = service_plink($contact, $guid);
    $datarray = array();
    $datarray['uid'] = $importer['channel_id'];
    $datarray['contact-id'] = $contact['id'];
    $datarray['wall'] = 0;
    $datarray['network'] = NETWORK_DIASPORA;
    $datarray['guid'] = $guid;
    $datarray['uri'] = $datarray['parent-uri'] = $message_id;
    $datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert('UTC', 'UTC', $created);
    $datarray['private'] = $private;
    $datarray['parent'] = 0;
    $datarray['plink'] = $plink;
    $datarray['owner-name'] = $contact['name'];
    $datarray['owner-link'] = $contact['url'];
    //$datarray['owner-avatar'] = $contact['thumb'];
    $datarray['owner-avatar'] = x($contact, 'thumb') ? $contact['thumb'] : $contact['photo'];
    $datarray['author-name'] = $contact['name'];
    $datarray['author-link'] = $contact['url'];
    $datarray['author-avatar'] = $contact['thumb'];
    $datarray['body'] = $body;
    $datarray['app'] = 'Diaspora/Cubbi.es';
    $result = item_store($datarray);
    if ($result['success']) {
        sync_an_item($importer['channel_id'], $result['item_id']);
    }
    return;
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:73,代码来源:inbound.php

示例10: diaspora_reshare

function diaspora_reshare($importer, $xml, $msg)
{
    logger('diaspora_reshare: init: ' . print_r($xml, true), LOGGER_DATA);
    $a = get_app();
    $guid = notags(unxmlify($xml['guid']));
    $diaspora_handle = notags(diaspora_get_author($xml));
    if ($diaspora_handle != $msg['author']) {
        logger('Potential forgery. Message handle is not the same as envelope sender.');
        return 202;
    }
    $contact = diaspora_get_contact_by_handle($importer['channel_id'], $diaspora_handle);
    if (!$contact) {
        return;
    }
    $search_guid = strlen($guid) == 64 ? $guid . '%' : $guid;
    $r = q("SELECT id FROM item WHERE uid = %d AND mid like '%s' LIMIT 1", intval($importer['channel_id']), dbesc($search_guid));
    if ($r) {
        logger('diaspora_reshare: message exists: ' . $guid);
        return;
    }
    $orig_author = notags(diaspora_get_root_author($xml));
    $orig_guid = notags(unxmlify($xml['root_guid']));
    $source_url = 'https://' . substr($orig_author, strpos($orig_author, '@') + 1) . '/p/' . $orig_guid . '.xml';
    $orig_url = 'https://' . substr($orig_author, strpos($orig_author, '@') + 1) . '/posts/' . $orig_guid;
    $source_xml = get_diaspora_reshare_xml($source_url);
    if ($source_xml['status_message']) {
        $body = diaspora2bb(diaspora_get_body($source_xml['status_message']));
        $orig_author = diaspora_get_author($source_xml['status_message']);
        $orig_guid = notags(unxmlify($source_xml['status_message']['guid']));
        // Checking for embedded pictures
        if ($source_xml['status_message']['photo']['remote_photo_path'] && $source_xml['status_message']['photo']['remote_photo_name']) {
            $remote_photo_path = notags(unxmlify($source_xml['status_message']['photo']['remote_photo_path']));
            $remote_photo_name = notags(unxmlify($source_xml['status_message']['photo']['remote_photo_name']));
            $body = '[img]' . $remote_photo_path . $remote_photo_name . '[/img]' . "\n" . $body;
            logger('diaspora_reshare: embedded picture link found: ' . $body, LOGGER_DEBUG);
        }
        $body = scale_external_images($body);
        // Add OEmbed and other information to the body
        //		$body = add_page_info_to_body($body, false, true);
    } else {
        // Maybe it is a reshare of a photo that will be delivered at a later time (testing)
        logger('diaspora_reshare: no reshare content found: ' . print_r($source_xml, true));
        $body = "";
        //return;
    }
    $maxlen = get_max_import_size();
    if ($maxlen && mb_strlen($body) > $maxlen) {
        $body = mb_substr($body, 0, $maxlen, 'UTF-8');
        logger('message length exceeds max_import_size: truncated');
    }
    $person = find_diaspora_person_by_handle($orig_author);
    if ($person) {
        $orig_author_name = $person['xchan_name'];
        $orig_author_link = $person['xchan_url'];
        $orig_author_photo = $person['xchan_photo_m'];
    }
    $created = unxmlify($xml['created_at']);
    $private = unxmlify($xml['public']) == 'false' ? 1 : 0;
    $datarray = array();
    // Look for tags and linkify them
    $results = linkify_tags(get_app(), $body, $importer['channel_id'], true);
    $datarray['term'] = array();
    if ($results) {
        foreach ($results as $result) {
            $success = $result['success'];
            if ($success['replaced']) {
                $datarray['term'][] = array('uid' => $importer['channel_id'], 'ttype' => $success['termtype'], 'otype' => TERM_OBJ_POST, 'term' => $success['term'], 'url' => $success['url']);
            }
        }
    }
    $cnt = preg_match_all('/@\\[url=(.*?)\\](.*?)\\[\\/url\\]/ism', $body, $matches, PREG_SET_ORDER);
    if ($cnt) {
        foreach ($matches as $mtch) {
            $datarray['term'][] = array('uid' => $importer['channel_id'], 'ttype' => TERM_MENTION, 'otype' => TERM_OBJ_POST, 'term' => $mtch[2], 'url' => $mtch[1]);
        }
    }
    $cnt = preg_match_all('/@\\[zrl=(.*?)\\](.*?)\\[\\/zrl\\]/ism', $body, $matches, PREG_SET_ORDER);
    if ($cnt) {
        foreach ($matches as $mtch) {
            // don't include plustags in the term
            $term = substr($mtch[2], -1, 1) === '+' ? substr($mtch[2], 0, -1) : $mtch[2];
            $datarray['term'][] = array('uid' => $importer['channel_id'], 'ttype' => TERM_MENTION, 'otype' => TERM_OBJ_POST, 'term' => $term, 'url' => $mtch[1]);
        }
    }
    $newbody = "[share author='" . urlencode($orig_author_name) . "' profile='" . $orig_author_link . "' avatar='" . $orig_author_photo . "' link='" . $orig_url . "' posted='" . datetime_convert('UTC', 'UTC', unxmlify($source_xml['status_message']['created_at'])) . "' message_id='" . unxmlify($source_xml['status_message']['guid']) . "']" . $body . "[/share]";
    $plink = service_plink($contact, $guid);
    $datarray['aid'] = $importer['channel_account_id'];
    $datarray['uid'] = $importer['channel_id'];
    $datarray['mid'] = $datarray['parent_mid'] = $guid;
    $datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert('UTC', 'UTC', $created);
    $datarray['item_private'] = $private;
    $datarray['plink'] = $plink;
    $datarray['owner_xchan'] = $contact['xchan_hash'];
    $datarray['author_xchan'] = $contact['xchan_hash'];
    $datarray['body'] = $newbody;
    $datarray['app'] = 'Diaspora';
    $tgroup = tgroup_check($importer['channel_id'], $datarray);
    if (!$importer['system'] && !perm_is_allowed($importer['channel_id'], $contact['xchan_hash'], 'send_stream') && !$tgroup) {
        logger('diaspora_reshare: Ignoring this author.');
        return 202;
//.........这里部分代码省略.........
开发者ID:phellmes,项目名称:hubzilla-addons,代码行数:101,代码来源:inbound.php

示例11: diaspora2bb

/**
 * @brief
 *
 * We don't want to support a bbcode specific markdown interpreter
 * and the markdown library we have is pretty good, but provides HTML output.
 * So we'll use that to convert to HTML, then convert the HTML back to bbcode,
 * and then clean up a few Diaspora specific constructs.
 *
 * @param string $s
 * @param boolean $use_zrl default false
 * @return string
 */
function diaspora2bb($s, $use_zrl = false)
{
    $s = str_replace("&#xD;", "\r", $s);
    $s = str_replace("&#xD;\n&gt;", "", $s);
    $s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
    // first try plustags
    $s = preg_replace_callback('/\\@\\{(.+?)\\; (.+?)\\@(.+?)\\}\\+/', 'diaspora_mention_callback', $s);
    $s = preg_replace_callback('/\\@\\{(.+?)\\; (.+?)\\@(.+?)\\}/', 'diaspora_mention_callback', $s);
    // Escaping the hash tags - doesn't always seem to work
    // $s = preg_replace('/\#([^\s\#])/','\\#$1',$s);
    // This seems to work
    $s = preg_replace('/\\#([^\\s\\#])/', '&#35;$1', $s);
    $s = Markdown($s);
    $s = str_replace("\r", "", $s);
    $s = str_replace('&#35;', '#', $s);
    $s = html2bbcode($s);
    // protect the recycle symbol from turning into a tag, but without unescaping angles and naked ampersands
    $s = str_replace('&#x2672;', html_entity_decode('&#x2672;', ENT_QUOTES, 'UTF-8'), $s);
    // Convert everything that looks like a link to a link
    if ($use_zrl) {
        $s = str_replace(array('[img', '/img]'), array('[zmg', '/zmg]'), $s);
        $s = preg_replace("/([^\\]\\=]|^)(https?\\:\\/\\/)([a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", '$1[zrl=$2$3]$2$3[/zrl]', $s);
    } else {
        $s = preg_replace("/([^\\]\\=]|^)(https?\\:\\/\\/)([a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", '$1[url=$2$3]$2$3[/url]', $s);
    }
    //$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3$4]$2$3$4[/url]',$s);
    $s = bb_tag_preg_replace("/\\[url\\=?(.*?)\\]https?:\\/\\/www.youtube.com\\/watch\\?v\\=(.*?)\\[\\/url\\]/ism", '[embed]https://www.youtube.com/watch?v=$2[/embed]', 'url', $s);
    $s = bb_tag_preg_replace("/\\[url\\=https?:\\/\\/www.youtube.com\\/watch\\?v\\=(.*?)\\].*?\\[\\/url\\]/ism", '[embed]https://www.youtube.com/watch?v=$1[/embed]', 'url', $s);
    $s = bb_tag_preg_replace("/\\[url\\=?(.*?)\\]https?:\\/\t\\/vimeo.com\\/([0-9]+)(.*?)\\[\\/url\\]/ism", '[embed]https://vimeo.com/$2[/embed]', 'url', $s);
    $s = bb_tag_preg_replace("/\\[url\\=https?:\\/\\/vimeo.com\\/([0-9]+)\\](.*?)\\[\\/url\\]/ism", '[embed]https://vimeo.com/$1[/embed]', 'url', $s);
    // remove duplicate adjacent code tags
    $s = preg_replace("/(\\[code\\])+(.*?)(\\[\\/code\\])+/ism", "[code]\$2[/code]", $s);
    // Don't show link to full picture (until it is fixed)
    $s = scale_external_images($s, false);
    return $s;
}
开发者ID:TamirAl,项目名称:hubzilla,代码行数:48,代码来源:bb2diaspora.php

示例12: post


//.........这里部分代码省略.........
         // created using tinymce. Otherwise leave it alone.
         $plaintext = true;
         //		$plaintext = ((feature_enabled($profile_uid,'richtext')) ? false : true);
         //		if((! $parent) && (! $api_source) && (! $plaintext)) {
         //			$body = fix_mce_lf($body);
         //		}
         // If we're sending a private top-level message with a single @-taggable channel as a recipient, @-tag it, if our pconfig is set.
         if (!$parent && get_pconfig($profile_uid, 'system', 'tagifonlyrecip') && substr_count($str_contact_allow, '<') == 1 && $str_group_allow == '' && $str_contact_deny == '' && $str_group_deny == '') {
             $x = q("select abook_id, abconfig.v from abook left join abconfig on abook_xchan = abconfig.xchan and abook_channel = abconfig.chan and cat= 'their_perms' and abconfig.k = 'tag_deliver' and abconfig.v = 1 and abook_xchan = '%s' and abook_channel = %d limit 1", dbesc(str_replace(array('<', '>'), array('', ''), $str_contact_allow)), intval($profile_uid));
             if ($x) {
                 $body .= "\n\n@group+" . $x[0]['abook_id'] . "\n";
             }
         }
         /**
          * fix naked links by passing through a callback to see if this is a hubzilla site
          * (already known to us) which will get a zrl, otherwise link with url, add bookmark tag to both.
          * First protect any url inside certain bbcode tags so we don't double link it.
          */
         $body = preg_replace_callback('/\\[code(.*?)\\[\\/(code)\\]/ism', '\\red_escape_codeblock', $body);
         $body = preg_replace_callback('/\\[url(.*?)\\[\\/(url)\\]/ism', '\\red_escape_codeblock', $body);
         $body = preg_replace_callback('/\\[zrl(.*?)\\[\\/(zrl)\\]/ism', '\\red_escape_codeblock', $body);
         $body = preg_replace_callback("/([^\\]\\='" . '"' . "\\/]|^|\\#\\^)(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\@\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", 'nakedoembed', $body);
         $body = preg_replace_callback("/([^\\]\\='" . '"' . "\\/]|^|\\#\\^)(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\@\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", '\\red_zrl_callback', $body);
         $body = preg_replace_callback('/\\[\\$b64zrl(.*?)\\[\\/(zrl)\\]/ism', '\\red_unescape_codeblock', $body);
         $body = preg_replace_callback('/\\[\\$b64url(.*?)\\[\\/(url)\\]/ism', '\\red_unescape_codeblock', $body);
         $body = preg_replace_callback('/\\[\\$b64code(.*?)\\[\\/(code)\\]/ism', '\\red_unescape_codeblock', $body);
         // fix any img tags that should be zmg
         $body = preg_replace_callback('/\\[img(.*?)\\](.*?)\\[\\/img\\]/ism', '\\red_zrlify_img_callback', $body);
         $body = bb_translate_video($body);
         /**
          * Fold multi-line [code] sequences
          */
         $body = preg_replace('/\\[\\/code\\]\\s*\\[code\\]/ism', "\n", $body);
         $body = scale_external_images($body, false);
         // Look for tags and linkify them
         $results = linkify_tags($a, $body, $uid ? $uid : $profile_uid);
         if ($results) {
             // Set permissions based on tag replacements
             set_linkified_perms($results, $str_contact_allow, $str_group_allow, $profile_uid, $parent_item, $private);
             $post_tags = array();
             foreach ($results as $result) {
                 $success = $result['success'];
                 if ($success['replaced']) {
                     $post_tags[] = array('uid' => $profile_uid, 'ttype' => $success['termtype'], 'otype' => TERM_OBJ_POST, 'term' => $success['term'], 'url' => $success['url']);
                 }
             }
         }
         /**
          *
          * When a photo was uploaded into the message using the (profile wall) ajax 
          * uploader, The permissions are initially set to disallow anybody but the
          * owner from seeing it. This is because the permissions may not yet have been
          * set for the post. If it's private, the photo permissions should be set
          * appropriately. But we didn't know the final permissions on the post until
          * now. So now we'll look for links of uploaded photos and attachments that are in the
          * post and set them to the same permissions as the post itself.
          *
          * If the post was end-to-end encrypted we can't find images and attachments in the body,
          * use our media_str input instead which only contains these elements - but only do this
          * when encrypted content exists because the photo/attachment may have been removed from 
          * the post and we should keep it private. If it's encrypted we have no way of knowing
          * so we'll set the permissions regardless and realise that the media may not be 
          * referenced in the post. 
          *
          * What is preventing us from being able to upload photos into comments is dealing with
          * the photo and attachment permissions, since we don't always know who was in the 
开发者ID:phellmes,项目名称:hubzilla,代码行数:67,代码来源:Item.php

示例13: diaspora_photo

function diaspora_photo($importer, $xml, $msg, $attempt = 1)
{
    $a = get_app();
    logger('diaspora_photo: init', LOGGER_DEBUG);
    $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));
    logger('diaspora_photo: status_message_guid: ' . $status_message_guid, LOGGER_DEBUG);
    $contact = diaspora_get_contact_by_handle($importer['uid'], $msg['author']);
    if (!$contact) {
        logger('diaspora_photo: contact record not found: ' . $msg['author'] . ' handle: ' . $diaspora_handle);
        return;
    }
    if (!diaspora_post_allow($importer, $contact)) {
        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)) {
        if ($attempt <= 3) {
            q("INSERT INTO dsprphotoq (uid, msg, attempt) VALUES (%d, '%s', %d)", intval($importer['uid']), dbesc(serialize($msg)), intval($attempt + 1));
        }
        logger('diaspora_photo: attempt = ' . $attempt . '; status message not found: ' . $status_message_guid . ' for photo: ' . $guid);
        return;
    }
    $parent_item = $r[0];
    $link_text = '[img]' . $remote_photo_path . $remote_photo_name . '[/img]' . "\n";
    $link_text = scale_external_images($link_text, true, array($remote_photo_name, 'scaled_full_' . $remote_photo_name));
    if (strpos($parent_item['body'], $link_text) === false) {
        $r = q("update item set `body` = '%s', `visible` = 1 where `id` = %d and `uid` = %d", dbesc($link_text . $parent_item['body']), intval($parent_item['id']), intval($parent_item['uid']));
    }
    return;
}
开发者ID:jzacman,项目名称:friendica,代码行数:37,代码来源:diaspora.php


注:本文中的scale_external_images函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。