aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r--Zotlabs/Module/Admin/Site.php4
-rw-r--r--Zotlabs/Module/Article_edit.php3
-rw-r--r--Zotlabs/Module/Channel.php19
-rw-r--r--Zotlabs/Module/Item.php8
-rw-r--r--Zotlabs/Module/Magic.php3
-rw-r--r--Zotlabs/Module/Manage.php68
-rw-r--r--Zotlabs/Module/Photos.php8
-rw-r--r--Zotlabs/Module/Pubstream.php2
-rw-r--r--Zotlabs/Module/Removeme.php46
-rw-r--r--Zotlabs/Module/Sse.php3
-rw-r--r--Zotlabs/Module/Sse_bs.php30
11 files changed, 112 insertions, 82 deletions
diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php
index 3b2632411..76e117a84 100644
--- a/Zotlabs/Module/Admin/Site.php
+++ b/Zotlabs/Module/Admin/Site.php
@@ -480,12 +480,12 @@ class Site {
'$invitation_only' => [
'invitation_only',
t("Require invite code"),
- $invitation_only
+ get_config('system', 'invitation_only', 0)
],
'$invitation_also' => [
'invitation_also',
t("Allow invite code"),
- $invitation_also
+ get_config('system', 'invitation_also', 0)
],
'$verify_email' => [
'verify_email',
diff --git a/Zotlabs/Module/Article_edit.php b/Zotlabs/Module/Article_edit.php
index efa02e1c1..97c87f2ba 100644
--- a/Zotlabs/Module/Article_edit.php
+++ b/Zotlabs/Module/Article_edit.php
@@ -85,7 +85,6 @@ class Article_edit extends \Zotlabs\Web\Controller {
$mimetype = $itm[0]['mimetype'];
- $summary = (($itm[0]['summary']) ? '[summary]' . $itm[0]['summary'] . '[/summary]' . "\r\n" : '');
$content = $itm[0]['body'];
$rp = 'articles/' . $channel['channel_address'];
@@ -109,7 +108,7 @@ class Article_edit extends \Zotlabs\Web\Controller {
'ptyp' => $itm[0]['type'],
'mimeselect' => false,
'mimetype' => $itm[0]['mimetype'],
- 'body' => $summary . undo_post_tagging($content),
+ 'body' => undo_post_tagging($content),
'post_id' => $post_id,
'visitor' => true,
'title' => htmlspecialchars($itm[0]['title'],ENT_COMPAT,'UTF-8'),
diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php
index a7deb4f6b..20cbe0b5c 100644
--- a/Zotlabs/Module/Channel.php
+++ b/Zotlabs/Module/Channel.php
@@ -46,14 +46,22 @@ class Channel extends Controller {
}
$profile = 0;
- $channel = App::get_channel();
if ((local_channel()) && (argc() > 2) && (argv(2) === 'view')) {
+ $channel = App::get_channel();
$which = $channel['channel_address'];
$profile = argv(1);
}
- $channel = channelx_by_nick($which);
+
+ // Do not use channelx_by_nick() here since it will dismiss deleted channels.
+ // We need to provide zotinfo for deleted channels so that directories can pick up the info.
+ $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_address = '%s' LIMIT 1",
+ dbesc($which)
+ );
+
+ $channel = $r[0];
+
if (!$channel) {
http_status_exit(404, 'Not found');
}
@@ -83,12 +91,17 @@ class Channel extends Controller {
'Digest' => HTTPSig::generate_digest_header($data),
'(request-target)' => strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI']
];
- $h = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_url($channel));
+
+ $h = HTTPSig::create_sig($headers, $channel['channel_prvkey'], channel_url($channel));
HTTPSig::set_headers($h);
echo $data;
killme();
}
+ if ($channel['channel_removed']) {
+ http_status_exit(404, 'Not found');
+ }
+
if (ActivityStreams::is_as_request($channel)) {
// Somebody may attempt an ActivityStreams fetch on one of our message permalinks
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php
index ff52babf5..73a943039 100644
--- a/Zotlabs/Module/Item.php
+++ b/Zotlabs/Module/Item.php
@@ -745,10 +745,10 @@ class Item extends Controller {
if($parent_item) {
$acl->set($parent_item);
- $private = intval($acl->is_private() || $parent_item['item_private']);
- $public_policy = $parent_item['public_policy'];
- $owner_hash = $parent_item['owner_xchan'];
- $webpage = $parent_item['item_type'];
+ $private = intval($parent_item['item_private']);
+ $public_policy = $parent_item['public_policy'];
+ $owner_hash = $parent_item['owner_xchan'];
+ $webpage = $parent_item['item_type'];
}
if((! $allow_empty) && (! strlen($body))) {
diff --git a/Zotlabs/Module/Magic.php b/Zotlabs/Module/Magic.php
index b4372e26d..bfd38d2fa 100644
--- a/Zotlabs/Module/Magic.php
+++ b/Zotlabs/Module/Magic.php
@@ -40,7 +40,7 @@ class Magic extends Controller {
goaway($dest);
}
- $basepath = $parsed['scheme'] . '://' . $parsed['host'] . (($parsed['port']) ? ':' . $parsed['port'] : '');
+ $basepath = $parsed['scheme'] . '://' . $parsed['host'] . (isset($parsed['port']) ? ':' . $parsed['port'] : '');
$owapath = SConfig::get($basepath,'system','openwebauth', $basepath . '/owa');
// This is ready-made for a plugin that provides a blacklist or "ask me" before blindly authenticating.
@@ -110,6 +110,7 @@ class Magic extends Controller {
$headers['(request-target)'] = 'post ' . '/owa';
$headers = HTTPSig::create_sig($headers,$channel['channel_prvkey'], channel_url($channel),true,'sha512');
+ $redirects = 0;
$x = z_post_url($owapath,$data,$redirects,[ 'headers' => $headers ]);
logger('owa fetch returned: ' . print_r($x,true),LOGGER_DATA);
if ($x['success']) {
diff --git a/Zotlabs/Module/Manage.php b/Zotlabs/Module/Manage.php
index 20d5b0449..bc2034b95 100644
--- a/Zotlabs/Module/Manage.php
+++ b/Zotlabs/Module/Manage.php
@@ -5,18 +5,18 @@ namespace Zotlabs\Module;
class Manage extends \Zotlabs\Web\Controller {
function get() {
-
+
if((! get_account_id()) || ($_SESSION['delegate'])) {
notice( t('Permission denied.') . EOL);
return;
}
nav_set_selected('Channel Manager', 'settings/manage');
-
+
require_once('include/security.php');
-
+
$change_channel = ((argc() > 1) ? intval(argv(1)) : 0);
-
+
if((argc() > 2) && (argv(2) === 'default')) {
$r = q("select channel_id from channel where channel_id = %d and channel_account_id = %d limit 1",
intval($change_channel),
@@ -31,7 +31,7 @@ class Manage extends \Zotlabs\Web\Controller {
goaway(z_root() . '/manage');
}
-
+
if($change_channel) {
$r = change_channel($change_channel);
@@ -45,29 +45,29 @@ class Manage extends \Zotlabs\Web\Controller {
}
goaway(z_root());
}
-
+
$channels = null;
-
+
$r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel.channel_account_id = %d and channel_removed = 0 order by channel_name ",
intval(get_account_id())
);
-
+
$account = \App::get_account();
-
+
if($r && count($r)) {
$channels = $r;
for($x = 0; $x < count($channels); $x ++) {
$channels[$x]['link'] = 'manage/' . intval($channels[$x]['channel_id']);
- $channels[$x]['default'] = (($channels[$x]['channel_id'] == $account['account_default_channel']) ? "1" : '');
+ $channels[$x]['default'] = (($channels[$x]['channel_id'] == $account['account_default_channel']) ? "1" : '');
$channels[$x]['default_links'] = '1';
-
-
+
+
$c = q("SELECT id, item_wall FROM item
WHERE item_unseen = 1 and uid = %d " . item_normal(),
intval($channels[$x]['channel_id'])
);
-
- if($c) {
+
+ if($c) {
foreach ($c as $it) {
if(intval($it['item_wall']))
$channels[$x]['home'] ++;
@@ -75,25 +75,25 @@ class Manage extends \Zotlabs\Web\Controller {
$channels[$x]['network'] ++;
}
}
-
-
+
+
$intr = 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_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ",
intval($channels[$x]['channel_id'])
);
-
+
if($intr)
$channels[$x]['intros'] = intval($intr[0]['total']);
-
-
+
+
$mails = q("SELECT count(id) as total from mail WHERE channel_id = %d AND mail_seen = 0 and from_xchan != '%s' ",
intval($channels[$x]['channel_id']),
dbesc($channels[$x]['channel_hash'])
);
-
+
if($mails)
$channels[$x]['mail'] = intval($mails[0]['total']);
-
-
+
+
$events = q("SELECT etype, dtstart, adjust FROM event
WHERE event.uid = %d AND dtstart < '%s' AND dtstart > '%s' and dismissed = 0
ORDER BY dtstart ASC ",
@@ -101,7 +101,7 @@ class Manage extends \Zotlabs\Web\Controller {
dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + 7 days')),
dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days'))
);
-
+
if($events) {
$channels[$x]['all_events'] = count($events);
@@ -128,7 +128,7 @@ class Manage extends \Zotlabs\Web\Controller {
}
}
- }
+ }
$r = q("select count(channel_id) as total from channel where channel_account_id = %d and channel_removed = 0",
intval(get_account_id())
@@ -140,23 +140,23 @@ class Manage extends \Zotlabs\Web\Controller {
else {
$channel_usage_message = '';
}
-
-
+
+
$create = array( 'new_channel', t('Create a new channel'), t('Create New'));
-
+
$delegates = null;
if(local_channel()) {
- $delegates = q("select * from abook left join xchan on abook_xchan = xchan_hash where
+ $delegates = q("select * from abook left join xchan on abook_xchan = xchan_hash where
abook_channel = %d and abook_xchan in ( select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'delegate' and v = '1' )",
intval(local_channel()),
intval(local_channel())
);
}
-
+
if($delegates) {
for($x = 0; $x < count($delegates); $x ++) {
- $delegates[$x]['link'] = 'magic?f=&bdest=' . bin2hex($delegates[$x]['xchan_url'])
+ $delegates[$x]['link'] = 'magic?f=&bdest=' . bin2hex($delegates[$x]['xchan_url'] . '?zid=' . get_my_address() . '&delegate=' . urlencode($delegates[$x]['xchan_addr']))
. '&delegate=' . urlencode($delegates[$x]['xchan_addr']);
$delegates[$x]['channel_name'] = $delegates[$x]['xchan_name'];
$delegates[$x]['delegate'] = 1;
@@ -165,7 +165,7 @@ class Manage extends \Zotlabs\Web\Controller {
else {
$delegates = null;
}
-
+
$o = replace_macros(get_markup_template('channels.tpl'), array(
'$header' => t('Channel Manager'),
'$msg_selected' => t('Current Channel'),
@@ -181,9 +181,9 @@ class Manage extends \Zotlabs\Web\Controller {
'$delegated_desc' => t('Delegated Channel'),
'$delegates' => $delegates
));
-
+
return $o;
-
+
}
-
+
}
diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php
index 099289c03..e62accb06 100644
--- a/Zotlabs/Module/Photos.php
+++ b/Zotlabs/Module/Photos.php
@@ -876,7 +876,7 @@ class Photos extends \Zotlabs\Web\Controller {
$prevlink = '';
$nextlink = '';
- if($_GET['order'] === 'posted')
+ if(isset($_GET['order']) && $_GET['order'] === 'posted')
$order = 'ASC';
else
$order = 'DESC';
@@ -901,8 +901,8 @@ class Photos extends \Zotlabs\Web\Controller {
}
}
- $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' : '');
+ $prevlink = z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/image/' . $prvnxt[$prv]['hash'] . (($order == 'ASC') ? '?f=&order=posted' : '');
+ $nextlink = z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/image/' . $prvnxt[$nxt]['hash'] . (($order == 'ASC') ? '?f=&order=posted' : '');
}
@@ -987,7 +987,7 @@ class Photos extends \Zotlabs\Web\Controller {
}
$tags = array();
- if($link_item['term']) {
+ if(x($link_item, 'term')) {
$cnt = 0;
foreach($link_item['term'] as $t) {
$tags[$cnt] = array(0 => format_term_for_display($t));
diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php
index 113f0a196..9c63c735d 100644
--- a/Zotlabs/Module/Pubstream.php
+++ b/Zotlabs/Module/Pubstream.php
@@ -197,7 +197,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
if($update) {
- $ordering = "commented";
+ $ordering = get_config('system', 'pubstream_ordering', 'commented');
if($load) {
if($mid) {
diff --git a/Zotlabs/Module/Removeme.php b/Zotlabs/Module/Removeme.php
index 876d61ca6..a0697675b 100644
--- a/Zotlabs/Module/Removeme.php
+++ b/Zotlabs/Module/Removeme.php
@@ -5,54 +5,54 @@ namespace Zotlabs\Module;
class Removeme extends \Zotlabs\Web\Controller {
function post() {
-
+
if(! local_channel())
return;
-
+
if($_SESSION['delegate'])
return;
-
+
if((! x($_POST,'qxz_password')) || (! strlen(trim($_POST['qxz_password']))))
return;
-
+
if((! x($_POST,'verify')) || (! strlen(trim($_POST['verify']))))
return;
-
+
if($_POST['verify'] !== $_SESSION['remove_account_verify'])
return;
-
-
+
+
$account = \App::get_account();
-
-
+
+
$x = account_verify_password($account['account_email'],$_POST['qxz_password']);
if(! ($x && $x['account']))
return;
-
+
if($account['account_password_changed'] > NULL_DATE) {
$d1 = datetime_convert('UTC','UTC','now - 48 hours');
- if($account['account_password_changed'] > d1) {
+ if($account['account_password_changed'] > $d1) {
notice( t('Channel removals are not allowed within 48 hours of changing the account password.') . EOL);
return;
}
}
-
+
$global_remove = 0; //intval($_POST['global']);
channel_remove(local_channel(),1 - $global_remove,true);
-
+
}
-
-
+
+
function get() {
-
+
if(! local_channel())
goaway(z_root());
-
+
$hash = random_string();
-
+
$_SESSION['remove_account_verify'] = $hash;
-
+
$tpl = get_markup_template('removeme.tpl');
$o .= replace_macros($tpl, array(
'$basedir' => z_root(),
@@ -63,9 +63,9 @@ class Removeme extends \Zotlabs\Web\Controller {
// '$global' => [ 'global', t('Remove this channel and all its clones from the network'), false, t('By default only the instance of the channel located on this hub will be removed from the network'), [ t('No'),t('Yes') ] ],
'$submit' => t('Remove Channel')
));
-
- return $o;
-
+
+ return $o;
+
}
-
+
}
diff --git a/Zotlabs/Module/Sse.php b/Zotlabs/Module/Sse.php
index 8bea65207..6f3df299f 100644
--- a/Zotlabs/Module/Sse.php
+++ b/Zotlabs/Module/Sse.php
@@ -108,7 +108,8 @@ class Sse extends Controller {
echo 'data: {}';
echo "\n\n";
- ob_end_flush();
+ if(ob_get_length() > 0)
+ ob_end_flush();
flush();
if(connection_status() != CONNECTION_NORMAL || connection_aborted()) {
diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php
index cc67c8eb7..109b043ad 100644
--- a/Zotlabs/Module/Sse_bs.php
+++ b/Zotlabs/Module/Sse_bs.php
@@ -144,11 +144,15 @@ class Sse_bs extends Controller {
$result['network']['notifications'] = [];
$result['network']['count'] = 0;
- if(! self::$uid)
+ if(! self::$uid) {
+ $result['network']['offset'] = -1;
return $result;
+ }
- if(! (self::$vnotify & VNOTIFY_NETWORK))
+ if(! (self::$vnotify & VNOTIFY_NETWORK)) {
+ $result['network']['offset'] = -1;
return $result;
+ }
$limit = intval(self::$limit);
$offset = self::$offset;
@@ -216,11 +220,15 @@ class Sse_bs extends Controller {
$result['dm']['notifications'] = [];
$result['dm']['count'] = 0;
- if(! self::$uid)
+ if(! self::$uid) {
+ $result['dm']['offset'] = -1;
return $result;
+ }
- if(! (self::$vnotify & VNOTIFY_MAIL))
+ if(! (self::$vnotify & VNOTIFY_MAIL)) {
+ $result['dm']['offset'] = -1;
return $result;
+ }
$limit = intval(self::$limit);
$offset = self::$offset;
@@ -287,11 +295,15 @@ class Sse_bs extends Controller {
$result['home']['notifications'] = [];
$result['home']['count'] = 0;
- if(! self::$uid)
+ if(! self::$uid) {
+ $result['home']['offset'] = -1;
return $result;
+ }
- if(! (self::$vnotify & VNOTIFY_CHANNEL))
+ if(! (self::$vnotify & VNOTIFY_CHANNEL)) {
+ $result['home']['offset'] = -1;
return $result;
+ }
$limit = intval(self::$limit);
$offset = self::$offset;
@@ -359,15 +371,19 @@ class Sse_bs extends Controller {
$result['pubs']['notifications'] = [];
$result['pubs']['count'] = 0;
- if(! (self::$vnotify & VNOTIFY_PUBS))
+ if(! (self::$vnotify & VNOTIFY_PUBS)) {
+ $result['pubs']['offset'] = -1;
return $result;
+ }
if((observer_prohibited(true))) {
+ $result['pubs']['offset'] = -1;
return $result;
}
if(! intval(get_config('system','open_pubstream',1))) {
if(! get_observer_hash()) {
+ $result['pubs']['offset'] = -1;
return $result;
}
}