本文整理汇总了PHP中local_user函数的典型用法代码示例。如果您正苦于以下问题:PHP local_user函数的具体用法?PHP local_user怎么用?PHP local_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了local_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: viewsrc_content
function viewsrc_content(&$a)
{
$o = '';
$item_id = argc() > 1 ? intval(argv(1)) : 0;
$json = argc() > 2 && argv(2) === 'json' ? true : false;
if (!local_user()) {
notice(t('Permission denied.') . EOL);
}
if (!$item_id) {
$a->error = 404;
notice(t('Item not found.') . EOL);
}
if (local_user() && $item_id) {
$r = q("select item_flags, body from item where item_restrict = 0 and uid = %d and id = %d limit 1", intval(local_user()), intval($item_id));
if ($r) {
if ($r[0]['item_flags'] & ITEM_OBSCURED) {
$r[0]['body'] = crypto_unencapsulate(json_decode($r[0]['body'], true), get_config('system', 'prvkey'));
}
$o = $json ? json_encode($r[0]['body']) : str_replace("\n", '<br />', $r[0]['body']);
}
}
if (is_ajax()) {
echo $o;
killme();
}
return $o;
}
示例2: blackout_redirect
function blackout_redirect($a, $b)
{
// if we have a logged in user, don't throw her out
if (local_user()) {
return true;
}
if (!(version_compare(PHP_VERSION, '5.3.0') >= 0)) {
return true;
}
// else...
$mystart = get_config('blackout', 'begindate');
$myend = get_config('blackout', 'enddate');
$myurl = get_config('blackout', 'url');
$now = time();
$date1 = DateTime::createFromFormat('Y-m-d G:i', $mystart);
$date2 = DateTime::createFromFormat('Y-m-d G:i', $myend);
if ($date1 && $date2) {
$date1 = DateTime::createFromFormat('Y-m-d G:i', $mystart)->format('U');
$date2 = DateTime::createFromFormat('Y-m-d G:i', $myend)->format('U');
} else {
$date1 = 0;
$date2 = 0;
}
if ($date1 <= $now && $now <= $date2) {
logger('redirecting user to blackout page');
goaway($myurl);
}
}
示例3: repair_ostatus_content
function repair_ostatus_content(&$a)
{
if (!local_user()) {
notice(t('Permission denied.') . EOL);
goaway($_SESSION['return_url']);
// NOTREACHED
}
$o = "<h2>" . t("Resubsribing to OStatus contacts") . "</h2>";
$uid = local_user();
$a = get_app();
$counter = intval($_REQUEST['counter']);
$r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE\n `uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)", intval($uid), dbesc(NETWORK_OSTATUS), intval(CONTACT_IS_FRIEND), intval(CONTACT_IS_SHARING));
if (!$r) {
return $o . t("Error");
}
$total = $r[0]["total"];
$r = q("SELECT `url` FROM `contact` WHERE\n `uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)\n\t\tORDER BY `url`\n\t\tLIMIT %d, 1", intval($uid), dbesc(NETWORK_OSTATUS), intval(CONTACT_IS_FRIEND), intval(CONTACT_IS_SHARING), $counter++);
if (!$r) {
$o .= t("Done");
return $o;
}
$o .= "<p>" . $counter . "/" . $total . ": " . $r[0]["url"] . "</p>";
$o .= "<p>" . t("Keep this window open until done.") . "</p>";
$result = new_contact($uid, $r[0]["url"], true);
$a->page['htmlhead'] = '<meta http-equiv="refresh" content="1; URL=' . $a->get_baseurl() . '/repair_ostatus?counter=' . $counter . '">';
return $o;
}
示例4: tagrm_content
function tagrm_content(&$a)
{
$o = '';
if (!local_user()) {
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
// NOTREACHED
}
$item = $a->argc > 1 ? intval($a->argv[1]) : 0;
if (!$item) {
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
// NOTREACHED
}
$r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($item), intval(local_user()));
if (!count($r)) {
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
}
$arr = explode(',', $r[0]['tag']);
if (!count($arr)) {
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
}
$o .= '<h3>' . t('Remove Item Tag') . '</h3>';
$o .= '<p id="tag-remove-desc">' . t('Select a tag to remove: ') . '</p>';
$o .= '<form id="tagrm" action="tagrm" method="post" >';
$o .= '<input type="hidden" name="item" value="' . $item . '" />';
$o .= '<ul>';
foreach ($arr as $x) {
$o .= '<li><input type="checkbox" name="tag" value="' . bin2hex($x) . '" >' . bbcode($x) . '</input></li>';
}
$o .= '</ul>';
$o .= '<input id="tagrm-submit" type="submit" name="submit" value="' . t('Remove') . '" />';
$o .= '<input id="tagrm-cancel" type="submit" name="submit" value="' . t('Cancel') . '" />';
$o .= '</form>';
return $o;
}
示例5: snautofollow_settings
function snautofollow_settings(&$a, &$s)
{
if (!local_user()) {
return;
}
/* Add our stylesheet to the page so we can make our settings look nice */
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/snautofollow/snautofollow.css' . '" media="all" />' . "\r\n";
/* Get the current state of our config variable */
$snautofollow = get_pconfig(local_user(), 'system', 'ostatus_autofriend');
if ($snautofollow === false) {
$snautofollow = false;
}
$snautofollow_checked = $snautofollow ? ' checked="checked" ' : '';
/* Add some HTML to the existing form */
$s .= '<span id="settings_snautofollow_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_snautofollow_expanded\'); openClose(\'settings_snautofollow_inflated\');">';
$s .= '<h3>' . t('StatusNet AutoFollow') . '</h3>';
$s .= '</span>';
$s .= '<div id="settings_snautofollow_expanded" class="settings-block" style="display: none;">';
$s .= '<span class="fakelink" onclick="openClose(\'settings_snautofollow_expanded\'); openClose(\'settings_snautofollow_inflated\');">';
$s .= '<h3>' . t('StatusNet AutoFollow') . '</h3>';
$s .= '</span>';
$s .= '<div id="snautofollow-wrapper">';
$s .= '<label id="snautofollow-label" for="snautofollow-checkbox">' . t('Automatically follow any StatusNet followers/mentioners') . '</label>';
$s .= '<input id="snautofollow-checkbox" type="checkbox" name="snautofollow" value="1" ' . $snautofollow_checked . '/>';
$s .= '</div><div class="clear"></div>';
/* provide a submit button */
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="snautofollow-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
}
示例6: regmod_content
function regmod_content(&$a)
{
global $lang;
$_SESSION['return_url'] = $a->cmd;
if (!local_user()) {
info(t('Please login.') . EOL);
$o .= '<br /><br />' . login($a->config['register_policy'] == REGISTER_CLOSED ? 0 : 1);
return $o;
}
if (!is_site_admin() || x($_SESSION, 'submanage') && intval($_SESSION['submanage'])) {
notice(t('Permission denied.') . EOL);
return '';
}
if ($a->argc != 3) {
killme();
}
$cmd = $a->argv[1];
$hash = $a->argv[2];
if ($cmd === 'deny') {
user_deny($hash);
goaway($a->get_baseurl() . "/admin/users/");
killme();
}
if ($cmd === 'allow') {
user_allow($hash);
goaway($a->get_baseurl() . "/admin/users/");
killme();
}
}
示例7: startpage_settings
/**
*
* Called from the Plugin Setting form.
* Add our own settings info to the page.
*
*/
function startpage_settings(&$a, &$s)
{
if (!local_user()) {
return;
}
/* Add our stylesheet to the page so we can make our settings look nice */
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/startpage/startpage.css' . '" media="all" />' . "\r\n";
/* Get the current state of our config variable */
$page = get_pconfig(local_user(), 'startpage', 'startpage');
/* Add some HTML to the existing form */
$s .= '<span id="settings_startpage_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_startpage_expanded\'); openClose(\'settings_startpage_inflated\');">';
$s .= '<h3>' . t('Startpage') . '</h3>';
$s .= '</span>';
$s .= '<div id="settings_startpage_expanded" class="settings-block" style="display: none;">';
$s .= '<span class="fakelink" onclick="openClose(\'settings_startpage_expanded\'); openClose(\'settings_startpage_inflated\');">';
$s .= '<h3>' . t('Startpage') . '</h3>';
$s .= '</span>';
$s .= '<div id="startpage-page-wrapper">';
$s .= '<label id="startpage-page-label" for="startpage-page">' . t('Home page to load after login - leave blank for profile wall') . '</label>';
$s .= '<input id="startpage-page" type="text" name="startpage" value="' . $page . '" />';
$s .= '</div><div class="clear"></div>';
$s .= '<div id="startpage-desc">' . t('Examples: "network" or "notifications/system"') . '</div>';
/* provide a submit button */
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="startpage-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
}
示例8: regmod_content
function regmod_content(&$a)
{
global $lang;
$_SESSION['return_url'] = $a->cmd;
if (!local_user()) {
info(t('Please login.') . EOL);
$o .= '<br /><br />' . login($a->config['register_policy'] == REGISTER_CLOSED ? 0 : 1);
return $o;
}
if (!is_site_admin()) {
notice(t('Permission denied.') . EOL);
return '';
}
if ($a->argc != 3) {
killme();
}
$cmd = $a->argv[1];
$hash = $a->argv[2];
if ($cmd === 'deny') {
if (!user_deny($hash)) {
killme();
}
}
if ($cmd === 'allow') {
if (!user_allow($hash)) {
killme();
}
}
}
示例9: altpager_settings
/**
*
* Called from the Plugin Setting form.
* Add our own settings info to the page.
*
*/
function altpager_settings(&$a, &$s)
{
if (!local_user()) {
return;
}
$global = get_config("alt_pager", "global");
if ($global == 1) {
return;
}
/* Add our stylesheet to the page so we can make our settings look nice */
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/altpager/altpager.css' . '" media="all" />' . "\r\n";
/* Get the current state of our config variable */
$altpager = get_pconfig(local_user(), 'system', 'alt_pager');
if ($altpager === false) {
$altpager = 0;
}
$checked = $altpager ? ' checked="checked" ' : '';
/* Add some HTML to the existing form */
$s .= '<div class="settings-block">';
$s .= '<h3>' . t('Alternate Pagination Setting') . '</h3>';
$s .= '<div id="altpager-wrapper">';
$s .= '<label id="altpager-label" for="altpager">' . t('Use links to "newer" and "older" pages in place of page numbers?') . '</label>';
$s .= '<input id="altpager-input" type="checkbox" name="altpager" value="1" ' . $checked . '/>';
$s .= '</div><div class="clear"></div>';
/* provide a submit button */
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="altpager-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
}
示例10: theme_post
function theme_post(&$a)
{
if (!local_user()) {
return;
}
if (isset($_POST['diabook-settings-submit'])) {
set_pconfig(local_user(), 'diabook', 'font_size', $_POST['diabook_font_size']);
set_pconfig(local_user(), 'diabook', 'line_height', $_POST['diabook_line_height']);
set_pconfig(local_user(), 'diabook', 'resolution', $_POST['diabook_resolution']);
set_pconfig(local_user(), 'diabook', 'color', $_POST['diabook_color']);
set_pconfig(local_user(), 'diabook', 'TSearchTerm', $_POST['diabook_TSearchTerm']);
set_pconfig(local_user(), 'diabook', 'ELZoom', $_POST['diabook_ELZoom']);
set_pconfig(local_user(), 'diabook', 'ELPosX', $_POST['diabook_ELPosX']);
set_pconfig(local_user(), 'diabook', 'ELPosY', $_POST['diabook_ELPosY']);
set_pconfig(local_user(), 'diabook', 'ELPosY', $_POST['diabook_ELPosY']);
set_pconfig(local_user(), 'diabook', 'close_pages', $_POST['diabook_close_pages']);
set_pconfig(local_user(), 'diabook', 'close_mapquery', $_POST['diabook_close_mapquery']);
set_pconfig(local_user(), 'diabook', 'close_profiles', $_POST['diabook_close_profiles']);
set_pconfig(local_user(), 'diabook', 'close_helpers', $_POST['diabook_close_helpers']);
set_pconfig(local_user(), 'diabook', 'close_services', $_POST['diabook_close_services']);
set_pconfig(local_user(), 'diabook', 'close_friends', $_POST['diabook_close_friends']);
set_pconfig(local_user(), 'diabook', 'close_twitter', $_POST['diabook_close_twitter']);
set_pconfig(local_user(), 'diabook', 'close_lastusers', $_POST['diabook_close_lastusers']);
set_pconfig(local_user(), 'diabook', 'close_lastphotos', $_POST['diabook_close_lastphotos']);
set_pconfig(local_user(), 'diabook', 'close_lastlikes', $_POST['diabook_close_lastlikes']);
}
}
示例11: share_init
function share_init(&$a)
{
$post_id = $a->argc > 1 ? intval($a->argv[1]) : 0;
if (!$post_id || !local_user()) {
killme();
}
$r = q("SELECT item.*, contact.network FROM `item` \n\t\tleft join contact on `item`.`contact-id` = `contact`.`id` \n\t\tWHERE `item`.`id` = %d AND `item`.`uid` = %d LIMIT 1", intval($post_id), intval(local_user()));
if (!count($r) || $r[0]['private'] == 1) {
killme();
}
if (intval(get_config('system', 'new_share'))) {
if (strpos($r[0]['body'], "[/share]") !== false) {
$pos = strpos($r[0]['body'], "[share");
$o = substr($r[0]['body'], $pos);
} else {
$o = "[share author='" . str_replace("'", "'", $r[0]['author-name']) . "' profile='" . $r[0]['author-link'] . "' avatar='" . $r[0]['author-avatar'] . "' link='" . $r[0]['plink'] . "' posted='" . $r[0]['created'] . "']\n";
if ($r[0]['title']) {
$o .= '[b]' . $r[0]['title'] . '[/b]' . "\n";
}
$o .= $r[0]['body'];
$o .= "[/share]";
}
} else {
$o = '';
$o .= "♲" . ' [url=' . $r[0]['author-link'] . ']' . $r[0]['author-name'] . '[/url]' . "\n";
if ($r[0]['title']) {
$o .= '[b]' . $r[0]['title'] . '[/b]' . "\n";
}
$o .= $r[0]['body'] . "\n";
$o .= $r[0]['plink'] ? '[url=' . $r[0]['plink'] . ']' . t('link') . '[/url]' . "\n" : '';
}
echo $o;
killme();
}
示例12: redir_init
function redir_init(&$a)
{
if (!local_user() || !($a->argc == 2) || !intval($a->argv[1])) {
goaway(z_root());
}
$cid = $a->argv[1];
$url = x($_GET, 'url') ? $_GET['url'] : '';
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval(local_user()));
if (!count($r) || $r[0]['network'] !== 'dfrn') {
goaway(z_root());
}
$dfrn_id = $orig_id = $r[0]['issued-id'] ? $r[0]['issued-id'] : $r[0]['dfrn-id'];
if ($r[0]['duplex'] && $r[0]['issued-id']) {
$orig_id = $r[0]['issued-id'];
$dfrn_id = '1:' . $orig_id;
}
if ($r[0]['duplex'] && $r[0]['dfrn-id']) {
$orig_id = $r[0]['dfrn-id'];
$dfrn_id = '0:' . $orig_id;
}
$sec = random_string();
q("INSERT INTO `profile_check` ( `uid`, `cid`, `dfrn_id`, `sec`, `expire`)\n\t\tVALUES( %d, %s, '%s', '%s', %d )", intval(local_user()), intval($cid), dbesc($dfrn_id), dbesc($sec), intval(time() + 45));
logger('mod_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG);
$dest = $url ? '&destination_url=' . $url : '';
goaway($r[0]['poll'] . '?dfrn_id=' . $dfrn_id . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest);
}
示例13: invite_content
function invite_content(&$a)
{
if (!local_user()) {
notice(t('Permission denied.') . EOL);
return;
}
$tpl = get_markup_template('invite.tpl');
$invonly = false;
if (get_config('system', 'invitation_only')) {
$invonly = true;
$x = get_pconfig(local_user(), 'system', 'invites_remaining');
if (!$x && !is_site_admin()) {
notice(t('You have no more invitations available') . EOL);
return '';
}
}
$dirloc = get_config('system', 'directory_submit_url');
if (strlen($dirloc)) {
if ($a->config['register_policy'] == REGISTER_CLOSED) {
$linktxt = sprintf(t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.'), dirname($dirloc) . '/siteinfo');
} elseif ($a->config['register_policy'] != REGISTER_CLOSED) {
$linktxt = sprintf(t('To accept this invitation, please visit and register at %s or any other public Friendica website.'), $a->get_baseurl()) . "\r\n" . "\r\n" . sprintf(t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.'), dirname($dirloc) . '/siteinfo');
}
} else {
$o = t('Our apologies. This system is not currently configured to connect with other public sites or invite members.');
return $o;
}
$o = replace_macros($tpl, array('$invite' => t('Send invitations'), '$addr_text' => t('Enter email addresses, one per line:'), '$msg_text' => t('Your message:'), '$default_message' => t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n" . $linktxt . "\r\n" . "\r\n" . ($invonly ? t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') . t('Once you have registered, please connect with me via my profile page at:') . "\r\n" . "\r\n" . $a->get_baseurl() . '/profile/' . $a->user['nickname'] . "\r\n" . "\r\n" . t('For more information about the Friendica project and why we feel it is important, please visit http://friendica.com') . "\r\n" . "\r\n", '$submit' => t('Submit')));
return $o;
}
示例14: hcard_init
function hcard_init(&$a)
{
if (argc() > 1) {
$which = argv(1);
} else {
notice(t('Requested profile is not available.') . EOL);
$a->error = 404;
return;
}
$profile = '';
$channel = $a->get_channel();
if (local_user() && argc() > 2 && argv(2) === 'view') {
$which = $channel['channel_address'];
$profile = argv(1);
$r = q("select profile_guid from profile where id = %d and uid = %d limit 1", intval($profile), intval(local_user()));
if (!$r) {
$profile = '';
}
$profile = $r[0]['profile_guid'];
}
$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/feed/' . $which . '" />' . "\r\n";
if (!$profile) {
$x = q("select channel_id as profile_uid from channel where channel_address = '%s' limit 1", dbesc(argv(1)));
if ($x) {
$a->profile = $x[0];
}
}
profile_load($a, $which, $profile);
}
示例15: fsuggest_content
function fsuggest_content(&$a)
{
require_once 'include/acl_selectors.php';
if (!local_user()) {
notice(t('Permission denied.') . EOL);
return;
}
if ($a->argc != 2) {
return;
}
$contact_id = intval($a->argv[1]);
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), intval(local_user()));
if (!count($r)) {
notice(t('Contact not found.') . EOL);
return;
}
$contact = $r[0];
$o = '<h3>' . t('Suggest Friends') . '</h3>';
$o .= '<div id="fsuggest-desc" >' . sprintf(t('Suggest a friend for %s'), $contact['name']) . '</div>';
$o .= '<form id="fsuggest-form" action="fsuggest/' . $contact_id . '" method="post" >';
$o .= contact_selector('suggest', 'suggest-select', false, array('size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true));
$o .= '<div id="fsuggest-submit-wrapper"><input id="fsuggest-submit" type="submit" name="submit" value="' . t('Submit') . '" /></div>';
$o .= '</form>';
return $o;
}