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


PHP import_profile_photo函数代码示例

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


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

示例1: crepair_post

function crepair_post(&$a)
{
    if (!local_user()) {
        return;
    }
    $cid = $a->argc > 1 ? intval($a->argv[1]) : 0;
    if ($cid) {
        $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval(local_user()));
    }
    if (!count($r)) {
        return;
    }
    $contact = $r[0];
    $nick = x($_POST, 'nick') ? $_POST['nick'] : '';
    $url = x($_POST, 'url') ? $_POST['url'] : '';
    $request = x($_POST, 'request') ? $_POST['request'] : '';
    $confirm = x($_POST, 'confirm') ? $_POST['confirm'] : '';
    $notify = x($_POST, 'notify') ? $_POST['notify'] : '';
    $poll = x($_POST, 'poll') ? $_POST['poll'] : '';
    $attag = x($_POST, 'attag') ? $_POST['attag'] : '';
    $photo = x($_POST, 'photo') ? $_POST['photo'] : '';
    $r = q("UPDATE `contact` SET `nick` = '%s', `url` = '%s', `request` = '%s', `confirm` = '%s', `notify` = '%s', `poll` = '%s', `attag` = '%s' \n\t\tWHERE `id` = %d AND `uid` = %d LIMIT 1", dbesc($nick), dbesc($url), dbesc($request), dbesc($confirm), dbesc($notify), dbesc($poll), dbesc($attag), intval($contact['id']), local_user());
    if ($photo) {
        logger('mod-crepair: updating photo from ' . $photo);
        require_once "Photo.php";
        $photos = import_profile_photo($photo, local_user(), $contact['id']);
        $x = q("UPDATE `contact` SET `photo` = '%s',\n\t\t\t`thumb` = '%s',\n\t\t\t`micro` = '%s',\n\t\t\t`name-date` = '%s',\n\t\t\t`uri-date` = '%s',\n\t\t\t`avatar-date` = '%s'\n\t\t\tWHERE `id` = %d LIMIT 1\n\t\t\t", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), intval($contact['id']));
    }
    if ($r) {
        info(t('Contact settings applied.') . EOL);
    } else {
        notice(t('Contact update failed.') . EOL);
    }
    return;
}
开发者ID:nphyx,项目名称:friendica,代码行数:35,代码来源:crepair.php

示例2: import_xchan


