• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP html2plain函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: display_content


//.........这里部分代码省略.........
        $a->page_contact = $r[0];
    }
    $is_owner = local_user() && local_user() == $a->profile['profile_uid'] ? true : false;
    if ($a->profile['hidewall'] && !$is_owner && !$remote_contact) {
        notice(t('Access to this profile has been restricted.') . EOL);
        return;
    }
    if ($is_owner) {
        $celeb = $a->user['page-flags'] == PAGE_SOAPBOX || $a->user['page-flags'] == PAGE_COMMUNITY ? true : false;
        $x = array('is_owner' => true, 'allow_location' => $a->user['allow_location'], 'default_location' => $a->user['default-location'], 'nickname' => $a->user['nickname'], 'lockstate' => is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock', 'acl' => populate_acl($a->user, $celeb), 'bang' => '', 'visitor' => 'block', 'profile_uid' => local_user(), 'acl_data' => construct_acl_data($a, $a->user));
        $o .= status_editor($a, $x, 0, true);
    }
    $sql_extra = item_permissions_sql($a->profile['uid'], $remote_contact, $groups);
    //	        AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE ( `id` = '%s' OR `uri` = '%s' ))
    if ($update) {
        $r = q("SELECT id FROM item WHERE item.uid = %d\n\t\t        AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE (`id` = '%s' OR `uri` = '%s'))\n\t\t        {$sql_extra} AND unseen = 1", intval($a->profile['uid']), dbesc($item_id), dbesc($item_id));
        if (!$r) {
            return '';
        }
    }
    //	AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE ( `id` = '%s' OR `uri` = '%s' )
    $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,  `item`.`network` AS `item_network`,\n\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,\n\t\t`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,\n\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`\n\t\tFROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\tand `item`.`moderated` = 0\n\t\tAND `item`.`parent` = (SELECT `parent` FROM `item` WHERE (`id` = '%s' OR `uri` = '%s')\n\t\tAND uid = %d)\n\t\t{$sql_extra}\n\t\tORDER BY `parent` DESC, `gravity` ASC, `id` ASC", intval($a->profile['uid']), dbesc($item_id), dbesc($item_id), intval($a->profile['uid']));
    if (!$r && local_user()) {
        // Check if this is another person's link to a post that we have
        $r = q("SELECT `item`.uri FROM `item`\n\t\t\tWHERE (`item`.`id` = '%s' OR `item`.`uri` = '%s' )\n\t\t\tLIMIT 1", dbesc($item_id), dbesc($item_id));
        if ($r) {
            $item_uri = $r[0]['uri'];
            //	AND `item`.`parent` = ( SELECT `parent` FROM `item` FORCE INDEX (PRIMARY, `uri`) WHERE `uri` = '%s' AND uid = %d )
            $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,  `item`.`network` AS `item_network`,\n\t\t\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,\n\t\t\t\t`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, \n\t\t\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`\n\t\t\t\tFROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\t\t\tand `item`.`moderated` = 0\n\t\t\t\tAND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `uri` = '%s' AND uid = %d)\n\t\t\t\tORDER BY `parent` DESC, `gravity` ASC, `id` ASC ", intval(local_user()), dbesc($item_uri), intval(local_user()));
        }
    }
    if ($r) {
        if (local_user() && local_user() == $a->profile['uid']) {
            q("UPDATE `item` SET `unseen` = 0\n\t\t\t\tWHERE `parent` = %d AND `unseen` = 1", intval($r[0]['parent']));
        }
        $items = conv_sort($r, "`commented`");
        if (!$update) {
            $o .= "<script> var netargs = '?f=&nick=" . $nick . "&item_id=" . $item_id . "'; </script>";
        }
        $o .= conversation($a, $items, 'display', $update);
        // Preparing the meta header
        require_once 'include/bbcode.php';
        require_once "include/html2plain.php";
        $description = trim(html2plain(bbcode($r[0]["body"], false, false), 0, true));
        $title = trim(html2plain(bbcode($r[0]["title"], false, false), 0, true));
        $author_name = $r[0]["author-name"];
        $image = "";
        if ($image == "") {
            $image = $r[0]["thumb"];
        }
        if ($title == "") {
            $title = $author_name;
        }
        $description = htmlspecialchars($description, ENT_COMPAT, 'UTF-8', true);
        // allow double encoding here
        $title = htmlspecialchars($title, ENT_COMPAT, 'UTF-8', true);
        // allow double encoding here
        $author_name = htmlspecialchars($author_name, ENT_COMPAT, 'UTF-8', true);
        // allow double encoding here
        //<meta name="keywords" content="">
        $a->page['htmlhead'] .= '<meta name="author" content="' . $author_name . '" />' . "\n";
        $a->page['htmlhead'] .= '<meta name="title" content="' . $title . '" />' . "\n";
        $a->page['htmlhead'] .= '<meta name="fulltitle" content="' . $title . '" />' . "\n";
        $a->page['htmlhead'] .= '<meta name="description" content="' . $description . '" />' . "\n";
        // Schema.org microdata
        $a->page['htmlhead'] .= '<meta itemprop="name" content="' . $title . '" />' . "\n";
        $a->page['htmlhead'] .= '<meta itemprop="description" content="' . $description . '" />' . "\n";
        $a->page['htmlhead'] .= '<meta itemprop="image" content="' . $image . '" />' . "\n";
        $a->page['htmlhead'] .= '<meta itemprop="author" content="' . $author_name . '" />' . "\n";
        // Twitter cards
        $a->page['htmlhead'] .= '<meta name="twitter:card" content="summary" />' . "\n";
        $a->page['htmlhead'] .= '<meta name="twitter:title" content="' . $title . '" />' . "\n";
        $a->page['htmlhead'] .= '<meta name="twitter:description" content="' . $description . '" />' . "\n";
        $a->page['htmlhead'] .= '<meta name="twitter:image" content="' . $image . '" />' . "\n";
        $a->page['htmlhead'] .= '<meta name="twitter:url" content="' . $r[0]["plink"] . '" />' . "\n";
        // Dublin Core
        $a->page['htmlhead'] .= '<meta name="DC.title" content="' . $title . '" />' . "\n";
        $a->page['htmlhead'] .= '<meta name="DC.description" content="' . $description . '" />' . "\n";
        // Open Graph
        $a->page['htmlhead'] .= '<meta property="og:type" content="website" />' . "\n";
        $a->page['htmlhead'] .= '<meta property="og:title" content="' . $title . '" />' . "\n";
        $a->page['htmlhead'] .= '<meta property="og:image" content="' . $image . '" />' . "\n";
        $a->page['htmlhead'] .= '<meta property="og:url" content="' . $r[0]["plink"] . '" />' . "\n";
        $a->page['htmlhead'] .= '<meta property="og:description" content="' . $description . '" />' . "\n";
        $a->page['htmlhead'] .= '<meta name="og:article:author" content="' . $author_name . '" />' . "\n";
        // article:tag
        return $o;
    }
    $r = q("SELECT `id`,`deleted` FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1", dbesc($item_id), dbesc($item_id));
    if ($r) {
        if ($r[0]['deleted']) {
            notice(t('Item has been removed.') . EOL);
        } else {
            notice(t('Permission denied.') . EOL);
        }
    } else {
        notice(t('Item not found.') . EOL);
    }
    return $o;
}
开发者ID:strk,项目名称:friendica,代码行数:101,代码来源:display.php


