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

PHP item_new_uri函数代码示例

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

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



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

示例1: subthread_content

function subthread_content(&$a)
{
    if (!local_user() && !remote_user()) {
        return;
    }
    $activity = ACTIVITY_FOLLOW;
    $item_id = $a->argc > 1 ? notags(trim($a->argv[1])) : 0;
    $r = q("SELECT * FROM `item` WHERE `parent` = '%s' OR `parent-uri` = '%s' and parent = id LIMIT 1", dbesc($item_id), dbesc($item_id));
    if (!$item_id || !count($r)) {
        logger('subthread: no item ' . $item_id);
        return;
    }
    $item = $r[0];
    $owner_uid = $item['uid'];
    if (!can_write_wall($a, $owner_uid)) {
        return;
    }
    $remote_owner = null;
    if (!$item['wall']) {
        // The top level post may have been written by somebody on another system
        $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($item['contact-id']), intval($item['uid']));
        if (!count($r)) {
            return;
        }
        if (!$r[0]['self']) {
            $remote_owner = $r[0];
        }
    }
    // this represents the post owner on this system.
    $r = q("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`\n\t\tWHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1", intval($owner_uid));
    if (count($r)) {
        $owner = $r[0];
    }
    if (!$owner) {
        logger('like: no owner');
        return;
    }
    if (!$remote_owner) {
        $remote_owner = $owner;
    }
    // This represents the person posting
    if (local_user() && local_user() == $owner_uid) {
        $contact = $owner;
    } else {
        $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($_SESSION['visitor_id']), intval($owner_uid));
        if (count($r)) {
            $contact = $r[0];
        }
    }
    if (!$contact) {
        return;
    }
    $uri = item_new_uri($a->get_hostname(), $owner_uid);
    $post_type = $item['resource-id'] ? t('photo') : t('status');
    $objtype = $item['resource-id'] ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE;
    $link = xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n");
    $body = $item['body'];
    $obj = <<<EOT

\t<object>
\t\t<type>{$objtype}</type>
\t\t<local>1</local>
\t\t<id>{$item['uri']}</id>
\t\t<link>{$link}</link>
\t\t<title></title>
\t\t<content>{$body}</content>
\t</object>
EOT;
    $bodyverb = t('%1$s is following %2$s\'s %3$s');
    if (!isset($bodyverb)) {
        return;
    }
    $arr = array();
    $arr['uri'] = $uri;
    $arr['uid'] = $owner_uid;
    $arr['contact-id'] = $contact['id'];
    $arr['type'] = 'activity';
    $arr['wall'] = $item['wall'];
    $arr['origin'] = 1;
    $arr['gravity'] = GRAVITY_LIKE;
    $arr['parent'] = $item['id'];
    $arr['parent-uri'] = $item['uri'];
    $arr['thr-parent'] = $item['uri'];
    $arr['owner-name'] = $remote_owner['name'];
    $arr['owner-link'] = $remote_owner['url'];
    $arr['owner-avatar'] = $remote_owner['thumb'];
    $arr['author-name'] = $contact['name'];
    $arr['author-link'] = $contact['url'];
    $arr['author-avatar'] = $contact['thumb'];
    $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
    $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
    $plink = '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
    $arr['body'] = sprintf($bodyverb, $ulink, $alink, $plink);
    $arr['verb'] = $activity;
    $arr['object-type'] = $objtype;
    $arr['object'] = $obj;
    $arr['allow_cid'] = $item['allow_cid'];
    $arr['allow_gid'] = $item['allow_gid'];
    $arr['deny_cid'] = $item['deny_cid'];
    $arr['deny_gid'] = $item['deny_gid'];
//.........这里部分代码省略.........
开发者ID:ridcully,项目名称:friendica,代码行数:101,代码来源:subthread.php


示例2: pumpio_dolike

function pumpio_dolike(&$a, $uid, $self, $post, $own_id, $threadcompletion = true)
{
    require_once 'include/items.php';
    // Searching for the liked post
    // Two queries for speed issues
    $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($post->object->id), intval($uid));
    if (count($r)) {
        $orig_post = $r[0];
    } else {
        $r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1", dbesc($post->object->id), intval($uid));
        if (!count($r)) {
            return;
        } else {
            $orig_post = $r[0];
        }
    }
    // thread completion
    if ($threadcompletion) {
        pumpio_fetchallcomments($a, $uid, $post->object->id);
    }
    $contactid = 0;
    if (link_compare($post->actor->url, $own_id)) {
        $contactid = $self[0]['id'];
        $post->actor->displayName = $self[0]['name'];
        $post->actor->url = $self[0]['url'];
        $post->actor->image->url = $self[0]['photo'];
    } else {
        $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1", dbesc($post->actor->url), intval($uid));
        if (count($r)) {
            $contactid = $r[0]['id'];
        }
        if ($contactid == 0) {
            $contactid = $orig_post['contact-id'];
        }
    }
    $r = q("SELECT parent FROM `item` WHERE `verb` = '%s' AND `uid` = %d AND `contact-id` = %d AND `thr-parent` = '%s' LIMIT 1", dbesc(ACTIVITY_LIKE), intval($uid), intval($contactid), dbesc($orig_post['uri']));
    if (count($r)) {
        logger("pumpio_dolike: found existing like. User " . $own_id . " " . $uid . " Contact: " . $contactid . " Url " . $orig_post['uri']);
        return;
    }
    $likedata = array();
    $likedata['parent'] = $orig_post['id'];
    $likedata['verb'] = ACTIVITY_LIKE;
    $likedata['gravity'] = 3;
    $likedata['uid'] = $uid;
    $likedata['wall'] = 0;
    $likedata['uri'] = item_new_uri($a->get_baseurl(), $uid);
    $likedata['parent-uri'] = $orig_post["uri"];
    $likedata['contact-id'] = $contactid;
    $likedata['app'] = $post->generator->displayName;
    $likedata['author-name'] = $post->actor->displayName;
    $likedata['author-link'] = $post->actor->url;
    $likedata['author-avatar'] = $post->actor->image->url;
    $author = '[url=' . $likedata['author-link'] . ']' . $likedata['author-name'] . '[/url]';
    $objauthor = '[url=' . $orig_post['author-link'] . ']' . $orig_post['author-name'] . '[/url]';
    $post_type = t('status');
    $plink = '[url=' . $orig_post['plink'] . ']' . $post_type . '[/url]';
    $likedata['object-type'] = ACTIVITY_OBJ_NOTE;
    $likedata['body'] = sprintf(t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
    $likedata['object'] = '<object><type>' . ACTIVITY_OBJ_NOTE . '</type><local>1</local>' . '<id>' . $orig_post['uri'] . '</id><link>' . xmlify('<link rel="alternate" type="text/html" href="' . xmlify($orig_post['plink']) . '" />') . '</link><title>' . $orig_post['title'] . '</title><content>' . $orig_post['body'] . '</content></object>';
    $ret = item_store($likedata);
    logger("pumpio_dolike: " . $ret . " User " . $own_id . " " . $uid . " Contact: " . $contactid . " Url " . $orig_post['uri']);
}
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:63,代码来源:pumpio.php


