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

PHP link_compare函数代码示例

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

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



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

示例1: pubsub_init

function pubsub_init(&$a)
{
    $nick = argc() > 1 ? escape_tags(trim(argv(1))) : '';
    $contact_id = argc() > 2 ? intval(argv(2)) : 0;
    if ($_SERVER['REQUEST_METHOD'] === 'GET') {
        $hub_mode = x($_GET, 'hub_mode') ? notags(trim($_GET['hub_mode'])) : '';
        $hub_topic = x($_GET, 'hub_topic') ? notags(trim($_GET['hub_topic'])) : '';
        $hub_challenge = x($_GET, 'hub_challenge') ? notags(trim($_GET['hub_challenge'])) : '';
        $hub_lease = x($_GET, 'hub_lease_seconds') ? notags(trim($_GET['hub_lease_seconds'])) : '';
        $hub_verify = x($_GET, 'hub_verify_token') ? notags(trim($_GET['hub_verify_token'])) : '';
        logger('pubsub: Subscription from ' . $_SERVER['REMOTE_ADDR']);
        logger('pubsub: data: ' . print_r($_GET, true), LOGGER_DATA);
        $subscribe = $hub_mode === 'subscribe' ? 1 : 0;
        $channel = channelx_by_nick($nick);
        if (!$channel) {
            http_status_exit(404, 'not found.');
        }
        $connections = abook_connections($channel['channel_id'], ' and abook_id = ' . $contact_id);
        if ($connections) {
            $xchan = $connections[0];
        } else {
            logger('connection ' . $contact_id . ' not found.');
            http_status_exit(404, 'not found.');
        }
        if ($hub_verify) {
            $verify = get_abconfig($channel['channel_id'], $xchan['xchan_hash'], 'pubsubhubbub', 'verify_token');
            if ($verify != $hub_verify) {
                logger('hub verification failed.');
                http_status_exit(404, 'not found.');
            }
        }
        $feed_url = z_root() . '/feed/' . $channel['channel_address'];
        if ($hub_topic) {
            if (!link_compare($hub_topic, $feed_url)) {
                logger('hub topic ' . $hub_topic . ' != ' . $feed_url);
                // should abort but let's humour them.
            }
        }
        $contact = $r[0];
        // We must initiate an unsubscribe request with a verify_token.
        // Don't allow outsiders to unsubscribe us.
        if ($hub_mode === 'unsubscribe') {
            if (!strlen($hub_verify)) {
                logger('pubsub: bogus unsubscribe');
                http_status_exit(403, 'permission denied.');
            }
            logger('pubsub: unsubscribe success');
        }
        if ($hub_mode) {
            set_abconfig($channel['channel_id'], $xchan['xchan_hash'], 'pubsubhubbub', 'subscribed', intval($subscribe));
        }
        header($_SERVER["SERVER_PROTOCOL"] . ' 200 ' . 'OK');
        echo $hub_challenge;
        killme();
    }
}
开发者ID:phellmes,项目名称:hubzilla-addons,代码行数:56,代码来源:pubsub.php


示例2: pubsub_init

