本文整理汇总了PHP中feature_enabled函数的典型用法代码示例。如果您正苦于以下问题:PHP feature_enabled函数的具体用法?PHP feature_enabled怎么用?PHP feature_enabled使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了feature_enabled函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forumlist_profile_advanced
/**
* @brief Format forumlist as contact block
*
* This function is used to show the forumlist in
* the advanced profile.
*
* @param int $uid
* @return string
*
*/
function forumlist_profile_advanced($uid)
{
$profile = intval(feature_enabled($uid, 'forumlist_profile'));
if (!$profile) {
return;
}
$o = '';
// place holder in case somebody wants configurability
$show_total = 9999;
//don't sort by last updated item
$lastitem = false;
$contacts = get_forumlist($uid, false, $lastitem, false);
$total_shown = 0;
foreach ($contacts as $contact) {
$forumlist .= micropro($contact, false, 'forumlist-profile-advanced');
$total_shown++;
if ($total_shown == $show_total) {
break;
}
}
if (count($contacts) > 0) {
$o .= $forumlist;
}
return $o;
}
示例2: get
function get()
{
if (!local_channel()) {
notice(t('Permission denied.') . EOL);
return '';
}
if (!feature_enabled(local_channel(), 'channel_sources')) {
return '';
}
// list sources
if (argc() == 1) {
$r = q("select source.*, xchan.* from source left join xchan on src_xchan = xchan_hash where src_channel_id = %d", intval(local_channel()));
if ($r) {
for ($x = 0; $x < count($r); $x++) {
if ($r[$x]['src_xchan'] == '*') {
$r[$x]['xchan_name'] = t('*');
}
$r[$x]['src_patt'] = htmlspecialchars($r[$x]['src_patt'], ENT_COMPAT, 'UTF-8');
}
}
$o = replace_macros(get_markup_template('sources_list.tpl'), array('$title' => t('Channel Sources'), '$desc' => t('Manage remote sources of content for your channel.'), '$new' => t('New Source'), '$sources' => $r));
return $o;
}
if (argc() == 2 && argv(1) === 'new') {
// TODO add the words 'or RSS feed' and corresponding code to manage feeds and frequency
$o = replace_macros(get_markup_template('sources_new.tpl'), array('$title' => t('New Source'), '$desc' => t('Import all or selected content from the following channel into this channel and distribute it according to your channel settings.'), '$words' => array('words', t('Only import content with these words (one per line)'), '', t('Leave blank to import all public content')), '$name' => array('name', t('Channel Name'), '', ''), '$tags' => array('tags', t('Add the following categories to posts imported from this source (comma separated)'), '', t('Optional')), '$submit' => t('Submit')));
return $o;
}
if (argc() == 2 && intval(argv(1))) {
// edit source
$r = q("select source.*, xchan.* from source left join xchan on src_xchan = xchan_hash where src_id = %d and src_channel_id = %d limit 1", intval(argv(1)), intval(local_channel()));
if ($r) {
$x = q("select abook_id from abook where abook_xchan = '%s' and abook_channel = %d limit 1", dbesc($r[0]['src_xchan']), intval(local_channel()));
}
if (!$r) {
notice(t('Source not found.') . EOL);
return '';
}
$r[0]['src_patt'] = htmlspecialchars($r[0]['src_patt'], ENT_QUOTES, 'UTF-8');
$o = replace_macros(get_markup_template('sources_edit.tpl'), array('$title' => t('Edit Source'), '$drop' => t('Delete Source'), '$id' => $r[0]['src_id'], '$desc' => t('Import all or selected content from the following channel into this channel and distribute it according to your channel settings.'), '$words' => array('words', t('Only import content with these words (one per line)'), $r[0]['src_patt'], t('Leave blank to import all public content')), '$xchan' => $r[0]['src_xchan'], '$abook' => $x[0]['abook_id'], '$tags' => array('tags', t('Add the following categories to posts imported from this source (comma separated)'), $r[0]['src_tag'], t('Optional')), '$name' => array('name', t('Channel Name'), $r[0]['xchan_name'], ''), '$submit' => t('Submit')));
return $o;
}
if (argc() == 3 && intval(argv(1)) && argv(2) === 'drop') {
$r = q("select * from source where src_id = %d and src_channel_id = %d limit 1", intval(argv(1)), intval(local_channel()));
if (!$r) {
notice(t('Source not found.') . EOL);
return '';
}
$r = q("delete from source where src_id = %d and src_channel_id = %d", intval(argv(1)), intval(local_channel()));
if ($r) {
info(t('Source removed') . EOL);
} else {
notice(t('Unable to remove source.') . EOL);
}
goaway(z_root() . '/sources');
}
// shouldn't get here.
}
示例3: editlayout_content
function editlayout_content(&$a)
{
// We first need to figure out who owns the webpage, grab it from an argument
$which = argv(1);
// $a->get_channel() and stuff don't work here, so we've got to find the owner for ourselves.
$r = q("select channel_id from channel where channel_address = '%s'", dbesc($which));
if ($r) {
$owner = intval($r[0]['channel_id']);
//logger('owner: ' . print_r($owner,true));
}
if (local_user() && argc() > 2 && argv(2) === 'view') {
$which = $channel['channel_address'];
}
$o = '';
// Figure out which post we're editing
$post_id = argc() > 2 ? intval(argv(2)) : 0;
if (!$post_id) {
notice(t('Item not found') . EOL);
return;
}
// Now we've got a post and an owner, let's find out if we're allowed to edit it
$observer = $a->get_observer();
$ob_hash = $observer ? $observer['xchan_hash'] : '';
$perms = get_all_perms($owner, $ob_hash);
if (!$perms['write_pages']) {
notice(t('Permission denied.') . EOL);
return;
}
// We've already figured out which item we want and whose copy we need, so we don't need anything fancy here
$itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s LIMIT 1", intval($post_id), intval($owner));
$item_id = q("select * from item_id where service = 'PDL' and iid = %d limit 1", $itm[0]['id']);
if ($item_id) {
$layout_title = $item_id[0]['sid'];
}
$plaintext = true;
// You may or may not be a local user. This won't work,
// if(feature_enabled(local_user(),'richtext'))
// $plaintext = false;
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array('$title' => t('Edit Layout')));
$a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array('$baseurl' => $a->get_baseurl(), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$ispublic' => ' ', '$geotag' => $geotag, '$nickname' => $a->user['nickname'], '$confirmdelete' => t('Delete layout?')));
$tpl = get_markup_template("jot.tpl");
$jotplugins = '';
$jotnets = '';
call_hooks('jot_tool', $jotplugins);
call_hooks('jot_networks', $jotnets);
$channel = $a->get_channel();
//$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
//FIXME A return path with $_SESSION doesn't always work for observer - it may WSoD instead of loading a sensible page. So, send folk to the webpage list.
$rp = '/layouts/' . $which;
$o .= replace_macros($tpl, array('$return_path' => $rp, '$action' => 'item', '$webpage' => ITEM_PDL, '$share' => t('Edit'), '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$weblink' => t('Insert web link'), '$youtube' => t('Insert YouTube video'), '$video' => t('Insert Vorbis [.ogg] video'), '$audio' => t('Insert Vorbis [.ogg] audio'), '$setloc' => t('Set your location'), '$noloc' => t('Clear browser location'), '$wait' => t('Please wait'), '$permset' => t('Permission settings'), '$ptyp' => $itm[0]['type'], '$content' => undo_post_tagging($itm[0]['body']), '$post_id' => $post_id, '$baseurl' => $a->get_baseurl(), '$defloc' => $channel['channel_location'], '$visitor' => false, '$public' => t('Public post'), '$jotnets' => $jotnets, '$title' => htmlspecialchars($itm[0]['title'], ENT_COMPAT, 'UTF-8'), '$placeholdertitle' => t('Set title'), '$pagetitle' => $layout_title, '$category' => '', '$placeholdercategory' => t('Categories (comma-separated list)'), '$emtitle' => t('Example: bob@example.com, mary@example.com'), '$lockstate' => $lockstate, '$acl' => '', '$bang' => '', '$profile_uid' => intval($owner), '$preview' => feature_enabled(local_user(), 'preview') ? t('Preview') : '', '$jotplugins' => $jotplugins, '$sourceapp' => t($a->sourcename), '$defexpire' => '', '$feature_expire' => false, '$expires' => t('Set expiration date')));
$ob = get_observer_hash();
if ($itm[0]['author_xchan'] === $ob || $itm[0]['owner_xchan'] === $ob) {
$o .= '<br /><br /><a class="layout-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Layout') . '</a><br />';
}
return $o;
}
示例4: get
function get()
{
$o = '';
if (!local_channel()) {
notice(t('Permission denied.') . EOL);
return;
}
$post_id = argc() > 1 ? intval(argv(1)) : 0;
if (!$post_id) {
notice(t('Item not found') . EOL);
return;
}
$itm = q("SELECT * FROM `item` WHERE `id` = %d AND ( owner_xchan = '%s' OR author_xchan = '%s' ) LIMIT 1", intval($post_id), dbesc(get_observer_hash()), dbesc(get_observer_hash()));
if (!count($itm)) {
notice(t('Item is not editable') . EOL);
return;
}
if ($itm[0]['resource_type'] === 'event' && $itm[0]['resource_id']) {
goaway(z_root() . '/events/' . $itm[0]['resource_id'] . '?expandform=1');
}
$owner_uid = $itm[0]['uid'];
$channel = \App::get_channel();
if (intval($itm[0]['item_obscured'])) {
$key = get_config('system', 'prvkey');
if ($itm[0]['title']) {
$itm[0]['title'] = crypto_unencapsulate(json_decode_plus($itm[0]['title']), $key);
}
if ($itm[0]['body']) {
$itm[0]['body'] = crypto_unencapsulate(json_decode_plus($itm[0]['body']), $key);
}
}
$category = '';
$catsenabled = feature_enabled($owner_uid, 'categories') ? 'categories' : '';
if ($catsenabled) {
$itm = fetch_post_tags($itm);
$cats = get_terms_oftype($itm[0]['term'], TERM_CATEGORY);
foreach ($cats as $cat) {
if (strlen($category)) {
$category .= ', ';
}
$category .= $cat['term'];
}
}
if ($itm[0]['attach']) {
$j = json_decode($itm[0]['attach'], true);
if ($j) {
foreach ($j as $jj) {
$itm[0]['body'] .= "\n" . '[attachment]' . basename($jj['href']) . ',' . $jj['revision'] . '[/attachment]' . "\n";
}
}
}
$x = array('nickname' => $channel['channel_address'], 'editor_autocomplete' => true, 'bbco_autocomplete' => 'bbcode', 'return_path' => $_SESSION['return_url'], 'button' => t('Edit'), 'hide_voting' => true, 'hide_future' => true, 'hide_location' => true, 'mimetype' => $itm[0]['mimetype'], 'ptyp' => $itm[0]['obj_type'], 'body' => undo_post_tagging($itm[0]['body']), 'post_id' => $post_id, 'defloc' => $channel['channel_location'], 'visitor' => true, 'title' => htmlspecialchars($itm[0]['title'], ENT_COMPAT, 'UTF-8'), 'category' => $category, 'showacl' => false, 'profile_uid' => $owner_uid, 'catsenabled' => $catsenabled, 'hide_expire' => true, 'bbcode' => true);
$editor = status_editor($a, $x);
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array('$title' => t('Edit post'), '$editor' => $editor));
return $o;
}
示例5: get
function get()
{
$arr = array();
$features = get_features();
foreach ($features as $fname => $fdata) {
$arr[$fname] = array();
$arr[$fname][0] = $fdata[0];
foreach (array_slice($fdata, 1) as $f) {
$arr[$fname][1][] = array('feature_' . $f[0], $f[1], intval(feature_enabled(local_channel(), $f[0])) ? "1" : '', $f[2], array(t('Off'), t('On')));
}
}
$tpl = get_markup_template("settings_features.tpl");
$o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_features"), '$title' => t('Additional Features'), '$features' => $arr, '$submit' => t('Submit')));
return $o;
}
示例6: categories_widget
function categories_widget($baseurl, $selected = '')
{
if (!feature_enabled(App::$profile['profile_uid'], 'categories')) {
return '';
}
$item_normal = item_normal();
$terms = array();
$r = q("select distinct(term.term)\n from term join item on term.oid = item.id\n where item.uid = %d\n and term.uid = item.uid\n and term.ttype = %d\n\t\t\t\tand term.otype = %d\n and item.owner_xchan = '%s'\n\t\t\t\tand item.item_wall = 1\n\t\t\t\t{$item_normal}\n order by term.term asc", intval(App::$profile['profile_uid']), intval(TERM_CATEGORY), intval(TERM_OBJ_POST), dbesc(App::$profile['channel_hash']));
if ($r && count($r)) {
foreach ($r as $rr) {
$terms[] = array('name' => $rr['term'], 'selected' => $selected == $rr['term'] ? 'selected' : '');
}
return replace_macros(get_markup_template('categories_widget.tpl'), array('$title' => t('Categories'), '$desc' => '', '$sel_all' => $selected == '' ? 'selected' : '', '$all' => t('Everything'), '$terms' => $terms, '$base' => $baseurl));
}
return '';
}
示例7: search_saved_searches
function search_saved_searches()
{
$o = '';
if (!feature_enabled(local_user(), 'savedsearch')) {
return $o;
}
$r = q("SELECT `id`,`term` FROM `search` WHERE `uid` = %d", intval(local_user()));
if (count($r)) {
$saved = array();
foreach ($r as $rr) {
$saved[] = array('id' => $rr['id'], 'term' => $rr['term'], 'encodedterm' => urlencode($rr['term']), 'delete' => t('Remove term'), 'selected' => $search == $rr['term']);
}
$tpl = get_markup_template("saved_searches_aside.tpl");
$o .= replace_macros($tpl, array('$title' => t('Saved Searches'), '$add' => '', '$searchbox' => '', '$saved' => $saved));
}
return $o;
}
示例8: categories_widget
function categories_widget($baseurl, $selected = '')
{
$a = get_app();
if (!feature_enabled($a->profile['profile_uid'], 'categories')) {
return '';
}
$saved = get_pconfig($a->profile['profile_uid'], 'system', 'filetags');
if (!strlen($saved)) {
return;
}
$matches = false;
$terms = array();
$cnt = preg_match_all('/<(.*?)>/', $saved, $matches, PREG_SET_ORDER);
if ($cnt) {
foreach ($matches as $mtch) {
$unescaped = xmlify(file_tag_decode($mtch[1]));
$terms[] = array('name' => $unescaped, 'selected' => $selected == $unescaped ? 'selected' : '');
}
}
return replace_macros(get_markup_template('categories_widget.tpl'), array('$title' => t('Categories'), '$desc' => '', '$sel_all' => $selected == '' ? 'selected' : '', '$all' => t('Everything'), '$terms' => $terms, '$base' => $baseurl));
}
示例9: get
function get()
{
if (!local_channel()) {
notice(t('Permission denied.') . EOL);
return;
}
if (!feature_enabled(local_channel(), 'advanced_theming')) {
notice(t('Feature disabled.') . EOL);
return;
}
if (argc() > 1) {
$module = 'mod_' . argv(1) . '.pdl';
} else {
$o .= '<div class="generic-content-wrapper-styled">';
$o .= '<h1>' . t('Edit System Page Description') . '</h1>';
$files = glob('Zotlabs/Module/*.php');
if ($files) {
foreach ($files as $f) {
$name = lcfirst(basename($f, '.php'));
$x = theme_include('mod_' . $name . '.pdl');
if ($x) {
$o .= '<a href="pdledit/' . $name . '" >' . $name . '</a><br />';
}
}
}
$o .= '</div>';
// list module pdl files
return $o;
}
$t = get_pconfig(local_channel(), 'system', $module);
if (!$t) {
$t = file_get_contents(theme_include($module));
}
if (!$t) {
notice(t('Layout not found.') . EOL);
return '';
}
$o = replace_macros(get_markup_template('pdledit.tpl'), array('$header' => t('Edit System Page Description'), '$mname' => t('Module Name:'), '$help' => t('Layout Help'), '$module' => argv(1), '$content' => htmlspecialchars($t, ENT_COMPAT, 'UTF-8'), '$submit' => t('Submit')));
return $o;
}
示例10: wallmessage_content
function wallmessage_content(&$a)
{
if (!get_my_url()) {
notice(t('Permission denied.') . EOL);
return;
}
$recipient = $a->argc > 1 ? $a->argv[1] : '';
if (!$recipient) {
notice(t('No recipient.') . EOL);
return;
}
$r = q("select * from user where nickname = '%s' limit 1", dbesc($recipient));
if (!count($r)) {
notice(t('No recipient.') . EOL);
logger('wallmessage: no recipient');
return;
}
$user = $r[0];
if (!intval($user['unkmail'])) {
notice(t('Permission denied.') . EOL);
return;
}
$r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1", intval($user['uid']));
if ($r[0]['total'] > $user['cntunkmail']) {
notice(sprintf(t('Number of daily wall messages for %s exceeded. Message failed.', $user['username'])));
return;
}
$editselect = 'none';
if (feature_enabled(local_user(), 'richtext')) {
$editselect = '/(profile-jot-text|prvmail-text)/';
}
$tpl = get_markup_template('wallmsg-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$editselect' => $editselect, '$nickname' => $user['nickname'], '$linkurl' => t('Please enter a link URL:')));
$tpl = get_markup_template('wallmsg-end.tpl');
$a->page['end'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$editselect' => $editselect, '$nickname' => $user['nickname'], '$linkurl' => t('Please enter a link URL:')));
$tpl = get_markup_template('wallmessage.tpl');
$o .= replace_macros($tpl, array('$header' => t('Send Private Message'), '$subheader' => sprintf(t('If you wish for %s to respond, please check that the privacy settings on your site allow private mail from unknown senders.'), $user['username']), '$to' => t('To:'), '$subject' => t('Subject:'), '$recipname' => $user['username'], '$nickname' => $user['nickname'], '$subjtxt' => x($_REQUEST, 'subject') ? strip_tags($_REQUEST['subject']) : '', '$text' => x($_REQUEST, 'body') ? escape_tags(htmlspecialchars($_REQUEST['body'])) : '', '$readonly' => '', '$yourmessage' => t('Your message:'), '$select' => $select, '$parent' => '', '$upload' => t('Upload photo'), '$insert' => t('Insert web link'), '$wait' => t('Please wait')));
return $o;
}
示例11: profile_sidebar
/**
* @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)
{
$a = get_app();
$observer = $a->get_observer();
$o = '';
$location = false;
$pdesc = true;
$reddress = true;
if (!is_array($profile) && !count($profile)) {
return $o;
}
head_set_icon($profile['thumb']);
$is_owner = $profile['uid'] == local_channel() ? true : false;
if (is_sys_channel($profile['uid'])) {
$show_connect = false;
}
$profile['picdate'] = urlencode($profile['picdate']);
call_hooks('profile_sidebar_enter', $profile);
require_once 'include/Contact.php';
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($profile['channel_address'] . '@' . $a->get_hostname()));
}
// premium channel - over-ride
if ($profile['channel_pageflags'] & PAGE_PREMIUM) {
$connect_url = z_root() . '/connect/' . $profile['channel_address'];
}
}
// show edit profile to yourself
if ($is_owner) {
$profile['menu'] = array('chg_photo' => t('Change profile photo'), 'entries' => array());
$multi_profiles = feature_enabled(local_channel(), 'multi_profiles');
if ($multi_profiles) {
$profile['edit'] = array($a->get_baseurl() . '/profiles', t('Profiles'), "", t('Manage/edit profiles'));
$profile['menu']['cr_new'] = t('Create New Profile');
} else {
$profile['edit'] = array($a->get_baseurl() . '/profiles/' . $profile['id'], t('Edit Profile'), '', t('Edit Profile'));
}
$r = q("SELECT * FROM `profile` WHERE `uid` = %d", local_channel());
if ($r) {
foreach ($r as $rr) {
if (!($multi_profiles || $rr['is_default'])) {
continue;
}
$profile['menu']['entries'][] = array('photo' => $rr['thumb'], 'id' => $rr['id'], 'alt' => t('Profile Image'), 'profile_name' => $rr['profile_name'], 'isdefault' => $rr['is_default'], 'visible_to_everybody' => t('visible to everybody'), 'edit_visibility' => t('Edit visibility'));
}
}
}
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 (!perm_is_allowed($profile['uid'], is_array($observer) ? $observer['xchan_hash'] : '', 'view_profile')) {
$block = true;
}
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(), '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) {
require_once 'include/comanche.php';
$channel_menu .= comanche_block($menublock);
}
$tpl = get_markup_template('profile_vcard.tpl');
require_once 'include/widgets.php';
$z = widget_rating(array('target' => $profile['channel_hash']));
//.........这里部分代码省略.........
示例12: wall_upload_post
//.........这里部分代码省略.........
}
@unlink($src);
killme();
}
$imagedata = @file_get_contents($src);
$ph = new Photo($imagedata, $filetype);
if (!$ph->is_valid()) {
$msg = t('Unable to process image.');
if ($r_json) {
echo json_encode(['error' => $msg]);
} else {
echo $msg . EOL;
}
@unlink($src);
killme();
}
$ph->orient($src);
@unlink($src);
$max_length = get_config('system', 'max_image_length');
if (!$max_length) {
$max_length = MAX_IMAGE_LENGTH;
}
if ($max_length > 0) {
$ph->scaleImage($max_length);
logger("File upload: Scaling picture to new size " . $max_length, LOGGER_DEBUG);
}
$width = $ph->getWidth();
$height = $ph->getHeight();
$hash = photo_new_resource();
$smallest = 0;
$defperm = '<' . $default_cid . '>';
$r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 0, 0, $defperm);
if (!$r) {
$msg = t('Image upload failed.');
if ($r_json) {
echo json_encode(['error' => $msg]);
} else {
echo $msg . EOL;
}
killme();
}
if ($width > 640 || $height > 640) {
$ph->scaleImage(640);
$r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 1, 0, $defperm);
if ($r) {
$smallest = 1;
}
}
if ($width > 320 || $height > 320) {
$ph->scaleImage(320);
$r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 2, 0, $defperm);
if ($r and $smallest == 0) {
$smallest = 2;
}
}
$basename = basename($filename);
if (!$desktopmode) {
$r = q("SELECT `id`, `datasize`, `width`, `height`, `type` FROM `photo` WHERE `resource-id` = '%s' ORDER BY `width` DESC LIMIT 1", $hash);
if (!$r) {
if ($r_json) {
echo json_encode(['error' => '']);
killme();
}
return false;
}
$picture = array();
$picture["id"] = $r[0]["id"];
$picture["size"] = $r[0]["datasize"];
$picture["width"] = $r[0]["width"];
$picture["height"] = $r[0]["height"];
$picture["type"] = $r[0]["type"];
$picture["albumpage"] = $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash;
$picture["picture"] = $a->get_baseurl() . "/photo/{$hash}-0." . $ph->getExt();
$picture["preview"] = $a->get_baseurl() . "/photo/{$hash}-{$smallest}." . $ph->getExt();
if ($r_json) {
echo json_encode(['picture' => $picture]);
killme();
}
return $picture;
}
if ($r_json) {
echo json_encode(['ok' => true]);
killme();
}
/* mod Waitman Gobble NO WARRANTY */
//if we get the signal then return the image url info in BBCODE, otherwise this outputs the info and bails (for the ajax image uploader on wall post)
if ($_REQUEST['hush'] != 'yeah') {
if (local_user() && (!feature_enabled(local_user(), 'richtext') || x($_REQUEST['nomce']))) {
echo "\n\n" . '[url=' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}." . $ph->getExt() . "[/img][/url]\n\n";
} else {
echo '<br /><br /><a href="' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '" ><img src="' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}." . $ph->getExt() . "\" alt=\"{$basename}\" /></a><br /><br />";
}
} else {
$m = '[url=' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}." . $ph->getExt() . "[/img][/url]";
return $m;
}
/* mod Waitman Gobble NO WARRANTY */
killme();
// NOTREACHED
}
示例13: profile_tabs
/**
* @brief
*
* @param App $a
* @param boolean $is_owner default false
* @param string $nickname default null
* @return void|string
*/
function profile_tabs($a, $is_owner = false, $nickname = null)
{
// Don't provide any profile tabs if we're running as the sys channel
if ($a->is_sys) {
return;
}
$channel = $a->get_channel();
if (is_null($nickname)) {
$nickname = $channel['channel_address'];
}
$uid = $a->profile['profile_uid'] ? $a->profile['profile_uid'] : local_channel();
if (get_pconfig($uid, 'system', 'noprofiletabs')) {
return;
}
if (x($_GET, 'tab')) {
$tab = notags(trim($_GET['tab']));
}
$url = $a->get_baseurl() . '/channel/' . $nickname;
$pr = $a->get_baseurl() . '/profile/' . $nickname;
$tabs = array(array('label' => t('Channel'), 'url' => $url, 'sel' => argv(0) == 'channel' ? 'active' : '', 'title' => t('Status Messages and Posts'), 'id' => 'status-tab'));
$p = get_all_perms($uid, get_observer_hash());
if ($p['view_profile']) {
$tabs[] = array('label' => t('About'), 'url' => $pr, 'sel' => argv(0) == 'profile' ? 'active' : '', 'title' => t('Profile Details'), 'id' => 'profile-tab');
}
if ($p['view_photos']) {
$tabs[] = array('label' => t('Photos'), 'url' => $a->get_baseurl() . '/photos/' . $nickname, 'sel' => argv(0) == 'photos' ? 'active' : '', 'title' => t('Photo Albums'), 'id' => 'photo-tab');
}
if ($p['view_storage']) {
$tabs[] = array('label' => t('Files'), 'url' => $a->get_baseurl() . '/cloud/' . $nickname . (get_observer_hash() ? '' : '?f=&davguest=1'), 'sel' => argv(0) == 'cloud' || argv(0) == 'sharedwithme' ? 'active' : '', 'title' => t('Files and Storage'), 'id' => 'files-tab');
}
if ($p['chat']) {
require_once 'include/chat.php';
$has_chats = chatroom_list_count($uid);
if ($has_chats) {
$tabs[] = array('label' => t('Chatrooms'), 'url' => $a->get_baseurl() . '/chat/' . $nickname, 'sel' => argv(0) == 'chat' ? 'active' : '', 'title' => t('Chatrooms'), 'id' => 'chat-tab');
}
}
require_once 'include/menu.php';
$has_bookmarks = menu_list_count(local_channel(), '', MENU_BOOKMARK) + menu_list_count(local_channel(), '', MENU_SYSTEM | MENU_BOOKMARK);
if ($is_owner && $has_bookmarks) {
$tabs[] = array('label' => t('Bookmarks'), 'url' => $a->get_baseurl() . '/bookmarks', 'sel' => argv(0) == 'bookmarks' ? 'active' : '', 'title' => t('Saved Bookmarks'), 'id' => 'bookmarks-tab');
}
if ($is_owner && feature_enabled($uid, 'webpages')) {
$tabs[] = array('label' => t('Webpages'), 'url' => $a->get_baseurl() . '/webpages/' . $nickname, 'sel' => argv(0) == 'webpages' ? 'active' : '', 'title' => t('Manage Webpages'), 'id' => 'webpages-tab');
} else {
/**
* @FIXME we probably need a listing of events that were created by
* this channel and are visible to the observer
*/
}
$arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $tab ? $tab : false, 'tabs' => $tabs);
call_hooks('profile_tabs', $arr);
$tpl = get_markup_template('common_tabs.tpl');
return replace_macros($tpl, array('$tabs' => $arr['tabs']));
}
示例14: mail_content
function mail_content(&$a)
{
$o = '';
nav_set_selected('messages');
if (!local_user()) {
notice(t('Permission denied.') . EOL);
return login();
}
$channel = $a->get_channel();
head_set_icon($channel['xchan_photo_s']);
$cipher = get_pconfig(local_user(), 'system', 'default_cipher');
if (!$cipher) {
$cipher = 'aes256';
}
$tpl = get_markup_template('mail_head.tpl');
$header = replace_macros($tpl, array('$messages' => t('Messages'), '$tab_content' => $tab_content));
if (argc() == 3 && argv(1) === 'drop') {
if (!intval(argv(2))) {
return;
}
$cmd = argv(1);
$r = private_messages_drop(local_user(), argv(2));
if ($r) {
info(t('Message deleted.') . EOL);
}
goaway($a->get_baseurl(true) . '/message');
}
if (argc() == 3 && argv(1) === 'recall') {
if (!intval(argv(2))) {
return;
}
$cmd = argv(1);
$r = q("update mail set mail_flags = mail_flags | %d where id = %d and channel_id = %d limit 1", intval(MAIL_RECALLED), intval(argv(2)), intval(local_user()));
proc_run('php', 'include/notifier.php', 'mail', intval(argv(2)));
if ($r) {
info(t('Message recalled.') . EOL);
}
goaway($a->get_baseurl(true) . '/message');
}
if (argc() > 1 && argv(1) === 'new') {
$o .= $header;
$plaintext = true;
$tpl = get_markup_template('msg-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$nickname' => $channel['channel_address'], '$linkurl' => t('Please enter a link URL:'), '$expireswhen' => t('Expires YYYY-MM-DD HH:MM')));
$preselect = isset($a->argv[2]) ? array($a->argv[2]) : false;
$prename = $preurl = $preid = '';
if (x($_REQUEST, 'hash')) {
$r = q("select abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash\n\t\t\t\twhere abook_channel = %d and abook_xchan = '%s' limit 1", intval(local_user()), dbesc($_REQUEST['hash']));
if ($r) {
$prename = $r[0]['xchan_name'];
$preurl = $r[0]['xchan_url'];
$preid = $r[0]['abook_id'];
$preselect = array($preid);
}
}
if ($preselect) {
$r = q("select abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash\n\t\t\t\twhere abook_channel = %d and abook_id = %d limit 1", intval(local_user()), intval(argv(2)));
if ($r) {
$prename = $r[0]['xchan_name'];
$preurl = $r[0]['xchan_url'];
$preid = $r[0]['abook_id'];
}
}
$prefill = $preselect ? $prename : '';
if (!$prefill) {
if (array_key_exists('to', $_REQUEST)) {
$prefill = $_REQUEST['to'];
}
}
// the ugly select box
$select = contact_select('messageto', 'message-to-select', $preselect, 4, true, false, false, 10);
$tpl = get_markup_template('prv_message.tpl');
$o .= replace_macros($tpl, array('$header' => t('Send Private Message'), '$to' => t('To:'), '$showinputs' => 'true', '$prefill' => $prefill, '$autocomp' => $autocomp, '$preid' => $preid, '$subject' => t('Subject:'), '$subjtxt' => x($_REQUEST, 'subject') ? strip_tags($_REQUEST['subject']) : '', '$text' => x($_REQUEST, 'body') ? htmlspecialchars($_REQUEST['body'], ENT_COMPAT, 'UTF-8') : '', '$readonly' => '', '$yourmessage' => t('Your message:'), '$select' => $select, '$parent' => '', '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$insert' => t('Insert web link'), '$wait' => t('Please wait'), '$submit' => t('Send'), '$defexpire' => '', '$feature_expire' => feature_enabled(local_user(), 'content_expire') ? true : false, '$expires' => t('Set expiration date'), '$feature_encrypt' => feature_enabled(local_user(), 'content_encrypt') ? true : false, '$encrypt' => t('Encrypt text'), '$cipher' => $cipher));
return $o;
}
if (argc() > 1 && intval(argv(1))) {
$o .= $header;
$plaintext = true;
// if( local_user() && feature_enabled(local_user(),'richtext') )
// $plaintext = false;
$messages = private_messages_fetch_conversation(local_user(), argv(1), true);
if (!$messages) {
info(t('Message not found.') . EOL);
return $o;
}
if ($messages[0]['to_xchan'] === $channel['channel_hash']) {
$a->poi = $messages[0]['from'];
} else {
$a->poi = $messages[0]['to'];
}
// require_once('include/Contact.php');
// $a->set_widget('mail_conversant',vcard_from_xchan($a->poi,$get_observer_hash,'mail'));
$tpl = get_markup_template('msg-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array('$nickname' => $channel['channel_addr'], '$baseurl' => $a->get_baseurl(true), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$linkurl' => t('Please enter a link URL:'), '$expireswhen' => t('Expires YYYY-MM-DD HH:MM')));
$mails = array();
$seen = 0;
$unknown = false;
foreach ($messages as $message) {
$s = theme_attachments($message);
$mails[] = array('id' => $message['id'], 'from_name' => $message['from']['xchan_name'], 'from_url' => chanlink_hash($message['from_xchan']), 'from_photo' => $message['from']['xchan_photo_m'], 'to_name' => $message['to']['xchan_name'], 'to_url' => chanlink_hash($message['to_xchan']), 'to_photo' => $message['to']['xchan_photo_m'], 'subject' => $message['title'], 'body' => smilies(bbcode($message['body']) . $s), 'delete' => t('Delete message'), 'recall' => t('Recall message'), 'can_recall' => $channel['channel_hash'] == $message['from_xchan'] ? true : false, 'is_recalled' => $message['mail_flags'] & MAIL_RECALLED ? t('Message has been recalled.') : '', 'date' => datetime_convert('UTC', date_default_timezone_get(), $message['created'], 'D, d M Y - g:i A'));
//.........这里部分代码省略.........
示例15: photos_content
//.........这里部分代码省略.........
$r = fetch_post_tags($r, true);
$r = conv_sort($r, 'commented');
}
$tags = array();
if ($link_item['term']) {
$cnt = 0;
foreach ($link_item['term'] as $t) {
$tags[$cnt] = array(0 => format_term_for_display($t));
if ($can_post && $ph[0]['uid'] == $owner_uid) {
$tags[$cnt][1] = 'tagrm/drop/' . $link_item['id'] . '/' . bin2hex($t['term']);
//?f=&item=' . $link_item['id'];
$tags[$cnt][2] = t('Remove');
}
$cnt++;
}
}
if (local_channel() && local_channel() == $link_item['uid']) {
q("UPDATE `item` SET item_unseen = 0 WHERE parent = %d and uid = %d and item_unseen = 1", intval($link_item['parent']), intval(local_channel()));
}
if ($link_item['coord']) {
$map = generate_map($link_item['coord']);
}
}
// logger('mod_photo: link_item' . print_r($link_item,true));
// FIXME - remove this when we move to conversation module
$r = $r[0]['children'];
$edit = null;
if ($can_post) {
$album_e = $ph[0]['album'];
$caption_e = $ph[0]['description'];
$aclselect_e = $_is_owner ? populate_acl($ph[0]) : '';
$albums = array_key_exists('albums', $a->data) ? $a->data['albums'] : photos_albums_list($a->data['channel'], $a->data['observer']);
$_SESSION['album_return'] = bin2hex($ph[0]['album']);
$edit = array('edit' => t('Edit photo'), 'id' => $link_item['id'], 'rotatecw' => t('Rotate CW (right)'), 'rotateccw' => t('Rotate CCW (left)'), 'albums' => $albums['albums'], 'album' => $album_e, 'newalbum_label' => t('Enter a new album name'), 'newalbum_placeholder' => t('or select an existing one (doubleclick)'), 'nickname' => $a->data['channel']['channel_address'], 'resource_id' => $ph[0]['resource_id'], 'capt_label' => t('Caption'), 'caption' => $caption_e, 'tag_label' => t('Add a Tag'), 'permissions' => t('Permissions'), 'aclselect' => $aclselect_e, 'lockstate' => $lockstate[0], 'help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com'), 'item_id' => count($linked_items) ? $link_item['id'] : 0, 'adult_enabled' => feature_enabled($owner_uid, 'adult_photo_flagging'), 'adult' => array('adult', t('Flag as adult in album view'), intval($ph[0]['is_nsfw']), ''), 'submit' => t('Submit'), 'delete' => t('Delete Photo'));
}
if (count($linked_items)) {
$cmnt_tpl = get_markup_template('comment_item.tpl');
$tpl = get_markup_template('photo_item.tpl');
$return_url = $a->cmd;
$like_tpl = get_markup_template('like_noshare.tpl');
$likebuttons = '';
if ($can_post || $can_comment) {
$likebuttons = array('id' => $link_item['id'], 'likethis' => t("I like this (toggle)"), 'nolike' => t("I don't like this (toggle)"), 'share' => t('Share'), 'wait' => t('Please wait'));
}
$comments = '';
if (!count($r)) {
if ($can_post || $can_comment) {
$commentbox = replace_macros($cmnt_tpl, array('$return_path' => '', '$mode' => 'photos', '$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'), '$preview' => t('Preview'), '$ww' => '', '$feature_encrypt' => false));
}
}
$alike = array();
$dlike = array();
$like = '';
$dislike = '';
$conv_responses = array('like' => array('title' => t('Likes', 'title')), 'dislike' => array('title' => t('Dislikes', 'title')), 'agree' => array('title' => t('Agree', 'title')), 'disagree' => array('title' => t('Disagree', 'title')), 'abstain' => array('title' => t('Abstain', 'title')), 'attendyes' => array('title' => t('Attending', 'title')), 'attendno' => array('title' => t('Not attending', 'title')), 'attendmaybe' => array('title' => t('Might attend', 'title')));
if ($r) {
foreach ($r as $item) {
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 = '';