示例3: event_store

function event_store($arr)
{
    require_once 'include/datetime.php';
    require_once 'include/items.php';
    require_once 'include/bbcode.php';
    $a = get_app();
    $arr['created'] = $arr['created'] ? $arr['created'] : datetime_convert();
    $arr['edited'] = $arr['edited'] ? $arr['edited'] : datetime_convert();
    $arr['type'] = $arr['type'] ? $arr['type'] : 'event';
    $arr['cid'] = intval($arr['cid']) ? intval($arr['cid']) : 0;
    $arr['uri'] = x($arr, 'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(), $arr['uid']);
    $arr['private'] = x($arr, 'private') ? intval($arr['private']) : 0;
    if ($arr['cid']) {
        $c = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($arr['cid']), intval($arr['uid']));
    } else {
        $c = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", intval($arr['uid']));
    }
    if (count($c)) {
        $contact = $c[0];
    }
    // Existing event being modified
    if ($arr['id']) {
        // has the event actually changed?
        $r = q("SELECT * FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($arr['id']), intval($arr['uid']));
        if (!count($r) || $r[0]['edited'] === $arr['edited']) {
            // Nothing has changed. Grab the item id to return.
            $r = q("SELECT * FROM `item` WHERE `event-id` = %d AND `uid` = %d LIMIT 1", intval($arr['id']), intval($arr['uid']));
            return count($r) ? $r[0]['id'] : 0;
        }
        // The event changed. Update it.
        $r = q("UPDATE `event` SET\n\t\t\t`edited` = '%s',\n\t\t\t`start` = '%s',\n\t\t\t`finish` = '%s',\n\t\t\t`desc` = '%s',\n\t\t\t`location` = '%s',\n\t\t\t`type` = '%s',\n\t\t\t`adjust` = %d,\n\t\t\t`nofinish` = %d,\n\t\t\t`allow_cid` = '%s',\n\t\t\t`allow_gid` = '%s',\n\t\t\t`deny_cid` = '%s',\n\t\t\t`deny_gid` = '%s'\n\t\t\tWHERE `id` = %d AND `uid` = %d LIMIT 1", dbesc($arr['edited']), dbesc($arr['start']), dbesc($arr['finish']), dbesc($arr['desc']), dbesc($arr['location']), dbesc($arr['type']), intval($arr['adjust']), intval($arr['nofinish']), dbesc($arr['allow_cid']), dbesc($arr['allow_gid']), dbesc($arr['deny_cid']), dbesc($arr['deny_gid']), intval($arr['id']), intval($arr['uid']));
        $r = q("SELECT * FROM `item` WHERE `event-id` = %d AND `uid` = %d LIMIT 1", intval($arr['id']), intval($arr['uid']));
        if (count($r)) {
            $object = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($arr['uri']) . '</id>';
            $object .= '<content>' . xmlify(format_event_bbcode($arr)) . '</content>';
            $object .= '</object>' . "\n";
            q("UPDATE `item` SET `body` = '%s', `object` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `edited` = '%s', `private` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", dbesc(format_event_bbcode($arr)), dbesc($object), dbesc($arr['allow_cid']), dbesc($arr['allow_gid']), dbesc($arr['deny_cid']), dbesc($arr['deny_gid']), dbesc($arr['edited']), intval($arr['private']), intval($r[0]['id']), intval($arr['uid']));
            return $r[0]['id'];
        } else {
            return 0;
        }
    } else {
        // New event. Store it.
        $r = q("INSERT INTO `event` ( `uid`,`cid`,`uri`,`created`,`edited`,`start`,`finish`,`desc`,`location`,`type`,\n\t\t\t`adjust`,`nofinish`,`allow_cid`,`allow_gid`,`deny_cid`,`deny_gid`)\n\t\t\tVALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' ) ", intval($arr['uid']), intval($arr['cid']), dbesc($arr['uri']), dbesc($arr['created']), dbesc($arr['edited']), dbesc($arr['start']), dbesc($arr['finish']), dbesc($arr['desc']), dbesc($arr['location']), dbesc($arr['type']), intval($arr['adjust']), intval($arr['nofinish']), dbesc($arr['allow_cid']), dbesc($arr['allow_gid']), dbesc($arr['deny_cid']), dbesc($arr['deny_gid']));
        $r = q("SELECT * FROM `event` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($arr['uri']), intval($arr['uid']));
        if (count($r)) {
            $event = $r[0];
        }
        $item_arr = array();
        $item_arr['uid'] = $arr['uid'];
        $item_arr['contact-id'] = $arr['cid'];
        $item_arr['uri'] = $arr['uri'];
        $item_arr['parent-uri'] = $arr['uri'];
        $item_arr['type'] = 'activity';
        $item_arr['wall'] = $arr['cid'] ? 0 : 1;
        $item_arr['contact-id'] = $contact['id'];
        $item_arr['owner-name'] = $contact['name'];
        $item_arr['owner-link'] = $contact['url'];
        $item_arr['owner-avatar'] = $contact['thumb'];
        $item_arr['author-name'] = $contact['name'];
        $item_arr['author-link'] = $contact['url'];
        $item_arr['author-avatar'] = $contact['thumb'];
        $item_arr['title'] = '';
        $item_arr['allow_cid'] = $arr['allow_cid'];
        $item_arr['allow_gid'] = $arr['allow_gid'];
        $item_arr['deny_cid'] = $arr['deny_cid'];
        $item_arr['deny_gid'] = $arr['deny_gid'];
        $item_arr['private'] = $arr['private'];
        $item_arr['last-child'] = 1;
        $item_arr['visible'] = 1;
        $item_arr['verb'] = ACTIVITY_POST;
        $item_arr['object-type'] = ACTIVITY_OBJ_EVENT;
        $item_arr['origin'] = intval($arr['cid']) == 0 ? 1 : 0;
        $item_arr['body'] = format_event_bbcode($event);
        $item_arr['object'] = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($uri) . '</id>';
        $item_arr['object'] .= '<content>' . xmlify(format_event_bbcode($event)) . '</content>';
        $item_arr['object'] .= '</object>' . "\n";
        $item_id = item_store($item_arr);
        $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($arr['uid']));
        if (count($r)) {
            $plink = $a->get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id;
        }
        if ($item_id) {
            q("UPDATE `item` SET `plink` = '%s', `event-id` = %d  WHERE `uid` = %d AND `id` = %d LIMIT 1", dbesc($plink), intval($event['id']), intval($arr['uid']), intval($item_id));
        }
        return $item_id;
    }
}
开发者ID:nextgensh,项目名称:friendica,代码行数:88,代码来源:event.php


示例4: profile_activity

function profile_activity($changed, $value)
{
    $a = get_app();
    if (!local_user() || !is_array($changed) || !count($changed)) {
        return;
    }
    if ($a->user['hidewall'] || get_config('system', 'block_public')) {
        return;
    }
    if (!get_pconfig(local_user(), 'system', 'post_profilechange')) {
        return;
    }
    require_once 'include/items.php';
    $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", intval(local_user()));
    if (!count($self)) {
        return;
    }
    $arr = array();
    $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), local_user());
    $arr['uid'] = local_user();
    $arr['contact-id'] = $self[0]['id'];
    $arr['wall'] = 1;
    $arr['type'] = 'wall';
    $arr['gravity'] = 0;
    $arr['origin'] = 1;
    $arr['author-name'] = $arr['owner-name'] = $self[0]['name'];
    $arr['author-link'] = $arr['owner-link'] = $self[0]['url'];
    $arr['author-avatar'] = $arr['owner-avatar'] = $self[0]['thumb'];
    $arr['verb'] = ACTIVITY_UPDATE;
    $arr['object-type'] = ACTIVITY_OBJ_PROFILE;
    $A = '[url=' . $self[0]['url'] . ']' . $self[0]['name'] . '[/url]';
    $changes = '';
    $t = count($changed);
    $z = 0;
    foreach ($changed as $ch) {
        if (strlen($changes)) {
            if ($z == $t - 1) {
                $changes .= t(' and ');
            } else {
                $changes .= ', ';
            }
        }
        $z++;
        $changes .= $ch;
    }
    $prof = '[url=' . $self[0]['url'] . '?tab=profile' . ']' . t('public profile') . '[/url]';
    if ($t == 1 && strlen($value)) {
        $message = sprintf(t('%1$s changed %2$s to &ldquo;%3$s&rdquo;'), $A, $changes, $value);
        $message .= "\n\n" . sprintf(t(' - Visit %1$s\'s %2$s'), $A, $prof);
    } else {
        $message = sprintf(t('%1$s has an updated %2$s, changing %3$s.'), $A, $prof, $changes);
    }
    $arr['body'] = $message;
    $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PROFILE . '</type><title>' . $self[0]['name'] . '</title>' . '<id>' . $self[0]['url'] . '/' . $self[0]['name'] . '</id>';
    $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $self[0]['url'] . '?tab=profile' . '" />' . "\n");
    $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $self[0]['thumb'] . '" />' . "\n");
    $arr['object'] .= '</link></object>' . "\n";
    $arr['last-child'] = 1;
    $arr['allow_cid'] = $a->user['allow_cid'];
    $arr['allow_gid'] = $a->user['allow_gid'];
    $arr['deny_cid'] = $a->user['deny_cid'];
    $arr['deny_gid'] = $a->user['deny_gid'];
    $i = item_store($arr);
    if ($i) {
        // give it a permanent link
        //q("update item set plink = '%s' where id = %d",
        //	dbesc($a->get_baseurl() . '/display/' . $a->user['nickname'] . '/' . $i),
        //	intval($i)
        //);
        proc_run('php', "include/notifier.php", "activity", "{$i}");
    }
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:72,代码来源:profiles.php


