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


PHP zid函数代码示例

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


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

示例1: vcard_from_xchan

function vcard_from_xchan($xchan, $observer = null, $mode = '')
{
    $a = get_app();
    if (!$xchan) {
        if (App::$poi) {
            $xchan = App::$poi;
        } elseif (is_array(App::$profile) && App::$profile['channel_hash']) {
            $r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc(App::$profile['channel_hash']));
            if ($r) {
                $xchan = $r[0];
            }
        }
    }
    if (!$xchan) {
        return;
    }
    // FIXME - show connect button to observer if appropriate
    $connect = false;
    if (local_channel()) {
        $r = q("select * from abook where abook_xchan = '%s' and abook_channel = %d limit 1", dbesc($xchan['xchan_hash']), intval(local_channel()));
        if (!$r) {
            $connect = t('Connect');
        }
    }
    if (array_key_exists('channel_id', $xchan)) {
        App::$profile_uid = $xchan['channel_id'];
    }
    $url = $observer ? z_root() . '/magic?f=&dest=' . $xchan['xchan_url'] . '&addr=' . $xchan['xchan_addr'] : $xchan['xchan_url'];
    return replace_macros(get_markup_template('xchan_vcard.tpl'), array('$name' => $xchan['xchan_name'], '$photo' => is_array(App::$profile) && array_key_exists('photo', App::$profile) ? App::$profile['photo'] : $xchan['xchan_photo_l'], '$follow' => $xchan['xchan_addr'], '$link' => zid($xchan['xchan_url']), '$connect' => $connect, '$newwin' => $mode === 'chanview' ? t('New window') : '', '$newtit' => t('Open the selected location in a different window or browser tab'), '$url' => $url));
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:30,代码来源:Contact.php

示例2: oembed_fetch_url

function oembed_fetch_url($embedurl)
{
    $a = get_app();
    $txt = Cache::get($a->videowidth . $embedurl);
    if (strstr($txt, 'youtu')) {
        $txt = str_replace('http:', 'https:', $txt);
    }
    // These media files should now be caught in bbcode.php
    // left here as a fallback in case this is called from another source
    $noexts = array("mp3", "mp4", "ogg", "ogv", "oga", "ogm", "webm");
    $ext = pathinfo(strtolower($embedurl), PATHINFO_EXTENSION);
    if (is_null($txt)) {
        $txt = "";
        if (in_array($ext, $noexts)) {
            require_once 'include/hubloc.php';
            $zrl = is_matrix_url($embedurl);
            if ($zrl) {
                $embedurl = zid($embedurl);
            }
        } else {
            // try oembed autodiscovery
            $redirects = 0;
            $result = z_fetch_url($embedurl, false, $redirects, array('timeout' => 15, 'accept_content' => "text/*", 'novalidate' => true));
            if ($result['success']) {
                $html_text = $result['body'];
            }
            if ($html_text) {
                $dom = @DOMDocument::loadHTML($html_text);
                if ($dom) {
                    $xpath = new DOMXPath($dom);
                    $attr = "oembed";
                    $xattr = oe_build_xpath("class", "oembed");
                    $entries = $xpath->query("//link[@type='application/json+oembed']");
                    foreach ($entries as $e) {
                        $href = $e->getAttributeNode("href")->nodeValue;
                        $x = z_fetch_url($href . '&maxwidth=' . $a->videowidth);
                        $txt = $x['body'];
                        break;
                    }
                }
            }
        }
        if ($txt == false || $txt == "") {
            $x = array('url' => $embedurl, 'videowidth' => $a->videowidth);
            call_hooks('oembed_probe', $x);
            if (array_key_exists('embed', $x)) {
                $txt = $x['embed'];
            }
        }
        $txt = trim($txt);
        if ($txt[0] != "{") {
            $txt = '{"type":"error"}';
        }
        //save in cache
        Cache::set($a->videowidth . $embedurl, $txt);
    }
    $j = json_decode($txt);
    $j->embedurl = $embedurl;
    return $j;
}
开发者ID:Mauru,项目名称:red,代码行数:60,代码来源:oembed.php

示例3: menu_render