function pubsub_init(&$a)
{
    $nick = $a->argc > 1 ? notags(trim($a->argv[1])) : '';
    $contact_id = $a->argc > 2 ? intval($a->argv[2]) : 0;
    if ($_SERVER['REQUEST_METHOD'] === 'GET') {
        $hub_mode = x($_GET, 'hub_mode') ? notags(trim($_GET['hub_mode'])) : '';
        $hub_topic = x($_GET, 'hub_topic') ? notags(trim($_GET['hub_topic'])) : '';
        $hub_challenge = x($_GET, 'hub_challenge') ? notags(trim($_GET['hub_challenge'])) : '';
        $hub_lease = x($_GET, 'hub_lease_seconds') ? notags(trim($_GET['hub_lease_seconds'])) : '';
        $hub_verify = x($_GET, 'hub_verify_token') ? notags(trim($_GET['hub_verify_token'])) : '';
        logger('pubsub: Subscription from ' . $_SERVER['REMOTE_ADDR']);
        logger('pubsub: data: ' . print_r($_GET, true), LOGGER_DATA);
        $subscribe = $hub_mode === 'subscribe' ? 1 : 0;
        $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", dbesc($nick));
        if (!count($r)) {
            logger('pubsub: local account not found: ' . $nick);
            hub_return(false, '');
        }
        $owner = $r[0];
        $sql_extra = strlen($hub_verify) ? sprintf(" AND `hub-verify` = '%s' ", dbesc($hub_verify)) : '';
        $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d \n\t\t\tAND `blocked` = 0 AND `pending` = 0 {$sql_extra} LIMIT 1", intval($contact_id), intval($owner['uid']));
        if (!count($r)) {
            logger('pubsub: contact ' . $contact_id . ' not found.');
            hub_return(false, '');
        }
        if ($hub_topic) {
            if (!link_compare($hub_topic, $r[0]['poll'])) {
                logger('pubsub: hub topic ' . $hub_topic . ' != ' . $r[0]['poll']);
                // should abort but let's humour them.
            }
        }
        $contact = $r[0];
        // We must initiate an unsubscribe request with a verify_token.
        // Don't allow outsiders to unsubscribe us.
        if ($hub_mode === 'unsubscribe') {
            if (!strlen($hub_verify)) {
                logger('pubsub: bogus unsubscribe');
                hub_return(false, '');
            }
            logger('pubsub: unsubscribe success');
        }
        if ($hub_mode) {
            $r = q("UPDATE `contact` SET `subhub` = %d WHERE `id` = %d", intval($subscribe), intval($contact['id']));
        }
        hub_return(true, $hub_challenge);
    }
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:47,代码来源:pubsub.php


示例3: pubsubhubbub_init

function pubsubhubbub_init(&$a)
{
    // PuSH subscription must be considered "public" so just block it
    // if public access isn't enabled.
    if (get_config('system', 'block_public')) {
        http_status_exit(403);
    }
    // Subscription request from subscriber
    // https://pubsubhubbub.googlecode.com/git/pubsubhubbub-core-0.4.html#anchor4
    // Example from GNU Social:
    // [hub_mode] => subscribe
    // [hub_callback] => http://status.local/main/push/callback/1
    // [hub_verify] => sync
    // [hub_verify_token] => af11...
    // [hub_secret] => af11...
    // [hub_topic] => http://friendica.local/dfrn_poll/sazius
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        $hub_mode = push_post_var('hub_mode');
        $hub_callback = push_post_var('hub_callback');
        $hub_verify = push_post_var('hub_verify');
        $hub_verify_token = push_post_var('hub_verify_token');
        $hub_secret = push_post_var('hub_secret');
        $hub_topic = push_post_var('hub_topic');
        // check for valid hub_mode
        if ($hub_mode === 'subscribe') {
            $subscribe = 1;
        } else {
            if ($hub_mode === 'unsubscribe') {
                $subscribe = 0;
            } else {
                logger("pubsubhubbub: invalid hub_mode={$hub_mode}, ignoring.");
                http_status_exit(404);
            }
        }
        logger("pubsubhubbub: {$hub_mode} request from " . $_SERVER['REMOTE_ADDR']);
        // get the nick name from the topic, a bit hacky but needed
        $nick = substr(strrchr($hub_topic, "/"), 1);
        if (!$nick) {
            logger('pubsubhubbub: bad hub_topic=$hub_topic, ignoring.');
            http_status_exit(404);
        }
        // fetch user from database given the nickname
        $owner = channelx_by_nick($nick);
        if (!$owner) {
            logger('pubsubhubbub: local account not found: ' . $nick);
            http_status_exit(404);
        }
        if (!perm_is_allowed($owner['channel_id'], '', 'view_stream')) {
            logger('pubsubhubbub: local channel ' . $nick . 'has chosen to hide wall, ignoring.');
            http_status_exit(403);
        }
        // sanity check that topic URLs are the same
        if (!link_compare($hub_topic, z_root() . '/feed/' . $nick)) {
            logger('pubsubhubbub: not a valid hub topic ' . $hub_topic);
            http_status_exit(404);
        }
        // do subscriber verification according to the PuSH protocol
        $hub_challenge = random_string(40);
        $params = 'hub.mode=' . ($subscribe == 1 ? 'subscribe' : 'unsubscribe') . '&hub.topic=' . urlencode($hub_topic) . '&hub.challenge=' . $hub_challenge . '&hub.lease_seconds=604800' . '&hub.verify_token=' . $hub_verify_token;
        // lease time is hard coded to one week (in seconds)
        // we don't actually enforce the lease time because GNU
        // Social/StatusNet doesn't honour it (yet)
        $x = z_fetch_url($hub_callback . "?" . $params);
        if (!$x['success']) {
            logger("pubsubhubbub: subscriber verification at {$hub_callback} " . "returned {$ret}, ignoring.");
            http_status_exit(404);
        }
        // check that the correct hub_challenge code was echoed back
        if (trim($x['body']) !== $hub_challenge) {
            logger("pubsubhubbub: subscriber did not echo back " . "hub.challenge, ignoring.");
            logger("\"{$hub_challenge}\" != \"" . trim($x['body']) . "\"");
            http_status_exit(404);
        }
        // fetch the old subscription if it exists
        $orig = q("SELECT * FROM `push_subscriber` WHERE `callback_url` = '%s'", dbesc($hub_callback));
        // delete old subscription if it exists
        q("DELETE FROM push_subscriber WHERE callback_url = '%s' and topic = '%s'", dbesc($hub_callback), dbesc($hub_topic));
        if ($subscribe) {
            $last_update = datetime_convert('UTC', 'UTC', 'now', 'Y-m-d H:i:s');
            // if we are just updating an old subscription, keep the
            // old values for last_update
            if ($orig) {
                $last_update = $orig[0]['last_update'];
            }
            // subscribe means adding the row to the table
            q("INSERT INTO push_subscriber ( callback_url, topic, last_update, secret) values ('%s', '%s', '%s', '%s') ", dbesc($hub_callback), dbesc($hub_topic), dbesc($last_update), dbesc($hub_secret));
            logger("pubsubhubbub: successfully subscribed [{$hub_callback}].");
        } else {
            logger("pubsubhubbub: successfully unsubscribed [{$hub_callback}].");
            // we do nothing here, since the row was already deleted
        }
        http_status_exit(202);
    }
    killme();
}
开发者ID:phellmes,项目名称:hubzilla-addons,代码行数:95,代码来源:pubsubhubbub.php