示例5: tagger_content

function tagger_content(&$a)
{
    if (!local_user() && !remote_user()) {
        return;
    }
    $term = notags(trim($_GET['term']));
    // no commas allowed
    $term = str_replace(array(',', ' '), array('', '_'), $term);
    if (!$term) {
        return;
    }
    $item_id = $a->argc > 1 ? notags(trim($a->argv[1])) : 0;
    logger('tagger: tag ' . $term . ' item ' . $item_id);
    $r = q("SELECT * FROM `item` WHERE `id` = '%s' LIMIT 1", dbesc($item_id));
    if (!$item_id || !count($r)) {
        logger('tagger: no item ' . $item_id);
        return;
    }
    $item = $r[0];
    $owner_uid = $item['uid'];
    $r = q("select `nickname`,`blocktags` from user where uid = %d limit 1", intval($owner_uid));
    if (count($r)) {
        $owner_nick = $r[0]['nickname'];
        $blocktags = $r[0]['blocktags'];
    }
    if (local_user() != $owner_uid) {
        return;
    }
    if (remote_user()) {
        $r = q("select * from contact where id = %d AND `uid` = %d limit 1", intval(remote_user()), intval($item['uid']));
    } else {
        $r = q("select * from contact where self = 1 and uid = %d limit 1", intval(local_user()));
    }
    if (count($r)) {
        $contact = $r[0];
    } else {
        logger('tagger: no contact_id');
        return;
    }
    $uri = item_new_uri($a->get_hostname(), $owner_uid);
    $post_type = $item['resource-id'] ? t('photo') : t('status');
    $targettype = $item['resource-id'] ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE;
    $link = xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n");
    $body = $item['body'];
    $target = <<<EOT
\t<target>
\t\t<type>{$targettype}</type>
\t\t<local>1</local>
\t\t<id>{$item['uri']}</id>
\t\t<link>{$link}</link>
\t\t<title></title>
\t\t<content>{$body}</content>
\t</target>
EOT;
    $tagid = $a->get_baseurl() . '/search?search=' . $term;
    $objtype = ACTIVITY_OBJ_TAGTERM;
    $obj = <<<EOT
\t<object>
\t\t<type>{$objtype}</type>
\t\t<local>1</local>
\t\t<id>{$tagid}</id>
\t\t<link>{$tagid}</link>
\t\t<title>{$term}</title>
\t\t<content>{$term}</content>
\t</object>
EOT;
    $bodyverb = t('%1$s tagged %2$s\'s %3$s with %4$s');
    if (!isset($bodyverb)) {
        return;
    }
    $termlink = html_entity_decode('&#x2317;') . '[url=' . $a->get_baseurl() . '/search?search=' . urlencode($term) . ']' . $term . '[/url]';
    $arr = array();
    $arr['uri'] = $uri;
    $arr['uid'] = $owner_uid;
    $arr['contact-id'] = $contact['id'];
    $arr['type'] = 'activity';
    $arr['wall'] = $item['wall'];
    $arr['gravity'] = GRAVITY_COMMENT;
    $arr['parent'] = $item['id'];
    $arr['parent-uri'] = $item['uri'];
    $arr['owner-name'] = $item['author-name'];
    $arr['owner-link'] = $item['author-link'];
    $arr['owner-avatar'] = $item['author-avatar'];
    $arr['author-name'] = $contact['name'];
    $arr['author-link'] = $contact['url'];
    $arr['author-avatar'] = $contact['thumb'];
    $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
    $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
    $plink = '[url=' . $item['plink'] . ']' . $post_type . '[/url]';
    $arr['body'] = sprintf($bodyverb, $ulink, $alink, $plink, $termlink);
    $arr['verb'] = ACTIVITY_TAG;
    $arr['target-type'] = $targettype;
    $arr['target'] = $target;
    $arr['object-type'] = $objtype;
    $arr['object'] = $obj;
    $arr['allow_cid'] = $item['allow_cid'];
    $arr['allow_gid'] = $item['allow_gid'];
    $arr['deny_cid'] = $item['deny_cid'];
    $arr['deny_gid'] = $item['deny_gid'];
    $arr['visible'] = 1;
//.........这里部分代码省略.........
开发者ID:nextgensh,项目名称:friendica,代码行数:101,代码来源:tagger.php


示例6: fbsync_createlike

function fbsync_createlike($a, $uid, $self_id, $self, $contacts, $like)
{
    $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc("fb::" . $like->post_id), intval($uid));
    if (count($r)) {
        $orig_post = $r[0];
    } else {
        return;
    }
    // If we posted the like locally, it will be found with our url, not the FB url.
    $second_url = $like->user_id == $self_id ? $self[0]["url"] : $contacts[$like->user_id]->url;
    $r = q("SELECT * FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `verb` = '%s'\n\t\tAND (`author-link` = '%s' OR `author-link` = '%s') LIMIT 1", dbesc($orig_post["uri"]), intval($uid), dbesc(ACTIVITY_LIKE), dbesc($contacts[$like->user_id]->url), dbesc($second_url));
    if (count($r)) {
        return;
    }
    $contact_id = fbsync_fetch_contact($uid, $contacts[$like->user_id], array(), false);
    if ($contact_id <= 0) {
        $contact_id = $self[0]["id"];
    }
    $likedata = array();
    $likedata['parent'] = $orig_post['id'];
    $likedata['verb'] = ACTIVITY_LIKE;
    $likedata['object-type'] = ACTIVITY_OBJ_NOTE;
    $likedate['network'] = dbesc(NETWORK_FACEBOOK);
    $likedata['gravity'] = 3;
    $likedata['uid'] = $uid;
    $likedata['wall'] = 0;
    $likedata['uri'] = item_new_uri($a->get_baseurl(), $uid);
    $likedata['parent-uri'] = $orig_post["uri"];
    $likedata['app'] = "Facebook";
    if ($like->user_id != $self_id) {
        $likedata['contact-id'] = $contact_id;
        $likedata['author-name'] = $contacts[$like->user_id]->name;
        $likedata['author-link'] = $contacts[$like->user_id]->url;
        $likedata['author-avatar'] = $contacts[$like->user_id]->pic_square;
    } else {
        $likedata['contact-id'] = $self[0]["id"];
        $likedata['author-name'] = $self[0]["name"];
        $likedata['author-link'] = $self[0]["url"];
        $likedata['author-avatar'] = $self[0]["photo"];
    }
    $author = '[url=' . $likedata['author-link'] . ']' . $likedata['author-name'] . '[/url]';
    $objauthor = '[url=' . $orig_post['author-link'] . ']' . $orig_post['author-name'] . '[/url]';
    $post_type = t('status');
    $plink = '[url=' . $orig_post['plink'] . ']' . $post_type . '[/url]';
    $likedata['object-type'] = ACTIVITY_OBJ_NOTE;
    $likedata['body'] = sprintf(t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
    $likedata['object'] = '<object><type>' . ACTIVITY_OBJ_NOTE . '</type><local>1</local>' . '<id>' . $orig_post['uri'] . '</id><link>' . xmlify('<link rel="alternate" type="text/html" href="' . xmlify($orig_post['plink']) . '" />') . '</link><title>' . $orig_post['title'] . '</title><content>' . $orig_post['body'] . '</content></object>';
    $r = q("SELECT * FROM `item` WHERE `parent-uri` = '%s' AND `author-link` = '%s' AND `verb` = '%s' AND `uid` = %d LIMIT 1", dbesc($likedata['parent-uri']), dbesc($likedata['author-link']), dbesc(ACTIVITY_LIKE), intval($uid));
    if (count($r)) {
        return;
    }
    $item = item_store($likedata);
    logger('fbsync_createlike: liked item ' . $item . '. User ' . $self[0]["nick"], LOGGER_DEBUG);
}
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:54,代码来源:fbsync.php


示例7: item_post


//.........这里部分代码省略.........
                            $str_tags .= $newtag;
                        }
                    }
                }
            }
        }
    }
    $attachments = '';
    $match = false;
    if (preg_match_all('/(\\[attachment\\]([0-9]+)\\[\\/attachment\\])/', $body, $match)) {
        foreach ($match[2] as $mtch) {
            $r = q("SELECT `id`,`filename`,`filesize`,`filetype` FROM `attach` WHERE `uid` = %d AND `id` = %d LIMIT 1", intval($profile_uid), intval($mtch));
            if (count($r)) {
                if (strlen($attachments)) {
                    $attachments .= ',';
                }
                $attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . ($r[0]['filename'] ? $r[0]['filename'] : '') . '"[/attach]';
            }
            $body = str_replace($match[1], '', $body);
        }
    }
    $wall = 0;
    if ($post_type === 'wall' || $post_type === 'wall-comment') {
        $wall = 1;
    }
    if (!strlen($verb)) {
        $verb = ACTIVITY_POST;
    }
    $gravity = $parent ? 6 : 0;
    // even if the post arrived via API we are considering that it
    // originated on this site by default for determining relayability.
    $origin = x($_REQUEST, 'origin') ? intval($_REQUEST['origin']) : 1;
    $notify_type = $parent ? 'comment-new' : 'wall-new';
    $uri = item_new_uri($a->get_hostname(), $profile_uid);
    $datarray = array();
    $datarray['uid'] = $profile_uid;
    $datarray['type'] = $post_type;
    $datarray['wall'] = $wall;
    $datarray['gravity'] = $gravity;
    $datarray['contact-id'] = $contact_id;
    $datarray['owner-name'] = $contact_record['name'];
    $datarray['owner-link'] = $contact_record['url'];
    $datarray['owner-avatar'] = $contact_record['thumb'];
    $datarray['author-name'] = $author['name'];
    $datarray['author-link'] = $author['url'];
    $datarray['author-avatar'] = $author['thumb'];
    $datarray['created'] = datetime_convert();
    $datarray['edited'] = datetime_convert();
    $datarray['commented'] = datetime_convert();
    $datarray['received'] = datetime_convert();
    $datarray['changed'] = datetime_convert();
    $datarray['uri'] = $uri;
    $datarray['title'] = $title;
    $datarray['body'] = $body;
    $datarray['app'] = $app;
    $datarray['location'] = $location;
    $datarray['coord'] = $coord;
    $datarray['tag'] = $str_tags;
    $datarray['inform'] = $inform;
    $datarray['verb'] = $verb;
    $datarray['allow_cid'] = $str_contact_allow;
    $datarray['allow_gid'] = $str_group_allow;
    $datarray['deny_cid'] = $str_contact_deny;
    $datarray['deny_gid'] = $str_group_deny;
    $datarray['private'] = $private;
    $datarray['pubmail'] = $pubmail_enable;