//.........这里部分代码省略.........
    } else {
        $import_photos = true;
        if (($arr['site']['directory_mode'] === 'standalone' || $dirmode & DIRECTORY_MODE_STANDALONE) && $arr['site']['url'] != z_root()) {
            $arr['searchable'] = false;
        }
        $hidden = 1 - intval($arr['searchable']);
        if ($hidden) {
            $new_flags = XCHAN_FLAGS_HIDDEN;
        } else {
            $new_flags = 0;
        }
        if ($arr['adult_content']) {
            $new_flags |= XCHAN_FLAGS_SELFCENSORED;
        }
        if (array_key_exists('deleted', $arr) && $arr['deleted']) {
            $new_flags |= XCHAN_FLAGS_DELETED;
        }
        $x = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_mimetype,\n\t\t\t\txchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_flags)\n\t\t\t\tvalues ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d) ", dbesc($xchan_hash), dbesc($arr['guid']), dbesc($arr['guid_sig']), dbesc($arr['key']), dbesc($arr['photo_mimetype']), dbesc($arr['photo']), dbesc($arr['address']), dbesc($arr['url']), dbesc($arr['connections_url']), dbesc($arr['follow_url']), dbesc($arr['connect_url']), dbesc($arr['name']), dbesc('zot'), dbesc($arr['photo_updated']), dbesc($arr['name_updated']), intval($new_flags));
        $what .= 'new_xchan';
        $changed = true;
    }
    if ($import_photos) {
        require_once 'include/photo/photo_driver.php';
        // see if this is a channel clone that's hosted locally - which we treat different from other xchans/connections
        $local = q("select channel_account_id, channel_id from channel where channel_hash = '%s' limit 1", dbesc($xchan_hash));
        if ($local) {
            $ph = z_fetch_url($arr['photo'], true);
            if ($ph['success']) {
                import_channel_photo($ph['body'], $arr['photo_mimetype'], $local[0]['channel_account_id'], $local[0]['channel_id']);
                // reset the names in case they got messed up when we had a bug in this function
                $photos = array(z_root() . '/photo/profile/l/' . $local[0]['channel_id'], z_root() . '/photo/profile/m/' . $local[0]['channel_id'], z_root() . '/photo/profile/s/' . $local[0]['channel_id'], $arr['photo_mimetype'], false);
            }
        } else {
            $photos = import_profile_photo($arr['photo'], $xchan_hash);
        }
        if ($photos) {
            if ($photos[4]) {
                // importing the photo failed somehow. Leave the photo_date alone so we can try again at a later date.
                // This often happens when somebody joins the matrix with a bad cert.
                $r = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s'\n\t\t\t\t\twhere xchan_hash = '%s' limit 1", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc($photos[3]), dbesc($xchan_hash));
            } else {
                $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s'\n\t\t\t\t\twhere xchan_hash = '%s' limit 1", dbesc(datetime_convert('UTC', 'UTC', $arr['photo_updated'])), dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc($photos[3]), dbesc($xchan_hash));
            }
            $what .= 'photo ';
            $changed = true;
        }
    }
    // what we are missing for true hub independence is for any changes in the primary hub to
    // get reflected not only in the hublocs, but also to update the URLs and addr in the appropriate xchan
    if ($arr['locations']) {
        $xisting = q("select hubloc_id, hubloc_url, hubloc_sitekey from hubloc where hubloc_hash = '%s'", dbesc($xchan_hash));
        // See if a primary is specified
        $has_primary = false;
        foreach ($arr['locations'] as $location) {
            if ($location['primary']) {
                $has_primary = true;
                break;
            }
        }
        foreach ($arr['locations'] as $location) {
            if (!rsa_verify($location['url'], base64url_decode($location['url_sig']), $arr['key'])) {
                logger('import_xchan: Unable to verify site signature for ' . $location['url']);
                $ret['message'] .= sprintf(t('Unable to verify site signature for %s'), $location['url']) . EOL;
                continue;
            }
            // Ensure that they have one primary hub
开发者ID:Mauru,项目名称:red,代码行数:67,代码来源:zot.php

示例3: import_author_unknown

function import_author_unknown($x)
{
    if (!$x['url']) {
        return false;
    }
    $r = q("select xchan_hash from xchan where xchan_network = 'unknown' and xchan_url = '%s' limit 1", dbesc($x['url']));
    if ($r) {
        logger('import_author_unknown: in cache', LOGGER_DEBUG);
        return $r[0]['xchan_hash'];
    }
    $name = trim($x['name']);
    $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_url, xchan_name, xchan_network )\n\t\tvalues ( '%s', '%s', '%s', '%s', '%s' )", dbesc($x['url']), dbesc($x['url']), dbesc($x['url']), dbesc($name ? $name : t('(Unknown)')), dbesc('unknown'));
    if ($r && $x['photo']) {
        $photos = import_profile_photo($x['photo']['src'], $x['url']);
        if ($photos) {
            /** @bug $arr is undefined in this SQL query */
            $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_url = '%s' and xchan_network = 'unknown'", dbesc(datetime_convert('UTC', 'UTC', $arr['photo_updated'])), dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc($photos[3]), dbesc($x['url']));
            if ($r) {
                return $x['url'];
            }
        }
    }
    return false;
}
开发者ID:einervonvielen,项目名称:redmatrix,代码行数:24,代码来源:items.php

示例4: app_update

function app_update($arr)
{
    $darray = array();
    $ret = array('success' => false);
    $darray['app_url'] = x($arr, 'url') ? $arr['url'] : '';
    $darray['app_channel'] = x($arr, 'uid') ? $arr['uid'] : 0;
    $darray['app_id'] = x($arr, 'guid') ? $arr['guid'] : 0;
    if (!$darray['app_url'] || !$darray['app_channel'] || !$darray['app_id']) {
        return $ret;
    }
    if ($arr['photo'] && !strstr($arr['photo'], z_root())) {
        $x = import_profile_photo($arr['photo'], get_observer_hash(), true);
        $arr['photo'] = $x[1];
    }
    $darray['app_sig'] = x($arr, 'sig') ? $arr['sig'] : '';
    $darray['app_author'] = x($arr, 'author') ? $arr['author'] : get_observer_hash();
    $darray['app_name'] = x($arr, 'name') ? escape_tags($arr['name']) : t('Unknown');
    $darray['app_desc'] = x($arr, 'desc') ? escape_tags($arr['desc']) : '';
    $darray['app_photo'] = x($arr, 'photo') ? $arr['photo'] : z_root() . '/' . get_default_profile_photo(80);
    $darray['app_version'] = x($arr, 'version') ? escape_tags($arr['version']) : '';
    $darray['app_addr'] = x($arr, 'addr') ? escape_tags($arr['addr']) : '';
    $darray['app_price'] = x($arr, 'price') ? escape_tags($arr['price']) : '';
    $darray['app_page'] = x($arr, 'page') ? escape_tags($arr['page']) : '';
    $darray['app_requires'] = x($arr, 'requires') ? escape_tags($arr['requires']) : '';
    $r = q("update app set app_sig = '%s', app_author = '%s', app_name = '%s', app_desc = '%s', app_url = '%s', app_photo = '%s', app_version = '%s', app_addr = '%s', app_price = '%s', app_page = '%s', app_requires = '%s' where app_id = '%s' and app_channel = %d limit 1", dbesc($darray['app_sig']), dbesc($darray['app_author']), dbesc($darray['app_name']), dbesc($darray['app_desc']), dbesc($darray['app_url']), dbesc($darray['app_photo']), dbesc($darray['app_version']), dbesc($darray['app_addr']), dbesc($darray['app_price']), dbesc($darray['app_page']), dbesc($darray['app_requires']), dbesc($darray['app_id']), intval($darray['app_channel']));
    if ($r) {
        $ret['success'] = true;
        $ret['app_id'] = $darray['app_id'];
    }
    return $ret;
}
开发者ID:Mauru,项目名称:red,代码行数:31,代码来源:apps.php

示例5: new_follower

function new_follower($importer, $contact, $datarray, $item, $sharing = false)
{
    $url = notags(trim($datarray['author-link']));
    $name = notags(trim($datarray['author-name']));
    $photo = notags(trim($datarray['author-avatar']));
    if (is_object($item)) {
        $rawtag = $item->get_item_tags(NAMESPACE_ACTIVITY, 'actor');
        if ($rawtag && $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data']) {
            $nick = $rawtag[0]['child'][NAMESPACE_POCO]['preferredUsername'][0]['data'];
        }
    } else {
        $nick = $item;
    }
    if (is_array($contact)) {
        if ($contact['network'] == NETWORK_OSTATUS && $contact['rel'] == CONTACT_IS_SHARING || $sharing && $contact['rel'] == CONTACT_IS_FOLLOWER) {
            $r = q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d", intval(CONTACT_IS_FRIEND), intval($contact['id']), intval($importer['uid']));
        }
        // send email notification to owner?
    } else {
        // create contact record
        $r = q("INSERT INTO `contact` (`uid`, `created`, `url`, `nurl`, `name`, `nick`, `photo`, `network`, `rel`,\n\t\t\t`blocked`, `readonly`, `pending`, `writable`)\n\t\t\tVALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, 0, 0, 1, 1)", intval($importer['uid']), dbesc(datetime_convert()), dbesc($url), dbesc(normalise_link($url)), dbesc($name), dbesc($nick), dbesc($photo), dbesc($sharing ? NETWORK_ZOT : NETWORK_OSTATUS), intval($sharing ? CONTACT_IS_SHARING : CONTACT_IS_FOLLOWER));
        $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `pending` = 1 LIMIT 1", intval($importer['uid']), dbesc($url));
        if (count($r)) {
            $contact_record = $r[0];
            $photos = import_profile_photo($photo, $importer["uid"], $contact_record["id"]);
            q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), intval($contact_record["id"]));
        }
        $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($importer['uid']));
        $a = get_app();
        if (count($r) and !in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) {
            // create notification
            $hash = random_string();
            if (is_array($contact_record)) {
                $ret = q("INSERT INTO `intro` ( `uid`, `contact-id`, `blocked`, `knowyou`, `hash`, `datetime`)\n\t\t\t\t\tVALUES ( %d, %d, 0, 0, '%s', '%s' )", intval($importer['uid']), intval($contact_record['id']), dbesc($hash), dbesc(datetime_convert()));
            }
            if (intval($r[0]['def_gid'])) {
                require_once 'include/group.php';
                group_add_member($r[0]['uid'], '', $contact_record['id'], $r[0]['def_gid']);
            }
            if ($r[0]['notify-flags'] & NOTIFY_INTRO && in_array($r[0]['page-flags'], array(PAGE_NORMAL))) {
                notification(array('type' => NOTIFY_INTRO, 'notify_flags' => $r[0]['notify-flags'], 'language' => $r[0]['language'], 'to_name' => $r[0]['username'], 'to_email' => $r[0]['email'], 'uid' => $r[0]['uid'], 'link' => $a->get_baseurl() . '/notifications/intro', 'source_name' => strlen(stripslashes($contact_record['name'])) ? stripslashes($contact_record['name']) : t('[Name Withheld]'), 'source_link' => $contact_record['url'], 'source_photo' => $contact_record['photo'], 'verb' => $sharing ? ACTIVITY_FRIEND : ACTIVITY_FOLLOW, 'otype' => 'intro'));
            }
        } elseif (count($r) and in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE))) {
            $r = q("UPDATE `contact` SET `pending` = 0 WHERE `uid` = %d AND `url` = '%s' AND `pending` LIMIT 1", intval($importer['uid']), dbesc($url));
        }
    }
}
开发者ID:EmilienB,项目名称:friendica,代码行数:47,代码来源:items.php