function menu_render($menu, $class = '', $edit = false, $var = array())
{
    if (!$menu) {
        return '';
    }
    $channel_id = is_array(App::$profile) ? App::$profile['profile_uid'] : 0;
    if (!$channel_id && local_channel()) {
        $channel_id = local_channel();
    }
    $menu_list = menu_list($channel_id);
    $menu_names = array();
    foreach ($menu_list as $menus) {
        if ($menus['menu_name'] != $menu['menu']['menu_name']) {
            $menu_names[] = $menus['menu_name'];
        }
    }
    for ($x = 0; $x < count($menu['items']); $x++) {
        if (in_array($menu['items'][$x]['mitem_link'], $menu_names)) {
            $m = menu_fetch($menu['items'][$x]['mitem_link'], $channel_id, get_observer_hash());
            $submenu = menu_render($m, 'dropdown-menu', $edit = false, array('wrap' => 'none'));
            $menu['items'][$x]['submenu'] = $submenu;
        }
        if ($menu['items'][$x]['mitem_flags'] & MENU_ITEM_ZID) {
            $menu['items'][$x]['mitem_link'] = zid($menu['items'][$x]['mitem_link']);
        }
        if ($menu['items'][$x]['mitem_flags'] & MENU_ITEM_NEWWIN) {
            $menu['items'][$x]['newwin'] = '1';
        }
        $menu['items'][$x]['mitem_desc'] = bbcode($menu['items'][$x]['mitem_desc']);
    }
    $wrap = $var['wrap'] === 'none' ? false : true;
    $ret = replace_macros(get_markup_template('usermenu.tpl'), array('$menu' => $menu['menu'], '$class' => $class, '$edit' => $edit ? t("Edit") : '', '$id' => $menu['menu']['menu_id'], '$items' => $menu['items'], '$wrap' => $wrap));
    return $ret;
}
开发者ID:einervonvielen,项目名称:hubzilla,代码行数:34,代码来源:menu.php

示例4: get

 function get()
 {
     $status = strip_tags($_REQUEST['status']);
     $room_id = intval(\App::$data['chat']['room_id']);
     $stopped = x($_REQUEST, 'stopped') && intval($_REQUEST['stopped']) ? true : false;
     if ($status && $room_id) {
         $x = q("select channel_address from channel where channel_id = %d limit 1", intval(\App::$data['chat']['uid']));
         $r = q("update chatpresence set cp_status = '%s', cp_last = '%s' where cp_room = %d and cp_xchan = '%s' and cp_client = '%s'", dbesc($status), dbesc(datetime_convert()), intval($room_id), dbesc(get_observer_hash()), dbesc($_SERVER['REMOTE_ADDR']));
         goaway(z_root() . '/chat/' . $x[0]['channel_address'] . '/' . $room_id);
     }
     if (!$stopped) {
         $lastseen = intval($_REQUEST['last']);
         $ret = array('success' => false);
         $sql_extra = permissions_sql(\App::$data['chat']['uid']);
         $r = q("select * from chatroom where cr_uid = %d and cr_id = %d {$sql_extra}", intval(\App::$data['chat']['uid']), intval(\App::$data['chat']['room_id']));
         if (!$r) {
             json_return_and_die($ret);
         }
         $inroom = array();
         $r = q("select * from chatpresence left join xchan on xchan_hash = cp_xchan where cp_room = %d order by xchan_name", intval(\App::$data['chat']['room_id']));
         if ($r) {
             foreach ($r as $rr) {
                 switch ($rr['cp_status']) {
                     case 'away':
                         $status = t('Away');
                         $status_class = 'away';
                         break;
                     case 'online':
                     default:
                         $status = t('Online');
                         $status_class = 'online';
                         break;
                 }
                 $inroom[] = array('img' => zid($rr['xchan_photo_m']), 'img_type' => $rr['xchan_photo_mimetype'], 'name' => $rr['xchan_name'], 'status' => $status, 'status_class' => $status_class);
             }
         }
         $chats = array();
         $r = q("select * from chat left join xchan on chat_xchan = xchan_hash where chat_room = %d and chat_id > %d order by created", intval(\App::$data['chat']['room_id']), intval($lastseen));
         if ($r) {
             foreach ($r as $rr) {
                 $chats[] = array('id' => $rr['chat_id'], 'img' => zid($rr['xchan_photo_m']), 'img_type' => $rr['xchan_photo_mimetype'], 'name' => $rr['xchan_name'], 'isotime' => datetime_convert('UTC', date_default_timezone_get(), $rr['created'], 'c'), 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $rr['created'], 'r'), 'text' => smilies(bbcode($rr['chat_text'])), 'self' => get_observer_hash() == $rr['chat_xchan'] ? 'self' : '');
             }
         }
     }
     $r = q("update chatpresence set cp_last = '%s' where cp_room = %d and cp_xchan = '%s' and cp_client = '%s'", dbesc(datetime_convert()), intval(\App::$data['chat']['room_id']), dbesc(get_observer_hash()), dbesc($_SERVER['REMOTE_ADDR']));
     $ret['success'] = true;
     if (!$stopped) {
         $ret['inroom'] = $inroom;
         $ret['chats'] = $chats;
     }
     json_return_and_die($ret);
 }
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:52,代码来源:Chatsvc.php

