function search_ac_init(&$a) { if (!local_channel()) { killme(); } $start = x($_REQUEST, 'start') ? $_REQUEST['start'] : 0; $count = x($_REQUEST, 'count') ? $_REQUEST['count'] : 100; $search = x($_REQUEST, 'search') ? $_REQUEST['search'] : ""; if (x($_REQUEST, 'query') && strlen($_REQUEST['query'])) { $search = $_REQUEST['query']; } // Priority to people searches if ($search) { $people_sql_extra = protect_sprintf(" AND `xchan_name` LIKE '%" . dbesc($search) . "%' "); $tag_sql_extra = protect_sprintf(" AND term LIKE '%" . dbesc($search) . "%' "); } $r = q("SELECT `abook_id`, `xchan_name`, `xchan_photo_s`, `xchan_url`, `xchan_addr` FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d \n\t\t{$people_sql_extra}\n\t\tORDER BY `xchan_name` ASC ", intval(local_channel())); $results = array(); if ($r) { foreach ($r as $g) { $results[] = array("photo" => $g['xchan_photo_s'], "name" => '@' . $g['xchan_name'], "id" => $g['abook_id'], "link" => $g['xchan_url'], "label" => '', "nick" => ''); } } $r = q("select distinct term, tid, url from term where type in ( %d, %d ) {$tag_sql_extra} group by term order by term asc", intval(TERM_HASHTAG), intval(TERM_COMMUNITYTAG)); if (count($r)) { foreach ($r as $g) { $results[] = array("photo" => $a->get_baseurl() . '/images/hashtag.png', "name" => '#' . $g['term'], "id" => $g['tid'], "link" => $g['url'], "label" => '', "nick" => ''); } } header("content-type: application/json"); $o = array('start' => $start, 'count' => $count, 'items' => $results); echo json_encode($o); logger('search_ac: ' . print_r($x, true)); killme(); }
function get() { if (!local_channel()) { return; } $postid = $_REQUEST['postid']; if (!$postid) { return; } $emoji = $_REQUEST['emoji']; if ($_REQUEST['emoji']) { $i = q("select * from item where id = %d and uid = %d", intval($postid), intval(local_channel())); if (!$i) { return; } $channel = \App::get_channel(); $n = array(); $n['aid'] = $channel['channel_account_id']; $n['uid'] = $channel['channel_id']; $n['item_origin'] = true; $n['parent'] = $postid; $n['parent_mid'] = $i[0]['mid']; $n['mid'] = item_message_id(); $n['verb'] = ACTIVITY_REACT . '#' . $emoji; $n['body'] = "\n\n[zmg=32x32]" . z_root() . '/images/emoji/' . $emoji . '.png[/zmg]' . "\n\n"; $n['author_xchan'] = $channel['channel_hash']; $x = item_store($n); if ($x['success']) { $nid = $x['item_id']; \Zotlabs\Daemon\Master::Summon(array('Notifier', 'like', $nid)); } } }
function get() { require_once 'include/acl_selectors.php'; if (!local_channel()) { notice(t('Permission denied.') . EOL); return; } if (\App::$argc != 2) { return; } $contact_id = intval(\App::$argv[1]); $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), intval(local_channel())); 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" >'; // FIXME contact_selector deprecated, removed // $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; }
function dwpost_post_local(&$a, &$b) { // This can probably be changed to allow editing by pointing to a different API endpoint if ($b['edit']) { return; } if (!local_channel() || local_channel() != $b['uid']) { return; } if ($b['item_private'] || $b['parent']) { return; } logger('Dreamwidth xpost invoked'); $dw_post = intval(get_pconfig(local_channel(), 'dwpost', 'post')); $dw_enable = $dw_post && x($_REQUEST, 'dwpost_enable') ? intval($_REQUEST['dwpost_enable']) : 0; if ($_REQUEST['api_source'] && intval(get_pconfig(local_channel(), 'dwpost', 'post_by_default'))) { $dw_enable = 1; } if (!$dw_enable) { return; } if (strlen($b['postopts'])) { $b['postopts'] .= ','; } $b['postopts'] .= 'dwpost'; }
function filer_content(&$a) { if (!local_channel()) { killme(); } $term = unxmlify(trim($_GET['term'])); $item_id = $a->argc > 1 ? intval($a->argv[1]) : 0; logger('filer: tag ' . $term . ' item ' . $item_id); if ($item_id && strlen($term)) { // file item store_item_tag(local_channel(), $item_id, TERM_OBJ_POST, TERM_FILE, $term, ''); // protect the entire conversation from periodic expiration $r = q("select parent from item where id = %d and uid = %d limit 1", intval($item_id), intval(local_channel())); if ($r) { $x = q("update item set item_retained = 1 where id = %d and uid = %d", intval($r[0]['parent']), intval(local_channel())); } } else { $filetags = array(); $r = q("select distinct(term) from term where uid = %d and type = %d order by term asc", intval(local_channel()), intval(TERM_FILE)); if (count($r)) { foreach ($r as $rr) { $filetags[] = $rr['term']; } } $tpl = get_markup_template("filer_dialog.tpl"); $o = replace_macros($tpl, array('$field' => array('term', t("Save to Folder:"), '', '', $filetags, t('- select -')), '$submit' => t('Save'))); echo $o; } killme(); }
function bookmarks_content(&$a) { if (!local_channel()) { notice(t('Permission denied.') . EOL); return; } require_once 'include/menu.php'; require_once 'include/conversation.php'; $channel = App::get_channel(); $o = profile_tabs($a, true, $channel['channel_address']); $o .= '<div class="generic-content-wrapper-styled">'; $o .= '<h3>' . t('My Bookmarks') . '</h3>'; $x = menu_list(local_channel(), '', MENU_BOOKMARK); if ($x) { foreach ($x as $xx) { $y = menu_fetch($xx['menu_name'], local_channel(), get_observer_hash()); $o .= menu_render($y, '', true); } } $o .= '<h3>' . t('My Connections Bookmarks') . '</h3>'; $x = menu_list(local_channel(), '', MENU_SYSTEM | MENU_BOOKMARK); if ($x) { foreach ($x as $xx) { $y = menu_fetch($xx['menu_name'], local_channel(), get_observer_hash()); $o .= menu_render($y, '', true); } } $o .= '</div>'; return $o; }
function nofed_post_local(&$a, &$b) { if ($b['created'] != $b['edited']) { return; } if ($b['mid'] !== $b['parent_mid']) { return; } if (local_channel() && local_channel() == $b['uid']) { if ($b['allow_cid'] || $b['allow_gid'] || $b['deny_cid'] || $b['deny_gid']) { return; } $nofed_post = get_pconfig(local_channel(), 'nofed', 'post'); if (!$nofed_post) { return; } $nofed_enable = $nofed_post && x($_REQUEST, 'nofed_enable') ? intval($_REQUEST['nofed_enable']) : 0; // if API is used, default to the chosen settings if ($_REQUEST['api_source'] && intval(get_pconfig(local_channel(), 'nofed', 'post_by_default'))) { $nofed_enable = 1; } if ($nofed_enable) { return; } if (strlen($b['postopts'])) { $b['postopts'] .= ','; } $b['postopts'] .= 'nodeliver'; } }
function likebanner_content(&$a) { if (local_channel()) { $channel = $a->get_channel(); } else { $channel = null; } $o = '<h1>Like Banner</h1>'; $def = $_REQUEST['addr']; if ($channel && !$def) { $def = $channel['xchan_addr']; } $o .= '<form action="likebanner" method="get" >'; $o .= t('Your Webbie:'); $o .= '<br /><br />'; $o .= '<input type="text" name="addr" size="32" value="' . $def . '" />'; $o .= '<br /><br />' . t('Fontsize (px):'); $o .= '<br /><br />'; $o .= '<input type="text" name="size" size="32" value="' . ($_REQUEST['size'] ? $_REQUEST['size'] : 28) . '" /><br /><br />'; $o .= '<input type="submit" name="submit" value="' . t('Submit') . '" /></form><br /><br/>'; if ($_REQUEST['addr']) { $o .= '<img style="border: 1px solid #000;" src="likebanner/show/?f=&addr=' . urlencode($_REQUEST['addr']) . '&size=' . $_REQUEST['size'] . '" alt="banner" />'; if ($channel) { $p = q("select profile_guid from profile where uid = %d and is_default = 1 limit 1", intval($channel['channel_id'])); if ($p) { $link = z_root() . '/like/profile/' . $p[0]['profile_guid'] . '?f=&verb=like&interactive=1'; $o .= EOL . EOL . t('Link:') . EOL . '<input type="text" size="64" onclick="this.select();" value="' . $link . '" />'; $html = '<a href="' . $link . '" ><img src="' . z_root() . '/likebanner?f=&addr=' . $def . '&size=' . $_REQUEST['size'] . '" alt="' . t('Like us on RedMatrix') . '" /></a>'; $o .= EOL . EOL . t('Embed:') . EOL . '<input type="text" size="64" onclick="this.select();" value="' . htmlspecialchars($html, ENT_QUOTES, 'UTF-8') . '" />'; } } } return $o; }
function login_content(&$a) { if (local_channel()) { goaway(z_root()); } return login($a->config['system']['register_policy'] == REGISTER_CLOSED ? false : true); }
function get() { if (!local_channel()) { killme(); } if (argc() > 2 && intval(argv(1)) && argv(2)) { $r = q("SELECT abook_xchan from abook where abook_xchan = '%s' and abook_channel = %d and abook_self = 0 limit 1", dbesc(base64url_decode(argv(2))), intval(local_channel())); if ($r) { $change = $r[0]['abook_xchan']; } } if (argc() > 1 && intval(argv(1))) { $r = q("SELECT * FROM `groups` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1", intval(argv(1)), intval(local_channel())); if (!$r) { killme(); } $group = $r[0]; $members = group_get_members($group['id']); $preselected = array(); if (count($members)) { foreach ($members as $member) { $preselected[] = $member['xchan_hash']; } } if ($change) { if (in_array($change, $preselected)) { group_rmv_member(local_channel(), $group['gname'], $change); } else { group_add_member(local_channel(), $group['gname'], $change); } } } killme(); }
function viewsrc_content(&$a) { $o = ''; $sys = get_sys_channel(); $item_id = argc() > 1 ? intval(argv(1)) : 0; $json = argc() > 2 && argv(2) === 'json' ? true : false; if (!local_channel()) { notice(t('Permission denied.') . EOL); } if (!$item_id) { App::$error = 404; notice(t('Item not found.') . EOL); } $item_normal = item_normal(); if (local_channel() && $item_id) { $r = q("select id, item_flags, item_obscured, body from item where uid in (%d , %d) and id = %d {$item_normal} limit 1", intval(local_channel()), intval($sys['channel_id']), intval($item_id)); if ($r) { if (intval($r[0]['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()) { print '<div><i class="icon-pencil"> ' . t('Source of Item') . ' ' . $r[0]['id'] . '</i></div>'; echo $o; killme(); } return $o; }
function apps_content(&$a) { if (argc() == 2 && argv(1) == 'edit') { $mode = 'edit'; } else { $mode = 'list'; } $_SESSION['return_url'] = $a->cmd; $apps = array(); $syslist = get_system_apps(); if (local_channel()) { $list = app_list(local_channel()); if ($list) { foreach ($list as $x) { $syslist[] = app_encode($x); } } } usort($syslist, 'app_name_compare'); // logger('apps: ' . print_r($syslist,true)); foreach ($syslist as $app) { $apps[] = app_render($app, $mode); } return replace_macros(get_markup_template('myapps.tpl'), array('$sitename' => get_config('system', 'sitename'), '$title' => t('Apps'), '$apps' => $apps)); }
function msgfooter_post_hook($a, &$item) { /** * * An item was posted on the local system. * We are going to look for specific items: * - A status post by a profile owner * - The profile owner must have allowed our plugin * */ logger('msgfooter invoked'); if (!local_channel()) { /* non-zero if this is a logged in user of this system */ return; } if (local_channel() != $item['uid']) { /* Does this person own the post? */ return; } if ($item['item_type']) { return; } if ($item['parent']) { /* If the item has a parent, this is a comment or something else, not a status post. */ return; } /* Retrieve our config setting */ $footer = get_config('msgfooter', 'msgfooter_text'); if (!$footer) { return; } $item['body'] .= '[footer]' . $footer . '[/footer]'; return; }
/** * Set the mode we'll be displayed on */ private function set_mode($mode) { if ($this->get_mode() == $mode) { return; } $a = $this->get_app(); $this->observer = App::get_observer(); $ob_hash = $this->observer ? $this->observer['xchan_hash'] : ''; switch ($mode) { case 'network': $this->profile_owner = local_channel(); $this->writable = true; break; case 'channel': $this->profile_owner = App::$profile['profile_uid']; $this->writable = perm_is_allowed($this->profile_owner, $ob_hash, 'post_comments'); break; case 'display': // in this mode we set profile_owner after initialisation (from conversation()) and then // pull some trickery which allows us to re-invoke this function afterward // it's an ugly hack so FIXME $this->writable = perm_is_allowed($this->profile_owner, $ob_hash, 'post_comments'); break; case 'page': $this->profile_owner = App::$profile['uid']; $this->writable = perm_is_allowed($this->profile_owner, $ob_hash, 'post_comments'); break; default: logger('[ERROR] Conversation::set_mode : Unhandled mode (' . $mode . ').', LOGGER_DEBUG); return false; break; } $this->mode = $mode; }
function post() { // logger('file upload: ' . print_r($_REQUEST,true)); $channel = $_REQUEST['channick'] ? get_channel_by_nick($_REQUEST['channick']) : null; if (!$channel) { logger('channel not found'); killme(); } $_REQUEST['source'] = 'file_upload'; if ($channel['channel_id'] != local_channel()) { $_REQUEST['contact_allow'] = expand_acl($channel['channel_allow_cid']); $_REQUEST['group_allow'] = expand_acl($channel['channel_allow_gid']); $_REQUEST['contact_deny'] = expand_acl($channel['channel_deny_cid']); $_REQUEST['group_deny'] = expand_acl($channel['channel_deny_gid']); } if ($_REQUEST['filename']) { $_REQUEST['allow_cid'] = perms2str($_REQUEST['contact_allow']); $_REQUEST['allow_gid'] = perms2str($_REQUEST['group_allow']); $_REQUEST['deny_cid'] = perms2str($_REQUEST['contact_deny']); $_REQUEST['deny_gid'] = perms2str($_REQUEST['group_deny']); $r = attach_mkdir($channel, get_observer_hash(), $_REQUEST); } else { $r = attach_store($channel, get_observer_hash(), '', $_REQUEST); } goaway(z_root() . '/' . $_REQUEST['return_url']); }
function tasks_content(&$a) { if (!local_channel()) { return; } return ''; }
function pdledit_content(&$a) { if (!local_channel()) { notice(t('Permission denied.') . EOL); return; } if (argc() > 1) { $module = 'mod_' . argv(1) . '.pdl'; } else { $o .= '<h1>' . t('Edit System Page Description') . '</h1>'; $files = glob('mod/*'); if ($files) { foreach ($files as $f) { $name = basename($f, '.php'); $x = theme_include('mod_' . $name . '.pdl'); if ($x) { $o .= '<a href="pdledit/' . $name . '" >' . $name . '</a><br />'; } } } // 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; }
function libertree_post_local(&$a, &$b) { // This can probably be changed to allow editing by pointing to a different API endpoint if ($b['edit']) { return; } if (!local_channel() || local_channel() != $b['uid']) { return; } if ($b['item_private'] || $b['mid'] != $b['parent_mid']) { return; } $ltree_post = intval(get_pconfig(local_channel(), 'libertree', 'post')); $ltree_enable = $ltree_post && x($_REQUEST, 'libertree_enable') ? intval($_REQUEST['libertree_enable']) : 0; if ($_REQUEST['api_source'] && intval(get_pconfig(local_channel(), 'libertree', 'post_by_default'))) { $ltree_enable = 1; } if (!$ltree_enable) { return; } if (strlen($b['postopts'])) { $b['postopts'] .= ','; } $b['postopts'] .= 'libertree'; }
function get() { if (!local_channel()) { goaway(z_root() . '/' . $_SESSION['photo_return']); // NOTREACHED } // remove tag on the fly if item and tag are provided if (argc() == 4 && argv(1) === 'drop' && intval(argv(2))) { $item = intval(argv(2)); $tag = argv(3); $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($item), intval(local_channel())); if (!$r) { goaway(z_root() . '/' . $_SESSION['photo_return']); } $r = fetch_post_tags($r, true); $item = $r[0]; $new_tags = array(); if ($item['term']) { for ($x = 0; $x < count($item['term']); $x++) { if ($item['term'][$x]['term'] !== hex2bin($tag)) { $new_tags[] = $item['term'][$x]; } } } if ($new_tags) { $item['term'] = $new_tags; } else { unset($item['term']); } item_store_update($item); info(t('Tag removed') . EOL); goaway(z_root() . '/' . $_SESSION['photo_return']); } //if we got only the item print a list of tags to select if (argc() == 3 && argv(1) === 'drop' && intval(argv(2))) { $o = ''; $item = intval(argv(2)); $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($item), intval(local_channel())); if (!$r) { goaway(z_root() . '/' . $_SESSION['photo_return']); } $r = fetch_post_tags($r, true); if (!count($r[0]['term'])) { goaway(z_root() . '/' . $_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 ($r[0]['term'] as $x) { $o .= '<li><input type="checkbox" name="tag" value="' . bin2hex($x['term']) . '" >' . bbcode($x['term']) . '</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; } }
function get() { if (!local_channel()) { notice(t('Permission denied.') . EOL); return; } $channel = \App::get_channel(); $app = null; $embed = null; if ($_REQUEST['appid']) { $r = q("select * from app where app_id = '%s' and app_channel = %d limit 1", dbesc($_REQUEST['appid']), dbesc(local_channel())); if ($r) { $app = $r[0]; $term = q("select * from term where otype = %d and oid = %d", intval(TERM_OBJ_APP), intval($r[0]['id'])); if ($term) { $app['categories'] = ''; foreach ($term as $t) { if ($app['categories']) { $app['categories'] .= ','; } $app['categories'] .= $t['term']; } } } $embed = array('embed', t('Embed code'), app_encode($app, true), '', 'onclick="this.select();"'); } return replace_macros(get_markup_template('app_create.tpl'), array('$banner' => $app ? t('Edit App') : t('Create App'), '$app' => $app, '$guid' => $app ? $app['app_id'] : '', '$author' => $app ? $app['app_author'] : $channel['channel_hash'], '$addr' => $app ? $app['app_addr'] : $channel['xchan_addr'], '$name' => array('name', t('Name of app'), $app ? $app['app_name'] : '', t('Required')), '$url' => array('url', t('Location (URL) of app'), $app ? $app['app_url'] : '', t('Required')), '$desc' => array('desc', t('Description'), $app ? $app['app_desc'] : '', ''), '$photo' => array('photo', t('Photo icon URL'), $app ? $app['app_photo'] : '', t('80 x 80 pixels - optional')), '$categories' => array('categories', t('Categories (optional, comma separated list)'), $app ? $app['categories'] : '', ''), '$version' => array('version', t('Version ID'), $app ? $app['app_version'] : '', ''), '$price' => array('price', t('Price of app'), $app ? $app['app_price'] : '', ''), '$page' => array('page', t('Location (URL) to purchase app'), $app ? $app['app_page'] : '', ''), '$system' => $app ? intval($app['app_system']) : 0, '$requires' => $app ? $app['app_requires'] : '', '$embed' => $embed, '$submit' => t('Submit'))); }
function uexport_init(&$a) { if (!local_channel()) { killme(); } if (argc() > 1) { $channel = App::get_channel(); require_once 'include/identity.php'; if (argc() > 1 && intval(argv(1)) > 1900) { $year = intval(argv(1)); } if (argc() > 2 && intval(argv(2)) > 0 && intval(argv(2)) <= 12) { $month = intval(argv(2)); } header('content-type: application/octet_stream'); header('content-disposition: attachment; filename="' . $channel['channel_address'] . ($year ? '-' . $year : '') . ($month ? '-' . $month : '') . '.json"'); if ($year) { echo json_encode(identity_export_year(local_channel(), $year, $month)); killme(); } if (argc() > 1 && argv(1) === 'basic') { echo json_encode(identity_basic_export(local_channel())); killme(); } // FIXME - this basically doesn't work in the wild with a channel more than a few months old due to memory and execution time limits. // It probably needs to be built at the CLI and offered to download as a tarball. Maybe stored in the members dav. if (argc() > 1 && argv(1) === 'complete') { echo json_encode(identity_basic_export(local_channel(), true)); killme(); } } }
/** @file */ function notes_init(&$a) { if (!local_channel()) { return; } $ret = array('success' => true); if (array_key_exists('note_text', $_REQUEST)) { $body = escape_tags($_REQUEST['note_text']); // I've had my notes vanish into thin air twice in four years. // Provide a backup copy if there were contents previously // and there are none being saved now. if (!$body) { $old_text = get_pconfig(local_channel(), 'notes', 'text'); if ($old_text) { set_pconfig(local_channel(), 'notes', 'text.bak', $old_text); } } set_pconfig(local_channel(), 'notes', 'text', $body); } // push updates to channel clones if (argc() > 1 && argv(1) === 'sync') { require_once 'include/zot.php'; build_sync_packet(); } logger('notes saved.', LOGGER_DEBUG); json_return_and_die($ret); }
function pubsites_content(&$a) { require_once 'include/dir_fns.php'; $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'; } $url .= '/sites'; $o .= '<h1>' . t('Public Sites') . '</h1>'; $o .= '<div class="descriptive-text">' . t('The listed sites allow public registration into the Red Matrix. All sites in the matrix are interlinked so membership on any of them conveys membership in the matrix as a whole. Some sites may require subscription or provide tiered service plans. The provider links <strong>may</strong> provide additional details.') . '</div>' . EOL; $ret = z_fetch_url($url); if ($ret['success']) { $j = json_decode($ret['body'], true); if ($j) { $rate_meta = local_channel() ? '<td>' . t('Rate this hub') . '</td>' : ''; $o .= '<table border="1"><tr><td>' . t('Site URL') . '</td><td>' . t('Access Type') . '</td><td>' . t('Registration Policy') . '</td><td>' . t('Location') . '</td><td>' . t('View hub ratings') . '</td>' . $rate_meta . '</tr>'; if ($j['sites']) { foreach ($j['sites'] as $jj) { $host = strtolower(substr($jj['url'], strpos($jj['url'], '://') + 3)); $rate_links = local_channel() ? '<td><a href="rate?f=&target=' . $host . '" class="btn-btn-default"><i class="icon-check"></i> ' . t('Rate') . '</a></td>' : ''; $o .= '<tr><td>' . '<a href="' . ($jj['sellpage'] ? $jj['sellpage'] : $jj['url'] . '/register') . '" >' . $jj['url'] . '</a>' . '</td><td>' . $jj['access'] . '</td><td>' . $jj['register'] . '</td><td>' . $jj['location'] . '</td><td><a href="ratings/' . $host . '" class="btn-btn-default"><i class="icon-eye-open"></i> ' . t('View ratings') . '</a></td>' . $rate_links . '</tr>'; } } $o .= '</table>'; } } return $o; }
function get() { if (!local_channel()) { return; } return ''; }
function get() { if (argc() > 2 && argv(2) === 'add') { $tpl = get_markup_template("settings_oauth_edit.tpl"); $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_oauth"), '$title' => t('Add application'), '$submit' => t('Submit'), '$cancel' => t('Cancel'), '$name' => array('name', t('Name'), '', t('Name of application')), '$key' => array('key', t('Consumer Key'), random_string(16), t('Automatically generated - change if desired. Max length 20')), '$secret' => array('secret', t('Consumer Secret'), random_string(16), t('Automatically generated - change if desired. Max length 20')), '$redirect' => array('redirect', t('Redirect'), '', t('Redirect URI - leave blank unless your application specifically requires this')), '$icon' => array('icon', t('Icon url'), '', t('Optional')))); return $o; } if (argc() > 3 && argv(2) === 'edit') { $r = q("SELECT * FROM clients WHERE client_id='%s' AND uid=%d", dbesc(argv(3)), local_channel()); if (!count($r)) { notice(t('Application not found.')); return; } $app = $r[0]; $tpl = get_markup_template("settings_oauth_edit.tpl"); $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_oauth"), '$title' => t('Add application'), '$submit' => t('Update'), '$cancel' => t('Cancel'), '$name' => array('name', t('Name'), $app['clname'], ''), '$key' => array('key', t('Consumer Key'), $app['client_id'], ''), '$secret' => array('secret', t('Consumer Secret'), $app['pw'], ''), '$redirect' => array('redirect', t('Redirect'), $app['redirect_uri'], ''), '$icon' => array('icon', t('Icon url'), $app['icon'], ''))); return $o; } if (argc() > 3 && argv(2) === 'delete') { check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth', 't'); $r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d", dbesc(argv(3)), local_channel()); goaway(z_root() . "/settings/oauth/"); return; } $r = q("SELECT clients.*, tokens.id as oauth_token, (clients.uid=%d) AS my \n\t\t\t\tFROM clients\n\t\t\t\tLEFT JOIN tokens ON clients.client_id=tokens.client_id\n\t\t\t\tWHERE clients.uid IN (%d,0)", local_channel(), local_channel()); $tpl = get_markup_template("settings_oauth.tpl"); $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_oauth"), '$baseurl' => z_root(), '$title' => t('Connected Apps'), '$add' => t('Add application'), '$edit' => t('Edit'), '$delete' => t('Delete'), '$consumerkey' => t('Client key starts with'), '$noname' => t('No name'), '$remove' => t('Remove authorization'), '$apps' => $r)); return $o; }
function get() { if (argc() == 2 && argv(1) == 'edit') { $mode = 'edit'; } else { $mode = 'list'; } $_SESSION['return_url'] = \App::$cmd; $apps = array(); if (local_channel()) { import_system_apps(); $syslist = array(); $list = app_list(local_channel(), false, $_GET['cat']); if ($list) { foreach ($list as $x) { $syslist[] = app_encode($x); } } translate_system_apps($syslist); } else { $syslist = get_system_apps(true); } usort($syslist, 'app_name_compare'); // logger('apps: ' . print_r($syslist,true)); foreach ($syslist as $app) { $apps[] = app_render($app, $mode); } return replace_macros(get_markup_template('myapps.tpl'), array('$sitename' => get_config('system', 'sitename'), '$cat' => array_key_exists('cat', $_GET) && $_GET['cat'] ? ' - ' . escape_tags($_GET['cat']) : '', '$title' => t('Apps'), '$apps' => $apps)); }
function search_doc_files($s) { $a = get_app(); $itemspage = get_pconfig(local_channel(), 'system', 'itemspage'); App::set_pager_itemspage(intval($itemspage) ? $itemspage : 20); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start'])); $regexop = db_getfunc('REGEXP'); $r = q("select item_id.sid, item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and\n\t\tbody {$regexop} '%s' and item_type = %d {$pager_sql}", dbesc($s), intval(ITEM_TYPE_DOC)); $r = fetch_post_tags($r, true); for ($x = 0; $x < count($r); $x++) { $r[$x]['text'] = $r[$x]['body']; $r[$x]['rank'] = 0; if ($r[$x]['term']) { foreach ($r[$x]['term'] as $t) { if (stristr($t['term'], $s)) { $r[$x]['rank']++; } } } if (stristr($r[$x]['sid'], $s)) { $r[$x]['rank']++; } $r[$x]['rank'] += substr_count(strtolower($r[$x]['text']), strtolower($s)); // bias the results to the observer's native language if ($r[$x]['lang'] === App::$language) { $r[$x]['rank'] = $r[$x]['rank'] + 10; } } usort($r, 'doc_rank_sort'); return $r; }
function checkid($realm, &$attributes) { logger('checkid: ' . $realm); logger('checkid attrs: ' . print_r($attributes, true)); if (isset($_POST['cancel'])) { $this->cancel(); } $data = \Zotlabs\Module\Id::getUserData(); if (!$data) { return false; } $q = get_pconfig(local_channel(), 'openid', $realm); $attrs = array(); if ($q) { $attrs = $q; } elseif (isset($_POST['attributes'])) { $attrs = array_keys($_POST['attributes']); } elseif (!isset($_POST['once']) && !isset($_POST['always'])) { return false; } $attributes = array(); foreach ($attrs as $attr) { if (isset($this->attrFieldMap[$attr])) { $attributes[$attr] = $data[$this->attrFieldMap[$attr]]; } } if (isset($_POST['always'])) { set_pconfig(local_channel(), 'openid', $realm, array_keys($attributes)); } return z_root() . '/id/' . $data['channel_address']; }
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_channel() && 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_channel())); 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); }
function get() { if (!local_channel()) { notice(t('Permission denied.') . EOL); return; } // if(! \App::$data['target']) { // notice( t('No recipients.') . EOL); // return; // } $rating_enabled = get_config('system', 'rating_enabled'); if (!$rating_enabled) { notice('Ratings are disabled on this site.'); return; } $channel = \App::get_channel(); $r = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1", dbesc($channel['channel_hash']), dbesc(\App::$data['target'])); if ($r) { \App::$data['xlink'] = $r[0]; $rating_val = $r[0]['xlink_rating']; $rating_text = $r[0]['xlink_rating_text']; } else { $rating_val = 0; $rating_text = ''; } if ($rating_enabled) { $rating = replace_macros(get_markup_template('rating_slider.tpl'), array('$min' => -10, '$val' => $rating_val)); } else { $rating = false; } $o = replace_macros(get_markup_template('rating_form.tpl'), array('$header' => t('Rating'), '$website' => t('Website:'), '$site' => \App::$data['site'] ? '<a href="' . \App::$data['site']['site_url'] . '" >' . \App::$data['site']['site_url'] . '</a>' : '', 'target' => \App::$data['target'], '$tgt_name' => \App::$poi && \App::$poi['xchan_name'] ? \App::$poi['xchan_name'] : sprintf(t('Remote Channel [%s] (not yet known on this site)'), substr(\App::$data['target'], 0, 16)), '$lbl_rating' => t('Rating (this information is public)'), '$lbl_rating_txt' => t('Optionally explain your rating (this information is public)'), '$rating_txt' => $rating_text, '$rating' => $rating, '$rating_val' => $rating_val, '$slide' => $slide, '$submit' => t('Submit'))); return $o; }