Пример #1
0
 function init()
 {
     $ret = array('result' => false);
     if (argc() != 2) {
         json_return_and_die($ret);
     }
     $ret = get_online_status(argv(1));
     json_return_and_die($ret);
 }
Пример #2
0
/**
 * @brief Loads a profile into the App structure.
 *
 * The function requires a writeable copy of the main App structure, and the
 * nickname of a valid channel.
 *
 * Permissions of the current observer are checked. If a restricted profile is available
 * to the current observer, that will be loaded instead of the channel default profile.
 * 
 * The channel owner can set $profile to a valid profile_guid to preview that profile.
 *
 * The channel default theme is also selected for use, unless over-riden elsewhere.
 *
 * @param[in,out] App &$a
 * @param string $nickname
 * @param string $profile
 */
function profile_load(&$a, $nickname, $profile = '')
{
    //	logger('profile_load: ' . $nickname . (($profile) ? ' profile: ' . $profile : ''));
    $user = q("select channel_id from channel where channel_address = '%s' and channel_removed = 0  limit 1", dbesc($nickname));
    if (!$user) {
        logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
        notice(t('Requested channel is not available.') . EOL);
        $a->error = 404;
        return;
    }
    // get the current observer
    $observer = $a->get_observer();
    $can_view_profile = true;
    // Can the observer see our profile?
    require_once 'include/permissions.php';
    if (!perm_is_allowed($user[0]['channel_id'], $observer['xchan_hash'], 'view_profile')) {
        $can_view_profile = false;
    }
    if (!$profile) {
        $r = q("SELECT abook_profile FROM abook WHERE abook_xchan = '%s' and abook_channel = '%d' limit 1", dbesc($observer['xchan_hash']), intval($user[0]['channel_id']));
        if ($r) {
            $profile = $r[0]['abook_profile'];
        }
    }
    $p = null;
    if ($profile) {
        $p = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile\n\t\t\t\tLEFT JOIN channel ON profile.uid = channel.channel_id\n\t\t\t\tWHERE channel.channel_address = '%s' AND profile.profile_guid = '%s' LIMIT 1", dbesc($nickname), dbesc($profile));
    }
    if (!$p) {
        $p = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile\n\t\t\tLEFT JOIN channel ON profile.uid = channel.channel_id\n\t\t\tWHERE channel.channel_address = '%s' and channel_removed = 0\n\t\t\tAND profile.is_default = 1 LIMIT 1", dbesc($nickname));
    }
    if (!$p) {
        logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
        notice(t('Requested profile is not available.') . EOL);
        $a->error = 404;
        return;
    }
    $q = q("select * from profext where hash = '%s' and channel_id = %d", dbesc($p[0]['profile_guid']), intval($p[0]['profile_uid']));
    if ($q) {
        $extra_fields = array();
        require_once 'include/identity.php';
        $profile_fields_basic = get_profile_fields_basic();
        $profile_fields_advanced = get_profile_fields_advanced();
        $advanced = feature_enabled(local_channel(), 'advanced_profiles') ? true : false;
        if ($advanced) {
            $fields = $profile_fields_advanced;
        } else {
            $fields = $profile_fields_basic;
        }
        foreach ($q as $qq) {
            foreach ($fields as $k => $f) {
                if ($k == $qq['k']) {
                    $p[0][$k] = $qq['v'];
                    $extra_fields[] = $k;
                    break;
                }
            }
        }
    }
    $p[0]['extra_fields'] = $extra_fields;
    $z = q("select xchan_photo_date, xchan_addr from xchan where xchan_hash = '%s' limit 1", dbesc($p[0]['channel_hash']));
    if ($z) {
        $p[0]['picdate'] = $z[0]['xchan_photo_date'];
        $p[0]['reddress'] = str_replace('@', '@', $z[0]['xchan_addr']);
    }
    // fetch user tags if this isn't the default profile
    if (!$p[0]['is_default']) {
        /** @BUG $profile_uid is undefinded for this query, so should not work. */
        $x = q("select `keywords` from `profile` where uid = %d and `is_default` = 1 limit 1", intval($profile_uid));
        if ($x && $can_view_profile) {
            $p[0]['keywords'] = $x[0]['keywords'];
        }
    }
    if ($p[0]['keywords']) {
        $keywords = str_replace(array('#', ',', ' ', ',,'), array('', ' ', ',', ','), $p[0]['keywords']);
        if (strlen($keywords) && $can_view_profile) {
            $a->page['htmlhead'] .= '<meta name="keywords" content="' . htmlentities($keywords, ENT_COMPAT, 'UTF-8') . '" />' . "\r\n";
        }
    }
    $a->profile = $p[0];
    $a->profile_uid = $p[0]['profile_uid'];
    $a->page['title'] = $a->profile['channel_name'] . " - " . $a->profile['channel_address'] . "@" . $a->get_hostname();
    $a->profile['permission_to_view'] = $can_view_profile;
    if ($can_view_profile) {
        $online = get_online_status($nickname);
        $a->profile['online_status'] = $online['result'];
    }
    if (local_channel()) {
        $a->profile['channel_mobile_theme'] = get_pconfig(local_channel(), 'system', 'mobile_theme');
        $_SESSION['mobile_theme'] = $a->profile['channel_mobile_theme'];
    }
    /*
     * load/reload current theme info
     */
    $_SESSION['theme'] = $p[0]['channel_theme'];
    //	$a->set_template_engine(); // reset the template engine to the default in case the user's theme doesn't specify one
    //	$theme_info_file = "view/theme/".current_theme()."/php/theme.php";
    //	if (file_exists($theme_info_file)){
    //		require_once($theme_info_file);
    //	}
}
Пример #3
0
                            $result = $db->GetRow($query);
                            if ($result) {
                                ?>
								<br />
								<h2>Original Post: <small><?php 
                                echo html_encode($result["topic_title"]);
                                ?>
</small></h2>
								<table class="discussions posts" style="width: 100%" cellspacing="0" cellpadding="0" border="0">
								<colgroup>
									<col style="width: 30%" />
									<col style="width: 70%" />
								</colgroup>
								<tr>
									<td style="border-bottom: none; border-right: none"><?php 
                                echo get_online_status($result["proxy_id"], "image");
                                ?>
 <a href="<?php 
                                echo ENTRADA_URL . "/people?profile=" . html_encode($result["poster_username"]);
                                ?>
" style="font-weight: bold; text-decoration: underline"><?php 
                                echo html_encode($result["poster_fullname"]);
                                ?>
</a></td>
									<td style="border-bottom: none">
										<div style="float: left">
											<span class="content-small"><strong>Posted:</strong> <?php 
                                echo date(DEFAULT_DATE_FORMAT, $result["updated_date"]);
                                ?>
</span>
										</div>