本文整理汇总了PHP中conversation函数的典型用法代码示例。如果您正苦于以下问题:PHP conversation函数的具体用法?PHP conversation怎么用?PHP conversation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了conversation函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: community_content
function community_content(&$a, $update = 0)
{
$o = '';
if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
notice(t('Public access denied.') . EOL);
return;
}
if (get_config('system', 'no_community_page')) {
notice(t('Not available.') . EOL);
return;
}
require_once "include/bbcode.php";
require_once 'include/security.php';
require_once 'include/conversation.php';
$o .= '<h3>' . t('Community') . '</h3>';
if (!$update) {
nav_set_selected('community');
}
if (x($a->data, 'search')) {
$search = notags(trim($a->data['search']));
} else {
$search = x($_GET, 'search') ? notags(trim(rawurldecode($_GET['search']))) : '';
}
// Here is the way permissions work in this module...
// Only public posts can be shown
// OR your own posts if you are a logged in member
if (!get_config('alt_pager', 'global') && !get_pconfig(local_user(), 'system', 'alt_pager')) {
$r = q("SELECT COUNT(distinct(`item`.`uri`)) AS `total`\n\t\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`\n\t\t\tWHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0\n\t\t\tAND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' \n\t\t\tAND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''\n\t\t\tAND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0 \n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0");
if (count($r)) {
$a->set_pager_total($r[0]['total']);
}
if (!$r[0]['total']) {
info(t('No results.') . EOL);
return $o;
}
}
//$r = q("SELECT distinct(`item`.`uri`)
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`, \n\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`,\n\t\t`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, \n\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,\n\t\t`user`.`nickname`, `user`.`hidewall`\n\t\tFROM `item` FORCE INDEX (`received`) LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tLEFT JOIN `user` ON `user`.`uid` = `item`.`uid`\n\t\tWHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0\n\t\tAND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''\n\t\tAND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' \n\t\tAND `item`.`private` = 0 AND `item`.`wall` = 1 AND `item`.`id` = `item`.`parent`\n\t\tAND `user`.`hidewall` = 0\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self`\n\t\tORDER BY `received` DESC LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
// group by `item`.`uri`
if (!count($r)) {
info(t('No results.') . EOL);
return $o;
}
// we behave the same in message lists as the search module
$o .= conversation($a, $r, 'community', $update);
if (get_config('alt_pager', 'global') || get_pconfig(local_user(), 'system', 'alt_pager')) {
$o .= alt_pager($a, count($r));
} else {
$o .= paginate($a);
}
return $o;
}
示例2: notes_content
function notes_content(&$a, $update = false)
{
if (!local_user()) {
notice(t('Permission denied.') . EOL);
return;
}
require_once "include/bbcode.php";
require_once 'include/security.php';
require_once 'include/conversation.php';
require_once 'include/acl_selectors.php';
$groups = array();
$o = '';
$remote_contact = false;
$contact_id = $_SESSION['cid'];
$contact = $a->contact;
$is_owner = true;
$o = "";
$o .= profile_tabs($a, True);
if (!$update) {
$o .= '<h3>' . t('Personal Notes') . '</h3>';
$commpage = false;
$commvisitor = false;
$celeb = false;
$x = array('is_owner' => $is_owner, 'allow_location' => $a->user['allow_location'] ? true : false, 'default_location' => $a->user['default-location'], 'nickname' => $a->user['nickname'], 'lockstate' => 'lock', 'acl' => '', 'bang' => '', 'visitor' => 'block', 'profile_uid' => local_user(), 'button' => t('Save'), 'acl_data' => '');
$o .= status_editor($a, $x, $a->contact['id']);
}
// Construct permissions
// default permissions - anonymous user
$sql_extra = " AND `allow_cid` = '<" . $a->contact['id'] . ">' ";
$r = q("SELECT COUNT(*) AS `total`\n\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 \n\t\tAND `item`.`deleted` = 0 AND `item`.`type` = 'note'\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self` = 1\n\t\tAND `item`.`id` = `item`.`parent` AND `item`.`wall` = 0\n\t\t{$sql_extra} ", intval(local_user()));
if (count($r)) {
$a->set_pager_total($r[0]['total']);
$a->set_pager_itemspage(40);
}
$r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid`\n\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 \n\t\tand `item`.`moderated` = 0 AND `item`.`type` = 'note'\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self` = 1\n\t\tAND `item`.`id` = `item`.`parent` AND `item`.`wall` = 0\n\t\t{$sql_extra}\n\t\tORDER BY `item`.`created` DESC LIMIT %d ,%d ", intval(local_user()), intval($a->pager['start']), intval($a->pager['itemspage']));
$parents_arr = array();
$parents_str = '';
if (count($r)) {
foreach ($r as $rr) {
$parents_arr[] = $rr['item_id'];
}
$parents_str = implode(', ', $parents_arr);
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, \n\t\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`network`, `contact`.`rel`, \n\t\t\t`contact`.`thumb`, `contact`.`self`, `contact`.`writable`, \n\t\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`\n\t\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0\n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\tAND `item`.`parent` IN ( %s )\n\t\t\t{$sql_extra}\n\t\t\tORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ", intval(local_user()), dbesc($parents_str));
if (count($r)) {
$items = conv_sort($r, "`commented`");
$o .= conversation($a, $items, 'notes', $update);
}
}
$o .= paginate($a);
return $o;
}
示例3: community_content
function community_content(&$a, $update = 0)
{
$o = '';
if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
notice(t('Public access denied.') . EOL);
return;
}
if (get_config('system', 'no_community_page')) {
notice(t('Not available.') . EOL);
return;
}
require_once "include/bbcode.php";
require_once 'include/security.php';
require_once 'include/conversation.php';
$o .= '<h3>' . t('Community') . '</h3>';
if (!$update) {
nav_set_selected('community');
$o .= '<div id="live-community"></div>' . "\r\n";
$o .= "<script> var profile_uid = -1; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
}
if (x($a->data, 'search')) {
$search = notags(trim($a->data['search']));
} else {
$search = x($_GET, 'search') ? notags(trim(rawurldecode($_GET['search']))) : '';
}
// Here is the way permissions work in this module...
// Only public wall posts can be shown
// OR your own posts if you are a logged in member
$r = q("SELECT COUNT(*) AS `total`\n\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`\n\t\tWHERE `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\tAND `wall` = 1 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' \n\t\tAND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `user`.`hidewall` = 0 \n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 ");
if (count($r)) {
$a->set_pager_total($r[0]['total']);
}
if (!$r[0]['total']) {
info(t('No results.') . EOL);
return $o;
}
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, \n\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,\n\t\t`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, \n\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,\n\t\t`user`.`nickname`, `user`.`hidewall`\n\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tLEFT JOIN `user` ON `user`.`uid` = `item`.`uid`\n\t\tWHERE `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\tAND `wall` = 1 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' \n\t\tAND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `user`.`hidewall` = 0 \n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\tORDER BY `received` DESC LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
// we behave the same in message lists as the search module
$o .= conversation($a, $r, 'community', false);
$o .= paginate($a);
$o .= '<div class="cc-license">' . t('Shared content is covered by the <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0</a> license.') . '</div>';
return $o;
}
示例4: search_content
function search_content(&$a)
{
if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
notice(t('Public access denied.') . EOL);
return;
}
nav_set_selected('search');
require_once "include/bbcode.php";
require_once 'include/security.php';
require_once 'include/conversation.php';
$o = '<div id="live-search"></div>' . "\r\n";
$o .= '<h3>' . t('Search This Site') . '</h3>';
if (x($a->data, 'search')) {
$search = notags(trim($a->data['search']));
} else {
$search = x($_GET, 'search') ? notags(trim(rawurldecode($_GET['search']))) : '';
}
$o .= search($search, 'search-box', '/search', local_user() ? true : false);
if (!$search) {
return $o;
}
// Here is the way permissions work in the search module...
// Only public wall posts can be shown
// OR your own posts if you are a logged in member
$s_regx = sprintf("AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' )", dbesc(preg_quote($search)), dbesc('\\]' . preg_quote($search) . '\\['));
$search_alg = $s_regx;
$r = q("SELECT COUNT(*) AS `total`\n\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`\n\t\tWHERE `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\tAND (( `wall` = 1 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `user`.`hidewall` = 0) \n\t\t\tOR `item`.`uid` = %d )\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t{$search_alg} ", intval(local_user()));
if (count($r)) {
$a->set_pager_total($r[0]['total']);
}
if (!$r[0]['total']) {
info(t('No results.') . EOL);
return $o;
}
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, \n\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,\n\t\t`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, \n\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,\n\t\t`user`.`nickname`\n\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tLEFT JOIN `user` ON `user`.`uid` = `item`.`uid`\n\t\tWHERE `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\tAND (( `wall` = 1 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `user`.`hidewall` = 0 ) \n\t\t\tOR `item`.`uid` = %d )\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t{$search_alg}\n\t\tORDER BY `received` DESC LIMIT %d , %d ", intval(local_user()), intval($a->pager['start']), intval($a->pager['itemspage']));
$o .= '<h2>Search results for: ' . $search . '</h2>';
$o .= conversation($a, $r, 'search', false);
$o .= paginate($a);
return $o;
}
示例5: search_content
function search_content(&$a, $update = 0, $load = false)
{
if (get_config('system', 'block_public') || get_config('system', 'block_public_search')) {
if (!local_channel() && !remote_channel()) {
notice(t('Public access denied.') . EOL);
return;
}
}
if ($load) {
$_SESSION['loadtime'] = datetime_convert();
}
nav_set_selected('search');
require_once "include/bbcode.php";
require_once 'include/security.php';
require_once 'include/conversation.php';
require_once 'include/items.php';
$format = $_REQUEST['format'] ? $_REQUEST['format'] : '';
if ($format !== '') {
$update = $load = 1;
}
$observer = $a->get_observer();
$observer_hash = $observer ? $observer['xchan_hash'] : '';
$o = '<div id="live-search"></div>' . "\r\n";
$o .= '<h3>' . t('Search') . '</h3>';
if (x($a->data, 'search')) {
$search = trim($a->data['search']);
} else {
$search = x($_GET, 'search') ? trim(rawurldecode($_GET['search'])) : '';
}
$tag = false;
if (x($_GET, 'tag')) {
$tag = true;
$search = x($_GET, 'tag') ? trim(rawurldecode($_GET['tag'])) : '';
}
if (!local_channel() || !feature_enabled(local_channel(), 'savedsearch')) {
$o .= search($search, 'search-box', '/search', local_channel() ? true : false);
}
if (strpos($search, '#') === 0) {
$tag = true;
$search = substr($search, 1);
}
if (strpos($search, '@') === 0) {
$search = substr($search, 1);
goaway(z_root() . '/directory' . '?f=1&search=' . $search);
}
// look for a naked webbie
if (strpos($search, '@') !== false) {
goaway(z_root() . '/directory' . '?f=1&search=' . $search);
}
if (!$search) {
return $o;
}
if ($tag) {
$sql_extra = sprintf(" AND `item`.`id` IN (select `oid` from term where otype = %d and type = %d and term = '%s') ", intval(TERM_OBJ_POST), intval(TERM_HASHTAG), dbesc(protect_sprintf($search)));
} else {
$regstr = db_getfunc('REGEXP');
$sql_extra = sprintf(" AND `item`.`body` {$regstr} '%s' ", dbesc(protect_sprintf(preg_quote($search))));
}
// Here is the way permissions work in the search module...
// Only public posts can be shown
// OR your own posts if you are a logged in member
// No items will be shown if the member has a blocked profile wall.
if (!$update && !$load) {
// This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
// because browser prefetching might change it on us. We have to deliver it with the page.
$o .= '<div id="live-search"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . (intval(local_channel()) ? local_channel() : -1) . "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
$a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"), array('$baseurl' => z_root(), '$pgtype' => 'search', '$uid' => $a->profile['profile_uid'] ? $a->profile['profile_uid'] : '0', '$gid' => '0', '$cid' => '0', '$cmin' => '0', '$cmax' => '0', '$star' => '0', '$liked' => '0', '$conv' => '0', '$spam' => '0', '$fh' => '0', '$nouveau' => '0', '$wall' => '0', '$list' => x($_REQUEST, 'list') ? intval($_REQUEST['list']) : 0, '$page' => $a->pager['page'] != 1 ? $a->pager['page'] : 1, '$search' => ($tag ? urlencode('#') : '') . $search, '$order' => '', '$file' => '', '$cats' => '', '$tags' => '', '$mid' => '', '$verb' => '', '$dend' => '', '$dbegin' => ''));
}
$pub_sql = public_permissions_sql($observer_hash);
require_once 'include/identity.php';
$sys = get_sys_channel();
if ($update && $load) {
$itemspage = get_pconfig(local_channel(), 'system', 'itemspage');
$a->set_pager_itemspage(intval($itemspage) ? $itemspage : 20);
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($a->pager['itemspage']), intval($a->pager['start']));
// in case somebody turned off public access to sys channel content with permissions
if (!perm_is_allowed($sys['channel_id'], $observer_hash, 'view_stream')) {
$sys['xchan_hash'] .= 'disabled';
}
if ($load) {
$r = null;
if (ACTIVE_DBTYPE == DBTYPE_POSTGRES) {
$prefix = 'distinct on (created, mid)';
$suffix = 'ORDER BY created DESC, mid';
} else {
$prefix = 'distinct';
$suffix = 'group by mid ORDER BY created DESC';
}
if (local_channel()) {
$r = q("SELECT {$prefix} mid, item.id as item_id, item.* from item\n\t\t\t\t\tWHERE item_restrict = 0\n\t\t\t\t\tAND ((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 ) \n\t\t\t\t\tOR ( `item`.`uid` = %d )) OR item.owner_xchan = '%s' )\n\t\t\t\t\t{$sql_extra}\n\t\t\t\t\t{$suffix} {$pager_sql} ", intval(local_channel()), dbesc($sys['xchan_hash']));
}
if ($r === null) {
$r = q("SELECT {$prefix} mid, item.id as item_id, item.* from item\n\t\t\t\t\tWHERE item_restrict = 0\n\t\t\t\t\tAND (((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = ''\n\t\t\t\t\tAND `item`.`deny_gid` = '' AND item_private = 0 )\n\t\t\t\t\tand owner_xchan in ( " . stream_perms_xchans($observer ? PERMS_NETWORK | PERMS_PUBLIC : PERMS_PUBLIC) . " ))\n\t\t\t\t\t\t{$pub_sql} ) OR owner_xchan = '%s')\n\t\t\t\t\t{$sql_extra} \n\t\t\t\t\t{$suffix} {$pager_sql}", dbesc($sys['xchan_hash']));
}
} else {
$r = array();
}
}
if ($r) {
//.........这里部分代码省略.........
示例6: network_content
function network_content(&$a, $update = 0)
{
require_once 'include/conversation.php';
if (!local_user()) {
$_SESSION['return_url'] = $a->query_string;
return login(false);
}
$arr = array('query' => $a->query_string);
call_hooks('network_content_init', $arr);
$o = '';
// item filter tabs
// TODO: fix this logic, reduce duplication
//$a->page['content'] .= '<div class="tabs-wrapper">';
$starred_active = '';
$new_active = '';
$bookmarked_active = '';
$all_active = '';
$search_active = '';
$conv_active = '';
$spam_active = '';
if ($a->argc > 1 && $a->argv[1] === 'new' || $a->argc > 2 && $a->argv[2] === 'new') {
$new_active = 'active';
}
if (x($_GET, 'search')) {
$search_active = 'active';
}
if (x($_GET, 'star')) {
$starred_active = 'active';
}
if (x($_GET, 'bmark')) {
$bookmarked_active = 'active';
}
if (x($_GET, 'conv')) {
$conv_active = 'active';
}
if (x($_GET, 'spam')) {
$spam_active = 'active';
}
if ($new_active == '' && $starred_active == '' && $bookmarked_active == '' && $conv_active == '' && $search_active == '' && $spam_active == '') {
$all_active = 'active';
}
$postord_active = '';
if ($all_active && x($_GET, 'order') && $_GET['order'] !== 'comment') {
$all_active = '';
$postord_active = 'active';
}
// tabs
$tabs = array(array('label' => t('Commented Order'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . (x($_GET, 'cid') ? '?f=&cid=' . $_GET['cid'] : ''), 'sel' => $all_active, 'title' => t('Sort by Comment Date')), array('label' => t('Posted Order'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . '?f=&order=post' . (x($_GET, 'cid') ? '&cid=' . $_GET['cid'] : ''), 'sel' => $postord_active, 'title' => t('Sort by Post Date')), array('label' => t('Personal'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . (x($_GET, 'cid') ? '/?f=&cid=' . $_GET['cid'] : '') . '&conv=1', 'sel' => $conv_active, 'title' => t('Posts that mention or involve you')), array('label' => t('New'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . '/new' . (x($_GET, 'cid') ? '/?f=&cid=' . $_GET['cid'] : ''), 'sel' => $new_active, 'title' => t('Activity Stream - by date')), array('label' => t('Starred'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . (x($_GET, 'cid') ? '/?f=&cid=' . $_GET['cid'] : '') . '&star=1', 'sel' => $starred_active, 'title' => t('Favourite Posts')), array('label' => t('Shared Links'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . (x($_GET, 'cid') ? '/?f=&cid=' . $_GET['cid'] : '') . '&bmark=1', 'sel' => $bookmarked_active, 'title' => t('Interesting Links')));
$arr = array('tabs' => $tabs);
call_hooks('network_tabs', $arr);
$o .= replace_macros(get_markup_template('common_tabs.tpl'), array('$tabs' => $arr['tabs']));
// --- end item filter tabs
$contact_id = $a->cid;
$group = 0;
$nouveau = false;
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 ($a->argc > 2 && $a->argv[2] === 'new') {
$nouveau = true;
}
if ($a->argc > 1) {
if ($a->argv[1] === 'new') {
$nouveau = true;
} else {
$group = intval($a->argv[1]);
$def_acl = array('allow_gid' => '<' . $group . '>');
}
}
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);
}
}
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);
//.........这里部分代码省略.........
示例7: network_content
function network_content(&$a, $update = 0)
{
require_once 'include/conversation.php';
if (!local_user()) {
$_SESSION['return_url'] = $a->query_string;
return login(false);
}
// TODO:is this really necessary? $a is already available to hooks
$arr = array('query' => $a->query_string);
call_hooks('network_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 = '';
// item filter tabs
// TODO: fix this logic, reduce duplication
//$a->page['content'] .= '<div class="tabs-wrapper">';
list($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) = network_query_get_sel_tab($a);
// if no tabs are selected, defaults to comments
if ($no_active == 'active') {
$all_active = 'active';
}
$cmd = $datequery ? '' : $a->cmd;
$len_naked_cmd = strlen(str_replace('/new', '', $cmd));
// tabs
$tabs = array(array('label' => t('Commented Order'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . '?f=&order=comment' . (x($_GET, 'cid') ? '&cid=' . $_GET['cid'] : ''), 'sel' => $all_active, 'title' => t('Sort by Comment Date')), array('label' => t('Posted Order'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . '?f=&order=post' . (x($_GET, 'cid') ? '&cid=' . $_GET['cid'] : ''), 'sel' => $postord_active, 'title' => t('Sort by Post Date')));
if (feature_enabled(local_user(), 'personal_tab')) {
$tabs[] = array('label' => t('Personal'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . (x($_GET, 'cid') ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&conv=1', 'sel' => $conv_active, 'title' => t('Posts that mention or involve you'));
}
if (feature_enabled(local_user(), 'new_tab')) {
$tabs[] = array('label' => t('New'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ($len_naked_cmd ? '/' : '') . 'new' . (x($_GET, 'cid') ? '/?f=&cid=' . $_GET['cid'] : ''), 'sel' => $new_active, 'title' => t('Activity Stream - by date'));
}
if (feature_enabled(local_user(), 'link_tab')) {
$tabs[] = array('label' => t('Shared Links'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . (x($_GET, 'cid') ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&bmark=1', 'sel' => $bookmarked_active, 'title' => t('Interesting Links'));
}
if (feature_enabled(local_user(), 'star_posts')) {
$tabs[] = array('label' => t('Starred'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . (x($_GET, 'cid') ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&star=1', 'sel' => $starred_active, 'title' => t('Favourite Posts'));
}
// save selected tab, but only if not in search or file mode
if (!x($_GET, 'search') && !x($_GET, 'file')) {
set_pconfig(local_user(), 'network.view', 'tab.selected', array($all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active));
}
$arr = array('tabs' => $tabs);
call_hooks('network_tabs', $arr);
$o .= replace_macros(get_markup_template('common_tabs.tpl'), array('$tabs' => $arr['tabs']));
// --- end item filter tabs
$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);
}
}
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);
//.........这里部分代码省略.........
示例8: display_content
function display_content(&$a)
{
if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
notice(t('Public access denied.') . EOL);
return;
}
require_once "include/bbcode.php";
require_once 'include/security.php';
require_once 'include/conversation.php';
$o = '<div id="live-display"></div>' . "\r\n";
$a->page['htmlhead'] .= '<script>$(document).ready(function() { $(".comment-edit-wrapper textarea").contact_autocomplete(baseurl+"/acl"); });</script>';
$nick = $a->argc > 1 ? $a->argv[1] : '';
profile_load($a, $nick);
$item_id = $a->argc > 2 ? intval($a->argv[2]) : 0;
if (!$item_id) {
$a->error = 404;
notice(t('Item not found.') . EOL);
return;
}
$groups = array();
$contact = null;
$remote_contact = false;
if (remote_user()) {
$contact_id = $_SESSION['visitor_id'];
$groups = init_groups_visitor($contact_id);
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), intval($a->profile['uid']));
if (count($r)) {
$contact = $r[0];
$remote_contact = true;
}
}
if (!$remote_contact) {
if (local_user()) {
$contact_id = $_SESSION['cid'];
$contact = $a->contact;
}
}
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", intval($a->profile['uid']));
if (count($r)) {
$a->page_contact = $r[0];
}
$is_owner = local_user() && local_user() == $a->profile['profile_uid'] ? true : false;
if ($a->profile['hidewall'] && !$is_owner && !$remote_contact) {
notice(t('Access to this profile has been restricted.') . EOL);
return;
}
$sql_extra = permissions_sql($a->profile['uid'], $remote_contact, $groups);
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, \n\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,\n\t\t`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, \n\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`\n\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\tAND `item`.`parent` = ( SELECT `parent` FROM `item` WHERE ( `id` = '%s' OR `uri` = '%s' ))\n\t\t{$sql_extra}\n\t\tORDER BY `parent` DESC, `gravity` ASC, `id` ASC ", intval($a->profile['uid']), dbesc($item_id), dbesc($item_id));
if (count($r)) {
if (local_user() && local_user() == $a->profile['uid']) {
q("UPDATE `item` SET `unseen` = 0 \n\t\t\t\tWHERE `parent` = %d AND `unseen` = 1", intval($r[0]['parent']));
}
$o .= conversation($a, $r, 'display', false);
} else {
$r = q("SELECT `id` FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1", dbesc($item_id), dbesc($item_id));
if (count($r)) {
if ($r[0]['deleted']) {
notice(t('Item has been removed.') . EOL);
} else {
notice(t('Permission denied.') . EOL);
}
} else {
notice(t('Item not found.') . EOL);
}
}
return $o;
}
示例9: network_content
function network_content(&$a, $update = 0)
{
require_once 'include/conversation.php';
if (!local_user()) {
return login(false);
}
$o = '';
// item filter tabs
// TODO: fix this logic, reduce duplication
//$a->page['content'] .= '<div class="tabs-wrapper">';
$starred_active = '';
$new_active = '';
$bookmarked_active = '';
$all_active = '';
$search_active = '';
$conv_active = '';
if ($a->argc > 1 && $a->argv[1] === 'new' || $a->argc > 2 && $a->argv[2] === 'new') {
$new_active = 'active';
}
if (x($_GET, 'search')) {
$search_active = 'active';
}
if (x($_GET, 'star')) {
$starred_active = 'active';
}
if ($_GET['bmark']) {
$bookmarked_active = 'active';
}
if ($_GET['conv']) {
$conv_active = 'active';
}
if ($new_active == '' && $starred_active == '' && $bookmarked_active == '' && $conv_active == '' && $search_active == '') {
$all_active = 'active';
}
$postord_active = '';
if ($all_active && x($_GET, 'order') && $_GET['order'] !== 'comment') {
$all_active = '';
$postord_active = 'active';
}
// tabs
$tabs = array(array('label' => t('Commented Order'), 'url' => $a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . (x($_GET, 'cid') ? '?cid=' . $_GET['cid'] : ''), 'sel' => $all_active), array('label' => t('Posted Order'), 'url' => $a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . '?order=post' . (x($_GET, 'cid') ? '&cid=' . $_GET['cid'] : ''), 'sel' => $postord_active), array('label' => t('Personal'), 'url' => $a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . (x($_GET, 'cid') ? '/?cid=' . $_GET['cid'] : '') . '&conv=1', 'sel' => $conv_active), array('label' => t('New'), 'url' => $a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . '/new' . (x($_GET, 'cid') ? '/?cid=' . $_GET['cid'] : ''), 'sel' => $new_active), array('label' => t('Starred'), 'url' => $a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . (x($_GET, 'cid') ? '/?cid=' . $_GET['cid'] : '') . '&star=1', 'sel' => $starred_active), array('label' => t('Bookmarks'), 'url' => $a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . (x($_GET, 'cid') ? '/?cid=' . $_GET['cid'] : '') . '&bmark=1', 'sel' => $bookmarked_active));
$tpl = get_markup_template('common_tabs.tpl');
$o .= replace_macros($tpl, array('$tabs' => $tabs));
// --- end item filter tabs
$contact_id = $a->cid;
$group = 0;
$nouveau = false;
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;
if ($a->argc > 2 && $a->argv[2] === 'new') {
$nouveau = true;
}
if ($a->argc > 1) {
if ($a->argv[1] === 'new') {
$nouveau = true;
} else {
$group = intval($a->argv[1]);
$def_acl = array('allow_gid' => '<' . $group . '>');
}
}
if (x($_GET, 'search')) {
$nouveau = true;
}
if ($cid) {
$def_acl = array('allow_cid' => '<' . intval($cid) . '>');
}
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');
$_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']));
//.........这里部分代码省略.........
示例10: item_post
//.........这里部分代码省略.........
$datarray['coord'] = $coord;
$datarray['tag'] = $str_tags;
$datarray['file'] = $categories;
$datarray['inform'] = $inform;
$datarray['verb'] = $verb;
$datarray['object-type'] = $objecttype;
$datarray['allow_cid'] = $str_contact_allow;
$datarray['allow_gid'] = $str_group_allow;
$datarray['deny_cid'] = $str_contact_deny;
$datarray['deny_gid'] = $str_group_deny;
$datarray['private'] = $private;
$datarray['pubmail'] = $pubmail_enable;
$datarray['attach'] = $attachments;
$datarray['bookmark'] = intval($bookmark);
$datarray['thr-parent'] = $thr_parent;
$datarray['postopts'] = $postopts;
$datarray['origin'] = $origin;
$datarray['moderated'] = $allow_moderated;
/**
* These fields are for the convenience of plugins...
* 'self' if true indicates the owner is posting on their own wall
* If parent is 0 it is a top-level post.
*/
$datarray['parent'] = $parent;
$datarray['self'] = $self;
// $datarray['prvnets'] = $user['prvnets'];
if ($orig_post) {
$datarray['edit'] = true;
}
// Search for hashtags
item_body_set_hashtags($datarray);
// preview mode - prepare the body for display and send it via json
if ($preview) {
require_once 'include/conversation.php';
$o = conversation($a, array(array_merge($contact_record, $datarray)), 'search', false, true);
logger('preview: ' . $o);
echo json_encode(array('preview' => $o));
killme();
}
call_hooks('post_local', $datarray);
if (x($datarray, 'cancel')) {
logger('mod_item: post cancelled by plugin.');
if ($return_path) {
goaway($a->get_baseurl() . "/" . $return_path);
}
$json = array('cancel' => 1);
if (x($_REQUEST, 'jsreload') && strlen($_REQUEST['jsreload'])) {
$json['reload'] = $a->get_baseurl() . '/' . $_REQUEST['jsreload'];
}
echo json_encode($json);
killme();
}
// Fill the cache field
put_item_in_cache($datarray);
if ($orig_post) {
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `attach` = '%s', `file` = '%s', `rendered-html` = '%s', `rendered-hash` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d", dbesc($datarray['title']), dbesc($datarray['body']), dbesc($datarray['tag']), dbesc($datarray['attach']), dbesc($datarray['file']), dbesc($datarray['rendered-html']), dbesc($datarray['rendered-hash']), dbesc(datetime_convert()), dbesc(datetime_convert()), intval($post_id), intval($profile_uid));
create_tags_from_item($post_id);
create_files_from_item($post_id);
update_thread($post_id);
// update filetags in pconfig
file_tag_update_pconfig($uid, $categories_old, $categories_new, 'category');
proc_run('php', "include/notifier.php", 'edit_post', "{$post_id}");
if (x($_REQUEST, 'return') && strlen($return_path)) {
logger('return: ' . $return_path);
goaway($a->get_baseurl() . "/" . $return_path);
}
示例11: post
//.........这里部分代码省略.........
$datarray['item_type'] = $webpage;
$datarray['item_private'] = intval($private);
$datarray['item_thread_top'] = intval($item_thread_top);
$datarray['item_unseen'] = intval($item_unseen);
$datarray['item_starred'] = intval($item_starred);
$datarray['item_uplink'] = intval($item_uplink);
$datarray['item_consensus'] = intval($item_consensus);
$datarray['item_notshown'] = intval($item_notshown);
$datarray['item_nsfw'] = intval($item_nsfw);
$datarray['item_relay'] = intval($item_relay);
$datarray['item_mentionsme'] = intval($item_mentionsme);
$datarray['item_nocomment'] = intval($item_nocomment);
$datarray['item_obscured'] = intval($item_obscured);
$datarray['item_verified'] = intval($item_verified);
$datarray['item_retained'] = intval($item_retained);
$datarray['item_rss'] = intval($item_rss);
$datarray['item_deleted'] = intval($item_deleted);
$datarray['item_hidden'] = intval($item_hidden);
$datarray['item_unpublished'] = intval($item_unpublished);
$datarray['item_delayed'] = intval($item_delayed);
$datarray['item_pending_remove'] = intval($item_pending_remove);
$datarray['item_blocked'] = intval($item_blocked);
$datarray['layout_mid'] = $layout_mid;
$datarray['public_policy'] = $public_policy;
$datarray['comment_policy'] = map_scope($comment_policy);
$datarray['term'] = $post_tags;
$datarray['plink'] = $plink;
$datarray['route'] = $route;
if ($iconfig) {
$datarray['iconfig'] = $iconfig;
}
// preview mode - prepare the body for display and send it via json
if ($preview) {
require_once 'include/conversation.php';
$datarray['owner'] = $owner_xchan;
$datarray['author'] = $observer;
$datarray['attach'] = json_encode($datarray['attach']);
$o = conversation($a, array($datarray), 'search', false, 'preview');
// logger('preview: ' . $o, LOGGER_DEBUG);
echo json_encode(array('preview' => $o));
killme();
}
if ($orig_post) {
$datarray['edit'] = true;
}
// suppress duplicates, *unless* you're editing an existing post. This could get picked up
// as a duplicate if you're editing it very soon after posting it initially and you edited
// some attribute besides the content, such as title or categories.
if (feature_enabled($profile_uid, 'suppress_duplicates') && !$orig_post) {
$z = q("select created from item where uid = %d and created > %s - INTERVAL %s and body = '%s' limit 1", intval($profile_uid), db_utcnow(), db_quoteinterval('2 MINUTE'), dbesc($body));
if ($z) {
$datarray['cancel'] = 1;
notice(t('Duplicate post suppressed.') . EOL);
logger('Duplicate post. Faking plugin cancel.');
}
}
call_hooks('post_local', $datarray);
if (x($datarray, 'cancel')) {
logger('mod_item: post cancelled by plugin or duplicate suppressed.');
if ($return_path) {
goaway(z_root() . "/" . $return_path);
}
$json = array('cancel' => 1);
$json['reload'] = z_root() . '/' . $_REQUEST['jsreload'];
echo json_encode($json);
killme();
示例12: home_content
//.........这里部分代码省略.........
if ($l) {
require_once 'include/comanche.php';
comanche_parser($a, $l[0]['body']);
$a->pdl = $l[0]['body'];
}
}
$a->profile = array('profile_uid' => $u[0]['channel_id']);
$a->profile_uid = $u[0]['channel_id'];
$o .= prepare_page($r[0]);
return $o;
}
}
// Nope, we didn't find an item. Let's see if there's any html
if (file_exists('home.html')) {
$o .= file_get_contents('home.html');
} else {
$sitename = get_config('system', 'sitename');
if ($sitename) {
$o .= '<h1>' . sprintf(t("Welcome to %s"), $sitename) . '</h1>';
}
if (intval(get_config('system', 'block_public')) && !local_channel() && !remote_channel()) {
// If there's nothing special happening, just spit out a login box
if (!$a->config['system']['no_login_on_homepage']) {
$o .= login($a->config['system']['register_policy'] == REGISTER_CLOSED ? 0 : 1);
}
return $o;
} else {
if (get_config('system', 'disable_discover_tab')) {
call_hooks('home_content', $o);
return $o;
}
if (!$update) {
$maxheight = get_config('system', 'home_divmore_height');
if (!$maxheight) {
$maxheight = 75;
}
$o .= '<div id="live-home"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . (intval(local_channel()) ? local_channel() : -1) . "; var profile_page = " . $a->pager['page'] . "; divmore_height = " . intval($maxheight) . "; </script>\r\n";
$a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"), array('$baseurl' => z_root(), '$pgtype' => 'home', '$uid' => local_channel() ? local_channel() : '0', '$gid' => '0', '$cid' => '0', '$cmin' => '0', '$cmax' => '99', '$star' => '0', '$liked' => '0', '$conv' => '0', '$spam' => '0', '$fh' => '1', '$nouveau' => '0', '$wall' => '0', '$list' => '0', '$page' => $a->pager['page'] != 1 ? $a->pager['page'] : 1, '$search' => '', '$order' => 'comment', '$file' => '', '$cats' => '', '$tags' => '', '$dend' => '', '$mid' => '', '$verb' => '', '$dbegin' => ''));
}
if ($update && !$load) {
// only setup pagination on initial page view
$pager_sql = '';
} else {
$a->set_pager_itemspage(20);
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($a->pager['itemspage']), intval($a->pager['start']));
}
require_once 'include/identity.php';
if (get_config('system', 'site_firehose')) {
require_once 'include/security.php';
$uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and (item_flags & " . intval(ITEM_WALL) . " ) > 0 ";
} else {
$sys = get_sys_channel();
$uids = " and item.uid = " . intval($sys['channel_id']) . " ";
$a->data['firehose'] = intval($sys['channel_id']);
}
$page_mode = 'list';
$simple_update = $update ? " and item.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 = '';
}
//logger('update: ' . $update . ' load: ' . $load);
if ($update) {
$ordering = "commented";
if ($load) {
// Fetch a page full of parent items for this page
$r = q("SELECT distinct item.id AS item_id, {$ordering} FROM item\n\t\t\t\t\t\tleft join abook on item.author_xchan = abook.abook_xchan\n\t\t\t\t\t\tWHERE true {$uids} AND item.item_restrict = 0\n\t\t\t\t\t\tAND item.parent = item.id\n\t\t\t\t\t\tand ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)\n\t\t\t\t\t\t{$sql_extra3} {$sql_extra} {$sql_nets}\n\t\t\t\t\t\tORDER BY {$ordering} DESC {$pager_sql} ", intval(ABOOK_FLAG_BLOCKED));
} elseif ($update) {
$r = q("SELECT distinct item.id AS item_id, {$ordering} FROM item\n\t\t\t\t\t\tleft join abook on item.author_xchan = abook.abook_xchan\n\t\t\t\t\t\tWHERE true {$uids} AND item.item_restrict = 0\n\t\t\t\t\t\tAND item.parent = item.id {$simple_update}\n\t\t\t\t\t\tand ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)\n\t\t\t\t\t\t{$sql_extra3} {$sql_extra} {$sql_nets}", intval(ABOOK_FLAG_BLOCKED));
$_SESSION['loadtime'] = datetime_convert();
}
// Then fetch all the children of the parents that are on this page
$parents_str = '';
$update_unseen = '';
if ($r) {
$parents_str = ids_to_querystr($r, 'item_id');
$items = q("SELECT item.*, item.id AS item_id FROM item\n\t\t\t\t\t\tWHERE true {$uids} AND item.item_restrict = 0\n\t\t\t\t\t\tAND item.parent IN ( %s )\n\t\t\t\t\t\t{$sql_extra} ", dbesc($parents_str));
xchan_query($items, true, -1);
$items = fetch_post_tags($items, true);
$items = conv_sort($items, $ordering);
} else {
$items = array();
}
}
// fake it
$mode = 'network';
$o .= conversation($a, $items, $mode, $update, $page_mode);
if ($items && !$update) {
$o .= alt_pager($a, count($items));
}
return $o;
}
call_hooks('home_content', $o);
return $o;
}
return $o;
}
示例13: get
//.........这里部分代码省略.........
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);
}
} else {
$r = q("SELECT distinct id AS item_id, created FROM item \n\t\t\t\t\t\tleft join abook on item.author_xchan = abook.abook_xchan\n\t\t\t\t\t\tWHERE uid = %d {$item_normal}\n\t\t\t\t\t\tAND item_wall = 1 and item_thread_top = 1\n\t\t\t\t\t\tAND (abook_blocked = 0 or abook.abook_flags is null)\n\t\t\t\t\t\t{$sql_extra} {$sql_extra2}\n\t\t\t\t\t\tORDER BY created DESC {$pager_sql} ", intval(\App::$profile['profile_uid']));
}
} else {
$r = array();
}
}
if ($r) {
$parents_str = ids_to_querystr($r, 'item_id');
$items = q("SELECT `item`.*, `item`.`id` AS `item_id` \n\t\t\t\tFROM `item`\n\t\t\t\tWHERE `item`.`uid` = %d {$item_normal}\n\t\t\t\tAND `item`.`parent` IN ( %s )\n\t\t\t\t{$sql_extra} ", intval(\App::$profile['profile_uid']), dbesc($parents_str));
xchan_query($items);
$items = fetch_post_tags($items, true);
$items = conv_sort($items, 'created');
if ($load && $mid && !count($items)) {
// This will happen if we don't have sufficient permissions
// to view the parent item (or the item itself if it is toplevel)
notice(t('Permission denied.') . EOL);
}
} else {
$items = array();
}
if (!$update && !$load) {
// This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
// because browser prefetching might change it on us. We have to deliver it with the page.
$maxheight = get_pconfig(\App::$profile['profile_uid'], 'system', 'channel_divmore_height');
if (!$maxheight) {
$maxheight = 400;
}
$o .= '<div id="live-channel"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . \App::$profile['profile_uid'] . "; var netargs = '?f='; var profile_page = " . \App::$pager['page'] . "; divmore_height = " . intval($maxheight) . "; </script>\r\n";
\App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"), array('$baseurl' => z_root(), '$pgtype' => 'channel', '$uid' => \App::$profile['profile_uid'] ? \App::$profile['profile_uid'] : '0', '$gid' => '0', '$cid' => '0', '$cmin' => '0', '$cmax' => '0', '$star' => '0', '$liked' => '0', '$conv' => '0', '$spam' => '0', '$nouveau' => '0', '$wall' => '1', '$fh' => '0', '$page' => \App::$pager['page'] != 1 ? \App::$pager['page'] : 1, '$search' => '', '$order' => '', '$list' => x($_REQUEST, 'list') ? intval($_REQUEST['list']) : 0, '$file' => '', '$cats' => $category ? $category : '', '$tags' => $hashtags ? $hashtags : '', '$mid' => $mid, '$verb' => '', '$dend' => $datequery, '$dbegin' => $datequery2));
}
$update_unseen = '';
if ($page_mode === 'list') {
/**
* in "list mode", only mark the parent item and any like activities as "seen".
* We won't distinguish between comment likes and post likes. The important thing
* is that the number of unseen comments will be accurate. The SQL to separate the
* comment likes could also get somewhat hairy.
*/
if ($parents_str) {
$update_unseen = " AND ( id IN ( " . dbesc($parents_str) . " )";
$update_unseen .= " OR ( parent IN ( " . dbesc($parents_str) . " ) AND verb in ( '" . dbesc(ACTIVITY_LIKE) . "','" . dbesc(ACTIVITY_DISLIKE) . "' ))) ";
}
} else {
if ($parents_str) {
$update_unseen = " AND parent IN ( " . dbesc($parents_str) . " )";
}
}
if ($is_owner && $update_unseen) {
$r = q("UPDATE item SET item_unseen = 0 where item_unseen = 1 and item_wall = 1 AND uid = %d {$update_unseen}", intval(local_channel()));
}
if ($checkjs->disabled()) {
$o .= conversation($a, $items, 'channel', $update, 'traditional');
} else {
$o .= conversation($a, $items, 'channel', $update, $page_mode);
}
if (!$update || $checkjs->disabled()) {
$o .= alt_pager($a, count($items));
if ($mid && $items[0]['title']) {
\App::$page['title'] = $items[0]['title'] . " - " . \App::$page['title'];
}
}
if ($mid) {
$o .= '<div id="content-complete"></div>';
}
return $o;
}
示例14: search_content
function search_content(&$a)
{
if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
notice(t('Public access denied.') . EOL);
return;
}
nav_set_selected('search');
require_once "include/bbcode.php";
require_once 'include/security.php';
require_once 'include/conversation.php';
$o = '<h3>' . t('Search') . '</h3>';
if (x($a->data, 'search')) {
$search = notags(trim($a->data['search']));
} else {
$search = x($_GET, 'search') ? notags(trim(rawurldecode($_GET['search']))) : '';
}
$tag = false;
if (x($_GET, 'tag')) {
$tag = true;
$search = x($_GET, 'tag') ? notags(trim(rawurldecode($_GET['tag']))) : '';
}
$o .= search($search, 'search-box', '/search', local_user() ? true : false);
if (strpos($search, '#') === 0) {
$tag = true;
$search = substr($search, 1);
}
if (strpos($search, '@') === 0) {
require_once 'mod/dirfind.php';
return dirfind_content($a);
}
if (!$search) {
return $o;
}
if (get_config('system', 'only_tag_search')) {
$tag = true;
}
if ($tag) {
$sql_extra = "";
$sql_table = sprintf("`item` INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d) AS `term` ON `item`.`id` = `term`.`oid` ", dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
$sql_order = "`item`.`id`";
} else {
if (get_config('system', 'use_fulltext_engine')) {
$sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
} else {
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
}
$sql_table = "`item`";
$sql_order = "`item`.`id`";
//$sql_order = "`item`.`received`";
}
// Here is the way permissions work in the search module...
// Only public posts can be shown
// OR your own posts if you are a logged in member
// No items will be shown if the member has a blocked profile wall.
if (!get_config('alt_pager', 'global') && !get_pconfig(local_user(), 'system', 'alt_pager')) {
$r = q("SELECT distinct(`item`.`uri`) as `total`\n\t\t FROM {$sql_table} INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\tINNER JOIN `user` ON `user`.`uid` = `item`.`uid`\n\t\t WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0\n\t\t AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0)\n\t\t\t OR ( `item`.`uid` = %d ))\n\t\t {$sql_extra} ", intval(local_user()));
// $sql_extra group by `item`.`uri` ",
if (count($r)) {
$a->set_pager_total(count($r));
}
if (!count($r)) {
info(t('No results.') . EOL);
return $o;
}
}
$r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,\n\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`,\n\t\t`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, \n\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,\n\t\t`user`.`nickname`, `user`.`uid`, `user`.`hidewall`\n\t\tFROM {$sql_table} INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\tINNER JOIN `user` ON `user`.`uid` = `item`.`uid`\n\t\tWHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0\n\t\tAND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0 ) \n\t\t\tOR ( `item`.`uid` = %d ))\n\t\t{$sql_extra} GROUP BY `item`.`uri`\n\t\tORDER BY {$sql_order} DESC LIMIT %d , %d ", intval(local_user()), intval($a->pager['start']), intval($a->pager['itemspage']));
// group by `item`.`uri`
if (!count($r)) {
info(t('No results.') . EOL);
return $o;
}
if ($tag) {
$o .= '<h2>Items tagged with: ' . $search . '</h2>';
} else {
$o .= '<h2>Search results for: ' . $search . '</h2>';
}
$o .= conversation($a, $r, 'search', false);
if (get_config('alt_pager', 'global') || get_pconfig(local_user(), 'system', 'alt_pager')) {
$o .= alt_pager($a, count($r));
} else {
$o .= paginate($a);
}
return $o;
}
示例15: item_post
//.........这里部分代码省略.........
$datarray['body'] = $body;
$datarray['app'] = $app;
$datarray['location'] = $location;
$datarray['coord'] = $coord;
$datarray['tag'] = $str_tags;
$datarray['inform'] = $inform;
$datarray['verb'] = $verb;
$datarray['allow_cid'] = $str_contact_allow;
$datarray['allow_gid'] = $str_group_allow;
$datarray['deny_cid'] = $str_contact_deny;
$datarray['deny_gid'] = $str_group_deny;
$datarray['private'] = $private;
$datarray['pubmail'] = $pubmail_enable;
$datarray['attach'] = $attachments;
$datarray['bookmark'] = intval($bookmark);
$datarray['thr-parent'] = $thr_parent;
$datarray['postopts'] = '';
$datarray['origin'] = $origin;
/**
* These fields are for the convenience of plugins...
* 'self' if true indicates the owner is posting on their own wall
* If parent is 0 it is a top-level post.
*/
$datarray['parent'] = $parent;
$datarray['self'] = $self;
// $datarray['prvnets'] = $user['prvnets'];
if ($orig_post) {
$datarray['edit'] = true;
} else {
$datarray['guid'] = get_guid();
}
// preview mode - prepare the body for display and send it via json
if ($preview) {
require_once 'include/conversation.php';
$o = conversation(&$a, array(array_merge($contact_record, $datarray)), 'search', false, true);
echo json_encode(array('preview' => $o));
killme();
}
call_hooks('post_local', $datarray);
if ($orig_post) {
$r = q("UPDATE `item` SET `body` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", dbesc($body), dbesc(datetime_convert()), intval($post_id), intval($profile_uid));
proc_run('php', "include/notifier.php", 'edit_post', "{$post_id}");
if (x($_POST, 'return') && strlen($return_path)) {
logger('return: ' . $return_path);
goaway($a->get_baseurl() . "/" . $return_path);
}
killme();
} else {
$post_id = 0;
}
$r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, \n\t\t`author-name`, `author-link`, `author-avatar`, `created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`, \n\t\t`tag`, `inform`, `verb`, `postopts`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark`,`origin` )\n\t\tVALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d )", dbesc($datarray['guid']), intval($datarray['uid']), dbesc($datarray['type']), intval($datarray['wall']), intval($datarray['gravity']), intval($datarray['contact-id']), dbesc($datarray['owner-name']), dbesc($datarray['owner-link']), dbesc($datarray['owner-avatar']), dbesc($datarray['author-name']), dbesc($datarray['author-link']), dbesc($datarray['author-avatar']), dbesc($datarray['created']), dbesc($datarray['edited']), dbesc($datarray['commented']), dbesc($datarray['received']), dbesc($datarray['changed']), dbesc($datarray['uri']), dbesc($datarray['thr-parent']), dbesc($datarray['title']), dbesc($datarray['body']), dbesc($datarray['app']), dbesc($datarray['location']), dbesc($datarray['coord']), dbesc($datarray['tag']), dbesc($datarray['inform']), dbesc($datarray['verb']), dbesc($datarray['postopts']), dbesc($datarray['allow_cid']), dbesc($datarray['allow_gid']), dbesc($datarray['deny_cid']), dbesc($datarray['deny_gid']), intval($datarray['private']), intval($datarray['pubmail']), dbesc($datarray['attach']), intval($datarray['bookmark']), intval($datarray['origin']));
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($datarray['uri']));
if (count($r)) {
$post_id = $r[0]['id'];
logger('mod_item: saved item ' . $post_id);
if ($parent) {
// This item is the last leaf and gets the comment box, clear any ancestors
$r = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent` = %d ", dbesc(datetime_convert()), intval($parent));
// Inherit ACL's from the parent item.
$r = q("UPDATE `item` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `private` = %d\n\t\t\t\tWHERE `id` = %d LIMIT 1", dbesc($parent_item['allow_cid']), dbesc($parent_item['allow_gid']), dbesc($parent_item['deny_cid']), dbesc($parent_item['deny_gid']), intval($parent_item['private']), intval($post_id));
if ($contact_record != $author) {
notification(array('type' => NOTIFY_COMMENT, 'notify_flags' => $user['notify-flags'], 'language' => $user['language'], 'to_name' => $user['username'], 'to_email' => $user['email'], 'item' => $datarray, 'link' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id, 'source_name' => $datarray['author-name'], 'source_link' => $datarray['author-link'], 'source_photo' => $datarray['author-avatar'], 'verb' => ACTIVITY_POST, 'otype' => 'item'));
}
// We won't be able to sign Diaspora comments for authenticated visitors - we don't have their private key
if ($self) {
require_once 'include/bb2diaspora.php';