示例6: import_xchan


//.........这里部分代码省略.........
    } else {
        $import_photos = true;
        if (($arr['site']['directory_mode'] === 'standalone' || $dirmode & DIRECTORY_MODE_STANDALONE) && $arr['site']['url'] != z_root()) {
            $arr['searchable'] = false;
        }
        $hidden = 1 - intval($arr['searchable']);
        if ($hidden) {
            $new_flags = XCHAN_FLAGS_HIDDEN;
        } else {
            $new_flags = 0;
        }
        if ($arr['adult_content']) {
            $new_flags |= XCHAN_FLAGS_SELFCENSORED;
        }
        if (array_key_exists('deleted', $arr) && $arr['deleted']) {
            $new_flags |= XCHAN_FLAGS_DELETED;
        }
        $x = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_mimetype,\n\t\t\t\txchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_flags)\n\t\t\t\tvalues ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d) ", dbesc($xchan_hash), dbesc($arr['guid']), dbesc($arr['guid_sig']), dbesc($arr['key']), dbesc($arr['photo_mimetype']), dbesc($arr['photo']), dbesc($arr['address']), dbesc($arr['url']), dbesc($arr['connections_url']), dbesc($arr['follow_url']), dbesc($arr['connect_url']), dbesc($arr['name'] ? $arr['name'] : '-'), dbesc('zot'), dbescdate($arr['photo_updated']), dbescdate($arr['name_updated']), intval($new_flags));
        $what .= 'new_xchan';
        $changed = true;
    }
    if ($import_photos) {
        require_once 'include/photo/photo_driver.php';
        // see if this is a channel clone that's hosted locally - which we treat different from other xchans/connections
        $local = q("select channel_account_id, channel_id from channel where channel_hash = '%s' limit 1", dbesc($xchan_hash));
        if ($local) {
            $ph = z_fetch_url($arr['photo'], true);
            if ($ph['success']) {
                import_channel_photo($ph['body'], $arr['photo_mimetype'], $local[0]['channel_account_id'], $local[0]['channel_id']);
                // reset the names in case they got messed up when we had a bug in this function
                $photos = array(z_root() . '/photo/profile/l/' . $local[0]['channel_id'], z_root() . '/photo/profile/m/' . $local[0]['channel_id'], z_root() . '/photo/profile/s/' . $local[0]['channel_id'], $arr['photo_mimetype'], false);
            }
        } else {
            $photos = import_profile_photo($arr['photo'], $xchan_hash);
        }
        if ($photos) {
            if ($photos[4]) {
                // importing the photo failed somehow. Leave the photo_date alone so we can try again at a later date.
                // This often happens when somebody joins the matrix with a bad cert.
                $r = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s'\n\t\t\t\t\twhere xchan_hash = '%s'", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc($photos[3]), dbesc($xchan_hash));
            } else {
                $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s'\n\t\t\t\t\twhere xchan_hash = '%s'", dbescdate(datetime_convert('UTC', 'UTC', $arr['photo_updated'])), dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc($photos[3]), dbesc($xchan_hash));
            }
            $what .= 'photo ';
            $changed = true;
        }
    }
    // what we are missing for true hub independence is for any changes in the primary hub to
    // get reflected not only in the hublocs, but also to update the URLs and addr in the appropriate xchan
    $s = sync_locations($arr, $arr);
    if ($s) {
        if ($s['change_message']) {
            $what .= $s['change_message'];
        }
        if ($s['changed']) {
            $changed = $s['changed'];
        }
        if ($s['message']) {
            $ret['message'] .= $s['message'];
        }
    }
    // Which entries in the update table are we interested in updating?
    $address = $ud_arr && $ud_arr['ud_addr'] ? $ud_arr['ud_addr'] : $arr['address'];
    // Are we a directory server of some kind?
    $other_realm = false;
    $realm = get_directory_realm();
开发者ID:HaakonME,项目名称:redmatrix,代码行数:67,代码来源:zot.php

示例7: pumpio_get_contact

