本文整理汇总了PHP中protect_sprintf函数的典型用法代码示例。如果您正苦于以下问题:PHP protect_sprintf函数的具体用法?PHP protect_sprintf怎么用?PHP protect_sprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了protect_sprintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search_ac_init
function search_ac_init(&$a)
{
if (!local_channel()) {
killme();
}
$start = x($_REQUEST, 'start') ? $_REQUEST['start'] : 0;
$count = x($_REQUEST, 'count') ? $_REQUEST['count'] : 100;
$search = x($_REQUEST, 'search') ? $_REQUEST['search'] : "";
if (x($_REQUEST, 'query') && strlen($_REQUEST['query'])) {
$search = $_REQUEST['query'];
}
// Priority to people searches
if ($search) {
$people_sql_extra = protect_sprintf(" AND `xchan_name` LIKE '%" . dbesc($search) . "%' ");
$tag_sql_extra = protect_sprintf(" AND term LIKE '%" . dbesc($search) . "%' ");
}
$r = q("SELECT `abook_id`, `xchan_name`, `xchan_photo_s`, `xchan_url`, `xchan_addr` FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d \n\t\t{$people_sql_extra}\n\t\tORDER BY `xchan_name` ASC ", intval(local_channel()));
$results = array();
if ($r) {
foreach ($r as $g) {
$results[] = array("photo" => $g['xchan_photo_s'], "name" => '@' . $g['xchan_name'], "id" => $g['abook_id'], "link" => $g['xchan_url'], "label" => '', "nick" => '');
}
}
$r = q("select distinct term, tid, url from term where type in ( %d, %d ) {$tag_sql_extra} group by term order by term asc", intval(TERM_HASHTAG), intval(TERM_COMMUNITYTAG));
if (count($r)) {
foreach ($r as $g) {
$results[] = array("photo" => $a->get_baseurl() . '/images/hashtag.png', "name" => '#' . $g['term'], "id" => $g['tid'], "link" => $g['url'], "label" => '', "nick" => '');
}
}
header("content-type: application/json");
$o = array('start' => $start, 'count' => $count, 'items' => $results);
echo json_encode($o);
logger('search_ac: ' . print_r($x, true));
killme();
}
示例2: chatroom_destroy
function chatroom_destroy($channel, $arr)
{
$ret = array('success' => false);
if (intval($arr['cr_id'])) {
$sql_extra = " and cr_id = " . intval($arr['cr_id']) . " ";
} elseif (trim($arr['cr_name'])) {
$sql_extra = " and cr_name = '" . protect_sprintf(dbesc(trim($arr['cr_name']))) . "' ";
} else {
$ret['message'] = t('Invalid room specifier.');
return $ret;
}
$r = q("select * from chatroom where cr_uid = %d {$sql_extra} limit 1", intval($channel['channel_id']));
if (!$r) {
$ret['message'] = t('Invalid room specifier.');
return $ret;
}
build_sync_packet($channel['channel_id'], array('chatroom' => $r));
q("delete from chatroom where cr_id = %d", intval($r[0]['cr_id']));
if ($r[0]['cr_id']) {
q("delete from chatpresence where cp_room = %d", intval($r[0]['cr_id']));
q("delete from chat where chat_room = %d", intval($r[0]['cr_id']));
}
$ret['success'] = true;
return $ret;
}
示例3: term_query
function term_query($table, $s, $type = TERM_UNKNOWN, $type2 = '')
{
if ($type2) {
return sprintf(" AND " . ($table ? dbesc($table) . '.' : '') . "id in (select term.oid from term where term.type in (%d, %d) and term.term = '%s' and term.uid = " . ($table ? dbesc($table) . '.' : '') . "uid ) ", intval($type), intval($type2), protect_sprintf(dbesc($s)));
} else {
return sprintf(" AND " . ($table ? dbesc($table) . '.' : '') . "id in (select term.oid from term where term.type = %d and term.term = '%s' and term.uid = " . ($table ? dbesc($table) . '.' : '') . "uid ) ", intval($type), protect_sprintf(dbesc($s)));
}
}
示例4: menu_list_count
function menu_list_count($channel_id, $name = '', $flags = 0)
{
$sel_options = '';
$sel_options .= $name ? " and menu_name = '" . protect_sprintf(dbesc($name)) . "' " : '';
$sel_options .= $flags ? " and menu_flags = " . intval($flags) . " " : '';
$r = q("select count(*) as total from menu where menu_channel_id = %d {$sel_options}", intval($channel_id));
return $r[0]['total'];
}
示例5: menu_list
/**
* If $flags is present, check that all the bits in $flags are set
* so that MENU_SYSTEM|MENU_BOOKMARK will return entries with both
* bits set. We will use this to find system generated bookmarks.
*/
function menu_list($channel_id, $name = '', $flags = 0)
{
$sel_options = '';
$sel_options .= $name ? " and menu_name = '" . protect_sprintf(dbesc($name)) . "' " : '';
$sel_options .= $flags ? " and menu_flags = " . intval($flags) . " " : '';
$r = q("select * from menu where menu_channel_id = %d {$sel_options} order by menu_desc", intval($channel_id));
return $r;
}
示例6: sync_directories
function sync_directories($dirmode)
{
if ($dirmode == DIRECTORY_MODE_STANDALONE || $dirmode == DIRECTORY_MODE_NORMAL) {
return;
}
$realm = get_directory_realm();
if ($realm == DIRECTORY_REALM) {
$r = q("select * from site where (site_flags & %d) and site_url != '%s' and ( site_realm = '%s' or site_realm = '') ", intval(DIRECTORY_MODE_PRIMARY | DIRECTORY_MODE_SECONDARY), dbesc(z_root()), dbesc($realm));
} else {
$r = q("select * from site where (site_flags & %d) and site_url != '%s' and site_realm like '%s' ", intval(DIRECTORY_MODE_PRIMARY | DIRECTORY_MODE_SECONDARY), dbesc(z_root()), dbesc(protect_sprintf('%' . $realm . '%')));
}
// If there are no directory servers, setup the fallback master
// FIXME - what to do if we're in a different realm?
if (!$r && z_root() != DIRECTORY_FALLBACK_MASTER) {
$r = array('site_url' => DIRECTORY_FALLBACK_MASTER, 'site_flags' => DIRECTORY_MODE_PRIMARY, 'site_update' => NULL_DATE, 'site_directory' => DIRECTORY_FALLBACK_MASTER . '/dirsearch', 'site_realm' => DIRECTORY_REALM);
$x = q("insert into site ( site_url, site_flags, site_update, site_directory, site_realm )\n\t\t\tvalues ( '%s', %d', '%s', '%s', '%s' ) ", dbesc($r[0]['site_url']), intval($r[0]['site_flags']), dbesc($r[0]['site_update']), dbesc($r[0]['site_directory']), dbesc($r[0]['site_realm']));
$r = q("select * from site where (site_flags & %d) and site_url != '%s'", intval(DIRECTORY_MODE_PRIMARY | DIRECTORY_MODE_SECONDARY), dbesc(z_root()));
}
if (!$r) {
return;
}
foreach ($r as $rr) {
if (!$rr['site_directory']) {
continue;
}
logger('sync directories: ' . $rr['site_directory']);
// for brand new directory servers, only load the last couple of days. Everything before that will be repeats.
$syncdate = $rr['site_sync'] === NULL_DATE ? datetime_convert('UTC', 'UTC', 'now - 2 days') : $rr['site_sync'];
$x = z_fetch_url($rr['site_directory'] . '?f=&sync=' . urlencode($syncdate));
if (!$x['success']) {
continue;
}
$j = json_decode($x['body'], true);
if (!$j['transactions'] || !is_array($j['transactions'])) {
continue;
}
q("update site set site_sync = '%s' where site_url = '%s' limit 1", dbesc(datetime_convert()), dbesc($rr['site_url']));
logger('sync_directories: ' . $rr['site_url'] . ': ' . print_r($j, true), LOGGER_DATA);
if (count($j['transactions'])) {
foreach ($j['transactions'] as $t) {
$r = q("select * from updates where ud_guid = '%s' limit 1", dbesc($t['transaction_id']));
if ($r) {
continue;
}
$ud_flags = 0;
if (is_array($t['flags']) && in_array('deleted', $t['flags'])) {
$ud_flags |= UPDATE_FLAGS_DELETED;
}
if (is_array($t['flags']) && in_array('forced', $t['flags'])) {
$ud_flags |= UPDATE_FLAGS_FORCED;
}
$z = q("insert into updates ( ud_hash, ud_guid, ud_date, ud_flags, ud_addr )\n\t\t\t\t\tvalues ( '%s', '%s', '%s', %d, '%s' ) ", dbesc($t['hash']), dbesc($t['transaction_id']), dbesc($t['timestamp']), intval($ud_flags), dbesc($t['address']));
}
}
}
}
示例7: init
function init()
{
if (!local_channel()) {
killme();
}
$start = x($_REQUEST, 'start') ? $_REQUEST['start'] : 0;
$count = x($_REQUEST, 'count') ? $_REQUEST['count'] : 100;
$search = x($_REQUEST, 'search') ? $_REQUEST['search'] : "";
if (x($_REQUEST, 'query') && strlen($_REQUEST['query'])) {
$search = $_REQUEST['query'];
}
$do_people = true;
$do_tags = true;
if (substr($search, 0, 1) === '@') {
$do_tags = false;
$search = substr($search, 1);
}
if (substr($search, 0, 1) === '#') {
$do_people = false;
$search = substr($search, 1);
}
// Priority to people searches
if ($search) {
$people_sql_extra = protect_sprintf(" AND xchan_name LIKE '%" . dbesc($search) . "%' ");
$tag_sql_extra = protect_sprintf(" AND term LIKE '%" . dbesc($search) . "%' ");
}
$results = [];
if ($do_people) {
$r = q("SELECT abook_id, xchan_name, xchan_photo_s, xchan_url, xchan_addr FROM abook \n\t\t\t\tleft join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d \n\t\t\t\t{$people_sql_extra}\n\t\t\t\tORDER BY xchan_name ASC ", intval(local_channel()));
if ($r) {
foreach ($r as $g) {
$results[] = ['photo' => $g['xchan_photo_s'], 'name' => '@' . $g['xchan_name'], 'id' => $g['abook_id'], 'link' => $g['xchan_url'], 'label' => '', 'nick' => ''];
}
}
}
if ($do_tags) {
$r = q("select distinct term, tid, url from term \n\t\t\t\twhere ttype in ( %d, %d ) {$tag_sql_extra} group by term order by term asc", intval(TERM_HASHTAG), intval(TERM_COMMUNITYTAG));
if ($r) {
foreach ($r as $g) {
$results[] = ['photo' => z_root() . '/images/hashtag.png', 'name' => '#' . $g['term'], 'id' => $g['tid'], 'link' => $g['url'], 'label' => '', 'nick' => ''];
}
}
}
header("content-type: application/json");
$o = array('start' => $start, 'count' => $count, 'items' => $results);
echo json_encode($o);
logger('search_ac: ' . print_r($x, true), LOGGER_DATA, LOG_INFO);
killme();
}
示例8: search_ac_init
function search_ac_init(&$a)
{
if (!local_user()) {
return "";
}
$start = x($_REQUEST, 'start') ? $_REQUEST['start'] : 0;
$count = x($_REQUEST, 'count') ? $_REQUEST['count'] : 100;
$search = x($_REQUEST, 'search') ? $_REQUEST['search'] : "";
if (x($_REQUEST, 'query') && strlen($_REQUEST['query'])) {
$search = $_REQUEST['query'];
}
$sql_extra = '';
$x = array();
$x['query'] = $search;
$x['photos'] = array();
$x['links'] = array();
$x['suggestions'] = array();
$x['data'] = array();
// Priority to people searches
if ($search) {
$people_sql_extra = protect_sprintf(" AND `xchan_name` LIKE '%" . dbesc($search) . "%' ");
$tag_sql_extra = protect_sprintf(" AND term LIKE '%" . dbesc($search) . "%' ");
}
$r = q("SELECT `abook_id`, `xchan_name`, `xchan_photo_s`, `xchan_url` FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d \n\t\t{$people_sql_extra}\n\t\tORDER BY `xchan_name` ASC ", intval(local_user()));
if ($r) {
foreach ($r as $g) {
$x['photos'][] = $g['xchan_photo_s'];
$x['links'][] = $g['xchan_url'];
$x['suggestions'][] = '@' . $g['xchan_name'];
$x['data'][] = 'cid=' . intval($g['abook_id']);
}
}
$r = q("select distinct term, tid, url from term where type = %d {$tag_sql_extra} group by term order by term asc", intval(TERM_HASHTAG));
if (count($r)) {
foreach ($r as $g) {
$x['photos'][] = $a->get_baseurl() . '/images/hashtag.png';
$x['links'][] = $g['url'];
$x['suggestions'][] = '#' . $g['term'];
$x['data'][] = intval($g['tid']);
}
}
header("content-type: application/json");
echo json_encode($x);
logger('search_ac: ' . print_r($x, true));
killme();
}
示例9: get
//.........这里部分代码省略.........
if ($search) {
$o .= replace_macros(get_markup_template("section_title.tpl"), array('$title' => t('Search Results For:') . ' ' . htmlspecialchars($search, ENT_COMPAT, 'UTF-8')));
}
nav_set_selected('network');
$channel_acl = array('allow_cid' => $channel['channel_allow_cid'], 'allow_gid' => $channel['channel_allow_gid'], 'deny_cid' => $channel['channel_deny_cid'], 'deny_gid' => $channel['channel_deny_gid']);
$private_editing = ($group || $cid) && !intval($_GET['pf']) ? true : false;
$x = array('is_owner' => true, 'allow_location' => intval(get_pconfig($channel['channel_id'], 'system', 'use_browser_location')) ? '1' : '', 'default_location' => $channel['channel_location'], 'nickname' => $channel['channel_address'], 'lockstate' => $private_editing || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid'] ? 'lock' : 'unlock', 'acl' => populate_acl($private_editing ? $def_acl : $channel_acl, true, \PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'), 'bang' => $private_editing ? '!' : '', 'visitor' => true, 'profile_uid' => local_channel(), 'editor_autocomplete' => true, 'bbco_autocomplete' => 'bbcode', 'bbcode' => true);
if ($deftag) {
$x['pretext'] = $deftag;
}
$status_editor = status_editor($a, $x);
$o .= $status_editor;
}
// 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 item_starred = 1 " : '';
$sql_nets = '';
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE item_thread_top = 1 {$sql_options} ) ";
if ($group) {
$contact_str = '';
$contacts = group_get_members($group);
if ($contacts) {
foreach ($contacts as $c) {
if ($contact_str) {
$contact_str .= ',';
}
$contact_str .= "'" . $c['xchan'] . "'";
}
} else {
$contact_str = ' 0 ';
info(t('Privacy group is empty'));
}
$sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true {$sql_options} AND (( author_xchan IN ( {$contact_str} ) OR owner_xchan in ( {$contact_str} )) or allow_gid like '" . protect_sprintf('%<' . dbesc($group_hash) . '>%') . "' ) and id = parent {$item_normal} ) ";
$x = group_rec_byhash(local_channel(), $group_hash);
if ($x) {
$title = replace_macros(get_markup_template("section_title.tpl"), array('$title' => t('Privacy group: ') . $x['name']));
}
$o = $tabs;
$o .= $title;
$o .= $status_editor;
} elseif ($cid) {
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_channel = %d and abook_blocked = 0 limit 1", intval($cid), intval(local_channel()));
if ($r) {
$sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true {$sql_options} AND uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) {$item_normal} ) ";
$title = replace_macros(get_markup_template("section_title.tpl"), array('$title' => '<a href="' . zid($r[0]['xchan_url']) . '" ><img src="' . zid($r[0]['xchan_photo_s']) . '" alt="' . urlencode($r[0]['xchan_name']) . '" /></a> <a href="' . zid($r[0]['xchan_url']) . '" >' . $r[0]['xchan_name'] . '</a>'));
$o = $tabs;
$o .= $title;
$o .= $status_editor;
} else {
notice(t('Invalid connection.') . EOL);
goaway(z_root() . '/network');
}
}
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 (!$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).
if ($gid || $cid || $cmin || $cmax != 99 || $star || $liked || $conv || $spam || $nouveau || $list) {
$firehose = 0;
示例10: xchan_query
function xchan_query(&$items, $abook = true, $effective_uid = 0)
{
$arr = array();
if ($items && count($items)) {
if ($effective_uid) {
for ($x = 0; $x < count($items); $x++) {
$items[$x]['real_uid'] = $items[$x]['uid'];
$items[$x]['uid'] = $effective_uid;
}
}
foreach ($items as $item) {
if ($item['owner_xchan'] && !in_array($item['owner_xchan'], $arr)) {
$arr[] = "'" . dbesc($item['owner_xchan']) . "'";
}
if ($item['author_xchan'] && !in_array($item['author_xchan'], $arr)) {
$arr[] = "'" . dbesc($item['author_xchan']) . "'";
}
}
}
if (count($arr)) {
if ($abook) {
$chans = q("select * from xchan left join hubloc on hubloc_hash = xchan_hash left join abook on abook_xchan = xchan_hash and abook_channel = %d\n\t\t\t\twhere xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and hubloc_primary = 1", intval($item['uid']));
} else {
$chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash\n\t\t\t\twhere xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and hubloc_primary = 1");
}
$xchans = q("select * from xchan where xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and xchan_network in ('rss','unknown')");
if (!$chans) {
$chans = $xchans;
} else {
$chans = array_merge($xchans, $chans);
}
}
if ($items && count($items) && $chans && count($chans)) {
for ($x = 0; $x < count($items); $x++) {
$items[$x]['owner'] = find_xchan_in_array($items[$x]['owner_xchan'], $chans);
$items[$x]['author'] = find_xchan_in_array($items[$x]['author_xchan'], $chans);
}
}
}
示例11: get
function get($update = 0, $load = false)
{
if ($load) {
$_SESSION['loadtime'] = datetime_convert();
}
$checkjs = new \Zotlabs\Web\CheckJS(1);
$category = $datequery = $datequery2 = '';
$mid = x($_REQUEST, 'mid') ? $_REQUEST['mid'] : '';
$datequery = x($_GET, 'dend') && is_a_date_arg($_GET['dend']) ? notags($_GET['dend']) : '';
$datequery2 = x($_GET, 'dbegin') && is_a_date_arg($_GET['dbegin']) ? notags($_GET['dbegin']) : '';
if (observer_prohibited(true)) {
return login();
}
$category = x($_REQUEST, 'cat') ? $_REQUEST['cat'] : '';
$hashtags = x($_REQUEST, 'tag') ? $_REQUEST['tag'] : '';
$groups = array();
$o = '';
if ($update) {
// Ensure we've got a profile owner if updating.
\App::$profile['profile_uid'] = \App::$profile_uid = $update;
} else {
if (\App::$profile['profile_uid'] == local_channel()) {
nav_set_selected('home');
}
}
$is_owner = local_channel() && \App::$profile['profile_uid'] == local_channel() ? true : false;
$channel = \App::get_channel();
$observer = \App::get_observer();
$ob_hash = $observer ? $observer['xchan_hash'] : '';
$perms = get_all_perms(\App::$profile['profile_uid'], $ob_hash);
if (!$perms['view_stream']) {
// We may want to make the target of this redirect configurable
if ($perms['view_profile']) {
notice(t('Insufficient permissions. Request redirected to profile page.') . EOL);
goaway(z_root() . "/profile/" . \App::$profile['channel_address']);
}
notice(t('Permission denied.') . EOL);
return;
}
if (!$update) {
$o .= profile_tabs($a, $is_owner, \App::$profile['channel_address']);
$o .= common_friends_visitor_widget(\App::$profile['profile_uid']);
if ($channel && $is_owner) {
$channel_acl = array('allow_cid' => $channel['channel_allow_cid'], 'allow_gid' => $channel['channel_allow_gid'], 'deny_cid' => $channel['channel_deny_cid'], 'deny_gid' => $channel['channel_deny_gid']);
} else {
$channel_acl = array();
}
if ($perms['post_wall']) {
$x = array('is_owner' => $is_owner, 'allow_location' => ($is_owner || $observer) && intval(get_pconfig(\App::$profile['profile_uid'], 'system', 'use_browser_location')) ? true : false, 'default_location' => $is_owner ? \App::$profile['channel_location'] : '', 'nickname' => \App::$profile['channel_address'], 'lockstate' => strlen(\App::$profile['channel_allow_cid']) || strlen(\App::$profile['channel_allow_gid']) || strlen(\App::$profile['channel_deny_cid']) || strlen(\App::$profile['channel_deny_gid']) ? 'lock' : 'unlock', 'acl' => $is_owner ? populate_acl($channel_acl, true, \PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post') : '', 'showacl' => $is_owner ? 'yes' : '', 'bang' => '', 'visitor' => $is_owner || $observer ? true : false, 'profile_uid' => \App::$profile['profile_uid'], 'editor_autocomplete' => true, 'bbco_autocomplete' => 'bbcode', 'bbcode' => true);
$o .= status_editor($a, $x);
}
}
/**
* Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
*/
$item_normal = item_normal();
$sql_extra = item_permissions_sql(\App::$profile['profile_uid']);
if (get_pconfig(\App::$profile['profile_uid'], 'system', 'channel_list_mode') && !$mid) {
$page_mode = 'list';
} else {
$page_mode = 'client';
}
$abook_uids = " and abook.abook_channel = " . intval(\App::$profile['profile_uid']) . " ";
$simple_update = $update ? " AND item_unseen = 1 " : '';
\App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$query_string) . '" title="oembed" />' . "\r\n";
if ($update && $_SESSION['loadtime']) {
$simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC', 'UTC', $_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC', 'UTC', $_SESSION['loadtime']) . "' ) ";
}
if ($load) {
$simple_update = '';
}
if ($update && !$load) {
if ($mid) {
$r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d {$item_normal}\n\t\t\t\t\tAND item_wall = 1 AND item_unseen = 1 {$sql_extra} limit 1", dbesc($mid . '%'), intval(\App::$profile['profile_uid']));
} else {
$r = q("SELECT distinct parent AS `item_id`, created from item\n\t\t\t\t\tleft join abook on ( item.owner_xchan = abook.abook_xchan {$abook_uids} )\n\t\t\t\t\tWHERE uid = %d {$item_normal}\n\t\t\t\t\tAND item_wall = 1 {$simple_update}\n\t\t\t\t\tAND (abook.abook_blocked = 0 or abook.abook_flags is null)\n\t\t\t\t\t{$sql_extra}\n\t\t\t\t\tORDER BY created DESC", intval(\App::$profile['profile_uid']));
$_SESSION['loadtime'] = datetime_convert();
}
} else {
if (x($category)) {
$sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY));
}
if (x($hashtags)) {
$sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG));
}
if ($datequery) {
$sql_extra2 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery))));
}
if ($datequery2) {
$sql_extra2 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery2))));
}
$itemspage = get_pconfig(local_channel(), 'system', 'itemspage');
\App::set_pager_itemspage(intval($itemspage) ? $itemspage : 20);
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start']));
if ($load || $checkjs->disabled()) {
if ($mid) {
$r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d {$item_normal}\n\t\t\t\t\t\tAND item_wall = 1 {$sql_extra} limit 1", dbesc($mid), intval(\App::$profile['profile_uid']));
if (!$r) {
notice(t('Permission denied.') . EOL);
}
//.........这里部分代码省略.........
示例12: contacts_content
//.........这里部分代码省略.........
default:
break;
}
if (!in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) {
$relation_text = "";
}
$relation_text = sprintf($relation_text, $contact['name']);
if ($contact['network'] === NETWORK_DFRN && $contact['rel']) {
$url = "redir/{$contact['id']}";
$sparkle = ' class="sparkle" ';
} else {
$url = $contact['url'];
$sparkle = '';
}
$insecure = t('Private communications are not available for this contact.');
$last_update = $contact['last-update'] == '0000-00-00 00:00:00' ? t('Never') : datetime_convert('UTC', date_default_timezone_get(), $contact['last-update'], 'D, j M Y, g:i A');
if ($contact['last-update'] !== '0000-00-00 00:00:00') {
$last_update .= ' ' . ($contact['last-update'] <= $contact['success_update'] ? t("(Update was successful)") : t("(Update was not successful)"));
}
$lblsuggest = $contact['network'] === NETWORK_DFRN ? t('Suggest friends') : '';
$poll_enabled = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2));
$nettype = sprintf(t('Network type: %s'), network_to_name($contact['network']));
$common = count_common_friends(local_user(), $contact['id']);
$common_text = $common ? sprintf(tt('%d contact in common', '%d contacts in common', $common), $common) : '';
$polling = $contact['network'] === NETWORK_MAIL | $contact['network'] === NETWORK_FEED ? 'polling' : '';
$x = count_all_friends(local_user(), $contact['id']);
$all_friends = $x ? t('View all contacts') : '';
// tabs
$tabs = array(array('label' => $contact['blocked'] ? t('Unblock') : t('Block'), 'url' => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/block', 'sel' => '', 'title' => t('Toggle Blocked status')), array('label' => $contact['readonly'] ? t('Unignore') : t('Ignore'), 'url' => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/ignore', 'sel' => '', 'title' => t('Toggle Ignored status')), array('label' => $contact['archive'] ? t('Unarchive') : t('Archive'), 'url' => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/archive', 'sel' => '', 'title' => t('Toggle Archive status')), array('label' => t('Repair'), 'url' => $a->get_baseurl(true) . '/crepair/' . $contact_id, 'sel' => '', 'title' => t('Advanced Contact Settings')));
$tab_tpl = get_markup_template('common_tabs.tpl');
$tab_str = replace_macros($tab_tpl, array('$tabs' => $tabs));
$lost_contact = $contact['archive'] && $contact['term-date'] != '0000-00-00 00:00:00' && $contact['term-date'] < datetime_convert('', '', 'now') ? t('Communications lost with this contact!') : '';
if ($contact['network'] == NETWORK_FEED) {
$fetch_further_information = array('fetch_further_information', t('Fetch further information for feeds'), $contact['fetch_further_information'], t('Fetch further information for feeds'), array('0' => t('Disabled'), '1' => t('Fetch information'), '2' => t('Fetch information and keywords')));
}
if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2))) {
$poll_interval = contact_poll_interval($contact['priority'], !$poll_enabled);
}
if ($contact['network'] == NETWORK_DFRN) {
$profile_select = contact_profile_assign($contact['profile-id'], $contact['network'] !== NETWORK_DFRN ? true : false);
}
$o .= replace_macros($tpl, array('$header' => t('Contact Editor'), '$tab_str' => $tab_str, '$submit' => t('Submit'), '$lbl_vis1' => t('Profile Visibility'), '$lbl_vis2' => sprintf(t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['name']), '$lbl_info1' => t('Contact Information / Notes'), '$infedit' => t('Edit contact notes'), '$common_text' => $common_text, '$common_link' => $a->get_baseurl(true) . '/common/loc/' . local_user() . '/' . $contact['id'], '$all_friends' => $all_friends, '$relation_text' => $relation_text, '$visit' => sprintf(t('Visit %s\'s profile [%s]'), $contact['name'], $contact['url']), '$blockunblock' => t('Block/Unblock contact'), '$ignorecont' => t('Ignore contact'), '$lblcrepair' => t("Repair URL settings"), '$lblrecent' => t('View conversations'), '$lblsuggest' => $lblsuggest, '$delete' => t('Delete contact'), '$nettype' => $nettype, '$poll_interval' => $poll_interval, '$poll_enabled' => $poll_enabled, '$lastupdtext' => t('Last update:'), '$lost_contact' => $lost_contact, '$updpub' => t('Update public posts'), '$last_update' => $last_update, '$udnow' => t('Update now'), '$profile_select' => $profile_select, '$contact_id' => $contact['id'], '$block_text' => $contact['blocked'] ? t('Unblock') : t('Block'), '$ignore_text' => $contact['readonly'] ? t('Unignore') : t('Ignore'), '$insecure' => $contact['network'] !== NETWORK_DFRN && $contact['network'] !== NETWORK_MAIL && $contact['network'] !== NETWORK_FACEBOOK && $contact['network'] !== NETWORK_DIASPORA ? $insecure : '', '$info' => $contact['info'], '$blocked' => $contact['blocked'] ? t('Currently blocked') : '', '$ignored' => $contact['readonly'] ? t('Currently ignored') : '', '$archived' => $contact['archive'] ? t('Currently archived') : '', '$hidden' => array('hidden', t('Hide this contact from others'), $contact['hidden'] == 1, t('Replies/likes to your public posts <strong>may</strong> still be visible')), '$notify' => array('notify', t('Notification for new posts'), $contact['notify_new_posts'] == 1, t('Send a notification of every new post of this contact')), '$fetch_further_information' => $fetch_further_information, '$ffi_keyword_blacklist' => $contact['ffi_keyword_blacklist'], '$ffi_keyword_blacklist' => array('ffi_keyword_blacklist', t('Blacklisted keywords'), $contact['ffi_keyword_blacklist'], t('Comma separated list of keywords that should not be converted to hashtags, when "Fetch information and keywords" is selected')), '$photo' => $contact['photo'], '$name' => $contact['name'], '$dir_icon' => $dir_icon, '$alt_text' => $alt_text, '$sparkle' => $sparkle, '$url' => $url));
$arr = array('contact' => $contact, 'output' => $o);
call_hooks('contact_edit', $arr);
return $arr['output'];
}
$blocked = false;
$hidden = false;
$ignored = false;
$all = false;
if ($a->argc == 2 && $a->argv[1] === 'all') {
$sql_extra = '';
$all = true;
} elseif ($a->argc == 2 && $a->argv[1] === 'blocked') {
$sql_extra = " AND `blocked` = 1 ";
$blocked = true;
} elseif ($a->argc == 2 && $a->argv[1] === 'hidden') {
$sql_extra = " AND `hidden` = 1 ";
$hidden = true;
} elseif ($a->argc == 2 && $a->argv[1] === 'ignored') {
$sql_extra = " AND `readonly` = 1 ";
$ignored = true;
} elseif ($a->argc == 2 && $a->argv[1] === 'archived') {
$sql_extra = " AND `archive` = 1 ";
$archived = true;
} else {
$sql_extra = " AND `blocked` = 0 ";
}
$search = x($_GET, 'search') ? notags(trim($_GET['search'])) : '';
$nets = x($_GET, 'nets') ? notags(trim($_GET['nets'])) : '';
$tabs = array(array('label' => t('Suggestions'), 'url' => $a->get_baseurl(true) . '/suggest', 'sel' => '', 'title' => t('Suggest potential friends')), array('label' => t('All Contacts'), 'url' => $a->get_baseurl(true) . '/contacts/all', 'sel' => $all ? 'active' : '', 'title' => t('Show all contacts')), array('label' => t('Unblocked'), 'url' => $a->get_baseurl(true) . '/contacts', 'sel' => !$all && !$blocked && !$hidden && !$search && !$nets && !$ignored && !$archived ? 'active' : '', 'title' => t('Only show unblocked contacts')), array('label' => t('Blocked'), 'url' => $a->get_baseurl(true) . '/contacts/blocked', 'sel' => $blocked ? 'active' : '', 'title' => t('Only show blocked contacts')), array('label' => t('Ignored'), 'url' => $a->get_baseurl(true) . '/contacts/ignored', 'sel' => $ignored ? 'active' : '', 'title' => t('Only show ignored contacts')), array('label' => t('Archived'), 'url' => $a->get_baseurl(true) . '/contacts/archived', 'sel' => $archived ? 'active' : '', 'title' => t('Only show archived contacts')), array('label' => t('Hidden'), 'url' => $a->get_baseurl(true) . '/contacts/hidden', 'sel' => $hidden ? 'active' : '', 'title' => t('Only show hidden contacts')));
$tab_tpl = get_markup_template('common_tabs.tpl');
$t = replace_macros($tab_tpl, array('$tabs' => $tabs));
$searching = false;
if ($search) {
$search_hdr = $search;
$search_txt = dbesc(protect_sprintf(preg_quote($search)));
$searching = true;
}
$sql_extra .= $searching ? " AND (name REGEXP '{$search_txt}' OR url REGEXP '{$search_txt}' OR nick REGEXP '{$search_txt}') " : "";
if ($nets) {
$sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets));
}
$sql_extra2 = $sort_type > 0 && $sort_type <= CONTACT_IS_FRIEND ? sprintf(" AND `rel` = %d ", intval($sort_type)) : '';
$r = q("SELECT COUNT(*) AS `total` FROM `contact`\n\t\tWHERE `uid` = %d AND `self` = 0 AND `pending` = 0 {$sql_extra} {$sql_extra2} ", intval($_SESSION['uid']));
if (count($r)) {
$a->set_pager_total($r[0]['total']);
$total = $r[0]['total'];
}
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 {$sql_extra} {$sql_extra2} ORDER BY `name` ASC LIMIT %d , %d ", intval($_SESSION['uid']), intval($a->pager['start']), intval($a->pager['itemspage']));
$contacts = array();
if (count($r)) {
foreach ($r as $rr) {
$contacts[] = _contact_detail_for_template($rr);
}
}
$tpl = get_markup_template("contacts-template.tpl");
$o .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(), '$header' => t('Contacts') . ($nets ? ' - ' . network_to_name($nets) : ''), '$tabs' => $t, '$total' => $total, '$search' => $search_hdr, '$desc' => t('Search your contacts'), '$finding' => $searching ? t('Finding: ') . "'" . $search . "'" : "", '$submit' => t('Find'), '$cmd' => $a->cmd, '$contacts' => $contacts, '$contact_drop_confirm' => t('Do you really want to delete this contact?'), '$batch_actions' => array('contacts_batch_update' => t('Update'), 'contacts_batch_block' => t('Block') . "/" . t("Unblock"), "contacts_batch_ignore" => t('Ignore') . "/" . t("Unignore"), "contacts_batch_archive" => t('Archive') . "/" . t("Unarchive"), "contacts_batch_drop" => t('Delete')), '$paginate' => paginate($a)));
return $o;
}
示例13: zot_gethub
/**
* @brief Look up if channel is known and previously verified.
*
* A guid and a url, both signed by the sender, distinguish a known sender at a
* known location.
* This function looks these up to see if the channel is known and therefore
* previously verified. If not, we will need to verify it.
*
* @param array $arr an associative array which must contain:
* * \e string \b guid => guid of conversant
* * \e string \b guid_sig => guid signed with conversant's private key
* * \e string \b url => URL of the origination hub of this communication
* * \e string \b url_sig => URL signed with conversant's private key
*
* @returns array|null null if site is blacklisted or not found, otherwise an
* array with an hubloc record
*/
function zot_gethub($arr, $multiple = false)
{
if ($arr['guid'] && $arr['guid_sig'] && $arr['url'] && $arr['url_sig']) {
$blacklisted = false;
$bl1 = get_config('system', 'blacklisted_sites');
if (is_array($bl1) && $bl1) {
foreach ($bl1 as $bl) {
if ($bl && strpos($arr['url'], $bl) !== false) {
$blacklisted = true;
break;
}
}
}
if ($blacklisted) {
logger('zot_gethub: blacklisted site: ' . $arr['url']);
return null;
}
$limit = $multiple ? '' : ' limit 1 ';
$sitekey = array_key_exists('sitekey', $arr) && $arr['sitekey'] ? " and hubloc_sitekey = '" . protect_sprintf($arr['sitekey']) . "' " : '';
$r = q("select * from hubloc\n\t\t\t\twhere hubloc_guid = '%s' and hubloc_guid_sig = '%s'\n\t\t\t\tand hubloc_url = '%s' and hubloc_url_sig = '%s'\n\t\t\t\t{$sitekey} {$limit}", dbesc($arr['guid']), dbesc($arr['guid_sig']), dbesc($arr['url']), dbesc($arr['url_sig']));
if ($r) {
logger('zot_gethub: found', LOGGER_DEBUG);
return $multiple ? $r : $r[0];
}
}
logger('zot_gethub: not found: ' . print_r($arr, true), LOGGER_DEBUG);
return null;
}
示例14: profile_content
//.........这里部分代码省略.........
}
$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;
}
if (!$update) {
if (x($_GET, 'tab')) {
$tab = notags(trim($_GET['tab']));
}
$o .= profile_tabs($a, $is_owner, $a->profile['nickname']);
if ($tab === 'profile') {
$o .= advanced_profile($a);
call_hooks('profile_advanced', $o);
return $o;
}
$o .= common_friends_visitor_widget($a->profile['profile_uid']);
if (x($_SESSION, 'new_member') && $_SESSION['new_member'] && $is_owner) {
$o .= '<a href="newmember" id="newmember-tips" style="font-size: 1.2em;"><b>' . t('Tips for New Members') . '</b></a>' . EOL;
}
$commpage = $a->profile['page-flags'] == PAGE_COMMUNITY ? true : false;
$commvisitor = $commpage && $remote_contact == true ? true : false;
$a->page['aside'] .= posted_date_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'], $a->profile['profile_uid'], true);
$a->page['aside'] .= categories_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'], x($category) ? xmlify($category) : '');
if (can_write_wall($a, $a->profile['profile_uid'])) {
$x = array('is_owner' => $is_owner, 'allow_location' => ($is_owner || $commvisitor) && $a->profile['allow_location'] ? true : false, 'default_location' => $is_owner ? $a->user['default-location'] : '', 'nickname' => $a->profile['nickname'], 'lockstate' => 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' => $is_owner ? populate_acl($a->user, true) : '', 'bang' => '', 'visitor' => $is_owner || $commvisitor ? 'block' : 'none', 'profile_uid' => $a->profile['profile_uid'], 'acl_data' => $is_owner ? construct_acl_data($a, $a->user) : '');
$o .= status_editor($a, $x);
}
}
/**
* Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
*/
$sql_extra = item_permissions_sql($a->profile['profile_uid'], $remote_contact, $groups);
if ($update) {
$r = q("SELECT distinct(parent) AS `item_id`, `item`.`network` AS `item_network`,\n\t\t\t`contact`.`uid` AS `contact-uid`\n\t\t\tFROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND\n\t\t\t(`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE . "' OR item.verb = '" . ACTIVITY_DISLIKE . "')\n\t\t\tand `item`.`moderated` = 0 and `item`.`unseen` = 1\n\t\t\tAND `item`.`wall` = 1\n\t\t\t{$sql_extra}\n\t\t\tORDER BY `item`.`created` DESC", intval($a->profile['profile_uid']));
} else {
$sql_post_table = "";
if (x($category)) {
$sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ", dbesc(protect_sprintf($category)), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), intval($a->profile['profile_uid']));
//$sql_extra .= protect_sprintf(file_tag_file_query('item',$category,'category'));
}
if ($datequery) {
$sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery))));
}
if ($datequery2) {
$sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery2))));
}
if (get_config('system', 'old_pager')) {
$r = q("SELECT COUNT(*) AS `total`\n\t\t\t FROM `thread` INNER JOIN `item` ON `item`.`id` = `thread`.`iid`\n\t\t\t {$sql_post_table} INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`\n\t\t\t AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t WHERE `thread`.`uid` = %d AND `thread`.`visible` = 1 AND `thread`.`deleted` = 0\n\t\t\t and `thread`.`moderated` = 0\n\t\t\t AND `thread`.`wall` = 1\n\t\t\t {$sql_extra} {$sql_extra2} ", intval($a->profile['profile_uid']));
if (count($r)) {
$a->set_pager_total($r[0]['total']);
}
}
// check if we serve a mobile device and get the user settings
// accordingly
if ($a->is_mobile) {
$itemspage_network = get_pconfig(local_user(), 'system', 'itemspage_mobile_network');
$itemspage_network = intval($itemspage_network) ? $itemspage_network : 20;
} else {
$itemspage_network = get_pconfig(local_user(), 'system', 'itemspage_network');
$itemspage_network = intval($itemspage_network) ? $itemspage_network : 40;
}
// now that we have the user settings, see if the theme forces
// a maximum item number which is lower then the user choice
if ($a->force_max_items > 0 && $a->force_max_items < $itemspage_network) {
$itemspage_network = $a->force_max_items;
}
$a->set_pager_itemspage($itemspage_network);
$pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
$r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`,\n\t\t\t`thread`.`uid` AS `contact-uid`\n\t\t\tFROM `thread` INNER JOIN `item` ON `item`.`id` = `thread`.`iid`\n\t\t\t{$sql_post_table} INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`\n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\tWHERE `thread`.`uid` = %d AND `thread`.`visible` = 1 AND `thread`.`deleted` = 0\n\t\t\tand `thread`.`moderated` = 0\n\t\t\tAND `thread`.`wall` = 1\n\t\t\t{$sql_extra} {$sql_extra2}\n\t\t\tORDER BY `thread`.`created` DESC {$pager_sql} ", intval($a->profile['profile_uid']));
}
$parents_arr = array();
$parents_str = '';
if (count($r)) {
foreach ($r as $rr) {
$parents_arr[] = $rr['item_id'];
}
$parents_str = implode(', ', $parents_arr);
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,\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`, `contact`\n\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\t\tand `item`.`moderated` = 0\n\t\t\tAND `contact`.`id` = `item`.`contact-id`\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} ", intval($a->profile['profile_uid']), dbesc($parents_str));
$items = conv_sort($items, 'created');
} else {
$items = array();
}
if ($is_owner && !$update && !get_config('theme', 'hide_eventlist')) {
$o .= get_birthdays();
$o .= get_events();
}
if ($is_owner) {
$r = q("UPDATE `item` SET `unseen` = 0\n\t\t\tWHERE `wall` = 1 AND `unseen` = 1 AND `uid` = %d", intval(local_user()));
}
$o .= conversation($a, $items, 'profile', $update);
if (!$update) {
if (!get_config('system', 'old_pager')) {
$o .= alt_pager($a, count($items));
} else {
$o .= paginate($a);
}
}
return $o;
}
示例15: dir_query_build
function dir_query_build($joiner, $field, $s)
{
$ret = '';
if (trim($s)) {
$ret .= dbesc($joiner) . " " . dbesc($field) . " like '" . protect_sprintf('%' . dbesc($s) . '%') . "' ";
}
return $ret;
}