本文整理匯總了PHP中json_decode_plus函數的典型用法代碼示例。如果您正苦於以下問題:PHP json_decode_plus函數的具體用法?PHP json_decode_plus怎麽用?PHP json_decode_plus使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了json_decode_plus函數的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: get
function get()
{
$o = '';
if (!local_channel()) {
notice(t('Permission denied.') . EOL);
return;
}
$post_id = argc() > 1 ? intval(argv(1)) : 0;
if (!$post_id) {
notice(t('Item not found') . EOL);
return;
}
$itm = q("SELECT * FROM `item` WHERE `id` = %d AND ( owner_xchan = '%s' OR author_xchan = '%s' ) LIMIT 1", intval($post_id), dbesc(get_observer_hash()), dbesc(get_observer_hash()));
if (!count($itm)) {
notice(t('Item is not editable') . EOL);
return;
}
if ($itm[0]['resource_type'] === 'event' && $itm[0]['resource_id']) {
goaway(z_root() . '/events/' . $itm[0]['resource_id'] . '?expandform=1');
}
$owner_uid = $itm[0]['uid'];
$channel = \App::get_channel();
if (intval($itm[0]['item_obscured'])) {
$key = get_config('system', 'prvkey');
if ($itm[0]['title']) {
$itm[0]['title'] = crypto_unencapsulate(json_decode_plus($itm[0]['title']), $key);
}
if ($itm[0]['body']) {
$itm[0]['body'] = crypto_unencapsulate(json_decode_plus($itm[0]['body']), $key);
}
}
$category = '';
$catsenabled = feature_enabled($owner_uid, 'categories') ? 'categories' : '';
if ($catsenabled) {
$itm = fetch_post_tags($itm);
$cats = get_terms_oftype($itm[0]['term'], TERM_CATEGORY);
foreach ($cats as $cat) {
if (strlen($category)) {
$category .= ', ';
}
$category .= $cat['term'];
}
}
if ($itm[0]['attach']) {
$j = json_decode($itm[0]['attach'], true);
if ($j) {
foreach ($j as $jj) {
$itm[0]['body'] .= "\n" . '[attachment]' . basename($jj['href']) . ',' . $jj['revision'] . '[/attachment]' . "\n";
}
}
}
$x = array('nickname' => $channel['channel_address'], 'editor_autocomplete' => true, 'bbco_autocomplete' => 'bbcode', 'return_path' => $_SESSION['return_url'], 'button' => t('Edit'), 'hide_voting' => true, 'hide_future' => true, 'hide_location' => true, 'mimetype' => $itm[0]['mimetype'], 'ptyp' => $itm[0]['obj_type'], 'body' => undo_post_tagging($itm[0]['body']), 'post_id' => $post_id, 'defloc' => $channel['channel_location'], 'visitor' => true, 'title' => htmlspecialchars($itm[0]['title'], ENT_COMPAT, 'UTF-8'), 'category' => $category, 'showacl' => false, 'profile_uid' => $owner_uid, 'catsenabled' => $catsenabled, 'hide_expire' => true, 'bbcode' => true);
$editor = status_editor($a, $x);
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array('$title' => t('Edit post'), '$editor' => $editor));
return $o;
}
示例2: remove_community_tag
/**
* @brief
*
* @param array $sender an associative array with
* * \e string \b hash a xchan_hash
* @param array $arr an associative array
* * \e int \b verb
* * \e int \b obj_type
* * \e int \b mid
* @param int $uid
*/
function remove_community_tag($sender, $arr, $uid)
{
if (!(activity_match($arr['verb'], ACTIVITY_TAG) && $arr['obj_type'] == ACTIVITY_OBJ_TAGTERM)) {
return;
}
logger('remove_community_tag: invoked');
if (!get_pconfig($uid, 'system', 'blocktags')) {
logger('remove_community tag: permission denied.');
return;
}
$r = q("select * from item where mid = '%s' and uid = %d limit 1", dbesc($arr['mid']), intval($uid));
if (!$r) {
logger('remove_community_tag: no item');
return;
}
if ($sender['hash'] != $r[0]['owner_xchan'] && $sender['hash'] != $r[0]['author_xchan']) {
logger('remove_community_tag: sender not authorised.');
return;
}
$i = $r[0];
if ($i['target']) {
$i['target'] = json_decode_plus($i['target']);
}
if ($i['object']) {
$i['object'] = json_decode_plus($i['object']);
}
if (!($i['target'] && $i['object'])) {
logger('remove_community_tag: no target/object');
return;
}
$message_id = $i['target']['id'];
$r = q("select id from item where mid = '%s' and uid = %d limit 1", dbesc($message_id), intval($uid));
if (!$r) {
logger('remove_community_tag: no parent message');
return;
}
q("delete from term where uid = %d and oid = %d and otype = %d and type = %d and term = '%s' and url = '%s'", intval($uid), intval($r[0]['id']), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), dbesc($i['object']['title']), dbesc(get_rel_link($i['object']['link'], 'alternate')));
}
示例3: tag_deliver
/**
* @brief Called when we deliver things that might be tagged in ways that require delivery processing.
*
* Handles community tagging of posts and also look for mention tags and sets up
* a second delivery chain if appropriate.
*
* @param int $uid
* @param int $item_id
*/
function tag_deliver($uid, $item_id)
{
$mention = false;
/*
* Fetch stuff we need - a channel and an item
*/
$u = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d limit 1", intval($uid));
if (!$u) {
return;
}
$i = q("select * from item where id = %d and uid = %d limit 1", intval($item_id), intval($uid));
if (!$i) {
return;
}
$i = fetch_post_tags($i);
$item = $i[0];
if ($item['source_xchan'] && $item['item_flags'] & ITEM_UPLINK && $item['item_flags'] & ITEM_THREAD_TOP && $item['edited'] != $item['created']) {
// this is an update (edit) to a post which was already processed by us and has a second delivery chain
// Just start the second delivery chain to deliver the updated post
proc_run('php', 'include/notifier.php', 'tgroup', $item['id']);
return;
}
/*
* Seems like a good place to plug in a poke notification.
*/
if (stristr($item['verb'], ACTIVITY_POKE)) {
$poke_notify = true;
if ($item['obj_type'] == "" || $item['obj_type'] !== ACTIVITY_OBJ_PERSON || !$item['object']) {
$poke_notify = false;
}
$obj = json_decode_plus($item['object']);
if ($obj) {
if ($obj['id'] !== $u[0]['channel_hash']) {
$poke_notify = false;
}
}
if ($item['item_restrict'] & ITEM_DELETED) {
$poke_notify = false;
}
$verb = urldecode(substr($item['verb'], strpos($item['verb'], '#') + 1));
if ($poke_notify) {
require_once 'include/enotify.php';
notification(array('to_xchan' => $u[0]['channel_hash'], 'from_xchan' => $item['author_xchan'], 'type' => NOTIFY_POKE, 'item' => $item, 'link' => $i[0]['llink'], 'verb' => ACTIVITY_POKE, 'activity' => $verb, 'otype' => 'item'));
}
}
/*
* Do community tagging
*/
if ($item['obj_type'] === ACTIVITY_OBJ_TAGTERM) {
// We received a community tag activity for a post.
// See if we are the owner of the parent item and have given permission to tag our posts.
// If so tag the parent post.
logger('tag_deliver: community tag activity received');
if ($item['owner_xchan'] === $u[0]['channel_hash'] && !get_pconfig($u[0]['channel_id'], 'system', 'blocktags')) {
logger('tag_deliver: community tag recipient: ' . $u[0]['channel_name']);
$j_tgt = json_decode_plus($item['target']);
if ($j_tgt && $j_tgt['id']) {
$p = q("select * from item where mid = '%s' and uid = %d limit 1", dbesc($j_tgt['id']), intval($u[0]['channel_id']));
if ($p) {
$j_obj = json_decode_plus($item['object']);
logger('tag_deliver: tag object: ' . print_r($j_obj, true), LOGGER_DATA);
if ($j_obj && $j_obj['id'] && $j_obj['title']) {
if (is_array($j_obj['link'])) {
$taglink = get_rel_link($j_obj['link'], 'alternate');
}
store_item_tag($u[0]['channel_id'], $p[0]['id'], TERM_OBJ_POST, TERM_HASHTAG, $j_obj['title'], $j_obj['id']);
$x = q("update item set edited = '%s', received = '%s', changed = '%s' where mid = '%s' and uid = %d", dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc($j_tgt['id']), intval($u[0]['channel_id']));
proc_run('php', 'include/notifier.php', 'edit_post', $p[0]['id']);
}
}
}
} else {
logger('tag_deliver: tag permission denied for ' . $u[0]['channel_address']);
}
}
/*
* A "union" is a message which our channel has sourced from another channel.
* This sets up a second delivery chain just like forum tags do.
* Find out if this is a source-able post.
*/
$union = check_item_source($uid, $item);
if ($union) {
logger('check_item_source returns true');
}
// This might be a followup (e.g. comment) by the original post author to a tagged forum
// If so setup a second delivery chain
if (!($item['item_flags'] & ITEM_THREAD_TOP)) {
$x = q("select * from item where id = parent and parent = %d and uid = %d limit 1", intval($item['parent']), intval($uid));
if ($x && $x[0]['item_flags'] & ITEM_UPLINK) {
start_delivery_chain($u[0], $item, $item_id, $x[0]);
}
//.........這裏部分代碼省略.........
示例4: localize_item
/**
* Render actions localized
*/
function localize_item(&$item)
{
if (activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) {
if (!$item['object']) {
return;
}
if ($item['item_flags'] & ITEM_THREAD_TOP) {
return;
}
$obj = json_decode_plus($item['object']);
if (!$obj && $item['object']) {
logger('localize_item: failed to decode object: ' . print_r($item['object'], true));
}
if ($obj['author'] && $obj['author']['link']) {
$author_link = get_rel_link($obj['author']['link'], 'alternate');
} else {
$author_link = '';
}
$author_name = $obj['author'] && $obj['author']['name'] ? $obj['author']['name'] : '';
$item_url = get_rel_link($obj['link'], 'alternate');
$Bphoto = '';
switch ($obj['type']) {
case ACTIVITY_OBJ_PHOTO:
$post_type = t('photo');
break;
case ACTIVITY_OBJ_EVENT:
$post_type = t('event');
break;
case ACTIVITY_OBJ_PERSON:
$post_type = t('channel');
$author_name = $obj['title'];
if ($obj['link']) {
$author_link = get_rel_link($obj['link'], 'alternate');
$Bphoto = get_rel_link($obj['link'], 'photo');
}
break;
case ACTIVITY_OBJ_THING:
$post_type = $obj['title'];
if ($obj['owner']) {
if (array_key_exists('name', $obj['owner'])) {
$obj['owner']['name'];
}
if (array_key_exists('link', $obj['owner'])) {
$author_link = get_rel_link($obj['owner']['link'], 'alternate');
}
}
if ($obj['link']) {
$Bphoto = get_rel_link($obj['link'], 'photo');
}
break;
case ACTIVITY_OBJ_NOTE:
default:
$post_type = t('status');
if ($obj['mid'] != $obj['parent_mid']) {
$post_type = t('comment');
}
break;
}
// If we couldn't parse something useful, don't bother translating.
// We need something better than zid here, probably magic_link(), but it needs writing
if ($author_link && $author_name && $item_url) {
$author = '[zrl=' . chanlink_url($item['author']['xchan_url']) . ']' . $item['author']['xchan_name'] . '[/zrl]';
$objauthor = '[zrl=' . chanlink_url($author_link) . ']' . $author_name . '[/zrl]';
$plink = '[zrl=' . zid($item_url) . ']' . $post_type . '[/zrl]';
if (activity_match($item['verb'], ACTIVITY_LIKE)) {
$bodyverb = t('%1$s likes %2$s\'s %3$s');
} elseif (activity_match($item['verb'], ACTIVITY_DISLIKE)) {
$bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
}
$item['body'] = $item['localize'] = sprintf($bodyverb, $author, $objauthor, $plink);
if ($Bphoto != "") {
$item['body'] .= "\n\n\n" . '[zrl=' . chanlink_url($author_link) . '][zmg=80x80]' . $Bphoto . '[/zmg][/zrl]';
}
} else {
logger('localize_item like failed: link ' . $author_link . ' name ' . $author_name . ' url ' . $item_url);
}
}
if (activity_match($item['verb'], ACTIVITY_FRIEND)) {
if ($item['obj_type'] == "" || $item['obj_type'] !== ACTIVITY_OBJ_PERSON) {
return;
}
$Aname = $item['author']['xchan_name'];
$Alink = $item['author']['xchan_url'];
$obj = json_decode_plus($item['object']);
$Blink = $Bphoto = '';
if ($obj['link']) {
$Blink = get_rel_link($obj['link'], 'alternate');
$Bphoto = get_rel_link($obj['link'], 'photo');
}
$Bname = $obj['title'];
$A = '[zrl=' . chanlink_url($Alink) . ']' . $Aname . '[/zrl]';
$B = '[zrl=' . chanlink_url($Blink) . ']' . $Bname . '[/zrl]';
if ($Bphoto != "") {
$Bphoto = '[zrl=' . chanlink_url($Blink) . '][zmg=80x80]' . $Bphoto . '[/zmg][/zrl]';
}
$item['body'] = $item['localize'] = sprintf(t('%1$s is now connected with %2$s'), $A, $B);
$item['body'] .= "\n\n\n" . $Bphoto;
//.........這裏部分代碼省略.........
示例5: theme_attachments
function theme_attachments(&$item)
{
$arr = json_decode_plus($item['attach']);
if (is_array($arr) && count($arr)) {
$attaches = array();
foreach ($arr as $r) {
$icon = getIconFromType($r['type']);
$label = $r['title'] ? urldecode(htmlspecialchars($r['title'], ENT_COMPAT, 'UTF-8')) : t('Unknown Attachment');
//some feeds provide an attachment where title an empty space
if ($label == ' ') {
$label = t('Unknown Attachment');
}
$title = t('Size') . ' ' . ($r['length'] ? userReadableSize($r['length']) : t('unknown'));
require_once 'include/identity.php';
if (is_foreigner($item['author_xchan'])) {
$url = $r['href'];
} else {
$url = z_root() . '/magic?f=&hash=' . $item['author_xchan'] . '&dest=' . $r['href'] . '/' . $r['revision'];
}
//$s .= '<a href="' . $url . '" title="' . $title . '" class="attachlink" >' . $icon . '</a>';
$attaches[] = array('label' => $label, 'url' => $url, 'icon' => $icon, 'title' => $title);
}
$s = replace_macros(get_markup_template('item_attach.tpl'), array('$attaches' => $attaches));
}
return $s;
}
示例6: private_messages_fetch_conversation
function private_messages_fetch_conversation($channel_id, $messageitem_id, $updateseen = false)
{
// find the parent_mid of the message being requested
$r = q("SELECT parent_mid from mail WHERE channel_id = %d and id = %d limit 1", intval($channel_id), intval($messageitem_id));
if (!$r) {
return array();
}
$messages = q("select * from mail where parent_mid = '%s' and channel_id = %d order by created asc", dbesc($r[0]['parent_mid']), intval($channel_id));
if (!$messages) {
return array();
}
$chans = array();
foreach ($messages as $rr) {
$s = "'" . dbesc(trim($rr['from_xchan'])) . "'";
if (!in_array($s, $chans)) {
$chans[] = $s;
}
$s = "'" . dbesc(trim($rr['to_xchan'])) . "'";
if (!in_array($s, $chans)) {
$chans[] = $s;
}
}
$c = q("select * from xchan where xchan_hash in (" . implode(',', $chans) . ")");
foreach ($messages as $k => $message) {
$messages[$k]['from'] = find_xchan_in_array($message['from_xchan'], $c);
$messages[$k]['to'] = find_xchan_in_array($message['to_xchan'], $c);
if ($messages[$k]['mail_flags'] & MAIL_OBSCURED) {
$key = get_config('system', 'prvkey');
if ($messages[$k]['title']) {
$messages[$k]['title'] = crypto_unencapsulate(json_decode_plus($messages[$k]['title']), $key);
}
if ($messages[$k]['body']) {
$messages[$k]['body'] = crypto_unencapsulate(json_decode_plus($messages[$k]['body']), $key);
}
}
}
if ($updateseen) {
$r = q("UPDATE `mail` SET mail_flags = (mail_flags ^ %d) where not (mail_flags & %d) and parent_mid = '%s' AND channel_id = %d", intval(MAIL_SEEN), intval(MAIL_SEEN), dbesc($r[0]['parent_mid']), intval($channel_id));
}
return $messages;
}
示例7: get
function get()
{
if (!\App::$profile) {
notice(t('Requested profile is not available.') . EOL);
\App::$error = 404;
return;
}
$which = argv(1);
$uid = local_channel();
$owner = 0;
$channel = null;
$observer = \App::get_observer();
$channel = \App::get_channel();
if (\App::$is_sys && is_site_admin()) {
$sys = get_sys_channel();
if ($sys && intval($sys['channel_id'])) {
$uid = $owner = intval($sys['channel_id']);
$channel = $sys;
$observer = $sys;
}
}
if (!$owner) {
// Figure out who the page owner is.
$r = q("select channel_id from channel where channel_address = '%s'", dbesc($which));
if ($r) {
$owner = intval($r[0]['channel_id']);
}
}
$ob_hash = $observer ? $observer['xchan_hash'] : '';
if (!perm_is_allowed($owner, $ob_hash, 'write_pages')) {
notice(t('Permission denied.') . EOL);
return;
}
$is_owner = $uid && $uid == $owner ? true : false;
$o = '';
// Figure out which post we're editing
$post_id = argc() > 2 ? intval(argv(2)) : 0;
if (!$post_id) {
notice(t('Item not found') . EOL);
return;
}
$ob_hash = $observer ? $observer['xchan_hash'] : '';
$perms = get_all_perms($owner, $ob_hash);
if (!$perms['write_pages']) {
notice(t('Permission denied.') . EOL);
return;
}
// We've already figured out which item we want and whose copy we need,
// so we don't need anything fancy here
$sql_extra = item_permissions_sql($owner);
$itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s {$sql_extra} LIMIT 1", intval($post_id), intval($owner));
if (!$itm) {
notice(t('Permission denied.') . EOL);
return;
}
if (intval($itm[0]['item_obscured'])) {
$key = get_config('system', 'prvkey');
if ($itm[0]['title']) {
$itm[0]['title'] = crypto_unencapsulate(json_decode_plus($itm[0]['title']), $key);
}
if ($itm[0]['body']) {
$itm[0]['body'] = crypto_unencapsulate(json_decode_plus($itm[0]['body']), $key);
}
}
$item_id = q("select * from item_id where service = 'WEBPAGE' and iid = %d limit 1", intval($itm[0]['id']));
if ($item_id) {
$page_title = $item_id[0]['sid'];
}
$mimetype = $itm[0]['mimetype'];
if ($mimetype === 'application/x-php') {
if (!$uid || $uid != $itm[0]['uid']) {
notice(t('Permission denied.') . EOL);
return;
}
}
$layout = $itm[0]['layout_mid'];
$tpl = get_markup_template("jot.tpl");
$rp = 'webpages/' . $which;
$x = array('nickname' => $channel['channel_address'], 'bbco_autocomplete' => $mimetype == 'text/bbcode' ? 'bbcode' : '', 'return_path' => $rp, 'webpage' => ITEM_TYPE_WEBPAGE, 'ptlabel' => t('Page link'), 'pagetitle' => $page_title, 'writefiles' => $mimetype == 'text/bbcode' ? perm_is_allowed($owner, get_observer_hash(), 'write_storage') : false, 'button' => t('Edit'), 'weblink' => $mimetype == 'text/bbcode' ? t('Insert web link') : false, 'hide_location' => true, 'hide_voting' => true, 'ptyp' => $itm[0]['type'], 'body' => undo_post_tagging($itm[0]['body']), 'post_id' => $post_id, 'visitor' => $is_owner ? true : false, 'acl' => populate_acl($itm[0], false, \PermissionDescription::fromGlobalPermission('view_pages')), 'showacl' => $is_owner ? true : false, 'mimetype' => $mimetype, 'mimeselect' => true, 'layout' => $layout, 'layoutselect' => true, 'title' => htmlspecialchars($itm[0]['title'], ENT_COMPAT, 'UTF-8'), 'lockstate' => strlen($itm[0]['allow_cid']) || strlen($itm[0]['allow_gid']) || strlen($itm[0]['deny_cid']) || strlen($itm[0]['deny_gid']) ? 'lock' : 'unlock', 'profile_uid' => intval($owner), 'bbcode' => $mimetype == 'text/bbcode' ? true : false);
$editor = status_editor($a, $x);
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array('$title' => t('Edit Webpage'), '$delete' => $itm[0]['author_xchan'] === $ob_hash || $itm[0]['owner_xchan'] === $ob_hash ? t('Delete') : false, '$editor' => $editor, '$id' => $itm[0]['id']));
return $o;
}
示例8: editwebpage_content
function editwebpage_content(&$a)
{
if (!App::$profile) {
notice(t('Requested profile is not available.') . EOL);
App::$error = 404;
return;
}
$which = argv(1);
$uid = local_channel();
$owner = 0;
$channel = null;
$observer = App::get_observer();
$channel = App::get_channel();
if (App::$is_sys && is_site_admin()) {
$sys = get_sys_channel();
if ($sys && intval($sys['channel_id'])) {
$uid = $owner = intval($sys['channel_id']);
$channel = $sys;
$observer = $sys;
}
}
if (!$owner) {
// Figure out who the page owner is.
$r = q("select channel_id from channel where channel_address = '%s'", dbesc($which));
if ($r) {
$owner = intval($r[0]['channel_id']);
}
}
$ob_hash = $observer ? $observer['xchan_hash'] : '';
if (!perm_is_allowed($owner, $ob_hash, 'write_pages')) {
notice(t('Permission denied.') . EOL);
return;
}
$is_owner = $uid && $uid == $owner ? true : false;
$o = '';
// Figure out which post we're editing
$post_id = argc() > 2 ? intval(argv(2)) : 0;
if (!$post_id) {
notice(t('Item not found') . EOL);
return;
}
$ob_hash = $observer ? $observer['xchan_hash'] : '';
$perms = get_all_perms($owner, $ob_hash);
if (!$perms['write_pages']) {
notice(t('Permission denied.') . EOL);
return;
}
// We've already figured out which item we want and whose copy we need,
// so we don't need anything fancy here
$sql_extra = item_permissions_sql($owner);
$itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s {$sql_extra} LIMIT 1", intval($post_id), intval($owner));
if (!$itm) {
notice(t('Permission denied.') . EOL);
return;
}
if (intval($itm[0]['item_obscured'])) {
$key = get_config('system', 'prvkey');
if ($itm[0]['title']) {
$itm[0]['title'] = crypto_unencapsulate(json_decode_plus($itm[0]['title']), $key);
}
if ($itm[0]['body']) {
$itm[0]['body'] = crypto_unencapsulate(json_decode_plus($itm[0]['body']), $key);
}
}
$item_id = q("select * from item_id where service = 'WEBPAGE' and iid = %d limit 1", intval($itm[0]['id']));
if ($item_id) {
$page_title = $item_id[0]['sid'];
}
$plaintext = true;
$mimetype = $itm[0]['mimetype'];
if ($mimetype === 'application/x-php') {
if (!$uid || $uid != $itm[0]['uid']) {
notice(t('Permission denied.') . EOL);
return;
}
}
$mimeselect = '';
if ($mimetype != 'text/bbcode') {
$plaintext = true;
}
if (get_config('system', 'page_mimetype')) {
$mimeselect = '<input type="hidden" name="mimetype" value="' . $mimetype . '" />';
} else {
$mimeselect = mimetype_select($itm[0]['uid'], $mimetype);
}
$layout = get_config('system', 'page_layout');
if ($layout) {
$layoutselect = '<input type="hidden" name="layout_mid" value="' . $layout . '" />';
} else {
$layoutselect = layout_select($itm[0]['uid'], $itm[0]['layout_mid']);
}
App::$page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array('$baseurl' => z_root(), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$pretext' => '', '$ispublic' => ' ', '$geotag' => $geotag, '$nickname' => $channel['channel_address'], '$confirmdelete' => t('Delete webpage?'), '$bbco_autocomplete' => $mimetype == 'text/bbcode' ? 'bbcode' : ''));
$tpl = get_markup_template("jot.tpl");
$jotplugins = '';
$jotnets = '';
call_hooks('jot_tool', $jotplugins);
call_hooks('jot_networks', $jotnets);
// FIXME A return path with $_SESSION doesn't always work for observer - it may WSoD
// instead of loading a sensible page. So, send folk to the webpage list.
$rp = 'webpages/' . $which;
//.........這裏部分代碼省略.........
示例9: diaspora_send_mail
function diaspora_send_mail($item, $owner, $contact)
{
$a = get_app();
$myaddr = $owner['channel_address'] . '@' . get_app()->get_hostname();
$r = q("select * from conv where id = %d and uid = %d limit 1", intval($item['convid']), intval($item['channel_id']));
if (!count($r)) {
logger('diaspora_send_mail: conversation not found.');
return;
}
$cnv = $r[0];
$conv = array('guid' => xmlify($cnv['guid']), 'subject' => xmlify($cnv['subject']), 'created_at' => xmlify(datetime_convert('UTC', 'UTC', $cnv['created'], 'Y-m-d H:i:s \\U\\T\\C')), 'diaspora_handle' => xmlify($cnv['creator']), 'participant_handles' => xmlify($cnv['recips']));
if (array_key_exists('mail_flags', $item) && $item['mail_flags'] & MAIL_OBSCURED) {
$key = get_config('system', 'prvkey');
// if($item['title'])
// $item['title'] = crypto_unencapsulate(json_decode_plus($item['title']),$key);
if ($item['body']) {
$item['body'] = crypto_unencapsulate(json_decode_plus($item['body']), $key);
}
}
$body = bb2diaspora($item['body']);
$created = datetime_convert('UTC', 'UTC', $item['created'], 'Y-m-d H:i:s \\U\\T\\C');
$signed_text = $item['mid'] . ';' . $cnv['guid'] . ';' . $body . ';' . $created . ';' . $myaddr . ';' . $cnv['guid'];
$sig = base64_encode(rsa_sign($signed_text, $owner['channel_prvkey'], 'sha256'));
$msg = array('guid' => xmlify($item['mid']), 'parent_guid' => xmlify($cnv['guid']), 'parent_author_signature' => $item['reply'] ? null : xmlify($sig), 'author_signature' => xmlify($sig), 'text' => xmlify($body), 'created_at' => xmlify($created), 'diaspora_handle' => xmlify($myaddr), 'conversation_guid' => xmlify($cnv['guid']));
if ($item['reply']) {
$tpl = get_markup_template('diaspora_message.tpl');
$xmsg = replace_macros($tpl, array('$msg' => $msg));
} else {
$conv['messages'] = array($msg);
$tpl = get_markup_template('diaspora_conversation.tpl');
$xmsg = replace_macros($tpl, array('$conv' => $conv));
}
logger('diaspora_conversation: ' . print_r($xmsg, true), LOGGER_DATA);
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($xmsg, $owner, $contact, $owner['channel_prvkey'], $contact['xchan_pubkey'], false)));
return diaspora_transmit($owner, $contact, $slap, false);
}
示例10: theme_attachments
function theme_attachments(&$item)
{
$arr = json_decode_plus($item['attach']);
if (is_array($arr) && count($arr)) {
$attaches = array();
foreach ($arr as $r) {
$icon = '';
$icontype = substr($r['type'], 0, strpos($r['type'], '/'));
/**
* @FIXME This should probably be a giant "if" statement in the
* template so that we don't have icon names embedded in php code.
*/
switch ($icontype) {
case 'video':
$icon = 'icon-facetime-video';
break;
case 'audio':
$icon = 'icon-volume-up';
break;
case 'image':
$icon = 'icon-picture';
break;
case 'text':
$icon = 'icon-align-justify';
break;
default:
$icon = 'icon-question';
break;
}
$title = htmlspecialchars($r['title'], ENT_COMPAT, 'UTF-8');
if (!$title) {
$title = t('unknown.???');
}
$title .= ' ' . $r['length'] . ' ' . t('bytes');
require_once 'include/identity.php';
if (is_foreigner($item['author_xchan'])) {
$url = $r['href'];
} else {
$url = z_root() . '/magic?f=&hash=' . $item['author_xchan'] . '&dest=' . $r['href'] . '/' . $r['revision'];
}
$s .= '<a href="' . $url . '" title="' . $title . '" class="attachlink" >' . $icon . '</a>';
$attaches[] = array('title' => $title, 'url' => $url, 'icon' => $icon);
}
}
$s = replace_macros(get_markup_template('item_attach.tpl'), array('$attaches' => $attaches));
return $s;
}
示例11: editwebpage_content
function editwebpage_content(&$a)
{
// We first need to figure out who owns the webpage, grab it from an argument
$which = argv(1);
// $a->get_channel() and stuff don't work here, so we've got to find the owner for ourselves.
$r = q("select channel_id from channel where channel_address = '%s'", dbesc($which));
if ($r) {
$owner = intval($r[0]['channel_id']);
//logger('owner: ' . print_r($owner,true));
}
$is_owner = local_user() && local_user() == $owner ? true : false;
$o = '';
// Figure out which post we're editing
$post_id = argc() > 2 ? intval(argv(2)) : 0;
if (!$post_id) {
notice(t('Item not found') . EOL);
return;
}
// Now we've got a post and an owner, let's find out if we're allowed to edit it
$observer = $a->get_observer();
$ob_hash = $observer ? $observer['xchan_hash'] : '';
$perms = get_all_perms($owner, $ob_hash);
if (!$perms['write_pages']) {
notice(t('Permission denied.') . EOL);
return;
}
// We've already figured out which item we want and whose copy we need, so we don't need anything fancy here
$itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s LIMIT 1", intval($post_id), intval($owner));
if ($itm[0]['item_flags'] & ITEM_OBSCURED) {
$key = get_config('system', 'prvkey');
if ($itm[0]['title']) {
$itm[0]['title'] = crypto_unencapsulate(json_decode_plus($itm[0]['title']), $key);
}
if ($itm[0]['body']) {
$itm[0]['body'] = crypto_unencapsulate(json_decode_plus($itm[0]['body']), $key);
}
}
$item_id = q("select * from item_id where service = 'WEBPAGE' and iid = %d limit 1", $itm[0]['id']);
if ($item_id) {
$page_title = $item_id[0]['sid'];
}
$plaintext = true;
// if(feature_enabled($itm[0]['uid'],'richtext'))
// $plaintext = false;
$mimetype = $itm[0]['mimetype'];
if ($mimetype === 'application/x-php') {
if (!local_user() || local_user() != $itm[0]['uid']) {
notice(t('Permission denied.') . EOL);
return;
}
}
$mimeselect = '';
if ($mimetype != 'text/bbcode') {
$plaintext = true;
}
if (get_config('system', 'page_mimetype')) {
$mimeselect = '<input type="hidden" name="mimetype" value="' . $mimetype . '" />';
} else {
$mimeselect = mimetype_select($itm[0]['uid'], $mimetype);
}
$layout = get_config('system', 'page_layout');
if ($layout) {
$layoutselect = '<input type="hidden" name="layout_mid" value="' . $layout . '" />';
} else {
$layoutselect = layout_select($itm[0]['uid'], $itm[0]['layout_mid']);
}
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array('$title' => t('Edit Webpage')));
$a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array('$baseurl' => $a->get_baseurl(), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$ispublic' => ' ', '$geotag' => $geotag, '$nickname' => $a->user['nickname'], '$confirmdelete' => t('Delete webpage?')));
$tpl = get_markup_template("jot.tpl");
$jotplugins = '';
$jotnets = '';
call_hooks('jot_tool', $jotplugins);
call_hooks('jot_networks', $jotnets);
$channel = $a->get_channel();
//$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
//FIXME A return path with $_SESSION doesn't always work for observer - it may WSoD instead of loading a sensible page. So, send folk to the webpage list.
$rp = 'webpages/' . $which;
$o .= replace_macros($tpl, array('$return_path' => $rp, '$webpage' => ITEM_WEBPAGE, '$placeholdpagetitle' => t('Page link title'), '$pagetitle' => $page_title, '$action' => 'item', '$share' => t('Edit'), '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$weblink' => t('Insert web link'), '$youtube' => t('Insert YouTube video'), '$video' => t('Insert Vorbis [.ogg] video'), '$audio' => t('Insert Vorbis [.ogg] audio'), '$setloc' => t('Set your location'), '$noloc' => t('Clear browser location'), '$wait' => t('Please wait'), '$permset' => t('Permission settings'), '$ptyp' => $itm[0]['type'], '$content' => undo_post_tagging($itm[0]['body']), '$post_id' => $post_id, '$baseurl' => $a->get_baseurl(), '$defloc' => $itm[0]['location'], '$visitor' => $is_owner ? true : false, '$acl' => populate_acl($itm[0], false), '$showacl' => $is_owner ? true : false, '$public' => t('Public post'), '$jotnets' => $jotnets, '$mimeselect' => $mimeselect, '$layoutselect' => $layoutselect, '$title' => htmlspecialchars($itm[0]['title'], ENT_COMPAT, 'UTF-8'), '$placeholdertitle' => t('Set title'), '$category' => '', '$placeholdercategory' => t('Categories (comma-separated list)'), '$emtitle' => t('Example: bob@example.com, mary@example.com'), 'lockstate' => strlen($itm[0]['allow_cid']) || strlen($itm[0]['allow_gid']) || strlen($itm[0]['deny_cid']) || strlen($itm[0]['deny_gid']) ? 'lock' : 'unlock', '$bang' => '', '$profile_uid' => intval($owner), '$preview' => feature_enabled(local_user(), 'preview') ? t('Preview') : '', '$jotplugins' => $jotplugins, '$sourceapp' => t($a->sourcename), '$defexpire' => '', '$feature_expire' => false, '$expires' => t('Set expiration date')));
$ob = get_observer_hash();
if ($itm[0]['author_xchan'] === $ob || $itm[0]['owner_xchan'] === $ob) {
$o .= '<br /><br /><a class="page-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Webpage') . '</a><br />';
}
return $o;
}
示例12: editpost_content
function editpost_content(&$a)
{
$o = '';
if (!local_channel()) {
notice(t('Permission denied.') . EOL);
return;
}
$post_id = argc() > 1 ? intval(argv(1)) : 0;
if (!$post_id) {
notice(t('Item not found') . EOL);
return;
}
$itm = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d and author_xchan = '%s' LIMIT 1", intval($post_id), intval(local_channel()), dbesc(get_observer_hash()));
if (!count($itm)) {
notice(t('Item is not editable') . EOL);
return;
}
$plaintext = true;
// if(feature_enabled(local_channel(),'richtext'))
// $plaintext = false;
$channel = $a->get_channel();
$a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array('$baseurl' => $a->get_baseurl(), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$ispublic' => ' ', '$geotag' => $geotag, '$nickname' => $channel['channel_address'], '$expireswhen' => t('Expires YYYY-MM-DD HH:MM'), '$confirmdelete' => t('Delete item?')));
if ($itm[0]['item_flags'] & ITEM_OBSCURED) {
$key = get_config('system', 'prvkey');
if ($itm[0]['title']) {
$itm[0]['title'] = crypto_unencapsulate(json_decode_plus($itm[0]['title']), $key);
}
if ($itm[0]['body']) {
$itm[0]['body'] = crypto_unencapsulate(json_decode_plus($itm[0]['body']), $key);
}
}
$tpl = get_markup_template("jot.tpl");
$jotplugins = '';
$jotnets = '';
call_hooks('jot_tool', $jotplugins);
call_hooks('jot_networks', $jotnets);
$channel = $a->get_channel();
//$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
$voting = feature_enabled(local_channel(), 'consensus_tools');
$category = '';
$catsenabled = feature_enabled(local_channel(), 'categories') ? 'categories' : '';
if ($catsenabled) {
$itm = fetch_post_tags($itm);
$cats = get_terms_oftype($itm[0]['term'], TERM_CATEGORY);
foreach ($cats as $cat) {
if (strlen($category)) {
$category .= ', ';
}
$category .= $cat['term'];
}
}
if ($itm[0]['attach']) {
$j = json_decode($itm[0]['attach'], true);
if ($j) {
foreach ($j as $jj) {
$itm[0]['body'] .= "\n" . '[attachment]' . basename($jj['href']) . ',' . $jj['revision'] . '[/attachment]' . "\n";
}
}
}
$cipher = get_pconfig(get_app()->profile['profile_uid'], 'system', 'default_cipher');
if (!$cipher) {
$cipher = 'aes256';
}
$editor = replace_macros($tpl, array('$return_path' => $_SESSION['return_url'], '$action' => 'item', '$share' => t('Edit'), '$bold' => t('Bold'), '$italic' => t('Italic'), '$underline' => t('Underline'), '$quote' => t('Quote'), '$code' => t('Code'), '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$weblink' => t('Insert web link'), '$youtube' => t('Insert YouTube video'), '$video' => t('Insert Vorbis [.ogg] video'), '$audio' => t('Insert Vorbis [.ogg] audio'), '$setloc' => t('Set your location'), '$noloc' => t('Clear browser location'), '$voting' => t('Toggle voting'), '$feature_voting' => $voting, '$consensus' => $itm[0]['item_flags'] & ITEM_CONSENSUS ? 1 : 0, '$wait' => t('Please wait'), '$permset' => t('Permission settings'), '$ptyp' => $itm[0]['type'], '$content' => undo_post_tagging($itm[0]['body']), '$post_id' => $post_id, '$parent' => $itm[0]['parent'] != $itm[0]['id'] ? $itm[0]['parent'] : '', '$baseurl' => $a->get_baseurl(), '$defloc' => $channel['channel_location'], '$visitor' => false, '$public' => t('Public post'), '$jotnets' => $jotnets, '$title' => htmlspecialchars($itm[0]['title'], ENT_COMPAT, 'UTF-8'), '$placeholdertitle' => t('Title (optional)'), '$category' => $category, '$placeholdercategory' => t('Categories (optional, comma-separated list)'), '$emtitle' => t('Example: bob@example.com, mary@example.com'), '$lockstate' => $lockstate, '$acl' => '', '$bang' => '', '$profile_uid' => local_channel(), '$preview' => t('Preview'), '$jotplugins' => $jotplugins, '$sourceapp' => t($a->sourcename), '$catsenabled' => $catsenabled, '$defexpire' => datetime_convert('UTC', date_default_timezone_get(), $itm[0]['expires']), '$feature_expire' => feature_enabled(get_app()->profile['profile_uid'], 'content_expire') && !$webpage ? true : false, '$expires' => t('Set expiration date'), '$feature_encrypt' => feature_enabled(get_app()->profile['profile_uid'], 'content_encrypt') && !$webpage ? true : false, '$encrypt' => t('Encrypt text'), '$cipher' => $cipher, '$expiryModalOK' => t('OK'), '$expiryModalCANCEL' => t('Cancel')));
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array('$title' => t('Edit post'), '$editor' => $editor));
return $o;
}