function pumpio_get_contact($uid, $contact)
{
    $r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1", dbesc(normalise_link($contact->url)));
    if (count($r) == 0) {
        q("INSERT INTO unique_contacts (url, name, nick, avatar) VALUES ('%s', '%s', '%s', '%s')", dbesc(normalise_link($contact->url)), dbesc($contact->displayName), dbesc($contact->preferredUsername), dbesc($contact->image->url));
    } else {
        q("UPDATE unique_contacts SET name = '%s', nick = '%s', avatar = '%s' WHERE url = '%s'", dbesc($contact->displayName), dbesc($contact->preferredUsername), dbesc($contact->image->url), dbesc(normalise_link($contact->url)));
    }
    if (DB_UPDATE_VERSION >= "1177") {
        q("UPDATE `unique_contacts` SET `location` = '%s', `about` = '%s' WHERE url = '%s'", dbesc($contact->location->displayName), dbesc($contact->summary), dbesc(normalise_link($contact->url)));
    }
    $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' LIMIT 1", intval($uid), dbesc($contact->url));
    if (!count($r)) {
        // create contact record
        q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,\n\t\t\t\t\t`name`, `nick`, `photo`, `network`, `rel`, `priority`,\n\t\t\t\t\t`writable`, `blocked`, `readonly`, `pending` )\n\t\t\t\tVALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ", intval($uid), dbesc(datetime_convert()), dbesc($contact->url), dbesc(normalise_link($contact->url)), dbesc(str_replace("acct:", "", $contact->id)), dbesc(''), dbesc($contact->id), dbesc('pump.io ' . $contact->id), dbesc($contact->displayName), dbesc($contact->preferredUsername), dbesc($contact->image->url), dbesc(NETWORK_PUMPIO), intval(CONTACT_IS_FRIEND), intval(1), intval(1));
        $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1", dbesc($contact->url), intval($uid));
        if (!count($r)) {
            return false;
        }
        $contact_id = $r[0]['id'];
        $g = q("select def_gid from user where uid = %d limit 1", intval($uid));
        if ($g && intval($g[0]['def_gid'])) {
            require_once 'include/group.php';
            group_add_member($uid, '', $contact_id, $g[0]['def_gid']);
        }
        require_once "Photo.php";
        $photos = import_profile_photo($contact->image->url, $uid, $contact_id);
        q("UPDATE `contact` SET `photo` = '%s',\n\t\t\t\t\t`thumb` = '%s',\n\t\t\t\t\t`micro` = '%s',\n\t\t\t\t\t`name-date` = '%s',\n\t\t\t\t\t`uri-date` = '%s',\n\t\t\t\t\t`avatar-date` = '%s'\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()), intval($contact_id));
        if (DB_UPDATE_VERSION >= "1177") {
            q("UPDATE `contact` SET `location` = '%s',\n\t\t\t\t\t\t`about` = '%s'\n\t\t\t\t\tWHERE `id` = %d", dbesc($contact->location->displayName), dbesc($contact->summary), intval($contact_id));
        }
    } else {
        // update profile photos once every two weeks as we have no notification of when they change.
        //$update_photo = (($r[0]['avatar-date'] < datetime_convert('','','now -14 days')) ? true : false);
        $update_photo = $r[0]['avatar-date'] < datetime_convert('', '', 'now -12 hours');
        // check that we have all the photos, this has been known to fail on occasion
        if (!$r[0]['photo'] || !$r[0]['thumb'] || !$r[0]['micro'] || $update_photo) {
            require_once "Photo.php";
            $photos = import_profile_photo($contact->image->url, $uid, $r[0]['id']);
            q("UPDATE `contact` SET `photo` = '%s',\n\t\t\t\t\t`thumb` = '%s',\n\t\t\t\t\t`micro` = '%s',\n\t\t\t\t\t`name-date` = '%s',\n\t\t\t\t\t`uri-date` = '%s',\n\t\t\t\t\t`avatar-date` = '%s',\n\t\t\t\t\t`name` = '%s',\n\t\t\t\t\t`nick` = '%s'\n\t\t\t\t\tWHERE `id` = %d\n\t\t\t\t", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc($contact->displayName), dbesc($contact->preferredUsername), intval($r[0]['id']));
            if (DB_UPDATE_VERSION >= "1177") {
                q("UPDATE `contact` SET `location` = '%s',\n\t\t\t\t\t\t\t`about` = '%s'\n\t\t\t\t\t\tWHERE `id` = %d", dbesc($contact->location->displayName), dbesc($contact->summary), intval($r[0]['id']));
            }
        }
    }
    return $r[0]["id"];
}
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:47,代码来源:pumpio.php

示例8: ostatus_fetchauthor

