本文整理汇总了PHP中local_channel函数的典型用法代码示例。如果您正苦于以下问题:PHP local_channel函数的具体用法?PHP local_channel怎么用?PHP local_channel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了local_channel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search_ac_init
function search_ac_init(&$a)
{
if (!local_channel()) {
killme();
}
$start = x($_REQUEST, 'start') ? $_REQUEST['start'] : 0;
$count = x($_REQUEST, 'count') ? $_REQUEST['count'] : 100;
$search = x($_REQUEST, 'search') ? $_REQUEST['search'] : "";
if (x($_REQUEST, 'query') && strlen($_REQUEST['query'])) {
$search = $_REQUEST['query'];
}
// Priority to people searches
if ($search) {
$people_sql_extra = protect_sprintf(" AND `xchan_name` LIKE '%" . dbesc($search) . "%' ");
$tag_sql_extra = protect_sprintf(" AND term LIKE '%" . dbesc($search) . "%' ");
}
$r = q("SELECT `abook_id`, `xchan_name`, `xchan_photo_s`, `xchan_url`, `xchan_addr` FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d \n\t\t{$people_sql_extra}\n\t\tORDER BY `xchan_name` ASC ", intval(local_channel()));
$results = array();
if ($r) {
foreach ($r as $g) {
$results[] = array("photo" => $g['xchan_photo_s'], "name" => '@' . $g['xchan_name'], "id" => $g['abook_id'], "link" => $g['xchan_url'], "label" => '', "nick" => '');
}
}
$r = q("select distinct term, tid, url from term where type in ( %d, %d ) {$tag_sql_extra} group by term order by term asc", intval(TERM_HASHTAG), intval(TERM_COMMUNITYTAG));
if (count($r)) {
foreach ($r as $g) {
$results[] = array("photo" => $a->get_baseurl() . '/images/hashtag.png', "name" => '#' . $g['term'], "id" => $g['tid'], "link" => $g['url'], "label" => '', "nick" => '');
}
}
header("content-type: application/json");
$o = array('start' => $start, 'count' => $count, 'items' => $results);
echo json_encode($o);
logger('search_ac: ' . print_r($x, true));
killme();
}
示例2: get
function get()
{
if (!local_channel()) {
return;
}
$postid = $_REQUEST['postid'];
if (!$postid) {
return;
}
$emoji = $_REQUEST['emoji'];
if ($_REQUEST['emoji']) {
$i = q("select * from item where id = %d and uid = %d", intval($postid), intval(local_channel()));
if (!$i) {
return;
}
$channel = \App::get_channel();
$n = array();
$n['aid'] = $channel['channel_account_id'];
$n['uid'] = $channel['channel_id'];
$n['item_origin'] = true;
$n['parent'] = $postid;
$n['parent_mid'] = $i[0]['mid'];
$n['mid'] = item_message_id();
$n['verb'] = ACTIVITY_REACT . '#' . $emoji;
$n['body'] = "\n\n[zmg=32x32]" . z_root() . '/images/emoji/' . $emoji . '.png[/zmg]' . "\n\n";
$n['author_xchan'] = $channel['channel_hash'];
$x = item_store($n);
if ($x['success']) {
$nid = $x['item_id'];
\Zotlabs\Daemon\Master::Summon(array('Notifier', 'like', $nid));
}
}
}
示例3: get
function get()
{
require_once 'include/acl_selectors.php';
if (!local_channel()) {
notice(t('Permission denied.') . EOL);
return;
}
if (\App::$argc != 2) {
return;
}
$contact_id = intval(\App::$argv[1]);
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), intval(local_channel()));
if (!count($r)) {
notice(t('Contact not found.') . EOL);
return;
}
$contact = $r[0];
$o = '<h3>' . t('Suggest Friends') . '</h3>';
$o .= '<div id="fsuggest-desc" >' . sprintf(t('Suggest a friend for %s'), $contact['name']) . '</div>';
$o .= '<form id="fsuggest-form" action="fsuggest/' . $contact_id . '" method="post" >';
// FIXME contact_selector deprecated, removed
// $o .= contact_selector('suggest','suggest-select', false,
// array('size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true));
$o .= '<div id="fsuggest-submit-wrapper"><input id="fsuggest-submit" type="submit" name="submit" value="' . t('Submit') . '" /></div>';
$o .= '</form>';
return $o;
}
示例4: dwpost_post_local
function dwpost_post_local(&$a, &$b)
{
// This can probably be changed to allow editing by pointing to a different API endpoint
if ($b['edit']) {
return;
}
if (!local_channel() || local_channel() != $b['uid']) {
return;
}
if ($b['item_private'] || $b['parent']) {
return;
}
logger('Dreamwidth xpost invoked');
$dw_post = intval(get_pconfig(local_channel(), 'dwpost', 'post'));
$dw_enable = $dw_post && x($_REQUEST, 'dwpost_enable') ? intval($_REQUEST['dwpost_enable']) : 0;
if ($_REQUEST['api_source'] && intval(get_pconfig(local_channel(), 'dwpost', 'post_by_default'))) {
$dw_enable = 1;
}
if (!$dw_enable) {
return;
}
if (strlen($b['postopts'])) {
$b['postopts'] .= ',';
}
$b['postopts'] .= 'dwpost';
}
示例5: filer_content
function filer_content(&$a)
{
if (!local_channel()) {
killme();
}
$term = unxmlify(trim($_GET['term']));
$item_id = $a->argc > 1 ? intval($a->argv[1]) : 0;
logger('filer: tag ' . $term . ' item ' . $item_id);
if ($item_id && strlen($term)) {
// file item
store_item_tag(local_channel(), $item_id, TERM_OBJ_POST, TERM_FILE, $term, '');
// protect the entire conversation from periodic expiration
$r = q("select parent from item where id = %d and uid = %d limit 1", intval($item_id), intval(local_channel()));
if ($r) {
$x = q("update item set item_retained = 1 where id = %d and uid = %d", intval($r[0]['parent']), intval(local_channel()));
}
} else {
$filetags = array();
$r = q("select distinct(term) from term where uid = %d and type = %d order by term asc", intval(local_channel()), intval(TERM_FILE));
if (count($r)) {
foreach ($r as $rr) {
$filetags[] = $rr['term'];
}
}
$tpl = get_markup_template("filer_dialog.tpl");
$o = replace_macros($tpl, array('$field' => array('term', t("Save to Folder:"), '', '', $filetags, t('- select -')), '$submit' => t('Save')));
echo $o;
}
killme();
}
示例6: bookmarks_content
function bookmarks_content(&$a)
{
if (!local_channel()) {
notice(t('Permission denied.') . EOL);
return;
}
require_once 'include/menu.php';
require_once 'include/conversation.php';
$channel = App::get_channel();
$o = profile_tabs($a, true, $channel['channel_address']);
$o .= '<div class="generic-content-wrapper-styled">';
$o .= '<h3>' . t('My Bookmarks') . '</h3>';
$x = menu_list(local_channel(), '', MENU_BOOKMARK);
if ($x) {
foreach ($x as $xx) {
$y = menu_fetch($xx['menu_name'], local_channel(), get_observer_hash());
$o .= menu_render($y, '', true);
}
}
$o .= '<h3>' . t('My Connections Bookmarks') . '</h3>';
$x = menu_list(local_channel(), '', MENU_SYSTEM | MENU_BOOKMARK);
if ($x) {
foreach ($x as $xx) {
$y = menu_fetch($xx['menu_name'], local_channel(), get_observer_hash());
$o .= menu_render($y, '', true);
}
}
$o .= '</div>';
return $o;
}
示例7: nofed_post_local
function nofed_post_local(&$a, &$b)
{
if ($b['created'] != $b['edited']) {
return;
}
if ($b['mid'] !== $b['parent_mid']) {
return;
}
if (local_channel() && local_channel() == $b['uid']) {
if ($b['allow_cid'] || $b['allow_gid'] || $b['deny_cid'] || $b['deny_gid']) {
return;
}
$nofed_post = get_pconfig(local_channel(), 'nofed', 'post');
if (!$nofed_post) {
return;
}
$nofed_enable = $nofed_post && x($_REQUEST, 'nofed_enable') ? intval($_REQUEST['nofed_enable']) : 0;
// if API is used, default to the chosen settings
if ($_REQUEST['api_source'] && intval(get_pconfig(local_channel(), 'nofed', 'post_by_default'))) {
$nofed_enable = 1;
}
if ($nofed_enable) {
return;
}
if (strlen($b['postopts'])) {
$b['postopts'] .= ',';
}
$b['postopts'] .= 'nodeliver';
}
}
示例8: likebanner_content
function likebanner_content(&$a)
{
if (local_channel()) {
$channel = $a->get_channel();
} else {
$channel = null;
}
$o = '<h1>Like Banner</h1>';
$def = $_REQUEST['addr'];
if ($channel && !$def) {
$def = $channel['xchan_addr'];
}
$o .= '<form action="likebanner" method="get" >';
$o .= t('Your Webbie:');
$o .= '<br /><br />';
$o .= '<input type="text" name="addr" size="32" value="' . $def . '" />';
$o .= '<br /><br />' . t('Fontsize (px):');
$o .= '<br /><br />';
$o .= '<input type="text" name="size" size="32" value="' . ($_REQUEST['size'] ? $_REQUEST['size'] : 28) . '" /><br /><br />';
$o .= '<input type="submit" name="submit" value="' . t('Submit') . '" /></form><br /><br/>';
if ($_REQUEST['addr']) {
$o .= '<img style="border: 1px solid #000;" src="likebanner/show/?f=&addr=' . urlencode($_REQUEST['addr']) . '&size=' . $_REQUEST['size'] . '" alt="banner" />';
if ($channel) {
$p = q("select profile_guid from profile where uid = %d and is_default = 1 limit 1", intval($channel['channel_id']));
if ($p) {
$link = z_root() . '/like/profile/' . $p[0]['profile_guid'] . '?f=&verb=like&interactive=1';
$o .= EOL . EOL . t('Link:') . EOL . '<input type="text" size="64" onclick="this.select();" value="' . $link . '" />';
$html = '<a href="' . $link . '" ><img src="' . z_root() . '/likebanner?f=&addr=' . $def . '&size=' . $_REQUEST['size'] . '" alt="' . t('Like us on RedMatrix') . '" /></a>';
$o .= EOL . EOL . t('Embed:') . EOL . '<input type="text" size="64" onclick="this.select();" value="' . htmlspecialchars($html, ENT_QUOTES, 'UTF-8') . '" />';
}
}
}
return $o;
}
示例9: login_content
function login_content(&$a)
{
if (local_channel()) {
goaway(z_root());
}
return login($a->config['system']['register_policy'] == REGISTER_CLOSED ? false : true);
}
示例10: get
function get()
{
if (!local_channel()) {
killme();
}
if (argc() > 2 && intval(argv(1)) && argv(2)) {
$r = q("SELECT abook_xchan from abook where abook_xchan = '%s' and abook_channel = %d and abook_self = 0 limit 1", dbesc(base64url_decode(argv(2))), intval(local_channel()));
if ($r) {
$change = $r[0]['abook_xchan'];
}
}
if (argc() > 1 && intval(argv(1))) {
$r = q("SELECT * FROM `groups` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1", intval(argv(1)), intval(local_channel()));
if (!$r) {
killme();
}
$group = $r[0];
$members = group_get_members($group['id']);
$preselected = array();
if (count($members)) {
foreach ($members as $member) {
$preselected[] = $member['xchan_hash'];
}
}
if ($change) {
if (in_array($change, $preselected)) {
group_rmv_member(local_channel(), $group['gname'], $change);
} else {
group_add_member(local_channel(), $group['gname'], $change);
}
}
}
killme();
}
示例11: viewsrc_content
function viewsrc_content(&$a)
{
$o = '';
$sys = get_sys_channel();
$item_id = argc() > 1 ? intval(argv(1)) : 0;
$json = argc() > 2 && argv(2) === 'json' ? true : false;
if (!local_channel()) {
notice(t('Permission denied.') . EOL);
}
if (!$item_id) {
App::$error = 404;
notice(t('Item not found.') . EOL);
}
$item_normal = item_normal();
if (local_channel() && $item_id) {
$r = q("select id, item_flags, item_obscured, body from item where uid in (%d , %d) and id = %d {$item_normal} limit 1", intval(local_channel()), intval($sys['channel_id']), intval($item_id));
if ($r) {
if (intval($r[0]['item_obscured'])) {
$r[0]['body'] = crypto_unencapsulate(json_decode($r[0]['body'], true), get_config('system', 'prvkey'));
}
$o = $json ? json_encode($r[0]['body']) : str_replace("\n", '<br />', $r[0]['body']);
}
}
if (is_ajax()) {
print '<div><i class="icon-pencil"> ' . t('Source of Item') . ' ' . $r[0]['id'] . '</i></div>';
echo $o;
killme();
}
return $o;
}
示例12: apps_content
function apps_content(&$a)
{
if (argc() == 2 && argv(1) == 'edit') {
$mode = 'edit';
} else {
$mode = 'list';
}
$_SESSION['return_url'] = $a->cmd;
$apps = array();
$syslist = get_system_apps();
if (local_channel()) {
$list = app_list(local_channel());
if ($list) {
foreach ($list as $x) {
$syslist[] = app_encode($x);
}
}
}
usort($syslist, 'app_name_compare');
// logger('apps: ' . print_r($syslist,true));
foreach ($syslist as $app) {
$apps[] = app_render($app, $mode);
}
return replace_macros(get_markup_template('myapps.tpl'), array('$sitename' => get_config('system', 'sitename'), '$title' => t('Apps'), '$apps' => $apps));
}
示例13: msgfooter_post_hook
function msgfooter_post_hook($a, &$item)
{
/**
*
* An item was posted on the local system.
* We are going to look for specific items:
* - A status post by a profile owner
* - The profile owner must have allowed our plugin
*
*/
logger('msgfooter invoked');
if (!local_channel()) {
/* non-zero if this is a logged in user of this system */
return;
}
if (local_channel() != $item['uid']) {
/* Does this person own the post? */
return;
}
if ($item['item_type']) {
return;
}
if ($item['parent']) {
/* If the item has a parent, this is a comment or something else, not a status post. */
return;
}
/* Retrieve our config setting */
$footer = get_config('msgfooter', 'msgfooter_text');
if (!$footer) {
return;
}
$item['body'] .= '[footer]' . $footer . '[/footer]';
return;
}
示例14: set_mode
/**
* Set the mode we'll be displayed on
*/
private function set_mode($mode)
{
if ($this->get_mode() == $mode) {
return;
}
$a = $this->get_app();
$this->observer = App::get_observer();
$ob_hash = $this->observer ? $this->observer['xchan_hash'] : '';
switch ($mode) {
case 'network':
$this->profile_owner = local_channel();
$this->writable = true;
break;
case 'channel':
$this->profile_owner = App::$profile['profile_uid'];
$this->writable = perm_is_allowed($this->profile_owner, $ob_hash, 'post_comments');
break;
case 'display':
// in this mode we set profile_owner after initialisation (from conversation()) and then
// pull some trickery which allows us to re-invoke this function afterward
// it's an ugly hack so FIXME
$this->writable = perm_is_allowed($this->profile_owner, $ob_hash, 'post_comments');
break;
case 'page':
$this->profile_owner = App::$profile['uid'];
$this->writable = perm_is_allowed($this->profile_owner, $ob_hash, 'post_comments');
break;
default:
logger('[ERROR] Conversation::set_mode : Unhandled mode (' . $mode . ').', LOGGER_DEBUG);
return false;
break;
}
$this->mode = $mode;
}
示例15: post
function post()
{
// logger('file upload: ' . print_r($_REQUEST,true));
$channel = $_REQUEST['channick'] ? get_channel_by_nick($_REQUEST['channick']) : null;
if (!$channel) {
logger('channel not found');
killme();
}
$_REQUEST['source'] = 'file_upload';
if ($channel['channel_id'] != local_channel()) {
$_REQUEST['contact_allow'] = expand_acl($channel['channel_allow_cid']);
$_REQUEST['group_allow'] = expand_acl($channel['channel_allow_gid']);
$_REQUEST['contact_deny'] = expand_acl($channel['channel_deny_cid']);
$_REQUEST['group_deny'] = expand_acl($channel['channel_deny_gid']);
}
if ($_REQUEST['filename']) {
$_REQUEST['allow_cid'] = perms2str($_REQUEST['contact_allow']);
$_REQUEST['allow_gid'] = perms2str($_REQUEST['group_allow']);
$_REQUEST['deny_cid'] = perms2str($_REQUEST['contact_deny']);
$_REQUEST['deny_gid'] = perms2str($_REQUEST['group_deny']);
$r = attach_mkdir($channel, get_observer_hash(), $_REQUEST);
} else {
$r = attach_store($channel, get_observer_hash(), '', $_REQUEST);
}
goaway(z_root() . '/' . $_REQUEST['return_url']);
}