开发者ID:nphyx,项目名称:friendica,代码行数:67,代码来源:item.php


示例8: photos_post


//.........这里部分代码省略.........
                $ph = new Photo($r[0]['data']);
                if ($ph->is_valid()) {
                    $ph->rotate(270);
                    $width = $ph->getWidth();
                    $height = $ph->getHeight();
                    $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 0 limit 1", dbesc($ph->imageString()), intval($height), intval($width), dbesc($resource_id), intval($page_owner_uid));
                    if ($width > 640 || $height > 640) {
                        $ph->scaleImage(640);
                        $width = $ph->getWidth();
                        $height = $ph->getHeight();
                        $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 1 limit 1", dbesc($ph->imageString()), intval($height), intval($width), dbesc($resource_id), intval($page_owner_uid));
                    }
                    if ($width > 320 || $height > 320) {
                        $ph->scaleImage(320);
                        $width = $ph->getWidth();
                        $height = $ph->getHeight();
                        $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 2 limit 1", dbesc($ph->imageString()), intval($height), intval($width), dbesc($resource_id), intval($page_owner_uid));
                    }
                }
            }
        }
        $p = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ORDER BY `scale` DESC", dbesc($resource_id), intval($page_owner_uid));
        if (count($p)) {
            $r = q("UPDATE `photo` SET `desc` = '%s', `album` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' WHERE `resource-id` = '%s' AND `uid` = %d", dbesc($desc), dbesc($albname), dbesc($str_contact_allow), dbesc($str_group_allow), dbesc($str_contact_deny), dbesc($str_group_deny), dbesc($resource_id), intval($page_owner_uid));
        }
        /* Don't make the item visible if the only change was the album name */
        $visibility = 0;
        if ($p[0]['desc'] !== $desc || strlen($rawtags)) {
            $visibility = 1;
        }
        if (!$item_id) {
            // Create item container
            $title = '';
            $uri = item_new_uri($a->get_hostname(), $page_owner_uid);
            $arr = array();
            $arr['uid'] = $page_owner_uid;
            $arr['uri'] = $uri;
            $arr['parent-uri'] = $uri;
            $arr['type'] = 'photo';
            $arr['wall'] = 1;
            $arr['resource-id'] = $p[0]['resource-id'];
            $arr['contact-id'] = $owner_record['id'];
            $arr['owner-name'] = $owner_record['name'];
            $arr['owner-link'] = $owner_record['url'];
            $arr['owner-avatar'] = $owner_record['thumb'];
            $arr['author-name'] = $owner_record['name'];
            $arr['author-link'] = $owner_record['url'];
            $arr['author-avatar'] = $owner_record['thumb'];
            $arr['title'] = $title;
            $arr['allow_cid'] = $p[0]['allow_cid'];
            $arr['allow_gid'] = $p[0]['allow_gid'];
            $arr['deny_cid'] = $p[0]['deny_cid'];
            $arr['deny_gid'] = $p[0]['deny_gid'];
            $arr['last-child'] = 1;
            $arr['visible'] = $visibility;
            $arr['origin'] = 1;
            $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.jpg' . '[/img]' . '[/url]';
            $item_id = item_store($arr);
        }
        if ($item_id) {
            $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($item_id), intval($page_owner_uid));
        }
        if (count($r)) {
            $old_tag = $r[0]['tag'];
            $old_inform = $r[0]['inform'];
        }