function ostatus_fetchauthor($xpath, $context, $importer, &$contact)
{
    $author = array();
    $author["author-link"] = $xpath->evaluate('atom:author/atom:uri/text()', $context)->item(0)->nodeValue;
    $author["author-name"] = $xpath->evaluate('atom:author/atom:name/text()', $context)->item(0)->nodeValue;
    // Preserve the value
    $authorlink = $author["author-link"];
    $alternate = $xpath->query("atom:author/atom:link[@rel='alternate']", $context)->item(0)->attributes;
    if (is_object($alternate)) {
        foreach ($alternate as $attributes) {
            if ($attributes->name == "href") {
                $author["author-link"] = $attributes->textContent;
            }
        }
    }
    $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` IN ('%s', '%s') AND `network` != '%s'", intval($importer["uid"]), dbesc(normalise_link($author["author-link"])), dbesc(normalise_link($authorlink)), dbesc(NETWORK_STATUSNET));
    if ($r) {
        $contact = $r[0];
        $author["contact-id"] = $r[0]["id"];
    } else {
        $author["contact-id"] = $contact["id"];
    }
    $avatarlist = array();
    $avatars = $xpath->query("atom:author/atom:link[@rel='avatar']", $context);
    foreach ($avatars as $avatar) {
        $href = "";
        $width = 0;
        foreach ($avatar->attributes as $attributes) {
            if ($attributes->name == "href") {
                $href = $attributes->textContent;
            }
            if ($attributes->name == "width") {
                $width = $attributes->textContent;
            }
        }
        if ($width > 0 and $href != "") {
            $avatarlist[$width] = $href;
        }
    }
    if (count($avatarlist) > 0) {
        krsort($avatarlist);
        $author["author-avatar"] = current($avatarlist);
    }
    $displayname = $xpath->evaluate('atom:author/poco:displayName/text()', $context)->item(0)->nodeValue;
    if ($displayname != "") {
        $author["author-name"] = $displayname;
    }
    $author["owner-name"] = $author["author-name"];
    $author["owner-link"] = $author["author-link"];
    $author["owner-avatar"] = $author["author-avatar"];
    if ($r) {
        // Update contact data
        $update_contact = $r[0]['name-date'] < datetime_convert('', '', 'now -12 hours');
        if ($update_contact) {
            logger("Update contact data for contact " . $contact["id"], LOGGER_DEBUG);
            $value = $xpath->evaluate('atom:author/poco:displayName/text()', $context)->item(0)->nodeValue;
            if ($value != "") {
                $contact["name"] = $value;
            }
            $value = $xpath->evaluate('atom:author/poco:preferredUsername/text()', $context)->item(0)->nodeValue;
            if ($value != "") {
                $contact["nick"] = $value;
            }
            $value = $xpath->evaluate('atom:author/poco:note/text()', $context)->item(0)->nodeValue;
            if ($value != "") {
                $contact["about"] = $value;
            }
            $value = $xpath->evaluate('atom:author/poco:address/poco:formatted/text()', $context)->item(0)->nodeValue;
            if ($value != "") {
                $contact["location"] = $value;
            }
            q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `about` = '%s', `location` = '%s', `name-date` = '%s' WHERE `id` = %d", dbesc($contact["name"]), dbesc($contact["nick"]), dbesc($contact["about"]), dbesc($contact["location"]), dbesc(datetime_convert()), intval($contact["id"]));
            poco_check($contact["url"], $contact["name"], $contact["network"], $author["author-avatar"], $contact["about"], $contact["location"], "", "", "", datetime_convert(), 2, $contact["id"], $contact["uid"]);
        }
        $update_photo = $r[0]['avatar-date'] < datetime_convert('', '', 'now -12 hours');
        if ($update_photo and isset($author["author-avatar"])) {
            logger("Update profile picture for contact " . $contact["id"], LOGGER_DEBUG);
            $photos = import_profile_photo($author["author-avatar"], $importer["uid"], $contact["id"]);
            q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' WHERE `id` = %d", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc(datetime_convert()), intval($contact["id"]));
        }
    }
    return $author;
}
开发者ID:rahmiyildiz,项目名称:friendica,代码行数:83,代码来源:ostatus.php

示例9: poller_run


//.........这里部分代码省略.........
        //update statistics in config
        require_once 'include/statistics_fns.php';
        update_channels_total_stat();
        update_channels_active_halfyear_stat();
        update_channels_active_monthly_stat();
        update_local_posts_stat();
        // expire any read notifications over a month old
        q("delete from notify where seen = 1 and date < %s - INTERVAL %s", db_utcnow(), db_quoteinterval('30 DAY'));
        // expire any expired accounts
        downgrade_accounts();
        // If this is a directory server, request a sync with an upstream
        // directory at least once a day, up to once every poll interval.
        // Pull remote changes and push local changes.
        // potential issue: how do we keep from creating an endless update loop?
        if ($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) {
            require_once 'include/dir_fns.php';
            sync_directories($dirmode);
        }
        set_config('system', 'last_expire_day', $d2);
        proc_run('php', 'include/expire.php');
        proc_run('php', 'include/cli_suggest.php');
        require_once 'include/hubloc.php';
        remove_obsolete_hublocs();
        /**
         * End Cron Daily
         */
    }
    // update any photos which didn't get imported properly
    // This should be rare
    $r = q("select xchan_photo_l, xchan_hash from xchan where xchan_photo_l != '' and xchan_photo_m = '' \n\t\tand xchan_photo_date < %s - INTERVAL %s", db_utcnow(), db_quoteinterval('1 DAY'));
    if ($r) {
        require_once 'include/photo/photo_driver.php';
        foreach ($r as $rr) {
            $photos = import_profile_photo($rr['xchan_photo_l'], $rr['xchan_hash']);
            $x = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s'\n\t\t\t\twhere xchan_hash = '%s'", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc($photos[3]), dbesc($rr['xchan_hash']));
        }
    }
    // pull in some public posts
    if (!get_config('system', 'disable_discover_tab')) {
        proc_run('php', 'include/externals.php');
    }
    $manual_id = 0;
    $generation = 0;
    $force = false;
    $restart = false;
    if ($argc > 1 && $argv[1] == 'force') {
        $force = true;
    }
    if ($argc > 1 && $argv[1] == 'restart') {
        $restart = true;
        $generation = intval($argv[2]);
        if (!$generation) {
            killme();
        }
    }
    if ($argc > 1 && intval($argv[1])) {
        $manual_id = intval($argv[1]);
        $force = true;
    }
    $sql_extra = $manual_id ? " AND abook_id = " . intval($manual_id) . " " : "";
    reload_plugins();
    $d = datetime_convert();
    // TODO check to see if there are any cronhooks before wasting a process
    if (!$restart) {
        proc_run('php', 'include/cronhooks.php');
    }
开发者ID:redmatrix,项目名称:red,代码行数:67,代码来源:poller.php

示例10: fb_get_friends_sync_parsecontact

/**
 * @param int $uid
 * @param object $contact
 */
function fb_get_friends_sync_parsecontact($uid, $contact)
{
    $contact->link = 'http://facebook.com/profile.php?id=' . $contact->id;
    // If its a page then set the first name from the username
    if (!$contact->first_name and $contact->username) {
        $contact->first_name = $contact->username;
    }
    // check if we already have a contact
    $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' LIMIT 1", intval($uid), dbesc($contact->link));
    if (count($r)) {
        // check that we have all the photos, this has been known to fail on occasion
        if (!$r[0]['photo'] || !$r[0]['thumb'] || !$r[0]['micro']) {
            require_once "Photo.php";
            $photos = import_profile_photo('https://graph.facebook.com/' . $contact->id . '/picture', $uid, $r[0]['id']);
            q("UPDATE `contact` SET `photo` = '%s',\n                                        `thumb` = '%s',\n                                        `micro` = '%s',\n                                        `name-date` = '%s',\n                                        `uri-date` = '%s',\n                                        `avatar-date` = '%s'\n                                        WHERE `id` = %d LIMIT 1\n                                ", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), intval($r[0]['id']));
        }
        return;
    } else {
        // create contact record
        q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`,\n                                `name`, `nick`, `photo`, `network`, `rel`, `priority`,\n                                `writable`, `blocked`, `readonly`, `pending` )\n                                VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, 0, 0, 0 ) ", intval($uid), dbesc(datetime_convert()), dbesc($contact->link), dbesc(normalise_link($contact->link)), dbesc(''), dbesc(''), dbesc($contact->id), dbesc('facebook ' . $contact->id), dbesc($contact->name), dbesc($contact->nickname ? $contact->nickname : strtolower($contact->first_name)), dbesc('https://graph.facebook.com/' . $contact->id . '/picture'), dbesc(NETWORK_FACEBOOK), intval(CONTACT_IS_FRIEND), intval(1), intval(1));
    }
    $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1", dbesc($contact->link), intval($uid));
    if (!count($r)) {
        return;
    }
    $contact_id = $r[0]['id'];
    $g = q("select def_gid from user where uid = %d limit 1", intval($uid));
    if ($g && intval($g[0]['def_gid'])) {
        require_once 'include/group.php';
        group_add_member($uid, '', $contact_id, $g[0]['def_gid']);
    }
    require_once "Photo.php";
    $photos = import_profile_photo($r[0]['photo'], $uid, $contact_id);
    q("UPDATE `contact` SET `photo` = '%s',\n                        `thumb` = '%s',\n                        `micro` = '%s',\n                        `name-date` = '%s',\n                        `uri-date` = '%s',\n                        `avatar-date` = '%s'\n                        WHERE `id` = %d LIMIT 1\n                ", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), intval($contact_id));
}
开发者ID:robhell,项目名称:friendica-addons,代码行数:39,代码来源:facebook.php