示例5: 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

示例6: menu_render

function menu_render($menu, $class = '', $edit = false)
{
    if (!$menu) {
        return '';
    }
    for ($x = 0; $x < count($menu['items']); $x++) {
        if ($menu['items'][$x]['mitem_flags'] & MENU_ITEM_ZID) {
            $menu['items'][$x]['mitem_link'] = zid($menu['items'][$x]['mitem_link']);
        }
        if ($menu['items'][$x]['mitem_flags'] & MENU_ITEM_NEWWIN) {
            $menu['items'][$x]['newwin'] = '1';
        }
        $menu['items'][$x]['mitem_desc'] = bbcode($menu['items'][$x]['mitem_desc']);
    }
    return replace_macros(get_markup_template('usermenu.tpl'), array('$menu' => $menu['menu'], '$class' => $class, '$edit' => $edit ? t("Edit") : '', '$items' => $menu['items']));
}
开发者ID:Mauru,项目名称:red,代码行数:16,代码来源:menu.php

示例7: 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

示例8: match_content

/**
 * @brief Controller for /match.
 *
 * It takes keywords from your profile and queries the directory server for
 * matching keywords from other profiles.
 *
 * @FIXME this has never been properly ported from Friendica.
 *
 * @param App &$a
 * @return void|string
 */
function match_content(&$a)
{
    $o = '';
    if (!local_channel()) {
        return;
    }
    $_SESSION['return_url'] = z_root() . '/' . App::$cmd;
    $o .= '<h2>' . t('Profile Match') . '</h2>';
    $r = q("SELECT `keywords` FROM `profile` WHERE `is_default` = 1 AND `uid` = %d LIMIT 1", intval(local_channel()));
    if (!count($r)) {
        return;
    }
    if (!$r[0]['keywords']) {
        notice(t('No keywords to match. Please add keywords to your default profile.') . EOL);
        return;
    }
    $params = array();
    $tags = trim($r[0]['keywords']);
    if ($tags) {
        $params['s'] = $tags;
        if (App::$pager['page'] != 1) {
            $params['p'] = App::$pager['page'];
        }
        //		if(strlen(get_config('system','directory_submit_url')))
        //			$x = post_url('http://dir.friendica.com/msearch', $params);
        //		else
        //			$x = post_url(z_root() . '/msearch', $params);
        $j = json_decode($x);
        if ($j->total) {
            App::set_pager_total($j->total);
            App::set_pager_itemspage($j->items_page);
        }
        if (count($j->results)) {
            $tpl = get_markup_template('match.tpl');
            foreach ($j->results as $jj) {
                $connlnk = z_root() . '/follow/?url=' . $jj->url;
                $o .= replace_macros($tpl, array('$url' => zid($jj->url), '$name' => $jj->name, '$photo' => $jj->photo, '$inttxt' => ' ' . t('is interested in:'), '$conntxt' => t('Connect'), '$connlnk' => $connlnk, '$tags' => $jj->tags));
            }
        } else {
            info(t('No matches') . EOL);
        }
    }
    $o .= cleardiv();
    $o .= paginate($a);
    return $o;
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:57,代码来源:match.php

示例9: get


//.........这里部分代码省略.........
     }
     // 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;
         }
         $maxheight = get_pconfig(local_channel(), 'system', 'network_divmore_height');
         if (!$maxheight) {
             $maxheight = 400;
         }
         $o .= '<div id="live-network"></div>' . "\r\n";
         $o .= "<script> var profile_uid = " . local_channel() . "; 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' => 'network', '$uid' => local_channel() ? local_channel() : '0', '$gid' => $gid ? $gid : '0', '$cid' => $cid ? $cid : '0', '$cmin' => $cmin ? $cmin : '0', '$cmax' => $cmax ? $cmax : '0', '$star' => $star ? $star : '0', '$liked' => $liked ? $liked : '0', '$conv' => $conv ? $conv : '0', '$spam' => $spam ? $spam : '0', '$fh' => $firehose ? $firehose : '0', '$nouveau' => $nouveau ? $nouveau : '0', '$wall' => '0', '$list' => x($_REQUEST, 'list') ? intval($_REQUEST['list']) : 0, '$page' => \App::$pager['page'] != 1 ? \App::$pager['page'] : 1, '$search' => $search ? $search : '', '$order' => $order, '$file' => $file, '$cats' => $category, '$tags' => $hashtags, '$dend' => $datequery, '$mid' => '', '$verb' => $verb, '$dbegin' => $datequery2));
     }
     $sql_extra3 = '';
     if ($datequery) {
         $sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery))));
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:67,代码来源:Network.php

