本文整理汇总了PHP中get_item_elements函数的典型用法代码示例。如果您正苦于以下问题:PHP get_item_elements函数的具体用法?PHP get_item_elements怎么用?PHP get_item_elements使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_item_elements函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: run
public static function run($argc, $argv)
{
logger('onepoll: start');
if ($argc > 1 && intval($argv[1])) {
$contact_id = intval($argv[1]);
}
if (!$contact_id) {
logger('onepoll: no contact');
return;
}
$d = datetime_convert();
$contacts = q("SELECT abook.*, xchan.*, account.*\n\t\t\tFROM abook LEFT JOIN account on abook_account = account_id left join xchan on xchan_hash = abook_xchan \n\t\t\twhere abook_id = %d\n\t\t\tand abook_pending = 0 and abook_archived = 0 and abook_blocked = 0 and abook_ignored = 0\n\t\t\tAND (( account_flags = %d ) OR ( account_flags = %d )) limit 1", intval($contact_id), intval(ACCOUNT_OK), intval(ACCOUNT_UNVERIFIED));
if (!$contacts) {
logger('onepoll: abook_id not found: ' . $contact_id);
return;
}
$contact = $contacts[0];
$t = $contact['abook_updated'];
$importer_uid = $contact['abook_channel'];
$r = q("SELECT * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d limit 1", intval($importer_uid));
if (!$r) {
return;
}
$importer = $r[0];
logger("onepoll: poll: ({$contact['id']}) IMPORTER: {$importer['xchan_name']}, CONTACT: {$contact['xchan_name']}");
$last_update = $contact['abook_updated'] === $contact['abook_created'] || $contact['abook_updated'] <= NULL_DATE ? datetime_convert('UTC', 'UTC', 'now - 7 days') : datetime_convert('UTC', 'UTC', $contact['abook_updated'] . ' - 2 days');
if ($contact['xchan_network'] === 'rss') {
logger('onepoll: processing feed ' . $contact['xchan_name'], LOGGER_DEBUG);
handle_feed($importer['channel_id'], $contact_id, $contact['xchan_hash']);
q("update abook set abook_connected = '%s' where abook_id = %d", dbesc(datetime_convert()), intval($contact['abook_id']));
return;
}
if ($contact['xchan_network'] !== 'zot') {
return;
}
// update permissions
$x = zot_refresh($contact, $importer);
$responded = false;
$updated = datetime_convert();
$connected = datetime_convert();
if (!$x) {
// mark for death by not updating abook_connected, this is caught in include/poller.php
q("update abook set abook_updated = '%s' where abook_id = %d", dbesc($updated), intval($contact['abook_id']));
} else {
q("update abook set abook_updated = '%s', abook_connected = '%s' where abook_id = %d", dbesc($updated), dbesc($connected), intval($contact['abook_id']));
$responded = true;
}
if (!$responded) {
return;
}
if ($contact['xchan_connurl']) {
$fetch_feed = true;
$x = null;
// They haven't given us permission to see their stream
$can_view_stream = intval(get_abconfig($importer_uid, $contact['abook_xchan'], 'their_perms', 'view_stream'));
if (!$can_view_stream) {
$fetch_feed = false;
}
// we haven't given them permission to send us their stream
$can_send_stream = intval(get_abconfig($importer_uid, $contact['abook_xchan'], 'my_perms', 'send_stream'));
if (!$can_send_stream) {
$fetch_feed = false;
}
if ($fetch_feed) {
$feedurl = str_replace('/poco/', '/zotfeed/', $contact['xchan_connurl']);
$feedurl .= '?f=&mindate=' . urlencode($last_update);
$x = z_fetch_url($feedurl);
logger('feed_update: ' . print_r($x, true), LOGGER_DATA);
}
if ($x && $x['success']) {
$total = 0;
logger('onepoll: feed update ' . $contact['xchan_name'] . ' ' . $feedurl);
$j = json_decode($x['body'], true);
if ($j['success'] && $j['messages']) {
foreach ($j['messages'] as $message) {
$results = process_delivery(array('hash' => $contact['xchan_hash']), get_item_elements($message), array(array('hash' => $importer['xchan_hash'])), false);
logger('onepoll: feed_update: process_delivery: ' . print_r($results, true), LOGGER_DATA);
$total++;
}
logger("onepoll: {$total} messages processed");
}
}
}
// update the poco details for this connection
if ($contact['xchan_connurl']) {
$r = q("SELECT xlink_id from xlink \n\t\t\t\twhere xlink_xchan = '%s' and xlink_updated > %s - INTERVAL %s and xlink_static = 0 limit 1", intval($contact['xchan_hash']), db_utcnow(), db_quoteinterval('1 DAY'));
if (!$r) {
poco_load($contact['xchan_hash'], $contact['xchan_connurl']);
}
}
return;
}
开发者ID:phellmes,项目名称:hubzilla,代码行数:92,代码来源:Onepoll.php
示例2: zot_import
//.........这里部分代码省略.........
}
if (!$r) {
logger('recips: no recipients on this site');
continue;
}
// It's a specifically targetted post. If we were sent a public_scope hint (likely),
// get rid of it so that it doesn't get stored and cause trouble.
if ($i && is_array($i) && array_key_exists('message', $i) && is_array($i['message']) && $i['message']['type'] === 'activity' && array_key_exists('public_scope', $i['message'])) {
unset($i['message']['public_scope']);
}
$deliveries = $r;
// We found somebody on this site that's in the recipient list.
} else {
if ($i['message'] && array_key_exists('flags', $i['message']) && in_array('private', $i['message']['flags']) && $i['message']['type'] === 'activity') {
if (array_key_exists('public_scope', $i['message']) && $i['message']['public_scope'] === 'public') {
// This should not happen but until we can stop it...
logger('private message was delivered with no recipients.');
continue;
}
}
logger('public post');
// Public post. look for any site members who are or may be accepting posts from this sender
// and who are allowed to see them based on the sender's permissions
$deliveries = allowed_public_recips($i);
if ($i['message'] && array_key_exists('type', $i['message']) && $i['message']['type'] === 'location') {
$sys = get_sys_channel();
$deliveries = array(array('hash' => $sys['xchan_hash']));
}
// if the scope is anything but 'public' we're going to store it as private regardless
// of the private flag on the post.
if ($i['message'] && array_key_exists('public_scope', $i['message']) && $i['message']['public_scope'] !== 'public') {
if (!array_key_exists('flags', $i['message'])) {
$i['message']['flags'] = array();
}
if (!in_array('private', $i['message']['flags'])) {
$i['message']['flags'][] = 'private';
}
}
}
// Go through the hash array and remove duplicates. array_unique() won't do this because the array is more than one level.
$no_dups = array();
if ($deliveries) {
foreach ($deliveries as $d) {
if (!in_array($d['hash'], $no_dups)) {
$no_dups[] = $d['hash'];
}
}
if ($no_dups) {
$deliveries = array();
foreach ($no_dups as $n) {
$deliveries[] = array('hash' => $n);
}
}
}
if (!$deliveries) {
logger('zot_import: no deliveries on this site');
continue;
}
if ($i['message']) {
if ($i['message']['type'] === 'activity') {
$arr = get_item_elements($i['message']);
$v = validate_item_elements($i['message'], $arr);
if (!$v['success']) {
logger('Activity rejected: ' . $v['message'] . ' ' . print_r($i['message'], true));
continue;
}
logger('Activity received: ' . print_r($arr, true), LOGGER_DATA);
logger('Activity recipients: ' . print_r($deliveries, true), LOGGER_DATA);
$relay = array_key_exists('flags', $i['message']) && in_array('relay', $i['message']['flags']) ? true : false;
$result = process_delivery($i['notify']['sender'], $arr, $deliveries, $relay, false, $message_request);
} elseif ($i['message']['type'] === 'mail') {
$arr = get_mail_elements($i['message']);
logger('Mail received: ' . print_r($arr, true), LOGGER_DATA);
logger('Mail recipients: ' . print_r($deliveries, true), LOGGER_DATA);
$result = process_mail_delivery($i['notify']['sender'], $arr, $deliveries);
} elseif ($i['message']['type'] === 'profile') {
$arr = get_profile_elements($i['message']);
logger('Profile received: ' . print_r($arr, true), LOGGER_DATA);
logger('Profile recipients: ' . print_r($deliveries, true), LOGGER_DATA);
$result = process_profile_delivery($i['notify']['sender'], $arr, $deliveries);
} elseif ($i['message']['type'] === 'channel_sync') {
// $arr = get_channelsync_elements($i['message']);
$arr = $i['message'];
logger('Channel sync received: ' . print_r($arr, true), LOGGER_DATA);
logger('Channel sync recipients: ' . print_r($deliveries, true), LOGGER_DATA);
$result = process_channel_sync_delivery($i['notify']['sender'], $arr, $deliveries);
} elseif ($i['message']['type'] === 'location') {
$arr = $i['message'];
logger('Location message received: ' . print_r($arr, true), LOGGER_DATA);
logger('Location message recipients: ' . print_r($deliveries, true), LOGGER_DATA);
$result = process_location_delivery($i['notify']['sender'], $arr, $deliveries);
}
}
if ($result) {
$return = array_merge($return, $result);
}
}
}
return $return;
}
开发者ID:23n,项目名称:hubzilla,代码行数:101,代码来源:zot.php
示例3: import_items
function import_items($channel, $items, $sync = false, $relocate = null)
{
if ($channel && $items) {
$allow_code = false;
$r = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id \n\t\t\twhere channel_id = %d limit 1", intval($channel['channel_id']));
if ($r) {
if ($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE || $r[0]['channel_pageflags'] & PAGE_ALLOWCODE) {
$allow_code = true;
}
}
$deliver = false;
// Don't deliver any messages or notifications when importing
foreach ($items as $i) {
$item_result = false;
$item = get_item_elements($i, $allow_code);
if (!$item) {
continue;
}
if ($relocate && $item['mid'] === $item['parent_mid']) {
item_url_replace($channel, $item, $relocate['url'], z_root(), $relocate['channel_address']);
}
$r = q("select id, edited from item where mid = '%s' and uid = %d limit 1", dbesc($item['mid']), intval($channel['channel_id']));
if ($r) {
// flags may have changed and we are probably relocating the post,
// so force an update even if we have the same timestamp
if ($item['edited'] >= $r[0]['edited']) {
$item['id'] = $r[0]['id'];
$item['uid'] = $channel['channel_id'];
$item_result = item_store_update($item, $allow_code, $deliver);
}
} else {
$item['aid'] = $channel['channel_account_id'];
$item['uid'] = $channel['channel_id'];
$item_result = item_store($item, $allow_code, $deliver);
}
if ($sync && $item['item_wall']) {
// deliver singletons if we have any
if ($item_result && $item_result['success']) {
Zotlabs\Daemon\Master::Summon(['Notifier', 'single_activity', $item_result['item_id']]);
}
}
}
}
}
开发者ID:einervonvielen,项目名称:hubzilla,代码行数:44,代码来源:import.php
示例4: import_items
function import_items($channel, $items)
{
if ($channel && $items) {
$allow_code = false;
$r = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id \n\t\t\twhere channel_id = %d limit 1", intval($channel['channel_id']));
if ($r) {
if ($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE || $r[0]['channel_pageflags'] & PAGE_ALLOWCODE) {
$allow_code = true;
}
}
foreach ($items as $i) {
$item = get_item_elements($i, $allow_code);
if (!$item) {
continue;
}
$r = q("select id, edited from item where mid = '%s' and uid = %d limit 1", dbesc($item['mid']), intval($channel['channel_id']));
if ($r) {
if ($item['edited'] > $r[0]['edited']) {
$item['id'] = $r[0]['id'];
$item['uid'] = $channel['channel_id'];
item_store_update($item);
continue;
}
} else {
$item['aid'] = $channel['channel_account_id'];
$item['uid'] = $channel['channel_id'];
$item_result = item_store($item);
}
}
}
}
开发者ID:HaakonME,项目名称:redmatrix,代码行数:31,代码来源:zot.php
示例5: externals_run
function externals_run($argv, $argc)
{
cli_startup();
$a = get_app();
$total = 0;
$attempts = 0;
logger('externals: startup', LOGGER_DEBUG);
// pull in some public posts
while ($total == 0 && $attempts < 3) {
$arr = array('url' => '');
call_hooks('externals_url_select', $arr);
if ($arr['url']) {
$url = $arr['url'];
} else {
$randfunc = db_getfunc('RAND');
// fixme this query does not deal with directory realms.
$r = q("select site_url, site_pull from site where site_url != '%s' and site_flags != %d and site_type = %d and site_dead = 0 order by {$randfunc} limit 1", dbesc(z_root()), intval(DIRECTORY_MODE_STANDALONE), intval(SITE_TYPE_ZOT));
if ($r) {
$url = $r[0]['site_url'];
}
}
$blacklisted = false;
if (!check_siteallowed($url)) {
logger('blacklisted site: ' . $url);
$blacklisted = true;
}
$attempts++;
// make sure we can eventually break out if somebody blacklists all known sites
if ($blacklisted) {
if ($attempts > 20) {
break;
}
$attempts--;
continue;
}
if ($url) {
if ($r[0]['site_pull'] !== NULL_DATE) {
$mindate = urlencode(datetime_convert('', '', $r[0]['site_pull'] . ' - 1 day'));
} else {
$days = get_config('externals', 'since_days');
if ($days === false) {
$days = 15;
}
$mindate = urlencode(datetime_convert('', '', 'now - ' . intval($days) . ' days'));
}
$feedurl = $url . '/zotfeed?f=&mindate=' . $mindate;
logger('externals: pulling public content from ' . $feedurl, LOGGER_DEBUG);
$x = z_fetch_url($feedurl);
if ($x && $x['success']) {
q("update site set site_pull = '%s' where site_url = '%s'", dbesc(datetime_convert()), dbesc($url));
$j = json_decode($x['body'], true);
if ($j['success'] && $j['messages']) {
$sys = get_sys_channel();
foreach ($j['messages'] as $message) {
// on these posts, clear any route info.
$message['route'] = '';
$results = process_delivery(array('hash' => 'undefined'), get_item_elements($message), array(array('hash' => $sys['xchan_hash'])), false, true);
$total++;
}
logger('externals: import_public_posts: ' . $total . ' messages imported', LOGGER_DEBUG);
}
}
}
}
}
开发者ID:msooon,项目名称:hubzilla,代码行数:65,代码来源:externals.php
示例6: externals_run
function externals_run($argv, $argc)
{
cli_startup();
$a = get_app();
$total = 0;
$attempts = 0;
logger('externals: startup', LOGGER_DEBUG);
// pull in some public posts
while ($total == 0 && $attempts < 3) {
$arr = array('url' => '');
call_hooks('externals_url_select', $arr);
if ($arr['url']) {
$url = $arr['url'];
} else {
$randfunc = db_getfunc('RAND');
$r = q("select site_url, site_pull from site where site_url != '%s' and site_flags != %d order by {$randfunc} limit 1", dbesc(z_root()), intval(DIRECTORY_MODE_STANDALONE));
if ($r) {
$url = $r[0]['site_url'];
}
}
// Note: blacklisted sites must be stored in the config as an array.
// No simple way to turn this into a personal config because we have no identity here.
// For that we probably need a variant of superblock.
$blacklisted = false;
$bl1 = get_config('system', 'blacklisted_sites');
if (is_array($bl1) && $bl1) {
foreach ($bl1 as $bl) {
if ($bl && strpos($url, $bl) !== false) {
$blacklisted = true;
break;
}
}
}
$attempts++;
// make sure we can eventually break out if somebody blacklists all known sites
if ($blacklisted) {
if ($attempts > 20) {
break;
}
$attempts--;
continue;
}
if ($url) {
if ($r[0]['site_pull'] !== NULL_DATE) {
$mindate = urlencode(datetime_convert('', '', $r[0]['site_pull'] . ' - 1 day'));
} else {
$days = get_config('externals', 'since_days');
if ($days === false) {
$days = 15;
}
$mindate = urlencode(datetime_convert('', '', 'now - ' . intval($days) . ' days'));
}
$feedurl = $url . '/zotfeed?f=&mindate=' . $mindate;
logger('externals: pulling public content from ' . $feedurl, LOGGER_DEBUG);
$x = z_fetch_url($feedurl);
if ($x && $x['success']) {
q("update site set site_pull = '%s' where site_url = '%s'", dbesc(datetime_convert()), dbesc($url));
$j = json_decode($x['body'], true);
if ($j['success'] && $j['messages']) {
$sys = get_sys_channel();
foreach ($j['messages'] as $message) {
// on these posts, clear any route info.
$message['route'] = '';
$results = process_delivery(array('hash' => 'undefined'), get_item_elements($message), array(array('hash' => $sys['xchan_hash'])), false, true);
$total++;
// $z = q("select id from item where mid = '%s' and uid = %d limit 1",
// dbesc($message['message_id']),
// intval($sys['channel_id'])
// );
$z = null;
if ($z) {
$flag_bits = ITEM_WALL | ITEM_ORIGIN | ITEM_UPLINK;
// preserve the source
$r = q("update item set source_xchan = owner_xchan where id = %d", intval($z[0]['id']));
$r = q("update item set item_flags = ( item_flags | %d ), owner_xchan = '%s' \n\t\t\t\t\t\t\t\twhere id = %d", intval($flag_bits), dbesc($sys['xchan_hash']), intval($z[0]['id']));
}
}
logger('externals: import_public_posts: ' . $total . ' messages imported', LOGGER_DEBUG);
}
}
}
}
}
开发者ID:redmatrix,项目名称:red,代码行数:83,代码来源:externals.php
示例7: import_post
//.........这里部分代码省略.........
foreach ($abooks as $abook) {
if ($max_friends !== false && $friends > $max_friends) {
continue;
}
if ($max_feeds !== false && $abook['abook_flags'] & ABOOK_FLAG_FEED && $feeds > $max_feeds) {
continue;
}
unset($abook['abook_id']);
$abook['abook_account'] = get_account_id();
$abook['abook_channel'] = $channel['channel_id'];
dbesc_array($abook);
$r = dbq("INSERT INTO abook (`" . implode("`, `", array_keys($abook)) . "`) VALUES ('" . implode("', '", array_values($abook)) . "')");
$friends++;
if ($abook['abook_flags'] & ABOOK_FLAG_FEED) {
$feeds++;
}
}
}
$configs = $data['config'];
if ($configs) {
foreach ($configs as $config) {
unset($config['id']);
$config['uid'] = $channel['channel_id'];
dbesc_array($config);
$r = dbq("INSERT INTO pconfig (`" . implode("`, `", array_keys($config)) . "`) VALUES ('" . implode("', '", array_values($config)) . "')");
}
}
$groups = $data['group'];
if ($groups) {
$saved = array();
foreach ($groups as $group) {
$saved[$group['hash']] = array('old' => $group['id']);
unset($group['id']);
$group['uid'] = $channel['channel_id'];
dbesc_array($group);
$r = dbq("INSERT INTO groups (`" . implode("`, `", array_keys($group)) . "`) VALUES ('" . implode("', '", array_values($group)) . "')");
}
$r = q("select * from `groups` where uid = %d", intval($channel['channel_id']));
if ($r) {
foreach ($r as $rr) {
$saved[$rr['hash']]['new'] = $rr['id'];
}
}
}
$group_members = $data['group_member'];
if ($groups_members) {
foreach ($group_members as $group_member) {
unset($group_member['id']);
$group_member['uid'] = $channel['channel_id'];
foreach ($saved as $x) {
if ($x['old'] == $group_member['gid']) {
$group_member['gid'] = $x['new'];
}
}
dbesc_array($group_member);
$r = dbq("INSERT INTO group_member (`" . implode("`, `", array_keys($group_member)) . "`) VALUES ('" . implode("', '", array_values($group_member)) . "')");
}
}
$saved_notification_flags = notifications_off($channel['channel_id']);
if ($import_posts && array_key_exists('item', $data) && $data['item']) {
foreach ($data['item'] as $i) {
$item = get_item_elements($i);
$r = q("select id, edited from item where mid = '%s' and uid = %d limit 1", dbesc($item['mid']), intval($channel['channel_id']));
if ($r) {
if ($item['edited'] > $r[0]['edited']) {
$item['id'] = $r[0]['id'];
$item['uid'] = $channel['channel_id'];
item_store_update($item);
continue;
}
} else {
$item['aid'] = $channel['channel_account_id'];
$item['uid'] = $channel['channel_id'];
$item_result = item_store($item);
}
}
}
notifications_on($channel['channel_id'], $saved_notification_flags);
if (array_key_exists('item_id', $data) && $data['item_id']) {
foreach ($data['item_id'] as $i) {
$r = q("select id from item where mid = '%s' and uid = %d limit 1", dbesc($i['mid']), intval($channel['channel_id']));
if (!$r) {
continue;
}
$z = q("select * from item_id where service = '%s' and sid = '%s' and iid = %d and uid = %d limit 1", dbesc($i['service']), dbesc($i['sid']), intval($r[0]['id']), intval($channel['channel_id']));
if (!$z) {
q("insert into item_id (iid,uid,sid,service) values(%d,%d,'%s','%s')", intval($r[0]['id']), intval($channel['channel_id']), dbesc($i['sid']), dbesc($i['service']));
}
}
}
// FIXME - ensure we have a self entry if somebody is trying to pull a fast one
// send out refresh requests
// notify old server that it may no longer be primary.
proc_run('php', 'include/notifier.php', 'location', $channel['channel_id']);
// This will indirectly perform a refresh_all *and* update the directory
proc_run('php', 'include/directory.php', $channel['channel_id']);
notice(t('Import completed.') . EOL);
change_channel($channel['channel_id']);
goaway(z_root() . '/network');
}
开发者ID:redmatrix,项目名称:red,代码行数:101,代码来源:import.php
示例8: photo_upload
//.........这里部分代码省略.........
$lat = $lon = null;
if ($exif && $exif['GPS']) {
if (feature_enabled($channel_id, 'photo_location')) {
$lat = getGps($exif['GPS']['GPSLatitude'], $exif['GPS']['GPSLatitudeRef']);
$lon = getGps($exif['GPS']['GPSLongitude'], $exif['GPS']['GPSLongitudeRef']);
}
}
$title = $args['description'] ? $args['description'] : $args['filename'];
$large_photos = feature_enabled($channel['channel_id'], 'large_photos');
linkify_tags($a, $args['body'], $channel_id);
if ($large_photos) {
$scale = 1;
$width = $link[1]['width'];
$height = $link[1]['height'];
$tag = $r1 ? '[zmg=' . $width . 'x' . $height . ']' : '[zmg]';
} else {
$scale = 2;
$width = $link[2]['width'];
$height = $link[2]['height'];
$tag = $r2 ? '[zmg=' . $width . 'x' . $height . ']' : '[zmg]';
}
$author_link = '[zrl=' . z_root() . '/channel/' . $channel['channel_address'] . ']' . $channel['channel_name'] . '[/zrl]';
$photo_link = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']' . t('a new photo') . '[/zrl]';
$album_link = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/album/' . bin2hex($album) . ']' . (strlen($album) ? $album : '/') . '[/zrl]';
$activity_format = sprintf(t('%1$s posted %2$s to %3$s', 'photo_upload'), $author_link, $photo_link, $album_link);
$summary = ($args['body'] ? $args['body'] : '') . '[footer]' . $activity_format . '[/footer]';
$obj_body = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']' . $tag . z_root() . "/photo/{$photo_hash}-{$scale}." . $ph->getExt() . '[/zmg]' . '[/zrl]';
// Create item object
$object = array('type' => ACTIVITY_OBJ_PHOTO, 'title' => $title, 'created' => $p['created'], 'edited' => $p['edited'], 'id' => z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash, 'link' => $link, 'body' => $obj_body);
$target = array('type' => ACTIVITY_OBJ_ALBUM, 'title' => $album ? $album : '/', 'id' => z_root() . '/photos/' . $channel['channel_address'] . '/album/' . bin2hex($album));
// Create item container
if ($args['item']) {
foreach ($args['item'] as $i) {
$item = get_item_elements($i);
$force = false;
if ($item['mid'] === $item['parent_mid']) {
$item['body'] = $summary;
$item['obj_type'] = ACTIVITY_OBJ_PHOTO;
$item['obj'] = json_encode($object);
$item['tgt_type'] = ACTIVITY_OBJ_ALBUM;
$item['target'] = json_encode($target);
if ($item['author_xchan'] === $channel['channel_hash']) {
$item['sig'] = base64url_encode(rsa_sign($item['body'], $channel['channel_prvkey']));
$item['item_verified'] = 1;
} else {
$item['sig'] = '';
}
$force = true;
}
$r = q("select id, edited from item where mid = '%s' and uid = %d limit 1", dbesc($item['mid']), intval($channel['channel_id']));
if ($r) {
if ($item['edited'] > $r[0]['edited'] || $force) {
$item['id'] = $r[0]['id'];
$item['uid'] = $channel['channel_id'];
item_store_update($item, false, $deliver);
continue;
}
} else {
$item['aid'] = $channel['channel_account_id'];
$item['uid'] = $channel['channel_id'];
$item_result = item_store($item, false, $deliver);
}
}
} else {
$mid = item_message_id();
$arr = array();
开发者ID:einervonvielen,项目名称:hubzilla,代码行数:67,代码来源:photos.php
示例9: import_items
function import_items($channel, $items, $sync = false)
{
if ($channel && $items) {
$allow_code = false;
$r = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id \n\t\t\twhere channel_id = %d limit 1", intval($channel['channel_id']));
if ($r) {
if ($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE || $r[0]['channel_pageflags'] & PAGE_ALLOWCODE) {
$allow_code = true;
}
}
$deliver = false;
// Don't deliver any messages or notifications when importing
foreach ($items as $i) {
$item_result = false;
$item = get_item_elements($i, $allow_code);
if (!$item) {
continue;
}
$r = q("select id, edited from item where mid = '%s' and uid = %d limit 1", dbesc($item['mid']), intval($channel['channel_id']));
if ($r) {
if ($item['edited'] > $r[0]['edited']) {
$item['id'] = $r[0]['id'];
$item['uid'] = $channel['channel_id'];
$item_result = item_store_update($item, $allow_code, $deliver);
if ($sync && $item['item_wall']) {
// deliver singletons if we have any
if ($item_result && $item_result['success']) {
Zotlabs\Daemon\Master::Summon(array('Notifier', 'single_activity', $item_result['item_id']));
}
}
continue;
}
} else {
$item['aid'] = $channel['channel_account_id'];
$item['uid'] = $channel['channel_id'];
$item_result = item_store($item, $allow_code, $deliver);
}
if ($sync && $item['item_wall']) {
// deliver singletons if we have any
if ($item_result && $item_result['success']) {
Zotlabs\Daemon\Master::Summon(array('Notifier', 'single_activity', $item_result['item_id']));
}
}
}
}
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:46,代码来源:import.php
示例10: photo_upload
//.........这里部分代码省略.........
if (!$r2) {
$errors = true;
}
}
if (($width > 320 || $height > 320) && !$errors) {
$ph->scaleImage(320);
$p['scale'] = 2;
$r3 = $ph->save($p);
$smallest = 2;
if (!$r3) {
$errors = true;
}
}
if ($errors) {
q("delete from photo where resource_id = '%s' and uid = %d", dbesc($photo_hash), intval($channel_id));
$ret['message'] = t('Photo storage failed.');
logger('photo_upload: photo store failed.');
call_hooks('photo_upload_end', $ret);
return $ret;
}
// This will be the width and height of the smallest representation
$width_x_height = $ph->getWidth() . 'x' . $ph->getHeight();
// Create item container
$item_hidden = $visible ? 0 : 1;
$lat = $lon = null;
if ($exif && $exif['GPS']) {
if (feature_enabled($channel_id, 'photo_location')) {
$lat = getGps($exif['GPS']['GPSLatitude'], $exif['GPS']['GPSLatitudeRef']);
$lon = getGps($exif['GPS']['GPSLongitude'], $exif['GPS']['GPSLongitudeRef']);
}
}
if ($args['item']) {
foreach ($args['item'] as $i) {
$item = get_item_elements($i);
$force = false;
if ($item['mid'] === $item['parent_mid']) {
$item['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']' . $tag . z_root() . "/photo/{$photo_hash}-{$smallest}." . $ph->getExt() . '[/zmg]' . '[/zrl]';
if ($item['author_xchan'] === $channel['channel_hash']) {
$item['sig'] = base64url_encode(rsa_sign($item['body'], $channel['channel_prvkey']));
$item['item_verified'] = 1;
} else {
$item['sig'] = '';
}
$force = true;
}
$r = q("select id, edited from item where mid = '%s' and uid = %d limit 1", dbesc($item['mid']), intval($channel['channel_id']));
if ($r) {
if ($item['edited'] > $r[0]['edited'] || $force) {
$item['id'] = $r[0]['id'];
$item['uid'] = $channel['channel_id'];
item_store_update($item);
continue;
}
} else {
$item['aid'] = $channel['channel_account_id'];
$item['uid'] = $channel['channel_id'];
$item_result = item_store($item);
}
}
} else {
$title = '';
$mid = item_message_id();
$arr = array();
if ($lat && $lon) {
$arr['coord'] = $lat . ' ' . $lon;
}
开发者ID:kenrestivo,项目名称:hubzilla,代码行数:67,代码来源:photos.php
示例11: onepoll_run
function onepoll_run($argv, $argc)
{
cli_startup();
$a = get_app();
logger('onepoll: start');
$manual_id = 0;
$generation = 0;
$force = false;
$restart = false;
if ($argc > 1 && intval($argv[1])) {
$contact_id = intval($argv[1]);
}
if (!$contact_id) {
logger('onepoll: no contact');
return;
}
$d = datetime_convert();
$contacts = q("SELECT abook.*, xchan.*, account.*\n\t\tFROM abook LEFT JOIN account on abook_account = account_id left join xchan on xchan_hash = abook_xchan \n\t\twhere abook_id = %d\n\t\tAND (( abook_flags & %d ) OR ( abook_flags = %d ))\n\t\tAND NOT ( abook_flags & %d )\n\t\tAND (( account_flags = %d ) OR ( account_flags = %d )) limit 1", intval($contact_id), intval(ABOOK_FLAG_HIDDEN | ABOOK_FLAG_PENDING | ABOOK_FLAG_UNCONNECTED | ABOOK_FLAG_FEED), intval(0), intval(ABOOK_FLAG_ARCHIVED | ABOOK_FLAG_BLOCKED | ABOOK_FLAG_IGNORED), intval(ACCOUNT_OK), intval(ACCOUNT_UNVERIFIED));
if (!$contacts) {
logger('onepoll: abook_id not found: ' . $contact_id);
return;
}
$contact = $contacts[0];
$t = $contact['abook_updated'];
$importer_uid = $contact['abook_channel'];
$r = q("SELECT * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d limit 1", intval($importer_uid));
if (!$r) {
return;
}
$importer = $r[0];
logger("onepoll: poll: ({$contact['id']}) IMPORTER: {$importer['xchan_name']}, CONTACT: {$contact['xchan_name']}");
$last_update = $contact['abook_updated'] === $contact['abook_created'] || $contact['abook_updated'] === NULL_DATE ? datetime_convert('UTC', 'UTC', 'now - 7 days') : datetime_convert('UTC', 'UTC', $contact['abook_updated'] . ' - 2 days');
if ($contact['xchan_network'] === 'rss') {
logger('onepoll: processing feed ' . $contact['xchan_name'], LOGGER_DEBUG);
handle_feed($importer['channel_id'], $contact_id, $contact['xchan_hash']);
q("update abook set abook_connected = '%s' where abook_id = %d limit 1", dbesc(datetime_convert()), intval($contact['abook_id']));
return;
}
if ($contact['xchan_network'] !== 'zot') {
return;
}
// update permissions
$x = zot_refresh($contact, $importer);
$responded = false;
$updated = datetime_convert();
if (!$x) {
// mark for death by not updating abook_connected, this is caught in include/poller.php
q("update abook set abook_updated = '%s' where abook_id = %d limit 1", dbesc($updated), intval($contact['abook_id']));
} else {
q("update abook set abook_updated = '%s', abook_connected = '%s' where abook_id = %d limit 1", dbesc($updated), dbesc($updated), intval($contact['abook_id']));
$responded = true;
}
if (!$responded) {
return;
}
if ($contact['xchan_connurl']) {
$fetch_feed = true;
$x = null;
if (!($contact['abook_their_perms'] & PERMS_R_STREAM)) {
$fetch_feed = false;
}
if ($fetch_feed) {
$feedurl = str_replace('/poco/', '/zotfeed/', $contact['xchan_connurl']);
$x = z_fetch_url($feedurl . '?f=&mindate=' . urlencode($last_update));
logger('feed_update: ' . print_r($x, true), LOGGER_DATA);
}
if ($x && $x['success']) {
$total = 0;
logger('onepoll: feed update ' . $contact['xchan_name']);
$j = json_decode($x['body'], true);
if ($j['success'] && $j['messages']) {
foreach ($j['messages'] as $message) {
$results = process_delivery(array('hash' => $contact['xchan_hash']), get_item_elements($message), array(array('hash' => $importer['xchan_hash'])), false);
logger('onepoll: feed_update: process_delivery: ' . print_r($results, true));
$total++;
}
logger("onepoll: {$total} messages processed");
}
}
}
// fetch some items
// set last updated timestamp
if ($contact['xchan_connurl']) {
$r = q("SELECT xlink_id from xlink \n\t\t\twhere xlink_xchan = '%s' and xlink_updated > UTC_TIMESTAMP() - INTERVAL 1 DAY limit 1", intval($contact['xchan_hash']));
if (!$r) {
poco_load($contact['xchan_hash'], $contact['xchan_connurl']);
}
}
return;
}
开发者ID:Mauru,项目名称:red,代码行数:90,代码来源:onepoll.php
注:本文中的get_item_elements函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论