开发者ID:robhell,项目名称:friendica,代码行数:67,代码来源:photos.php


示例9: photos_post

function photos_post(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        killme();
    }
    $r = q("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = 1  WHERE `self` = 1 LIMIT 1");
    $contact_record = $r[0];
    if ($a->argc > 2 && $a->argv[1] == 'album') {
        $album = hex2bin($a->argv[2]);
        if ($album == t('Profile Photos') || $album == t('Contact Photos')) {
            goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
            return;
            // NOTREACHED
        }
        $r = q("SELECT count(*) FROM `photo` WHERE `album` = '%s' ", dbesc($album));
        if (!count($r)) {
            notice(t('Album not found.') . EOL);
            goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
            return;
            // NOTREACHED
        }
        $newalbum = notags(trim($_POST['albumname']));
        if ($newalbum != $album) {
            q("UPDATE `photo` SET `album` = '%s' WHERE `album` = '%s' ", dbesc($newalbum), dbesc($album));
            $newurl = str_replace(bin2hex($album), bin2hex($newalbum), $_SESSION['photo_return']);
            goaway($a->get_baseurl() . '/' . $newurl);
            return;
            // NOTREACHED
        }
        if ($_POST['dropalbum'] == t('Delete Album')) {
            $res = array();
            $r = q("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `album` = '%s'", dbesc($album));
            if (count($r)) {
                foreach ($r as $rr) {
                    $res[] = "'" . dbesc($rr['rid']) . "'";
                }
            } else {
                goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
                return;
                // NOTREACHED
            }
            $str_res = implode(',', $res);
            q("DELETE FROM `photo` WHERE `resource-id` IN ( {$str_res} ) ");
            $r = q("SELECT `parent-uri` FROM `item` WHERE `resource-id` IN ( {$str_res} ) ");
            if (count($r)) {
                foreach ($r as $rr) {
                    q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' ", dbesc(datetime_convert()), dbesc($rr['parent-uri']));
                    $drop_id = intval($rr['id']);
                    $php_path = strlen($a->config['php_path']) ? $a->config['php_path'] : 'php';
                    // send the notification upstream/downstream as the case may be
                    if ($rr['visible']) {
                        proc_close(proc_open("\"{$php_path}\" \"include/notifier.php\" \"drop\" \"{$drop_id}\" & ", array(), $foo));
                    }
                }
            }
        }
        goaway($a->get_baseurl() . '/photos/' . $a->data['user']['nickname']);
        return;
        // NOTREACHED
    }
    if ($a->argc > 1 && x($_POST, 'delete') && $_POST['delete'] == t('Delete Photo')) {
        $r = q("SELECT `id` FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", dbesc($a->argv[1]));
        if (count($r)) {
            q("DELETE FROM `photo` WHERE `resource-id` = '%s'", dbesc($r[0]['resource-id']));
            $i = q("SELECT * FROM `item` WHERE `resource-id` = '%s' LIMIT 1", dbesc($r[0]['resource-id']));
            if (count($i)) {
                q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s'  WHERE `parent-uri` = '%s' ", dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc($i[0]['uri']));
                $drop_id = intval($i[0]['id']);
                $php_path = strlen($a->config['php_path']) ? $a->config['php_path'] : 'php';
                // send the notification upstream/downstream as the case may be
                if ($i[0]['visible']) {
                    proc_close(proc_open("\"{$php_path}\" \"include/notifier.php\" \"drop\" \"{$drop_id}\" & ", array(), $foo));
                }
            }
        }
        goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
        return;
        // NOTREACHED
    }
    if ($a->argc > 1 && x($_POST, 'desc') !== false) {
        $desc = notags(trim($_POST['desc']));
        $tags = notags(trim($_POST['tags']));
        $item_id = intval($_POST['item_id']);
        $resource_id = $a->argv[1];
        $p = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' ORDER BY `scale` DESC", dbesc($resource_id));
        if (count($r)) {
            $r = q("UPDATE `photo` SET `desc` = '%s' WHERE `resource-id` = '%s' ", dbesc($desc), dbesc($resource_id));
        }
        if (!$item_id) {
            $title = '';
            $basename = basename($filename);
            // Create item container
            $body = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.jpg' . '[/img]' . '[/url]';
            $uri = item_new_uri($a->get_hostname(), get_uid());
            $r = q("INSERT INTO `item` (`type`, `wall`, `resource-id`, `contact-id`,\n\t\t\t\t`owner-name`,`owner-link`,`owner-avatar`, `created`,\n\t\t\t\t`edited`, `changed`, `uri`, `parent-uri`, `title`, `body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`)\n\t\t\t\tVALUES( '%s', %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", dbesc('photo'), intval(1), dbesc($p[0]['resource-id']), intval($contact_record['id']), dbesc($contact_record['name']), dbesc($contact_record['url']), dbesc($contact_record['thumb']), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc($uri), dbesc($uri), dbesc($title), dbesc($body), dbesc($p[0]['allow_cid']), dbesc($p[0]['allow_gid']), dbesc($p[0]['deny_cid']), dbesc($p[0]['deny_gid']));
            if ($r) {
                $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($uri));
                if (count($r)) {
                    $item_id = $r[0]['id'];
//.........这里部分代码省略.........
开发者ID:vishalp,项目名称:MistparkPE-Remix,代码行数:101,代码来源:photos.php


示例10: diaspora_request

function diaspora_request($importer, $xml)
{
    $a = get_app();
    $sender_handle = unxmlify($xml->sender_handle);
    $recipient_handle = unxmlify($xml->recipient_handle);
    if (!$sender_handle || !$recipient_handle) {
        return;
    }
    $contact = diaspora_get_contact_by_handle($importer['uid'], $sender_handle);
    if ($contact) {
        // perhaps we were already sharing with this person. Now they're sharing with us.
        // That makes us friends.
        if ($contact['rel'] == CONTACT_IS_FOLLOWER) {
            q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1", intval(CONTACT_IS_FRIEND), intval($contact['id']), intval($importer['uid']));
        }
        // send notification
        $r = q("SELECT `hide-friends` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1", intval($importer['uid']));
        if (count($r) && $r[0]['hide-friends'] == 0) {
            require_once 'include/items.php';
            $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", intval($importer['uid']));
            // they are not CONTACT_IS_FOLLOWER anymore but that's what we have in the array
            if (count($self) && $contact['rel'] == CONTACT_IS_FOLLOWER) {
                $arr = array();
                $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $importer['uid']);
                $arr['uid'] = $importer['uid'];
                $arr['contact-id'] = $self[0]['id'];
                $arr['wall'] = 1;
                $arr['type'] = 'wall';
                $arr['gravity'] = 0;
                $arr['origin'] = 1;
                $arr['author-name'] = $arr['owner-name'] = $self[0]['name'];
                $arr['author-link'] = $arr['owner-link'] = $self[0]['url'];
                $arr['author-avatar'] = $arr['owner-avatar'] = $self[0]['thumb'];
                $arr['verb'] = ACTIVITY_FRIEND;
                $arr['object-type'] = ACTIVITY_OBJ_PERSON;
                $A = '[url=' . $self[0]['url'] . ']' . $self[0]['name'] . '[/url]';
                $B = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
                $BPhoto = '[url=' . $contact['url'] . ']' . '[img]' . $contact['thumb'] . '[/img][/url]';
                $arr['body'] = sprintf(t('%1$s is now friends with %2$s'), $A, $B) . "\n\n\n" . $Bphoto;
                $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $contact['name'] . '</title>' . '<id>' . $contact['url'] . '/' . $contact['name'] . '</id>';
                $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $contact['url'] . '" />' . "\n");
                $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $contact['thumb'] . '" />' . "\n");
                $arr['object'] .= '</link></object>' . "\n";
                $arr['last-child'] = 1;
                $arr['allow_cid'] = $user[0]['allow_cid'];
                $arr['allow_gid'] = $user[0]['allow_gid'];
                $arr['deny_cid'] = $user[0]['deny_cid'];
                $arr['deny_gid'] = $user[0]['deny_gid'];
                $i = item_store($arr);
                if ($i) {
                    proc_run('php', "include/notifier.php", "activity", "{$i}");
                }
            }
        }
        return;
    }
    $ret = find_diaspora_person_by_handle($sender_handle);
    if (!count($ret) || $ret['network'] != NETWORK_DIASPORA) {
        logger('diaspora_request: Cannot resolve diaspora handle ' . $sender_handle . ' for ' . $recipient_handle);
        return;
    }
    $batch = $ret['batch'] ? $ret['batch'] : implode('/', array_slice(explode('/', $ret['url']), 0, 3)) . '/receive/public';
    $r = q("INSERT INTO `contact` (`uid`, `network`,`addr`,`created`,`url`,`nurl`,`batch`,`name`,`nick`,`photo`,`pubkey`,`notify`,`poll`,`blocked`,`priority`)\n\t\tVALUES ( %d, '%s', '%s', '%s', '%s','%s','%s','%s','%s','%s','%s','%s','%s',%d,%d) ", intval($importer['uid']), dbesc($ret['network']), dbesc($ret['addr']), datetime_convert(), dbesc($ret['url']), dbesc(normalise_link($ret['url'])), dbesc($batch), dbesc($ret['name']), dbesc($ret['nick']), dbesc($ret['photo']), dbesc($ret['pubkey']), dbesc($ret['notify']), dbesc($ret['poll']), 1, 2);
    // find the contact record we just created
    $contact_record = diaspora_get_contact_by_handle($importer['uid'], $sender_handle);
    $hash = random_string() . (string) time();
    // Generate a confirm_key
    if ($contact_record) {
        $ret = q("INSERT INTO `intro` ( `uid`, `contact-id`, `blocked`, `knowyou`, `note`, `hash`, `datetime` )\n\t\t\tVALUES ( %d, %d, %d, %d, '%s', '%s', '%s' )", intval($importer['uid']), intval($contact_record['id']), 0, 0, dbesc(t('Sharing notification from Diaspora network')), dbesc($hash), dbesc(datetime_convert()));
    }
    return;
}
开发者ID:ryivhnn,项目名称:friendica,代码行数:72,代码来源:diaspora.php