示例10: get_plink

function get_plink($item, $conversation_mode = true)
{
    if ($conversation_mode) {
        $key = 'plink';
    } else {
        $key = 'llink';
    }
    if (x($item, $key)) {
        return array('href' => zid($item[$key]), 'title' => t('Link to Source'));
    } else {
        return false;
    }
}
开发者ID:23n,项目名称:hubzilla,代码行数:13,代码来源:text.php

示例11: app_render

function app_render($papp, $mode = 'view')
{
    /**
     * modes:
     *    view: normal mode for viewing an app via bbcode from a conversation or page
     *       provides install/update button if you're logged in locally
     *    list: normal mode for viewing an app on the app page
     *       no buttons are shown
     *    edit: viewing the app page in editing mode provides a delete button
     */
    $installed = false;
    if (!$papp['photo']) {
        $papp['photo'] = z_root() . '/' . get_default_profile_photo(80);
    }
    if (!$papp) {
        return;
    }
    $papp['papp'] = papp_encode($papp);
    foreach ($papp as $k => $v) {
        if (strpos($v, 'http') === 0 && $k != 'papp') {
            $papp[$k] = zid($v);
        }
        if ($k === 'desc') {
            $papp['desc'] = str_replace(array('\'', '"'), array('&#39;', '&dquot;'), $papp['desc']);
        }
        if ($k === 'requires') {
            $require = trim(strtolower($v));
            switch ($require) {
                case 'nologin':
                    if (local_user()) {
                        return '';
                    }
                    break;
                case 'admin':
                    if (!is_site_admin()) {
                        return '';
                    }
                    break;
                case 'local_user':
                    if (!local_user()) {
                        return '';
                    }
                    break;
                case 'public_profile':
                    if (!is_public_profile()) {
                        return '';
                    }
                    break;
                case 'observer':
                    $observer = get_app()->get_observer();
                    if (!$observer) {
                        return '';
                    }
                    break;
                default:
                    if (!local_user() && feature_enabled(local_user(), $require)) {
                        return '';
                    }
                    break;
            }
        }
    }
    $hosturl = '';
    if (local_user()) {
        $installed = app_installed(local_user(), $papp);
        $hosturl = z_root() . '/';
    } elseif (remote_user()) {
        $observer = get_app()->get_observer();
        if ($observer && $observer['xchan_network'] === 'zot') {
            // some folks might have xchan_url redirected offsite, use the connurl
            $x = parse_url($observer['xchan_connurl']);
            if ($x) {
                $hosturl = $x['scheme'] . '://' . $x['host'] . '/';
            }
        }
    }
    $install_action = $installed ? t('Update') : t('Install');
    return replace_macros(get_markup_template('app.tpl'), array('$app' => $papp, '$hosturl' => $hosturl, '$purchase' => $papp['page'] && !$installed ? t('Purchase') : '', '$install' => $hosturl && $mode == 'view' ? $install_action : '', '$edit' => local_user() && $installed && $mode == 'edit' ? t('Edit') : '', '$delete' => local_user() && $installed && $mode == 'edit' ? t('Delete') : ''));
}
开发者ID:Mauru,项目名称:red,代码行数:79,代码来源:apps.php

示例12: dirprofile_init

