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

PHP lrdd函数代码示例

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

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



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

示例1: webfinger_content

function webfinger_content(&$a)
{
    $o .= '<h3>Webfinger Diagnostic</h3>';
    $o .= '<form action="webfinger" method="get">';
    $o .= 'Lookup address: <input type="text" style="width: 250px;" name="addr" value="' . $_GET['addr'] . '" />';
    $o .= '<input type="submit" name="submit" value="Submit" /></form>';
    $o .= '<br /><br />';
    if (x($_GET, 'addr')) {
        $addr = trim($_GET['addr']);
        if (strpos($addr, '@') !== false) {
            $res = webfinger_rfc7033($addr, true);
            if (!$res) {
                $res = old_webfinger($addr);
            }
        } else {
            if (function_exists('lrdd')) {
                $res = lrdd($addr);
            }
        }
        $o .= '<pre>';
        $o .= str_replace("\n", '<br />', print_r($res, true));
        $o .= '</pre>';
    }
    return $o;
}
开发者ID:TamirAl,项目名称:hubzilla,代码行数:25,代码来源:webfinger.php


示例2: get_salmon_key

function get_salmon_key($uri, $keyhash)
{
    $ret = array();
    logger('Fetching salmon key for ' . $uri);
    $arr = lrdd($uri);
    if (is_array($arr)) {
        foreach ($arr as $a) {
            if ($a['@attributes']['rel'] === 'magic-public-key') {
                $ret[] = $a['@attributes']['href'];
            }
        }
    } else {
        return '';
    }
    // We have found at least one key URL
    // If it's inline, parse it - otherwise get the key
    if (count($ret)) {
        for ($x = 0; $x < count($ret); $x++) {
            if (substr($ret[$x], 0, 5) === 'data:') {
                if (strstr($ret[$x], ',')) {
                    $ret[$x] = substr($ret[$x], strpos($ret[$x], ',') + 1);
                } else {
                    $ret[$x] = substr($ret[$x], 5);
                }
            } else {
                $ret[$x] = fetch_url($ret[$x]);
            }
        }
    }
    logger('Key located: ' . print_r($ret, true));
    if (count($ret) == 1) {
        // We only found one one key so we don't care if the hash matches.
        // If it's the wrong key we'll find out soon enough because
        // message verification will fail. This also covers some older
        // software which don't supply a keyhash. As long as they only
        // have one key we'll be right.
        return $ret[0];
    } else {
        foreach ($ret as $a) {
            $hash = base64url_encode(hash('sha256', $a));
            if ($hash == $keyhash) {
                return $a;
            }
        }
    }
    return '';
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:47,代码来源:salmon.php


示例3: probe_url

function probe_url($url, $mode = PROBE_NORMAL)
{
    require_once 'include/email.php';
    $result = array();
    if (!$url) {
        return $result;
    }
    $network = null;
    $diaspora = false;
    $diaspora_base = '';
    $diaspora_guid = '';
    $diaspora_key = '';
    $has_lrdd = false;
    $email_conversant = false;
    $twitter = strpos($url, 'twitter.com') !== false ? true : false;
    $at_addr = strpos($url, '@') !== false ? true : false;
    if (!$twitter) {
        if (strpos($url, 'mailto:') !== false && $at_addr) {
            $url = str_replace('mailto:', '', $url);
            $links = array();
        } else {
            $links = lrdd($url);
        }
        if (count($links)) {
            $has_lrdd = true;
            logger('probe_url: found lrdd links: ' . print_r($links, true), LOGGER_DATA);
            foreach ($links as $link) {
                if ($link['@attributes']['rel'] === NAMESPACE_ZOT) {
                    $zot = unamp($link['@attributes']['href']);
                }
                if ($link['@attributes']['rel'] === NAMESPACE_DFRN) {
                    $dfrn = unamp($link['@attributes']['href']);
                }
                if ($link['@attributes']['rel'] === 'salmon') {
                    $notify = unamp($link['@attributes']['href']);
                }
                if ($link['@attributes']['rel'] === NAMESPACE_FEED) {
                    $poll = unamp($link['@attributes']['href']);
                }
                if ($link['@attributes']['rel'] === 'http://microformats.org/profile/hcard') {
                    $hcard = unamp($link['@attributes']['href']);
                }
                if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
                    $profile = unamp($link['@attributes']['href']);
                }
                if ($link['@attributes']['rel'] === 'http://portablecontacts.net/spec/1.0') {
                    $poco = unamp($link['@attributes']['href']);
                }
                if ($link['@attributes']['rel'] === 'http://joindiaspora.com/seed_location') {
                    $diaspora_base = unamp($link['@attributes']['href']);
                    $diaspora = true;
                }
                if ($link['@attributes']['rel'] === 'http://joindiaspora.com/guid') {
                    $diaspora_guid = unamp($link['@attributes']['href']);
                    $diaspora = true;
                }
                if ($link['@attributes']['rel'] === 'diaspora-public-key') {
                    $diaspora_key = base64_decode(unamp($link['@attributes']['href']));
                    $pubkey = rsatopem($diaspora_key);
                    $diaspora = true;
                }
            }
            // Status.Net can have more than one profile URL. We need to match the profile URL
            // to a contact on incoming messages to prevent spam, and we won't know which one
            // to match. So in case of two, one of them is stored as an alias. Only store URL's
            // and not webfinger user@host aliases. If they've got more than two non-email style
            // aliases, let's hope we're lucky and get one that matches the feed author-uri because
            // otherwise we're screwed.
            foreach ($links as $link) {
                if ($link['@attributes']['rel'] === 'alias') {
                    if (strpos($link['@attributes']['href'], '@') === false) {
                        if (isset($profile)) {
                            if ($link['@attributes']['href'] !== $profile) {
                                $alias = unamp($link['@attributes']['href']);
                            }
                        } else {
                            $profile = unamp($link['@attributes']['href']);
                        }
                    }
                }
            }
        } elseif ($mode == PROBE_NORMAL) {
            // Check email
            $orig_url = $url;
            if (strpos($orig_url, '@') && validate_email($orig_url)) {
                $x = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval(local_user()));
                $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval(local_user()));
                if (count($x) && count($r)) {
                    $mailbox = construct_mailbox_name($r[0]);
                    $password = '';
                    openssl_private_decrypt(hex2bin($r[0]['pass']), $password, $x[0]['prvkey']);
                    $mbox = email_connect($mailbox, $r[0]['user'], $password);
                    if (!$mbox) {
                        logger('probe_url: email_connect failed.');
                    }
                    unset($password);
                }
                if ($mbox) {
                    $msgs = email_poll($mbox, $orig_url);
                    logger('probe_url: searching ' . $orig_url . ', ' . count($msgs) . ' messages found.', LOGGER_DEBUG);
//.........这里部分代码省略.........
开发者ID:robhell,项目名称:friendica,代码行数:101,代码来源:Scrape.php


示例4: photos_post


//.........这里部分代码省略.........
            $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'];
        }
        if (strlen($rawtags)) {
            $str_tags = '';
            $inform = '';
            // if the new tag doesn't have a namespace specifier (@foo or #foo) give it a hashtag
            $x = substr($rawtags, 0, 1);
            if ($x !== '@' && $x !== '#') {
                $rawtags = '#' . $rawtags;
            }
            $taginfo = array();
            $tags = get_tags($rawtags);
            if (count($tags)) {
                foreach ($tags as $tag) {
                    if (isset($profile)) {
                        unset($profile);
                    }
                    if (strpos($tag, '@') === 0) {
                        $name = substr($tag, 1);
                        if (strpos($name, '@') || strpos($name, 'http://')) {
                            $newname = $name;
                            $links = @lrdd($name);
                            if (count($links)) {
                                foreach ($links as $link) {
                                    if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
                                        $profile = $link['@attributes']['href'];
                                    }
                                    if ($link['@attributes']['rel'] === 'salmon') {
                                        $salmon = '$url:' . str_replace(',', '%sc', $link['@attributes']['href']);
                                        if (strlen($inform)) {
                                            $inform .= ',';
                                        }
                                        $inform .= $salmon;
                                    }
                                }
                            }
                            $taginfo[] = array($newname, $profile, $salmon);
                        } else {
                            $newname = $name;
                            $alias = '';
                            $tagcid = 0;
                            if (strrpos($newname, '+')) {
                                $tagcid = intval(substr($newname, strrpos($newname, '+') + 1));
                            }
                            if ($tagcid) {
                                $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($tagcid), intval($profile_uid));
                            } elseif (strstr($name, '_') || strstr($name, ' ')) {
                                $newname = str_replace('_', ' ', $name);
                                $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1", dbesc($newname), intval($page_owner_uid));
                            } else {
                                $r = q("SELECT * FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1", dbesc($name), dbesc($name), intval($page_owner_uid));
                            }
                            if (count($r)) {
                                $newname = $r[0]['name'];
开发者ID:robhell,项目名称:friendica,代码行数:67,代码来源:photos.php


示例5: handle_tag

/**
 * This function removes the tag $tag from the text $body and replaces it with
 * the appropiate link.
 *
 * @param unknown_type $body the text to replace the tag in
 * @param unknown_type $inform a comma-seperated string containing everybody to inform
 * @param unknown_type $str_tags string to add the tag to
 * @param unknown_type $profile_uid
 * @param unknown_type $tag the tag to replace
 *
 * @return boolean true if replaced, false if not replaced
 */
function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $network = "")
{
    $replaced = false;
    $r = null;
    //is it a person tag?
    if (strpos($tag, '@') === 0) {
        //is it already replaced?
        if (strpos($tag, '[url=')) {
            return $replaced;
        }
        $stat = false;
        //get the person's name
        $name = substr($tag, 1);
        //is it a link or a full dfrn address?
        if (strpos($name, '@') || strpos($name, 'http://')) {
            $newname = $name;
            //get the profile links
            $links = @lrdd($name);
            if (count($links)) {
                //for all links, collect how is to inform and how's profile is to link
                foreach ($links as $link) {
                    if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
                        $profile = $link['@attributes']['href'];
                    }
                    if ($link['@attributes']['rel'] === 'salmon') {
                        if (strlen($inform)) {
                            $inform .= ',';
                        }
                        $inform .= 'url:' . str_replace(',', '%2c', $link['@attributes']['href']);
                    }
                }
            }
        } elseif ($network != NETWORK_OSTATUS and $network != NETWORK_TWITTER and $network != NETWORK_STATUSNET and $network != NETWORK_APPNET) {
            //if it is a name rather than an address
            $newname = $name;
            $alias = '';
            $tagcid = 0;
            //is it some generated name?
            if (strrpos($newname, '+')) {
                //get the id
                $tagcid = intval(substr($newname, strrpos($newname, '+') + 1));
                //remove the next word from tag's name
                if (strpos($name, ' ')) {
                    $name = substr($name, 0, strpos($name, ' '));
                }
            }
            if ($tagcid) {
                //if there was an id
                //select contact with that id from the logged in user's contact list
                $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($tagcid), intval($profile_uid));
            } else {
                $newname = str_replace('_', ' ', $name);
                // At first try to fetch a contact according to the given network
                if ($network != "") {
                    //select someone from this user's contacts by name
                    $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1", dbesc($newname), dbesc($network), intval($profile_uid));
                    if (!$r) {
                        //select someone by attag or nick and the name passed in
                        $r = q("SELECT * FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `network` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1", dbesc($name), dbesc($name), dbesc($network), intval($profile_uid));
                    }
                } else {
                    $r = false;
                }
                if (!$r) {
                    //select someone from this user's contacts by name
                    $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1", dbesc($newname), intval($profile_uid));
                }
                if (!$r) {
                    //select someone by attag or nick and the name passed in
                    $r = q("SELECT * FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1", dbesc($name), dbesc($name), intval($profile_uid));
                }
            }
            /*			} elseif(strstr($name,'_') || strstr($name,' ')) { //no id
            				//get the real name
            				$newname = str_replace('_',' ',$name);
            				//select someone from this user's contacts by name
            				$r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
            						dbesc($newname),
            						intval($profile_uid)
            				);
            			} else {
            				//select someone by attag or nick and the name passed in
            				$r = q("SELECT * FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
            						dbesc($name),
            						dbesc($name),
            						intval($profile_uid)
            				);
            			}*/
//.........这里部分代码省略.........
开发者ID:strk,项目名称:friendica,代码行数:101,代码来源:item.php


示例6: profiles_post

function profiles_post(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    $namechanged = false;
    call_hooks('profile_post', $_POST);
    if ($a->argc > 1 && $a->argv[1] !== "new" && intval($a->argv[1])) {
        $orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[1]), intval(local_user()));
        if (!count($orig)) {
            notice(t('Profile not found.') . EOL);
            return;
        }
        $is_default = $orig[0]['is-default'] ? 1 : 0;
        $profile_name = notags(trim($_POST['profile_name']));
        if (!strlen($profile_name)) {
            notify(t('Profile Name is required.') . EOL);
            return;
        }
        $year = intval($_POST['year']);
        if ($year < 1900 || $year > 2100 || $year < 0) {
            $year = 0;
        }
        $month = intval($_POST['month']);
        if ($month > 12 || $month < 0) {
            $month = 0;
        }
        $mtab = array(0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
        $day = intval($_POST['day']);
        if ($day > $mtab[$month] || $day < 0) {
            $day = 0;
        }
        $dob = '0000-00-00';
        $dob = sprintf('%04d-%02d-%02d', $year, $month, $day);
        $name = notags(trim($_POST['name']));
        if ($orig[0]['name'] != $name) {
            $namechanged = true;
        }
        $pdesc = notags(trim($_POST['pdesc']));
        $gender = notags(trim($_POST['gender']));
        $address = notags(trim($_POST['address']));
        $locality = notags(trim($_POST['locality']));
        $region = notags(trim($_POST['region']));
        $postal_code = notags(trim($_POST['postal_code']));
        $country_name = notags(trim($_POST['country_name']));
        $pub_keywords = notags(trim($_POST['pub_keywords']));
        $prv_keywords = notags(trim($_POST['prv_keywords']));
        $marital = notags(trim($_POST['marital']));
        if ($marital != $orig[0]['marital']) {
            $maritalchanged = true;
        }
        $with = x($_POST, 'with') ? notags(trim($_POST['with'])) : '';
        // linkify the relationship target if applicable
        if (strlen($with)) {
            if ($with != strip_tags($orig[0]['with'])) {
                $prf = '';
                $lookup = $with;
                if (strpos($lookup, '@') === 0) {
                    $lookup = substr($lookup, 1);
                }
                $lookup = str_replace('_', ' ', $lookup);
                if (strpos($lookup, '@') || strpos($lookup, 'http://')) {
                    $newname = $lookup;
                    $links = @lrdd($lookup);
                    if (count($links)) {
                        foreach ($links as $link) {
                            if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
                                $prf = $link['@attributes']['href'];
                            }
                        }
                    }
                } else {
                    $newname = $lookup;
                    if (strstr($lookup, ' ')) {
                        $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1", dbesc($newname), intval(local_user()));
                    } else {
                        $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1", dbesc($lookup), intval(local_user()));
                    }
                    if (count($r)) {
                        $prf = $r[0]['url'];
                        $newname = $r[0]['name'];
                    }
                }
                if ($prf) {
                    $with = str_replace($lookup, '<a href="' . $prf . '">' . $newname . '</a>', $with);
                    if (strpos($with, '@') === 0) {
                        $with = substr($with, 1);
                    }
                }
            } else {
                $with = $orig[0]['with'];
            }
        }
        $sexual = notags(trim($_POST['sexual']));
        $homepage = notags(trim($_POST['homepage']));
        $politic = notags(trim($_POST['politic']));
        $religion = notags(trim($_POST['religion']));
        $about = escape_tags(trim($_POST['about']));
        $interest = escape_tags(trim($_POST['interest']));
//.........这里部分代码省略.........
开发者ID:nextgensh,项目名称:friendica,代码行数:101,代码来源:profiles.php


示例7: profiles_post

function profiles_post(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    $namechanged = false;
    call_hooks('profile_post', $_POST);
    if ($a->argc > 1 && $a->argv[1] !== "new" && intval($a->argv[1])) {
        $orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[1]), intval(local_user()));
        if (!count($orig)) {
            notice(t('Profile not found.') . EOL);
            return;
        }
        check_form_security_token_redirectOnErr('/profiles', 'profile_edit');
        $is_default = $orig[0]['is-default'] ? 1 : 0;
        $profile_name = notags(trim($_POST['profile_name']));
        if (!strlen($profile_name)) {
            notice(t('Profile Name is required.') . EOL);
            return;
        }
        $dob = $_POST['dob'] ? escape_tags(trim($_POST['dob'])) : '0000-00-00';
        // FIXME: Needs to be validated?
        $y = substr($dob, 0, 4);
        if (!ctype_digit($y) || $y < 1900) {
            $ignore_year = true;
        } else {
            $ignore_year = false;
        }
        if ($dob != '0000-00-00') {
            if (strpos($dob, '0000-') === 0) {
                $ignore_year = true;
                $dob = substr($dob, 5);
            }
            $dob = datetime_convert('UTC', 'UTC', $ignore_year ? '1900-' . $dob : $dob, $ignore_year ? 'm-d' : 'Y-m-d');
            if ($ignore_year) {
                $dob = '0000-' . $dob;
            }
        }
        $name = notags(trim($_POST['name']));
        if (!strlen($name)) {
            $name = '[No Name]';
        }
        if ($orig[0]['name'] != $name) {
            $namechanged = true;
        }
        $pdesc = notags(trim($_POST['pdesc']));
        $gender = notags(trim($_POST['gender']));
        $address = notags(trim($_POST['address']));
        $locality = notags(trim($_POST['locality']));
        $region = notags(trim($_POST['region']));
        $postal_code = notags(trim($_POST['postal_code']));
        $country_name = notags(trim($_POST['country_name']));
        $pub_keywords = profile_clean_keywords(notags(trim($_POST['pub_keywords'])));
        $prv_keywords = profile_clean_keywords(notags(trim($_POST['prv_keywords'])));
        $marital = notags(trim($_POST['marital']));
        $howlong = notags(trim($_POST['howlong']));
        $with = x($_POST, 'with') ? notags(trim($_POST['with'])) : '';
        if (!strlen($howlong)) {
            $howlong = '0000-00-00 00:00:00';
        } else {
            $howlong = datetime_convert(date_default_timezone_get(), 'UTC', $howlong);
        }
        // linkify the relationship target if applicable
        $withchanged = false;
        if (strlen($with)) {
            if ($with != strip_tags($orig[0]['with'])) {
                $withchanged = true;
                $prf = '';
                $lookup = $with;
                if (strpos($lookup, '@') === 0) {
                    $lookup = substr($lookup, 1);
                }
                $lookup = str_replace('_', ' ', $lookup);
                if (strpos($lookup, '@') || strpos($lookup, 'http://')) {
                    $newname = $lookup;
                    $links = @lrdd($lookup);
                    if (count($links)) {
                        foreach ($links as $link) {
                            if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
                                $prf = $link['@attributes']['href'];
                            }
                        }
                    }
                } else {
                    $newname = $lookup;
                    /*					if(strstr($lookup,' ')) {
                    						$r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
                    							dbesc($newname),
                    							intval(local_user())
                    						);
                    					}
                    					else {
                    						$r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
                    							dbesc($lookup),
                    							intval(local_user())
                    						);
                    					}*/
                    $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1", dbesc($newname), intval(local_user()));
                    if (!$r) {
//.........这里部分代码省略.........
开发者ID:ZerGabriel,项目名称:friendica,代码行数:101,代码来源:profiles.php


示例8: dfrn_confirm_post


//.........这里部分代码省略.........
                $r = q("DELETE FROM `intro` WHERE `id` = %d AND `uid` = %d", intval($intro_id), intval($uid));
            }
            if ($status != 0) {
                return;
            }
        }
        /*
         *
         * We have now established a relationship with the other site.
         * Let's make our own personal copy of their profile photo so we don't have
         * to always load it from their site.
         *
         * We will also update the contact record with the nature and scope of the relationship.
         *
         */
        require_once 'include/Photo.php';
        $photos = import_profile_photo($contact['photo'], $uid, $contact_id);
        logger('dfrn_confirm: confirm - imported photos');
        if ($network === NETWORK_DFRN) {
            $new_relation = CONTACT_IS_FOLLOWER;
            if ($relation == CONTACT_IS_SHARING || $duplex) {
                $new_relation = CONTACT_IS_FRIEND;
            }
            if ($relation == CONTACT_IS_SHARING && $duplex) {
                $duplex = 0;
            }
            $r = q("UPDATE `contact` SET\n\t\t\t\t`photo` = '%s',\n\t\t\t\t`thumb` = '%s',\n\t\t\t\t`micro` = '%s',\n\t\t\t\t`rel` = %d,\n\t\t\t\t`name-date` = '%s',\n\t\t\t\t`uri-date` = '%s',\n\t\t\t\t`avatar-date` = '%s',\n\t\t\t\t`blocked` = 0,\n\t\t\t\t`pending` = 0,\n\t\t\t\t`duplex` = %d,\n\t\t\t\t`hidden` = %d,\n\t\t\t\t`network` = '%s' WHERE `id` = %d\n\t\t\t", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), intval($new_relation), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), intval($duplex), intval($hidden), dbesc(NETWORK_DFRN), intval($contact_id));
        } else {
            // $network !== NETWORK_DFRN
            $network = $contact['network'] ? $contact['network'] : NETWORK_OSTATUS;
            $notify = $contact['notify'] ? $contact['notify'] : '';
            $poll = $contact['poll'] ? $contact['poll'] : '';
            if (!$contact['notify'] || !$contact['poll']) {
                $arr = lrdd($contact['url']);
                if (count($arr)) {
                    foreach ($arr as $link) {
                        if ($link['@attributes']['rel'] === 'salmon') {
                            $notify = $link['@attributes']['href'];
                        }
                        if ($link['@attributes']['rel'] === NAMESPACE_FEED) {
                            $poll = $link['@attributes']['href'];
                        }
                    }
                }
            }
            $new_relation = $contact['rel'];
            $writable = $contact['writable'];
            if ($network === NETWORK_DIASPORA) {
                if ($duplex) {
                    $new_relation = CONTACT_IS_FRIEND;
                } else {
                    $new_relation = CONTACT_IS_FOLLOWER;
                }
                if ($new_relation != CONTACT_IS_FOLLOWER) {
                    $writable = 1;
                }
            }
            $r = q("DELETE FROM `intro` WHERE `id` = %d AND `uid` = %d", intval($intro_id), intval($uid));
            $r = q("UPDATE `contact` SET `photo` = '%s',\n\t\t\t\t`thumb` = '%s',\n\t\t\t\t`micro` = '%s',\n\t\t\t\t`name-date` = '%s',\n\t\t\t\t`uri-date` = '%s',\n\t\t\t\t`avatar-date` = '%s',\n\t\t\t\t`notify` = '%s',\n\t\t\t\t`poll` = '%s',\n\t\t\t\t`blocked` = 0,\n\t\t\t\t`pending` = 0,\n\t\t\t\t`network` = '%s',\n\t\t\t\t`writable` = %d,\n\t\t\t\t`hidden` = %d,\n\t\t\t\t`rel` = %d\n\t\t\t\tWHERE `id` = %d\n\t\t\t", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc($notify), dbesc($poll), dbesc($network), intval($writable), intval($hidden), intval($new_relation), intval($contact_id));
        }
        if ($r === false) {
            notice(t('Unable to set contact photo.') . EOL);
        }
        // reload contact info
        $r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", intval($contact_id));
        if (count($r)) {
开发者ID:vinzv,项目名称:friendica,代码行数:67,代码来源:dfrn_confirm.php


示例9: item_post


//.........这里部分代码省略.........
     */
    if ($parent_contact && $parent_contact['network'] === NETWORK_OSTATUS && $parent_contact['nick'] && !in_array('@' . $parent_contact['nick'], $tags)) {
        $body = '@' . $parent_contact['nick'] . ' ' . $body;
        $tags[] = '@' . $parent_contact['nick'];
    }
    if (count($tags)) {
        foreach ($tags as $tag) {
            if (isset($profile)) {
                unset($profile);
            }
            if (strpos($tag, '#') === 0) {
                if (strpos($tag, '[url=')) {
                    continue;
                }
                $basetag = str_replace('_', ' ', substr($tag, 1));
                $body = str_replace($tag, '#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]', $body);
                $newtag = '#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
                if (!stristr($str_tags, $newtag)) {
                    if (strlen($str_tags)) {
                        $str_tags .= ',';
                    }
                    $str_tags .= $newtag;
                }
                continue;
            }
            if (strpos($tag, '@') === 0) {
                if (strpos($tag, '[url=')) {
                    continue;
                }
                $stat = false;
                $name = substr($tag, 1);
                if (strpos($name, '@') || strpos($name, 'http://')) {
                    $newname = $name;
                    $links = @lrdd($name);
                    if (count($links)) {
                        foreach ($links as $link) {
                            if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
                                $profile = $link['@attributes']['href'];
                            }
                            if ($link['@attributes']['rel'] === 'salmon') {
                                if (strlen($inform)) {
                                    $inform .= ',';
                                }
                                $inform .= 'url:' . str_replace(',', '%2c', $link['@attributes']['href']);
                            }
                        }
                    }
                } else {
                    $newname = $name;
                    $alias = '';
                    $tagcid = 0;
                    if (strrpos($newname, '+')) {
                        $tagcid = intval(substr($newname, strrpos($newname, '+') + 1));
                        if (strpos($name, ' ')) {
                            $name = substr($name, 0, strpos($name, ' '));
                        }
                    }
                    if ($tagcid) {
                        $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($tagcid), intval($profile_uid));
                    } elseif (strstr($name, '_') || strstr($name, ' ')) {
                        $newname = str_replace('_', ' ', $name);
                        $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1", dbesc($newname), intval($profile_uid));
                    } else {
                        $r = q("SELECT * FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1", dbesc($name), dbesc($name), intval($profile_uid));
                    }
                    if (count($r)) {
开发者ID:nphyx,项目名称:friendica,代码行数:67,代码来源:item.php


示例10: probe_url

function probe_url($url, $mode = PROBE_NORMAL, $level = 1)
{
    require_once 'include/email.php';
    $result = array();
    if (!$url) {
        return $result;
    }
    $result = Cache::get("probe_url:" . $mode . ":" . $url);
    if (!is_null($result)) {
        $result = unserialize($result);
        return $result;
    }
    $network = null;
    $diaspora = false;
    $diaspora_base = '';
    $diaspora_guid = '';
    $diaspora_key = '';
    $has_lrdd = false;
    $email_conversant = false;
    $connectornetworks = false;
    $appnet = false;
    if (strpos($url, 'twitter.com')) {
        $connectornetworks = true;
        $network = NETWORK_TWITTER;
    }
    // Twitter is deactivated since twitter closed its old API
    //$twitter = ((strpos($url,'twitter.com') !== false) ? true : false);
    $lastfm = strpos($url, 'last.fm/user') !== false ? true : false;
    $at_addr = strpos($url, '@') !== false ? true : false;
    if (!$appnet && !$lastfm && !$connectornetworks) {
        if (strpos($url, 'mailto:') !== false && $at_addr) {
            $url = str_replace('mailto:', '', $url);
            $links = array();
        } else {
            $links = lrdd($url);
        }
        if (count($links)) {
            $has_lrdd = true;
            logger('probe_url: found lrdd links: ' . print_r($links, true), LOGGER_DATA);
            foreach ($links as $link) {
                if ($link['@attributes']['rel'] === NAMESPACE_ZOT) {
                    $zot = unamp($link['@attributes']['href']);
                }
                if ($link['@attributes']['rel'] === NAMESPACE_DFRN) {
                    $dfrn = unamp($link['@attributes']['href']);
                }
                if ($link['@attributes']['rel'] === 'salmon') {
                    $notify = unamp($link['@attributes']['href']);
                }
                if ($link['@attributes']['rel'] === NAMESPACE_FEED) {
                    $poll = unamp($link['@attributes']['href']);
                }
                if ($link['@attributes']['rel'] === 'http://microformats.org/profile/hcard') {
                    $hcard = unamp($link['@attributes']['href']);
                }
                if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
                    $profile = unamp($link['@attributes']['href']);
                }
                if ($link['@attributes']['rel'] === 'http://portablecontacts.net/spec/1.0') {
                    $poco = unamp($link['@attributes']['href']);
                }
                if ($link['@attributes']['rel'] === 'http://joindiaspora.com/seed_location') {
                    $diaspora_base = unamp($link['@attributes']['href']);
                    $diaspora = true;
                }
                if ($link['@attributes']['rel'] === 'http://joindiaspora.com/guid') {
                    $diaspora_guid = unamp($link['@attributes']['href']);
                    $diaspora = true;
                }
                if ($link['@attributes']['rel'] === 'diaspora-public-key') {
                    $diaspora_key = base64_decode(unamp($link['@attributes']['href']));
                    if (strstr($diaspora_key, 'RSA ')) {
                        $pubkey = rsatopem($diaspora_key);
                    } else {
                        $pubkey = $diaspora_key;
                    }
                    $diaspora = true;
                }
                if ($link['@attributes']['rel'] === 'http://ostatus.org/schema/1.0/subscribe' and $mode == PROBE_NORMAL) {
                    $diaspora = false;
                }
            }
            // Status.Net can have more than one profile URL. We need to match the profile URL
            // to a contact on incoming messages to prevent spam, and we won't know which one
            // to match. So in case of two, one of them is stored as an alias. Only store URL's
            // and not webfinger user@host aliases. If they've got more than two non-email style
            // aliases, let's hope we're lucky and get one that matches the feed author-uri because
            // otherwise we're screwed.
            foreach ($links as $link) {
                if ($link['@attributes']['rel'] === 'alias') {
                    if (strpos($link['@attributes']['href'], '@') === false) {
                        if (isset($profile)) {
                            if ($link['@attributes']['href'] !== $profile) {
                                $alias = unamp($link['@attributes']['href']);
                            }
                        } else {
                            $profile = unamp($link['@attributes']['href']);
                        }
                    }
                }
//.........这里部分代码省略.........
开发者ID:vinzv,项目名称:friendica,代码行数:101,代码来源:Scrape.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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