本文整理汇总了PHP中encode_item函数的典型用法代码示例。如果您正苦于以下问题:PHP encode_item函数的具体用法?PHP encode_item怎么用?PHP encode_item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了encode_item函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
function init()
{
$starred = 0;
if (!local_channel()) {
killme();
}
if (argc() > 1) {
$message_id = intval(argv(1));
}
if (!$message_id) {
killme();
}
$r = q("SELECT item_flags FROM item WHERE uid = %d AND id = %d LIMIT 1", intval(local_channel()), intval($message_id));
if (!count($r)) {
killme();
}
$item_starred = intval($r[0]['item_starred']) ? 0 : 1;
$r = q("UPDATE item SET item_starred = %d WHERE uid = %d and id = %d", intval($item_starred), intval(local_channel()), intval($message_id));
$r = q("select * from item where id = %d", intval($message_id));
if ($r) {
xchan_query($r);
$sync_item = fetch_post_tags($r);
build_sync_packet(local_channel(), ['item' => [encode_item($sync_item[0], true)]]);
}
header('Content-type: application/json');
echo json_encode(array('result' => $item_starred));
killme();
}
示例2: zot_feed
function zot_feed($uid, $observer_hash, $arr)
{
$result = array();
$mindate = null;
$message_id = null;
require_once 'include/security.php';
if (array_key_exists('mindate', $arr)) {
$mindate = datetime_convert('UTC', 'UTC', $arr['mindate']);
}
if (array_key_exists('message_id', $arr)) {
$message_id = $arr['message_id'];
}
if (!$mindate) {
$mindate = NULL_DATE;
}
$mindate = dbesc($mindate);
logger('zot_feed: requested for uid ' . $uid . ' from observer ' . $observer_hash, LOGGER_DEBUG);
if ($message_id) {
logger('message_id: ' . $message_id, LOGGER_DEBUG);
}
if (!perm_is_allowed($uid, $observer_hash, 'view_stream')) {
logger('zot_feed: permission denied.');
return $result;
}
if (!is_sys_channel($uid)) {
$sql_extra = item_permissions_sql($uid, $observer_hash);
}
$limit = " LIMIT 100 ";
if ($mindate != NULL_DATE) {
$sql_extra .= " and ( created > '{$mindate}' or changed > '{$mindate}' ) ";
}
if ($message_id) {
$sql_extra .= " and mid = '" . dbesc($message_id) . "' ";
$limit = '';
}
$items = array();
/** @FIXME re-unite these SQL statements. There is no need for them to be separate. The mySQL is convoluted with misuse of group by. As it stands, there is a slight difference where the postgres version doesn't remove the duplicate parents up to 100. In practice this doesn't matter. It could be made to match behavior by adding "distinct on (parent) " to the front of the selection list, at a not-worth-it performance penalty (page temp results to disk). duplicates are still ignored in the in() clause, you just get less than 100 parents if there are many children. */
if (ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
$groupby = '';
} else {
$groupby = 'GROUP BY parent';
}
$item_normal = item_normal();
if (is_sys_channel($uid)) {
$r = q("SELECT parent, created, postopts from item\n\t\t\tWHERE uid != %d\n\t\t\t{$item_normal}\n\t\t\tAND item_wall = 1\n\t\t\tand item_private = 0 {$sql_extra} {$groupby} ORDER BY created ASC {$limit}", intval($uid));
} else {
$r = q("SELECT parent, created, postopts from item\n\t\t\tWHERE uid = %d {$item_normal}\n\t\t\tAND item_wall = 1\n\t\t\t{$sql_extra} {$groupby} ORDER BY created ASC {$limit}", intval($uid));
}
if ($r) {
for ($x = 0; $x < count($r); $x++) {
if (strpos($r[$x]['postopts'], 'nodeliver') !== false) {
unset($r[$x]);
}
}
$parents_str = ids_to_querystr($r, 'parent');
$sys_query = is_sys_channel($uid) ? $sql_extra : '';
$item_normal = item_normal();
$items = q("SELECT `item`.*, `item`.`id` AS `item_id` FROM `item`\n\t\t\tWHERE `item`.`parent` IN ( %s ) {$item_normal} {$sys_query} ", dbesc($parents_str));
}
if ($items) {
xchan_query($items);
$items = fetch_post_tags($items);
require_once 'include/conversation.php';
$items = conv_sort($items, 'ascending');
} else {
$items = array();
}
logger('zot_feed: number items: ' . count($items), LOGGER_DEBUG);
foreach ($items as $item) {
$result[] = encode_item($item);
}
return $result;
}
示例3: attach_export_data
function attach_export_data($channel, $resource_id, $deleted = false)
{
$ret = array();
$paths = array();
$hash_ptr = $resource_id;
$ret['fetch_url'] = z_root() . '/getfile';
$ret['original_channel'] = $channel['channel_address'];
if ($deleted) {
$ret['attach'] = array(array('hash' => $resource_id, 'deleted' => 1));
return $ret;
}
do {
$r = q("select * from attach where hash = '%s' and uid = %d limit 1", dbesc($hash_ptr), intval($channel['channel_id']));
if (!$r) {
break;
}
if ($hash_ptr === $resource_id) {
$attach_ptr = $r[0];
}
$hash_ptr = $r[0]['folder'];
$paths[] = $r[0];
} while ($hash_ptr);
$paths = array_reverse($paths);
$ret['attach'] = $paths;
if ($attach_ptr['is_photo']) {
$r = q("select * from photo where resource_id = '%s' and uid = %d order by imgscale asc", dbesc($resource_id), intval($channel['channel_id']));
if ($r) {
for ($x = 0; $x < count($r); $x++) {
$r[$x]['content'] = base64_encode($r[$x]['content']);
}
$ret['photo'] = $r;
}
$r = q("select * from item where resource_id = '%s' and resource_type = 'photo' and uid = %d ", dbesc($resource_id), intval($channel['channel_id']));
if ($r) {
$ret['item'] = array();
$items = q("select item.*, item.id as item_id from item where item.parent = %d ", intval($r[0]['id']));
if ($items) {
xchan_query($items);
$items = fetch_post_tags($items, true);
foreach ($items as $rr) {
$ret['item'][] = encode_item($rr, true);
}
}
}
}
return $ret;
}
示例4: zot_feed
function zot_feed($uid, $observer_xchan, $mindate)
{
$result = array();
$mindate = datetime_convert('UTC', 'UTC', $mindate);
if (!$mindate) {
$mindate = NULL_DATE;
}
$mindate = dbesc($mindate);
logger('zot_feed: ' . $uid);
if (!perm_is_allowed($uid, $observer_xchan, 'view_stream')) {
logger('zot_feed: permission denied.');
return $result;
}
if (!is_sys_channel($uid)) {
require_once 'include/security.php';
$sql_extra = item_permissions_sql($uid);
}
if ($mindate != NULL_DATE) {
$sql_extra .= " and ( created > '{$mindate}' or edited > '{$mindate}' ) ";
$limit = "";
} else {
$limit = " limit 0, 50 ";
}
$items = array();
if (is_sys_channel($uid)) {
require_once 'include/security.php';
$r = q("SELECT distinct parent from item\n\t\t\tWHERE uid != %d\n\t\t\tand uid in (" . stream_perms_api_uids(PERMS_PUBLIC) . ") AND item_restrict = 0 \n\t\t\tAND (item_flags & %d) \n\t\t\tand item_private = 0 {$sql_extra} ORDER BY created ASC {$limit}", intval($uid), intval(ITEM_WALL));
} else {
$r = q("SELECT distinct parent from item\n\t\t\tWHERE uid = %d AND item_restrict = 0\n\t\t\tAND (item_flags & %d) \n\t\t\t{$sql_extra} ORDER BY created ASC {$limit}", intval($uid), intval(ITEM_WALL));
}
if ($r) {
$parents_str = ids_to_querystr($r, 'parent');
$sys_query = is_sys_channel($uid) ? $sql_extra : '';
$items = q("SELECT `item`.*, `item`.`id` AS `item_id` FROM `item` \n\t\t\tWHERE `item`.`item_restrict` = 0\n\t\t\tAND `item`.`parent` IN ( %s ) {$sys_query} ", dbesc($parents_str));
}
if ($items) {
xchan_query($items);
$items = fetch_post_tags($items);
require_once 'include/conversation.php';
$items = conv_sort($items, 'ascending');
} else {
$items = array();
}
logger('zot_feed: number items: ' . count($items), LOGGER_DEBUG);
foreach ($items as $item) {
$result[] = encode_item($item);
}
return $result;
}
示例5: sync_an_item
function sync_an_item($channel_id, $item_id)
{
$r = q("select * from item where id = %d", intval($item_id));
if ($r) {
xchan_query($r);
$sync_item = fetch_post_tags($r);
$rid = q("select * from item_id where iid = %d", intval($item_id));
build_sync_packet($channel_d, array('item' => array(encode_item($sync_item[0], true)), 'item_id' => $rid));
}
}
示例6: get
function get()
{
if (!local_channel() && !remote_channel()) {
return;
}
$observer_hash = get_observer_hash();
//strip html-tags
$term = notags(trim($_GET['term']));
//check if empty
if (!$term) {
return;
}
$item_id = argc() > 1 ? notags(trim(argv(1))) : 0;
logger('tagger: tag ' . $term . ' item ' . $item_id);
$r = q("SELECT * FROM item left join xchan on xchan_hash = author_xchan WHERE id = '%s' and uid = %d LIMIT 1", dbesc($item_id), intval(local_channel()));
if (!$item_id || !$r) {
logger('tagger: no item ' . $item_id);
return;
}
$item = $r[0];
$owner_uid = $item['uid'];
switch ($item['resource_type']) {
case 'photo':
$targettype = ACTIVITY_OBJ_PHOTO;
$post_type = t('photo');
break;
case 'event':
$targgettype = ACTIVITY_OBJ_EVENT;
$post_type = t('event');
break;
default:
$targettype = ACTIVITY_OBJ_NOTE;
$post_type = t('post');
if ($item['mid'] != $item['parent_mid']) {
$post_type = t('comment');
}
break;
}
$links = array(array('rel' => 'alternate', 'type' => 'text/html', 'href' => z_root() . '/display/' . $item['mid']));
$target = json_encode(array('type' => $targettype, 'id' => $item['mid'], 'link' => $links, 'title' => $item['title'], 'content' => $item['body'], 'created' => $item['created'], 'edited' => $item['edited'], 'author' => array('name' => $item['xchan_name'], 'address' => $item['xchan_addr'], 'guid' => $item['xchan_guid'], 'guid_sig' => $item['xchan_guid_sig'], 'link' => array(array('rel' => 'alternate', 'type' => 'text/html', 'href' => $item['xchan_url']), array('rel' => 'photo', 'type' => $item['xchan_photo_mimetype'], 'href' => $item['xchan_photo_m'])))));
$link = xmlify('<link rel="alternate" type="text/html" href="' . z_root() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n");
$tagid = z_root() . '/search?tag=' . $term;
$objtype = ACTIVITY_OBJ_TAGTERM;
$obj = json_encode(array('type' => $objtype, 'id' => $tagid, 'link' => array(array('rel' => 'alternate', 'type' => 'text/html', 'href' => $tagid)), 'title' => $term, 'content' => $term));
$bodyverb = t('%1$s tagged %2$s\'s %3$s with %4$s');
// saving here for reference
// also check out x22d5 and x2317 and x0d6b and x0db8 and x24d0 and xff20 !!!
$termlink = html_entity_decode('⋕') . '[zrl=' . z_root() . '/search?tag=' . urlencode($term) . ']' . $term . '[/zrl]';
$channel = \App::get_channel();
$arr = array();
$arr['owner_xchan'] = $item['owner_xchan'];
$arr['author_xchan'] = $channel['channel_hash'];
$arr['item_origin'] = 1;
$arr['item_wall'] = intval($item['item_wall']) ? 1 : 0;
$ulink = '[zrl=' . $channel['xchan_url'] . ']' . $channel['channel_name'] . '[/zrl]';
$alink = '[zrl=' . $item['xchan_url'] . ']' . $item['xchan_name'] . '[/zrl]';
$plink = '[zrl=' . $item['plink'] . ']' . $post_type . '[/zrl]';
$arr['body'] = sprintf($bodyverb, $ulink, $alink, $plink, $termlink);
$arr['verb'] = ACTIVITY_TAG;
$arr['tgt_type'] = $targettype;
$arr['target'] = $target;
$arr['obj_type'] = $objtype;
$arr['obj'] = $obj;
$arr['parent_mid'] = $item['mid'];
store_item_tag($item['uid'], $item['id'], TERM_OBJ_POST, TERM_COMMUNITYTAG, $term, $tagid);
$ret = post_activity_item($arr);
if ($ret['success']) {
build_sync_packet(local_channel(), ['item' => [encode_item($ret['activity'], true)]]);
}
killme();
}
示例7: event_addtocal
function event_addtocal($item_id, $uid)
{
$c = q("select * from channel where channel_id = %d limit 1", intval($uid));
if (!$c) {
return false;
}
$channel = $c[0];
$r = q("select * from item where id = %d and uid = %d limit 1", intval($item_id), intval($channel['channel_id']));
if (!$r || $r[0]['obj_type'] !== ACTIVITY_OBJ_EVENT) {
return false;
}
$item = $r[0];
$ev = bbtoevent($r[0]['body']);
if (x($ev, 'summary') && x($ev, 'start')) {
$ev['event_xchan'] = $item['author_xchan'];
$ev['uid'] = $channel['channel_id'];
$ev['account'] = $channel['channel_account_id'];
$ev['edited'] = $item['edited'];
$ev['mid'] = $item['mid'];
$ev['private'] = $item['item_private'];
// is this an edit?
if ($item['resource_type'] === 'event') {
$ev['event_hash'] = $item['resource_id'];
}
$event = event_store_event($ev);
if ($event) {
$r = q("update item set resource_id = '%s', resource_type = 'event' where id = %d and uid = %d", dbesc($event['event_hash']), intval($item['id']), intval($channel['channel_id']));
$item['resource_id'] = $event['event_hash'];
$item['resource_type'] = 'event';
$i = array($item);
xchan_query($i);
$sync_item = fetch_post_tags($i);
$z = q("select * from event where event_hash = '%s' and uid = %d limit 1", dbesc($event['event_hash']), intval($channel['channel_id']));
if ($z) {
build_sync_packet($channel['channel_id'], array('event_item' => array(encode_item($sync_item[0], true)), 'event' => $z));
}
return true;
}
}
return false;
}
示例8: identity_export_year
function identity_export_year($channel_id, $year, $month = 0)
{
if (!$year) {
return array();
}
if ($month && $month <= 12) {
$target_month = sprintf('%02d', $month);
$target_month_plus = sprintf('%02d', $month + 1);
} else {
$target_month = '01';
}
$ret = array();
$mindate = datetime_convert('UTC', 'UTC', $year . '-' . $target_month . '-01 00:00:00');
if ($month && $month < 12) {
$maxdate = datetime_convert('UTC', 'UTC', $year . '-' . $target_month_plus . '-01 00:00:00');
} else {
$maxdate = datetime_convert('UTC', 'UTC', $year + 1 . '-01-01 00:00:00');
}
$r = q("select * from item where item_wall = 1 and item_deleted = 0 and uid = %d and created >= '%s' and created < '%s' and resource_type = '' order by created", intval($channel_id), dbesc($mindate), dbesc($maxdate));
if ($r) {
$ret['item'] = array();
xchan_query($r);
$r = fetch_post_tags($r, true);
foreach ($r as $rr) {
$ret['item'][] = encode_item($rr, true);
}
}
$r = q("select item_id.*, item.mid from item_id left join item on item_id.iid = item.id where item_id.uid = %d \n\t\tand item.created >= '%s' and item.created < '%s' order by created ", intval($channel_id), dbesc($mindate), dbesc($maxdate));
if ($r) {
$ret['item_id'] = $r;
}
return $ret;
}
示例9: notifier_run
//.........这里部分代码省略.........
logger('notifier: target item is undeliverable', LOGGER_DEBUG);
return;
}
$s = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d limit 1", intval($target_item['uid']));
if ($s) {
$channel = $s[0];
}
if ($channel['channel_hash'] !== $target_item['author_xchan'] && $channel['channel_hash'] !== $target_item['owner_xchan']) {
logger("notifier: Sending channel {$channel['channel_hash']} is not owner {$target_item['owner_xchan']} or author {$target_item['author_xchan']}", LOGGER_NORMAL, LOG_WARNING);
return;
}
if ($target_item['id'] == $target_item['parent']) {
$parent_item = $target_item;
$top_level_post = true;
} else {
// fetch the parent item
$r = q("SELECT * from item where id = %d order by id asc", intval($target_item['parent']));
if (!$r) {
return;
}
if (strpos($r[0]['postopts'], 'nodeliver') !== false) {
logger('notifier: target item is undeliverable', LOGGER_DEBUG, LOG_NOTICE);
return;
}
xchan_query($r);
$r = fetch_post_tags($r);
$parent_item = $r[0];
$top_level_post = false;
}
// avoid looping of discover items 12/4/2014
if ($sys && $parent_item['uid'] == $sys['channel_id']) {
return;
}
$encoded_item = encode_item($target_item);
// Send comments to the owner to re-deliver to everybody in the conversation
// We only do this if the item in question originated on this site. This prevents looping.
// To clarify, a site accepting a new comment is responsible for sending it to the owner for relay.
// Relaying should never be initiated on a post that arrived from elsewhere.
// We should normally be able to rely on ITEM_ORIGIN, but start_delivery_chain() incorrectly set this
// flag on comments for an extended period. So we'll also call comment_local_origin() which looks at
// the hostname in the message_id and provides a second (fallback) opinion.
$relay_to_owner = !$top_level_post && intval($target_item['item_origin']) && comment_local_origin($target_item) ? true : false;
$uplink = false;
// $cmd === 'relay' indicates the owner is sending it to the original recipients
// don't allow the item in the relay command to relay to owner under any circumstances, it will loop
logger('notifier: relay_to_owner: ' . ($relay_to_owner ? 'true' : 'false'), LOGGER_DATA, LOG_DEBUG);
logger('notifier: top_level_post: ' . ($top_level_post ? 'true' : 'false'), LOGGER_DATA, LOG_DEBUG);
// tag_deliver'd post which needs to be sent back to the original author
if ($cmd === 'uplink' && intval($parent_item['item_uplink']) && !$top_level_post) {
logger('notifier: uplink');
$uplink = true;
}
if (($relay_to_owner || $uplink) && $cmd !== 'relay') {
logger('notifier: followup relay', LOGGER_DEBUG);
$recipients = array($uplink ? $parent_item['source_xchan'] : $parent_item['owner_xchan']);
$private = true;
if (!$encoded_item['flags']) {
$encoded_item['flags'] = array();
}
$encoded_item['flags'][] = 'relay';
} else {
logger('notifier: normal distribution', LOGGER_DEBUG);
if ($cmd === 'relay') {
logger('notifier: owner relay');
}
// if our parent is a tag_delivery recipient, uplink to the original author causing
示例10: item_post
//.........这里部分代码省略.........
logger('mod_item: post cancelled by plugin.');
if ($return_path) {
goaway($a->get_baseurl() . "/" . $return_path);
}
$json = array('cancel' => 1);
if (x($_REQUEST, 'jsreload') && strlen($_REQUEST['jsreload'])) {
$json['reload'] = $a->get_baseurl() . '/' . $_REQUEST['jsreload'];
}
echo json_encode($json);
killme();
}
if (mb_strlen($datarray['title']) > 255) {
$datarray['title'] = mb_substr($datarray['title'], 0, 255);
}
if (array_key_exists('item_private', $datarray) && $datarray['item_private']) {
$datarray['body'] = trim(z_input_filter($datarray['uid'], $datarray['body'], $datarray['mimetype']));
if ($uid) {
if ($channel['channel_hash'] === $datarray['author_xchan']) {
$datarray['sig'] = base64url_encode(rsa_sign($datarray['body'], $channel['channel_prvkey']));
$datarray['item_verified'] = 1;
}
}
}
if ($orig_post) {
$datarray['id'] = $post_id;
item_store_update($datarray, $execflag);
update_remote_id($channel, $post_id, $webpage, $pagetitle, $namespace, $remote_id, $mid);
if (!$parent) {
$r = q("select * from item where id = %d", intval($post_id));
if ($r) {
xchan_query($r);
$sync_item = fetch_post_tags($r);
$rid = q("select * from item_id where iid = %d", intval($post_id));
build_sync_packet($uid, array('item' => array(encode_item($sync_item[0], true)), 'item_id' => $rid));
}
}
if (!$nopush) {
proc_run('php', "include/notifier.php", 'edit_post', $post_id);
}
if (x($_REQUEST, 'return') && strlen($return_path)) {
logger('return: ' . $return_path);
goaway($a->get_baseurl() . "/" . $return_path);
}
killme();
} else {
$post_id = 0;
}
$post = item_store($datarray, $execflag);
$post_id = $post['item_id'];
if ($post_id) {
logger('mod_item: saved item ' . $post_id);
if ($parent) {
// only send comment notification if this is a wall-to-wall comment,
// otherwise it will happen during delivery
if ($datarray['owner_xchan'] != $datarray['author_xchan'] && intval($parent_item['item_wall'])) {
notification(array('type' => NOTIFY_COMMENT, 'from_xchan' => $datarray['author_xchan'], 'to_xchan' => $datarray['owner_xchan'], 'item' => $datarray, 'link' => $a->get_baseurl() . '/display/' . $datarray['mid'], 'verb' => ACTIVITY_POST, 'otype' => 'item', 'parent' => $parent, 'parent_mid' => $parent_item['mid']));
}
} else {
$parent = $post_id;
if ($datarray['owner_xchan'] != $datarray['author_xchan']) {
notification(array('type' => NOTIFY_WALL, 'from_xchan' => $datarray['author_xchan'], 'to_xchan' => $datarray['owner_xchan'], 'item' => $datarray, 'link' => $a->get_baseurl() . '/display/' . $datarray['mid'], 'verb' => ACTIVITY_POST, 'otype' => 'item'));
}
if ($uid && $uid == $profile_uid && is_item_normal($datarray)) {
q("update channel set channel_lastpost = '%s' where channel_id = %d", dbesc(datetime_convert()), intval($uid));
}
}
示例11: notifier_run
//.........这里部分代码省略.........
$deleted_item = true;
}
$unforwardable = ITEM_UNPUBLISHED | ITEM_DELAYED_PUBLISH | ITEM_WEBPAGE | ITEM_BUILDBLOCK | ITEM_PDL;
if ($target_item['item_restrict'] & $unforwardable) {
logger('notifier: target item not forwardable: flags ' . $target_item['item_restrict'], LOGGER_DEBUG);
return;
}
$s = q("select * from channel where channel_id = %d limit 1", intval($target_item['uid']));
if ($s) {
$channel = $s[0];
}
if ($channel['channel_hash'] !== $target_item['author_xchan'] && $channel['channel_hash'] !== $target_item['owner_xchan']) {
logger("notifier: Sending channel {$channel['channel_hash']} is not owner {$target_item['owner_xchan']} or author {$target_item['author_xchan']}");
return;
}
if ($target_item['id'] == $target_item['parent']) {
$parent_item = $target_item;
$top_level_post = true;
} else {
// fetch the parent item
$r = q("SELECT * from item where id = %d order by id asc", intval($target_item['parent']));
if (!$r) {
return;
}
xchan_query($r);
$r = fetch_post_tags($r);
$parent_item = $r[0];
$top_level_post = false;
}
// avoid looping of discover items 12/4/2014
if ($sys && $parent_item['uid'] == $sys['channel_id']) {
return;
}
$encoded_item = encode_item($target_item);
// Send comments to the owner to re-deliver to everybody in the conversation
// We only do this if the item in question originated on this site. This prevents looping.
// To clarify, a site accepting a new comment is responsible for sending it to the owner for relay.
// Relaying should never be initiated on a post that arrived from elsewhere.
// We should normally be able to rely on ITEM_ORIGIN, but start_delivery_chain() incorrectly set this
// flag on comments for an extended period. So we'll also call comment_local_origin() which looks at
// the hostname in the message_id and provides a second (fallback) opinion.
$relay_to_owner = !$top_level_post && $target_item['item_flags'] & ITEM_ORIGIN && comment_local_origin($target_item) ? true : false;
$uplink = false;
// $cmd === 'relay' indicates the owner is sending it to the original recipients
// don't allow the item in the relay command to relay to owner under any circumstances, it will loop
logger('notifier: relay_to_owner: ' . ($relay_to_owner ? 'true' : 'false'), LOGGER_DATA);
logger('notifier: top_level_post: ' . ($top_level_post ? 'true' : 'false'), LOGGER_DATA);
logger('notifier: target_item_flags: ' . $target_item['item_flags'] . ' ' . ($target_item['item_flags'] & ITEM_ORIGIN ? 'true' : 'false'), LOGGER_DATA);
// tag_deliver'd post which needs to be sent back to the original author
if ($cmd === 'uplink' && $parent_item['item_flags'] & ITEM_UPLINK && !$top_level_post) {
logger('notifier: uplink');
$uplink = true;
}
if (($relay_to_owner || $uplink) && $cmd !== 'relay') {
logger('notifier: followup relay', LOGGER_DEBUG);
$recipients = array($uplink ? $parent_item['source_xchan'] : $parent_item['owner_xchan']);
$private = true;
if (!$encoded_item['flags']) {
$encoded_item['flags'] = array();
}
$encoded_item['flags'][] = 'relay';
} else {
logger('notifier: normal distribution', LOGGER_DEBUG);
if ($cmd === 'relay') {
logger('notifier: owner relay');
}
示例12: red_item
function red_item($a, $type)
{
if (api_user() === false) {
logger('api_red_item_full: no user');
return false;
}
if ($_REQUEST['mid']) {
$arr = array('mid' => $_REQUEST['mid']);
} elseif ($_REQUEST['item_id']) {
$arr = array('item_id' => $_REQUEST['item_id']);
} else {
json_return_and_die(array());
}
$arr['start'] = 0;
$arr['records'] = 999999;
$arr['item_type'] = '*';
$i = items_fetch($arr, App::get_channel(), get_observer_hash());
if (!$i) {
json_return_and_die(array());
}
$ret = array();
$tmp = array();
foreach ($i as $ii) {
$tmp[] = encode_item($ii, true);
}
$ret['item'] = $tmp;
json_return_and_die($ret);
}
示例13: api_photo_detail
function api_photo_detail(&$a, $type)
{
if (api_user() === false) {
return false;
}
if (!$_REQUEST['photo_id']) {
return false;
}
$scale = array_key_exists('scale', $_REQUEST) ? intval($_REQUEST['scale']) : 0;
$r = q("select * from photo where uid = %d and resource_id = '%s' and scale = %d limit 1", intval(local_channel()), dbesc($_REQUEST['photo_id']), intval($scale));
if ($r) {
$data = dbunescbin($r[0]['data']);
if (array_key_exists('os_storage', $r[0]) && intval($r[0]['os_storage'])) {
$data = file_get_contents($data);
}
$r[0]['data'] = base64_encode($data);
$ret = array('photo' => $r[0]);
$i = q("select id from item where uid = %d and resource_type = 'photo' and resource_id = '%s' limit 1", intval(local_channel()), dbesc($_REQUEST['photo_id']));
if ($i) {
$ii = q("select * from item where parent = %d order by id", intval($i[0]['id']));
if ($ii) {
xchan_query($ii, true, 0);
$ii = fetch_post_tags($ii, true);
if ($ii) {
$ret['item'] = array();
foreach ($ii as $iii) {
$ret['item'][] = encode_item($iii, true);
}
}
}
}
json_return_and_die($ret);
}
killme();
}
示例14: identity_basic_export
/**
* @brief Create an array representing the important channel information
* which would be necessary to create a nomadic identity clone. This includes
* most channel resources and connection information with the exception of content.
*
* @param int $channel_id
* Channel_id to export
* @param boolean $items
* Include channel posts (wall items), default false
*
* @returns array
* See function for details
*/
function identity_basic_export($channel_id, $items = false)
{
/*
* Red basic channel export
*/
$ret = array();
$ret['compatibility'] = array('project' => RED_PLATFORM, 'version' => RED_VERSION, 'database' => DB_UPDATE_VERSION);
$r = q("select * from channel where channel_id = %d limit 1", intval($channel_id));
if ($r) {
$ret['channel'] = $r[0];
}
$r = q("select * from profile where uid = %d", intval($channel_id));
if ($r) {
$ret['profile'] = $r;
}
$xchans = array();
$r = q("select * from abook where abook_channel = %d ", intval($channel_id));
if ($r) {
$ret['abook'] = $r;
foreach ($r as $rr) {
$xchans[] = $rr['abook_xchan'];
}
stringify_array_elms($xchans);
}
if ($xchans) {
$r = q("select * from xchan where xchan_hash in ( " . implode(',', $xchans) . " ) ");
if ($r) {
$ret['xchan'] = $r;
}
$r = q("select * from hubloc where hubloc_hash in ( " . implode(',', $xchans) . " ) ");
if ($r) {
$ret['hubloc'] = $r;
}
}
$r = q("select * from `groups` where uid = %d ", intval($channel_id));
if ($r) {
$ret['group'] = $r;
}
$r = q("select * from group_member where uid = %d ", intval($channel_id));
if ($r) {
$ret['group_member'] = $r;
}
$r = q("select * from pconfig where uid = %d", intval($channel_id));
if ($r) {
$ret['config'] = $r;
}
$r = q("select type, data from photo where scale = 4 and profile = 1 and uid = %d limit 1", intval($channel_id));
if ($r) {
$ret['photo'] = array('type' => $r[0]['type'], 'data' => base64url_encode($r[0]['data']));
}
// All other term types will be included in items, if requested.
$r = q("select * from term where type in (%d,%d) and uid = %d", intval(TERM_SAVEDSEARCH), intval(TERM_THING), intval($channel_id));
if ($r) {
$ret['term'] = $r;
}
$r = q("select * from obj where obj_channel = %d", intval($channel_id));
if ($r) {
$ret['obj'] = $r;
}
if (!$items) {
return $ret;
}
$r = q("select likes.*, item.mid from likes left join item on likes.iid = item.id where likes.channel_id = %d", intval($channel_id));
if ($r) {
$ret['likes'] = $r;
}
$r = q("select item_id.*, item.mid from item_id left join item on item_id.iid = item.id where item_id.uid = %d", intval($channel_id));
if ($r) {
$ret['item_id'] = $r;
}
//$key = get_config('system','prvkey');
/** @warning this may run into memory limits on smaller systems */
$r = q("select * from item where (item_flags & %d)>0 and not (item_restrict & %d)>0 and uid = %d", intval(ITEM_WALL), intval(ITEM_DELETED), intval($channel_id));
if ($r) {
$ret['item'] = array();
xchan_query($r);
$r = fetch_post_tags($r, true);
foreach ($r as $rr) {
$ret['item'][] = encode_item($rr, true);
}
}
return $ret;
}
示例15: search_content
//.........这里部分代码省略.........
if (x($a->data, 'search')) {
$search = trim($a->data['search']);
} else {
$search = x($_GET, 'search') ? trim(rawurldecode($_GET['search'])) : '';
}
$tag = false;
if (x($_GET, 'tag')) {
$tag = true;
$search = x($_GET, 'tag') ? trim(rawurldecode($_GET['tag'])) : '';
}
if (!local_channel() || !feature_enabled(local_channel(), 'savedsearch')) {
$o .= search($search, 'search-box', '/search', local_channel() ? true : false);
}
if (strpos($search, '#') === 0) {
$tag = true;
$search = substr($search, 1);
}
if (strpos($search, '@') === 0) {
$search = substr($search, 1);
goaway(z_root() . '/directory' . '?f=1&search=' . $search);
}
// look for a naked webbie
if (strpos($search, '@') !== false) {
goaway(z_root() . '/directory' . '?f=1&search=' . $search);
}
if (!$search) {
return $o;
}
if ($tag) {
$sql_extra = sprintf(" AND `item`.`id` IN (select `oid` from term where otype = %d and type = %d and term = '%s') ", intval(TERM_OBJ_POST), intval(TERM_HASHTAG), dbesc(protect_sprintf($search)));
} else {
$regstr = db_getfunc('REGEXP');
$sql_extra = sprintf(" AND `item`.`body` {$regstr} '%s' ", dbesc(protect_sprintf(preg_quote($search))));
}
// Here is the way permissions work in the search module...
// Only public posts can be shown
// OR your own posts if you are a logged in member
// No items will be shown if the member has a blocked profile wall.
if (!$update && !$load) {
// This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
// because browser prefetching might change it on us. We have to deliver it with the page.
$o .= '<div id="live-search"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . (intval(local_channel()) ? local_channel() : -1) . "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
$a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"), array('$baseurl' => z_root(), '$pgtype' => 'search', '$uid' => $a->profile['profile_uid'] ? $a->profile['profile_uid'] : '0', '$gid' => '0', '$cid' => '0', '$cmin' => '0', '$cmax' => '0', '$star' => '0', '$liked' => '0', '$conv' => '0', '$spam' => '0', '$fh' => '0', '$nouveau' => '0', '$wall' => '0', '$list' => x($_REQUEST, 'list') ? intval($_REQUEST['list']) : 0, '$page' => $a->pager['page'] != 1 ? $a->pager['page'] : 1, '$search' => ($tag ? urlencode('#') : '') . $search, '$order' => '', '$file' => '', '$cats' => '', '$tags' => '', '$mid' => '', '$verb' => '', '$dend' => '', '$dbegin' => ''));
}
$pub_sql = public_permissions_sql($observer_hash);
require_once 'include/identity.php';
$sys = get_sys_channel();
if ($update && $load) {
$itemspage = get_pconfig(local_channel(), 'system', 'itemspage');
$a->set_pager_itemspage(intval($itemspage) ? $itemspage : 20);
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($a->pager['itemspage']), intval($a->pager['start']));
// in case somebody turned off public access to sys channel content with permissions
if (!perm_is_allowed($sys['channel_id'], $observer_hash, 'view_stream')) {
$sys['xchan_hash'] .= 'disabled';
}
if ($load) {
$r = null;
if (ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
$prefix = 'distinct on (created, mid)';
$suffix = 'ORDER BY created DESC, mid';
} else {
$prefix = 'distinct';
$suffix = 'group by mid ORDER BY created DESC';
}
if (local_channel()) {
$r = q("SELECT {$prefix} mid, item.id as item_id, item.* from item\n\t\t\t\t\tWHERE item_restrict = 0\n\t\t\t\t\tAND ((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 ) \n\t\t\t\t\tOR ( `item`.`uid` = %d )) OR item.owner_xchan = '%s' )\n\t\t\t\t\t{$sql_extra}\n\t\t\t\t\t{$suffix} {$pager_sql} ", intval(local_channel()), dbesc($sys['xchan_hash']));
}
if ($r === null) {
$r = q("SELECT {$prefix} mid, item.id as item_id, item.* from item\n\t\t\t\t\tWHERE item_restrict = 0\n\t\t\t\t\tAND (((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = ''\n\t\t\t\t\tAND `item`.`deny_gid` = '' AND item_private = 0 )\n\t\t\t\t\tand owner_xchan in ( " . stream_perms_xchans($observer ? PERMS_NETWORK | PERMS_PUBLIC : PERMS_PUBLIC) . " ))\n\t\t\t\t\t\t{$pub_sql} ) OR owner_xchan = '%s')\n\t\t\t\t\t{$sql_extra} \n\t\t\t\t\t{$suffix} {$pager_sql}", dbesc($sys['xchan_hash']));
}
} else {
$r = array();
}
}
if ($r) {
xchan_query($r);
$items = fetch_post_tags($r, true);
} else {
$items = array();
}
if ($format == 'json') {
$result = array();
require_once 'include/conversation.php';
foreach ($items as $item) {
$item['html'] = bbcode($item['body']);
$x = encode_item($item);
$x['html'] = prepare_text($item['body'], $item['mimetype']);
$result[] = $x;
}
json_return_and_die(array('success' => true, 'messages' => $result));
}
if ($tag) {
$o .= '<h2>Items tagged with: ' . htmlspecialchars($search, ENT_COMPAT, 'UTF-8') . '</h2>';
} else {
$o .= '<h2>Search results for: ' . htmlspecialchars($search, ENT_COMPAT, 'UTF-8') . '</h2>';
}
$o .= conversation($a, $items, 'search', $update, 'client');
return $o;
}