' . $desc . '
';
- if(! ( local_channel() && Apps::system_app_installed(local_channel(),'Affinity Tool'))) {
+ if(! ( local_channel() && Apps::system_app_installed(local_channel(),'Friend Zoom'))) {
return $text;
}
@@ -52,7 +52,7 @@ class Affinity extends \Zotlabs\Web\Controller {
// '$field' => array('affinity_cmax', t('Default maximum affinity level'), $cmax, t('0-99 default 99'))
// ));
- if(Apps::system_app_installed(local_channel(),'Affinity Tool')) {
+ if(Apps::system_app_installed(local_channel(),'Friend Zoom')) {
$labels = array(
0 => t('Me'),
@@ -80,7 +80,7 @@ class Affinity extends \Zotlabs\Web\Controller {
}
$s .= replace_macros(get_markup_template('generic_app_settings.tpl'), array(
- '$addon' => array('affinity', '' . t('Affinity Tool Settings'), '', t('Submit')),
+ '$addon' => array('affinity', '' . t('Friend Zoom Settings'), '', t('Submit')),
'$content' => $setting_fields
));
diff --git a/Zotlabs/Module/Alist.php b/Zotlabs/Module/Alist.php
deleted file mode 100644
index 111f6b52d..000000000
--- a/Zotlabs/Module/Alist.php
+++ /dev/null
@@ -1,279 +0,0 @@
- t('Access Lists'),
- '$add_new_label' => t('Create access list'),
- '$new' => $new,
-
- // new group form
- '$gname' => array('groupname',t('Access list name')),
- '$public' => array('public',t('Members are visible to other channels'), false),
- '$form_security_token' => get_form_security_token("group_edit"),
- '$submit' => t('Submit'),
-
- // groups list
- '$title' => t('Access Lists'),
- '$name_label' => t('Name'),
- '$count_label' => t('Members'),
- '$entries' => $entries
- ]);
-
- return $o;
-
- }
-
-
-
-
- $context = array('$submit' => t('Submit'));
- $tpl = get_markup_template('group_edit.tpl');
-
- if((argc() == 3) && (argv(1) === 'drop')) {
- check_form_security_token_redirectOnErr('/alist', 'group_drop', 't');
-
- if(intval(argv(2))) {
- $r = q("SELECT gname FROM pgrp WHERE id = %d AND uid = %d LIMIT 1",
- intval(argv(2)),
- intval(local_channel())
- );
- if($r)
- $result = AccessList::remove(local_channel(),$r[0]['gname']);
- if($result)
- info( t('Access list removed.') . EOL);
- else
- notice( t('Unable to remove access list.') . EOL);
- }
- goaway(z_root() . '/alist');
- // NOTREACHED
- }
-
-
- if((argc() > 2) && intval(argv(1)) && argv(2)) {
-
- check_form_security_token_ForbiddenOnErr('group_member_change', 't');
-
- $r = q("SELECT abook_xchan from abook left join xchan on abook_xchan = xchan_hash where abook_xchan = '%s' and abook_channel = %d and xchan_deleted = 0 and abook_self = 0 and abook_blocked = 0 and abook_pending = 0 limit 1",
- dbesc(base64url_decode(argv(2))),
- intval(local_channel())
- );
- if(count($r))
- $change = base64url_decode(argv(2));
-
- }
-
- if((argc() > 1) && (intval(argv(1)))) {
-
- require_once('include/acl_selectors.php');
- $r = q("SELECT * FROM pgrp WHERE id = %d AND uid = %d AND deleted = 0 LIMIT 1",
- intval(argv(1)),
- intval(local_channel())
- );
- if(! $r) {
- notice( t('Access list not found.') . EOL );
- goaway(z_root() . '/connections');
- }
- $group = $r[0];
-
-
- $members = AccessList::members($group['id']);
-
- $preselected = array();
- if(count($members)) {
- foreach($members as $member)
- if(! in_array($member['xchan_hash'],$preselected))
- $preselected[] = $member['xchan_hash'];
- }
-
- if($change) {
-
- if(in_array($change,$preselected)) {
- AccessList::member_remove(local_channel(),$group['gname'],$change);
- }
- else {
- AccessList::member_add(local_channel(),$group['gname'],$change);
- }
-
- $members = AccessList::members($group['id']);
-
- $preselected = array();
- if(count($members)) {
- foreach($members as $member)
- $preselected[] = $member['xchan_hash'];
- }
- }
-
- $context = $context + array(
- '$title' => sprintf(t('Access List: %s'), $group['gname']),
- '$details_label' => t('Edit'),
- '$gname' => array('groupname',t('Access list name: '),$group['gname'], ''),
- '$gid' => $group['id'],
- '$drop' => $drop_txt,
- '$public' => array('public',t('Members are visible to other channels'), $group['visible'], ''),
- '$form_security_token_edit' => get_form_security_token('group_edit'),
- '$delete' => t('Delete access list'),
- '$form_security_token_drop' => get_form_security_token("group_drop"),
- );
-
- }
-
- if(! isset($group))
- return;
-
- $groupeditor = array(
- 'label_members' => t('List members'),
- 'members' => array(),
- 'label_contacts' => t('Not in this list'),
- 'contacts' => array(),
- );
-
- $sec_token = addslashes(get_form_security_token('group_member_change'));
- $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : 'card');
- foreach($members as $member) {
- if($member['xchan_url']) {
- $member['archived'] = (intval($member['abook_archived']) ? true : false);
- $member['click'] = 'groupChangeMember(' . $group['id'] . ',\'' . base64url_encode($member['xchan_hash']) . '\',\'' . $sec_token . '\'); return false;';
- $groupeditor['members'][] = micropro($member,true,'mpgroup', $textmode);
- }
- else
- AccessList::member_remove(local_channel(),$group['gname'],$member['xchan_hash']);
- }
-
- $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d AND abook_self = 0 and abook_blocked = 0 and abook_pending = 0 and xchan_deleted = 0 order by xchan_name asc",
- intval(local_channel())
- );
-
- if(count($r)) {
- $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : 'card');
- foreach($r as $member) {
- if(! in_array($member['xchan_hash'],$preselected)) {
- $member['archived'] = (intval($member['abook_archived']) ? true : false);
- $member['click'] = 'groupChangeMember(' . $group['id'] . ',\'' . base64url_encode($member['xchan_hash']) . '\',\'' . $sec_token . '\'); return false;';
- $groupeditor['contacts'][] = micropro($member,true,'mpall', $textmode);
- }
- }
- }
-
- $context['$groupeditor'] = $groupeditor;
- $context['$desc'] = t('Click a channel to toggle membership');
-
- if($change) {
- $tpl = get_markup_template('groupeditor.tpl');
- echo replace_macros($tpl, $context);
- killme();
- }
-
- return replace_macros($tpl, $context);
-
- }
-
-
-}
diff --git a/Zotlabs/Module/Appman.php b/Zotlabs/Module/Appman.php
index 50de90ac2..eecf1f95b 100644
--- a/Zotlabs/Module/Appman.php
+++ b/Zotlabs/Module/Appman.php
@@ -1,116 +1,113 @@
- intval($_REQUEST['uid']),
- 'url' => escape_tags($_REQUEST['url']),
- 'guid' => escape_tags($_REQUEST['guid']),
- 'author' => escape_tags($_REQUEST['author']),
- 'addr' => escape_tags($_REQUEST['addr']),
- 'name' => escape_tags($_REQUEST['name']),
- 'desc' => escape_tags($_REQUEST['desc']),
- 'photo' => escape_tags($_REQUEST['photo']),
- 'version' => escape_tags($_REQUEST['version']),
- 'price' => escape_tags($_REQUEST['price']),
- 'page' => escape_tags($_REQUEST['page']),
- 'requires' => escape_tags($_REQUEST['requires']),
- 'system' => intval($_REQUEST['system']),
- 'plugin' => escape_tags($_REQUEST['plugin']),
- 'sig' => escape_tags($_REQUEST['sig']),
+ if ($_POST['url']) {
+ $arr = [
+ 'uid' => intval($_REQUEST['uid']),
+ 'url' => escape_tags($_REQUEST['url']),
+ 'guid' => escape_tags($_REQUEST['guid']),
+ 'author' => escape_tags($_REQUEST['author']),
+ 'addr' => escape_tags($_REQUEST['addr']),
+ 'name' => escape_tags($_REQUEST['name']),
+ 'desc' => escape_tags($_REQUEST['desc']),
+ 'photo' => escape_tags($_REQUEST['photo']),
+ 'version' => escape_tags($_REQUEST['version']),
+ 'price' => escape_tags($_REQUEST['price']),
+ 'page' => escape_tags($_REQUEST['sellpage']), // do not use 'page' as a request variable here as it conflicts with pagination
+ 'requires' => escape_tags($_REQUEST['requires']),
+ 'system' => intval($_REQUEST['system']),
+ 'plugin' => escape_tags($_REQUEST['plugin']),
+ 'sig' => escape_tags($_REQUEST['sig']),
'categories' => escape_tags($_REQUEST['categories'])
- );
+ ];
- $_REQUEST['appid'] = Zlib\Apps::app_install(local_channel(),$arr);
+ $_REQUEST['appid'] = Apps::app_install(local_channel(),$arr);
- if(Zlib\Apps::app_installed(local_channel(),$arr))
+ if (Apps::app_installed(local_channel(),$arr)) {
info( t('App installed.') . EOL);
+ }
goaway(z_root() . '/apps');
- return; //not reached
}
- $papp = Zlib\Apps::app_decode($_POST['papp']);
+ $papp = Apps::app_decode($_POST['papp']);
- if(! is_array($papp)) {
+ if (! is_array($papp)) {
notice( t('Malformed app.') . EOL);
return;
}
- if($_POST['install']) {
- Zlib\Apps::app_install(local_channel(),$papp);
- if(Zlib\Apps::app_installed(local_channel(),$papp))
+ if ($_POST['install']) {
+ Apps::app_install(local_channel(),$papp);
+ if (Apps::app_installed(local_channel(),$papp))
info( t('App installed.') . EOL);
}
- if($_POST['delete']) {
- Zlib\Apps::app_destroy(local_channel(),$papp);
+ if ($_POST['delete']) {
+ Apps::app_destroy(local_channel(),$papp);
}
- if($_POST['edit']) {
+ if ($_POST['edit']) {
return;
}
- if($_POST['feature']) {
- Zlib\Apps::app_feature(local_channel(), $papp, $_POST['feature']);
+ if ($_POST['feature']) {
+ Apps::app_feature(local_channel(), $papp, $_POST['feature']);
}
- if($_POST['pin']) {
- Zlib\Apps::app_feature(local_channel(), $papp, $_POST['pin']);
+ if ($_POST['pin']) {
+ Apps::app_feature(local_channel(), $papp, $_POST['pin']);
}
- if($_SESSION['return_url'])
+ if ($_SESSION['return_url']) {
goaway(z_root() . '/' . $_SESSION['return_url']);
-
+ }
+
goaway(z_root() . '/apps');
-
-
}
function get() {
- if(! local_channel()) {
+ if (! local_channel()) {
notice( t('Permission denied.') . EOL);
return;
}
- $channel = \App::get_channel();
+ $channel = App::get_channel();
- if(argc() > 3) {
+ if (argc() > 3) {
if(argv(2) === 'moveup') {
- Zlib\Apps::moveup(local_channel(),argv(1),argv(3));
+ Apps::moveup(local_channel(),argv(1),argv(3));
}
if(argv(2) === 'movedown') {
- Zlib\Apps::movedown(local_channel(),argv(1),argv(3));
+ Apps::movedown(local_channel(),argv(1),argv(3));
}
goaway(z_root() . '/apporder');
}
-
-
-
$app = null;
$embed = null;
- if($_REQUEST['appid']) {
+ 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) {
+ if ($r) {
$app = $r[0];
$term = q("select * from term where otype = %d and oid = %d and uid = %d",
@@ -118,41 +115,34 @@ class Appman extends \Zotlabs\Web\Controller {
intval($r[0]['id']),
intval(local_channel())
);
- if($term) {
- $app['categories'] = '';
- foreach($term as $t) {
- if($app['categories'])
- $app['categories'] .= ',';
- $app['categories'] .= $t['term'];
- }
+ if ($term) {
+ $app['categories'] = array_elm_to_str($term,'term');
}
}
- $embed = array('embed', t('Embed code'), Zlib\Apps::app_encode($app,true),'', 'onclick="this.select();"');
-
+ $embed = [ 'embed', t('Embed code'), Apps::app_encode($app,true), EMPTY_STR, '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),
- '$plugin' => (($app) ? $app['app_plugin'] : ''),
- '$requires' => (($app) ? $app['app_requires'] : ''),
- '$embed' => $embed,
- '$submit' => t('Submit')
- ));
+ return replace_macros(get_markup_template('app_create.tpl'), [
+ '$banner' => (($app) ? t('Edit App') : t('Create App')),
+ '$app' => $app,
+ '$guid' => (($app) ? $app['app_id'] : EMPTY_STR),
+ '$author' => (($app) ? $app['app_author'] : $channel['channel_hash']),
+ '$addr' => (($app) ? $app['app_addr'] : $channel['xchan_addr']),
+ '$name' => [ 'name', t('Name of app'),(($app) ? $app['app_name'] : EMPTY_STR), t('Required') ],
+ '$url' => [ 'url', t('Location (URL) of app'),(($app) ? $app['app_url'] : EMPTY_STR), t('Required') ],
+ '$desc' => [ 'desc', t('Description'),(($app) ? $app['app_desc'] : EMPTY_STR), EMPTY_STR],
+ '$photo' => [ 'photo', t('Photo icon URL'),(($app) ? $app['app_photo'] : EMPTY_STR), t('80 x 80 pixels - optional') ],
+ '$categories' => [ 'categories',t('Categories (optional, comma separated list)'),(($app) ? $app['categories'] : EMPTY_STR), EMPTY_STR ],
+ '$version' => [ 'version', t('Version ID'),(($app) ? $app['app_version'] : EMPTY_STR), EMPTY_STR ],
+ '$price' => [ 'price', t('Price of app'),(($app) ? $app['app_price'] : EMPTY_STR), EMPTY_STR ],
+ '$page' => [ 'sellpage', t('Location (URL) to purchase app'),(($app) ? $app['app_page'] : EMPTY_STR), EMPTY_STR ],
+ '$system' => (($app) ? intval($app['app_system']) : 0),
+ '$plugin' => (($app) ? $app['app_plugin'] : EMPTY_STR),
+ '$requires' => (($app) ? $app['app_requires'] : EMPTY_STR),
+ '$embed' => $embed,
+ '$submit' => t('Submit')
+ ]);
}
diff --git a/Zotlabs/Module/Apporder.php b/Zotlabs/Module/Apporder.php
index eac1abc2d..132324dcb 100644
--- a/Zotlabs/Module/Apporder.php
+++ b/Zotlabs/Module/Apporder.php
@@ -2,53 +2,51 @@
namespace Zotlabs\Module;
-use \Zotlabs\Lib as Zlib;
+use Zotlabs\Web\Controller;
+use Zotlabs\Lib\Apps;
class Apporder extends \Zotlabs\Web\Controller {
- function post() {
-
- }
function get() {
- if(! local_channel())
+ if (! local_channel()) {
return;
+ }
nav_set_selected('Order Apps');
- foreach( [ 'nav_featured_app', 'nav_pinned_app' ] as $l ) {
+ foreach ( [ 'nav_featured_app', 'nav_pinned_app' ] as $l ) {
$syslist = [];
- $list = Zlib\Apps::app_list(local_channel(), false, [ $l ]);
- if($list) {
- foreach($list as $li) {
- $syslist[] = Zlib\Apps::app_encode($li);
+ $list = Apps::app_list(local_channel(), false, [ $l ]);
+ if ($list) {
+ foreach ($list as $li) {
+ $syslist[] = Apps::app_encode($li);
}
}
- Zlib\Apps::translate_system_apps($syslist);
+ Apps::translate_system_apps($syslist);
usort($syslist,'Zotlabs\\Lib\\Apps::app_name_compare');
- $syslist = Zlib\Apps::app_order(local_channel(),$syslist, $l);
+ $syslist = Apps::app_order(local_channel(),$syslist, $l);
- foreach($syslist as $app) {
- if($l === 'nav_pinned_app') {
- $navbar_apps[] = Zlib\Apps::app_render($app,'nav-order');
+ foreach ($syslist as $app) {
+ if ($l === 'nav_pinned_app') {
+ $navbar_apps[] = Apps::app_render($app,'nav-order-pinned');
}
- elseif(strpos($app['categories'],'nav_pinned_app') === false) {
- $nav_apps[] = Zlib\Apps::app_render($app,'nav-order');
+ else {
+ $nav_apps[] = Apps::app_render($app,'nav-order');
}
}
}
- return replace_macros(get_markup_template('apporder.tpl'),
- [
- '$header' => [t('Change Order of Pinned Navbar Apps'), t('Change Order of App Tray Apps')],
- '$desc' => [t('Use arrows to move the corresponding app left (top) or right (bottom) in the navbar'), t('Use arrows to move the corresponding app up or down in the app tray')],
- '$nav_apps' => $nav_apps,
+ return replace_macros(get_markup_template('apporder.tpl'), [
+ '$header' => [ t('Change Order of Pinned Navbar Apps'), t('Change Order of App Tray Apps') ],
+ '$desc' => [ t('Use arrows to move the corresponding app left (top) or right (bottom) in the navbar'),
+ t('Use arrows to move the corresponding app up or down in the app tray') ],
+ '$nav_apps' => $nav_apps,
'$navbar_apps' => $navbar_apps
- ]
- );
+ ]);
}
}
diff --git a/Zotlabs/Module/Apschema.php b/Zotlabs/Module/Apschema.php
index 996e0c0ee..d2dbefe8a 100644
--- a/Zotlabs/Module/Apschema.php
+++ b/Zotlabs/Module/Apschema.php
@@ -17,12 +17,17 @@ class Apschema extends \Zotlabs\Web\Controller {
'ostatus' => 'http://ostatus.org#',
'conversation' => 'ostatus:conversation',
'sensitive' => 'as:sensitive',
+ 'movedTo' => 'as:movedTo',
+ 'copiedTo' => 'as:copiedTo',
+ 'alsoKnownAs' => 'as:alsoKnownAs',
'inheritPrivacy' => 'as:inheritPrivacy',
'commentPolicy' => 'zot:commentPolicy',
'topicalCollection' => 'zot:topicalCollection',
'eventRepeat' => 'zot:eventRepeat',
'emojiReaction' => 'zot:emojiReaction',
'expires' => 'zot:expires',
+ 'directMessage' => 'zot:directMessage',
+ 'replyTo' => 'zot:replyTo'
]
];
diff --git a/Zotlabs/Module/Authorize.php b/Zotlabs/Module/Authorize.php
index c6709f602..17563f72f 100644
--- a/Zotlabs/Module/Authorize.php
+++ b/Zotlabs/Module/Authorize.php
@@ -50,13 +50,21 @@ class Authorize extends \Zotlabs\Web\Controller {
// TODO: The automatic client registration protocol below should adhere more
// closely to "OAuth 2.0 Dynamic Client Registration Protocol" defined
// at https://tools.ietf.org/html/rfc7591
-
+
+ // If no client_id was provided, generate a new one.
+ if (x($_POST, 'client_name')) {
+ $client_name = $_POST['client_name'];
+ } else {
+ $client_name = $_POST['client_name'] = EMPTY_STR;
+ }
+
// If no client_id was provided, generate a new one.
if (x($_POST, 'client_id')) {
$client_id = $_POST['client_id'];
} else {
$client_id = $_POST['client_id'] = random_string(16);
}
+
// If no redirect_uri was provided, generate a fake one.
if (x($_POST, 'redirect_uri')) {
$redirect_uri = $_POST['redirect_uri'];
@@ -76,7 +84,7 @@ class Authorize extends \Zotlabs\Web\Controller {
// Until "Dynamic Client Registration" is pursued - allow new clients to assign their own secret in the REQUEST
$client_secret = (isset($_REQUEST['client_secret'])) ? $_REQUEST['client_secret'] : random_string(16);
// Client apps are registered per channel
- $storage->setClientDetails($client_id, $client_secret, $redirect_uri, 'authorization_code', $_REQUEST['scope'], $user_id);
+ $storage->setClientDetails($client_id, $client_secret, $redirect_uri, $_REQUEST['grant_types'], $_REQUEST['scope'], $user_id, $client_name);
}
if (!$client = $storage->getClientDetails($client_id)) {
// There was an error registering the client.
diff --git a/Zotlabs/Module/Cal.php b/Zotlabs/Module/Cal.php
index 09ae16755..c3c31ac7d 100644
--- a/Zotlabs/Module/Cal.php
+++ b/Zotlabs/Module/Cal.php
@@ -81,9 +81,8 @@ class Cal extends Controller {
nav_set_selected('Calendar');
$sql_extra = permissions_sql($channel['channel_id'],get_observer_hash(),'event');
-
- $first_day = get_pconfig(local_channel(),'system','cal_first_day');
- $first_day = (($first_day) ? $first_day : 0);
+
+ $first_day = intval(get_pconfig($channel['channel_id'],'system','cal_first_day',0));
$htpl = get_markup_template('event_head.tpl');
\App::$page['htmlhead'] .= replace_macros($htpl,array(
diff --git a/Zotlabs/Module/Calendar.php b/Zotlabs/Module/Calendar.php
index 6d39483bb..128ffff0b 100644
--- a/Zotlabs/Module/Calendar.php
+++ b/Zotlabs/Module/Calendar.php
@@ -429,12 +429,12 @@ class Calendar extends Controller {
'end' => $end,
'drop' => $drop,
'allDay' => $allDay,
- 'title' => htmlentities($rr['summary'], ENT_COMPAT, 'UTF-8'),
+ 'title' => html_entity_decode($rr['summary'], ENT_COMPAT, 'UTF-8'),
'editable' => $edit ? true : false,
'item' => $rr,
'plink' => [ $rr['plink'], t('Link to source') ],
- 'description' => htmlentities($rr['description'], ENT_COMPAT, 'UTF-8'),
- 'location' => htmlentities($rr['location'], ENT_COMPAT, 'UTF-8'),
+ 'description' => htmlentities($rr['description'], ENT_COMPAT, 'UTF-8',false),
+ 'location' => htmlentities($rr['location'], ENT_COMPAT, 'UTF-8',false),
'allow_cid' => expand_acl($rr['allow_cid']),
'allow_gid' => expand_acl($rr['allow_gid']),
'deny_cid' => expand_acl($rr['deny_cid']),
@@ -443,7 +443,7 @@ class Calendar extends Controller {
];
}
}
-
+
if ($export) {
header('Content-type: text/calendar');
header('content-disposition: attachment; filename="' . t('calendar') . '-' . $channel['channel_address'] . '.ics"' );
diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php
index 217506582..af8ce519b 100644
--- a/Zotlabs/Module/Channel.php
+++ b/Zotlabs/Module/Channel.php
@@ -76,6 +76,7 @@ class Channel extends Controller {
'href' => z_root() . '/feed/' . $which . '?f=&top=1'
]);
+
// handle zot6 channel discovery
if(Libzot::is_zot_request()) {
@@ -113,7 +114,7 @@ class Channel extends Controller {
ACTIVITYSTREAMS_JSONLD_REV,
'https://w3id.org/security/v1',
z_root() . ZOT_APSCHEMA_REV
- ]], Activity::encode_person($channel,true,((defined('NOMADIC')) ? false : true)));
+ ]], Activity::encode_person($channel,true,true));
$headers = [];
$headers['Content-Type'] = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' ;
@@ -135,6 +136,16 @@ class Channel extends Controller {
Libprofile::load($which,$profile);
+ App::$meta->set('og:title', $channel['channel_name']);
+ App::$meta->set('og:image', $channel['xchan_photo_l']);
+ App::$meta->set('og:type','webpage');
+ App::$meta->set('og:url', channel_url($channel));
+ if(App::$profile['about'] && perm_is_allowed($channel['channel_id'],get_observer_hash(),'view_profile')) {
+ App::$meta->set('og:description', App::$profile['about']);
+ }
+ else {
+ App::$meta->set('og:description', sprintf( t('This is the home page of %s.'), $channel['channel_name']));
+ }
}
function get($update = 0, $load = false) {
@@ -440,6 +451,7 @@ class Channel extends Controller {
'$nouveau' => '0',
'$wall' => '1',
'$fh' => '0',
+ '$dm' => '0',
'$static' => $static,
'$page' => ((App::$pager['page'] != 1) ? App::$pager['page'] : 1),
'$search' => $search,
diff --git a/Zotlabs/Module/Cloud.php b/Zotlabs/Module/Cloud.php
index 2a1e96389..7589bb1a6 100644
--- a/Zotlabs/Module/Cloud.php
+++ b/Zotlabs/Module/Cloud.php
@@ -37,18 +37,11 @@ class Cloud extends Controller {
if (argc() > 1)
$which = argv(1);
-
- if (argc() < 2 && intval(get_config('system','cloud_disable_siteroot'))) {
- notice( t('Permission denied.') . EOL);
- construct_page();
- killme();
- }
-
$profile = 0;
- if ($which)
+ if ($which) {
Libprofile::load( $which, $profile);
-
+ }
$auth = new \Zotlabs\Storage\BasicAuth();
diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php
index ac57ce03f..2e1aa0b44 100644
--- a/Zotlabs/Module/Connections.php
+++ b/Zotlabs/Module/Connections.php
@@ -1,20 +1,24 @@
t('Delete connection'),
'id' => $rr['abook_id'],
'thumb' => $rr['xchan_photo_m'],
- 'name' => $rr['xchan_name'],
+ 'name' => $rr['xchan_name'] . (($rr['abook_alias']) ? ' <' . $rr['abook_alias'] . '>' : ''),
'classes' => ((intval($rr['abook_archived']) || intval($rr['abook_not_here'])) ? 'archived' : ''),
'link' => z_root() . '/connedit/' . $rr['abook_id'],
'deletelink' => z_root() . '/connedit/' . intval($rr['abook_id']) . '/drop',
@@ -303,7 +312,7 @@ class Connections extends \Zotlabs\Web\Controller {
'$finding' => (($searching) ? t('Connections search') . ": '" . $search . "'" : ""),
'$submit' => t('Find'),
'$edit' => t('Edit'),
- '$cmd' => \App::$cmd,
+ '$cmd' => App::$cmd,
'$contacts' => $contacts,
'$paginate' => paginate($a),
diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php
index c0f62bd0d..2a90f81aa 100644
--- a/Zotlabs/Module/Connedit.php
+++ b/Zotlabs/Module/Connedit.php
@@ -74,15 +74,6 @@ class Connedit extends Controller {
$channel = App::get_channel();
- // TODO if configured for hassle-free permissions, we'll post the form with ajax as soon as the
- // connection enable is toggled to a special autopost url and set permissions immediately, leaving
- // the other form elements alone pending a manual submit of the form. The downside is that there
- // will be a window of opportunity when the permissions have been set but before you've had a chance
- // to review and possibly restrict them. The upside is we won't have to warn you that your connection
- // can't do anything until you save the bloody form.
-
- $autopost = (((argc() > 2) && (argv(2) === 'auto')) ? true : false);
-
$orig_record = q("SELECT * FROM abook WHERE abook_id = %d AND abook_channel = %d LIMIT 1",
intval($contact_id),
intval(local_channel())
@@ -127,6 +118,7 @@ class Connedit extends Controller {
$abook_incl = ((array_key_exists('abook_incl',$_POST)) ? escape_tags($_POST['abook_incl']) : $orig_record[0]['abook_incl']);
$abook_excl = ((array_key_exists('abook_excl',$_POST)) ? escape_tags($_POST['abook_excl']) : $orig_record[0]['abook_excl']);
+ $abook_alias = ((array_key_exists('abook_alias',$_POST)) ? escape_tags(trim($_POST['abook_alias'])) : $orig_record[0]['abook_alias']);
$hidden = intval($_POST['hidden']);
@@ -184,13 +176,14 @@ class Connedit extends Controller {
$abook_pending = (($new_friend) ? 0 : $orig_record[0]['abook_pending']);
$r = q("UPDATE abook SET abook_profile = '%s', abook_closeness = %d, abook_pending = %d,
- abook_incl = '%s', abook_excl = '%s'
+ abook_incl = '%s', abook_excl = '%s', abook_alias = '%s'
where abook_id = %d AND abook_channel = %d",
dbesc($profile_id),
intval($closeness),
intval($abook_pending),
dbesc($abook_incl),
dbesc($abook_excl),
+ dbesc($abook_alias),
intval($contact_id),
intval(local_channel())
);
@@ -247,8 +240,7 @@ class Connedit extends Controller {
post_activity_item($xarr);
}
-
-
+
// pull in a bit of content if there is any to pull in
Master::Summon( [ 'Onepoll', $contact_id ]);
@@ -287,33 +279,33 @@ class Connedit extends Controller {
function connedit_clone(&$a) {
- if(! App::$poi)
- return;
+ if (! App::$poi) {
+ return;
+ }
+ $channel = App::get_channel();
- $channel = App::get_channel();
+ $r = q("SELECT abook.*, xchan.*
+ FROM abook left join xchan on abook_xchan = xchan_hash
+ WHERE abook_channel = %d and abook_id = %d LIMIT 1",
+ intval(local_channel()),
+ intval(App::$poi['abook_id'])
+ );
+ if ($r) {
+ App::$poi = array_shift($r);
+ }
- $r = q("SELECT abook.*, xchan.*
- FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE abook_channel = %d and abook_id = %d LIMIT 1",
- intval(local_channel()),
- intval(App::$poi['abook_id'])
- );
- if($r) {
- App::$poi = array_shift($r);
- }
+ $clone = App::$poi;
- $clone = App::$poi;
+ unset($clone['abook_id']);
+ unset($clone['abook_account']);
+ unset($clone['abook_channel']);
- unset($clone['abook_id']);
- unset($clone['abook_account']);
- unset($clone['abook_channel']);
-
- $abconfig = load_abconfig($channel['channel_id'],$clone['abook_xchan']);
- if($abconfig)
- $clone['abconfig'] = $abconfig;
-
- Libsync::build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone)));
+ $abconfig = load_abconfig($channel['channel_id'],$clone['abook_xchan']);
+ if ($abconfig) {
+ $clone['abconfig'] = $abconfig;
+ }
+ Libsync::build_sync_packet($channel['channel_id'], [ 'abook' => [ $clone ] ] );
}
/* @brief Generate content of connection edit page
@@ -431,7 +423,7 @@ class Connedit extends Controller {
notice(t('Unable to set address book parameters.') . EOL);
goaway(z_root() . '/connedit/' . $contact_id);
}
-
+
if($cmd === 'ignore') {
if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_IGNORED)) {
$this->connedit_clone($a);
@@ -441,6 +433,15 @@ class Connedit extends Controller {
goaway(z_root() . '/connedit/' . $contact_id);
}
+ if($cmd === 'censor') {
+ if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_CENSORED)) {
+ $this->connedit_clone($a);
+ }
+ else
+ notice(t('Unable to set address book parameters.') . EOL);
+ goaway(z_root() . '/connedit/' . $contact_id);
+ }
+
if($cmd === 'archive') {
if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_ARCHIVED)) {
$this->connedit_clone($a);
@@ -574,7 +575,15 @@ class Connedit extends Controller {
'title' => t('Ignore (or Unignore) all inbound communications from this connection'),
'info' => (intval($contact['abook_ignored']) ? t('This connection is ignored!') : ''),
),
-
+
+ 'censor' => array(
+ 'label' => (intval($contact['abook_censor']) ? t('Uncensor') : t('Censor')),
+ 'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/censor',
+ 'sel' => (intval($contact['abook_censor']) ? 'active' : ''),
+ 'title' => t('Censor (or Uncensor) images from this connection'),
+ 'info' => (intval($contact['abook_censor']) ? t('This connection is censored!') : ''),
+ ),
+
'archive' => array(
'label' => (intval($contact['abook_archived']) ? t('Unarchive') : t('Archive')),
'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/archive',
@@ -637,13 +646,13 @@ class Connedit extends Controller {
$tpl = get_markup_template("abook_edit.tpl");
- if(Apps::system_app_installed(local_channel(),'Affinity Tool')) {
+ if(Apps::system_app_installed(local_channel(),'Friend Zoom')) {
$sections['affinity'] = [
- 'label' => t('Affinity'),
+ 'label' => t('Friend Zoom'),
'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/?f=§ion=affinity',
'sel' => '',
- 'title' => t('Open Set Affinity section by default'),
+ 'title' => t('Open Friend Zoom section by default'),
];
$labels = [
@@ -714,13 +723,13 @@ class Connedit extends Controller {
$multiprofs = ((feature_enabled(local_channel(),'multi_profiles')) ? true : false);
if($slide && !$multiprofs)
- $affinity = t('Set Affinity');
+ $affinity = t('Set Friend Zoom');
if(!$slide && $multiprofs)
$affinity = t('Set Profile');
if($slide && $multiprofs)
- $affinity = t('Set Affinity & Profile');
+ $affinity = t('Set Friend Zoom & Profile');
$theirs = get_abconfig(local_channel(),$contact['abook_xchan'],'system','their_perms',EMPTY_STR);
@@ -776,7 +785,7 @@ class Connedit extends Controller {
$not_here = t('This connection is unreachable from this location. Location independence is not supported by their network.');
$o .= replace_macros($tpl, [
- '$header' => (($self) ? t('Connection Default Permissions') : sprintf( t('Connection: %s'),$contact['xchan_name'])),
+ '$header' => (($self) ? t('Connection Default Permissions') : sprintf( t('Connection: %s'),$contact['xchan_name']) . (($contact['abook_alias']) ? ' <' . $contact['abook_alias'] . '>' : '')),
'$autoperms' => array('autoperms',t('Apply these permissions automatically'), ((get_pconfig(local_channel(),'system','autoperms')) ? 1 : 0), t('Connection requests will be approved without your interaction'), $yes_no),
'$permcat' => [ 'permcat', t('Permission role'), '', '' . $desc . '
';
- if(! ( local_channel() && Apps::system_app_installed(local_channel(),'Expire Posts'))) {
+ if (! ( local_channel() && Apps::system_app_installed(local_channel(),'Expire Posts'))) {
return $text;
}
-
-
- $setting_fields .= replace_macros(get_markup_template('field_input.tpl'), array(
+ $setting_fields .= replace_macros(get_markup_template('field_input.tpl'), [
'$field' => array('selfexpiredays', t('Expire and delete all my posts after this many days'), intval(get_pconfig(local_channel(),'system','selfexpiredays',0)), t('Leave at 0 if you wish to manually control expiration of specific posts.'))
- ));
+ ]);
- $s .= replace_macros(get_markup_template('generic_app_settings.tpl'), array(
+ return replace_macros(get_markup_template('generic_app_settings.tpl'), [
'$addon' => array('expire', t('Automatic Expiration Settings'), '', t('Submit')),
'$content' => $setting_fields
- ));
-
- return $s;
-
-
-
-
-
-
-
-
+ ]);
}
diff --git a/Zotlabs/Module/Feed.php b/Zotlabs/Module/Feed.php
index dd7691835..ace1109a8 100644
--- a/Zotlabs/Module/Feed.php
+++ b/Zotlabs/Module/Feed.php
@@ -1,9 +1,11 @@
1) {
+ if (argc() > 1) {
- if(observer_prohibited(true)) {
+ if (observer_prohibited(true)) {
killme();
}
$channel = channelx_by_nick(argv(1));
- if(! $channel) {
+ if (! $channel) {
killme();
- }
-
+ }
logger('public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $channel['channel_address']);
diff --git a/Zotlabs/Module/Follow.php b/Zotlabs/Module/Follow.php
index 42486075e..e3174cc52 100644
--- a/Zotlabs/Module/Follow.php
+++ b/Zotlabs/Module/Follow.php
@@ -15,11 +15,8 @@ class Follow extends Controller {
function init() {
- if(! local_channel()) {
- return;
- }
- if(ActivityStreams::is_as_request() && argc() == 2) {
+ if (ActivityStreams::is_as_request() && argc() == 2) {
$abook_id = intval(argv(1));
if(! $abook_id)
return;
@@ -27,18 +24,21 @@ class Follow extends Controller {
$r = q("select * from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d",
intval($abook_id)
);
- if (! $r)
+ if (! $r) {
return;
+ }
$chan = channelx_by_n($r[0]['abook_channel']);
- if(! $chan)
+ if (! $chan) {
http_status_exit(404, 'Not found');
-
+ }
+
$actor = Activity::encode_person($chan,true,true);
- if(! $actor)
+ if (! $actor) {
http_status_exit(404, 'Not found');
-
+ }
+
$x = array_merge(['@context' => [
ACTIVITYSTREAMS_JSONLD_REV,
'https://w3id.org/security/v1',
@@ -64,6 +64,13 @@ class Follow extends Controller {
}
+
+ if (! local_channel()) {
+ return;
+ }
+
+
+
$uid = local_channel();
$url = notags(trim(punify($_REQUEST['url'])));
$return_url = $_SESSION['return_url'];
@@ -71,17 +78,13 @@ class Follow extends Controller {
$interactive = (($_REQUEST['interactive']) ? intval($_REQUEST['interactive']) : 1);
$channel = App::get_channel();
- if(strpos($url,'@') === false && strpos($url,'/') === false) {
- $url = $url . '@' . App::get_hostname();
- }
-
-
$result = Connect::connect($channel,$url);
- if($result['success'] == false) {
- if($result['message'])
+ if ($result['success'] == false) {
+ if ($result['message']) {
notice($result['message']);
- if($interactive) {
+ }
+ if ($interactive) {
goaway($return_url);
}
else {
@@ -92,8 +95,8 @@ class Follow extends Controller {
info( t('Connection added.') . EOL);
$clone = array();
- foreach($result['abook'] as $k => $v) {
- if(strpos($k,'abook_') === 0) {
+ foreach ($result['abook'] as $k => $v) {
+ if (strpos($k,'abook_') === 0) {
$clone[$k] = $v;
}
}
@@ -102,19 +105,20 @@ class Follow extends Controller {
unset($clone['abook_channel']);
$abconfig = load_abconfig($channel['channel_id'],$clone['abook_xchan']);
- if($abconfig)
+ if ($abconfig) {
$clone['abconfig'] = $abconfig;
-
+ }
Libsync::build_sync_packet(0, [ 'abook' => [ $clone ] ], true);
$can_view_stream = their_perms_contains($channel['channel_id'],$clone['abook_xchan'],'view_stream');
// If we can view their stream, pull in some posts
- if(($can_view_stream) || ($result['abook']['xchan_network'] === 'rss'))
+ if (($can_view_stream) || ($result['abook']['xchan_network'] === 'rss')) {
Master::Summon([ 'Onepoll', $result['abook']['abook_id'] ]);
+ }
- if($interactive) {
+ if ($interactive) {
goaway(z_root() . '/connedit/' . $result['abook']['abook_id'] . '?follow=1');
}
else {
@@ -124,7 +128,7 @@ class Follow extends Controller {
}
function get() {
- if(! local_channel()) {
+ if (! local_channel()) {
return login();
}
}
diff --git a/Zotlabs/Module/Followers.php b/Zotlabs/Module/Followers.php
new file mode 100644
index 000000000..8e4e96e1b
--- /dev/null
+++ b/Zotlabs/Module/Followers.php
@@ -0,0 +1,73 @@
+ [
+ ACTIVITYSTREAMS_JSONLD_REV,
+ 'https://w3id.org/security/v1',
+ z_root() . ZOT_APSCHEMA_REV
+ ]], Activity::encode_follow_collection($r, App::$query_string, 'OrderedCollection'));
+
+
+ $headers = [];
+ $headers['Content-Type'] = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' ;
+ $x['signature'] = LDSignatures::sign($x,$channel);
+ $ret = json_encode($x, JSON_UNESCAPED_SLASHES);
+ $headers['Digest'] = HTTPSig::generate_digest_header($ret);
+ $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI'];
+ $h = HTTPSig::create_sig($headers,$channel['channel_prvkey'],channel_url($channel));
+ HTTPSig::set_headers($h);
+ echo $ret;
+ killme();
+
+ }
+
+ }
+
+}
diff --git a/Zotlabs/Module/Following.php b/Zotlabs/Module/Following.php
new file mode 100644
index 000000000..264284432
--- /dev/null
+++ b/Zotlabs/Module/Following.php
@@ -0,0 +1,70 @@
+ [
+ ACTIVITYSTREAMS_JSONLD_REV,
+ 'https://w3id.org/security/v1',
+ z_root() . ZOT_APSCHEMA_REV
+ ]], Activity::encode_follow_collection($r, App::$query_string, 'OrderedCollection'));
+
+ $headers = [];
+ $headers['Content-Type'] = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' ;
+ $x['signature'] = LDSignatures::sign($x,$channel);
+ $ret = json_encode($x, JSON_UNESCAPED_SLASHES);
+ $headers['Digest'] = HTTPSig::generate_digest_header($ret);
+ $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI'];
+ $h = HTTPSig::create_sig($headers,$channel['channel_prvkey'],channel_url($channel));
+ HTTPSig::set_headers($h);
+ echo $ret;
+ killme();
+
+ }
+
+ }
+
+}
diff --git a/Zotlabs/Module/Getfile.php b/Zotlabs/Module/Getfile.php
index c222177dc..68441c19f 100644
--- a/Zotlabs/Module/Getfile.php
+++ b/Zotlabs/Module/Getfile.php
@@ -1,6 +1,9 @@
1) {
$verify_hash = argv(1);
- if($verify_hash !== $hash) {
+ if($verify_hash !== $resource) {
+ logger('resource mismatch');
killme();
}
}
if(! $hash) {
+ logger('no sender hash');
killme();
}
@@ -53,7 +61,7 @@ class Getfile extends \Zotlabs\Web\Controller {
continue;
}
- $verified = \Zotlabs\Web\HTTPSig::verify('');
+ $verified = HTTPSig::verify('');
if($verified && $verified['header_signed'] && $verified['header_valid']) {
$r = q("select hubloc_hash from hubloc where hubloc_id_url = '%s' or hubloc_addr = '%s' limit 1",
dbesc($verified['signer']),
diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php
index 6c7c09383..8c763d6be 100644
--- a/Zotlabs/Module/Hq.php
+++ b/Zotlabs/Module/Hq.php
@@ -1,19 +1,23 @@
$channel['channel_allow_cid'],
@@ -119,7 +123,7 @@ class Hq extends \Zotlabs\Web\Controller {
'default_location' => $channel['channel_location'],
'nickname' => $channel['channel_address'],
'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
- 'acl' => populate_acl($channel_acl,true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'),
+ 'acl' => populate_acl($channel_acl,true, PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'),
'permissions' => $channel_acl,
'bang' => '',
'visitor' => true,
@@ -165,7 +169,7 @@ class Hq extends \Zotlabs\Web\Controller {
$o .= "\r\n";
- \App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),[
+ App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),[
'$baseurl' => z_root(),
'$pgtype' => 'hq',
'$uid' => local_channel(),
@@ -178,6 +182,7 @@ class Hq extends \Zotlabs\Web\Controller {
'$conv' => '0',
'$spam' => '0',
'$fh' => '0',
+ '$dm' => '0',
'$nouveau' => '0',
'$wall' => '0',
'$static' => $static,
diff --git a/Zotlabs/Module/Id.php b/Zotlabs/Module/Id.php
index 59dda5d08..0dfec4c7b 100644
--- a/Zotlabs/Module/Id.php
+++ b/Zotlabs/Module/Id.php
@@ -90,7 +90,7 @@ class Id extends Controller {
xchan_query($r,true);
$items = fetch_post_tags($r,true);
- $i = Activity::encode_item($items[0],( defined('NOMADIC') ? false : true));
+ $i = Activity::encode_item($items[0],( get_config('system','activitypub') ? true : false ));
if(! $i)
http_status_exit(404, 'Not found');
diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php
index 7934d1360..d45120d55 100644
--- a/Zotlabs/Module/Import.php
+++ b/Zotlabs/Module/Import.php
@@ -122,7 +122,7 @@ class Import extends Controller {
}
}
- $codebase = ((defined('NOMADIC')) ? 'zap' : 'osada');
+ $codebase = 'zap';
if ((! array_path_exists('compatibility/codebase',$data)) || $data['compatibility']['codebase'] !== $codebase) {
notice('Data export format is not compatible with this software');
@@ -142,7 +142,7 @@ class Import extends Controller {
$max_identities = account_service_class_fetch($account_id,'total_identities');
if ($max_identities !== false) {
- $r = q("select channel_id from channel where channel_account_id = %d",
+ $r = q("select channel_id from channel where channel_account_id = %d and channel_removed = 0 ",
intval($account_id)
);
if ($r && count($r) > $max_identities) {
@@ -161,6 +161,9 @@ class Import extends Controller {
if ((! $x) || strlen($x) > 64) {
$x = strtolower(URLify::transliterate($newname));
}
+ else {
+ $x = $newname;
+ }
$newname = $x;
}
diff --git a/Zotlabs/Module/Inbox.php b/Zotlabs/Module/Inbox.php
new file mode 100644
index 000000000..9357d2b8f
--- /dev/null
+++ b/Zotlabs/Module/Inbox.php
@@ -0,0 +1,274 @@
+is_valid() && $AS->type === 'Announce' && is_array($AS->obj)
+ && array_key_exists('object',$AS->obj) && array_key_exists('actor',$AS->obj)) {
+ // This is a relayed/forwarded Activity (as opposed to a shared/boosted object)
+ // Reparse the encapsulated Activity and use that instead
+ logger('relayed activity',LOGGER_DEBUG);
+ $AS = new ActivityStreams($AS->obj);
+ }
+
+ //logger('debug: ' . $AS->debug());
+
+ if (! $AS->is_valid()) {
+ if ($AS->deleted) {
+ // process mastodon user deletion activities, but only if we can validate the signature
+ if ($hsig['header_valid'] && $hsig['content_valid'] && $hsig['portable_id']) {
+ logger('removing deleted actor');
+ remove_all_xchan_resources($hsig['portable_id']);
+ }
+ else {
+ logger('ignoring deleted actor', LOGGER_DEBUG, LOG_INFO);
+ }
+ }
+ return;
+ }
+
+
+ // $observer_hash in this case is the sender
+
+ if ($hsig['header_valid'] && $hsig['content_valid'] && $hsig['portable_id']) {
+ $observer_hash = $hsig['portable_id'];
+ }
+ else {
+ $observer_hash = $AS->actor['id'];
+ }
+
+ if (! $observer_hash) {
+ return;
+ }
+
+ $m = parse_url($observer_hash);
+ if ($m && $m['scheme'] && $m['host']) {
+ if (! check_siteallowed($m['scheme'] . '://' . $m['host'])) {
+ http_status_exit(404,'Permission denied');
+ }
+ }
+
+ if (is_array($AS->actor) && array_key_exists('id',$AS->actor)) {
+ Activity::actor_store($AS->actor['id'],$AS->actor);
+ }
+
+ if (is_array($AS->obj) && ActivityStreams::is_an_actor($AS->obj['type'])) {
+ Activity::actor_store($AS->obj['id'],$AS->obj);
+ }
+
+ if (is_array($AS->obj) && is_array($AS->obj['actor']) && array_key_exists('id',$AS->obj['actor']) && $AS->obj['actor']['id'] !== $AS->actor['id']) {
+ Activity::actor_store($AS->obj['actor']['id'],$AS->obj['actor']);
+ }
+
+ $test = q("update hubloc set hubloc_connected = '%s' where hubloc_hash = '%s' and hubloc_network = 'activitypub'",
+ dbesc(datetime_convert()),
+ dbesc($observer_hash)
+ );
+ // $test is ignored
+
+
+ if ($is_public) {
+
+ if ($AS->type === 'Follow' && $AS->obj && ActivityStreams::is_an_actor($AS->obj['type'])) {
+ $channels = q("SELECT * from channel where channel_address = '%s' and channel_removed = 0 ",
+ dbesc(basename($AS->obj['id']))
+ );
+ }
+ else {
+ // deliver to anybody following $AS->actor
+
+ $channels = q("SELECT * from channel where channel_id in ( SELECT abook_channel from abook left join xchan on abook_xchan = xchan_hash WHERE xchan_network = 'activitypub' and xchan_hash = '%s' ) and channel_removed = 0 ",
+ dbesc($observer_hash)
+ );
+ if (! $channels) {
+ $channels = [];
+ }
+
+ $parent = $AS->parent_id;
+ if ($parent) {
+ // this is a comment - deliver to everybody who owns the parent
+ $owners = q("SELECT * from channel where channel_id in ( SELECT uid from item where mid = '%s' ) ",
+ dbesc($parent)
+ );
+ if ($owners) {
+ $channels = array_merge($channels,$owners);
+ }
+ }
+ }
+
+ if ($channels === false) {
+ $channels = [];
+ }
+
+ if (in_array(ACTIVITY_PUBLIC_INBOX,$AS->recips)) {
+
+ // look for channels with send_stream = PERMS_PUBLIC
+
+ $r = q("select * from channel where channel_id in (select uid from pconfig where cat = 'perm_limits' and k = 'send_stream' and v = '1' ) and channel_removed = 0 ");
+ if ($r) {
+ $channels = array_merge($channels,$r);
+ }
+
+ if (! $sys_disabled) {
+ $channels[] = get_sys_channel();
+ }
+
+ }
+
+ }
+
+ if (! $channels) {
+ logger('no deliveries on this site');
+ return;
+ }
+
+ $saved_recips = [];
+ foreach ( [ 'to', 'cc', 'audience' ] as $x ) {
+ if (array_key_exists($x,$AS->data)) {
+ $saved_recips[$x] = $AS->data[$x];
+ }
+ }
+ $AS->set_recips($saved_recips);
+
+
+ foreach ($channels as $channel) {
+
+ if (! get_pconfig($channel['channel_id'],'system','activitypub',true)) {
+ continue;
+ }
+
+ logger('inbox_channel: ' . $channel['channel_address'],LOGGER_DEBUG);
+
+ switch ($AS->type) {
+ case 'Follow':
+ if ($AS->obj & ActivityStreams::is_an_actor($AS->obj['type'])) {
+ // do follow activity
+ Activity::follow($channel,$AS);
+ }
+ break;
+ case 'Accept':
+ if ($AS->obj & $AS->obj['type'] === 'Follow') {
+ // do follow activity
+ Activity::follow($channel,$AS);
+ }
+ break;
+
+ case 'Reject':
+
+ default:
+ break;
+
+ }
+
+ // These activities require permissions
+
+ $item = null;
+
+ switch ($AS->type) {
+ case 'Update':
+ if (is_array($AS->obj) && array_key_exists('type',$AS->obj) && ActivityStreams::is_an_actor($AS->obj['type'])) {
+ // pretend this is an old cache entry to force an update of all the actor details
+ $AS->obj['cached'] = true;
+ $AS->obj['updated'] = datetime_convert('UTC','UTC','1980-01-01', ATOM_TIME);
+ Activity::actor_store($AS->obj['id'],$AS->obj);
+ break;
+ }
+ case 'Create':
+ case 'Like':
+ case 'Dislike':
+ case 'Announce':
+ case 'Accept':
+ case 'Reject':
+ case 'TentativeAccept':
+ case 'TentativeReject':
+ case 'emojiReaction':
+ // These require a resolvable object structure
+ if (is_array($AS->obj)) {
+ $item = Activity::decode_note($AS);
+ // @wip replies must go to the replyTo endpoint if the top level post originated here.
+ //if ($item['mid'] !== $item['parent_mid'] && stripos(z_root(), $item['parent_mid']) === 0) {
+ // $item = null;
+ // break;
+ //}
+ }
+ else {
+ logger('unresolved object: ' . print_r($AS->obj,true));
+ }
+ break;
+ case 'Undo':
+ if ($AS->obj & $AS->obj['type'] === 'Follow') {
+ // do unfollow activity
+ Activity::unfollow($channel,$AS);
+ break;
+ }
+ case 'Delete':
+ Activity::drop($channel,$observer_hash,$AS);
+ break;
+ case 'Add':
+ case 'Remove':
+ default:
+ break;
+
+ }
+
+ if ($item) {
+ logger('parsed_item: ' . print_r($item,true),LOGGER_DATA);
+ Activity::store($channel,$observer_hash,$AS,$item);
+ }
+
+ }
+
+ http_status_exit(200,'OK');
+ }
+
+ function get() {
+
+ }
+
+}
+
+
+
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php
index 7c72eadf4..15fce34f0 100644
--- a/Zotlabs/Module/Item.php
+++ b/Zotlabs/Module/Item.php
@@ -4,12 +4,14 @@ namespace Zotlabs\Module;
/**
*
- * This is the POST destination for most all locally posted
+ * As a GET request, this module answers to activitypub and zot6 item fetches and
+ * acts as a permalink for local content.
+ *
+ * Otherwise this is the POST destination for most all locally posted
* text stuff. This function handles status, wall-to-wall status,
* local comments, and remote coments that are posted on this site
* (as opposed to being delivered in a feed).
- * Also processed here are posts and comments coming through the
- * statusnet/twitter API.
+ * Also processed here are posts and comments coming through the API.
* All of these become an "item" which is our basic unit of
* information.
* Posts that originate externally or do not fall into the above
@@ -29,7 +31,10 @@ use Zotlabs\Lib\Config;
use Zotlabs\Lib\IConfig;
use Zotlabs\Lib\Enotify;
use Zotlabs\Lib\Apps;
+use Zotlabs\Access\PermissionLimits;
+use Zotlabs\Access\AccessControl;
use App;
+use URLify;
require_once('include/attach.php');
require_once('include/bbcode.php');
@@ -54,8 +59,9 @@ class Item extends Controller {
$i = null;
// do we have the item (at all)?
+ // add preferential bias to item owners (item_wall = 1)
- $r = q("select * from item where mid = '%s' or uuid = '%s' $item_normal limit 1",
+ $r = q("select * from item where mid = '%s' or uuid = '%s' $item_normal order by item_wall desc limit 1",
dbesc(z_root() . '/item/' . $item_id),
dbesc($item_id)
);
@@ -88,11 +94,12 @@ class Item extends Controller {
}
// if we don't have a parent id belonging to the signer see if we can obtain one as a visitor that we have permission to access
+ // with a bias towards those items owned by channels on this site (item_wall = 1)
$sql_extra = item_permissions_sql(0);
if (! $i) {
- $i = q("select id as item_id from item where mid = '%s' $item_normal $sql_extra limit 1",
+ $i = q("select id as item_id from item where mid = '%s' $item_normal $sql_extra order by item_wall desc limit 1",
dbesc($r[0]['parent_mid'])
);
}
@@ -114,7 +121,7 @@ class Item extends Controller {
if(! perm_is_allowed($chan['channel_id'],get_observer_hash(),'view_stream'))
http_status_exit(403, 'Forbidden');
- $i = Activity::encode_item($items[0],((defined('NOMADIC')) ? false : true));
+ $i = Activity::encode_item($items[0],((get_config('system','activitypub')) ? true : false));
if(! $i)
http_status_exit(404, 'Not found');
@@ -189,11 +196,12 @@ class Item extends Controller {
}
// if we don't have a parent id belonging to the signer see if we can obtain one as a visitor that we have permission to access
-
+ // with a bias towards those items owned by channels on this site (item_wall = 1)
+
$sql_extra = item_permissions_sql(0);
if (! $i) {
- $i = q("select id as item_id from item where mid = '%s' $item_normal $sql_extra limit 1",
+ $i = q("select id as item_id from item where mid = '%s' $item_normal $sql_extra order by item_wall desc limit 1",
dbesc($r[0]['parent_mid'])
);
}
@@ -259,7 +267,7 @@ class Item extends Controller {
if(! perm_is_allowed($chan['channel_id'],get_observer_hash(),'view_stream'))
http_status_exit(403, 'Forbidden');
- $i = Activity::encode_item_collection($nitems,'conversation/' . $item_id,'OrderedCollection',( defined('NOMADIC') ? false : true));
+ $i = Activity::encode_item_collection($nitems,'conversation/' . $item_id,'OrderedCollection',( get_config('system','activitypub') ? true : false));
if($portable_id) {
ThreadListener::store(z_root() . '/item/' . $item_id,$portable_id);
}
@@ -286,12 +294,17 @@ class Item extends Controller {
}
- if(argc() > 1 && argv(1) !== 'drop') {
- $x = q("select uid, item_wall, llink, mid from item where mid = '%s' ",
- dbesc(z_root() . '/item/' . argv(1))
+ // if it isn't a drop command and isn't a post method and wasn't handled already,
+ // the default action is a browser request for a persistent uri and this should return
+ // the text/html page of the item.
+
+ if (argc() > 1 && argv(1) !== 'drop') {
+ $x = q("select uid, item_wall, llink, mid from item where mid = '%s' or mid = '%s' ",
+ dbesc(z_root() . '/item/' . argv(1)),
+ dbesc(z_root() . '/activity/' . argv(1))
);
- if($x) {
- foreach($x as $xv) {
+ if ($x) {
+ foreach ($x as $xv) {
if (intval($xv['item_wall'])) {
$c = channelx_by_n($xv['uid']);
if ($c) {
@@ -307,12 +320,20 @@ class Item extends Controller {
function post() {
- // This will change. Figure out who the observer is and whether or not
- // they have permission to post here. Else ignore the post.
-
if((! local_channel()) && (! remote_channel()) && (! x($_REQUEST,'anonname')))
return;
+ // drop an array of items.
+
+ if (x($_REQUEST,'dropitems')) {
+ $arr_drop = explode(',',$_REQUEST['dropitems']);
+ drop_items($arr_drop);
+ $json = array('success' => 1);
+ echo json_encode($json);
+ killme();
+ }
+
+
$uid = local_channel();
$channel = null;
$observer = null;
@@ -323,34 +344,35 @@ class Item extends Controller {
* Is this a reply to something?
*/
- $parent = ((x($_REQUEST,'parent')) ? intval($_REQUEST['parent']) : 0);
+ $parent = ((x($_REQUEST,'parent')) ? intval($_REQUEST['parent']) : 0);
$parent_mid = ((x($_REQUEST,'parent_mid')) ? trim($_REQUEST['parent_mid']) : '');
- $remote_xchan = ((x($_REQUEST,'remote_xchan')) ? trim($_REQUEST['remote_xchan']) : false);
+ /**
+ * Who is viewing this page and posting this thing
+ */
+
+ $remote_xchan = ((x($_REQUEST,'remote_xchan')) ? trim($_REQUEST['remote_xchan']) : false);
$remote_observer = xchan_match( ['xchan_hash' => $remote_xchan ] );
- if(! $remote_observer) {
+ if (! $remote_observer) {
$remote_xchan = $remote_observer = false;
}
+ // This is the local channel representing who the posted item will belong to.
+
$profile_uid = ((x($_REQUEST,'profile_uid')) ? intval($_REQUEST['profile_uid']) : 0);
+ // *If* you are logged in as the site admin you are allowed to create items for the sys channel.
+ // This would typically be a webpage or webpage element.
+
$sys = get_sys_channel();
- if($sys && $profile_uid && ($sys['channel_id'] == $profile_uid) && is_site_admin()) {
+ if ($sys && $profile_uid && ($sys['channel_id'] == $profile_uid) && is_site_admin()) {
$uid = intval($sys['channel_id']);
$channel = $sys;
$observer = $sys;
}
-
- if(x($_REQUEST,'dropitems')) {
- $arr_drop = explode(',',$_REQUEST['dropitems']);
- drop_items($arr_drop);
- $json = array('success' => 1);
- echo json_encode($json);
- killme();
- }
-
+
call_hooks('post_local_start', $_REQUEST);
// logger('postvars ' . print_r($_REQUEST,true), LOGGER_DATA);
@@ -359,7 +381,18 @@ class Item extends Controller {
$consensus = intval($_REQUEST['consensus']);
$nocomment = intval($_REQUEST['nocomment']);
-
+
+ // If this is a poll, grab the poll data
+
+ $qtype = intval($_REQUEST['qtype']);
+ if($_REQUEST['answers'] && is_array($_REQUEST['answers'])) {
+ $pollchoices = [];
+ foreach($_REQUEST['answers'] as $q) {
+ $pollchoices[] = escape_tags($q);
+ }
+ $_REQUEST['obj_type'] = ACTIVITY_OBJ_POLL;
+ }
+
// 'origin' (if non-zero) indicates that this network is where the message originated,
// for the purpose of relaying comments to other conversation members.
// If using the API from a device (leaf node) you must set origin to 1 (default) or leave unset.
@@ -410,10 +443,14 @@ class Item extends Controller {
}
}
- if($pagetitle) {
- $pagetitle = strtolower(\URLify::transliterate($pagetitle));
+ if ($pagetitle) {
+ $pagetitle = strtolower(URLify::transliterate($pagetitle));
}
+ /**
+ * process collections by tagging them
+ */
+
if (array_key_exists('collections',$_REQUEST) && is_array($_REQUEST['collections']) && count($_REQUEST['collections'])) {
foreach ($_REQUEST['collections'] as $clct) {
$r = q("select xchan_url, xchan_hash from xchan left join hubloc on hubloc_hash = xchan_hash where hubloc_addr = '%s' limit 1",
@@ -443,21 +480,27 @@ class Item extends Controller {
$thr_parent = '';
$parid = 0;
$r = false;
+
+
+ // If this is a comment, find the parent and preset some stuff
+
+ if ($parent || $parent_mid) {
- if($parent || $parent_mid) {
-
- if(! x($_REQUEST,'type'))
+ if (! x($_REQUEST,'type')) {
$_REQUEST['type'] = 'net-comment';
-
- if($obj_type == ACTIVITY_OBJ_NOTE)
+ }
+ if ($obj_type == ACTIVITY_OBJ_NOTE) {
$obj_type = ACTIVITY_OBJ_COMMENT;
-
- if($parent) {
+ }
+
+ // fetch the parent item
+
+ if ($parent) {
$r = q("SELECT * FROM item WHERE id = %d LIMIT 1",
intval($parent)
);
}
- elseif($parent_mid && $uid) {
+ elseif ($parent_mid && $uid) {
// This is coming from an API source, and we are logged in
$r = q("SELECT * FROM item WHERE mid = '%s' AND uid = %d LIMIT 1",
dbesc($parent_mid),
@@ -465,29 +508,31 @@ class Item extends Controller {
);
}
// if this isn't the real parent of the conversation, find it
- if($r) {
+ if ($r) {
$parid = $r[0]['parent'];
$parent_mid = $r[0]['mid'];
- if($r[0]['id'] != $r[0]['parent']) {
+ if ($r[0]['id'] != $r[0]['parent']) {
$r = q("SELECT * FROM item WHERE id = parent AND parent = %d LIMIT 1",
intval($parid)
);
}
- // if interacting with a pubstream item,
+ // if interacting with a pubstream item (owned by the sys channel),
// create a copy of the parent in your stream
- if($r[0]['uid'] === $sys['channel_id'] && local_channel()) {
+ if ($r[0]['uid'] === $sys['channel_id'] && local_channel()) {
$r = [ copy_of_pubitem(App::get_channel(), $r[0]['mid']) ];
}
}
- if(! $r) {
+ if (! $r) {
notice( t('Unable to locate original post.') . EOL);
- if($api_source)
- return ( [ 'success' => false, 'message' => 'invalid post id' ] );
- if(x($_REQUEST,'return'))
+ if ($api_source) {
+ return ( [ 'success' => false, 'message' => 'invalid post id' ] );
+ }
+ if (x($_REQUEST,'return')) {
goaway(z_root() . "/" . $return_path );
+ }
killme();
}
@@ -506,27 +551,30 @@ class Item extends Controller {
$moderated = false;
- if(! $observer) {
+ if (! $observer) {
$observer = App::get_observer();
- if(! $observer) {
+ if (! $observer) {
+ // perhaps we're allowing moderated comments from anonymous viewers
$observer = anon_identity_init($_REQUEST);
- if($observer) {
+ if ($observer) {
$moderated = true;
$remote_xchan = $remote_observer = $observer;
}
}
}
- if(! $observer) {
+ if (! $observer) {
notice( t('Permission denied.') . EOL) ;
- if($api_source)
- return ( [ 'success' => false, 'message' => 'permission denied' ] );
- if(x($_REQUEST,'return'))
+ if ($api_source) {
+ return ( [ 'success' => false, 'message' => 'permission denied' ] );
+ }
+ if (x($_REQUEST,'return')) {
goaway(z_root() . "/" . $return_path );
+ }
killme();
}
- if($parent) {
+ if ($parent) {
logger('mod_item: item_post parent=' . $parent);
$can_comment = false;
@@ -547,6 +595,7 @@ class Item extends Controller {
}
}
else {
+ // fixme - $webpage could also be a wiki page or article and require a different permission to be checked.
if(! perm_is_allowed($profile_uid,$observer['xchan_hash'],($webpage) ? 'write_pages' : 'post_wall')) {
notice( t('Permission denied.') . EOL) ;
if($api_source)
@@ -556,13 +605,16 @@ class Item extends Controller {
killme();
}
}
-
+
+ // check if this author is being moderated through the 'moderated' (negative) permission
+ // when posting wall-to-wall
if ($moderated === false && intval($uid) !== intval($profile_uid)) {
$moderated = perm_is_allowed($profile_uid,$observer['xchan_hash'],'moderated');
}
-
+
+ // If this is a comment, check the moderated permission of the parent; who may be on another site
$remote_moderated = (($parent) ? their_perms_contains($profile_uid,$parent_item['owner_xchan'],'moderated') : false);
- if($remote_moderated) {
+ if ($remote_moderated) {
notice( t('Comment may be moderated.') . EOL);
}
@@ -570,7 +622,7 @@ class Item extends Controller {
$orig_post = null;
- if($namespace && $remote_id) {
+ if ($namespace && $remote_id) {
// It wasn't an internally generated post - see if we've got an item matching this remote service id
$i = q("select iid from iconfig where cat = 'system' and k = '%s' and v = '%s' limit 1",
dbesc($namespace),
@@ -661,10 +713,10 @@ class Item extends Controller {
}
}
- $acl = new \Zotlabs\Access\AccessControl($channel);
+ $acl = new AccessControl($channel);
- $view_policy = \Zotlabs\Access\PermissionLimits::Get($channel['channel_id'],'view_stream');
- $comment_policy = \Zotlabs\Access\PermissionLimits::Get($channel['channel_id'],'post_comments');
+ $view_policy = PermissionLimits::Get($channel['channel_id'],'view_stream');
+ $comment_policy = PermissionLimits::Get($channel['channel_id'],'post_comments');
$public_policy = ((x($_REQUEST,'public_policy')) ? escape_tags($_REQUEST['public_policy']) : map_scope($view_policy,true));
if($webpage)
@@ -684,9 +736,9 @@ class Item extends Controller {
$private = $orig_post['item_private'];
}
- if($private || $public_policy || $acl->is_private())
- $private = 1;
-
+ if($public_policy || $acl->is_private()) {
+ $private = (($private) ? $private : 1);
+ }
$location = $orig_post['location'];
$coord = $orig_post['coord'];
@@ -763,14 +815,14 @@ class Item extends Controller {
$allow_empty = ((array_key_exists('allow_empty',$_REQUEST)) ? intval($_REQUEST['allow_empty']) : 0);
- $private = intval($acl->is_private() || ($public_policy));
+ $private = (($private) ? $private : intval($acl->is_private() || ($public_policy)));
// If this is a comment, set the permissions from the parent.
if($parent_item) {
$private = 0;
$acl->set($parent_item);
- $private = intval($acl->is_private() || $parent_item['item_private']);
+ $private = ((intval($parent_item['item_private']) ? $parent_item['item_private'] : $acl->is_private()));
$public_policy = $parent_item['public_policy'];
$owner_hash = $parent_item['owner_xchan'];
$webpage = $parent_item['item_type'];
@@ -875,7 +927,12 @@ class Item extends Controller {
}
}
}
-
+
+ if(($str_contact_allow) && (! $str_group_allow)) {
+ // direct message - private between individual channels but not groups
+ $private = 2;
+ }
+
/**
*
@@ -1102,7 +1159,9 @@ class Item extends Controller {
$plink = z_root() . '/item/' . $uuid;
}
-
+
+
+
$datarray['aid'] = $channel['channel_account_id'];
$datarray['uid'] = $profile_uid;
$datarray['uuid'] = $uuid;
@@ -1168,7 +1227,7 @@ class Item extends Controller {
if(! array_key_exists('obj',$datarray)) {
$copy = $datarray;
$copy['author'] = $observer;
- $datarray['obj'] = Activity::encode_item($copy,((defined('NOMADIC')) ? false : true));
+ $datarray['obj'] = Activity::encode_item($copy,((get_config('system','activitypub')) ? true : false));
}
// A specific ACL over-rides public_policy completely
@@ -1176,9 +1235,15 @@ class Item extends Controller {
if(! empty_acl($datarray))
$datarray['public_policy'] = '';
- if($iconfig)
+ if ($iconfig) {
$datarray['iconfig'] = $iconfig;
-
+ }
+ if ($private) {
+ IConfig::set($datarray,'ocap','relay',new_token());
+ }
+
+
+
// preview mode - prepare the body for display and send it via json
if($preview) {
@@ -1422,13 +1487,14 @@ class Item extends Controller {
if((argc() == 3) && (argv(1) === 'drop') && intval(argv(2))) {
- $i = q("select id, uid, item_origin, author_xchan, owner_xchan, source_xchan, item_type from item where id = %d limit 1",
+ $i = q("select * from item where id = %d limit 1",
intval(argv(2))
);
if($i) {
$can_delete = false;
$local_delete = false;
+ $regular_delete = false;
if(local_channel() && local_channel() == $i[0]['uid']) {
$local_delete = true;
@@ -1437,6 +1503,7 @@ class Item extends Controller {
$ob_hash = get_observer_hash();
if($ob_hash && ($ob_hash === $i[0]['author_xchan'] || $ob_hash === $i[0]['owner_xchan'] || $ob_hash === $i[0]['source_xchan'])) {
$can_delete = true;
+ $regular_delete = true;
}
// The site admin can delete any post/item on the site.
@@ -1454,7 +1521,36 @@ class Item extends Controller {
notice( t('Permission denied.') . EOL);
return;
}
-
+
+ if ($i[0]['resource_type'] === 'event') {
+ // delete and sync the event separately
+ $r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
+ dbesc($i[0]['resource_id']),
+ intval($i[0]['uid'])
+ );
+ if ($r && $regular_delete) {
+ $sync_event = $r[0];
+ q("delete from event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
+ dbesc($i[0]['resource_id']),
+ intval($i[0]['uid'])
+ );
+ $sync_event['event_deleted'] = 1;
+ Libsync::build_sync_packet($i[0]['uid'],array('event' => array($sync_event)));
+ }
+ }
+
+ if ($i[0]['resource_type'] === 'photo') {
+ attach_delete($i[0]['uid'], $i[0]['resource_id'], true );
+ $ch = channelx_by_n($i[0]['uid']);
+ if ($ch && $regular_delete) {
+ $sync = attach_export_data($ch,$i[0]['resource_id'], true);
+ if ($sync) {
+ Libsync::build_sync_packet($i[0]['uid'],array('file' => array($sync)));
+ }
+ }
+ }
+
+
// if this is a different page type or it's just a local delete
// but not by the item author or owner, do a simple deletion
diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php
index ffce7bb86..1441b3d10 100644
--- a/Zotlabs/Module/Like.php
+++ b/Zotlabs/Module/Like.php
@@ -1,6 +1,7 @@
channel_url($ch[0]) ]));
-
+
// second like of the same thing is "undo" for the first like
$z = q("select * from likes where channel_id = %d and liker = '%s' and verb = '%s' and target_type = '%s' and target_id = '%s' limit 1",
@@ -234,7 +235,7 @@ class Like extends Controller {
if($r) {
if($r[0]['uid'] === $sys_channel['channel_id'] && local_channel()) {
- $r = [ copy_of_pubitem(\App::get_channel(), $r[0]['mid']) ];
+ $r = [ copy_of_pubitem(App::get_channel(), $r[0]['mid']) ];
}
}
@@ -283,8 +284,10 @@ class Like extends Controller {
$multi_undo = false;
- $item_normal = item_normal();
-
+ $item_normal = " and item.item_deleted = 0 and item.item_unpublished = 0 and item.item_delayed = 0
+ and item.item_pending_remove = 0 and item.item_blocked = 0 and item.obj_type != '" . ACTIVITY_OBJ_FILE . "' ";
+
+
$r = q("SELECT id, parent, uid, verb FROM item WHERE verb in ( $verbs ) $item_normal
AND author_xchan = '%s' AND thr_parent = '%s' and uid = %d ",
dbesc($observer['xchan_hash']),
@@ -360,6 +363,16 @@ class Like extends Controller {
$r = q("update item set item_hidden = 0 where id = %d",
intval($item['id'])
);
+
+ $r = q("select * from item where id = %d",
+ intval($item['id'])
+ );
+ if($r) {
+ xchan_query($r);
+ $sync_item = fetch_post_tags($r);
+ Libsync::build_sync_packet($ch[0]['channel_id'], [ 'item' => [ encode_item($sync_item[0],true) ] ]);
+ }
+
Master::Summon(array('Notifier','wall-new',$item['id']));
}
diff --git a/Zotlabs/Module/Linkinfo.php b/Zotlabs/Module/Linkinfo.php
index 0e8f0a986..5ad45547d 100644
--- a/Zotlabs/Module/Linkinfo.php
+++ b/Zotlabs/Module/Linkinfo.php
@@ -138,6 +138,15 @@ class Linkinfo extends Controller {
$x = Activity::fetch($url);
if (is_array($x)) {
$y = new ActivityStreams($x);
+ if ($y->is_valid() && $y->type === 'Announce' && is_array($y->obj)
+ && array_key_exists('object',$y->obj) && array_key_exists('actor',$y->obj)) {
+ // This is a relayed/forwarded Activity (as opposed to a shared/boosted object)
+ // Reparse the encapsulated Activity and use that instead
+ logger('relayed activity',LOGGER_DEBUG);
+ $y = new ActivityStreams($y->obj);
+ }
+
+
if ($y->is_valid()) {
$z = Activity::decode_note($y);
$r = q("select hubloc_hash, hubloc_network, hubloc_url from hubloc where hubloc_hash = '%s' OR hubloc_id_url = '%s'",
diff --git a/Zotlabs/Module/Lists.php b/Zotlabs/Module/Lists.php
new file mode 100644
index 000000000..404e992d9
--- /dev/null
+++ b/Zotlabs/Module/Lists.php
@@ -0,0 +1,356 @@
+ [
+ ACTIVITYSTREAMS_JSONLD_REV,
+ 'https://w3id.org/security/v1',
+ z_root() . ZOT_APSCHEMA_REV
+ ]], Activity::encode_follow_collection($members, App::$query_string, 'OrderedCollection'));
+
+
+ $headers = [];
+ $headers['Content-Type'] = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' ;
+ $x['signature'] = LDSignatures::sign($x,$channel);
+ $ret = json_encode($x, JSON_UNESCAPED_SLASHES);
+ $headers['Digest'] = HTTPSig::generate_digest_header($ret);
+ $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI'];
+ $h = HTTPSig::create_sig($headers,$channel['channel_prvkey'],channel_url($channel));
+ HTTPSig::set_headers($h);
+ echo $ret;
+ killme();
+
+ }
+
+ if (! local_channel()) {
+ notice( t('Permission denied.') . EOL);
+ return;
+ }
+
+ App::$profile_uid = local_channel();
+ nav_set_selected('Access Lists');
+ }
+
+ function post() {
+
+ if (! local_channel()) {
+ notice( t('Permission denied.') . EOL);
+ return;
+ }
+
+ if ((argc() == 2) && (argv(1) === 'new')) {
+ check_form_security_token_redirectOnErr('/lists/new', 'group_edit');
+
+ $name = notags(trim($_POST['groupname']));
+ $public = intval($_POST['public']);
+ $r = AccessList::add(local_channel(),$name,$public);
+ if ($r) {
+ info( t('Access list created.') . EOL );
+ }
+ else {
+ notice( t('Could not create access list.') . EOL );
+ }
+ goaway(z_root() . '/lists');
+
+ }
+ if ((argc() == 2) && (intval(argv(1)))) {
+ check_form_security_token_redirectOnErr('/lists', 'group_edit');
+
+ $r = q("SELECT * FROM pgrp WHERE id = %d AND uid = %d LIMIT 1",
+ intval(argv(1)),
+ intval(local_channel())
+ );
+ if (! $r) {
+ notice( t('Access list not found.') . EOL );
+ goaway(z_root() . '/connections');
+
+ }
+ $group = array_shift($r);
+ $groupname = notags(trim($_POST['groupname']));
+ $public = intval($_POST['public']);
+
+ if ((strlen($groupname)) && (($groupname != $group['gname']) || ($public != $group['visible']))) {
+ $r = q("UPDATE pgrp SET gname = '%s', visible = %d WHERE uid = %d AND id = %d",
+ dbesc($groupname),
+ intval($public),
+ intval(local_channel()),
+ intval($group['id'])
+ );
+ if ($r) {
+ info( t('Access list updated.') . EOL );
+ }
+ Libsync::build_sync_packet(local_channel(),null,true);
+ }
+
+ goaway(z_root() . '/lists/' . argv(1) . '/' . argv(2));
+ }
+ return;
+ }
+
+ function get() {
+
+ $change = false;
+
+ logger('mod_lists: ' . \App::$cmd,LOGGER_DEBUG);
+
+ if (! local_channel()) {
+ notice( t('Permission denied') . EOL);
+ return;
+ }
+
+ // Switch to text mode interface if we have more than 'n' contacts or group members
+ $switchtotext = get_pconfig(local_channel(),'system','groupedit_image_limit');
+ if ($switchtotext === false) {
+ $switchtotext = get_config('system','groupedit_image_limit');
+ }
+ if ($switchtotext === false) {
+ $switchtotext = 400;
+ }
+
+
+ if ((argc() == 1) || ((argc() == 2) && (argv(1) === 'new'))) {
+
+ $new = (((argc() == 2) && (argv(1) === 'new')) ? true : false);
+
+ $groups = q("SELECT id, gname FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
+ intval(local_channel())
+ );
+
+ $i = 0;
+ foreach ($groups as $group) {
+ $entries[$i]['name'] = $group['gname'];
+ $entries[$i]['id'] = $group['id'];
+ $entries[$i]['count'] = count(AccessList::members(local_channel(),$group['id']));
+ $i++;
+ }
+
+ $tpl = get_markup_template('privacy_groups.tpl');
+ $o = replace_macros($tpl, [
+ '$title' => t('Access Lists'),
+ '$add_new_label' => t('Create access list'),
+ '$new' => $new,
+
+ // new group form
+ '$gname' => array('groupname',t('Access list name')),
+ '$public' => array('public',t('Members are visible to other channels'), false),
+ '$form_security_token' => get_form_security_token("group_edit"),
+ '$submit' => t('Submit'),
+
+ // groups list
+ '$title' => t('Access Lists'),
+ '$name_label' => t('Name'),
+ '$count_label' => t('Members'),
+ '$entries' => $entries
+ ]);
+
+ return $o;
+
+ }
+
+
+
+
+ $context = array('$submit' => t('Submit'));
+ $tpl = get_markup_template('group_edit.tpl');
+
+ if((argc() == 3) && (argv(1) === 'drop')) {
+ check_form_security_token_redirectOnErr('/lists', 'group_drop', 't');
+
+ if(intval(argv(2))) {
+ $r = q("SELECT gname FROM pgrp WHERE id = %d AND uid = %d LIMIT 1",
+ intval(argv(2)),
+ intval(local_channel())
+ );
+ if($r)
+ $result = AccessList::remove(local_channel(),$r[0]['gname']);
+ if($result)
+ info( t('Access list removed.') . EOL);
+ else
+ notice( t('Unable to remove access list.') . EOL);
+ }
+ goaway(z_root() . '/lists');
+ // NOTREACHED
+ }
+
+
+ if((argc() > 2) && intval(argv(1)) && argv(2)) {
+
+ check_form_security_token_ForbiddenOnErr('group_member_change', 't');
+
+ $r = q("SELECT abook_xchan from abook left join xchan on abook_xchan = xchan_hash where abook_xchan = '%s' and abook_channel = %d and xchan_deleted = 0 and abook_self = 0 and abook_blocked = 0 and abook_pending = 0 limit 1",
+ dbesc(base64url_decode(argv(2))),
+ intval(local_channel())
+ );
+ if(count($r))
+ $change = base64url_decode(argv(2));
+
+ }
+
+ if((argc() > 1) && (intval(argv(1)))) {
+
+ require_once('include/acl_selectors.php');
+ $r = q("SELECT * FROM pgrp WHERE id = %d AND uid = %d AND deleted = 0 LIMIT 1",
+ intval(argv(1)),
+ intval(local_channel())
+ );
+ if(! $r) {
+ notice( t('Access list not found.') . EOL );
+ goaway(z_root() . '/connections');
+ }
+ $group = $r[0];
+
+
+ $members = AccessList::members(local_channel(), $group['id']);
+
+ $preselected = array();
+ if(count($members)) {
+ foreach($members as $member)
+ if(! in_array($member['xchan_hash'],$preselected))
+ $preselected[] = $member['xchan_hash'];
+ }
+
+ if($change) {
+
+ if(in_array($change,$preselected)) {
+ AccessList::member_remove(local_channel(),$group['gname'],$change);
+ }
+ else {
+ AccessList::member_add(local_channel(),$group['gname'],$change);
+ }
+
+ $members = AccessList::members(local_channel(), $group['id']);
+
+ $preselected = array();
+ if(count($members)) {
+ foreach($members as $member)
+ $preselected[] = $member['xchan_hash'];
+ }
+ }
+
+ $context = $context + array(
+ '$title' => sprintf(t('Access List: %s'), $group['gname']),
+ '$details_label' => t('Edit'),
+ '$gname' => array('groupname',t('Access list name: '),$group['gname'], ''),
+ '$gid' => $group['id'],
+ '$drop' => $drop_txt,
+ '$public' => array('public',t('Members are visible to other channels'), $group['visible'], ''),
+ '$form_security_token_edit' => get_form_security_token('group_edit'),
+ '$delete' => t('Delete access list'),
+ '$form_security_token_drop' => get_form_security_token("group_drop"),
+ );
+
+ }
+
+ if(! isset($group))
+ return;
+
+ $groupeditor = array(
+ 'label_members' => t('List members'),
+ 'members' => array(),
+ 'label_contacts' => t('Not in this list'),
+ 'contacts' => array(),
+ );
+
+ $sec_token = addslashes(get_form_security_token('group_member_change'));
+ $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : 'card');
+ foreach($members as $member) {
+ if($member['xchan_url']) {
+ $member['archived'] = (intval($member['abook_archived']) ? true : false);
+ $member['click'] = 'groupChangeMember(' . $group['id'] . ',\'' . base64url_encode($member['xchan_hash']) . '\',\'' . $sec_token . '\'); return false;';
+ $groupeditor['members'][] = micropro($member,true,'mpgroup', $textmode);
+ }
+ else
+ AccessList::member_remove(local_channel(),$group['gname'],$member['xchan_hash']);
+ }
+
+ $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d AND abook_self = 0 and abook_blocked = 0 and abook_pending = 0 and xchan_deleted = 0 order by xchan_name asc",
+ intval(local_channel())
+ );
+
+ if(count($r)) {
+ $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : 'card');
+ foreach($r as $member) {
+ if(! in_array($member['xchan_hash'],$preselected)) {
+ $member['archived'] = (intval($member['abook_archived']) ? true : false);
+ $member['click'] = 'groupChangeMember(' . $group['id'] . ',\'' . base64url_encode($member['xchan_hash']) . '\',\'' . $sec_token . '\'); return false;';
+ $groupeditor['contacts'][] = micropro($member,true,'mpall', $textmode);
+ }
+ }
+ }
+
+ $context['$groupeditor'] = $groupeditor;
+ $context['$desc'] = t('Select a channel to toggle membership');
+
+ if($change) {
+ $tpl = get_markup_template('groupeditor.tpl');
+ echo replace_macros($tpl, $context);
+ killme();
+ }
+
+ return replace_macros($tpl, $context);
+
+ }
+
+
+}
diff --git a/Zotlabs/Module/Lockview.php b/Zotlabs/Module/Lockview.php
index d7ed07a53..8c8519c57 100644
--- a/Zotlabs/Module/Lockview.php
+++ b/Zotlabs/Module/Lockview.php
@@ -76,7 +76,7 @@ class Lockview extends \Zotlabs\Web\Controller {
killme();
}
- if(($item['item_private'] == 1) && (! strlen($item['allow_cid'])) && (! strlen($item['allow_gid']))
+ if(intval($item['item_private']) && (! strlen($item['allow_cid'])) && (! strlen($item['allow_gid']))
&& (! strlen($item['deny_cid'])) && (! strlen($item['deny_gid']))) {
// if the post is private, but public_policy is blank ("visible to the internet"), and there aren't any
diff --git a/Zotlabs/Module/Manage.php b/Zotlabs/Module/Manage.php
index 32c81f1d0..64b09fc74 100644
--- a/Zotlabs/Module/Manage.php
+++ b/Zotlabs/Module/Manage.php
@@ -3,6 +3,7 @@ namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
+use Zotlabs\Lib\PConfig;
require_once('include/security.php');
@@ -20,16 +21,22 @@ class Manage extends Controller {
$change_channel = ((argc() > 1) ? intval(argv(1)) : 0);
- if ((argc() > 2) && (argv(2) === 'default')) {
- $r = q("select channel_id from channel where channel_id = %d and channel_account_id = %d limit 1",
- intval($change_channel),
- intval(get_account_id())
- );
- if ($r) {
- q("update account set account_default_channel = %d where account_id = %d",
+ if (argc() > 2) {
+ if (argv(2) === 'default') {
+ $r = q("select channel_id from channel where channel_id = %d and channel_account_id = %d limit 1",
intval($change_channel),
intval(get_account_id())
);
+ if ($r) {
+ q("update account set account_default_channel = %d where account_id = %d",
+ intval($change_channel),
+ intval(get_account_id())
+ );
+ }
+ }
+ elseif (argv(2) === 'menu') {
+ $state = intval(PConfig::get($change_channel,'system','include_in_menu', 0));
+ PConfig::set($change_channel,'system','include_in_menu',1 - $state);
}
goaway(z_root() . '/manage');
}
@@ -60,6 +67,7 @@ class Manage extends Controller {
$channels = $r;
for ($x = 0; $x < count($channels); $x ++) {
$channels[$x]['link'] = 'manage/' . intval($channels[$x]['channel_id']);
+ $channels[$x]['include_in_menu'] = intval(PConfig::get($channels[$x]['channel_id'],'system','include_in_menu',0));
$channels[$x]['default'] = (($channels[$x]['channel_id'] == $account['account_default_channel']) ? "1" : '');
$channels[$x]['default_links'] = '1';
$channels[$x]['collections_label'] = t('Collection');
@@ -175,6 +183,8 @@ class Manage extends Controller {
'$desc' => t('Switch to one of your channels by selecting it.'),
'$msg_default' => t('Default Channel'),
'$msg_make_default' => t('Make Default'),
+ '$msg_include' => t('Add to menu'),
+ '$msg_no_include' => t('Remove from menu'),
'$create' => $create,
'$all_channels' => $channels,
'$mail_format' => t('%d new messages'),
diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php
index 050bbe0bb..5fb52d48c 100644
--- a/Zotlabs/Module/Network.php
+++ b/Zotlabs/Module/Network.php
@@ -64,7 +64,7 @@ class Network extends Controller {
$category = ((x($_REQUEST,'cat')) ? $_REQUEST['cat'] : '');
$hashtags = ((x($_REQUEST,'tag')) ? $_REQUEST['tag'] : '');
$verb = ((x($_REQUEST,'verb')) ? $_REQUEST['verb'] : '');
-
+ $dm = ((x($_REQUEST,'dm')) ? $_REQUEST['dm'] : 0);
$order = get_pconfig(local_channel(), 'mod_network', 'order', 0);
switch ($order) {
@@ -122,8 +122,8 @@ class Network extends Controller {
$def_acl = [ 'allow_gid' => '<' . $r[0]['hash'] . '>' ];
}
- $default_cmin = ((Apps::system_app_installed(local_channel(),'Affinity Tool')) ? get_pconfig(local_channel(),'affinity','cmin',0) : (-1));
- $default_cmax = ((Apps::system_app_installed(local_channel(),'Affinity Tool')) ? get_pconfig(local_channel(),'affinity','cmax',99) : (-1));
+ $default_cmin = ((Apps::system_app_installed(local_channel(),'Friend Zoom')) ? get_pconfig(local_channel(),'affinity','cmin',0) : (-1));
+ $default_cmax = ((Apps::system_app_installed(local_channel(),'Friend Zoom')) ? get_pconfig(local_channel(),'affinity','cmax',99) : (-1));
$cid = ((x($_GET,'cid')) ? intval($_GET['cid']) : 0);
$star = ((x($_GET,'star')) ? intval($_GET['star']) : 0);
@@ -229,7 +229,7 @@ class Network extends Controller {
if ($group) {
$contact_str = '';
- $contacts = AccessList::members($group);
+ $contacts = AccessList::members(local_channel(),$group);
if ($contacts) {
$contact_str = ids_to_querystr($contacts,'xchan',true);
}
@@ -336,6 +336,7 @@ class Network extends Controller {
'$conv' => (($conv) ? $conv : '0'),
'$spam' => (($spam) ? $spam : '0'),
'$fh' => '0',
+ '$dm' => (($dm) ? $dm : '0'),
'$nouveau' => (($nouveau) ? $nouveau : '0'),
'$wall' => '0',
'$static' => $static,
@@ -382,15 +383,27 @@ class Network extends Controller {
}
if ($verb) {
- $sql_extra .= sprintf(" AND item.verb like '%s' ",
- dbesc(protect_sprintf('%' . $verb . '%'))
- );
+ if (substr($verb,0,1) === '.') {
+ $verb = substr($verb,1);
+ $sql_extra .= sprintf(" AND item.obj_type like '%s' ",
+ dbesc(protect_sprintf('%' . $verb . '%'))
+ );
+ }
+ else {
+ $sql_extra .= sprintf(" AND item.verb like '%s' ",
+ dbesc(protect_sprintf('%' . $verb . '%'))
+ );
+ }
}
if (strlen($file)) {
$sql_extra .= term_query('item',$file,TERM_FILE);
}
+ if ($dm) {
+ $sql_extra .= " and item_private = 2 ";
+ }
+
if ($conv) {
$item_thread_top = '';
diff --git a/Zotlabs/Module/Nocomment.php b/Zotlabs/Module/Nocomment.php
new file mode 100644
index 000000000..c61759247
--- /dev/null
+++ b/Zotlabs/Module/Nocomment.php
@@ -0,0 +1,28 @@
+' . $desc . '';
+
+ if(! ( local_channel() && Apps::system_app_installed(local_channel(),'No Comment'))) {
+ return $text;
+ }
+
+ $desc = t('This app is installed. A button to control the ability to comment may be found below the post editor.');
+
+ $text = '' . $desc . '
';
+
+ return $text;
+
+ }
+}
diff --git a/Zotlabs/Module/Notes.php b/Zotlabs/Module/Notes.php
index a9fc38dbb..a779cec3f 100644
--- a/Zotlabs/Module/Notes.php
+++ b/Zotlabs/Module/Notes.php
@@ -3,7 +3,7 @@ namespace Zotlabs\Module; /** @file */
use Zotlabs\Lib\Libsync;
use Zotlabs\Web\Controller;
-
+use Zotlabs\Lib\Apps;
class Notes extends Controller {
@@ -26,17 +26,38 @@ class Notes extends Controller {
set_pconfig(local_channel(),'notes','text.bak',$old_text);
}
set_pconfig(local_channel(),'notes','text',$body);
- }
+
- // push updates to channel clones
+ // push updates to channel clones
- if((argc() > 1) && (argv(1) === 'sync')) {
- Libsync::build_sync_packet();
- }
+ if((argc() > 1) && (argv(1) === 'sync')) {
+ Libsync::build_sync_packet();
+ }
- logger('notes saved.', LOGGER_DEBUG);
- json_return_and_die($ret);
+ logger('notes saved.', LOGGER_DEBUG);
+ json_return_and_die($ret);
+ }
}
+
+ function get() {
+
+ $desc = t('This app allows you to create private notes for your personal use.');
+
+ $text = '' . $desc . '
';
+
+ if(! ( local_channel() && Apps::system_app_installed(local_channel(),'Notes'))) {
+ return $text;
+ }
+
+ $desc = t('This app is installed. The Notes tool can be found on your network stream page.');
+
+ $text = '' . $desc . '
';
+
+ return $text;
+
+ }
+
+
}
diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php
index 730a81629..7e58b896f 100644
--- a/Zotlabs/Module/Photo.php
+++ b/Zotlabs/Module/Photo.php
@@ -33,7 +33,7 @@ class Photo extends \Zotlabs\Web\Controller {
$channel = channelx_by_n($r[0]['uid']);
$obj = json_decode($r[0]['obj'],true);
- $obj['actor'] = Activity::encode_person($channel,true,((defined('NOMADIC')) ? false : true));
+ $obj['actor'] = Activity::encode_person($channel,true,((get_config('system','activitypub')) ? true : false));
$x = array_merge(['@context' => [
ACTIVITYSTREAMS_JSONLD_REV,
diff --git a/Zotlabs/Module/Photomap.php b/Zotlabs/Module/Photomap.php
new file mode 100644
index 000000000..275159ad6
--- /dev/null
+++ b/Zotlabs/Module/Photomap.php
@@ -0,0 +1,24 @@
+' . $desc . '';
+
+ if(! ( local_channel() && Apps::system_app_installed(local_channel(),'Photomap'))) {
+ return $text;
+ }
+
+ return $text . '' . $desc . '
';
+
+ if(! ( local_channel() && Apps::system_app_installed(local_channel(),'Tasks'))) {
+ return $text;
+ }
+
+ $obj = new \Zotlabs\Widget\Tasklist;
+ return $obj->widget([]);
+ }
+
+
}
diff --git a/Zotlabs/Module/Viewconnections.php b/Zotlabs/Module/Viewconnections.php
index af3b5292f..194d260da 100644
--- a/Zotlabs/Module/Viewconnections.php
+++ b/Zotlabs/Module/Viewconnections.php
@@ -6,102 +6,96 @@ use Zotlabs\Web\Controller;
use Zotlabs\Lib\Libprofile;
-class Viewconnections extends \Zotlabs\Web\Controller {
+class Viewconnections extends Controller {
function init() {
- if(observer_prohibited()) {
+ if (observer_prohibited()) {
return;
}
- if(argc() > 1) {
+ if (argc() > 1) {
Libprofile::load(argv(1));
}
-
}
function get() {
-
- if(observer_prohibited()) {
+
+ // logger('request: ' . print_r($_REQUEST,true));
+
+ if (observer_prohibited()) {
notice( t('Public access denied.') . EOL);
return;
}
-
- if(((! count(\App::$profile)) || (\App::$profile['hide_friends']))) {
+
+ if (((! (is_array(App::$profile) && count(App::$profile))) || (App::$profile['hide_friends']))) {
notice( t('Permission denied.') . EOL);
return;
}
- if(! perm_is_allowed(\App::$profile['uid'], get_observer_hash(),'view_contacts')) {
+ if (! perm_is_allowed(App::$profile['uid'], get_observer_hash(),'view_contacts')) {
notice( t('Permission denied.') . EOL);
return;
}
- if(! $_REQUEST['aj'])
- $_SESSION['return_url'] = \App::$query_string;
+ if (! $_REQUEST['aj']) {
+ $_SESSION['return_url'] = App::$query_string;
+ }
-
- $is_owner = ((local_channel() && local_channel() == \App::$profile['uid']) ? true : false);
+ $is_owner = ((local_channel() && local_channel() == App::$profile['uid']) ? true : false);
$abook_flags = " and abook_pending = 0 and abook_self = 0 ";
$sql_extra = '';
- if(! $is_owner) {
+ if (! $is_owner) {
$abook_flags .= " and abook_hidden = 0 ";
$sql_extra = " and xchan_hidden = 0 ";
}
- $r = q("SELECT count(*) as total FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d $abook_flags and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra ",
- intval(\App::$profile['uid'])
- );
- if($r) {
- \App::set_pager_total($r[0]['total']);
- }
-
$r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d $abook_flags and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra order by xchan_name LIMIT %d OFFSET %d ",
- intval(\App::$profile['uid']),
- intval(\App::$pager['itemspage']),
- intval(\App::$pager['start'])
+ intval(App::$profile['uid']),
+ intval(App::$pager['itemspage']),
+ intval(App::$pager['start'])
);
- if((! $r) && (! $_REQUEST['aj'])) {
+ if ((! $r) && (! $_REQUEST['aj'])) {
info( t('No connections.') . EOL );
return $o;
}
- $contacts = array();
+ $contacts = [];
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$oneway = false;
- if(! their_perms_contains(\App::$profile['uid'],$rr['xchan_hash'],'post_comments')) {
+ if (! their_perms_contains(App::$profile['uid'],$rr['xchan_hash'],'post_comments')) {
$oneway = true;
}
$url = chanlink_hash($rr['xchan_hash']);
- if($url) {
- $contacts[] = array(
- 'id' => $rr['abook_id'],
- 'archived' => (intval($rr['abook_archived']) ? true : false),
- 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'), $rr['xchan_name'], $rr['xchan_url']),
- 'thumb' => $rr['xchan_photo_m'],
- 'name' => substr($rr['xchan_name'],0,20),
- 'username' => $rr['xchan_addr'],
- 'link' => $url,
- 'sparkle' => '',
- 'itemurl' => $rr['url'],
- 'network' => '',
- 'oneway' => $oneway
- );
+ if ($url) {
+ $contacts[] = [
+ 'id' => $rr['abook_id'],
+ 'archived' => (intval($rr['abook_archived']) ? true : false),
+ 'img_hover' => sprintf( t('Visit %1$s\'s profile [%2$s]'), $rr['xchan_name'], $rr['xchan_url']),
+ 'thumb' => $rr['xchan_photo_m'],
+ 'name' => substr($rr['xchan_name'],0,20),
+ 'username' => $rr['xchan_addr'],
+ 'link' => $url,
+ 'sparkle' => '',
+ 'itemurl' => $rr['url'],
+ 'network' => '',
+ 'oneway' => $oneway
+ ];
}
}
- if($_REQUEST['aj']) {
- if($contacts) {
- $o = replace_macros(get_markup_template('viewcontactsajax.tpl'),array(
+ if ($_REQUEST['aj']) {
+ if ($contacts) {
+ $o = replace_macros(get_markup_template('viewcontactsajax.tpl'), [
'$contacts' => $contacts
- ));
+ ]);
}
else {
$o = '');
- if($r[0]['title'] && trim($r[0]['body']) != '$content') {
+ if ($r[0]['title'] && trim($r[0]['body']) != '$content') {
$o .= '
' . $r[0]['title'] . '
';
}
- if(trim($r[0]['body']) === '$content') {
- $o .= \App::$page['content'];
+ if (trim($r[0]['body']) === '$content') {
+ $o .= App::$page['content'];
}
else {
$o .= prepare_text($r[0]['body'], $r[0]['mimetype']);
@@ -436,7 +448,7 @@ class Comanche {
*/
function js($s) {
- switch($s) {
+ switch ($s) {
case 'jquery':
$path = 'view/js/jquery.js';
break;
@@ -450,9 +462,9 @@ class Comanche {
}
$ret = '';
- if($init)
+ if ($init) {
$ret .= $init;
-
+ }
return $ret;
}
@@ -464,7 +476,7 @@ class Comanche {
*/
function css($s) {
- switch($s) {
+ switch ($s) {
case 'bootstrap':
$path = 'vendor/twbs/bootstrap/dist/css/bootstrap.min.css';
break;
@@ -496,8 +508,8 @@ class Comanche {
$matches = array();
$cnt = preg_match_all("/\[authored\](.*?)\[\/authored\]/ism", $s, $matches, PREG_SET_ORDER);
- if($cnt) {
- foreach($matches as $mtch) {
+ if ($cnt) {
+ foreach ($matches as $mtch) {
$ret['authored'] = $mtch[1];
}
}
@@ -522,64 +534,70 @@ class Comanche {
}
}
- if(! purify_filename($name))
+ if (! purify_filename($name)) {
return '';
+ }
$clsname = ucfirst($name);
$nsname = "\\Zotlabs\\Widget\\" . $clsname;
$found = false;
$widgets = \Zotlabs\Extend\Widget::get();
- if($widgets) {
- foreach($widgets as $widget) {
- if(is_array($widget) && strtolower($widget[1]) === strtolower($name) && file_exists($widget[0])) {
+ if ($widgets) {
+ foreach ($widgets as $widget) {
+ if (is_array($widget) && strtolower($widget[1]) === strtolower($name) && file_exists($widget[0])) {
require_once($widget[0]);
$found = true;
}
}
}
- if(! $found) {
- if(file_exists('Zotlabs/SiteWidget/' . $clsname . '.php'))
+ if (! $found) {
+ if (file_exists('Zotlabs/SiteWidget/' . $clsname . '.php')) {
require_once('Zotlabs/SiteWidget/' . $clsname . '.php');
- elseif(file_exists('widget/' . $clsname . '/' . $clsname . '.php'))
+ }
+ elseif (file_exists('widget/' . $clsname . '/' . $clsname . '.php')) {
require_once('widget/' . $clsname . '/' . $clsname . '.php');
- elseif(file_exists('Zotlabs/Widget/' . $clsname . '.php'))
+ }
+ elseif (file_exists('Zotlabs/Widget/' . $clsname . '.php')) {
require_once('Zotlabs/Widget/' . $clsname . '.php');
+ }
else {
$pth = theme_include($clsname . '.php');
- if($pth) {
+ if ($pth) {
require_once($pth);
}
}
}
- if(class_exists($nsname)) {
+ if (class_exists($nsname)) {
$x = new $nsname;
$f = 'widget';
- if(method_exists($x,$f)) {
+ if (method_exists($x,$f)) {
return $x->$f($vars);
}
}
$func = 'widget_' . trim($name);
- if(! function_exists($func)) {
- if(file_exists('widget/' . trim($name) . '.php'))
+ if (! function_exists($func)) {
+ if (file_exists('widget/' . trim($name) . '.php')) {
require_once('widget/' . trim($name) . '.php');
- elseif(file_exists('widget/' . trim($name) . '/' . trim($name) . '.php'))
+ }
+ elseif (file_exists('widget/' . trim($name) . '/' . trim($name) . '.php')) {
require_once('widget/' . trim($name) . '/' . trim($name) . '.php');
-
- if(! function_exists($func)) {
+ }
+ if (! function_exists($func)) {
$theme_widget = $func . '.php';
- if(theme_include($theme_widget)) {
+ if (theme_include($theme_widget)) {
require_once(theme_include($theme_widget));
}
}
}
- if(function_exists($func))
+ if (function_exists($func)) {
return $func($vars);
+ }
}
@@ -590,8 +608,8 @@ class Comanche {
$matches = array();
$cnt = preg_match_all("/\[menu\](.*?)\[\/menu\]/ism", $s, $matches, PREG_SET_ORDER);
- if($cnt) {
- foreach($matches as $mtch) {
+ if ($cnt) {
+ foreach ($matches as $mtch) {
$s = str_replace($mtch[0], $this->menu(trim($mtch[1])), $s);
}
}
@@ -600,43 +618,42 @@ class Comanche {
// allows different menu renderings to be applied
$cnt = preg_match_all("/\[menu=(.*?)\](.*?)\[\/menu\]/ism", $s, $matches, PREG_SET_ORDER);
- if($cnt) {
- foreach($matches as $mtch) {
+ if ($cnt) {
+ foreach ($matches as $mtch) {
$s = str_replace($mtch[0],$this->menu(trim($mtch[2]),$mtch[1]),$s);
}
}
$cnt = preg_match_all("/\[block\](.*?)\[\/block\]/ism", $s, $matches, PREG_SET_ORDER);
- if($cnt) {
- foreach($matches as $mtch) {
+ if ($cnt) {
+ foreach ($matches as $mtch) {
$s = str_replace($mtch[0],$this->block(trim($mtch[1])),$s);
}
}
$cnt = preg_match_all("/\[block=(.*?)\](.*?)\[\/block\]/ism", $s, $matches, PREG_SET_ORDER);
- if($cnt) {
- foreach($matches as $mtch) {
+ if ($cnt) {
+ foreach ($matches as $mtch) {
$s = str_replace($mtch[0],$this->block(trim($mtch[2]),trim($mtch[1])),$s);
}
}
$cnt = preg_match_all("/\[js\](.*?)\[\/js\]/ism", $s, $matches, PREG_SET_ORDER);
- if($cnt) {
- foreach($matches as $mtch) {
+ if ($cnt) {
+ foreach ($matches as $mtch) {
$s = str_replace($mtch[0],$this->js(trim($mtch[1])),$s);
}
}
$cnt = preg_match_all("/\[css\](.*?)\[\/css\]/ism", $s, $matches, PREG_SET_ORDER);
- if($cnt) {
- foreach($matches as $mtch) {
+ if ($cnt) {
+ foreach ($matches as $mtch) {
$s = str_replace($mtch[0],$this->css(trim($mtch[1])),$s);
}
}
- // need to modify this to accept parameters
$cnt = preg_match_all("/\[widget=(.*?)\](.*?)\[\/widget\]/ism", $s, $matches, PREG_SET_ORDER);
- if($cnt) {
- foreach($matches as $mtch) {
+ if ($cnt) {
+ foreach ($matches as $mtch) {
$s = str_replace($mtch[0],$this->widget(trim($mtch[1]),$mtch[2]),$s);
}
}
@@ -660,7 +677,7 @@ class Comanche {
* )
*/
function register_page_template($arr) {
- \App::$page_layouts[$arr['template']] = array($arr['variant']);
+ App::$page_layouts[$arr['template']] = array($arr['variant']);
return;
}
diff --git a/Zotlabs/Render/SimpleTemplate.php b/Zotlabs/Render/SimpleTemplate.php
old mode 100755
new mode 100644
index ff1bb5c3c..cca2368f9
--- a/Zotlabs/Render/SimpleTemplate.php
+++ b/Zotlabs/Render/SimpleTemplate.php
@@ -6,20 +6,20 @@ define ("KEY_NOT_EXISTS", '^R_key_not_Exists^');
class SimpleTemplate implements TemplateEngine {
- static $name ="internal";
+ static $name = 'internal';
var $r;
var $search;
var $replace;
- var $stack = array();
- var $nodes = array();
- var $done = false;
- var $d = false;
- var $lang = null;
- var $debug=false;
+ var $stack = [];
+ var $nodes = [];
+ var $done = false;
+ var $d = false;
+ var $lang = null;
+ var $debug = false;
private function _preg_error() {
- switch(preg_last_error()) {
+ switch (preg_last_error()) {
case PREG_INTERNAL_ERROR: echo('PREG_INTERNAL_ERROR'); break;
case PREG_BACKTRACK_LIMIT_ERROR: echo('PREG_BACKTRACK_LIMIT_ERROR'); break;
case PREG_RECURSION_LIMIT_ERROR: echo('PREG_RECURSION_LIMIT_ERROR'); break;
@@ -27,7 +27,7 @@ class SimpleTemplate implements TemplateEngine {
// This is only valid for php > 5.3, not certain how to code around it for unit tests
// case PREG_BAD_UTF8_OFFSET_ERROR: echo('PREG_BAD_UTF8_OFFSET_ERROR'); break;
default:
- //die("Unknown preg error.");
+ // die("Unknown preg error.");
return;
}
echo "
";
@@ -36,20 +36,21 @@ class SimpleTemplate implements TemplateEngine {
}
private function _push_stack() {
- $this->stack[] = array($this->r, $this->nodes);
+ $this->stack[] = [ $this->r, $this->nodes ];
}
private function _pop_stack(){
list($this->r, $this->nodes) = array_pop($this->stack);
}
- private function _get_var($name, $retNoKey=false) {
- $keys = array_map('trim',explode(".",$name));
- if ($retNoKey && !array_key_exists($keys[0], $this->r))
+ private function _get_var($name, $retNoKey = false) {
+ $keys = array_map('trim',explode('.',$name));
+ if ($retNoKey && ! array_key_exists($keys[0], $this->r)) {
return KEY_NOT_EXISTS;
+ }
$val = $this->r;
- foreach($keys as $k) {
+ foreach ($keys as $k) {
$val = (isset($val[$k]) ? $val[$k] : null);
}
@@ -65,22 +66,28 @@ class SimpleTemplate implements TemplateEngine {
* \endcode
*/
private function _replcb_if($args) {
- if (strpos($args[2],"==")>0){
- list($a,$b) = array_map("trim",explode("==",$args[2]));
+ if (strpos($args[2],'==') > 0){
+ list($a,$b) = array_map('trim',explode('==',$args[2]));
$a = $this->_get_var($a);
- if ($b[0]=="$") $b = $this->_get_var($b);
+ if ($b[0] == '$') {
+ $b = $this->_get_var($b);
+ }
$val = ($a == $b);
- } else if (strpos($args[2],"!=")>0){
- list($a,$b) = array_map("trim", explode("!=",$args[2]));
+ }
+ elseif (strpos($args[2], '!=') > 0) {
+ list($a,$b) = array_map('trim', explode('!=',$args[2]));
$a = $this->_get_var($a);
- if ($b[0]=="$") $b = $this->_get_var($b);
+ if ($b[0] == '$') {
+ $b = $this->_get_var($b);
+ }
$val = ($a != $b);
- } else {
+ }
+ else {
$val = $this->_get_var($args[2]);
}
$x = preg_split("|{{ *else *}}|", $args[3]);
- return ( ($val) ? $x[0] : (isset($x[1]) ? $x[1] : ""));
+ return ( ($val) ? $x[0] : (isset($x[1]) ? $x[1] : EMPTY_STR));
}
/**
@@ -92,24 +99,31 @@ class SimpleTemplate implements TemplateEngine {
*/
private function _replcb_for($args) {
$m = array_map('trim', explode(" as ", $args[2]));
- $x = explode("=>",$m[1]);
+ $x = explode('=>',$m[1]);
if (count($x) == 1) {
$varname = $x[0];
- $keyname = "";
- } else {
+ $keyname = EMPTY_STR;
+ }
+ else {
list($keyname, $varname) = $x;
}
- if ($m[0]=="" || $varname=="" || is_null($varname)) die("template error: 'for ".$m[0]." as ".$varname."'") ;
- //$vals = $this->r[$m[0]];
- $vals = $this->_get_var($m[0]);
- $ret="";
- if (!is_array($vals)) return $ret;
+ if ($m[0] == EMPTY_STR || $varname == EMPTY_STR || is_null($varname)) {
+ die("template error: 'for ".$m[0]." as ".$varname."'") ;
+ }
- foreach ($vals as $k=>$v){
+ $vals = $this->_get_var($m[0]);
+ $ret = EMPTY_STR;
+ if (!is_array($vals)) {
+ return $ret;
+ }
+
+ foreach ($vals as $k => $v) {
$this->_push_stack();
$r = $this->r;
$r[$varname] = $v;
- if ($keyname!='') $r[$keyname] = (($k === 0) ? '0' : $k);
+ if ($keyname != EMPTY_STR) {
+ $r[$keyname] = (($k === 0) ? '0' : $k);
+ }
$ret .= $this->replace($args[3], $r);
$this->_pop_stack();
}
@@ -124,19 +138,22 @@ class SimpleTemplate implements TemplateEngine {
* \endcode
*/
private function _replcb_inc($args) {
- if (strpos($args[2],"with")) {
+ if (strpos($args[2],'with')) {
list($tplfile, $newctx) = array_map('trim', explode("with",$args[2]));
- } else {
+ }
+ else {
$tplfile = trim($args[2]);
$newctx = null;
}
- if ($tplfile[0]=="$") $tplfile = $this->_get_var($tplfile);
+ if ($tplfile[0] == '$') {
+ $tplfile = $this->_get_var($tplfile);
+ }
$this->_push_stack();
$r = $this->r;
- if (!is_null($newctx)) {
- list($a,$b) = array_map('trim', explode("=",$newctx));
+ if (! is_null($newctx)) {
+ list($a,$b) = array_map('trim', explode('=',$newctx));
$r[$a] = $this->_get_var($b);
}
$this->nodes = Array();
@@ -159,7 +176,7 @@ class SimpleTemplate implements TemplateEngine {
$vars[] = $args[1];
$ret = "";
- foreach ($vars as $var){
+ foreach ($vars as $var) {
$ret .= htmlspecialchars(var_export( $this->_get_var($var), true ));
$ret .= "\n";
}
@@ -170,7 +187,7 @@ class SimpleTemplate implements TemplateEngine {
private function _replcb_node($m) {
$node = $this->nodes[$m[1]];
- if (method_exists($this, "_replcb_".$node[1])){
+ if (method_exists($this, "_replcb_" . $node[1])) {
$s = call_user_func(array($this, "_replcb_".$node[1]), $node);
} else {
$s = "";
@@ -282,7 +299,7 @@ class SimpleTemplate implements TemplateEngine {
$os = "";
$count=0;
while (($os !== $s) && $count<10) {
- $os=$s;
+ $os = $s;
$count++;
$s = $this->var_replace($s);
}
diff --git a/Zotlabs/Render/SmartyInterface.php b/Zotlabs/Render/SmartyInterface.php
old mode 100755
new mode 100644
index 1dab7880e..ea8bd7d33
--- a/Zotlabs/Render/SmartyInterface.php
+++ b/Zotlabs/Render/SmartyInterface.php
@@ -18,14 +18,14 @@ class SmartyInterface extends Smarty {
// setTemplateDir can be set to an array, which Smarty will parse in order.
// The order is thus very important here
- $template_dirs = array('theme' => "view/theme/$thname/tpl/");
+ $template_dirs = [ 'theme' => "view/theme/$thname/tpl/" ];
if ( x(App::$theme_info,"extends") ) {
- $template_dirs = $template_dirs + array('extends' => "view/theme/" . \App::$theme_info["extends"] . "/tpl/");
+ $template_dirs = $template_dirs + [ 'extends' => "view/theme/" . App::$theme_info["extends"] . '/tpl/' ];
}
$template_dirs = $template_dirs + array('base' => 'view/tpl/');
$this->setTemplateDir($template_dirs);
- $basecompiledir = App::$config['system']['smarty3_folder'];
+ $basecompiledir = get_config('system','smarty3_folder');
$this->setCompileDir($basecompiledir.'/compiled/');
$this->setConfigDir($basecompiledir.'/config/');
diff --git a/Zotlabs/Render/SmartyTemplate.php b/Zotlabs/Render/SmartyTemplate.php
old mode 100755
new mode 100644
index 9bc5b8aab..7eaa8a55c
--- a/Zotlabs/Render/SmartyTemplate.php
+++ b/Zotlabs/Render/SmartyTemplate.php
@@ -83,7 +83,7 @@ class SmartyTemplate implements TemplateEngine {
$template->filename = $template_file;
return $template;
}
- return "";
+ return EMPTY_STR;
}
diff --git a/Zotlabs/Render/TemplateEngine.php b/Zotlabs/Render/TemplateEngine.php
old mode 100755
new mode 100644
index 600ff913e..bc25ce1af
--- a/Zotlabs/Render/TemplateEngine.php
+++ b/Zotlabs/Render/TemplateEngine.php
@@ -8,5 +8,5 @@ namespace Zotlabs\Render;
interface TemplateEngine {
public function replace_macros($s, $v);
- public function get_markup_template($file, $root='');
+ public function get_markup_template($file, $root = '');
}
diff --git a/Zotlabs/Storage/BasicAuth.php b/Zotlabs/Storage/BasicAuth.php
index a5c01fbb7..851d022d4 100644
--- a/Zotlabs/Storage/BasicAuth.php
+++ b/Zotlabs/Storage/BasicAuth.php
@@ -164,10 +164,13 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic {
*/
function check(RequestInterface $request, ResponseInterface $response) {
- if(local_channel()) {
+ if (local_channel()) {
$this->setAuthenticated(\App::get_channel());
return [ true, $this->principalPrefix . $this->channel_name ];
}
+ elseif (remote_channel()) {
+ return [ true, $this->principalPrefix . $this->observer ];
+ }
$auth = new \Sabre\HTTP\Auth\Basic(
$this->realm,
diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php
index ffd350c0f..8eef71aa2 100644
--- a/Zotlabs/Storage/Directory.php
+++ b/Zotlabs/Storage/Directory.php
@@ -721,18 +721,21 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo
* @return array Directory[]
*/
function ChannelList(&$auth) {
- $ret = array();
+ $ret = [];
- $r = q("SELECT channel_id, channel_address, profile.publish FROM channel left join profile on profile.uid = channel.channel_id WHERE channel_removed = 0 AND channel_system = 0 AND (channel_pageflags & %d) = 0",
+ if (intval(get_config('system','cloud_disable_siteroot'))) {
+ return $ret;
+ }
+
+ $r = q("SELECT channel_id, channel_address FROM channel left join profile on profile.uid = channel.channel_id WHERE channel_removed = 0 AND channel_system = 0 AND (channel_pageflags & %d) = 0",
intval(PAGE_HIDDEN)
);
if ($r) {
foreach ($r as $rr) {
- if (perm_is_allowed($rr['channel_id'], $auth->observer, 'view_storage') && $rr['publish']) {
- logger('found channel: /cloud/' . $rr['channel_address'], LOGGER_DATA);
- // @todo can't we drop '/cloud'? It gets stripped off anyway in RedDirectory
- $ret[] = new Directory('/cloud/' . $rr['channel_address'], $auth);
+ if (perm_is_allowed($rr['channel_id'], $auth->observer, 'view_storage')) {
+ logger('found channel: ' . $rr['channel_address'], LOGGER_DATA);
+ $ret[] = new Directory($rr['channel_address'], $auth);
}
}
}
@@ -882,7 +885,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo
intval($channel['channel_account_id'])
);
$used = (($r) ? (float) $r[0]['total'] : 0);
- $limit = (float) service_class_fetch($this->auth->owner_id, 'attach_upload_limit');
+ $limit = (float) engr_units_to_bytes(service_class_fetch($this->auth->owner_id, 'attach_upload_limit'));
if($limit) {
// Don't let the result go negative
$free = (($limit > $used) ? $limit - $used : 0);
diff --git a/Zotlabs/Storage/File.php b/Zotlabs/Storage/File.php
index 3635c8adb..7899003fa 100644
--- a/Zotlabs/Storage/File.php
+++ b/Zotlabs/Storage/File.php
@@ -353,7 +353,7 @@ class File extends DAV\Node implements DAV\IFile {
* filesize in bytes
*/
public function getSize() {
- return $this->data['filesize'];
+ return intval($this->data['filesize']);
}
/**
diff --git a/Zotlabs/Text/Tagadelic.php b/Zotlabs/Text/Tagadelic.php
index 55ecf2d75..8b898b3cb 100644
--- a/Zotlabs/Text/Tagadelic.php
+++ b/Zotlabs/Text/Tagadelic.php
@@ -7,15 +7,16 @@ class Tagadelic {
static public function calc($arr) {
- $tags = array();
+ $tags = [];
$min = 1e9;
$max = -1e9;
$x = 0;
- if(! $arr)
- return array();
+ if (! $arr) {
+ return [];
+ }
- foreach($arr as $rr) {
+ foreach ($arr as $rr) {
$tags[$x][0] = $rr['term'];
$tags[$x][1] = log($rr['total']);
$tags[$x][2] = 0;
@@ -28,7 +29,7 @@ class Tagadelic {
$range = max(.01, $max - $min) * 1.0001;
- for($x = 0; $x < count($tags); $x ++) {
+ for ($x = 0; $x < count($tags); $x ++) {
$tags[$x][2] = 1 + floor(9 * ($tags[$x][1] - $min) / $range);
}
@@ -36,8 +37,9 @@ class Tagadelic {
}
static public function tags_sort($a,$b) {
- if(strtolower($a[0]) == strtolower($b[0]))
+ if (strtolower($a[0]) === strtolower($b[0])) {
return 0;
+ }
return((strtolower($a[0]) < strtolower($b[0])) ? -1 : 1);
}
diff --git a/Zotlabs/Thumbs/Epubthumb.php b/Zotlabs/Thumbs/Epubthumb.php
index 22f1a5e8f..3f283dfa0 100644
--- a/Zotlabs/Thumbs/Epubthumb.php
+++ b/Zotlabs/Thumbs/Epubthumb.php
@@ -4,10 +4,13 @@ namespace Zotlabs\Thumbs;
require_once 'library/epub-meta/epub.php';
+use Epub;
+
/**
* @brief Thumbnail creation for epub files.
*
*/
+
class Epubthumb {
/**
@@ -16,6 +19,7 @@ class Epubthumb {
* @param string $type MimeType
* @return boolean
*/
+
function Match($type) {
return(($type === 'application/epub+zip') ? true : false );
}
@@ -28,18 +32,19 @@ class Epubthumb {
* @param number $height (optional) default 300
* @param number $width (optional) default 300
*/
+
function Thumb($attach, $preview_style, $height = 300, $width = 300) {
$photo = false;
- $ep = new \EPub(dbunescbin($attach['content']));
+ $ep = new EPub(dbunescbin($attach['content']));
$data = $ep->Cover();
- if($data['found']) {
+ if ($data['found']) {
$photo = $data['data'];
}
- if($photo) {
+ if ($photo) {
$image = imagecreatefromstring($photo);
$dest = imagecreatetruecolor($width, $height);
$srcwidth = imagesx($image);
diff --git a/Zotlabs/Thumbs/Mp3audio.php b/Zotlabs/Thumbs/Mp3audio.php
index 000d65b22..27a711cb2 100644
--- a/Zotlabs/Thumbs/Mp3audio.php
+++ b/Zotlabs/Thumbs/Mp3audio.php
@@ -2,7 +2,7 @@
namespace Zotlabs\Thumbs;
-use \ID3Parser\ID3Parser;
+use ID3Parser\ID3Parser;
class Mp3audio {
@@ -16,11 +16,11 @@ class Mp3audio {
$id = $p->analyze(dbunescbin($attach['content']));
$photo = isset($id['id3v2']['APIC'][0]['data']) ? $id['id3v2']['APIC'][0]['data'] : null;
- if(is_null($photo) && isset($id['id3v2']['PIC'][0]['data'])) {
+ if (is_null($photo) && isset($id['id3v2']['PIC'][0]['data'])) {
$photo = $id['id3v2']['PIC'][0]['data'];
}
- if($photo) {
+ if ($photo) {
$image = imagecreatefromstring($photo);
$dest = imagecreatetruecolor( $width, $height );
$srcwidth = imagesx($image);
diff --git a/Zotlabs/Thumbs/Pdf.php b/Zotlabs/Thumbs/Pdf.php
index 11714ad53..53b7d22f8 100644
--- a/Zotlabs/Thumbs/Pdf.php
+++ b/Zotlabs/Thumbs/Pdf.php
@@ -19,24 +19,24 @@ class Pdf {
$istream = fopen($file,'rb');
$ostream = fopen($tmpfile,'wb');
- if($istream && $ostream) {
+ if ($istream && $ostream) {
pipe_streams($istream,$ostream);
fclose($istream);
fclose($ostream);
}
$imagick_path = get_config('system','imagick_convert_path');
- if($imagick_path && @file_exists($imagick_path)) {
+ if ($imagick_path && @file_exists($imagick_path)) {
$cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmpfile . '[0]') . ' -resize ' . $width . 'x' . $height . ' ' . escapeshellarg(PROJECT_BASE . '/' . $outfile);
// logger('imagick thumbnail command: ' . $cmd);
- for($x = 0; $x < 4; $x ++) {
+ for ($x = 0; $x < 4; $x ++) {
exec($cmd);
- if(! file_exists($outfile)) {
+ if (! file_exists($outfile)) {
logger('imagick scale failed. Retrying.');
continue;
}
}
- if(! file_exists($outfile)) {
+ if (! file_exists($outfile)) {
logger('imagick scale failed.');
}
else {
diff --git a/Zotlabs/Thumbs/Text.php b/Zotlabs/Thumbs/Text.php
index 3ee7819bd..0f6632238 100644
--- a/Zotlabs/Thumbs/Text.php
+++ b/Zotlabs/Thumbs/Text.php
@@ -12,12 +12,12 @@ class Text {
function Thumb($attach,$preview_style,$height = 300, $width = 300) {
$stream = @fopen(dbunescbin($attach['content']),'rb');
- if($stream) {
+ if ($stream) {
$content = trim(stream_get_contents($stream,4096));
$content = str_replace("\r",'',$content);
$content_a = explode("\n",$content);
}
- if($content_a) {
+ if ($content_a) {
$fsize = 4;
$lsize = 8;
$image = imagecreate($width,$height);
@@ -30,16 +30,16 @@ class Text {
$x2 = ImageSX($image) - 1;
$y2 = ImageSY($image) - 1;
- for($i = 0; $i < 2; $i++) {
+ for ($i = 0; $i < 2; $i++) {
ImageRectangle($image, $x1++, $y1++, $x2--, $y2--, $border);
}
- foreach($content_a as $l => $t) {
+ foreach ($content_a as $l => $t) {
$l = $l + 1;
$x = 3;
$y = ($l * $lsize) + 3 - $fsize;
imagestring($image,1,$x,$y,$t,$colour);
- if(($l * $lsize) >= $height) {
+ if (($l * $lsize) >= $height) {
break;
}
}
diff --git a/Zotlabs/Thumbs/Video.php b/Zotlabs/Thumbs/Video.php
index 15d3ace12..cf20c561b 100644
--- a/Zotlabs/Thumbs/Video.php
+++ b/Zotlabs/Thumbs/Video.php
@@ -14,10 +14,12 @@ class Video {
$photo = false;
$t = explode('/',$attach['filetype']);
- if($t[1])
+ if ($t[1]) {
$extension = '.' . $t[1];
- else
- return;
+ }
+ else {
+ return;
+ }
$file = dbunescbin($attach['content']);
@@ -26,7 +28,7 @@ class Video {
$istream = fopen($file,'rb');
$ostream = fopen($tmpfile,'wb');
- if($istream && $ostream) {
+ if ($istream && $ostream) {
pipe_streams($istream,$ostream);
fclose($istream);
fclose($ostream);
@@ -40,19 +42,19 @@ class Video {
$ffmpeg = trim(shell_exec('which ffmpeg'));
- if($ffmpeg) {
+ if (! $ffmpeg) {
logger('ffmpeg not found in path. Video thumbnails may fail.');
}
$imagick_path = get_config('system','imagick_convert_path');
- if($imagick_path && @file_exists($imagick_path)) {
+ if ($imagick_path && @file_exists($imagick_path)) {
$cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmpfile . '[0]') . ' -resize ' . $width . 'x' . $height . ' ' . escapeshellarg(PROJECT_BASE . '/' . $outfile);
// logger('imagick thumbnail command: ' . $cmd);
/** @scrutinizer ignore-unhandled */
@exec($cmd);
- if(! file_exists($outfile)) {
+ if (! file_exists($outfile)) {
logger('imagick scale failed.');
}
else {
diff --git a/Zotlabs/Update/_1233.php b/Zotlabs/Update/_1233.php
new file mode 100644
index 000000000..392fd3590
--- /dev/null
+++ b/Zotlabs/Update/_1233.php
@@ -0,0 +1,34 @@
+in_progress['k']) {
+ if ($lines) {
+ foreach ($lines as $line) {
+ if (preg_match('/^\s+/',$line,$matches) && trim($line)) {
+ if ($this->in_progress['k']) {
$this->in_progress['v'] .= ' ' . ltrim($line);
continue;
}
}
else {
- if($this->in_progress['k']) {
+ if ($this->in_progress['k']) {
$this->parsed[] = [ $this->in_progress['k'] => $this->in_progress['v'] ];
$this->in_progress = [];
}
@@ -43,9 +42,9 @@ class HTTPHeaders {
function fetcharr() {
$ret = [];
- if($this->parsed) {
- foreach($this->parsed as $x) {
- foreach($x as $y => $z) {
+ if ($this->parsed) {
+ foreach ($this->parsed as $x) {
+ foreach ($x as $y => $z) {
$ret[$y] = $z;
}
}
diff --git a/Zotlabs/Web/HttpMeta.php b/Zotlabs/Web/HttpMeta.php
index 469a9ed8b..7bf54b467 100644
--- a/Zotlabs/Web/HttpMeta.php
+++ b/Zotlabs/Web/HttpMeta.php
@@ -10,56 +10,63 @@ class HttpMeta {
function __construct() {
- $this->vars = array();
- $this->og = array();
+ $this->vars = [];
+ $this->og = [];
}
function set($property,$value) {
- if(strpos($property,'og:') === 0)
+ if (strpos($property,'og:') === 0) {
$this->og[$property] = $value;
- else
+ }
+ else {
$this->vars[$property] = $value;
+ }
}
function check_required() {
- if(
+ if (
($this->og)
&& array_key_exists('og:title',$this->og)
&& array_key_exists('og:type', $this->og)
&& array_key_exists('og:image',$this->og)
&& array_key_exists('og:url', $this->og)
- )
+ ) {
return true;
+ }
return false;
}
function get_field($field) {
- if(strpos($field,'og:') === 0)
+ if (strpos($field,'og:') === 0) {
$arr = $this->og;
- else
+ }
+ else {
$arr = $this->vars;
-
- if($arr && array_key_exists($field,$arr) && $arr[$field])
+ }
+
+ if ($arr && array_key_exists($field,$arr) && $arr[$field]) {
return $arr[$field];
+ }
return false;
}
function get() {
$o = '';
- if($this->vars) {
- foreach($this->vars as $k => $v) {
- $o .= '' . "\r\n" ;
+ if ($this->vars) {
+ foreach ($this->vars as $k => $v) {
+ $o .= '' . "\r\n" ;
}
}
- if($this->check_required()) {
- foreach($this->og as $k => $v) {
- $o .= '' . "\r\n" ;
+ if ($this->check_required()) {
+ foreach ($this->og as $k => $v) {
+ $o .= '' . "\r\n" ;
}
}
- if($o)
+ if ($o) {
return "\r\n" . $o;
+ }
return $o;
}
diff --git a/Zotlabs/Web/Router.php b/Zotlabs/Web/Router.php
index 2e262af2d..97c67706a 100644
--- a/Zotlabs/Web/Router.php
+++ b/Zotlabs/Web/Router.php
@@ -2,7 +2,9 @@
namespace Zotlabs\Web;
+use App;
use Zotlabs\Extend\Route;
+use Zotlabs\Render\Theme;
use Exception;
/**
@@ -43,10 +45,10 @@ class Router {
*/
function __construct() {
- $module = \App::$module;
+ $module = App::$module;
$modname = "Zotlabs\\Module\\" . ucfirst($module);
- if(strlen($module)) {
+ if (strlen($module)) {
/*
* We will always have a module name.
@@ -54,13 +56,13 @@ class Router {
*/
$routes = Route::get();
- if($routes) {
- foreach($routes as $route) {
- if(is_array($route) && strtolower($route[1]) === $module) {
+ if ($routes) {
+ foreach ($routes as $route) {
+ if (is_array($route) && strtolower($route[1]) === $module) {
include_once($route[0]);
- if(class_exists($modname)) {
+ if (class_exists($modname)) {
$this->controller = new $modname;
- \App::$module_loaded = true;
+ App::$module_loaded = true;
}
}
}
@@ -72,42 +74,37 @@ class Router {
* Otherwise, look for the standard program module
*/
- if(! (\App::$module_loaded)) {
+ if(! (App::$module_loaded)) {
try {
$filename = 'Zotlabs/SiteModule/'. ucfirst($module). '.php';
- if(file_exists($filename)) {
+ if (file_exists($filename)) {
// This won't be picked up by the autoloader, so load it explicitly
require_once($filename);
$this->controller = new $modname;
- \App::$module_loaded = true;
+ App::$module_loaded = true;
}
else {
$filename = 'Zotlabs/Module/'. ucfirst($module). '.php';
- if(file_exists($filename)) {
+ if (file_exists($filename)) {
$this->controller = new $modname;
- \App::$module_loaded = true;
+ App::$module_loaded = true;
}
}
- if(! \App::$module_loaded)
- throw new \Exception('Module not found');
+ if (! App::$module_loaded) {
+ throw new Exception('Module not found');
+ }
}
- catch(\Exception $e) {
- if(file_exists("mod/site/{$module}.php")) {
- include_once("mod/site/{$module}.php");
- \App::$module_loaded = true;
- }
- elseif(file_exists("mod/{$module}.php")) {
- include_once("mod/{$module}.php");
- \App::$module_loaded = true;
- }
+ catch(Exception $e) {
+
}
}
$x = [
- 'module' => $module,
- 'installed' => \App::$module_loaded,
- 'controller' => $this->controller
+ 'module' => $module,
+ 'installed' => App::$module_loaded,
+ 'controller' => $this->controller
];
+
/**
* @hooks module_loaded
* Called when a module has been successfully locate to server a URL request.
@@ -121,8 +118,8 @@ class Router {
* * \e mixed \b controller - The initialized module object
*/
call_hooks('module_loaded', $x);
- if($x['installed']) {
- \App::$module_loaded = true;
+ if ($x['installed']) {
+ App::$module_loaded = true;
$this->controller = $x['controller'];
}
@@ -130,7 +127,7 @@ class Router {
* The URL provided does not resolve to a valid module.
*/
- if(! (\App::$module_loaded)) {
+ if (! (App::$module_loaded)) {
// undo the setting of a letsencrypt acme-challenge rewrite rule
// which blocks access to our .well-known routes.
@@ -138,15 +135,15 @@ class Router {
// for a custom .htaccess in the .well-known directory; but they should
// make the file read-only so letsencrypt doesn't modify it
- if(strpos($_SERVER['REQUEST_URI'],'/.well-known/') === 0) {
- if(file_exists('.well-known/.htaccess') && get_config('system','fix_apache_acme',true)) {
+ if (strpos($_SERVER['REQUEST_URI'],'/.well-known/') === 0) {
+ if (file_exists('.well-known/.htaccess') && get_config('system','fix_apache_acme',true)) {
rename('.well-known/.htaccess','.well-known/.htaccess.old');
}
}
$x = [
'module' => $module,
- 'installed' => \App::$module_loaded,
+ 'installed' => App::$module_loaded,
'controller' => $this->controller
];
call_hooks('page_not_found',$x);
@@ -154,11 +151,11 @@ class Router {
// Stupid browser tried to pre-fetch our Javascript img template.
// Don't log the event or return anything - just quietly exit.
- if((x($_SERVER, 'QUERY_STRING')) && preg_match('/{[0-9]}/', $_SERVER['QUERY_STRING']) !== 0) {
+ if ((x($_SERVER, 'QUERY_STRING')) && preg_match('/{[0-9]}/', $_SERVER['QUERY_STRING']) !== 0) {
killme();
}
- if(get_config('system','log_404',true)) {
+ if (get_config('system','log_404',true)) {
logger("Module {$module} not found.", LOGGER_DEBUG, LOG_WARNING);
logger('index.php: page not found: ' . $_SERVER['REQUEST_URI']
. ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: '
@@ -167,14 +164,12 @@ class Router {
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
$tpl = get_markup_template('404.tpl');
- \App::$page['content'] = replace_macros($tpl, array(
- '$message' => t('Page not found.')
- ));
+ App::$page['content'] = replace_macros(get_markup_template('404.tpl'), [ '$message' => t('Page not found.') ]);
// pretend this is a module so it will initialise the theme
- \App::$module = '404';
- \App::$module_loaded = true;
- \App::$error = true;
+ App::$module = '404';
+ App::$module_loaded = true;
+ App::$error = true;
}
}
}
@@ -189,9 +184,9 @@ class Router {
* Call module functions
*/
- if(\App::$module_loaded) {
+ if (App::$module_loaded) {
- \App::$page['page_title'] = \App::$module;
+ App::$page['page_title'] = App::$module;
$placeholder = '';
/*
@@ -201,16 +196,12 @@ class Router {
* to over-ride them.
*/
- $arr = array('init' => true, 'replace' => false);
- call_hooks(\App::$module . '_mod_init', $arr);
- if(! $arr['replace']) {
- if($this->controller && method_exists($this->controller,'init')) {
+ $arr = [ 'init' => true, 'replace' => false ];
+ call_hooks(App::$module . '_mod_init', $arr);
+ if (! $arr['replace']) {
+ if ($this->controller && method_exists($this->controller,'init')) {
$this->controller->init();
}
- elseif(function_exists(\App::$module . '_init')) {
- $func = \App::$module . '_init';
- $func($a);
- }
}
/*
@@ -233,52 +224,43 @@ class Router {
* load current theme info
*/
- $current_theme = \Zotlabs\Render\Theme::current();
+ $current_theme = Theme::current();
$theme_info_file = 'view/theme/' . $current_theme[0] . '/php/theme.php';
- if (file_exists($theme_info_file)){
+ if (file_exists($theme_info_file)) {
require_once($theme_info_file);
}
- if(function_exists(str_replace('-', '_', $current_theme[0]) . '_init')) {
+ if (function_exists(str_replace('-', '_', $current_theme[0]) . '_init')) {
$func = str_replace('-', '_', $current_theme[0]) . '_init';
$func($a);
}
- elseif (x(\App::$theme_info, 'extends') && file_exists('view/theme/' . \App::$theme_info['extends'] . '/php/theme.php')) {
- require_once('view/theme/' . \App::$theme_info['extends'] . '/php/theme.php');
- if(function_exists(str_replace('-', '_', \App::$theme_info['extends']) . '_init')) {
- $func = str_replace('-', '_', \App::$theme_info['extends']) . '_init';
+ elseif (x(App::$theme_info, 'extends') && file_exists('view/theme/' . App::$theme_info['extends'] . '/php/theme.php')) {
+ require_once('view/theme/' . App::$theme_info['extends'] . '/php/theme.php');
+ if (function_exists(str_replace('-', '_', App::$theme_info['extends']) . '_init')) {
+ $func = str_replace('-', '_', App::$theme_info['extends']) . '_init';
$func($a);
}
}
- if(($_SERVER['REQUEST_METHOD'] === 'POST') && (! \App::$error) && (! x($_POST, 'auth-params'))) {
- call_hooks(\App::$module . '_mod_post', $_POST);
-
- if($this->controller && method_exists($this->controller,'post')) {
+ if (($_SERVER['REQUEST_METHOD'] === 'POST') && (! App::$error) && (! x($_POST, 'auth-params'))) {
+ call_hooks(App::$module . '_mod_post', $_POST);
+ if ($this->controller && method_exists($this->controller,'post')) {
$this->controller->post();
}
- elseif(function_exists(\App::$module . '_post')) {
- $func = \App::$module . '_post';
- $func($a);
- }
}
- if(! \App::$error) {
- $arr = array('content' => \App::$page['content'], 'replace' => false);
- call_hooks(\App::$module . '_mod_content', $arr);
+ if (! App::$error) {
+ $arr = [ 'content' => \App::$page['content'], 'replace' => false ];
+ call_hooks(App::$module . '_mod_content', $arr);
- if(! $arr['replace']) {
- if($this->controller && method_exists($this->controller,'get')) {
- $arr = array('content' => $this->controller->get());
- }
- elseif(function_exists(\App::$module . '_content')) {
- $func = \App::$module . '_content';
- $arr = array('content' => $func($a));
+ if (! $arr['replace']) {
+ if ($this->controller && method_exists($this->controller,'get')) {
+ $arr = [ 'content' => $this->controller->get() ];
}
}
- call_hooks(\App::$module . '_mod_aftercontent', $arr);
- \App::$page['content'] = (($arr['replace']) ? $arr['content'] : \App::$page['content'] . $arr['content']);
+ call_hooks(App::$module . '_mod_aftercontent', $arr);
+ App::$page['content'] = (($arr['replace']) ? $arr['content'] : App::$page['content'] . $arr['content']);
}
}
}
diff --git a/Zotlabs/Web/Session.php b/Zotlabs/Web/Session.php
index 3a80e5d5c..380bbfc96 100644
--- a/Zotlabs/Web/Session.php
+++ b/Zotlabs/Web/Session.php
@@ -2,6 +2,8 @@
namespace Zotlabs\Web;
+use Zotlabs\Web\SessionHandler
+;
/**
*
* @brief This file includes session related functions.
@@ -16,6 +18,7 @@ class Session {
private $handler = null;
private $session_started = false;
private $custom_handler = false;
+
public function init() {
$gc_probability = 50;
@@ -33,27 +36,30 @@ class Session {
if ($this->custom_handler) {
/* Custom handler (files, memached, redis..) */
- $session_save_handler = strval(get_config('system', 'session_save_handler', Null));
- $session_save_path = strval(get_config('system', 'session_save_path', Null));
- if (!$session_save_handler || !$session_save_path) {
- logger('Session save handler or path not set.',LOGGER_NORMAL,LOG_ERR);
- } else {
- ini_set('session.save_handler', $session_save_handler);
- ini_set('session.save_path', $session_save_path);
- }
- } else {
- $handler = new \Zotlabs\Web\SessionHandler();
+ $session_save_handler = strval(get_config('system', 'session_save_handler', Null));
+ $session_save_path = strval(get_config('system', 'session_save_path', Null));
+ if ($session_save_handler && $session_save_path) {
+ ini_set('session.save_handler', $session_save_handler);
+ ini_set('session.save_path', $session_save_path);
+ }
+ else {
+ logger('Session save handler or path not set.',LOGGER_NORMAL,LOG_ERR);
+ }
+ }
+ else {
+ $handler = new SessionHandler();
$this->handler = $handler;
$x = session_set_save_handler($handler,false);
- if(! $x)
+ if (! $x) {
logger('Session save handler initialisation failed.',LOGGER_NORMAL,LOG_ERR);
+ }
};
+
// Force cookies to be secure (https only) if this site is SSL enabled.
// Must be done before session_start().
-
$arr = session_get_cookie_params();
// Note when setting cookies: set the domain to false which creates a single domain
@@ -85,8 +91,8 @@ class Session {
public function nuke() {
$this->new_cookie(0); // 0 means delete on browser exit
- if($_SESSION && count($_SESSION)) {
- foreach($_SESSION as $k => $v) {
+ if ($_SESSION && count($_SESSION)) {
+ foreach ($_SESSION as $k => $v) {
unset($_SESSION[$k]);
}
}
@@ -100,7 +106,7 @@ class Session {
$arr = session_get_cookie_params();
- if(($this->handler || $this->custom_handler) && $this->session_started) {
+ if (($this->handler || $this->custom_handler) && $this->session_started) {
session_regenerate_id(true);
@@ -110,9 +116,10 @@ class Session {
$this->handler->read(session_id());
}
}
- else
+ else {
logger('no session handler');
-
+ }
+
if (x($_COOKIE, 'jsdisabled')) {
setcookie('jsdisabled', $_COOKIE['jsdisabled'], $newxtime, '/', false,((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? true : false),((isset($arr['httponly'])) ? $arr['httponly'] : true));
}
@@ -131,8 +138,9 @@ class Session {
$xtime = (($_SESSION['remember_me']) ? (60 * 60 * 24 * 365) : 0 );
- if($xtime)
+ if ($xtime) {
setcookie(session_name(),session_id(),(time() + $xtime), '/', false,((isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? true : false),((isset($arr['httponly'])) ? $arr['httponly'] : true));
+ }
$arr = array('expire' => $xtime);
call_hooks('extend_cookie', $arr);
@@ -149,7 +157,7 @@ class Session {
// first check if we're enforcing that sessions can't change IP address
// @todo what to do with IPv6 addresses
- if($_SESSION['addr'] && $_SESSION['addr'] != $_SERVER['REMOTE_ADDR']) {
+ if ($_SESSION['addr'] && $_SESSION['addr'] != $_SERVER['REMOTE_ADDR']) {
logger('SECURITY: Session IP address changed: ' . $_SESSION['addr'] . ' != ' . $_SERVER['REMOTE_ADDR']);
$partial1 = substr($_SESSION['addr'], 0, strrpos($_SESSION['addr'], '.'));
@@ -157,10 +165,11 @@ class Session {
$paranoia = intval(get_pconfig($_SESSION['uid'], 'system', 'paranoia'));
- if(! $paranoia)
+ if (! $paranoia) {
$paranoia = intval(get_config('system', 'paranoia'));
-
- switch($paranoia) {
+ }
+
+ switch ($paranoia) {
case 0:
// no IP checking
break;
@@ -168,17 +177,18 @@ class Session {
// check 2 octets
$partial1 = substr($partial1, 0, strrpos($partial1, '.'));
$partial2 = substr($partial2, 0, strrpos($partial2, '.'));
- if($partial1 == $partial2)
+ if ($partial1 == $partial2) {
break;
+ }
case 1:
// check 3 octets
- if($partial1 == $partial2)
+ if ($partial1 == $partial2) {
break;
+ }
case 3:
default:
// check any difference at all
- logger('Session address changed. Paranoid setting in effect, blocking session. '
- . $_SESSION['addr'] . ' != ' . $_SERVER['REMOTE_ADDR']);
+ logger('Session address changed. Paranoid setting in effect, blocking session. ' . $_SESSION['addr'] . ' != ' . $_SERVER['REMOTE_ADDR']);
$this->nuke();
goaway(z_root());
break;
@@ -186,5 +196,4 @@ class Session {
}
return true;
}
-
}
diff --git a/Zotlabs/Web/SessionHandler.php b/Zotlabs/Web/SessionHandler.php
index 04c5cb5b5..b40b466ee 100644
--- a/Zotlabs/Web/SessionHandler.php
+++ b/Zotlabs/Web/SessionHandler.php
@@ -2,8 +2,9 @@
namespace Zotlabs\Web;
+use SessionHandlerInterface;
-class SessionHandler implements \SessionHandlerInterface {
+class SessionHandler implements SessionHandlerInterface {
function open ($s, $n) {
@@ -17,10 +18,10 @@ class SessionHandler implements \SessionHandlerInterface {
function read ($id) {
- if($id) {
+ if ($id) {
$r = q("SELECT sess_data FROM session WHERE sid= '%s'", dbesc($id));
- if($r) {
+ if ($r) {
return $r[0]['sess_data'];
}
else {
@@ -38,8 +39,11 @@ class SessionHandler implements \SessionHandlerInterface {
function write ($id, $data) {
- if(! $id || ! $data) {
- return false;
+ // Pretend everything is hunky-dory, even though it isn't. There probably isn't anything
+ // we can do about it in any event.
+
+ if (! $id) {
+ return true;
}
// Unless we authenticate somehow, only keep a session for 5 minutes
@@ -50,12 +54,12 @@ class SessionHandler implements \SessionHandlerInterface {
$expire = time() + 300;
- if($_SESSION) {
- if(array_key_exists('remember_me',$_SESSION) && intval($_SESSION['remember_me']))
+ if ($_SESSION) {
+ if (array_key_exists('remember_me',$_SESSION) && intval($_SESSION['remember_me']))
$expire = time() + (60 * 60 * 24 * 365);
- elseif(local_channel())
+ elseif (local_channel())
$expire = time() + (60 * 60 * 24 * 3);
- elseif(remote_channel())
+ elseif (remote_channel())
$expire = time() + (60 * 60 * 24 * 1);
}
diff --git a/Zotlabs/Web/WebServer.php b/Zotlabs/Web/WebServer.php
index cc66ba765..c3a7fc391 100644
--- a/Zotlabs/Web/WebServer.php
+++ b/Zotlabs/Web/WebServer.php
@@ -163,27 +163,26 @@ class WebServer {
'type' => 'application/jrd+json',
'url' => z_root() . '/.well-known/webfinger?f=&resource=acct%3A' . argv(1) . '%40' . App::get_hostname()
],
+
[
'rel' => 'zot',
'type' => 'application/x-zot+json',
'url' => z_root() . '/channel/' . argv(1)
],
+
+ [
+ 'rel' => 'self',
+ 'type' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
+ 'href' => z_root() . '/channel/' . argv(1)
+ ],
+
+ [
+ 'rel' => 'self',
+ 'type' => 'application/activity+json',
+ 'href' => z_root() . '/channel/' . argv(1)
+ ]
];
- if(! defined('NOMADIC')) {
- App::$channel_links[] =
- [
- 'rel' => 'self',
- 'type' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
- 'href' => z_root() . '/channel/' . argv(1)
- ];
- App::$channel_links[] =
- [
- 'rel' => 'self',
- 'type' => 'application/activity+json',
- 'href' => z_root() . '/channel/' . argv(1)
- ];
- }
$x = [ 'channel_address' => argv(1), 'channel_links' => App::$channel_links ];
call_hooks('channel_links', $x );
App::$channel_links = $x['channel_links'];
diff --git a/Zotlabs/Widget/Activity_filter.php b/Zotlabs/Widget/Activity_filter.php
index 37e040320..35cc631d5 100644
--- a/Zotlabs/Widget/Activity_filter.php
+++ b/Zotlabs/Widget/Activity_filter.php
@@ -2,6 +2,9 @@
namespace Zotlabs\Widget;
+use App;
+
+
class Activity_filter {
function widget($arr) {
@@ -9,11 +12,23 @@ class Activity_filter {
if(! local_channel())
return '';
- $cmd = \App::$cmd;
+ $cmd = App::$cmd;
$filter_active = false;
$tabs = [];
+ if(x($_GET,'dm')) {
+ $dm_active = (($_GET['dm'] == 1) ? 'active' : '');
+ $filter_active = 'dm';
+ }
+
+ $tabs[] = [
+ 'label' => t('Direct Messages'),
+ 'icon' => 'envelope-o',
+ 'url' => z_root() . '/' . $cmd . '/?dm=1',
+ 'sel' => $dm_active,
+ 'title' => t('Show direct (private) messages')
+ ];
if(x($_GET,'conv')) {
$conv_active = (($_GET['conv'] == 1) ? 'active' : '');
@@ -28,6 +43,21 @@ class Activity_filter {
'title' => t('Show posts that mention or involve me')
];
+
+ if(x($_GET,'verb')) {
+ $verb_active = (($_GET['verb'] == 1) ? 'active' : '');
+ $filter_active = 'events';
+ }
+
+ $tabs[] = [
+ 'label' => t('Events'),
+ 'icon' => 'calendar',
+ 'url' => z_root() . '/' . $cmd . '/?verb=%2EEvent',
+ 'sel' => $verb_active,
+ 'title' => t('Show posts that include events')
+ ];
+
+
if(feature_enabled(local_channel(),'star_posts')) {
if(x($_GET,'star')) {
$starred_active = (($_GET['star'] == 1) ? 'active' : '');
@@ -64,7 +94,7 @@ class Activity_filter {
}
$tabs[] = [
'id' => 'privacy_groups',
- 'label' => t('Access Lists'),
+ 'label' => t('Lists'),
'icon' => 'users',
'url' => '#',
'sel' => (($filter_active == 'group') ? true : false),
diff --git a/Zotlabs/Widget/Affinity.php b/Zotlabs/Widget/Affinity.php
index e9f087f68..bcd54f9cf 100644
--- a/Zotlabs/Widget/Affinity.php
+++ b/Zotlabs/Widget/Affinity.php
@@ -11,14 +11,14 @@ class Affinity {
if(! local_channel())
return '';
- $default_cmin = ((Apps::system_app_installed(local_channel(),'Affinity Tool')) ? get_pconfig(local_channel(),'affinity','cmin',0) : 0);
- $default_cmax = ((Apps::system_app_installed(local_channel(),'Affinity Tool')) ? get_pconfig(local_channel(),'affinity','cmax',99) : 99);
+ $default_cmin = ((Apps::system_app_installed(local_channel(),'Friend Zoom')) ? get_pconfig(local_channel(),'affinity','cmin',0) : 0);
+ $default_cmax = ((Apps::system_app_installed(local_channel(),'Friend Zoom')) ? get_pconfig(local_channel(),'affinity','cmax',99) : 99);
$cmin = ((x($_REQUEST,'cmin')) ? intval($_REQUEST['cmin']) : $default_cmin);
$cmax = ((x($_REQUEST,'cmax')) ? intval($_REQUEST['cmax']) : $default_cmax);
- if(Apps::system_app_installed(local_channel(),'Affinity Tool')) {
+ if(Apps::system_app_installed(local_channel(),'Friend Zoom')) {
$labels = array(
0 => t('Me'),
diff --git a/Zotlabs/Widget/Clock.php b/Zotlabs/Widget/Clock.php
index b63b5f748..8dae200c0 100644
--- a/Zotlabs/Widget/Clock.php
+++ b/Zotlabs/Widget/Clock.php
@@ -6,9 +6,7 @@ class Clock {
function widget($arr) {
- $miltime = 0;
- if(isset($arr['military']) && $arr['military'])
- $miltime = 1;
+ $miltime = ((isset($arr['military']) && $arr['military']) ? intval($arr['military']) : false);
$o = <<< EOT
@@ -29,7 +27,7 @@ function startclock(){
showtime()
}
-function showtime(){
+function showtime() {
var now = new Date()
var hours = now.getHours()
var minutes = now.getMinutes()
diff --git a/Zotlabs/Widget/Collections.php b/Zotlabs/Widget/Collections.php
index 3a7e98547..ae4952471 100644
--- a/Zotlabs/Widget/Collections.php
+++ b/Zotlabs/Widget/Collections.php
@@ -24,7 +24,7 @@ class Collections {
break;
case 'connections':
$every = 'connections';
- $each = 'group';
+ $each = 'lists';
$edit = true;
$current = $_REQUEST['gid'];
$abook_id = 0;
@@ -39,7 +39,7 @@ class Collections {
break;
case 'abook':
$every = 'connections';
- $each = 'group';
+ $each = 'lists';
$edit = false;
$current = 0;
$abook_id = App::$poi['abook_xchan'];
diff --git a/Zotlabs/Widget/Newmember.php b/Zotlabs/Widget/Newmember.php
index 858e8c261..bd3caabcb 100644
--- a/Zotlabs/Widget/Newmember.php
+++ b/Zotlabs/Widget/Newmember.php
@@ -1,24 +1,29 @@
t('New Member Links'),
'$options' => $options
-
]);
return $o;
diff --git a/Zotlabs/Widget/Notes.php b/Zotlabs/Widget/Notes.php
index 5c83a550f..ef3b2e981 100644
--- a/Zotlabs/Widget/Notes.php
+++ b/Zotlabs/Widget/Notes.php
@@ -2,21 +2,25 @@
namespace Zotlabs\Widget;
+use Zotlabs\Lib\Apps;
+
class Notes {
function widget($arr) {
- if(! local_channel())
+ if (! local_channel()) {
return '';
- if(! feature_enabled(local_channel(),'private_notes'))
+ }
+ if (! Apps::system_app_installed(local_channel(),'Notes')) {
return '';
+ }
$text = get_pconfig(local_channel(),'notes','text');
- $o = replace_macros(get_markup_template('notes.tpl'), array(
+ $o = replace_macros(get_markup_template('notes.tpl'), [
'$banner' => t('Notes'),
'$text' => $text,
'$save' => t('Save'),
- ));
+ ]);
return $o;
}
diff --git a/Zotlabs/Widget/Notifications.php b/Zotlabs/Widget/Notifications.php
index eb41df8ca..a442d8cb2 100644
--- a/Zotlabs/Widget/Notifications.php
+++ b/Zotlabs/Widget/Notifications.php
@@ -14,11 +14,11 @@ class Notifications {
'type' => 'network',
'icon' => 'th',
'severity' => 'secondary',
- 'label' => t('New Network Activity'),
- 'title' => t('New Network Activity Notifications'),
+ 'label' => t('New Stream Activity'),
+ 'title' => t('New Stream Activity Notifications'),
'viewall' => [
'url' => 'network',
- 'label' => t('View your network activity')
+ 'label' => t('View your stream activity')
],
'markall' => [
'label' => t('Mark all notifications read')
diff --git a/Zotlabs/Widget/Shortprofile.php b/Zotlabs/Widget/Shortprofile.php
index 9c2a46e75..4e98d02dd 100644
--- a/Zotlabs/Widget/Shortprofile.php
+++ b/Zotlabs/Widget/Shortprofile.php
@@ -2,17 +2,16 @@
namespace Zotlabs\Widget;
+use App;
+use Zotlabs\Lib\Libprofile;
+
class Shortprofile {
function widget($arr) {
-
- if(! \App::$profile['profile_uid'])
- return;
-
- $block = observer_prohibited();
-
- return profile_sidebar(\App::$profile, $block, true, true);
+ if (App::$profile['profile_uid']) {
+ return Libprofile::widget(App::$profile, observer_prohibited(), true, true);
+ }
+ return EMPTY_STR;
}
-
}
diff --git a/Zotlabs/Widget/Suggestions.php b/Zotlabs/Widget/Suggestions.php
index 5207496de..732aa0de9 100644
--- a/Zotlabs/Widget/Suggestions.php
+++ b/Zotlabs/Widget/Suggestions.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Widget;
+use App;
use Zotlabs\Lib\Apps;
require_once('include/socgraph.php');
@@ -42,7 +43,7 @@ class Suggestions {
'profile' => $rr['xchan_url'],
'name' => $rr['xchan_name'],
'photo' => $rr['xchan_photo_m'],
- 'ignlnk' => z_root() . '/directory?ignore=' . $rr['xchan_hash'],
+ 'ignlnk' => z_root() . '/directory?return=' . base64_encode(App::$query_string) . '&ignore=' . $rr['xchan_hash'],
'conntxt' => t('Connect'),
'connlnk' => $connlnk,
'ignore' => t('Ignore/Hide')
diff --git a/Zotlabs/Widget/Tasklist.php b/Zotlabs/Widget/Tasklist.php
index 56342bd17..122b7ecfb 100644
--- a/Zotlabs/Widget/Tasklist.php
+++ b/Zotlabs/Widget/Tasklist.php
@@ -2,14 +2,17 @@
namespace Zotlabs\Widget;
+use Zotlabs\Lib\Apps;
+
require_once('include/event.php');
class Tasklist {
function widget($arr) {
- if (! local_channel())
- return;
+ if(! ( local_channel() && Apps::system_app_installed(local_channel(),'Tasks'))) {
+ return EMPTY_STR;
+ }
$o .= '';
$o .= '