示例2: item_post


//.........这里部分代码省略.........
        if (x($_REQUEST, 'return') && strlen($return_path)) {
            logger('return: ' . $return_path);
            goaway($a->get_baseurl() . "/" . $return_path);
        }
        killme();
    } else {
        $post_id = 0;
    }
    $r = q("INSERT INTO `item` (`guid`, `extid`, `uid`,`type`,`wall`,`gravity`, `network`, `contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `author-name`, `author-link`, `author-avatar`,\n\t\t`created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`, `tag`, `inform`, `verb`, `object-type`, `postopts`,\n\t\t`allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark`,`origin`, `moderated`, `file`, `rendered-html`, `rendered-hash`)\n\t\tVALUES( '%s', '%s', %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s', '%s', '%s')", dbesc($datarray['guid']), dbesc($datarray['extid']), intval($datarray['uid']), dbesc($datarray['type']), intval($datarray['wall']), intval($datarray['gravity']), dbesc($datarray['network']), intval($datarray['contact-id']), dbesc($datarray['owner-name']), dbesc($datarray['owner-link']), dbesc($datarray['owner-avatar']), dbesc($datarray['author-name']), dbesc($datarray['author-link']), dbesc($datarray['author-avatar']), dbesc($datarray['created']), dbesc($datarray['edited']), dbesc($datarray['commented']), dbesc($datarray['received']), dbesc($datarray['changed']), dbesc($datarray['uri']), dbesc($datarray['thr-parent']), dbesc($datarray['title']), dbesc($datarray['body']), dbesc($datarray['app']), dbesc($datarray['location']), dbesc($datarray['coord']), dbesc($datarray['tag']), dbesc($datarray['inform']), dbesc($datarray['verb']), dbesc($datarray['object-type']), dbesc($datarray['postopts']), dbesc($datarray['allow_cid']), dbesc($datarray['allow_gid']), dbesc($datarray['deny_cid']), dbesc($datarray['deny_gid']), intval($datarray['private']), intval($datarray['pubmail']), dbesc($datarray['attach']), intval($datarray['bookmark']), intval($datarray['origin']), intval($datarray['moderated']), dbesc($datarray['file']), dbesc($datarray['rendered-html']), dbesc($datarray['rendered-hash']));
    $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($datarray['uri']));
    if (!count($r)) {
        logger('mod_item: unable to retrieve post that was just stored.');
        notice(t('System error. Post not saved.') . EOL);
        goaway($a->get_baseurl() . "/" . $return_path);
        // NOTREACHED
    }
    $post_id = $r[0]['id'];
    logger('mod_item: saved item ' . $post_id);
    $datarray["id"] = $post_id;
    $datarray["plink"] = $a->get_baseurl() . '/display/' . urlencode($datarray["guid"]);
    // update filetags in pconfig
    file_tag_update_pconfig($uid, $categories_old, $categories_new, 'category');
    if ($parent) {
        // This item is the last leaf and gets the comment box, clear any ancestors
        $r = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent` = %d ", dbesc(datetime_convert()), intval($parent));
        update_thread($parent, true);
        // Inherit ACLs from the parent item.
        $r = q("UPDATE `item` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `private` = %d\n\t\t\tWHERE `id` = %d", dbesc($parent_item['allow_cid']), dbesc($parent_item['allow_gid']), dbesc($parent_item['deny_cid']), dbesc($parent_item['deny_gid']), intval($parent_item['private']), intval($post_id));
        if ($contact_record != $author) {
            notification(array('type' => NOTIFY_COMMENT, 'notify_flags' => $user['notify-flags'], 'language' => $user['language'], 'to_name' => $user['username'], 'to_email' => $user['email'], 'uid' => $user['uid'], 'item' => $datarray, 'link' => $a->get_baseurl() . '/display/' . urlencode($datarray['guid']), 'source_name' => $datarray['author-name'], 'source_link' => $datarray['author-link'], 'source_photo' => $datarray['author-avatar'], 'verb' => ACTIVITY_POST, 'otype' => 'item', 'parent' => $parent, 'parent_uri' => $parent_item['uri']));
        }
        // Store the comment signature information in case we need to relay to Diaspora
        store_diaspora_comment_sig($datarray, $author, $self ? $a->user['prvkey'] : false, $parent_item, $post_id);
    } else {
        $parent = $post_id;
        if ($contact_record != $author) {
            notification(array('type' => NOTIFY_WALL, 'notify_flags' => $user['notify-flags'], 'language' => $user['language'], 'to_name' => $user['username'], 'to_email' => $user['email'], 'uid' => $user['uid'], 'item' => $datarray, 'link' => $a->get_baseurl() . '/display/' . urlencode($datarray['guid']), 'source_name' => $datarray['author-name'], 'source_link' => $datarray['author-link'], 'source_photo' => $datarray['author-avatar'], 'verb' => ACTIVITY_POST, 'otype' => 'item'));
        }
    }
    // fallback so that parent always gets set to non-zero.
    if (!$parent) {
        $parent = $post_id;
    }
    $r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s', `plink` = '%s', `changed` = '%s', `last-child` = 1, `visible` = 1\n\t\tWHERE `id` = %d", intval($parent), dbesc($parent == $post_id ? $uri : $parent_item['uri']), dbesc($a->get_baseurl() . '/display/' . urlencode($datarray['guid'])), dbesc(datetime_convert()), intval($post_id));
    // photo comments turn the corresponding item visible to the profile wall
    // This way we don't see every picture in your new photo album posted to your wall at once.
    // They will show up as people comment on them.
    if (!$parent_item['visible']) {
        $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d", intval($parent_item['id']));
        update_thread($parent_item['id']);
    }
    // update the commented timestamp on the parent
    q("UPDATE `item` set `commented` = '%s', `changed` = '%s' WHERE `id` = %d", dbesc(datetime_convert()), dbesc(datetime_convert()), intval($parent));
    if ($post_id != $parent) {
        update_thread($parent);
    }
    call_hooks('post_local_end', $datarray);
    if (strlen($emailcc) && $profile_uid == local_user()) {
        $erecips = explode(',', $emailcc);
        if (count($erecips)) {
            foreach ($erecips as $recip) {
                $addr = trim($recip);
                if (!strlen($addr)) {
                    continue;
                }
                $disclaimer = '<hr />' . sprintf(t('This message was sent to you by %s, a member of the Friendica social network.'), $a->user['username']) . '<br />';
                $disclaimer .= sprintf(t('You may visit them online at %s'), $a->get_baseurl() . '/profile/' . $a->user['nickname']) . EOL;
                $disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL;
                if (!$datarray['title'] == '') {
                    $subject = email_header_encode($datarray['title'], 'UTF-8');
                } else {
                    $subject = email_header_encode('[Friendica]' . ' ' . sprintf(t('%s posted an update.'), $a->user['username']), 'UTF-8');
                }
                $link = '<a href="' . $a->get_baseurl() . '/profile/' . $a->user['nickname'] . '"><img src="' . $author['thumb'] . '" alt="' . $a->user['username'] . '" /></a><br /><br />';
                $html = prepare_body($datarray);
                $message = '<html><body>' . $link . $html . $disclaimer . '</body></html>';
                include_once 'include/html2plain.php';
                $params = array('fromName' => $a->user['username'], 'fromEmail' => $a->user['email'], 'toEmail' => $addr, 'replyTo' => $a->user['email'], 'messageSubject' => $subject, 'htmlVersion' => $message, 'textVersion' => html2plain($html . $disclaimer));
                Emailer::send($params);
            }
        }
    }
    create_tags_from_item($post_id);
    create_files_from_item($post_id);
    if ($post_id == $parent) {
        add_thread($post_id);
    }
    // This is a real juggling act on shared hosting services which kill your processes
    // e.g. dreamhost. We used to start delivery to our native delivery agents in the background
    // and then run our plugin delivery from the foreground. We're now doing plugin delivery first,
    // because as soon as you start loading up a bunch of remote delivey processes, *this* page is
    // likely to get killed off. If you end up looking at an /item URL and a blank page,
    // it's very likely the delivery got killed before all your friends could be notified.
    // Currently the only realistic fixes are to use a reliable server - which precludes shared hosting,
    // or cut back on plugins which do remote deliveries.
    proc_run('php', "include/notifier.php", $notify_type, "{$post_id}");
    logger('post_complete');
    item_post_return($a->get_baseurl(), $api_source, $return_path);
    // NOTREACHED
}
开发者ID:strk,项目名称:friendica,代码行数:101,代码来源:item.php


示例3: format_ical_text

function format_ical_text($s)
{
    require_once 'include/bbcode.php';
    require_once 'include/html2plain.php';
    return wordwrap(str_replace(',', '\\,', html2plain(bbcode($s))), 72, "\n ", true);
}
开发者ID:HaakonME,项目名称:redmatrix,代码行数:6,代码来源:event.php


示例4: wppost_send

function wppost_send(&$a, &$b)
{
    if ($b['deleted'] || $b['private'] || $b['created'] !== $b['edited']) {
        return;
    }
    if (!strstr($b['postopts'], 'wppost')) {
        return;
    }
    if ($b['parent'] != $b['id']) {
        return;
    }
    $wp_username = xmlify(get_pconfig($b['uid'], 'wppost', 'wp_username'));
    $wp_password = xmlify(get_pconfig($b['uid'], 'wppost', 'wp_password'));
    $wp_blog = get_pconfig($b['uid'], 'wppost', 'wp_blog');
    if ($wp_username && $wp_password && $wp_blog) {
        require_once 'include/bbcode.php';
        require_once 'include/html2plain.php';
        // If the title is empty then try to guess
        if ($b['title'] == '') {
            // Take the description from the bookmark
            if (preg_match("/\\[bookmark\\=([^\\]]*)\\](.*?)\\[\\/bookmark\\]/is", $b['body'], $matches)) {
                $b['title'] = $matches[2];
            }
            // If no bookmark is found then take the first line
            if ($b['title'] == '') {
                $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);
            }
        }
        $title = '<title>' . ($b['title'] ? $b['title'] : t('Post from Friendica')) . '</title>';
        $post = $title . bbcode($b['body']);
        $wp_backlink = intval(get_pconfig($b['uid'], 'wppost', 'backlink'));
        if ($wp_backlink && $b['plink']) {
            $post .= EOL . EOL . '<a href="' . $b['plink'] . '">' . t('Read the original post and comment stream on Friendica') . '</a>' . EOL . EOL;
        }
        $post = xmlify($post);
        $xml = <<<EOT
<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
<methodCall>
  <methodName>blogger.newPost</methodName>
  <params>
    <param><value><string/></value></param>
    <param><value><string/></value></param>
    <param><value><string>{$wp_username}</string></value></param>
    <param><value><string>{$wp_password}</string></value></param>
    <param><value><string>{$post}</string></value></param>
    <param><value><int>1</int></value></param>
  </params>
</methodCall>

EOT;
        logger('wppost: data: ' . $xml, LOGGER_DATA);
        if ($wp_blog !== 'test') {
            $x = post_url($wp_blog, $xml);
        }
        logger('posted to wordpress: ' . ($x ? $x : ''), LOGGER_DEBUG);
    }
}
开发者ID:robhell,项目名称:friendica-addons,代码行数:62,代码来源:wppost.php


示例5: api_convert_item

function api_convert_item($item)
{
    $body = $item['body'];
    $attachments = api_get_attachments($body);
    // Workaround for ostatus messages where the title is identically to the body
    $html = bbcode(api_clean_plain_items($body), false, false, 2, true);
    $statusbody = trim(html2plain($html, 0));
    // handle data: images
    $statusbody = api_format_items_embeded_images($item, $statusbody);
    $statustitle = trim($item['title']);
    if ($statustitle != '' and strpos($statusbody, $statustitle) !== false) {
        $statustext = trim($statusbody);
    } else {
        $statustext = trim($statustitle . "\n\n" . $statusbody);
    }
    if ($item["network"] == NETWORK_FEED and strlen($statustext) > 1000) {
        $statustext = substr($statustext, 0, 1000) . "... \n" . $item["plink"];
    }
    $statushtml = trim(bbcode($body, false, false));
    if ($item['title'] != "") {
        $statushtml = "<h4>" . bbcode($item['title']) . "</h4>\n" . $statushtml;
    }
    $entities = api_get_entitities($statustext, $body);
    return array("text" => $statustext, "html" => $statushtml, "attachments" => $attachments, "entities" => $entities);
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:25,代码来源:api.php


示例6: store_doc_file

function store_doc_file($s)
{
    if (is_dir($s)) {
        return;
    }
    $item = array();
    $sys = get_sys_channel();
    $item['aid'] = 0;
    $item['uid'] = $sys['channel_id'];
    if (strpos($s, '.md')) {
        $mimetype = 'text/markdown';
    } elseif (strpos($s, '.html')) {
        $mimetype = 'text/html';
    } else {
        $mimetype = 'text/bbcode';
    }
    require_once 'include/html2plain.php';
    $item['body'] = html2plain(prepare_text(file_get_contents($s), $mimetype, true));
    $item['mimetype'] = 'text/plain';
    $item['plink'] = z_root() . '/' . str_replace('doc', 'help', $s);
    $item['owner_xchan'] = $item['author_xchan'] = $sys['channel_hash'];
    $item['item_type'] = ITEM_TYPE_DOC;
    $r = q("select item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and\n\t\tsid = '%s' and item_type = %d limit 1", dbesc($s), intval(ITEM_TYPE_DOC));
    if ($r) {
        $item['id'] = $r[0]['id'];
        $item['mid'] = $item['parent_mid'] = $r[0]['mid'];
        $x = item_store_update($item);
    } else {
        $item['mid'] = $item['parent_mid'] = item_message_id();
        $x = item_store($item);
    }
    if ($x['success']) {
        update_remote_id($sys, $x['item_id'], ITEM_TYPE_DOC, $s, 'docfile', 0, $item['mid']);
    }
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:35,代码来源:help.php


示例7: api_format_items

function api_format_items($r, $user_info, $filter_user = false)
{
    $a = get_app();
    $ret = array();
    foreach ($r as $item) {
        api_share_as_retweet($a, api_user(), $item);
        localize_item($item);
        $status_user = api_item_get_user($a, $item);
        // Look if the posts are matching if they should be filtered by user id
        if ($filter_user and $status_user["id"] != $user_info["id"]) {
            continue;
        }
        if ($item['thr-parent'] != $item['uri']) {
            $r = q("SELECT id FROM item WHERE uid=%d AND uri='%s' LIMIT 1", intval(api_user()), dbesc($item['thr-parent']));
            if ($r) {
                $in_reply_to_status_id = intval($r[0]['id']);
            } else {
                $in_reply_to_status_id = intval($item['parent']);
            }
            $in_reply_to_status_id_str = (string) intval($item['parent']);
            $in_reply_to_screen_name = NULL;
            $in_reply_to_user_id = NULL;
            $in_reply_to_user_id_str = NULL;
            $r = q("SELECT `author-link` FROM item WHERE uid=%d AND id=%d LIMIT 1", intval(api_user()), intval($in_reply_to_status_id));
            if ($r) {
                $r = q("SELECT * FROM unique_contacts WHERE `url` = '%s'", dbesc(normalise_link($r[0]['author-link'])));
                if ($r) {
                    if ($r[0]['nick'] == "") {
                        $r[0]['nick'] = api_get_nick($r[0]["url"]);
                    }
                    $in_reply_to_screen_name = $r[0]['nick'] ? $r[0]['nick'] : $r[0]['name'];
                    $in_reply_to_user_id = intval($r[0]['id']);
                    $in_reply_to_user_id_str = (string) intval($r[0]['id']);
                }
            }
        } else {
            $in_reply_to_screen_name = NULL;
            $in_reply_to_user_id = NULL;
            $in_reply_to_status_id = NULL;
            $in_reply_to_user_id_str = NULL;
            $in_reply_to_status_id_str = NULL;
        }
        // Workaround for ostatus messages where the title is identically to the body
        //$statusbody = trim(html2plain(bbcode(api_clean_plain_items($item['body']), false, false, 5, true), 0));
        $html = bbcode(api_clean_plain_items($item['body']), false, false, 2, true);
        $statusbody = trim(html2plain($html, 0));
        $statustitle = trim($item['title']);
        if ($statustitle != '' and strpos($statusbody, $statustitle) !== false) {
            $statustext = trim($statusbody);
        } else {
            $statustext = trim($statustitle . "\n\n" . $statusbody);
        }
        if ($item["network"] == NETWORK_FEED and strlen($statustext) > 1000) {
            $statustext = substr($statustext, 0, 1000) . "... \n" . $item["plink"];
        }
        $status = array('text' => $statustext, '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_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_str, 'in_reply_to_screen_name' => $in_reply_to_screen_name, 'geo' => NULL, 'favorited' => $item['starred'] ? true : false, 'user' => $status_user, 'statusnet_html' => trim(bbcode($item['body'], false, false)), 'statusnet_conversation_id' => $item['parent']);
        if ($item['title'] != "") {
            $status['statusnet_html'] = "<h4>" . bbcode($item['title']) . "</h4>\n" . $status['statusnet_html'];
        }
        $entities = api_get_entitities($status['text'], $item['body']);
        if (count($entities) > 0) {
            $status['entities'] = $entities;
        }
        if ($item['item_network'] != "" and $status["source"] == 'web') {
            $status["source"] = network_to_name($item['item_network']);
        } else {
            if ($item['item_network'] != "" and network_to_name($item['item_network']) != $status["source"]) {
                $status["source"] = trim($status["source"] . ' (' . network_to_name($item['item_network']) . ')');
            }
        }
        // Retweets are only valid for top postings
        // It doesn't work reliable with the link if its a feed
        $IsRetweet = $item['owner-link'] != $item['author-link'];
        if ($IsRetweet) {
            $IsRetweet = ($item['owner-name'] != $item['author-name'] or $item['owner-avatar'] != $item['author-avatar']);
        }
        if ($IsRetweet and $item["id"] == $item["parent"]) {
            $retweeted_status = $status;
            $retweeted_status["user"] = api_get_user($a, $item["author-link"]);
            $status["retweeted_status"] = $retweeted_status;
        }
        // "uid" and "self" are only needed for some internal stuff, so remove it from here
        unset($status["user"]["uid"]);
        unset($status["user"]["self"]);
        // 'geo' => array('type' => 'Point',
        //                   'coordinates' => array((float) $notice->lat,
        //                                          (float) $notice->lon));
        $ret[] = $status;
    }
    return $ret;
}
开发者ID:jzacman,项目名称:friendica,代码行数:91,代码来源:api.php


示例8: email_send

function email_send($addr, $subject, $headers, $item)
{
    //$headers .= 'MIME-Version: 1.0' . "\n";
    //$headers .= 'Content-Type: text/html; charset=UTF-8' . "\n";
    //$headers .= 'Content-Type: text/plain; charset=UTF-8' . "\n";
    //$headers .= 'Content-Transfer-Encoding: 8bit' . "\n\n";
    $part = uniqid("", true);
    $html = prepare_body($item);
    $headers .= "Mime-Version: 1.0\n";
    $headers .= 'Content-Type: multipart/alternative; boundary="=_' . $part . '"' . "\n\n";
    $body = "\n--=_" . $part . "\n";
    $body .= "Content-Transfer-Encoding: 8bit\n";
    $body .= "Content-Type: text/plain; charset=utf-8; format=flowed\n\n";
    $body .= html2plain($html) . "\n";
    $body .= "--=_" . $part . "\n";
    $body .= "Content-Transfer-Encoding: 8bit\n";
    $body .= "Content-Type: text/html; charset=utf-8\n\n";
    $body .= '<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">' . $html . "</body></html>\n";
    $body .= "--=_" . $part . "--";
    //$message = '<html><body>' . $html . '</body></html>';
    //$message = html2plain($html);
    logger('notifier: email delivery to ' . $addr);
    mail($addr, $subject, $body, $headers);
}
开发者ID:bashrc,项目名称:hubzilla,代码行数:24,代码来源:network.php


示例9: plaintext

function plaintext($a, $b, $limit = 0, $includedlinks = false, $htmlmode = 2)
{
    require_once "include/bbcode.php";
    require_once "include/html2plain.php";
    require_once "include/network.php";
    // At first look at data that is attached via "type-..." stuff
    // This will hopefully replaced with a dedicated bbcode later
    $post = get_attached_data($b["body"]);
    if ($b["title"] != "" and $post["text"] != "") {
        $post["text"] = trim($b["title"] . "\n\n" . $post["text"]);
    } elseif ($b["title"] != "") {
        $post["text"] = trim($b["title"]);
    }
    $html = bbcode($post["text"], false, false, $htmlmode);
    $msg = html2plain($html, 0, true);
    $msg = trim(html_entity_decode($msg, ENT_QUOTES, 'UTF-8'));
    $link = "";
    if ($includedlinks) {
        if ($post["type"] == "link") {
            $link = $post["url"];
        } elseif ($post["type"] == "video") {
            $link = $post["url"];
        } elseif ($post["type"] == "photo") {
            $link = $post["image"];
        }
        if ($msg == "" and isset($post["title"])) {
            $msg = trim($post["title"]);
        }
        if ($msg == "" and isset($post["description"])) {
            $msg = trim($post["description"]);
        }
        // If the link is already contained in the post, then it neeedn't to be added again
        // But: if the link is beyond the limit, then it has to be added.
        if ($link != "" and strstr($msg, $link)) {
            $pos = strpos($msg, $link);
            if ($limit == 0 or $pos < $limit) {
                $link = "";
            }
        }
    }
    if ($limit > 0) {
        // Reduce multiple spaces
        // When posted to a network with limited space, we try to gain space where possible
        while (strpos($msg, "  ") !== false) {
            $msg = str_replace("  ", " ", $msg);
        }
        // Twitter is using its own limiter, so we always assume that shortened links will have this length
        if (iconv_strlen($link, "UTF-8") > 0) {
            $limit = $limit - 23;
        }
        if (iconv_strlen($msg, "UTF-8") > $limit) {
            if (!isset($post["url"])) {
                $limit = $limit - 23;
                $post["url"] = $b["plink"];
            } elseif (strpos($b["body"], "[share") !== false) {
                $post["url"] = $b["plink"];
            } elseif (get_pconfig($b["uid"], "system", "no_intelligent_shortening")) {
                $post["url"] = $b["plink"];
            }
            $msg = shortenmsg($msg, $limit);
        }
    }
    $post["text"] = trim($msg);
    return $post;
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:65,代码来源:plaintext.php


示例10: format_ical_text

function format_ical_text($s)
{
    require_once 'include/bbcode.php';
    require_once 'include/html2plain.php';
    $s = html2plain(bbcode($s));
    $s = str_replace(["\r\n", "\n"], ["", ""], $s);
    return wordwrap(str_replace(['\\', ',', ';'], ['\\\\', '\\,', '\\;'], $s), 72, "\r\n ", true);
}
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:8,代码来源:event.php


示例11: wppost_send

function wppost_send(&$a, &$b)
{
    if ($b['deleted'] || $b['private'] || $b['created'] !== $b['edited']) {
        return;
    }
    if (!strstr($b['postopts'], 'wppost')) {
        return;
    }
    if ($b['parent'] != $b['id']) {
        return;
    }
    $wp_username = xmlify(get_pconfig($b['uid'], 'wppost', 'wp_username'));
    $wp_password = xmlify(get_pconfig($b['uid'], 'wppost', 'wp_password'));
    $wp_blog = get_pconfig($b['uid'], 'wppost', 'wp_blog');
    if ($wp_username && $wp_password && $wp_blog) {
        require_once 'include/bbcode.php';
        require_once 'include/html2plain.php';
        require_once 'include/plaintext.php';
        $wptitle = trim($b['title']);
        if (intval(get_pconfig($b['uid'], 'wppost', 'shortcheck'))) {
            // Checking, if its a post that is worth a blog post
            $postentry = false;
            $siteinfo = get_attached_data($b["body"]);
            // Is it a link to an aricle, a video or a photo?
            if (isset($siteinfo["type"])) {
                if (in_array($siteinfo["type"], array("link", "audio", "video", "photo"))) {
                    $postentry = true;
                }
            }
            // Does it have a title?
            if ($wptitle != "") {
                $postentry = true;
            }
            // Is it larger than 500 characters?
            if (strlen($b['body']) > 500) {
                $postentry = true;
            }
            if (!$postentry) {
                return;
            }
        }
        // If the title is empty then try to guess
        if ($wptitle == '') {
            // Fetch information about the post
            $siteinfo = get_attached_data($b["body"]);
            if (isset($siteinfo["title"])) {
                $wptitle = $siteinfo["title"];
            }
            // If no bookmark is found then take the first line
            if ($wptitle == '') {
                // Remove the share element before fetching the first line
                $title = trim(preg_replace("/\\[share.*?\\](.*?)\\[\\/share\\]/ism", "\n\$1\n", $b['body']));
                $title = html2plain(bbcode($title, false, false), 0, true) . "\n";
                $pos = strpos($title, "\n");
                $trailer = "";
                if ($pos == 0 or $pos > 100) {
                    $pos = 100;
                    $trailer = "...";
                }
                $wptitle = substr($title, 0, $pos) . $trailer;
            }
        }
        $title = '<title>' . ($wptitle ? $wptitle : t('Post from Friendica')) . '</title>';
        $post = bbcode($b['body'], false, false, 4);
        // If a link goes to youtube then remove the stuff around it. Wordpress detects youtube links and embeds it
        $post = preg_replace('/<a.*?href="(https?:\\/\\/www.youtube.com\\/.*?)".*?>(.*?)<\\/a>/ism', "\n\$1\n", $post);
        $post = preg_replace('/<a.*?href="(https?:\\/\\/youtu.be\\/.*?)".*?>(.*?)<\\/a>/ism', "\n\$1\n", $post);
        $post = $title . $post;
        $wp_backlink = intval(get_pconfig($b['uid'], 'wppost', 'backlink'));
        if ($wp_backlink && $b['plink']) {
            $post .= EOL . EOL . '<a href="' . $b['plink'] . '">' . t('Read the original post and comment stream on Friendica') . '</a>' . EOL . EOL;
        }
        $post = xmlify($post);
        $xml = <<<EOT
<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
<methodCall>
  <methodName>blogger.newPost</methodName>
  <params>
    <param><value><string/></value></param>
    <param><value><string/></value></param>
    <param><value><string>{$wp_username}</string></value></param>
    <param><value><string>{$wp_password}</string></value></param>
    <param><value><string>{$post}</string></value></param>
    <param><value><int>1</int></value></param>
  </params>
</methodCall>

EOT;
        logger('wppost: data: ' . $xml, LOGGER_DATA);
        if ($wp_blog !== 'test') {
            $x = post_url($wp_blog, $xml);
        }
        logger('posted to wordpress: ' . ($x ? $x : ''), LOGGER_DEBUG);
    }
}
开发者ID:rabuzarus,项目名称:friendica-addons,代码行数:95,代码来源:wppost.php


示例12: facebook_post_hook

/**
 * @param App $a
 * @param object $b
 * @return mixed
 */
function facebook_post_hook(&$a, &$b)
{
    if ($b['deleted'] || $b['created'] !== $b['edited']) {
        return;
    }
    /**
     * Post to Facebook stream
     */
    require_once 'include/group.php';
    require_once 'include/html2plain.php';
    logger('Facebook post');
    $reply = false;
    $likes = false;
    $deny_arr = array();
    $allow_arr = array();
    $toplevel = $b['id'] == $b['parent'] ? true : false;
    $linking = get_pconfig($b['uid'], 'facebook', 'no_linking') ? 0 : 1;
    if (!$toplevel && $linking) {
        $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($b['parent']), intval($b['uid']));
        if (count($r) && substr($r[0]['uri'], 0, 4) === 'fb::') {
            $reply = substr($r[0]['uri'], 4);
        } elseif (count($r) && substr($r[0]['extid'], 0, 4) === 'fb::') {
            $reply = substr($r[0]['extid'], 4);
        } else {
            return;
        }
        $u = q("SELECT * FROM user where uid = %d limit 1", intval($b['uid']));
        if (!count($u)) {
            return;
        }
        // only accept comments from the item owner. Other contacts are unknown to FB.
        if (!link_compare($b['author-link'], $a->get_baseurl() . '/profile/' . $u[0]['nickname'])) {
            return;
        }
        logger('facebook reply id=' . $reply);
    }
    if (strstr($b['postopts'], 'facebook') || $b['private'] || $reply) {
        if ($b['private'] && $reply === false) {
            $allow_people = expand_acl($b['allow_cid']);
            $allow_groups = expand_groups(expand_acl($b['allow_gid']));
            $deny_people = expand_acl($b['deny_cid']);
            $deny_groups = expand_groups(expand_acl($b['deny_gid']));
            $recipients = array_unique(array_merge($allow_people, $allow_groups));
            $deny = array_unique(array_merge($deny_people, $deny_groups));
            $allow_str = dbesc(implode(', ', $recipients));
            if ($allow_str) {
                $r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( {$allow_str} ) AND `network` = 'face'");
                if (count($r)) {
                    foreach ($r as $rr) {
                        $allow_arr[] = $rr['notify'];
                    }
                }
            }
            $deny_str = dbesc(implode(', ', $deny));
            if ($deny_str) {
                $r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( {$deny_str} ) AND `network` = 'face'");
                if (count($r)) {
                    foreach ($r as $rr) {
                        $deny_arr[] = $rr['notify'];
                    }
                }
            }
            if (count($deny_arr) && !count($allow_arr)) {
                // One or more FB folks were denied access but nobody on FB was specifically allowed access.
                // This might cause the post to be open to public on Facebook, but only to selected members
                // on another network. Since this could potentially leak a post to somebody who was denied,
                // we will skip posting it to Facebook with a slightly vague but relevant message that will
                // hopefully lead somebody to this code comment for a better explanation of what went wrong.
                notice(t('Post to Facebook cancelled because of multi-network access permission conflict.') . EOL);
                return;
            }
            // if it's a private message but no Facebook members are allowed or denied, skip Facebook post
            if (!count($allow_arr) && !count($deny_arr)) {
                return;
            }
        }
        if ($b['verb'] == ACTIVITY_LIKE) {
            $likes = true;
        }
        $appid = get_config('facebook', 'appid');
        $secret = get_config('facebook', 'appsecret');
        if ($appid && $secret) {
            logger('facebook: have appid+secret');
            $fb_token = get_pconfig($b['uid'], 'facebook', 'access_token');
            // post to facebook if it's a public post and we've ticked the 'post to Facebook' box,
            // or it's a private message with facebook participants
            // or it's a reply or likes action to an existing facebook post
            if ($fb_token && ($toplevel || $b['private'] || $reply)) {
                logger('facebook: able to post');
                require_once 'library/facebook.php';
                require_once 'include/bbcode.php';
                $msg = $b['body'];
                logger('Facebook post: original msg=' . $msg, LOGGER_DATA);
                // make links readable before we strip the code
                // unless it's a dislike - just send the text as a comment
//.........这里部分代码省略.........
开发者ID:robhell,项目名称:friendica-addons,代码行数:101,代码来源:facebook.php


示例13: windowsphonepush_cron

/**
 *
 * Cron function used to regularly check all users on the server with active windowsphonepushplugin and send
 * notifications to the Microsoft servers and consequently to the Windows Phone device
 *
 */
function windowsphonepush_cron()
{
    // retrieve all UID's for which the plugin windowsphonepush is enabled and loop through every user
    $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'windowsphonepush' AND `k` = 'enable' AND `v` = 1");
    if (count($r)) {
        foreach ($r as $rr) {
            // load stored information for the user-id of the current loop
            $device_url = get_pconfig($rr['uid'], 'windowsphonepush', 'device_url');
            $lastpushid = get_pconfig($rr['uid'], 'windowsphonepush', 'lastpushid');
            // pushing only possible if device_url (the URI on Microsoft server) is available or not "NA" (which will be sent
            // by app if user has switched the server setting in app - sending blank not possible as this would return an update error)
            if ($device_url == "" || $device_url == "NA") {
                // no Device-URL for the user availabe, but plugin is enabled --> write info to Logger
                logger("WARN: windowsphonepush is enable for user " . $rr['uid'] . ", but no Device-URL is specified for the user.");
            } else {
                // retrieve the number of unseen items and the id of the latest one (if there are more than
                // one new entries since last poller run, only the latest one will be pushed)
                $count = q("SELECT count(`id`) as count, max(`id`) as max FROM `item` WHERE `unseen` = 1 AND `type` <> 'activity' AND `uid` = %d", intval($rr['uid']));
                // send number of unseen items to the device (the number will be displayed on Start s 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP html2rgb函数代码示例发布时间:2022-05-15
下一篇:
PHP html2pdf函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap