当前位置: 首页>>代码示例>>PHP>>正文


PHP db_getfunc函数代码示例

本文整理汇总了PHP中db_getfunc函数的典型用法代码示例。如果您正苦于以下问题:PHP db_getfunc函数的具体用法?PHP db_getfunc怎么用?PHP db_getfunc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了db_getfunc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: search_doc_files

function search_doc_files($s)
{
    $a = get_app();
    $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']));
    $regexop = db_getfunc('REGEXP');
    $r = q("select item_id.sid, item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and\n\t\tbody {$regexop} '%s' and item_type = %d {$pager_sql}", dbesc($s), intval(ITEM_TYPE_DOC));
    $r = fetch_post_tags($r, true);
    for ($x = 0; $x < count($r); $x++) {
        $r[$x]['text'] = $r[$x]['body'];
        $r[$x]['rank'] = 0;
        if ($r[$x]['term']) {
            foreach ($r[$x]['term'] as $t) {
                if (stristr($t['term'], $s)) {
                    $r[$x]['rank']++;
                }
            }
        }
        if (stristr($r[$x]['sid'], $s)) {
            $r[$x]['rank']++;
        }
        $r[$x]['rank'] += substr_count(strtolower($r[$x]['text']), strtolower($s));
        // bias the results to the observer's native language
        if ($r[$x]['lang'] === App::$language) {
            $r[$x]['rank'] = $r[$x]['rank'] + 10;
        }
    }
    usort($r, 'doc_rank_sort');
    return $r;
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:31,代码来源:help.php

示例2: post

 /**
  * @brief Channels admin page.
  *
  * @param App &$a
  */
 function post()
 {
     $channels = x($_POST, 'channel') ? $_POST['channel'] : array();
     check_form_security_token_redirectOnErr('/admin/channels', 'admin_channels');
     $xor = db_getfunc('^');
     if (x($_POST, 'page_channels_block')) {
         foreach ($channels as $uid) {
             q("UPDATE channel SET channel_pageflags = ( channel_pageflags {$xor} %d ) where channel_id = %d", intval(PAGE_CENSORED), intval($uid));
             \Zotlabs\Daemon\Master::Summon(array('Directory', $uid, 'nopush'));
         }
         notice(sprintf(tt("%s channel censored/uncensored", "%s channels censored/uncensored", count($channels)), count($channels)));
     }
     if (x($_POST, 'page_channels_code')) {
         foreach ($channels as $uid) {
             q("UPDATE channel SET channel_pageflags = ( channel_pageflags {$xor} %d ) where channel_id = %d", intval(PAGE_ALLOWCODE), intval($uid));
         }
         notice(sprintf(tt("%s channel code allowed/disallowed", "%s channels code allowed/disallowed", count($channels)), count($channels)));
     }
     if (x($_POST, 'page_channels_delete')) {
         foreach ($channels as $uid) {
             channel_remove($uid, true);
         }
         notice(sprintf(tt("%s channel deleted", "%s channels deleted", count($channels)), count($channels)));
     }
     goaway(z_root() . '/admin/channels');
 }
开发者ID:phellmes,项目名称:hubzilla,代码行数:31,代码来源:Channels.php

示例3: custom_home_home

function custom_home_home(&$a, &$o)
{
    $x = get_config('system', 'custom_home');
    if ($x) {
        if ($x == "random") {
            $rand = db_getfunc('rand');
            $r = q("select channel_address from channel where channel_r_stream = 1 and channel_address != 'sys' order by {$rand} limit 1");
            $x = z_root() . '/channel/' . $r[0]['channel_address'];
        } else {
            $x = z_root() . '/' . $x;
        }
        goaway(zid($x));
    }
    //If nothing is set
    return $o;
}
开发者ID:royalterra,项目名称:hubzilla-addons,代码行数:16,代码来源:custom_home.php

示例4: custom_home_home

function custom_home_home(&$a, &$o)
{
    $x = get_config('system', 'custom_home');
    if ($x) {
        if ($x == "random") {
            $rand = db_getfunc('rand');
            $r = q("select channel_address from channel left join pconfig on channel_id = pconfig.uid where pconfig.cat = 'perm_limits' and pconfig.k = 'view_stream' and pconfig.v = 1 and channel_address != 'sys' order by {$rand} limit 1");
            $x = z_root() . '/channel/' . $r[0]['channel_address'];
        } else {
            $x = z_root() . '/' . $x;
        }
        goaway(zid($x));
    }
    //If nothing is set
    return $o;
}
开发者ID:phellmes,项目名称:hubzilla-addons,代码行数:16,代码来源:custom_home.php

示例5: init

 function init()
 {
     $start = $_REQUEST['start'] ? intval($_REQUEST['start']) : 0;
     $limit = intval($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 30;
     $order = $_REQUEST['order'] ? $_REQUEST['order'] : 'random';
     $open = $_REQUEST['open'] ? intval($_REQUEST['open']) : false;
     $sql_order = " order by site_url ";
     $rand = db_getfunc('rand');
     if ($order == 'random') {
         $sql_order = " order by {$rand} ";
     }
     $sql_limit = " LIMIT {$limit} OFFSET {$start} ";
     $sql_extra = "";
     if ($open) {
         $sql_extra = " and site_register = " . intval(REGISTER_OPEN) . " ";
     }
     $realm = get_directory_realm();
     if ($realm == DIRECTORY_REALM) {
         $sql_extra .= " and ( site_realm = '" . dbesc($realm) . "' or site_realm = '') ";
     } else {
         $sql_extra .= " and site_realm = '" . dbesc($realm) . "' ";
     }
     $result = array('success' => false);
     $r = q("select count(site_url) as total from site where site_type = %d {$sql_extra} ", intval(SITE_TYPE_ZOT));
     if ($r) {
         $result['total'] = intval($r[0]['total']);
     }
     $result['start'] = $start;
     $result['limit'] = $limit;
     $r = q("select * from site where site_type = %d {$sql_extra} {$sql_order} {$sql_limit}", intval(SITE_TYPE_ZOT));
     $result['results'] = 0;
     $result['entries'] = array();
     if ($r) {
         $result['success'] = true;
         $result['results'] = count($r);
         foreach ($r as $rr) {
             $result['entries'][] = array('url' => $rr['site_url']);
         }
     }
     echo json_encode($result);
     killme();
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:42,代码来源:Sitelist.php

示例6: connect_post

function connect_post(&$a)
{
    if (!array_key_exists('channel', App::$data)) {
        return;
    }
    $edit = local_channel() && local_channel() == App::$data['channel']['channel_id'] ? true : false;
    if ($edit) {
        $has_premium = App::$data['channel']['channel_pageflags'] & PAGE_PREMIUM ? 1 : 0;
        $premium = $_POST['premium'] ? intval($_POST['premium']) : 0;
        $text = escape_tags($_POST['text']);
        if ($has_premium != $premium) {
            $r = q("update channel set channel_pageflags = ( channel_pageflags %s %d ) where channel_id = %d", db_getfunc('^'), intval(PAGE_PREMIUM), intval(local_channel()));
            proc_run('php', 'include/notifier.php', 'refresh_all', App::$data['channel']['channel_id']);
        }
        set_pconfig(App::$data['channel']['channel_id'], 'system', 'selltext', $text);
        // reload the page completely to get fresh data
        goaway(z_root() . '/' . App::$query_string);
    }
    $url = '';
    $observer = App::get_observer();
    if ($observer && $_POST['submit'] === t('Continue')) {
        if ($observer['xchan_follow']) {
            $url = sprintf($observer['xchan_follow'], urlencode(App::$data['channel']['channel_address'] . '@' . App::get_hostname()));
        }
        if (!$url) {
            $r = q("select * from hubloc where hubloc_hash = '%s' order by hubloc_id desc limit 1", dbesc($observer['xchan_hash']));
            if ($r) {
                $url = $r[0]['hubloc_url'] . '/follow?f=&url=' . urlencode(App::$data['channel']['channel_address'] . '@' . App::get_hostname());
            }
        }
    }
    if ($url) {
        goaway($url . '&confirm=1');
    } else {
        notice('Unable to connect to your home hub location.');
    }
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:37,代码来源:connect.php

示例7: poller_run


//.........这里部分代码省略.........
        }
    }
    // pull in some public posts
    if (!get_config('system', 'disable_discover_tab')) {
        proc_run('php', 'include/externals.php');
    }
    $manual_id = 0;
    $generation = 0;
    $force = false;
    $restart = false;
    if ($argc > 1 && $argv[1] == 'force') {
        $force = true;
    }
    if ($argc > 1 && $argv[1] == 'restart') {
        $restart = true;
        $generation = intval($argv[2]);
        if (!$generation) {
            killme();
        }
    }
    if ($argc > 1 && intval($argv[1])) {
        $manual_id = intval($argv[1]);
        $force = true;
    }
    $sql_extra = $manual_id ? " AND abook_id = " . intval($manual_id) . " " : "";
    reload_plugins();
    $d = datetime_convert();
    // TODO check to see if there are any cronhooks before wasting a process
    if (!$restart) {
        proc_run('php', 'include/cronhooks.php');
    }
    // Only poll from those with suitable relationships
    $abandon_sql = $abandon_days ? sprintf(" AND account_lastlog > %s - INTERVAL %s ", db_utcnow(), db_quoteinterval(intval($abandon_days) . ' DAY')) : '';
    $randfunc = db_getfunc('RAND');
    $contacts = q("SELECT * FROM abook LEFT JOIN xchan on abook_xchan = xchan_hash \n\t\tLEFT JOIN account on abook_account = account_id\n\t\twhere abook_self = 0\n\t\t{$sql_extra} \n\t\tAND (( account_flags = %d ) OR ( account_flags = %d )) {$abandon_sql} ORDER BY {$randfunc}", intval(ACCOUNT_OK), intval(ACCOUNT_UNVERIFIED));
    if ($contacts) {
        foreach ($contacts as $contact) {
            $update = false;
            $t = $contact['abook_updated'];
            $c = $contact['abook_connected'];
            if (intval($contact['abook_feed'])) {
                $min = service_class_fetch($contact['abook_channel'], 'minimum_feedcheck_minutes');
                if (!$min) {
                    $min = intval(get_config('system', 'minimum_feedcheck_minutes'));
                }
                if (!$min) {
                    $min = 60;
                }
                $x = datetime_convert('UTC', 'UTC', "now - {$min} minutes");
                if ($c < $x) {
                    proc_run('php', 'include/onepoll.php', $contact['abook_id']);
                    if ($interval) {
                        @time_sleep_until(microtime(true) + (double) $interval);
                    }
                }
                continue;
            }
            if ($contact['xchan_network'] !== 'zot') {
                continue;
            }
            if ($c == $t) {
                if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 1 day")) {
                    $update = true;
                }
            } else {
                // if we've never connected with them, start the mark for death countdown from now
开发者ID:msooon,项目名称:hubzilla,代码行数:67,代码来源:poller.php

示例8: contact_block

function contact_block()
{
    $o = '';
    $a = get_app();
    if (!$a->profile['uid']) {
        return;
    }
    if (!perm_is_allowed($a->profile['uid'], get_observer_hash(), 'view_contacts')) {
        return;
    }
    $shown = get_pconfig($a->profile['uid'], 'system', 'display_friend_count');
    if ($shown === false) {
        $shown = 25;
    }
    if ($shown == 0) {
        return;
    }
    $is_owner = local_channel() && local_channel() == $a->profile['uid'] ? true : false;
    $sql_extra = '';
    $abook_flags = " and abook_pending = 0 and abook_self = 0 ";
    if (!$is_owner) {
        $abook_flags .= " and abook_hidden = 0 ";
        $sql_extra = " and xchan_hidden = 0 ";
    }
    if (!is_array($a->profile) || $a->profile['hide_friends']) {
        return $o;
    }
    $r = q("SELECT COUNT(abook_id) AS total FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d\n\t\t{$abook_flags} and xchan_orphan = 0 and xchan_deleted = 0 {$sql_extra}", intval($a->profile['uid']));
    if (count($r)) {
        $total = intval($r[0]['total']);
    }
    if (!$total) {
        $contacts = t('No connections');
        $micropro = null;
    } else {
        $randfunc = db_getfunc('RAND');
        $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash WHERE abook_channel = %d {$abook_flags} and abook_archived = 0 and xchan_orphan = 0 and xchan_deleted = 0 {$sql_extra} ORDER BY {$randfunc} LIMIT %d", intval($a->profile['uid']), intval($shown));
        if (count($r)) {
            $contacts = sprintf(tt('%d Connection', '%d Connections', $total), $total);
            $micropro = array();
            foreach ($r as $rr) {
                $rr['archived'] = intval($rr['abook_archived']) ? true : false;
                $micropro[] = micropro($rr, true, 'mpfriend');
            }
        }
    }
    $tpl = get_markup_template('contact_block.tpl');
    $o = replace_macros($tpl, array('$contacts' => $contacts, '$nickname' => $a->profile['channel_address'], '$viewconnections' => t('View Connections'), '$micropro' => $micropro));
    $arr = array('contacts' => $r, 'output' => $o);
    call_hooks('contact_block_end', $arr);
    return $o;
}
开发者ID:23n,项目名称:hubzilla,代码行数:52,代码来源:text.php

示例9: random_profile

function random_profile()
{
    $randfunc = db_getfunc('rand');
    $checkrandom = get_config('randprofile', 'check');
    // False by default
    $retryrandom = intval(get_config('randprofile', 'retry'));
    if ($retryrandom == 0) {
        $retryrandom = 5;
    }
    for ($i = 0; $i < $retryrandom; $i++) {
        $r = q("select xchan_url from xchan left join hubloc on hubloc_hash = xchan_hash where hubloc_connected > %s - interval %s order by {$randfunc} limit 1", db_utcnow(), db_quoteinterval('30 day'));
        if (!$r) {
            return '';
        }
        // Couldn't get a random channel
        if ($checkrandom) {
            $x = z_fetch_url($r[0]['xchan_url']);
            if ($x['success']) {
                return $r[0]['xchan_url'];
            } else {
                logger('Random channel turned out to be bad.');
            }
        } else {
            return $r[0]['xchan_url'];
        }
    }
    return '';
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:28,代码来源:Contact.php

示例10: list_public_sites

function list_public_sites()
{
    $rand = db_getfunc('rand');
    $realm = get_directory_realm();
    if ($realm == DIRECTORY_REALM) {
        $r = q("select * from site where site_access != 0 and site_register !=0 and ( site_realm = '%s' or site_realm = '') and site_type = %d order by {$rand}", dbesc($realm), intval(SITE_TYPE_ZOT));
    } else {
        $r = q("select * from site where site_access != 0 and site_register !=0 and site_realm = '%s' and site_type = %d order by {$rand}", dbesc($realm), intval(SITE_TYPE_ZOT));
    }
    $ret = array('success' => false);
    if ($r) {
        $ret['success'] = true;
        $ret['sites'] = array();
        $insecure = array();
        foreach ($r as $rr) {
            if ($rr['site_access'] == ACCESS_FREE) {
                $access = 'free';
            } elseif ($rr['site_access'] == ACCESS_PAID) {
                $access = 'paid';
            } elseif ($rr['site_access'] == ACCESS_TIERED) {
                $access = 'tiered';
            } else {
                $access = 'private';
            }
            if ($rr['site_register'] == REGISTER_OPEN) {
                $register = 'open';
            } elseif ($rr['site_register'] == REGISTER_APPROVE) {
                $register = 'approve';
            } else {
                $register = 'closed';
            }
            if (strpos($rr['site_url'], 'https://') !== false) {
                $ret['sites'][] = array('url' => $rr['site_url'], 'access' => $access, 'register' => $register, 'sellpage' => $rr['site_sellpage'], 'location' => $rr['site_location'], 'project' => $rr['site_project']);
            } else {
                $insecure[] = array('url' => $rr['site_url'], 'access' => $access, 'register' => $register, 'sellpage' => $rr['site_sellpage'], 'location' => $rr['site_location'], 'project' => $rr['site_project']);
            }
        }
        if ($insecure) {
            $ret['sites'] = array_merge($ret['sites'], $insecure);
        }
    }
    return $ret;
}
开发者ID:23n,项目名称:hubzilla,代码行数:43,代码来源:dirsearch.php

示例11: jappixmini_cron

function jappixmini_cron(&$a, $d)
{
    require_once 'include/Contact.php';
    // For autosubscribe/autoapprove, we need to maintain a list of jabber addresses of our contacts.
    set_config("jappixmini", "last_cron_execution", $d);
    // go through list of users with jabber enabled
    $users = q("SELECT uid FROM pconfig WHERE cat = 'jappixmini' AND ( k = 'autosubscribe' OR k = 'autoapprove') AND v = '1' group by uid ");
    logger("jappixmini: Update list of contacts' jabber accounts for " . count($users) . " users.");
    if (!count($users)) {
        return;
    }
    foreach ($users as $row) {
        $uid = $row["uid"];
        // for each user, go through list of contacts
        $rand = db_getfunc('rand');
        $contacts = q("SELECT * FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE `abook_channel`=%d AND not (abook_flags & %d) > 0 order by {$rand}", intval($uid), intval(ABOOK_FLAG_SELF));
        $channel = channelx_by_n($uid);
        if (!$channel || !$contacts) {
            continue;
        }
        foreach ($contacts as $contact_row) {
            $xchan_hash = $contact_row["abook_xchan"];
            $pubkey = $contact_row["xchan_pubkey"];
            // check if jabber address already present
            $present = get_pconfig($uid, "jappixmini", "id:" . $xchan_hash);
            $now = intval(time());
            if ($present) {
                // $present has format "timestamp:jabber_address"
                $p = strpos($present, ":");
                $timestamp = intval(substr($present, 0, $p));
                // do not re-retrieve jabber address if last retrieval
                // is not older than a week
                if ($now - $timestamp < 3600 * 24 * 7) {
                    continue;
                }
            }
            logger('jappixmini: checking ' . $contact_row['xchan_name'] . ' for channel ' . $channel['channel_name']);
            // construct base retrieval address
            $pos = strpos($contact_row['xchan_connurl'], "/poco/");
            if ($pos === false) {
                continue;
            }
            $url = substr($contact_row['xchan_connurl'], 0, $pos) . "/jappixmini?f=";
            // construct own address
            $username = get_pconfig($uid, 'jappixmini', 'username');
            if (!$username) {
                continue;
            }
            $server = get_pconfig($uid, 'jappixmini', 'server');
            if (!$server) {
                continue;
            }
            $address = $username . "@" . $server;
            // sign address
            $signed_address = "";
            openssl_private_encrypt($address, $signed_address, $channel['channel_prvkey']);
            // construct request url
            $signed_address_hex = base64url_encode($signed_address);
            $postvars = array('address' => $signed_address, 'requestor' => $channel['xchan_hash'], 'requestee' => $contact_row['xchan_hash']);
            try {
                // send request
                $answer_json = z_post_url($url, $postvars);
                logger('jappixmini: url response: ' . print_r($answer_json, true));
                if (!$answer_json['success']) {
                    logger('jappixmini: failed z_post_url ' . $url);
                    throw new Exception();
                }
                if ($answer_json['return_code'] == 404) {
                    logger('jappixmini: failed z_post_url (404)' . $url);
                    throw new Exception();
                }
                // parse answer
                $answer = json_decode($answer_json['body'], true);
                if ($answer['status'] != "ok") {
                    throw new Exception();
                }
                $address = base64url_decode($answer['address']);
                if (!$address) {
                    throw new Exception();
                }
                // decrypt address
                $decrypted_address = "";
                openssl_public_decrypt($address, $decrypted_address, $pubkey);
                if (!$decrypted_address) {
                    throw new Exception();
                }
            } catch (Exception $e) {
                $decrypted_address = "";
            }
            // save address
            set_pconfig($uid, "jappixmini", "id:" . $xchan_hash, "{$now}:{$decrypted_address}");
        }
    }
}
开发者ID:einervonvielen,项目名称:redmatrix-addons,代码行数:94,代码来源:jappixmini.php

示例12: 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) {
//.........这里部分代码省略.........
开发者ID:redmatrix,项目名称:red,代码行数:101,代码来源:search.php

示例13: stream_perms_api_uids

function stream_perms_api_uids($perms = NULL, $limit = 0, $rand = 0)
{
    $perms = is_null($perms) ? PERMS_SITE | PERMS_NETWORK | PERMS_PUBLIC : $perms;
    $ret = array();
    $limit_sql = $limit ? " LIMIT " . intval($limit) . " " : '';
    $random_sql = $rand ? " ORDER BY " . db_getfunc('RAND') . " " : '';
    if (local_channel()) {
        $ret[] = local_channel();
    }
    $r = q("select channel_id from channel where channel_r_stream > 0 and ( channel_r_stream & %d )>0 and ( channel_pageflags & %d ) = 0 {$random_sql} {$limit_sql} ", intval($perms), intval(PAGE_ADULT | PAGE_CENSORED | PAGE_SYSTEM | PAGE_REMOVED));
    if ($r) {
        foreach ($r as $rr) {
            if (!in_array($rr['channel_id'], $ret)) {
                $ret[] = $rr['channel_id'];
            }
        }
    }
    $str = '';
    if ($ret) {
        foreach ($ret as $rr) {
            if ($str) {
                $str .= ',';
            }
            $str .= intval($rr);
        }
    } else {
        $str = "''";
    }
    logger('stream_perms_api_uids: ' . $str, LOGGER_DEBUG);
    return $str;
}
开发者ID:einervonvielen,项目名称:redmatrix,代码行数:31,代码来源:security.php

示例14: stream_perms_api_uids

function stream_perms_api_uids($perms = NULL, $limit = 0, $rand = 0)
{
    $perms = is_null($perms) ? PERMS_SITE | PERMS_NETWORK | PERMS_PUBLIC : $perms;
    $ret = array();
    $limit_sql = $limit ? " LIMIT " . intval($limit) . " " : '';
    $random_sql = $rand ? " ORDER BY " . db_getfunc('RAND') . " " : '';
    if (local_channel()) {
        $ret[] = local_channel();
    }
    $x = q("select uid from pconfig where cat = 'perm_limits' and k = 'view_stream' and ( v & %d ) > 0 ", intval($perms));
    if ($x) {
        $ids = ids_to_querystr($x, 'uid');
        $r = q("select channel_id from channel where channel_id in ( {$ids} ) and ( channel_pageflags & %d ) = 0 and channel_system = 0 and channel_removed = 0 {$random_sql} {$limit_sql} ", intval(PAGE_ADULT | PAGE_CENSORED));
        if ($r) {
            foreach ($r as $rr) {
                if (!in_array($rr['channel_id'], $ret)) {
                    $ret[] = $rr['channel_id'];
                }
            }
        }
    }
    $str = '';
    if ($ret) {
        foreach ($ret as $rr) {
            if ($str) {
                $str .= ',';
            }
            $str .= intval($rr);
        }
    } else {
        $str = "''";
    }
    logger('stream_perms_api_uids: ' . $str, LOGGER_DEBUG);
    return $str;
}
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:35,代码来源:security.php

示例15: common_friends

function common_friends($uid, $xchan, $start = 0, $limit = 100000000, $shuffle = false)
{
    $rand = db_getfunc('rand');
    if ($shuffle) {
        $sql_extra = " order by {$rand} ";
    } else {
        $sql_extra = " order by xchan_name asc ";
    }
    $r = q("SELECT * from xchan left join xlink on xlink_link = xchan_hash where xlink_xchan = '%s' and xlink_static = 0 and xlink_link in\n\t\t(select abook_xchan from abook where abook_xchan != '%s' and abook_channel = %d and abook_self = 0 ) {$sql_extra} limit %d offset %d", dbesc($xchan), dbesc($xchan), intval($uid), intval($limit), intval($start));
    return $r;
}
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:11,代码来源:socgraph.php


注:本文中的db_getfunc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。