コード例 #1
0
ファイル: xrd.php プロジェクト: ZerGabriel/friendica
function xrd_init(&$a)
{
    $uri = urldecode(notags(trim($_GET['uri'])));
    if (substr($uri, 0, 4) === 'http') {
        $name = basename($uri);
    } else {
        $local = str_replace('acct:', '', $uri);
        if (substr($local, 0, 2) == '//') {
            $local = substr($local, 2);
        }
        $name = substr($local, 0, strpos($local, '@'));
    }
    $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1", dbesc($name));
    if (!count($r)) {
        killme();
    }
    $salmon_key = salmon_key($r[0]['spubkey']);
    header('Access-Control-Allow-Origin: *');
    header("Content-type: text/xml");
    if (get_config('system', 'diaspora_enabled')) {
        //$tpl = file_get_contents('view/xrd_diaspora.tpl');
        $tpl = get_markup_template('xrd_diaspora.tpl');
        $dspr = replace_macros($tpl, array('$baseurl' => $a->get_baseurl(), '$dspr_guid' => $r[0]['guid'], '$dspr_key' => base64_encode(pemtorsa($r[0]['pubkey']))));
    } else {
        $dspr = '';
    }
    //$tpl = file_get_contents('view/xrd_person.tpl');
    $tpl = get_markup_template('xrd_person.tpl');
    $o = replace_macros($tpl, array('$nick' => $r[0]['nickname'], '$accturi' => $uri, '$profile_url' => $a->get_baseurl() . '/profile/' . $r[0]['nickname'], '$hcard_url' => $a->get_baseurl() . '/hcard/' . $r[0]['nickname'], '$atom' => $a->get_baseurl() . '/dfrn_poll/' . $r[0]['nickname'], '$zot_post' => $a->get_baseurl() . '/post/' . $r[0]['nickname'], '$poco_url' => $a->get_baseurl() . '/poco/' . $r[0]['nickname'], '$photo' => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid'] . '.jpg', '$dspr' => $dspr, '$salmon' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'], '$salmen' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention', '$subscribe' => $a->get_baseurl() . '/follow?url={uri}', '$modexp' => 'data:application/magic-public-key,' . $salmon_key, '$bigkey' => salmon_key($r[0]['pubkey'])));
    $arr = array('user' => $r[0], 'xml' => $o);
    call_hooks('personal_xrd', $arr);
    echo $arr['xml'];
    killme();
}
コード例 #2
0
ファイル: Xrd.php プロジェクト: phellmes/hubzilla
 function init()
 {
     $uri = urldecode(notags(trim($_GET['uri'])));
     logger('xrd: ' . $uri, LOGGER_DEBUG);
     $resource = $uri;
     if (substr($uri, 0, 4) === 'http') {
         $uri = str_replace('~', '', $uri);
         $name = basename($uri);
     } else {
         $local = str_replace('acct:', '', $uri);
         if (substr($local, 0, 2) == '//') {
             $local = substr($local, 2);
         }
         $name = substr($local, 0, strpos($local, '@'));
     }
     $r = q("SELECT * FROM channel WHERE channel_address = '%s' LIMIT 1", dbesc($name));
     if (!$r) {
         killme();
     }
     $dspr = replace_macros(get_markup_template('xrd_diaspora.tpl'), array('$baseurl' => z_root(), '$dspr_guid' => $r[0]['channel_guid'] . str_replace('.', '', \App::get_hostname()), '$dspr_key' => base64_encode(pemtorsa($r[0]['channel_pubkey']))));
     $salmon_key = salmon_key($r[0]['channel_pubkey']);
     header('Access-Control-Allow-Origin: *');
     header("Content-type: application/xrd+xml");
     $aliases = array('acct:' . channel_reddress($r[0]), z_root() . '/channel/' . $r[0]['channel_address'], z_root() . '/~' . $r[0]['channel_address']);
     for ($x = 0; $x < count($aliases); $x++) {
         if ($aliases[$x] === $resource) {
             unset($aliases[$x]);
         }
     }
     $o = replace_macros(get_markup_template('xrd_person.tpl'), array('$nick' => $r[0]['channel_address'], '$accturi' => $resource, '$aliases' => $aliases, '$profile_url' => z_root() . '/channel/' . $r[0]['channel_address'], '$hcard_url' => z_root() . '/hcard/' . $r[0]['channel_address'], '$atom' => z_root() . '/feed/' . $r[0]['channel_address'], '$zot_post' => z_root() . '/post/' . $r[0]['channel_address'], '$poco_url' => z_root() . '/poco/' . $r[0]['channel_address'], '$photo' => z_root() . '/photo/profile/l/' . $r[0]['channel_id'], '$dspr' => $dspr, '$modexp' => 'data:application/magic-public-key,' . $salmon_key, '$subscribe' => z_root() . '/follow?url={uri}', '$bigkey' => salmon_key($r[0]['channel_pubkey'])));
     $arr = array('user' => $r[0], 'xml' => $o);
     call_hooks('personal_xrd', $arr);
     echo $arr['xml'];
     killme();
 }
コード例 #3
0
ファイル: xrd.php プロジェクト: redmatrix/red
function xrd_init(&$a)
{
    $uri = urldecode(notags(trim($_GET['uri'])));
    if (substr($uri, 0, 4) === 'http') {
        $name = basename($uri);
    } else {
        $local = str_replace('acct:', '', $uri);
        if (substr($local, 0, 2) == '//') {
            $local = substr($local, 2);
        }
        $name = substr($local, 0, strpos($local, '@'));
    }
    $r = q("SELECT * FROM channel WHERE channel_address = '%s' LIMIT 1", dbesc($name));
    if (!$r) {
        killme();
    }
    $dspr = replace_macros(get_markup_template('xrd_diaspora.tpl'), array('$baseurl' => $a->get_baseurl(), '$dspr_guid' => $r[0]['channel_guid'], '$dspr_key' => base64_encode(pemtorsa($r[0]['channel_pubkey']))));
    $salmon_key = salmon_key($r[0]['channel_pubkey']);
    header('Access-Control-Allow-Origin: *');
    header("Content-type: text/xml");
    $tpl = get_markup_template('view/xrd_person.tpl');
    $o = replace_macros(get_markup_template('xrd_person.tpl'), array('$nick' => $r[0]['channel_address'], '$accturi' => $uri, '$profile_url' => $a->get_baseurl() . '/channel/' . $r[0]['channel_address'], '$hcard_url' => $a->get_baseurl() . '/hcard/' . $r[0]['channel_address'], '$atom' => $a->get_baseurl() . '/feed/' . $r[0]['channel_address'], '$zot_post' => $a->get_baseurl() . '/post/' . $r[0]['channel_address'], '$poco_url' => $a->get_baseurl() . '/poco/' . $r[0]['channel_address'], '$photo' => $a->get_baseurl() . '/photo/profile/l/' . $r[0]['channel_id'], '$dspr' => $dspr, '$modexp' => 'data:application/magic-public-key,' . $salmon_key));
    $arr = array('user' => $r[0], 'xml' => $o);
    call_hooks('personal_xrd', $arr);
    echo $arr['xml'];
    killme();
}
コード例 #4
0
ファイル: channel.php プロジェクト: phellmes/hubzilla
/**
 * @brief Formats a profile for display in the sidebar.
 *
 * It is very difficult to templatise the HTML completely
 * because of all the conditional logic.
 *
 * @param array $profile
 * @param int $block
 * @param boolean $show_connect
 *
 * @return HTML string suitable for sidebar inclusion
 * Exceptions: Returns empty string if passed $profile is wrong type or not populated
 */
function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = false)
{
    $observer = App::get_observer();
    $o = '';
    $location = false;
    $pdesc = true;
    $reddress = true;
    if (!perm_is_allowed($profile['uid'], is_array($observer) ? $observer['xchan_hash'] : '', 'view_profile')) {
        $block = true;
    }
    if (!is_array($profile) && !count($profile)) {
        return $o;
    }
    head_set_icon($profile['thumb']);
    if (is_sys_channel($profile['uid'])) {
        $show_connect = false;
    }
    $profile['picdate'] = urlencode($profile['picdate']);
    call_hooks('profile_sidebar_enter', $profile);
    if ($show_connect) {
        // This will return an empty string if we're already connected.
        $connect_url = rconnect_url($profile['uid'], get_observer_hash());
        $connect = $connect_url ? t('Connect') : '';
        if ($connect_url) {
            $connect_url = sprintf($connect_url, urlencode(channel_reddress($profile)));
        }
        // premium channel - over-ride
        if ($profile['channel_pageflags'] & PAGE_PREMIUM) {
            $connect_url = z_root() . '/connect/' . $profile['channel_address'];
        }
    }
    if (x($profile, 'address') == 1 || x($profile, 'locality') == 1 || x($profile, 'region') == 1 || x($profile, 'postal_code') == 1 || x($profile, 'country_name') == 1) {
        $location = t('Location:');
    }
    $profile['homepage'] = linkify($profile['homepage'], true);
    $gender = x($profile, 'gender') == 1 ? t('Gender:') : False;
    $marital = x($profile, 'marital') == 1 ? t('Status:') : False;
    $homepage = x($profile, 'homepage') == 1 ? t('Homepage:') : False;
    $profile['online'] = $profile['online_status'] === 'online' ? t('Online Now') : False;
    //	logger('online: ' . $profile['online']);
    if ($profile['hidewall'] && !local_channel() && !remote_channel() || $block) {
        $location = $reddress = $pdesc = $gender = $marital = $homepage = False;
    }
    $firstname = strpos($profile['channel_name'], ' ') ? trim(substr($profile['channel_name'], 0, strpos($profile['channel_name'], ' '))) : $profile['channel_name'];
    $lastname = $firstname === $profile['channel_name'] ? '' : trim(substr($profile['channel_name'], strlen($firstname)));
    $diaspora = array('podloc' => z_root(), 'guid' => $profile['channel_guid'] . str_replace('.', '', App::get_hostname()), 'pubkey' => pemtorsa($profile['channel_pubkey']), 'searchable' => $block ? 'false' : 'true', 'nickname' => $profile['channel_address'], 'fullname' => $profile['channel_name'], 'firstname' => $firstname, 'lastname' => $lastname, 'photo300' => z_root() . '/photo/profile/300/' . $profile['uid'] . '.jpg', 'photo100' => z_root() . '/photo/profile/100/' . $profile['uid'] . '.jpg', 'photo50' => z_root() . '/photo/profile/50/' . $profile['uid'] . '.jpg');
    $contact_block = contact_block();
    $channel_menu = false;
    $menu = get_pconfig($profile['uid'], 'system', 'channel_menu');
    if ($menu && !$block) {
        require_once 'include/menu.php';
        $m = menu_fetch($menu, $profile['uid'], $observer['xchan_hash']);
        if ($m) {
            $channel_menu = menu_render($m);
        }
    }
    $menublock = get_pconfig($profile['uid'], 'system', 'channel_menublock');
    if ($menublock && !$block) {
        $comanche = new Zotlabs\Render\Comanche();
        $channel_menu .= $comanche->block($menublock);
    }
    if ($zcard) {
        $tpl = get_markup_template('profile_vcard_short.tpl');
    } else {
        $tpl = get_markup_template('profile_vcard.tpl');
    }
    require_once 'include/widgets.php';
    //	if(! feature_enabled($profile['uid'],'hide_rating'))
    $z = widget_rating(array('target' => $profile['channel_hash']));
    $o .= replace_macros($tpl, array('$zcard' => $zcard, '$profile' => $profile, '$connect' => $connect, '$connect_url' => $connect_url, '$location' => $location, '$gender' => $gender, '$pdesc' => $pdesc, '$marital' => $marital, '$homepage' => $homepage, '$chanmenu' => $channel_menu, '$diaspora' => $diaspora, '$reddress' => $reddress, '$rating' => $z, '$contact_block' => $contact_block, '$editmenu' => profile_edit_menu($profile['uid'])));
    $arr = array('profile' => &$profile, 'entry' => &$o);
    call_hooks('profile_sidebar', $arr);
    return $o;
}