示例11: mood_init

function mood_init(&$a)
{
    if (!local_user()) {
        return;
    }
    $uid = local_user();
    $verb = notags(trim($_GET['verb']));
    if (!$verb) {
        return;
    }
    $verbs = get_mood_verbs();
    if (!in_array($verb, $verbs)) {
        return;
    }
    $activity = ACTIVITY_MOOD . '#' . urlencode($verb);
    $parent = x($_GET, 'parent') ? intval($_GET['parent']) : 0;
    logger('mood: verb ' . $verb, LOGGER_DEBUG);
    if ($parent) {
        $r = q("select uri, private, allow_cid, allow_gid, deny_cid, deny_gid\n\t\t\tfrom item where id = %d and parent = %d and uid = %d limit 1", intval($parent), intval($parent), intval($uid));
        if (count($r)) {
            $parent_uri = $r[0]['uri'];
            $private = $r[0]['private'];
            $allow_cid = $r[0]['allow_cid'];
            $allow_gid = $r[0]['allow_gid'];
            $deny_cid = $r[0]['deny_cid'];
            $deny_gid = $r[0]['deny_gid'];
        }
    } else {
        $private = 0;
        $allow_cid = $a->user['allow_cid'];
        $allow_gid = $a->user['allow_gid'];
        $deny_cid = $a->user['deny_cid'];
        $deny_gid = $a->user['deny_gid'];
    }
    $poster = $a->contact;
    $uri = item_new_uri($a->get_hostname(), $uid);
    $action = sprintf(t('%1$s is currently %2$s'), '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]', $verbs[$verb]);
    $arr = array();
    $arr['uid'] = $uid;
    $arr['uri'] = $uri;
    $arr['parent-uri'] = $parent_uri ? $parent_uri : $uri;
    $arr['type'] = 'activity';
    $arr['wall'] = 1;
    $arr['contact-id'] = $poster['id'];
    $arr['owner-name'] = $poster['name'];
    $arr['owner-link'] = $poster['url'];
    $arr['owner-avatar'] = $poster['thumb'];
    $arr['author-name'] = $poster['name'];
    $arr['author-link'] = $poster['url'];
    $arr['author-avatar'] = $poster['thumb'];
    $arr['title'] = '';
    $arr['allow_cid'] = $allow_cid;
    $arr['allow_gid'] = $allow_gid;
    $arr['deny_cid'] = $deny_cid;
    $arr['deny_gid'] = $deny_gid;
    $arr['last-child'] = 1;
    $arr['visible'] = 1;
    $arr['verb'] = $activity;
    $arr['private'] = $private;
    $arr['origin'] = 1;
    $arr['body'] = $action;
    $item_id = item_store($arr);
    if ($item_id) {
        q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d", dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id), intval($uid), intval($item_id));
        proc_run('php', "include/notifier.php", "tag", "{$item_id}");
    }
    call_hooks('post_local_end', $arr);
    proc_run('php', "include/notifier.php", "like", "{$post_id}");
    return;
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:70,代码来源:mood.php


示例12: fb_consume_like

/**
 * @param App $a
 * @param array $user
 * @param array $self
 * @param string $fb_id
 * @param bool $wall
 * @param array $orig_post
 * @param object $likes
 */
function fb_consume_like(&$a, &$user, &$self, $fb_id, $wall, &$orig_post, &$likes)
{
    $top_item = $orig_post['id'];
    $uid = IntVal($user[0]['uid']);
    if (!$orig_post) {
        return;
    }
    // If we posted the like locally, it will be found with our url, not the FB url.
    $second_url = $likes->id == $fb_id ? $self[0]['url'] : 'http://facebook.com/profile.php?id=' . $likes->id;
    $r = q("SELECT * FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `verb` = '%s'\n    \tAND ( `author-link` = '%s' OR `author-link` = '%s' ) LIMIT 1", dbesc($orig_post['uri']), intval($uid), dbesc(ACTIVITY_LIKE), dbesc('http://facebook.com/profile.php?id=' . $likes->id), dbesc($second_url));
    if (count($r)) {
        return;
    }
    $likedata = array();
    $likedata['parent'] = $top_item;
    $likedata['verb'] = ACTIVITY_LIKE;
    $likedata['gravity'] = 3;
    $likedata['uid'] = $uid;
    $likedata['wall'] = $wall ? 1 : 0;
    $likedata['uri'] = item_new_uri($a->get_baseurl(), $uid);
    $likedata['parent-uri'] = $orig_post['uri'];
    if ($likes->id == $fb_id) {
        $likedata['contact-id'] = $self[0]['id'];
    } else {
        $r = q("SELECT * FROM `contact` WHERE `notify` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1", dbesc($likes->id), intval($uid));
        if (count($r)) {
            $likedata['contact-id'] = $r[0] 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP item_normal函数代码示例发布时间:2022-05-15
下一篇:
PHP item_message_id函数代码示例发布时间: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