aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Daemon/Cache_embeds.php27
-rw-r--r--Zotlabs/Daemon/Notifier.php13
-rw-r--r--Zotlabs/Lib/Activity.php50
-rw-r--r--Zotlabs/Lib/Apps.php376
-rw-r--r--Zotlabs/Lib/Libzot.php288
-rw-r--r--Zotlabs/Lib/PConfig.php21
-rw-r--r--Zotlabs/Lib/Share.php1
-rw-r--r--Zotlabs/Lib/ThreadItem.php34
-rw-r--r--Zotlabs/Lib/ThreadListener.php53
-rw-r--r--Zotlabs/Module/Admin.php2
-rw-r--r--Zotlabs/Module/Admin/Addons.php5
-rw-r--r--Zotlabs/Module/Admin/Site.php2
-rw-r--r--Zotlabs/Module/Affinity.php94
-rw-r--r--Zotlabs/Module/Cards.php16
-rw-r--r--Zotlabs/Module/Chanview.php2
-rw-r--r--Zotlabs/Module/Connedit.php2
-rw-r--r--Zotlabs/Module/Display.php5
-rw-r--r--Zotlabs/Module/Embed.php22
-rw-r--r--Zotlabs/Module/Embedphotos.php122
-rw-r--r--Zotlabs/Module/Events.php4
-rw-r--r--Zotlabs/Module/Group.php11
-rw-r--r--Zotlabs/Module/Item.php151
-rw-r--r--Zotlabs/Module/Mail.php4
-rw-r--r--Zotlabs/Module/Network.php8
-rw-r--r--Zotlabs/Module/Notes.php20
-rw-r--r--Zotlabs/Module/Oep.php11
-rw-r--r--Zotlabs/Module/Photos.php2
-rw-r--r--Zotlabs/Module/Profiles.php28
-rw-r--r--Zotlabs/Module/Settings/Featured.php42
-rw-r--r--Zotlabs/Module/Share.php140
-rw-r--r--Zotlabs/Module/Viewsrc.php4
-rw-r--r--Zotlabs/Photo/PhotoDriver.php498
-rw-r--r--Zotlabs/Photo/PhotoGd.php176
-rw-r--r--Zotlabs/Photo/PhotoImagick.php200
-rw-r--r--Zotlabs/Web/Session.php46
-rw-r--r--Zotlabs/Widget/Affinity.php89
-rw-r--r--Zotlabs/Widget/Settings_menu.php7
-rw-r--r--Zotlabs/Zot6/Zot6Handler.php36
38 files changed, 2033 insertions, 579 deletions
diff --git a/Zotlabs/Daemon/Cache_embeds.php b/Zotlabs/Daemon/Cache_embeds.php
new file mode 100644
index 000000000..08088abd6
--- /dev/null
+++ b/Zotlabs/Daemon/Cache_embeds.php
@@ -0,0 +1,27 @@
+<?php /** @file */
+
+namespace Zotlabs\Daemon;
+
+
+class Cache_embeds {
+
+ static public function run($argc,$argv) {
+
+ if(! $argc == 2)
+ return;
+
+ $c = q("select body from item where id = %d ",
+ dbesc(intval($argv[1]))
+ );
+
+ if(! $c)
+ return;
+
+ $item = $c[0];
+
+ // bbcode conversion by default processes embeds that aren't already cached.
+ // Ignore the returned html output.
+
+ bbcode($item['body']);
+ }
+}
diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php
index beb30ed96..df73d977d 100644
--- a/Zotlabs/Daemon/Notifier.php
+++ b/Zotlabs/Daemon/Notifier.php
@@ -434,6 +434,8 @@ class Notifier {
$x['body'] = 'private';
logger('notifier: encoded item: ' . print_r($x,true), LOGGER_DATA, LOG_DEBUG);
+ //logger('notifier: encoded activity: ' . print_r($activity,true), LOGGER_DATA, LOG_DEBUG);
+
stringify_array_elms($recipients);
if(! $recipients) {
logger('no recipients');
@@ -677,6 +679,17 @@ class Notifier {
}
$packet_type = (($upstream || $uplink) ? 'response' : 'activity');
+
+ // block zot private reshares from zot6, as this could cause a number of privacy issues
+ // due to parenting differences between the reshare implementations. In zot a reshare is
+ // a standalone parent activity and in zot6 it is a followup/child of the original activity.
+ // For public reshares, some comments to the reshare on the zot fork will not make it to zot6
+ // due to these different message models. This cannot be prevented at this time.
+
+ if($packet_type === 'activity' && $activity['type'] === 'Announce' && intval($target_item['item_private'])) {
+ continue;
+ }
+
$packet = Libzot::build_packet($channel,$packet_type,$zenv,$activity,'activitystreams',(($private) ? $hub['hubloc_sitekey'] : null),$hub['site_crypto']);
}
else {
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 154421b6a..bcbe53df7 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -35,6 +35,9 @@ class Activity {
if($x['type'] === ACTIVITY_OBJ_EVENT) {
return self::fetch_event($x);
}
+ if($x['type'] === ACTIVITY_OBJ_PHOTO) {
+ return self::fetch_image($x);
+ }
return $x;
@@ -102,6 +105,29 @@ class Activity {
}
}
+
+ static function fetch_image($x) {
+
+
+ $ret = [
+ 'type' => 'Image',
+ 'id' => $x['id'],
+ 'name' => $x['title'],
+ 'content' => bbcode($x['body']),
+ 'source' => [ 'mediaType' => 'text/bbcode', 'content' => $x['body'] ],
+ 'published' => datetime_convert('UTC','UTC',$x['created'],ATOM_TIME),
+ 'updated' => datetime_convert('UTC','UTC', $x['edited'],ATOM_TIME),
+ 'url' => [
+ 'type' => 'Link',
+ 'mediaType' => $x['link'][0]['type'],
+ 'href' => $x['link'][0]['href'],
+ 'width' => $x['link'][0]['width'],
+ 'height' => $x['link'][0]['height']
+ ]
+ ];
+ return $ret;
+ }
+
static function fetch_event($x) {
// convert old Zot event objects to ActivityStreams Event objects
@@ -210,7 +236,7 @@ class Activity {
$ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/item/' . urlencode($i['mid']));
if($i['title'])
- $ret['title'] = bbcode($i['title']);
+ $ret['name'] = $i['title'];
$ret['published'] = datetime_convert('UTC','UTC',$i['created'],ATOM_TIME);
if($i['created'] !== $i['edited'])
@@ -385,10 +411,17 @@ class Activity {
$ret['type'] = 'Tombstone';
$ret['formerType'] = self::activity_obj_mapper($i['obj_type']);
$ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/item/' . urlencode($i['mid']));
+ $actor = self::encode_person($i['author'],false);
+ if($actor)
+ $ret['actor'] = $actor;
+ else
+ return [];
return $ret;
}
$ret['type'] = self::activity_mapper($i['verb']);
+
+
$ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/activity/' . urlencode($i['mid']));
if($i['title'])
@@ -460,6 +493,10 @@ class Activity {
if(! is_array($i['obj'])) {
$i['obj'] = json_decode($i['obj'],true);
}
+ if($i['obj']['type'] === ACTIVITY_OBJ_PHOTO) {
+ $i['obj']['id'] = $i['id'];
+ }
+
$obj = self::encode_object($i['obj']);
if($obj)
$ret['object'] = $obj;
@@ -1374,6 +1411,9 @@ class Activity {
$s['owner_xchan'] = $act->actor['id'];
$s['author_xchan'] = $act->actor['id'];
+ // ensure we store the original actor
+ self::actor_store($act->actor['id'],$act->actor);
+
$s['mid'] = $act->obj['id'];
$s['parent_mid'] = $act->parent_id;
@@ -1446,7 +1486,8 @@ class Activity {
$s['verb'] = self::activity_decode_mapper($act->type);
- if($act->type === 'Tombstone') {
+
+ if($act->type === 'Tombstone' || ($act->type === 'Create' && $act->obj['type'] === 'Tombstone')) {
$s['item_deleted'] = 1;
}
@@ -1455,7 +1496,6 @@ class Activity {
$s['obj_type'] = ACTIVITY_OBJ_COMMENT;
}
-
if($act->obj['type'] === 'Event') {
$s['obj'] = [];
$s['obj']['asld'] = $act->obj;
@@ -1609,7 +1649,9 @@ class Activity {
}
- if($act->obj['type'] === 'Image') {
+ // avoid double images from hubzilla to zap/osada
+
+ if($act->obj['type'] === 'Image' && strpos($s['body'],'zrl=') === false) {
$ptr = null;
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php
index de7439ed7..56283ff76 100644
--- a/Zotlabs/Lib/Apps.php
+++ b/Zotlabs/Lib/Apps.php
@@ -1,32 +1,34 @@
-<?php /** @file */
+<?php
namespace Zotlabs\Lib;
-/**
- * Apps
- *
- */
-
require_once('include/plugin.php');
require_once('include/channel.php');
-
+/**
+ * @brief Apps class.
+ *
+ */
class Apps {
static public $available_apps = null;
static public $installed_apps = null;
-
static public $base_apps = null;
-
-
+ /**
+ * @brief
+ *
+ * @param boolean $translate (optional) default true
+ * @return array
+ */
static public function get_system_apps($translate = true) {
+ $ret = [];
- $ret = array();
if(is_dir('apps'))
$files = glob('apps/*.apd');
else
$files = glob('app/*.apd');
+
if($files) {
foreach($files as $f) {
$x = self::parse_app_description($f,$translate);
@@ -50,14 +52,17 @@ class Apps {
}
}
- call_hooks('get_system_apps',$ret);
+ /**
+ * @hooks get_system_apps
+ * Hook to manipulate the system apps array.
+ */
+ call_hooks('get_system_apps', $ret);
return $ret;
-
}
static public function get_base_apps() {
- $x = get_config('system','base_apps',[
+ $x = get_config('system','base_apps',[
'Connections',
'Network',
'Settings',
@@ -72,7 +77,13 @@ class Apps {
'Mail',
'Profile Photo'
]);
- call_hooks('get_base_apps',$x);
+
+ /**
+ * @hooks get_base_apps
+ * Hook to manipulate the base apps array.
+ */
+ call_hooks('get_base_apps', $x);
+
return $x;
}
@@ -81,7 +92,7 @@ class Apps {
return;
self::$base_apps = self::get_base_apps();
-
+
$apps = self::get_system_apps(false);
self::$available_apps = q("select * from app where app_channel = 0");
@@ -106,6 +117,7 @@ class Apps {
// $id will be boolean true or false to install an app, or an integer id to update an existing app
if($id === false)
continue;
+
if($id !== true) {
// if we already installed this app, but it changed, preserve any categories we created
$s = EMPTY_STR;
@@ -126,16 +138,17 @@ class Apps {
$app['guid'] = hash('whirlpool',$app['name']);
$app['system'] = 1;
self::app_install(local_channel(),$app);
-
}
- }
+ }
}
/**
- * Install the system app if no system apps have been installed, or if a new system app
+ * Install the system app if no system apps have been installed, or if a new system app
* is discovered, or if the version of a system app changes.
+ *
+ * @param array $app
+ * @return boolean|int
*/
-
static public function check_install_system_app($app) {
if((! is_array(self::$available_apps)) || (! count(self::$available_apps))) {
return true;
@@ -159,17 +172,16 @@ class Apps {
return $notfound;
}
-
/**
- * Install the system app if no system apps have been installed, or if a new system app
- * is discovered, or if the version of a system app changes.
+ * Install the personal app if no personal apps have been installed, or if a new personal app
+ * is discovered, or if the version of a personal app changes.
+ *
+ * @param array $app
+ * @return boolean|int
*/
-
-
-
static public function check_install_personal_app($app) {
$installed = false;
- foreach(self::$installed_apps as $iapp) {
+ foreach(self::$installed_apps as $iapp) {
if($iapp['app_id'] == hash('whirlpool',$app['name'])) {
$installed = true;
if(($iapp['app_version'] != $app['version'])
@@ -189,19 +201,24 @@ class Apps {
return strcasecmp($a['name'],$b['name']);
}
-
- static public function parse_app_description($f,$translate = true) {
-
- $ret = array();
+ /**
+ * @brief Parse app description.
+ *
+ * @param string $f filename
+ * @param boolean $translate (optional) default true
+ * @return boolean|array
+ */
+ static public function parse_app_description($f, $translate = true) {
+ $ret = [];
+ $matches = [];
$baseurl = z_root();
- $channel = \App::get_channel();
- $address = (($channel) ? $channel['channel_address'] : '');
-
+ //$channel = \App::get_channel();
+ //$address = (($channel) ? $channel['channel_address'] : '');
+
//future expansion
$observer = \App::get_observer();
-
$lines = @file($f);
if($lines) {
@@ -210,7 +227,7 @@ class Apps {
$ret[$matches[1]] = trim($matches[2]);
}
}
- }
+ }
if(! $ret['photo'])
$ret['photo'] = $baseurl . '/' . get_default_profile_photo(80);
@@ -292,15 +309,18 @@ class Apps {
if($ret) {
if($translate)
self::translate_system_apps($ret);
+
return $ret;
}
+
return false;
- }
+ }
static public function translate_system_apps(&$arr) {
$apps = array(
'Apps' => t('Apps'),
+ 'Affinity Tool' => t('Affinity Tool'),
'Articles' => t('Articles'),
'Cards' => t('Cards'),
'Admin' => t('Site Admin'),
@@ -311,17 +331,17 @@ class Apps {
'Remote Diagnostics' => t('Remote Diagnostics'),
'Suggest Channels' => t('Suggest Channels'),
'Login' => t('Login'),
- 'Channel Manager' => t('Channel Manager'),
+ 'Channel Manager' => t('Channel Manager'),
'Network' => t('Stream'),
'Settings' => t('Settings'),
'Files' => t('Files'),
'Webpages' => t('Webpages'),
'Wiki' => t('Wiki'),
- 'Channel Home' => t('Channel Home'),
+ 'Channel Home' => t('Channel Home'),
'View Profile' => t('View Profile'),
- 'Photos' => t('Photos'),
- 'Events' => t('Events'),
- 'Directory' => t('Directory'),
+ 'Photos' => t('Photos'),
+ 'Events' => t('Events'),
+ 'Directory' => t('Directory'),
'Help' => t('Help'),
'Mail' => t('Mail'),
'Mood' => t('Mood'),
@@ -366,30 +386,31 @@ class Apps {
if(array_key_exists($arr[$x]['name'],$apps)) {
$arr[$x]['name'] = $apps[$arr[$x]['name']];
} else {
- // Try to guess by app name if not in list
- $arr[$x]['name'] = t(trim($arr[$x]['name']));
+ // Try to guess by app name if not in list
+ $arr[$x]['name'] = t(trim($arr[$x]['name']));
}
}
}
-
}
-
- // papp is a portable app
-
- static public function app_render($papp,$mode = 'view') {
-
- /**
- * modes:
- * view: normal mode for viewing an app via bbcode from a conversation or page
- * provides install/update button if you're logged in locally
- * install: like view but does not display app-bin options if they are present
- * list: normal mode for viewing an app on the app page
- * no buttons are shown
- * edit: viewing the app page in editing mode provides a delete button
- * nav: render apps for app-bin
- */
-
+ /**
+ * @brief
+ *
+ * @param array $papp
+ * papp is a portable app
+ * @param string $mode (optional) default 'view'
+ * Render modes:
+ * * \b view: normal mode for viewing an app via bbcode from a conversation or page
+ * provides install/update button if you're logged in locally
+ * * \b install: like view but does not display app-bin options if they are present
+ * * \b list: normal mode for viewing an app on the app page
+ * no buttons are shown
+ * * \b edit: viewing the app page in editing mode provides a delete button
+ * * \b nav: render apps for app-bin
+ *
+ * @return void|string Parsed HTML
+ */
+ static public function app_render($papp, $mode = 'view') {
$installed = false;
if(! $papp)
@@ -414,7 +435,7 @@ class Apps {
$sys = get_sys_channel();
$view_channel = $sys['channel_id'];
}
- self::app_macros($view_channel,$papp);
+ self::app_macros($view_channel,$papp);
}
if(strpos($papp['url'], ',')) {
@@ -427,7 +448,6 @@ class Apps {
$papp['url'] = z_root() . ((strpos($papp['url'],'/') === 0) ? '' : '/') . $papp['url'];
-
foreach($papp as $k => $v) {
if(strpos($v,'http') === 0 && $k != 'papp') {
if(! (local_channel() && strpos($v,z_root()) === 0)) {
@@ -509,7 +529,7 @@ class Apps {
if($x) {
$hosturl = $x['scheme'] . '://' . $x['host'] . '/';
}
- }
+ }
}
$install_action = (($installed) ? t('Update') : t('Install'));
@@ -592,8 +612,14 @@ class Apps {
return false;
}
-
- static public function can_delete($uid,$app) {
+ /**
+ * @brief
+ *
+ * @param mixed $uid If not set return false, otherwise no influence
+ * @param array $app
+ * @return boolean
+ */
+ static public function can_delete($uid, $app) {
if(! $uid) {
return false;
}
@@ -601,7 +627,7 @@ class Apps {
$base_apps = self::get_base_apps();
if($base_apps) {
foreach($base_apps as $b) {
- if($app['guid'] === hash('whirlpool',$b)) {
+ if($app['guid'] === hash('whirlpool', $b)) {
return false;
}
}
@@ -613,7 +639,6 @@ class Apps {
static public function app_destroy($uid,$app) {
if($uid && $app['guid']) {
-
$x = q("select * from app where app_id = '%s' and app_channel = %d limit 1",
dbesc($app['guid']),
intval($uid)
@@ -622,7 +647,7 @@ class Apps {
if(! intval($x[0]['app_deleted'])) {
$x[0]['app_deleted'] = 1;
if(self::can_delete($uid,$app)) {
- $r = q("delete from app where app_id = '%s' and app_channel = %d",
+ q("delete from app where app_id = '%s' and app_channel = %d",
dbesc($app['guid']),
intval($uid)
);
@@ -630,10 +655,15 @@ class Apps {
intval(TERM_OBJ_APP),
intval($x[0]['id'])
);
+ /**
+ * @hooks app_destroy
+ * Called after app entry got removed from database
+ * and provide app array from database.
+ */
call_hooks('app_destroy', $x[0]);
}
else {
- $r = q("update app set app_deleted = 1 where app_id = '%s' and app_channel = %d",
+ q("update app set app_deleted = 1 where app_id = '%s' and app_channel = %d",
dbesc($app['guid']),
intval($uid)
);
@@ -647,22 +677,23 @@ class Apps {
}
}
}
-
}
- static public function app_undestroy($uid,$app) {
-
- // undelete a system app
-
+ /**
+ * @brief Undelete a system app.
+ *
+ * @param int $uid
+ * @param array $app
+ */
+ static public function app_undestroy($uid, $app) {
if($uid && $app['guid']) {
-
$x = q("select * from app where app_id = '%s' and app_channel = %d limit 1",
dbesc($app['guid']),
intval($uid)
);
if($x) {
if($x[0]['app_system']) {
- $r = q("update app set app_deleted = 0 where app_id = '%s' and app_channel = %d",
+ q("update app set app_deleted = 0 where app_id = '%s' and app_channel = %d",
dbesc($app['guid']),
intval($uid)
);
@@ -671,7 +702,15 @@ class Apps {
}
}
- static public function app_feature($uid,$app,$term) {
+ /**
+ * @brief
+ *
+ * @param int $uid
+ * @param array $app
+ * @param string $term
+ * @return void
+ */
+ static public function app_feature($uid, $app, $term) {
$r = q("select id from app where app_id = '%s' and app_channel = %d limit 1",
dbesc($app['guid']),
intval($uid)
@@ -695,23 +734,37 @@ class Apps {
}
}
- static public function app_installed($uid,$app,$bypass_filter=false) {
+ /**
+ * @brief
+ *
+ * @param int $uid
+ * @param array $app
+ * @param boolean $bypass_filter (optional) default false
+ * @return boolean
+ */
+ static public function app_installed($uid, $app, $bypass_filter = false) {
$r = q("select id from app where app_id = '%s' and app_channel = %d limit 1",
- dbesc((array_key_exists('guid',$app)) ? $app['guid'] : ''),
+ dbesc((array_key_exists('guid', $app)) ? $app['guid'] : ''),
intval($uid)
);
- if (!$bypass_filter) {
+ if(!$bypass_filter) {
$filter_arr = [
- 'uid'=>$uid,
- 'app'=>$app,
- 'installed'=>$r
+ 'uid' => $uid,
+ 'app' => $app,
+ 'installed' => $r
];
- call_hooks('app_installed_filter',$filter_arr);
+ /**
+ * @hooks app_installed_filter
+ * * \e int \b uid
+ * * \e array \b app
+ * * \e mixed \b installed - return value
+ */
+ call_hooks('app_installed_filter', $filter_arr);
$r = $filter_arr['installed'];
}
- return(($r) ? true : false);
+ return(($r) ? true : false);
}
@@ -727,11 +780,17 @@ class Apps {
'app'=>$app,
'installed'=>$r
];
- call_hooks('addon_app_installed_filter',$filter_arr);
+ /**
+ * @hooks addon_app_installed_filter
+ * * \e int \b uid
+ * * \e array \b app
+ * * \e mixed \b installed - return value
+ */
+ call_hooks('addon_app_installed_filter', $filter_arr);
$r = $filter_arr['installed'];
}
- return(($r) ? true : false);
+ return(($r) ? true : false);
}
static public function system_app_installed($uid,$app,$bypass_filter=false) {
@@ -746,28 +805,39 @@ class Apps {
'app'=>$app,
'installed'=>$r
];
- call_hooks('system_app_installed_filter',$filter_arr);
+ /**
+ * @hooks system_app_installed_filter
+ * * \e int \b uid
+ * * \e array \b app
+ * * \e mixed \b installed - return value
+ */
+ call_hooks('system_app_installed_filter', $filter_arr);
$r = $filter_arr['installed'];
}
- return(($r) ? true : false);
+ return(($r) ? true : false);
}
-
-
+ /**
+ * @brief
+ *
+ * @param int $uid
+ * @param boolean $deleted
+ * @param array $cats
+ * @return boolean|array
+ */
static public function app_list($uid, $deleted = false, $cats = []) {
- if($deleted)
- $sql_extra = "";
+ if($deleted)
+ $sql_extra = '';
else
- $sql_extra = " and app_deleted = 0 ";
+ $sql_extra = ' and app_deleted = 0 ';
if($cats) {
-
- $cat_sql_extra = " and ( ";
+ $cat_sql_extra = ' and ( ';
foreach($cats as $cat) {
if(strpos($cat_sql_extra, 'term'))
- $cat_sql_extra .= "or ";
+ $cat_sql_extra .= 'or ';
$cat_sql_extra .= "term = '" . dbesc($cat) . "' ";
}
@@ -779,11 +849,13 @@ class Apps {
);
if(! $r)
return $r;
- $sql_extra .= " and app.id in ( ";
+
+ $sql_extra .= ' and app.id in ( ';
$s = '';
foreach($r as $rr) {
if($s)
$s .= ',';
+
$s .= intval($rr['oid']);
}
$sql_extra .= $s . ') ';
@@ -794,12 +866,26 @@ class Apps {
);
if($r) {
- $hookinfo = Array('uid'=>$uid,'deleted'=>$deleted,'cats'=>$cats,'apps'=>$r);
- call_hooks('app_list',$hookinfo);
+ $hookinfo = [
+ 'uid' => $uid,
+ 'deleted' => $deleted,
+ 'cats' => $cats,
+ 'apps' => $r,
+ ];
+ /**
+ * @hooks app_list
+ * * \e int \b uid
+ * * \e boolean \b deleted
+ * * \e array \b cats
+ * * \e array \b apps - return value
+ */
+ call_hooks('app_list', $hookinfo);
$r = $hookinfo['apps'];
- for($x = 0; $x < count($r); $x ++) {
+
+ for($x = 0; $x < count($r); $x++) {
if(! $r[$x]['app_system'])
$r[$x]['type'] = 'personal';
+
$r[$x]['term'] = q("select * from term where otype = %d and oid = %d",
intval(TERM_OBJ_APP),
intval($r[$x]['id'])
@@ -807,7 +893,7 @@ class Apps {
}
}
- return($r);
+ return $r;
}
static public function app_order($uid,$apps,$menu) {
@@ -839,13 +925,14 @@ class Apps {
$ret[] = $ap;
}
}
- return $ret;
+ return $ret;
}
static function find_app_in_array($name,$arr) {
if(! $arr)
return false;
+
foreach($arr as $x) {
if($x['name'] === $name) {
return $x;
@@ -854,8 +941,16 @@ class Apps {
return false;
}
- static function moveup($uid,$guid,$menu) {
- $syslist = array();
+ /**
+ * @brief
+ *
+ * @param int $uid
+ * @param int $guid
+ * @param string $menu
+ * @return void
+ */
+ static function moveup($uid, $guid, $menu) {
+ $syslist = [];
$conf = (($menu === 'nav_featured_app') ? 'app_order' : 'app_pin_order');
@@ -865,6 +960,7 @@ class Apps {
$papp = self::app_encode($li);
if($menu !== 'nav_pinned_app' && strpos($papp['categories'],'nav_pinned_app') !== false)
continue;
+
$syslist[] = $papp;
}
}
@@ -877,8 +973,6 @@ class Apps {
if(! $syslist)
return;
- $newlist = [];
-
foreach($syslist as $k => $li) {
if($li['guid'] === $guid) {
$position = $k;
@@ -887,6 +981,7 @@ class Apps {
}
if(! $position)
return;
+
$dest_position = $position - 1;
$saved = $syslist[$dest_position];
$syslist[$dest_position] = $syslist[$position];
@@ -898,11 +993,18 @@ class Apps {
}
set_pconfig($uid,'system',$conf,implode(',',$narr));
-
}
- static function movedown($uid,$guid,$menu) {
- $syslist = array();
+ /**
+ * @brief
+ *
+ * @param int $uid
+ * @param int $guid
+ * @param string $menu
+ * @return void
+ */
+ static function movedown($uid, $guid, $menu) {
+ $syslist = [];
$conf = (($menu === 'nav_featured_app') ? 'app_order' : 'app_pin_order');
@@ -912,6 +1014,7 @@ class Apps {
$papp = self::app_encode($li);
if($menu !== 'nav_pinned_app' && strpos($papp['categories'],'nav_pinned_app') !== false)
continue;
+
$syslist[] = $papp;
}
}
@@ -924,8 +1027,6 @@ class Apps {
if(! $syslist)
return;
- $newlist = [];
-
foreach($syslist as $k => $li) {
if($li['guid'] === $guid) {
$position = $k;
@@ -934,6 +1035,7 @@ class Apps {
}
if($position >= count($syslist) - 1)
return;
+
$dest_position = $position + 1;
$saved = $syslist[$dest_position];
$syslist[$dest_position] = $syslist[$position];
@@ -945,7 +1047,6 @@ class Apps {
}
set_pconfig($uid,'system',$conf,implode(',',$narr));
-
}
static public function app_decode($s) {
@@ -953,8 +1054,14 @@ class Apps {
return json_decode($x,true);
}
-
- static public function app_macros($uid,&$arr) {
+ /**
+ * @brief
+ *
+ * @param int $uid
+ * @param[in,out] array $arr
+ * @return void
+ */
+ static public function app_macros($uid, &$arr) {
if(! intval($uid))
return;
@@ -962,21 +1069,17 @@ class Apps {
$baseurl = z_root();
$channel = channelx_by_n($uid);
$address = (($channel) ? $channel['channel_address'] : '');
-
+
//future expansion
- $observer = \App::get_observer();
-
+ //$observer = \App::get_observer();
+
$arr['url'] = str_replace(array('$baseurl','$nick'),array($baseurl,$address),$arr['url']);
$arr['photo'] = str_replace(array('$baseurl','$nick'),array($baseurl,$address),$arr['photo']);
-
}
-
-
-
static public function app_store($arr) {
//logger('app_store: ' . print_r($arr,true));
@@ -1160,16 +1263,20 @@ class Apps {
}
return $ret;
-
}
-
- static public function app_encode($app,$embed = false) {
-
- $ret = array();
+ /**
+ * @brief
+ *
+ * @param array $app
+ * @param boolean $embed (optional) default false
+ * @return array|string
+ */
+ static public function app_encode($app, $embed = false) {
+ $ret = [];
$ret['type'] = 'personal';
-
+
if($app['app_id'])
$ret['guid'] = $app['app_id'];
@@ -1202,7 +1309,7 @@ class Apps {
if($app['app_price'])
$ret['price'] = $app['app_price'];
-
+
if($app['app_page'])
$ret['page'] = $app['app_page'];
@@ -1226,12 +1333,12 @@ class Apps {
foreach($app['term'] as $t) {
if($s)
$s .= ',';
+
$s .= $t['term'];
}
$ret['categories'] = $s;
}
-
if(! $embed)
return $ret;
@@ -1239,18 +1346,15 @@ class Apps {
if(array_key_exists('categories',$ret))
unset($ret['categories']);
-
+
$j = json_encode($ret);
- return '[app]' . chunk_split(base64_encode($j),72,"\n") . '[/app]';
+ return '[app]' . chunk_split(base64_encode($j),72,"\n") . '[/app]';
}
static public function papp_encode($papp) {
return chunk_split(base64_encode(json_encode($papp)),72,"\n");
-
}
}
-
-
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index e66c929bf..019237568 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -2,11 +2,6 @@
namespace Zotlabs\Lib;
-/**
- * @brief lowlevel implementation of Zot6 protocol.
- *
- */
-
use Zotlabs\Zot6\HTTPSig;
use Zotlabs\Access\Permissions;
use Zotlabs\Access\PermissionLimits;
@@ -14,14 +9,17 @@ use Zotlabs\Daemon\Master;
require_once('include/crypto.php');
-
+/**
+ * @brief Lowlevel implementation of Zot6 protocol.
+ *
+ */
class Libzot {
/**
* @brief Generates a unique string for use as a zot guid.
*
- * Generates a unique string for use as a zot guid using our DNS-based url, the
- * channel nickname and some entropy.
+ * Generates a unique string for use as a zot guid using our DNS-based url,
+ * the channel nickname and some entropy.
* The entropy ensures uniqueness against re-installs where the same URL and
* nickname are chosen.
*
@@ -32,9 +30,8 @@ class Libzot {
* immediate universe.
*
* @param string $channel_nick a unique nickname of controlling entity
- * @returns string
+ * @return string
*/
-
static function new_uid($channel_nick) {
$rawstr = z_root() . '/' . $channel_nick . '.' . mt_rand();
return(base64url_encode(hash('whirlpool', $rawstr, true), true));
@@ -52,8 +49,8 @@ class Libzot {
*
* @param string $guid
* @param string $pubkey
+ * @return string
*/
-
static function make_xchan_hash($guid, $pubkey) {
return base64url_encode(hash('whirlpool', $guid . $pubkey, true));
}
@@ -65,10 +62,8 @@ class Libzot {
* should only be used by channels which are defined on this hub.
*
* @param string $hash - xchan_hash
- * @returns array of hubloc (hub location structures)
- *
+ * @return array of hubloc (hub location structures)
*/
-
static function get_hublocs($hash) {
/* Only search for active hublocs - e.g. those that haven't been marked deleted */
@@ -92,16 +87,17 @@ class Libzot {
* packet type: one of 'ping', 'pickup', 'purge', 'refresh', 'keychange', 'force_refresh', 'notify', 'auth_check'
* @param array $recipients
* envelope recipients, array of portable_id's; empty for public posts
- * @param string msg
+ * @param string $msg
* optional message
+ * @param string $encoding
+ * optional encoding, default 'activitystreams'
* @param string $remote_key
* optional public site key of target hub used to encrypt entire packet
* NOTE: remote_key and encrypted packets are required for 'auth_check' packets, optional for all others
* @param string $methods
- * optional comma separated list of encryption methods @ref self::best_algorithm()
+ * optional comma separated list of encryption methods @ref best_algorithm()
* @returns string json encoded zot packet
*/
-
static function build_packet($channel, $type = 'activity', $recipients = null, $msg = '', $encoding = 'activitystreams', $remote_key = null, $methods = '') {
$sig_method = get_config('system','signature_algorithm','sha256');
@@ -146,11 +142,10 @@ class Libzot {
* @brief Choose best encryption function from those available on both sites.
*
* @param string $methods
- * comma separated list of encryption methods
+ * Comma separated list of encryption methods
* @return string first match from our site method preferences crypto_methods() array
- * of a method which is common to both sites; or 'aes256cbc' if no matches are found.
+ * of a method which is common to both sites; or 'aes256cbc' if no matches are found.
*/
-
static function best_algorithm($methods) {
$x = [
@@ -164,7 +159,6 @@ class Libzot {
* * \e string \b methods - comma separated list of encryption methods
* * \e string \b result - the algorithm to return
*/
-
call_hooks('zot_best_algorithm', $x);
if($x['result'])
@@ -190,7 +184,7 @@ class Libzot {
/**
- * @brief send a zot message
+ * @brief Send a zot message.
*
* @see z_post_url()
*
@@ -200,18 +194,17 @@ class Libzot {
* @param array $crypto (required if encrypted httpsig, requires hubloc_sitekey and site_crypto elements)
* @return array see z_post_url() for returned data format
*/
-
static function zot($url, $data, $channel = null,$crypto = null) {
if($channel) {
- $headers = [
- 'X-Zot-Token' => random_string(),
- 'Digest' => HTTPSig::generate_digest_header($data),
+ $headers = [
+ 'X-Zot-Token' => random_string(),
+ 'Digest' => HTTPSig::generate_digest_header($data),
'Content-type' => 'application/x-zot+json',
'(request-target)' => 'post ' . get_request_string($url)
];
- $h = HTTPSig::create_sig($headers,$channel['channel_prvkey'],channel_url($channel),false,'sha512',
+ $h = HTTPSig::create_sig($headers,$channel['channel_prvkey'],channel_url($channel),false,'sha512',
(($crypto) ? [ 'key' => $crypto['hubloc_sitekey'], 'algorithm' => self::best_algorithm($crypto['site_crypto']) ] : false));
}
else {
@@ -227,7 +220,6 @@ class Libzot {
/**
* @brief Refreshes after permission changed or friending, etc.
*
- *
* refresh is typically invoked when somebody has changed permissions of a channel and they are notified
* to fetch new permissions via a finger/discovery operation. This may result in a new connection
* (abook entry) being added to a local channel and it may result in auto-permissions being granted.
@@ -251,7 +243,6 @@ class Libzot {
* * \b true if successful
* * otherwise \b false
*/
-
static function refresh($them, $channel = null, $force = false) {
logger('them: ' . print_r($them,true), LOGGER_DATA, LOG_DEBUG);
@@ -265,13 +256,13 @@ class Libzot {
}
else {
$r = null;
-
+
// if they re-installed the server we could end up with the wrong record - pointing to the old install.
// We'll order by reverse id to try and pick off the newest one first and hopefully end up with the
// correct hubloc. If this doesn't work we may have to re-write this section to try them all.
if(array_key_exists('xchan_addr',$them) && $them['xchan_addr']) {
- $r = q("select hubloc_id_url, hubloc_primary from hubloc where hubloc_addr = '%s' order by hubloc_id desc",
+ $r = q("select hubloc_id_url, hubloc_primary from hubloc where hubloc_addr = '%s' and hubloc_network = 'zot6' order by hubloc_id desc",
dbesc($them['xchan_addr'])
);
}
@@ -317,7 +308,7 @@ class Libzot {
if(! $hsig_valid) {
logger('http signature not valid: ' . print_r($hsig,true));
- return $result;
+ return false;
}
@@ -356,7 +347,7 @@ class Libzot {
);
if($r) {
-logger('4');
+
// connection exists
// if the dob is the same as what we have stored (disregarding the year), keep the one
@@ -416,7 +407,7 @@ logger('4');
if($y) {
logger("New introduction received for {$channel['channel_name']}");
$new_perms = get_all_perms($channel['channel_id'],$x['hash'],false);
-
+
// Send a clone sync packet and a permissions update if permissions have changed
$new_connection = q("select * from abook left join xchan on abook_xchan = xchan_hash where abook_xchan = '%s' and abook_channel = %d and abook_self = 0 order by abook_created desc limit 1",
@@ -524,10 +515,14 @@ logger('4');
return false;
}
-
-
-
- static function valid_hub($sender,$site_id) {
+ /**
+ * @brief
+ *
+ * @param string $sender
+ * @param string $site_id
+ * @return null|array
+ */
+ static function valid_hub($sender, $site_id) {
$r = q("select hubloc.*, site.site_crypto from hubloc left join site on hubloc_url = site_url where hubloc_hash = '%s' and hubloc_site_id = '%s' limit 1",
dbesc($sender),
@@ -548,7 +543,6 @@ logger('4');
}
return $r[0];
-
}
/**
@@ -559,21 +553,14 @@ logger('4');
* origination address. This will fetch the discovery packet of the sender,
* which contains the public key we need to verify our guid and url signatures.
*
- * @param array $arr an associative array which must contain:
- * * \e string \b guid => guid of conversant
- * * \e string \b guid_sig => guid signed with conversant's private key
- * * \e string \b url => URL of the origination hub of this communication
- * * \e string \b url_sig => URL signed with conversant's private key
+ * @param string $id
*
* @return array An associative array with
- * * \b success boolean true or false
- * * \b message (optional) error string only if success is false
+ * * \e boolean \b success
+ * * \e string \b message (optional, unused) error string only if success is false
*/
-
static function register_hub($id) {
- $id_hash = false;
- $valid = false;
$hsig_valid = false;
$result = [ 'success' => false ];
@@ -807,7 +794,7 @@ logger('4');
// If setting for the default profile, unset the profile photo flag from any other photos I own
if($is_default_profile) {
- q("UPDATE photo SET photo_usage = %d WHERE photo_usage = %d AND resource_id != '%s' AND aid = %d AND uid = %d",
+ q("UPDATE photo SET photo_usage = %d WHERE photo_usage = %d AND resource_id != '%s' AND aid = %d AND uid = %d",
intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE),
dbesc($hash),
@@ -954,8 +941,8 @@ logger('4');
* @param string $hub - url of site we just contacted
* @param array $arr - output of z_post_url()
* @param array $outq - The queue structure attached to this request
+ * @return void
*/
-
static function process_response($hub, $arr, $outq) {
logger('remote: ' . print_r($arr,true),LOGGER_DATA);
@@ -986,7 +973,7 @@ logger('4');
if(! $x['success']) {
// handle remote validation issues
-
+
$b = q("update dreport set dreport_result = '%s', dreport_time = '%s' where dreport_queue = '%s'",
dbesc(($x['message']) ? $x['message'] : 'unknown delivery error'),
dbesc(datetime_convert()),
@@ -994,7 +981,7 @@ logger('4');
);
}
- if(is_array($x) && array_key_exists('delivery_report',$x) && is_array($x['delivery_report'])) {
+ if(is_array($x) && array_key_exists('delivery_report',$x) && is_array($x['delivery_report'])) {
foreach($x['delivery_report'] as $xx) {
call_hooks('dreport_process',$xx);
@@ -1083,11 +1070,6 @@ logger('4');
*
* @param array $arr
* 'pickup' structure returned from remote site
- * @param string $sender_url
- * the url specified by the sender in the initial communication.
- * We will verify the sender and url in each returned message structure and
- * also verify that all the messages returned match the site url that we are
- * currently processing.
*
* @returns array
* Suitable for logging remotely, enumerating the processing results of each message/recipient combination
@@ -1095,7 +1077,6 @@ logger('4');
* * [1] => \e string $delivery_status
* * [2] => \e string $address
*/
-
static function import($arr) {
$env = $arr;
@@ -1117,7 +1098,7 @@ logger('4');
$has_data = array_key_exists('data',$env) && $env['data'];
$data = (($has_data) ? $env['data'] : false);
- $AS = null;
+ $AS = null;
if($env['encoding'] === 'activitystreams') {
@@ -1175,7 +1156,6 @@ logger('4');
$deliveries = self::public_recips($env,$AS);
-
}
$deliveries = array_unique($deliveries);
@@ -1194,31 +1174,31 @@ logger('4');
//logger($AS->debug());
- $r = q("select hubloc_hash from hubloc where hubloc_id_url = '%s' limit 1",
+ $r = q("select hubloc_hash from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' limit 1",
dbesc($AS->actor['id'])
- );
+ );
if($r) {
$arr['author_xchan'] = $r[0]['hubloc_hash'];
}
- $s = q("select hubloc_hash from hubloc where hubloc_id_url = '%s' limit 1",
+ $s = q("select hubloc_hash from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' limit 1",
dbesc($env['sender'])
- );
+ );
// in individual delivery, change owner if needed
if($s) {
$arr['owner_xchan'] = $s[0]['hubloc_hash'];
}
else {
- $arr['owner_xchan'] = $env['sender'];
+ $arr['owner_xchan'] = $env['sender'];
}
if($private) {
$arr['item_private'] = true;
}
- // @fixme - spoofable
+ /// @FIXME - spoofable
if($AS->data['hubloc']) {
$arr['item_verified'] = true;
}
@@ -1247,12 +1227,19 @@ logger('4');
}
if ($result) {
$return = array_merge($return, $result);
- }
+ }
return $return;
}
- static function is_top_level($env,$act) {
+ /**
+ * @brief
+ *
+ * @param array $env
+ * @param object $act
+ * @return boolean
+ */
+ static function is_top_level($env, $act) {
if($env['encoding'] === 'zot' && array_key_exists('flags',$env) && in_array('thread_parent', $env['flags'])) {
return true;
}
@@ -1295,9 +1282,9 @@ logger('4');
* Some of these will be rejected, but this gives us a place to start.
*
* @param array $msg
- * @return NULL|array
+ * @param object $act
+ * @return array
*/
-
static function public_recips($msg, $act) {
require_once('include/channel.php');
@@ -1442,7 +1429,7 @@ logger('4');
* will normally arrive first via sync delivery, but this isn't guaranteed.
* There's a chance the current delivery could take place before the cloned copy arrives
* hence the item could have the wrong ACL and *could* be used in subsequent deliveries or
- * access checks.
+ * access checks.
*/
if($sender === $channel['channel_portable_id'] && $arr['author_xchan'] === $channel['channel_portable_id'] && $arr['mid'] === $arr['parent_mid']) {
@@ -1497,14 +1484,37 @@ logger('4');
intval($channel['channel_id'])
);
if ($parent) {
- $allowed = can_comment_on_post($d,$parent[0]);
+ $allowed = can_comment_on_post($sender,$parent[0]);
}
}
- if($request) {
- $allowed = true;
+
+ if ($request) {
+
+ // Conversation fetches (e.g. $request == true) take place for
+ // a) new comments on expired posts
+ // b) hyperdrive (friend-of-friend) conversations
+ // c) Repeats of posts by others
+
+
+ // over-ride normal connection permissions for hyperdrive (friend-of-friend) conversations
+ // (if hyperdrive is enabled) and repeated posts by a friend.
+ // If $allowed is already true, this is probably the conversation of a direct friend or a
+ // conversation fetch for a new comment on an expired post
+ // Comments of all these activities are allowed and will only be rejected (later) if the parent
+ // doesn't exist.
+
+ if ($perm === 'send_stream') {
+ if (get_pconfig($channel['channel_id'],'system','hyperdrive',false) || $arr['verb'] === ACTIVITY_SHARE) {
+ $allowed = true;
+ }
+ }
+ else {
+ $allowed = true;
+ }
+
$friendofriend = true;
}
-
+
if (! $allowed) {
logger("permission denied for delivery to channel {$channel['channel_id']} {$channel['channel_address']}");
$DR->update('permission denied');
@@ -1513,16 +1523,18 @@ logger('4');
}
}
-logger('item: ' . print_r($arr,true), LOGGER_DATA);
+ // logger('item: ' . print_r($arr,true), LOGGER_DATA);
if($arr['mid'] !== $arr['parent_mid']) {
-logger('checking source: "' . $arr['mid'] . '" != "' . $arr['parent_mid'] . '"');
+
+ logger('checking source: "' . $arr['mid'] . '" != "' . $arr['parent_mid'] . '"');
+
// check source route.
// We are only going to accept comments from this sender if the comment has the same route as the top-level-post,
// this is so that permissions mismatches between senders apply to the entire conversation
// As a side effect we will also do a preliminary check that we have the top-level-post, otherwise
// processing it is pointless.
-
+
$r = q("select route, id, owner_xchan, item_private from item where mid = '%s' and uid = %d limit 1",
dbesc($arr['parent_mid']),
intval($channel['channel_id'])
@@ -1537,10 +1549,7 @@ logger('checking source: "' . $arr['mid'] . '" != "' . $arr['parent_mid'] . '"')
// have the copy and we don't want the request to loop.
// Also don't do this if this comment came from a conversation request packet.
// It's possible that comments are allowed but posting isn't and that could
- // cause a conversation fetch loop. We can detect these packets since they are
- // delivered via a 'notify' packet type that has a message_id element in the
- // initial zot packet (just like the corresponding 'request' packet type which
- // makes the request).
+ // cause a conversation fetch loop.
// We'll also check the send_stream permission - because if it isn't allowed,
// the top level post is unlikely to be imported and
// this is just an exercise in futility.
@@ -1551,14 +1560,14 @@ logger('checking source: "' . $arr['mid'] . '" != "' . $arr['parent_mid'] . '"')
}
continue;
}
-
+
if($relay || $friendofriend || (intval($r[0]['item_private']) === 0 && intval($arr['item_private']) === 0)) {
// reset the route in case it travelled a great distance upstream
// use our parent's route so when we go back downstream we'll match
// with whatever route our parent has.
// Also friend-of-friend conversations may have been imported without a route,
// but we are now getting comments via listener delivery
- // and if there is no privacy on this or the parent, we don't care about the route,
+ // and if there is no privacy on this or the parent, we don't care about the route,
// so just set the owner and route accordingly.
$arr['route'] = $r[0]['route'];
$arr['owner_xchan'] = $r[0]['owner_xchan'];
@@ -1601,7 +1610,7 @@ logger('checking source: "' . $arr['mid'] . '" != "' . $arr['parent_mid'] . '"')
$arr['route'] = $last_prior_route;
}
}
-logger('hey');
+
$ab = q("select * from abook where abook_channel = %d and abook_xchan = '%s'",
intval($channel['channel_id']),
dbesc($arr['owner_xchan'])
@@ -1612,13 +1621,13 @@ logger('hey');
// remove_community_tag is a no-op if this isn't a community tag activity
self::remove_community_tag($sender,$arr,$channel['channel_id']);
-
+
// set these just in case we need to store a fresh copy of the deleted post.
// This could happen if the delete got here before the original post did.
$arr['aid'] = $channel['channel_account_id'];
$arr['uid'] = $channel['channel_id'];
-
+
$item_id = self::delete_imported_item($sender,$arr,$channel['channel_id'],$relay);
$DR->update(($item_id) ? 'deleted' : 'delete_failed');
$result[] = $DR->get();
@@ -1714,7 +1723,7 @@ logger('hey');
* * \e array \b item
* * \e array \b sender
* * \e array \b channel
- */
+ */
call_hooks('activity_received', $parr);
// don't add a source route if it's a relay or later recipients will get a route mismatch
if(! $relay)
@@ -1779,17 +1788,17 @@ logger('hey');
logger($AS->debug());
- $r = q("select hubloc_hash from hubloc where hubloc_id_url = '%s' limit 1",
+ $r = q("select hubloc_hash from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' limit 1",
dbesc($AS->actor['id'])
- );
+ );
if(! $r) {
$y = import_author_xchan([ 'url' => $AS->actor['id'] ]);
if($y) {
- $r = q("select hubloc_hash from hubloc where hubloc_id_url = '%s' limit 1",
+ $r = q("select hubloc_hash from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' limit 1",
dbesc($AS->actor['id'])
);
- }
+ }
if(! $r) {
logger('FOF Activity: no actor');
continue;
@@ -1809,9 +1818,9 @@ logger('hey');
$arr['author_xchan'] = $r[0]['hubloc_hash'];
}
- $s = q("select hubloc_hash from hubloc where hubloc_id_url = '%s' limit 1",
+ $s = q("select hubloc_hash from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' limit 1",
dbesc($a['signature']['signer'])
- );
+ );
if($s) {
$arr['owner_xchan'] = $s[0]['hubloc_hash'];
@@ -1820,7 +1829,8 @@ logger('hey');
$arr['owner_xchan'] = $a['signature']['signer'];
}
- // @fixme - spoofable
+
+ /// @FIXME - spoofable
if($AS->data['hubloc']) {
$arr['item_verified'] = true;
}
@@ -1834,7 +1844,7 @@ logger('hey');
$result = self::process_delivery($arr['owner_xchan'],$arr, [ $channel['channel_portable_id'] ],false,false,true);
if ($result) {
$ret = array_merge($ret, $result);
- }
+ }
}
return $ret;
@@ -1851,8 +1861,8 @@ logger('hey');
* * \e int \b obj_type
* * \e int \b mid
* @param int $uid
+ * @return void
*/
-
static function remove_community_tag($sender, $arr, $uid) {
if(! (activity_match($arr['verb'], ACTIVITY_TAG) && ($arr['obj_type'] == ACTIVITY_OBJ_TAGTERM)))
@@ -1880,7 +1890,7 @@ logger('hey');
}
$i = $r[0];
-
+
if($i['target'])
$i['target'] = json_decode($i['target'],true);
if($i['object'])
@@ -1923,8 +1933,8 @@ logger('hey');
* @param array $orig
* @param int $uid
* @param boolean $tag_delivery
+ * @return void|array
*/
-
static function update_imported_item($sender, $item, $orig, $uid, $tag_delivery) {
// If this is a comment being updated, remove any privacy information
@@ -2064,7 +2074,7 @@ logger('hey');
}
foreach($deliveries as $d) {
-
+
$DR = new DReport(z_root(),$sender,$d,$arr['mid']);
$r = q("select * from channel where channel_portable_id = '%s' limit 1",
@@ -2083,7 +2093,7 @@ logger('hey');
if(! perm_is_allowed($channel['channel_id'],$sender,'post_mail')) {
- /*
+ /*
* Always allow somebody to reply if you initiated the conversation. It's anti-social
* and a bit rude to send a private message to somebody and block their ability to respond.
* If you are being harrassed and want to put an end to it, delete the conversation.
@@ -2143,12 +2153,13 @@ logger('hey');
* @brief Processes delivery of profile.
*
* @see import_directory_profile()
+ *
* @param array $sender an associative array
* * \e string \b hash a xchan_hash
* @param array $arr
* @param array $deliveries (unused)
+ * @return void
*/
-
static function process_profile_delivery($sender, $arr, $deliveries) {
logger('process_profile_delivery', LOGGER_DEBUG);
@@ -2169,6 +2180,7 @@ logger('hey');
* * \e string \b hash a xchan_hash
* @param array $arr
* @param array $deliveries (unused) deliveries is irrelevant
+ * @return void
*/
static function process_location_delivery($sender, $arr, $deliveries) {
@@ -2186,7 +2198,7 @@ logger('hey');
$x = Libsync::sync_locations($xchan,$arr,true);
logger('results: ' . print_r($x,true), LOGGER_DEBUG);
if($x['changed']) {
- $guid = random_string() . '@' . App::get_hostname();
+ //$guid = random_string() . '@' . App::get_hostname();
Libzotdir::update_modtime($sender,$r[0]['xchan_guid'],$arr['locations'][0]['address'],UPDATE_FLAGS_UPDATED);
}
}
@@ -2210,8 +2222,8 @@ logger('hey');
*
* @param string $sender_hash A channel hash
* @param array $locations
+ * @return void
*/
-
static function check_location_move($sender_hash, $locations) {
if(! $locations)
@@ -2253,7 +2265,6 @@ logger('hey');
}
-
/**
* @brief Returns an array with all known distinct hubs for this channel.
*
@@ -2262,7 +2273,6 @@ logger('hey');
* * \e string \b channel_hash the hash of the channel
* @return array an array with associative arrays
*/
-
static function encode_locations($channel) {
$ret = [];
@@ -2303,7 +2313,7 @@ logger('hey');
if(! $z['site_id']) {
$z['site_id'] = Libzot::make_xchan_hash($z['url'],$z['sitekey']);
}
-
+
$ret[] = $z;
}
}
@@ -2316,10 +2326,8 @@ logger('hey');
* @brief
*
* @param array $arr
- * @param string $pubkey
* @return boolean true if updated or inserted
*/
-
static function import_site($arr) {
if( (! is_array($arr)) || (! $arr['url']) || (! $arr['site_sig']))
@@ -2594,20 +2602,20 @@ logger('hey');
$feed = ((x($arr,'feed')) ? intval($arr['feed']) : 0);
if($ztarget) {
- $t = q("select * from hubloc where hubloc_id_url = '%s' limit 1",
+ $t = q("select * from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' limit 1",
dbesc($ztarget)
);
if($t) {
-
+
$ztarget_hash = $t[0]['hubloc_hash'];
}
else {
-
+
// should probably perform discovery of the requestor (target) but if they actually had
- // permissions we would know about them and we only want to know who they are to
+ // permissions we would know about them and we only want to know who they are to
// enumerate their specific permissions
-
+
$ztarget_hash = EMPTY_STR;
}
}
@@ -2754,7 +2762,7 @@ logger('hey');
$ret['id'] = $e['xchan_guid'];
$ret['id_sig'] = self::sign($e['xchan_guid'], $e['channel_prvkey']);
- $ret['primary_location'] = [
+ $ret['primary_location'] = [
'address' => $e['xchan_addr'],
'url' => $e['xchan_url'],
'connections_url' => $e['xchan_connurl'],
@@ -2776,7 +2784,7 @@ logger('hey');
$ret['searchable'] = $searchable;
$ret['adult_content'] = $adult_channel;
$ret['public_forum'] = $public_forum;
-
+
$ret['comments'] = map_scope(PermissionLimits::Get($e['channel_id'],'post_comments'));
$ret['mail'] = map_scope(PermissionLimits::Get($e['channel_id'],'post_mail'));
@@ -2834,14 +2842,20 @@ logger('hey');
$ret['locations'] = $x;
$ret['site'] = self::site_info();
+ /**
+ * @hooks zotinfo
+ * Hook to manipulate the zotinfo array before it is returned.
+ */
+ call_hooks('zotinfo', $ret);
- call_hooks('zotinfo',$ret);
-
- return($ret);
-
+ return $ret;
}
-
+ /**
+ * @brief Get siteinfo.
+ *
+ * @return array
+ */
static function site_info() {
$signing_key = get_config('system','prvkey');
@@ -2878,7 +2892,7 @@ logger('hey');
if($dirmode != DIRECTORY_MODE_STANDALONE) {
$register_policy = intval(get_config('system','register_policy'));
-
+
if($register_policy == REGISTER_CLOSED)
$ret['site']['register_policy'] = 'closed';
if($register_policy == REGISTER_APPROVE)
@@ -2925,18 +2939,16 @@ logger('hey');
}
return $ret['site'];
-
}
/**
* @brief
*
* @param array $hub
- * @param string $sitekey (optional, default empty)
+ * @param string $site_id (optional, default empty)
*
* @return string hubloc_url
*/
-
static function update_hub_connected($hub, $site_id = '') {
if ($site_id) {
@@ -2995,12 +3007,21 @@ logger('hey');
return $hub['hubloc_url'];
}
-
+ /**
+ * @brief
+ *
+ * @param string $data
+ * @param string $key
+ * @param string $alg (optional) default 'sha256'
+ * @return string
+ */
static function sign($data,$key,$alg = 'sha256') {
if(! $key)
return 'no key';
+
$sig = '';
openssl_sign($data,$sig,$key,$alg);
+
return $alg . '.' . base64url_encode($sig);
}
@@ -3013,24 +3034,27 @@ logger('hey');
if ($key && count($x) === 2) {
$alg = $x[0];
$signature = base64url_decode($x[1]);
-
+
$verify = @openssl_verify($data,$signature,$key,$alg);
if ($verify === (-1)) {
while ($msg = openssl_error_string()) {
logger('openssl_verify: ' . $msg,LOGGER_NORMAL,LOG_ERR);
}
- btlogger('openssl_verify: key: ' . $key, LOGGER_DEBUG, LOG_ERR);
+ btlogger('openssl_verify: key: ' . $key, LOGGER_DEBUG, LOG_ERR);
}
}
return(($verify > 0) ? true : false);
}
-
-
+ /**
+ * @brief
+ *
+ * @return boolean
+ */
static function is_zot_request() {
-
$x = getBestSupportedMimeType([ 'application/x-zot+json' ]);
+
return(($x) ? true : false);
}
diff --git a/Zotlabs/Lib/PConfig.php b/Zotlabs/Lib/PConfig.php
index 69f4de2db..c08c11e75 100644
--- a/Zotlabs/Lib/PConfig.php
+++ b/Zotlabs/Lib/PConfig.php
@@ -112,9 +112,11 @@ class PConfig {
* The configuration key to set
* @param string $value
* The value to store
+ * @param string $updated (optional)
+ * The datetime to store
* @return mixed Stored $value or false
*/
- static public function Set($uid, $family, $key, $value, $updated=NULL) {
+ static public function Set($uid, $family, $key, $value, $updated = NULL) {
// this catches subtle errors where this function has been called
// with local_channel() when not logged in (which returns false)
@@ -239,7 +241,9 @@ class PConfig {
* The category of the configuration value
* @param string $key
* The configuration key to delete
- * @return mixed
+ * @param string $updated (optional)
+ * The datetime to store
+ * @return boolean
*/
static public function Delete($uid, $family, $key, $updated = NULL) {
@@ -271,22 +275,13 @@ class PConfig {
dbesc($key)
);
+ // Synchronize delete with clones.
+
if ($family != 'hz_delpconfig') {
$hash = hash('sha256',$family.':'.$key);
set_pconfig($uid,'hz_delpconfig',$hash,$updated);
}
- // Synchronize delete with clones.
-
- if(! array_key_exists('transient', \App::$config[$uid]))
- \App::$config[$uid]['transient'] = array();
- if(! array_key_exists($family, \App::$config[$uid]['transient']))
- \App::$config[$uid]['transient'][$family] = array();
-
- if ($new) {
- \App::$config[$uid]['transient'][$family]['pcfgdel:'.$key] = $updated;
- }
-
return $ret;
}
diff --git a/Zotlabs/Lib/Share.php b/Zotlabs/Lib/Share.php
index d3ecbf7fa..3a2ab1783 100644
--- a/Zotlabs/Lib/Share.php
+++ b/Zotlabs/Lib/Share.php
@@ -54,6 +54,7 @@ class Share {
if(! $this->item)
return $obj;
+ $obj['asld'] = $this->item['mid'];
$obj['type'] = $this->item['obj_type'];
$obj['id'] = $this->item['mid'];
$obj['content'] = $this->item['body'];
diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php
index 83d243177..40c0fca4b 100644
--- a/Zotlabs/Lib/ThreadItem.php
+++ b/Zotlabs/Lib/ThreadItem.php
@@ -76,7 +76,7 @@ class ThreadItem {
* _ false on failure
*/
- public function get_template_data($conv_responses, $thread_level=1) {
+ public function get_template_data($conv_responses, $thread_level=1, $conv_flags = []) {
$result = array();
@@ -101,6 +101,7 @@ class ThreadItem {
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
? t('Private Message')
: false);
+
$shareable = ((($conv->get_profile_owner() == local_channel() && local_channel()) && ($item['item_private'] != 1)) ? true : false);
// allow an exemption for sharing stuff from your private feeds
@@ -115,6 +116,19 @@ class ThreadItem {
$privacy_warning = true;
}
+ if ($lock) {
+ if (($item['mid'] == $item['parent_mid']) && count(get_terms_oftype($item['term'],TERM_FORUM))) {
+ $privacy_warning = true;
+ $conv_flags['parent_privacy_warning'] = true;
+ }
+ }
+
+ $privacy_warning = (isset($conv_flags['parent_privacy_warning'])) ? $conv_flags['parent_privacy_warning'] : $privacy_warning;
+
+ if ($lock && $privacy_warning) {
+ $lock = t('Privacy conflict. Discretion advised.');
+ }
+
$mode = $conv->get_mode();
switch($item['item_type']) {
@@ -293,8 +307,15 @@ class ThreadItem {
$dislike = array( t("I don't like this \x28toggle\x29"), t("dislike"));
}
- if ($shareable)
- $share = array( t('Share This'), t('share'));
+ if ($shareable) {
+ // This actually turns out not to be possible in some protocol stacks without opening up hundreds of new issues.
+ // Will allow it only for uri resolvable sources.
+ if(strpos($item['mid'],'http') === 0) {
+ $share = []; //Not yet ready for primetime
+ //$share = array( t('Repeat This'), t('repeat'));
+ }
+ $embed = array( t('Share This'), t('share'));
+ }
$dreport = '';
@@ -408,12 +429,13 @@ class ThreadItem {
'like' => $like,
'dislike' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike : ''),
'share' => $share,
+ 'embed' => $embed,
'rawmid' => $item['mid'],
'plink' => get_plink($item),
'edpost' => $edpost, // ((feature_enabled($conv->get_profile_owner(),'edit_posts')) ? $edpost : ''),
- 'star' => ((feature_enabled($conv->get_profile_owner(),'star_posts')) ? $star : ''),
+ 'star' => ((feature_enabled($conv->get_profile_owner(),'star_posts') && ($item['item_type'] == ITEM_TYPE_POST)) ? $star : ''),
'tagger' => ((feature_enabled($conv->get_profile_owner(),'commtag')) ? $tagger : ''),
- 'filer' => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''),
+ 'filer' => ((feature_enabled($conv->get_profile_owner(),'filing') && ($item['item_type'] == ITEM_TYPE_POST)) ? $filer : ''),
'bookmark' => (($conv->get_profile_owner() == local_channel() && local_channel() && $has_bookmarks) ? t('Save Bookmarks') : ''),
'addtocal' => (($has_event) ? t('Add to Calendar') : ''),
'drop' => $drop,
@@ -470,7 +492,7 @@ class ThreadItem {
if(($this->get_display_mode() === 'normal') && ($nb_children > 0)) {
foreach($children as $child) {
- $result['children'][] = $child->get_template_data($conv_responses, $thread_level + 1);
+ $result['children'][] = $child->get_template_data($conv_responses, $thread_level + 1,$conv_flags);
}
// Collapse
if(($nb_children > $visible_comments) || ($thread_level > 1)) {
diff --git a/Zotlabs/Lib/ThreadListener.php b/Zotlabs/Lib/ThreadListener.php
new file mode 100644
index 000000000..308e02255
--- /dev/null
+++ b/Zotlabs/Lib/ThreadListener.php
@@ -0,0 +1,53 @@
+<?php
+
+namespace Zotlabs\Lib;
+
+class ThreadListener {
+
+ static public function store($target_id,$portable_id,$ltype = 0) {
+ $x = self::fetch($target_id,$portable_id,$ltype = 0);
+ if(! $x) {
+ $r = q("insert into listeners ( target_id, portable_id, ltype ) values ( '%s', '%s' , %d ) ",
+ dbesc($target_id),
+ dbesc($portable_id),
+ intval($ltype)
+ );
+ }
+ }
+
+ static public function fetch($target_id,$portable_id,$ltype = 0) {
+ $x = q("select * from listeners where target_id = '%s' and portable_id = '%s' and ltype = %d limit 1",
+ dbesc($target_id),
+ dbesc($portable_id),
+ intval($ltype)
+ );
+ if($x) {
+ return $x[0];
+ }
+ return false;
+ }
+
+ static public function fetch_by_target($target_id,$ltype = 0) {
+ $x = q("select * from listeners where target_id = '%s' and ltype = %d",
+ dbesc($target_id),
+ intval($ltype)
+ );
+
+ return $x;
+ }
+
+ static public function delete_by_target($target_id, $ltype = 0) {
+ return q("delete from listeners where target_id = '%s' and ltype = %d",
+ dbesc($target_id),
+ intval($ltype)
+ );
+ }
+
+ static public function delete_by_pid($portable_id, $ltype = 0) {
+ return q("delete from listeners where portable_id = '%s' and ltype = %d",
+ dbesc($portable_id),
+ intval($ltype)
+ );
+ }
+
+}
diff --git a/Zotlabs/Module/Admin.php b/Zotlabs/Module/Admin.php
index 8ccdaf4f5..88b84b9d2 100644
--- a/Zotlabs/Module/Admin.php
+++ b/Zotlabs/Module/Admin.php
@@ -86,7 +86,7 @@ class Admin extends \Zotlabs\Web\Controller {
// list total user accounts, expirations etc.
$accounts = array();
- $r = q("SELECT COUNT(*) AS total, COUNT(CASE WHEN account_expires > %s THEN 1 ELSE NULL END) AS expiring, COUNT(CASE WHEN account_expires < %s AND account_expires > '%s' THEN 1 ELSE NULL END) AS expired, COUNT(CASE WHEN (account_flags & %d)>0 THEN 1 ELSE NULL END) AS blocked FROM account",
+ $r = q("SELECT COUNT(CASE WHEN account_id > 0 THEN 1 ELSE NULL END) AS total, COUNT(CASE WHEN account_expires > %s THEN 1 ELSE NULL END) AS expiring, COUNT(CASE WHEN account_expires < %s AND account_expires > '%s' THEN 1 ELSE NULL END) AS expired, COUNT(CASE WHEN (account_flags & %d)>0 THEN 1 ELSE NULL END) AS blocked FROM account",
db_utcnow(),
db_utcnow(),
dbesc(NULL_DATE),
diff --git a/Zotlabs/Module/Admin/Addons.php b/Zotlabs/Module/Admin/Addons.php
index b35922aef..b8e3e3a2e 100644
--- a/Zotlabs/Module/Admin/Addons.php
+++ b/Zotlabs/Module/Admin/Addons.php
@@ -375,6 +375,9 @@ class Addons {
if($files) {
foreach($files as $file) {
if (is_dir($file)){
+ if($file == 'addon/addon_common/')
+ continue;
+
list($tmp, $id) = array_map('trim', explode('/', $file));
$info = get_plugin_info($id);
$enabled = in_array($id,\App::$plugins);
@@ -476,4 +479,4 @@ class Addons {
return(strcmp(strtolower($a[2]['name']),strtolower($b[2]['name'])));
}
-} \ No newline at end of file
+}
diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php
index 09b038729..55c8ca928 100644
--- a/Zotlabs/Module/Admin/Site.php
+++ b/Zotlabs/Module/Admin/Site.php
@@ -119,7 +119,7 @@ class Site {
del_config('system', 'admininfo');
} else {
require_once('include/text.php');
- linkify_tags($a, $admininfo, local_channel());
+ linkify_tags($admininfo, local_channel());
set_config('system', 'admininfo', $admininfo);
}
set_config('system','siteinfo',$siteinfo);
diff --git a/Zotlabs/Module/Affinity.php b/Zotlabs/Module/Affinity.php
new file mode 100644
index 000000000..f0d99f1e7
--- /dev/null
+++ b/Zotlabs/Module/Affinity.php
@@ -0,0 +1,94 @@
+<?php
+
+namespace Zotlabs\Module;
+
+use App;
+use Zotlabs\Lib\Apps;
+use Zotlabs\Lib\Libsync;
+
+class Affinity extends \Zotlabs\Web\Controller {
+
+ function post() {
+
+ if(! local_channel())
+ return;
+
+ if(! Apps::system_app_installed(local_channel(),'Affinity Tool'))
+ return;
+
+ check_form_security_token_redirectOnErr('affinity', 'affinity');
+
+ $cmax = intval($_POST['affinity_cmax']);
+ if($cmax < 0 || $cmax > 99)
+ $cmax = 99;
+
+ $cmin = intval($_POST['affinity_cmin']);
+ if($cmin < 0 || $cmin > 99)
+ $cmin = 0;
+
+ $lock = intval($_POST['affinity_lock']);
+
+ set_pconfig(local_channel(),'affinity','cmin',$cmin);
+ set_pconfig(local_channel(),'affinity','cmax',$cmax);
+ set_pconfig(local_channel(),'affinity','lock',$lock);
+
+ info( t('Affinity Tool settings updated.') . EOL);
+
+ Libsync::build_sync_packet();
+
+ }
+
+
+ function get() {
+
+ if(! local_channel())
+ return;
+
+ $desc = t('This app presents a slider control in your connection editor and also on your network page. The slider represents your degree of friendship (affinity) with each connection. It allows you to zoom in or out and display conversations from only your closest friends or everybody in your stream.');
+ if(! Apps::system_app_installed(local_channel(),'Affinity Tool')) {
+ //Do not display any associated widgets at this point
+ App::$pdl = '';
+
+ $o = '<b>' . t('Affinity Tool App') . ' (' . t('Not Installed') . '):</b><br>';
+ $o .= $desc;
+ return $o;
+ }
+
+ $text = t('The numbers below represent the minimum and maximum slider default positions for your network/stream page as a percentage.');
+
+ $content = '<div class="section-content-info-wrapper">' . $text . '</div>';
+
+ $cmax = intval(get_pconfig(local_channel(),'affinity','cmax'));
+ $cmax = (($cmax) ? $cmax : 99);
+ $content .= replace_macros(get_markup_template('field_input.tpl'), array(
+ '$field' => array('affinity_cmax', t('Default maximum affinity level'), $cmax, t('0-99 default 99'))
+ ));
+
+ $cmin = intval(get_pconfig(local_channel(),'affinity','cmin'));
+ $cmin = (($cmin) ? $cmin : 0);
+ $content .= replace_macros(get_markup_template('field_input.tpl'), array(
+ '$field' => array('affinity_cmin', t('Default minimum affinity level'), $cmin, t('0-99 - default 0'))
+ ));
+
+ $lock = intval(get_pconfig(local_channel(),'affinity','lock',1));
+
+ $content .= replace_macros(get_markup_template('field_checkbox.tpl'), array(
+ '$field' => array('affinity_lock', t('Persistent affinity levels'), $lock, t('If disabled the max and min levels will be reset to default after page reload'), ['No','Yes'])
+ ));
+
+ $tpl = get_markup_template("settings_addon.tpl");
+
+ $o = replace_macros($tpl, array(
+ '$action_url' => 'affinity',
+ '$form_security_token' => get_form_security_token("affinity"),
+ '$title' => t('Affinity Tool Settings'),
+ '$content' => $content,
+ '$baseurl' => z_root(),
+ '$submit' => t('Submit'),
+ ));
+
+ return $o;
+ }
+
+
+}
diff --git a/Zotlabs/Module/Cards.php b/Zotlabs/Module/Cards.php
index b66de158b..3f0e93de5 100644
--- a/Zotlabs/Module/Cards.php
+++ b/Zotlabs/Module/Cards.php
@@ -10,9 +10,13 @@ require_once('include/channel.php');
require_once('include/conversation.php');
require_once('include/acl_selectors.php');
+/**
+ * @brief Provides the Cards module.
+ *
+ */
class Cards extends Controller {
- function init() {
+ public function init() {
if(argc() > 1)
$which = argv(1);
@@ -20,14 +24,15 @@ class Cards extends Controller {
return;
profile_load($which);
-
}
/**
* {@inheritDoc}
- * @see \Zotlabs\Web\Controller::get()
+ * @see \\Zotlabs\\Web\\Controller::get()
+ *
+ * @return string Parsed HTML from template 'cards.tpl'
*/
- function get($update = 0, $load = false) {
+ public function get($update = 0, $load = false) {
if(observer_prohibited(true)) {
return login();
@@ -99,7 +104,6 @@ class Cards extends Controller {
}
-
if(perm_is_allowed($owner, $ob_hash, 'write_pages')) {
$x = [
@@ -110,7 +114,7 @@ class Cards extends Controller {
'nickname' => $channel['channel_address'],
'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid']
|| $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
- 'acl' => (($is_owner) ? populate_acl($channel_acl, false,
+ 'acl' => (($is_owner) ? populate_acl($channel_acl, false,
PermissionDescription::fromGlobalPermission('view_pages')) : ''),
'permissions' => $channel_acl,
'showacl' => (($is_owner) ? true : false),
diff --git a/Zotlabs/Module/Chanview.php b/Zotlabs/Module/Chanview.php
index 779c7e646..2e653d030 100644
--- a/Zotlabs/Module/Chanview.php
+++ b/Zotlabs/Module/Chanview.php
@@ -106,7 +106,7 @@ class Chanview extends \Zotlabs\Web\Controller {
if (\App::$poi) {
$url = \App::$poi['xchan_url'];
- if(\App::$poi['xchan_network'] === 'zot') {
+ if(in_array(\App::$poi['xchan_network'], ['zot', 'zot6'])) {
$is_zot = true;
}
if(local_channel()) {
diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php
index c14bcd0dd..a587324df 100644
--- a/Zotlabs/Module/Connedit.php
+++ b/Zotlabs/Module/Connedit.php
@@ -710,7 +710,7 @@ class Connedit extends \Zotlabs\Web\Controller {
$tpl = get_markup_template("abook_edit.tpl");
- if(feature_enabled(local_channel(),'affinity')) {
+ if(Apps::system_app_installed(local_channel(),'Affinity Tool')) {
$sections['affinity'] = [
'label' => t('Affinity'),
diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php
index e3691702d..04e5f9fce 100644
--- a/Zotlabs/Module/Display.php
+++ b/Zotlabs/Module/Display.php
@@ -178,8 +178,7 @@ class Display extends \Zotlabs\Web\Controller {
$static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0);
-
-
+
$simple_update = (($update) ? " AND item_unseen = 1 " : '');
if($update && $_SESSION['loadtime'])
@@ -314,7 +313,7 @@ class Display extends \Zotlabs\Web\Controller {
}
}
- if(! $r) {
+ if($r === null) {
// in case somebody turned off public access to sys channel content using permissions
// make that content unsearchable by ensuring the owner_xchan can't match
if(! perm_is_allowed($sysid,$observer_hash,'view_stream'))
diff --git a/Zotlabs/Module/Embed.php b/Zotlabs/Module/Embed.php
new file mode 100644
index 000000000..77b9254dd
--- /dev/null
+++ b/Zotlabs/Module/Embed.php
@@ -0,0 +1,22 @@
+<?php
+namespace Zotlabs\Module;
+
+require_once('include/security.php');
+require_once('include/bbcode.php');
+
+
+class Embed extends \Zotlabs\Web\Controller {
+
+ function init() {
+
+ $post_id = ((argc() > 1) ? intval(argv(1)) : 0);
+
+ if(! $post_id)
+ killme();
+
+ echo '[share=' . $post_id . '][/share]';
+ killme();
+
+ }
+
+}
diff --git a/Zotlabs/Module/Embedphotos.php b/Zotlabs/Module/Embedphotos.php
index bcbb0e116..2df14c239 100644
--- a/Zotlabs/Module/Embedphotos.php
+++ b/Zotlabs/Module/Embedphotos.php
@@ -3,8 +3,10 @@
namespace Zotlabs\Module;
/**
- * @brief
+ * @brief Embedphoto endpoint.
*
+ * Provide an AJAX endpoint to fill the embedPhotoModal with folders and photos
+ * selection.
*/
class Embedphotos extends \Zotlabs\Web\Controller {
@@ -13,42 +15,42 @@ class Embedphotos extends \Zotlabs\Web\Controller {
}
/**
+ * @brief This is the POST destination for the embedphotos button.
*
- * This is the POST destination for the embedphotos button
- *
+ * @return string A JSON string.
*/
- function post() {
+ public function post() {
if (argc() > 1 && argv(1) === 'album') {
// API: /embedphotos/album
- $name = (x($_POST,'name') ? $_POST['name'] : null );
- if(!$name) {
+ $name = (x($_POST, 'name') ? $_POST['name'] : null );
+ if (!$name) {
json_return_and_die(array('errormsg' => 'Error retrieving album', 'status' => false));
}
$album = $this->embedphotos_widget_album(array('channel' => \App::get_channel(), 'album' => $name));
json_return_and_die(array('status' => true, 'content' => $album));
}
- if(argc() > 1 && argv(1) === 'albumlist') {
+ if (argc() > 1 && argv(1) === 'albumlist') {
// API: /embedphotos/albumlist
- $album_list = $this->embedphotos_album_list($a);
+ $album_list = $this->embedphotos_album_list();
json_return_and_die(array('status' => true, 'albumlist' => $album_list));
}
- if(argc() > 1 && argv(1) === 'photolink') {
+ if (argc() > 1 && argv(1) === 'photolink') {
// API: /embedphotos/photolink
- $href = (x($_POST,'href') ? $_POST['href'] : null );
- if(!$href) {
+ $href = (x($_POST, 'href') ? $_POST['href'] : null );
+ if (!$href) {
json_return_and_die(array('errormsg' => 'Error retrieving link ' . $href, 'status' => false));
}
- $resource_id = array_pop(explode("/", $href));
+ $resource_id = array_pop(explode('/', $href));
$r = q("SELECT obj from item where resource_type = 'photo' and resource_id = '%s' limit 1",
dbesc($resource_id)
);
- if(!$r) {
+ if (!$r) {
json_return_and_die(array('errormsg' => 'Error retrieving resource ' . $resource_id, 'status' => false));
}
$obj = json_decode($r[0]['obj'], true);
- if(x($obj,'body')) {
+ if (x($obj, 'body')) {
$photolink = $obj['body'];
- } elseif (x($obj,'bbcode')) {
+ } elseif (x($obj, 'bbcode')) {
$photolink = $obj['bbcode'];
} else {
json_return_and_die(array('errormsg' => 'Error retrieving resource ' . $resource_id, 'status' => false));
@@ -58,48 +60,51 @@ class Embedphotos extends \Zotlabs\Web\Controller {
}
/**
- * Copied from include/widgets.php::widget_album() with a modification to get the profile_uid from
- * the input array as in widget_item()
+ * @brief Get photos from an album.
+ *
+ * @see \\Zotlabs\\Widget\\Album::widget()
*
- * @param array $args
- * @return string with HTML
+ * @param array $args associative array with
+ * * \e array \b channel
+ * * \e string \b album
+ * @return string with HTML code from 'photo_album.tpl'
*/
- function embedphotos_widget_album($args) {
-
+ protected function embedphotos_widget_album($args) {
$channel_id = 0;
- if(array_key_exists('channel', $args))
+
+ if (array_key_exists('channel', $args)) {
$channel = $args['channel'];
- $channel_id = intval($channel['channel_id']);
- if(! $channel_id)
+ $channel_id = intval($channel['channel_id']);
+ }
+ if (! $channel_id)
$channel_id = \App::$profile_uid;
- if(! $channel_id)
+ if (! $channel_id)
return '';
- $owner_uid = $channel_id;
require_once('include/security.php');
$sql_extra = permissions_sql($channel_id);
- if(! perm_is_allowed($channel_id,get_observer_hash(),'view_storage'))
+ if (! perm_is_allowed($channel_id, get_observer_hash(), 'view_storage'))
return '';
- if($args['album'])
+ if (isset($args['album']))
$album = (($args['album'] === '/') ? '' : $args['album']);
- if($args['title'])
+ if (isset($args['title']))
$title = $args['title'];
/**
- * This may return incorrect permissions if you have multiple directories of the same name.
+ * @note This may return incorrect permissions if you have multiple directories of the same name.
* It is a limitation of the photo table using a name for a photo album instead of a folder hash
*/
- if($album) {
+ if ($album) {
require_once('include/attach.php');
$x = q("select hash from attach where filename = '%s' and uid = %d limit 1",
dbesc($album),
- intval($owner_uid)
+ intval($channel_id)
);
- if($x) {
- $y = attach_can_view_folder($owner_uid,get_observer_hash(),$x[0]['hash']);
- if(! $y)
+ if ($x) {
+ $y = attach_can_view_folder($channel_id, get_observer_hash(), $x[0]['hash']);
+ if (! $y)
return '';
}
}
@@ -110,30 +115,33 @@ class Embedphotos extends \Zotlabs\Web\Controller {
(SELECT resource_id, max(imgscale) imgscale FROM photo WHERE uid = %d AND album = '%s' AND imgscale <= 4 AND photo_usage IN ( %d, %d ) $sql_extra GROUP BY resource_id) ph
ON (p.resource_id = ph.resource_id AND p.imgscale = ph.imgscale)
ORDER BY created $order",
- intval($owner_uid),
+ intval($channel_id),
dbesc($album),
intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE)
);
- $photos = array();
- if(count($r)) {
+ $photos = [];
+ if (count($r)) {
$twist = 'rotright';
- foreach($r as $rr) {
- if($twist == 'rotright')
+ foreach ($r as $rr) {
+ if ($twist == 'rotright')
$twist = 'rotleft';
else
$twist = 'rotright';
+ $ph = photo_factory('');
+ $phototypes = $ph->supportedTypes();
+
$ext = $phototypes[$rr['mimetype']];
$imgalt_e = $rr['filename'];
$desc_e = $rr['description'];
- $imagelink = (z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/image/' . $rr['resource_id']
+ $imagelink = (z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $rr['resource_id']
. (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''));
- $photos[] = array(
+ $photos[] = [
'id' => $rr['id'],
'twist' => ' ' . $twist . rand(2,4),
'link' => $imagelink,
@@ -143,35 +151,43 @@ class Embedphotos extends \Zotlabs\Web\Controller {
'desc'=> $desc_e,
'ext' => $ext,
'hash'=> $rr['resource_id'],
- 'unknown' => t('Unknown')
- );
+ 'unknown' => t('Unknown'),
+ ];
}
}
$tpl = get_markup_template('photo_album.tpl');
- $o .= replace_macros($tpl, array(
+ $o = replace_macros($tpl, [
'$photos' => $photos,
'$album' => (($title) ? $title : $album),
'$album_id' => rand(),
- '$album_edit' => array(t('Edit Album'), $album_edit),
+ '$album_edit' => array(t('Edit Album'), false),
'$can_post' => false,
'$upload' => array(t('Upload'), z_root() . '/photos/' . \App::$profile['channel_address'] . '/upload/' . bin2hex($album)),
'$order' => false,
- '$upload_form' => $upload_form,
- '$no_fullscreen_btn' => true
- ));
+ '$upload_form' => '',
+ '$no_fullscreen_btn' => true,
+ ]);
return $o;
}
- function embedphotos_album_list($a) {
+ /**
+ * @brief Get albums observer is allowed to see.
+ *
+ * @see photos_albums_list()
+ *
+ * @return NULL|array
+ */
+ protected function embedphotos_album_list() {
require_once('include/photos.php');
$p = photos_albums_list(\App::get_channel(), \App::get_observer());
- if($p['success']) {
+
+ if ($p['success']) {
return $p['albums'];
- } else {
- return null;
}
+
+ return null;
}
}
diff --git a/Zotlabs/Module/Events.php b/Zotlabs/Module/Events.php
index 7e5204e62..e883db49f 100644
--- a/Zotlabs/Module/Events.php
+++ b/Zotlabs/Module/Events.php
@@ -97,8 +97,8 @@ class Events extends \Zotlabs\Web\Controller {
$type = escape_tags(trim($_POST['type']));
require_once('include/text.php');
- linkify_tags($a, $desc, local_channel());
- linkify_tags($a, $location, local_channel());
+ linkify_tags($desc, local_channel());
+ linkify_tags($location, local_channel());
//$action = ($event_hash == '') ? 'new' : "event/" . $event_hash;
diff --git a/Zotlabs/Module/Group.php b/Zotlabs/Module/Group.php
index 3dcf903ad..12edf8428 100644
--- a/Zotlabs/Module/Group.php
+++ b/Zotlabs/Module/Group.php
@@ -66,6 +66,9 @@ class Group extends Controller {
$groupname = notags(trim($_POST['groupname']));
$public = intval($_POST['public']);
+ $hookinfo = [ 'pgrp_extras' => '', 'group'=>$group['id'] ];
+ call_hooks ('privacygroup_extras_post',$hookinfo);
+
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),
@@ -76,8 +79,6 @@ class Group extends Controller {
if($r)
info( t('Privacy group updated.') . EOL );
- $hookinfo = [ 'pgrp_extras' => '', 'group'=>$group['id'] ];
- call_hooks ('privacygroup_extras_post',$hookinfo);
build_sync_packet(local_channel(),null,true);
}
@@ -242,6 +243,10 @@ class Group extends Controller {
}
}
+ $hookinfo = [ 'pgrp_extras' => '', 'group'=>$group['id'] ];
+ call_hooks ('privacygroup_extras',$hookinfo);
+ $pgrp_extras = $hookinfo['pgrp_extras'];
+
$context = $context + array(
'$title' => sprintf(t('Privacy Group: %s'), $group['gname']),
'$details_label' => t('Edit'),
@@ -252,6 +257,7 @@ class Group extends Controller {
'$form_security_token_edit' => get_form_security_token('group_edit'),
'$delete' => t('Delete Group'),
'$form_security_token_drop' => get_form_security_token("group_drop"),
+ '$pgrp_extras' => $pgrp_extras,
);
}
@@ -295,6 +301,7 @@ class Group extends Controller {
$context['$groupeditor'] = $groupeditor;
$context['$desc'] = t('Click a channel to toggle membership');
+ $context['$pgrp_extras'] = $pgrp_extras;
if($change) {
$tpl = get_markup_template('groupeditor.tpl');
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php
index 24949c626..ebcf632ef 100644
--- a/Zotlabs/Module/Item.php
+++ b/Zotlabs/Module/Item.php
@@ -6,6 +6,13 @@ use Zotlabs\Lib\IConfig;
use Zotlabs\Lib\Enotify;
use Zotlabs\Web\Controller;
use Zotlabs\Daemon\Master;
+use Zotlabs\Lib\Activity;
+use Zotlabs\Lib\ActivityStreams;
+use Zotlabs\Lib\LDSignatures;
+use Zotlabs\Zot6\HTTPSig;
+use Zotlabs\Lib\Libzot;
+use Zotlabs\Lib\ThreadListener;
+use App;
require_once('include/crypto.php');
require_once('include/items.php');
@@ -30,6 +37,144 @@ require_once('include/security.php');
class Item extends Controller {
+
+ function init() {
+
+ if(Libzot::is_zot_request()) {
+
+ $conversation = false;
+
+ $item_id = argv(1);
+
+ if(! $item_id)
+ http_status_exit(404, 'Not found');
+
+
+ $portable_id = EMPTY_STR;
+
+ $sigdata = HTTPSig::verify(EMPTY_STR);
+ if($sigdata['portable_id'] && $sigdata['header_valid']) {
+ $portable_id = $sigdata['portable_id'];
+ }
+
+ $item_normal = " and item.item_hidden = 0 and item.item_type = 0 and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_blocked = 0 ";
+
+ $sql_extra = item_permissions_sql(0);
+
+ $r = q("select * from item where mid = '%s' $item_normal $sql_extra limit 1",
+ dbesc(z_root() . '/item/' . $item_id)
+ );
+ if(! $r) {
+
+
+ $r = q("select * from item where mid = '%s' $item_normal limit 1",
+ dbesc(z_root() . '/item/' . $item_id)
+ );
+ if($r) {
+ http_status_exit(403, 'Forbidden');
+ }
+ http_status_exit(404, 'Not found');
+ }
+
+
+ $items = q("select parent as item_id from item where mid = '%s' and uid = %d $item_normal $sql_extra ",
+ dbesc($r[0]['parent_mid']),
+ intval($r[0]['uid'])
+ );
+ if(! $items) {
+ http_status_exit(404, 'Not found');
+ }
+
+ $r = $items;
+
+ $parents_str = ids_to_querystr($r,'item_id');
+
+ $items = q("SELECT item.*, item.id AS item_id FROM item WHERE item.parent IN ( %s ) $item_normal $sql_extra ",
+ dbesc($parents_str)
+ );
+
+ if(! $items) {
+ http_status_exit(404, 'Not found');
+ }
+
+ $r = $items;
+ xchan_query($r,true);
+ $items = fetch_post_tags($r,true);
+
+ $observer = App::get_observer();
+ $parent = $items[0];
+ $recips = (($parent['owner']['xchan_network'] === 'activitypub') ? get_iconfig($parent['id'],'activitypub','recips', []) : []);
+ $to = (($recips && array_key_exists('to',$recips) && is_array($recips['to'])) ? $recips['to'] : null);
+ $nitems = [];
+ foreach($items as $i) {
+
+ $mids = [];
+
+ if(intval($i['item_private'])) {
+ if(! $observer) {
+ continue;
+ }
+ // ignore private reshare, possibly from hubzilla
+ if($i['verb'] === 'Announce') {
+ if(! in_array($i['thr_parent'],$mids)) {
+ $mids[] = $i['thr_parent'];
+ }
+ continue;
+ }
+ // also ignore any children of the private reshares
+ if(in_array($i['thr_parent'],$mids)) {
+ continue;
+ }
+
+ if((! $to) || (! in_array($observer['xchan_url'],$to))) {
+ continue;
+ }
+
+ }
+ $nitems[] = $i;
+ }
+
+ if(! $nitems)
+ http_status_exit(404, 'Not found');
+
+ $chan = channelx_by_n($nitems[0]['uid']);
+
+ if(! $chan)
+ http_status_exit(404, 'Not found');
+
+ 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));
+ if($portable_id) {
+ ThreadListener::store(z_root() . '/item/' . $item_id,$portable_id);
+ }
+
+ if(! $i)
+ http_status_exit(404, 'Not found');
+
+ $x = array_merge(['@context' => [
+ ACTIVITYSTREAMS_JSONLD_REV,
+ 'https://w3id.org/security/v1',
+ z_root() . ZOT_APSCHEMA_REV
+ ]], $i);
+
+ $headers = [];
+ $headers['Content-Type'] = 'application/x-zot+json' ;
+ $x['signature'] = LDSignatures::sign($x,$chan);
+ $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,$chan['channel_prvkey'],channel_url($chan));
+ HTTPSig::set_headers($h);
+ echo $ret;
+ killme();
+
+ }
+ }
+
+
+
function post() {
// This will change. Figure out who the observer is and whether or not
@@ -553,8 +698,8 @@ class Item extends Controller {
// Look for tags and linkify them
- $results = linkify_tags($a, $summary, ($uid) ? $uid : $profile_uid);
- $results = linkify_tags($a, $body, ($uid) ? $uid : $profile_uid);
+ $results = linkify_tags($summary, ($uid) ? $uid : $profile_uid);
+ $results = linkify_tags($body, ($uid) ? $uid : $profile_uid);
if($results) {
@@ -639,9 +784,9 @@ class Item extends Controller {
if(preg_match_all('/(\[share=(.*?)\](.*?)\[\/share\])/',$body,$match)) {
+
// process share by id
- $verb = ACTIVITY_SHARE;
$i = 0;
foreach($match[2] as $mtch) {
$reshare = new \Zotlabs\Lib\Share($mtch);
diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php
index d38c1d88c..3202d38a5 100644
--- a/Zotlabs/Module/Mail.php
+++ b/Zotlabs/Module/Mail.php
@@ -34,7 +34,7 @@ class Mail extends \Zotlabs\Web\Controller {
}
else {
$body = cleanup_bbcode($body);
- $results = linkify_tags($a, $body, local_channel());
+ $results = linkify_tags($body, local_channel());
if(preg_match_all('/(\[attachment\](.*?)\[\/attachment\])/',$body,$match)) {
$attachments = array();
@@ -111,7 +111,7 @@ class Mail extends \Zotlabs\Web\Controller {
}
require_once('include/text.php');
- linkify_tags($a, $body, local_channel());
+ linkify_tags($body, local_channel());
if(! $recipient) {
diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php
index d5cc06d09..2019082ed 100644
--- a/Zotlabs/Module/Network.php
+++ b/Zotlabs/Module/Network.php
@@ -1,6 +1,8 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Lib\Group;
+use Zotlabs\Lib\Apps;
use App;
require_once('include/items.php');
@@ -114,8 +116,8 @@ class Network extends \Zotlabs\Web\Controller {
$def_acl = array('allow_gid' => '<' . $r[0]['hash'] . '>');
}
- $default_cmin = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmin',0) : (-1));
- $default_cmax = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmax',99) : (-1));
+ $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));
$cid = ((x($_GET,'cid')) ? intval($_GET['cid']) : 0);
$star = ((x($_GET,'star')) ? intval($_GET['star']) : 0);
@@ -132,7 +134,7 @@ class Network extends \Zotlabs\Web\Controller {
$deftag = '';
- if (feature_enabled(local_channel(),'affinity')) {
+ if (Apps::system_app_installed(local_channel(),'Affinity Tool')) {
$affinity_locked = intval(get_pconfig(local_channel(),'affinity','lock',1));
if ($affinity_locked) {
set_pconfig(local_channel(),'affinity','cmin',$cmin);
diff --git a/Zotlabs/Module/Notes.php b/Zotlabs/Module/Notes.php
index 178a6bce0..7572f7420 100644
--- a/Zotlabs/Module/Notes.php
+++ b/Zotlabs/Module/Notes.php
@@ -1,28 +1,31 @@
<?php
-namespace Zotlabs\Module; /** @file */
+namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\Apps;
+/**
+ * @brief Notes Module controller.
+ */
class Notes extends Controller {
function post() {
-
+
if(! local_channel())
return EMPTY_STR;
if(! Apps::system_app_installed(local_channel(), 'Notes'))
return EMPTY_STR;
-
+
$ret = array('success' => true);
if(array_key_exists('note_text',$_REQUEST)) {
$body = escape_tags($_REQUEST['note_text']);
-
+
// I've had my notes vanish into thin air twice in four years.
- // Provide a backup copy if there were contents previously
+ // Provide a backup copy if there were contents previously
// and there are none being saved now.
-
+
if(! $body) {
$old_text = get_pconfig(local_channel(),'notes','text');
if($old_text)
@@ -40,11 +43,9 @@ class Notes extends Controller {
logger('notes saved.', LOGGER_DEBUG);
json_return_and_die($ret);
-
}
function get() {
-
if(! local_channel())
return EMPTY_STR;
@@ -61,7 +62,6 @@ class Notes extends Controller {
$arr = ['app' => true];
return $w->widget($arr);
-
}
-
+
}
diff --git a/Zotlabs/Module/Oep.php b/Zotlabs/Module/Oep.php
index 0f20a5f9a..c0d8e15e5 100644
--- a/Zotlabs/Module/Oep.php
+++ b/Zotlabs/Module/Oep.php
@@ -181,7 +181,7 @@ class Oep extends \Zotlabs\Web\Controller {
dbesc($res)
);
if($r) {
- $sql_extra = "and item.id = " . intval($r[0]['iid']) . " ";
+ $sql_extra .= " and item.id = " . intval($r[0]['iid']) . " ";
}
else {
return $ret;
@@ -194,6 +194,9 @@ class Oep extends \Zotlabs\Web\Controller {
intval(ITEM_TYPE_CARD)
);
+ if(! $r)
+ return;
+
$item_normal = " and item.item_hidden = 0 and item.item_type in (0,6) 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 ";
@@ -255,7 +258,6 @@ class Oep extends \Zotlabs\Web\Controller {
if(! $channel)
return $ret;
-
if(! perm_is_allowed($channel['channel_id'],get_observer_hash(),'view_pages'))
return $ret;
@@ -265,7 +267,7 @@ class Oep extends \Zotlabs\Web\Controller {
dbesc($res)
);
if($r) {
- $sql_extra = "and item.id = " . intval($r[0]['iid']) . " ";
+ $sql_extra .= " and item.id = " . intval($r[0]['iid']) . " ";
}
else {
return $ret;
@@ -278,6 +280,9 @@ class Oep extends \Zotlabs\Web\Controller {
intval(ITEM_TYPE_ARTICLE)
);
+ if(! $r)
+ return;
+
$item_normal = " and item.item_hidden = 0 and item.item_type in (0,7) 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 ";
diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php
index 3833d5088..a761dbd14 100644
--- a/Zotlabs/Module/Photos.php
+++ b/Zotlabs/Module/Photos.php
@@ -422,7 +422,7 @@ class Photos extends \Zotlabs\Web\Controller {
require_once('include/text.php');
$profile_uid = \App::$profile['profile_uid'];
- $results = linkify_tags($a, $rawtags, (local_channel()) ? local_channel() : $profile_uid);
+ $results = linkify_tags($rawtags, (local_channel()) ? local_channel() : $profile_uid);
$success = $results['success'];
$post_tags = array();
diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php
index de4075ba9..33e7d8a9d 100644
--- a/Zotlabs/Module/Profiles.php
+++ b/Zotlabs/Module/Profiles.php
@@ -354,20 +354,20 @@ class Profiles extends \Zotlabs\Web\Controller {
require_once('include/text.php');
- linkify_tags($a, $likes, local_channel());
- linkify_tags($a, $dislikes, local_channel());
- linkify_tags($a, $about, local_channel());
- linkify_tags($a, $interest, local_channel());
- linkify_tags($a, $interest, local_channel());
- linkify_tags($a, $contact, local_channel());
- linkify_tags($a, $channels, local_channel());
- linkify_tags($a, $music, local_channel());
- linkify_tags($a, $book, local_channel());
- linkify_tags($a, $tv, local_channel());
- linkify_tags($a, $film, local_channel());
- linkify_tags($a, $romance, local_channel());
- linkify_tags($a, $work, local_channel());
- linkify_tags($a, $education, local_channel());
+ linkify_tags($likes, local_channel());
+ linkify_tags($dislikes, local_channel());
+ linkify_tags($about, local_channel());
+ linkify_tags($interest, local_channel());
+ linkify_tags($interest, local_channel());
+ linkify_tags($contact, local_channel());
+ linkify_tags($channels, local_channel());
+ linkify_tags($music, local_channel());
+ linkify_tags($book, local_channel());
+ linkify_tags($tv, local_channel());
+ linkify_tags($film, local_channel());
+ linkify_tags($romance, local_channel());
+ linkify_tags($work, local_channel());
+ linkify_tags($education, local_channel());
$with = ((x($_POST,'with')) ? escape_tags(trim($_POST['with'])) : '');
diff --git a/Zotlabs/Module/Settings/Featured.php b/Zotlabs/Module/Settings/Featured.php
index 1d903fcf7..d5d740aff 100644
--- a/Zotlabs/Module/Settings/Featured.php
+++ b/Zotlabs/Module/Settings/Featured.php
@@ -10,24 +10,6 @@ class Featured {
call_hooks('feature_settings_post', $_POST);
- if($_POST['affinity_slider-submit']) {
- $cmax = intval($_POST['affinity_cmax']);
- if($cmax < 0 || $cmax > 99)
- $cmax = 99;
- $cmin = intval($_POST['affinity_cmin']);
- if($cmin < 0 || $cmin > 99)
- $cmin = 0;
-
- $lock = ($_POST['affinity_lock']) ? intval($_POST['affinity_lock']) : 1;
-
- set_pconfig(local_channel(),'affinity','cmin',$cmin);
- set_pconfig(local_channel(),'affinity','cmax',$cmax);
- set_pconfig(local_channel(),'affinity','lock',$lock);
-
- info( t('Affinity Slider settings updated.') . EOL);
-
- }
-
build_sync_packet();
return;
}
@@ -41,34 +23,10 @@ class Featured {
if(! $r)
$settings_addons = t('No feature settings configured');
- if(feature_enabled(local_channel(),'affinity')) {
-
- $cmax = intval(get_pconfig(local_channel(),'affinity','cmax'));
- $cmax = (($cmax) ? $cmax : 99);
- $setting_fields .= replace_macros(get_markup_template('field_input.tpl'), array(
- '$field' => array('affinity_cmax', t('Default maximum affinity level'), $cmax, t('0-99 default 99'))
- ));
- $cmin = intval(get_pconfig(local_channel(),'affinity','cmin'));
- $cmin = (($cmin) ? $cmin : 0);
- $setting_fields .= replace_macros(get_markup_template('field_input.tpl'), array(
- '$field' => array('affinity_cmin', t('Default minimum affinity level'), $cmin, t('0-99 - default 0'))
- ));
- $lock = intval(get_pconfig(local_channel(),'affinity','lock',1));
- $setting_fields .= replace_macros(get_markup_template('field_checkbox.tpl'), array(
- '$field' => array('affinity_lock', t('Always reset on new page visit.'), $lock, t('default: yes'), Array('No','Yes'))
- ));
-
- $settings_addons .= replace_macros(get_markup_template('generic_addon_settings.tpl'), array(
- '$addon' => array('affinity_slider', '' . t('Affinity Slider Settings'), '', t('Submit')),
- '$content' => $setting_fields
- ));
- }
-
call_hooks('feature_settings', $settings_addons);
$this->sortpanels($settings_addons);
-
$tpl = get_markup_template("settings_addons.tpl");
$o .= replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("settings_featured"),
diff --git a/Zotlabs/Module/Share.php b/Zotlabs/Module/Share.php
index c6d0be051..53a06b072 100644
--- a/Zotlabs/Module/Share.php
+++ b/Zotlabs/Module/Share.php
@@ -1,6 +1,11 @@
<?php
namespace Zotlabs\Module;
+use App;
+use Zotlabs\Daemon\Master;
+use Zotlabs\Lib\Activity;
+
+
require_once('include/security.php');
require_once('include/bbcode.php');
@@ -14,23 +19,23 @@ class Share extends \Zotlabs\Web\Controller {
if(! $post_id)
killme();
- echo '[share=' . $post_id . '][/share]';
- killme();
+ if(! local_channel()) {
+ killme();
+ }
+ $observer = App::get_observer();
- /**
- * The remaining code is deprecated and handled in Zotlabs/Lib/Share.php at post
- * submission time.
- */
+ $channel = App::get_channel();
- if(! (local_channel() || remote_channel()))
- killme();
-
$r = q("SELECT * from item left join xchan on author_xchan = xchan_hash WHERE id = %d LIMIT 1",
intval($post_id)
);
if(! $r)
killme();
+
+
+
+
if(($r[0]['item_private']) && ($r[0]['xchan_network'] !== 'rss'))
killme();
@@ -46,59 +51,86 @@ class Share extends \Zotlabs\Web\Controller {
if($r[0]['mimetype'] !== 'text/bbcode')
killme();
-
- /** @FIXME eventually we want to post remotely via rpost on your home site */
- // When that works remove this next bit:
-
- if(! local_channel())
- killme();
-
+
xchan_query($r);
- $is_photo = (($r[0]['obj_type'] === ACTIVITY_OBJ_PHOTO) ? true : false);
- if($is_photo) {
- $object = json_decode($r[0]['obj'],true);
- $photo_bb = $object['body'];
- }
-
- if (strpos($r[0]['body'], "[/share]") !== false) {
- $pos = strpos($r[0]['body'], "[share");
- $o = substr($r[0]['body'], $pos);
- } else {
- $o = "[share author='" . urlencode($r[0]['author']['xchan_name']) .
- "' profile='" . $r[0]['author']['xchan_url'] .
- "' avatar='" . $r[0]['author']['xchan_photo_s'] .
- "' link='" . $r[0]['plink'] .
- "' auth='" . (($r[0]['author']['network'] === 'zot') ? 'true' : 'false') .
- "' posted='" . $r[0]['created'] .
- "' message_id='" . $r[0]['mid'] .
- "']";
- if($r[0]['title'])
- $o .= '[b]'.$r[0]['title'].'[/b]'."\r\n";
- $o .= (($is_photo) ? $photo_bb . "\r\n" . $r[0]['body'] : $r[0]['body']);
- $o .= "[/share]";
- }
-
- if(local_channel()) {
- echo $o;
+ $arr = [];
+
+ $item = $r[0];
+
+ $owner_uid = $r[0]['uid'];
+ $owner_aid = $r[0]['aid'];
+
+ $can_comment = false;
+ if((array_key_exists('owner',$item)) && intval($item['owner']['abook_self']))
+ $can_comment = perm_is_allowed($item['uid'],$observer['xchan_hash'],'post_comments');
+ else
+ $can_comment = can_comment_on_post($observer['xchan_hash'],$item);
+
+ if(! $can_comment) {
+ notice( t('Permission denied') . EOL);
killme();
}
+
+ $r = q("select * from xchan where xchan_hash = '%s' limit 1",
+ dbesc($item['owner_xchan'])
+ );
+
+ if($r)
+ $thread_owner = $r[0];
+ else
+ killme();
- $observer = \App::get_observer();
- $parsed = $observer['xchan_url'];
- if($parsed) {
- $post_url = $parsed['scheme'] . '://' . $parsed['host'] . (($parsed['port']) ? ':' . $parsed['port'] : '')
- . '/rpost';
+ $r = q("select * from xchan where xchan_hash = '%s' limit 1",
+ dbesc($item['author_xchan'])
+ );
+ if($r)
+ $item_author = $r[0];
+ else
+ killme();
- /**
- * @FIXME we were probably called from JS so we don't know the return page.
- * In fact we won't be able to load the remote page.
- * we might need an iframe
- */
+
+ $arr['aid'] = $owner_aid;
+ $arr['uid'] = $owner_uid;
+
+ $arr['item_origin'] = 1;
+ $arr['item_wall'] = $item['item_wall'];
+ $arr['uuid'] = item_message_id();
+ $arr['mid'] = z_root() . '/activity/' . $arr['uuid'];
+ $arr['parent_mid'] = $item['mid'];
+
+ $mention = '@[zrl=' . $item['author']['xchan_url'] . ']' . $item['author']['xchan_name'] . '[/zrl]';
+ $arr['body'] = sprintf( t('&#x1f501; Repeated %1$s\'s %2$s'), $mention, Activity::activity_obj_mapper($item['obj_type']));
+
+ $arr['author_xchan'] = $channel['channel_hash'];
+ $arr['owner_xchan'] = $item['author_xchan'];
+ $arr['obj'] = Activity::encode_item($item);
+ $arr['obj_type'] = $item['obj_type'];
+ $arr['verb'] = 'Announce';
+
+ $post = item_store($arr);
+
+ $post_id = $post['item_id'];
+
+ $arr['id'] = $post_id;
- $x = z_post_url($post_url, array('f' => '', 'body' => $o ));
- killme();
+ call_hooks('post_local_end', $arr);
+
+ info( t('Post repeated') . EOL);
+
+ $r = q("select * from item where id = %d",
+ intval($post_id)
+ );
+ if($r) {
+ xchan_query($r);
+ $sync_item = fetch_post_tags($r);
+ build_sync_packet($channel['channel_id'], [ 'item' => [ encode_item($sync_item[0],true) ] ]);
}
+
+ Master::Summon([ 'Notifier','like',$post_id ]);
+
+ killme();
+
}
}
diff --git a/Zotlabs/Module/Viewsrc.php b/Zotlabs/Module/Viewsrc.php
index 119990b57..b73d81283 100644
--- a/Zotlabs/Module/Viewsrc.php
+++ b/Zotlabs/Module/Viewsrc.php
@@ -28,7 +28,7 @@ class Viewsrc extends \Zotlabs\Web\Controller {
$item_normal = item_normal();
if(local_channel() && $item_id) {
- $r = q("select id, item_flags, mimetype, item_obscured, body, llink, plink from item where uid in (%d , %d) and id = %d $item_normal limit 1",
+ $r = q("select id, mid, item_flags, mimetype, item_obscured, body, llink, plink from item where uid in (%d , %d) and id = %d $item_normal limit 1",
intval(local_channel()),
intval($sys['channel_id']),
intval($item_id)
@@ -53,7 +53,7 @@ class Viewsrc extends \Zotlabs\Web\Controller {
if(is_ajax()) {
echo '<div class="p-1">';
- echo '<div>id: ' . $r[0]['id'] . ' | <a href="' . $r[0]['plink'] . '" target="_blank">plink</a> | <a href="' . $r[0]['llink'] . '" target="_blank">llink</a></div>';
+ echo '<div>id: ' . $r[0]['id'] . ' | <a href="' . $r[0]['plink'] . '" target="_blank">plink</a> | <a href="' . $r[0]['llink'] . '" target="_blank">llink</a><br>mid: ' . $r[0]['mid'] . '</div>';
echo '<hr>';
echo '<pre class="p-1">' . $o . '</pre>';
echo '</div>';
diff --git a/Zotlabs/Photo/PhotoDriver.php b/Zotlabs/Photo/PhotoDriver.php
new file mode 100644
index 000000000..c47a7c3b2
--- /dev/null
+++ b/Zotlabs/Photo/PhotoDriver.php
@@ -0,0 +1,498 @@
+<?php
+
+namespace Zotlabs\Photo;
+
+/**
+ * @brief Abstract photo driver class.
+ *
+ * Inheritance seems not to be the best design pattern for such photo drivers.
+ */
+abstract class PhotoDriver {
+
+ /**
+ * @brief This variable keeps the image.
+ *
+ * For GD it is a PHP image resource.
+ * For ImageMagick it is an \Imagick object.
+ *
+ * @var resource|\Imagick
+ */
+ protected $image;
+
+ /**
+ * @var integer
+ */
+ protected $width;
+
+ /**
+ * @var integer
+ */
+ protected $height;
+
+ /**
+ * @var boolean
+ */
+ protected $valid;
+
+ /**
+ * @brief The mimetype of the image.
+ *
+ * @var string
+ */
+ protected $type;
+
+ /**
+ * @brief Supported mimetypes by the used photo driver.
+ *
+ * @var array
+ */
+ protected $types;
+
+ /**
+ * @brief Return an array with supported mimetypes.
+ *
+ * @return array
+ * Associative array with mimetype as key and file extension as value.
+ */
+ abstract public function supportedTypes();
+
+ abstract protected function load($data, $type);
+
+ abstract protected function destroy();
+
+ abstract protected function setDimensions();
+
+ /**
+ * @brief Return the current image.
+ *
+ * @fixme Shouldn't his method be protected, because outside of the current
+ * driver it makes no sense at all because of the different return values.
+ *
+ * @return boolean|resource|\Imagick
+ * false on failure, a PHP image resource for GD driver, an \Imagick object
+ * for ImageMagick driver.
+ */
+ abstract public function getImage();
+
+ abstract public function doScaleImage($new_width, $new_height);
+
+ abstract public function rotate($degrees);
+
+ abstract public function flip($horiz = true, $vert = false);
+
+ /**
+ * @brief Crops the image.
+ *
+ * @param int $maxx width of the new image
+ * @param int $maxy height of the new image
+ * @param int $x x-offset for region
+ * @param int $y y-offset for region
+ * @param int $w width of region
+ * @param int $h height of region
+ *
+ * @return boolean|void false on failure
+ */
+ abstract public function cropImageRect($maxx, $maxy, $x, $y, $w, $h);
+
+ /**
+ * @brief Return a binary string from the image resource.
+ *
+ * @return string A Binary String.
+ */
+ abstract public function imageString();
+
+ abstract public function clearexif();
+
+
+ /**
+ * @brief PhotoDriver constructor.
+ *
+ * @param string $data Image
+ * @param string $type mimetype
+ */
+ public function __construct($data, $type = '') {
+ $this->types = $this->supportedTypes();
+ if(! array_key_exists($type, $this->types)) {
+ $type = 'image/jpeg';
+ }
+ $this->type = $type;
+ $this->valid = false;
+ $this->load($data, $type);
+ }
+
+ public function __destruct() {
+ if($this->is_valid())
+ $this->destroy();
+ }
+
+ /**
+ * @brief Is it a valid image object.
+ *
+ * @return boolean
+ */
+ public function is_valid() {
+ return $this->valid;
+ }
+
+ /**
+ * @brief Get the width of the image.
+ *
+ * @return boolean|number Width of image in pixels, or false on failure
+ */
+ public function getWidth() {
+ if(! $this->is_valid())
+ return false;
+
+ return $this->width;
+ }
+
+ /**
+ * @brief Get the height of the image.
+ *
+ * @return boolean|number Height of image in pixels, or false on failure
+ */
+ public function getHeight() {
+ if(! $this->is_valid())
+ return false;
+
+ return $this->height;
+ }
+
+ /**
+ * @brief Saves the image resource to a file in filesystem.
+ *
+ * @param string $path Path and filename where to save the image
+ * @return boolean False on failure, otherwise true
+ */
+ public function saveImage($path) {
+ if(! $this->is_valid())
+ return false;
+
+ return (file_put_contents($path, $this->imageString()) ? true : false);
+ }
+
+ /**
+ * @brief Return mimetype of the image resource.
+ *
+ * @return boolean|string False on failure, otherwise mimetype.
+ */
+ public function getType() {
+ if(! $this->is_valid())
+ return false;
+
+ return $this->type;
+ }
+
+ /**
+ * @brief Return file extension of the image resource.
+ *
+ * @return boolean|string False on failure, otherwise file extension.
+ */
+ public function getExt() {
+ if(! $this->is_valid())
+ return false;
+
+ return $this->types[$this->getType()];
+ }
+
+ /**
+ * @brief Scale image to max pixel size in either dimension.
+ *
+ * @param int $max maximum pixel size in either dimension
+ * @param boolean $float_height (optional)
+ * If true allow height to float to any length on tall images, constraining
+ * only the width
+ * @return boolean|void false on failure, otherwise void
+ */
+ public function scaleImage($max, $float_height = true) {
+ if(! $this->is_valid())
+ return false;
+
+ $width = $this->width;
+ $height = $this->height;
+
+ $dest_width = $dest_height = 0;
+
+ if((! $width) || (! $height))
+ return false;
+
+ if($width > $max && $height > $max) {
+
+ // very tall image (greater than 16:9)
+ // constrain the width - let the height float.
+
+ if(((($height * 9) / 16) > $width) && ($float_height)) {
+ $dest_width = $max;
+ $dest_height = intval(($height * $max) / $width);
+ } // else constrain both dimensions
+ elseif($width > $height) {
+ $dest_width = $max;
+ $dest_height = intval(($height * $max) / $width);
+ } else {
+ $dest_width = intval(($width * $max) / $height);
+ $dest_height = $max;
+ }
+ } else {
+ if($width > $max) {
+ $dest_width = $max;
+ $dest_height = intval(($height * $max) / $width);
+ } else {
+ if($height > $max) {
+
+ // very tall image (greater than 16:9)
+ // but width is OK - don't do anything
+
+ if(((($height * 9) / 16) > $width) && ($float_height)) {
+ $dest_width = $width;
+ $dest_height = $height;
+ } else {
+ $dest_width = intval(($width * $max) / $height);
+ $dest_height = $max;
+ }
+ } else {
+ $dest_width = $width;
+ $dest_height = $height;
+ }
+ }
+ }
+ $this->doScaleImage($dest_width, $dest_height);
+ }
+
+ public function scaleImageUp($min) {
+ if(! $this->is_valid()) {
+ return false;
+ }
+
+ $width = $this->width;
+ $height = $this->height;
+
+ $dest_width = $dest_height = 0;
+
+ if((! $width) || (! $height))
+ return false;
+
+ if($width < $min && $height < $min) {
+ if($width > $height) {
+ $dest_width = $min;
+ $dest_height = intval(($height * $min) / $width);
+ } else {
+ $dest_width = intval(($width * $min) / $height);
+ $dest_height = $min;
+ }
+ } else {
+ if($width < $min) {
+ $dest_width = $min;
+ $dest_height = intval(($height * $min) / $width);
+ } else {
+ if($height < $min) {
+ $dest_width = intval(($width * $min) / $height);
+ $dest_height = $min;
+ } else {
+ $dest_width = $width;
+ $dest_height = $height;
+ }
+ }
+ }
+ $this->doScaleImage($dest_width, $dest_height);
+ }
+
+ /**
+ * @brief Scales image to a square.
+ *
+ * @param int $dim Pixel of square image
+ * @return boolean|void false on failure, otherwise void
+ */
+ public function scaleImageSquare($dim) {
+ if(! $this->is_valid())
+ return false;
+
+ $this->doScaleImage($dim, $dim);
+ }
+
+ /**
+ * @brief Crops a square image.
+ *
+ * @see cropImageRect()
+ *
+ * @param int $max size of the new image
+ * @param int $x x-offset for region
+ * @param int $y y-offset for region
+ * @param int $w width of region
+ * @param int $h height of region
+ *
+ * @return boolean|void false on failure
+ */
+ public function cropImage($max, $x, $y, $w, $h) {
+ if(! $this->is_valid())
+ return false;
+
+ $this->cropImageRect($max, $max, $x, $y, $w, $h);
+ }
+
+ /**
+ * @brief Reads exif data from a given filename.
+ *
+ * @param string $filename
+ * @return boolean|array
+ */
+ public function exif($filename) {
+ if((! function_exists('exif_read_data'))
+ || (! in_array($this->getType(), ['image/jpeg', 'image/tiff'])))
+ {
+ return false;
+ }
+
+ /*
+ * PHP 7.2 allows you to use a stream resource, which should reduce/avoid
+ * memory exhaustion on large images.
+ */
+
+ if(version_compare(PHP_VERSION, '7.2.0') >= 0) {
+ $f = @fopen($filename, 'rb');
+ } else {
+ $f = $filename;
+ }
+
+ if($f) {
+ return @exif_read_data($f, null, true);
+ }
+
+ return false;
+ }
+
+ /**
+ * @brief Orients current image based on exif orientation information.
+ *
+ * @param array $exif
+ * @return boolean true if oriented, otherwise false
+ */
+ public function orient($exif) {
+ if(! ($this->is_valid() && $exif)) {
+ return false;
+ }
+
+ $ort = ((array_key_exists('IFD0', $exif)) ? $exif['IFD0']['Orientation'] : $exif['Orientation']);
+
+ if(! $ort) {
+ return false;
+ }
+
+ switch($ort) {
+ case 1 : // nothing
+ break;
+ case 2 : // horizontal flip
+ $this->flip();
+ break;
+ case 3 : // 180 rotate left
+ $this->rotate(180);
+ break;
+ case 4 : // vertical flip
+ $this->flip(false, true);
+ break;
+ case 5 : // vertical flip + 90 rotate right
+ $this->flip(false, true);
+ $this->rotate(-90);
+ break;
+ case 6 : // 90 rotate right
+ $this->rotate(-90);
+ break;
+ case 7 : // horizontal flip + 90 rotate right
+ $this->flip();
+ $this->rotate(-90);
+ break;
+ case 8 : // 90 rotate left
+ $this->rotate(90);
+ break;
+ default :
+ break;
+ }
+
+ return true;
+ }
+
+ /**
+ * @brief Save photo to database.
+ *
+ * @param array $arr
+ * @param boolean $skipcheck (optional) default false
+ * @return boolean|array
+ */
+ public function save($arr, $skipcheck = false) {
+ if(! ($skipcheck || $this->is_valid())) {
+ logger('Attempt to store invalid photo.');
+ return false;
+ }
+
+ $p = [];
+
+ $p['aid'] = ((intval($arr['aid'])) ? intval($arr['aid']) : 0);
+ $p['uid'] = ((intval($arr['uid'])) ? intval($arr['uid']) : 0);
+ $p['xchan'] = (($arr['xchan']) ? $arr['xchan'] : '');
+ $p['resource_id'] = (($arr['resource_id']) ? $arr['resource_id'] : '');
+ $p['filename'] = (($arr['filename']) ? $arr['filename'] : '');
+ $p['mimetype'] = (($arr['mimetype']) ? $arr['mimetype'] : $this->getType());
+ $p['album'] = (($arr['album']) ? $arr['album'] : '');
+ $p['imgscale'] = ((intval($arr['imgscale'])) ? intval($arr['imgscale']) : 0);
+ $p['allow_cid'] = (($arr['allow_cid']) ? $arr['allow_cid'] : '');
+ $p['allow_gid'] = (($arr['allow_gid']) ? $arr['allow_gid'] : '');
+ $p['deny_cid'] = (($arr['deny_cid']) ? $arr['deny_cid'] : '');
+ $p['deny_gid'] = (($arr['deny_gid']) ? $arr['deny_gid'] : '');
+ $p['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert());
+ $p['title'] = (($arr['title']) ? $arr['title'] : '');
+ $p['description'] = (($arr['description']) ? $arr['description'] : '');
+ $p['photo_usage'] = intval($arr['photo_usage']);
+ $p['os_storage'] = intval($arr['os_storage']);
+ $p['os_path'] = $arr['os_path'];
+ $p['os_syspath'] = ((array_key_exists('os_syspath', $arr)) ? $arr['os_syspath'] : '');
+ $p['display_path'] = (($arr['display_path']) ? $arr['display_path'] : '');
+ $p['width'] = (($arr['width']) ? $arr['width'] : $this->getWidth());
+ $p['height'] = (($arr['height']) ? $arr['height'] : $this->getHeight());
+ $p['expires'] = (($arr['expires']) ? $arr['expires'] : gmdate('Y-m-d H:i:s', time() + get_config('system', 'photo_cache_time', 86400)));
+
+ if(! intval($p['imgscale']))
+ logger('save: ' . print_r($arr, true), LOGGER_DATA);
+
+ $x = q("select id, created from photo where resource_id = '%s' and uid = %d and xchan = '%s' and imgscale = %d limit 1", dbesc($p['resource_id']), intval($p['uid']), dbesc($p['xchan']), intval($p['imgscale']));
+
+ if($x) {
+ $p['created'] = (($x['created']) ? $x['created'] : $p['edited']);
+ $r = q("UPDATE photo set
+ aid = %d,
+ uid = %d,
+ xchan = '%s',
+ resource_id = '%s',
+ created = '%s',
+ edited = '%s',
+ filename = '%s',
+ mimetype = '%s',
+ album = '%s',
+ height = %d,
+ width = %d,
+ content = '%s',
+ os_storage = %d,
+ filesize = %d,
+ imgscale = %d,
+ photo_usage = %d,
+ title = '%s',
+ description = '%s',
+ os_path = '%s',
+ display_path = '%s',
+ allow_cid = '%s',
+ allow_gid = '%s',
+ deny_cid = '%s',
+ deny_gid = '%s',
+ expires = '%s'
+ where id = %d",
+ intval($p['aid']), intval($p['uid']), dbesc($p['xchan']), dbesc($p['resource_id']), dbescdate($p['created']), dbescdate($p['edited']), dbesc(basename($p['filename'])), dbesc($p['mimetype']), dbesc($p['album']), intval($p['height']), intval($p['width']), (intval($p['os_storage']) ? dbescbin($p['os_syspath']) : dbescbin($this->imageString())), intval($p['os_storage']), (intval($p['os_storage']) ? @filesize($p['os_syspath']) : strlen($this->imageString())), intval($p['imgscale']), intval($p['photo_usage']), dbesc($p['title']), dbesc($p['description']), dbesc($p['os_path']), dbesc($p['display_path']), dbesc($p['allow_cid']), dbesc($p['allow_gid']), dbesc($p['deny_cid']), dbesc($p['deny_gid']), dbescdate($p['expires']), intval($x[0]['id']));
+ } else {
+ $p['created'] = (($arr['created']) ? $arr['created'] : $p['edited']);
+ $r = q("INSERT INTO photo
+ ( aid, uid, xchan, resource_id, created, edited, filename, mimetype, album, height, width, content, os_storage, filesize, imgscale, photo_usage, title, description, os_path, display_path, allow_cid, allow_gid, deny_cid, deny_gid, expires )
+ VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", intval($p['aid']), intval($p['uid']), dbesc($p['xchan']), dbesc($p['resource_id']), dbescdate($p['created']), dbescdate($p['edited']), dbesc(basename($p['filename'])), dbesc($p['mimetype']), dbesc($p['album']), intval($p['height']), intval($p['width']), (intval($p['os_storage']) ? dbescbin($p['os_syspath']) : dbescbin($this->imageString())), intval($p['os_storage']), (intval($p['os_storage']) ? @filesize($p['os_syspath']) : strlen($this->imageString())), intval($p['imgscale']), intval($p['photo_usage']), dbesc($p['title']), dbesc($p['description']), dbesc($p['os_path']), dbesc($p['display_path']), dbesc($p['allow_cid']), dbesc($p['allow_gid']), dbesc($p['deny_cid']), dbesc($p['deny_gid']), dbescdate($p['expires']));
+ }
+ logger('Photo save imgscale ' . $p['imgscale'] . ' returned ' . intval($r));
+
+ return $r;
+ }
+
+}
diff --git a/Zotlabs/Photo/PhotoGd.php b/Zotlabs/Photo/PhotoGd.php
new file mode 100644
index 000000000..4054e1866
--- /dev/null
+++ b/Zotlabs/Photo/PhotoGd.php
@@ -0,0 +1,176 @@
+<?php
+
+namespace Zotlabs\Photo;
+
+/**
+ * @brief GD photo driver.
+ *
+ */
+class PhotoGd extends PhotoDriver {
+
+ /**
+ * {@inheritDoc}
+ * @see \Zotlabs\Photo\PhotoDriver::supportedTypes()
+ */
+ public function supportedTypes() {
+ $t = [];
+ $t['image/jpeg'] = 'jpg';
+ if(imagetypes() & IMG_PNG)
+ $t['image/png'] = 'png';
+ if(imagetypes() & IMG_GIF)
+ $t['image/gif'] = 'gif';
+
+ return $t;
+ }
+
+ protected function load($data, $type) {
+ $this->valid = false;
+ if(! $data)
+ return;
+
+ $this->image = @imagecreatefromstring($data);
+ if($this->image !== false) {
+ $this->valid = true;
+ $this->setDimensions();
+ imagealphablending($this->image, false);
+ imagesavealpha($this->image, true);
+ }
+ }
+
+ protected function setDimensions() {
+ $this->width = imagesx($this->image);
+ $this->height = imagesy($this->image);
+ }
+
+ /**
+ * @brief GD driver does not preserve EXIF, so not need to clear it.
+ *
+ * @return void
+ */
+ public function clearexif() {
+ return;
+ }
+
+ protected function destroy() {
+ if($this->is_valid()) {
+ imagedestroy($this->image);
+ }
+ }
+
+ /**
+ * @brief Return a PHP image resource of the current image.
+ *
+ * @see \Zotlabs\Photo\PhotoDriver::getImage()
+ *
+ * @return boolean|resource
+ */
+ public function getImage() {
+ if(! $this->is_valid())
+ return false;
+
+ return $this->image;
+ }
+
+ public function doScaleImage($dest_width, $dest_height) {
+
+ $dest = imagecreatetruecolor($dest_width, $dest_height);
+ $width = imagesx($this->image);
+ $height = imagesy($this->image);
+
+ imagealphablending($dest, false);
+ imagesavealpha($dest, true);
+ if($this->type == 'image/png')
+ imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
+
+ imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height);
+ if($this->image)
+ imagedestroy($this->image);
+
+ $this->image = $dest;
+ $this->setDimensions();
+ }
+
+ public function rotate($degrees) {
+ if(! $this->is_valid())
+ return false;
+
+ $this->image = imagerotate($this->image, $degrees, 0);
+ $this->setDimensions();
+ }
+
+ public function flip($horiz = true, $vert = false) {
+ if(! $this->is_valid())
+ return false;
+
+ $w = imagesx($this->image);
+ $h = imagesy($this->image);
+ $flipped = imagecreate($w, $h);
+ if($horiz) {
+ for($x = 0; $x < $w; $x++) {
+ imagecopy($flipped, $this->image, $x, 0, $w - $x - 1, 0, 1, $h);
+ }
+ }
+ if($vert) {
+ for($y = 0; $y < $h; $y++) {
+ imagecopy($flipped, $this->image, 0, $y, 0, $h - $y - 1, $w, 1);
+ }
+ }
+ $this->image = $flipped;
+ $this->setDimensions(); // Shouldn't really be necessary
+ }
+
+ public function cropImageRect($maxx, $maxy, $x, $y, $w, $h) {
+ if(! $this->is_valid())
+ return false;
+
+ $dest = imagecreatetruecolor($maxx, $maxy);
+ imagealphablending($dest, false);
+ imagesavealpha($dest, true);
+ if($this->type == 'image/png')
+ imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
+
+ imagecopyresampled($dest, $this->image, 0, 0, $x, $y, $maxx, $maxy, $w, $h);
+ if($this->image)
+ imagedestroy($this->image);
+
+ $this->image = $dest;
+ $this->setDimensions();
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see \Zotlabs\Photo\PhotoDriver::imageString()
+ */
+ public function imageString() {
+ if(! $this->is_valid())
+ return false;
+
+ $quality = false;
+
+ ob_start();
+
+ switch($this->getType()){
+ case 'image/png':
+ $quality = get_config('system', 'png_quality');
+ if((! $quality) || ($quality > 9))
+ $quality = PNG_QUALITY;
+
+ \imagepng($this->image, NULL, $quality);
+ break;
+ case 'image/jpeg':
+ // gd can lack imagejpeg(), but we verify during installation it is available
+ default:
+ $quality = get_config('system', 'jpeg_quality');
+ if((! $quality) || ($quality > 100))
+ $quality = JPEG_QUALITY;
+
+ \imagejpeg($this->image, NULL, $quality);
+ break;
+ }
+ $string = ob_get_contents();
+ ob_end_clean();
+
+ return $string;
+ }
+
+}
diff --git a/Zotlabs/Photo/PhotoImagick.php b/Zotlabs/Photo/PhotoImagick.php
new file mode 100644
index 000000000..a7026e8ca
--- /dev/null
+++ b/Zotlabs/Photo/PhotoImagick.php
@@ -0,0 +1,200 @@
+<?php
+
+namespace Zotlabs\Photo;
+
+/**
+ * @brief ImageMagick photo driver.
+ */
+class PhotoImagick extends PhotoDriver {
+
+ public function supportedTypes() {
+ return [
+ 'image/jpeg' => 'jpg',
+ 'image/png' => 'png',
+ 'image/gif' => 'gif',
+ ];
+ }
+
+ private function get_FormatsMap() {
+ return [
+ 'image/jpeg' => 'JPG',
+ 'image/png' => 'PNG',
+ 'image/gif' => 'GIF',
+ ];
+ }
+
+
+ protected function load($data, $type) {
+ $this->valid = false;
+ $this->image = new \Imagick();
+
+ if(! $data)
+ return;
+
+ try {
+ $this->image->readImageBlob($data);
+ } catch(\Exception $e) {
+ logger('Imagick readImageBlob() exception:' . print_r($e, true));
+ return;
+ }
+
+ /*
+ * Setup the image to the format it will be saved to
+ */
+
+ $map = $this->get_FormatsMap();
+ $format = $map[$type];
+
+ if($this->image) {
+ $this->image->setFormat($format);
+
+ // Always coalesce, if it is not a multi-frame image it won't hurt anyway
+ $this->image = $this->image->coalesceImages();
+
+ $this->valid = true;
+ $this->setDimensions();
+
+ /*
+ * setup the compression here, so we'll do it only once
+ */
+ switch($this->getType()) {
+ case 'image/png':
+ $quality = get_config('system', 'png_quality');
+ if((! $quality) || ($quality > 9))
+ $quality = PNG_QUALITY;
+ /*
+ * From http://www.imagemagick.org/script/command-line-options.php#quality:
+ *
+ * 'For the MNG and PNG image formats, the quality value sets
+ * the zlib compression level (quality / 10) and filter-type (quality % 10).
+ * The default PNG "quality" is 75, which means compression level 7 with adaptive PNG filtering,
+ * unless the image has a color map, in which case it means compression level 7 with no PNG filtering'
+ */
+ $quality = $quality * 10;
+ $this->image->setCompressionQuality($quality);
+ break;
+ case 'image/jpeg':
+ $quality = get_config('system', 'jpeg_quality');
+ if((! $quality) || ($quality > 100))
+ $quality = JPEG_QUALITY;
+ $this->image->setCompressionQuality($quality);
+ default:
+ break;
+ }
+ }
+ }
+
+ protected function destroy() {
+ if($this->is_valid()) {
+ $this->image->clear();
+ $this->image->destroy();
+ }
+ }
+
+ protected function setDimensions() {
+ $this->width = $this->image->getImageWidth();
+ $this->height = $this->image->getImageHeight();
+ }
+
+ /**
+ * @brief Strips the image of all profiles and comments.
+ *
+ * Keep ICC profile for better colors.
+ *
+ * @see \Zotlabs\Photo\PhotoDriver::clearexif()
+ */
+ public function clearexif() {
+ $profiles = $this->image->getImageProfiles('icc', true);
+
+ $this->image->stripImage();
+
+ if(! empty($profiles)) {
+ $this->image->profileImage('icc', $profiles['icc']);
+ }
+ }
+
+
+ /**
+ * @brief Return a \Imagick object of the current image.
+ *
+ * @see \Zotlabs\Photo\PhotoDriver::getImage()
+ *
+ * @return boolean|\Imagick
+ */
+ public function getImage() {
+ if(! $this->is_valid())
+ return false;
+
+ $this->image = $this->image->deconstructImages();
+ return $this->image;
+ }
+
+ public function doScaleImage($dest_width, $dest_height) {
+ /*
+ * If it is not animated, there will be only one iteration here,
+ * so don't bother checking
+ */
+ // Don't forget to go back to the first frame
+ $this->image->setFirstIterator();
+ do {
+ $this->image->scaleImage($dest_width, $dest_height);
+ } while($this->image->nextImage());
+
+ $this->setDimensions();
+ }
+
+ public function rotate($degrees) {
+ if(! $this->is_valid())
+ return false;
+
+ $this->image->setFirstIterator();
+ do {
+ // ImageMagick rotates in the opposite direction of imagerotate()
+ $this->image->rotateImage(new \ImagickPixel(), -$degrees);
+ } while($this->image->nextImage());
+
+ $this->setDimensions();
+ }
+
+ public function flip($horiz = true, $vert = false) {
+ if(! $this->is_valid())
+ return false;
+
+ $this->image->setFirstIterator();
+ do {
+ if($horiz) $this->image->flipImage();
+ if($vert) $this->image->flopImage();
+ } while($this->image->nextImage());
+
+ $this->setDimensions(); // Shouldn't really be necessary
+ }
+
+ public function cropImageRect($maxx, $maxy, $x, $y, $w, $h) {
+ if(! $this->is_valid())
+ return false;
+
+ $this->image->setFirstIterator();
+ do {
+ $this->image->cropImage($w, $h, $x, $y);
+ /*
+ * We need to remove the canvas,
+ * or the image is not resized to the crop:
+ * http://php.net/manual/en/imagick.cropimage.php#97232
+ */
+ $this->image->setImagePage(0, 0, 0, 0);
+ } while($this->image->nextImage());
+
+ $this->doScaleImage($maxx, $maxy);
+ }
+
+ public function imageString() {
+ if(! $this->is_valid())
+ return false;
+
+ /* Clean it */
+ $this->image = $this->image->deconstructImages();
+
+ return $this->image->getImagesBlob();
+ }
+
+}
diff --git a/Zotlabs/Web/Session.php b/Zotlabs/Web/Session.php
index 4f2a3f1f7..fe0a3fbf9 100644
--- a/Zotlabs/Web/Session.php
+++ b/Zotlabs/Web/Session.php
@@ -15,7 +15,7 @@ class Session {
private $handler = null;
private $session_started = false;
-
+ private $custom_handler = false;
public function init() {
$gc_probability = 50;
@@ -23,25 +23,46 @@ class Session {
ini_set('session.gc_probability', $gc_probability);
ini_set('session.use_only_cookies', 1);
ini_set('session.cookie_httponly', 1);
-
+
+ $this->custom_handler = boolval(get_config('system', 'session_custom', false));
+
/*
* Set our session storage functions.
*/
+
+ 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));
+ $session_gc_probability = intval(get_config('system', 'session_gc_probability', 1));
+ $session_gc_divisor = intval(get_config('system', 'session_gc_divisor', 100));
+ 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);
+ ini_set('session.gc_probability', $session_gc_probability);
+ ini_set('session.gc_divisor', $session_gc_divisor);
+ }
+ }
+ else {
+ $handler = new \Zotlabs\Web\SessionHandler();
- $handler = new \Zotlabs\Web\SessionHandler();
-
- $this->handler = $handler;
+ $this->handler = $handler;
- $x = session_set_save_handler($handler,false);
- if(! $x)
- logger('Session save handler initialisation failed.',LOGGER_NORMAL,LOG_ERR);
+ $x = session_set_save_handler($handler,false);
+ 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
// cookie. If you use a hostname it will create a .domain.com wildcard which will
// have some nasty side effects if you have any other subdomains running hubzilla.
@@ -86,14 +107,15 @@ class Session {
$arr = session_get_cookie_params();
- if($this->handler && $this->session_started) {
+ if(($this->handler || $this->custom_handler) && $this->session_started) {
session_regenerate_id(true);
// force SessionHandler record creation with the new session_id
// which occurs as a side effect of read()
-
- $this->handler->read(session_id());
+ if (! $this->custom_handler) {
+ $this->handler->read(session_id());
+ }
}
else
logger('no session handler');
diff --git a/Zotlabs/Widget/Affinity.php b/Zotlabs/Widget/Affinity.php
index 28190e187..572af0503 100644
--- a/Zotlabs/Widget/Affinity.php
+++ b/Zotlabs/Widget/Affinity.php
@@ -2,60 +2,65 @@
namespace Zotlabs\Widget;
+use Zotlabs\Lib\Apps;
+
class Affinity {
function widget($arr) {
if(! local_channel())
- return '';
-
- $default_cmin = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmin',0) : 0);
- $default_cmax = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmax',99) : 99);
+ return;
+
+ if(! Apps::system_app_installed(local_channel(),'Affinity Tool'))
+ 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);
$cmin = ((x($_REQUEST,'cmin')) ? intval($_REQUEST['cmin']) : $default_cmin);
$cmax = ((x($_REQUEST,'cmax')) ? intval($_REQUEST['cmax']) : $default_cmax);
- if(feature_enabled(local_channel(),'affinity')) {
-
- $affinity_locked = intval(get_pconfig(local_channel(),'affinity','lock',1));
- if ($affinity_locked) {
- set_pconfig(local_channel(),'affinity','cmin',$cmin);
- set_pconfig(local_channel(),'affinity','cmax',$cmax);
- }
-
- $labels = array(
- t('Me'),
- t('Family'),
- t('Friends'),
- t('Acquaintances'),
- t('All')
- );
- call_hooks('affinity_labels',$labels);
- $label_str = '';
-
- if($labels) {
- foreach($labels as $l) {
- if($label_str) {
- $label_str .= ", '|'";
- $label_str .= ", '" . $l . "'";
- }
- else
- $label_str .= "'" . $l . "'";
+ $affinity_locked = intval(get_pconfig(local_channel(),'affinity','lock',1));
+ if ($affinity_locked) {
+ set_pconfig(local_channel(),'affinity','cmin',$cmin);
+ set_pconfig(local_channel(),'affinity','cmax',$cmax);
+ }
+
+ $labels = array(
+ t('Me'),
+ t('Family'),
+ t('Friends'),
+ t('Acquaintances'),
+ t('All')
+ );
+ call_hooks('affinity_labels',$labels);
+
+ $label_str = '';
+
+ if($labels) {
+ foreach($labels as $l) {
+ if($label_str) {
+ $label_str .= ", '|'";
+ $label_str .= ", '" . $l . "'";
}
+ else
+ $label_str .= "'" . $l . "'";
}
-
- $tpl = get_markup_template('main_slider.tpl');
- $x = replace_macros($tpl,array(
- '$val' => $cmin . ',' . $cmax,
- '$refresh' => t('Refresh'),
- '$labels' => $label_str,
- ));
-
- $arr = array('html' => $x);
- call_hooks('main_slider',$arr);
- return $arr['html'];
}
- return '';
+
+ $tpl = get_markup_template('main_slider.tpl');
+ $x = replace_macros($tpl,array(
+ '$val' => $cmin . ',' . $cmax,
+ '$refresh' => t('Refresh'),
+ '$labels' => $label_str,
+ ));
+
+ $arr = array('html' => $x);
+ call_hooks('main_slider',$arr);
+
+ return $arr['html'];
+
+
}
}
diff --git a/Zotlabs/Widget/Settings_menu.php b/Zotlabs/Widget/Settings_menu.php
index c537c3835..25b80a4b4 100644
--- a/Zotlabs/Widget/Settings_menu.php
+++ b/Zotlabs/Widget/Settings_menu.php
@@ -42,19 +42,12 @@ class Settings_menu {
);
-
$tabs[] = array(
'label' => t('Display settings'),
'url' => z_root().'/settings/display',
'selected' => ((argv(1) === 'display') ? 'active' : ''),
);
- $tabs[] = array(
- 'label' => t('Addon settings'),
- 'url' => z_root().'/settings/featured',
- 'selected' => ((argv(1) === 'featured') ? 'active' : ''),
- );
-
if($hublocs) {
$tabs[] = array(
'label' => t('Manage locations'),
diff --git a/Zotlabs/Zot6/Zot6Handler.php b/Zotlabs/Zot6/Zot6Handler.php
index e320e7825..8f8957037 100644
--- a/Zotlabs/Zot6/Zot6Handler.php
+++ b/Zotlabs/Zot6/Zot6Handler.php
@@ -29,7 +29,7 @@ class Zot6Handler implements IHandler {
// Implementation of specific methods follows;
- // These generally do a small amout of validation and call Libzot
+ // These generally do a small amout of validation and call Libzot
// to do any heavy lifting
static function reply_notify($data,$hub) {
@@ -40,7 +40,7 @@ class Zot6Handler implements IHandler {
$x = Libzot::fetch($data);
$ret['delivery_report'] = $x;
-
+
$ret['success'] = true;
return $ret;
@@ -58,11 +58,11 @@ class Zot6Handler implements IHandler {
*
* @param array $sender
* @param array $recipients
+ * @param array $hub
*
- * @return json_return_and_die()
+ * @return array
*/
-
- static function reply_refresh($sender, $recipients,$hub) {
+ static function reply_refresh($sender, $recipients, $hub) {
$ret = array('success' => false);
if($recipients) {
@@ -70,19 +70,18 @@ class Zot6Handler implements IHandler {
// This would be a permissions update, typically for one connection
foreach ($recipients as $recip) {
-
$r = q("select channel.*,xchan.* from channel
left join xchan on channel_portable_id = xchan_hash
where xchan_hash ='%s' limit 1",
dbesc($recip)
);
-
+ /// @FIXME $msgtype is undefined
$x = Libzot::refresh( [ 'hubloc_id_url' => $hub['hubloc_id_url'] ], $r[0], (($msgtype === 'force_refresh') ? true : false));
}
}
else {
// system wide refresh
-
+ /// @FIXME $msgtype is undefined
$x = Libzot::refresh( [ 'hubloc_id_url' => $hub['hubloc_id_url'] ], null, (($msgtype === 'force_refresh') ? true : false));
}
@@ -100,17 +99,16 @@ class Zot6Handler implements IHandler {
* for that packet. We will create a message_list array of the entire conversation starting with
* the missing parent and invoke delivery to the sender of the packet.
*
- * Zotlabs/Daemon/Deliver.php (for local delivery) and
+ * Zotlabs/Daemon/Deliver.php (for local delivery) and
* mod/post.php???? @fixme (for web delivery) detect the existence of
* this 'message_list' at the destination and split it into individual messages which are
* processed/delivered in order.
*
- *
* @param array $data
+ * @param array $hub
* @return array
*/
-
- static function reply_message_request($data,$hub) {
+ static function reply_message_request($data, $hub) {
$ret = [ 'success' => false ];
$message_id = EMPTY_STR;
@@ -153,11 +151,10 @@ class Zot6Handler implements IHandler {
/*
* fetch the requested conversation
*/
-
+ /// @FIXME $sender_hash is undefined
$messages = zot_feed($c[0]['channel_id'],$sender_hash, [ 'message_id' => $data['message_id'], 'encoding' => 'activitystreams' ]);
return (($messages) ? : [] );
-
}
static function rekey_request($sender,$data,$hub) {
@@ -183,7 +180,7 @@ class Zot6Handler implements IHandler {
dbesc($oldhash)
);
}
- else
+ else
return $ret;
@@ -219,10 +216,10 @@ class Zot6Handler implements IHandler {
*
* @param array $sender
* @param array $recipients
+ * @param array $hub
*
- * return json_return_and_die()
+ * @return array
*/
-
static function reply_purge($sender, $recipients, $hub) {
$ret = array('success' => false);
@@ -259,9 +256,4 @@ class Zot6Handler implements IHandler {
return $ret;
}
-
-
-
-
-
}