示例11: xchan_store

function xchan_store($arr)
{
    logger('xchan_store: ' . print_r($arr, true));
    if (!$arr['hash']) {
        $arr['hash'] = $arr['guid'];
    }
    if (!$arr['hash']) {
        return false;
    }
    $r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($arr['hash']));
    if ($r) {
        return true;
    }
    if (!$arr['network']) {
        $arr['network'] = 'unknown';
    }
    if (!$arr['name']) {
        $arr['name'] = 'unknown';
    }
    if (!$arr['url']) {
        $arr['url'] = z_root();
    }
    if (!$arr['photo']) {
        $arr['photo'] = z_root() . '/' . get_default_profile_photo();
    }
    $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_instance_url, xchan_flags, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s','%s','%s','%s',%d,'%s') ", dbesc($arr['hash']), dbesc($arr['guid']), dbesc($arr['guid_sig']), dbesc($arr['pubkey']), dbesc($arr['address']), dbesc($arr['url']), dbesc($arr['connurl']), dbesc($arr['follow']), dbesc($arr['connpage']), dbesc($arr['name']), dbesc($arr['network']), dbesc($arr['instance_url']), intval($arr['flags']), dbesc(datetime_convert()));
    if (!$r) {
        return $r;
    }
    $photos = import_profile_photo($arr['photo'], $arr['hash']);
    $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s'", dbesc(datetime_convert()), dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc($photos[3]), dbesc($arr['hash']));
    return $r;
}
开发者ID:redmatrix,项目名称:red,代码行数:33,代码来源:hubloc.php

示例12: follow_init

