aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2021-01-20 13:15:40 +0100
committerMax Kostikov <max@kostikov.co>2021-01-20 13:15:40 +0100
commit9612a69a6448331ae3296503e97ef6ce204d9be1 (patch)
treeafae1ea1fa8c63db4c23836e0ebfe57b56b808ec /Zotlabs
parent308e94ea799b7851287fbc7635480ac13bfe3c61 (diff)
parent08264f8d11d349bbda92233d984ad52c16c6b2d6 (diff)
downloadvolse-hubzilla-9612a69a6448331ae3296503e97ef6ce204d9be1.tar.gz
volse-hubzilla-9612a69a6448331ae3296503e97ef6ce204d9be1.tar.bz2
volse-hubzilla-9612a69a6448331ae3296503e97ef6ce204d9be1.zip
Merge branch 'dev' into 'dev'
Dev sync See merge request kostikov/core!1
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Access/AccessList.php3
-rw-r--r--Zotlabs/Access/PermissionLimits.php15
-rw-r--r--Zotlabs/Access/PermissionRoles.php10
-rw-r--r--Zotlabs/Access/Permissions.php89
-rw-r--r--Zotlabs/Daemon/Addon.php7
-rw-r--r--Zotlabs/Daemon/Cache_embeds.php1
-rw-r--r--Zotlabs/Daemon/Checksites.php23
-rw-r--r--Zotlabs/Daemon/Cron.php125
-rw-r--r--Zotlabs/Daemon/Cron_daily.php40
-rw-r--r--Zotlabs/Daemon/Cron_weekly.php21
-rw-r--r--Zotlabs/Daemon/CurlAuth.php24
-rw-r--r--Zotlabs/Daemon/Deliver.php16
-rw-r--r--Zotlabs/Daemon/Deliver_hooks.php11
-rw-r--r--Zotlabs/Daemon/Directory.php40
-rw-r--r--Zotlabs/Daemon/Expire.php35
-rw-r--r--Zotlabs/Daemon/Externals.php53
-rw-r--r--Zotlabs/Daemon/Gprobe.php14
-rwxr-xr-xZotlabs/Daemon/Importdoc.php14
-rw-r--r--Zotlabs/Daemon/Importfile.php23
-rw-r--r--Zotlabs/Daemon/Master.php37
-rw-r--r--Zotlabs/Daemon/Notifier.php414
-rw-r--r--Zotlabs/Daemon/Onedirsync.php23
-rw-r--r--Zotlabs/Daemon/Onepoll.php109
-rw-r--r--Zotlabs/Daemon/Poller.php145
-rw-r--r--Zotlabs/Daemon/Queue.php23
-rw-r--r--Zotlabs/Daemon/Thumbnail.php46
-rw-r--r--Zotlabs/Lib/Apps.php2
-rw-r--r--Zotlabs/Lib/Enotify.php66
-rw-r--r--Zotlabs/Lib/JSalmon.php10
-rw-r--r--Zotlabs/Lib/Libzot.php10
-rw-r--r--Zotlabs/Lib/Libzotdir.php45
-rw-r--r--Zotlabs/Lib/NativeWiki.php16
-rw-r--r--Zotlabs/Lib/NativeWikiPage.php11
-rw-r--r--Zotlabs/Lib/Queue.php10
-rw-r--r--Zotlabs/Lib/Share.php2
-rw-r--r--Zotlabs/Lib/ThreadItem.php48
-rw-r--r--Zotlabs/Lib/Verify.php8
-rw-r--r--Zotlabs/Module/Acl.php171
-rw-r--r--Zotlabs/Module/Attach.php78
-rw-r--r--Zotlabs/Module/Cal.php12
-rw-r--r--Zotlabs/Module/Cdav.php4
-rw-r--r--Zotlabs/Module/Channel.php54
-rw-r--r--Zotlabs/Module/Channel_calendar.php417
-rw-r--r--Zotlabs/Module/Chanview.php2
-rw-r--r--Zotlabs/Module/Cloud.php2
-rw-r--r--Zotlabs/Module/Connections.php5
-rw-r--r--Zotlabs/Module/Connedit.php290
-rw-r--r--Zotlabs/Module/Dav.php4
-rw-r--r--Zotlabs/Module/Directory.php194
-rw-r--r--Zotlabs/Module/Dirsearch.php4
-rw-r--r--Zotlabs/Module/Display.php84
-rw-r--r--Zotlabs/Module/Embedphotos.php3
-rw-r--r--Zotlabs/Module/File_upload.php2
-rw-r--r--Zotlabs/Module/Getfile.php40
-rw-r--r--Zotlabs/Module/Item.php4
-rw-r--r--Zotlabs/Module/Like.php595
-rw-r--r--Zotlabs/Module/Network.php245
-rw-r--r--Zotlabs/Module/Notifications.php8
-rw-r--r--Zotlabs/Module/Owa.php2
-rw-r--r--Zotlabs/Module/Photo.php9
-rw-r--r--Zotlabs/Module/Photos.php609
-rw-r--r--Zotlabs/Module/Profile.php2
-rw-r--r--Zotlabs/Module/Profiles.php250
-rw-r--r--Zotlabs/Module/Pubsites.php27
-rw-r--r--Zotlabs/Module/Regver.php2
-rw-r--r--Zotlabs/Module/Sse_bs.php30
-rw-r--r--Zotlabs/Module/Zfinger.php8
-rw-r--r--Zotlabs/Storage/Browser.php47
-rw-r--r--Zotlabs/Web/HTTPSig.php2
-rw-r--r--Zotlabs/Widget/Dirsort.php4
-rw-r--r--Zotlabs/Zot6/Finger.php4
-rw-r--r--Zotlabs/Zot6/Zot6Handler.php12
72 files changed, 2409 insertions, 2406 deletions
diff --git a/Zotlabs/Access/AccessList.php b/Zotlabs/Access/AccessList.php
index 7cf7b5587..af6c4b7a6 100644
--- a/Zotlabs/Access/AccessList.php
+++ b/Zotlabs/Access/AccessList.php
@@ -54,7 +54,7 @@ class AccessList {
* * \e string \b channel_deny_gid => string of denied gids
*/
function __construct($channel) {
- if($channel) {
+ if ($channel) {
$this->allow_cid = $channel['channel_allow_cid'];
$this->allow_gid = $channel['channel_allow_gid'];
$this->deny_cid = $channel['channel_deny_cid'];
@@ -99,7 +99,6 @@ class AccessList {
$this->allow_gid = $arr['allow_gid'];
$this->deny_cid = $arr['deny_cid'];
$this->deny_gid = $arr['deny_gid'];
-
$this->explicit = $explicit;
}
diff --git a/Zotlabs/Access/PermissionLimits.php b/Zotlabs/Access/PermissionLimits.php
index c11dc95e6..fb5fe6133 100644
--- a/Zotlabs/Access/PermissionLimits.php
+++ b/Zotlabs/Access/PermissionLimits.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Access;
+use App;
use Zotlabs\Lib\PConfig;
/**
@@ -39,10 +40,10 @@ class PermissionLimits {
*/
static public function Std_Limits() {
$limits = [];
- $perms = Permissions::Perms();
+ $perms = Permissions::Perms();
- foreach($perms as $k => $v) {
- if(strstr($k, 'view'))
+ foreach ($perms as $k => $v) {
+ if (strstr($k, 'view'))
$limits[$k] = PERMS_PUBLIC;
else
$limits[$k] = PERMS_SPECIFIC;
@@ -77,14 +78,14 @@ class PermissionLimits {
* * \b array with all permission limits, if $perm is not set
*/
static public function Get($channel_id, $perm = '') {
- if($perm) {
+ if ($perm) {
return intval(PConfig::Get($channel_id, 'perm_limits', $perm));
}
PConfig::Load($channel_id);
- if(array_key_exists($channel_id, \App::$config)
- && array_key_exists('perm_limits', \App::$config[$channel_id]))
- return \App::$config[$channel_id]['perm_limits'];
+ if (array_key_exists($channel_id, App::$config)
+ && array_key_exists('perm_limits', App::$config[$channel_id]))
+ return App::$config[$channel_id]['perm_limits'];
return false;
}
diff --git a/Zotlabs/Access/PermissionRoles.php b/Zotlabs/Access/PermissionRoles.php
index 82df0c34b..2bcce4eb4 100644
--- a/Zotlabs/Access/PermissionRoles.php
+++ b/Zotlabs/Access/PermissionRoles.php
@@ -218,13 +218,13 @@ class PermissionRoles {
// set permissionlimits for this permission here, for example:
// if($perm === 'mynewperm')
- // \Zotlabs\Access\PermissionLimits::Set($uid,$perm,1);
+ // PermissionLimits::Set($uid,$perm,1);
if($perm === 'view_wiki')
- \Zotlabs\Access\PermissionLimits::Set($uid, $perm, PERMS_PUBLIC);
+ PermissionLimits::Set($uid, $perm, PERMS_PUBLIC);
if($perm === 'write_wiki')
- \Zotlabs\Access\PermissionLimits::Set($uid, $perm, PERMS_SPECIFIC);
+ PermissionLimits::Set($uid, $perm, PERMS_SPECIFIC);
// set autoperms here if applicable
@@ -262,11 +262,11 @@ class PermissionRoles {
case 'view_wiki':
set_abconfig($uid,$ab['abook_xchan'],'my_perms',$perm,
intval(get_abconfig($uid,$ab['abook_xchan'],'my_perms','view_pages')));
-
+ break;
case 'write_wiki':
set_abconfig($uid,$ab['abook_xchan'],'my_perms',$perm,
intval(get_abconfig($uid,$ab['abook_xchan'],'my_perms','write_pages')));
-
+ break;
default:
break;
}
diff --git a/Zotlabs/Access/Permissions.php b/Zotlabs/Access/Permissions.php
index 35016ed57..df5472cc3 100644
--- a/Zotlabs/Access/Permissions.php
+++ b/Zotlabs/Access/Permissions.php
@@ -75,7 +75,7 @@ class Permissions {
$x = [
'permissions' => $perms,
- 'filter' => $filter
+ 'filter' => $filter
];
/**
* @hooks permissions_list
@@ -84,7 +84,7 @@ class Permissions {
*/
call_hooks('permissions_list', $x);
- return($x['permissions']);
+ return ($x['permissions']);
}
/**
@@ -96,10 +96,10 @@ class Permissions {
*/
static public function BlockedAnonPerms() {
- $res = [];
+ $res = [];
$perms = PermissionLimits::Std_limits();
- foreach($perms as $perm => $limit) {
- if($limit != PERMS_PUBLIC) {
+ foreach ($perms as $perm => $limit) {
+ if ($limit != PERMS_PUBLIC) {
$res[] = $perm;
}
}
@@ -111,7 +111,7 @@ class Permissions {
*/
call_hooks('write_perms', $x);
- return($x['permissions']);
+ return ($x['permissions']);
}
/**
@@ -120,20 +120,20 @@ class Permissions {
* Converts [ 0 => 'view_stream', ... ]
* to [ 'view_stream' => 1 ] for any permissions in $arr;
* Undeclared permissions which exist in Perms() are added and set to 0.
- *
+ *
* @param array $arr
* @return array
*/
static public function FilledPerms($arr) {
- if(is_null($arr)) {
+ if (is_null($arr)) {
btlogger('FilledPerms: null');
$arr = [];
}
$everything = self::Perms();
- $ret = [];
- foreach($everything as $k => $v) {
- if(in_array($k, $arr))
+ $ret = [];
+ foreach ($everything as $k => $v) {
+ if (in_array($k, $arr))
$ret[$k] = 1;
else
$ret[$k] = 0;
@@ -155,9 +155,9 @@ class Permissions {
*/
static public function OPerms($arr) {
$ret = [];
- if($arr) {
- foreach($arr as $k => $v) {
- $ret[] = [ 'name' => $k, 'value' => $v ];
+ if ($arr) {
+ foreach ($arr as $k => $v) {
+ $ret[] = ['name' => $k, 'value' => $v];
}
}
return $ret;
@@ -170,15 +170,16 @@ class Permissions {
* @return boolean|array
*/
static public function FilledAutoperms($channel_id) {
- if(! intval(get_pconfig($channel_id,'system','autoperms')))
+ if (!intval(get_pconfig($channel_id, 'system', 'autoperms')))
return false;
$arr = [];
+
$r = q("select * from pconfig where uid = %d and cat = 'autoperms'",
intval($channel_id)
);
- if($r) {
- foreach($r as $rr) {
+ if ($r) {
+ foreach ($r as $rr) {
$arr[$rr['k']] = intval($rr['v']);
}
}
@@ -193,11 +194,11 @@ class Permissions {
* @return boolean true if all perms from $p1 exist also in $p2
*/
static public function PermsCompare($p1, $p2) {
- foreach($p1 as $k => $v) {
- if(! array_key_exists($k, $p2))
+ foreach ($p1 as $k => $v) {
+ if (!array_key_exists($k, $p2))
return false;
- if($p1[$k] != $p2[$k])
+ if ($p1[$k] != $p2[$k])
return false;
}
@@ -214,18 +215,18 @@ class Permissions {
*/
static public function connect_perms($channel_id) {
- $my_perms = [];
- $permcat = null;
+ $my_perms = [];
+ $permcat = null;
$automatic = 0;
// If a default permcat exists, use that
- $pc = ((feature_enabled($channel_id,'permcats')) ? get_pconfig($channel_id,'system','default_permcat') : 'default');
- if(! in_array($pc, [ '','default' ])) {
- $pcp = new Zlib\Permcat($channel_id);
+ $pc = ((feature_enabled($channel_id, 'permcats')) ? get_pconfig($channel_id, 'system', 'default_permcat') : 'default');
+ if (!in_array($pc, ['', 'default'])) {
+ $pcp = new Zlib\Permcat($channel_id);
$permcat = $pcp->fetch($pc);
- if($permcat && $permcat['perms']) {
- foreach($permcat['perms'] as $p) {
+ if ($permcat && $permcat['perms']) {
+ foreach ($permcat['perms'] as $p) {
$my_perms[$p['name']] = $p['value'];
}
}
@@ -235,15 +236,15 @@ class Permissions {
// and if there was no permcat or a default permcat, set the perms
// from the role
- $role = get_pconfig($channel_id,'system','permissions_role');
- if($role) {
+ $role = get_pconfig($channel_id, 'system', 'permissions_role');
+ if ($role) {
$xx = PermissionRoles::role_perms($role);
- if($xx['perms_auto'])
+ if ($xx['perms_auto'])
$automatic = 1;
- if((! $my_perms) && ($xx['perms_connect'])) {
+ if ((!$my_perms) && ($xx['perms_connect'])) {
$default_perms = $xx['perms_connect'];
- $my_perms = Permissions::FilledPerms($default_perms);
+ $my_perms = Permissions::FilledPerms($default_perms);
}
}
@@ -251,11 +252,11 @@ class Permissions {
// it is likely a custom permissions role. First see if there are any
// automatic permissions.
- if(! $my_perms) {
+ if (!$my_perms) {
$m = Permissions::FilledAutoperms($channel_id);
- if($m) {
+ if ($m) {
$automatic = 1;
- $my_perms = $m;
+ $my_perms = $m;
}
}
@@ -263,35 +264,35 @@ class Permissions {
// custom perms but they are not automatic. They will be stored in abconfig with
// the channel's channel_hash (the 'self' connection).
- if(! $my_perms) {
+ if (!$my_perms) {
$r = q("select channel_hash from channel where channel_id = %d",
intval($channel_id)
);
- if($r) {
+ if ($r) {
$x = q("select * from abconfig where chan = %d and xchan = '%s' and cat = 'my_perms'",
intval($channel_id),
dbesc($r[0]['channel_hash'])
);
- if($x) {
- foreach($x as $xv) {
+ if ($x) {
+ foreach ($x as $xv) {
$my_perms[$xv['k']] = intval($xv['v']);
}
}
}
}
- return ( [ 'perms' => $my_perms, 'automatic' => $automatic ] );
+ return (['perms' => $my_perms, 'automatic' => $automatic]);
}
static public function serialise($p) {
$n = [];
- if($p) {
- foreach($p as $k => $v) {
- if(intval($v)) {
+ if ($p) {
+ foreach ($p as $k => $v) {
+ if (intval($v)) {
$n[] = $k;
}
}
}
- return implode(',',$n);
+ return implode(',', $n);
}
}
diff --git a/Zotlabs/Daemon/Addon.php b/Zotlabs/Daemon/Addon.php
index c2889e596..c6778750d 100644
--- a/Zotlabs/Daemon/Addon.php
+++ b/Zotlabs/Daemon/Addon.php
@@ -2,13 +2,12 @@
namespace Zotlabs\Daemon;
-require_once('include/zot.php');
-
class Addon {
- static public function run($argc,$argv) {
+ static public function run($argc, $argv) {
- call_hooks('daemon_addon',$argv);
+ call_hooks('daemon_addon', $argv);
}
+
}
diff --git a/Zotlabs/Daemon/Cache_embeds.php b/Zotlabs/Daemon/Cache_embeds.php
index 08088abd6..9e5b8d2bb 100644
--- a/Zotlabs/Daemon/Cache_embeds.php
+++ b/Zotlabs/Daemon/Cache_embeds.php
@@ -2,7 +2,6 @@
namespace Zotlabs\Daemon;
-
class Cache_embeds {
static public function run($argc,$argv) {
diff --git a/Zotlabs/Daemon/Checksites.php b/Zotlabs/Daemon/Checksites.php
index 3bcfdd7cf..7227e96e4 100644
--- a/Zotlabs/Daemon/Checksites.php
+++ b/Zotlabs/Daemon/Checksites.php
@@ -6,34 +6,35 @@ require_once('include/hubloc.php');
class Checksites {
- static public function run($argc,$argv) {
+ static public function run($argc, $argv) {
logger('checksites: start');
-
- if(($argc > 1) && ($argv[1]))
+
+ if (($argc > 1) && ($argv[1]))
$site_id = $argv[1];
- if($site_id)
+ if ($site_id)
$sql_options = " and site_url = '" . dbesc($argv[1]) . "' ";
- $days = intval(get_config('system','sitecheckdays'));
- if($days < 1)
+ $days = intval(get_config('system', 'sitecheckdays'));
+ if ($days < 1)
$days = 30;
$r = q("select * from site where site_dead = 0 and site_update < %s - INTERVAL %s and site_type = %d $sql_options ",
- db_utcnow(), db_quoteinterval($days . ' DAY'),
+ db_utcnow(),
+ db_quoteinterval($days . ' DAY'),
intval(SITE_TYPE_ZOT)
);
- if(! $r)
+ if (!$r)
return;
- foreach($r as $rr) {
- if(! strcasecmp($rr['site_url'],z_root()))
+ foreach ($r as $rr) {
+ if (!strcasecmp($rr['site_url'], z_root()))
continue;
$x = ping_site($rr['site_url']);
- if($x['success']) {
+ if ($x['success']) {
logger('checksites: ' . $rr['site_url']);
q("update site set site_update = '%s' where site_url = '%s' ",
dbesc(datetime_convert()),
diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php
index 703d6ce08..e8fa3244f 100644
--- a/Zotlabs/Daemon/Cron.php
+++ b/Zotlabs/Daemon/Cron.php
@@ -6,14 +6,14 @@ use Zotlabs\Lib\Libsync;
class Cron {
- static public function run($argc,$argv) {
+ static public function run($argc, $argv) {
- $maxsysload = intval(get_config('system','maxloadavg'));
- if($maxsysload < 1)
+ $maxsysload = intval(get_config('system', 'maxloadavg'));
+ if ($maxsysload < 1)
$maxsysload = 50;
- if(function_exists('sys_getloadavg')) {
+ if (function_exists('sys_getloadavg')) {
$load = sys_getloadavg();
- if(intval($load[0]) > $maxsysload) {
+ if (intval($load[0]) > $maxsysload) {
logger('system: load ' . $load . ' too high. Cron deferred to next scheduled run.');
return;
}
@@ -21,17 +21,18 @@ class Cron {
// Check for a lockfile. If it exists, but is over an hour old, it's stale. Ignore it.
$lockfile = 'store/[data]/cron';
- if((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 3600))
- && (! get_config('system','override_cron_lockfile'))) {
+ if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 3600))
+ && (!get_config('system', 'override_cron_lockfile'))) {
logger("cron: Already running");
return;
}
-
+
// Create a lockfile. Needs two vars, but $x doesn't need to contain anything.
+ $x = '';
file_put_contents($lockfile, $x);
logger('cron: start');
-
+
// run queue delivery process in the background
Master::Summon(array('Queue'));
@@ -46,7 +47,7 @@ class Cron {
db_utcnow(),
db_quoteinterval('3 MINUTE')
);
-
+
// expire any expired mail
q("delete from mail where expires > '%s' and expires < %s ",
@@ -54,19 +55,23 @@ class Cron {
db_utcnow()
);
+ $interval = get_config('system', 'delivery_interval', 3);
+
// expire any expired items
$r = q("select id,item_wall from item where expires > '2001-01-01 00:00:00' and expires < %s
and item_deleted = 0 ",
db_utcnow()
);
- if($r) {
+ if ($r) {
require_once('include/items.php');
- foreach($r as $rr) {
- drop_item($rr['id'],false,(($rr['item_wall']) ? DROPITEM_PHASE1 : DROPITEM_NORMAL));
- if($rr['item_wall']) {
+ foreach ($r as $rr) {
+ drop_item($rr['id'], false, (($rr['item_wall']) ? DROPITEM_PHASE1 : DROPITEM_NORMAL));
+ if ($rr['item_wall']) {
// The notifier isn't normally invoked unless item_drop is interactive.
- Master::Summon( [ 'Notifier', 'drop', $rr['id'] ] );
+ Master::Summon(['Notifier', 'drop', $rr['id']]);
+ if ($interval)
+ @time_sleep_until(microtime(true) + (float)$interval);
}
}
}
@@ -78,9 +83,9 @@ class Cron {
dbesc(NULL_DATE),
db_utcnow()
);
- if($r) {
+ if ($r) {
require_once('include/security.php');
- foreach($r as $rr) {
+ foreach ($r as $rr) {
atoken_delete($rr['atoken_id']);
}
}
@@ -90,33 +95,33 @@ class Cron {
// or dead entries.
$r = q("select channel_id from channel where channel_dirdate < %s - INTERVAL %s and channel_removed = 0",
- db_utcnow(),
+ db_utcnow(),
db_quoteinterval('30 DAY')
);
- if($r) {
- foreach($r as $rr) {
- Master::Summon(array('Directory',$rr['channel_id'],'force'));
- if($interval)
- @time_sleep_until(microtime(true) + (float) $interval);
+ if ($r) {
+ foreach ($r as $rr) {
+ Master::Summon(array('Directory', $rr['channel_id'], 'force'));
+ if ($interval)
+ @time_sleep_until(microtime(true) + (float)$interval);
}
}
-
+
// Clean expired photos from cache
-
+
$r = q("SELECT DISTINCT xchan, content FROM photo WHERE photo_usage = %d AND expires < %s - INTERVAL %s",
intval(PHOTO_CACHE),
db_utcnow(),
- db_quoteinterval(get_config('system','active_expire_days', '30') . ' DAY')
+ db_quoteinterval(get_config('system', 'active_expire_days', '30') . ' DAY')
);
- if($r) {
+ if ($r) {
q("DELETE FROM photo WHERE photo_usage = %d AND expires < %s - INTERVAL %s",
intval(PHOTO_CACHE),
db_utcnow(),
- db_quoteinterval(get_config('system','active_expire_days', '30') . ' DAY')
+ db_quoteinterval(get_config('system', 'active_expire_days', '30') . ' DAY')
);
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$file = dbunescbin($rr['content']);
- if(is_file($file)) {
+ if (is_file($file)) {
@unlink($file);
@rmdir(dirname($file));
logger('info: deleted cached photo file ' . $file, LOGGER_DEBUG);
@@ -130,27 +135,29 @@ class Cron {
$r = q("select id from item where item_delayed = 1 and created <= %s and created > '%s' ",
db_utcnow(),
- dbesc(datetime_convert('UTC','UTC','now - 2 days'))
+ dbesc(datetime_convert('UTC', 'UTC', 'now - 2 days'))
);
- if($r) {
- foreach($r as $rr) {
+ if ($r) {
+ foreach ($r as $rr) {
$x = q("update item set item_delayed = 0 where id = %d",
intval($rr['id'])
);
- if($x) {
+ if ($x) {
$z = q("select * from item where id = %d",
- intval($message_id)
+ intval($rr['id'])
);
- if($z) {
+ if ($z) {
xchan_query($z);
$sync_item = fetch_post_tags($z);
Libsync::build_sync_packet($sync_item[0]['uid'],
- [
- 'item' => [ encode_item($sync_item[0],true) ]
+ [
+ 'item' => [encode_item($sync_item[0], true)]
]
);
}
- Master::Summon(array('Notifier','wall-new',$rr['id']));
+ Master::Summon(array('Notifier', 'wall-new', $rr['id']));
+ if ($interval)
+ @time_sleep_until(microtime(true) + (float)$interval);
}
}
}
@@ -163,27 +170,27 @@ class Cron {
require_once('include/attach.php');
attach_upgrade();
- $abandon_days = intval(get_config('system','account_abandon_days'));
- if($abandon_days < 1)
+ $abandon_days = intval(get_config('system', 'account_abandon_days'));
+ if ($abandon_days < 1)
$abandon_days = 0;
-
+
// once daily run birthday_updates and then expire in background
// FIXME: add birthday updates, both locally and for xprof for use
// by directory servers
- $d1 = intval(get_config('system','last_expire_day'));
- $d2 = intval(datetime_convert('UTC','UTC','now','d'));
+ $d1 = intval(get_config('system', 'last_expire_day'));
+ $d2 = intval(datetime_convert('UTC', 'UTC', 'now', 'd'));
// Allow somebody to staggger daily activities if they have more than one site on their server,
// or if it happens at an inconvenient (busy) hour.
- $h1 = intval(get_config('system','cron_hour'));
- $h2 = intval(datetime_convert('UTC','UTC','now','G'));
+ $h1 = intval(get_config('system', 'cron_hour'));
+ $h2 = intval(datetime_convert('UTC', 'UTC', 'now', 'G'));
- if(($d2 != $d1) && ($h1 == $h2)) {
+ if (($d2 != $d1) && ($h1 == $h2)) {
Master::Summon(array('Cron_daily'));
}
@@ -192,14 +199,14 @@ class Cron {
$r = q("select xchan_photo_l, xchan_hash from xchan where xchan_photo_l != '' and xchan_photo_m = ''
and xchan_photo_date < %s - INTERVAL %s",
- db_utcnow(),
+ db_utcnow(),
db_quoteinterval('1 DAY')
);
- if($r) {
+ if ($r) {
require_once('include/photo/photo_driver.php');
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$photos = import_xchan_photo($rr['xchan_photo_l'], $rr['xchan_hash'], false, true);
- $x = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s'
+ $x = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s'
where xchan_hash = '%s'",
dbesc($photos[0]),
dbesc($photos[1]),
@@ -213,18 +220,18 @@ class Cron {
// pull in some public posts
- $disable_discover_tab = get_config('system','disable_discover_tab') || get_config('system','disable_discover_tab') === false;
- if(! $disable_discover_tab)
+ $disable_discover_tab = get_config('system', 'disable_discover_tab') || get_config('system', 'disable_discover_tab') === false;
+ if (!$disable_discover_tab)
Master::Summon(array('Externals'));
$generation = 0;
- $restart = false;
+ $restart = false;
- if(($argc > 1) && ($argv[1] == 'restart')) {
- $restart = true;
+ if (($argc > 1) && ($argv[1] == 'restart')) {
+ $restart = true;
$generation = intval($argv[2]);
- if(! $generation)
+ if (!$generation)
return;
}
@@ -234,10 +241,10 @@ class Cron {
// TODO check to see if there are any cronhooks before wasting a process
- if(! $restart)
+ if (!$restart)
Master::Summon(array('Cronhooks'));
- set_config('system','lastcron',datetime_convert());
+ set_config('system', 'lastcron', datetime_convert());
//All done - clear the lockfile
@unlink($lockfile);
diff --git a/Zotlabs/Daemon/Cron_daily.php b/Zotlabs/Daemon/Cron_daily.php
index 07533cc6e..1983c68e6 100644
--- a/Zotlabs/Daemon/Cron_daily.php
+++ b/Zotlabs/Daemon/Cron_daily.php
@@ -2,9 +2,11 @@
namespace Zotlabs\Daemon;
+use Zotlabs\Lib\Libzotdir;
+
class Cron_daily {
- static public function run($argc,$argv) {
+ static public function run($argc, $argv) {
logger('cron_daily: start');
@@ -13,15 +15,12 @@ class Cron_daily {
*
*/
-
- require_once('include/dir_fns.php');
- check_upstream_directory();
-
+ Libzotdir::check_upstream_directory();
// Fire off the Cron_weekly process if it's the correct day.
-
- $d3 = intval(datetime_convert('UTC','UTC','now','N'));
- if($d3 == 7) {
+
+ $d3 = intval(datetime_convert('UTC', 'UTC', 'now', 'N'));
+ if ($d3 == 7) {
Master::Summon(array('Cron_weekly'));
}
@@ -52,8 +51,8 @@ class Cron_daily {
// Clean up emdedded content cache
q("DELETE FROM cache WHERE updated < %s - INTERVAL %s",
- db_utcnow(),
- db_quoteinterval(get_config('system','active_expire_days', '30') . ' DAY')
+ db_utcnow(),
+ db_quoteinterval(get_config('system', 'active_expire_days', '30') . ' DAY')
);
//update statistics in config
@@ -67,8 +66,8 @@ class Cron_daily {
// expire old delivery reports
- $keep_reports = intval(get_config('system','expire_delivery_reports'));
- if($keep_reports === 0)
+ $keep_reports = intval(get_config('system', 'expire_delivery_reports'));
+ if ($keep_reports === 0)
$keep_reports = 10;
q("delete from dreport where dreport_time < %s - INTERVAL %s",
@@ -80,18 +79,16 @@ class Cron_daily {
downgrade_accounts();
// If this is a directory server, request a sync with an upstream
- // directory at least once a day, up to once every poll interval.
+ // directory at least once a day, up to once every poll interval.
// Pull remote changes and push local changes.
- // potential issue: how do we keep from creating an endless update loop?
+ // potential issue: how do we keep from creating an endless update loop?
- $dirmode = get_config('system','directory_mode');
+ $dirmode = get_config('system', 'directory_mode');
- if($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) {
- require_once('include/dir_fns.php');
- sync_directories($dirmode);
+ if ($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) {
+ Libzotdir::sync_directories($dirmode);
}
-
Master::Summon(array('Expire'));
Master::Summon(array('Cli_suggest'));
@@ -99,9 +96,10 @@ class Cron_daily {
z6_discover();
- call_hooks('cron_daily',datetime_convert());
+ $date = datetime_convert();
+ call_hooks('cron_daily', $date);
- set_config('system','last_expire_day',intval(datetime_convert('UTC','UTC','now','d')));
+ set_config('system', 'last_expire_day', intval(datetime_convert('UTC', 'UTC', 'now', 'd')));
/**
* End Cron Daily
diff --git a/Zotlabs/Daemon/Cron_weekly.php b/Zotlabs/Daemon/Cron_weekly.php
index d44400767..407aa40ef 100644
--- a/Zotlabs/Daemon/Cron_weekly.php
+++ b/Zotlabs/Daemon/Cron_weekly.php
@@ -4,21 +4,22 @@ namespace Zotlabs\Daemon;
class Cron_weekly {
- static public function run($argc,$argv) {
+ static public function run($argc, $argv) {
/**
* Cron Weekly
- *
+ *
* Actions in the following block are executed once per day only on Sunday (once per week).
*
*/
- call_hooks('cron_weekly',datetime_convert());
+ $date = datetime_convert();
+ call_hooks('cron_weekly', $date);
z_check_cert();
prune_hub_reinstalls();
-
+
mark_orphan_hubsxchans();
// Find channels that were removed in the last three weeks, but
@@ -31,8 +32,8 @@ class Cron_weekly {
db_utcnow(), db_quoteinterval('21 DAY'),
db_utcnow(), db_quoteinterval('10 DAY')
);
- if($r) {
- foreach($r as $rv) {
+ if ($r) {
+ foreach ($r as $rv) {
channel_remove_final($rv['channel_id']);
}
}
@@ -43,14 +44,14 @@ class Cron_weekly {
db_utcnow(), db_quoteinterval('14 DAY')
);
- $dirmode = intval(get_config('system','directory_mode'));
- if($dirmode === DIRECTORY_MODE_SECONDARY || $dirmode === DIRECTORY_MODE_PRIMARY) {
- logger('regdir: ' . print_r(z_fetch_url(get_directory_primary() . '/regdir?f=&url=' . urlencode(z_root()) . '&realm=' . urlencode(get_directory_realm())),true));
+ $dirmode = intval(get_config('system', 'directory_mode'));
+ if ($dirmode === DIRECTORY_MODE_SECONDARY || $dirmode === DIRECTORY_MODE_PRIMARY) {
+ logger('regdir: ' . print_r(z_fetch_url(get_directory_primary() . '/regdir?f=&url=' . urlencode(z_root()) . '&realm=' . urlencode(get_directory_realm())), true));
}
// Check for dead sites
Master::Summon(array('Checksites'));
-
+
// update searchable doc indexes
Master::Summon(array('Importdoc'));
diff --git a/Zotlabs/Daemon/CurlAuth.php b/Zotlabs/Daemon/CurlAuth.php
index de41382e3..2396da9aa 100644
--- a/Zotlabs/Daemon/CurlAuth.php
+++ b/Zotlabs/Daemon/CurlAuth.php
@@ -2,6 +2,8 @@
namespace Zotlabs\Daemon;
+use App;
+
// generate a curl compatible cookie file with an authenticated session for the given channel_id.
// If this file is then used with curl and the destination url is sent through zid() or manually
// manipulated to add a zid, it should allow curl to provide zot magic-auth across domains.
@@ -10,15 +12,15 @@ namespace Zotlabs\Daemon;
class CurlAuth {
- static public function run($argc,$argv) {
+ static public function run($argc, $argv) {
- if($argc != 2)
+ if ($argc != 2)
return;
- \App::$session->start();
+ App::$session->start();
$_SESSION['authenticated'] = 1;
- $_SESSION['uid'] = $argv[1];
+ $_SESSION['uid'] = $argv[1];
$x = session_id();
@@ -29,14 +31,14 @@ class CurlAuth {
$output = '';
- if($e) {
+ if ($e) {
$lines = file($f);
- if($lines) {
- foreach($lines as $line) {
- if(strlen($line) > 0 && $line[0] != '#' && substr_count($line, "\t") == 6) {
+ if ($lines) {
+ foreach ($lines as $line) {
+ if (strlen($line) > 0 && $line[0] != '#' && substr_count($line, "\t") == 6) {
$tokens = explode("\t", $line);
$tokens = array_map('trim', $tokens);
- if($tokens[4] > time()) {
+ if ($tokens[4] > time()) {
$output .= $line . "\n";
}
}
@@ -46,9 +48,9 @@ class CurlAuth {
}
}
$t = time() + (24 * 3600);
- file_put_contents($f, $output . 'HttpOnly_' . \App::get_hostname() . "\tFALSE\t/\tTRUE\t$t\tPHPSESSID\t" . $x, (($e) ? FILE_APPEND : 0));
+ file_put_contents($f, $output . 'HttpOnly_' . App::get_hostname() . "\tFALSE\t/\tTRUE\t$t\tPHPSESSID\t" . $x, (($e) ? FILE_APPEND : 0));
- file_put_contents($c,$x);
+ file_put_contents($c, $x);
return;
}
diff --git a/Zotlabs/Daemon/Deliver.php b/Zotlabs/Daemon/Deliver.php
index c853af6a8..f8149ee69 100644
--- a/Zotlabs/Daemon/Deliver.php
+++ b/Zotlabs/Daemon/Deliver.php
@@ -5,25 +5,25 @@ namespace Zotlabs\Daemon;
require_once('include/queue_fn.php');
class Deliver {
-
- static public function run($argc,$argv) {
- if($argc < 2)
+ static public function run($argc, $argv) {
+
+ if ($argc < 2)
return;
- logger('deliver: invoked: ' . print_r($argv,true), LOGGER_DATA);
+ logger('deliver: invoked: ' . print_r($argv, true), LOGGER_DATA);
- for($x = 1; $x < $argc; $x ++) {
+ for ($x = 1; $x < $argc; $x++) {
- if(! $argv[$x])
+ if (!$argv[$x])
continue;
$r = q("select * from outq where outq_hash = '%s'",
dbesc($argv[$x])
);
- if($r) {
- queue_deliver($r[0],true);
+ if ($r) {
+ queue_deliver($r[0], true);
}
}
diff --git a/Zotlabs/Daemon/Deliver_hooks.php b/Zotlabs/Daemon/Deliver_hooks.php
index e8b5acef0..4d3ce4e1d 100644
--- a/Zotlabs/Daemon/Deliver_hooks.php
+++ b/Zotlabs/Daemon/Deliver_hooks.php
@@ -2,21 +2,18 @@
namespace Zotlabs\Daemon;
-require_once('include/zot.php');
-
class Deliver_hooks {
- static public function run($argc,$argv) {
+ static public function run($argc, $argv) {
- if($argc < 2)
+ if ($argc < 2)
return;
-
$r = q("select * from item where id = '%d'",
intval($argv[1])
);
- if($r)
- call_hooks('notifier_normal',$r[0]);
+ if ($r)
+ call_hooks('notifier_normal', $r[0]);
}
}
diff --git a/Zotlabs/Daemon/Directory.php b/Zotlabs/Daemon/Directory.php
index ab58432de..1f307b273 100644
--- a/Zotlabs/Daemon/Directory.php
+++ b/Zotlabs/Daemon/Directory.php
@@ -8,40 +8,40 @@ use Zotlabs\Lib\Queue;
class Directory {
- static public function run($argc,$argv){
+ static public function run($argc, $argv) {
- if($argc < 2)
+ if ($argc < 2)
return;
- $force = false;
+ $force = false;
$pushall = true;
- if($argc > 2) {
- if($argv[2] === 'force')
+ if ($argc > 2) {
+ if ($argv[2] === 'force')
$force = true;
- if($argv[2] === 'nopush')
+ if ($argv[2] === 'nopush')
$pushall = false;
- }
+ }
logger('directory update', LOGGER_DEBUG);
- $dirmode = get_config('system','directory_mode');
- if($dirmode === false)
+ $dirmode = get_config('system', 'directory_mode');
+ if ($dirmode === false)
$dirmode = DIRECTORY_MODE_NORMAL;
$x = q("select * from channel where channel_id = %d limit 1",
intval($argv[1])
);
- if(! $x)
+ if (!$x)
return;
$channel = $x[0];
- if($dirmode != DIRECTORY_MODE_NORMAL) {
+ if ($dirmode != DIRECTORY_MODE_NORMAL) {
// this is an in-memory update and we don't need to send a network packet.
- Libzotdir::local_dir_update($argv[1],$force);
+ Libzotdir::local_dir_update($argv[1], $force);
q("update channel set channel_dirdate = '%s' where channel_id = %d",
dbesc(datetime_convert()),
@@ -49,8 +49,8 @@ class Directory {
);
// Now update all the connections
- if($pushall)
- Master::Summon(array('Notifier','refresh_all',$channel['channel_id']));
+ if ($pushall)
+ Master::Summon(array('Notifier', 'refresh_all', $channel['channel_id']));
return;
}
@@ -63,14 +63,12 @@ class Directory {
// ensure the upstream directory is updated
-
- $packet = Libzot::build_packet($channel,(($force) ? 'force_refresh' : 'refresh'));
- $z = Libzot::zot($url,$packet,$channel);
-
+ $packet = Libzot::build_packet($channel, (($force) ? 'force_refresh' : 'refresh'));
+ $z = Libzot::zot($url, $packet, $channel);
// re-queue if unsuccessful
- if(! $z['success']) {
+ if (!$z['success']) {
/** @FIXME we aren't updating channel_dirdate if we have to queue
* the directory packet. That means we'll try again on the next poll run.
@@ -95,8 +93,8 @@ class Directory {
}
// Now update all the connections
- if($pushall)
- Master::Summon(array('Notifier','refresh_all',$channel['channel_id']));
+ if ($pushall)
+ Master::Summon(array('Notifier', 'refresh_all', $channel['channel_id']));
}
}
diff --git a/Zotlabs/Daemon/Expire.php b/Zotlabs/Daemon/Expire.php
index a688d6f97..8ca92b6c5 100644
--- a/Zotlabs/Daemon/Expire.php
+++ b/Zotlabs/Daemon/Expire.php
@@ -5,23 +5,24 @@ namespace Zotlabs\Daemon;
class Expire {
- static public function run($argc,$argv){
+ static public function run($argc, $argv) {
cli_startup();
-
+
$pid = get_config('expire', 'procid', false);
if ($pid && (function_exists('posix_kill') ? posix_kill($pid, 0) : true)) {
- logger('Expire: procedure already run with pid ' . $pid, LOGGER_DEBUG);
- return;
+ logger('Expire: procedure already run with pid ' . $pid, LOGGER_DEBUG);
+ return;
}
-
+
$pid = getmypid();
set_config('expire', 'procid', $pid);
// perform final cleanup on previously delete items
$r = q("select id from item where item_deleted = 1 and item_pending_remove = 0 and changed < %s - INTERVAL %s",
- db_utcnow(), db_quoteinterval('10 DAY')
+ db_utcnow(),
+ db_quoteinterval('10 DAY')
);
if ($r) {
foreach ($r as $rr) {
@@ -32,23 +33,22 @@ class Expire {
// physically remove anything that has been deleted for more than two months
/** @FIXME - this is a wretchedly inefficient query */
- $r = q("delete from item where item_pending_remove = 1 and changed < %s - INTERVAL %s",
- db_utcnow(), db_quoteinterval('36 DAY')
+ q("delete from item where item_pending_remove = 1 and changed < %s - INTERVAL %s",
+ db_utcnow(),
+ db_quoteinterval('36 DAY')
);
- /** @FIXME make this optional as it could have a performance impact on large sites */
-
if (intval(get_config('system', 'optimize_items')))
q("optimize table item");
logger('expire: start with pid ' . $pid, LOGGER_DEBUG);
- $site_expire = intval(get_config('system', 'default_expire_days'));
- $commented_days = intval(get_config('system','active_expire_days'));
+ $site_expire = intval(get_config('system', 'default_expire_days'));
+ $commented_days = intval(get_config('system', 'active_expire_days'));
logger('site_expire: ' . $site_expire);
- $r = q("SELECT channel_id, channel_system, channel_address, channel_expire_days from channel where true");
+ $r = dbq("SELECT channel_id, channel_system, channel_address, channel_expire_days from channel where true");
if ($r) {
foreach ($r as $rr) {
@@ -64,11 +64,12 @@ class Expire {
$channel_expire = $service_class_expire;
else
$channel_expire = $site_expire;
-
+
if (intval($channel_expire) && (intval($channel_expire) < intval($rr['channel_expire_days'])) ||
intval($rr['channel_expire_days'] == 0)) {
$expire_days = $channel_expire;
- } else {
+ }
+ else {
$expire_days = $rr['channel_expire_days'];
}
@@ -93,13 +94,13 @@ class Expire {
}
logger('Expire: sys interval: ' . $expire_days, LOGGER_DEBUG);
-
+
if ($expire_days)
item_expire($x['channel_id'], $expire_days, $commented_days);
logger('Expire: sys: done', LOGGER_DEBUG);
}
-
+
del_config('expire', 'procid');
}
}
diff --git a/Zotlabs/Daemon/Externals.php b/Zotlabs/Daemon/Externals.php
index a9988a509..b657f9de4 100644
--- a/Zotlabs/Daemon/Externals.php
+++ b/Zotlabs/Daemon/Externals.php
@@ -8,23 +8,22 @@ require_once('include/channel.php');
class Externals {
- static public function run($argc,$argv){
+ static public function run($argc, $argv) {
- $total = 0;
+ $total = 0;
$attempts = 0;
logger('externals: startup', LOGGER_DEBUG);
// pull in some public posts
+ while ($total == 0 && $attempts < 3) {
+ $arr = ['url' => ''];
+ call_hooks('externals_url_select', $arr);
- while($total == 0 && $attempts < 3) {
- $arr = array('url' => '');
- call_hooks('externals_url_select',$arr);
-
- if($arr['url']) {
+ if ($arr['url']) {
$url = $arr['url'];
- }
+ }
else {
$randfunc = db_getfunc('RAND');
@@ -35,36 +34,36 @@ class Externals {
intval(DIRECTORY_MODE_STANDALONE),
intval(SITE_TYPE_ZOT)
);
- if($r)
+ if ($r)
$url = $r[0]['site_url'];
}
$blacklisted = false;
- if(! check_siteallowed($url)) {
+ if (!check_siteallowed($url)) {
logger('blacklisted site: ' . $url);
$blacklisted = true;
}
- $attempts ++;
+ $attempts++;
// make sure we can eventually break out if somebody blacklists all known sites
- if($blacklisted) {
- if($attempts > 20)
+ if ($blacklisted) {
+ if ($attempts > 20)
break;
- $attempts --;
+ $attempts--;
continue;
}
- if($url) {
- if($r[0]['site_pull'] > NULL_DATE)
- $mindate = urlencode(datetime_convert('','',$r[0]['site_pull'] . ' - 1 day'));
+ if ($url) {
+ if ($r[0]['site_pull'] > NULL_DATE)
+ $mindate = urlencode(datetime_convert('', '', $r[0]['site_pull'] . ' - 1 day'));
else {
- $days = get_config('externals','since_days');
- if($days === false)
+ $days = get_config('externals', 'since_days');
+ if ($days === false)
$days = 15;
- $mindate = urlencode(datetime_convert('','','now - ' . intval($days) . ' days'));
+ $mindate = urlencode(datetime_convert('', '', 'now - ' . intval($days) . ' days'));
}
$feedurl = $url . '/zotfeed?f=&mindate=' . $mindate;
@@ -72,22 +71,22 @@ class Externals {
logger('externals: pulling public content from ' . $feedurl, LOGGER_DEBUG);
$x = z_fetch_url($feedurl);
- if(($x) && ($x['success'])) {
+ if (($x) && ($x['success'])) {
q("update site set site_pull = '%s' where site_url = '%s'",
dbesc(datetime_convert()),
dbesc($url)
);
- $j = json_decode($x['body'],true);
- if($j['success'] && $j['messages']) {
+ $j = json_decode($x['body'], true);
+ if ($j['success'] && $j['messages']) {
$sys = get_sys_channel();
- foreach($j['messages'] as $message) {
+ foreach ($j['messages'] as $message) {
// on these posts, clear any route info.
$message['route'] = '';
- $results = process_delivery(array('hash' => 'undefined'), get_item_elements($message),
- array(array('hash' => $sys['xchan_hash'])), false, true);
- $total ++;
+ process_delivery(['hash' => 'undefined'], get_item_elements($message),
+ [['hash' => $sys['xchan_hash']]], false, true);
+ $total++;
}
logger('externals: import_public_posts: ' . $total . ' messages imported', LOGGER_DEBUG);
}
diff --git a/Zotlabs/Daemon/Gprobe.php b/Zotlabs/Daemon/Gprobe.php
index 9e74eb8b5..29efcf475 100644
--- a/Zotlabs/Daemon/Gprobe.php
+++ b/Zotlabs/Daemon/Gprobe.php
@@ -9,27 +9,27 @@ use Zotlabs\Lib\Zotfinger;
// performs zot_finger on $argv[1], which is a hex_encoded webbie/reddress
class Gprobe {
- static public function run($argc,$argv) {
+ static public function run($argc, $argv) {
- if($argc != 2)
+ if ($argc != 2)
return;
$url = hex2bin($argv[1]);
- if(! strpos($url,'@'))
+ if (!strpos($url, '@'))
return;
$r = q("select * from hubloc where hubloc_addr = '%s' and hubloc_network = 'zot6' limit 1",
dbesc($url)
);
- if(! $r) {
+ if (!$r) {
$href = Webfinger::zot_url(punify($url));
- if($href) {
+ if ($href) {
$zf = Zotfinger::exec($href, null);
}
- if(is_array($zf) && array_path_exists('signature/signer',$zf) && $zf['signature']['signer'] === $href && intval($zf['signature']['header_valid'])) {
- $xc = Libzot::import_xchan($zf['data']);
+ if (is_array($zf) && array_path_exists('signature/signer', $zf) && $zf['signature']['signer'] === $href && intval($zf['signature']['header_valid'])) {
+ Libzot::import_xchan($zf['data']);
}
}
diff --git a/Zotlabs/Daemon/Importdoc.php b/Zotlabs/Daemon/Importdoc.php
index 0ca589e4a..9e818e2b3 100755
--- a/Zotlabs/Daemon/Importdoc.php
+++ b/Zotlabs/Daemon/Importdoc.php
@@ -5,7 +5,7 @@ namespace Zotlabs\Daemon;
class Importdoc {
- static public function run($argc,$argv) {
+ static public function run($argc, $argv) {
require_once('include/help.php');
@@ -16,20 +16,20 @@ class Importdoc {
static public function update_docs_dir($s) {
$f = basename($s);
$d = dirname($s);
- if($s === 'doc/html')
+ if ($s === 'doc/html')
return;
$files = glob("$d/$f");
- if($files) {
- foreach($files as $fi) {
- if($fi === 'doc/html') {
+ if ($files) {
+ foreach ($files as $fi) {
+ if ($fi === 'doc/html') {
continue;
}
- if(is_dir($fi)) {
+ if (is_dir($fi)) {
self::update_docs_dir("$fi/*");
}
else {
// don't update media content
- if(strpos(z_mime_content_type($fi),'text') === 0) {
+ if (strpos(z_mime_content_type($fi), 'text') === 0) {
store_doc_file($fi);
}
}
diff --git a/Zotlabs/Daemon/Importfile.php b/Zotlabs/Daemon/Importfile.php
index 749949679..299fb1ee5 100644
--- a/Zotlabs/Daemon/Importfile.php
+++ b/Zotlabs/Daemon/Importfile.php
@@ -6,22 +6,21 @@ use Zotlabs\Lib\Libsync;
class Importfile {
- static public function run($argc,$argv){
+ static public function run($argc, $argv) {
- logger('Importfile: ' . print_r($argv,true));
+ logger('Importfile: ' . print_r($argv, true));
- if($argc < 3)
+ if ($argc < 3)
return;
$channel = channelx_by_n($argv[1]);
- if(! $channel)
+ if (!$channel)
return;
$srcfile = $argv[2];
$folder = (($argc > 3) ? $argv[3] : '');
$dstname = (($argc > 4) ? $argv[4] : '');
-
- $hash = random_string();
+ $hash = random_string();
$arr = [
'src' => $srcfile,
@@ -35,15 +34,15 @@ class Importfile {
'replace' => true
];
- if($folder)
+ if ($folder)
$arr['folder'] = $folder;
- attach_store($channel,$channel['channel_hash'],'import',$arr);
+ attach_store($channel, $channel['channel_hash'], 'import', $arr);
+
+ $sync = attach_export_data($channel, $hash);
+ if ($sync)
+ Libsync::build_sync_packet($channel['channel_id'], ['file' => [$sync]]);
- $sync = attach_export_data($channel,$hash);
- if($sync)
- Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync)));
-
return;
}
}
diff --git a/Zotlabs/Daemon/Master.php b/Zotlabs/Daemon/Master.php
index 8c3a7e570..6fa656be5 100644
--- a/Zotlabs/Daemon/Master.php
+++ b/Zotlabs/Daemon/Master.php
@@ -2,58 +2,57 @@
namespace Zotlabs\Daemon;
-if(array_search( __file__ , get_included_files()) === 0) {
+if (array_search(__file__, get_included_files()) === 0) {
require_once('include/cli_startup.php');
array_shift($argv);
$argc = count($argv);
- if($argc)
- Master::Release($argc,$argv);
+ if ($argc)
+ Master::Release($argc, $argv);
return;
}
-
class Master {
static public function Summon($arr) {
$hookinfo = [
- 'argv'=>$arr
+ 'argv' => $arr
];
- call_hooks ('daemon_master_summon',$hookinfo);
+ call_hooks('daemon_master_summon', $hookinfo);
- $arr = $hookinfo['argv'];
+ $arr = $hookinfo['argv'];
$argc = count($arr);
- if ((!is_array($arr) || (count($arr) < 1))) {
- logger("Summon handled by hook.",LOGGER_DEBUG);
+ if ((!is_array($arr) || ($argc < 1))) {
+ logger("Summon handled by hook.", LOGGER_DEBUG);
return;
}
- $phpbin = get_config('system','phpbin','php');
- proc_run($phpbin,'Zotlabs/Daemon/Master.php',$arr);
+ $phpbin = get_config('system', 'phpbin', 'php');
+ proc_run($phpbin, 'Zotlabs/Daemon/Master.php', $arr);
}
- static public function Release($argc,$argv) {
+ static public function Release($argc, $argv) {
cli_startup();
$hookinfo = [
- 'argv'=>$argv
+ 'argv' => $argv
];
- call_hooks ('daemon_master_release',$hookinfo);
+ call_hooks('daemon_master_release', $hookinfo);
$argv = $hookinfo['argv'];
$argc = count($argv);
- if ((!is_array($argv) || (count($argv) < 1))) {
- logger("Release handled by hook.",LOGGER_DEBUG);
+ if ((!is_array($argv) || ($argc < 1))) {
+ logger("Release handled by hook.", LOGGER_DEBUG);
return;
}
- logger('Master: release: ' . json_encode($argv), LOGGER_ALL,LOG_DEBUG);
- $cls = '\\Zotlabs\\Daemon\\' . $argv[0];
- $cls::run($argc,$argv);
+ logger('Master: release: ' . json_encode($argv), LOGGER_ALL, LOG_DEBUG);
+ $cls = '\\Zotlabs\\Daemon\\' . $argv[0];
+ $cls::run($argc, $argv);
}
}
diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php
index 18fc57118..78e116d68 100644
--- a/Zotlabs/Daemon/Notifier.php
+++ b/Zotlabs/Daemon/Notifier.php
@@ -14,7 +14,6 @@ require_once('include/items.php');
require_once('include/bbcode.php');
-
/*
* This file was at one time responsible for doing all deliveries, but this caused
* big problems on shared hosting systems, where the process might get killed by the
@@ -81,198 +80,198 @@ require_once('include/bbcode.php');
*/
-
class Notifier {
- static public function run($argc,$argv){
+ static public function run($argc, $argv) {
- if($argc < 3)
+ if ($argc < 3)
return;
- logger('notifier: invoked: ' . print_r($argv,true), LOGGER_DEBUG);
+ logger('notifier: invoked: ' . print_r($argv, true), LOGGER_DEBUG);
$cmd = $argv[1];
$item_id = $argv[2];
- if(! $item_id)
+ if (!$item_id)
return;
$sys = get_sys_channel();
- $deliveries = array();
+ $deliveries = [];
- $request = false;
- $mail = false;
- $top_level = false;
- $location = false;
- $recipients = array();
- $url_recipients = array();
- $normal_mode = true;
- $packet_type = 'undefined';
+ $request = false;
+ $mail = false;
+ $location = false;
+ $recipients = [];
+ $normal_mode = true;
+ $packet_type = 'undefined';
- if($cmd === 'mail' || $cmd === 'single_mail') {
+ if ($cmd === 'mail' || $cmd === 'single_mail') {
$normal_mode = false;
- $mail = true;
- $private = true;
- $message = q("SELECT * FROM mail WHERE id = %d LIMIT 1",
- intval($item_id)
+ $mail = true;
+ $private = true;
+ $message = q("SELECT * FROM mail WHERE id = %d LIMIT 1",
+ intval($item_id)
);
- if(! $message) {
+ if (!$message) {
return;
}
xchan_mail_query($message[0]);
- $uid = $message[0]['channel_id'];
+ $uid = $message[0]['channel_id'];
$recipients[] = $message[0]['from_xchan']; // include clones
$recipients[] = $message[0]['to_xchan'];
- $item = $message[0];
-
+ $item = $message[0];
$encoded_item = encode_mail($item);
$s = q("select * from channel where channel_id = %d limit 1",
- intval($item['channel_id'])
+ intval($uid)
);
- if($s)
+ if ($s)
$channel = $s[0];
}
- elseif($cmd === 'request') {
- $channel_id = $item_id;
- $xchan = $argv[3];
+ elseif ($cmd === 'request') {
+ $channel_id = $item_id;
+ $xchan = $argv[3];
$request_message_id = $argv[4];
$s = q("select * from channel where channel_id = %d limit 1",
intval($channel_id)
);
- if($s)
+ if ($s)
$channel = $s[0];
- $private = true;
+ $private = true;
$recipients[] = $xchan;
- $packet_type = 'request';
- $normal_mode = false;
+ $packet_type = 'request';
+ $normal_mode = false;
}
- elseif($cmd === 'keychange') {
+ elseif ($cmd === 'keychange') {
$channel = channelx_by_n($item_id);
- $r = q("select abook_xchan from abook where abook_channel = %d",
+
+ $r = q("select abook_xchan from abook where abook_channel = %d",
intval($item_id)
);
- if($r) {
- foreach($r as $rr) {
+ if ($r) {
+ foreach ($r as $rr) {
$recipients[] = $rr['abook_xchan'];
}
}
- $private = false;
+ $private = false;
$packet_type = 'keychange';
$normal_mode = false;
}
- elseif(in_array($cmd, [ 'permission_update', 'permission_reject', 'permission_accept', 'permission_create' ])) {
+ elseif (in_array($cmd, ['permission_update', 'permission_reject', 'permission_accept', 'permission_create'])) {
// Get the (single) recipient
$r = q("select * from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_self = 0",
intval($item_id)
);
- if($r) {
+ if ($r) {
$uid = $r[0]['abook_channel'];
// Get the sender
$channel = channelx_by_n($uid);
- if($channel) {
- $perm_update = array('sender' => $channel, 'recipient' => $r[0], 'success' => false, 'deliveries' => '');
-
- if($cmd === 'permission_create')
- call_hooks('permissions_create',$perm_update);
- elseif($cmd === 'permission_accept')
- call_hooks('permissions_accept',$perm_update);
- elseif($cmd === 'permission_reject')
- call_hooks('permissions_reject',$perm_update);
+ if ($channel) {
+ $perm_update = ['sender' => $channel, 'recipient' => $r[0], 'success' => false, 'deliveries' => ''];
+
+ if ($cmd === 'permission_create')
+ call_hooks('permissions_create', $perm_update);
+ elseif ($cmd === 'permission_accept')
+ call_hooks('permissions_accept', $perm_update);
+ elseif ($cmd === 'permission_reject')
+ call_hooks('permissions_reject', $perm_update);
else
- call_hooks('permissions_update',$perm_update);
+ call_hooks('permissions_update', $perm_update);
- if($perm_update['success']) {
- if($perm_update['deliveries']) {
+ if ($perm_update['success']) {
+ if ($perm_update['deliveries']) {
$deliveries[] = $perm_update['deliveries'];
do_delivery($deliveries);
}
return;
}
else {
- $recipients[] = $r[0]['abook_xchan'];
- $private = false;
- $packet_type = 'refresh';
- $packet_recips = array(array('guid' => $r[0]['xchan_guid'],'guid_sig' => $r[0]['xchan_guid_sig'],'hash' => $r[0]['xchan_hash']));
+ $recipients[] = $r[0]['abook_xchan'];
+ $private = false;
+ $packet_type = 'refresh';
+ $packet_recips = [['guid' => $r[0]['xchan_guid'], 'guid_sig' => $r[0]['xchan_guid_sig'], 'hash' => $r[0]['xchan_hash']]];
}
}
}
}
- elseif($cmd === 'refresh_all') {
+ elseif ($cmd === 'refresh_all') {
logger('notifier: refresh_all: ' . $item_id);
- $uid = $item_id;
+ $uid = $item_id;
$channel = channelx_by_n($item_id);
- $r = q("select abook_xchan from abook where abook_channel = %d",
- intval($item_id)
+
+ $r = q("select abook_xchan from abook where abook_channel = %d",
+ intval($uid)
);
- if($r) {
- foreach($r as $rr) {
+ if ($r) {
+ foreach ($r as $rr) {
$recipients[] = $rr['abook_xchan'];
}
}
- $private = false;
+ $private = false;
$packet_type = 'refresh';
}
- elseif($cmd === 'location') {
+ elseif ($cmd === 'location') {
logger('notifier: location: ' . $item_id);
$s = q("select * from channel where channel_id = %d limit 1",
intval($item_id)
);
- if($s)
+ if ($s)
$channel = $s[0];
- $uid = $item_id;
- $recipients = array();
- $r = q("select abook_xchan from abook where abook_channel = %d",
- intval($item_id)
+
+ $uid = $item_id;
+ $recipients = [];
+
+ $r = q("select abook_xchan from abook where abook_channel = %d",
+ intval($uid)
);
- if($r) {
- foreach($r as $rr) {
+ if ($r) {
+ foreach ($r as $rr) {
$recipients[] = $rr['abook_xchan'];
}
}
- $encoded_item = array('locations' => Libzot::encode_locations($channel),'type' => 'location', 'encoding' => 'zot');
- $target_item = array('aid' => $channel['channel_account_id'],'uid' => $channel['channel_id']);
- $private = false;
- $packet_type = 'location';
- $location = true;
+ $encoded_item = ['locations' => Libzot::encode_locations($channel), 'type' => 'location', 'encoding' => 'zot'];
+ $target_item = ['aid' => $channel['channel_account_id'], 'uid' => $channel['channel_id']];
+ $private = false;
+ $packet_type = 'location';
+ $location = true;
}
- elseif($cmd === 'purge') {
+ elseif ($cmd === 'purge') {
$xchan = $argv[3];
logger('notifier: purge: ' . $item_id . ' => ' . $xchan);
- if (! $xchan) {
+ if (!$xchan) {
return;
}
- $channel = channelx_by_n($item_id);
- $recipients[] = $xchan;
- $private = true;
- $packet_type = 'purge';
+ $channel = channelx_by_n($item_id);
+ $recipients[] = $xchan;
+ $private = true;
+ $packet_type = 'purge';
$packet_recips[] = ['hash' => $xchan];
}
- elseif($cmd === 'purge_all') {
+ elseif ($cmd === 'purge_all') {
logger('notifier: purge_all: ' . $item_id);
$channel = channelx_by_n($item_id);
$recipients = [];
- $r = q("select abook_xchan from abook where abook_channel = %d and abook_self = 0",
+ $r = q("select abook_xchan from abook where abook_channel = %d and abook_self = 0",
intval($item_id)
);
- if (! $r) {
+ if (!$r) {
return;
}
foreach ($r as $rr) {
- $recipients[] = $rr['abook_xchan'];
+ $recipients[] = $rr['abook_xchan'];
$packet_recips[] = ['hash' => $rr['abook_xchan']];
}
- $private = false;
+ $private = false;
$packet_type = 'purge';
@@ -287,7 +286,7 @@ class Notifier {
intval($item_id)
);
- if(! $r)
+ if (!$r)
return;
xchan_query($r);
@@ -296,25 +295,22 @@ class Notifier {
$target_item = $r[0];
- if(in_array($target_item['author']['xchan_network'], ['rss', 'anon'])) {
+ if (in_array($target_item['author']['xchan_network'], ['rss', 'anon'])) {
logger('notifier: target item author is not a fetchable actor', LOGGER_DEBUG);
return;
}
- $deleted_item = false;
-
- if(intval($target_item['item_deleted'])) {
+ if (intval($target_item['item_deleted'])) {
logger('notifier: target item ITEM_DELETED', LOGGER_DEBUG);
- $deleted_item = true;
}
- if(! in_array(intval($target_item['item_type']), [ ITEM_TYPE_POST ] )) {
- $hookinfo=[
- 'targetitem'=>$target_item,
- 'deliver'=>false
+ if (!in_array(intval($target_item['item_type']), [ITEM_TYPE_POST])) {
+ $hookinfo = [
+ 'targetitem' => $target_item,
+ 'deliver' => false
];
if (intval($target_item['item_type'] == ITEM_TYPE_CUSTOM)) {
- call_hooks('customitem_deliver',$hookinfo);
+ call_hooks('customitem_deliver', $hookinfo);
}
if (!$hookinfo['deliver']) {
@@ -328,14 +324,14 @@ class Notifier {
// Check for non published items, but allow an exclusion for transmitting hidden file activities
- if(intval($target_item['item_unpublished']) || intval($target_item['item_delayed']) ||
+ if (intval($target_item['item_unpublished']) || intval($target_item['item_delayed']) ||
intval($target_item['item_blocked']) ||
- ( intval($target_item['item_hidden']) && ($target_item['obj_type'] !== ACTIVITY_OBJ_FILE))) {
+ (intval($target_item['item_hidden']) && ($target_item['obj_type'] !== ACTIVITY_OBJ_FILE))) {
logger('notifier: target item not published, so not forwardable', LOGGER_DEBUG);
return;
}
- if(strpos($target_item['postopts'],'nodeliver') !== false) {
+ if (strpos($target_item['postopts'], 'nodeliver') !== false) {
logger('notifier: target item is undeliverable', LOGGER_DEBUG);
return;
}
@@ -343,17 +339,17 @@ class Notifier {
$s = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d limit 1",
intval($target_item['uid'])
);
- if($s)
+ if ($s)
$channel = $s[0];
- if($channel['channel_hash'] !== $target_item['author_xchan'] && $channel['channel_hash'] !== $target_item['owner_xchan']) {
+ if ($channel['channel_hash'] !== $target_item['author_xchan'] && $channel['channel_hash'] !== $target_item['owner_xchan']) {
logger("notifier: Sending channel {$channel['channel_hash']} is not owner {$target_item['owner_xchan']} or author {$target_item['author_xchan']}", LOGGER_NORMAL, LOG_WARNING);
return;
}
- if($target_item['mid'] === $target_item['parent_mid']) {
- $parent_item = $target_item;
+ if ($target_item['mid'] === $target_item['parent_mid']) {
+ $parent_item = $target_item;
$top_level_post = true;
}
else {
@@ -362,10 +358,10 @@ class Notifier {
intval($target_item['parent'])
);
- if(! $r)
+ if (!$r)
return;
- if(strpos($r[0]['postopts'],'nodeliver') !== false) {
+ if (strpos($r[0]['postopts'], 'nodeliver') !== false) {
logger('notifier: target item is undeliverable', LOGGER_DEBUG, LOG_NOTICE);
return;
}
@@ -373,34 +369,34 @@ class Notifier {
xchan_query($r);
$r = fetch_post_tags($r);
- $parent_item = $r[0];
+ $parent_item = $r[0];
$top_level_post = false;
}
// avoid looping of discover items 12/4/2014
- if($sys && $parent_item['uid'] == $sys['channel_id'])
+ if ($sys && $parent_item['uid'] == $sys['channel_id'])
return;
$encoded_item = encode_item($target_item);
// Re-use existing signature unless the activity type changed to a Tombstone, which won't verify.
- $m = ((intval($target_item['item_deleted'])) ? '' : get_iconfig($target_item,'activitystreams','signed_data'));
+ $m = ((intval($target_item['item_deleted'])) ? '' : get_iconfig($target_item, 'activitystreams', 'signed_data'));
- if($m) {
- $activity = json_decode($m,true);
+ if ($m) {
+ $activity = json_decode($m, true);
}
else {
$activity = array_merge(['@context' => [
ACTIVITYSTREAMS_JSONLD_REV,
'https://w3id.org/security/v1',
z_root() . ZOT_APSCHEMA_REV
- ]], Activity::encode_activity($target_item)
+ ]], Activity::encode_activity($target_item)
);
}
- logger('target_item: ' . print_r($target_item,true), LOGGER_DEBUG);
- logger('encoded: ' . print_r($activity,true), LOGGER_DEBUG);
+ logger('target_item: ' . print_r($target_item, true), LOGGER_DEBUG);
+ logger('encoded: ' . print_r($activity, true), LOGGER_DEBUG);
// Send comments to the owner to re-deliver to everybody in the conversation
// We only do this if the item in question originated on this site. This prevents looping.
@@ -411,9 +407,7 @@ class Notifier {
// flag on comments for an extended period. So we'll also call comment_local_origin() which looks at
// the hostname in the message_id and provides a second (fallback) opinion.
- $relay_to_owner = (((! $top_level_post) && (intval($target_item['item_origin'])) && comment_local_origin($target_item)) ? true : false);
-
-
+ $relay_to_owner = (((!$top_level_post) && (intval($target_item['item_origin'])) && comment_local_origin($target_item)) ? true : false);
$uplink = false;
@@ -425,54 +419,46 @@ class Notifier {
// tag_deliver'd post which needs to be sent back to the original author
- if(($cmd === 'uplink') && intval($parent_item['item_uplink']) && (! $top_level_post)) {
+ if (($cmd === 'uplink') && intval($parent_item['item_uplink']) && (!$top_level_post)) {
logger('notifier: uplink');
$uplink = true;
}
- if(($relay_to_owner || $uplink) && ($cmd !== 'relay')) {
+ if (($relay_to_owner || $uplink) && ($cmd !== 'relay')) {
logger('notifier: followup relay', LOGGER_DEBUG);
- $recipients = array(($uplink) ? $parent_item['source_xchan'] : $parent_item['owner_xchan']);
- $private = true;
- if(! $encoded_item['flags'])
- $encoded_item['flags'] = array();
+ $recipients = [($uplink) ? $parent_item['source_xchan'] : $parent_item['owner_xchan']];
+ $private = true;
+ if (!$encoded_item['flags'])
+ $encoded_item['flags'] = [];
$encoded_item['flags'][] = 'relay';
- $upstream = true;
+ $upstream = true;
}
else {
logger('notifier: normal distribution', LOGGER_DEBUG);
- if($cmd === 'relay')
+ if ($cmd === 'relay')
logger('notifier: owner relay');
$upstream = false;
// if our parent is a tag_delivery recipient, uplink to the original author causing
// a delivery fork.
- if(($parent_item) && intval($parent_item['item_uplink']) && (! $top_level_post) && ($cmd !== 'uplink')) {
+ if (($parent_item) && intval($parent_item['item_uplink']) && (!$top_level_post) && ($cmd !== 'uplink')) {
// don't uplink a relayed post to the relay owner
- if($parent_item['source_xchan'] !== $parent_item['owner_xchan']) {
+ if ($parent_item['source_xchan'] !== $parent_item['owner_xchan']) {
logger('notifier: uplinking this item');
- Master::Summon(array('Notifier','uplink',$item_id));
+ Master::Summon(['Notifier', 'uplink', $item_id]);
}
}
- $private = false;
- $recipients = collect_recipients($parent_item,$private);
-
+ $private = false;
+ $recipients = collect_recipients($parent_item, $private);
if ($top_level_post) {
// remove clones who will receive the post via sync
- $recipients = array_diff($recipients, [ $target_item['owner_xchan'] ]);
+ $recipients = array_diff($recipients, [$target_item['owner_xchan']]);
}
// FIXME add any additional recipients such as mentions, etc.
- // don't send deletions onward for other people's stuff
- // TODO verify this is needed - copied logic from same place in old code
-
- if(intval($target_item['item_deleted']) && (! intval($target_item['item_wall']))) {
- logger('notifier: ignoring delete notification for non-wall item', LOGGER_NORMAL, LOG_NOTICE);
- return;
- }
}
}
@@ -481,32 +467,31 @@ class Notifier {
// Generic delivery section, we have an encoded item and recipients
// Now start the delivery process
- $x = $encoded_item;
+ $x = $encoded_item;
$x['title'] = 'private';
- $x['body'] = 'private';
- logger('notifier: encoded item: ' . print_r($x,true), LOGGER_DATA, LOG_DEBUG);
+ $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) {
+ if (!$recipients) {
logger('no recipients');
return;
}
// logger('notifier: recipients: ' . print_r($recipients,true), LOGGER_NORMAL, LOG_DEBUG);
- $env_recips = (($private) ? array() : null);
+ $env_recips = (($private) ? [] : null);
- $details = q("select xchan_hash, xchan_network, xchan_addr, xchan_guid, xchan_guid_sig from xchan where xchan_hash in (" . protect_sprintf(implode(',',$recipients)) . ")");
+ $details = q("select xchan_hash, xchan_network, xchan_addr, xchan_guid, xchan_guid_sig from xchan where xchan_hash in (" . protect_sprintf(implode(',', $recipients)) . ")");
- $recip_list = array();
-
- if($details) {
- foreach($details as $d) {
+ $recip_list = [];
+ if ($details) {
+ foreach ($details as $d) {
$recip_list[] = $d['xchan_addr'] . ' (' . $d['xchan_hash'] . ')';
- if($private) {
+ if ($private) {
$env_recips[] = [
'guid' => $d['xchan_guid'],
'guid_sig' => $d['xchan_guid_sig'],
@@ -542,8 +527,8 @@ class Notifier {
];
call_hooks('notifier_process', $narr);
- if($narr['queued']) {
- foreach($narr['queued'] as $pq)
+ if ($narr['queued']) {
+ foreach ($narr['queued'] as $pq)
$deliveries[] = $pq;
}
@@ -553,26 +538,26 @@ class Notifier {
$env_recips = $narr['env_recips'];
$packet_recips = $narr['packet_recips'];
- if(($private) && (! $env_recips)) {
+ if (($private) && (!$env_recips)) {
// shouldn't happen
- logger('notifier: private message with no envelope recipients.' . print_r($argv,true), LOGGER_NORMAL, LOG_NOTICE);
+ logger('notifier: private message with no envelope recipients.' . print_r($argv, true), LOGGER_NORMAL, LOG_NOTICE);
}
- logger('notifier: recipients (may be delivered to more if public): ' . print_r($recip_list,true), LOGGER_DEBUG);
+ logger('notifier: recipients (may be delivered to more if public): ' . print_r($recip_list, true), LOGGER_DEBUG);
// Now we have collected recipients (except for external mentions, FIXME)
// Let's reduce this to a set of hubs; checking that the site is not dead.
$hubs = q("select hubloc.*, site.site_crypto, site.site_flags, site.site_version, site.site_project, site.site_dead from hubloc left join site on site_url = hubloc_url
- where hubloc_hash in (" . protect_sprintf(implode(',',$recipients)) . ")
+ where hubloc_hash in (" . protect_sprintf(implode(',', $recipients)) . ")
and hubloc_error = 0 and hubloc_deleted = 0"
);
// public posts won't make it to the local public stream unless there's a recipient on this site.
// This code block sees if it's a public post and localhost is missing, and if so adds an entry for the local sys channel to the $hubs list
- if (! $private) {
+ if (!$private) {
$found_localhost = false;
if ($hubs) {
foreach ($hubs as $h) {
@@ -582,7 +567,7 @@ class Notifier {
}
}
}
- if (! $found_localhost) {
+ if (!$found_localhost) {
$localhub = q("select hubloc.*, site.site_crypto, site.site_flags, site.site_version, site.site_project, site.site_dead from hubloc
left join site on site_url = hubloc_url where hubloc_id_url = '%s' and hubloc_error = 0 and hubloc_deleted = 0",
dbesc(z_root() . '/channel/sys')
@@ -593,7 +578,7 @@ class Notifier {
}
}
- if(! $hubs) {
+ if (!$hubs) {
logger('notifier: no hubs', LOGGER_NORMAL, LOG_NOTICE);
return;
}
@@ -612,17 +597,17 @@ class Notifier {
$hub_env = []; // per-hub envelope so we don't broadcast the entire envelope to all
$dead = []; // known dead hubs - report them as undeliverable
- foreach($hubs as $hub) {
+ foreach ($hubs as $hub) {
if (intval($hub['site_dead'])) {
$dead[] = $hub;
continue;
}
- if($env_recips) {
- foreach($env_recips as $er) {
- if($hub['hubloc_hash'] === $er['hash']) {
- if(! array_key_exists($hub['hubloc_host'] . $hub['hubloc_sitekey'], $hub_env)) {
+ if ($env_recips) {
+ foreach ($env_recips as $er) {
+ if ($hub['hubloc_hash'] === $er['hash']) {
+ if (!array_key_exists($hub['hubloc_host'] . $hub['hubloc_sitekey'], $hub_env)) {
$hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']] = [];
}
$hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']][] = $er;
@@ -631,36 +616,36 @@ class Notifier {
}
- if($hub['hubloc_network'] == 'zot') {
- if(! in_array($hub['hubloc_sitekey'],$keys)) {
+ if ($hub['hubloc_network'] == 'zot') {
+ if (!in_array($hub['hubloc_sitekey'], $keys)) {
$hublist[] = $hub['hubloc_host'] . ' ' . $hub['hubloc_network'];
$dhubs[] = $hub;
$keys[] = $hub['hubloc_sitekey'];
}
}
else {
- if(! in_array($hub['hubloc_url'],$urls)) {
- if($hub['hubloc_url'] === z_root()) {
+ if (!in_array($hub['hubloc_url'], $urls)) {
+ if ($hub['hubloc_url'] === z_root()) {
//deliver to local hub first
array_unshift($hublist, $hub['hubloc_host'] . ' ' . $hub['hubloc_network']);
array_unshift($dhubs, $hub);
}
else {
$hublist[] = $hub['hubloc_host'] . ' ' . $hub['hubloc_network'];
- $dhubs[] = $hub;
+ $dhubs[] = $hub;
}
$urls[] = $hub['hubloc_url'];
}
}
}
- logger('notifier: will notify/deliver to these hubs: ' . print_r($hublist,true), LOGGER_DEBUG, LOG_DEBUG);
+ logger('notifier: will notify/deliver to these hubs: ' . print_r($hublist, true), LOGGER_DEBUG, LOG_DEBUG);
- foreach($dhubs as $hub) {
+ foreach ($dhubs as $hub) {
- logger('notifier_hub: ' . $hub['hubloc_url'],LOGGER_DEBUG);
+ logger('notifier_hub: ' . $hub['hubloc_url'], LOGGER_DEBUG);
- if(! in_array($hub['hubloc_network'], [ 'zot','zot6' ])) {
+ if (!in_array($hub['hubloc_network'], ['zot', 'zot6'])) {
$narr = [
'channel' => $channel,
'upstream' => $upstream,
@@ -687,9 +672,9 @@ class Notifier {
];
- call_hooks('notifier_hub',$narr);
- if($narr['queued']) {
- foreach($narr['queued'] as $pq)
+ call_hooks('notifier_hub', $narr);
+ if ($narr['queued']) {
+ foreach ($narr['queued'] as $pq)
$deliveries[] = $pq;
}
continue;
@@ -705,11 +690,11 @@ class Notifier {
// will invoke a delivery to those connections which are connected to just that
// hub instance.
- if($cmd === 'single_mail' || $cmd === 'single_activity') {
+ if ($cmd === 'single_mail' || $cmd === 'single_activity') {
continue;
}
- if(! in_array($hub['hubloc_network'], [ 'zot','zot6' ])) {
+ if (!in_array($hub['hubloc_network'], ['zot', 'zot6'])) {
continue;
}
@@ -717,31 +702,31 @@ class Notifier {
// in the loop. The signature verification step can't handle dashes in the
// hashes.
- $hash = random_string(48);
+ $hash = random_string(48);
$packet = null;
$pmsg = '';
- if($packet_type === 'refresh' || $packet_type === 'purge') {
- if($hub['hubloc_network'] === 'zot6') {
- $packet = Libzot::build_packet($channel, $packet_type, ids_to_array($packet_recips,'hash'));
+ if ($packet_type === 'refresh' || $packet_type === 'purge') {
+ if ($hub['hubloc_network'] === 'zot6') {
+ $packet = Libzot::build_packet($channel, $packet_type, ids_to_array($packet_recips, 'hash'));
}
else {
- $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null));
+ $packet = zot_build_packet($channel, $packet_type, (($packet_recips) ? $packet_recips : null));
}
}
- if($packet_type === 'keychange' && $hub['hubloc_network'] === 'zot') {
- $pmsg = get_pconfig($channel['channel_id'],'system','keychange');
- $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null));
+ if ($packet_type === 'keychange' && $hub['hubloc_network'] === 'zot') {
+ $pmsg = get_pconfig($channel['channel_id'], 'system', 'keychange');
+ $packet = zot_build_packet($channel, $packet_type, (($packet_recips) ? $packet_recips : null));
}
- elseif($packet_type === 'request' && $hub['hubloc_network'] === 'zot') {
- $env = (($hub_env && $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']]) ? $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']] : '');
- $packet = zot_build_packet($channel,$packet_type,$env,$hub['hubloc_sitekey'],$hub['site_crypto'],
- $hash, array('message_id' => $request_message_id)
+ elseif ($packet_type === 'request' && $hub['hubloc_network'] === 'zot') {
+ $env = (($hub_env && $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']]) ? $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']] : '');
+ $packet = zot_build_packet($channel, $packet_type, $env, $hub['hubloc_sitekey'], $hub['site_crypto'],
+ $hash, ['message_id' => $request_message_id]
);
}
- if($packet) {
+ if ($packet) {
Queue::insert(
[
'hash' => $hash,
@@ -757,11 +742,10 @@ class Notifier {
else {
$env = (($hub_env && $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']]) ? $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']] : '');
-
- if($hub['hubloc_network'] === 'zot6') {
+ if ($hub['hubloc_network'] === 'zot6') {
$zenv = [];
- if($env) {
- foreach($env as $e) {
+ if ($env) {
+ foreach ($env as $e) {
$zenv[] = $e['hash'];
}
}
@@ -774,11 +758,11 @@ class Notifier {
// 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'])) {
+ 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']);
+ $packet = Libzot::build_packet($channel, $packet_type, $zenv, $activity, 'activitystreams', (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto']);
}
else {
// currently zot6 delivery is only performed on normal items and not sync items or mail or anything else
@@ -786,28 +770,28 @@ class Notifier {
// with before switching to zot6 as the primary zot6 handler checks for the existence of a message delivery report
// to trigger dequeue'ing
- $z6 = (($encoded_item && $encoded_item['type'] === 'activity' && (! array_key_exists('allow_cid',$encoded_item))) ? true : false);
- if($z6) {
- $packet = zot6_build_packet($channel,'notify',$env, json_encode($encoded_item), (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash);
+ $z6 = (($encoded_item && $encoded_item['type'] === 'activity' && (!array_key_exists('allow_cid', $encoded_item))) ? true : false);
+ if ($z6) {
+ $packet = zot6_build_packet($channel, 'notify', $env, json_encode($encoded_item), (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'], $hash);
}
else {
- $packet = zot_build_packet($channel,'notify',$env, (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash);
+ $packet = zot_build_packet($channel, 'notify', $env, (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'], $hash);
}
}
// remove this after most hubs have updated to version 5.0
- if(stripos($hub['site_project'], 'hubzilla') !== false && version_compare($hub['site_version'], '4.7.3', '<=')) {
- if($encoded_item['type'] === 'mail') {
- $encoded_item['from']['network'] = 'zot';
+ if (stripos($hub['site_project'], 'hubzilla') !== false && version_compare($hub['site_version'], '4.7.3', '<=')) {
+ if ($encoded_item['type'] === 'mail') {
+ $encoded_item['from']['network'] = 'zot';
$encoded_item['from']['guid_sig'] = str_replace('sha256.', '', $encoded_item['from']['guid_sig']);
}
else {
- $encoded_item['owner']['network'] = 'zot';
+ $encoded_item['owner']['network'] = 'zot';
$encoded_item['owner']['guid_sig'] = str_replace('sha256.', '', $encoded_item['owner']['guid_sig']);
- if(strpos($encoded_item['author']['url'], z_root()) === 0) {
- $encoded_item['author']['network'] = 'zot';
+ if (strpos($encoded_item['author']['url'], z_root()) === 0) {
+ $encoded_item['author']['network'] = 'zot';
$encoded_item['author']['guid_sig'] = str_replace('sha256.', '', $encoded_item['author']['guid_sig']);
}
}
@@ -826,7 +810,7 @@ class Notifier {
);
// only create delivery reports for normal undeleted items
- if(is_array($target_item) && array_key_exists('postopts',$target_item) && (! $target_item['item_deleted']) && (! get_config('system','disable_dreport'))) {
+ if (is_array($target_item) && array_key_exists('postopts', $target_item) && (!$target_item['item_deleted']) && (!get_config('system', 'disable_dreport'))) {
q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan, dreport_queue ) values ( '%s','%s','%s','%s','%s','%s','%s' ) ",
dbesc($target_item['mid']),
dbesc($hub['hubloc_host']),
@@ -842,21 +826,21 @@ class Notifier {
$deliveries[] = $hash;
}
- if($normal_mode) {
+ if ($normal_mode) {
$x = q("select * from hook where hook = 'notifier_normal'");
- if($x) {
- Master::Summon( [ 'Deliver_hooks', $target_item['id'] ] );
+ if ($x) {
+ Master::Summon(['Deliver_hooks', $target_item['id']]);
}
}
- if($deliveries)
+ if ($deliveries)
do_delivery($deliveries);
logger('notifier: basic loop complete.', LOGGER_DEBUG);
if ($dead) {
foreach ($dead as $deceased) {
- if (is_array($target_item) && (! $target_item['item_deleted']) && (! get_config('system','disable_dreport'))) {
+ if (is_array($target_item) && (!$target_item['item_deleted']) && (!get_config('system', 'disable_dreport'))) {
q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_name, dreport_result, dreport_time, dreport_xchan, dreport_queue )
values ( '%s', '%s','%s','%s','%s','%s','%s','%s' ) ",
dbesc($target_item['mid']),
@@ -872,7 +856,7 @@ class Notifier {
}
}
- call_hooks('notifier_end',$target_item);
+ call_hooks('notifier_end', $target_item);
logger('notifer: complete.');
return;
diff --git a/Zotlabs/Daemon/Onedirsync.php b/Zotlabs/Daemon/Onedirsync.php
index 2ad76761d..f29fbe5b8 100644
--- a/Zotlabs/Daemon/Onedirsync.php
+++ b/Zotlabs/Daemon/Onedirsync.php
@@ -3,6 +3,7 @@
namespace Zotlabs\Daemon;
use Zotlabs\Lib\Libzot;
+use Zotlabs\Lib\Libzotdir;
require_once('include/zot.php');
require_once('include/dir_fns.php');
@@ -10,14 +11,14 @@ require_once('include/dir_fns.php');
class Onedirsync {
- static public function run($argc,$argv) {
+ static public function run($argc, $argv) {
logger('onedirsync: start ' . intval($argv[1]));
- if(($argc > 1) && (intval($argv[1])))
+ if (($argc > 1) && (intval($argv[1])))
$update_id = intval($argv[1]);
- if(! $update_id) {
+ if (!$update_id) {
logger('onedirsync: no update');
return;
}
@@ -26,9 +27,9 @@ class Onedirsync {
intval($update_id)
);
- if(! $r)
+ if (!$r)
return;
- if(($r[0]['ud_flags'] & UPDATE_FLAGS_UPDATED) || (! $r[0]['ud_addr']))
+ if (($r[0]['ud_flags'] & UPDATE_FLAGS_UPDATED) || (!$r[0]['ud_addr']))
return;
// Have we probed this channel more recently than the other directory server
@@ -40,8 +41,8 @@ class Onedirsync {
dbesc($r[0]['ud_date']),
intval(UPDATE_FLAGS_UPDATED)
);
- if($x) {
- $y = q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and ( ud_flags & %d ) = 0 and ud_date != '%s'",
+ if ($x) {
+ q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and ( ud_flags & %d ) = 0 and ud_date != '%s'",
intval(UPDATE_FLAGS_UPDATED),
dbesc($r[0]['ud_addr']),
intval(UPDATE_FLAGS_UPDATED),
@@ -58,8 +59,8 @@ class Onedirsync {
$h = Libzot::zot_record_preferred($h);
- if(($h) && ($h['hubloc_status'] & HUBLOC_OFFLINE)) {
- $y = q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and ( ud_flags & %d ) = 0 ",
+ if (($h) && ($h['hubloc_status'] & HUBLOC_OFFLINE)) {
+ q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and ( ud_flags & %d ) = 0 ",
intval(UPDATE_FLAGS_UPDATED),
dbesc($r[0]['ud_addr']),
intval(UPDATE_FLAGS_UPDATED)
@@ -71,10 +72,10 @@ class Onedirsync {
// we might have to pull this out some day, but for now update_directory_entry()
// runs zot_finger() and is kind of zot specific
- if($h && ! in_array($h['hubloc_network'], ['zot6', 'zot']))
+ if ($h && !in_array($h['hubloc_network'], ['zot6', 'zot']))
return;
- update_directory_entry($r[0]);
+ Libzotdir::update_directory_entry($r[0]);
return;
}
diff --git a/Zotlabs/Daemon/Onepoll.php b/Zotlabs/Daemon/Onepoll.php
index 93a5412b0..0228f10fb 100644
--- a/Zotlabs/Daemon/Onepoll.php
+++ b/Zotlabs/Daemon/Onepoll.php
@@ -2,6 +2,7 @@
namespace Zotlabs\Daemon;
+use App;
use Zotlabs\Lib\Libzot;
require_once('include/zot.php');
@@ -10,20 +11,18 @@ require_once('include/socgraph.php');
class Onepoll {
- static public function run($argc,$argv) {
+ static public function run($argc, $argv) {
logger('onepoll: start');
-
- if(($argc > 1) && (intval($argv[1])))
+
+ if (($argc > 1) && (intval($argv[1])))
$contact_id = intval($argv[1]);
- if(! $contact_id) {
+ if (!$contact_id) {
logger('onepoll: no contact');
return;
}
- $d = datetime_convert();
-
$contacts = q("SELECT abook.*, xchan.*, account.*
FROM abook LEFT JOIN account on abook_account = account_id left join xchan on xchan_hash = abook_xchan
where abook_id = %d
@@ -32,38 +31,36 @@ class Onepoll {
intval($contact_id),
intval(ACCOUNT_OK),
intval(ACCOUNT_UNVERIFIED)
- );
+ );
- if(! $contacts) {
+ if (!$contacts) {
logger('onepoll: abook_id not found: ' . $contact_id);
return;
}
$contact = $contacts[0];
- $t = $contact['abook_updated'];
-
$importer_uid = $contact['abook_channel'];
-
+
$r = q("SELECT * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d limit 1",
intval($importer_uid)
);
- if(! $r)
+ if (!$r)
return;
$importer = $r[0];
logger("onepoll: poll: ({$contact['id']}) IMPORTER: {$importer['xchan_name']}, CONTACT: {$contact['xchan_name']}");
- $last_update = ((($contact['abook_updated'] === $contact['abook_created']) || ($contact['abook_updated'] <= NULL_DATE))
- ? datetime_convert('UTC','UTC','now - 7 days')
- : datetime_convert('UTC','UTC',$contact['abook_updated'] . ' - 2 days')
+ $last_update = ((($contact['abook_updated'] === $contact['abook_created']) || ($contact['abook_updated'] <= NULL_DATE))
+ ? datetime_convert('UTC', 'UTC', 'now - 7 days')
+ : datetime_convert('UTC', 'UTC', $contact['abook_updated'] . ' - 2 days')
);
- if($contact['xchan_network'] === 'rss') {
+ if ($contact['xchan_network'] === 'rss') {
logger('onepoll: processing feed ' . $contact['xchan_name'], LOGGER_DEBUG);
- $alive = handle_feed($importer['channel_id'],$contact_id,$contact['xchan_hash']);
+ $alive = handle_feed($importer['channel_id'], $contact_id, $contact['xchan_hash']);
if ($alive) {
q("update abook set abook_connected = '%s' where abook_id = %d",
dbesc(datetime_convert()),
@@ -72,22 +69,22 @@ class Onepoll {
}
return;
}
-
- if(! in_array($contact['xchan_network'],['zot','zot6']))
+
+ if (!in_array($contact['xchan_network'], ['zot', 'zot6']))
return;
// update permissions
- if($contact['xchan_network'] === 'zot6')
- $x = Libzot::refresh($contact,$importer);
+ if ($contact['xchan_network'] === 'zot6')
+ $x = Libzot::refresh($contact, $importer);
- if($contact['xchan_network'] === 'zot')
- $x = zot_refresh($contact,$importer);
+ if ($contact['xchan_network'] === 'zot')
+ $x = zot_refresh($contact, $importer);
$responded = false;
$updated = datetime_convert();
$connected = datetime_convert();
- if(! $x) {
+ if (!$x) {
// mark for death by not updating abook_connected, this is caught in include/poller.php
q("update abook set abook_updated = '%s' where abook_id = %d",
dbesc($updated),
@@ -103,38 +100,38 @@ class Onepoll {
$responded = true;
}
- if(! $responded)
+ if (!$responded)
return;
- if($contact['xchan_connurl']) {
+ if ($contact['xchan_connurl']) {
$fetch_feed = true;
- $x = null;
+ $x = null;
// They haven't given us permission to see their stream
- $can_view_stream = intval(get_abconfig($importer_uid,$contact['abook_xchan'],'their_perms','view_stream'));
+ $can_view_stream = intval(get_abconfig($importer_uid, $contact['abook_xchan'], 'their_perms', 'view_stream'));
- if(! $can_view_stream)
+ if (!$can_view_stream)
$fetch_feed = false;
// we haven't given them permission to send us their stream
- $can_send_stream = intval(get_abconfig($importer_uid,$contact['abook_xchan'],'my_perms','send_stream'));
-
- if(! $can_send_stream)
+ $can_send_stream = intval(get_abconfig($importer_uid, $contact['abook_xchan'], 'my_perms', 'send_stream'));
+
+ if (!$can_send_stream)
$fetch_feed = false;
- if($fetch_feed) {
+ if ($fetch_feed) {
- if(strpos($contact['xchan_connurl'],z_root()) === 0) {
+ if (strpos($contact['xchan_connurl'], z_root()) === 0) {
// local channel - save a network fetch
$c = channelx_by_hash($contact['xchan_hash']);
- if($c) {
- $x = [
- 'success' => true,
- 'body' => json_encode( [
- 'success' => true,
- 'messages' => zot_feed($c['channel_id'], $importer['xchan_hash'], [ 'mindate' => $last_update ])
+ if ($c) {
+ $x = [
+ 'success' => true,
+ 'body' => json_encode([
+ 'success' => true,
+ 'messages' => zot_feed($c['channel_id'], $importer['xchan_hash'], ['mindate' => $last_update])
])
];
}
@@ -142,43 +139,43 @@ class Onepoll {
else {
// remote fetch
- $feedurl = str_replace('/poco/','/zotfeed/',$contact['xchan_connurl']);
- $feedurl .= '?f=&mindate=' . urlencode($last_update) . '&zid=' . $importer['channel_address'] . '@' . \App::get_hostname();
+ $feedurl = str_replace('/poco/', '/zotfeed/', $contact['xchan_connurl']);
+ $feedurl .= '?f=&mindate=' . urlencode($last_update) . '&zid=' . $importer['channel_address'] . '@' . App::get_hostname();
$recurse = 0;
- $x = z_fetch_url($feedurl, false, $recurse, [ 'session' => true ]);
+ $x = z_fetch_url($feedurl, false, $recurse, ['session' => true]);
}
- logger('feed_update: ' . print_r($x,true), LOGGER_DATA);
+ logger('feed_update: ' . print_r($x, true), LOGGER_DATA);
}
- if(($x) && ($x['success'])) {
+ if (($x) && ($x['success'])) {
$total = 0;
logger('onepoll: feed update ' . $contact['xchan_name'] . ' ' . $feedurl);
- $j = json_decode($x['body'],true);
- if($j['success'] && $j['messages']) {
- foreach($j['messages'] as $message) {
- $results = process_delivery(array('hash' => $contact['xchan_hash']), get_item_elements($message),
- array(array('hash' => $importer['xchan_hash'])), false);
- logger('onepoll: feed_update: process_delivery: ' . print_r($results,true), LOGGER_DATA);
- $total ++;
+ $j = json_decode($x['body'], true);
+ if ($j['success'] && $j['messages']) {
+ foreach ($j['messages'] as $message) {
+ $results = process_delivery(['hash' => $contact['xchan_hash']], get_item_elements($message),
+ [['hash' => $importer['xchan_hash']]], false);
+ logger('onepoll: feed_update: process_delivery: ' . print_r($results, true), LOGGER_DATA);
+ $total++;
}
logger("onepoll: $total messages processed");
}
}
}
-
+
// update the poco details for this connection
- if($contact['xchan_connurl']) {
+ if ($contact['xchan_connurl']) {
$r = q("SELECT xlink_id from xlink
where xlink_xchan = '%s' and xlink_updated > %s - INTERVAL %s and xlink_static = 0 limit 1",
intval($contact['xchan_hash']),
db_utcnow(), db_quoteinterval('1 DAY')
);
- if(! $r) {
- poco_load($contact['xchan_hash'],$contact['xchan_connurl']);
+ if (!$r) {
+ poco_load($contact['xchan_hash'], $contact['xchan_connurl']);
}
}
diff --git a/Zotlabs/Daemon/Poller.php b/Zotlabs/Daemon/Poller.php
index ebc0584ba..8cbdfab0d 100644
--- a/Zotlabs/Daemon/Poller.php
+++ b/Zotlabs/Daemon/Poller.php
@@ -4,73 +4,67 @@ namespace Zotlabs\Daemon;
class Poller {
- static public function run($argc,$argv) {
+ static public function run($argc, $argv) {
- $maxsysload = intval(get_config('system','maxloadavg'));
- if($maxsysload < 1)
+ $maxsysload = intval(get_config('system', 'maxloadavg'));
+ if ($maxsysload < 1)
$maxsysload = 50;
- if(function_exists('sys_getloadavg')) {
+ if (function_exists('sys_getloadavg')) {
$load = sys_getloadavg();
- if(intval($load[0]) > $maxsysload) {
+ if (intval($load[0]) > $maxsysload) {
logger('system: load ' . $load . ' too high. Poller deferred to next scheduled run.');
return;
}
}
- $interval = intval(get_config('system','poll_interval'));
- if(! $interval)
- $interval = ((get_config('system','delivery_interval') === false) ? 3 : intval(get_config('system','delivery_interval')));
+ $interval = intval(get_config('system', 'poll_interval'));
+ if (!$interval)
+ $interval = ((get_config('system', 'delivery_interval') === false) ? 3 : intval(get_config('system', 'delivery_interval')));
// Check for a lockfile. If it exists, but is over an hour old, it's stale. Ignore it.
$lockfile = 'store/[data]/poller';
- if((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 3600))
- && (! get_config('system','override_poll_lockfile'))) {
+ if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 3600))
+ && (!get_config('system', 'override_poll_lockfile'))) {
logger("poller: Already running");
return;
}
-
+
// Create a lockfile. Needs two vars, but $x doesn't need to contain anything.
+ $x = '';
file_put_contents($lockfile, $x);
logger('poller: start');
-
- $manual_id = 0;
- $generation = 0;
- $force = false;
- $restart = false;
+ $manual_id = 0;
+ $force = false;
- if(($argc > 1) && ($argv[1] == 'force'))
+ if (($argc > 1) && ($argv[1] == 'force'))
$force = true;
- if(($argc > 1) && ($argv[1] == 'restart')) {
- $restart = true;
+ if (($argc > 1) && ($argv[1] == 'restart')) {
$generation = intval($argv[2]);
- if(! $generation)
+ if (!$generation)
return;
}
- if(($argc > 1) && intval($argv[1])) {
+ if (($argc > 1) && intval($argv[1])) {
$manual_id = intval($argv[1]);
$force = true;
}
-
$sql_extra = (($manual_id) ? " AND abook_id = " . intval($manual_id) . " " : "");
reload_plugins();
- $d = datetime_convert();
-
// Only poll from those with suitable relationships
- $abandon_sql = (($abandon_days)
- ? sprintf(" AND account_lastlog > %s - INTERVAL %s ", db_utcnow(), db_quoteinterval(intval($abandon_days).' DAY'))
- : ''
+ $abandon_sql = (($abandon_days)
+ ? sprintf(" AND account_lastlog > %s - INTERVAL %s ", db_utcnow(), db_quoteinterval(intval($abandon_days) . ' DAY'))
+ : ''
);
$randfunc = db_getfunc('RAND');
-
+
$contacts = q("SELECT abook.abook_updated, abook.abook_connected, abook.abook_feed,
abook.abook_channel, abook.abook_id, abook.abook_archived, abook.abook_pending,
abook.abook_ignored, abook.abook_blocked,
@@ -85,118 +79,117 @@ class Poller {
intval(ACCOUNT_UNVERIFIED) // FIXME
);
- if($contacts) {
+ if ($contacts) {
+ foreach ($contacts as $contact) {
- foreach($contacts as $contact) {
-
- $update = false;
+ $update = false;
$t = $contact['abook_updated'];
$c = $contact['abook_connected'];
- if(intval($contact['abook_feed'])) {
- $min = service_class_fetch($contact['abook_channel'],'minimum_feedcheck_minutes');
- if(! $min)
- $min = intval(get_config('system','minimum_feedcheck_minutes'));
- if(! $min)
+ if (intval($contact['abook_feed'])) {
+ $min = service_class_fetch($contact['abook_channel'], 'minimum_feedcheck_minutes');
+ if (!$min)
+ $min = intval(get_config('system', 'minimum_feedcheck_minutes'));
+ if (!$min)
$min = 60;
- $x = datetime_convert('UTC','UTC',"now - $min minutes");
- if($c < $x) {
- Master::Summon(array('Onepoll',$contact['abook_id']));
- if($interval)
- @time_sleep_until(microtime(true) + (float) $interval);
+ $x = datetime_convert('UTC', 'UTC', "now - $min minutes");
+ if ($c < $x) {
+ Master::Summon(['Onepoll', $contact['abook_id']]);
+ if ($interval)
+ @time_sleep_until(microtime(true) + (float)$interval);
}
continue;
}
- if(! in_array($contact['xchan_network'],['zot','zot6']))
+ if (!in_array($contact['xchan_network'], ['zot', 'zot6']))
continue;
- if($c == $t) {
- if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day"))
+ if ($c == $t) {
+ if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 1 day"))
$update = true;
}
else {
-
+
// if we've never connected with them, start the mark for death countdown from now
-
- if($c <= NULL_DATE) {
- $r = q("update abook set abook_connected = '%s' where abook_id = %d",
+
+ if ($c <= NULL_DATE) {
+ q("update abook set abook_connected = '%s' where abook_id = %d",
dbesc(datetime_convert()),
intval($contact['abook_id'])
);
- $c = datetime_convert();
+ $c = datetime_convert();
$update = true;
}
// He's dead, Jim
- if(strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $c . " + 30 day")) > 0) {
- $r = q("update abook set abook_archived = 1 where abook_id = %d",
+ if (strcmp(datetime_convert('UTC', 'UTC', 'now'), datetime_convert('UTC', 'UTC', $c . " + 30 day")) > 0) {
+ q("update abook set abook_archived = 1 where abook_id = %d",
intval($contact['abook_id'])
);
- $update = false;
continue;
}
- if(intval($contact['abook_archived'])) {
- $update = false;
+ if (intval($contact['abook_archived'])) {
continue;
}
// might be dead, so maybe don't poll quite so often
-
+
// recently deceased, so keep up the regular schedule for 3 days
-
- if((strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $c . " + 3 day")) > 0)
- && (strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $t . " + 1 day")) > 0))
+
+ if ((strcmp(datetime_convert('UTC', 'UTC', 'now'), datetime_convert('UTC', 'UTC', $c . " + 3 day")) > 0)
+ && (strcmp(datetime_convert('UTC', 'UTC', 'now'), datetime_convert('UTC', 'UTC', $t . " + 1 day")) > 0))
$update = true;
// After that back off and put them on a morphine drip
- if(strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $t . " + 2 day")) > 0) {
+ if (strcmp(datetime_convert('UTC', 'UTC', 'now'), datetime_convert('UTC', 'UTC', $t . " + 2 day")) > 0) {
$update = true;
}
}
- if(intval($contact['abook_pending']) || intval($contact['abook_archived']) || intval($contact['abook_ignored']) || intval($contact['abook_blocked']))
+ if (intval($contact['abook_pending']) || intval($contact['abook_archived']) || intval($contact['abook_ignored']) || intval($contact['abook_blocked']))
continue;
- if((! $update) && (! $force))
- continue;
+ if ((!$update) && (!$force))
+ continue;
- Master::Summon(array('Onepoll',$contact['abook_id']));
- if($interval)
- @time_sleep_until(microtime(true) + (float) $interval);
+ Master::Summon(['Onepoll', $contact['abook_id']]);
+ if ($interval)
+ @time_sleep_until(microtime(true) + (float)$interval);
}
}
- if($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) {
+ $dirmode = intval(get_config('system', 'directory_mode'));
+
+ if ($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) {
$r = q("SELECT u.ud_addr, u.ud_id, u.ud_last FROM updates AS u INNER JOIN (SELECT ud_addr, max(ud_id) AS ud_id FROM updates WHERE ( ud_flags & %d ) = 0 AND ud_addr != '' AND ( ud_last <= '%s' OR ud_last > %s - INTERVAL %s ) GROUP BY ud_addr) AS s ON s.ud_id = u.ud_id ",
intval(UPDATE_FLAGS_UPDATED),
dbesc(NULL_DATE),
db_utcnow(), db_quoteinterval('7 DAY')
);
- if($r) {
- foreach($r as $rr) {
+ if ($r) {
+ foreach ($r as $rr) {
// If they didn't respond when we attempted before, back off to once a day
// After 7 days we won't bother anymore
- if($rr['ud_last'] > NULL_DATE)
- if($rr['ud_last'] > datetime_convert('UTC','UTC', 'now - 1 day'))
+ if ($rr['ud_last'] > NULL_DATE)
+ if ($rr['ud_last'] > datetime_convert('UTC', 'UTC', 'now - 1 day'))
continue;
- Master::Summon(array('Onedirsync',$rr['ud_id']));
- if($interval)
- @time_sleep_until(microtime(true) + (float) $interval);
+ Master::Summon(['Onedirsync', $rr['ud_id']]);
+ if ($interval)
+ @time_sleep_until(microtime(true) + (float)$interval);
}
}
- }
+ }
- set_config('system','lastpoll',datetime_convert());
+ set_config('system', 'lastpoll', datetime_convert());
//All done - clear the lockfile
diff --git a/Zotlabs/Daemon/Queue.php b/Zotlabs/Daemon/Queue.php
index 814148404..36bdcfe81 100644
--- a/Zotlabs/Daemon/Queue.php
+++ b/Zotlabs/Daemon/Queue.php
@@ -7,12 +7,12 @@ require_once('include/zot.php');
class Queue {
- static public function run($argc,$argv) {
+ static public function run($argc, $argv) {
require_once('include/items.php');
require_once('include/bbcode.php');
- if($argc > 1)
+ if ($argc > 1)
$queue_id = $argv[1];
else
$queue_id = EMPTY_STR;
@@ -25,10 +25,9 @@ class Queue {
$r = q("select outq_posturl from outq where outq_created < %s - INTERVAL %s",
db_utcnow(), db_quoteinterval('3 DAY')
);
- if($r) {
- foreach($r as $rr) {
- $site_url = '';
- $h = parse_url($rr['outq_posturl']);
+ if ($r) {
+ foreach ($r as $rr) {
+ $h = parse_url($rr['outq_posturl']);
$desturl = $h['scheme'] . '://' . $h['host'] . (($h['port']) ? ':' . $h['port'] : '');
q("update site set site_dead = 1 where site_dead = 0 and site_url = '%s' and site_update < %s - INTERVAL %s",
dbesc($desturl),
@@ -37,11 +36,11 @@ class Queue {
}
}
- $r = q("DELETE FROM outq WHERE outq_created < %s - INTERVAL %s",
+ q("DELETE FROM outq WHERE outq_created < %s - INTERVAL %s",
db_utcnow(), db_quoteinterval('3 DAY')
);
- if($queue_id) {
+ if ($queue_id) {
$r = q("SELECT * FROM outq WHERE outq_hash = '%s' LIMIT 1",
dbesc($queue_id)
);
@@ -54,7 +53,7 @@ class Queue {
// so that we don't start off a thousand deliveries for a couple of dead hubs.
// The zot driver will deliver everything destined for a single hub once contact is made (*if* contact is made).
// Other drivers will have to do something different here and may need their own query.
-
+
// Note: this requires some tweaking as new posts to long dead hubs once a day will keep them in the
// "every 15 minutes" category. We probably need to prioritise them when inserted into the queue
// or just prior to this query based on recent and long-term delivery history. If we have good reason to believe
@@ -67,7 +66,7 @@ class Queue {
db_utcnow()
);
while ($r) {
- foreach($r as $rv) {
+ foreach ($r as $rv) {
queue_deliver($rv);
}
$r = q("SELECT *,$sqlrandfunc as rn FROM outq WHERE outq_delivered = 0 and outq_scheduled < %s order by rn limit 1",
@@ -75,10 +74,10 @@ class Queue {
);
}
}
- if(! $r)
+ if (!$r)
return;
- foreach($r as $rv) {
+ foreach ($r as $rv) {
queue_deliver($rv);
}
}
diff --git a/Zotlabs/Daemon/Thumbnail.php b/Zotlabs/Daemon/Thumbnail.php
index e1f17c304..72034b870 100644
--- a/Zotlabs/Daemon/Thumbnail.php
+++ b/Zotlabs/Daemon/Thumbnail.php
@@ -5,30 +5,30 @@ namespace Zotlabs\Daemon;
class Thumbnail {
- static public function run($argc,$argv) {
+ static public function run($argc, $argv) {
- if(! $argc == 2)
+ if (!$argc == 2)
return;
$c = q("select * from attach where hash = '%s' ",
dbesc($argv[1])
);
- if(! $c)
+ if (!$c)
return;
$attach = $c[0];
- $preview_style = intval(get_config('system','thumbnail_security',0));
- $preview_width = intval(get_config('system','thumbnail_width',300));
- $preview_height = intval(get_config('system','thumbnail_height',300));
+ $preview_style = intval(get_config('system', 'thumbnail_security', 0));
+ $preview_width = intval(get_config('system', 'thumbnail_width', 300));
+ $preview_height = intval(get_config('system', 'thumbnail_height', 300));
$p = [
'attach' => $attach,
'preview_style' => $preview_style,
'preview_width' => $preview_width,
'preview_height' => $preview_height,
- 'thumbnail' => null
+ 'thumbnail' => null
];
/**
@@ -40,39 +40,39 @@ class Thumbnail {
* * \e string \b thumbnail
*/
- call_hooks('thumbnail',$p);
- if($p['thumbnail']) {
+ call_hooks('thumbnail', $p);
+ if ($p['thumbnail']) {
return;
}
$default_controller = null;
-
+
$files = glob('Zotlabs/Thumbs/*.php');
- if($files) {
- foreach($files as $f) {
- $clsname = '\\Zotlabs\\Thumbs\\' . ucfirst(basename($f,'.php'));
- if(class_exists($clsname)) {
+ if ($files) {
+ foreach ($files as $f) {
+ $clsname = '\\Zotlabs\\Thumbs\\' . ucfirst(basename($f, '.php'));
+ if (class_exists($clsname)) {
$x = new $clsname();
- if(method_exists($x,'Match')) {
+ if (method_exists($x, 'Match')) {
$matched = $x->Match($attach['filetype']);
- if($matched) {
- $x->Thumb($attach,$preview_style,$preview_width,$preview_height);
+ if ($matched) {
+ $x->Thumb($attach, $preview_style, $preview_width, $preview_height);
}
}
- if(method_exists($x,'MatchDefault')) {
- $default_matched = $x->MatchDefault(substr($attach['filetype'],0,strpos($attach['filetype'],'/')));
- if($default_matched) {
+ if (method_exists($x, 'MatchDefault')) {
+ $default_matched = $x->MatchDefault(substr($attach['filetype'], 0, strpos($attach['filetype'], '/')));
+ if ($default_matched) {
$default_controller = $x;
}
}
}
}
}
- if(($default_controller)
- && ((! file_exists(dbunescbin($attach['content']) . '.thumb'))
+ if (($default_controller)
+ && ((!file_exists(dbunescbin($attach['content']) . '.thumb'))
|| (filectime(dbunescbin($attach['content']) . 'thumb') < (time() - 60)))) {
- $default_controller->Thumb($attach,$preview_style,$preview_width,$preview_height);
+ $default_controller->Thumb($attach, $preview_style, $preview_width, $preview_height);
}
}
}
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php
index 7b980b8d3..05b2ba177 100644
--- a/Zotlabs/Lib/Apps.php
+++ b/Zotlabs/Lib/Apps.php
@@ -524,7 +524,7 @@ class Apps {
}
elseif(remote_channel()) {
$observer = \App::get_observer();
- if($observer && $observer['xchan_network'] === 'zot') {
+ if($observer && in_array($observer['xchan_network'], ['zot6', 'zot'])) {
// some folks might have xchan_url redirected offsite, use the connurl
$x = parse_url($observer['xchan_connurl']);
if($x) {
diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php
index c78325ee3..3a24cd349 100644
--- a/Zotlabs/Lib/Enotify.php
+++ b/Zotlabs/Lib/Enotify.php
@@ -64,7 +64,7 @@ class Enotify {
$sitename = get_config('system','sitename');
$site_admin = sprintf( t('%s Administrator'), $sitename);
$opt_out1 = sprintf( t('This email was sent by %1$s at %2$s.'), t('$Projectname'), \App::get_hostname());
- $opt_out2 = sprintf( t('To stop receiving these messages, please adjust your Notification Settings at %s'), z_root() . '/settings');
+ $opt_out2 = sprintf( t('To stop receiving these messages, please adjust your Notification Settings at %s'), z_root() . '/settings');
$hopt_out2 = sprintf( t('To stop receiving these messages, please adjust your %s.'), '<a href="' . z_root() . '/settings' . '">' . t('Notification Settings') . '</a>');
$sender_name = $product;
$hostname = \App::get_hostname();
@@ -80,7 +80,7 @@ class Enotify {
$sender_email = get_config('system','from_email');
if(! $sender_email)
$sender_email = 'Administrator' . '@' . $hostname;
-
+
$sender_name = get_config('system','from_email_name');
if(! $sender_name)
$sender_name = \Zotlabs\Lib\System::get_site_name();
@@ -108,7 +108,7 @@ class Enotify {
logger('notification invoked for an old item which may have been refetched.',LOGGER_DEBUG,LOG_INFO);
return;
}
- }
+ }
else {
$title = $body = '';
}
@@ -181,7 +181,7 @@ class Enotify {
pop_lang();
return;
}
-
+
// if it's a post figure out who's post it is.
@@ -219,7 +219,7 @@ class Enotify {
$itemlink,
$p[0]['author']['xchan_name'],
$item_post_type);
-
+
// "your post"
if($p[0]['owner']['xchan_name'] == $p[0]['author']['xchan_name'] && intval($p[0]['item_wall']))
$dest_str = sprintf(t('%1$s %2$s [zrl=%3$s]your %4$s[/zrl]'),
@@ -230,15 +230,15 @@ class Enotify {
// Some mail softwares relies on subject field for threading.
// So, we cannot have different subjects for notifications of the same thread.
- // Before this we have the name of the replier on the subject rendering
+ // Before this we have the name of the replier on the subject rendering
// differents subjects for messages on the same thread.
if($moderated)
$subject = sprintf( t('[$Projectname:Notify] Moderated Comment to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']);
else
$subject = sprintf( t('[$Projectname:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']);
- $preamble = sprintf( t('%1$s commented on an item/conversation you have been following.'), $sender['xchan_name']);
- $epreamble = $dest_str;
+ $preamble = sprintf( t('%1$s commented on an item/conversation you have been following.'), $sender['xchan_name']);
+ $epreamble = $dest_str;
$sitelink = t('Please visit %s to view and/or reply to the conversation.');
$tsitelink = sprintf( $sitelink, $siteurl );
@@ -247,7 +247,7 @@ class Enotify {
$tsitelink .= "\n\n" . sprintf( t('Please visit %s to approve or reject this comment.'), z_root() . '/moderate' );
$hsitelink .= "<br><br>" . sprintf( t('Please visit %s to approve or reject this comment.'), '<a href="' . z_root() . '/moderate">' . z_root() . '/moderate</a>' );
}
-
+
}
if ($params['type'] == NOTIFY_LIKE) {
@@ -278,7 +278,7 @@ class Enotify {
pop_lang();
return;
}
-
+
// if it's a post figure out who's post it is.
@@ -314,12 +314,12 @@ class Enotify {
// Some mail softwares relies on subject field for threading.
// So, we cannot have different subjects for notifications of the same thread.
- // Before this we have the name of the replier on the subject rendering
+ // Before this we have the name of the replier on the subject rendering
// differents subjects for messages on the same thread.
$subject = sprintf( t('[$Projectname:Notify] Like received to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']);
- $preamble = sprintf( t('%1$s liked an item/conversation you created.'), $sender['xchan_name']);
- $epreamble = $dest_str;
+ $preamble = sprintf( t('%1$s liked an item/conversation you created.'), $sender['xchan_name']);
+ $epreamble = $dest_str;
$sitelink = t('Please visit %s to view and/or reply to the conversation.');
$tsitelink = sprintf( $sitelink, $siteurl );
@@ -335,7 +335,7 @@ class Enotify {
$epreamble = sprintf( t('%1$s posted to [zrl=%2$s]your wall[/zrl]') ,
'[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]',
- $params['link']);
+ $params['link']);
$sitelink = t('Please visit %s to view and/or reply to the conversation.');
$tsitelink = sprintf( $sitelink, $siteurl );
@@ -355,12 +355,12 @@ class Enotify {
pop_lang();
return;
}
-
+
$subject = sprintf( t('[$Projectname:Notify] %s tagged you') , $sender['xchan_name']);
$preamble = sprintf( t('%1$s tagged you at %2$s') , $sender['xchan_name'], $sitename);
$epreamble = sprintf( t('%1$s [zrl=%2$s]tagged you[/zrl].') ,
'[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]',
- $params['link']);
+ $params['link']);
$sitelink = t('Please visit %s to view and/or reply to the conversation.');
$tsitelink = sprintf( $sitelink, $siteurl );
@@ -373,7 +373,7 @@ class Enotify {
$preamble = sprintf( t('%1$s poked you at %2$s') , $sender['xchan_name'], $sitename);
$epreamble = sprintf( t('%1$s [zrl=%2$s]poked you[/zrl].') ,
'[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]',
- $params['link']);
+ $params['link']);
$subject = str_replace('poked', t($params['activity']), $subject);
$preamble = str_replace('poked', t($params['activity']), $preamble);
@@ -390,7 +390,7 @@ class Enotify {
$preamble = sprintf( t('%1$s tagged your post at %2$s'),$sender['xchan_name'], $sitename);
$epreamble = sprintf( t('%1$s tagged [zrl=%2$s]your post[/zrl]') ,
'[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]',
- $itemlink);
+ $itemlink);
$sitelink = t('Please visit %s to view and/or reply to the conversation.');
$tsitelink = sprintf( $sitelink, $siteurl );
@@ -400,10 +400,10 @@ class Enotify {
if ($params['type'] == NOTIFY_INTRO) {
$subject = sprintf( t('[$Projectname:Notify] Introduction received'));
- $preamble = sprintf( t('You\'ve received an new connection request from \'%1$s\' at %2$s'), $sender['xchan_name'], $sitename);
+ $preamble = sprintf( t('You\'ve received an new connection request from \'%1$s\' at %2$s'), $sender['xchan_name'], $sitename);
$epreamble = sprintf( t('You\'ve received [zrl=%1$s]a new connection request[/zrl] from %2$s.'),
$siteurl . '/connections/ifpending',
- '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]');
+ '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]');
$body = sprintf( t('You may visit their profile at %s'),$sender['xchan_url']);
$sitelink = t('Please visit %s to approve or reject the connection request.');
@@ -414,11 +414,11 @@ class Enotify {
if ($params['type'] == NOTIFY_SUGGEST) {
$subject = sprintf( t('[$Projectname:Notify] Friend suggestion received'));
- $preamble = sprintf( t('You\'ve received a friend suggestion from \'%1$s\' at %2$s'), $sender['xchan_name'], $sitename);
+ $preamble = sprintf( t('You\'ve received a friend suggestion from \'%1$s\' at %2$s'), $sender['xchan_name'], $sitename);
$epreamble = sprintf( t('You\'ve received [zrl=%1$s]a friend suggestion[/zrl] for %2$s from %3$s.'),
$itemlink,
'[zrl=' . $params['item']['url'] . ']' . $params['item']['name'] . '[/zrl]',
- '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]');
+ '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]');
$body = t('Name:') . ' ' . $params['item']['name'] . "\n";
$body .= t('Photo:') . ' ' . $params['item']['photo'] . "\n";
@@ -462,7 +462,7 @@ class Enotify {
$sitelink = $h['sitelink'];
$tsitelink = $h['tsitelink'];
$hsitelink = $h['hsitelink'];
- $itemlink = $h['itemlink'];
+ $itemlink = $h['itemlink'];
require_once('include/html2bbcode.php');
@@ -510,7 +510,7 @@ class Enotify {
// Mark some notifications as seen right away
// Note! The notification have to be created, because they are used to send emails
// So easiest solution to hide them from Notices is to mark them as seen right away.
- // Another option would be to not add them to the DB, and change how emails are handled
+ // Another option would be to not add them to the DB, and change how emails are handled
// (probably would be better that way)
if (!$always_show_in_notices) {
@@ -555,7 +555,7 @@ class Enotify {
// wretched hack, but we don't want to duplicate all the preamble variations and we also don't want to screw up a translation
if ((\App::$language === 'en' || (! \App::$language)) && strpos($msg,', '))
- $msg = substr($msg,strpos($msg,', ')+1);
+ $msg = substr($msg,strpos($msg,', ')+1);
$datarray['id'] = $notify_id;
$datarray['msg'] = $msg;
@@ -587,12 +587,12 @@ class Enotify {
$htmlversion = bbcode(stripslashes(str_replace(array("\\r","\\n"), array("","<br />\n"),$body)));
- // use $_SESSION['zid_override'] to force zid() to use
+ // use $_SESSION['zid_override'] to force zid() to use
// the recipient address instead of the current observer
$_SESSION['zid_override'] = channel_reddress($recip);
$_SESSION['zrl_override'] = z_root() . '/channel/' . $recip['channel_address'];
-
+
$textversion = zidify_links($textversion);
$htmlversion = zidify_links($htmlversion);
@@ -754,7 +754,7 @@ class Enotify {
return $params['result'];
}
- $fromName = email_header_encode(html_entity_decode($params['fromName'],ENT_QUOTES,'UTF-8'),'UTF-8');
+ $fromName = email_header_encode(html_entity_decode($params['fromName'],ENT_QUOTES,'UTF-8'),'UTF-8');
$messageSubject = email_header_encode(html_entity_decode($params['messageSubject'],ENT_QUOTES,'UTF-8'),'UTF-8');
// generate a mime boundary
@@ -767,8 +767,8 @@ class Enotify {
$messageHeader =
$params['additionalMailHeader'] .
"From: $fromName <{$params['fromEmail']}>" . PHP_EOL .
- "Reply-To: $fromName <{$params['replyTo']}>" . PHP_EOL .
- "MIME-Version: 1.0" . PHP_EOL .
+ "Reply-To: $fromName <{$params['replyTo']}>" . PHP_EOL .
+ "MIME-Version: 1.0" . PHP_EOL .
"Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\"";
// assemble the final multipart message body with the text and html types included
@@ -782,7 +782,7 @@ class Enotify {
$textBody . PHP_EOL .
"--" . $mimeBoundary . PHP_EOL . // text/html section
"Content-Type: text/html; charset=UTF-8" . PHP_EOL .
- "Content-Transfer-Encoding: base64" . PHP_EOL . PHP_EOL .
+ "Content-Transfer-Encoding: base64" . PHP_EOL . PHP_EOL .
$htmlBody . PHP_EOL .
"--" . $mimeBoundary . "--" . PHP_EOL; // message ending
@@ -803,7 +803,7 @@ class Enotify {
require_once('include/conversation.php');
- // Call localize_item to get a one line status for activities.
+ // Call localize_item to get a one line status for activities.
// This should set $item['localized'] to indicate we have a brief summary.
// and perhaps $item['shortlocalized'] for an even briefer summary
@@ -860,7 +860,7 @@ class Enotify {
//'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])),
'thread_top' => (($item['item_thread_top']) ? true : false),
'message' => bbcode(escape_tags($itemem_text)),
- 'body' => htmlentities(html2plain(bbcode($item['body']), 75, true), ENT_COMPAT, 'UTF-8', false),
+ 'body' => htmlentities(html2plain(bbcode($item['body']), 75, true), ENT_QUOTES, 'UTF-8', false),
// these are for the superblock addon
'hash' => $item[$who]['xchan_hash'],
'uid' => $item['uid'],
diff --git a/Zotlabs/Lib/JSalmon.php b/Zotlabs/Lib/JSalmon.php
index 48a4e649b..7f63cf914 100644
--- a/Zotlabs/Lib/JSalmon.php
+++ b/Zotlabs/Lib/JSalmon.php
@@ -40,15 +40,15 @@ class JSalmon {
$ret = [ 'results' => [] ];
if(! is_array($x)) {
- return $false;
+ return false;
}
if(! ( array_key_exists('signed',$x) && $x['signed'])) {
- return $false;
+ return false;
}
- $signed_data = preg_replace('/\s+/','',$x['data']) . '.'
- . base64url_encode($x['data_type'],true) . '.'
- . base64url_encode($x['encoding'],true) . '.'
+ $signed_data = preg_replace('/\s+/','',$x['data']) . '.'
+ . base64url_encode($x['data_type'],true) . '.'
+ . base64url_encode($x['encoding'],true) . '.'
. base64url_encode($x['alg'],true);
$key = HTTPSig::get_key(EMPTY_STR,'zot6',base64url_decode($x['sigs']['key_id']));
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index 972ebe0e9..cde4c0145 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -87,7 +87,7 @@ 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 array $msg
* optional message
* @param string $encoding
* optional encoding, default 'activitystreams'
@@ -98,7 +98,7 @@ class Libzot {
* 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 = '') {
+ static function build_packet($channel, $type = 'activity', $recipients = null, $msg = [], $encoding = 'activitystreams', $remote_key = null, $methods = '') {
$sig_method = get_config('system','signature_algorithm','sha256');
@@ -189,7 +189,7 @@ class Libzot {
* @see z_post_url()
*
* @param string $url
- * @param array $data
+ * @param string $data
* @param array $channel (required if using zot6 delivery)
* @param array $crypto (required if encrypted httpsig, requires hubloc_sitekey and site_crypto elements)
* @return array see z_post_url() for returned data format
@@ -237,7 +237,7 @@ class Libzot {
*
* @param array $them => xchan structure of sender
* @param array $channel => local channel structure of target recipient, required for "friending" operations
- * @param array $force (optional) default false
+ * @param boolean $force (optional) default false
*
* @return boolean
* * \b true if successful
@@ -421,7 +421,7 @@ class Libzot {
if($new_connection) {
if(! Permissions::PermsCompare($new_perms,$previous_perms))
- Master::Summon([ 'Notifier', 'permissions_create', $new_connection[0]['abook_id'] ]);
+ Master::Summon([ 'Notifier', 'permission_create', $new_connection[0]['abook_id'] ]);
Enotify::submit(
[
'type' => NOTIFY_INTRO,
diff --git a/Zotlabs/Lib/Libzotdir.php b/Zotlabs/Lib/Libzotdir.php
index b02516a98..d4c5398ee 100644
--- a/Zotlabs/Lib/Libzotdir.php
+++ b/Zotlabs/Lib/Libzotdir.php
@@ -19,7 +19,6 @@ class Libzotdir {
*/
static function find_upstream_directory($dirmode) {
- global $DIRECTORY_FALLBACK_SERVERS;
$preferred = get_config('system','directory_server');
@@ -31,7 +30,7 @@ class Libzotdir {
);
if(($r) && ($r[0]['site_flags'] & DIRECTORY_MODE_STANDALONE)) {
$preferred = '';
- }
+ }
}
@@ -42,19 +41,21 @@ class Libzotdir {
* from our list of directory servers. However, if we're a directory
* server ourself, point at the local instance
* We will then set this value so this should only ever happen once.
- * Ideally there will be an admin setting to change to a different
+ * Ideally there will be an admin setting to change to a different
* directory server if you don't like our choice or if circumstances change.
*/
+ $directory_fallback_servers = get_directory_fallback_servers();
+
$dirmode = intval(get_config('system','directory_mode'));
if ($dirmode == DIRECTORY_MODE_NORMAL) {
- $toss = mt_rand(0,count($DIRECTORY_FALLBACK_SERVERS));
- $preferred = $DIRECTORY_FALLBACK_SERVERS[$toss];
+ $toss = mt_rand(0,count($directory_fallback_servers));
+ $preferred = $directory_fallback_servers[$toss];
if(! $preferred) {
$preferred = DIRECTORY_FALLBACK_MASTER;
}
set_config('system','directory_server',$preferred);
- }
+ }
else {
set_config('system','directory_server',z_root());
}
@@ -108,7 +109,7 @@ class Libzotdir {
$ret = get_config('directory', $setting);
- // 'safemode' is the default if there is no observer or no established preference.
+ // 'safemode' is the default if there is no observer or no established preference.
if($setting === 'safemode' && $ret === false)
$ret = 1;
@@ -175,8 +176,8 @@ class Libzotdir {
*
* Checks the directory mode of this hub to see if it is some form of directory server. If it is,
* get the directory realm of this hub. Fetch a list of all other directory servers in this realm and request
- * a directory sync packet. This will contain both directory updates and new ratings. Store these all in the DB.
- * In the case of updates, we will query each of them asynchronously from a poller task. Ratings are stored
+ * a directory sync packet. This will contain both directory updates and new ratings. Store these all in the DB.
+ * In the case of updates, we will query each of them asynchronously from a poller task. Ratings are stored
* directly if the rater's signature matches.
*
* @param int $dirmode;
@@ -188,16 +189,17 @@ class Libzotdir {
return;
$realm = get_directory_realm();
+
if ($realm == DIRECTORY_REALM) {
- $r = q("select * from site where (site_flags & %d) > 0 and site_url != '%s' and site_type = %d and ( site_realm = '%s' or site_realm = '') ",
+ $r = q("select * from site where (site_flags & %d) > 0 and site_url != '%s' and site_type = %d and ( site_realm = '%s' or site_realm = '') and site_dead = 0",
intval(DIRECTORY_MODE_PRIMARY|DIRECTORY_MODE_SECONDARY),
dbesc(z_root()),
intval(SITE_TYPE_ZOT),
dbesc($realm)
);
- }
+ }
else {
- $r = q("select * from site where (site_flags & %d) > 0 and site_url != '%s' and site_realm like '%s' and site_type = %d ",
+ $r = q("select * from site where (site_flags & %d) > 0 and site_url != '%s' and site_realm like '%s' and site_type = %d and site_dead = 0",
intval(DIRECTORY_MODE_PRIMARY|DIRECTORY_MODE_SECONDARY),
dbesc(z_root()),
dbesc(protect_sprintf('%' . $realm . '%')),
@@ -205,6 +207,8 @@ class Libzotdir {
);
}
+
+
// If there are no directory servers, setup the fallback master
/** @FIXME What to do if we're in a different realm? */
@@ -214,14 +218,14 @@ class Libzotdir {
[
'site_url' => DIRECTORY_FALLBACK_MASTER,
'site_flags' => DIRECTORY_MODE_PRIMARY,
- 'site_update' => NULL_DATE,
+ 'site_update' => NULL_DATE,
'site_directory' => DIRECTORY_FALLBACK_MASTER . '/dirsearch',
'site_realm' => DIRECTORY_REALM,
'site_valid' => 1,
]
);
- $r = q("select * from site where site_flags in (%d, %d) and site_url != '%s' and site_type = %d ",
+ $r = q("select * from site where site_flags in (%d, %d) and site_url != '%s' and site_type = %d and site_dead = 0",
intval(DIRECTORY_MODE_PRIMARY),
intval(DIRECTORY_MODE_SECONDARY),
dbesc(z_root()),
@@ -245,7 +249,6 @@ class Libzotdir {
$syncdate = (($rr['site_sync'] <= NULL_DATE) ? datetime_convert('UTC','UTC','now - 2 days') : $rr['site_sync']);
$x = z_fetch_url($rr['site_directory'] . '?f=&sync=' . urlencode($syncdate) . (($token) ? '&t=' . $token : ''));
-
if (! $x['success'])
continue;
@@ -273,7 +276,7 @@ class Libzotdir {
$ud_flags |= UPDATE_FLAGS_DELETED;
if (is_array($t['flags']) && in_array('forced',$t['flags']))
$ud_flags |= UPDATE_FLAGS_FORCED;
-
+
$z = q("insert into updates ( ud_hash, ud_guid, ud_date, ud_flags, ud_addr )
values ( '%s', '%s', '%s', %d, '%s' ) ",
dbesc($t['hash']),
@@ -338,7 +341,7 @@ class Libzotdir {
static function local_dir_update($uid, $force) {
-
+
logger('local_dir_update: uid: ' . $uid, LOGGER_DEBUG);
$p = q("select channel.channel_hash, channel_address, channel_timezone, channel_portable_id, profile.* from profile left join channel on channel_id = uid where uid = %d and is_default = 1",
@@ -354,7 +357,7 @@ class Libzotdir {
$profile['description'] = $p[0]['pdesc'];
$profile['birthday'] = $p[0]['dob'];
- if ($age = age($p[0]['dob'],$p[0]['channel_timezone'],''))
+ if ($age = age($p[0]['dob'],$p[0]['channel_timezone'],''))
$profile['age'] = $age;
$profile['gender'] = $p[0]['gender'];
@@ -415,7 +418,7 @@ class Libzotdir {
dbesc($legacy_hash)
);
}
-
+
}
$ud_hash = random_string() . '@' . \App::get_hostname();
@@ -446,7 +449,7 @@ class Libzotdir {
$arr['xprof_hash'] = $hash;
$arr['xprof_dob'] = (($profile['birthday'] === '0000-00-00') ? $profile['birthday'] : datetime_convert('','',$profile['birthday'],'Y-m-d')); // !!!! check this for 0000 year
$arr['xprof_age'] = (($profile['age']) ? intval($profile['age']) : 0);
- $arr['xprof_desc'] = (($profile['description']) ? htmlspecialchars($profile['description'], ENT_COMPAT,'UTF-8',false) : '');
+ $arr['xprof_desc'] = (($profile['description']) ? htmlspecialchars($profile['description'], ENT_COMPAT,'UTF-8',false) : '');
$arr['xprof_gender'] = (($profile['gender']) ? htmlspecialchars($profile['gender'], ENT_COMPAT,'UTF-8',false) : '');
$arr['xprof_marital'] = (($profile['marital']) ? htmlspecialchars($profile['marital'], ENT_COMPAT,'UTF-8',false) : '');
$arr['xprof_sexual'] = (($profile['sexual']) ? htmlspecialchars($profile['sexual'], ENT_COMPAT,'UTF-8',false) : '');
@@ -641,7 +644,7 @@ class Libzotdir {
dbesc(datetime_convert()),
intval($flags),
dbesc($addr)
- );
+ );
}
else {
q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and not (ud_flags & %d)>0 ",
diff --git a/Zotlabs/Lib/NativeWiki.php b/Zotlabs/Lib/NativeWiki.php
index 3ec032075..c3032d02c 100644
--- a/Zotlabs/Lib/NativeWiki.php
+++ b/Zotlabs/Lib/NativeWiki.php
@@ -9,7 +9,7 @@ define ( 'NWIKI_ITEM_RESOURCE_TYPE', 'nwiki' );
class NativeWiki {
- static public function listwikis($channel, $observer_hash) {
+ public static function listwikis($channel, $observer_hash) {
$sql_extra = item_permissions_sql($channel['channel_id'], $observer_hash);
$wikis = q("SELECT * FROM item
@@ -40,7 +40,7 @@ class NativeWiki {
}
- function create_wiki($channel, $observer_hash, $wiki, $acl) {
+ public static function create_wiki($channel, $observer_hash, $wiki, $acl) {
$resource_id = new_uuid();
$uuid = new_uuid();
@@ -101,7 +101,7 @@ class NativeWiki {
}
}
- function update_wiki($channel_id, $observer_hash, $arr, $acl) {
+ public static function update_wiki($channel_id, $observer_hash, $arr, $acl) {
$w = self::get_wiki($channel_id, $observer_hash, $arr['resource_id']);
$item = $w['wiki'];
@@ -156,7 +156,7 @@ class NativeWiki {
}
}
- static public function sync_a_wiki_item($uid,$id,$resource_id) {
+ public static function sync_a_wiki_item($uid,$id,$resource_id) {
$r = q("SELECT * from item WHERE uid = %d AND ( id = %d OR ( resource_type = '%s' and resource_id = '%s' )) ",
@@ -185,7 +185,7 @@ class NativeWiki {
}
}
- function delete_wiki($channel_id,$observer_hash,$resource_id) {
+ public static function delete_wiki($channel_id,$observer_hash,$resource_id) {
$w = self::get_wiki($channel_id,$observer_hash,$resource_id);
$item = $w['wiki'];
@@ -202,7 +202,7 @@ class NativeWiki {
}
- static public function get_wiki($channel_id, $observer_hash, $resource_id) {
+ public static function get_wiki($channel_id, $observer_hash, $resource_id) {
$sql_extra = item_permissions_sql($channel_id,$observer_hash);
@@ -236,7 +236,7 @@ class NativeWiki {
}
- static public function exists_by_name($uid, $urlName) {
+ public static function exists_by_name($uid, $urlName) {
$sql_extra = item_permissions_sql($uid);
@@ -258,7 +258,7 @@ class NativeWiki {
}
- static public function get_permissions($resource_id, $owner_id, $observer_hash) {
+ public static function get_permissions($resource_id, $owner_id, $observer_hash) {
// TODO: For now, only the owner can edit
$sql_extra = item_permissions_sql($owner_id, $observer_hash);
diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php
index d84cc50a8..71f193b70 100644
--- a/Zotlabs/Lib/NativeWikiPage.php
+++ b/Zotlabs/Lib/NativeWikiPage.php
@@ -163,7 +163,7 @@ class NativeWikiPage {
return [ 'success' => true, 'page' => $page ];
}
- return [ 'success' => false, 'item_id' => $c['item_id'], 'message' => t('Page not found') ];
+ return [ 'success' => false, 'message' => t('Page not found') ];
}
@@ -339,7 +339,6 @@ class NativeWikiPage {
}
static public function save_page($arr) {
-
$pageUrlName = ((array_key_exists('pageUrlName',$arr)) ? $arr['pageUrlName'] : '');
$content = ((array_key_exists('content',$arr)) ? $arr['content'] : '');
$resource_id = ((array_key_exists('resource_id',$arr)) ? $arr['resource_id'] : '');
@@ -385,7 +384,7 @@ class NativeWikiPage {
$ret = item_store($item, false, false);
if($ret['item_id'])
- return array('message' => '', 'item_id' => $ret['item_id'], 'filename' => $filename, 'success' => true);
+ return array('message' => '', 'item_id' => $ret['item_id'], 'filename' => $pageUrlName, 'success' => true);
else
return array('message' => t('Page update failed.'), 'success' => false);
}
@@ -432,12 +431,12 @@ class NativeWikiPage {
$channel_id = ((array_key_exists('channel_id',$arr)) ? $arr['channel_id'] : 0);
if (! $commitHash) {
- return array('content' => $content, 'message' => 'No commit was provided', 'success' => false);
+ return array('message' => 'No commit was provided', 'success' => false);
}
$w = Zlib\NativeWiki::get_wiki($channel_id, $observer_hash, $resource_id);
if (!$w['wiki']) {
- return array('content' => $content, 'message' => 'Error reading wiki', 'success' => false);
+ return array('message' => 'Error reading wiki', 'success' => false);
}
$x = $arr;
@@ -451,7 +450,7 @@ class NativeWikiPage {
$content = $loaded['body'];
return [ 'content' => $content, 'success' => true ];
}
- return [ 'content' => $content, 'success' => false ];
+ return [ 'success' => false ];
}
}
diff --git a/Zotlabs/Lib/Queue.php b/Zotlabs/Lib/Queue.php
index 6acc58bc5..779719d8b 100644
--- a/Zotlabs/Lib/Queue.php
+++ b/Zotlabs/Lib/Queue.php
@@ -2,9 +2,6 @@
namespace Zotlabs\Lib;
-use Zotlabs\Lib\Libzot;
-
-
class Queue {
static function update($id, $add_priority = 0) {
@@ -39,7 +36,7 @@ class Queue {
// queue item is less than 12 hours old, we'll schedule for fifteen
// minutes.
- $r = q("UPDATE outq SET outq_scheduled = '%s' WHERE outq_posturl = '%s'",
+ q("UPDATE outq SET outq_scheduled = '%s' WHERE outq_posturl = '%s'",
dbesc(datetime_convert('UTC','UTC','now + 5 days')),
dbesc($x[0]['outq_posturl'])
);
@@ -88,7 +85,7 @@ class Queue {
static function set_delivered($id,$channel = 0) {
logger('queue: set delivered ' . $id,LOGGER_DEBUG);
- $sql_extra = (($channel_id) ? " and outq_channel = " . intval($channel_id) . " " : '');
+ $sql_extra = (($channel['channel_id']) ? " and outq_channel = " . intval($channel['channel_id']) . " " : '');
// Set the next scheduled run date so far in the future that it will be expired
// long before it ever makes it back into the delivery chain.
@@ -230,11 +227,10 @@ class Queue {
logger('deliver: dest: ' . $outq['outq_posturl'], LOGGER_DEBUG);
-
if($outq['outq_posturl'] === z_root() . '/zot') {
// local delivery
$zot = new \Zotlabs\Zot6\Receiver(new \Zotlabs\Zot6\Zot6Handler(),$outq['outq_notify']);
- $result = $zot->run(true);
+ $result = $zot->run();
logger('returned_json: ' . json_encode($result,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES), LOGGER_DATA);
logger('deliver: local zot delivery succeeded to ' . $outq['outq_posturl']);
Libzot::process_response($outq['outq_posturl'],[ 'success' => true, 'body' => json_encode($result) ], $outq);
diff --git a/Zotlabs/Lib/Share.php b/Zotlabs/Lib/Share.php
index d34c0eaba..b4cd5a194 100644
--- a/Zotlabs/Lib/Share.php
+++ b/Zotlabs/Lib/Share.php
@@ -2,8 +2,6 @@
namespace Zotlabs\Lib;
-use Zotlabs\Lib\Activity;
-
class Share {
private $item = null;
diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php
index 024502d2a..b7eecbd94 100644
--- a/Zotlabs/Lib/ThreadItem.php
+++ b/Zotlabs/Lib/ThreadItem.php
@@ -35,7 +35,7 @@ class ThreadItem {
public function __construct($data) {
-
+
$this->data = $data;
$this->toplevel = ($this->get_id() == $this->get_data_value('parent'));
$this->threaded = get_config('system','thread_allow');
@@ -98,7 +98,7 @@ class ThreadItem {
$conv = $this->get_conversation();
$observer = $conv->get_observer();
- $lock = (((intval($item['item_private'])) || (($item['uid'] == local_channel()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
+ $lock = (((intval($item['item_private'])) || (($item['uid'] == local_channel()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
? t('Private Message')
: false);
@@ -151,9 +151,9 @@ class ThreadItem {
if($observer && $observer['xchan_hash']
- && ($observer['xchan_hash'] == $this->get_data_value('author_xchan')
- || $observer['xchan_hash'] == $this->get_data_value('owner_xchan')
- || $observer['xchan_hash'] == $this->get_data_value('source_xchan')
+ && ($observer['xchan_hash'] == $this->get_data_value('author_xchan')
+ || $observer['xchan_hash'] == $this->get_data_value('owner_xchan')
+ || $observer['xchan_hash'] == $this->get_data_value('source_xchan')
|| $this->get_data_value('uid') == local_channel()))
$dropping = true;
@@ -169,15 +169,15 @@ class ThreadItem {
'dropping' => $dropping,
'delete' => t('Delete'),
);
- }
+ }
elseif(is_site_admin()) {
$drop = [ 'dropping' => true, 'delete' => t('Admin Delete') ];
}
// FIXME
- if($observer_is_pageowner) {
+ if($observer_is_pageowner) {
$multidrop = array(
- 'select' => t('Select'),
+ 'select' => t('Select'),
);
}
@@ -223,7 +223,7 @@ class ThreadItem {
if(! feature_enabled($conv->get_profile_owner(),'dislike'))
unset($conv_responses['dislike']);
-
+
$responses = get_responses($conv_responses,$response_verbs,$this,$item);
$my_responses = [];
@@ -254,7 +254,7 @@ class ThreadItem {
}
$showlike = ((x($conv_responses['like'],$item['mid'])) ? format_like($conv_responses['like'][$item['mid']],$conv_responses['like'][$item['mid'] . '-l'],'like',$item['mid']) : '');
- $showdislike = ((x($conv_responses['dislike'],$item['mid']) && feature_enabled($conv->get_profile_owner(),'dislike'))
+ $showdislike = ((x($conv_responses['dislike'],$item['mid']) && feature_enabled($conv->get_profile_owner(),'dislike'))
? format_like($conv_responses['dislike'][$item['mid']],$conv_responses['dislike'][$item['mid'] . '-l'],'dislike',$item['mid']) : '');
/*
@@ -264,7 +264,7 @@ class ThreadItem {
*/
$this->check_wall_to_wall();
-
+
if($this->is_toplevel()) {
// FIXME check this permission
if(($conv->get_profile_owner() == local_channel()) && (! array_key_exists('real_uid',$item))) {
@@ -275,7 +275,7 @@ class ThreadItem {
);
}
- }
+ }
else {
$is_comment = true;
}
@@ -349,7 +349,7 @@ class ThreadItem {
// $viewthread (below) is only valid in list mode. If this is a channel page, build the thread viewing link
// since we can't depend on llink or plink pointing to the right local location.
-
+
$owner_address = substr($item['owner']['xchan_addr'],0,strpos($item['owner']['xchan_addr'],'@'));
$viewthread = $item['llink'];
if($conv->get_mode() === 'channel')
@@ -357,7 +357,7 @@ class ThreadItem {
$comment_count_txt = sprintf( tt('%d comment','%d comments',$total_children),$total_children );
$list_unseen_txt = (($unseen_comments) ? sprintf( t('%d unseen'),$unseen_comments) : '');
-
+
$children = $this->get_children();
$has_tags = (($body['tags'] || $body['categories'] || $body['mentions'] || $body['attachments'] || $body['folders']) ? true : false);
@@ -386,7 +386,7 @@ class ThreadItem {
$tmp_item = array(
'template' => $this->get_template(),
'mode' => $mode,
- 'item_type' => intval($item['item_type']),
+ 'item_type' => intval($item['item_type']),
//'type' => implode("",array_slice(explode("/",$item['verb']),-1)),
'body' => $body['html'],
'tags' => $body['tags'],
@@ -518,8 +518,8 @@ class ThreadItem {
// needed for scroll to comment from notification but needs more work
// as we do not want to open all comments unless there is actually an #item_xx anchor
-// and the url fragment is not sent to the server.
-// if(in_array(\App::$module,['display','update_display']))
+// and the url fragment is not sent to the server.
+// if(in_array(\App::$module,['display','update_display']))
// $visible_comments = 99999;
if(($this->get_display_mode() === 'normal') && ($nb_children > 0)) {
@@ -539,7 +539,7 @@ class ThreadItem {
}
}
}
-
+
$result['private'] = $item['item_private'];
$result['toplevel'] = ($this->is_toplevel() ? 'toplevel_item' : '');
@@ -554,7 +554,7 @@ class ThreadItem {
return $result;
}
-
+
public function get_id() {
return $this->get_data_value('id');
}
@@ -609,7 +609,7 @@ class ThreadItem {
if(activity_match($item->get_data_value('verb'),ACTIVITY_LIKE) || activity_match($item->get_data_value('verb'),ACTIVITY_DISLIKE)) {
return false;
}
-
+
$item->set_parent($this);
$this->children[] = $item;
return end($this->children);
@@ -683,7 +683,7 @@ class ThreadItem {
*/
public function set_conversation($conv) {
$previous_mode = ($this->conversation ? $this->conversation->get_mode() : '');
-
+
$this->conversation = $conv;
// Set it on our children too
@@ -792,7 +792,7 @@ class ThreadItem {
if(!$this->is_toplevel() && !get_config('system','thread_allow')) {
return '';
}
-
+
$comment_box = '';
$conv = $this->get_conversation();
@@ -808,7 +808,7 @@ class ThreadItem {
$arr = array('comment_buttons' => '','id' => $this->get_id());
call_hooks('comment_buttons',$arr);
$comment_buttons = $arr['comment_buttons'];
-
+
$comment_box = replace_macros($template,array(
'$return_path' => '',
'$threaded' => $this->is_threaded(),
@@ -865,7 +865,7 @@ class ThreadItem {
if($conv->get_mode() === 'channel')
return;
-
+
if($this->is_toplevel() && ($this->get_data_value('author_xchan') != $this->get_data_value('owner_xchan'))) {
$this->owner_url = chanlink_hash($this->data['owner']['xchan_hash']);
$this->owner_photo = $this->data['owner']['xchan_photo_m'];
diff --git a/Zotlabs/Lib/Verify.php b/Zotlabs/Lib/Verify.php
index 8703e29e6..f8dc8f8d4 100644
--- a/Zotlabs/Lib/Verify.php
+++ b/Zotlabs/Lib/Verify.php
@@ -5,7 +5,7 @@ namespace Zotlabs\Lib;
class Verify {
- function create($type,$channel_id,$token,$meta) {
+ public static function create($type,$channel_id,$token,$meta) {
return q("insert into verify ( vtype, channel, token, meta, created ) values ( '%s', %d, '%s', '%s', '%s' )",
dbesc($type),
intval($channel_id),
@@ -15,7 +15,7 @@ class Verify {
);
}
- function match($type,$channel_id,$token,$meta) {
+ public static function match($type,$channel_id,$token,$meta) {
$r = q("select id from verify where vtype = '%s' and channel = %d and token = '%s' and meta = '%s' limit 1",
dbesc($type),
intval($channel_id),
@@ -31,7 +31,7 @@ class Verify {
return false;
}
- function get_meta($type,$channel_id,$token) {
+ public static function get_meta($type,$channel_id,$token) {
$r = q("select id, meta from verify where vtype = '%s' and channel = %d and token = '%s' limit 1",
dbesc($type),
intval($channel_id),
@@ -52,7 +52,7 @@ class Verify {
* @param string $type Verify type
* @param string $interval SQL compatible time interval
*/
- function purge($type, $interval) {
+ public static function purge($type, $interval) {
q("delete from verify where vtype = '%s' and created < %s - INTERVAL %s",
dbesc($type),
db_utcnow(),
diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php
index e0206bd43..fb95b0504 100644
--- a/Zotlabs/Module/Acl.php
+++ b/Zotlabs/Module/Acl.php
@@ -2,6 +2,8 @@
namespace Zotlabs\Module;
+use Zotlabs\Lib\Libzotdir;
+
require_once 'include/acl_selectors.php';
require_once 'include/group.php';
@@ -46,20 +48,20 @@ class Acl extends \Zotlabs\Web\Controller {
// 'a' => autocomplete connections (mod_connections, mod_poke, mod_sources, mod_photos)
// 'x' => nav search bar autocomplete (match any xchan)
// $_REQUEST['query'] contains autocomplete search text.
-
- // List of channels whose connections to also suggest,
+
+ // List of channels whose connections to also suggest,
// e.g. currently viewed channel or channels mentioned in a post
$extra_channels = (x($_REQUEST,'extra_channels') ? $_REQUEST['extra_channels'] : array());
-
+
// The different autocomplete libraries use different names for the search text
// parameter. Internally we'll use $search to represent the search text no matter
- // what request variable it was attached to.
-
+ // what request variable it was attached to.
+
if(array_key_exists('query',$_REQUEST)) {
$search = $_REQUEST['query'];
}
-
+
if( (! local_channel()) && (! in_array($type, [ 'x', 'c', 'f' ])))
killme();
@@ -68,7 +70,7 @@ class Acl extends \Zotlabs\Web\Controller {
if(in_array($type, [ 'm', 'a', 'c', 'f' ])) {
// These queries require permission checking. We'll create a simple array of xchan_hash for those with
- // the requisite permissions which we can check against.
+ // the requisite permissions which we can check against.
$x = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = '%s' and v = '1'",
intval(local_channel()),
@@ -85,34 +87,34 @@ class Acl extends \Zotlabs\Web\Controller {
$sql_extra2 = "AND ( xchan_name LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " OR xchan_addr LIKE " . protect_sprintf( "'%" . dbesc(punify($search)) . ((strpos($search,'@') === false) ? "%@%'" : "%'")) . ") ";
$sql_extra2_xchan = "AND ( xchan_name LIKE " . protect_sprintf( "'" . dbesc($search) . "%'" ) . " OR xchan_addr LIKE " . protect_sprintf( "'" . dbesc(punify($search)) . ((strpos($search,'@') === false) ? "%@%'" : "%'")) . ") ";
- // This horrible mess is needed because position also returns 0 if nothing is found.
+ // This horrible mess is needed because position also returns 0 if nothing is found.
// Would be MUCH easier if it instead returned a very large value
- // Otherwise we could just
+ // Otherwise we could just
// order by LEAST(POSITION($search IN xchan_name),POSITION($search IN xchan_addr)).
- $order_extra2 = "CASE WHEN xchan_name LIKE "
- . protect_sprintf( "'%" . dbesc($search) . "%'" )
- . " then POSITION('" . protect_sprintf(dbesc($search))
+ $order_extra2 = "CASE WHEN xchan_name LIKE "
+ . protect_sprintf( "'%" . dbesc($search) . "%'" )
+ . " then POSITION('" . protect_sprintf(dbesc($search))
. "' IN xchan_name) else position('" . protect_sprintf(dbesc(punify($search))) . "' IN xchan_addr) end, ";
$sql_extra3 = "AND ( xchan_addr like " . protect_sprintf( "'%" . dbesc(punify($search)) . "%'" ) . " OR xchan_name like " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " ) ";
-
+
}
else {
$sql_extra = $sql_extra2 = $sql_extra3 = "";
}
-
-
+
+
$groups = array();
$contacts = array();
-
+
if($type == '' || $type == 'g') {
// virtual groups based on private profile viewing ability
$r = q("select id, profile_guid, profile_name from profile where is_default = 0 and uid = %d",
intval(local_channel())
- );
+ );
if($r) {
foreach($r as $rv) {
$groups[] = array(
@@ -130,19 +132,19 @@ class Acl extends \Zotlabs\Web\Controller {
// Normal privacy groups
$r = q("SELECT pgrp.id, pgrp.hash, pgrp.gname
- FROM pgrp, pgrp_member
- WHERE pgrp.deleted = 0 AND pgrp.uid = %d
+ FROM pgrp, pgrp_member
+ WHERE pgrp.deleted = 0 AND pgrp.uid = %d
AND pgrp_member.gid = pgrp.id
$sql_extra
GROUP BY pgrp.id
- ORDER BY pgrp.gname
+ ORDER BY pgrp.gname
LIMIT %d OFFSET %d",
intval(local_channel()),
intval($count),
intval($start)
);
- if($r) {
+ if($r) {
foreach($r as $g){
// logger('acl: group: ' . $g['gname'] . ' members: ' . group_get_members_xchan($g['id']));
$groups[] = array(
@@ -157,10 +159,10 @@ class Acl extends \Zotlabs\Web\Controller {
}
}
}
-
+
if($type == '' || $type == 'c' || $type === 'f') {
- $extra_channels_sql = '';
+ $extra_channels_sql = '';
// Only include channels who allow the observer to view their connections
if($extra_channels) {
@@ -172,7 +174,7 @@ class Acl extends \Zotlabs\Web\Controller {
}
}
}
-
+
// Getting info from the abook is better for local users because it contains info about permissions
if(local_channel()) {
if($extra_channels_sql != '')
@@ -199,7 +201,7 @@ class Acl extends \Zotlabs\Web\Controller {
$r2 = array();
foreach($r1 as $rr) {
$x = atoken_xchan($rr);
- $r2[] = [
+ $r2[] = [
'id' => 'a' . $rr['atoken_id'] ,
'hash' => $x['xchan_hash'],
'name' => $x['xchan_name'],
@@ -211,12 +213,12 @@ class Acl extends \Zotlabs\Web\Controller {
'abook_self' => 0
];
}
- }
+ }
// add connections
-
- $r = q("SELECT abook_id as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, abook_their_perms, xchan_pubforum, abook_flags, abook_self
- FROM abook left join xchan on abook_xchan = xchan_hash
+
+ $r = q("SELECT abook_id as id, xchan_hash as hash, xchan_name as name, xchan_network as net, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, abook_their_perms, xchan_pubforum, abook_flags, abook_self
+ FROM abook left join xchan on abook_xchan = xchan_hash
WHERE (abook_channel = %d $extra_channels_sql) AND abook_blocked = 0 and abook_pending = 0 and xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc" ,
intval(local_channel())
);
@@ -225,28 +227,28 @@ class Acl extends \Zotlabs\Web\Controller {
}
else { // Visitors
- $r = q("SELECT xchan_hash as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags, 0 as abook_self
+ $r = q("SELECT xchan_hash as id, xchan_hash as hash, xchan_name as name, xchan_network as net, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags, 0 as abook_self
FROM xchan left join xlink on xlink_link = xchan_hash
WHERE xlink_xchan = '%s' AND xchan_deleted = 0 $sql_extra2_xchan order by $order_extra2 xchan_name asc" ,
dbesc(get_observer_hash())
);
-
+
// Find contacts of extra channels
// This is probably more complicated than it needs to be
if($extra_channels_sql) {
// Build a list of hashes that we got previously so we don't get them again
$known_hashes = array("'".get_observer_hash()."'");
if($r)
- foreach($r as $rr)
+ foreach($r as $rr)
$known_hashes[] = "'".$rr['hash']."'";
$known_hashes_sql = 'AND xchan_hash not in ('.join(',',$known_hashes).')';
-
- $r2 = q("SELECT abook_id as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, abook_their_perms, abook_flags, abook_self
- FROM abook left join xchan on abook_xchan = xchan_hash
+
+ $r2 = q("SELECT abook_id as id, xchan_hash as hash, xchan_name as name, xchan_network as net, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, abook_their_perms, abook_flags, abook_self
+ FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_channel IN ($extra_channels_sql) $known_hashes_sql AND abook_blocked = 0 and abook_pending = 0 and abook_hidden = 0 and xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc");
if($r2)
$r = array_merge($r,$r2);
-
+
// Sort accoring to match position, then alphabetically. This could be avoided if the above two SQL queries could be combined into one, and the sorting could be done on the SQl server (like in the case of a local user)
$matchpos = function($x) use($search) {
$namepos = strpos($x['name'],$search);
@@ -269,22 +271,22 @@ class Acl extends \Zotlabs\Web\Controller {
}
}
if((count($r) < 100) && $type == 'c') {
- $r2 = q("SELECT substr(xchan_hash,1,18) as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags, 0 as abook_self
- FROM xchan
+ $r2 = q("SELECT substr(xchan_hash,1,18) as id, xchan_hash as hash, xchan_name as name, xchan_network as net, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags, 0 as abook_self
+ FROM xchan
WHERE xchan_deleted = 0 and not xchan_network in ('rss','anon','unknown') $sql_extra2_xchan order by $order_extra2 xchan_name asc"
);
if($r2) {
$r = array_merge($r,$r2);
$r = unique_multidim_array($r,'hash');
- }
+ }
}
}
elseif($type == 'm') {
$r = array();
- $z = q("SELECT xchan_hash as hash, xchan_name as name, xchan_addr as nick, xchan_photo_s as micro, xchan_url as url
+ $z = q("SELECT xchan_hash as hash, xchan_name as name, xchan_network as net, xchan_addr as nick, xchan_photo_s as micro, xchan_url as url
FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE abook_channel = %d
+ WHERE abook_channel = %d
and xchan_deleted = 0
and xchan_network IN ('zot', 'diaspora', 'friendica-over-diaspora')
$sql_extra3
@@ -298,18 +300,18 @@ class Acl extends \Zotlabs\Web\Controller {
}
}
}
-
+
}
elseif($type == 'a') {
-
- $r = q("SELECT abook_id as id, xchan_name as name, xchan_hash as hash, xchan_addr as nick, xchan_photo_s as micro, xchan_network as network, xchan_url as url, xchan_addr as attag , abook_their_perms FROM abook left join xchan on abook_xchan = xchan_hash
+
+ $r = q("SELECT abook_id as id, xchan_name as name, xchan_network as net, xchan_hash as hash, xchan_addr as nick, xchan_photo_s as micro, xchan_url as url, xchan_addr as attag , abook_their_perms FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_channel = %d
and xchan_deleted = 0
$sql_extra3
ORDER BY xchan_name ASC ",
intval(local_channel())
);
-
+
}
elseif($type == 'x') {
$r = $this->navbar_complete($a);
@@ -323,7 +325,7 @@ class Acl extends \Zotlabs\Web\Controller {
);
}
}
-
+
$o = array(
'start' => $start,
'count' => $count,
@@ -334,27 +336,34 @@ class Acl extends \Zotlabs\Web\Controller {
}
else
$r = array();
-
+
if($r) {
+ $i = count($contacts);
+ $x = [];
foreach($r as $g) {
-
- if(in_array($g['network'],['rss','anon','unknown']) && ($type != 'a'))
+
+ if(in_array($g['net'],['rss','anon','unknown']) && ($type != 'a'))
continue;
$g['hash'] = urlencode($g['hash']);
-
+
if(! $g['nick']) {
$g['nick'] = $g['url'];
}
+ $clink = ($g['nick']) ? $g['nick'] : $g['url'];
+ $lkey = md5($clink);
+ if (! array_key_exists($lkey, $x))
+ $x[$lkey] = $i;
+
if(in_array($g['hash'],$permitted) && $type === 'f' && (! $noforums)) {
- $contacts[] = array(
+ $contacts[$i] = array(
"type" => "c",
"photo" => "images/twopeople.png",
"name" => $g['name'],
"id" => urlencode($g['id']),
"xid" => $g['hash'],
- "link" => (($g['nick']) ? $g['nick'] : $g['url']),
+ "link" => $clink,
"nick" => substr($g['nick'],0,strpos($g['nick'],'@')),
"self" => (intval($g['abook_self']) ? 'abook-self' : ''),
"taggable" => 'taggable',
@@ -362,24 +371,28 @@ class Acl extends \Zotlabs\Web\Controller {
);
}
if($type !== 'f') {
- $contacts[] = array(
- "type" => "c",
- "photo" => $g['micro'],
- "name" => $g['name'],
- "id" => urlencode($g['id']),
- "xid" => $g['hash'],
- "link" => (($g['nick']) ? $g['nick'] : $g['url']),
- "nick" => ((strpos($g['nick'],'@')) ? substr($g['nick'],0,strpos($g['nick'],'@')) : $g['nick']),
- "self" => (intval($g['abook_self']) ? 'abook-self' : ''),
- "taggable" => '',
- "label" => '',
- );
+ if (! array_key_exists($x[$lkey], $contacts) || ($contacts[$x[$lkey]]['net'] !== 'zot6' && ($g['net'] == 'zot6' || $g['net'] == 'zot'))) {
+ $contacts[$x[$lkey]] = array(
+ "type" => "c",
+ "photo" => $g['micro'],
+ "name" => $g['name'],
+ "id" => urlencode($g['id']),
+ "xid" => $g['hash'],
+ "link" => $clink,
+ "nick" => ((strpos($g['nick'],'@')) ? substr($g['nick'],0,strpos($g['nick'],'@')) : $g['nick']),
+ "self" => (intval($g['abook_self']) ? 'abook-self' : ''),
+ "taggable" => '',
+ "label" => '',
+ "net" => $g['net']
+ );
+ }
}
- }
+ $i++;
+ }
}
-
+
$items = array_merge($groups, $contacts);
-
+
$o = array(
'start' => $start,
'count' => $count,
@@ -393,50 +406,50 @@ class Acl extends \Zotlabs\Web\Controller {
function navbar_complete(&$a) {
-
+
// logger('navbar_complete');
-
+
if(observer_prohibited()) {
return;
}
-
+
$dirmode = intval(get_config('system','directory_mode'));
$search = ((x($_REQUEST,'search')) ? htmlentities($_REQUEST['search'],ENT_COMPAT,'UTF-8',false) : '');
if(! $search || mb_strlen($search) < 2)
return array();
-
+
$star = false;
$address = false;
-
+
if(substr($search,0,1) === '@')
$search = substr($search,1);
-
+
if(substr($search,0,1) === '*') {
$star = true;
$search = substr($search,1);
}
-
+
if(strpos($search,'@') !== false) {
$address = true;
}
-
+
if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
$url = z_root() . '/dirsearch';
}
-
+
if(! $url) {
require_once("include/dir_fns.php");
- $directory = find_upstream_directory($dirmode);
+ $directory = Libzotdir::find_upstream_directory($dirmode);
$url = $directory['url'] . '/dirsearch';
}
$token = get_config('system','realm_token');
-
+
$count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 100);
if($url) {
$query = $url . '?f=' . (($token) ? '&t=' . urlencode($token) : '');
$query .= '&name=' . urlencode($search) . "&limit=$count" . (($address) ? '&address=' . urlencode(punify($search)) : '');
-
+
$x = z_fetch_url($query);
if($x['success']) {
$t = 0;
diff --git a/Zotlabs/Module/Attach.php b/Zotlabs/Module/Attach.php
index 0bf7689be..5f5779b51 100644
--- a/Zotlabs/Module/Attach.php
+++ b/Zotlabs/Module/Attach.php
@@ -1,4 +1,5 @@
<?php
+
namespace Zotlabs\Module;
use ZipArchive;
@@ -12,25 +13,24 @@ class Attach extends Controller {
function post() {
- $attach_ids = ((x($_REQUEST, 'attach_ids')) ? $_REQUEST['attach_ids'] : []);
+ $attach_ids = ((x($_REQUEST, 'attach_ids')) ? $_REQUEST['attach_ids'] : []);
$attach_path = ((x($_REQUEST, 'attach_path')) ? $_REQUEST['attach_path'] : '');
+ $channel_id = ((x($_REQUEST, 'channel_id')) ? intval($_REQUEST['channel_id']) : 0);
+ $channel = channelx_by_n($channel_id);
- $channel_id = ((x($_REQUEST, 'channel_id')) ? intval($_REQUEST['channel_id']) : 0);
- $channel = channelx_by_n($channel_id);
-
- if (! $channel) {
+ if (!$channel) {
notice(t('Channel not found.') . EOL);
return;
}
- $strip_str = '/cloud/' . $channel['channel_address'] . '/';
- $count = strlen($strip_str);
+ $strip_str = '/cloud/' . $channel['channel_address'] . '/';
+ $count = strlen($strip_str);
$attach_path = substr($attach_path, $count);
if ($attach_ids) {
$zip_dir = 'store/[data]/' . $channel['channel_address'] . '/tmp';
- if (! is_dir($zip_dir))
+ if (!is_dir($zip_dir))
mkdir($zip_dir, STORAGE_DEFAULT_PERMISSIONS, true);
$token = random_string(32);
@@ -48,14 +48,14 @@ class Attach extends Controller {
$meta = [
'zip_filename' => $zip_filename,
- 'zip_path' => $zip_path
+ 'zip_path' => $zip_path
];
Verify::create('zip_token', 0, $token, json_encode($meta));
json_return_and_die([
'success' => true,
- 'token' => $token
+ 'token' => $token
]);
}
@@ -64,25 +64,29 @@ class Attach extends Controller {
function get() {
- if(argc() < 2) {
- notice( t('Item not available.') . EOL);
+ if (argc() < 2) {
+ notice(t('Item not available.') . EOL);
return;
}
- if(argv(1) === 'download') {
+ $token = ((x($_REQUEST, 'token')) ? $_REQUEST['token'] : '');
- $token = ((x($_REQUEST, 'token')) ? $_REQUEST['token'] : '');
+ if (argv(1) === 'download') {
$meta = Verify::get_meta('zip_token', 0, $token);
+
+ if (!$meta)
+ killme();
+
$meta = json_decode($meta, true);
header('Content-Type: application/zip');
- header('Content-Disposition: attachment; filename="'. $meta['zip_filename'] . '"');
+ header('Content-Disposition: attachment; filename="' . $meta['zip_filename'] . '"');
header('Content-Length: ' . filesize($meta['zip_path']));
$istream = fopen($meta['zip_path'], 'rb');
$ostream = fopen('php://output', 'wb');
- if($istream && $ostream) {
- pipe_streams($istream,$ostream);
+ if ($istream && $ostream) {
+ pipe_streams($istream, $ostream);
fclose($istream);
fclose($ostream);
}
@@ -91,10 +95,10 @@ class Attach extends Controller {
killme();
}
- $r = attach_by_hash(argv(1),get_observer_hash(),((argc() > 2) ? intval(argv(2)) : 0));
+ $r = attach_by_hash(argv(1), get_observer_hash(), ((argc() > 2) ? intval(argv(2)) : 0));
- if(! $r['success']) {
- notice( $r['message'] . EOL);
+ if (!$r['success']) {
+ notice($r['message'] . EOL);
return;
}
@@ -102,28 +106,28 @@ class Attach extends Controller {
intval($r['data']['uid'])
);
- if(! $c)
+ if (!$c)
return;
- $unsafe_types = array('text/html','text/css','application/javascript');
+ $unsafe_types = array('text/html', 'text/css', 'application/javascript');
- if(in_array($r['data']['filetype'],$unsafe_types) && (! channel_codeallowed($r['data']['uid']))) {
- header('Content-Type: text/plain');
+ if (in_array($r['data']['filetype'], $unsafe_types) && (!channel_codeallowed($r['data']['uid']))) {
+ header('Content-Type: text/plain');
}
else {
header('Content-Type: ' . $r['data']['filetype']);
}
header('Content-Disposition: attachment; filename="' . $r['data']['filename'] . '"');
- if(intval($r['data']['os_storage'])) {
+ if (intval($r['data']['os_storage'])) {
$fname = $r['data']['content'];
- if(strpos($fname,'store') !== false)
- $istream = fopen($fname,'rb');
+ if (strpos($fname, 'store') !== false)
+ $istream = fopen($fname, 'rb');
else
- $istream = fopen('store/' . $c[0]['channel_address'] . '/' . $fname,'rb');
- $ostream = fopen('php://output','wb');
- if($istream && $ostream) {
- pipe_streams($istream,$ostream);
+ $istream = fopen('store/' . $c[0]['channel_address'] . '/' . $fname, 'rb');
+ $ostream = fopen('php://output', 'wb');
+ if ($istream && $ostream) {
+ pipe_streams($istream, $ostream);
fclose($istream);
fclose($ostream);
}
@@ -137,14 +141,14 @@ class Attach extends Controller {
public function zip_archive_handler($zip, $attach_ids, $attach_path, $pass = 1) {
$observer_hash = get_observer_hash();
- $single = ((count($attach_ids) == 1) ? true : false);
+ $single = ((count($attach_ids) == 1) ? true : false);
$download_name = 'download.zip';
- foreach($attach_ids as $attach_id) {
+ foreach ($attach_ids as $attach_id) {
$r = attach_by_id($attach_id, $observer_hash);
- if (! $r['success']) {
+ if (!$r['success']) {
continue;
}
@@ -155,8 +159,8 @@ class Attach extends Controller {
if ($attach_path) {
$strip_str = $attach_path . '/';
- $count = strlen($strip_str);
- $zip_path = substr($r['data']['display_path'], $count);
+ $count = strlen($strip_str);
+ $zip_path = substr($r['data']['display_path'], $count);
}
if ($r['data']['is_dir']) {
@@ -172,6 +176,8 @@ class Attach extends Controller {
else {
$file_path = $r['data']['content'];
$zip->addFile($file_path, $zip_path);
+ // compressing can be ressource intensive - just store the data
+ $zip->setCompressionName($zip_path, ZipArchive::CM_STORE);
}
}
diff --git a/Zotlabs/Module/Cal.php b/Zotlabs/Module/Cal.php
index 07bee38bd..65dba927b 100644
--- a/Zotlabs/Module/Cal.php
+++ b/Zotlabs/Module/Cal.php
@@ -37,8 +37,6 @@ class Cal extends Controller {
$observer = App::get_observer();
App::$data['observer'] = $observer;
- $observer_xchan = (($observer) ? $observer['xchan_hash'] : '');
-
head_set_icon(App::$data['channel']['xchan_photo_s']);
App::$page['htmlhead'] .= "<script> var profile_uid = " . ((App::$data['channel']) ? App::$data['channel']['channel_id'] : 0) . "; </script>" ;
@@ -159,10 +157,10 @@ class Cal extends Controller {
'timezone' => $tz,
'start'=> $start,
'end' => $end,
- 'drop' => $drop,
+ 'drop' => false,
'allDay' => (($rr['adjust']) ? 0 : 1),
'title' => html_entity_decode($rr['summary'], ENT_COMPAT, 'UTF-8'),
- 'editable' => $edit ? true : false,
+ 'editable' => false,
'item' => $rr,
'plink' => [$rr['plink'], t('Link to source')],
'description' => html_entity_decode($rr['description'], ENT_COMPAT, 'UTF-8'),
@@ -205,9 +203,9 @@ class Cal extends Controller {
'$prev' => t('Previous'),
'$next' => t('Next'),
'$today' => t('Today'),
- '$title' => $title,
- '$dtstart' => $dtstart,
- '$dtend' => $dtend,
+ '$title' => '',
+ '$dtstart' => '',
+ '$dtend' => '',
'$nick' => $nick
]);
diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php
index f7e43e436..fe697a526 100644
--- a/Zotlabs/Module/Cdav.php
+++ b/Zotlabs/Module/Cdav.php
@@ -50,7 +50,7 @@ class Cdav extends Controller {
if($sigblock) {
$keyId = str_replace('acct:','',$sigblock['keyId']);
if($keyId) {
- $r = q("select * from hubloc where hubloc_addr = '%s'",
+ $r = q("select * from hubloc where hubloc_id_url = '%s'",
dbesc($keyId)
);
if($r) {
@@ -284,7 +284,7 @@ class Cdav extends Controller {
$server->addPlugin(new \Sabre\CardDAV\VCFExportPlugin());
// And off we go!
- $server->exec();
+ $server->start();
killme();
diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php
index 7ff394750..fe7341e52 100644
--- a/Zotlabs/Module/Channel.php
+++ b/Zotlabs/Module/Channel.php
@@ -25,7 +25,7 @@ class Channel extends Controller {
function init() {
- if(in_array(substr($_GET['search'],0,1),[ '@', '!', '?']))
+ if(in_array(substr($_GET['search'],0,1),[ '@', '!', '?']))
goaway('search' . '?f=&search=' . $_GET['search']);
$which = null;
@@ -56,10 +56,10 @@ class Channel extends Controller {
http_status_exit(404, 'Not found');
}
- // handle zot6 channel discovery
+ // handle zot6 channel discovery
if(Libzot::is_zot_request()) {
-
+
$sigdata = HTTPSig::verify(file_get_contents('php://input'), EMPTY_STR, 'zot6');
if($sigdata && $sigdata['signer'] && $sigdata['header_valid']) {
@@ -76,8 +76,8 @@ class Channel extends Controller {
$data = json_encode(Libzot::zotinfo([ 'address' => $channel['channel_address'] ]));
}
- $headers = [
- 'Content-Type' => 'application/x-zot+json',
+ $headers = [
+ 'Content-Type' => 'application/x-zot+json',
'Digest' => HTTPSig::generate_digest_header($data),
'(request-target)' => strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI']
];
@@ -93,15 +93,15 @@ class Channel extends Controller {
$profile = argv(1);
}
- head_add_link( [
- 'rel' => 'alternate',
+ head_add_link( [
+ 'rel' => 'alternate',
'type' => 'application/atom+xml',
'title' => t('Posts and comments'),
'href' => z_root() . '/feed/' . $which
]);
- head_add_link( [
- 'rel' => 'alternate',
+ head_add_link( [
+ 'rel' => 'alternate',
'type' => 'application/atom+xml',
'title' => t('Only posts'),
'href' => z_root() . '/feed/' . $which . '?f=&top=1'
@@ -111,18 +111,18 @@ class Channel extends Controller {
// Run profile_load() here to make sure the theme is set before
// we start loading content
profile_load($which,$profile);
-
+
// Add Opengraph markup
$mid = ((x($_REQUEST,'mid')) ? $_REQUEST['mid'] : '');
if(strpos($mid,'b64.') === 0)
$mid = @base64url_decode(substr($mid,4));
-
+
if($mid)
$r = q("SELECT * FROM item WHERE mid = '%s' AND uid = %d AND item_private = 0 LIMIT 1",
dbesc($mid),
intval($channel['channel_id'])
);
-
+
opengraph_add_meta($r ? $r[0] : [], $channel);
}
@@ -233,7 +233,7 @@ class Channel extends Controller {
/**
* Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
*/
-
+
$item_normal = " and item.item_hidden = 0 and item.item_type = 0 and item.item_deleted = 0
and item.item_unpublished = 0 and item.item_pending_remove = 0
and item.item_blocked = 0 ";
@@ -266,7 +266,7 @@ class Channel extends Controller {
}
}
- head_add_link([
+ head_add_link([
'rel' => 'alternate',
'type' => 'application/json+oembed',
'href' => z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . App::$query_string),
@@ -333,12 +333,12 @@ class Channel extends Controller {
}
}
else {
- $r = q("SELECT DISTINCT item.parent AS item_id, $ordering FROM item
+ $r = q("SELECT DISTINCT item.parent AS item_id, $ordering FROM item
left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids )
WHERE true and item.uid = %d $item_normal
AND (abook.abook_blocked = 0 or abook.abook_flags is null)
AND item.item_wall = 1 AND item.item_thread_top = 1
- $sql_extra $sql_extra2
+ $sql_extra $sql_extra2
ORDER BY $ordering DESC, item_id $pager_sql ",
intval(App::$profile['profile_uid'])
);
@@ -375,6 +375,15 @@ class Channel extends Controller {
$items = array();
}
+ // Add pinned content
+ if(! x($_REQUEST,'mid') && ! $search) {
+ $pinned = new \Zotlabs\Widget\Pinned;
+ $r = $pinned->widget(intval(App::$profile['profile_uid']), [ITEM_TYPE_POST]);
+ $o .= $r['html'];
+ }
+
+ $mode = (($search) ? 'search' : 'channel');
+
if((! $update) && (! $load)) {
if($decoded)
@@ -421,20 +430,11 @@ class Channel extends Controller {
'$net' => '',
'$dend' => $datequery,
'$dbegin' => $datequery2,
- '$conv_mode' => 'channel'
+ '$conv_mode' => 'channel',
+ '$page_mode' => $page_mode
));
-
}
- // Add pinned content
- if(! x($_REQUEST,'mid') && ! $search) {
- $pinned = new \Zotlabs\Widget\Pinned;
- $r = $pinned->widget(intval(App::$profile['profile_uid']), [ITEM_TYPE_POST]);
- $o .= $r['html'];
- }
-
- $mode = (($search) ? 'search' : 'channel');
-
if($update) {
$o .= conversation($items,$mode,$update,$page_mode);
}
diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php
index ae4afb2f3..ac1545644 100644
--- a/Zotlabs/Module/Channel_calendar.php
+++ b/Zotlabs/Module/Channel_calendar.php
@@ -1,7 +1,12 @@
<?php
+
namespace Zotlabs\Module;
+use App;
+use Zotlabs\Web\Controller;
use Zotlabs\Lib\Libsync;
+use Zotlabs\Access\AccessList;
+use Zotlabs\Daemon\Master;
require_once('include/conversation.php');
require_once('include/bbcode.php');
@@ -10,37 +15,37 @@ require_once('include/event.php');
require_once('include/items.php');
require_once('include/html2plain.php');
-class Channel_calendar extends \Zotlabs\Web\Controller {
+class Channel_calendar extends Controller {
function post() {
-
- logger('post: ' . print_r($_REQUEST,true), LOGGER_DATA);
-
- if(! local_channel())
- return;
- $event_id = ((x($_POST,'event_id')) ? intval($_POST['event_id']) : 0);
- $event_hash = ((x($_POST,'event_hash')) ? $_POST['event_hash'] : '');
-
- $xchan = ((x($_POST,'xchan')) ? dbesc($_POST['xchan']) : '');
+ logger('post: ' . print_r($_REQUEST, true), LOGGER_DATA);
+
$uid = local_channel();
+ if (!$uid)
+ return;
+
+ $event_id = ((x($_POST, 'event_id')) ? intval($_POST['event_id']) : 0);
+
+ $xchan = ((x($_POST, 'xchan')) ? dbesc($_POST['xchan']) : '');
+
// only allow editing your own events.
- if(($xchan) && ($xchan !== get_observer_hash()))
+ if (($xchan) && ($xchan !== get_observer_hash()))
return;
$categories = escape_tags(trim($_POST['categories']));
-
+
// allday events have adjust = 0, normal events have adjust = 1
$adjust = intval($_POST['adjust']);
- $start = datetime_convert((($adjust) ? $tz : 'UTC'), 'UTC', escape_tags($_REQUEST['dtstart']));
- $finish = datetime_convert((($adjust) ? $tz : 'UTC'), 'UTC', escape_tags($_REQUEST['dtend']));
+ $timezone = ((x($_POST, 'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
+ $tz = (($timezone) ? $timezone : date_default_timezone_get());
- $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
- $tz = (($timezone) ? $timezone : date_default_timezone_get());
+ $start = datetime_convert((($adjust) ? $tz : 'UTC'), 'UTC', escape_tags($_REQUEST['dtstart']));
+ $finish = datetime_convert((($adjust) ? $tz : 'UTC'), 'UTC', escape_tags($_REQUEST['dtend']));
- if(! $adjust)
+ if (!$adjust)
$tz = 'UTC';
$summary = escape_tags(trim($_POST['summary']));
@@ -52,88 +57,86 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
// It won't hurt anything, but somebody will file a bug report
// and we'll waste a bunch of time responding to it. Time that
// could've been spent doing something else.
-
- if(strcmp($finish,$start) < 0 && !$nofinish) {
- notice( t('Event can not end before it has started.') . EOL);
- if(intval($_REQUEST['preview'])) {
- echo( t('Unable to generate preview.'));
+
+ if (strcmp($finish, $start) < 0) {
+ notice(t('Event can not end before it has started.') . EOL);
+ if (intval($_REQUEST['preview'])) {
+ echo(t('Unable to generate preview.'));
}
killme();
}
-
- if((! $summary) || (! $start)) {
- notice( t('Event title and start time are required.') . EOL);
- if(intval($_REQUEST['preview'])) {
- echo( t('Unable to generate preview.'));
+
+ if ((!$summary) || (!$start)) {
+ notice(t('Event title and start time are required.') . EOL);
+ if (intval($_REQUEST['preview'])) {
+ echo(t('Unable to generate preview.'));
}
killme();
}
- $channel = \App::get_channel();
-
- $acl = new \Zotlabs\Access\AccessList(false);
-
- if($event_id) {
+ $acl = new AccessList([]);
+
+ if ($event_id) {
$x = q("select * from event where id = %d and uid = %d limit 1",
intval($event_id),
- intval(local_channel())
+ intval($uid)
);
- if(! $x) {
- notice( t('Event not found.') . EOL);
- if(intval($_REQUEST['preview'])) {
- echo( t('Unable to generate preview.'));
+ if (!$x) {
+ notice(t('Event not found.') . EOL);
+ if (intval($_REQUEST['preview'])) {
+ echo(t('Unable to generate preview.'));
killme();
}
return;
}
-
+
$acl->set($x[0]);
-
+
$created = $x[0]['created'];
- $edited = datetime_convert();
+ $edited = datetime_convert();
}
else {
$created = $edited = datetime_convert();
$acl->set_from_array($_POST);
}
-
+
$post_tags = array();
- $channel = \App::get_channel();
- $ac = $acl->get();
+ $channel = App::get_channel();
+ $ac = $acl->get();
$str_contact_allow = $ac['allow_cid'];
$str_group_allow = $ac['allow_gid'];
- $str_contact_deny = $ac['deny_cid'];
- $str_group_deny = $ac['deny_gid'];
+ $str_contact_deny = $ac['deny_cid'];
+ $str_group_deny = $ac['deny_gid'];
$private = $acl->is_private();
require_once('include/text.php');
- $results = linkify_tags($desc, local_channel());
+ $results = linkify_tags($desc, $uid);
- if($results) {
+ if ($results) {
// Set permissions based on tag replacements
- set_linkified_perms($results, $str_contact_allow, $str_group_allow, local_channel(), false, $private);
+ set_linkified_perms($results, $str_contact_allow, $str_group_allow, $uid, false, $private);
- foreach($results as $result) {
+ foreach ($results as $result) {
$success = $result['success'];
- if($success['replaced']) {
+ if ($success['replaced']) {
$post_tags[] = array(
- 'uid' => local_channel(),
+ 'uid' => $uid,
'ttype' => $success['termtype'],
'otype' => TERM_OBJ_POST,
'term' => $success['term'],
'url' => $success['url']
- );
+ );
}
}
}
- if(strlen($categories)) {
- $cats = explode(',',$categories);
- foreach($cats as $cat) {
+ if (strlen($categories)) {
+ $cats = explode(',', $categories);
+ foreach ($cats as $cat) {
$post_tags[] = array(
- 'uid' => local_channel(),
+ 'uid' => $uid,
'ttype' => TERM_CATEGORY,
'otype' => TERM_OBJ_POST,
'term' => trim($cat),
@@ -141,175 +144,170 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
);
}
}
-
- $datarray = array();
- $datarray['dtstart'] = $start;
- $datarray['dtend'] = $finish;
- $datarray['summary'] = $summary;
+
+ $datarray = array();
+ $datarray['dtstart'] = $start;
+ $datarray['dtend'] = $finish;
+ $datarray['summary'] = $summary;
$datarray['description'] = $desc;
- $datarray['location'] = $location;
- $datarray['etype'] = $type;
- $datarray['adjust'] = $adjust;
- $datarray['nofinish'] = 0;
- $datarray['uid'] = local_channel();
- $datarray['account'] = get_account_id();
+ $datarray['location'] = $location;
+ $datarray['etype'] = $type;
+ $datarray['adjust'] = $adjust;
+ $datarray['nofinish'] = 0;
+ $datarray['uid'] = $uid;
+ $datarray['account'] = get_account_id();
$datarray['event_xchan'] = $channel['channel_hash'];
- $datarray['allow_cid'] = $str_contact_allow;
- $datarray['allow_gid'] = $str_group_allow;
- $datarray['deny_cid'] = $str_contact_deny;
- $datarray['deny_gid'] = $str_group_deny;
- $datarray['private'] = intval($private);
- $datarray['id'] = $event_id;
- $datarray['created'] = $created;
- $datarray['edited'] = $edited;
- $datarray['timezone'] = $tz;
-
-
- if(intval($_REQUEST['preview'])) {
+ $datarray['allow_cid'] = $str_contact_allow;
+ $datarray['allow_gid'] = $str_group_allow;
+ $datarray['deny_cid'] = $str_contact_deny;
+ $datarray['deny_gid'] = $str_group_deny;
+ $datarray['private'] = intval($private);
+ $datarray['id'] = $event_id;
+ $datarray['created'] = $created;
+ $datarray['edited'] = $edited;
+ $datarray['timezone'] = $tz;
+
+
+ if (intval($_REQUEST['preview'])) {
$html = format_event_html($datarray);
echo $html;
killme();
}
-
+
$event = event_store_event($datarray);
-
- if($post_tags)
+
+ if ($post_tags)
$datarray['term'] = $post_tags;
-
- $item_id = event_store_item($datarray,$event);
-
- if($item_id) {
+
+ $item_id = event_store_item($datarray, $event);
+
+ if ($item_id) {
$r = q("select * from item where id = %d",
intval($item_id)
);
- if($r) {
+ if ($r) {
xchan_query($r);
$sync_item = fetch_post_tags($r);
- $z = q("select * from event where event_hash = '%s' and uid = %d limit 1",
+ $z = q("select * from event where event_hash = '%s' and uid = %d limit 1",
dbesc($r[0]['resource_id']),
intval($channel['channel_id'])
);
- if($z) {
- Libsync::build_sync_packet($channel['channel_id'],array('event_item' => array(encode_item($sync_item[0],true)),'event' => $z));
+ if ($z) {
+ Libsync::build_sync_packet($channel['channel_id'], array('event_item' => array(encode_item($sync_item[0], true)), 'event' => $z));
}
}
}
-
- \Zotlabs\Daemon\Master::Summon(array('Notifier','event',$item_id));
+
+ Master::Summon(array('Notifier', 'event', $item_id));
killme();
-
+
}
-
-
-
+
+
function get() {
-
- if(argc() > 2 && argv(1) == 'ical') {
+
+ if (argc() > 2 && argv(1) == 'ical') {
$event_id = argv(2);
-
+
require_once('include/security.php');
$sql_extra = permissions_sql(local_channel());
-
+
$r = q("select * from event where event_hash = '%s' $sql_extra limit 1",
dbesc($event_id)
);
- if($r) {
+ if ($r) {
header('Content-type: text/calendar');
- header('content-disposition: attachment; filename="' . t('event') . '-' . $event_id . '.ics"' );
+ header('content-disposition: attachment; filename="' . t('event') . '-' . $event_id . '.ics"');
echo ical_wrapper($r);
killme();
}
else {
- notice( t('Event not found.') . EOL );
+ notice(t('Event not found.') . EOL);
return;
}
}
-
- if(! local_channel()) {
- notice( t('Permission denied.') . EOL);
+
+ if (!local_channel()) {
+ notice(t('Permission denied.') . EOL);
return;
}
- if((argc() > 2) && (argv(1) === 'ignore') && intval(argv(2))) {
- $r = q("update event set dismissed = 1 where id = %d and uid = %d",
+ if ((argc() > 2) && (argv(1) === 'ignore') && intval(argv(2))) {
+ q("update event set dismissed = 1 where id = %d and uid = %d",
intval(argv(2)),
intval(local_channel())
);
}
-
- if((argc() > 2) && (argv(1) === 'unignore') && intval(argv(2))) {
- $r = q("update event set dismissed = 0 where id = %d and uid = %d",
+
+ if ((argc() > 2) && (argv(1) === 'unignore') && intval(argv(2))) {
+ q("update event set dismissed = 0 where id = %d and uid = %d",
intval(argv(2)),
intval(local_channel())
);
}
- $channel = \App::get_channel();
-
- $mode = 'view';
- $export = false;
- $ignored = ((x($_REQUEST,'ignored')) ? " and dismissed = " . intval($_REQUEST['ignored']) . " " : '');
+ $mode = 'view';
+ $export = false;
+ $ignored = ((x($_REQUEST, 'ignored')) ? " and dismissed = " . intval($_REQUEST['ignored']) . " " : '');
- if(argc() > 1) {
- if(argc() > 2 && argv(1) === 'add') {
- $mode = 'add';
+ if (argc() > 1) {
+ if (argc() > 2 && argv(1) === 'add') {
+ $mode = 'add';
$item_id = intval(argv(2));
}
- if(argc() > 2 && argv(1) === 'drop') {
- $mode = 'drop';
+ if (argc() > 2 && argv(1) === 'drop') {
+ $mode = 'drop';
$event_id = argv(2);
}
- if(argc() <= 2 && argv(1) === 'export') {
+ if (argc() <= 2 && argv(1) === 'export') {
$export = true;
}
- if(argc() > 2 && intval(argv(1)) && intval(argv(2))) {
+ if (argc() > 2 && intval(argv(1)) && intval(argv(2))) {
$mode = 'view';
}
- if(argc() <= 2) {
- $mode = 'view';
+ if (argc() <= 2) {
+ $mode = 'view';
$event_id = argv(1);
}
}
-
- if($mode === 'add') {
- event_addtocal($item_id,local_channel());
+
+ if ($mode === 'add') {
+ event_addtocal($item_id, local_channel());
killme();
}
-
- if($mode == 'view') {
-
+
+ if ($mode == 'view') {
+
/* edit/create form */
- if($event_id) {
- $r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
+ if ($event_id) {
+ q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
dbesc($event_id),
intval(local_channel())
);
- if(count($r))
- $orig_event = $r[0];
}
-
- $channel = \App::get_channel();
- if (argv(1) === 'json'){
- if (x($_GET,'start')) $start = $_GET['start'];
- if (x($_GET,'end')) $finish = $_GET['end'];
+ $channel = App::get_channel();
+
+ if (argv(1) === 'json') {
+ if (x($_GET, 'start')) $start = $_GET['start'];
+ if (x($_GET, 'end')) $finish = $_GET['end'];
}
-
- $start = datetime_convert('UTC','UTC',$start);
- $finish = datetime_convert('UTC','UTC',$finish);
- $adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start);
+
+ $start = datetime_convert('UTC', 'UTC', $start);
+ $finish = datetime_convert('UTC', 'UTC', $finish);
+ $adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start);
$adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
- if (x($_GET,'id')){
- $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan, item.id as item_id
+ if (x($_GET, 'id')) {
+ $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan, item.id as item_id
from event left join item on item.resource_id = event.event_hash
where item.resource_type = 'event' and event.uid = %d and event.id = %d limit 1",
intval(local_channel()),
intval($_GET['id'])
);
}
- elseif($export) {
+ elseif ($export) {
$r = q("SELECT event.*, item.id as item_id
from event left join item on item.resource_id = event.event_hash
where event.uid = %d and event.dtstart > '%s' and event.dtend > event.dtstart",
@@ -335,104 +333,105 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
dbesc($adjust_finish)
);
}
-
- if($r && ! $export) {
+
+ if ($r && !$export) {
xchan_query($r);
- $r = fetch_post_tags($r,true);
+ $r = fetch_post_tags($r, true);
$r = sort_by_date($r);
}
$events = [];
- if($r) {
-
- foreach($r as $rr) {
+ if ($r) {
+
+ foreach ($r as $rr) {
$start = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtstart'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtstart'], 'c'));
- if ($rr['nofinish']){
+ if ($rr['nofinish']) {
$end = null;
- } else {
+ }
+ else {
$end = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtend'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtend'], 'c'));
}
- $catsenabled = feature_enabled(local_channel(),'categories');
- $categories = '';
- if($catsenabled){
- if($rr['term']) {
+ $catsenabled = feature_enabled(local_channel(), 'categories');
+ $categories = '';
+ if ($catsenabled) {
+ if ($rr['term']) {
$cats = get_terms_oftype($rr['term'], TERM_CATEGORY);
foreach ($cats as $cat) {
- if(strlen($categories))
+ if (strlen($categories))
$categories .= ', ';
$categories .= $cat['term'];
}
}
}
- $edit = ((local_channel() && $rr['author_xchan'] == get_observer_hash()) ? array(z_root().'/events/'.$rr['event_hash'].'?expandform=1',t('Edit event'),'','') : false);
-
- $drop = array(z_root().'/events/drop/'.$rr['event_hash'],t('Delete event'),'','');
-
+ $edit = ((local_channel() && $rr['author_xchan'] == get_observer_hash()) ? array(z_root() . '/events/' . $rr['event_hash'] . '?expandform=1', t('Edit event'), '', '') : false);
+
+ $drop = array(z_root() . '/events/drop/' . $rr['event_hash'], t('Delete event'), '', '');
+
$tz = get_iconfig($rr, 'event', 'timezone');
- if(! $tz)
+ if (!$tz)
$tz = 'UTC';
$events[] = array(
'calendar_id' => 'channel_calendar',
- 'rw' => true,
- 'id'=>$rr['id'],
- 'uri' => $rr['event_hash'],
- 'timezone' => $tz,
- 'start'=> $start,
- 'end' => $end,
- 'drop' => $drop,
- 'allDay' => (($rr['adjust']) ? 0 : 1),
- 'title' => html_entity_decode($rr['summary'], ENT_COMPAT, 'UTF-8'),
- 'editable' => $edit ? true : false,
- 'item' => $rr,
- 'plink' => [$rr['plink'], t('Link to source')],
+ 'rw' => true,
+ 'id' => $rr['id'],
+ 'uri' => $rr['event_hash'],
+ 'timezone' => $tz,
+ 'start' => $start,
+ 'end' => $end,
+ 'drop' => $drop,
+ 'allDay' => (($rr['adjust']) ? 0 : 1),
+ 'title' => html_entity_decode($rr['summary'], ENT_COMPAT, 'UTF-8'),
+ 'editable' => $edit ? true : false,
+ 'item' => $rr,
+ 'plink' => [$rr['plink'], t('Link to source')],
'description' => html_entity_decode($rr['description'], ENT_COMPAT, 'UTF-8'),
- 'location' => html_entity_decode($rr['location'], ENT_COMPAT, 'UTF-8'),
- 'allow_cid' => expand_acl($rr['allow_cid']),
- 'allow_gid' => expand_acl($rr['allow_gid']),
- 'deny_cid' => expand_acl($rr['deny_cid']),
- 'deny_gid' => expand_acl($rr['deny_gid']),
- 'categories' => $categories
+ 'location' => html_entity_decode($rr['location'], ENT_COMPAT, 'UTF-8'),
+ 'allow_cid' => expand_acl($rr['allow_cid']),
+ 'allow_gid' => expand_acl($rr['allow_gid']),
+ 'deny_cid' => expand_acl($rr['deny_cid']),
+ 'deny_gid' => expand_acl($rr['deny_gid']),
+ 'categories' => $categories
);
}
}
-
- if($export) {
+
+ if ($export) {
header('Content-type: text/calendar');
- header('content-disposition: attachment; filename="' . t('calendar') . '-' . $channel['channel_address'] . '.ics"' );
+ header('content-disposition: attachment; filename="' . t('calendar') . '-' . $channel['channel_address'] . '.ics"');
echo ical_wrapper($r);
killme();
}
- if (\App::$argv[1] === 'json'){
+ if (App::$argv[1] === 'json') {
json_return_and_die($events);
}
}
-
- if($mode === 'drop' && $event_id) {
+
+ if ($mode === 'drop' && $event_id) {
$r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
dbesc($event_id),
intval(local_channel())
);
-
+
$sync_event = $r[0];
-
- if($r) {
+
+ if ($r) {
$r = q("delete from event where event_hash = '%s' and uid = %d",
dbesc($event_id),
intval(local_channel())
);
- if($r) {
+ if ($r) {
$sync_event['event_deleted'] = 1;
- Libsync::build_sync_packet(0,array('event' => array($sync_event)));
+ Libsync::build_sync_packet(0, array('event' => array($sync_event)));
$i = q("select * from item where resource_type = 'event' and resource_id = '%s' and uid = %d",
dbesc($event_id),
@@ -441,11 +440,11 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
if ($i) {
- $can_delete = false;
+ $can_delete = false;
$local_delete = true;
$ob_hash = get_observer_hash();
- if($ob_hash && ($ob_hash === $i[0]['author_xchan'] || $ob_hash === $i[0]['owner_xchan'] || $ob_hash === $i[0]['source_xchan'])) {
+ if ($ob_hash && ($ob_hash === $i[0]['author_xchan'] || $ob_hash === $i[0]['owner_xchan'] || $ob_hash === $i[0]['source_xchan'])) {
$can_delete = true;
}
@@ -453,49 +452,49 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
// If the item originated on this site+channel the deletion will propagate downstream.
// Otherwise just the local copy is removed.
- if(is_site_admin()) {
+ if (is_site_admin()) {
$local_delete = true;
- if(intval($i[0]['item_origin']))
+ if (intval($i[0]['item_origin']))
$can_delete = true;
}
- if($can_delete || $local_delete) {
+ if ($can_delete || $local_delete) {
// if this is a different page type or it's just a local delete
// but not by the item author or owner, do a simple deletion
- $complex = false;
+ $complex = false;
- if(intval($i[0]['item_type']) || ($local_delete && (! $can_delete))) {
+ if (intval($i[0]['item_type']) || ($local_delete && (!$can_delete))) {
drop_item($i[0]['id']);
}
else {
// complex deletion that needs to propagate and be performed in phases
- drop_item($i[0]['id'],true,DROPITEM_PHASE1);
+ drop_item($i[0]['id'], true, DROPITEM_PHASE1);
$complex = true;
}
$ii = q("select * from item where id = %d",
intval($i[0]['id'])
);
- if($ii) {
+ if ($ii) {
xchan_query($ii);
$sync_item = fetch_post_tags($ii);
- Libsync::build_sync_packet($i[0]['uid'],array('item' => array(encode_item($sync_item[0],true))));
+ Libsync::build_sync_packet($i[0]['uid'], array('item' => array(encode_item($sync_item[0], true))));
}
- if($complex) {
- tag_deliver($i[0]['uid'],$i[0]['id']);
+ if ($complex) {
+ tag_deliver($i[0]['uid'], $i[0]['id']);
}
}
}
killme();
}
- notice( t('Failed to remove event' ) . EOL);
+ notice(t('Failed to remove event') . EOL);
killme();
}
}
-
+
}
-
+
}
diff --git a/Zotlabs/Module/Chanview.php b/Zotlabs/Module/Chanview.php
index 12e1891d4..8ae4841b4 100644
--- a/Zotlabs/Module/Chanview.php
+++ b/Zotlabs/Module/Chanview.php
@@ -70,7 +70,7 @@ class Chanview extends \Zotlabs\Web\Controller {
$zf = Zotfinger::exec($_REQUEST['url'], null);
if(array_path_exists('signature/signer',$zf) && $zf['signature']['signer'] === $_REQUEST['url'] && intval($zf['signature']['header_valid'])) {
- Libzot::import_xchan($j);
+ Libzot::import_xchan($zf['data']);
$r = q("select * from xchan where xchan_url = '%s'",
dbesc($_REQUEST['url'])
);
diff --git a/Zotlabs/Module/Cloud.php b/Zotlabs/Module/Cloud.php
index 39ae0f92f..3d1b97980 100644
--- a/Zotlabs/Module/Cloud.php
+++ b/Zotlabs/Module/Cloud.php
@@ -105,7 +105,7 @@ class Cloud extends Controller {
// All we need to do now, is to fire up the server
- $server->exec();
+ $server->start();
if($browser->build_page)
construct_page();
diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php
index 7dc301623..5025f4e22 100644
--- a/Zotlabs/Module/Connections.php
+++ b/Zotlabs/Module/Connections.php
@@ -109,6 +109,7 @@ class Connections extends \Zotlabs\Web\Controller {
case 'all':
$head = t('All');
+ break;
default:
$search_flags = " and abook_blocked = 0 and abook_ignored = 0 and abook_hidden = 0 and abook_archived = 0 and abook_not_here = 0 ";
$active = true;
@@ -238,7 +239,7 @@ class Connections extends \Zotlabs\Web\Controller {
}
$r = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash
- where abook_channel = %d and abook_self = 0 and xchan_deleted = 0 and xchan_orphan = 0 $sql_extra $sql_extra2 ",
+ where abook_channel = %d and abook_self = 0 and xchan_deleted = 0 and xchan_orphan = 0 $sql_extra ",
intval(local_channel())
);
if($r) {
@@ -247,7 +248,7 @@ class Connections extends \Zotlabs\Web\Controller {
}
$r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash
- WHERE abook_channel = %d and abook_self = 0 and xchan_deleted = 0 and xchan_orphan = 0 $sql_extra $sql_extra2 ORDER BY $sql_order LIMIT %d OFFSET %d ",
+ WHERE abook_channel = %d and abook_self = 0 and xchan_deleted = 0 and xchan_orphan = 0 $sql_extra ORDER BY $sql_order LIMIT %d OFFSET %d ",
intval(local_channel()),
intval(App::$pager['itemspage']),
intval(App::$pager['start'])
diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php
index becf8460d..582563451 100644
--- a/Zotlabs/Module/Connedit.php
+++ b/Zotlabs/Module/Connedit.php
@@ -32,10 +32,10 @@ class Connedit extends Controller {
*/
function init() {
-
+
if(! local_channel())
return;
-
+
if((argc() >= 2) && intval(argv(1))) {
$r = q("SELECT abook.*, xchan.*
FROM abook left join xchan on abook_xchan = xchan_hash
@@ -47,54 +47,54 @@ class Connedit extends Controller {
App::$poi = array_shift($r);
}
}
-
+
$channel = App::get_channel();
if($channel)
head_set_icon($channel['xchan_photo_s']);
-
+
}
-
+
/* @brief Evaluate posted values and set changes
*
*/
-
+
function post() {
-
+
if(! local_channel())
return;
-
+
$contact_id = intval(argv(1));
if(! $contact_id)
return;
-
+
$channel = App::get_channel();
-
+
// TODO if configured for hassle-free permissions, we'll post the form with ajax as soon as the
// connection enable is toggled to a special autopost url and set permissions immediately, leaving
// the other form elements alone pending a manual submit of the form. The downside is that there
// will be a window of opportunity when the permissions have been set but before you've had a chance
// to review and possibly restrict them. The upside is we won't have to warn you that your connection
// can't do anything until you save the bloody form.
-
+
$autopost = (((argc() > 2) && (argv(2) === 'auto')) ? true : false);
-
+
$orig_record = q("SELECT * FROM abook WHERE abook_id = %d AND abook_channel = %d LIMIT 1",
intval($contact_id),
intval(local_channel())
);
-
+
if(! $orig_record) {
notice( t('Could not access contact record.') . EOL);
goaway(z_root() . '/connections');
return; // NOTREACHED
}
-
+
call_hooks('contact_edit_post', $_POST);
-
+
$vc = get_abconfig(local_channel(),$orig_record['abook_xchan'],'system','vcard');
- $vcard = (($vc) ? \Sabre\VObject\Reader::read($vc) : null);
+ $vcard = (($vc) ? \Sabre\VObject\Reader::read($vc) : null);
$serialised_vcard = update_vcard($_REQUEST,$vcard);
if($serialised_vcard)
set_abconfig(local_channel(),$orig_record[0]['abook_xchan'],'system','vcard',$serialised_vcard);
@@ -107,8 +107,8 @@ class Connedit extends Controller {
$autoperms = null;
$is_self = false;
}
-
-
+
+
$profile_id = ((array_key_exists('profile_assign',$_POST)) ? $_POST['profile_assign'] : $orig_record[0]['abook_profile']);
if($profile_id) {
@@ -121,17 +121,17 @@ class Connedit extends Controller {
return;
}
}
-
+
$abook_incl = ((array_key_exists('abook_incl',$_POST)) ? escape_tags($_POST['abook_incl']) : $orig_record[0]['abook_incl']);
$abook_excl = ((array_key_exists('abook_excl',$_POST)) ? escape_tags($_POST['abook_excl']) : $orig_record[0]['abook_excl']);
$hidden = intval($_POST['hidden']);
-
+
$priority = intval($_POST['poll']);
if($priority > 5 || $priority < 0)
$priority = 0;
-
+
if(! array_key_exists('closeness',$_POST)) {
$_POST['closeness'] = 80;
}
@@ -139,15 +139,15 @@ class Connedit extends Controller {
if($closeness < 0 || $closeness > 99) {
$closeness = 80;
}
-
+
$rating = intval($_POST['rating']);
if($rating < (-10))
$rating = (-10);
if($rating > 10)
$rating = 10;
-
+
$rating_text = trim(escape_tags($_REQUEST['rating_text']));
-
+
$all_perms = Permissions::Perms();
if($all_perms) {
@@ -168,27 +168,27 @@ class Connedit extends Controller {
}
}
- if(! is_null($autoperms))
+ if(! is_null($autoperms))
set_pconfig($channel['channel_id'],'system','autoperms',$autoperms);
-
+
$new_friend = false;
-
+
// only store a record and notify the directory if the rating changed
if(! $is_self) {
-
+
$signed = $orig_record[0]['abook_xchan'] . '.' . $rating . '.' . $rating_text;
$sig = base64url_encode(rsa_sign($signed,$channel['channel_prvkey']));
$rated = ((intval($rating) || strlen($rating_text)) ? true : false);
-
+
$record = 0;
-
+
$z = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1 limit 1",
dbesc($channel['channel_hash']),
dbesc($orig_record[0]['abook_xchan'])
);
-
+
if($z) {
if(($z[0]['xlink_rating'] != $rating) || ($z[0]['xlink_rating_text'] != $rating_text)) {
$record = $z[0]['xlink_id'];
@@ -223,18 +223,18 @@ class Connedit extends Controller {
Master::Summon(array('Ratenotif','rating',$record));
}
}
-
+
if(($_REQUEST['pending']) && intval($orig_record[0]['abook_pending'])) {
$new_friend = true;
-
+
// @fixme it won't be common, but when you accept a new connection request
// the permissions will now be that of your permissions role and ignore
// any you may have set manually on the form. We'll probably see a bug if somebody
// tries to set the permissions *and* approve the connection in the same
// request. The workaround is to approve the connection, then go back and
// adjust permissions as desired.
-
+
$p = Permissions::connect_perms(local_channel());
$my_perms = $p['perms'];
if($my_perms) {
@@ -247,7 +247,7 @@ class Connedit extends Controller {
$abook_pending = (($new_friend) ? 0 : $orig_record[0]['abook_pending']);
-
+
$r = q("UPDATE abook SET abook_profile = '%s', abook_closeness = %d, abook_pending = %d,
abook_incl = '%s', abook_excl = '%s'
where abook_id = %d AND abook_channel = %d",
@@ -259,7 +259,7 @@ class Connedit extends Controller {
intval($contact_id),
intval(local_channel())
);
-
+
if($r)
info( t('Connection updated.') . EOL);
else
@@ -267,16 +267,16 @@ class Connedit extends Controller {
if(! intval(App::$poi['abook_self'])) {
if($new_friend) {
- Master::Summon( [ 'Notifier', 'permission_accept', $contact_id ] );
+ Master::Summon( [ 'Notifier', 'permission_accept', $contact_id ] );
}
- Master::Summon( [
- 'Notifier',
- (($new_friend) ? 'permission_create' : 'permission_update'),
- $contact_id
+ Master::Summon( [
+ 'Notifier',
+ (($new_friend) ? 'permission_create' : 'permission_update'),
+ $contact_id
]);
}
-
+
if($new_friend) {
$default_group = $channel['channel_default_group'];
if($default_group) {
@@ -285,11 +285,11 @@ class Connedit extends Controller {
if($g)
group_add_member(local_channel(),'',App::$poi['abook_xchan'],$g['id']);
}
-
+
// Check if settings permit ("post new friend activity" is allowed, and
// friends in general or this friend in particular aren't hidden)
// and send out a new friend activity
-
+
$pr = q("select * from profile where uid = %d and is_default = 1 and hide_friends = 0",
intval($channel['channel_id'])
);
@@ -305,23 +305,23 @@ class Connedit extends Controller {
$xarr['deny_cid'] = $channel['channel_deny_cid'];
$xarr['deny_gid'] = $channel['channel_deny_gid'];
$xarr['item_private'] = (($xarr['allow_cid']||$xarr['allow_gid']||$xarr['deny_cid']||$xarr['deny_gid']) ? 1 : 0);
-
+
$xarr['body'] = '[zrl=' . $channel['xchan_url'] . ']' . $channel['xchan_name'] . '[/zrl]' . ' ' . t('is now connected to') . ' ' . '[zrl=' . App::$poi['xchan_url'] . ']' . App::$poi['xchan_name'] . '[/zrl]';
-
+
$xarr['body'] .= "\n\n\n" . '[zrl=' . App::$poi['xchan_url'] . '][zmg=80x80]' . App::$poi['xchan_photo_m'] . '[/zmg][/zrl]';
-
+
post_activity_item($xarr);
-
+
}
-
-
+
+
// pull in a bit of content if there is any to pull in
Master::Summon(array('Onepoll',$contact_id));
-
+
}
-
+
// Refresh the structure in memory with the new data
-
+
$r = q("SELECT abook.*, xchan.*
FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_channel = %d and abook_id = %d LIMIT 1",
@@ -331,34 +331,34 @@ class Connedit extends Controller {
if($r) {
App::$poi = $r[0];
}
-
+
if($new_friend) {
$arr = array('channel_id' => local_channel(), 'abook' => App::$poi);
call_hooks('accept_follow', $arr);
}
-
+
$this->connedit_clone($a);
-
+
if(($_REQUEST['pending']) && (!$_REQUEST['done']))
goaway(z_root() . '/connections/ifpending');
-
+
return;
-
+
}
-
+
/* @brief Clone connection
*
*
*/
-
+
function connedit_clone(&$a) {
-
+
if(! App::$poi)
return;
-
-
+
+
$channel = App::get_channel();
-
+
$r = q("SELECT abook.*, xchan.*
FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_channel = %d and abook_id = %d LIMIT 1",
@@ -368,40 +368,40 @@ class Connedit extends Controller {
if($r) {
App::$poi = array_shift($r);
}
-
+
$clone = App::$poi;
-
+
unset($clone['abook_id']);
unset($clone['abook_account']);
unset($clone['abook_channel']);
-
+
$abconfig = load_abconfig($channel['channel_id'],$clone['abook_xchan']);
if($abconfig)
$clone['abconfig'] = $abconfig;
-
+
Libsync::build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone)));
}
-
+
/* @brief Generate content of connection edit page
*
*
*/
-
+
function get() {
-
+
$sort_type = 0;
$o = '';
-
+
if(! local_channel()) {
notice( t('Permission denied.') . EOL);
return login();
}
-
+
$section = ((array_key_exists('section',$_REQUEST)) ? $_REQUEST['section'] : '');
$channel = App::get_channel();
-
+
$yes_no = array(t('No'),t('Yes'));
-
+
$connect_perms = Permissions::connect_perms(local_channel());
$o .= "<script>function connectDefaultShare() {
@@ -415,13 +415,13 @@ class Connedit extends Controller {
}
}
$o .= " }\n</script>\n";
-
+
if(argc() == 3) {
-
+
$contact_id = intval(argv(1));
if(! $contact_id)
return;
-
+
$cmd = argv(2);
$orig_record = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash
@@ -429,17 +429,17 @@ class Connedit extends Controller {
intval($contact_id),
intval(local_channel())
);
-
+
if(! count($orig_record)) {
notice( t('Could not access address book record.') . EOL);
goaway(z_root() . '/connections');
}
-
+
if($cmd === 'update') {
// pull feed and consume it, which should subscribe to the hub.
Master::Summon(array('Poller',$contact_id));
goaway(z_root() . '/connedit/' . $contact_id);
-
+
}
if($cmd === 'fetchvc') {
@@ -474,7 +474,7 @@ class Connedit extends Controller {
dbesc($orig_record[0]['xchan_hash'])
);
$cmd = 'refresh';
- }
+ }
if($cmd === 'refresh') {
if($orig_record[0]['xchan_network'] === 'zot') {
@@ -486,13 +486,13 @@ class Connedit extends Controller {
notice( t('Refresh failed - channel is currently unavailable.') );
}
else {
-
+
// if you are on a different network we'll force a refresh of the connection basic info
Master::Summon(array('Notifier','permission_update',$contact_id));
}
goaway(z_root() . '/connedit/' . $contact_id);
}
-
+
if($cmd === 'block') {
if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_BLOCKED)) {
$this->connedit_clone($a);
@@ -501,7 +501,7 @@ class Connedit extends Controller {
notice(t('Unable to set address book parameters.') . EOL);
goaway(z_root() . '/connedit/' . $contact_id);
}
-
+
if($cmd === 'ignore') {
if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_IGNORED)) {
$this->connedit_clone($a);
@@ -510,7 +510,7 @@ class Connedit extends Controller {
notice(t('Unable to set address book parameters.') . EOL);
goaway(z_root() . '/connedit/' . $contact_id);
}
-
+
if($cmd === 'archive') {
if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_ARCHIVED)) {
$this->connedit_clone($a);
@@ -519,7 +519,7 @@ class Connedit extends Controller {
notice(t('Unable to set address book parameters.') . EOL);
goaway(z_root() . '/connedit/' . $contact_id);
}
-
+
if($cmd === 'hide') {
if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_HIDDEN)) {
$this->connedit_clone($a);
@@ -528,10 +528,10 @@ class Connedit extends Controller {
notice(t('Unable to set address book parameters.') . EOL);
goaway(z_root() . '/connedit/' . $contact_id);
}
-
+
// We'll prevent somebody from unapproving an already approved contact.
// Though maybe somebody will want this eventually (??)
-
+
if($cmd === 'approve') {
if(intval($orig_record[0]['abook_pending'])) {
if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_PENDING)) {
@@ -542,10 +542,10 @@ class Connedit extends Controller {
}
goaway(z_root() . '/connedit/' . $contact_id);
}
-
-
+
+
if($cmd === 'drop') {
-
+
contact_remove(local_channel(), $orig_record[0]['abook_id']);
Master::Summon( [ 'Notifier', 'purge', local_channel(), $orig_record[0]['xchan_hash'] ] );
@@ -556,17 +556,17 @@ class Connedit extends Controller {
'entry_deleted' => true))
)
);
-
+
info( t('Connection has been removed.') . EOL );
if(x($_SESSION,'return_url'))
goaway(z_root() . '/' . $_SESSION['return_url']);
goaway(z_root() . '/contacts');
-
+
}
}
-
+
if(App::$poi) {
-
+
$abook_prev = 0;
$abook_next = 0;
@@ -595,14 +595,14 @@ class Connedit extends Controller {
}
$tools = array(
-
+
'view' => array(
'label' => t('View Profile'),
'url' => chanlink_cid($contact['abook_id']),
'sel' => '',
'title' => sprintf( t('View %s\'s profile'), $contact['xchan_name']),
),
-
+
'refresh' => array(
'label' => t('Refresh Permissions'),
'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/refresh',
@@ -616,14 +616,14 @@ class Connedit extends Controller {
'sel' => '',
'title' => t('Fetch updated photo'),
),
-
+
'recent' => array(
'label' => t('Recent Activity'),
'url' => z_root() . '/network/?f=&cid=' . $contact['abook_id'],
'sel' => '',
'title' => t('View recent posts and comments'),
),
-
+
'block' => array(
'label' => (intval($contact['abook_blocked']) ? t('Unblock') : t('Block')),
'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/block',
@@ -631,7 +631,7 @@ class Connedit extends Controller {
'title' => t('Block (or Unblock) all communications with this connection'),
'info' => (intval($contact['abook_blocked']) ? t('This connection is blocked!') : ''),
),
-
+
'ignore' => array(
'label' => (intval($contact['abook_ignored']) ? t('Unignore') : t('Ignore')),
'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/ignore',
@@ -639,7 +639,7 @@ class Connedit extends Controller {
'title' => t('Ignore (or Unignore) all inbound communications from this connection'),
'info' => (intval($contact['abook_ignored']) ? t('This connection is ignored!') : ''),
),
-
+
'archive' => array(
'label' => (intval($contact['abook_archived']) ? t('Unarchive') : t('Archive')),
'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/archive',
@@ -647,7 +647,7 @@ class Connedit extends Controller {
'title' => t('Archive (or Unarchive) this connection - mark channel dead but keep content'),
'info' => (intval($contact['abook_archived']) ? t('This connection is archived!') : ''),
),
-
+
'hide' => array(
'label' => (intval($contact['abook_hidden']) ? t('Unhide') : t('Hide')),
'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/hide',
@@ -655,18 +655,18 @@ class Connedit extends Controller {
'title' => t('Hide or Unhide this connection from your other connections'),
'info' => (intval($contact['abook_hidden']) ? t('This connection is hidden!') : ''),
),
-
+
'delete' => array(
'label' => t('Delete'),
'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/drop',
'sel' => '',
'title' => t('Delete this connection'),
),
-
+
);
- if($contact['xchan_network'] === 'zot') {
+ if(in_array($contact['xchan_network'], ['zot6', 'zot'])) {
$tools['fetchvc'] = [
'label' => t('Fetch Vcard'),
'url' => z_root() . '/connedit/' . $contact['abook_id'] . '/fetchvc',
@@ -684,24 +684,24 @@ class Connedit extends Controller {
'sel' => '',
'title' => t('Open Individual Permissions section by default'),
];
-
+
$self = false;
-
+
if(intval($contact['abook_self'])) {
$self = true;
$abook_prev = $abook_next = 0;
}
-
+
$vc = get_abconfig(local_channel(),$contact['abook_xchan'],'system','vcard');
- $vctmp = (($vc) ? \Sabre\VObject\Reader::read($vc) : null);
+ $vctmp = (($vc) ? \Sabre\VObject\Reader::read($vc) : null);
$vcard = (($vctmp) ? get_vcard_array($vctmp,$contact['abook_id']) : [] );
if(! $vcard)
$vcard['fn'] = $contact['xchan_name'];
$tpl = get_markup_template("abook_edit.tpl");
-
+
if(Apps::system_app_installed(local_channel(),'Affinity Tool')) {
$sections['affinity'] = [
@@ -710,7 +710,7 @@ class Connedit extends Controller {
'sel' => '',
'title' => t('Open Set Affinity section by default'),
];
-
+
$labels = [
t('Me'),
t('Family'),
@@ -720,7 +720,7 @@ class Connedit extends Controller {
];
call_hooks('affinity_labels',$labels);
$label_str = '';
-
+
if($labels) {
foreach($labels as $l) {
if($label_str) {
@@ -731,11 +731,11 @@ class Connedit extends Controller {
$label_str .= "'" . $l . "'";
}
}
-
+
$slider_tpl = get_markup_template('contact_slider.tpl');
-
+
$slideval = intval($contact['abook_closeness']);
-
+
$slide = replace_macros($slider_tpl,array(
'$min' => 1,
'$val' => $slideval,
@@ -751,22 +751,22 @@ class Connedit extends Controller {
'title' => t('Open Custom Filter section by default'),
];
}
-
+
$rating_val = 0;
$rating_text = '';
-
+
$xl = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1",
dbesc($channel['channel_hash']),
dbesc($contact['xchan_hash'])
);
-
+
if($xl) {
$rating_val = intval($xl[0]['xlink_rating']);
$rating_text = $xl[0]['xlink_rating_text'];
}
-
+
$rating_enabled = get_config('system','rating_enabled');
-
+
if($rating_enabled) {
$rating = replace_macros(get_markup_template('rating_slider.tpl'),array(
'$min' => -10,
@@ -776,28 +776,28 @@ class Connedit extends Controller {
else {
$rating = false;
}
-
-
+
+
$perms = array();
$channel = App::get_channel();
-
+
$global_perms = Permissions::Perms();
$existing = get_all_perms(local_channel(),$contact['abook_xchan'],false);
-
+
$unapproved = array('pending', t('Approve this connection'), '', t('Accept connection to allow communication'), array(t('No'),('Yes')));
-
+
$multiprofs = ((feature_enabled(local_channel(),'multi_profiles')) ? true : false);
-
+
if($slide && !$multiprofs)
$affinity = t('Set Affinity');
-
+
if(!$slide && $multiprofs)
$affinity = t('Set Profile');
-
+
if($slide && $multiprofs)
$affinity = t('Set Affinity & Profile');
-
+
$theirs = q("select * from abconfig where chan = %d and xchan = '%s' and cat = 'their_perms'",
intval(local_channel()),
dbesc($contact['abook_xchan'])
@@ -812,20 +812,20 @@ class Connedit extends Controller {
foreach($global_perms as $k => $v) {
$thisperm = get_abconfig(local_channel(),$contact['abook_xchan'],'my_perms',$k);
//fixme
-
+
$checkinherited = PermissionLimits::Get(local_channel(),$k);
-
+
// For auto permissions (when $self is true) we don't want to look at existing
// permissions because they are enabled for the channel owner
if((! $self) && ($existing[$k]))
$thisperm = "1";
-
-
+
+
$perms[] = array('perms_' . $k, $v, ((array_key_exists($k,$their_perms)) ? intval($their_perms[$k]) : ''),$thisperm, 1, (($checkinherited & PERMS_SPECIFIC) ? '' : '1'), '', $checkinherited);
}
-
+
$pcat = new Permcat(local_channel());
$pcatlist = $pcat->listing();
$permcats = [];
@@ -838,23 +838,23 @@ class Connedit extends Controller {
$locstr = locations_by_netid($contact['xchan_hash']);
if(! $locstr)
$locstr = unpunify($contact['xchan_url']);
-
+
$clone_warn = '';
$clonable = (in_array($contact['xchan_network'],['zot', 'zot6', 'rss']) ? true : false);
if(! $clonable) {
$clone_warn = '<strong>';
- $clone_warn .= ((intval($contact['abook_not_here']))
+ $clone_warn .= ((intval($contact['abook_not_here']))
? t('This connection is unreachable from this location.')
: t('This connection may be unreachable from other channel locations.')
);
$clone_warn .= '</strong><br>' . t('Location independence is not supported by their network.');
}
-
+
if(intval($contact['abook_not_here']) && $unclonable)
$not_here = t('This connection is unreachable from this location. Location independence is not supported by their network.');
-
+
$o .= replace_macros($tpl, [
'$header' => (($self) ? t('Connection Default Permissions') : sprintf( t('Connection: %s'),$contact['xchan_name'])),
'$autoperms' => array('autoperms',t('Apply these permissions automatically'), ((get_pconfig(local_channel(),'system','autoperms')) ? 1 : 0), t('Connection requests will be approved without your interaction'), $yes_no),
@@ -910,7 +910,7 @@ class Connedit extends Controller {
'$name' => $contact['xchan_name'],
'$abook_prev' => $abook_prev,
'$abook_next' => $abook_next,
- '$vcard_label' => t('Details'),
+ '$vcard_label' => t('Details'),
'$displayname' => $displayname,
'$name_label' => t('Name'),
'$org_label' => t('Organisation'),
@@ -939,13 +939,13 @@ class Connedit extends Controller {
'$zip_code' => t('ZIP Code'),
'$country' => t('Country')
]);
-
+
$arr = array('contact' => $contact,'output' => $o);
-
+
call_hooks('contact_edit', $arr);
-
+
return $arr['output'];
-
- }
+
+ }
}
}
diff --git a/Zotlabs/Module/Dav.php b/Zotlabs/Module/Dav.php
index 949b89950..96fe2c898 100644
--- a/Zotlabs/Module/Dav.php
+++ b/Zotlabs/Module/Dav.php
@@ -51,7 +51,7 @@ class Dav extends \Zotlabs\Web\Controller {
if($sigblock) {
$keyId = str_replace('acct:','',$sigblock['keyId']);
if($keyId) {
- $r = q("select * from hubloc where hubloc_addr = '%s'",
+ $r = q("select * from hubloc where hubloc_id_url = '%s'",
dbesc($keyId)
);
if($r) {
@@ -124,7 +124,7 @@ class Dav extends \Zotlabs\Web\Controller {
// $server->addPlugin(new \Zotlabs\Storage\QuotaPlugin($auth));
// All we need to do now, is to fire up the server
- $server->exec();
+ $server->start();
killme();
}
diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php
index e1bf0f6cf..7295f3099 100644
--- a/Zotlabs/Module/Directory.php
+++ b/Zotlabs/Module/Directory.php
@@ -4,6 +4,8 @@ namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
+use Zotlabs\Lib\Libzotdir;
+
require_once('include/socgraph.php');
require_once('include/dir_fns.php');
@@ -15,7 +17,7 @@ class Directory extends Controller {
function init() {
App::set_pager_itemspage(30);
-
+
if(local_channel() && x($_GET,'ignore')) {
q("insert into xign ( uid, xchan ) values ( %d, '%s' ) ",
intval(local_channel()),
@@ -26,12 +28,12 @@ class Directory extends Controller {
if(local_channel())
App::$profile_uid = local_channel();
-
+
$observer = get_observer_hash();
$global_changed = false;
$safe_changed = false;
$pubforums_changed = false;
-
+
if(array_key_exists('global',$_REQUEST)) {
$globaldir = intval($_REQUEST['global']);
$global_changed = true;
@@ -41,7 +43,7 @@ class Directory extends Controller {
if($observer)
set_xconfig($observer,'directory','globaldir',$globaldir);
}
-
+
if(array_key_exists('safe',$_REQUEST)) {
$safemode = intval($_REQUEST['safe']);
$safe_changed = true;
@@ -51,8 +53,8 @@ class Directory extends Controller {
if($observer)
set_xconfig($observer,'directory','safemode',$safemode);
}
-
-
+
+
if(array_key_exists('pubforums',$_REQUEST)) {
$pubforums = intval($_REQUEST['pubforums']);
$pubforums_changed = true;
@@ -64,52 +66,52 @@ class Directory extends Controller {
}
}
-
+
function get() {
-
+
if(observer_prohibited()) {
notice( t('Public access denied.') . EOL);
return;
}
-
+
if(get_config('system','block_public_directory',false) && (! get_observer_hash())) {
notice( t('Public access denied.') . EOL);
return;
}
-
+
$observer = get_observer_hash();
-
- $globaldir = get_directory_setting($observer, 'globaldir');
+
+ $globaldir = Libzotdir::get_directory_setting($observer, 'globaldir');
// override your personal global search pref if we're doing a navbar search of the directory
if(intval($_REQUEST['navsearch']))
$globaldir = 1;
-
- $safe_mode = get_directory_setting($observer, 'safemode');
-
- $pubforums = get_directory_setting($observer, 'pubforums');
-
+
+ $safe_mode = Libzotdir::get_directory_setting($observer, 'safemode');
+
+ $pubforums = Libzotdir::get_directory_setting($observer, 'pubforums');
+
$o = '';
nav_set_selected('Directory');
-
+
if(x($_POST,'search'))
$search = notags(trim($_POST['search']));
else
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
-
-
+
+
if(strpos($search,'=') && local_channel() && feature_enabled(local_channel(), 'advanced_dirsearch'))
$advanced = $search;
-
+
$keywords = (($_GET['keywords']) ? $_GET['keywords'] : '');
-
+
// Suggest channels if no search terms or keywords are given
$suggest = (local_channel() && x($_REQUEST,'suggest')) ? $_REQUEST['suggest'] : '';
-
+
if($suggest) {
// the directory options have no effect in suggestion mode
-
+
$globaldir = 1;
$safe_mode = 1;
$type = 0;
@@ -120,7 +122,7 @@ class Directory extends Controller {
notice( t('No default suggestions were found.') . EOL);
return;
}
-
+
// Remember in which order the suggestions were
$addresses = array();
$common = array();
@@ -129,7 +131,7 @@ class Directory extends Controller {
$common[$rr['xchan_addr']] = ((intval($rr['total']) > 0) ? intval($rr['total']) - 1 : 0);
$addresses[$rr['xchan_addr']] = $index++;
}
-
+
// Build query to get info about suggested people
$advanced = '';
foreach(array_keys($addresses) as $address) {
@@ -137,13 +139,13 @@ class Directory extends Controller {
}
// Remove last space in the advanced query
$advanced = rtrim($advanced);
-
+
}
-
+
$tpl = get_markup_template('directory_header.tpl');
-
+
$dirmode = intval(get_config('system','directory_mode'));
-
+
$directory_admin = false;
if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
@@ -154,19 +156,19 @@ class Directory extends Controller {
}
if(! $url) {
- $directory = find_upstream_directory($dirmode);
+ $directory = Libzotdir::find_upstream_directory($dirmode);
if((! $directory) || (! array_key_exists('url',$directory)) || (! $directory['url']))
logger('CRITICAL: No directory server URL');
$url = $directory['url'] . '/dirsearch';
}
-
+
$token = get_config('system','realm_token');
-
-
+
+
logger('mod_directory: URL = ' . $url, LOGGER_DEBUG);
-
+
$contacts = array();
-
+
if(local_channel()) {
$x = q("select abook_xchan from abook where abook_channel = %d",
intval(local_channel())
@@ -176,24 +178,24 @@ class Directory extends Controller {
$contacts[] = $xx['abook_xchan'];
}
}
-
+
if($url) {
-
+
$numtags = get_config('system','directorytags');
-
+
$kw = ((intval($numtags) > 0) ? intval($numtags) : 50);
-
+
if(get_config('system','disable_directory_keywords'))
$kw = 0;
-
+
$query = $url . '?f=&kw=' . $kw . (($safe_mode != 1) ? '&safe=' . $safe_mode : '');
-
+
if($token)
$query .= '&t=' . $token;
-
+
if(! $globaldir)
$query .= '&hub=' . App::get_hostname();
-
+
if($search)
$query .= '&name=' . urlencode($search) . '&keywords=' . urlencode($search);
if(strpos($search,'@'))
@@ -204,29 +206,29 @@ class Directory extends Controller {
$query .= '&query=' . urlencode($advanced);
if(! is_null($pubforums))
$query .= '&pubforums=' . intval($pubforums);
-
+
$directory_sort_order = get_config('system','directory_sort_order');
if(! $directory_sort_order)
$directory_sort_order = 'date';
-
+
$sort_order = ((x($_REQUEST,'order')) ? $_REQUEST['order'] : $directory_sort_order);
-
+
if($sort_order)
$query .= '&order=' . urlencode($sort_order);
-
+
if(App::$pager['page'] != 1)
$query .= '&p=' . App::$pager['page'];
-
+
logger('mod_directory: query: ' . $query);
-
+
$x = z_fetch_url($query);
logger('directory: return from upstream: ' . print_r($x,true), LOGGER_DATA);
-
+
if($x['success']) {
$t = 0;
$j = json_decode($x['body'],true);
if($j) {
-
+
if($j['results']) {
$results = $j['results'];
@@ -235,23 +237,23 @@ class Directory extends Controller {
}
$entries = array();
-
+
$photo = 'thumb';
-
+
foreach($results as $rr) {
-
+
$profile_link = chanlink_url($rr['url']);
-
+
$pdesc = (($rr['description']) ? $rr['description'] . '<br />' : '');
- $connect_link = ((local_channel()) ? z_root() . '/follow?f=&url=' . urlencode($rr['address']) : '');
-
+ $connect_link = ((local_channel()) ? z_root() . '/follow?f=&url=' . urlencode($rr['address']) : '');
+
// Checking status is disabled ATM until someone checks the performance impact more carefully
//$online = remote_online_status($rr['address']);
$online = '';
-
+
if(in_array($rr['hash'],$contacts))
$connect_link = '';
-
+
$location = '';
if(strlen($rr['locale']))
$location .= $rr['locale'];
@@ -265,53 +267,53 @@ class Directory extends Controller {
$location .= ', ';
$location .= $rr['country'];
}
-
+
$age = '';
if(strlen($rr['birthday'])) {
if(($years = age($rr['birthday'],'UTC','')) > 0)
$age = $years;
}
-
+
$page_type = '';
-
+
$rating_enabled = get_config('system','rating_enabled');
if($rr['total_ratings'] && $rating_enabled)
$total_ratings = sprintf( tt("%d rating", "%d ratings", $rr['total_ratings']), $rr['total_ratings']);
else
$total_ratings = '';
-
+
$profile = $rr;
-
+
if ((x($profile,'locale') == 1)
|| (x($profile,'region') == 1)
|| (x($profile,'postcode') == 1)
|| (x($profile,'country') == 1))
-
+
$gender = ((x($profile,'gender') == 1) ? t('Gender: ') . $profile['gender']: False);
-
+
$marital = ((x($profile,'marital') == 1) ? t('Status: ') . $profile['marital']: False);
-
+
$homepage = ((x($profile,'homepage') == 1) ? t('Homepage: ') : False);
- $homepageurl = ((x($profile,'homepage') == 1) ? html2plain($profile['homepage']) : '');
-
+ $homepageurl = ((x($profile,'homepage') == 1) ? html2plain($profile['homepage']) : '');
+
$hometown = ((x($profile,'hometown') == 1) ? html2plain($profile['hometown']) : False);
-
+
$about = ((x($profile,'about') == 1) ? zidify_links(bbcode($profile['about'], ['tryoembed' => false])) : False);
if ($about && $safe_mode) {
$about = html2plain($about);
}
-
+
$keywords = ((x($profile,'keywords')) ? $profile['keywords'] : '');
-
+
$out = '';
-
+
if($keywords) {
$keywords = str_replace(',',' ', $keywords);
$keywords = str_replace(' ',' ', $keywords);
$karr = explode(' ', $keywords);
-
+
if($karr) {
if(local_channel()) {
$r = q("select keywords from profile where uid = %d and is_default = 1 limit 1",
@@ -332,9 +334,9 @@ class Directory extends Controller {
$out .= '<a href="' . z_root() . '/directory/f=&keywords=' . urlencode($k) .'">' . $k . '</a>';
}
}
-
+
}
-
+
$entry = array(
'id' => ++$t,
'profile_link' => $profile_link,
@@ -366,7 +368,7 @@ class Directory extends Controller {
'about' => $about,
'about_label' => t('About:'),
'conn_label' => t('Connect'),
- 'forum_label' => t('Public Forum:'),
+ 'forum_label' => t('Public Forum:'),
'connect' => $connect_link,
'online' => $online,
'kw' => (($out) ? t('Keywords: ') : ''),
@@ -378,36 +380,36 @@ class Directory extends Controller {
'common_count' => intval($common[$rr['address']]),
'safe' => $safe_mode
);
-
+
$arr = array('contact' => $rr, 'entry' => $entry);
-
+
call_hooks('directory_item', $arr);
-
+
unset($profile);
unset($location);
-
+
if(! $arr['entry']) {
continue;
- }
-
+ }
+
if($sort_order == '' && $suggest) {
$entries[$addresses[$rr['address']]] = $arr['entry']; // Use the same indexes as originally to get the best suggestion first
}
-
+
else {
$entries[] = $arr['entry'];
}
}
-
+
ksort($entries); // Sort array by key so that foreach-constructs work as expected
-
+
if($j['keywords']) {
App::$data['directory_keywords'] = $j['keywords'];
}
-
+
logger('mod_directory: entries: ' . print_r($entries,true), LOGGER_DATA);
-
-
+
+
if($_REQUEST['aj']) {
if($entries) {
$o = replace_macros(get_markup_template('directajax.tpl'),array(
@@ -422,9 +424,9 @@ class Directory extends Controller {
}
else {
$maxheight = 94;
-
+
$dirtitle = (($globaldir) ? t('Global Directory') : t('Local Directory'));
-
+
$o .= "<script> var page_query = '" . escape_tags(urlencode($_GET['q'])) . "'; var extra_args = '" . extra_query_args() . "' ; divmore_height = " . intval($maxheight) . "; </script>";
$o .= replace_macros($tpl, array(
'$search' => $search,
@@ -442,10 +444,10 @@ class Directory extends Controller {
'$reversedate' => t('Oldest to Newest'),
'$suggest' => $suggest ? '&suggest=1' : ''
));
-
-
+
+
}
-
+
}
else {
if($_REQUEST['aj']) {
@@ -463,7 +465,7 @@ class Directory extends Controller {
}
return $o;
}
-
+
static public function reorder_results($results,$suggests) {
if(! $suggests)
diff --git a/Zotlabs/Module/Dirsearch.php b/Zotlabs/Module/Dirsearch.php
index c15b13a90..804d7af5c 100644
--- a/Zotlabs/Module/Dirsearch.php
+++ b/Zotlabs/Module/Dirsearch.php
@@ -192,7 +192,7 @@ class Dirsearch extends Controller {
else {
$qlimit = " LIMIT " . intval($perpage) . " OFFSET " . intval($startrec);
if($return_total) {
- $r = q("SELECT COUNT(xchan_hash) AS total FROM xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and xchan_network = 'zot' and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0 $safesql ");
+ $r = q("SELECT COUNT(xchan_hash) AS total FROM xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and xchan_network = 'zot6' and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0 $safesql ");
if($r) {
$ret['total_items'] = $r[0]['total'];
}
@@ -261,7 +261,7 @@ class Dirsearch extends Controller {
else {
$r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash
- where ( $logic $sql_extra ) $hub_query and xchan_network = 'zot' and xchan_system = 0 and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0
+ where ( $logic $sql_extra ) $hub_query and xchan_network = 'zot6' and xchan_system = 0 and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0
$safesql $order $qlimit "
);
diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php
index 81ac0f7b8..04aeb6d5c 100644
--- a/Zotlabs/Module/Display.php
+++ b/Zotlabs/Module/Display.php
@@ -19,21 +19,21 @@ class Display extends \Zotlabs\Web\Controller {
if(argc() > 1) {
$module_format = substr(argv(1),strrpos(argv(1),'.') + 1);
if(! in_array($module_format,['atom','zot','json']))
- $module_format = 'html';
+ $module_format = 'html';
}
if(observer_prohibited()) {
notice( t('Public access denied.') . EOL);
return;
}
-
+
if(argc() > 1) {
$item_hash = argv(1);
if($module_format !== 'html') {
$item_hash = substr($item_hash,0,strrpos($item_hash,'.'));
}
}
-
+
if($_REQUEST['mid'])
$item_hash = $_REQUEST['mid'];
@@ -42,19 +42,19 @@ class Display extends \Zotlabs\Web\Controller {
notice( t('Item not found.') . EOL);
return;
}
-
+
$observer_is_owner = false;
if(local_channel() && (! $update)) {
-
+
$channel = \App::get_channel();
$channel_acl = array(
- 'allow_cid' => $channel['channel_allow_cid'],
- 'allow_gid' => $channel['channel_allow_gid'],
- 'deny_cid' => $channel['channel_deny_cid'],
+ 'allow_cid' => $channel['channel_allow_cid'],
+ 'allow_gid' => $channel['channel_allow_gid'],
+ 'deny_cid' => $channel['channel_deny_cid'],
'deny_gid' => $channel['channel_deny_gid']
- );
+ );
$x = array(
'is_owner' => true,
@@ -62,7 +62,7 @@ class Display extends \Zotlabs\Web\Controller {
'default_location' => $channel['channel_location'],
'nickname' => $channel['channel_address'],
'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
- 'acl' => populate_acl($channel_acl,true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'),
+ 'acl' => populate_acl($channel_acl,true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'),
'permissions' => $channel_acl,
'bang' => '',
'visitor' => true,
@@ -75,21 +75,21 @@ class Display extends \Zotlabs\Web\Controller {
'jotnets' => true,
'reset' => t('Reset form')
);
-
+
$o = '<div id="jot-popup">';
$o .= status_editor($a,$x,false,'Display');
$o .= '</div>';
}
-
+
// This page can be viewed by anybody so the query could be complicated
// First we'll see if there is a copy of the item which is owned by us - if we're logged in locally.
- // If that fails (or we aren't logged in locally),
+ // If that fails (or we aren't logged in locally),
// query an item in which the observer (if logged in remotely) has cid or gid rights
- // and if that fails, look for a copy of the post that has no privacy restrictions.
+ // and if that fails, look for a copy of the post that has no privacy restrictions.
// If we find the post, but we don't find a copy that we're allowed to look at, this fact needs to be reported.
-
+
// find a copy of the item somewhere
-
+
$target_item = null;
if(strpos($item_hash,'b64.') === 0)
@@ -100,7 +100,7 @@ class Display extends \Zotlabs\Web\Controller {
$r = q("select id, uid, mid, parent, parent_mid, thr_parent, verb, item_type, item_deleted, author_xchan, item_blocked from item where mid like '%s' limit 1",
dbesc($item_hash . '%')
);
-
+
if($r) {
$target_item = $r[0];
}
@@ -117,14 +117,14 @@ class Display extends \Zotlabs\Web\Controller {
if($target_item['item_blocked'] == ITEM_MODERATED) {
goaway(z_root() . '/moderate/' . $target_item['id']);
}
-
+
$r = null;
-
+
if($target_item['item_type'] == ITEM_TYPE_WEBPAGE) {
$x = q("select * from channel where channel_id = %d limit 1",
intval($target_item['uid'])
);
- $y = q("select * from iconfig left join item on iconfig.iid = item.id
+ $y = q("select * from iconfig left join item on iconfig.iid = item.id
where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'WEBPAGE' and item.id = %d limit 1",
intval($target_item['uid']),
intval($target_item['parent'])
@@ -141,7 +141,7 @@ class Display extends \Zotlabs\Web\Controller {
$x = q("select * from channel where channel_id = %d limit 1",
intval($target_item['uid'])
);
- $y = q("select * from iconfig left join item on iconfig.iid = item.id
+ $y = q("select * from iconfig left join item on iconfig.iid = item.id
where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'ARTICLE' and item.id = %d limit 1",
intval($target_item['uid']),
intval($target_item['parent'])
@@ -160,7 +160,7 @@ class Display extends \Zotlabs\Web\Controller {
intval($target_item['uid'])
);
- $y = q("select * from iconfig left join item on iconfig.iid = item.id
+ $y = q("select * from iconfig left join item on iconfig.iid = item.id
where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'CARD' and item.id = %d limit 1",
intval($target_item['uid']),
intval($target_item['parent'])
@@ -179,7 +179,7 @@ class Display extends \Zotlabs\Web\Controller {
notice( t('Page not found.') . EOL);
return '';
}
-
+
$simple_update = '';
if($update && $_SESSION['loadtime'])
$simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) ";
@@ -191,14 +191,14 @@ class Display extends \Zotlabs\Web\Controller {
//$mid = ((($target_item['verb'] == ACTIVITY_LIKE) || ($target_item['verb'] == ACTIVITY_DISLIKE)) ? $target_item['thr_parent'] : $target_item['mid']);
$mid = $target_item['mid'];
- // if we got a decoded hash we must encode it again before handing to javascript
+ // if we got a decoded hash we must encode it again before handing to javascript
if($decoded)
$mid = 'b64.' . base64url_encode($mid);
$o .= '<div id="live-display"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . ((intval(local_channel())) ? local_channel() : (-1))
. "; var netargs = '?f='; var profile_page = " . \App::$pager['page'] . "; </script>\r\n";
-
+
\App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
'$baseurl' => z_root(),
'$pgtype' => 'display',
@@ -230,7 +230,7 @@ class Display extends \Zotlabs\Web\Controller {
'$mid' => (($mid) ? urlencode($mid) : '')
));
- head_add_link([
+ head_add_link([
'rel' => 'alternate',
'type' => 'application/json+oembed',
'href' => z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$query_string),
@@ -270,8 +270,8 @@ class Display extends \Zotlabs\Web\Controller {
$r = q("SELECT item.id as item_id from item
WHERE mid = '%s'
- AND (((( item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = ''
- AND item.deny_gid = '' AND item_private = 0 )
+ AND (((( item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = ''
+ AND item.deny_gid = '' AND item_private = 0 )
and uid in ( " . stream_perms_api_uids(($observer_hash) ? (PERMS_NETWORK|PERMS_PUBLIC) : PERMS_PUBLIC) . " ))
OR uid = %d )
$sql_extra )
@@ -282,7 +282,7 @@ class Display extends \Zotlabs\Web\Controller {
);
}
}
-
+
elseif($update && !$load) {
$r = null;
@@ -307,8 +307,8 @@ class Display extends \Zotlabs\Web\Controller {
$sysid = 0;
$r = q("SELECT item.parent AS item_id from item
WHERE parent_mid = '%s'
- AND (((( item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = ''
- AND item.deny_gid = '' AND item_private = 0 )
+ AND (((( item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = ''
+ AND item.deny_gid = '' AND item_private = 0 )
and uid in ( " . stream_perms_api_uids(($observer_hash) ? (PERMS_NETWORK|PERMS_PUBLIC) : PERMS_PUBLIC) . " ))
OR uid = %d )
$sql_extra )
@@ -320,7 +320,7 @@ class Display extends \Zotlabs\Web\Controller {
);
}
}
-
+
else {
$r = array();
}
@@ -328,7 +328,7 @@ class Display extends \Zotlabs\Web\Controller {
if($r) {
$parents_str = ids_to_querystr($r,'item_id');
if($parents_str) {
- $items = q("SELECT item.*, item.id AS item_id
+ $items = q("SELECT item.*, item.id AS item_id
FROM item
WHERE parent in ( %s ) $item_normal ",
dbesc($parents_str)
@@ -341,10 +341,10 @@ class Display extends \Zotlabs\Web\Controller {
else {
$items = array();
}
-
+
switch($module_format) {
-
+
case 'html':
if ($update) {
@@ -363,7 +363,7 @@ class Display extends \Zotlabs\Web\Controller {
\App::$page['title'] = (($items[0]['title']) ? $items[0]['title'] . " - " . \App::$page['title'] : \App::$page['title']);
$o .= conversation($items, 'display', $update, 'client');
- }
+ }
break;
@@ -380,7 +380,7 @@ class Display extends \Zotlabs\Web\Controller {
'$owner' => '',
'$profile_page' => xmlify(z_root() . '/display/' . $target_item['mid']),
));
-
+
$x = [ 'xml' => $atom, 'channel' => $channel, 'observer_hash' => $observer_hash, 'params' => $params ];
call_hooks('atom_feed_top',$x);
@@ -406,13 +406,13 @@ class Display extends \Zotlabs\Web\Controller {
header('Content-type: application/atom+xml');
echo $atom;
killme();
-
+
}
$o .= '<div id="content-complete"></div>';
if((($update && $load) || $noscript_content) && (! $items)) {
-
+
$r = q("SELECT id, item_deleted FROM item WHERE mid = '%s' LIMIT 1",
dbesc($item_hash)
);
@@ -421,14 +421,14 @@ class Display extends \Zotlabs\Web\Controller {
if(intval($r[0]['item_deleted'])) {
notice( t('Item has been removed.') . EOL );
}
- else {
- notice( t('Permission denied.') . EOL );
+ else {
+ notice( t('Permission denied.') . EOL );
}
}
else {
notice( t('Item not found.') . EOL );
}
-
+
}
$_SESSION['loadtime'] = datetime_convert();
diff --git a/Zotlabs/Module/Embedphotos.php b/Zotlabs/Module/Embedphotos.php
index 9b0884197..ed5b24724 100644
--- a/Zotlabs/Module/Embedphotos.php
+++ b/Zotlabs/Module/Embedphotos.php
@@ -40,7 +40,8 @@ class Embedphotos extends \Zotlabs\Web\Controller {
if (!$href) {
json_return_and_die(array('errormsg' => 'Error retrieving link ' . $href, 'status' => false));
}
- $resource_id = array_pop(explode('/', $href));
+ $arr = explode('/', $href);
+ $resource_id = array_pop($arr);
$x = self::photolink($resource_id);
if($x)
json_return_and_die(array('status' => true, 'photolink' => $x, 'resource_id' => $resource_id));
diff --git a/Zotlabs/Module/File_upload.php b/Zotlabs/Module/File_upload.php
index 6794dceee..e18067e20 100644
--- a/Zotlabs/Module/File_upload.php
+++ b/Zotlabs/Module/File_upload.php
@@ -64,7 +64,7 @@ class File_upload extends \Zotlabs\Web\Controller {
if($x['partial']) {
header('Range: bytes=0-' . (($x['length']) ? $x['length'] - 1 : 0));
- json_return_and_die($result);
+ json_return_and_die($x);
}
else {
header('Range: bytes=0-' . (($x['size']) ? $x['size'] - 1 : 0));
diff --git a/Zotlabs/Module/Getfile.php b/Zotlabs/Module/Getfile.php
index 17d1c84b8..20cc23ac0 100644
--- a/Zotlabs/Module/Getfile.php
+++ b/Zotlabs/Module/Getfile.php
@@ -6,20 +6,20 @@ use Zotlabs\Lib\Libzot;
/**
* module: getfile
- *
+ *
* used for synchronising files and photos across clones
- *
+ *
* The site initiating the file operation will send a sync packet to known clones.
* They will respond by building the DB structures they require, then will provide a
* post request to this site to grab the file data. This is sent as a stream direct to
* disk at the other end, avoiding memory issues.
*
* Since magic-auth cannot easily be used by the CURL process at the other end,
- * we will require a signed request which includes a timestamp. This should not be
- * used without SSL and is potentially vulnerable to replay if an attacker decrypts
+ * we will require a signed request which includes a timestamp. This should not be
+ * used without SSL and is potentially vulnerable to replay if an attacker decrypts
* the SSL traffic fast enough. The amount of time slop is configurable but defaults
* to 3 minutes.
- *
+ *
*/
@@ -54,13 +54,13 @@ class Getfile extends \Zotlabs\Web\Controller {
$keyId = $sigblock['keyId'];
if($keyId) {
- $r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash
- where hubloc_addr = '%s'",
+ $r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash
+ where hubloc_id_url = '%s'",
dbesc(str_replace('acct:','',$keyId))
);
if($r) {
$hubloc = Libzot::zot_record_preferred($r);
- $verified = HTTPSig::verify('',$hubloc['xchan_pubkey']);
+ $verified = HTTPSig::verify('',$hubloc['xchan_pubkey']);
if($verified && $verified['header_signed'] && $verified['header_valid'] && $hash == $hubloc['hubloc_hash']) {
$header_verified = true;
}
@@ -74,15 +74,15 @@ class Getfile extends \Zotlabs\Web\Controller {
logger('post: ' . print_r($_POST,true),LOGGER_DEBUG,LOG_INFO);
if($header_verified) {
logger('HTTPSig verified');
- }
-
+ }
+
$channel = channelx_by_hash($hash);
if((! $channel) || (! $time) || (! $sig)) {
logger('error: missing info');
killme();
}
-
+
if(isset($_POST['resolution']))
$resolution = intval($_POST['resolution']);
elseif(substr($resource,-2,1) == '-') {
@@ -91,21 +91,21 @@ class Getfile extends \Zotlabs\Web\Controller {
}
else {
$resolution = (-1);
- }
+ }
$slop = intval(get_pconfig($channel['channel_id'],'system','getfile_time_slop'));
if($slop < 1)
$slop = 3;
-
+
$d1 = datetime_convert('UTC','UTC',"now + $slop minutes");
- $d2 = datetime_convert('UTC','UTC',"now - $slop minutes");
-
+ $d2 = datetime_convert('UTC','UTC',"now - $slop minutes");
+
if(! $header_verified) {
if(($time > $d1) || ($time < $d2)) {
logger('time outside allowable range');
killme();
}
-
+
if(! rsa_verify($hash . '.' . $time,base64url_decode($sig),$channel['channel_pubkey'])) {
logger('verify failed.');
killme();
@@ -137,20 +137,20 @@ class Getfile extends \Zotlabs\Web\Controller {
else {
echo dbunescbin($r[0]['content']);
}
- }
+ }
killme();
}
$r = attach_by_hash($resource,$channel['channel_hash'],$revision);
-
+
if(! $r['success']) {
logger('attach_by_hash failed: ' . $r['message']);
notice( $r['message'] . EOL);
return;
}
-
+
$unsafe_types = array('text/html','text/css','application/javascript');
-
+
if(in_array($r['data']['filetype'],$unsafe_types) && (! channel_codeallowed($channel['channel_id']))) {
header('Content-type: text/plain');
}
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php
index 9a120dac1..83424a50d 100644
--- a/Zotlabs/Module/Item.php
+++ b/Zotlabs/Module/Item.php
@@ -976,7 +976,7 @@ class Item extends Controller {
$item_unseen = ((local_channel() != $profile_uid) ? 1 : 0);
- $item_wall = (($post_type === 'wall' || $post_type === 'wall-comment') ? 1 : 0);
+ $item_wall = (($_REQUEST['type'] === 'wall' || $_REQUEST['type'] === 'wall-comment') ? 1 : 0);
$item_origin = (($origin) ? 1 : 0);
$item_consensus = (($consensus) ? 1 : 0);
$item_nocomment = (($nocomment) ? 1 : 0);
@@ -1337,7 +1337,7 @@ class Item extends Controller {
killme();
}
- if(($parent == $post_id) || ($datarray['item_private'] == 1)) {
+ if($parent || $datarray['item_private'] == 1) {
$r = q("select * from item where id = %d",
intval($post_id)
);
diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php
index bb5c6db7a..e3fe4a954 100644
--- a/Zotlabs/Module/Like.php
+++ b/Zotlabs/Module/Like.php
@@ -1,37 +1,42 @@
<?php
+
namespace Zotlabs\Module;
+use App;
use Zotlabs\Lib\Activity;
use Zotlabs\Lib\Libsync;
+use Zotlabs\Web\Controller;
+use Zotlabs\Daemon\Master;
+
require_once('include/security.php');
require_once('include/bbcode.php');
require_once('include/items.php');
require_once('include/conversation.php');
-class Like extends \Zotlabs\Web\Controller {
+class Like extends Controller {
private function reaction_to_activity($reaction) {
$acts = [
- 'like' => ACTIVITY_LIKE ,
- 'dislike' => ACTIVITY_DISLIKE ,
- 'agree' => ACTIVITY_AGREE ,
- 'disagree' => ACTIVITY_DISAGREE ,
- 'abstain' => ACTIVITY_ABSTAIN ,
- 'attendyes' => ACTIVITY_ATTEND ,
- 'attendno' => ACTIVITY_ATTENDNO ,
- 'attendmaybe' => ACTIVITY_ATTENDMAYBE
+ 'like' => ACTIVITY_LIKE,
+ 'dislike' => ACTIVITY_DISLIKE,
+ 'agree' => ACTIVITY_AGREE,
+ 'disagree' => ACTIVITY_DISAGREE,
+ 'abstain' => ACTIVITY_ABSTAIN,
+ 'attendyes' => ACTIVITY_ATTEND,
+ 'attendno' => ACTIVITY_ATTENDNO,
+ 'attendmaybe' => ACTIVITY_ATTENDMAYBE
];
// unlike (etc.) reactions are an undo of positive reactions, rather than a negative action.
// The activity is the same in undo actions and will have the same activity mapping
- if(substr($reaction,0,2) === 'un') {
- $reaction = substr($reaction,2);
+ if (substr($reaction, 0, 2) === 'un') {
+ $reaction = substr($reaction, 2);
}
- if(array_key_exists($reaction,$acts)) {
+ if (array_key_exists($reaction, $acts)) {
return $acts[$reaction];
}
@@ -41,117 +46,124 @@ class Like extends \Zotlabs\Web\Controller {
private function like_response($arr) {
- if($arr['conv_mode'] === 'channel') {
+ $page_mode = (($arr['item']['item_thread_top'] && $_REQUEST['page_mode']) ? $_REQUEST['page_mode'] : 'r_preview');
+ $conv_mode = (($_REQUEST['conv_mode']) ? $_REQUEST['conv_mode'] : 'network');
+
+ if ($conv_mode === 'channel') {
$parts = explode('@', $arr['owner_xchan']['xchan_addr']);
profile_load($parts[0]);
}
-
$item_normal = item_normal();
- $activities = q("SELECT item.*, item.id AS item_id FROM item
- WHERE uid = %d $item_normal
- AND thr_parent = '%s'
- AND verb IN ('%s', '%s', '%s', '%s', '%s')",
- intval($arr['item']['uid']),
- dbesc($arr['item']['mid']),
- dbesc(ACTIVITY_LIKE),
- dbesc(ACTIVITY_DISLIKE),
- dbesc(ACTIVITY_ATTEND),
- dbesc(ACTIVITY_ATTENDNO),
- dbesc(ACTIVITY_ATTENDMAYBE)
- );
-
- xchan_query($activities,true);
-
- $convitems[] = $arr['item'];
- $convitems = array_merge($convitems, $activities);
-
- $convitems = fetch_post_tags($convitems,true);
+ if ($page_mode === 'list') {
+ $items = q("SELECT item.*, item.id AS item_id FROM item
+ WHERE uid = %d $item_normal
+ AND parent = %d",
+ intval($arr['item']['uid']),
+ intval($arr['item']['parent'])
+ );
+ xchan_query($items, true);
+ $items = fetch_post_tags($items, true);
+ $items = conv_sort($items, 'commented');
+ }
+ else {
+ $activities = q("SELECT item.*, item.id AS item_id FROM item
+ WHERE uid = %d $item_normal
+ AND thr_parent = '%s'
+ AND verb IN ('%s', '%s', '%s', '%s', '%s')",
+ intval($arr['item']['uid']),
+ dbesc($arr['item']['mid']),
+ dbesc(ACTIVITY_LIKE),
+ dbesc(ACTIVITY_DISLIKE),
+ dbesc(ACTIVITY_ATTEND),
+ dbesc(ACTIVITY_ATTENDNO),
+ dbesc(ACTIVITY_ATTENDMAYBE)
+ );
+ xchan_query($activities, true);
+ $items = array_merge([$arr['item']], $activities);
+ $items = fetch_post_tags($items, true);
+ }
$ret = [
'success' => 1,
'orig_id' => $arr['orig_item_id'], //this is required for pubstream items where $item_id != $item['id']
- 'id' => $arr['item']['id'],
- 'html' => conversation($convitems, $arr['conv_mode'], true, 'r_preview'),
+ 'id' => $arr['item']['id'],
+ 'html' => conversation($items, $conv_mode, true, $page_mode),
];
-
return $ret;
}
public function get() {
-
- $o = EMPTY_STR;
+ $o = EMPTY_STR;
$sys_channel = get_sys_channel();
- $sys_channel_id = (($sys_channel) ? $sys_channel['channel_id'] : 0);
-
- $observer = \App::get_observer();
+ $observer = App::get_observer();
$interactive = $_REQUEST['interactive'];
- if((! $observer) || ($interactive)) {
+
+ if ((!$observer) || ($interactive)) {
$o .= '<h1>' . t('Like/Dislike') . '</h1>';
$o .= EOL . EOL;
-
- if(! $observer) {
- $_SESSION['return_url'] = \App::$query_string;
+
+ if (!$observer) {
+ $_SESSION['return_url'] = App::$query_string;
+
$o .= t('This action is restricted to members.') . EOL;
$o .= t('Please <a href="rmagic">login with your $Projectname ID</a> or <a href="register">register as a new $Projectname member</a> to continue.') . EOL;
return $o;
}
}
-
+
$verb = notags(trim($_GET['verb']));
- $mode = (($_GET['conv_mode'] === 'channel') ? 'channel' : 'network');
- if(! $verb)
+ if (!$verb)
$verb = 'like';
-
+
$activity = $this->reaction_to_activity($verb);
- if(! $activity) {
- return EMPTY_STR;
+ if (!$activity) {
+ return EMPTY_STR;
}
$is_rsvp = false;
- if (in_array($activity, [ ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE ])) {
+ if (in_array($activity, [ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE])) {
$is_rsvp = true;
}
-
$extended_like = false;
- $object = $target = null;
- $post_type = EMPTY_STR;
- $objtype = EMPTY_STR;
-
- if(argc() == 3) {
-
- if(! $observer)
+ $object = $target = null;
+ $post_type = EMPTY_STR;
+ $objtype = EMPTY_STR;
+
+ if (argc() == 3) {
+
+ if (!$observer)
killme();
-
+
$extended_like = true;
- $obj_type = argv(1);
- $obj_id = argv(2);
- $public = true;
-
- if($obj_type == 'profile') {
+ $obj_type = argv(1);
+ $obj_id = argv(2);
+ $public = true;
+
+ if ($obj_type == 'profile') {
$r = q("select * from profile where profile_guid = '%s' limit 1",
dbesc(argv(2))
);
- if(! $r)
- killme();
+ if (!$r)
+ killme();
$owner_uid = $r[0]['uid'];
- if($r[0]['is_default'])
+ if ($r[0]['is_default'])
$public = true;
- if(! $public) {
+ if (!$public) {
$d = q("select abook_xchan from abook where abook_profile = '%s' and abook_channel = %d",
dbesc($r[0]['profile_guid']),
intval($owner_uid)
);
- if(! $d) {
+ if (!$d) {
// forgery - illegal
- if($interactive) {
- notice( t('Invalid request.') . EOL);
+ if ($interactive) {
+ notice(t('Invalid request.') . EOL);
return $o;
}
killme();
@@ -159,122 +171,122 @@ class Like extends \Zotlabs\Web\Controller {
// $d now contains a list of those who can see this profile - only send the status notification
// to them.
$allow_cid = $allow_gid = $deny_cid = $deny_gid = '';
- foreach($d as $dd) {
+ foreach ($d as $dd) {
$allow_cid .= '<' . $dd['abook_xchan'] . '>';
}
}
$post_type = t('channel');
- $objtype = ACTIVITY_OBJ_PROFILE;
-
+ $objtype = ACTIVITY_OBJ_PROFILE;
+
$profile = $r[0];
}
- elseif($obj_type == 'thing') {
-
+ elseif ($obj_type == 'thing') {
+
$r = q("select * from obj where obj_type = %d and obj_obj = '%s' limit 1",
- intval(TERM_OBJ_THING),
- dbesc(argv(2))
- );
-
- if(! $r) {
- if($interactive) {
- notice( t('Invalid request.') . EOL);
+ intval(TERM_OBJ_THING),
+ dbesc(argv(2))
+ );
+
+ if (!$r) {
+ if ($interactive) {
+ notice(t('Invalid request.') . EOL);
return $o;
}
- killme();
+ killme();
}
-
+
$owner_uid = $r[0]['obj_channel'];
-
+
$allow_cid = $r[0]['allow_cid'];
$allow_gid = $r[0]['allow_gid'];
- $deny_cid = $r[0]['deny_cid'];
- $deny_gid = $r[0]['deny_gid'];
- if($allow_cid || $allow_gid || $deny_cid || $deny_gid)
+ $deny_cid = $r[0]['deny_cid'];
+ $deny_gid = $r[0]['deny_gid'];
+ if ($allow_cid || $allow_gid || $deny_cid || $deny_gid)
$public = false;
-
+
$post_type = t('thing');
- $objtype = ACTIVITY_OBJ_PROFILE;
- $tgttype = ACTIVITY_OBJ_THING;
-
+ $objtype = ACTIVITY_OBJ_PROFILE;
+ $tgttype = ACTIVITY_OBJ_THING;
+
$links = array();
- $links[] = array('rel' => 'alternate', 'type' => 'text/html',
- 'href' => z_root() . '/thing/' . $r[0]['obj_obj']);
- if($r[0]['imgurl'])
+ $links[] = array('rel' => 'alternate', 'type' => 'text/html',
+ 'href' => z_root() . '/thing/' . $r[0]['obj_obj']);
+ if ($r[0]['imgurl'])
$links[] = array('rel' => 'photo', 'href' => $r[0]['obj_imgurl']);
-
+
$target = json_encode(array(
'type' => $tgttype,
'title' => $r[0]['obj_term'],
'id' => z_root() . '/thing/' . $r[0]['obj_obj'],
'link' => $links
));
-
+
$plink = '[zrl=' . z_root() . '/thing/' . $r[0]['obj_obj'] . ']' . $r[0]['obj_term'] . '[/zrl]';
-
+
}
-
- if(! ($owner_uid && $r)) {
- if($interactive) {
- notice( t('Invalid request.') . EOL);
+
+ if (!($owner_uid && $r)) {
+ if ($interactive) {
+ notice(t('Invalid request.') . EOL);
return $o;
}
killme();
}
-
+
// The resultant activity is going to be a wall-to-wall post, so make sure this is allowed
-
- $perms = get_all_perms($owner_uid,$observer['xchan_hash']);
-
- if(! ($perms['post_like'] && $perms['view_profile'])) {
- if($interactive) {
- notice( t('Permission denied.') . EOL);
+
+ $perms = get_all_perms($owner_uid, $observer['xchan_hash']);
+
+ if (!($perms['post_like'] && $perms['view_profile'])) {
+ if ($interactive) {
+ notice(t('Permission denied.') . EOL);
return $o;
}
killme();
}
-
+
$ch = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d limit 1",
intval($owner_uid)
);
- if(! $ch) {
- if($interactive) {
- notice( t('Channel unavailable.') . EOL);
+ if (!$ch) {
+ if ($interactive) {
+ notice(t('Channel unavailable.') . EOL);
return $o;
}
killme();
}
-
- if(! $plink)
+
+ if (!$plink)
$plink = '[zrl=' . z_root() . '/profile/' . $ch[0]['channel_address'] . ']' . $post_type . '[/zrl]';
-
- $object = json_encode(Activity::fetch_profile([ 'id' => channel_url($ch[0]) ]));
+
+ $object = json_encode(Activity::fetch_profile(['id' => channel_url($ch[0])]));
// second like of the same thing is "undo" for the first like
-
+
$z = q("select * from likes where channel_id = %d and liker = '%s' and verb = '%s' and target_type = '%s' and target_id = '%s' limit 1",
intval($ch[0]['channel_id']),
dbesc($observer['xchan_hash']),
dbesc($activity),
- dbesc(($tgttype)?$tgttype:$objtype),
+ dbesc(($tgttype) ? $tgttype : $objtype),
dbesc($obj_id)
);
-
- if($z) {
+
+ if ($z) {
$z[0]['deleted'] = 1;
- Libsync::build_sync_packet($ch[0]['channel_id'],array('likes' => $z));
-
+ Libsync::build_sync_packet($ch[0]['channel_id'], array('likes' => $z));
+
q("delete from likes where id = %d",
intval($z[0]['id'])
);
- if($z[0]['i_mid']) {
+ if ($z[0]['i_mid']) {
$r = q("select id from item where mid = '%s' and uid = %d limit 1",
dbesc($z[0]['i_mid']),
intval($ch[0]['channel_id'])
);
- if($r)
- drop_item($r[0]['id'],false);
- if($interactive) {
- notice( t('Previous action reversed.') . EOL);
+ if ($r)
+ drop_item($r[0]['id'], false);
+ if ($interactive) {
+ notice(t('Previous action reversed.') . EOL);
return $o;
}
}
@@ -283,19 +295,19 @@ class Like extends \Zotlabs\Web\Controller {
}
else {
- if(! $observer)
+ if (!$observer)
killme();
-
+
// this is used to like an item or comment
-
+
$item_id = ((argc() == 2) ? notags(trim(argv(1))) : 0);
-
+
logger('like: verb ' . $verb . ' item ' . $item_id, LOGGER_DEBUG);
-
+
// get the item. Allow linked photos (which are normally hidden) to be liked
- $r = q("SELECT * FROM item WHERE id = %d
- and item_type in (0,6,7) and item_deleted = 0 and item_unpublished = 0
+ $r = q("SELECT * FROM item WHERE id = %d
+ and item_type in (0,6,7) and item_deleted = 0 and item_unpublished = 0
and item_delayed = 0 and item_pending_remove = 0 and item_blocked = 0 LIMIT 1",
intval($item_id)
);
@@ -304,32 +316,30 @@ class Like extends \Zotlabs\Web\Controller {
// create a copy of the parent in your stream. If not the conversation
// parent, copy that as well.
- if($r) {
- if($r[0]['uid'] === $sys_channel['channel_id'] && local_channel()) {
- $r = [ copy_of_pubitem(\App::get_channel(), $r[0]['mid']) ];
+ if ($r) {
+ if ($r[0]['uid'] === $sys_channel['channel_id'] && local_channel()) {
+ $r = [copy_of_pubitem(App::get_channel(), $r[0]['mid'])];
}
}
- if(! $item_id || (! $r)) {
+ if (!$item_id || (!$r)) {
logger('like: no item ' . $item_id);
killme();
}
- xchan_query($r,true);
-
- $item = $r[0];
+ xchan_query($r, true);
+ $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 ((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);
+ if (!$can_comment) {
+ notice(t('Permission denied') . EOL);
killme();
}
@@ -337,7 +347,7 @@ class Like extends \Zotlabs\Web\Controller {
dbesc($item['owner_xchan'])
);
- if($r)
+ if ($r)
$thread_owner = $r[0];
else
killme();
@@ -345,223 +355,207 @@ class Like extends \Zotlabs\Web\Controller {
$r = q("select * from xchan where xchan_hash = '%s' limit 1",
dbesc($item['author_xchan'])
);
- if($r)
+ if ($r)
$item_author = $r[0];
else
killme();
- $verbs = " '".dbesc($activity)."' ";
-
- $multi_undo = false;
-
+ $verbs = " '" . dbesc($activity) . "' ";
+
+ $multi_undo = false;
+
// event participation and consensus items are essentially radio toggles. If you make a subsequent choice,
- // we need to eradicate your first choice.
-
- if($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) {
- $verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' ";
+ // we need to eradicate your first choice.
+
+ if ($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) {
+ $verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' ";
$multi_undo = 1;
}
- if($activity === ACTIVITY_AGREE || $activity === ACTIVITY_DISAGREE || $activity === ACTIVITY_ABSTAIN) {
- $verbs = " '" . dbesc(ACTIVITY_AGREE) . "','" . dbesc(ACTIVITY_DISAGREE) . "','" . dbesc(ACTIVITY_ABSTAIN) . "' ";
+ if ($activity === ACTIVITY_AGREE || $activity === ACTIVITY_DISAGREE || $activity === ACTIVITY_ABSTAIN) {
+ $verbs = " '" . dbesc(ACTIVITY_AGREE) . "','" . dbesc(ACTIVITY_DISAGREE) . "','" . dbesc(ACTIVITY_ABSTAIN) . "' ";
$multi_undo = true;
}
-
+
$item_normal = item_normal();
-
+
$r = q("SELECT id, parent, uid, verb FROM item WHERE verb in ( $verbs ) $item_normal
AND author_xchan = '%s' AND thr_parent = '%s' and uid = %d ",
dbesc($observer['xchan_hash']),
dbesc($item['mid']),
intval($owner_uid)
);
-
- if($r) {
+
+ if ($r) {
// already liked it. Drop that item.
require_once('include/items.php');
- foreach($r as $rr) {
- drop_item($rr['id'],false,DROPITEM_PHASE1);
+ foreach ($r as $rr) {
+ drop_item($rr['id'], false, DROPITEM_PHASE1);
// set the changed timestamp on the parent so we'll see the update without a page reload
- $z = q("update item set changed = '%s' where id = %d and uid = %d",
+ q("update item set changed = '%s' where id = %d and uid = %d",
dbesc(datetime_convert()),
intval($rr['parent']),
intval($rr['uid'])
);
- // Prior activity was a duplicate of the one we're submitting, just undo it;
+ // Prior activity was a duplicate of the one we're submitting, just undo it;
// don't fall through and create another
- if(activity_match($rr['verb'],$activity))
+ if (activity_match($rr['verb'], $activity))
$multi_undo = false;
-
+
// drop_item was not done interactively, so we need to invoke the notifier
// in order to push the changes to connections
- \Zotlabs\Daemon\Master::Summon(array('Notifier','drop',$rr['id']));
+ Master::Summon(array('Notifier', 'drop', $rr['id']));
-
}
-
- if($interactive)
+
+ if ($interactive)
return;
-
- if(! $multi_undo) {
+
+ if (!$multi_undo) {
$ret = self::like_response([
- 'item' => $item,
- 'orig_item_id' => $item_id,
- 'owner_xchan' => $thread_owner,
- 'conv_mode' => $mode
+ 'item' => $item,
+ 'orig_item_id' => $item_id,
+ 'owner_xchan' => $thread_owner
]);
json_return_and_die($ret);
}
-
-
}
}
-
+
$uuid = item_message_id();
-
+
$arr = array();
-
- $arr['uuid'] = $uuid;
- $arr['mid'] = z_root() . (($is_rsvp) ? '/activity/' : '/item/') . $uuid;
- if($extended_like) {
+ $arr['uuid'] = $uuid;
+ $arr['mid'] = z_root() . (($is_rsvp) ? '/activity/' : '/item/') . $uuid;
+
+ if ($extended_like) {
$arr['item_thread_top'] = 1;
- $arr['item_origin'] = 1;
- $arr['item_wall'] = 1;
+ $arr['item_origin'] = 1;
+ $arr['item_wall'] = 1;
}
else {
$post_type = (($item['resource_type'] === 'photo') ? t('photo') : t('status'));
- if($item['obj_type'] === ACTIVITY_OBJ_EVENT)
+ if ($item['obj_type'] === ACTIVITY_OBJ_EVENT)
$post_type = t('event');
-
- $links = array(array('rel' => 'alternate','type' => 'text/html', 'href' => $item['plink']));
- $objtype = (($item['resource_type'] === 'photo') ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
- if($objtype === ACTIVITY_OBJ_NOTE && (! intval($item['item_thread_top'])))
+ $objtype = (($item['resource_type'] === 'photo') ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE);
+
+ if ($objtype === ACTIVITY_OBJ_NOTE && (!intval($item['item_thread_top'])))
$objtype = ACTIVITY_OBJ_COMMENT;
-
- $body = $item['body'];
-
- $object = json_encode(Activity::fetch_item( [ 'id' => $item['mid'] ]));
+ $object = json_encode(Activity::fetch_item(['id' => $item['mid']]));
+
+ if (!intval($item['item_thread_top']))
+ $post_type = 'comment';
- if(! intval($item['item_thread_top']))
- $post_type = 'comment';
-
- $arr['item_origin'] = 1;
+ $arr['item_origin'] = 1;
$arr['item_notshown'] = 1;
- $arr['item_type'] = $item['item_type'];
-
- if(intval($item['item_wall']))
+ $arr['item_type'] = $item['item_type'];
+
+ if (intval($item['item_wall']))
$arr['item_wall'] = 1;
-
+
// if this was a linked photo and was hidden, unhide it.
-
- if(intval($item['item_hidden'])) {
+
+ if (intval($item['item_hidden'])) {
$r = q("update item set item_hidden = 0 where id = %d",
intval($item['id'])
);
- }
-
+ }
+
}
-
- if($verb === 'like')
+
+ if ($verb === 'like')
$bodyverb = t('%1$s likes %2$s\'s %3$s');
- if($verb === 'dislike')
+ if ($verb === 'dislike')
$bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
- if($verb === 'agree')
+ if ($verb === 'agree')
$bodyverb = t('%1$s agrees with %2$s\'s %3$s');
- if($verb === 'disagree')
+ if ($verb === 'disagree')
$bodyverb = t('%1$s doesn\'t agree with %2$s\'s %3$s');
- if($verb === 'abstain')
+ if ($verb === 'abstain')
$bodyverb = t('%1$s abstains from a decision on %2$s\'s %3$s');
- if($verb === 'attendyes')
+ if ($verb === 'attendyes')
$bodyverb = t('%1$s is attending %2$s\'s %3$s');
- if($verb === 'attendno')
+ if ($verb === 'attendno')
$bodyverb = t('%1$s is not attending %2$s\'s %3$s');
- if($verb === 'attendmaybe')
+ if ($verb === 'attendmaybe')
$bodyverb = t('%1$s may attend %2$s\'s %3$s');
-
- if(! isset($bodyverb))
- killme();
-
-
-
- if($extended_like) {
- $ulink = '[zrl=' . $ch[0]['xchan_url'] . '][bdi]' . $ch[0]['xchan_name'] . '[/bdi][/zrl]';
- $alink = '[zrl=' . $observer['xchan_url'] . '][bdi]' . $observer['xchan_name'] . '[/bdi][/zrl]';
+
+ if (!isset($bodyverb))
+ killme();
+
+ if ($extended_like) {
+ $ulink = '[zrl=' . $ch[0]['xchan_url'] . '][bdi]' . $ch[0]['xchan_name'] . '[/bdi][/zrl]';
+ $alink = '[zrl=' . $observer['xchan_url'] . '][bdi]' . $observer['xchan_name'] . '[/bdi][/zrl]';
$private = (($public) ? 0 : 1);
}
else {
- $arr['parent'] = $item['id'];
- $arr['thr_parent'] = $item['mid'];
- $ulink = '[zrl=' . $item_author['xchan_url'] . '][bdi]' . $item_author['xchan_name'] . '[/bdi][/zrl]';
- $alink = '[zrl=' . $observer['xchan_url'] . '][bdi]' . $observer['xchan_name'] . '[/bdi][/zrl]';
- $plink = '[zrl=' . z_root() . '/display/' . gen_link_id($item['mid']) . ']' . $post_type . '[/zrl]';
- $allow_cid = $item['allow_cid'];
- $allow_gid = $item['allow_gid'];
- $deny_cid = $item['deny_cid'];
- $deny_gid = $item['deny_gid'];
- $private = $item['private'];
-
+ $arr['parent'] = $item['id'];
+ $arr['thr_parent'] = $item['mid'];
+ $ulink = '[zrl=' . $item_author['xchan_url'] . '][bdi]' . $item_author['xchan_name'] . '[/bdi][/zrl]';
+ $alink = '[zrl=' . $observer['xchan_url'] . '][bdi]' . $observer['xchan_name'] . '[/bdi][/zrl]';
+ $plink = '[zrl=' . z_root() . '/display/' . gen_link_id($item['mid']) . ']' . $post_type . '[/zrl]';
+ $allow_cid = $item['allow_cid'];
+ $allow_gid = $item['allow_gid'];
+ $deny_cid = $item['deny_cid'];
+ $deny_gid = $item['deny_gid'];
+ $private = $item['private'];
+
}
-
-
+
$arr['aid'] = (($extended_like) ? $ch[0]['channel_account_id'] : $owner_aid);
$arr['uid'] = $owner_uid;
-
-
- $arr['item_flags'] = $item_flags;
- $arr['item_wall'] = $item_wall;
+ $arr['item_flags'] = $item['item_flags'];
+ $arr['item_wall'] = $item['item_wall'];
$arr['parent_mid'] = (($extended_like) ? $arr['mid'] : $item['mid']);
$arr['owner_xchan'] = (($extended_like) ? $ch[0]['xchan_hash'] : $thread_owner['xchan_hash']);
$arr['author_xchan'] = $observer['xchan_hash'];
-
-
- $arr['body'] = sprintf( $bodyverb, $alink, $ulink, $plink );
- if($obj_type === 'thing' && $r[0]['imgurl']) {
+ $arr['body'] = sprintf($bodyverb, $alink, $ulink, $plink);
+
+ if ($obj_type === 'thing' && $r[0]['imgurl']) {
$arr['body'] .= "\n\n[zmg=80x80]" . $r[0]['imgurl'] . '[/zmg]';
- }
- if($obj_type === 'profile') {
- if($public) {
- $arr['body'] .= "\n\n" . '[embed]' . z_root() . '/profile/' . $ch[0]['channel_address'] . '[/embed]';
+ }
+ if ($obj_type === 'profile') {
+ if ($public) {
+ $arr['body'] .= "\n\n" . '[embed]' . z_root() . '/profile/' . $ch[0]['channel_address'] . '[/embed]';
}
else
$arr['body'] .= "\n\n[zmg=80x80]" . $profile['thumb'] . '[/zmg]';
- }
-
-
- $arr['verb'] = $activity;
- $arr['obj_type'] = $objtype;
- $arr['obj'] = $object;
-
- if($target) {
- $arr['tgt_type'] = $tgttype;
- $arr['target'] = $target;
}
-
- $arr['allow_cid'] = $allow_cid;
- $arr['allow_gid'] = $allow_gid;
- $arr['deny_cid'] = $deny_cid;
- $arr['deny_gid'] = $deny_gid;
- $arr['item_private'] = $private;
-
- call_hooks('post_local',$arr);
-
- $post = item_store($arr);
+
+ $arr['verb'] = $activity;
+ $arr['obj_type'] = $objtype;
+ $arr['obj'] = $object;
+
+ if ($target) {
+ $arr['tgt_type'] = $tgttype;
+ $arr['target'] = $target;
+ }
+
+ $arr['allow_cid'] = $allow_cid;
+ $arr['allow_gid'] = $allow_gid;
+ $arr['deny_cid'] = $deny_cid;
+ $arr['deny_gid'] = $deny_gid;
+ $arr['item_private'] = $private;
+
+ call_hooks('post_local', $arr);
+
+ $post = item_store($arr);
$post_id = $post['item_id'];
// save the conversation from expiration
- if(local_channel() && array_key_exists('item',$post) && (intval($post['item']['id']) != intval($post['item']['parent'])))
- retain_item($post['item']['parent']);
-
+ if (local_channel() && array_key_exists('item', $post) && (intval($post['item']['id']) != intval($post['item']['parent'])))
+ retain_item($post['item']['parent']);
+
$arr['id'] = $post_id;
-
+
call_hooks('post_local_end', $arr);
-
-
- if($extended_like) {
+
+ if ($extended_like) {
$r = q("insert into likes (channel_id,liker,likee,iid,i_mid,verb,target_type,target_id,target) values (%d,'%s','%s',%d,'%s','%s','%s','%s','%s')",
intval($ch[0]['channel_id']),
dbesc($observer['xchan_hash']),
@@ -569,39 +563,38 @@ class Like extends \Zotlabs\Web\Controller {
intval($post_id),
dbesc($arr['mid']),
dbesc($activity),
- dbesc(($tgttype)? $tgttype : $objtype),
+ dbesc(($tgttype) ? $tgttype : $objtype),
dbesc($obj_id),
- dbesc(($target) ? $target : $object)
+ dbesc(($target) ? $target : $object)
);
$r = q("select * from likes where liker = '%s' and likee = '%s' and i_mid = '%s' and verb = '%s' and target_type = '%s' and target_id = '%s' ",
dbesc($observer['xchan_hash']),
dbesc($ch[0]['channel_hash']),
dbesc($arr['mid']),
dbesc($activity),
- dbesc(($tgttype)? $tgttype : $objtype),
+ dbesc(($tgttype) ? $tgttype : $objtype),
dbesc($obj_id)
);
- if($r)
- Libsync::build_sync_packet($ch[0]['channel_id'],array('likes' => $r));
-
+ if ($r)
+ Libsync::build_sync_packet($ch[0]['channel_id'], array('likes' => $r));
+
}
-
- \Zotlabs\Daemon\Master::Summon(array('Notifier','like',$post_id));
-
- if($interactive) {
- notice( t('Action completed.') . EOL);
+
+ Master::Summon(array('Notifier', 'like', $post_id));
+
+ if ($interactive) {
+ notice(t('Action completed.') . EOL);
$o .= t('Thank you.');
return $o;
}
$ret = self::like_response([
- 'item' => $item,
- 'orig_item_id' => $item_id,
- 'owner_xchan' => $thread_owner,
- 'conv_mode' => $mode
+ 'item' => $item,
+ 'orig_item_id' => $item_id,
+ 'owner_xchan' => $thread_owner
]);
json_return_and_die($ret);
}
-
+
}
diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php
index 4a1692d64..e9edd8de3 100644
--- a/Zotlabs/Module/Network.php
+++ b/Zotlabs/Module/Network.php
@@ -22,42 +22,42 @@ class Network extends \Zotlabs\Web\Controller {
if(in_array(substr($_GET['search'],0,1),[ '@', '!', '?']))
goaway('search' . '?f=&search=' . $_GET['search']);
-
+
if(count($_GET) < 2) {
$network_options = get_pconfig(local_channel(),'system','network_page_default');
if($network_options)
goaway('network' . '?f=&' . $network_options);
}
-
+
$channel = App::get_channel();
App::$profile_uid = local_channel();
head_set_icon($channel['xchan_photo_s']);
-
+
}
-
+
function get($update = 0, $load = false) {
-
+
if(! local_channel()) {
$_SESSION['return_url'] = App::$query_string;
return login(false);
}
-
+
$o = '';
$arr = array('query' => App::$query_string);
-
+
call_hooks('network_content_init', $arr);
-
+
$channel = App::get_channel();
$item_normal = item_normal();
$item_normal_update = item_normal_update();
-
+
$datequery = $datequery2 = '';
-
+
$group = 0;
-
+
$nouveau = false;
-
+
$datequery = ((x($_GET,'dend') && is_a_date_arg($_GET['dend'])) ? notags($_GET['dend']) : '');
$datequery2 = ((x($_GET,'dbegin') && is_a_date_arg($_GET['dbegin'])) ? notags($_GET['dbegin']) : '');
$gid = ((x($_GET,'gid')) ? intval($_GET['gid']) : 0);
@@ -87,13 +87,13 @@ class Network extends \Zotlabs\Web\Controller {
$search = '';
}
}
-
+
if($datequery)
$order = 'post';
-
-
+
+
// filter by collection (e.g. group)
-
+
if($gid) {
$r = q("SELECT * FROM pgrp WHERE id = %d AND uid = %d LIMIT 1",
intval($gid),
@@ -106,12 +106,12 @@ class Network extends \Zotlabs\Web\Controller {
goaway(z_root() . '/network');
// NOTREACHED
}
-
+
$group = $gid;
$group_hash = $r[0]['hash'];
$def_acl = array('allow_gid' => '<' . $r[0]['hash'] . '>');
}
-
+
$default_cmin = ((Apps::system_app_installed(local_channel(),'Affinity Tool')) ? get_pconfig(local_channel(),'affinity','cmin',0) : (-1));
$default_cmax = ((Apps::system_app_installed(local_channel(),'Affinity Tool')) ? get_pconfig(local_channel(),'affinity','cmax',99) : (-1));
@@ -127,7 +127,7 @@ class Network extends \Zotlabs\Web\Controller {
$net = ((x($_GET,'net')) ? $_GET['net'] : '');
$pf = ((x($_GET,'pf')) ? $_GET['pf'] : '');
$unseen = ((x($_GET,'unseen')) ? $_GET['unseen'] : '');
-
+
if (Apps::system_app_installed(local_channel(),'Affinity Tool')) {
$affinity_locked = intval(get_pconfig(local_channel(),'affinity','lock',1));
if ($affinity_locked) {
@@ -155,16 +155,16 @@ class Network extends \Zotlabs\Web\Controller {
}
$def_acl = [ 'allow_cid' => '<' . $cid_r[0]['abook_xchan'] . '>', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ];
}
-
+
if(! $update) {
-
+
// search terms header
if($search || $hashtags) {
$o .= replace_macros(get_markup_template("section_title.tpl"),array(
'$title' => t('Search Results For:') . ' ' . (($search) ? htmlspecialchars($search, ENT_COMPAT,'UTF-8') : '#' . htmlspecialchars($hashtags, ENT_COMPAT,'UTF-8'))
));
}
-
+
nav_set_selected('Network');
$bang = '!';
@@ -179,14 +179,14 @@ class Network extends \Zotlabs\Web\Controller {
}
$channel_acl = array(
- 'allow_cid' => $channel['channel_allow_cid'],
- 'allow_gid' => $channel['channel_allow_gid'],
- 'deny_cid' => $channel['channel_deny_cid'],
+ 'allow_cid' => $channel['channel_allow_cid'],
+ 'allow_gid' => $channel['channel_allow_gid'],
+ 'deny_cid' => $channel['channel_deny_cid'],
'deny_gid' => $channel['channel_deny_gid']
);
$private_editing = (($group || $cid) ? true : false);
-
+
$x = array(
'is_owner' => true,
'allow_location' => ((intval(get_pconfig($channel['channel_id'],'system','use_browser_location'))) ? '1' : ''),
@@ -204,28 +204,28 @@ class Network extends \Zotlabs\Web\Controller {
'jotnets' => true,
'reset' => t('Reset form')
);
-
+
$status_editor = status_editor($a,$x,false,'Network');
$o .= $status_editor;
}
-
-
+
+
// We don't have to deal with ACL's on this page. You're looking at everything
// that belongs to you, hence you can see all of it. We will filter by group if
// desired.
-
-
+
+
$sql_options = (($star)
? " and item_starred = 1 "
: '');
-
+
$sql_nets = '';
$item_thread_top = ' AND item_thread_top = 1 ';
-
+
$sql_extra = '';
-
+
if($group) {
$contact_str = '';
@@ -241,18 +241,18 @@ class Network extends \Zotlabs\Web\Controller {
}
$item_thread_top = '';
$sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str )) or allow_gid like '" . protect_sprintf('%<' . dbesc($group_hash) . '>%') . "' ) and id = parent $item_normal ) ";
-
+
$x = group_rec_byhash(local_channel(), $group_hash);
-
+
if($x) {
$title = replace_macros(get_markup_template("section_title.tpl"),array(
'$title' => t('Privacy group: ') . $x['gname']
));
}
-
+
$o = $title;
$o .= $status_editor;
-
+
}
elseif($cid_r) {
$item_thread_top = '';
@@ -324,75 +324,26 @@ class Network extends \Zotlabs\Web\Controller {
}
}
-
+
if(x($category)) {
$sql_extra .= protect_sprintf(term_query('item', $category, TERM_CATEGORY));
}
if(x($hashtags)) {
$sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG));
}
-
- if(! $update) {
- // The special div is needed for liveUpdate to kick in for this page.
- // We only launch liveUpdate if you aren't filtering in some incompatible
- // way and also you aren't writing a comment (discovered in javascript).
- $maxheight = get_pconfig(local_channel(),'system','network_divmore_height');
- if(! $maxheight)
- $maxheight = 400;
-
-
- $o .= '<div id="live-network"></div>' . "\r\n";
- $o .= "<script> var profile_uid = " . local_channel()
- . "; var profile_page = " . App::$pager['page']
- . "; divmore_height = " . intval($maxheight) . "; </script>\r\n";
-
- App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
- '$baseurl' => z_root(),
- '$pgtype' => 'network',
- '$uid' => ((local_channel()) ? local_channel() : '0'),
- '$gid' => (($gid) ? $gid : '0'),
- '$cid' => (($cid) ? $cid : '0'),
- '$cmin' => (($cmin) ? $cmin : '(-1)'),
- '$cmax' => (($cmax) ? $cmax : '(-1)'),
- '$star' => (($star) ? $star : '0'),
- '$liked' => (($liked) ? $liked : '0'),
- '$conv' => (($conv) ? $conv : '0'),
- '$spam' => (($spam) ? $spam : '0'),
- '$fh' => '0',
- '$dm' => (($dm) ? $dm : '0'),
- '$nouveau' => (($nouveau) ? $nouveau : '0'),
- '$wall' => '0',
- '$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0),
- '$page' => ((App::$pager['page'] != 1) ? App::$pager['page'] : 1),
- '$search' => (($search) ? urlencode($search) : ''),
- '$xchan' => (($xchan) ? urlencode($xchan) : ''),
- '$order' => $order,
- '$file' => (($file) ? urlencode($file) : ''),
- '$cats' => (($category) ? urlencode($category) : ''),
- '$tags' => (($hashtags) ? urlencode($hashtags) : ''),
- '$dend' => $datequery,
- '$mid' => '',
- '$verb' => (($verb) ? urlencode($verb) : ''),
- '$net' => (($net) ? urlencode($net) : ''),
- '$dbegin' => $datequery2,
- '$pf' => (($pf) ? intval($pf) : 0),
- '$unseen' => (($unseen) ? urlencode($unseen) : '')
- ));
- }
-
$sql_extra3 = '';
-
+
if($datequery) {
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery))));
}
if($datequery2) {
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
}
-
+
$sql_extra2 = (($nouveau) ? '' : " AND item.parent = item.id ");
$sql_extra3 = (($nouveau) ? '' : $sql_extra3);
-
+
if(x($_GET,'search')) {
$search = escape_tags($_GET['search']);
if(strpos($search,'#') === 0) {
@@ -405,7 +356,7 @@ class Network extends \Zotlabs\Web\Controller {
);
}
}
-
+
if ($verb) {
// the presence of a leading dot in the verb determines
@@ -425,7 +376,7 @@ class Network extends \Zotlabs\Web\Controller {
);
}
}
-
+
if(strlen($file)) {
$sql_extra .= term_query('item',$file,TERM_FILE);
}
@@ -433,52 +384,52 @@ class Network extends \Zotlabs\Web\Controller {
if ($dm) {
$sql_extra .= " AND item_private = 2 ";
}
-
+
if($conv) {
$item_thread_top = '';
$sql_extra .= " AND ( author_xchan = '" . dbesc($channel['channel_hash']) . "' OR item_mentionsme = 1 ) ";
}
-
+
if($update && ! $load) {
-
+
// only setup pagination on initial page view
$pager_sql = '';
-
+
}
else {
$itemspage = get_pconfig(local_channel(),'system','itemspage');
App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 10));
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start']));
}
-
+
// cmin and cmax are both -1 when the affinity tool is disabled
if(($cmin != (-1)) || ($cmax != (-1))) {
-
+
// Not everybody who shows up in the network stream will be in your address book.
// By default those that aren't are assumed to have closeness = 99; but this isn't
// recorded anywhere. So if cmax is 99, we'll open the search up to anybody in
// the stream with a NULL address book entry.
-
+
$sql_nets .= " AND ";
-
+
if($cmax == 99)
$sql_nets .= " ( ";
-
+
$sql_nets .= "( abook.abook_closeness >= " . intval($cmin) . " ";
$sql_nets .= " AND abook.abook_closeness <= " . intval($cmax) . " ) ";
-
+
if($cmax == 99)
$sql_nets .= " OR abook.abook_closeness IS NULL ) ";
-
+
}
- $net_query = (($net) ? " left join xchan on xchan_hash = author_xchan " : '');
+ $net_query = (($net) ? " left join xchan on xchan_hash = author_xchan " : '');
$net_query2 = (($net) ? " and xchan_network = '" . protect_sprintf(dbesc($net)) . "' " : '');
$abook_uids = " and abook.abook_channel = " . local_channel() . " ";
$uids = " and item.uid = " . local_channel() . " ";
-
+
if(feature_enabled(local_channel(), 'network_list_mode'))
$page_mode = 'list';
else
@@ -504,7 +455,7 @@ class Network extends \Zotlabs\Web\Controller {
if($nouveau && $load) {
// "New Item View" - show all items unthreaded in reverse created date order
- $items = q("SELECT item.*, item.id AS item_id, created FROM item
+ $items = q("SELECT item.*, item.id AS item_id, created FROM item
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
$net_query
WHERE true $uids $item_normal
@@ -517,23 +468,23 @@ class Network extends \Zotlabs\Web\Controller {
$parents_str = ids_to_querystr($items,'item_id');
require_once('include/items.php');
-
+
xchan_query($items);
-
+
$items = fetch_post_tags($items,true);
}
elseif($update) {
-
+
// Normal conversation view
-
+
if($order === 'post')
$ordering = "created";
else
$ordering = "commented";
-
+
if($load) {
// Fetch a page full of parent items for this page
- $r = q("SELECT item.parent AS item_id FROM item
+ $r = q("SELECT item.parent AS item_id FROM item
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )
$net_query
WHERE true $uids $item_thread_top $item_normal
@@ -557,18 +508,18 @@ class Network extends \Zotlabs\Web\Controller {
}
// Then fetch all the children of the parents that are on this page
-
+
if($r) {
-
+
$parents_str = ids_to_querystr($r,'item_id');
-
+
$items = q("SELECT item.*, item.id AS item_id FROM item
WHERE true $uids $item_normal
AND item.parent IN ( %s )
$sql_extra ",
dbesc($parents_str)
);
-
+
xchan_query($items,true);
$items = fetch_post_tags($items,true);
$items = conv_sort($items,$ordering);
@@ -578,20 +529,70 @@ class Network extends \Zotlabs\Web\Controller {
}
}
-
+
$mode = (($nouveau) ? 'network-new' : 'network');
if($search)
$mode = 'search';
-
+
+ if(! $update) {
+ // The special div is needed for liveUpdate to kick in for this page.
+ // We only launch liveUpdate if you aren't filtering in some incompatible
+ // way and also you aren't writing a comment (discovered in javascript).
+
+ $maxheight = get_pconfig(local_channel(),'system','network_divmore_height');
+ if(! $maxheight)
+ $maxheight = 400;
+
+
+ $o .= '<div id="live-network"></div>' . "\r\n";
+ $o .= "<script> var profile_uid = " . local_channel()
+ . "; var profile_page = " . App::$pager['page']
+ . "; divmore_height = " . intval($maxheight) . "; </script>\r\n";
+
+ App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array(
+ '$baseurl' => z_root(),
+ '$pgtype' => 'network',
+ '$uid' => ((local_channel()) ? local_channel() : '0'),
+ '$gid' => (($gid) ? $gid : '0'),
+ '$cid' => (($cid) ? $cid : '0'),
+ '$cmin' => (($cmin) ? $cmin : '(-1)'),
+ '$cmax' => (($cmax) ? $cmax : '(-1)'),
+ '$star' => (($star) ? $star : '0'),
+ '$liked' => (($liked) ? $liked : '0'),
+ '$conv' => (($conv) ? $conv : '0'),
+ '$spam' => (($spam) ? $spam : '0'),
+ '$fh' => '0',
+ '$dm' => (($dm) ? $dm : '0'),
+ '$nouveau' => (($nouveau) ? $nouveau : '0'),
+ '$wall' => '0',
+ '$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0),
+ '$page' => ((App::$pager['page'] != 1) ? App::$pager['page'] : 1),
+ '$search' => (($search) ? urlencode($search) : ''),
+ '$xchan' => (($xchan) ? urlencode($xchan) : ''),
+ '$order' => $order,
+ '$file' => (($file) ? urlencode($file) : ''),
+ '$cats' => (($category) ? urlencode($category) : ''),
+ '$tags' => (($hashtags) ? urlencode($hashtags) : ''),
+ '$dend' => $datequery,
+ '$mid' => '',
+ '$verb' => (($verb) ? urlencode($verb) : ''),
+ '$net' => (($net) ? urlencode($net) : ''),
+ '$dbegin' => $datequery2,
+ '$pf' => (($pf) ? intval($pf) : 0),
+ '$unseen' => (($unseen) ? urlencode($unseen) : ''),
+ '$page_mode' => $page_mode
+ ));
+ }
+
$o .= conversation($items,$mode,$update,$page_mode);
-
+
if(($items) && (! $update))
$o .= alt_pager(count($items));
$_SESSION['loadtime'] = datetime_convert();
-
+
return $o;
}
-
+
}
diff --git a/Zotlabs/Module/Notifications.php b/Zotlabs/Module/Notifications.php
index 1762ad5f6..55268e0a2 100644
--- a/Zotlabs/Module/Notifications.php
+++ b/Zotlabs/Module/Notifications.php
@@ -19,7 +19,7 @@ class Notifications extends \Zotlabs\Web\Controller {
$r = q("select count(*) as total from notify where uid = %d and seen = 0",
intval(local_channel())
);
- if($r && intval($t[0]['total']) > 49) {
+ if($r && intval($r[0]['total']) > 49) {
$r = q("select * from notify where uid = %d
and seen = 0 order by created desc limit 50",
intval(local_channel())
@@ -32,7 +32,7 @@ class Notifications extends \Zotlabs\Web\Controller {
$r2 = q("select * from notify where uid = %d
and seen = 1 order by created desc limit %d",
intval(local_channel()),
- intval(50 - intval($t[0]['total']))
+ intval(50 - intval($r[0]['total']))
);
$r = array_merge($r1,$r2);
}
@@ -41,7 +41,7 @@ class Notifications extends \Zotlabs\Web\Controller {
$notifications_available = 1;
foreach ($r as $rr) {
$x = strip_tags(bbcode($rr['msg']));
- $notif_content .= replace_macros(get_markup_template('notify.tpl'),array(
+ $notif_content = replace_macros(get_markup_template('notify.tpl'),array(
'$item_link' => z_root().'/notify/view/'. $rr['id'],
'$item_image' => $rr['photo'],
'$item_text' => $x,
@@ -52,7 +52,7 @@ class Notifications extends \Zotlabs\Web\Controller {
}
}
else {
- $notif_content .= t('No more system notifications.');
+ $notif_content = t('No more system notifications.');
}
$o .= replace_macros(get_markup_template('notifications.tpl'),array(
diff --git a/Zotlabs/Module/Owa.php b/Zotlabs/Module/Owa.php
index d6aeb8af5..9a3513f34 100644
--- a/Zotlabs/Module/Owa.php
+++ b/Zotlabs/Module/Owa.php
@@ -39,7 +39,7 @@ class Owa extends Controller {
$found = discover_by_webbie(str_replace('acct:','',$keyId));
if ($found) {
$r = q("SELECT * FROM hubloc LEFT JOIN xchan ON hubloc_hash = xchan_hash
- WHERE OR hubloc_id_url = '%s'",
+ WHERE hubloc_id_url = '%s'",
dbesc($keyId)
);
}
diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php
index 01edda9ae..041bdf5a2 100644
--- a/Zotlabs/Module/Photo.php
+++ b/Zotlabs/Module/Photo.php
@@ -35,7 +35,7 @@ class Photo extends \Zotlabs\Web\Controller {
call_hooks('cache_mode_hook', $cache_mode);
$observer_xchan = get_observer_hash();
- $cachecontrol = '';
+ $cachecontrol = ', no-cache';
if(isset($type)) {
@@ -102,7 +102,7 @@ class Photo extends \Zotlabs\Web\Controller {
$modified = filemtime($default);
}
- $cachecontrol = ', must-revalidate';
+ $cachecontrol .= ', must-revalidate';
}
else {
@@ -147,7 +147,7 @@ class Photo extends \Zotlabs\Web\Controller {
);
if($r) {
$allowed = (-1);
-
+ $filename = $r[0]['filename'];
$u = intval($r[0]['photo_usage']);
if($u) {
$allowed = 1;
@@ -169,6 +169,7 @@ class Photo extends \Zotlabs\Web\Controller {
$url = z_root() . '/sslify/' . $filename . '?f=&url=' . urlencode($url);
goaway($url);
}
+ $cachecontrol = '';
}
}
}
@@ -271,7 +272,7 @@ class Photo extends \Zotlabs\Web\Controller {
// in the event that infrastructure caching is present.
$smaxage = intval($maxage/12);
- header("Cache-Control: no-cache, s-maxage=" . $smaxage . ", max-age=" . $maxage . $cachecontrol);
+ header("Cache-Control: s-maxage=" . $smaxage . ", max-age=" . $maxage . $cachecontrol);
}
diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php
index fa9216c97..099289c03 100644
--- a/Zotlabs/Module/Photos.php
+++ b/Zotlabs/Module/Photos.php
@@ -16,66 +16,66 @@ require_once('include/text.php');
class Photos extends \Zotlabs\Web\Controller {
function init() {
-
+
if(observer_prohibited()) {
return;
}
-
+
if(argc() > 1) {
$nick = argv(1);
-
+
profile_load($nick);
-
+
$channelx = channelx_by_nick($nick);
-
+
if(! $channelx)
return;
-
+
\App::$data['channel'] = $channelx;
-
+
$observer = \App::get_observer();
\App::$data['observer'] = $observer;
-
+
$observer_xchan = (($observer) ? $observer['xchan_hash'] : '');
-
+
head_set_icon(\App::$data['channel']['xchan_photo_s']);
-
+
\App::$page['htmlhead'] .= "<script> var profile_uid = " . ((\App::$data['channel']) ? \App::$data['channel']['channel_id'] : 0) . "; </script>" ;
-
+
}
-
+
return;
}
-
-
-
+
+
+
function post() {
-
+
logger('mod-photos: photos_post: begin' , LOGGER_DEBUG);
-
+
logger('mod_photos: REQUEST ' . print_r($_REQUEST,true), LOGGER_DATA);
logger('mod_photos: FILES ' . print_r($_FILES,true), LOGGER_DATA);
-
+
$ph = photo_factory('');
-
+
$phototypes = $ph->supportedTypes();
-
+
$can_post = false;
-
+
$page_owner_uid = \App::$data['channel']['channel_id'];
-
+
if(perm_is_allowed($page_owner_uid,get_observer_hash(),'write_storage'))
$can_post = true;
-
+
if(! $can_post) {
notice( t('Permission denied.') . EOL );
if(is_ajax())
killme();
return;
}
-
+
$s = abook_self($page_owner_uid);
-
+
if(! $s) {
notice( t('Page owner information could not be retrieved.') . EOL);
logger('mod_photos: post: unable to locate contact record for page owner. uid=' . $page_owner_uid);
@@ -83,30 +83,30 @@ class Photos extends \Zotlabs\Web\Controller {
killme();
return;
}
-
- $owner_record = $s[0];
-
+
+ $owner_record = $s[0];
+
$acl = new \Zotlabs\Access\AccessList(\App::$data['channel']);
-
+
if((argc() > 3) && (argv(2) === 'album')) {
-
+
$album = argv(3);
if(! photos_album_exists($page_owner_uid, get_observer_hash(), $album)) {
notice( t('Album not found.') . EOL);
goaway(z_root() . '/' . $_SESSION['photo_return']);
}
-
-
+
+
/*
* DELETE photo album and all its photos
*/
-
+
if($_REQUEST['dropalbum'] == t('Delete Album')) {
-
-
+
+
$folder_hash = '';
-
+
$r = q("select * from attach where is_dir = 1 and uid = %d and hash = '%s'",
intval($page_owner_uid),
dbesc($album)
@@ -116,13 +116,13 @@ class Photos extends \Zotlabs\Web\Controller {
return;
}
$folder_hash = $r[0]['hash'];
-
-
+
+
$res = array();
$admin_delete = false;
// get the list of photos we are about to delete
-
+
if(remote_channel() && (! local_channel())) {
$str = photos_album_get_db_idstr($page_owner_uid,$album,remote_channel());
}
@@ -139,7 +139,7 @@ class Photos extends \Zotlabs\Web\Controller {
if(! $str) {
goaway(z_root() . '/' . $_SESSION['photo_return']);
}
-
+
$r = q("select id from item where resource_id in ( $str ) and resource_type = 'photo' and uid = %d " . item_normal(),
intval($page_owner_uid)
);
@@ -148,34 +148,34 @@ class Photos extends \Zotlabs\Web\Controller {
attach_delete($page_owner_uid, $i['resource_id'], true );
}
}
-
+
// remove the associated photos in case they weren't attached to an item
-
+
q("delete from photo where resource_id in ( $str ) and uid = %d",
intval($page_owner_uid)
);
-
+
// @FIXME do the same for the linked attach
-
+
if($folder_hash) {
attach_delete($page_owner_uid, $folder_hash, true );
- if(! $admin_delete) {
+ if(! $admin_delete) {
$sync = attach_export_data(\App::$data['channel'],$folder_hash, true);
-
- if($sync)
+
+ if($sync)
Libsync::build_sync_packet($page_owner_uid,array('file' => array($sync)));
}
}
-
+
}
-
+
goaway(z_root() . '/photos/' . \App::$data['channel']['channel_address']);
}
-
+
if((argc() > 2) && (x($_REQUEST,'delete')) && ($_REQUEST['delete'] === t('Delete Photo'))) {
// same as above but remove single photo
-
+
$ob_hash = get_observer_hash();
if(! $ob_hash)
goaway(z_root() . '/' . $_SESSION['photo_return']);
@@ -185,18 +185,18 @@ class Photos extends \Zotlabs\Web\Controller {
intval(local_channel()),
dbesc(argv(2))
);
-
+
if($r) {
attach_delete($page_owner_uid, $r[0]['resource_id'], true );
$sync = attach_export_data(\App::$data['channel'],$r[0]['resource_id'], true);
-
- if($sync)
+
+ if($sync)
Libsync::build_sync_packet($page_owner_uid,array('file' => array($sync)));
}
elseif(is_site_admin()) {
// If the admin deletes a photo, don't sync
attach_delete($page_owner_uid, argv(2), true);
- }
+ }
goaway(z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . $_SESSION['album_return']);
@@ -208,10 +208,10 @@ class Photos extends \Zotlabs\Web\Controller {
intval($page_owner_uid)
);
if(($m) && ($m[0]['folder'] != $_POST['move_to_album'])) {
- attach_move($page_owner_uid,argv(2),$_POST['move_to_album']);
+ attach_move($page_owner_uid,argv(2),$_POST['move_to_album']);
$sync = attach_export_data(\App::$data['channel'], argv(2), false);
- if($sync)
+ if($sync)
Libsync::build_sync_packet($page_owner_uid,array('file' => array($sync)));
if(! ($_POST['desc'] && $_POST['newtag']))
@@ -220,28 +220,28 @@ class Photos extends \Zotlabs\Web\Controller {
}
if((argc() > 2) && ((x($_POST,'desc') !== false) || (x($_POST,'newtag') !== false))) {
-
+
$desc = ((x($_POST,'desc')) ? notags(trim($_POST['desc'])) : '');
$rawtags = ((x($_POST,'newtag')) ? notags(trim($_POST['newtag'])) : '');
$item_id = ((x($_POST,'item_id')) ? intval($_POST['item_id']) : 0);
$is_nsfw = ((x($_POST,'adult')) ? intval($_POST['adult']) : 0);
-
+
$acl->set_from_array($_POST);
$perm = $acl->get();
-
+
$resource_id = argv(2);
-
- if((x($_POST,'rotate') !== false) &&
+
+ if((x($_POST,'rotate') !== false) &&
( (intval($_POST['rotate']) == 1) || (intval($_POST['rotate']) == 2) )) {
logger('rotate');
-
+
$r = q("select * from photo where resource_id = '%s' and uid = %d and imgscale = 0 limit 1",
dbesc($resource_id),
intval($page_owner_uid)
);
if(count($r)) {
-
+
$ph = photo_factory(@file_get_contents(dbunescbin($r[0]['content'])), $r[0]['mimetype']);
if($ph->is_valid()) {
$rotate_deg = ( (intval($_POST['rotate']) == 1) ? 270 : 90 );
@@ -255,12 +255,12 @@ class Photos extends \Zotlabs\Web\Controller {
dbesc($resource_id),
intval($page_owner_uid)
);
-
+
$ph->saveImage(dbunescbin($r[0]['content']));
-
- $arr = [
+
+ $arr = [
'aid' => get_account_id(),
- 'uid' => intval($page_owner_uid),
+ 'uid' => intval($page_owner_uid),
'resource_id' => dbesc($resource_id),
'filename' => $r[0]['filename'],
'imgscale' => 0,
@@ -277,28 +277,31 @@ class Photos extends \Zotlabs\Web\Controller {
unset($arr['os_syspath']);
- if($width > 1024 || $height > 1024)
+ $width = $r[0]['width'];
+ $height = $r[0]['height'];
+
+ if($width > 1024 || $height > 1024)
$ph->scaleImage(1024);
$ph->storeThumbnail($arr, PHOTO_RES_1024);
- if($width > 640 || $height > 640)
+ if($width > 640 || $height > 640)
$ph->scaleImage(640);
$ph->storeThumbnail($arr, PHOTO_RES_640);
- if($width > 320 || $height > 320)
+ if($width > 320 || $height > 320)
$ph->scaleImage(320);
$ph->storeThumbnail($arr, PHOTO_RES_320);
}
}
}
-
+
$p = q("SELECT mimetype, is_nsfw, description, resource_id, imgscale, allow_cid, allow_gid, deny_cid, deny_gid FROM photo WHERE resource_id = '%s' AND uid = %d ORDER BY imgscale DESC",
dbesc($resource_id),
intval($page_owner_uid)
);
if($p) {
$ext = $phototypes[$p[0]['mimetype']];
-
+
$r = q("UPDATE photo SET description = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s' WHERE resource_id = '%s' AND uid = %d",
dbesc($desc),
dbesc($perm['allow_cid']),
@@ -309,9 +312,7 @@ class Photos extends \Zotlabs\Web\Controller {
intval($page_owner_uid)
);
}
-
- $item_private = (($str_contact_allow || $str_group_allow || $str_contact_deny || $str_group_deny) ? true : false);
-
+
$old_is_nsfw = $p[0]['is_nsfw'];
if($old_is_nsfw != $is_nsfw) {
$r = q("update photo set is_nsfw = %d where resource_id = '%s' and uid = %d",
@@ -320,31 +321,31 @@ class Photos extends \Zotlabs\Web\Controller {
intval($page_owner_uid)
);
}
-
+
/* Don't make the item visible if the only change was the album name */
-
+
$visibility = 0;
if($p[0]['description'] !== $desc || strlen($rawtags))
$visibility = 1;
-
+
if(! $item_id) {
$item_id = photos_create_item(\App::$data['channel'],get_observer_hash(),$p[0],$visibility);
-
+
}
-
+
if($item_id) {
$r = q("SELECT * FROM item WHERE id = %d AND uid = %d LIMIT 1",
intval($item_id),
intval($page_owner_uid)
);
-
+
if($r) {
$old_tag = $r[0]['tag'];
$old_inform = $r[0]['inform'];
}
}
-
-
+
+
// make sure the linked item has the same permissions as the photo regardless of any other changes
$x = q("update item set allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', item_private = %d
where id = %d",
@@ -355,7 +356,7 @@ class Photos extends \Zotlabs\Web\Controller {
intval($acl->is_private()),
intval($item_id)
);
-
+
// make sure the attach has the same permissions as the photo regardless of any other changes
$x = q("update attach set allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s' where hash = '%s' and uid = %d and is_photo = 1",
dbesc($perm['allow_cid']),
@@ -365,46 +366,46 @@ class Photos extends \Zotlabs\Web\Controller {
dbesc($resource_id),
intval($page_owner_uid)
);
-
-
-
+
+
+
if(strlen($rawtags)) {
-
+
$str_tags = '';
$inform = '';
-
+
// if the new tag doesn't have a namespace specifier (@foo or #foo) give it a mention
-
+
$x = substr($rawtags,0,1);
if($x !== '@' && $x !== '#')
$rawtags = '@' . $rawtags;
-
+
require_once('include/text.php');
$profile_uid = \App::$profile['profile_uid'];
-
+
$results = linkify_tags($rawtags, (local_channel()) ? local_channel() : $profile_uid);
-
+
$success = $results['success'];
$post_tags = array();
-
+
foreach($results as $result) {
$success = $result['success'];
if($success['replaced']) {
$post_tags[] = array(
- 'uid' => $profile_uid,
+ 'uid' => $profile_uid,
'ttype' => $success['termtype'],
'otype' => TERM_OBJ_POST,
'term' => $success['term'],
'url' => $success['url']
- );
+ );
}
}
-
+
$r = q("select * from item where id = %d and uid = %d limit 1",
intval($item_id),
intval($page_owner_uid)
);
-
+
if($r) {
$r = fetch_post_tags($r,true);
$datarray = $r[0];
@@ -412,42 +413,42 @@ class Photos extends \Zotlabs\Web\Controller {
if((! array_key_exists('term',$datarray)) || (! is_array($datarray['term'])))
$datarray['term'] = $post_tags;
else
- $datarray['term'] = array_merge($datarray['term'],$post_tags);
+ $datarray['term'] = array_merge($datarray['term'],$post_tags);
}
item_store_update($datarray,$execflag);
}
-
+
}
$sync = attach_export_data(\App::$data['channel'],$resource_id);
-
- if($sync)
+
+ if($sync)
Libsync::build_sync_packet($page_owner_uid,array('file' => array($sync)));
-
+
goaway(z_root() . '/' . $_SESSION['photo_return']);
return; // NOTREACHED
-
-
+
+
}
-
-
+
+
/**
* default post action - upload a photo
*/
-
+
$channel = \App::$data['channel'];
$observer = \App::$data['observer'];
-
+
$_REQUEST['source'] = 'photos';
require_once('include/attach.php');
-
+
if(! local_channel()) {
$_REQUEST['contact_allow'] = expand_acl($channel['channel_allow_cid']);
$_REQUEST['group_allow'] = expand_acl($channel['channel_allow_gid']);
$_REQUEST['contact_deny'] = expand_acl($channel['channel_deny_cid']);
$_REQUEST['group_deny'] = expand_acl($channel['channel_deny_gid']);
}
-
+
$matches = [];
$partial = false;
@@ -467,7 +468,7 @@ class Photos extends \Zotlabs\Web\Controller {
if($x['partial']) {
header('Range: bytes=0-' . (($x['length']) ? $x['length'] - 1 : 0));
- json_return_and_die($result);
+ json_return_and_die($x);
}
else {
header('Range: bytes=0-' . (($x['size']) ? $x['size'] - 1 : 0));
@@ -481,7 +482,7 @@ class Photos extends \Zotlabs\Web\Controller {
];
}
}
- else {
+ else {
if(! array_key_exists('userfile',$_FILES)) {
$_FILES['userfile'] = [
'name' => $_FILES['files']['name'],
@@ -494,53 +495,53 @@ class Photos extends \Zotlabs\Web\Controller {
}
$r = attach_store($channel,get_observer_hash(), '', $_REQUEST);
-
+
if(! $r['success']) {
notice($r['message'] . EOL);
goaway(z_root() . '/photos/' . \App::$data['channel']['channel_address']);
- }
+ }
goaway(z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . $r['data']['folder']);
-
+
}
-
-
-
+
+
+
function get() {
-
+
// URLs:
// photos/name
// photos/name/album/xxxxx (xxxxx is album name)
// photos/name/image/xxxxx
-
-
+
+
if(observer_prohibited()) {
notice( t('Public access denied.') . EOL);
return;
}
-
+
$unsafe = ((array_key_exists('unsafe',$_REQUEST) && $_REQUEST['unsafe']) ? 1 : 0);
-
+
require_once('include/bbcode.php');
require_once('include/security.php');
require_once('include/conversation.php');
-
+
if(! x(\App::$data,'channel')) {
notice( t('No photos selected') . EOL );
return;
}
-
+
$ph = photo_factory('');
$phototypes = $ph->supportedTypes();
-
+
$_SESSION['photo_return'] = \App::$cmd;
-
+
//
- // Parse arguments
+ // Parse arguments
//
-
+
$can_comment = perm_is_allowed(\App::$profile['profile_uid'],get_observer_hash(),'post_comments');
-
+
if(argc() > 3) {
$datatype = argv(2);
$datum = argv(3);
@@ -552,70 +553,70 @@ class Photos extends \Zotlabs\Web\Controller {
else
$datatype = 'summary';
}
-
+
if(argc() > 4)
$cmd = argv(4);
else
$cmd = 'view';
-
+
//
// Setup permissions structures
//
-
+
$can_post = false;
$visitor = 0;
-
-
+
+
$owner_uid = \App::$data['channel']['channel_id'];
$owner_aid = \App::$data['channel']['channel_account_id'];
-
+
$observer = \App::get_observer();
-
+
$can_post = perm_is_allowed($owner_uid,$observer['xchan_hash'],'write_storage');
$can_view = perm_is_allowed($owner_uid,$observer['xchan_hash'],'view_storage');
-
+
if(! $can_view) {
notice( t('Access to this item is restricted.') . EOL);
return;
}
-
+
$sql_item = item_permissions_sql($owner_uid,get_observer_hash());
$sql_extra = permissions_sql($owner_uid,get_observer_hash(),'photo');
$sql_attach = permissions_sql($owner_uid,get_observer_hash(),'attach');
nav_set_selected('Photos');
-
+
$o = '<script src="vendor/blueimp/jquery-file-upload/js/vendor/jquery.ui.widget.js"></script>
<script src="vendor/blueimp/jquery-file-upload/js/jquery.iframe-transport.js"></script>
<script src="vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js"></script>';
- $o .= "<script> var profile_uid = " . \App::$profile['profile_uid']
+ $o .= "<script> var profile_uid = " . \App::$profile['profile_uid']
. "; var netargs = '?f='; var profile_page = " . \App::$pager['page'] . "; </script>\r\n";
-
+
$_is_owner = (local_channel() && (local_channel() == $owner_uid));
-
+
/**
* Display upload form
*/
-
+
if( $can_post) {
-
+
$uploader = '';
-
+
$ret = array('post_url' => z_root() . '/photos/' . \App::$data['channel']['channel_address'],
'addon_text' => $uploader,
'default_upload' => true);
-
+
call_hooks('photo_upload_form',$ret);
-
+
/* Show space usage */
-
+
$r = q("select sum(filesize) as total from photo where aid = %d and imgscale = 0 ",
intval(\App::$data['channel']['channel_account_id'])
);
-
-
+
+
$limit = engr_units_to_bytes(service_class_fetch(\App::$data['channel']['channel_id'],'photo_upload_limit'));
if($limit !== false) {
$usage_message = sprintf( t("%1$.2f MB of %2$.2f MB photo storage used."), $r[0]['total'] / 1024000, $limit / 1024000 );
@@ -623,22 +624,22 @@ class Photos extends \Zotlabs\Web\Controller {
else {
$usage_message = sprintf( t('%1$.2f MB photo storage used.'), $r[0]['total'] / 1024000 );
}
-
+
if($_is_owner) {
$channel = \App::get_channel();
-
+
$acl = new \Zotlabs\Access\AccessList($channel);
$channel_acl = $acl->get();
-
+
$lockstate = (($acl->is_private()) ? 'lock' : 'unlock');
}
-
+
$aclselect = (($_is_owner) ? populate_acl($channel_acl,false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_storage')) : '');
-
+
// this is wrong but is to work around an issue with js_upload wherein it chokes if these variables
- // don't exist. They really should be set to a parseable representation of the channel's default permissions
- // which can be processed by getSelected()
-
+ // don't exist. They really should be set to a parseable representation of the channel's default permissions
+ // which can be processed by getSelected()
+
if(! $aclselect) {
$aclselect = '<input id="group_allow" type="hidden" name="allow_gid[]" value="" /><input id="contact_allow" type="hidden" name="allow_cid[]" value="" /><input id="group_deny" type="hidden" name="deny_gid[]" value="" /><input id="contact_deny" type="hidden" name="deny_cid[]" value="" />';
}
@@ -648,11 +649,11 @@ class Photos extends \Zotlabs\Web\Controller {
if($datum) {
$h = attach_by_hash_nodata($datum,get_observer_hash());
$selname = $h['data']['display_path'];
- }
+ }
+
-
$albums = ((array_key_exists('albums', \App::$data)) ? \App::$data['albums'] : photos_albums_list(\App::$data['channel'],\App::$data['observer']));
-
+
if(! $selname) {
$def_album = get_pconfig(\App::$data['channel']['channel_id'],'system','photo_path');
if($def_album) {
@@ -660,7 +661,7 @@ class Photos extends \Zotlabs\Web\Controller {
$albums['album'][] = array('text' => $selname);
}
}
-
+
$tpl = get_markup_template('photos_upload.tpl');
$upload_form = replace_macros($tpl,array(
'$pagename' => t('Upload Photos'),
@@ -685,22 +686,22 @@ class Photos extends \Zotlabs\Web\Controller {
'$default' => (($ret['default_upload']) ? true : false),
'$uploadurl' => $ret['post_url'],
'$submit' => t('Upload')
-
+
));
-
+
}
-
+
//
// dispatch request
//
-
+
/*
* Display a single photo album
*/
-
+
if($datatype === 'album') {
- head_add_link([
+ head_add_link([
'rel' => 'alternate',
'type' => 'application/json+oembed',
'href' => z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$query_string),
@@ -710,7 +711,7 @@ class Photos extends \Zotlabs\Web\Controller {
if($x = photos_album_exists($owner_uid, get_observer_hash(), $datum)) {
\App::set_pager_itemspage(30);
$album = $x['display_path'];
- }
+ }
else {
goaway(z_root() . '/photos/' . \App::$data['channel']['channel_address']);
}
@@ -721,7 +722,7 @@ class Photos extends \Zotlabs\Web\Controller {
$order = 'DESC';
$r = q("SELECT p.resource_id, p.id, p.filename, p.mimetype, p.imgscale, p.description, p.created FROM photo p INNER JOIN
- (SELECT resource_id, max(imgscale) imgscale FROM photo left join attach on folder = '%s' and photo.resource_id = attach.hash WHERE attach.uid = %d AND imgscale <= 4 AND photo_usage IN ( %d, %d ) and is_nsfw = %d $sql_extra GROUP BY resource_id) ph
+ (SELECT resource_id, max(imgscale) imgscale FROM photo left join attach on folder = '%s' and photo.resource_id = attach.hash WHERE attach.uid = %d AND imgscale <= 4 AND photo_usage IN ( %d, %d ) and is_nsfw = %d $sql_extra GROUP BY resource_id) ph
ON (p.resource_id = ph.resource_id AND p.imgscale = ph.imgscale)
ORDER BY created $order LIMIT %d OFFSET %d",
dbesc($x['hash']),
@@ -739,9 +740,9 @@ class Photos extends \Zotlabs\Web\Controller {
if($can_post) {
$album_e = $album;
$albums = ((array_key_exists('albums', \App::$data)) ? \App::$data['albums'] : photos_albums_list(\App::$data['channel'],\App::$data['observer']));
-
+
// @fixme - syncronise actions with DAV
-
+
// $edit_tpl = get_markup_template('album_edit.tpl');
// $album_edit = replace_macros($edit_tpl,array(
// '$nametext' => t('Enter a new album name'),
@@ -753,32 +754,32 @@ class Photos extends \Zotlabs\Web\Controller {
// '$submit' => t('Submit'),
// '$dropsubmit' => t('Delete Album')
// ));
-
+
}
-
+
if($_GET['order'] === 'posted')
$order = array(t('Show Newest First'), z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . $datum);
else
$order = array(t('Show Oldest First'), z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . $datum . '?f=&order=posted');
-
+
$photos = array();
if(count($r)) {
$twist = 'rotright';
foreach($r as $rr) {
-
+
if($twist == 'rotright')
$twist = 'rotleft';
else
$twist = 'rotright';
-
+
$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']
. (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''));
-
+
$photos[] = array(
'id' => $rr['id'],
'twist' => ' ' . $twist . rand(2,4),
@@ -793,7 +794,7 @@ class Photos extends \Zotlabs\Web\Controller {
);
}
}
-
+
if($_REQUEST['aj']) {
if($photos) {
$o = replace_macros(get_markup_template('photosajax.tpl'),array(
@@ -821,71 +822,71 @@ class Photos extends \Zotlabs\Web\Controller {
'$upload_form' => $upload_form,
'$usage' => $usage_message
));
-
+
}
-
+
if((! $photos) && ($_REQUEST['aj'])) {
$o .= '<div id="content-complete"></div>';
echo $o;
killme();
}
-
+
return $o;
-
- }
-
- /**
+
+ }
+
+ /**
* Display one photo
*/
-
+
if($datatype === 'image') {
-
+
\App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$cmd) . '" title="oembed" />' . "\r\n";
-
+
$x = q("select folder from attach where hash = '%s' and uid = %d $sql_attach limit 1",
dbesc($datum),
intval($owner_uid)
);
// fetch image, item containing image, then comments
-
- $ph = q("SELECT id,aid,uid,xchan,resource_id,created,edited,title,description,album,filename,mimetype,height,width,filesize,imgscale,photo_usage,is_nsfw,allow_cid,allow_gid,deny_cid,deny_gid FROM photo WHERE uid = %d AND resource_id = '%s'
+
+ $ph = q("SELECT id,aid,uid,xchan,resource_id,created,edited,title,description,album,filename,mimetype,height,width,filesize,imgscale,photo_usage,is_nsfw,allow_cid,allow_gid,deny_cid,deny_gid FROM photo WHERE uid = %d AND resource_id = '%s'
$sql_extra ORDER BY imgscale ASC ",
intval($owner_uid),
dbesc($datum)
);
-
+
if(! ($ph && $x)) {
-
+
/* Check again - this time without specifying permissions */
-
+
$ph = q("SELECT id FROM photo WHERE uid = %d AND resource_id = '%s' LIMIT 1",
intval($owner_uid),
dbesc($datum)
);
- if($ph)
+ if($ph)
notice( t('Permission denied. Access to this item may be restricted.') . EOL);
else
notice( t('Photo not available') . EOL );
return;
}
-
-
-
+
+
+
$prevlink = '';
$nextlink = '';
-
+
if($_GET['order'] === 'posted')
$order = 'ASC';
else
$order = 'DESC';
-
+
$prvnxt = q("SELECT hash FROM attach WHERE folder = '%s' AND uid = %d AND is_photo = 1
$sql_attach ORDER BY created $order ",
dbesc($x[0]['folder']),
intval($owner_uid)
- );
+ );
if(count($prvnxt)) {
for($z = 0; $z < count($prvnxt); $z++) {
@@ -899,12 +900,12 @@ class Photos extends \Zotlabs\Web\Controller {
break;
}
}
-
+
$prevlink = z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/image/' . $prvnxt[$prv]['hash'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
$nextlink = z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/image/' . $prvnxt[$nxt]['hash'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
}
-
-
+
+
if(count($ph) == 1)
$hires = $lores = $ph[0];
if(count($ph) > 1) {
@@ -917,74 +918,74 @@ class Photos extends \Zotlabs\Web\Controller {
$lores = $ph[1];
}
}
-
+
$album_link = z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . $x[0]['folder'];
$tools = Null;
$lock = Null;
-
+
if($can_post && ($ph[0]['uid'] == $owner_uid)) {
$tools = array(
'profile'=>array(z_root() . '/profile_photo/use/'.$ph[0]['resource_id'], t('Use as profile photo')),
'cover'=>array(z_root() . '/cover_photo/use/'.$ph[0]['resource_id'], t('Use as cover photo')),
);
}
-
+
// lockstate
$lockstate = ( ( (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid'])
|| strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid'])) )
? array('lock', t('Private Photo'))
: array('unlock', Null));
-
+
\App::$page['htmlhead'] .= '<script>$(document).keydown(function(event) {' . "\n";
if($prevlink)
\App::$page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 37) { event.preventDefault(); window.location.href = \'' . $prevlink . '\'; }' . "\n";
if($nextlink)
\App::$page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 39) { event.preventDefault(); window.location.href = \'' . $nextlink . '\'; }' . "\n";
\App::$page['htmlhead'] .= '});</script>';
-
+
if($prevlink)
$prevlink = array($prevlink, t('Previous'));
-
+
$photo = array(
'href' => z_root() . '/photo/' . $hires['resource_id'] . '-' . $hires['imgscale'] . '.' . $phototypes[$hires['mimetype']],
'title'=> t('View Full Size'),
'src' => z_root() . '/photo/' . $lores['resource_id'] . '-' . $lores['imgscale'] . '.' . $phototypes[$lores['mimetype']]
);
-
+
if($nextlink)
$nextlink = array($nextlink, t('Next'));
-
-
+
+
// Do we have an item for this photo?
-
- $linked_items = q("SELECT * FROM item WHERE resource_id = '%s' and resource_type = 'photo'
+
+ $linked_items = q("SELECT * FROM item WHERE resource_id = '%s' and resource_type = 'photo'
$sql_item LIMIT 1",
dbesc($datum)
);
-
+
$map = null;
-
+
if($linked_items) {
-
+
xchan_query($linked_items);
$linked_items = fetch_post_tags($linked_items,true);
-
+
$link_item = $linked_items[0];
$item_normal = item_normal();
-
- $r = q("select * from item where parent_mid = '%s'
+
+ $r = q("select * from item where parent_mid = '%s'
$item_normal and uid = %d $sql_item ",
dbesc($link_item['mid']),
intval($link_item['uid'])
-
+
);
-
+
if($r) {
xchan_query($r);
$r = fetch_post_tags($r,true);
$r = conv_sort($r,'commented');
}
-
+
$tags = array();
if($link_item['term']) {
$cnt = 0;
@@ -997,23 +998,23 @@ class Photos extends \Zotlabs\Web\Controller {
$cnt ++;
}
}
-
+
if((local_channel()) && (local_channel() == $link_item['uid'])) {
q("UPDATE item SET item_unseen = 0 WHERE parent = %d and uid = %d and item_unseen = 1",
intval($link_item['parent']),
intval(local_channel())
);
}
-
+
if($link_item['coord']) {
$map = generate_map($link_item['coord']);
}
}
-
+
// logger('mod_photo: link_item' . print_r($link_item,true));
-
- // FIXME - remove this when we move to conversation module
-
+
+ // FIXME - remove this when we move to conversation module
+
$r = $r[0]['children'];
$edit = null;
@@ -1023,11 +1024,11 @@ class Photos extends \Zotlabs\Web\Controller {
$caption_e = $ph[0]['description'];
$aclselect_e = (($_is_owner) ? populate_acl($ph[0], true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_storage')) : '');
$albums = ((array_key_exists('albums', \App::$data)) ? \App::$data['albums'] : photos_albums_list(\App::$data['channel'],\App::$data['observer']));
-
+
$_SESSION['album_return'] = bin2hex($ph[0]['album']);
$folder_list = attach_folder_select_list($ph[0]['uid']);
-
+
$edit = [
'edit' => t('Edit photo'),
'id' => $link_item['id'],
@@ -1058,17 +1059,17 @@ class Photos extends \Zotlabs\Web\Controller {
'delete' => t('Delete Photo')
];
}
-
+
if(count($linked_items)) {
-
+
$cmnt_tpl = get_markup_template('comment_item.tpl');
$tpl = get_markup_template('photo_item.tpl');
$return_url = \App::$cmd;
-
+
$like_tpl = get_markup_template('like_noshare.tpl');
-
+
$likebuttons = '';
-
+
if($observer && ($can_post || $can_comment)) {
$likebuttons = [
'id' => $link_item['id'],
@@ -1078,12 +1079,12 @@ class Photos extends \Zotlabs\Web\Controller {
'wait' => t('Please wait')
];
}
-
+
$comments = '';
if(! $r) {
if($observer && ($can_post || $can_comment)) {
$commentbox = replace_macros($cmnt_tpl,array(
- '$return_path' => '',
+ '$return_path' => '',
'$mode' => 'photos',
'$jsreload' => $return_url,
'$type' => 'wall-comment',
@@ -1101,28 +1102,28 @@ class Photos extends \Zotlabs\Web\Controller {
));
}
}
-
+
$alike = array();
$dlike = array();
-
+
$like = '';
$dislike = '';
-
+
$conv_responses = array(
'like' => array('title' => t('Likes','title')),'dislike' => array('title' => t('Dislikes','title')),
- 'agree' => array('title' => t('Agree','title')),'disagree' => array('title' => t('Disagree','title')), 'abstain' => array('title' => t('Abstain','title')),
+ 'agree' => array('title' => t('Agree','title')),'disagree' => array('title' => t('Disagree','title')), 'abstain' => array('title' => t('Abstain','title')),
'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title'))
);
-
-
-
-
+
+
+
+
if($r) {
-
+
foreach($r as $item) {
builtin_activity_puller($item, $conv_responses);
}
-
+
$like_count = ((x($alike,$link_item['mid'])) ? $alike[$link_item['mid']] : '');
$like_list = ((x($alike,$link_item['mid'])) ? $alike[$link_item['mid'] . '-l'] : '');
@@ -1133,7 +1134,7 @@ class Photos extends \Zotlabs\Web\Controller {
$like_list_part = '';
}
$like_button_label = tt('Like','Likes',$like_count,'noun');
-
+
//if (feature_enabled($conv->get_profile_owner(),'dislike')) {
$dislike_count = ((x($dlike,$link_item['mid'])) ? $dlike[$link_item['mid']] : '');
$dislike_list = ((x($dlike,$link_item['mid'])) ? $dlike[$link_item['mid'] . '-l'] : '');
@@ -1145,44 +1146,44 @@ class Photos extends \Zotlabs\Web\Controller {
$dislike_list_part = '';
}
//}
-
-
+
+
$like = ((isset($alike[$link_item['mid']])) ? format_like($alike[$link_item['mid']],$alike[$link_item['mid'] . '-l'],'like',$link_item['mid']) : '');
$dislike = ((isset($dlike[$link_item['mid']])) ? format_like($dlike[$link_item['mid']],$dlike[$link_item['mid'] . '-l'],'dislike',$link_item['mid']) : '');
-
+
// display comments
-
+
foreach($r as $item) {
$comment = '';
$template = $tpl;
$sparkle = '';
-
+
if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) && ($item['id'] != $item['parent']))
continue;
-
+
$redirect_url = z_root() . '/redir/' . $item['cid'] ;
-
-
+
+
$profile_url = zid($item['author']['xchan_url']);
$sparkle = '';
-
-
+
+
$profile_name = $item['author']['xchan_name'];
$profile_avatar = $item['author']['xchan_photo_m'];
-
+
$profile_link = $profile_url;
-
+
$drop = '';
-
+
if($observer['xchan_hash'] === $item['author_xchan'] || $observer['xchan_hash'] === $item['owner_xchan'])
$drop = replace_macros(get_markup_template('photo_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete')));
-
-
+
+
$name_e = $profile_name;
$title_e = $item['title'];
unobscure($item);
$body_e = prepare_text($item['body'],$item['mimetype']);
-
+
$comments .= replace_macros($template,array(
'$id' => $item['id'],
'$mode' => 'photos',
@@ -1197,9 +1198,9 @@ class Photos extends \Zotlabs\Web\Controller {
'$drop' => $drop,
'$comment' => $comment
));
-
+
}
-
+
if($observer && ($can_post || $can_comment)) {
$commentbox = replace_macros($cmnt_tpl,array(
'$return_path' => '',
@@ -1216,20 +1217,20 @@ class Photos extends \Zotlabs\Web\Controller {
'$ww' => ''
));
}
-
+
}
$paginate = paginate($a);
}
-
+
$album_e = array($album_link,$ph[0]['album']);
$like_e = $like;
$dislike_e = $dislike;
-
-
+
+
$response_verbs = array('like');
if(feature_enabled($owner_uid,'dislike'))
$response_verbs[] = 'dislike';
-
+
$responses = get_responses($conv_responses,$response_verbs,'',$link_item);
$hookdata = [
@@ -1238,7 +1239,7 @@ class Photos extends \Zotlabs\Web\Controller {
'nickname' => \App::$data['channel']['channel_address']
];
call_hooks('photo_view_filter', $hookdata);
-
+
$photo_tpl = get_markup_template('photo_view.tpl');
$o .= replace_macros($photo_tpl, array(
'$id' => $ph[0]['id'],
@@ -1255,7 +1256,7 @@ class Photos extends \Zotlabs\Web\Controller {
'$tag_hdr' => t('In This Photo:'),
'$tags' => $tags,
'responses' => $responses,
- '$edit' => $edit,
+ '$edit' => $edit,
'$map' => $map,
'$map_text' => t('Map'),
'$likebuttons' => $likebuttons,
@@ -1277,26 +1278,26 @@ class Photos extends \Zotlabs\Web\Controller {
'$paginate' => $paginate,
'$onclick' => $hookdata['onclick']
));
-
+
\App::$data['photo_html'] = $o;
-
+
return $o;
}
-
+
// Default - show recent photos with upload link (if applicable)
//$o = '';
-
+
\App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$cmd) . '" title="oembed" />' . "\r\n";
-
+
\App::set_pager_itemspage(30);
-
- $r = q("SELECT p.resource_id, p.id, p.filename, p.mimetype, p.album, p.imgscale, p.created, p.display_path
- FROM photo p
- INNER JOIN ( SELECT resource_id, max(imgscale) imgscale FROM photo
- WHERE photo.uid = %d AND photo_usage IN ( %d, %d )
- AND is_nsfw = %d $sql_extra group by resource_id ) ph
- ON (p.resource_id = ph.resource_id and p.imgscale = ph.imgscale)
+
+ $r = q("SELECT p.resource_id, p.id, p.filename, p.mimetype, p.album, p.imgscale, p.created, p.display_path
+ FROM photo p
+ INNER JOIN ( SELECT resource_id, max(imgscale) imgscale FROM photo
+ WHERE photo.uid = %d AND photo_usage IN ( %d, %d )
+ AND is_nsfw = %d $sql_extra group by resource_id ) ph
+ ON (p.resource_id = ph.resource_id and p.imgscale = ph.imgscale)
ORDER by p.created DESC LIMIT %d OFFSET %d",
intval(\App::$data['channel']['channel_id']),
intval(PHOTO_NORMAL),
@@ -1305,9 +1306,9 @@ class Photos extends \Zotlabs\Web\Controller {
intval(\App::$pager['itemspage']),
intval(\App::$pager['start'])
);
-
-
-
+
+
+
$photos = array();
if($r) {
$twist = 'rotright';
@@ -1321,7 +1322,7 @@ class Photos extends \Zotlabs\Web\Controller {
else
$twist = 'rotright';
$ext = $phototypes[$rr['mimetype']];
-
+
$alt_e = $rr['filename'];
$name_e = dirname($rr['display_path']);
@@ -1335,11 +1336,11 @@ class Photos extends \Zotlabs\Web\Controller {
'album' => array(
'name' => $name_e,
),
-
+
);
}
}
-
+
if($_REQUEST['aj']) {
if($photos) {
$o = replace_macros(get_markup_template('photosajax.tpl'),array(
@@ -1355,7 +1356,7 @@ class Photos extends \Zotlabs\Web\Controller {
}
else {
$o .= "<script> var page_query = '" . escape_tags(urlencode($_GET['q'])) . "'; var extra_args = '" . extra_query_args() . "' ; </script>";
- $tpl = get_markup_template('photos_recent.tpl');
+ $tpl = get_markup_template('photos_recent.tpl');
$o .= replace_macros($tpl, array(
'$title' => t('Recent Photos'),
'$album_id' => bin2hex(t('Recent Photos')),
@@ -1365,18 +1366,18 @@ class Photos extends \Zotlabs\Web\Controller {
'$upload_form' => $upload_form,
'$usage' => $usage_message
));
-
+
}
-
+
if((! $photos) && ($_REQUEST['aj'])) {
$o .= '<div id="content-complete"></div>';
echo $o;
killme();
}
-
+
// paginate($a);
return $o;
}
-
-
+
+
}
diff --git a/Zotlabs/Module/Profile.php b/Zotlabs/Module/Profile.php
index 4235f0b97..0373630a9 100644
--- a/Zotlabs/Module/Profile.php
+++ b/Zotlabs/Module/Profile.php
@@ -90,7 +90,7 @@ class Profile extends \Zotlabs\Web\Controller {
if(argc() > 2 && argv(2) === 'vcard') {
header('Content-type: text/vcard');
- header('content-disposition: attachment; filename="' . t('vcard') . '-' . $profile['channel_address'] . '.vcf"' );
+ header('content-disposition: attachment; filename="' . t('vcard') . '-' . \App::$profile['channel_address'] . '.vcf"' );
echo \App::$profile['profile_vcard'];
killme();
}
diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php
index 9ac0e725e..ca6ab435f 100644
--- a/Zotlabs/Module/Profiles.php
+++ b/Zotlabs/Module/Profiles.php
@@ -12,11 +12,11 @@ class Profiles extends \Zotlabs\Web\Controller {
function init() {
nav_set_selected('Profiles', 'settings/profiles');
-
+
if(! local_channel()) {
return;
}
-
+
if((argc() > 2) && (argv(1) === "drop") && intval(argv(2))) {
$r = q("SELECT * FROM profile WHERE id = %d AND uid = %d AND is_default = 0 LIMIT 1",
intval(argv(2)),
@@ -28,11 +28,11 @@ class Profiles extends \Zotlabs\Web\Controller {
return; // NOTREACHED
}
$profile_guid = $r['profile_guid'];
-
+
check_form_security_token_redirectOnErr('/profiles', 'profile_drop', 't');
-
+
// move every contact using this profile as their default to the user default
-
+
$r = q("UPDATE abook SET abook_profile = (SELECT profile_guid FROM profile WHERE is_default = 1 AND uid = %d LIMIT 1) WHERE abook_profile = '%s' AND abook_channel = %d ",
intval(local_channel()),
dbesc($profile_guid),
@@ -44,34 +44,34 @@ class Profiles extends \Zotlabs\Web\Controller {
);
if($r)
info( t('Profile deleted.') . EOL);
-
- // @fixme this is a much more complicated sync - add any changed abook entries and
+
+ // @fixme this is a much more complicated sync - add any changed abook entries and
// also add deleted flag to profile structure
// profiles_build_sync is just here as a placeholder - it doesn't work at all here
-
+
// profiles_build_sync(local_channel());
-
+
goaway(z_root() . '/profiles');
return; // NOTREACHED
}
-
-
-
-
-
+
+
+
+
+
if((argc() > 1) && (argv(1) === 'new')) {
-
+
// check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't');
-
+
$r0 = q("SELECT id FROM profile WHERE uid = %d",
intval(local_channel()));
$num_profiles = count($r0);
-
+
$name = t('Profile-') . ($num_profiles + 1);
-
+
$r1 = q("SELECT fullname, photo, thumb FROM profile WHERE uid = %d AND is_default = 1 LIMIT 1",
intval(local_channel()));
-
+
$r2 = profile_store_lowlevel(
[
'aid' => intval(get_account_id()),
@@ -83,27 +83,27 @@ class Profiles extends \Zotlabs\Web\Controller {
'thumb' => $r1[0]['thumb']
]
);
-
+
$r3 = q("SELECT id FROM profile WHERE uid = %d AND profile_name = '%s' LIMIT 1",
intval(local_channel()),
dbesc($name)
);
-
+
info( t('New profile created.') . EOL);
if(count($r3) == 1)
goaway(z_root() . '/profiles/' . $r3[0]['id']);
-
+
goaway(z_root() . '/profiles');
- }
-
+ }
+
if((argc() > 2) && (argv(1) === 'clone')) {
-
+
check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't');
-
+
$r0 = q("SELECT id FROM profile WHERE uid = %d",
intval(local_channel()));
$num_profiles = count($r0);
-
+
$name = t('Profile-') . ($num_profiles + 1);
$r1 = q("SELECT * FROM profile WHERE uid = %d AND id = %d LIMIT 1",
intval(local_channel()),
@@ -116,30 +116,30 @@ class Profiles extends \Zotlabs\Web\Controller {
}
unset($r1[0]['id']);
$r1[0]['is_default'] = 0;
- $r1[0]['publish'] = 0;
+ $r1[0]['publish'] = 0;
$r1[0]['profile_name'] = dbesc($name);
$r1[0]['profile_guid'] = dbesc(random_string());
-
+
create_table_from_array('profile', $r1[0]);
-
+
$r3 = q("SELECT id FROM profile WHERE uid = %d AND profile_name = '%s' LIMIT 1",
intval(local_channel()),
dbesc($name)
);
info( t('New profile created.') . EOL);
-
+
profiles_build_sync(local_channel());
-
+
if(($r3) && (count($r3) == 1))
goaway(z_root() . '/profiles/' . $r3[0]['id']);
-
+
goaway(z_root() . '/profiles');
-
+
return; // NOTREACHED
}
-
+
if((argc() > 2) && (argv(1) === 'export')) {
-
+
$r1 = q("SELECT * FROM profile WHERE uid = %d AND id = %d LIMIT 1",
intval(local_channel()),
intval(argv(2))
@@ -151,7 +151,7 @@ class Profiles extends \Zotlabs\Web\Controller {
}
header('content-type: application/octet_stream');
header('content-disposition: attachment; filename="' . $r1[0]['profile_name'] . '.json"' );
-
+
unset($r1[0]['id']);
unset($r1[0]['aid']);
unset($r1[0]['uid']);
@@ -162,10 +162,10 @@ class Profiles extends \Zotlabs\Web\Controller {
echo json_encode($r1[0]);
killme();
}
-
-
-
-
+
+
+
+
// Run profile_load() here to make sure the theme is set before
// we start loading content
if(((argc() > 1) && (intval(argv(1)))) || !feature_enabled(local_channel(),'multi_profiles')) {
@@ -187,28 +187,28 @@ class Profiles extends \Zotlabs\Web\Controller {
\App::$error = 404;
return;
}
-
+
$chan = \App::get_channel();
-
+
profile_load($chan['channel_address'],$r[0]['id']);
}
}
-
+
function post() {
-
+
if(! local_channel()) {
notice( t('Permission denied.') . EOL);
return;
}
-
+
require_once('include/activities.php');
-
+
$namechanged = false;
-
-
+
+
// import from json export file.
// Only import fields that are allowed on this hub
-
+
if(x($_FILES,'userfile')) {
$src = $_FILES['userfile']['tmp_name'];
$filesize = intval($_FILES['userfile']['size']);
@@ -230,10 +230,10 @@ class Profiles extends \Zotlabs\Web\Controller {
}
}
}
-
+
call_hooks('profile_post', $_POST);
-
-
+
+
if((argc() > 1) && (argv(1) !== "new") && intval(argv(1))) {
$orig = q("SELECT * FROM profile WHERE id = %d AND uid = %d LIMIT 1",
intval(\App::$argv[1]),
@@ -243,26 +243,26 @@ class Profiles extends \Zotlabs\Web\Controller {
notice( t('Profile not found.') . EOL);
return;
}
-
+
check_form_security_token_redirectOnErr('/profiles', 'profile_edit');
-
+
$is_default = (($orig[0]['is_default']) ? 1 : 0);
-
+
$profile_name = notags(trim($_POST['profile_name']));
if(! strlen($profile_name)) {
notice( t('Profile Name is required.') . EOL);
return;
}
-
+
$dob = $_POST['dob'] ? escape_tags(trim($_POST['dob'])) : '0000-00-00'; // FIXME: Needs to be validated?
-
+
$y = substr($dob,0,4);
if((! ctype_digit($y)) || ($y < 1900))
$ignore_year = true;
else
$ignore_year = false;
-
+
if($dob != '0000-00-00') {
if(strpos($dob,'0000-') === 0) {
$ignore_year = true;
@@ -272,12 +272,12 @@ class Profiles extends \Zotlabs\Web\Controller {
if($ignore_year)
$dob = '0000-' . $dob;
}
-
+
$name = escape_tags(trim($_POST['name']));
-
+
if($orig[0]['fullname'] != $name) {
$namechanged = true;
-
+
$v = validate_channelname($name);
if($v) {
notice($v);
@@ -285,7 +285,7 @@ class Profiles extends \Zotlabs\Web\Controller {
$name = $orig[0]['fullname'];
}
}
-
+
$pdesc = escape_tags(trim($_POST['pdesc']));
$gender = escape_tags(trim($_POST['gender']));
$address = escape_tags(trim($_POST['address']));
@@ -301,10 +301,10 @@ class Profiles extends \Zotlabs\Web\Controller {
$hometown = escape_tags(trim($_POST['hometown']));
$politic = escape_tags(trim($_POST['politic']));
$religion = escape_tags(trim($_POST['religion']));
-
+
$likes = fix_mce_lf(escape_tags(trim($_POST['likes'])));
$dislikes = fix_mce_lf(escape_tags(trim($_POST['dislikes'])));
-
+
$about = fix_mce_lf(escape_tags(trim($_POST['about'])));
$interest = fix_mce_lf(escape_tags(trim($_POST['interest'])));
$contact = fix_mce_lf(escape_tags(trim($_POST['contact'])));
@@ -316,11 +316,11 @@ class Profiles extends \Zotlabs\Web\Controller {
$romance = fix_mce_lf(escape_tags(trim($_POST['romance'])));
$work = fix_mce_lf(escape_tags(trim($_POST['work'])));
$education = fix_mce_lf(escape_tags(trim($_POST['education'])));
-
+
$hide_friends = ((intval($_POST['hide_friends'])) ? 1: 0);
-
+
// start fresh and create a new vcard. TODO: preserve the original guid or whatever else needs saving
-// $orig_vcard = (($orig[0]['profile_vcard']) ? \Sabre\VObject\Reader::read($orig[0]['profile_vcard']) : null);
+// $orig_vcard = (($orig[0]['profile_vcard']) ? \Sabre\VObject\Reader::read($orig[0]['profile_vcard']) : null);
$orig_vcard = null;
@@ -347,7 +347,7 @@ class Profiles extends \Zotlabs\Web\Controller {
5 => $postal_code,
6 => $country_name
];
-
+
$profile_vcard = update_vcard($defcard,$orig_vcard);
$orig_vcard = \Sabre\VObject\Reader::read($profile_vcard);
@@ -370,19 +370,19 @@ class Profiles extends \Zotlabs\Web\Controller {
linkify_tags($romance, local_channel());
linkify_tags($work, local_channel());
linkify_tags($education, local_channel());
-
-
+
+
$with = ((x($_POST,'with')) ? escape_tags(trim($_POST['with'])) : '');
-
+
if(! strlen($howlong))
$howlong = NULL_DATE;
else
$howlong = datetime_convert(date_default_timezone_get(),'UTC',$howlong);
-
+
// linkify the relationship target if applicable
-
+
$withchanged = false;
-
+
if(strlen($with)) {
if($with != strip_tags($orig[0]['partner'])) {
$withchanged = true;
@@ -392,7 +392,7 @@ class Profiles extends \Zotlabs\Web\Controller {
$lookup = substr($lookup,1);
$lookup = str_replace('_',' ', $lookup);
$newname = $lookup;
-
+
$r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash WHERE xchan_name = '%s' AND abook_channel = %d LIMIT 1",
dbesc($newname),
intval(local_channel())
@@ -407,8 +407,8 @@ class Profiles extends \Zotlabs\Web\Controller {
$prf = $r[0]['xchan_url'];
$newname = $r[0]['xchan_name'];
}
-
-
+
+
if($prf) {
$with = str_replace($lookup,'<a href="' . $prf . '">' . $newname . '</a>', $with);
if(strpos($with,'@') === 0)
@@ -418,7 +418,7 @@ class Profiles extends \Zotlabs\Web\Controller {
else
$with = $orig[0]['partner'];
}
-
+
$profile_fields_basic = get_profile_fields_basic();
$profile_fields_advanced = get_profile_fields_advanced();
$advanced = ((feature_enabled(local_channel(),'advanced_profiles')) ? true : false);
@@ -426,7 +426,7 @@ class Profiles extends \Zotlabs\Web\Controller {
$fields = $profile_fields_advanced;
else
$fields = $profile_fields_basic;
-
+
$z = q("select * from profdef where true");
if($z) {
foreach($z as $zz) {
@@ -453,7 +453,7 @@ class Profiles extends \Zotlabs\Web\Controller {
}
}
}
-
+
$changes = array();
$value = '';
if($is_default) {
@@ -513,12 +513,12 @@ class Profiles extends \Zotlabs\Web\Controller {
$comma2 = (($region && $country_name) ? ', ' : '');
$value = $locality . $comma1 . $region . $comma2 . $country_name;
}
-
+
profile_activity($changes,$value);
-
- }
-
- $r = q("UPDATE profile
+
+ }
+
+ $r = q("UPDATE profile
SET profile_name = '%s',
fullname = '%s',
pdesc = '%s',
@@ -591,10 +591,10 @@ class Profiles extends \Zotlabs\Web\Controller {
intval(argv(1)),
intval(local_channel())
);
-
+
if($r)
info( t('Profile updated.') . EOL);
-
+
$r = q("select * from profile where id = %d and uid = %d limit 1",
intval(argv(1)),
intval(local_channel())
@@ -603,9 +603,9 @@ class Profiles extends \Zotlabs\Web\Controller {
require_once('include/zot.php');
Libsync::build_sync_packet(local_channel(),array('profile' => $r));
}
-
+
$channel = \App::get_channel();
-
+
if($namechanged && $is_default) {
$r = q("UPDATE xchan SET xchan_name = '%s', xchan_name_date = '%s' WHERE xchan_url = '%s'",
dbesc($name),
@@ -617,7 +617,7 @@ class Profiles extends \Zotlabs\Web\Controller {
dbesc($channel['xchan_hash'])
);
}
-
+
if($is_default) {
// reload the info for the sidebar widget - why does this not work?
profile_load($channel['channel_address']);
@@ -625,24 +625,24 @@ class Profiles extends \Zotlabs\Web\Controller {
}
}
}
-
-
+
+
function get() {
-
+
$o = '';
-
+
$channel = \App::get_channel();
-
+
if(! local_channel()) {
notice( t('Permission denied.') . EOL);
return;
}
-
+
require_once('include/channel.php');
-
+
$profile_fields_basic = get_profile_fields_basic();
$profile_fields_advanced = get_profile_fields_advanced();
-
+
if(((argc() > 1) && (intval(argv(1)))) || !feature_enabled(local_channel(),'multi_profiles')) {
if(feature_enabled(local_channel(),'multi_profiles'))
$id = \App::$argv[1];
@@ -652,7 +652,7 @@ class Profiles extends \Zotlabs\Web\Controller {
);
if($x)
$id = $x[0]['id'];
- }
+ }
$r = q("SELECT * FROM profile WHERE id = %d AND uid = %d LIMIT 1",
intval($id),
intval(local_channel())
@@ -661,20 +661,20 @@ class Profiles extends \Zotlabs\Web\Controller {
notice( t('Profile not found.') . EOL);
return;
}
-
+
$editselect = 'none';
-
+
\App::$page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array(
'$baseurl' => z_root(),
'$editselect' => $editselect,
));
-
+
$advanced = ((feature_enabled(local_channel(),'advanced_profiles')) ? true : false);
if($advanced)
$fields = $profile_fields_advanced;
else
$fields = $profile_fields_basic;
-
+
$hide_friends = array(
'hide_friends',
t('Hide your connections list from viewers of this profile'),
@@ -682,36 +682,36 @@ class Profiles extends \Zotlabs\Web\Controller {
'',
array(t('No'),t('Yes'))
);
-
+
$q = q("select * from profdef where true");
if($q) {
$extra_fields = array();
-
+
foreach($q as $qq) {
$mine = q("select v from profext where k = '%s' and hash = '%s' and channel_id = %d limit 1",
- dbesc($qq['field_name']),
+ dbesc($qq['field_name']),
dbesc($r[0]['profile_guid']),
intval(local_channel())
);
-
+
if(array_key_exists($qq['field_name'],$fields)) {
$extra_fields[] = array($qq['field_name'],$qq['field_desc'],(($mine) ? $mine[0]['v'] : ''), $qq['field_help']);
}
}
}
-
+
//logger('extra_fields: ' . print_r($extra_fields,true));
$vc = $r[0]['profile_vcard'];
- $vctmp = (($vc) ? \Sabre\VObject\Reader::read($vc) : null);
+ $vctmp = (($vc) ? \Sabre\VObject\Reader::read($vc) : null);
$vcard = (($vctmp) ? get_vcard_array($vctmp,$r[0]['id']) : [] );
-
+
$f = get_config('system','birthday_input_format');
if(! $f)
$f = 'ymd';
-
+
$is_default = (($r[0]['is_default']) ? 1 : 0);
-
+
$tpl = get_markup_template("profile_edit.tpl");
$o .= replace_macros($tpl,array(
'$multi_profiles' => ((feature_enabled(local_channel(),'multi_profiles')) ? true : false),
@@ -749,7 +749,7 @@ class Profiles extends \Zotlabs\Web\Controller {
'$default' => t('This is your default profile.') . EOL . translate_scope(map_scope(\Zotlabs\Access\PermissionLimits::Get($channel['channel_id'],'view_profile'))),
'$advanced' => $advanced,
'$name' => array('name', t('Your full name'), $r[0]['fullname'], t('Required'), '*'),
- '$pdesc' => array('pdesc', t('Title/Description'), $r[0]['pdesc']),
+ '$pdesc' => array('pdesc', t('Short title/tescription'), $r[0]['pdesc'], t('Maximal 190 characters'), '', 'maxlength="190"'),
'$dob' => dob($r[0]['dob']),
'$hide_friends' => $hide_friends,
'$address' => array('address', t('Street address'), $r[0]['address']),
@@ -802,18 +802,18 @@ class Profiles extends \Zotlabs\Web\Controller {
'$delete' => t('Delete'),
'$cancel' => t('Cancel'),
));
-
+
$arr = array('profile' => $r[0], 'entry' => $o);
call_hooks('profile_edit', $arr);
-
+
return $o;
}
else {
-
+
$r = q("SELECT * FROM profile WHERE uid = %d",
local_channel());
if($r) {
-
+
$tpl = get_markup_template('profile_entry.tpl');
foreach($r as $rr) {
$profiles .= replace_macros($tpl, array(
@@ -821,24 +821,24 @@ class Profiles extends \Zotlabs\Web\Controller {
'$id' => $rr['id'],
'$alt' => t('Profile Image'),
'$profile_name' => $rr['profile_name'],
- '$visible' => (($rr['is_default'])
- ? '<strong>' . translate_scope(map_scope(\Zotlabs\Access\PermissionLimits::Get($channel['channel_id'],'view_profile'))) . '</strong>'
+ '$visible' => (($rr['is_default'])
+ ? '<strong>' . translate_scope(map_scope(\Zotlabs\Access\PermissionLimits::Get($channel['channel_id'],'view_profile'))) . '</strong>'
: '<a href="' . z_root() . '/profperm/' . $rr['id'] . '" />' . t('Edit visibility') . '</a>')
));
}
-
+
$tpl_header = get_markup_template('profile_listing_header.tpl');
$o .= replace_macros($tpl_header,array(
'$header' => t('Edit Profiles'),
'$cr_new' => t('Create New'),
'$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new"),
'$profiles' => $profiles
- ));
-
+ ));
+
}
return $o;
}
-
+
}
-
+
}
diff --git a/Zotlabs/Module/Pubsites.php b/Zotlabs/Module/Pubsites.php
index daec5dde3..4b64d9af6 100644
--- a/Zotlabs/Module/Pubsites.php
+++ b/Zotlabs/Module/Pubsites.php
@@ -1,18 +1,19 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Lib\Libzotdir;
class Pubsites extends \Zotlabs\Web\Controller {
function get() {
- require_once('include/dir_fns.php');
+ require_once('include/dir_fns.php');
$dirmode = intval(get_config('system','directory_mode'));
-
+
if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
$url = z_root() . '/dirsearch';
}
if(! $url) {
- $directory = find_upstream_directory($dirmode);
+ $directory = Libzotdir::find_upstream_directory($dirmode);
$url = $directory['url'] . '/dirsearch';
}
$url .= '/sites';
@@ -20,12 +21,12 @@ class Pubsites extends \Zotlabs\Web\Controller {
$rating_enabled = get_config('system','rating_enabled');
$o .= '<div class="generic-content-wrapper">';
-
+
$o .= '<div class="section-title-wrapper"><h2>' . t('Public Hubs') . '</h2></div>';
-
- $o .= '<div class="section-content-tools-wrapper"><div class="descriptive-text">' .
+
+ $o .= '<div class="section-content-tools-wrapper"><div class="descriptive-text">' .
t('The listed hubs allow public registration for the $Projectname network. All hubs in the network are interlinked so membership on any of them conveys membership in the network as a whole. Some hubs may require subscription or provide tiered service plans. The hub itself <strong>may</strong> provide additional details.') . '</div>' . EOL;
-
+
$ret = z_fetch_url($url);
if($ret['success']) {
$j = json_decode($ret['body'],true);
@@ -48,8 +49,8 @@ class Pubsites extends \Zotlabs\Web\Controller {
$host = strtolower(substr($jj['url'],strpos($jj['url'],'://')+3));
$rate_links = ((local_channel()) ? '<td><a href="rate?f=&target=' . $host . '" class="btn-btn-default"><i class="fa fa-check-square-o"></i> ' . t('Rate') . '</a></td>' : '');
$location = '';
- if(!empty($jj['location'])) {
- $location = '<p title="' . t('Location') . '" style="margin: 5px 5px 0 0; text-align: right"><i class="fa fa-globe"></i> ' . $jj['location'] . '</p>';
+ if(!empty($jj['location'])) {
+ $location = '<p title="' . t('Location') . '" style="margin: 5px 5px 0 0; text-align: right"><i class="fa fa-globe"></i> ' . $jj['location'] . '</p>';
}
else {
$location = '<br />&nbsp;';
@@ -61,14 +62,14 @@ class Pubsites extends \Zotlabs\Web\Controller {
$o .= '</tr>';
}
}
-
+
$o .= '</table>';
-
+
$o .= '</div></div>';
-
+
}
}
return $o;
}
-
+
}
diff --git a/Zotlabs/Module/Regver.php b/Zotlabs/Module/Regver.php
index 82b162f56..c45723063 100644
--- a/Zotlabs/Module/Regver.php
+++ b/Zotlabs/Module/Regver.php
@@ -6,8 +6,6 @@ class Regver extends \Zotlabs\Web\Controller {
function get() {
- global $lang;
-
$_SESSION['return_url'] = \App::$cmd;
if(argc() != 3)
diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php
index 287c24829..396e07001 100644
--- a/Zotlabs/Module/Sse_bs.php
+++ b/Zotlabs/Module/Sse_bs.php
@@ -123,7 +123,7 @@ class Sse_bs extends Controller {
$mids[] = '\'' . dbesc(@base64url_decode(substr($a,4))) . '\'';
}
- $str = implode($mids, ',');
+ $str = implode(',', $mids);
$x = [ 'channel_id' => self::$uid, 'update' => 'unset' ];
call_hooks('update_unseen',$x);
@@ -162,7 +162,7 @@ class Sse_bs extends Controller {
$item_normal = item_normal();
if ($notifications) {
- $items = q("SELECT * FROM item
+ $items = q("SELECT * FROM item
WHERE uid = %d
AND created <= '%s'
AND item_unseen = 1 AND item_wall = 0 AND item_private IN (0, 1)
@@ -190,7 +190,7 @@ class Sse_bs extends Controller {
}
- $r = q("SELECT count(id) as total FROM item
+ $r = q("SELECT count(id) as total FROM item
WHERE uid = %d and item_unseen = 1 AND item_wall = 0 AND item_private IN (0, 1)
AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image')
AND author_xchan != '%s'
@@ -231,10 +231,10 @@ class Sse_bs extends Controller {
$item_normal = item_normal();
if ($notifications) {
- $items = q("SELECT * FROM item
+ $items = q("SELECT * FROM item
WHERE uid = %d
AND created <= '%s'
- AND item_unseen = 1 AND item_wall = 0 AND item_private = 2
+ AND item_unseen = 1 AND item_private = 2
AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image')
AND author_xchan != '%s'
$item_normal
@@ -259,8 +259,8 @@ class Sse_bs extends Controller {
}
- $r = q("SELECT count(id) as total FROM item
- WHERE uid = %d and item_unseen = 1 AND item_wall = 0 AND item_private = 2
+ $r = q("SELECT count(id) as total FROM item
+ WHERE uid = %d and item_unseen = 1 AND item_private = 2
$item_normal
$sql_extra
AND author_xchan != '%s'",
@@ -300,10 +300,10 @@ class Sse_bs extends Controller {
$item_normal = item_normal();
if ($notifications) {
- $items = q("SELECT * FROM item
+ $items = q("SELECT * FROM item
WHERE uid = %d
AND created <= '%s'
- AND item_unseen = 1 AND item_wall = 1
+ AND item_unseen = 1 AND item_wall = 1 AND item_private IN (0, 1)
AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image')
AND author_xchan != '%s'
$item_normal
@@ -328,8 +328,8 @@ class Sse_bs extends Controller {
}
- $r = q("SELECT count(id) as total FROM item
- WHERE uid = %d and item_unseen = 1 AND item_wall = 1
+ $r = q("SELECT count(id) as total FROM item
+ WHERE uid = %d and item_unseen = 1 AND item_wall = 1 AND item_private IN (0, 1)
$item_normal
$sql_extra
AND author_xchan != '%s'",
@@ -379,7 +379,7 @@ class Sse_bs extends Controller {
$item_normal = item_normal();
if ($notifications) {
- $items = q("SELECT * FROM item
+ $items = q("SELECT * FROM item
WHERE uid = %d
AND created <= '%s'
AND item_unseen = 1
@@ -410,7 +410,7 @@ class Sse_bs extends Controller {
}
- $r = q("SELECT count(id) as total FROM item
+ $r = q("SELECT count(id) as total FROM item
WHERE uid = %d AND item_unseen = 1
AND created > '%s'
$item_normal
@@ -516,7 +516,7 @@ class Sse_bs extends Controller {
$p_str = ids_to_querystr($p, 'parent');
$p_sql = (($p_str) ? "OR parent IN ( $p_str )" : '');
- $r = q("select mid from item
+ $r = q("select mid from item
where uid = %d and ( owner_xchan = '%s' OR author_xchan = '%s' $p_sql ) and item_unseen = 1 $sql_extra $item_normal",
intval(self::$uid),
dbesc($forums[$x]['xchan_hash']),
@@ -577,7 +577,7 @@ class Sse_bs extends Controller {
$item_normal = item_normal();
- $r = q("SELECT * FROM item
+ $r = q("SELECT * FROM item
WHERE verb = '%s'
AND obj_type IN ('Document', 'Video', 'Audio', 'Image')
AND uid = %d
diff --git a/Zotlabs/Module/Zfinger.php b/Zotlabs/Module/Zfinger.php
index 533f0a5db..ce7117ad8 100644
--- a/Zotlabs/Module/Zfinger.php
+++ b/Zotlabs/Module/Zfinger.php
@@ -7,7 +7,7 @@ use Zotlabs\Lib\Libzot;
class Zfinger extends \Zotlabs\Web\Controller {
function init() {
-
+
require_once('include/zot.php');
require_once('include/crypto.php');
@@ -26,7 +26,7 @@ class Zfinger extends \Zotlabs\Web\Controller {
if($chan) {
$headers['Digest'] = HTTPSig::generate_digest_header($ret);
- $h = HTTPSig::create_sig($headers,$chan['channel_prvkey'],'acct:' . channel_reddress($chan));
+ $h = HTTPSig::create_sig($headers,$chan['channel_prvkey'], channel_url($chan));
HTTPSig::set_headers($h);
}
else {
@@ -37,7 +37,7 @@ class Zfinger extends \Zotlabs\Web\Controller {
echo $ret;
killme();
-
+
}
-
+
}
diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php
index 7b20e9ddb..fdef35210 100644
--- a/Zotlabs/Storage/Browser.php
+++ b/Zotlabs/Storage/Browser.php
@@ -264,7 +264,6 @@ class Browser extends DAV\Browser\Plugin {
$ft['attach_id'] = $id;
$ft['icon'] = $icon;
$ft['photo_icon'] = $photo_icon;
- $ft['is_owner'] = $is_owner;
$ft['is_creator'] = $is_creator;
$ft['rel_path'] = (($data) ? '/cloud/' . $nick .'/' . $data['display_path'] : $href);
$ft['full_path'] = z_root() . (($data) ? '/cloud/' . $nick .'/' . $data['display_path'] : $href);
@@ -295,9 +294,16 @@ class Browser extends DAV\Browser\Plugin {
// create a copy of the list which we can alter for the current resource
$folders = $folder_list;
+
if($data['is_dir']) {
- // can not copy a folder into itself
- unset($folders[$folder_hash]);
+
+ $rm_path = $folders[$folder_hash];
+ // can not copy a folder into itself or own child folders
+ foreach($folders as $k => $v) {
+ if(strpos($v, $rm_path) === 0)
+ unset($folders[$k]);
+ }
+
}
$ft['newfolder'] = ['newfolder_' . $id, t('Select a target location'), $data['folder'], '', $folders];
@@ -325,7 +331,7 @@ class Browser extends DAV\Browser\Plugin {
}
$ft['attach_bbcode'] = $attach_bbcode;
- $link_bbcode = '[zrl]' . $ft['full_path'] . '[/zrl]';
+ $link_bbcode = '[zrl=' . $ft['full_path'] . ']' . $ft['name'] . '[/zrl]';
$ft['link_bbcode'] = $link_bbcode;
$f[] = $ft;
@@ -360,7 +366,7 @@ class Browser extends DAV\Browser\Plugin {
'$upload' => t('Add Files'),
'$is_owner' => $is_owner,
'$is_admin' => is_site_admin(),
- '$admin_delete' => t('Admin Delete'),
+ '$admin_delete_label' => t('Admin Delete'),
'$parentpath' => $parent_path,
'$folder_parent' => $folder_parent,
'$folder' => $parent->folder_hash,
@@ -373,26 +379,36 @@ class Browser extends DAV\Browser\Plugin {
'$size' => t('Size'),
'$lastmod' => t('Last Modified'),
'$parent' => t('parent'),
- '$edit' => t('Submit'),
- '$delete' => t('Delete'),
+ '$submit_label' => t('Submit'),
+ '$cancel_label' => t('Cancel'),
+ '$delete_label' => t('Delete'),
'$channel_id' => $channel_id,
'$cpdesc' => t('Copy/paste this code to attach file to a post'),
'$cpldesc' => t('Copy/paste this URL to link file from a web page'),
-
'$categories' => ['categories', t('Categories')],
'$recurse' => ['recurse', t('Set permissions for all files and sub folders'), 0, '', [t('No'), t('Yes')]],
-
'$newfolder' => ['newfolder', t('Select a target location'), $parent->folder_hash, '', $folder_list],
'$copy' => ['copy', t('Copy to target location'), 0, '', [t('No'), t('Yes')]],
'$return_path' => $path,
-
'$lockstate' => $lockstate,
'$allow_cid' => acl2json($channel_acl['allow_cid']),
'$allow_gid' => acl2json($channel_acl['allow_gid']),
'$deny_cid' => acl2json($channel_acl['deny_cid']),
- '$deny_gid' => acl2json($channel_acl['deny_gid'])
-
-
+ '$deny_gid' => acl2json($channel_acl['deny_gid']),
+ '$is_owner' => $is_owner,
+ '$select_all_label' => t('Select All'),
+ '$bulk_actions_label' => t('Bulk Actions'),
+ '$adjust_permissions_label' => t('Adjust Permissions'),
+ '$move_copy_label' => t('Move or Copy'),
+ '$categories_label' => t('Categories'),
+ '$download_label' => t('Download'),
+ '$info_label' => t('Info'),
+ '$rename_label' => t('Rename'),
+ '$post_label' => t('Post'),
+ '$attach_bbcode_label' => t('Attachment BBcode'),
+ '$embed_bbcode_label' => t('Embed BBcode'),
+ '$link_bbcode_label' => t('Link BBcode'),
+ '$close_label' => t('Close')
));
$a = false;
@@ -491,7 +507,7 @@ class Browser extends DAV\Browser\Plugin {
$breadcrumbs_html = '';
- if($display_path && ! $_REQUEST['cat']){
+ if($display_path && ! $_REQUEST['cat'] && ! $_SESSION['cloud_tiles']){
$breadcrumbs = [];
$folders = explode('/', $display_path);
$folder_hashes = explode('/', $node->os_path);
@@ -534,7 +550,8 @@ class Browser extends DAV\Browser\Plugin {
'$folder' => $node->folder_hash,
'$dragdroptext' => t('Drop files here to immediately upload'),
'$notify' => ['notify', t('Show in your contacts shared folder'), 0, '', [t('No'), t('Yes')]],
- '$breadcrumbs_html' => $breadcrumbs_html
+ '$breadcrumbs_html' => $breadcrumbs_html,
+ '$drop_area_label' => t('You can select files via the upload button or drop them right here or into an existing folder.')
));
}
diff --git a/Zotlabs/Web/HTTPSig.php b/Zotlabs/Web/HTTPSig.php
index 1f6979191..0b3e2bf2e 100644
--- a/Zotlabs/Web/HTTPSig.php
+++ b/Zotlabs/Web/HTTPSig.php
@@ -225,7 +225,7 @@ class HTTPSig {
}
if($keytype === 'zot6') {
- $key = self::get_zotfinger_key($id,$force);
+ $key = self::get_zotfinger_key($id);
if($key) {
return $key;
}
diff --git a/Zotlabs/Widget/Dirsort.php b/Zotlabs/Widget/Dirsort.php
index e75a00e50..2fb38b7df 100644
--- a/Zotlabs/Widget/Dirsort.php
+++ b/Zotlabs/Widget/Dirsort.php
@@ -2,10 +2,10 @@
namespace Zotlabs\Widget;
-require_once('include/dir_fns.php');
+use Zotlabs\Lib\Libzotdir;
class Dirsort {
function widget($arr) {
- return dir_sort_links();
+ return Libzotdir::dir_sort_links();
}
}
diff --git a/Zotlabs/Zot6/Finger.php b/Zotlabs/Zot6/Finger.php
index 22ce4685d..cec3f98ab 100644
--- a/Zotlabs/Zot6/Finger.php
+++ b/Zotlabs/Zot6/Finger.php
@@ -88,7 +88,7 @@ class Finger {
$headers = [];
$headers['X-Zot-Channel'] = $channel['channel_address'] . '@' . \App::get_hostname();
$headers['X-Zot-Nonce'] = random_string();
- $xhead = HTTPSig::create_sig($headers,$channel['channel_prvkey'],'acct:' . channel_reddress($channel));
+ $xhead = HTTPSig::create_sig($headers,$channel['channel_prvkey'], channel_url($channel));
$retries = 0;
@@ -100,7 +100,7 @@ class Finger {
$result = z_post_url('http://' . $host . $rhs,$postvars, $retries, [ 'headers' => $xhead ]);
}
}
- }
+ }
else {
$rhs .= '?f=&address=' . urlencode($address) . '&token=' . self::$token;
diff --git a/Zotlabs/Zot6/Zot6Handler.php b/Zotlabs/Zot6/Zot6Handler.php
index d717b147b..bd321c4b1 100644
--- a/Zotlabs/Zot6/Zot6Handler.php
+++ b/Zotlabs/Zot6/Zot6Handler.php
@@ -226,18 +226,18 @@ class Zot6Handler implements IHandler {
if ($recipients) {
// basically this means "unfriend"
foreach ($recipients as $recip) {
- $r = q("select channel.*,xchan.* from channel
+ $channel = q("select channel.*,xchan.* from channel
left join xchan on channel_hash = xchan_hash
where channel_hash = '%s' limit 1",
dbesc($recip)
);
- if ($r) {
- $r = q("select abook_id from abook where uid = %d and abook_xchan = '%s' limit 1",
- intval($r[0]['channel_id']),
+ if ($channel) {
+ $abook = q("select abook_id from abook where abook_channel = %d and abook_xchan = '%s' limit 1",
+ intval($channel[0]['channel_id']),
dbesc($sender)
);
- if ($r) {
- contact_remove($r[0]['channel_id'],$r[0]['abook_id']);
+ if ($abook) {
+ contact_remove($channel[0]['channel_id'],$abook[0]['abook_id']);
}
}
}