function dirprofile_init(&$a)
{
    if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
        notice(t('Public access denied.') . EOL);
        return;
    }
    $hash = $_REQUEST['hash'];
    if (!$hash) {
        return '';
    }
    $o = '';
    $dirmode = intval(get_config('system', 'directory_mode'));
    if ($dirmode == DIRECTORY_MODE_PRIMARY || $dirmode == DIRECTORY_MODE_STANDALONE) {
        $url = z_root() . '/dirsearch';
    }
    if (!$url) {
        $directory = find_upstream_directory($dirmode);
        $url = $directory['url'] . '/dirsearch';
    }
    logger('mod_directory: URL = ' . $url, LOGGER_DEBUG);
    $contacts = array();
    if (local_user()) {
        $x = q("select abook_xchan from abook where abook_channel = %d", intval(local_user()));
        if ($x) {
            foreach ($x as $xx) {
                $contacts[] = $xx['abook_xchan'];
            }
        }
    }
    if ($url) {
        $query = $url . '?f=&hash=' . $hash;
        $x = z_fetch_url($query);
        logger('dirprofile: return from upstream: ' . print_r($x, true), LOGGER_DATA);
        if ($x['success']) {
            $t = 0;
            $j = json_decode($x['body'], true);
            if ($j) {
                if ($j['results']) {
                    $entries = array();
                    $photo = 'thumb';
                    foreach ($j['results'] as $rr) {
                        $profile_link = chanlink_url($rr['url']);
                        $pdesc = $rr['description'] ? $rr['description'] . '<br />' : '';
                        $qrlink = zid($rr['url']);
                        $connect_link = local_user() ? z_root() . '/follow?f=&url=' . urlencode($rr['address']) : '';
                        $online = remote_online_status($rr['address']);
                        if (in_array($rr['hash'], $contacts)) {
                            $connect_link = '';
                        }
                        $details = '';
                        if (strlen($rr['locale'])) {
                            $details .= $rr['locale'];
                        }
                        if (strlen($rr['region'])) {
                            if (strlen($rr['locale'])) {
                                $details .= ', ';
                            }
                            $details .= $rr['region'];
                        }
                        if (strlen($rr['country'])) {
                            if (strlen($details)) {
                                $details .= ', ';
                            }
                            $details .= $rr['country'];
                        }
                        if (strlen($rr['birthday'])) {
                            if (($years = age($rr['birthday'], 'UTC', '')) != 0) {
                                $details .= '<br />' . t('Age: ') . $years;
                            }
                        }
                        if (strlen($rr['gender'])) {
                            $details .= '<br />' . t('Gender: ') . $rr['gender'];
                        }
                        $page_type = '';
                        $profile = $rr;
                        if (x($profile, 'locale') == 1 || x($profile, 'region') == 1 || x($profile, 'postcode') == 1 || x($profile, 'country') == 1) {
                            $location = t('Location:');
                        }
                        $marital = x($profile, 'marital') == 1 ? t('Status: ') . $profile['marital'] : False;
                        $sexual = x($profile, 'sexual') == 1 ? t('Sexual Preference: ') . $profile['sexual'] : False;
                        $homepage = x($profile, 'homepage') == 1 ? t('Homepage: ') . linkify($profile['homepage']) : False;
                        $hometown = x($profile, 'hometown') == 1 ? t('Hometown: ') . $profile['hometown'] : False;
                        $about = x($profile, 'about') == 1 ? t('About: ') . bbcode($profile['about']) : False;
                        $keywords = x($profile, 'keywords') ? $profile['keywords'] : '';
                        if ($keywords) {
                            $keywords = str_replace(',', ' ', $keywords);
                            $keywords = str_replace('  ', ' ', $keywords);
                            $karr = explode(' ', $keywords);
                            $out = '';
                            if ($karr) {
                                if (local_user()) {
                                    $r = q("select keywords from profile where uid = %d and is_default = 1 limit 1", intval(local_user()));
                                    if ($r) {
                                        $keywords = str_replace(',', ' ', $r[0]['keywords']);
                                        $keywords = str_replace('  ', ' ', $keywords);
                                        $marr = explode(' ', $keywords);
                                    }
                                }
                                foreach ($karr as $k) {
                                    if (strlen($out)) {
//.........这里部分代码省略.........
开发者ID:Mauru,项目名称:red,代码行数:101,代码来源:dirprofile.php

示例13: new_contact

function new_contact($uid, $url, $channel, $interactive = false, $confirm = false)
{
    $result = array('success' => false, 'message' => '');
    $is_red = false;
    $is_http = strpos($url, '://') !== false ? true : false;
    if ($is_http && substr($url, -1, 1) === '/') {
        $url = substr($url, 0, -1);
    }
    if (!allowed_url($url)) {
        $result['message'] = t('Channel is blocked on this site.');
        return $result;
    }
    if (!$url) {
        $result['message'] = t('Channel location missing.');
        return $result;
    }
    // check service class limits
    $r = q("select count(*) as total from abook where abook_channel = %d and abook_self = 0 ", intval($uid));
    if ($r) {
        $total_channels = $r[0]['total'];
    }
    if (!service_class_allows($uid, 'total_channels', $total_channels)) {
        $result['message'] = upgrade_message();
        return $result;
    }
    $arr = array('url' => $url, 'channel' => array());
    call_hooks('follow', $arr);
    if ($arr['channel']['success']) {
        $ret = $arr['channel'];
    } elseif (!$is_http) {
        $ret = Zotlabs\Zot\Finger::run($url, $channel);
    }
    if ($ret && is_array($ret) && $ret['success']) {
        $is_red = true;
        $j = $ret;
    }
    $my_perms = get_channel_default_perms($uid);
    $role = get_pconfig($uid, 'system', 'permissions_role');
    if ($role) {
        $x = \Zotlabs\Access\PermissionRoles::role_perms($role);
        if ($x['perms_connect']) {
            $my_perms = $x['perms_connect'];
        }
    }
    if ($is_red && $j) {
        logger('follow: ' . $url . ' ' . print_r($j, true), LOGGER_DEBUG);
        if (!($j['success'] && $j['guid'])) {
            $result['message'] = t('Response from remote channel was incomplete.');
            logger('mod_follow: ' . $result['message']);
            return $result;
        }
        // Premium channel, set confirm before callback to avoid recursion
        if (array_key_exists('connect_url', $j) && $interactive && !$confirm) {
            goaway(zid($j['connect_url']));
        }
        // do we have an xchan and hubloc?
        // If not, create them.
        $x = import_xchan($j);
        if (array_key_exists('deleted', $j) && intval($j['deleted'])) {
            $result['message'] = t('Channel was deleted and no longer exists.');
            return $result;
        }
        if (!$x['success']) {
            return $x;
        }
        $xchan_hash = $x['hash'];
        if (array_key_exists('permissions', $j) && array_key_exists('data', $j['permissions'])) {
            $permissions = crypto_unencapsulate(array('data' => $j['permissions']['data'], 'key' => $j['permissions']['key'], 'iv' => $j['permissions']['iv']), $channel['channel_prvkey']);
            if ($permissions) {
                $permissions = json_decode($permissions, true);
            }
            logger('decrypted permissions: ' . print_r($permissions, true), LOGGER_DATA);
        } else {
            $permissions = $j['permissions'];
        }
        if (is_array($permissions) && $permissions) {
            foreach ($permissions as $k => $v) {
                set_abconfig($channel['channel_uid'], $xchan_hash, 'their_perms', $k, intval($v));
            }
        }
    } else {
        $xchan_hash = '';
        $r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' limit 1", dbesc($url), dbesc($url));
        if (!$r) {
            // attempt network auto-discovery
            $d = discover_by_webbie($url);
            if (!$d && $is_http) {
                // try RSS discovery
                if (get_config('system', 'feed_contacts')) {
                    $d = discover_by_url($url);
                } else {
                    $result['message'] = t('Protocol disabled.');
                    return $result;
                }
            }
            if ($d) {
                $r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' limit 1", dbesc($url), dbesc($url));
            }
        }
        // if discovery was a success we should have an xchan record in $r
//.........这里部分代码省略.........
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:101,代码来源:follow.php

示例14: chanview_content

function chanview_content(&$a)
{
    $observer = $a->get_observer();
    $xchan = null;
    $r = null;
    if ($_REQUEST['hash']) {
        $r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($_REQUEST['hash']));
    }
    if ($_REQUEST['address']) {
        $r = q("select * from xchan where xchan_addr = '%s' limit 1", dbesc($_REQUEST['address']));
    } elseif (local_channel() && intval($_REQUEST['cid'])) {
        $r = q("SELECT abook.*, xchan.* \n\t\t\tFROM abook left join xchan on abook_xchan = xchan_hash\n\t\t\tWHERE abook_channel = %d and abook_id = %d LIMIT 1", intval(local_channel()), intval($_REQUEST['cid']));
    } elseif ($_REQUEST['url']) {
        // if somebody re-installed they will have more than one xchan, use the most recent name date as this is
        // the most useful consistently ascending table item we have.
        $r = q("select * from xchan where xchan_url = '%s' order by xchan_name_date desc limit 1", dbesc($_REQUEST['url']));
    }
    if ($r) {
        $a->poi = $r[0];
    }
    // Here, let's see if we have an xchan. If we don't, how we proceed is determined by what
    // info we do have. If it's a URL, we can offer to visit it directly. If it's a webbie or
    // address, we can and should try to import it. If it's just a hash, we can't continue, but we
    // probably wouldn't have a hash if we don't already have an xchan for this channel.
    if (!$a->poi) {
        logger('mod_chanview: fallback');
        // This is hackish - construct a zot address from the url
        if ($_REQUEST['url']) {
            if (preg_match('/https?\\:\\/\\/(.*?)(\\/channel\\/|\\/profile\\/)(.*?)$/ism', $_REQUEST['url'], $matches)) {
                $_REQUEST['address'] = $matches[3] . '@' . $matches[1];
            }
            logger('mod_chanview: constructed address ' . print_r($matches, true));
        }
        if ($_REQUEST['address']) {
            $ret = zot_finger($_REQUEST['address'], null);
            if ($ret['success']) {
                $j = json_decode($ret['body'], true);
                if ($j) {
                    import_xchan($j);
                }
                $r = q("select * from xchan where xchan_addr = '%s' limit 1", dbesc($_REQUEST['address']));
                if ($r) {
                    $a->poi = $r[0];
                }
            }
        }
    }
    if (!$a->poi) {
        //		We don't know who this is, and we can't figure it out from the URL
        //		On the plus side, there's a good chance we know somebody else at that
        //		hub so sending them there with a Zid will probably work anyway.
        $url = $_REQUEST['url'];
        if ($observer) {
            $url = zid($url);
        }
    }
    if ($a->poi) {
        $url = $a->poi['xchan_url'];
        if ($observer) {
            $url = zid($url);
        }
    }
    // let somebody over-ride the iframed viewport presentation
    // or let's just declare this a failed experiment.
    //	if((! local_channel()) || (get_pconfig(local_channel(),'system','chanview_full')))
    goaway($url);
    //	$o = replace_macros(get_markup_template('chanview.tpl'),array(
    //		'$url' => $url,
    //		'$full' => t('toggle full screen mode')
    //	));
    //	return $o;
}
开发者ID:msooon,项目名称:hubzilla,代码行数:72,代码来源:chanview.php

示例15: photos_content


//.........这里部分代码省略.........
                    builtin_activity_puller($item, $conv_responses);
                }
                $like_count = x($alike, $link_item['mid']) ? $alike[$link_item['mid']] : '';
                $like_list = x($alike, $link_item['mid']) ? $alike[$link_item['mid'] . '-l'] : '';
                if (count($like_list) > MAX_LIKERS) {
                    $like_list_part = array_slice($like_list, 0, MAX_LIKERS);
                    array_push($like_list_part, '<a href="#" data-toggle="modal" data-target="#likeModal-' . $this->get_id() . '"><b>' . t('View all') . '</b></a>');
                } else {
                    $like_list_part = '';
                }
                $like_button_label = tt('Like', 'Likes', $like_count, 'noun');
                //if (feature_enabled($conv->get_profile_owner(),'dislike')) {
                $dislike_count = x($dlike, $link_item['mid']) ? $dlike[$link_item['mid']] : '';
                $dislike_list = x($dlike, $link_item['mid']) ? $dlike[$link_item['mid'] . '-l'] : '';
                $dislike_button_label = tt('Dislike', 'Dislikes', $dislike_count, 'noun');
                if (count($dislike_list) > MAX_LIKERS) {
                    $dislike_list_part = array_slice($dislike_list, 0, MAX_LIKERS);
                    array_push($dislike_list_part, '<a href="#" data-toggle="modal" data-target="#dislikeModal-' . $this->get_id() . '"><b>' . t('View all') . '</b></a>');
                } else {
                    $dislike_list_part = '';
                }
                //}
                $like = isset($alike[$link_item['mid']]) ? format_like($alike[$link_item['mid']], $alike[$link_item['mid'] . '-l'], 'like', $link_item['mid']) : '';
                $dislike = isset($dlike[$link_item['mid']]) ? format_like($dlike[$link_item['mid']], $dlike[$link_item['mid'] . '-l'], 'dislike', $link_item['mid']) : '';
                // display comments
                foreach ($r as $item) {
                    $comment = '';
                    $template = $tpl;
                    $sparkle = '';
                    if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && $item['id'] != $item['parent']) {
                        continue;
                    }
                    $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'];
                    $profile_url = zid($item['author']['xchan_url']);
                    $sparkle = '';
                    $profile_name = $item['author']['xchan_name'];
                    $profile_avatar = $item['author']['xchan_photo_m'];
                    $profile_link = $profile_url;
                    $drop = '';
                    if ($observer['xchan_hash'] === $item['author_xchan'] || $observer['xchan_hash'] === $item['owner_xchan']) {
                        $drop = replace_macros(get_markup_template('photo_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete')));
                    }
                    $name_e = $profile_name;
                    $title_e = $item['title'];
                    unobscure($item);
                    $body_e = prepare_text($item['body'], $item['mimetype']);
                    $comments .= replace_macros($template, array('$id' => $item['id'], '$mode' => 'photos', '$profile_url' => $profile_link, '$name' => $name_e, '$thumb' => $profile_avatar, '$sparkle' => $sparkle, '$title' => $title_e, '$body' => $body_e, '$ago' => relative_date($item['created']), '$indent' => $item['parent'] != $item['id'] ? ' comment' : '', '$drop' => $drop, '$comment' => $comment));
                }
                if ($can_post || $can_comment) {
                    $commentbox = replace_macros($cmnt_tpl, array('$return_path' => '', '$jsreload' => $return_url, '$type' => 'wall-comment', '$id' => $link_item['id'], '$parent' => $link_item['id'], '$profile_uid' => $owner_uid, '$mylink' => $observer['xchan_url'], '$mytitle' => t('This is you'), '$myphoto' => $observer['xchan_photo_s'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$ww' => ''));
                }
            }
            $paginate = paginate($a);
        }
        $album_e = array($album_link, $ph[0]['album']);
        $like_e = $like;
        $dislike_e = $dislike;
        $response_verbs = array('like');
        if (feature_enabled($owner_uid, 'dislike')) {
            $response_verbs[] = 'dislike';
        }
        $responses = get_responses($conv_responses, $response_verbs, '', $link_item);
        $photo_tpl = get_markup_template('photo_view.tpl');
        $o .= replace_macros($photo_tpl, array('$id' => $ph[0]['id'], '$album' => $album_e, '$tools' => $tools, '$lock' => $lockstate[1], '$photo' => $photo, '$prevlink' => $prevlink, '$nextlink' => $nextlink, '$desc' => $ph[0]['description'], '$filename' => $ph[0]['filename'], '$unknown' => t('Unknown'), '$tag_hdr' => t('In This Photo:'), '$tags' => $tags, 'responses' => $responses, '$edit' => $edit, '$map' => $map, '$map_text' => t('Map'), '$likebuttons' => $likebuttons, '$like' => $like_e, '$dislike' => $dislike_e, '$like_count' => $like_count, '$like_list' => $like_list, '$like_list_part' => $like_list_part, '$like_button_label' => $like_button_label, '$like_modal_title' => t('Likes', 'noun'), '$dislike_modal_title' => t('Dislikes', 'noun'), '$dislike_count' => $dislike_count, '$dislike_list' => $dislike_list, '$dislike_list_part' => $dislike_list_part, '$dislike_button_label' => $dislike_button_label, '$modal_dismiss' => t('Close'), '$comments' => $comments, '$commentbox' => $commentbox, '$paginate' => $paginate));
        $a->data['photo_html'] = $o;
        return $o;
开发者ID:spthaolt,项目名称:hubzilla,代码行数:67,代码来源:photos.php


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