示例4: render_content


//.........这里部分代码省略.........
                }
                $override_comment_box = $page_writeable && $item_writeable ? true : false;
                $show_comment_box = $page_writeable && $item_writeable && $comments_seen == $comments[$item['parent']] ? true : false;
                if ($comments[$item['parent']] > 2 && $comments_seen <= $comments[$item['parent']] - 2 && $item['gravity'] == 6) {
                    if (!$comments_collapsed) {
                        $threads[$threadsid]['num_comments'] = sprintf(tt('%d comment', '%d comments', $comments[$item['parent']]), $comments[$item['parent']]);
                        $threads[$threadsid]['hidden_comments_num'] = $comments[$item['parent']];
                        $threads[$threadsid]['hidden_comments_text'] = tt('comment', 'comments', $comments[$item['parent']]);
                        $threads[$threadsid]['hide_text'] = t('show more');
                        $comments_collapsed = true;
                        $comment_firstcollapsed = true;
                    }
                }
                if ($comments[$item['parent']] > 2 && $comments_seen == $comments[$item['parent']] - 1) {
                    $comment_lastcollapsed = true;
                }
                $redirect_url = $a->get_baseurl($ssl_state) . '/redir/' . $item['cid'];
                $lock = $item['private'] == 1 || $item['uid'] == local_user() && (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) ? t('Private Message') : false;
                // Top-level wall post not written by the wall owner (wall-to-wall)
                // First figure out who owns it.
                $osparkle = '';
                if ($toplevelpost && !$item['self'] && $mode !== 'profile') {
                    if ($item['wall']) {
                        // On the network page, I am the owner. On the display page it will be the profile owner.
                        // This will have been stored in $a->page_contact by our calling page.
                        // Put this person as the wall owner of the wall-to-wall notice.
                        $owner_url = zrl($a->page_contact['url']);
                        $owner_photo = $a->page_contact['thumb'];
                        $owner_name = $a->page_contact['name'];
                        $template = $wallwall;
                        $commentww = 'ww';
                    }
                    if (!$item['wall'] && $item['owner-link']) {
                        $owner_linkmatch = $item['owner-link'] && link_compare($item['owner-link'], $item['author-link']);
                        $alias_linkmatch = $item['alias'] && link_compare($item['alias'], $item['author-link']);
                        $owner_namematch = $item['owner-name'] && $item['owner-name'] == $item['author-name'];
                        if (!$owner_linkmatch && !$alias_linkmatch && !$owner_namematch) {
                            // The author url doesn't match the owner (typically the contact)
                            // and also doesn't match the contact alias.
                            // The name match is a hack to catch several weird cases where URLs are
                            // all over the park. It can be tricked, but this prevents you from
                            // seeing "Bob Smith to Bob Smith via Wall-to-wall" and you know darn
                            // well that it's the same Bob Smith.
                            // But it could be somebody else with the same name. It just isn't highly likely.
                            $owner_url = $item['owner-link'];
                            $owner_photo = $item['owner-avatar'];
                            $owner_name = $item['owner-name'];
                            $template = $wallwall;
                            $commentww = 'ww';
                            // If it is our contact, use a friendly redirect link
                            if (link_compare($item['owner-link'], $item['url']) && $item['network'] === NETWORK_DFRN) {
                                $owner_url = $redirect_url;
                                $osparkle = ' sparkle';
                            } else {
                                $owner_url = zrl($owner_url);
                            }
                        }
                    }
                }
                $likebuttons = '';
                $shareable = $profile_owner == local_user() && $item['private'] != 1 ? true : false;
                if ($page_writeable) {
                    /*					if($toplevelpost) {  */
                    $likebuttons = array('like' => array(t("I like this (toggle)"), t("like")), 'dislike' => array(t("I don't like this (toggle)"), t("dislike")));
                    if ($shareable) {
                        $likebuttons['share'] = array(t('Share this'), t('share'));
开发者ID:ZerGabriel,项目名称:friendica,代码行数:67,代码来源:content.php


示例5: check_wall_to_wall

 /**
  * Check if we are a wall to wall item and set the relevant properties
  */
 protected function check_wall_to_wall()
 {
     $a = $this->get_app();
     $conv = $this->get_conversation();
     $this->wall_to_wall = false;
     if ($this->is_toplevel()) {
         if ($conv->get_mode() !== 'profile') {
             if ($this->get_data_value('wall') and !$this->get_data_value('self')) {
                 // On the network page, I am the owner. On the display page it will be the profile owner.
                 // This will have been stored in $a->page_contact by our calling page.
                 // Put this person as the wall owner of the wall-to-wall notice.
                 $this->owner_url = zrl($a->page_contact['url']);
                 $this->owner_photo = $a->page_contact['thumb'];
                 $this->owner_name = $a->page_contact['name'];
                 $this->wall_to_wall = true;
             } else {
                 if ($this->get_data_value('owner-link')) {
                     $owner_linkmatch = $this->get_data_value('owner-link') && link_compare($this->get_data_value('owner-link'), $this->get_data_value('author-link'));
                     $alias_linkmatch = $this->get_data_value('alias') && link_compare($this->get_data_value('alias'), $this->get_data_value('author-link'));
                     $owner_namematch = $this->get_data_value('owner-name') && $this->get_data_value('owner-name') == $this->get_data_value('author-name');
                     if (!$owner_linkmatch && !$alias_linkmatch && !$owner_namematch) {
                         // The author url doesn't match the owner (typically the contact)
                         // and also doesn't match the contact alias.
                         // The name match is a hack to catch several weird cases where URLs are
                         // all over the park. It can be tricked, but this prevents you from
                         // seeing "Bob Smith to Bob Smith via Wall-to-wall" and you know darn
                         // well that it's the same Bob Smith.
                         // But it could be somebody else with the same name. It just isn't highly likely.
                         $this->owner_photo = $this->get_data_value('owner-avatar');
                         $this->owner_name = $this->get_data_value('owner-name');
                         $this->wall_to_wall = true;
                         // If it is our contact, use a friendly redirect link
                         if (link_compare($this->get_data_value('owner-link'), $this->get_data_value('url')) && $this->get_data_value('network') === NETWORK_DFRN) {
                             $this->owner_url = $this->get_redirect_url();
                         } else {
                             $this->owner_url = zrl($this->get_data_value('owner-link'));
                         }
                     }
                 }
             }
         }
     }
     if (!$this->wall_to_wall) {
         $this->set_template('wall');
         $this->owner_url = '';
         $this->owner_photo = '';
         $this->owner_name = '';
     }
 }
开发者ID:jzacman,项目名称:friendica,代码行数:52,代码来源:Item.php


示例6: like_puller

 function like_puller($a, $item, &$arr, $mode)
 {
     $url = '';
     $sparkle = '';
     $verb = $mode === 'like' ? ACTIVITY_LIKE : ACTIVITY_DISLIKE;
     if (activity_match($item['verb'], $verb) && $item['id'] != $item['parent']) {
         $url = $item['author-link'];
         if (local_user() && local_user() == $item['uid'] && $item['network'] === 'dfrn' && !$item['self'] && link_compare($item['author-link'], $item['url'])) {
             $url = $a->get_baseurl(true) . '/redir/' . $item['contact-id'];
             $sparkle = ' class="sparkle" ';
         } else {
             $url = zrl($url);
         }
         if (!$item['thr-parent']) {
             $item['thr-parent'] = $item['parent-uri'];
         }
         if (!(isset($arr[$item['thr-parent'] . '-l']) && is_array($arr[$item['thr-parent'] . '-l']))) {
             $arr[$item['thr-parent'] . '-l'] = array();
         }
         if (!isset($arr[$item['thr-parent']])) {
             $arr[$item['thr-parent']] = 1;
         } else {
             $arr[$item['thr-parent']]++;
         }
         $arr[$item['thr-parent'] . '-l'][] = '<a href="' . $url . '"' . $sparkle . '>' . $item['author-name'] . '</a>';
     }
     return;
 }
开发者ID:jzacman,项目名称:friendica,代码行数:28,代码来源:conversation.php


示例7: diaspora_signed_retraction

function diaspora_signed_retraction($importer, $xml, $msg)
{
    $guid = notags(unxmlify($xml->target_guid));
    $diaspora_handle = notags(unxmlify($xml->sender_handle));
    $type = notags(unxmlify($xml->target_type));
    $sig = notags(unxmlify($xml->target_author_signature));
    $parent_author_signature = $xml->parent_author_signature ? notags(unxmlify($xml->parent_author_signature)) : '';
    $contact = diaspora_get_contact_by_handle($importer['uid'], $diaspora_handle);
    if (!$contact) {
        logger('diaspora_signed_retraction: no contact ' . $diaspora_handle . ' for ' . $importer['uid']);
        return;
    }
    $signed_data = $guid . ';' . $type;
    $key = $msg['key'];
    /* How Diaspora performs relayable_retraction signature checking:
    
    	   - If an item has been sent by the item author to the top-level post owner to relay on
    	     to the rest of the contacts on the top-level post, the top-level post owner checks
    	     the author_signature, then creates a parent_author_signature before relaying the item on
    	   - If an item has been relayed on by the top-level post owner, the contacts who receive it
    	     check only the parent_author_signature. Basically, they trust that the top-level post
    	     owner has already verified the authenticity of anything he/she sends out
    	   - In either case, the signature that get checked is the signature created by the person
    	     who sent the salmon
    	*/
    if ($parent_author_signature) {
        $parent_author_signature = base64_decode($parent_author_signature);
        if (!rsa_verify($signed_data, $parent_author_signature, $key, 'sha256')) {
            logger('diaspora_signed_retraction: top-level post owner verification failed');
            return;
        }
    } else {
        $sig_decode = base64_decode($sig);
        if (!rsa_verify($signed_data, $sig_decode, $key, 'sha256')) {
            logger('diaspora_signed_retraction: retraction owner verification failed.' . print_r($msg, true));
            return;
        }
    }
    if ($type === 'StatusMessage' || $type === 'Comment' || $type === 'Like') {
        $r = q("select * from item where guid = '%s' and uid = %d and not file like '%%[%%' limit 1", dbesc($guid), intval($importer['uid']));
        if (count($r)) {
            if (link_compare($r[0]['author-link'], $contact['url'])) {
                q("update item set `deleted` = 1, `edited` = '%s', `changed` = '%s', `body` = '' , `title` = '' where `id` = %d", dbesc(datetime_convert()), dbesc(datetime_convert()), intval($r[0]['id']));
                delete_thread($r[0]['id'], $r[0]['parent-uri']);
                // Now check if the retraction needs to be relayed by us
                //
                // The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always
                // return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent.
                // The only item with `parent` and `id` as the parent id is the parent item.
                $p = q("select origin from item where parent = %d and id = %d limit 1", $r[0]['parent'], $r[0]['parent']);
                if (count($p)) {
                    if ($p[0]['origin'] && !$parent_author_signature) {
                        q("insert into sign (`retract_iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", $r[0]['id'], dbesc($signed_data), dbesc($sig), dbesc($diaspora_handle));
                        // the existence of parent_author_signature would have meant the parent_author or owner
                        // is already relaying.
                        logger('diaspora_signed_retraction: relaying relayable_retraction');
                        proc_run('php', 'include/notifier.php', 'drop', $r[0]['id']);
                    }
                }
            }
        }
    } else {
        logger('diaspora_signed_retraction: unknown type: ' . $type);
    }
    return 202;
    // NOTREACHED
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:67,代码来源:diaspora.php


示例8: pubsubhubbub_init

function pubsubhubbub_init(&$a)
{
    // PuSH subscription must be considered "public" so just block it
    // if public access isn't enabled.
    if (get_config('system', 'block_public')) {
        http_status_exit(403);
    }
    // Subscription request from subscriber
    // https://pubsubhubbub.googlecode.com/git/pubsubhubbub-core-0.4.html#anchor4
    // Example from GNU Social:
    // [hub_mode] => subscribe
    // [hub_callback] => http://status.local/main/push/callback/1
    // [hub_verify] => sync
    // [hub_verify_token] => af11...
    // [hub_secret] => af11...
    // [hub_topic] => http://friendica.local/dfrn_poll/sazius
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        $hub_mode = post_var('hub_mode');
        $hub_callback = post_var('hub_callback');
        $hub_verify = post_var('hub_verify');
        $hub_verify_token = post_var('hub_verify_token');
        $hub_secret = post_var('hub_secret');
        $hub_topic = post_var('hub_topic');
        // check for valid hub_mode
        if ($hub_mode === 'subscribe') {
            $subscribe = 1;
        } else {
            if ($hub_mode === 'unsubscribe') {
                $subscribe = 0;
            } else {
                logger("pubsubhubbub: invalid hub_mode={$hub_mode}, ignoring.");
                http_status_exit(404);
            }
        }
        logger("pubsubhubbub: {$hub_mode} request from " . $_SERVER['REMOTE_ADDR']);
        // get the nick name from the topic, a bit hacky but needed
        $nick = substr(strrchr($hub_topic, "/"), 1);
        if (!$nick) {
            logger('pubsubhubbub: bad hub_topic=$hub_topic, ignoring.');
            http_status_exit(404);
        }
        // fetch user from database given the nickname
        $r = q("SELECT * FROM `user` WHERE `nickname` = '%s'" . " AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1", dbesc($nick));
        if (!count($r)) {
            logger('pubsubhubbub: local account not found: ' . $nick);
            http_status_exit(404);
        }
        $owner = $r[0];
        // abort if user's wall is supposed to be private
        if ($r[0]['hidewall']) {
            logger('pubsubhubbub: local user ' . $nick . 'has chosen to hide wall, ignoring.');
            http_status_exit(403);
        }
        // get corresponding row from contact table
        $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND NOT `blocked`" . " AND NOT `pending` AND `self` LIMIT 1", intval($owner['uid']));
        if (!count($r)) {
            logger('pubsubhubbub: contact not found.');
            http_status_exit(404);
        }
        $contact = $r[0];
        // sanity check that topic URLs are the same
        if (!link_compare($hub_topic, $contact['poll'])) {
            logger('pubsubhubbub: hub topic ' . $hub_topic . ' != ' . $contact['poll']);
            http_status_exit(404);
        }
        // do subscriber verification according to the PuSH protocol
        $hub_challenge = random_string(40);
        $params = 'hub.mode=' . ($subscribe == 1 ? 'subscribe' : 'unsubscribe') . '&hub.topic=' . urlencode($hub_topic) . '&hub.challenge=' . $hub_challenge . '&hub.lease_seconds=604800' . '&hub.verify_token=' . $hub_verify_token;
        // lease time is hard coded to one week (in seconds)
        // we don't actually enforce the lease time because GNU
        // Social/StatusNet doesn't honour it (yet)
        $body = fetch_url($hub_callback . "?" . $params);
        $ret = $a->get_curl_code();
        // give up if the HTTP return code wasn't a success (2xx)
        if ($ret < 200 || $ret > 299) {
            logger("pubsubhubbub: subscriber verification at {$hub_callback} " . "returned {$ret}, ignoring.");
            http_status_exit(404);
        }
        // check that the correct hub_challenge code was echoed back
        if (trim($body) !== $hub_challenge) {
            logger("pubsubhubbub: subscriber did not echo back " . "hub.challenge, ignoring.");
            logger("\"{$hub_challenge}\" != \"" . trim($body) . "\"");
            http_status_exit(404);
        }
        // fetch the old subscription if it exists
        $r = q("SELECT * FROM `push_subscriber` WHERE `callback_url` = '%s'", dbesc($hub_callback));
        // delete old subscription if it exists
        q("DELETE FROM `push_subscriber` WHERE `callback_url` = '%s'", dbesc($hub_callback));
        if ($subscribe) {
            $last_update = datetime_convert('UTC', 'UTC', 'now', 'Y-m-d H:i:s');
            $push_flag = 0;
            // if we are just updating an old subscription, keep the
            // old values for push and last_update
            if (count($r)) {
                $last_update = $r[0]['last_update'];
                $push_flag = $r[0]['push'];
            }
            // subscribe means adding the row to the table
            q("INSERT INTO `push_subscriber` (`uid`, `callback_url`, " . "`topic`, `nickname`, `push`, `last_update`, `secret`) values " . "(%d, '%s', '%s', '%s', %d, '%s', '%s')", intval($owner['uid']), dbesc($hub_callback), dbesc($hub_topic), dbesc($nick), intval($push_flag), dbesc($last_update), dbesc($hub_secret));
            logger("pubsubhubbub: successfully subscribed [{$hub_callback}].");
//.........这里部分代码省略.........
开发者ID:vinzv,项目名称:friendica,代码行数:101,代码来源:pubsubhubbub.php


示例9: notifier_run


//.........这里部分代码省略.........
    }
    $r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) AND `blocked` = 0 AND `pending` = 0 ", dbesc($recip_str));
    require_once 'include/salmon.php';
    $interval = get_config('system', 'delivery_interval') === false ? 2 : intval(get_config('system', 'delivery_interval'));
    // delivery loop
    if (count($r)) {
        foreach ($r as $contact) {
            if (!$mail && !$fsuggest && !$followup && !$contact['self']) {
                if ($contact['network'] === NETWORK_DIASPORA && $public_message) {
                    continue;
                }
                q("insert into deliverq ( `cmd`,`item`,`contact` ) values ('%s', %d, %d )", dbesc($cmd), intval($item_id), intval($contact['id']));
            }
        }
        foreach ($r as $contact) {
            if ($contact['self']) {
                continue;
            }
            // potentially more than one recipient. Start a new process and space them out a bit.
            // we will deliver single recipient types of message and email receipients here.
            if (!$mail && !$fsuggest && !$followup) {
                proc_run('php', 'include/delivery.php', $cmd, $item_id, $contact['id']);
                if ($interval) {
                    @time_sleep_until(microtime(true) + (double) $interval);
                }
                continue;
            }
            $deliver_status = 0;
            logger("main delivery by notifier: followup={$followup} mail={$mail} fsuggest={$fsuggest}");
            switch ($contact['network']) {
                case NETWORK_DFRN:
                    // perform local delivery if we are on the same site
                    $basepath = implode('/', array_slice(explode('/', $contact['url']), 0, 3));
                    if (link_compare($basepath, $a->get_baseurl())) {
                        $nickname = basename($contact['url']);
                        if ($contact['issued-id']) {
                            $sql_extra = sprintf(" AND `dfrn-id` = '%s' ", dbesc($contact['issued-id']));
                        } else {
                            $sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($contact['dfrn-id']));
                        }
                        $x = q("SELECT\t`contact`.*, `contact`.`uid` AS `importer_uid`, \n\t\t\t\t\t\t\t`contact`.`pubkey` AS `cpubkey`, \n\t\t\t\t\t\t\t`contact`.`prvkey` AS `cprvkey`, \n\t\t\t\t\t\t\t`contact`.`thumb` AS `thumb`, \n\t\t\t\t\t\t\t`contact`.`url` as `url`,\n\t\t\t\t\t\t\t`contact`.`name` as `senderName`,\n\t\t\t\t\t\t\t`user`.* \n\t\t\t\t\t\t\tFROM `contact` \n\t\t\t\t\t\t\tLEFT JOIN `user` ON `contact`.`uid` = `user`.`uid` \n\t\t\t\t\t\t\tWHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t\t\t\t\tAND `contact`.`network` = '%s' AND `user`.`nickname` = '%s'\n\t\t\t\t\t\t\t{$sql_extra}\n\t\t\t\t\t\t\tAND `user`.`account_expired` = 0 LIMIT 1", dbesc(NETWORK_DFRN), dbesc($nickname));
                        if (count($x)) {
                            require_once 'library/simplepie/simplepie.inc';
                            logger('mod-delivery: local delivery');
                            local_delivery($x[0], $atom);
                            break;
                        }
                    }
                    logger('notifier: dfrndelivery: ' . $contact['name']);
                    $deliver_status = dfrn_deliver($owner, $contact, $atom);
                    logger('notifier: dfrn_delivery returns ' . $deliver_status);
                    if ($deliver_status == -1) {
                        logger('notifier: delivery failed: queuing message');
                        // queue message for redelivery
                        add_to_queue($contact['id'], NETWORK_DFRN, $atom);
                    }
                    break;
                case NETWORK_OSTATUS:
                    // Do not send to otatus if we are not configured to send to public networks
                    if ($owner['prvnets']) {
                        break;
                    }
                    if (get_config('system', 'ostatus_disabled') || get_config('system', 'dfrn_only')) {
                        break;
                    }
                    if ($followup && $contact['notify']) {
开发者ID:ryivhnn,项目名称:friendica,代码行数:67,代码来源:notifier.php


示例10: delivery_run


//.........这里部分代码省略.........
                logger('notifier: dfrndelivery: ' . $contact['name']);
                $feed_template = get_markup_template('atom_feed.tpl');
                $mail_template = get_markup_template('atom_mail.tpl');
                $atom = '';
                $birthday = feed_birthday($owner['uid'], $owner['timezone']);
                if (strlen($birthday)) {
                    $birthday = '<dfrn:birthday>' . xmlify($birthday) . '</dfrn:birthday>';
                }
                $atom .= replace_macros($feed_template, array('$version' => xmlify(FRIENDICA_VERSION), '$feed_id' => xmlify($a->get_baseurl() . '/profile/' . $owner['nickname']), '$feed_title' => xmlify($owner['name']), '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00', ATOM_TIME)), '$hub' => $hubxml, '$salmon' => '', '$name' => xmlify($owner['name']), '$profile_page' => xmlify($owner['url']), '$photo' => xmlify($owner['photo']), '$thumb' => xmlify($owner['thumb']), '$picdate' => xmlify(datetime_convert('UTC', 'UTC', $owner['avatar-date'] . '+00:00', ATOM_TIME)), '$uridate' => xmlify(datetime_convert('UTC', 'UTC', $owner['uri-date'] . '+00:00', ATOM_TIME)), '$namdate' => xmlify(datetime_convert('UTC', 'UTC', $owner['name-date'] . '+00:00', ATOM_TIME)), '$birthday' => $birthday, '$community' => $owner['page-flags'] == PAGE_COMMUNITY ? '<dfrn:community>1</dfrn:community>' : ''));
                foreach ($items as $item) {
                    if (!$item['parent']) {
                        continue;
                    }
                    // private emails may be in included in public conversations. Filter them.
                    if ($public_message && $item['private'] == 1) {
                        continue;
                    }
                    $item_contact = get_item_contact($item, $icontacts);
                    if (!$item_contact) {
                        continue;
                    }
                    if ($normal_mode) {
                        if ($item_id == $item['id'] || $item['id'] == $item['parent']) {
                            $atom .= atom_entry($item, 'text', null, $owner, true, $top_level ? $contact['id'] : 0);
                        }
                    } else {
                        $atom .= atom_entry($item, 'text', null, $owner, true);
                    }
                }
                $atom .= '</feed>' . "\r\n";
                logger('notifier: ' . $atom, LOGGER_DATA);
                $basepath = implode('/', array_slice(explode('/', $contact['url']), 0, 3));
                // perform local delivery if we are on the same site
                if (link_compare($basepath, $a->get_baseurl())) {
                    $nickname = basename($contact['url']);
                    if ($contact['issued-id']) {
                        $sql_extra = sprintf(" AND `dfrn-id` = '%s' ", dbesc($contact['issued-id']));
                    } else {
                        $sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($contact['dfrn-id']));
                    }
                    $x = q("SELECT\t`contact`.*, `contact`.`uid` AS `importer_uid`,\n\t\t\t\t\t\t`contact`.`pubkey` AS `cpubkey`,\n\t\t\t\t\t\t`contact`.`prvkey` AS `cprvkey`,\n\t\t\t\t\t\t`contact`.`thumb` AS `thumb`,\n\t\t\t\t\t\t`contact`.`url` as `url`,\n\t\t\t\t\t\t`contact`.`name` as `senderName`,\n\t\t\t\t\t\t`user`.*\n\t\t\t\t\t\tFROM `contact`\n\t\t\t\t\t\tINNER JOIN `user` ON `contact`.`uid` = `user`.`uid`\n\t\t\t\t\t\tWHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t\t\t\tAND `contact`.`network` = '%s' AND `user`.`nickname` = '%s'\n\t\t\t\t\t\t{$sql_extra}\n\t\t\t\t\t\tAND `user`.`account_expired` = 0 AND `user`.`account_removed` = 0 LIMIT 1", dbesc(NETWORK_DFRN), dbesc($nickname));
                    if ($x && count($x)) {
                        $write_flag = $x[0]['rel'] && $x[0]['rel'] != CONTACT_IS_SHARING ? true : false;
                        if (($owner['page-flags'] == PAGE_COMMUNITY || $write_flag) && !$x[0]['writable']) {
                            q("update contact set writable = 1 where id = %d", intval($x[0]['id']));
                            $x[0]['writable'] = 1;
                        }
                        $ssl_policy = get_config('system', 'ssl_policy');
                        fix_contact_ssl_policy($x[0], $ssl_policy);
                        // If we are setup as a soapbox we aren't accepting input from this person
                        if ($x[0]['page-flags'] == PAGE_SOAPBOX) {
                            break;
                        }
                        require_once 'library/simplepie/simplepie.inc';
                        logger('mod-delivery: local delivery');
                        local_delivery($x[0], $atom);
                        break;
                    }
                }
                if (!was_recently_delayed($contact['id'])) {
                    $deliver_status = dfrn_deliver($owner, $contact, $atom);
                } else {
                    $deliver_status = -1;
                }
                logger('notifier: dfrn_delivery returns ' . $deliver_status);
                if ($deliver_status == -1) {
开发者ID:strk,项目名称:friendica,代码行数:67,代码来源:delivery.php


示例11: api_item_get_user

function api_item_get_user(&$a, $item)
{
    // The author is our direct contact, in a conversation with us.
    if (link_compare($item['url'], $item['author-link'])) {
        return api_get_user($a, $item['cid']);
    } else {
        // The author may be a contact of ours, but is replying to somebody else.
        // Figure out if we know him/her.
        $normalised = normalise_link(strlen($item['author-link']) ? $item['author-link'] : $item['url']);
        if ($normalised != 'mailbox' && x($a->contacts[$normalised])) {
            return api_get_user($a, $a->contacts[$normalised]['id']);
        }
    }
    // We don't know this person directly.
    list($nick, $name) = array_map("trim", explode("(", $item['author-name']));
    $name = str_replace(")", "", $name);
    $ret = array('uid' => 0, 'id' => 0, 'name' => $name, 'screen_name' => $nick, 'location' => '', 'profile_image_url' => $item['author-avatar'], 'url' => $item['author-link'], 'contact_url' => 0, 'protected' => false, 'friends_count' => 0, 'created_at' => '', 'utc_offset' => 0, 'time_zone' => '', 'geo_enabled' => false, 'statuses_count' => 0, 'lang' => 'en', 'description' => '', 'followers_count' => 0, 'favourites_count' => 0, 'contributors_enabled' => false, 'follow_request_sent' => false, 'profile_background_color' => 'cfe8f6', 'profile_text_color' => '000000', 'profile_link_color' => 'FF8500', 'profile_sidebar_fill_color' => 'AD0066', 'profile_sidebar_border_color' => 'AD0066', 'profile_background_image_url' => '', 'profile_background_tile' => false, 'profile_use_background_image' => false, 'notifications' => false, 'verified' => true, 'followers' => '', 'status' => array());
    return $ret;
}
开发者ID:nphyx,项目名称:friendica,代码行数:19,代码来源:api.php


示例12: fbpost_post_hook

/**
 * @param App $a
 * @param object $b
 * @return mixed
 */
function fbpost_post_hook(&$a, &$b)
{
    logger('fbpost_post_hook: Facebook post invoked', LOGGER_DEBUG);
    if ($b['deleted'] || $b['created'] !== $b['edited']) {
        return;
    }
    logger('fbpost_post_hook: Facebook post first check successful', LOGGER_DEBUG);
    // if post comes from facebook don't send it back
    if ($b['extid'] == NETWORK_FACEBOOK) {
        return;
    }
    if ($b['app'] == "Facebook" and $b['verb'] != ACTIVITY_LIKE) {
        return;
    }
    logger('fbpost_post_hook: Facebook post accepted', LOGGER_DEBUG);
    /**
     * Post to Facebook stream
     */
    require_once 'include/group.php';
    require_once 'include/html2plain.php';
    $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']));
        //$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
        //	dbesc($b['parent-uri']),
        //	intval($b['uid'])
        //);
        // is it a reply to a facebook post?
        // A reply to a toplevel post is only allowed for "real" facebook posts
        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::' and $r[0]['id'] != $r[0]['parent']) {
            $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('fbpost_post_hook: 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) {
                logger("fbpost_post_hook: private post to: " . $allow_str, LOGGER_DEBUG);
                $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;
            logger('fbpost_post_hook: liking ' . print_r($b, true), LOGGER_DEBUG);
//.........这里部分代码省略.........
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:101,代码来源:fbpost.php


示例13: diaspora_retraction

function diaspora_retraction($importer, $xml, $msg = null)
{
    $guid = notags(diaspora_get_target_guid($xml));
    $diaspora_handle = notags(diaspora_get_author($xml));
    $type = notags(diaspora_get_type($xml));
    $contact = diaspora_get_contac 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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