本文整理汇总了PHP中expand_groups函数的典型用法代码示例。如果您正苦于以下问题:PHP expand_groups函数的具体用法?PHP expand_groups怎么用?PHP expand_groups使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了expand_groups函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enumerate_permissions
/**
* @brief Returns an array of contact-ids that are allowed to see this object.
*
* @param object $obj
* @return array
*/
function enumerate_permissions($obj)
{
require_once 'include/group.php';
$allow_people = expand_acl($obj['allow_cid']);
$allow_groups = expand_groups(expand_acl($obj['allow_gid']));
$deny_people = expand_acl($obj['deny_cid']);
$deny_groups = expand_groups(expand_acl($obj['deny_gid']));
$recipients = array_unique(array_merge($allow_people, $allow_groups));
$deny = array_unique(array_merge($deny_people, $deny_groups));
$recipients = array_diff($recipients, $deny);
return $recipients;
}
示例2: network_content
//.........这里部分代码省略.........
if ($contact) {
$content = "@" . $contact[0]["nick"] . "+" . $cid;
}
}
$x = array('is_owner' => true, 'allow_location' => $a->user['allow_location'], 'default_location' => $a->user['default-location'], 'nickname' => $a->user['nickname'], 'lockstate' => $group || $cid || $nets || is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock', 'default_perms' => get_acl_permissions($a->user), 'acl' => populate_acl($group || $cid || $nets ? $def_acl : $a->user, true), 'bang' => $group || $cid || $nets ? '!' : '', 'visitor' => 'block', 'profile_uid' => local_user(), 'acl_data' => construct_acl_data($a, $a->user), 'content' => $content);
$o .= status_editor($a, $x);
}
// We don't have to deal with ACLs on this page. You're looking at everything
// that belongs to you, hence you can see all of it. We will filter by group if
// desired.
$sql_post_table = "";
$sql_options = $star ? " and starred = 1 " : '';
$sql_options .= $bmark ? " and bookmark = 1 " : '';
$sql_extra = $sql_options;
$sql_extra2 = "";
$sql_extra3 = "";
$sql_table = "`thread`";
$sql_parent = "`iid`";
if ($nouveau or strlen($file) or $update) {
$sql_table = "`item`";
$sql_parent = "`parent`";
}
$sql_nets = $nets ? sprintf(" and {$sql_table}.`network` = '%s' ", dbesc($nets)) : '';
if ($group) {
$r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($group), intval($_SESSION['uid']));
if (!count($r)) {
if ($update) {
killme();
}
notice(t('No such group') . EOL);
goaway($a->get_baseurl(true) . '/network/0');
// NOTREACHED
}
$contacts = expand_groups(array($group));
$contact_str_self = "";
if (is_array($contacts) && count($contacts)) {
$contact_str = implode(',', $contacts);
$self = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($_SESSION['uid']));
if (count($self)) {
$contact_str_self = "," . $self[0]["id"];
}
} else {
$contact_str = ' 0 ';
info(t('Group is empty'));
}
//$sql_post_table = " INNER JOIN (SELECT DISTINCT(`parent`) FROM `item` WHERE (`contact-id` IN ($contact_str) OR `allow_gid` like '".protect_sprintf('%<'.intval($group).'>%')."') and deleted = 0 ORDER BY `created` DESC) AS `temp1` ON $sql_table.$sql_parent = `temp1`.`parent` ";
$sql_extra3 .= " AND `contact-id` IN ({$contact_str}{$contact_str_self}) ";
$sql_extra3 .= " AND EXISTS (SELECT id FROM `item` WHERE (`contact-id` IN ({$contact_str}) \n\t\t\t\tOR `allow_gid` like '" . protect_sprintf('%<' . intval($group) . '>%') . "') and deleted = 0 \n\t\t\t\tAND parent = {$sql_table}.{$sql_parent}) ";
$o = replace_macros(get_markup_template("section_title.tpl"), array('$title' => sprintf(t('Group: %s'), $r[0]['name']))) . $o;
} elseif ($cid) {
$r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d\n\t\t\t\tAND `blocked` = 0 AND `pending` = 0 LIMIT 1", intval($cid));
if (count($r)) {
$sql_post_table = " INNER JOIN (SELECT DISTINCT(`parent`) FROM `item` \n\t\t\t\t\t WHERE 1 {$sql_options} AND `contact-id` = " . intval($cid) . " and deleted = 0 \n\t\t\t\t\t ORDER BY `item`.`received` DESC) AS `temp1` \n\t\t\t\t\t ON {$sql_table}.{$sql_parent} = `temp1`.`parent` ";
$sql_extra = "";
$o = replace_macros(get_markup_template("section_title.tpl"), array('$title' => sprintf(t('Contact: %s'), $r[0]['name']))) . $o;
if ($r[0]['network'] === NETWORK_OSTATUS && $r[0]['writable'] && !get_pconfig(local_user(), 'system', 'nowarn_insecure')) {
notice(t('Private messages to this person are at risk of public disclosure.') . EOL);
}
} else {
notice(t('Invalid contact.') . EOL);
goaway($a->get_baseurl(true) . '/network');
// NOTREACHED
}
}
if (!$group && !$cid && !$update && !get_config('theme', 'hide_eventlist')) {
$o .= get_birthdays();
示例3: notifier_run
//.........这里部分代码省略.........
$relay_to_owner = true;
}
if ($cmd === 'uplink' && intval($parent['forum_mode']) && !$top_level) {
$relay_to_owner = true;
}
// until the 'origin' flag has been in use for several months
// we will just use it as a fallback test
// later we will be able to use it as the primary test of whether or not to relay.
if (!$target_item['origin']) {
$relay_to_owner = false;
}
if ($parent['origin']) {
$relay_to_owner = false;
}
if ($relay_to_owner) {
logger('notifier: followup', LOGGER_DEBUG);
// local followup to remote post
$followup = true;
$public_message = false;
// not public
$conversant_str = dbesc($parent['contact-id']);
} else {
$followup = false;
// don't send deletions onward for other people's stuff
if ($target_item['deleted'] && !intval($target_item['wall'])) {
logger('notifier: ignoring delete notification for non-wall item');
return;
}
if (strlen($parent['allow_cid']) || strlen($parent['allow_gid']) || strlen($parent['deny_cid']) || strlen($parent['deny_gid'])) {
$public_message = false;
// private recipients, not public
}
$allow_people = expand_acl($parent['allow_cid']);
$allow_groups = expand_groups(expand_acl($parent['allow_gid']));
$deny_people = expand_acl($parent['deny_cid']);
$deny_groups = expand_groups(expand_acl($parent['deny_gid']));
// if our parent is a forum, uplink to the origonal author causing
// a delivery fork
if (intval($parent['forum_mode']) && !$top_level && $cmd !== 'uplink') {
proc_run('php', 'include/notifier', 'uplink', $item_id);
}
$conversants = array();
foreach ($items as $item) {
$recipients[] = $item['contact-id'];
$conversants[] = $item['contact-id'];
// pull out additional tagged people to notify (if public message)
if ($public_message && strlen($item['inform'])) {
$people = explode(',', $item['inform']);
foreach ($people as $person) {
if (substr($person, 0, 4) === 'cid:') {
$recipients[] = intval(substr($person, 4));
$conversants[] = intval(substr($person, 4));
} else {
$url_recipients[] = substr($person, 4);
}
}
}
}
logger('notifier: url_recipients' . print_r($url_recipients, true));
$conversants = array_unique($conversants);
$recipients = array_unique(array_merge($recipients, $allow_people, $allow_groups));
$deny = array_unique(array_merge($deny_people, $deny_groups));
$recipients = array_diff($recipients, $deny);
$conversant_str = dbesc(implode(', ', $conversants));
}
$r = q("SELECT * FROM `contact` WHERE `id` IN ( {$conversant_str} ) AND `blocked` = 0 AND `pending` = 0");
示例4: fbpost_post_hook
/**
* @param App $a
* @param object $b
* @return mixed
*/
function fbpost_post_hook(&$a, &$b)
{
logger('fbpost_post_hook: Facebook post invoked', LOGGER_DEBUG);
if ($b['deleted'] || $b['created'] !== $b['edited']) {
return;
}
logger('fbpost_post_hook: Facebook post first check successful', LOGGER_DEBUG);
// if post comes from facebook don't send it back
if ($b['extid'] == NETWORK_FACEBOOK) {
return;
}
if ($b['app'] == "Facebook" and $b['verb'] != ACTIVITY_LIKE) {
return;
}
logger('fbpost_post_hook: Facebook post accepted', LOGGER_DEBUG);
/**
* Post to Facebook stream
*/
require_once 'include/group.php';
require_once 'include/html2plain.php';
$reply = false;
$likes = false;
$deny_arr = array();
$allow_arr = array();
$toplevel = $b['id'] == $b['parent'] ? true : false;
$linking = get_pconfig($b['uid'], 'facebook', 'no_linking') ? 0 : 1;
if (!$toplevel && $linking) {
$r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($b['parent']), intval($b['uid']));
//$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
// dbesc($b['parent-uri']),
// intval($b['uid'])
//);
// is it a reply to a facebook post?
// A reply to a toplevel post is only allowed for "real" facebook posts
if (count($r) && substr($r[0]['uri'], 0, 4) === 'fb::') {
$reply = substr($r[0]['uri'], 4);
} elseif (count($r) && substr($r[0]['extid'], 0, 4) === 'fb::' and $r[0]['id'] != $r[0]['parent']) {
$reply = substr($r[0]['extid'], 4);
} else {
return;
}
$u = q("SELECT * FROM user where uid = %d limit 1", intval($b['uid']));
if (!count($u)) {
return;
}
// only accept comments from the item owner. Other contacts are unknown to FB.
if (!link_compare($b['author-link'], $a->get_baseurl() . '/profile/' . $u[0]['nickname'])) {
return;
}
logger('fbpost_post_hook: facebook reply id=' . $reply);
}
if (strstr($b['postopts'], 'facebook') || $b['private'] || $reply) {
if ($b['private'] && $reply === false) {
$allow_people = expand_acl($b['allow_cid']);
$allow_groups = expand_groups(expand_acl($b['allow_gid']));
$deny_people = expand_acl($b['deny_cid']);
$deny_groups = expand_groups(expand_acl($b['deny_gid']));
$recipients = array_unique(array_merge($allow_people, $allow_groups));
$deny = array_unique(array_merge($deny_people, $deny_groups));
$allow_str = dbesc(implode(', ', $recipients));
if ($allow_str) {
logger("fbpost_post_hook: private post to: " . $allow_str, LOGGER_DEBUG);
$r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( {$allow_str} ) AND `network` = 'face'");
if (count($r)) {
foreach ($r as $rr) {
$allow_arr[] = $rr['notify'];
}
}
}
$deny_str = dbesc(implode(', ', $deny));
if ($deny_str) {
$r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( {$deny_str} ) AND `network` = 'face'");
if (count($r)) {
foreach ($r as $rr) {
$deny_arr[] = $rr['notify'];
}
}
}
if (count($deny_arr) && !count($allow_arr)) {
// One or more FB folks were denied access but nobody on FB was specifically allowed access.
// This might cause the post to be open to public on Facebook, but only to selected members
// on another network. Since this could potentially leak a post to somebody who was denied,
// we will skip posting it to Facebook with a slightly vague but relevant message that will
// hopefully lead somebody to this code comment for a better explanation of what went wrong.
notice(t('Post to Facebook cancelled because of multi-network access permission conflict.') . EOL);
return;
}
// if it's a private message but no Facebook members are allowed or denied, skip Facebook post
if (!count($allow_arr) && !count($deny_arr)) {
return;
}
}
if ($b['verb'] == ACTIVITY_LIKE) {
$likes = true;
logger('fbpost_post_hook: liking ' . print_r($b, true), LOGGER_DEBUG);
//.........这里部分代码省略.........
示例5: network_content
//.........这里部分代码省略.........
notice(t('Private messages to this group are at risk of public disclosure.') . EOL);
}
}
nav_set_selected('network');
$_SESSION['return_url'] = $a->cmd;
$celeb = $a->user['page-flags'] == PAGE_SOAPBOX || $a->user['page-flags'] == PAGE_COMMUNITY ? true : false;
$x = array('is_owner' => true, 'allow_location' => $a->user['allow_location'], 'default_location' => $a->user['default_location'], 'nickname' => $a->user['nickname'], 'lockstate' => $group || is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock', 'acl' => populate_acl($group || $cid ? $def_acl : $a->user, $celeb), 'bang' => $group || $cid ? '!' : '', 'visitor' => 'block', 'profile_uid' => local_user());
$o .= status_editor($a, $x);
}
// We aren't going to try and figure out at the item, group, and page
// level which items you've seen and which you haven't. If you're looking
// at the top level network page just mark everything seen.
if (!$group && !$cid && !$star) {
$r = q("UPDATE `item` SET `unseen` = 0 \n\t\t\tWHERE `unseen` = 1 AND `uid` = %d", intval($_SESSION['uid']));
}
// We don't have to deal with ACL's on this page. You're looking at everything
// that belongs to you, hence you can see all of it. We will filter by group if
// desired.
$star_sql = $star ? " AND `starred` = 1 " : '';
if ($bmark) {
$star_sql .= " AND `bookmark` = 1 ";
}
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` {$star_sql} ) ";
if ($group) {
$r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($group), intval($_SESSION['uid']));
if (!count($r)) {
if ($update) {
killme();
}
notice(t('No such group') . EOL);
goaway($a->get_baseurl() . '/network');
// NOTREACHED
}
$contacts = expand_groups(array($group));
if (is_array($contacts) && count($contacts)) {
$contact_str = implode(',', $contacts);
} else {
$contact_str = ' 0 ';
info(t('Group is empty'));
}
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` {$star_sql} AND ( `contact-id` IN ( {$contact_str} ) OR `allow_gid` REGEXP '<" . intval($group) . ">' )) ";
$o = '<h2>' . t('Group: ') . $r[0]['name'] . '</h2>' . $o;
} elseif ($cid) {
$r = q("SELECT `id`,`name`,`network`,`writable` FROM `contact` WHERE `id` = %d \n\t\t\t\tAND `blocked` = 0 AND `pending` = 0 LIMIT 1", intval($cid));
if (count($r)) {
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` {$star_sql} AND `contact-id` IN ( " . intval($cid) . " )) ";
$o = '<h2>' . t('Contact: ') . $r[0]['name'] . '</h2>' . $o;
if ($r[0]['network'] !== NETWORK_MAIL && $r[0]['network'] !== NETWORK_DFRN && $r[0]['network'] !== NETWORK_FACEBOOK && $r[0]['network'] !== NETWORK_DIASPORA && $r[0]['writable'] && !get_pconfig(local_user(), 'system', 'nowarn_insecure')) {
notice(t('Private messages to this person are at risk of public disclosure.') . EOL);
}
} else {
notice(t('Invalid contact.') . EOL);
goaway($a->get_baseurl() . '/network');
// NOTREACHED
}
}
if (!$group && !$cid && !$update) {
$o .= get_birthdays();
$o .= get_events();
}
if (!$update) {
// The special div is needed for liveUpdate to kick in for this page.
// We only launch liveUpdate if you aren't filtering in some incompatible
// way and also you aren't writing a comment (discovered in javascript).
$o .= '<div id="live-network"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . $_SESSION['uid'] . "; var netargs = '" . substr($a->cmd, 8) . '?f=' . (x($_GET, 'cid') ? '&cid=' . $_GET['cid'] : '') . (x($_GET, 'search') ? '&search=' . $_GET['search'] : '') . (x($_GET, 'star') ? '&star=' . $_GET['star'] : '') . (x($_GET, 'order') ? '&order=' . $_GET['order'] : '') . (x($_GET, 'bmark') ? '&bmark=' . $_GET['bmark'] : '') . (x($_GET, 'liked') ? '&liked=' . $_GET['liked'] : '') . (x($_GET, 'conv') ? '&conv=' . $_GET['conv'] : '') . "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
示例6: content_content
function content_content(&$a, $update = 0)
{
require_once 'include/conversation.php';
// Currently security is based on the logged in user
if (!local_user()) {
return;
}
$arr = array('query' => $a->query_string);
call_hooks('content_content_init', $arr);
$datequery = $datequery2 = '';
$group = 0;
$nouveau = false;
if ($a->argc > 1) {
for ($x = 1; $x < $a->argc; $x++) {
if (is_a_date_arg($a->argv[$x])) {
if ($datequery) {
$datequery2 = escape_tags($a->argv[$x]);
} else {
$datequery = escape_tags($a->argv[$x]);
$_GET['order'] = 'post';
}
} elseif ($a->argv[$x] === 'new') {
$nouveau = true;
} elseif (intval($a->argv[$x])) {
$group = intval($a->argv[$x]);
$def_acl = array('allow_gid' => '<' . $group . '>');
}
}
}
$o = '';
$contact_id = $a->cid;
require_once 'include/acl_selectors.php';
$cid = x($_GET, 'cid') ? intval($_GET['cid']) : 0;
$star = x($_GET, 'star') ? intval($_GET['star']) : 0;
$bmark = x($_GET, 'bmark') ? intval($_GET['bmark']) : 0;
$order = x($_GET, 'order') ? notags($_GET['order']) : 'comment';
$liked = x($_GET, 'liked') ? intval($_GET['liked']) : 0;
$conv = x($_GET, 'conv') ? intval($_GET['conv']) : 0;
$spam = x($_GET, 'spam') ? intval($_GET['spam']) : 0;
$nets = x($_GET, 'nets') ? $_GET['nets'] : '';
$cmin = x($_GET, 'cmin') ? intval($_GET['cmin']) : 0;
$cmax = x($_GET, 'cmax') ? intval($_GET['cmax']) : 99;
$file = x($_GET, 'file') ? $_GET['file'] : '';
if (x($_GET, 'search') || x($_GET, 'file')) {
$nouveau = true;
}
if ($cid) {
$def_acl = array('allow_cid' => '<' . intval($cid) . '>');
}
if ($nets) {
$r = q("select id from contact where uid = %d and network = '%s' and self = 0", intval(local_user()), dbesc($nets));
$str = '';
if (count($r)) {
foreach ($r as $rr) {
$str .= '<' . $rr['id'] . '>';
}
}
if (strlen($str)) {
$def_acl = array('allow_cid' => $str);
}
}
$sql_options = $star ? " and starred = 1 " : '';
$sql_options .= $bmark ? " and bookmark = 1 " : '';
$sql_nets = $nets ? sprintf(" and `contact`.`network` = '%s' ", dbesc($nets)) : '';
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` {$sql_options} ) ";
if ($group) {
$r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($group), intval($_SESSION['uid']));
if (!count($r)) {
if ($update) {
killme();
}
notice(t('No such group') . EOL);
goaway($a->get_baseurl(true) . '/network');
// NOTREACHED
}
$contacts = expand_groups(array($group));
if (is_array($contacts) && count($contacts)) {
$contact_str = implode(',', $contacts);
} else {
$contact_str = ' 0 ';
info(t('Group is empty'));
}
$sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 {$sql_options} AND ( `contact-id` IN ( {$contact_str} ) OR `allow_gid` like '" . protect_sprintf('%<' . intval($group) . '>%') . "' ) and deleted = 0 ) ";
$o = replace_macros(get_markup_template("section_title.tpl"), array('$title' => sprintf(t('Group: %s'), $r[0]['name']))) . $o;
} elseif ($cid) {
$r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d \n\t\t\t\tAND `blocked` = 0 AND `pending` = 0 LIMIT 1", intval($cid));
if (count($r)) {
$sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 {$sql_options} AND `contact-id` = " . intval($cid) . " and deleted = 0 ) ";
} else {
killme();
}
}
$sql_extra3 = '';
if ($datequery) {
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery))));
}
if ($datequery2) {
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery2))));
}
$sql_extra2 = $nouveau ? '' : " AND `item`.`parent` = `item`.`id` ";
//.........这里部分代码省略.........
示例7: notifier_run
//.........这里部分代码省略.........
$push_notify = true;
}
// We notify Friendica users in the thread when it is an OStatus thread.
// Hopefully this transfers the messages to the other Friendica servers. (Untested)
if ($thr_parent and $thr_parent[0]['network'] == NETWORK_OSTATUS or $parent['network'] == NETWORK_OSTATUS) {
$push_notify = true;
if ($parent["network"] == NETWORK_OSTATUS) {
$r = q("SELECT `author-link` FROM `item` WHERE `parent` = %d AND `author-link` != '%s'", intval($target_item["parent"]), dbesc($owner['url']));
foreach ($r as $parent_item) {
$probed_contact = probe_url($parent_item["author-link"]);
if ($probed_contact["notify"] != "" and $probed_contact["network"] == NETWORK_DFRN) {
logger('Notify Friendica user ' . $probed_contact["url"] . ': ' . $probed_contact["notify"]);
$url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
}
}
}
if (count($url_recipients)) {
logger("url_recipients " . print_r($url_recipients, true));
}
}
} else {
$followup = false;
logger('Distributing directly ' . $target_item["guid"], LOGGER_DEBUG);
// don't send deletions onward for other people's stuff
if ($target_item['deleted'] && !intval($target_item['wall'])) {
logger('notifier: ignoring delete notification for non-wall item');
return;
}
if (strlen($parent['allow_cid']) || strlen($parent['allow_gid']) || strlen($parent['deny_cid']) || strlen($parent['deny_gid'])) {
$public_message = false;
// private recipients, not public
}
$allow_people = expand_acl($parent['allow_cid']);
$allow_groups = expand_groups(expand_acl($parent['allow_gid']), true);
$deny_people = expand_acl($parent['deny_cid']);
$deny_groups = expand_groups(expand_acl($parent['deny_gid']));
// if our parent is a public forum (forum_mode == 1), uplink to the origional author causing
// a delivery fork. private groups (forum_mode == 2) do not uplink
if (intval($parent['forum_mode']) == 1 && !$top_level && $cmd !== 'uplink') {
proc_run('php', 'include/notifier.php', 'uplink', $item_id);
}
$conversants = array();
foreach ($items as $item) {
$recipients[] = $item['contact-id'];
$conversants[] = $item['contact-id'];
// pull out additional tagged people to notify (if public message)
if ($public_message && strlen($item['inform'])) {
$people = explode(',', $item['inform']);
foreach ($people as $person) {
if (substr($person, 0, 4) === 'cid:') {
$recipients[] = intval(substr($person, 4));
$conversants[] = intval(substr($person, 4));
} else {
$url_recipients[] = substr($person, 4);
}
}
}
}
if (count($url_recipients)) {
logger('notifier: ' . $target_item["guid"] . ' url_recipients ' . print_r($url_recipients, true));
}
$conversants = array_unique($conversants);
$recipients = array_unique(array_merge($recipients, $allow_people, $allow_groups));
$deny = array_unique(array_merge($deny_people, $deny_groups));
$recipients = array_diff($recipients, $deny);
$conversant_str = dbesc(implode(', ', $conversants));
示例8: network_content
function network_content(&$a, $update = false)
{
if (!local_user()) {
return;
}
require_once "include/bbcode.php";
$contact_id = $a->cid;
$group = 0;
if (!$update) {
// pull out the group here because the updater might have different args
if ($a->argc > 1) {
$group = intval($a->argv[1]);
}
$_SESSION['return_url'] = $a->cmd;
$tpl = file_get_contents('view/jot-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl()));
require_once 'view/acl_selectors.php';
$tpl = file_get_contents("view/jot.tpl");
$o .= replace_macros($tpl, array('$return_path' => $a->cmd, '$baseurl' => $a->get_baseurl(), '$defloc' => $a->user['default-location'], '$visitor' => 'block', '$lockstate' => 'unlock', '$acl' => populate_acl($a->user), '$profile_uid' => $_SESSION['uid']));
// The special div is needed for liveUpdate to kick in for this page.
// We only launch liveUpdate if you are on the front page, you aren't
// filtering by group and also you aren't writing a comment (the last
// criteria is discovered in javascript).
if ($a->pager['start'] == 0 && $a->argc == 1) {
$o .= '<div id="live-network"></div>' . "\r\n";
}
}
// We aren't going to try and figure out at the item, group, and page level
// which items you've seen and which you haven't. You're looking at some
// subset of items, so just mark everything seen.
$r = q("UPDATE `item` SET `unseen` = 0 WHERE `unseen` = 1 ");
// We don't have to deal with ACL's on this page. You're looking at everything
// that belongs to you, hence you can see all of it. We will filter by group if
// desired.
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `type` IN ('wall', 'photo', 'remote' )) ";
$sql_extra = '';
if ($group) {
$r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d LIMIT 1", intval($group));
if (!count($r)) {
notice(t('No such group') . EOL);
goaway($a->get_baseurl() . '/network');
return;
// NOTREACHED
}
$contacts = expand_groups(array($group));
$contact_str = implode(',', $contacts);
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `type` IN ('wall', 'photo', 'remote') AND `contact-id` IN ( {$contact_str} )) ";
$o = '<h4>' . t('Group: ') . $r[0]['name'] . '</h4>' . $o;
}
$r = q("SELECT COUNT(*) AS `total`\n\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tWHERE `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t{$sql_extra} ");
if (count($r)) {
$a->set_pager_total($r[0]['total']);
}
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, \n\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, \n\t\t`contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, \n\t\t`contact`.`id` AS `cid`\n\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tWHERE `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t{$sql_extra}\n\t\tORDER BY `parent` DESC, `created` ASC LIMIT %d ,%d ", intval($a->pager['start']), intval($a->pager['itemspage']));
$cmnt_tpl = file_get_contents('view/comment_item.tpl');
$tpl = file_get_contents('view/wall_item.tpl');
$wallwall = file_get_contents('view/wallwall_item.tpl');
if (count($r)) {
foreach ($r as $item) {
$comment = '';
$template = $tpl;
$commentww = '';
$profile_url = $item['url'];
$redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'];
// Top-level wall post not written by the wall owner (wall-to-wall)
// First figure out who owns it.
if ($item['parent'] == $item['item_id'] && !$item['self']) {
if ($item['type'] == 'wall') {
// I do. Put me on the left of the wall-to-wall notice.
$owner_url = $a->contact['url'];
$owner_photo = $a->contact['thumb'];
$owner_name = $a->contact['name'];
$template = $wallwall;
$commentww = 'ww';
}
if ($item['type'] == 'remote' && $item['owner-link'] != $item['author-link']) {
// Could be anybody.
$owner_url = $item['owner-link'];
$owner_photo = $item['owner-avatar'];
$owner_name = $item['owner-name'];
$template = $wallwall;
$commentww = 'ww';
// If it is our contact, use a friendly redirect link
if ($item['owner-link'] == $item['url'] && ($item['rel'] == DIRECTION_IN || $item['rel'] == DIRECTION_BOTH)) {
$owner_url = $redirect_url;
}
}
}
if ($update) {
$return_url = $_SESSION['return_url'];
} else {
$return_url = $_SESSION['return_url'] = $a->cmd;
}
if ($item['last-child']) {
$comment = replace_macros($cmnt_tpl, array('$return_path' => $_SESSION['return_url'], '$type' => 'net-comment', '$id' => $item['item_id'], '$parent' => $item['parent'], '$profile_uid' => $_SESSION['uid'], '$mylink' => $a->contact['url'], '$mytitle' => t('Me'), '$myphoto' => $a->contact['thumb'], '$ww' => $commentww));
}
$drop = replace_macros(file_get_contents('view/wall_item_drop.tpl'), array('$id' => $item['id']));
if (strlen($item['dfrn-id']) && !$item['self']) {
$profile_url = $redirect_url;
}
//.........这里部分代码省略.........
示例9: killme
} else {
killme();
}
if ($cmd != 'mail') {
require_once 'include/group.php';
$parent = $items[0];
if ($parent['type'] == 'remote') {
// local followup to remote post
$followup = true;
$conversant_str = dbesc($parent['contact-id']);
} else {
$followup = false;
$allow_people = expand_acl($parent['allow_cid']);
$allow_groups = expand_groups(expand_acl($parent['allow_gid']));
$deny_people = expand_acl($parent['deny_cid']);
$deny_groups = expand_groups(expand_acl($parent['deny_gid']));
$conversants = array();
foreach ($items as $item) {
$recipients[] = $item['contact-id'];
$conversants[] = $item['contact-id'];
}
$conversants = array_unique($conversants, SORT_NUMERIC);
$recipients = array_unique(array_merge($recipients, $allow_people, $allow_groups), SORT_NUMERIC);
$deny = array_unique(array_merge($deny_people, $deny_groups), SORT_NUMERIC);
$recipients = array_diff($recipients, $deny);
$conversant_str = dbesc(implode(', ', $conversants));
}
$r = q("SELECT * FROM `contact` WHERE `id` IN ( {$conversant_str} ) AND `blocked` = 0 AND `pending` = 0");
if (!count($r)) {
killme();
}
示例10: facebook_post_hook
/**
* @param App $a
* @param object $b
* @return mixed
*/
function facebook_post_hook(&$a, &$b)
{
if ($b['deleted'] || $b['created'] !== $b['edited']) {
return;
}
/**
* Post to Facebook stream
*/
require_once 'include/group.php';
require_once 'include/html2plain.php';
logger('Facebook post');
$reply = false;
$likes = false;
$deny_arr = array();
$allow_arr = array();
$toplevel = $b['id'] == $b['parent'] ? true : false;
$linking = get_pconfig($b['uid'], 'facebook', 'no_linking') ? 0 : 1;
if (!$toplevel && $linking) {
$r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($b['parent']), intval($b['uid']));
if (count($r) && substr($r[0]['uri'], 0, 4) === 'fb::') {
$reply = substr($r[0]['uri'], 4);
} elseif (count($r) && substr($r[0]['extid'], 0, 4) === 'fb::') {
$reply = substr($r[0]['extid'], 4);
} else {
return;
}
$u = q("SELECT * FROM user where uid = %d limit 1", intval($b['uid']));
if (!count($u)) {
return;
}
// only accept comments from the item owner. Other contacts are unknown to FB.
if (!link_compare($b['author-link'], $a->get_baseurl() . '/profile/' . $u[0]['nickname'])) {
return;
}
logger('facebook reply id=' . $reply);
}
if (strstr($b['postopts'], 'facebook') || $b['private'] || $reply) {
if ($b['private'] && $reply === false) {
$allow_people = expand_acl($b['allow_cid']);
$allow_groups = expand_groups(expand_acl($b['allow_gid']));
$deny_people = expand_acl($b['deny_cid']);
$deny_groups = expand_groups(expand_acl($b['deny_gid']));
$recipients = array_unique(array_merge($allow_people, $allow_groups));
$deny = array_unique(array_merge($deny_people, $deny_groups));
$allow_str = dbesc(implode(', ', $recipients));
if ($allow_str) {
$r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( {$allow_str} ) AND `network` = 'face'");
if (count($r)) {
foreach ($r as $rr) {
$allow_arr[] = $rr['notify'];
}
}
}
$deny_str = dbesc(implode(', ', $deny));
if ($deny_str) {
$r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( {$deny_str} ) AND `network` = 'face'");
if (count($r)) {
foreach ($r as $rr) {
$deny_arr[] = $rr['notify'];
}
}
}
if (count($deny_arr) && !count($allow_arr)) {
// One or more FB folks were denied access but nobody on FB was specifically allowed access.
// This might cause the post to be open to public on Facebook, but only to selected members
// on another network. Since this could potentially leak a post to somebody who was denied,
// we will skip posting it to Facebook with a slightly vague but relevant message that will
// hopefully lead somebody to this code comment for a better explanation of what went wrong.
notice(t('Post to Facebook cancelled because of multi-network access permission conflict.') . EOL);
return;
}
// if it's a private message but no Facebook members are allowed or denied, skip Facebook post
if (!count($allow_arr) && !count($deny_arr)) {
return;
}
}
if ($b['verb'] == ACTIVITY_LIKE) {
$likes = true;
}
$appid = get_config('facebook', 'appid');
$secret = get_config('facebook', 'appsecret');
if ($appid && $secret) {
logger('facebook: have appid+secret');
$fb_token = get_pconfig($b['uid'], 'facebook', 'access_token');
// post to facebook if it's a public post and we've ticked the 'post to Facebook' box,
// or it's a private message with facebook participants
// or it's a reply or likes action to an existing facebook post
if ($fb_token && ($toplevel || $b['private'] || $reply)) {
logger('facebook: able to post');
require_once 'library/facebook.php';
require_once 'include/bbcode.php';
$msg = $b['body'];
logger('Facebook post: original msg=' . $msg, LOGGER_DATA);
// make links readable before we strip the code
// unless it's a dislike - just send the text as a comment
//.........这里部分代码省略.........
示例11: network_content
//.........这里部分代码省略.........
if (strlen($str)) {
$def_acl = array('allow_cid' => $str);
}
}
if (!$update) {
if ($group) {
if (($t = group_public_members($group)) && !get_pconfig(local_user(), 'system', 'nowarn_insecure')) {
notice(sprintf(tt('Warning: This group contains %s member from an insecure network.', 'Warning: This group contains %s members from an insecure network.', $t), $t) . EOL);
notice(t('Private messages to this group are at risk of public disclosure.') . EOL);
}
}
nav_set_selected('network');
$celeb = $a->user['page-flags'] == PAGE_SOAPBOX || $a->user['page-flags'] == PAGE_COMMUNITY ? true : false;
$x = array('is_owner' => true, 'allow_location' => $a->user['allow_location'], 'default_location' => $a->user['default-location'], 'nickname' => $a->user['nickname'], 'lockstate' => $group || $cid || $nets || is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock', 'acl' => populate_acl($group || $cid || $nets ? $def_acl : $a->user, $celeb), 'bang' => $group || $cid || $nets ? '!' : '', 'visitor' => 'block', 'profile_uid' => local_user());
$o .= status_editor($a, $x);
}
// We don't have to deal with ACL's on this page. You're looking at everything
// that belongs to you, hence you can see all of it. We will filter by group if
// desired.
$sql_options = $star ? " and starred = 1 " : '';
$sql_options .= $bmark ? " and bookmark = 1 " : '';
$sql_nets = $nets ? sprintf(" and `contact`.`network` = '%s' ", dbesc($nets)) : '';
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` {$sql_options} ) ";
if ($group) {
$r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($group), intval($_SESSION['uid']));
if (!count($r)) {
if ($update) {
killme();
}
notice(t('No such group') . EOL);
goaway($a->get_baseurl(true) . '/network');
// NOTREACHED
}
$contacts = expand_groups(array($group));
if (is_array($contacts) && count($contacts)) {
$contact_str = implode(',', $contacts);
} else {
$contact_str = ' 0 ';
info(t('Group is empty'));
}
$sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 {$sql_options} AND ( `contact-id` IN ( {$contact_str} ) OR `allow_gid` like '" . protect_sprintf('%<' . intval($group) . '>%') . "' ) and deleted = 0 ) ";
$o = '<h2>' . t('Group: ') . $r[0]['name'] . '</h2>' . $o;
} elseif ($cid) {
$r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d \n\t\t\t\tAND `blocked` = 0 AND `pending` = 0 LIMIT 1", intval($cid));
if (count($r)) {
$sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 {$sql_options} AND `contact-id` = " . intval($cid) . " and deleted = 0 ) ";
$o = '<h2>' . t('Contact: ') . $r[0]['name'] . '</h2>' . $o;
if ($r[0]['network'] === NETWORK_OSTATUS && $r[0]['writable'] && !get_pconfig(local_user(), 'system', 'nowarn_insecure')) {
notice(t('Private messages to this person are at risk of public disclosure.') . EOL);
}
} else {
notice(t('Invalid contact.') . EOL);
goaway($a->get_baseurl(true) . '/network');
// NOTREACHED
}
}
if (!$group && !$cid && !$update) {
$o .= get_birthdays();
$o .= get_events();
}
if (!$update) {
// The special div is needed for liveUpdate to kick in for this page.
// We only launch liveUpdate if you aren't filtering in some incompatible
// way and also you aren't writing a comment (discovered in javascript).
$o .= '<div id="live-network"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . $_SESSION['uid'] . "; var netargs = '" . substr($a->cmd, 8) . '?f=' . (x($_GET, 'cid') ? '&cid=' . $_GET['cid'] : '') . (x($_GET, 'search') ? '&search=' . $_GET['search'] : '') . (x($_GET, 'star') ? '&star=' . $_GET['star'] : '') . (x($_GET, 'order') ? '&order=' . $_GET['order'] : '') . (x($_GET, 'bmark') ? '&bmark=' . $_GET['bmark'] : '') . (x($_GET, 'liked') ? '&liked=' . $_GET['liked'] : '') . (x($_GET, 'conv') ? '&conv=' . $_GET['conv'] : '') . (x($_GET, 'spam') ? '&spam=' . $_GET['spam'] : '') . (x($_GET, 'nets') ? '&nets=' . $_GET['nets'] : '') . (x($_GET, 'cmin') ? '&cmin=' . $_GET['cmin'] : '') . (x($_GET, 'cmax') ? '&cmax=' . $_GET['cmax'] : '') . (x($_GET, 'file') ? '&file=' . $_GET['file'] : '') . "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
示例12: network_content
//.........这里部分代码省略.........
$def_acl = array('allow_cid' => $str);
}
}
set_pconfig(local_user(), 'network.view', 'net.selected', $nets ? $nets : 'all');
if (!$update) {
if ($group) {
if (($t = group_public_members($group)) && !get_pconfig(local_user(), 'system', 'nowarn_insecure')) {
notice(sprintf(tt('Warning: This group contains %s member from an insecure network.', 'Warning: This group contains %s members from an insecure network.', $t), $t) . EOL);
notice(t('Private messages to this group are at risk of public disclosure.') . EOL);
}
}
nav_set_selected('network');
$celeb = $a->user['page-flags'] == PAGE_SOAPBOX || $a->user['page-flags'] == PAGE_COMMUNITY ? true : false;
$x = array('is_owner' => true, 'allow_location' => $a->user['allow_location'], 'default_location' => $a->user['default-location'], 'nickname' => $a->user['nickname'], 'lockstate' => $group || $cid || $nets || is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock', 'default_perms' => get_acl_permissions($a->user), 'acl' => populate_acl($group || $cid || $nets ? $def_acl : $a->user, $celeb), 'bang' => $group || $cid || $nets ? '!' : '', 'visitor' => 'block', 'profile_uid' => local_user(), 'acl_data' => construct_acl_data($a, $a->user));
$o .= status_editor($a, $x);
}
// We don't have to deal with ACLs on this page. You're looking at everything
// that belongs to you, hence you can see all of it. We will filter by group if
// desired.
$sql_options = $star ? " and starred = 1 " : '';
$sql_options .= $bmark ? " and bookmark = 1 " : '';
$sql_nets = $nets ? sprintf(" and `contact`.`network` = '%s' ", dbesc($nets)) : '';
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` {$sql_options} ) ";
if ($group) {
$r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($group), intval($_SESSION['uid']));
if (!count($r)) {
if ($update) {
killme();
}
notice(t('No such group') . EOL);
goaway($a->get_baseurl(true) . '/network/0');
// NOTREACHED
}
$contacts = expand_groups(array($group));
if (is_array($contacts) && count($contacts)) {
$contact_str = implode(',', $contacts);
} else {
$contact_str = ' 0 ';
info(t('Group is empty'));
}
$sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 {$sql_options} AND ( `contact-id` IN ( {$contact_str} ) OR `allow_gid` like '" . protect_sprintf('%<' . intval($group) . '>%') . "' ) and deleted = 0 ) ";
$o = '<h2>' . t('Group: ') . $r[0]['name'] . '</h2>' . $o;
} elseif ($cid) {
$r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d \n\t\t\t\tAND `blocked` = 0 AND `pending` = 0 LIMIT 1", intval($cid));
if (count($r)) {
$sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 {$sql_options} AND `contact-id` = " . intval($cid) . " and deleted = 0 ) ";
$o = '<h2>' . t('Contact: ') . $r[0]['name'] . '</h2>' . $o;
if ($r[0]['network'] === NETWORK_OSTATUS && $r[0]['writable'] && !get_pconfig(local_user(), 'system', 'nowarn_insecure')) {
notice(t('Private messages to this person are at risk of public disclosure.') . EOL);
}
} else {
notice(t('Invalid contact.') . EOL);
goaway($a->get_baseurl(true) . '/network');
// NOTREACHED
}
}
if (!$group && !$cid && !$update && !get_config('theme', 'hide_eventlist')) {
$o .= get_birthdays();
$o .= get_events();
}
$sql_extra3 = '';
if ($datequery) {
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery))));
}
if ($datequery2) {
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery2))));