本文整理汇总了PHP中observer_prohibited函数的典型用法代码示例。如果您正苦于以下问题:PHP observer_prohibited函数的具体用法?PHP observer_prohibited怎么用?PHP observer_prohibited使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了observer_prohibited函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
function init()
{
$params = array();
$params['begin'] = x($_REQUEST, 'date_begin') ? $_REQUEST['date_begin'] : NULL_DATE;
$params['end'] = x($_REQUEST, 'date_end') ? $_REQUEST['date_end'] : '';
$params['type'] = stristr(argv(0), 'json') ? 'json' : 'xml';
$params['pages'] = x($_REQUEST, 'pages') ? intval($_REQUEST['pages']) : 0;
$params['top'] = x($_REQUEST, 'top') ? intval($_REQUEST['top']) : 0;
$params['start'] = x($params, 'start') ? intval($params['start']) : 0;
$params['records'] = x($params, 'records') ? intval($params['records']) : 40;
$params['direction'] = x($params, 'direction') ? dbesc($params['direction']) : 'desc';
$params['cat'] = x($_REQUEST, 'cat') ? escape_tags($_REQUEST['cat']) : '';
$channel = '';
if (argc() > 1) {
$r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_address = '%s' limit 1", dbesc(argv(1)));
if (!($r && count($r))) {
killme();
}
$channel = $r[0];
if (observer_prohibited(true)) {
killme();
}
logger('mod_feed: public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $channel['channel_address']);
echo get_public_feed($channel, $params);
killme();
}
}
示例2: init
function init()
{
$result = array('success' => false);
$mindate = $_REQUEST['mindate'] ? datetime_convert('UTC', 'UTC', $_REQUEST['mindate']) : '';
if (!$mindate) {
$mindate = datetime_convert('UTC', 'UTC', 'now - 14 days');
}
if (observer_prohibited()) {
$result['message'] = 'Public access denied';
json_return_and_die($result);
}
$observer = \App::get_observer();
$channel_address = argc() > 1 ? argv(1) : '';
if ($channel_address) {
$r = q("select channel_id, channel_name from channel where channel_address = '%s' and channel_removed = 0 limit 1", dbesc(argv(1)));
} else {
$x = get_sys_channel();
if ($x) {
$r = array($x);
}
$mindate = datetime_convert('UTC', 'UTC', 'now - 14 days');
}
if (!$r) {
$result['message'] = 'Channel not found.';
json_return_and_die($result);
}
logger('zotfeed request: ' . $r[0]['channel_name'], LOGGER_DEBUG);
$result['messages'] = zot_feed($r[0]['channel_id'], $observer['xchan_hash'], array('mindate' => $mindate));
$result['success'] = true;
json_return_and_die($result);
}
示例3: get
function get()
{
if (observer_prohibited()) {
notice(t('Public access denied.') . EOL);
return;
}
if (!count(\App::$profile) || \App::$profile['hide_friends']) {
notice(t('Permission denied.') . EOL);
return;
}
if (!perm_is_allowed(\App::$profile['uid'], get_observer_hash(), 'view_contacts')) {
notice(t('Permission denied.') . EOL);
return;
}
if (!$_REQUEST['aj']) {
$_SESSION['return_url'] = \App::$query_string;
}
$is_owner = local_channel() && local_channel() == \App::$profile['uid'] ? true : false;
$abook_flags = " and abook_pending = 0 and abook_self = 0 ";
$sql_extra = '';
if (!$is_owner) {
$abook_flags = " and abook_hidden = 0 ";
$sql_extra = " and xchan_hidden = 0 ";
}
$r = q("SELECT count(*) as total FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d {$abook_flags} and xchan_orphan = 0 and xchan_deleted = 0 {$sql_extra} ", intval(\App::$profile['uid']));
if ($r) {
\App::set_pager_total($r[0]['total']);
}
$r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d {$abook_flags} and xchan_orphan = 0 and xchan_deleted = 0 {$sql_extra} order by xchan_name LIMIT %d OFFSET %d ", intval(\App::$profile['uid']), intval(\App::$pager['itemspage']), intval(\App::$pager['start']));
if (!$r && !$_REQUEST['aj']) {
info(t('No connections.') . EOL);
return $o;
}
$contacts = array();
foreach ($r as $rr) {
$url = chanlink_url($rr['xchan_url']);
if ($url) {
$contacts[] = array('id' => $rr['abook_id'], 'archived' => intval($rr['abook_archived']) ? true : false, 'img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $rr['xchan_name'], $rr['xchan_url']), 'thumb' => $rr['xchan_photo_m'], 'name' => substr($rr['xchan_name'], 0, 20), 'username' => $rr['xchan_addr'], 'link' => $url, 'sparkle' => '', 'itemurl' => $rr['url'], 'network' => '');
}
}
if ($_REQUEST['aj']) {
if ($contacts) {
$o = replace_macros(get_markup_template('viewcontactsajax.tpl'), array('$contacts' => $contacts));
} else {
$o = '<div id="content-complete"></div>';
}
echo $o;
killme();
} else {
$o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; </script>";
$tpl = get_markup_template("viewcontact_template.tpl");
$o .= replace_macros($tpl, array('$title' => t('View Connections'), '$contacts' => $contacts));
}
if (!$contacts) {
$o .= '<div id="content-complete"></div>';
}
return $o;
}
示例4: get
function get()
{
if (observer_prohibited()) {
notice(t('Public access denied.') . EOL);
return;
}
$rating_enabled = get_config('system', 'rating_enabled');
if (!$rating_enabled) {
return;
}
$site_target = array_key_exists('target', \App::$data) && array_key_exists('site_url', \App::$data['target']) ? '<a href="' . \App::$data['target']['site_url'] . '" >' . \App::$data['target']['site_url'] . '</a>' : '';
$o = replace_macros(get_markup_template('prep.tpl'), array('$header' => t('Ratings'), '$rating_lbl' => t('Rating: '), '$website' => t('Website: '), '$site' => $site_target, '$rating_text_lbl' => t('Description: '), '$raters' => \App::$data['results']));
return $o;
}
示例5: get
function get()
{
if (observer_prohibited(true)) {
return login();
}
$groups = array();
$tab = 'profile';
$o = '';
if (!perm_is_allowed(\App::$profile['profile_uid'], get_observer_hash(), 'view_profile')) {
notice(t('Permission denied.') . EOL);
return;
}
$is_owner = local_channel() && local_channel() == \App::$profile['profile_uid'] ? true : false;
if (\App::$profile['hidewall'] && !$is_owner && !remote_channel()) {
notice(t('Permission denied.') . EOL);
return;
}
$o .= profile_tabs($a, $is_owner, \App::$profile['channel_address']);
\App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$query_string) . '" title="oembed" />' . "\r\n";
$o .= advanced_profile($a);
call_hooks('profile_advanced', $o);
return $o;
}
示例6: get
function get()
{
if (observer_prohibited()) {
return;
}
$channel = null;
if (argc() > 1) {
$channel = channelx_by_nick(argv(1));
}
if (!$channel) {
notice(t('Channel not found.') . EOL);
return;
}
// since we don't currently have an event permission - use the stream permission
if (!perm_is_allowed($channel['channel_id'], get_observer_hash(), 'view_stream')) {
notice(t('Permissions denied.') . EOL);
return;
}
$sql_extra = permissions_sql($channel['channel_id'], get_observer_hash(), 'event');
$first_day = get_pconfig(local_channel(), 'system', 'cal_first_day');
$first_day = $first_day ? $first_day : 0;
$htpl = get_markup_template('event_head.tpl');
\App::$page['htmlhead'] .= replace_macros($htpl, array('$baseurl' => z_root(), '$module_url' => '/cal/' . $channel['channel_address'], '$modparams' => 2, '$lang' => \App::$language, '$first_day' => $first_day));
$o = '';
$tabs = profile_tabs($a, True, $channel['channel_address']);
$mode = 'view';
$y = 0;
$m = 0;
$ignored = x($_REQUEST, 'ignored') ? " and dismissed = " . intval($_REQUEST['ignored']) . " " : '';
// logger('args: ' . print_r(\App::$argv,true));
if (argc() > 3 && intval(argv(2)) && intval(argv(3))) {
$mode = 'view';
$y = intval(argv(2));
$m = intval(argv(3));
}
if (argc() <= 3) {
$mode = 'view';
$event_id = argv(2);
}
if ($mode == 'view') {
/* edit/create form */
if ($event_id) {
$r = q("SELECT * FROM `event` WHERE event_hash = '%s' AND `uid` = %d LIMIT 1", dbesc($event_id), intval($channel['channel_id']));
if (count($r)) {
$orig_event = $r[0];
}
}
// Passed parameters overrides anything found in the DB
if (!x($orig_event)) {
$orig_event = array();
}
$tz = date_default_timezone_get();
if (x($orig_event)) {
$tz = $orig_event['adjust'] ? date_default_timezone_get() : 'UTC';
}
$syear = datetime_convert('UTC', $tz, $sdt, 'Y');
$smonth = datetime_convert('UTC', $tz, $sdt, 'm');
$sday = datetime_convert('UTC', $tz, $sdt, 'd');
$shour = datetime_convert('UTC', $tz, $sdt, 'H');
$sminute = datetime_convert('UTC', $tz, $sdt, 'i');
$stext = datetime_convert('UTC', $tz, $sdt);
$stext = substr($stext, 0, 14) . "00:00";
$fyear = datetime_convert('UTC', $tz, $fdt, 'Y');
$fmonth = datetime_convert('UTC', $tz, $fdt, 'm');
$fday = datetime_convert('UTC', $tz, $fdt, 'd');
$fhour = datetime_convert('UTC', $tz, $fdt, 'H');
$fminute = datetime_convert('UTC', $tz, $fdt, 'i');
$ftext = datetime_convert('UTC', $tz, $fdt);
$ftext = substr($ftext, 0, 14) . "00:00";
$type = x($orig_event) ? $orig_event['etype'] : 'event';
$f = get_config('system', 'event_input_format');
if (!$f) {
$f = 'ymd';
}
$catsenabled = feature_enabled($channel['channel_id'], 'categories');
$show_bd = perm_is_allowed($channel['channel_id'], get_observer_hash(), 'view_contacts');
if (!$show_bd) {
$sql_extra .= " and event.etype != 'birthday' ";
}
$category = '';
$thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
$thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
if (!$y) {
$y = intval($thisyear);
}
if (!$m) {
$m = intval($thismonth);
}
// Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
// An upper limit was chosen to keep search engines from exploring links millions of years in the future.
if ($y < 1901) {
$y = 1900;
}
if ($y > 2099) {
$y = 2100;
}
$nextyear = $y;
$nextmonth = $m + 1;
if ($nextmonth > 12) {
$nextmonth = 1;
//.........这里部分代码省略.........
示例7: get
function get($update = 0, $load = false)
{
$checkjs = new \Zotlabs\Web\CheckJS(1);
if ($load) {
$_SESSION['loadtime'] = datetime_convert();
}
if (observer_prohibited()) {
notice(t('Public access denied.') . EOL);
return;
}
require_once "include/bbcode.php";
require_once 'include/security.php';
require_once 'include/conversation.php';
require_once 'include/acl_selectors.php';
require_once 'include/items.php';
\App::$page['htmlhead'] .= replace_macros(get_markup_template('display-head.tpl'), array());
if (argc() > 1 && argv(1) !== 'load') {
$item_hash = argv(1);
}
if ($_REQUEST['mid']) {
$item_hash = $_REQUEST['mid'];
}
if (!$item_hash) {
\App::$error = 404;
notice(t('Item not found.') . EOL);
return;
}
$observer_is_owner = false;
if (local_channel() && !$update) {
$channel = \App::get_channel();
$channel_acl = array('allow_cid' => $channel['channel_allow_cid'], 'allow_gid' => $channel['channel_allow_gid'], 'deny_cid' => $channel['channel_deny_cid'], 'deny_gid' => $channel['channel_deny_gid']);
$x = array('is_owner' => true, 'allow_location' => intval(get_pconfig($channel['channel_id'], 'system', 'use_browser_location')) ? '1' : '', 'default_location' => $channel['channel_location'], 'nickname' => $channel['channel_address'], 'lockstate' => $group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid'] ? 'lock' : 'unlock', 'acl' => populate_acl($channel_acl), 'permissions' => $channel_acl, 'bang' => '', 'visitor' => true, 'profile_uid' => local_channel(), 'return_path' => 'channel/' . $channel['channel_address'], 'expanded' => true, 'editor_autocomplete' => true, 'bbco_autocomplete' => 'bbcode', 'bbcode' => true);
$o = '<div id="jot-popup">';
$o .= status_editor($a, $x);
$o .= '</div>';
}
// This page can be viewed by anybody so the query could be complicated
// First we'll see if there is a copy of the item which is owned by us - if we're logged in locally.
// If that fails (or we aren't logged in locally),
// query an item in which the observer (if logged in remotely) has cid or gid rights
// and if that fails, look for a copy of the post that has no privacy restrictions.
// If we find the post, but we don't find a copy that we're allowed to look at, this fact needs to be reported.
// find a copy of the item somewhere
$target_item = null;
$r = q("select id, uid, mid, parent_mid, item_type, item_deleted from item where mid like '%s' limit 1", dbesc($item_hash . '%'));
if ($r) {
$target_item = $r[0];
}
$r = null;
if ($target_item['item_type'] == ITEM_TYPE_WEBPAGE) {
$x = q("select * from channel where channel_id = %d limit 1", intval($target_item['uid']));
$y = q("select * from iconfig left join item on iconfig.iid = item.id \n\t\t\t\twhere item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'WEBPAGE' and item.id = %d limit 1", intval($target_item['uid']), intval($target_item['id']));
if ($x && $y) {
goaway(z_root() . '/page/' . $x[0]['channel_address'] . '/' . $y[0]['v']);
} else {
notice(t('Page not found.') . EOL);
return '';
}
}
$simple_update = $update ? " AND item_unseen = 1 " : '';
if ($update && $_SESSION['loadtime']) {
$simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC', 'UTC', $_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC', 'UTC', $_SESSION['loadtime']) . "' ) ";
}
if ($load) {
$simple_update = '';
}
if (!$update && !$load) {
$o .= '<div id="live-display"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . (intval(local_channel()) ? local_channel() : -1) . "; var netargs = '?f='; var profile_page = " . \App::$pager['page'] . "; </script>\r\n";
\App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"), array('$baseurl' => z_root(), '$pgtype' => 'display', '$uid' => '0', '$gid' => '0', '$cid' => '0', '$cmin' => '0', '$cmax' => '99', '$star' => '0', '$liked' => '0', '$conv' => '0', '$spam' => '0', '$fh' => '0', '$nouveau' => '0', '$wall' => '0', '$page' => \App::$pager['page'] != 1 ? \App::$pager['page'] : 1, '$list' => x($_REQUEST, 'list') ? intval($_REQUEST['list']) : 0, '$search' => '', '$order' => '', '$file' => '', '$cats' => '', '$tags' => '', '$dend' => '', '$dbegin' => '', '$verb' => '', '$mid' => $item_hash));
}
$observer_hash = get_observer_hash();
$item_normal = item_normal();
$sql_extra = public_permissions_sql($observer_hash);
if ($update && $load || $checkjs->disabled()) {
$updateable = false;
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start']));
if ($load || $checkjs->disabled()) {
$r = null;
require_once 'include/channel.php';
$sys = get_sys_channel();
$sysid = $sys['channel_id'];
if (local_channel()) {
$r = q("SELECT * from item\n\t\t\t\t\t\tWHERE uid = %d\n\t\t\t\t\t\tand mid = '%s'\n\t\t\t\t\t\t{$item_normal}\n\t\t\t\t\t\tlimit 1", intval(local_channel()), dbesc($target_item['parent_mid']));
if ($r) {
$updateable = true;
}
}
if ($r === null) {
// in case somebody turned off public access to sys channel content using permissions
// make that content unsearchable by ensuring the owner_xchan can't match
if (!perm_is_allowed($sysid, $observer_hash, 'view_stream')) {
$sysid = 0;
}
$r = q("SELECT * from item\n\t\t\t\t\t\tWHERE mid = '%s'\n\t\t\t\t\t\tAND (((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' \n\t\t\t\t\t\tAND `item`.`deny_gid` = '' AND item_private = 0 ) \n\t\t\t\t\t\tand owner_xchan in ( " . stream_perms_xchans($observer_hash ? PERMS_NETWORK | PERMS_PUBLIC : PERMS_PUBLIC) . " ))\n\t\t\t\t\t\tOR uid = %d )\n\t\t\t\t\t\t{$sql_extra} )\n\t\t\t\t\t\t{$item_normal}\n\t\t\t\t\t\tlimit 1", dbesc($target_item['parent_mid']), intval($sysid));
}
}
} elseif ($update && !$load) {
$r = null;
require_once 'include/channel.php';
//.........这里部分代码省略.........
示例8: get
function get($update = 0, $load = false)
{
if ($load) {
$_SESSION['loadtime'] = datetime_convert();
}
$checkjs = new \Zotlabs\Web\CheckJS(1);
$category = $datequery = $datequery2 = '';
$mid = x($_REQUEST, 'mid') ? $_REQUEST['mid'] : '';
$datequery = x($_GET, 'dend') && is_a_date_arg($_GET['dend']) ? notags($_GET['dend']) : '';
$datequery2 = x($_GET, 'dbegin') && is_a_date_arg($_GET['dbegin']) ? notags($_GET['dbegin']) : '';
if (observer_prohibited(true)) {
return login();
}
$category = x($_REQUEST, 'cat') ? $_REQUEST['cat'] : '';
$hashtags = x($_REQUEST, 'tag') ? $_REQUEST['tag'] : '';
$groups = array();
$o = '';
if ($update) {
// Ensure we've got a profile owner if updating.
\App::$profile['profile_uid'] = \App::$profile_uid = $update;
} else {
if (\App::$profile['profile_uid'] == local_channel()) {
nav_set_selected('home');
}
}
$is_owner = local_channel() && \App::$profile['profile_uid'] == local_channel() ? true : false;
$channel = \App::get_channel();
$observer = \App::get_observer();
$ob_hash = $observer ? $observer['xchan_hash'] : '';
$perms = get_all_perms(\App::$profile['profile_uid'], $ob_hash);
if (!$perms['view_stream']) {
// We may want to make the target of this redirect configurable
if ($perms['view_profile']) {
notice(t('Insufficient permissions. Request redirected to profile page.') . EOL);
goaway(z_root() . "/profile/" . \App::$profile['channel_address']);
}
notice(t('Permission denied.') . EOL);
return;
}
if (!$update) {
$o .= profile_tabs($a, $is_owner, \App::$profile['channel_address']);
$o .= common_friends_visitor_widget(\App::$profile['profile_uid']);
if ($channel && $is_owner) {
$channel_acl = array('allow_cid' => $channel['channel_allow_cid'], 'allow_gid' => $channel['channel_allow_gid'], 'deny_cid' => $channel['channel_deny_cid'], 'deny_gid' => $channel['channel_deny_gid']);
} else {
$channel_acl = array();
}
if ($perms['post_wall']) {
$x = array('is_owner' => $is_owner, 'allow_location' => ($is_owner || $observer) && intval(get_pconfig(\App::$profile['profile_uid'], 'system', 'use_browser_location')) ? true : false, 'default_location' => $is_owner ? \App::$profile['channel_location'] : '', 'nickname' => \App::$profile['channel_address'], 'lockstate' => strlen(\App::$profile['channel_allow_cid']) || strlen(\App::$profile['channel_allow_gid']) || strlen(\App::$profile['channel_deny_cid']) || strlen(\App::$profile['channel_deny_gid']) ? 'lock' : 'unlock', 'acl' => $is_owner ? populate_acl($channel_acl, true, \PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post') : '', 'showacl' => $is_owner ? 'yes' : '', 'bang' => '', 'visitor' => $is_owner || $observer ? true : false, 'profile_uid' => \App::$profile['profile_uid'], 'editor_autocomplete' => true, 'bbco_autocomplete' => 'bbcode', 'bbcode' => true);
$o .= status_editor($a, $x);
}
}
/**
* Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
*/
$item_normal = item_normal();
$sql_extra = item_permissions_sql(\App::$profile['profile_uid']);
if (get_pconfig(\App::$profile['profile_uid'], 'system', 'channel_list_mode') && !$mid) {
$page_mode = 'list';
} else {
$page_mode = 'client';
}
$abook_uids = " and abook.abook_channel = " . intval(\App::$profile['profile_uid']) . " ";
$simple_update = $update ? " AND item_unseen = 1 " : '';
\App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$query_string) . '" title="oembed" />' . "\r\n";
if ($update && $_SESSION['loadtime']) {
$simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC', 'UTC', $_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC', 'UTC', $_SESSION['loadtime']) . "' ) ";
}
if ($load) {
$simple_update = '';
}
if ($update && !$load) {
if ($mid) {
$r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d {$item_normal}\n\t\t\t\t\tAND item_wall = 1 AND item_unseen = 1 {$sql_extra} limit 1", dbesc($mid . '%'), intval(\App::$profile['profile_uid']));
} else {
$r = q("SELECT distinct parent AS `item_id`, created from item\n\t\t\t\t\tleft join abook on ( item.owner_xchan = abook.abook_xchan {$abook_uids} )\n\t\t\t\t\tWHERE uid = %d {$item_normal}\n\t\t\t\t\tAND item_wall = 1 {$simple_update}\n\t\t\t\t\tAND (abook.abook_blocked = 0 or abook.abook_flags is null)\n\t\t\t\t\t{$sql_extra}\n\t\t\t\t\tORDER BY created DESC", intval(\App::$profile['profile_uid']));
$_SESSION['loadtime'] = datetime_convert();
}
} else {
if (x($category)) {
$sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY));
}
if (x($hashtags)) {
$sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG));
}
if ($datequery) {
$sql_extra2 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery))));
}
if ($datequery2) {
$sql_extra2 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery2))));
}
$itemspage = get_pconfig(local_channel(), 'system', 'itemspage');
\App::set_pager_itemspage(intval($itemspage) ? $itemspage : 20);
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start']));
if ($load || $checkjs->disabled()) {
if ($mid) {
$r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d {$item_normal}\n\t\t\t\t\t\tAND item_wall = 1 {$sql_extra} limit 1", dbesc($mid), intval(\App::$profile['profile_uid']));
if (!$r) {
notice(t('Permission denied.') . EOL);
}
//.........这里部分代码省略.........
示例9: get_online_status
function get_online_status($nick)
{
$ret = array('result' => false);
if (observer_prohibited()) {
return $ret;
}
$r = q("select channel_id, channel_hash from channel where channel_address = '%s' limit 1", dbesc(argv(1)));
if ($r) {
$hide = get_pconfig($r[0]['channel_id'], 'system', 'hide_online_status');
if ($hide) {
return $ret;
}
$x = q("select cp_status from chatpresence where cp_xchan = '%s' and cp_room = 0 limit 1", dbesc($r[0]['channel_hash']));
if ($x) {
$ret['result'] = $x[0]['cp_status'];
}
}
return $ret;
}
示例10: poco
function poco($a, $extended = false)
{
$system_mode = false;
if (observer_prohibited()) {
logger('mod_poco: block_public');
http_status_exit(401);
}
$observer = App::get_observer();
if (argc() > 1) {
$user = notags(trim(argv(1)));
}
if (!x($user)) {
$c = q("select * from pconfig where cat = 'system' and k = 'suggestme' and v = '1'");
if (!$c) {
logger('mod_poco: system mode. No candidates.', LOGGER_DEBUG);
http_status_exit(404);
}
$system_mode = true;
}
$format = $_REQUEST['format'] ? $_REQUEST['format'] : 'json';
$justme = false;
if (argc() > 2 && argv(2) === '@me') {
$justme = true;
}
if (argc() > 3) {
if (argv(3) === '@all') {
$justme = false;
} elseif (argv(3) === '@self') {
$justme = true;
}
}
if (argc() > 4 && intval(argv(4)) && $justme == false) {
$cid = intval(argv(4));
}
if (!$system_mode) {
$r = q("SELECT channel_id from channel where channel_address = '%s' limit 1", dbesc($user));
if (!$r) {
logger('mod_poco: user mode. Account not found. ' . $user);
http_status_exit(404);
}
$channel_id = $r[0]['channel_id'];
$ohash = $observer ? $observer['xchan_hash'] : '';
if (!perm_is_allowed($channel_id, $ohash, 'view_contacts')) {
logger('mod_poco: user mode. Permission denied for ' . $ohash . ' user: ' . $user);
http_status_exit(401);
}
}
if ($justme) {
$sql_extra = " and abook_self = 1 ";
} else {
$sql_extra = " and abook_self = 0 ";
}
if ($cid) {
$sql_extra = sprintf(" and abook_id = %d and abook_hidden = 0 ", intval($cid));
}
if ($system_mode) {
$r = q("SELECT count(*) as `total` from abook where abook_self = 1 \n\t\t\tand abook_channel in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = '1') ");
} else {
$r = q("SELECT count(*) as `total` from abook where abook_channel = %d \n\t\t\t{$sql_extra} ", intval($channel_id));
$rooms = q("select * from menu_item where ( mitem_flags & " . intval(MENU_ITEM_CHATROOM) . " )>0 and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = '' and mitem_channel_id = %d", intval($channel_id));
}
if ($r) {
$totalResults = intval($r[0]['total']);
} else {
$totalResults = 0;
}
$startIndex = intval($_GET['startIndex']);
if (!$startIndex) {
$startIndex = 0;
}
$itemsPerPage = x($_GET, 'count') && intval($_GET['count']) ? intval($_GET['count']) : $totalResults;
if ($system_mode) {
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_self = 1 \n\t\t\tand abook_channel in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = '1') \n\t\t\tlimit %d offset %d ", intval($itemsPerPage), intval($startIndex));
} else {
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d \n\t\t\t{$sql_extra} LIMIT %d OFFSET %d", intval($channel_id), intval($itemsPerPage), intval($startIndex));
}
$ret = array();
if (x($_GET, 'sorted')) {
$ret['sorted'] = 'false';
}
if (x($_GET, 'filtered')) {
$ret['filtered'] = 'false';
}
if (x($_GET, 'updatedSince')) {
$ret['updateSince'] = 'false';
}
$ret['startIndex'] = (string) $startIndex;
$ret['itemsPerPage'] = (string) $itemsPerPage;
$ret['totalResults'] = (string) $totalResults;
if ($rooms) {
$ret['chatrooms'] = array();
foreach ($rooms as $room) {
$ret['chatrooms'][] = array('url' => $room['mitem_link'], 'desc' => $room['mitem_desc']);
}
}
$ret['entry'] = array();
$fields_ret = array('id' => false, 'guid' => false, 'guid_sig' => false, 'hash' => false, 'displayName' => false, 'urls' => false, 'preferredUsername' => false, 'photos' => false, 'rating' => false);
if (!x($_GET, 'fields') || $_GET['fields'] === '@all') {
foreach ($fields_ret as $k => $v) {
$fields_ret[$k] = true;
//.........这里部分代码省略.........
示例11: navbar_complete
function navbar_complete(&$a)
{
// logger('navbar_complete');
if (observer_prohibited()) {
return;
}
$dirmode = intval(get_config('system', 'directory_mode'));
$search = x($_REQUEST, 'search') ? htmlentities($_REQUEST['search'], ENT_COMPAT, 'UTF-8', false) : '';
if (!$search || mb_strlen($search) < 2) {
return array();
}
$star = false;
$address = false;
if (substr($search, 0, 1) === '@') {
$search = substr($search, 1);
}
if (substr($search, 0, 1) === '*') {
$star = true;
$search = substr($search, 1);
}
if (strpos($search, '@') !== false) {
$address = true;
}
if ($dirmode == DIRECTORY_MODE_PRIMARY || $dirmode == DIRECTORY_MODE_STANDALONE) {
$url = z_root() . '/dirsearch';
}
if (!$url) {
require_once "include/dir_fns.php";
$directory = find_upstream_directory($dirmode);
$url = $directory['url'] . '/dirsearch';
}
$count = x($_REQUEST, 'count') ? $_REQUEST['count'] : 100;
if ($url) {
$query = $url . '?f=';
$query .= '&name=' . urlencode($search) . "&limit={$count}" . ($address ? '&address=' . urlencode($search) : '');
$x = z_fetch_url($query);
if ($x['success']) {
$t = 0;
$j = json_decode($x['body'], true);
if ($j && $j['results']) {
return $j['results'];
}
}
}
return array();
}
示例12: get
function get()
{
// URLs:
// photos/name
// photos/name/album/xxxxx (xxxxx is album name)
// photos/name/image/xxxxx
if (observer_prohibited()) {
notice(t('Public access denied.') . EOL);
return;
}
$unsafe = array_key_exists('unsafe', $_REQUEST) && $_REQUEST['unsafe'] ? 1 : 0;
require_once 'include/bbcode.php';
require_once 'include/security.php';
require_once 'include/conversation.php';
if (!x(\App::$data, 'channel')) {
notice(t('No photos selected') . EOL);
return;
}
$ph = photo_factory('');
$phototypes = $ph->supportedTypes();
$_SESSION['photo_return'] = \App::$cmd;
//
// Parse arguments
//
$can_comment = perm_is_allowed(\App::$profile['profile_uid'], get_observer_hash(), 'post_comments');
if (argc() > 3) {
$datatype = argv(2);
$datum = argv(3);
} else {
if (argc() > 2) {
$datatype = argv(2);
$datum = '';
} else {
$datatype = 'summary';
}
}
if (argc() > 4) {
$cmd = argv(4);
} else {
$cmd = 'view';
}
//
// Setup permissions structures
//
$can_post = false;
$visitor = 0;
$owner_uid = \App::$data['channel']['channel_id'];
$owner_aid = \App::$data['channel']['channel_account_id'];
$observer = \App::get_observer();
$can_post = perm_is_allowed($owner_uid, $observer['xchan_hash'], 'write_storage');
$can_view = perm_is_allowed($owner_uid, $observer['xchan_hash'], 'view_storage');
if (!$can_view) {
notice(t('Access to this item is restricted.') . EOL);
return;
}
$sql_extra = permissions_sql($owner_uid);
$o = "";
$o .= "<script> var profile_uid = " . \App::$profile['profile_uid'] . "; var netargs = '?f='; var profile_page = " . \App::$pager['page'] . "; </script>\r\n";
// tabs
$_is_owner = local_channel() && local_channel() == $owner_uid;
$o .= profile_tabs($a, $_is_owner, \App::$data['channel']['channel_address']);
/**
* Display upload form
*/
if ($can_post) {
$uploader = '';
$ret = array('post_url' => z_root() . '/photos/' . \App::$data['channel']['channel_address'], 'addon_text' => $uploader, 'default_upload' => true);
call_hooks('photo_upload_form', $ret);
/* Show space usage */
$r = q("select sum(filesize) as total from photo where aid = %d and imgscale = 0 ", intval(\App::$data['channel']['channel_account_id']));
$limit = engr_units_to_bytes(service_class_fetch(\App::$data['channel']['channel_id'], 'photo_upload_limit'));
if ($limit !== false) {
$usage_message = sprintf(t("%1\$.2f MB of %2\$.2f MB photo storage used."), $r[0]['total'] / 1024000, $limit / 1024000);
} else {
$usage_message = sprintf(t('%1$.2f MB photo storage used.'), $r[0]['total'] / 1024000);
}
if ($_is_owner) {
$channel = \App::get_channel();
$acl = new \Zotlabs\Access\AccessList($channel);
$channel_acl = $acl->get();
$lockstate = $acl->is_private() ? 'lock' : 'unlock';
}
$aclselect = $_is_owner ? populate_acl($channel_acl, false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_storage')) : '';
// this is wrong but is to work around an issue with js_upload wherein it chokes if these variables
// don't exist. They really should be set to a parseable representation of the channel's default permissions
// which can be processed by getSelected()
if (!$aclselect) {
$aclselect = '<input id="group_allow" type="hidden" name="allow_gid[]" value="" /><input id="contact_allow" type="hidden" name="allow_cid[]" value="" /><input id="group_deny" type="hidden" name="deny_gid[]" value="" /><input id="contact_deny" type="hidden" name="deny_cid[]" value="" />';
}
$selname = $datum ? hex2bin($datum) : '';
$albums = array_key_exists('albums', \App::$data) ? \App::$data['albums'] : photos_albums_list(\App::$data['channel'], \App::$data['observer']);
if (!$selname) {
$def_album = get_pconfig(\App::$data['channel']['channel_id'], 'system', 'photo_path');
if ($def_album) {
$selname = filepath_macro($def_album);
$albums['album'][] = array('text' => $selname);
}
}
$tpl = get_markup_template('photos_upload.tpl');
$upload_form = replace_macros($tpl, array('$pagename' => t('Upload Photos'), '$sessid' => session_id(), '$usage' => $usage_message, '$nickname' => \App::$data['channel']['channel_address'], '$newalbum_label' => t('Enter an album name'), '$newalbum_placeholder' => t('or select an existing album (doubleclick)'), '$visible' => array('visible', t('Create a status post for this upload'), 0, '', array(t('No'), t('Yes')), 'onclick="showHideBodyTextarea();"'), '$caption' => array('description', t('Caption (optional):')), '$body' => array('body', t('Description (optional):'), '', 'Description will only appear in the status post'), '$albums' => $albums['albums'], '$selname' => $selname, '$permissions' => t('Permissions'), '$aclselect' => $aclselect, '$allow_cid' => acl2json($channel_acl['allow_cid']), '$allow_gid' => acl2json($channel_acl['allow_gid']), '$deny_cid' => acl2json($channel_acl['deny_cid']), '$deny_gid' => acl2json($channel_acl['deny_gid']), '$lockstate' => $lockstate, '$uploader' => $ret['addon_text'], '$default' => $ret['default_upload'] ? true : false, '$uploadurl' => $ret['post_url'], '$submit' => t('Submit')));
//.........这里部分代码省略.........
示例13: widget_shortprofile
function widget_shortprofile($arr)
{
if (!App::$profile['profile_uid']) {
return;
}
$block = observer_prohibited();
return profile_sidebar(App::$profile, $block, true, true);
}
示例14: get
function get()
{
if (observer_prohibited(true)) {
return login();
}
if (!feature_enabled(\App::$profile_uid, 'wiki')) {
notice(t('Not found') . EOL);
return;
}
$tab = 'wiki';
require_once 'include/wiki.php';
require_once 'include/acl_selectors.php';
require_once 'include/conversation.php';
// TODO: Combine the interface configuration into a unified object
// Something like $interface = array('new_page_button' => false, 'new_wiki_button' => false, ...)
$wiki_owner = false;
$showNewWikiButton = false;
$showCommitMsg = false;
$hidePageHistory = false;
$pageHistory = array();
$local_observer = null;
$resource_id = '';
// init() should have forced the URL to redirect to /wiki/channel so assume argc() > 1
$nick = argv(1);
$channel = get_channel_by_nick($nick);
// The channel who owns the wikis being viewed
if (!$channel) {
notice('Invalid channel' . EOL);
goaway('/' . argv(0));
}
// Determine if the observer is the channel owner so the ACL dialog can be populated
if (local_channel() === intval($channel['channel_id'])) {
$local_observer = \App::get_channel();
$wiki_owner = true;
// Obtain the default permission settings of the channel
$channel_acl = array('allow_cid' => $local_observer['channel_allow_cid'], 'allow_gid' => $local_observer['channel_allow_gid'], 'deny_cid' => $local_observer['channel_deny_cid'], 'deny_gid' => $local_observer['channel_deny_gid']);
// Initialize the ACL to the channel default permissions
$x = array('lockstate' => $local_observer['channel_allow_cid'] || $local_observer['channel_allow_gid'] || $local_observer['channel_deny_cid'] || $local_observer['channel_deny_gid'] ? 'lock' : 'unlock', 'acl' => populate_acl($channel_acl), 'bang' => '');
} else {
// Not the channel owner
$channel_acl = $x = array();
}
switch (argc()) {
case 2:
// Configure page template
$wikiheaderName = t('Wiki');
$wikiheaderPage = t('Sandbox');
require_once 'library/markdown.php';
$content = t('"# Wiki Sandbox\\n\\nContent you **edit** and **preview** here *will not be saved*."');
$renderedContent = Markdown(json_decode($content));
$hide_editor = false;
$showPageControls = false;
$showNewWikiButton = $wiki_owner;
$showNewPageButton = false;
$hidePageHistory = true;
$showCommitMsg = false;
break;
case 3:
// /wiki/channel/wiki -> No page was specified, so redirect to Home.md
$wikiUrlName = urlencode(argv(2));
goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/Home');
case 4:
// GET /wiki/channel/wiki/page
// Fetch the wiki info and determine observer permissions
$wikiUrlName = urlencode(argv(2));
$pageUrlName = urlencode(argv(3));
$w = wiki_exists_by_name($channel['channel_id'], $wikiUrlName);
if (!$w['resource_id']) {
notice('Wiki not found' . EOL);
goaway('/' . argv(0) . '/' . argv(1));
}
$resource_id = $w['resource_id'];
if (!$wiki_owner) {
// Check for observer permissions
$observer_hash = get_observer_hash();
$perms = wiki_get_permissions($resource_id, intval($channel['channel_id']), $observer_hash);
if (!$perms['read']) {
notice('Permission denied.' . EOL);
goaway('/' . argv(0) . '/' . argv(1));
}
if ($perms['write']) {
$wiki_editor = true;
} else {
$wiki_editor = false;
}
} else {
$wiki_editor = true;
}
$wikiheaderName = urldecode($wikiUrlName);
$wikiheaderPage = urldecode($pageUrlName);
$p = wiki_get_page_content(array('resource_id' => $resource_id, 'pageUrlName' => $pageUrlName));
if (!$p['success']) {
notice('Error retrieving page content' . EOL);
goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName);
}
$content = $p['content'] !== '' ? htmlspecialchars_decode($p['content'], ENT_COMPAT) : '"# New page\\n"';
// Render the Markdown-formatted page content in HTML
require_once 'library/markdown.php';
$html = wiki_generate_toc(purify_html(Markdown(json_decode($content))));
$renderedContent = wiki_convert_links($html, argv(0) . '/' . argv(1) . '/' . $wikiUrlName);
//.........这里部分代码省略.........
示例15: get
function get()
{
if (observer_prohibited()) {
notice(t('Public access denied.') . EOL);
return;
}
$observer = get_observer_hash();
$globaldir = get_directory_setting($observer, 'globaldir');
// override your personal global search pref if we're doing a navbar search of the directory
if (intval($_REQUEST['navsearch'])) {
$globaldir = 1;
}
$safe_mode = get_directory_setting($observer, 'safemode');
$pubforums = get_directory_setting($observer, 'pubforums');
$o = '';
nav_set_selected('directory');
if (x($_POST, 'search')) {
$search = notags(trim($_POST['search']));
} else {
$search = x($_GET, 'search') ? notags(trim(rawurldecode($_GET['search']))) : '';
}
if (strpos($search, '=') && local_channel() && feature_enabled(local_channel(), 'advanced_dirsearch')) {
$advanced = $search;
}
$keywords = $_GET['keywords'] ? $_GET['keywords'] : '';
// Suggest channels if no search terms or keywords are given
$suggest = local_channel() && x($_REQUEST, 'suggest') ? $_REQUEST['suggest'] : '';
if ($suggest) {
$r = suggestion_query(local_channel(), get_observer_hash());
// Remember in which order the suggestions were
$addresses = array();
$common = array();
$index = 0;
foreach ($r as $rr) {
$common[$rr['xchan_addr']] = $rr['total'];
$addresses[$rr['xchan_addr']] = $index++;
}
// Build query to get info about suggested people
$advanced = '';
foreach (array_keys($addresses) as $address) {
$advanced .= "address=\"{$address}\" ";
}
// Remove last space in the advanced query
$advanced = rtrim($advanced);
}
$tpl = get_markup_template('directory_header.tpl');
$dirmode = intval(get_config('system', 'directory_mode'));
if ($dirmode == DIRECTORY_MODE_PRIMARY || $dirmode == DIRECTORY_MODE_STANDALONE) {
$url = z_root() . '/dirsearch';
}
if (!$url) {
$directory = find_upstream_directory($dirmode);
if (!$directory || !array_key_exists('url', $directory) || !$directory['url']) {
logger('CRITICAL: No directory server URL');
}
$url = $directory['url'] . '/dirsearch';
}
$token = get_config('system', 'realm_token');
logger('mod_directory: URL = ' . $url, LOGGER_DEBUG);
$contacts = array();
if (local_channel()) {
$x = q("select abook_xchan from abook where abook_channel = %d", intval(local_channel()));
if ($x) {
foreach ($x as $xx) {
$contacts[] = $xx['abook_xchan'];
}
}
}
if ($url) {
$numtags = get_config('system', 'directorytags');
$kw = intval($numtags) > 0 ? intval($numtags) : 50;
if (get_config('system', 'disable_directory_keywords')) {
$kw = 0;
}
$query = $url . '?f=&kw=' . $kw . ($safe_mode != 1 ? '&safe=' . $safe_mode : '');
if ($token) {
$query .= '&t=' . $token;
}
if (!$globaldir) {
$query .= '&hub=' . \App::get_hostname();
}
if ($search) {
$query .= '&name=' . urlencode($search) . '&keywords=' . urlencode($search);
}
if (strpos($search, '@')) {
$query .= '&address=' . urlencode($search);
}
if ($keywords) {
$query .= '&keywords=' . urlencode($keywords);
}
if ($advanced) {
$query .= '&query=' . urlencode($advanced);
}
if (!is_null($pubforums)) {
$query .= '&pubforums=' . intval($pubforums);
}
$directory_sort_order = get_config('system', 'directory_sort_order');
if (!$directory_sort_order) {
$directory_sort_order = 'date';
}
//.........这里部分代码省略.........