diff options
author | Christian Vogeley <christian.vogeley@hotmail.de> | 2014-03-09 04:15:11 +0100 |
---|---|---|
committer | Christian Vogeley <christian.vogeley@hotmail.de> | 2014-03-09 04:15:11 +0100 |
commit | 76ab9403af3b562531a7eb0831e5a7ecc9aedb38 (patch) | |
tree | c4d74f0cc8aac0fcd5a52520170a64c8d4b01395 /mod | |
parent | e8e980c8175be6dae7d642d9707493c465b7137b (diff) | |
parent | 80e381176e1e301782bc56cbb7c6037825eddf2d (diff) | |
download | volse-hubzilla-76ab9403af3b562531a7eb0831e5a7ecc9aedb38.tar.gz volse-hubzilla-76ab9403af3b562531a7eb0831e5a7ecc9aedb38.tar.bz2 volse-hubzilla-76ab9403af3b562531a7eb0831e5a7ecc9aedb38.zip |
merge
Diffstat (limited to 'mod')
-rw-r--r-- | mod/block.php | 86 | ||||
-rw-r--r-- | mod/blocks.php | 2 | ||||
-rw-r--r-- | mod/bookmarks.php | 4 | ||||
-rw-r--r-- | mod/chat.php | 16 | ||||
-rw-r--r-- | mod/chatsvc.php | 4 | ||||
-rw-r--r-- | mod/connections.php | 50 | ||||
-rw-r--r-- | mod/connedit.php | 6 | ||||
-rw-r--r-- | mod/directory.php | 8 | ||||
-rw-r--r-- | mod/dirsearch.php | 126 | ||||
-rw-r--r-- | mod/editblock.php | 91 | ||||
-rw-r--r-- | mod/follow.php | 2 | ||||
-rw-r--r-- | mod/help.php | 9 | ||||
-rw-r--r-- | mod/item.php | 2 | ||||
-rw-r--r-- | mod/lang.php | 6 | ||||
-rw-r--r-- | mod/layouts.php | 114 | ||||
-rw-r--r-- | mod/openid.php | 3 | ||||
-rw-r--r-- | mod/pdledit.php | 62 | ||||
-rw-r--r-- | mod/ping.php | 2 | ||||
-rw-r--r-- | mod/poco.php | 11 | ||||
-rw-r--r-- | mod/post.php | 1 | ||||
-rw-r--r-- | mod/rbmark.php | 113 | ||||
-rw-r--r-- | mod/rpost.php | 2 | ||||
-rw-r--r-- | mod/settings.php | 2 | ||||
-rwxr-xr-x | mod/setup.php | 3 | ||||
-rw-r--r-- | mod/siteinfo.php | 18 | ||||
-rw-r--r-- | mod/wfinger.php | 2 | ||||
-rw-r--r-- | mod/zfinger.php | 15 |
27 files changed, 585 insertions, 175 deletions
diff --git a/mod/block.php b/mod/block.php new file mode 100644 index 000000000..043b0e9e8 --- /dev/null +++ b/mod/block.php @@ -0,0 +1,86 @@ +<?php + +require_once('include/items.php'); +require_once('include/conversation.php'); +require_once('include/page_widgets.php'); + +function block_init(&$a) { + + $which = argv(1); + $profile = 0; + profile_load($a,$which,$profile); + + if($a->profile['profile_uid']) + head_set_icon($a->profile['thumb']); + +} + + +function block_content(&$a) { + + if(! perm_is_allowed($a->profile['profile_uid'],get_observer_hash(),'view_pages')) { + notice( t('Permission denied.') . EOL); + return; + } + + if(argc() < 3) { + notice( t('Invalid item.') . EOL); + return; + } + + $channel_address = argv(1); + $page_id = argv(2); + + $u = q("select channel_id from channel where channel_address = '%s' limit 1", + dbesc($channel_address) + ); + + if(! $u) { + notice( t('Channel not found.') . EOL); + return; + } + + if($_REQUEST['rev']) + $revision = " and revision = " . intval($_REQUEST['rev']) . " "; + else + $revision = " order by revision desc "; + + require_once('include/security.php'); + $sql_options = item_permissions_sql($u[0]['channel_id']); + + $r = q("select item.* from item left join item_id on item.id = item_id.iid + where item.uid = %d and sid = '%s' and service = 'BUILDBLOCK' and + item_restrict = %d $sql_options $revision limit 1", + intval($u[0]['channel_id']), + dbesc($page_id), + intval(ITEM_BUILDBLOCK) + ); + + if(! $r) { + + // Check again with no permissions clause to see if it is a permissions issue + + $x = q("select item.* from item left join item_id on item.id = item_id.iid + where item.uid = %d and sid = '%s' and service = 'BUILDBLOCK' and + item_restrict = %d $revision limit 1", + intval($u[0]['channel_id']), + dbesc($page_id), + intval(ITEM_BUILDBLOCK) + ); + if($x) { + // Yes, it's there. You just aren't allowed to see it. + notice( t('Permission denied.') . EOL); + } + else { + notice( t('Page not found.') . EOL); + } + return; + } + + xchan_query($r); + $r = fetch_post_tags($r,true); + + $o .= prepare_page($r[0]); + return $o; + +} diff --git a/mod/blocks.php b/mod/blocks.php index 9a4e0b1ca..81337448c 100644 --- a/mod/blocks.php +++ b/mod/blocks.php @@ -88,7 +88,7 @@ $r = q("select * from item_id where uid = %d and service = 'BUILDBLOCK' order by //Build the base URL for edit links $url = z_root() . "/editblock/" . $which; // This isn't pretty, but it works. Until I figure out what to do with the UI, it's Good Enough(TM). - return $o . replace_macros(get_markup_template("webpagelist.tpl"), array( + return $o . replace_macros(get_markup_template("blocklist.tpl"), array( '$baseurl' => $url, '$edit' => t('Edit'), '$pages' => $pages, diff --git a/mod/bookmarks.php b/mod/bookmarks.php index c5be68b8e..141ae2e0b 100644 --- a/mod/bookmarks.php +++ b/mod/bookmarks.php @@ -57,7 +57,7 @@ function bookmarks_content(&$a) { if($x) { foreach($x as $xx) { $y = menu_fetch($xx['menu_name'],local_user(),get_observer_hash()); - $o .= menu_render($y,true); + $o .= menu_render($y,'',true); } } @@ -69,7 +69,7 @@ function bookmarks_content(&$a) { if($x) { foreach($x as $xx) { $y = menu_fetch($xx['menu_name'],local_user(),get_observer_hash()); - $o .= menu_render($y,true); + $o .= menu_render($y,'',true); } } diff --git a/mod/chat.php b/mod/chat.php index a960f4f37..0f2b94b9d 100644 --- a/mod/chat.php +++ b/mod/chat.php @@ -1,6 +1,7 @@ <?php /** @file */ require_once('include/chat.php'); +require_once('include/bookmarks.php'); function chat_init(&$a) { @@ -82,6 +83,7 @@ function chat_content(&$a) { if(local_user()) $channel = $a->get_channel(); + $ob = $a->get_observer(); $observer = get_observer_hash(); if(! $observer) { notice( t('Permission denied.') . EOL); @@ -144,6 +146,8 @@ function chat_content(&$a) { if(argc() > 2 && intval(argv(2))) { $room_id = intval(argv(2)); + $bookmark_link = get_bookmark_link($ob); + $x = chatroom_enter($observer,$room_id,'online',$_SERVER['REMOTE_ADDR']); if(! $x) return; @@ -152,8 +156,16 @@ function chat_content(&$a) { intval($a->profile['profile_uid']) ); if($x) { + $private = ((($x[0]['allow_cid']) || ($x[0]['allow_gid']) || ($x[0]['deny_cid']) || ($x[0]['deny_gid'])) ? true : false); $room_name = $x[0]['cr_name']; + if($bookmark_link) + $bookmark_link .= '&url=' . z_root() . '/chat/' . argv(1) . '/' . argv(2) . '&title=' . urlencode($x[0]['cr_name']) . (($private) ? '&private=1' : '') . '&ischat=1'; + } + else { + notice( t('Room not found') . EOL); + return; } + $o = replace_macros(get_markup_template('chat.tpl'),array( '$room_name' => $room_name, '$room_id' => $room_id, @@ -162,7 +174,9 @@ function chat_content(&$a) { '$submit' => t('Submit'), '$leave' => t('Leave Room'), '$away' => t('I am away right now'), - '$online' => t('I am online') + '$online' => t('I am online'), + '$bookmark_link' => $bookmark_link, + '$bookmark' => t('Bookmark this room') )); return $o; diff --git a/mod/chatsvc.php b/mod/chatsvc.php index e6590f57a..9cc8778f5 100644 --- a/mod/chatsvc.php +++ b/mod/chatsvc.php @@ -113,7 +113,7 @@ function chatsvc_content(&$a) { $chats = array(); - $r = q("select * from chat left join xchan on chat_xchan = xchan_hash where chat_room = %d and chat_id > %d", + $r = q("select * from chat left join xchan on chat_xchan = xchan_hash where chat_room = %d and chat_id > %d order by created", intval($a->data['chat']['room_id']), intval($lastseen) ); @@ -147,4 +147,4 @@ function chatsvc_content(&$a) { json_return_and_die($ret); } -
\ No newline at end of file + diff --git a/mod/connections.php b/mod/connections.php index e36cb5fc7..dbdcbdc93 100644 --- a/mod/connections.php +++ b/mod/connections.php @@ -35,7 +35,7 @@ function connections_post(&$a) { if(! $orig_record) { notice( t('Could not access contact record.') . EOL); - goaway($a->get_baseurl(true) . '/connections'); + goaway(z_root() . '/connections'); return; // NOTREACHED } @@ -170,14 +170,14 @@ function connections_content(&$a) { return login(); } - $blocked = false; - $hidden = false; - $ignored = false; - $archived = false; - $unblocked = false; - $pending = false; - - $all = false; + $blocked = false; + $hidden = false; + $ignored = false; + $archived = false; + $unblocked = false; + $pending = false; + $unconnected = false; + $all = false; $_SESSION['return_url'] = $a->query_string; @@ -212,6 +212,11 @@ function connections_content(&$a) { $pending = true; nav_set_selected('intros'); break; + case 'unconnected': + $search_flags = ABOOK_FLAG_UNCONNECTED; + $head = t('Unconnected'); + $unconnected = true; + break; case 'all': $head = t('All'); @@ -223,7 +228,8 @@ function connections_content(&$a) { } $sql_extra = (($search_flags) ? " and ( abook_flags & " . $search_flags . " ) " : ""); - + if(argv(1) === 'pending') + $sql_extra .= " and not ( abook_flags & " . ABOOK_FLAG_IGNORED . " ) "; } else { @@ -236,57 +242,65 @@ function connections_content(&$a) { $tabs = array( array( 'label' => t('Suggestions'), - 'url' => $a->get_baseurl(true) . '/suggest', + 'url' => z_root() . '/suggest', 'sel' => '', 'title' => t('Suggest new connections'), ), array( 'label' => t('New Connections'), - 'url' => $a->get_baseurl(true) . '/connections/pending', + 'url' => z_root() . '/connections/pending', 'sel' => ($pending) ? 'active' : '', 'title' => t('Show pending (new) connections'), ), array( 'label' => t('All Connections'), - 'url' => $a->get_baseurl(true) . '/connections/all', + 'url' => z_root() . '/connections/all', 'sel' => ($all) ? 'active' : '', 'title' => t('Show all connections'), ), array( 'label' => t('Unblocked'), - 'url' => $a->get_baseurl(true) . '/connections', + 'url' => z_root() . '/connections', 'sel' => (($unblocked) && (! $search) && (! $nets)) ? 'active' : '', 'title' => t('Only show unblocked connections'), ), array( 'label' => t('Blocked'), - 'url' => $a->get_baseurl(true) . '/connections/blocked', + 'url' => z_root() . '/connections/blocked', 'sel' => ($blocked) ? 'active' : '', 'title' => t('Only show blocked connections'), ), array( 'label' => t('Ignored'), - 'url' => $a->get_baseurl(true) . '/connections/ignored', + 'url' => z_root() . '/connections/ignored', 'sel' => ($ignored) ? 'active' : '', 'title' => t('Only show ignored connections'), ), array( 'label' => t('Archived'), - 'url' => $a->get_baseurl(true) . '/connections/archived', + 'url' => z_root() . '/connections/archived', 'sel' => ($archived) ? 'active' : '', 'title' => t('Only show archived connections'), ), array( 'label' => t('Hidden'), - 'url' => $a->get_baseurl(true) . '/connections/hidden', + 'url' => z_root() . '/connections/hidden', 'sel' => ($hidden) ? 'active' : '', 'title' => t('Only show hidden connections'), ), + array( + 'label' => t('Unconnected'), + 'url' => z_root() . '/connections/unconnected', + 'sel' => ($unconnected) ? 'active' : '', + 'title' => t('Only show one-way connections'), + ), + + ); $tab_tpl = get_markup_template('common_tabs.tpl'); diff --git a/mod/connedit.php b/mod/connedit.php index c6f64ccfc..b9b7fcce3 100644 --- a/mod/connedit.php +++ b/mod/connedit.php @@ -177,7 +177,13 @@ function connedit_content(&$a) { $sort_type = 0; $o = ''; + // this triggers some javascript to set Full Sharing by default after + // completing a "follow" - which can be changed to something else before + // form submission, but this gives us something useable + if($_GET['follow'] == 1) { + $o .= '<script>var after_following = 1;</script>'; + } if(! local_user()) { notice( t('Permission denied.') . EOL); return login(); diff --git a/mod/directory.php b/mod/directory.php index 8fc62e95b..6e0e2e7dc 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -42,12 +42,13 @@ function directory_content(&$a) { else $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : ''); + $advanced = ((x($_REQUEST,'query')) ? notags(trim($_REQUEST['query'])) : ''); + $keywords = (($_GET['keywords']) ? $_GET['keywords'] : ''); $tpl = get_markup_template('directory_header.tpl'); - $dirmode = intval(get_config('system','directory_mode')); if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) { @@ -81,6 +82,7 @@ function directory_content(&$a) { if($url) { // We might want to make the tagadelic count (&kw=) configurable or turn it off completely. + $numtags = get_config('system','directorytags'); $kw = ((intval($numtags)) ? $numtags : 24); @@ -92,7 +94,9 @@ function directory_content(&$a) { $query .= '&address=' . urlencode($search); if($keywords) $query .= '&keywords=' . urlencode($keywords); - + if($advanced) + $query .= '&query=' . urlencode($advanced); + $sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : ''); if($sort_order) $query .= '&order=' . urlencode($sort_order); diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 59a1d448d..1f2ec1108 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -27,6 +27,27 @@ function dirsearch_content(&$a) { json_return_and_die($ret); } + $sql_extra = ''; + + $tables = array('name','address','locale','region','postcode','country','gender','marital','sexual','keywords'); + + + if($_REQUEST['query']) { + $advanced = dir_parse_query($_REQUEST['query']); + if($advanced) { + foreach($advanced as $adv) { + if(in_array($adv['field'],$tables)) { + if($adv['field'] === 'name') + $sql_extra .= dir_query_build($adv['logic'],'xchan_name',$adv['value']); + elseif($adv['field'] === 'address') + $sql_extra .= dir_query_build($adv['logic'],'xchan_addr',$adv['value']); + else + $sql_extra .= dir_query_build($adv['logic'],'xprof_' . $adv['field'],$adv['value']); + } + } + } + } + $hash = ((x($_REQUEST['hash'])) ? $_REQUEST['hash'] : ''); $name = ((x($_REQUEST,'name')) ? $_REQUEST['name'] : ''); @@ -38,6 +59,7 @@ function dirsearch_content(&$a) { $country = ((x($_REQUEST,'country')) ? $_REQUEST['country'] : ''); $gender = ((x($_REQUEST,'gender')) ? $_REQUEST['gender'] : ''); $marital = ((x($_REQUEST,'marital')) ? $_REQUEST['marital'] : ''); + $sexual = ((x($_REQUEST,'sexual')) ? $_REQUEST['sexual'] : ''); $keywords = ((x($_REQUEST,'keywords')) ? $_REQUEST['keywords'] : ''); $agege = ((x($_REQUEST,'agege')) ? intval($_REQUEST['agege']) : 0 ); $agele = ((x($_REQUEST,'agele')) ? intval($_REQUEST['agele']) : 0 ); @@ -59,36 +81,38 @@ function dirsearch_content(&$a) { $sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : ''); -// TODO - a meta search which joins all of these things to one search string - - $sql_extra = ''; + $joiner = ' OR '; + if($_REQUEST['and']) + $joiner = ' AND '; if($name) - $sql_extra .= " OR xchan_name like '" . protect_sprintf( '%' . dbesc($name) . '%' ) . "' "; + $sql_extra .= dir_query_build($joiner,'xchan_name',$name); if($hub) - $sql_extra .= " OR xchan_hash in (select hubloc_hash from hubloc where hubloc_host = '" . protect_sprintf(dbesc($hub)) . "') "; + $sql_extra .= " $joiner xchan_hash in (select hubloc_hash from hubloc where hubloc_host = '" . protect_sprintf(dbesc($hub)) . "') "; if($address) - $sql_extra .= " OR xchan_addr like '" . protect_sprintf( '%' . dbesc($address) . '%' ) . "' "; + $sql_extra .= dir_query_build($joiner,'xchan_addr',$address); if($city) - $sql_extra .= " OR xprof_locale like '" . protect_sprintf( '%' . dbesc($city) . '%' ) . "' "; + $sql_extra .= dir_query_build($joiner,'xprof_locale',$city); if($region) - $sql_extra .= " OR xprof_region like '" . protect_sprintf( '%' . dbesc($region) . '%' ) . "' "; + $sql_extra .= dir_query_build($joiner,'xprof_region',$region); if($post) - $sql_extra .= " OR xprof_postcode like '" . protect_sprintf( '%' . dbesc($post) . '%' ) . "' "; + $sql_extra .= dir_query_build($joiner,'xprof_postcode',$post); if($country) - $sql_extra .= " OR xprof_country like '" . protect_sprintf( '%' . dbesc($country) . '%' ) . "' "; + $sql_extra .= dir_query_build($joiner,'xprof_country',$country); if($gender) - $sql_extra .= " OR xprof_gender like '" . protect_sprintf( '%' . dbesc($gender) . '%' ) . "' "; + $sql_extra .= dir_query_build($joiner,'xprof_gender',$gender); if($marital) - $sql_extra .= " OR xprof_marital like '" . protect_sprintf( '%' . dbesc($marital) . '%' ) . "' "; + $sql_extra .= dir_query_build($joiner,'xprof_marital',$marital); + if($sexual) + $sql_extra .= dir_query_build($joiner,'xprof_sexual',$sexual); if($keywords) - $sql_extra .= " OR xprof_keywords like '" . protect_sprintf( '%' . dbesc($keywords) . '%' ) . "' "; + $sql_extra .= dir_query_build($joiner,'xprof_keywords',$keywords); // we only support an age range currently. You must set both agege // (greater than or equal) and agele (less than or equal) if($agele && $agege) { - $sql_extra .= " OR ( xprof_age <= " . intval($agele) . " "; + $sql_extra .= " $joiner ( xprof_age <= " . intval($agele) . " "; $sql_extra .= " AND xprof_age >= " . intval($agege) . ") "; } @@ -98,8 +122,7 @@ function dirsearch_content(&$a) { } - - $perpage = (($_REQUEST['n']) ? $_REQUEST['n'] : 80); + $perpage = (($_REQUEST['n']) ? $_REQUEST['n'] : 300); $page = (($_REQUEST['p']) ? intval($_REQUEST['p'] - 1) : 0); $startrec = (($page+1) * $perpage) - $perpage; $limit = (($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 0); @@ -159,7 +182,12 @@ function dirsearch_content(&$a) { ); if($r) { foreach($r as $rr) { - $flags = (($rr['ud_flags'] & UPDATE_FLAGS_DELETED) ? array('deleted') : array()); + $flags = array(); + if($rr['ud_flags'] & UPDATE_FLAGS_DELETED) + $flags[] = 'deleted'; + if($rr['ud_flags'] & UPDATE_FLAGS_FORCED) + $flags[] = 'forced'; + $spkt['transactions'][] = array( 'hash' => $rr['ud_hash'], 'address' => $rr['ud_addr'], @@ -231,6 +259,70 @@ function dirsearch_content(&$a) { } +function dir_query_build($joiner,$field,$s) { + $ret = ''; + if(trim($s)) + $ret .= dbesc($joiner) . " " . dbesc($field) . " like '" . protect_sprintf( '%' . dbesc($s) . '%' ) . "' "; + return $ret; +} + +function dir_parse_query($s) { + + $ret = array(); + $curr = array(); + $all = explode(' ',$s); + $quoted_string = false; + + if($all) { + foreach($all as $q) { + if($q === 'and') { + $curr['logic'] = 'and'; + continue; + } + if($q === 'or') { + $curr['logic'] = 'or'; + continue; + } + if($q === 'not') { + $curr['logic'] .= ' not'; + continue; + } + if(strpos($q,'=')) { + if(! isset($curr['logic'])) + $curr['logic'] = 'or'; + $curr['field'] = trim(substr($q,0,strpos($q,'='))); + $curr['value'] = trim(substr($q,strpos($q,'=')+1)); + if(strpos($curr['value'],'"') !== false) { + $quoted_string = true; + $curr['value'] = substr($curr['value'],strpos($curr['value'],'"')+1); + } + else { + $ret[] = $curr; + $curr = array(); + $continue; + } + } + elseif($quoted_string) { + if(strpos($q,'"') !== false) { + $curr['value'] .= ' ' . str_replace('"','',trim($q)); + $ret[] = $curr; + $curr = array(); + $quoted_string = false; + } + else + $curr['value'] .= ' ' . trim(q); + } + } + } + logger('dir_parse_query:' . print_r($ret,true),LOGGER_DATA); + return $ret; +} + + + + + + function list_public_sites() { $r = q("select * from site where site_access != 0 and site_register !=0 order by rand()"); diff --git a/mod/editblock.php b/mod/editblock.php index dcb4b42a7..8ccccc24b 100644 --- a/mod/editblock.php +++ b/mod/editblock.php @@ -1,74 +1,68 @@ <?php -// What is this here for? I think it's cruft, but comment out for now in case it's here for a reason -// require_once('acl_selectors.php'); function editblock_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(argc() < 2) { + notice( t('Item not found') . EOL); + return; + } + $channel = get_channel_by_nick(argv(1)); - - - if((local_user()) && (argc() > 2) && (argv(2) === 'view')) { - $which = $channel['channel_address']; - } + if($c) { + $owner = intval($channel['channel_id']); + } $o = ''; -// Figure out which post we're editing + // Figure out which post we're editing $post_id = ((argc() > 2) ? intval(argv(2)) : 0); - if(! $post_id) { + if(! ($post_id && $channel)) { 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'] : ''); + // Now we've got a post and an owner, let's find out if we're allowed to edit it - $perms = get_all_perms($owner,$ob_hash); - - if(! $perms['write_pages']) { - notice( t('Permission denied.') . EOL); - return; - } + if(! perm_is_allowed($channel['channel_id'],get_observer_hash(),'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 = 'BUILDBLOCK' and iid = %d limit 1", - $itm[0]['id'] + // 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($channel['channel_id']) ); - if($item_id) - $block_title = $item_id[0]['sid']; + if($itm) { + $item_id = q("select * from item_id where service = 'BUILDBLOCK' and iid = %d limit 1", + $itm[0]['id'] + ); + if($item_id) + $block_title = $item_id[0]['sid']; + } + else { + notice( t('Item not found') . EOL); + return; + } $plaintext = true; -// You may or may not be a local user. This won't work, - if(feature_enabled(local_user(),'richtext')) + + // You may or may not be a local user. + if(local_user() && feature_enabled(local_user(),'richtext')) $plaintext = false; $mimeselect = ''; + $mimetype = $itm[0]['mimetype']; if($mimetype != 'text/bbcode') $plaintext = true; @@ -79,9 +73,6 @@ function editblock_content(&$a) { $mimeselect = mimetype_select($itm[0]['uid'],$mimetype); - - - $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( '$title' => t('Edit Block') )); @@ -91,8 +82,8 @@ function editblock_content(&$a) { '$baseurl' => $a->get_baseurl(), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$ispublic' => ' ', // t('Visible to <strong>everybody</strong>'), - '$geotag' => $geotag, - '$nickname' => $a->user['nickname'], + '$geotag' => '', + '$nickname' => $channel['channel_address'], '$confirmdelete' => t('Delete block?') )); @@ -105,13 +96,13 @@ function editblock_content(&$a) { 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. + // 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 = '/blocks/' . $which; + $rp = 'blocks/' . $channel['channel_address']; $o .= replace_macros($tpl,array( '$return_path' => $rp, @@ -147,10 +138,10 @@ function editblock_content(&$a) { '$lockstate' => $lockstate, '$acl' => '', '$bang' => '', - '$profile_uid' => (intval($owner)), + '$profile_uid' => (intval($channel['channel_id'])), '$preview' => ((feature_enabled(local_user(),'preview')) ? t('Preview') : ''), '$jotplugins' => $jotplugins, - '$sourceapp' => t($a->sourcename), + '$sourceapp' => $itm[0]['app'], '$defexpire' => '', '$feature_expire' => 'none', '$expires' => t('Set expiration date'), diff --git a/mod/follow.php b/mod/follow.php index 962bb71a7..663fb7536 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -30,7 +30,7 @@ function follow_init(&$a) { proc_run('php','include/onepoll.php',$result['abook']['abook_id']); - goaway(z_root() . '/connedit/' . $result['abook']['abook_id']); + goaway(z_root() . '/connedit/' . $result['abook']['abook_id'] . '?f=&follow=1'); } diff --git a/mod/help.php b/mod/help.php index a4ccd1cfe..aa0ee8ae6 100644 --- a/mod/help.php +++ b/mod/help.php @@ -40,19 +40,19 @@ function help_content(&$a) { if(argc() > 1) { $text = load_doc_file('doc/' . $a->argv[1] . '.md'); - $a->page['title'] = t('Help:') . ' ' . str_replace('-',' ',notags(argv(1))); + $a->page['title'] = t('Help:') . ' ' . ucwords(str_replace('-',' ',notags(argv(1)))); } if(! $text) { $text = load_doc_file('doc/' . $a->argv[1] . '.bb'); if($text) $doctype = 'bbcode'; - $a->page['title'] = t('Help:') . ' ' . str_replace('-',' ',notags(argv(1))); + $a->page['title'] = t('Help:') . ' ' . ucwords(str_replace('_',' ',notags(argv(1)))); } if(! $text) { $text = load_doc_file('doc/' . $a->argv[1] . '.html'); if($text) $doctype = 'html'; - $a->page['title'] = t('Help:') . ' ' . str_replace('-',' ',notags(argv(1))); + $a->page['title'] = t('Help:') . ' ' . ucwords(str_replace('-',' ',notags(argv(1)))); } if(! $text) { @@ -60,7 +60,8 @@ function help_content(&$a) { $a->page['title'] = t('Help'); } if(! $text) { - $text = load_doc_file('doc/Home.md'); + $doctype = 'bbcode'; + $text = load_doc_file('doc/main.bb'); $a->page['title'] = t('Help'); } diff --git a/mod/item.php b/mod/item.php index 2feb64a37..6ea434542 100644 --- a/mod/item.php +++ b/mod/item.php @@ -862,7 +862,7 @@ function item_post(&$a) { // figure out how to return, depending on from whence we came if($api_source) - return; + return $post; if($return_path) { goaway($a->get_baseurl() . "/" . $return_path); diff --git a/mod/lang.php b/mod/lang.php new file mode 100644 index 000000000..fba5f9c73 --- /dev/null +++ b/mod/lang.php @@ -0,0 +1,6 @@ +<?php + +function lang_content(&$a) { + return lang_selector(); +} + diff --git a/mod/layouts.php b/mod/layouts.php index 9ed349850..0dcaba361 100644 --- a/mod/layouts.php +++ b/mod/layouts.php @@ -28,84 +28,94 @@ function layouts_content(&$a) { return; } + // Get the observer, check their permissions + $observer = $a->get_observer(); + $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); + $perms = get_all_perms($owner,$ob_hash); -// Get the observer, check their permissions + if(! $perms['write_pages']) { + notice( t('Permission denied.') . EOL); + return; + } - $observer = $a->get_observer(); - $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); + if((argc() > 3) && (argv(2) === 'share') && (argv(3))) { + $r = q("select sid, service, mimetype, title, body from item_id left join item on item.id = item_id.iid where item_id.uid = %d and item.mid = '%s' and service = 'PDL' order by sid asc", + intval($owner), + dbesc(argv(3)) + ); + if($r) { + header('Content-type: application/x-redmatrix-layout'); + header('Content-disposition: attachment; filename="' . $r[0]['sid'] . '.pdl"'); + echo json_encode($r); + killme(); - $perms = get_all_perms($owner,$ob_hash); + } + } - if(! $perms['write_pages']) { - notice( t('Permission denied.') . EOL); - return; - } + $tabs = array( + array( + 'label' => t('Layout Help'), + 'url' => 'help/Comanche', + 'sel' => '', + 'title' => t('Help with this feature'), + 'id' => 'layout-help-tab', + )); -// if(local_user() && local_user() == $owner) { - // $a->set_widget('design',design_tools()); - // } - $tabs = array( - array( - 'label' => t('Layout Help'), - 'url' => 'help/Comanche', - 'sel' => '', - 'title' => t('Help with this feature'), - 'id' => 'layout-help-tab', - )); + $o .= replace_macros(get_markup_template('common_tabs.tpl'),array('$tabs' => $tabs)); - $o .= replace_macros(get_markup_template('common_tabs.tpl'),array('$tabs' => $tabs)); + // Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages + // Nickname is set to the observers xchan, and profile_uid to the owners. This lets you post pages at other people's channels. + require_once ('include/conversation.php'); -// Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages -// Nickname is set to the observers xchan, and profile_uid to the owners. This lets you post pages at other people's channels. -require_once ('include/conversation.php'); - $x = array( - 'webpage' => ITEM_PDL, - 'is_owner' => true, - 'nickname' => $a->profile['channel_address'], - 'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), - 'bang' => (($group || $cid) ? '!' : ''), - 'visitor' => 'none', - 'nopreview' => 1, - 'ptlabel' => t('Layout Name'), - 'profile_uid' => intval($owner), - ); + $x = array( + 'webpage' => ITEM_PDL, + 'is_owner' => true, + 'nickname' => $a->profile['channel_address'], + 'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), + 'bang' => (($group || $cid) ? '!' : ''), + 'visitor' => 'none', + 'nopreview' => 1, + 'ptlabel' => t('Layout Name'), + 'profile_uid' => intval($owner), + ); - $o .= status_editor($a,$x); + $o .= status_editor($a,$x); - //Get a list of blocks. We can't display all them because endless scroll makes that unusable, so just list titles and an edit link. -//TODO - this should be replaced with pagelist_widget + // Get a list of blocks. We can't display all them because endless scroll makes that unusable, so just list titles and an edit link. + // TODO - this should be replaced with pagelist_widget -$r = q("select * from item_id where uid = %d and service = 'PDL' order by sid asc", - intval($owner) -); + $r = q("select iid, sid, mid from item_id left join item on item.id = item_id.iid where item_id.uid = %d and service = 'PDL' order by sid asc", + intval($owner) + ); - $pages = null; + $pages = null; + + if($r) { + $pages = array(); + foreach($r as $rr) { + $pages[$rr['iid']][] = array('url' => $rr['iid'],'title' => $rr['sid'], 'mid' => $rr['mid']); + } + } - if($r) { - $pages = array(); - foreach($r as $rr) { - $pages[$rr['iid']][] = array('url' => $rr['iid'],'title' => $rr['sid']); - } - } + //Build the base URL for edit links + $url = z_root() . "/editlayout/" . $which; -//Build the base URL for edit links - $url = z_root() . "/editlayout/" . $which; -// This isn't pretty, but it works. Until I figure out what to do with the UI, it's Good Enough(TM). - return $o . replace_macros(get_markup_template("webpagelist.tpl"), array( + return $o . replace_macros(get_markup_template("layoutlist.tpl"), array( '$baseurl' => $url, '$edit' => t('Edit'), + '$share' => t('Share'), '$pages' => $pages, '$channel' => $which, '$view' => t('View'), '$preview' => '1', - )); + )); } diff --git a/mod/openid.php b/mod/openid.php index 1ab8749ee..2112e0af4 100644 --- a/mod/openid.php +++ b/mod/openid.php @@ -42,6 +42,7 @@ function openid_content(&$a) { if(($record['account_flags'] == ACCOUNT_OK) || ($record['account_flags'] == ACCOUNT_UNVERIFIED)) { logger('mod_openid: openid success for ' . $x[0]['channel_name']); $_SESSION['uid'] = $r[0]['channel_id']; + $_SESSION['account_id'] = $r[0]['channel_account_id']; $_SESSION['authenticated'] = true; authenticate_success($record,true,true,true,true); goaway(z_root()); @@ -61,6 +62,7 @@ function openid_content(&$a) { if($r) { $_SESSION['authenticated'] = 1; $_SESSION['visitor_id'] = $r[0]['xchan_hash']; + $_SESSION['my_url'] = $r[0]['xchan_url']; $_SESSION['my_address'] = $r[0]['xchan_addr']; $arr = array('xchan' => $r[0], 'session' => $_SESSION); call_hooks('magic_auth_openid_success',$arr); @@ -168,6 +170,7 @@ function openid_content(&$a) { set_xconfig($url,'system','openid',$authid); $_SESSION['authenticated'] = 1; $_SESSION['visitor_id'] = $r[0]['xchan_hash']; + $_SESSION['my_url'] = $r[0]['xchan_url']; $_SESSION['my_address'] = $r[0]['xchan_addr']; $arr = array('xchan' => $r[0], 'session' => $_SESSION); call_hooks('magic_auth_openid_success',$arr); diff --git a/mod/pdledit.php b/mod/pdledit.php new file mode 100644 index 000000000..36b9a0c14 --- /dev/null +++ b/mod/pdledit.php @@ -0,0 +1,62 @@ +<?php + +function pdledit_post(&$a) { + if(! local_user()) + return; + if(! $_REQUEST['module']) + return; + if(! trim($_REQUEST['content'])) { + del_pconfig(local_user(),'system','mod_' . $_REQUEST['module'] . '.pdl'); + goaway(z_root() . '/pdledit/' . $_REQUEST['module']); + } + set_pconfig(local_user(),'system','mod_' . $_REQUEST['module'] . '.pdl',escape_tags($_REQUEST['content'])); + info( t('Layout updated.') . EOL); + goaway(z_root() . '/pdledit/' . $_REQUEST['module']); +} + + +function pdledit_content(&$a) { + + if(! local_user()) { + 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_user(),'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; +} diff --git a/mod/ping.php b/mod/ping.php index 390613d7a..b9d9a9c77 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -28,7 +28,7 @@ function ping_init(&$a) { header("content-type: application/json"); - $result['invalid'] = ((local_user()) && (intval($_GET['uid'])) && (intval($_GET['uid']) != local_user()) ? 1 : 0); + $result['invalid'] = ((intval($_GET['uid'])) && (intval($_GET['uid']) != local_user()) ? 1 : 0); if(x($_SESSION,'sysmsg')){ foreach ($_SESSION['sysmsg'] as $m){ diff --git a/mod/poco.php b/mod/poco.php index a5808b7db..9295f13de 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -76,6 +76,9 @@ function poco_init(&$a) { $sql_extra ", intval($channel_id) ); + $c = q("select * from menu_item where ( mitem_flags & " . intval(MENU_ITEM_CHATROOM) . " ) and allow_cid = '' and allow_gid = '' and deny_cid = '' and deny_gid = '' and mitem_channel_id = %d", + intval($channel_id) + ); } if($r) $totalResults = intval($r[0]['total']); @@ -115,6 +118,14 @@ function poco_init(&$a) { $ret['startIndex'] = (string) $startIndex; $ret['itemsPerPage'] = (string) $itemsPerPage; $ret['totalResults'] = (string) $totalResults; + + if($c) { + $ret['chatrooms'] = array(); + foreach($c as $d) { + $ret['chatrooms'][] = array('url' => $d['mitem_link'], 'desc' => $d['mitem_desc']); + } + } + $ret['entry'] = array(); diff --git a/mod/post.php b/mod/post.php index 6c57bfa0d..54d0d8db9 100644 --- a/mod/post.php +++ b/mod/post.php @@ -243,6 +243,7 @@ function post_init(&$a) { $_SESSION['authenticated'] = 1; $_SESSION['visitor_id'] = $x[0]['xchan_hash']; + $_SESSION['my_url'] = $x[0]['xchan_url']; $_SESSION['my_address'] = $address; $_SESSION['remote_service_class'] = $remote_service_class; $_SESSION['remote_level'] = $remote_level; diff --git a/mod/rbmark.php b/mod/rbmark.php new file mode 100644 index 000000000..e35c2494a --- /dev/null +++ b/mod/rbmark.php @@ -0,0 +1,113 @@ +<?php /** @file */ + +require_once('acl_selectors.php'); +require_once('include/crypto.php'); +require_once('include/items.php'); +require_once('include/taxonomy.php'); +require_once('include/conversation.php'); +require_once('include/zot.php'); +require_once('include/bookmarks.php'); + +/** + * remote bookmark + * + * https://yoursite/rbmark?f=&title=&url=&private=&remote_return= + * + * This can be called via either GET or POST, use POST for long body content as suhosin often limits GET parameter length + * + * f= placeholder, often required + * title= link text + * url= URL to bookmark + * ischat=1 if this bookmark is a chatroom + * private= Don't share this link + * remote_return= absolute URL to return after posting is finished + * + */ + +function rbmark_post(&$a) { + if($_POST['submit'] !== t('Save')) + return; + + logger('rbmark_post: ' . print_r($_REQUEST,true)); + + $channel = $a->get_channel(); + + $t = array('url' => escape_tags($_REQUEST['url']),'term' => escape_tags($_REQUEST['title'])); + bookmark_add($channel,$channel,$t,((x($_REQUEST,'private')) ? intval($_REQUEST['private']) : 0), + array('menu_id' => ((x($_REQUEST,'menu_id')) ? intval($_REQUEST['menu_id']) : 0), + 'menu_name' => ((x($_REQUEST,'menu_name')) ? escape_tags($_REQUEST['menu_name']) : ''), + 'ischat' => ((x($_REQUEST['ischat'])) ? intval($_REQUEST['ischat']) : 0) + )); + + goaway(z_root() . '/bookmarks'); + +} + + +function rbmark_content(&$a) { + + $o = ''; + + if(! local_user()) { + + // The login procedure is going to bugger our $_REQUEST variables + // so save them in the session. + + if(array_key_exists('url',$_REQUEST)) { + $_SESSION['bookmark'] = $_REQUEST; + } + return login(); + } + + // If we have saved rbmark session variables, but nothing in the current $_REQUEST, recover the saved variables + + if((! array_key_exists('url',$_REQUEST)) && (array_key_exists('bookmark',$_SESSION))) { + $_REQUEST = $_SESSION['bookmark']; + unset($_SESSION['bookmark']); + } + + if($_REQUEST['remote_return']) { + $_SESSION['remote_return'] = $_REQUEST['remote_return']; + } + if(argc() > 1 && argv(1) === 'return') { + if($_SESSION['remote_return']) + goaway($_SESSION['remote_return']); + goaway(z_root() . '/bookmarks'); + } + + $channel = $a->get_channel(); + + $m = menu_list($channel,'',MENU_BOOKMARK); + $menus = array(); + if($m) { + $menus = array(0 => ''); + foreach($m as $n) { + $menus[$n['menu_id']] = $n['menu_name']; + } + } + $menu_select = array('menu_id',t('Select a bookmark folder'),false,'',$menus); + + + $o .= replace_macros(get_markup_template('rbmark.tpl'), array( + + '$header' => t('Save Bookmark'), + '$url' => array('url',t('URL of bookmark'),escape_tags($_REQUEST['url'])), + '$title' => array('title',t('Description'),escape_tags($_REQUEST['title'])), + '$ischat' => ((x($_REQUEST,'ischat')) ? intval($_REQUEST['ischat']) : 0), + '$private' => ((x($_REQUEST,'private')) ? intval($_REQUEST['private']) : 0), + '$submit' => t('Save'), + '$menu_name' => array('menu_name',t('Or enter new bookmark folder name'),'',''), + '$menus' => $menu_select + + )); + + + + + + + return $o; + +} + + diff --git a/mod/rpost.php b/mod/rpost.php index 852a57d78..18d4c86cd 100644 --- a/mod/rpost.php +++ b/mod/rpost.php @@ -33,7 +33,7 @@ function rpost_content(&$a) { if(remote_user()) { // redirect to your own site. // We can only do this with a GET request so you'll need to keep the text short or risk getting truncated - // by the wretched beast called 'shusoin'. All the browsers now allow long GET requests, but suhosin + // by the wretched beast called 'suhosin'. All the browsers now allow long GET requests, but suhosin // blocks them. $url = get_rpost_path($a->get_observer()); diff --git a/mod/settings.php b/mod/settings.php index b88380ff0..1d2a5ecf9 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -439,7 +439,6 @@ function settings_post(&$a) { dbesc($str_group_deny), intval(local_user()) ); - if($r) info( t('Settings updated.') . EOL); @@ -759,6 +758,7 @@ function settings_content(&$a) { '$itemspage' => array('itemspage', t("Maximum number of conversations to load at any time:"), $itemspage, t('Maximum of 100 items')), '$nosmile' => array('nosmile', t("Don't show emoticons"), $nosmile, ''), '$chanview_full' => array('chanview_full', t('Do not view remote profiles in frames'), $chanview, t('By default open in a sub-window of your own site')), + '$layout_editor' => t('System Page Layout Editor - (advanced)'), '$theme_config' => $theme_config, )); diff --git a/mod/setup.php b/mod/setup.php index 14572699e..d12627e84 100755 --- a/mod/setup.php +++ b/mod/setup.php @@ -602,6 +602,9 @@ function what_next() { $a = get_app(); // install the standard theme set_config('system','allowed_themes','redbasic'); + // Create a system channel + require_once ('include/identity.php'); + create_sys_channel(); $baseurl = $a->get_baseurl(); return t('<h1>What next</h1>') diff --git a/mod/siteinfo.php b/mod/siteinfo.php index 7fdb892d2..bdf9b1af6 100644 --- a/mod/siteinfo.php +++ b/mod/siteinfo.php @@ -90,24 +90,6 @@ function siteinfo_content(&$a) { $admininfo = bbcode(get_config('system','admininfo')); - $project_donate = t('Project Donations'); - $donate_text = t('<p>The Red Matrix is provided for you by volunteers working in their spare time. Your support will help us to build a better, freer, and privacy respecting web. Select the following option for a one-time donation of your choosing</p>'); - $alternatively = t('<p>or</p>'); - $recurring = t('Recurring Donation Options'); - - $donate = <<< EOT -<h3>{$project_donate}</h3> -$donate_text -<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_donations" /><input type="hidden" name="business" value="mike@macgirvin.com" /><input type="hidden" name="lc" value="US" /><input type="hidden" name="item_name" value="Distributed Social Network Support Donation" /><input type="hidden" name="no_note" value="0" /><input type="hidden" name="currency_code" value="USD" /><input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHostedGuest" /><input style="border: none;" type="image" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" alt="Donations gladly accepted to support our work" /></form><br /> -<strong>$alternatively</strong> -<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_s-xclick" /><input type="hidden" name="hosted_button_id" value="FHV36KE28CYM8" /><br /> -<table><tbody><tr><td><input type="hidden" name="on0" value="$recurring" />$recurring</td> -</tr><tr><td> -<select name="os0"><option value="Option 1">Option 1 : $3.00USD - monthly</option><option value="Option 2">Option 2 : $5.00USD - monthly</option><option value="Option 3">Option 3 : $10.00USD - monthly</option><option value="Option 4">Option 4 : $20.00USD - monthly</option></select></td> -</tr></tbody></table><p><input type="hidden" name="currency_code" value="USD" /><input type="image" style="border: none;" border="0" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribeCC_LG.gif" alt="PayPal - The safer, easier way to pay online!" /><img src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" alt="" width="1" height="1" border="0" /></p></form> -<p></p> -EOT; - if(file_exists('doc/site_donate.html')) $donate .= file_get_contents('doc/site_donate.html'); diff --git a/mod/wfinger.php b/mod/wfinger.php index 33d2fe478..fb75da193 100644 --- a/mod/wfinger.php +++ b/mod/wfinger.php @@ -80,7 +80,7 @@ function wfinger_init(&$a) { array( 'rel' => 'http://purl.org/zot/protocol', - 'href' => z_root() . '/.well-known/zot-info' . '?zaddr=' . $r[0]['xchan_addr'], + 'href' => z_root() . '/.well-known/zot-info' . '?address=' . $r[0]['xchan_addr'], ) ); diff --git a/mod/zfinger.php b/mod/zfinger.php index 94671271b..4f59c1973 100644 --- a/mod/zfinger.php +++ b/mod/zfinger.php @@ -176,10 +176,21 @@ function zfinger_init(&$a) { $ret['follow_url'] = z_root() . '/follow?f=&url=%s'; - $permissions = get_all_perms($e['channel_id'],(($ztarget && $zsig) + $ztarget_hash = (($ztarget && $zsig) ? base64url_encode(hash('whirlpool',$ztarget . $zsig,true)) - : '' ),false); + : '' ); + $permissions = get_all_perms($e['channel_id'],$ztarget_hash,false); + + if($ztarget_hash) { + $permissions['connected'] = false; + $b = q("select * from abook where abook_xchan = '%s' and abook_channel = %d limit 1", + dbesc($ztarget_hash), + intval($e['channel_id']) + ); + if($b) + $permissions['connected'] = true; + } $ret['permissions'] = (($ztarget && $zkey) ? aes_encapsulate(json_encode($permissions),$zkey) : $permissions); |