function follow_init(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        goaway($_SESSION['return_url']);
        // NOTREACHED
    }
    $url = $orig_url = notags(trim($_REQUEST['url']));
    // remove ajax junk, e.g. Twitter
    $url = str_replace('/#!/', '/', $url);
    if (!allowed_url($url)) {
        notice(t('Disallowed profile URL.') . EOL);
        goaway($_SESSION['return_url']);
        // NOTREACHED
    }
    if (!$url) {
        notice(t('Connect URL missing.') . EOL);
        goaway($_SESSION['return_url']);
        // NOTREACHED
    }
    $ret = probe_url($url);
    if ($ret['network'] === NETWORK_DFRN) {
        if (strlen($a->path)) {
            $myaddr = bin2hex($a->get_baseurl() . '/profile/' . $a->user['nickname']);
        } else {
            $myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
        }
        goaway($ret['request'] . "&addr={$myaddr}");
        // NOTREACHED
    } else {
        if (get_config('system', 'dfrn_only')) {
            notice(t('This site is not configured to allow communications with other networks.') . EOL);
            notice(t('No compatible communication protocols or feeds were discovered.') . EOL);
            goaway($_SESSION['return_url']);
        }
    }
    // do we have enough information?
    if (!(x($ret, 'name') && x($ret, 'poll') && (x($ret, 'url') || x($ret, 'addr')))) {
        notice(t('The profile address specified does not provide adequate information.') . EOL);
        if (!x($ret, 'poll')) {
            notice(t('No compatible communication protocols or feeds were discovered.') . EOL);
        }
        if (!x($ret, 'name')) {
            notice(t('An author or name was not found.') . EOL);
        }
        if (!x($ret, 'url')) {
            notice(t('No browser URL could be matched to this address.') . EOL);
        }
        if (strpos($url, '@') !== false) {
            notice('Unable to match @-style Identity Address with a known protocol or email contact');
        }
        goaway($_SESSION['return_url']);
    }
    if ($ret['network'] === NETWORK_OSTATUS && get_config('system', 'ostatus_disabled')) {
        notice(t('The profile address specified belongs to a network which has been disabled on this site.') . EOL);
        $ret['notify'] = '';
    }
    if (!$ret['notify']) {
        notice(t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . EOL);
    }
    $writeable = $ret['network'] === NETWORK_OSTATUS && $ret['notify'] ? 1 : 0;
    $hidden = $ret['network'] === NETWORK_MAIL ? 1 : 0;
    if ($ret['network'] === NETWORK_MAIL) {
        $writeable = 1;
    }
    if ($ret['network'] === NETWORK_DIASPORA) {
        $writeable = 1;
    }
    // check if we already have a contact
    // the poll url is more reliable than the profile url, as we may have
    // indirect links or webfinger links
    $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `poll` = '%s' LIMIT 1", intval(local_user()), dbesc($ret['poll']));
    if (count($r)) {
        // update contact
        if ($r[0]['rel'] == CONTACT_IS_FOLLOWER || $network === NETWORK_DIASPORA && $r[0]['rel'] == CONTACT_IS_SHARING) {
            q("UPDATE `contact` SET `rel` = %d , `readonly` = 0 WHERE `id` = %d AND `uid` = %d LIMIT 1", intval(CONTACT_IS_FRIEND), intval($r[0]['id']), intval(local_user()));
        }
    } else {
        $new_relation = $ret['network'] === NETWORK_MAIL ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING;
        if ($ret['network'] === NETWORK_DIASPORA) {
            $new_relation = CONTACT_IS_FOLLOWER;
        }
        // create contact record
        $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`,\n\t\t\t`writable`, `hidden`, `blocked`, `readonly`, `pending` )\n\t\t\tVALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, 0, 0, 0 ) ", intval(local_user()), dbesc(datetime_convert()), dbesc($ret['url']), dbesc(normalise_link($ret['url'])), dbesc($ret['addr']), dbesc($ret['alias']), dbesc($ret['batch']), dbesc($ret['notify']), dbesc($ret['poll']), dbesc($ret['poco']), dbesc($ret['name']), dbesc($ret['nick']), dbesc($ret['photo']), dbesc($ret['network']), dbesc($ret['pubkey']), intval($new_relation), intval($ret['priority']), intval($writeable), intval($hidden));
    }
    $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1", dbesc($ret['url']), intval(local_user()));
    if (!count($r)) {
        notice(t('Unable to retrieve contact information.') . EOL);
        goaway($_SESSION['return_url']);
        // NOTREACHED
    }
    $contact = $r[0];
    $contact_id = $r[0]['id'];
    require_once "Photo.php";
    $photos = import_profile_photo($ret['photo'], local_user(), $contact_id);
    $r = q("UPDATE `contact` SET `photo` = '%s', \n\t\t\t`thumb` = '%s',\n\t\t\t`micro` = '%s', \n\t\t\t`name-date` = '%s', \n\t\t\t`uri-date` = '%s', \n\t\t\t`avatar-date` = '%s'\n\t\t\tWHERE `id` = %d LIMIT 1\n\t\t", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), intval($contact_id));
    // pull feed and consume it, which should subscribe to the hub.
    proc_run('php', "include/poller.php", "{$contact_id}");
    // create a follow slap
    $tpl = get_markup_template('follow_slap.tpl');
//.........这里部分代码省略.........
开发者ID:nextgensh,项目名称:friendica,代码行数:101,代码来源:follow.php

示例13: poller_run


//.........这里部分代码省略.........
            prune_hub_reinstalls();
            require_once 'include/Contact.php';
            mark_orphan_hubsxchans();
            /**
             * End Cron Weekly
             */
        }
        update_birthdays();
        // expire any read notifications over a month old
        q("delete from notify where seen = 1 and date < UTC_TIMESTAMP() - INTERVAL 30 DAY");
        // expire any expired accounts
        downgrade_accounts();
        // If this is a directory server, request a sync with an upstream
        // directory at least once a day, up to once every poll interval.
        // Pull remote changes and push local changes.
        // potential issue: how do we keep from creating an endless update loop?
        if ($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) {
            require_once 'include/dir_fns.php';
            sync_directories($dirmode);
        }
        set_config('system', 'last_expire_day', $d2);
        proc_run('php', 'include/expire.php');
        proc_run('php', 'include/cli_suggest.php');
        /**
         * End Cron Daily
         */
    }
    // update any photos which didn't get imported properly
    // This should be rare
    $r = q("select xchan_photo_l, xchan_hash from xchan where xchan_photo_l != '' and xchan_photo_m = '' \n\t\tand xchan_photo_date < UTC_TIMESTAMP() - INTERVAL 1 DAY");
    if ($r) {
        require_once 'include/photo/photo_driver.php';
        foreach ($r as $rr) {
            $photos = import_profile_photo($rr['xchan_photo_l'], $rr['xchan_hash']);
            $x = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s'\n\t\t\t\twhere xchan_hash = '%s' limit 1", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc($photos[3]), dbesc($rr['xchan_hash']));
        }
    }
    // pull in some public posts
    if (!get_config('system', 'disable_discover_tab')) {
        proc_run('php', 'include/externals.php');
    }
    $manual_id = 0;
    $generation = 0;
    $force = false;
    $restart = false;
    if ($argc > 1 && $argv[1] == 'force') {
        $force = true;
    }
    if ($argc > 1 && $argv[1] == 'restart') {
        $restart = true;
        $generation = intval($argv[2]);
        if (!$generation) {
            killme();
        }
    }
    if ($argc > 1 && intval($argv[1])) {
        $manual_id = intval($argv[1]);
        $force = true;
    }
    $sql_extra = $manual_id ? " AND abook_id = {$manual_id} " : "";
    reload_plugins();
    $d = datetime_convert();
    //TODO check to see if there are any cronhooks before wasting a process
    if (!$restart) {
        proc_run('php', 'include/cronhooks.php');
    }
开发者ID:Mauru,项目名称:red,代码行数:67,代码来源:poller.php

示例14: _contact_update_profile

function _contact_update_profile($contact_id)
{
    $r = q("SELECT `url`, `network` FROM `contact` WHERE `id` = %d", intval($contact_id));
    if (!$r) {
        return;
    }
    $data = probe_url($r[0]["url"]);
    // "Feed" is mostly a sign of communication problems
    if ($data["network"] == NETWORK_FEED and $data["network"] != $r[0]["network"]) {
        return;
    }
    $updatefields = array("name", "nick", "url", "addr", "batch", "notify", "poll", "request", "confirm", "poco", "network", "alias", "pubkey");
    $update = array();
    foreach ($updatefields as $field) {
        if (isset($data[$field]) and $data[$field] != "") {
            $update[$field] = $data[$field];
        }
    }
    $update["nurl"] = normalise_link($data["url"]);
    $query = "";
    if (isset($data["priority"]) and $data["priority"] != 0) {
        $query = "`priority` = " . intval($data["priority"]);
    }
    foreach ($update as $key => $value) {
        if ($query != "") {
            $query .= ", ";
        }
        $query .= "`" . $key . "` = '" . dbesc($value) . "'";
    }
    if ($query == "") {
        return;
    }
    $r = q("UPDATE `contact` SET {$query} WHERE `id` = %d AND `uid` = %d", intval($contact_id), intval(local_user()));
    $photos = import_profile_photo($data['photo'], local_user(), $contact_id);
    $r = q("UPDATE `contact` SET `photo` = '%s',\n\t\t\t`thumb` = '%s',\n\t\t\t`micro` = '%s',\n\t\t\t`name-date` = '%s',\n\t\t\t`uri-date` = '%s',\n\t\t\t`avatar-date` = '%s'\n\t\t\tWHERE `id` = %d", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), intval($contact_id));
}
开发者ID:rahmiyildiz,项目名称:friendica,代码行数:36,代码来源:contacts.php

示例15: thing_init

function thing_init(&$a)
{
    if (!local_channel()) {
        return;
    }
    $account_id = $a->get_account();
    $channel = $a->get_channel();
    $term_hash = $_REQUEST['term_hash'] ? $_REQUEST['term_hash'] : '';
    $name = escape_tags($_REQUEST['term']);
    $verb = escape_tags($_REQUEST['verb']);
    $activity = intval($_REQUEST['activity']);
    $profile_guid = escape_tags($_REQUEST['profile_assign']);
    $url = $_REQUEST['link'];
    $photo = $_REQUEST['img'];
    $hash = random_string();
    $verbs = obj_verbs();
    /**
     * verbs: [0] = first person singular, e.g. "I want", [1] = 3rd person singular, e.g. "Bill wants" 
     * We use the first person form when creating an activity, but the third person for use in activities
     * @FIXME There is no accounting for verb gender for languages where this is significant. We may eventually
     * require obj_verbs() to provide full conjugations and specify which form to use in the $_REQUEST params to this module.
     */
    $translated_verb = $verbs[$verb][1];
    /*
     * The site administrator can do things that normals cannot.
     * This is restricted because it will likely cause
     * an activitystreams protocol violation and the activity might
     * choke in some other network and result in unnecessary 
     * support requests. It isn't because we're trying to be heavy-handed
     * about what you can and can't do. 
     */
    if (!$translated_verb) {
        if (is_site_admin()) {
            $translated_verb = $verb;
        }
    }
    /*
     * Things, objects: We do not provide definite (a, an) or indefinite (the) articles or singular/plural designators
     * That needs to be specified in your thing. e.g. Mike has "a carrot", Greg wants "balls", Bob likes "the Boston Red Sox".  
     */
    /*
     * Future work on this module might produce more complex activities with targets, e.g. Phillip likes Karen's moustache
     * and to describe other non-thing objects like channels, such as Karl wants Susan - where Susan represents a channel profile.
     */
    if (!$name || !$translated_verb) {
        return;
    }
    if ($term_hash) {
        $t = q("select * from obj left join term on obj_obj = term_hash where term_hash != '' and obj_type = %d and term_hash = '%s' limit 1", intval(TERM_OBJ_THING), dbesc($term_hash));
        if (!$t) {
            notice(t('Item not found.') . EOL);
            return;
        }
        $orig_record = $t[0];
        if ($photo != $orig_record['imgurl']) {
            $arr = import_profile_photo($photo, get_observer_hash(), true);
            $local_photo = $arr[0];
            $local_photo_type = $arr[3];
        } else {
            $local_photo = $orig_record['imgurl'];
        }
        $r = q("update term  set term = '%s', url = '%s', imgurl = '%s' where term_hash = '%s' and uid = %d", dbesc($name), dbesc($url ? $url : z_root() . '/thing/' . $term_hash), dbesc($local_photo), dbesc($term_hash), intval(local_channel()));
        info(t('Thing updated') . EOL);
        return;
    }
    $sql = $profile_guid ? " and profile_guid = '" . dbesc($profile_guid) . "' " : " and is_default = 1 ";
    $p = q("select profile_guid, is_default from profile where uid = %d {$sql} limit 1", intval(local_channel()));
    if ($p) {
        $profile = $p[0];
    } else {
        return;
    }
    $local_photo = null;
    if ($photo) {
        $arr = import_profile_photo($photo, get_observer_hash(), true);
        $local_photo = $arr[0];
        $local_photo_type = $arr[3];
    }
    $r = q("select * from term where uid = %d and otype = %d and type = %d and term = '%s' limit 1", intval(local_channel()), intval(TERM_OBJ_THING), intval(TERM_THING), dbesc($name));
    if (!$r) {
        $r = q("insert into term ( aid, uid, oid, otype, type, term, url, imgurl, term_hash )\n\t\t\tvalues( %d, %d, %d, %d, %d, '%s', '%s', '%s', '%s' ) ", intval($account_id), intval(local_channel()), 0, intval(TERM_OBJ_THING), intval(TERM_THING), dbesc($name), dbesc($url ? $url : z_root() . '/thing/' . $hash), dbesc($photo ? $local_photo : ''), dbesc($hash));
        $r = q("select * from term where uid = %d and otype = %d and type = %d and term = '%s' limit 1", intval(local_channel()), intval(TERM_OBJ_THING), intval(TERM_THING), dbesc($name));
    }
    $term = $r[0];
    $r = q("insert into obj ( obj_page, obj_verb, obj_type, obj_channel, obj_obj) values ('%s','%s', %d, %d, '%s') ", dbesc($profile['profile_guid']), dbesc($verb), intval(TERM_OBJ_THING), intval(local_channel()), dbesc($term['term_hash']));
    if (!$r) {
        notice(t('Object store: failed'));
        return;
    }
    info(t('Thing added'));
    if ($activity) {
        $arr = array();
        $links = array(array('rel' => 'alternate', 'type' => 'text/html', 'href' => $term['url']));
        if ($local_photo) {
            $links[] = array('rel' => 'photo', 'type' => $local_photo_type, 'href' => $local_photo);
        }
        $objtype = ACTIVITY_OBJ_THING;
        $obj = json_encode(array('type' => $objtype, 'id' => $term['url'], 'link' => $links, 'title' => $term['term'], 'content' => $term['term']));
        $bodyverb = str_replace('OBJ: ', '', t('OBJ: %1$s %2$s %3$s'));
        $arr['owner_xchan'] = $channel['channel_hash'];
//.........这里部分代码省略.........
开发者ID:redmatrix,项目名称:red,代码行数:101,代码来源:thing.php


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