aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r--Zotlabs/Module/Acl.php3
-rw-r--r--Zotlabs/Module/Activity.php175
-rw-r--r--Zotlabs/Module/Channel.php1
-rw-r--r--Zotlabs/Module/Dircensor.php52
-rw-r--r--Zotlabs/Module/Directory.php43
-rw-r--r--Zotlabs/Module/Dirsearch.php54
-rw-r--r--Zotlabs/Module/Display.php1
-rw-r--r--Zotlabs/Module/Event.php76
-rw-r--r--Zotlabs/Module/Hq.php1
-rw-r--r--Zotlabs/Module/Item.php2
-rw-r--r--Zotlabs/Module/Like.php9
-rw-r--r--Zotlabs/Module/Mail.php449
-rw-r--r--Zotlabs/Module/Network.php6
-rw-r--r--Zotlabs/Module/Pubstream.php10
-rw-r--r--Zotlabs/Module/Search.php1
-rw-r--r--Zotlabs/Module/Sse_bs.php2
16 files changed, 389 insertions, 496 deletions
diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php
index 82c156a9c..e0206bd43 100644
--- a/Zotlabs/Module/Acl.php
+++ b/Zotlabs/Module/Acl.php
@@ -42,7 +42,7 @@ class Acl extends \Zotlabs\Web\Controller {
// $type =
- // 'm' => autocomplete private mail recipient (checks post_mail permission)
+ // 'm' => autocomplete private mail recipient (checks post_mail permission and displays only zot, diaspora, friendica-over-diaspora xchan_network xchan's)
// '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.
@@ -286,6 +286,7 @@ class Acl extends \Zotlabs\Web\Controller {
FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_channel = %d
and xchan_deleted = 0
+ and xchan_network IN ('zot', 'diaspora', 'friendica-over-diaspora')
$sql_extra3
ORDER BY xchan_name ASC ",
intval(local_channel())
diff --git a/Zotlabs/Module/Activity.php b/Zotlabs/Module/Activity.php
new file mode 100644
index 000000000..93b5a15fc
--- /dev/null
+++ b/Zotlabs/Module/Activity.php
@@ -0,0 +1,175 @@
+<?php
+namespace Zotlabs\Module;
+
+use Zotlabs\Lib\IConfig;
+use Zotlabs\Lib\Enotify;
+use Zotlabs\Web\Controller;
+use Zotlabs\Daemon\Master;
+use Zotlabs\Lib\Activity as ZlibActivity;
+use Zotlabs\Lib\ActivityStreams;
+use Zotlabs\Lib\LDSignatures;
+use Zotlabs\Web\HTTPSig;
+use Zotlabs\Lib\Libzot;
+use Zotlabs\Lib\ThreadListener;
+use App;
+
+
+class Activity extends Controller {
+
+ function init() {
+
+ if (Libzot::is_zot_request()) {
+
+ $item_id = argv(1);
+
+ if (! $item_id)
+ http_status_exit(404, 'Not found');
+
+ $portable_id = EMPTY_STR;
+
+ $item_normal = " and item.item_hidden = 0 and item.item_type = 0 and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_blocked = 0 ";
+
+ $i = null;
+
+ // do we have the item (at all)?
+
+ $r = q("select * from item where mid = '%s' $item_normal limit 1",
+ dbesc(z_root() . '/activity/' . $item_id)
+ );
+
+ if (! $r) {
+ http_status_exit(404,'Not found');
+ }
+
+ // process an authenticated fetch
+
+ $sigdata = HTTPSig::verify(EMPTY_STR);
+ if($sigdata['portable_id'] && $sigdata['header_valid']) {
+ $portable_id = $sigdata['portable_id'];
+ observer_auth($portable_id);
+
+ // first see if we have a copy of this item's parent owned by the current signer
+ // include xchans for all zot-like networks - these will have the same guid and public key
+
+ $x = q("select * from xchan where xchan_hash = '%s'",
+ dbesc($sigdata['portable_id'])
+ );
+
+ if ($x) {
+ $xchans = q("select xchan_hash from xchan where xchan_hash = '%s' OR ( xchan_guid = '%s' AND xchan_pubkey = '%s' ) ",
+ dbesc($sigdata['portable_id']),
+ dbesc($x[0]['xchan_guid']),
+ dbesc($x[0]['xchan_pubkey'])
+ );
+
+ if ($xchans) {
+ $hashes = ids_to_querystr($xchans,'xchan_hash',true);
+ $i = q("select id as item_id from item where mid = '%s' $item_normal and owner_xchan in ( " . protect_sprintf($hashes) . " ) limit 1",
+ dbesc($r[0]['parent_mid'])
+ );
+ }
+ }
+ }
+
+ // if we don't have a parent id belonging to the signer see if we can obtain one as a visitor that we have permission to access
+ // with a bias towards those items owned by channels on this site (item_wall = 1)
+
+ $sql_extra = item_permissions_sql(0);
+
+ if (! $i) {
+ $i = q("select id as item_id from item where mid = '%s' $item_normal $sql_extra order by item_wall desc limit 1",
+ dbesc($r[0]['parent_mid'])
+ );
+ }
+
+ if(! $i) {
+ http_status_exit(403,'Forbidden');
+ }
+
+ $parents_str = ids_to_querystr($i,'item_id');
+
+ $items = q("SELECT item.*, item.id AS item_id FROM item WHERE item.parent IN ( %s ) $item_normal ",
+ dbesc($parents_str)
+ );
+
+ if(! $items) {
+ http_status_exit(404, 'Not found');
+ }
+
+ xchan_query($items,true);
+ $items = fetch_post_tags($items,true);
+
+ $observer = App::get_observer();
+ $parent = $items[0];
+ $recips = (($parent['owner']['xchan_network'] === 'activitypub') ? get_iconfig($parent['id'],'activitypub','recips', []) : []);
+ $to = (($recips && array_key_exists('to',$recips) && is_array($recips['to'])) ? $recips['to'] : null);
+ $nitems = [];
+ foreach($items as $i) {
+
+ $mids = [];
+
+ if(intval($i['item_private'])) {
+ if(! $observer) {
+ continue;
+ }
+ // ignore private reshare, possibly from hubzilla
+ if($i['verb'] === 'Announce') {
+ if(! in_array($i['thr_parent'],$mids)) {
+ $mids[] = $i['thr_parent'];
+ }
+ continue;
+ }
+ // also ignore any children of the private reshares
+ if(in_array($i['thr_parent'],$mids)) {
+ continue;
+ }
+
+ if((! $to) || (! in_array($observer['xchan_url'],$to))) {
+ continue;
+ }
+
+ }
+ $nitems[] = $i;
+ }
+
+ if(! $nitems)
+ http_status_exit(404, 'Not found');
+
+ $chan = channelx_by_n($nitems[0]['uid']);
+
+ if(! $chan)
+ http_status_exit(404, 'Not found');
+
+ if(! perm_is_allowed($chan['channel_id'],get_observer_hash(),'view_stream'))
+ http_status_exit(403, 'Forbidden');
+
+ $i = ZlibActivity::encode_item_collection($nitems,'conversation/' . $item_id,'OrderedCollection');
+ if($portable_id) {
+ ThreadListener::store(z_root() . '/activity/' . $item_id,$portable_id);
+ }
+
+ if(! $i)
+ http_status_exit(404, 'Not found');
+
+ $x = array_merge(['@context' => [
+ ACTIVITYSTREAMS_JSONLD_REV,
+ 'https://w3id.org/security/v1',
+ z_root() . ZOT_APSCHEMA_REV
+ ]], $i);
+
+ $headers = [];
+ $headers['Content-Type'] = 'application/x-zot+json' ;
+ $x['signature'] = LDSignatures::sign($x,$chan);
+ $ret = json_encode($x, JSON_UNESCAPED_SLASHES);
+ $headers['Digest'] = HTTPSig::generate_digest_header($ret);
+ $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI'];
+ $h = HTTPSig::create_sig($headers,$chan['channel_prvkey'],channel_url($chan));
+ HTTPSig::set_headers($h);
+ echo $ret;
+ killme();
+
+ }
+
+ }
+
+}
diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php
index 5529db70e..170b81787 100644
--- a/Zotlabs/Module/Channel.php
+++ b/Zotlabs/Module/Channel.php
@@ -419,6 +419,7 @@ class Channel extends Controller {
'$nouveau' => '0',
'$wall' => '1',
'$fh' => '0',
+ '$dm' => '0',
'$static' => $static,
'$page' => ((App::$pager['page'] != 1) ? App::$pager['page'] : 1),
'$search' => $search,
diff --git a/Zotlabs/Module/Dircensor.php b/Zotlabs/Module/Dircensor.php
new file mode 100644
index 000000000..0fa65e948
--- /dev/null
+++ b/Zotlabs/Module/Dircensor.php
@@ -0,0 +1,52 @@
+<?php
+
+namespace Zotlabs\Module;
+
+use App;
+use Zotlabs\Web\Controller;
+
+
+class Dircensor extends Controller {
+
+ function get() {
+ if(! is_site_admin()) {
+ return;
+ }
+
+ $dirmode = intval(get_config('system','directory_mode'));
+
+ if (! ($dirmode == DIRECTORY_MODE_PRIMARY || $dirmode == DIRECTORY_MODE_STANDALONE)) {
+ return;
+ }
+
+ $xchan = argv(1);
+ if(! $xchan) {
+ return;
+ }
+
+ $r = q("select * from xchan where xchan_hash = '%s'",
+ dbesc($xchan)
+ );
+
+ if(! $r) {
+ return;
+ }
+
+ $val = (($r[0]['xchan_censored']) ? 0 : 1);
+
+ q("update xchan set xchan_censored = $val where xchan_hash = '%s'",
+ dbesc($xchan)
+ );
+
+ if($val) {
+ info( t('Entry censored') . EOL);
+ }
+ else {
+ info( t('Entry uncensored') . EOL);
+ }
+
+ goaway(z_root() . '/directory');
+
+ }
+
+}
diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php
index dee22721d..3eafd9f71 100644
--- a/Zotlabs/Module/Directory.php
+++ b/Zotlabs/Module/Directory.php
@@ -2,15 +2,19 @@
namespace Zotlabs\Module;
+use App;
+use Zotlabs\Web\Controller;
+
require_once('include/socgraph.php');
require_once('include/dir_fns.php');
require_once('include/bbcode.php');
+require_once('include/html2plain.php');
-class Directory extends \Zotlabs\Web\Controller {
+class Directory extends Controller {
function init() {
- \App::set_pager_itemspage(60);
+ App::set_pager_itemspage(60);
if(local_channel() && x($_GET,'ignore')) {
q("insert into xign ( uid, xchan ) values ( %d, '%s' ) ",
@@ -21,7 +25,7 @@ class Directory extends \Zotlabs\Web\Controller {
}
if(local_channel())
- \App::$profile_uid = local_channel();
+ App::$profile_uid = local_channel();
$observer = get_observer_hash();
$global_changed = false;
@@ -140,9 +144,15 @@ class Directory extends \Zotlabs\Web\Controller {
$dirmode = intval(get_config('system','directory_mode'));
+ $directory_admin = false;
+
if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
$url = z_root() . '/dirsearch';
- }
+ if (is_site_admin()) {
+ $directory_admin = true;
+ }
+ }
+
if(! $url) {
$directory = find_upstream_directory($dirmode);
if((! $directory) || (! array_key_exists('url',$directory)) || (! $directory['url']))
@@ -182,7 +192,7 @@ class Directory extends \Zotlabs\Web\Controller {
$query .= '&t=' . $token;
if(! $globaldir)
- $query .= '&hub=' . \App::get_hostname();
+ $query .= '&hub=' . App::get_hostname();
if($search)
$query .= '&name=' . urlencode($search) . '&keywords=' . urlencode($search);
@@ -204,8 +214,8 @@ class Directory extends \Zotlabs\Web\Controller {
if($sort_order)
$query .= '&order=' . urlencode($sort_order);
- if(\App::$pager['page'] != 1)
- $query .= '&p=' . \App::$pager['page'];
+ if(App::$pager['page'] != 1)
+ $query .= '&p=' . App::$pager['page'];
logger('mod_directory: query: ' . $query);
@@ -283,12 +293,15 @@ class Directory extends \Zotlabs\Web\Controller {
$marital = ((x($profile,'marital') == 1) ? t('Status: ') . $profile['marital']: False);
$homepage = ((x($profile,'homepage') == 1) ? t('Homepage: ') : False);
- $homepageurl = ((x($profile,'homepage') == 1) ? $profile['homepage'] : '');
-
- $hometown = ((x($profile,'hometown') == 1) ? $profile['hometown'] : False);
+ $homepageurl = ((x($profile,'homepage') == 1) ? html2plain($profile['homepage']) : '');
- $about = ((x($profile,'about') == 1) ? zidify_links(bbcode($profile['about'])) : False);
+ $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'] : '');
@@ -343,9 +356,11 @@ class Directory extends \Zotlabs\Web\Controller {
'canrate' => (($rating_enabled && local_channel()) ? true : false),
'pdesc' => $pdesc,
'pdesc_label' => t('Description:'),
+ 'censor' => (($directory_admin) ? 'dircensor/' . $rr['hash'] : ''),
+ 'censor_label' => (($rr['censored']) ? t('Uncensor') : t('Censor')),
'marital' => $marital,
'homepage' => $homepage,
- 'homepageurl' => linkify($homepageurl, true),
+ 'homepageurl' => (($safe_mode) ? $homepageurl : linkify($homepageurl)),
'hometown' => $hometown,
'hometown_label' => t('Hometown:'),
'about' => $about,
@@ -387,7 +402,7 @@ class Directory extends \Zotlabs\Web\Controller {
ksort($entries); // Sort array by key so that foreach-constructs work as expected
if($j['keywords']) {
- \App::$data['directory_keywords'] = $j['keywords'];
+ App::$data['directory_keywords'] = $j['keywords'];
}
logger('mod_directory: entries: ' . print_r($entries,true), LOGGER_DATA);
@@ -438,7 +453,7 @@ class Directory extends \Zotlabs\Web\Controller {
echo $o;
killme();
}
- if(\App::$pager['page'] == 1 && $j['records'] == 0 && strpos($search,'@')) {
+ if(App::$pager['page'] == 1 && $j['records'] == 0 && strpos($search,'@')) {
goaway(z_root() . '/chanview/?f=&address=' . $search);
}
info( t("No entries (some entries may be hidden).") . EOL);
diff --git a/Zotlabs/Module/Dirsearch.php b/Zotlabs/Module/Dirsearch.php
index 92b33df0c..62af75f4c 100644
--- a/Zotlabs/Module/Dirsearch.php
+++ b/Zotlabs/Module/Dirsearch.php
@@ -1,14 +1,17 @@
<?php
namespace Zotlabs\Module;
+use App;
+use Zotlabs\Web\Controller;
+
require_once('include/dir_fns.php');
-class Dirsearch extends \Zotlabs\Web\Controller {
+class Dirsearch extends Controller {
function init() {
- \App::set_pager_itemspage(60);
+ App::set_pager_itemspage(60);
}
@@ -25,7 +28,8 @@ class Dirsearch extends \Zotlabs\Web\Controller {
$ret['message'] = t('This site is not a directory server');
json_return_and_die($ret);
}
-
+
+
$access_token = $_REQUEST['t'];
$token = get_config('system','realm_token');
@@ -286,29 +290,29 @@ class Dirsearch extends \Zotlabs\Web\Controller {
else
$entry['total_ratings'] = 0;
- $entry['name'] = $rr['xchan_name'];
- $entry['hash'] = $rr['xchan_hash'];
-
+ $entry['name'] = $rr['xchan_name'];
+ $entry['hash'] = $rr['xchan_hash'];
+ $entry['censored'] = $rr['xchan_censored'];
+ $entry['selfcensored'] = $rr['xchan_selfcensored'];
$entry['public_forum'] = (intval($rr['xchan_pubforum']) ? true : false);
-
- $entry['url'] = $rr['xchan_url'];
- $entry['photo_l'] = $rr['xchan_photo_l'];
- $entry['photo'] = $rr['xchan_photo_m'];
- $entry['address'] = $rr['xchan_addr'];
- $entry['description'] = $rr['xprof_desc'];
- $entry['locale'] = $rr['xprof_locale'];
- $entry['region'] = $rr['xprof_region'];
- $entry['postcode'] = $rr['xprof_postcode'];
- $entry['country'] = $rr['xprof_country'];
- $entry['birthday'] = $rr['xprof_dob'];
- $entry['age'] = $rr['xprof_age'];
- $entry['gender'] = $rr['xprof_gender'];
- $entry['marital'] = $rr['xprof_marital'];
- $entry['sexual'] = $rr['xprof_sexual'];
- $entry['about'] = $rr['xprof_about'];
- $entry['homepage'] = $rr['xprof_homepage'];
- $entry['hometown'] = $rr['xprof_hometown'];
- $entry['keywords'] = $rr['xprof_keywords'];
+ $entry['url'] = $rr['xchan_url'];
+ $entry['photo_l'] = $rr['xchan_photo_l'];
+ $entry['photo'] = $rr['xchan_photo_m'];
+ $entry['address'] = $rr['xchan_addr'];
+ $entry['description'] = $rr['xprof_desc'];
+ $entry['locale'] = $rr['xprof_locale'];
+ $entry['region'] = $rr['xprof_region'];
+ $entry['postcode'] = $rr['xprof_postcode'];
+ $entry['country'] = $rr['xprof_country'];
+ $entry['birthday'] = $rr['xprof_dob'];
+ $entry['age'] = $rr['xprof_age'];
+ $entry['gender'] = $rr['xprof_gender'];
+ $entry['marital'] = $rr['xprof_marital'];
+ $entry['sexual'] = $rr['xprof_sexual'];
+ $entry['about'] = $rr['xprof_about'];
+ $entry['homepage'] = $rr['xprof_homepage'];
+ $entry['hometown'] = $rr['xprof_hometown'];
+ $entry['keywords'] = $rr['xprof_keywords'];
$entries[] = $entry;
diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php
index cf38aba1a..777d183e1 100644
--- a/Zotlabs/Module/Display.php
+++ b/Zotlabs/Module/Display.php
@@ -224,6 +224,7 @@ class Display extends \Zotlabs\Web\Controller {
'$conv' => '0',
'$spam' => '0',
'$fh' => '0',
+ '$dm' => '0',
'$nouveau' => '0',
'$wall' => '0',
'$static' => $static,
diff --git a/Zotlabs/Module/Event.php b/Zotlabs/Module/Event.php
new file mode 100644
index 000000000..22a1341cc
--- /dev/null
+++ b/Zotlabs/Module/Event.php
@@ -0,0 +1,76 @@
+<?php
+namespace Zotlabs\Module;
+
+use Zotlabs\Web\Controller;
+use Zotlabs\Lib\ActivityStreams;
+use Zotlabs\Lib\Activity;
+use Zotlabs\Lib\LDSignatures;
+use Zotlabs\Web\HTTPSig;
+
+class Event extends Controller {
+
+ function init() {
+
+ if(ActivityStreams::is_as_request()) {
+ $item_id = argv(1);
+
+ if(! $item_id)
+ return;
+
+ $item_normal = " and item.item_hidden = 0 and item.item_type = 0 and item.item_unpublished = 0
+ and item.item_delayed = 0 and item.item_blocked = 0 ";
+
+ $sql_extra = item_permissions_sql(0);
+
+ $r = q("select * from item where mid like '%s' $item_normal $sql_extra limit 1",
+ dbesc(z_root() . '/activity/' . $item_id . '%')
+ );
+
+ if(! $r) {
+ $r = q("select * from item where mid like '%s' $item_normal limit 1",
+ dbesc(z_root() . '/activity/' . $item_id . '%')
+ );
+
+ if($r) {
+ http_status_exit(403, 'Forbidden');
+ }
+ http_status_exit(404, 'Not found');
+ }
+
+ xchan_query($r,true);
+ $items = fetch_post_tags($r,true);
+
+ $channel = channelx_by_n($items[0]['uid']);
+
+ if(! is_array($items[0]['obj'])) {
+ $obj = json_decode($items[0]['obj'],true);
+ }
+ else {
+ $obj = $items[0]['obj'];
+ }
+
+ $x = array_merge(['@context' => [
+ ACTIVITYSTREAMS_JSONLD_REV,
+ 'https://w3id.org/security/v1',
+ z_root() . ZOT_APSCHEMA_REV
+ ]], $obj );
+
+ $headers = [];
+ $headers['Content-Type'] = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' ;
+ $x['signature'] = LDSignatures::sign($x,$channel);
+ $ret = json_encode($x, JSON_UNESCAPED_SLASHES);
+ $headers['Date'] = datetime_convert('UTC','UTC', 'now', 'D, d M Y H:i:s \\G\\M\\T');
+ $headers['Digest'] = HTTPSig::generate_digest_header($ret);
+ $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI'];
+
+ $h = HTTPSig::create_sig($headers,$channel['channel_prvkey'],channel_url($channel));
+ HTTPSig::set_headers($h);
+
+ echo $ret;
+ killme();
+
+ }
+
+ }
+
+} \ No newline at end of file
diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php
index d8c540fb9..5b331f4c1 100644
--- a/Zotlabs/Module/Hq.php
+++ b/Zotlabs/Module/Hq.php
@@ -179,6 +179,7 @@ class Hq extends \Zotlabs\Web\Controller {
'$conv' => '0',
'$spam' => '0',
'$fh' => '0',
+ '$dm' => '0',
'$nouveau' => '0',
'$wall' => '0',
'$static' => $static,
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php
index 14881844d..1a25e54df 100644
--- a/Zotlabs/Module/Item.php
+++ b/Zotlabs/Module/Item.php
@@ -42,8 +42,6 @@ class Item extends Controller {
if (Libzot::is_zot_request()) {
- $conversation = false;
-
$item_id = argv(1);
if (! $item_id)
diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php
index 052d51d43..e4636a4a6 100644
--- a/Zotlabs/Module/Like.php
+++ b/Zotlabs/Module/Like.php
@@ -75,7 +75,12 @@ class Like extends \Zotlabs\Web\Controller {
return EMPTY_STR;
}
-
+ $is_rsvp = false;
+ if (in_array($activity, [ ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE ])) {
+ $is_rsvp = true;
+ }
+
+
$extended_like = false;
$object = $target = null;
$post_type = EMPTY_STR;
@@ -381,7 +386,7 @@ class Like extends \Zotlabs\Web\Controller {
$arr = array();
$arr['uuid'] = $uuid;
- $arr['mid'] = z_root() . '/item/' . $uuid;
+ $arr['mid'] = z_root() . (($is_rsvp) ? '/activity/' : '/item/') . $uuid;
if($extended_like) {
$arr['item_thread_top'] = 1;
diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php
deleted file mode 100644
index 636fc4e33..000000000
--- a/Zotlabs/Module/Mail.php
+++ /dev/null
@@ -1,449 +0,0 @@
-<?php
-namespace Zotlabs\Module;
-
-require_once('include/acl_selectors.php');
-require_once('include/message.php');
-require_once('include/zot.php');
-require_once("include/bbcode.php");
-
-
-
-
-class Mail extends \Zotlabs\Web\Controller {
-
- function post() {
-
- if(! local_channel())
- return;
-
- $replyto = ((x($_REQUEST,'replyto')) ? notags(trim($_REQUEST['replyto'])) : '');
- $subject = ((x($_REQUEST,'subject')) ? notags(trim($_REQUEST['subject'])) : '');
- $body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : '');
- $recipient = ((x($_REQUEST,'messageto')) ? notags(trim(urldecode($_REQUEST['messageto']))) : '');
- $rstr = ((x($_REQUEST,'messagerecip')) ? notags(trim($_REQUEST['messagerecip'])) : '');
- $preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0);
- $expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE);
- $raw = ((x($_REQUEST,'raw')) ? intval($_REQUEST['raw']) : 0);
- $mimetype = ((x($_REQUEST,'mimetype')) ? notags(trim($_REQUEST['mimetype'])) : 'text/bbcode');
-
- $sig = ((x($_REQUEST,'signature')) ? trim($_REQUEST['signature']) : '');
- if(strpos($sig,'b64.') === 0)
- $sig = base64_decode(str_replace('b64.', '', $sig));
-
- if($preview) {
-
- if($raw) {
- $body = mail_prepare_binary(['id' => 'M0']);
- echo json_encode(['preview' => $body]);
- }
- else {
- $body = cleanup_bbcode($body);
- $results = linkify_tags($body, local_channel());
-
- if(preg_match_all('/(\[attachment\](.*?)\[\/attachment\])/',$body,$match)) {
- $attachments = array();
- foreach($match[2] as $mtch) {
- $hash = substr($mtch,0,strpos($mtch,','));
- $rev = intval(substr($mtch,strpos($mtch,',')));
- $r = attach_by_hash_nodata($hash,get_observer_hash(),$rev);
- if($r['success']) {
- $attachments[] = array(
- 'href' => z_root() . '/attach/' . $r['data']['hash'],
- 'length' => $r['data']['filesize'],
- 'type' => $r['data']['filetype'],
- 'title' => urlencode($r['data']['filename']),
- 'revision' => $r['data']['revision']
- );
- }
- $body = trim(str_replace($match[1],'',$body));
- }
- }
- echo json_encode(['preview' => zidify_links(smilies(bbcode($body)))]);
- }
- killme();
- }
-
- // If we have a raw string for a recipient which hasn't been auto-filled,
- // it means they probably aren't in our address book, hence we don't know
- // if we have permission to send them private messages.
- // finger them and find out before we try and send it.
-
- if(! $recipient) {
- $channel = \App::get_channel();
-
- $j = \Zotlabs\Zot\Finger::run(punify($rstr),$channel);
-
- if(! $j['success']) {
- notice( t('Unable to lookup recipient.') . EOL);
- return;
- }
-
- logger('message_post: lookup: ' . $rstr . ' ' . print_r($j,true));
-
- if(! $j['guid']) {
- notice( t('Unable to communicate with requested channel.'));
- return;
- }
-
- $x = import_xchan($j);
-
- if(! $x['success']) {
- notice( t('Cannot verify requested channel.'));
- return;
- }
-
- $recipient = $x['hash'];
-
- $their_perms = 0;
-
- if($j['permissions']['data']) {
- $permissions = crypto_unencapsulate($j['permissions'],$channel['channel_prvkey']);
- if($permissions)
- $permissions = json_decode($permissions, true);
- logger('decrypted permissions: ' . print_r($permissions,true), LOGGER_DATA);
- }
- else
- $permissions = $j['permissions'];
-
- if(! ($permissions['post_mail'])) {
- notice( t('Selected channel has private message restrictions. Send failed.'));
- // reported issue: let's still save the message and continue. We'll just tell them
- // that nothing useful is likely to happen. They might have spent hours on it.
- // return;
-
- }
- }
-
- require_once('include/text.php');
- linkify_tags($body, local_channel());
-
-
- if(! $recipient) {
- notice('No recipient found.');
- \App::$argc = 2;
- \App::$argv[1] = 'new';
- return;
- }
-
- // We have a local_channel, let send_message use the session channel and save a lookup
-
- $ret = send_message(0, $recipient, $body, $subject, $replyto, $expires, $mimetype, $raw, $sig);
-
- if($ret['success']) {
- xchan_mail_query($ret['mail']);
- build_sync_packet(0,array('conv' => array($ret['conv']),'mail' => array(encode_mail($ret['mail'],true))));
- }
- else {
- notice($ret['message']);
- }
-
- goaway(z_root() . '/mail/combined');
-
- }
-
- function get() {
-
- $o = '';
- nav_set_selected('Mail');
-
- if(! local_channel()) {
- notice( t('Permission denied.') . EOL);
- return login();
- }
-
- $channel = \App::get_channel();
-
- head_set_icon($channel['xchan_photo_s']);
-
- $cipher = get_pconfig(local_channel(),'system','default_cipher');
- if(! $cipher)
- $cipher = 'aes256';
-
- $tpl = get_markup_template('mail_head.tpl');
- $header = replace_macros($tpl, array(
- '$header' => t('Messages'),
- ));
-
- if(argc() == 3 && intval(argv(1)) && argv(2) === 'download') {
-
- $r = q("select * from mail where id = %d and channel_id = %d",
- intval(argv(1)),
- intval(local_channel())
- );
-
- if($r) {
-
- header('Content-type: ' . $r[0]['mail_mimetype']);
- header('Content-disposition: attachment; filename="' . t('message') . '-' . $r[0]['id'] . '"' );
- $body = (($r[0]['mail_obscured']) ? base64url_decode(str_rot47($r[0]['body'])) : $r[0]['body']);
- echo $body;
- killme();
- }
-
- }
-
-
- if((argc() == 4) && (argv(2) === 'drop')) {
- if(! intval(argv(3)))
- return;
- $cmd = argv(2);
- $mailbox = argv(1);
- $r = private_messages_drop(local_channel(), argv(3));
- if($r) {
- //info( t('Message deleted.') . EOL );
- }
- goaway(z_root() . '/mail/' . $mailbox);
- }
-
- if((argc() == 4) && (argv(2) === 'recall')) {
- if(! intval(argv(3)))
- return;
- $cmd = argv(2);
- $mailbox = argv(1);
- $r = q("update mail set mail_recalled = 1 where id = %d and channel_id = %d",
- intval(argv(3)),
- intval(local_channel())
- );
- $x = q("select * from mail where id = %d and channel_id = %d",
- intval(argv(3)),
- intval(local_channel())
- );
- if($x) {
- build_sync_packet(local_channel(),array('mail' => encode_mail($x[0],true)));
- }
-
- \Zotlabs\Daemon\Master::Summon(array('Notifier','mail',intval(argv(3))));
-
- if($r) {
- info( t('Message recalled.') . EOL );
- }
- goaway(z_root() . '/mail/' . $mailbox . '/' . argv(3));
-
- }
-
- if((argc() == 4) && (argv(2) === 'dropconv')) {
- if(! intval(argv(3)))
- return;
- $cmd = argv(2);
- $mailbox = argv(1);
- $r = private_messages_drop(local_channel(), argv(3), true);
- if($r)
- info( t('Conversation removed.') . EOL );
- goaway(z_root() . '/mail/' . $mailbox);
- }
-
- if((argc() > 1) && (argv(1) === 'new')) {
-
- $plaintext = true;
-
- $tpl = get_markup_template('msg-header.tpl');
-
- $header = replace_macros($tpl, array(
- '$baseurl' => z_root(),
- '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
- '$nickname' => $channel['channel_address'],
- '$linkurl' => t('Please enter a link URL:'),
- '$expireswhen' => t('Expires YYYY-MM-DD HH:MM')
- ));
-
- \App::$page['htmlhead'] .= $header;
-
- $prename = '';
- $preid = '';
-
- if(x($_REQUEST,'hash')) {
-
- $r = q("select abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash
- where abook_channel = %d and abook_xchan = '%s' limit 1",
- intval(local_channel()),
- dbesc($_REQUEST['hash'])
- );
-
- if(!$r) {
- $r = q("select * from xchan where xchan_hash = '%s' and xchan_network = 'zot' limit 1",
- dbesc($_REQUEST['hash'])
- );
- }
-
- if($r) {
- $prename = (($r[0]['abook_id']) ? $r[0]['xchan_name'] : $r[0]['xchan_addr']);
- $preurl = $r[0]['xchan_url'];
- $preid = (($r[0]['abook_id']) ? ($r[0]['xchan_hash']) : '');
- }
- else {
- notice( t('Requested channel is not in this network') . EOL );
- }
-
- }
-
- $tpl = get_markup_template('prv_message.tpl');
- $o .= replace_macros($tpl,array(
- '$new' => true,
- '$header' => t('Send Private Message'),
- '$to' => t('To:'),
- '$prefill' => $prename,
- '$preid' => $preid,
- '$subject' => t('Subject:'),
- '$subjtxt' => ((x($_REQUEST,'subject')) ? strip_tags($_REQUEST['subject']) : ''),
- '$text' => ((x($_REQUEST,'body')) ? htmlspecialchars($_REQUEST['body'], ENT_COMPAT, 'UTF-8') : ''),
- '$yourmessage' => t('Your message:'),
- '$parent' => '',
- '$attach' => t('Attach file'),
- '$insert' => t('Insert web link'),
- '$submit' => t('Send'),
- '$defexpire' => '',
- '$feature_expire' => ((feature_enabled(local_channel(),'content_expire')) ? true : false),
- '$expires' => t('Set expiration date'),
- '$feature_encrypt' => ((feature_enabled(local_channel(),'content_encrypt')) ? true : false),
- '$encrypt' => t('Encrypt text'),
- '$cipher' => $cipher,
- ));
-
- return $o;
- }
-
- $direct_mid = 0;
-
- switch(argv(1)) {
- case 'combined':
- $mailbox = 'combined';
- break;
- case 'inbox':
- $mailbox = 'inbox';
- break;
- case 'outbox':
- $mailbox = 'outbox';
- break;
- default:
- $mailbox = 'combined';
-
- // notifications direct to mail/nn
-
- if(intval(argv(1)))
- $direct_mid = intval(argv(1));
- break;
- }
-
-
- $last_message = private_messages_list(local_channel(), $mailbox, 0, 1);
-
- $mid = ((argc() > 2) && (intval(argv(2)))) ? argv(2) : $last_message[0]['id'];
-
- if($direct_mid)
- $mid = $direct_mid;
-
-
- $plaintext = true;
-
- // if( local_channel() && feature_enabled(local_channel(),'richtext') )
- // $plaintext = false;
-
-
-
- if($mailbox == 'combined') {
- $messages = private_messages_fetch_conversation(local_channel(), $mid, true);
- }
- else {
- $messages = private_messages_fetch_message(local_channel(), $mid, true);
- }
-
- if(! $messages) {
- //info( t('Message not found.') . EOL);
- return;
- }
-
- if($messages[0]['to_xchan'] === $channel['channel_hash'])
- \App::$poi = $messages[0]['from'];
- else
- \App::$poi = $messages[0]['to'];
-
- $tpl = get_markup_template('msg-header.tpl');
-
- \App::$page['htmlhead'] .= replace_macros($tpl, array(
- '$nickname' => $channel['channel_address'],
- '$baseurl' => z_root(),
- '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
- '$linkurl' => t('Please enter a link URL:'),
- '$expireswhen' => t('Expires YYYY-MM-DD HH:MM')
- ));
-
- $mails = array();
-
- $seen = 0;
- $unknown = false;
-
- foreach($messages as $message) {
-
- $s = theme_attachments($message);
-
- if($message['mail_raw'])
- $message['body'] = mail_prepare_binary([ 'id' => $message['id'] ]);
- else
- $message['body'] = zidify_links(smilies(bbcode($message['body'])));
-
- $mails[] = array(
- 'mailbox' => $mailbox,
- 'id' => $message['id'],
- 'mid' => $message['mid'],
- 'from_name' => $message['from']['xchan_name'],
- 'from_url' => chanlink_hash($message['from_xchan']),
- 'from_photo' => $message['from']['xchan_photo_s'],
- 'to_name' => $message['to']['xchan_name'],
- 'to_url' => chanlink_hash($message['to_xchan']),
- 'to_photo' => $message['to']['xchan_photo_s'],
- 'subject' => $message['title'],
- 'body' => $message['body'],
- 'attachments' => $s,
- 'delete' => t('Delete message'),
- 'dreport' => t('Delivery report'),
- 'recall' => t('Recall message'),
- 'can_recall' => ($channel['channel_hash'] == $message['from_xchan']),
- 'is_recalled' => (intval($message['mail_recalled']) ? t('Message has been recalled.') : ''),
- 'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'], 'c'),
- 'sig' => base64_encode($message['sig'])
- );
-
- $seen = $message['seen'];
-
- }
-
- $recp = (($message['from_xchan'] === $channel['channel_hash']) ? 'to' : 'from');
-
- $tpl = get_markup_template('mail_display.tpl');
- $o = replace_macros($tpl, array(
- '$mailbox' => $mailbox,
- '$prvmsg_header' => $message['title'],
- '$thread_id' => $mid,
- '$thread_subject' => $message['title'],
- '$thread_seen' => $seen,
- '$delete' => t('Delete Conversation'),
- '$canreply' => (($unknown) ? false : '1'),
- '$unknown_text' => t("No secure communications available. You <strong>may</strong> be able to respond from the sender's profile page."),
- '$mails' => $mails,
-
- // reply
- '$header' => t('Send Reply'),
- '$to' => t('To:'),
- '$reply' => true,
- '$subject' => t('Subject:'),
- '$subjtxt' => $message['title'],
- '$yourmessage' => sprintf(t('Your message for %s (%s):'), $message[$recp]['xchan_name'], $message[$recp]['xchan_addr']),
- '$text' => '',
- '$parent' => $message['parent_mid'],
- '$recphash' => $message[$recp]['xchan_hash'],
- '$attach' => t('Attach file'),
- '$insert' => t('Insert web link'),
- '$submit' => t('Submit'),
- '$defexpire' => '',
- '$feature_expire' => ((feature_enabled(local_channel(),'content_expire')) ? true : false),
- '$expires' => t('Set expiration date'),
- '$feature_encrypt' => ((feature_enabled(local_channel(),'content_encrypt')) ? true : false),
- '$encrypt' => t('Encrypt text'),
- '$cipher' => $cipher,
- ));
-
- return $o;
-
- }
-
-}
diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php
index 1c16e34ef..a8efd0d9e 100644
--- a/Zotlabs/Module/Network.php
+++ b/Zotlabs/Module/Network.php
@@ -69,6 +69,7 @@ class Network extends \Zotlabs\Web\Controller {
$category = ((x($_REQUEST,'cat')) ? $_REQUEST['cat'] : '');
$hashtags = ((x($_REQUEST,'tag')) ? $_REQUEST['tag'] : '');
$verb = ((x($_REQUEST,'verb')) ? $_REQUEST['verb'] : '');
+ $dm = ((x($_REQUEST,'dm')) ? $_REQUEST['dm'] : 0);
$order = get_pconfig(local_channel(), 'mod_network', 'order', 0);
@@ -363,6 +364,7 @@ class Network extends \Zotlabs\Web\Controller {
'$conv' => (($conv) ? $conv : '0'),
'$spam' => (($spam) ? $spam : '0'),
'$fh' => '0',
+ '$dm' => (($dm) ? $dm : '0'),
'$nouveau' => (($nouveau) ? $nouveau : '0'),
'$wall' => '0',
'$static' => $static,
@@ -418,6 +420,10 @@ class Network extends \Zotlabs\Web\Controller {
if(strlen($file)) {
$sql_extra .= term_query('item',$file,TERM_FILE);
}
+
+ if ($dm) {
+ $sql_extra .= " AND item_private = 2 ";
+ }
if($conv) {
$item_thread_top = '';
diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php
index 84ac42f72..92ef44696 100644
--- a/Zotlabs/Module/Pubstream.php
+++ b/Zotlabs/Module/Pubstream.php
@@ -62,6 +62,11 @@ class Pubstream extends \Zotlabs\Web\Controller {
$static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0);
$net = ((array_key_exists('net',$_REQUEST)) ? escape_tags($_REQUEST['net']) : '');
+ $title = replace_macros(get_markup_template("section_title.tpl"),array(
+ '$title' => (($hashtags) ? '#' . htmlspecialchars($hashtags, ENT_COMPAT,'UTF-8') : '')
+ ));
+
+ $o = (($hashtags) ? $title : '');
if(local_channel() && (! $update)) {
@@ -94,7 +99,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
'reset' => t('Reset form')
);
- $o = '<div id="jot-popup">';
+ $o .= '<div id="jot-popup">';
$o .= status_editor($a,$x,false,'Pubstream');
$o .= '</div>';
}
@@ -139,6 +144,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
'$conv' => '0',
'$spam' => '0',
'$fh' => '1',
+ '$dm' => '0',
'$nouveau' => '0',
'$wall' => '0',
'$list' => '0',
@@ -285,7 +291,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
}
// fake it
- $mode = ('pubstream');
+ $mode = (($hashtags) ? 'search' : 'pubstream');
$o .= conversation($items,$mode,$update,$page_mode);
diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php
index 214ece9a3..686afb2d2 100644
--- a/Zotlabs/Module/Search.php
+++ b/Zotlabs/Module/Search.php
@@ -128,6 +128,7 @@ class Search extends \Zotlabs\Web\Controller {
'$conv' => '0',
'$spam' => '0',
'$fh' => '0',
+ '$dm' => '0',
'$nouveau' => '0',
'$wall' => '0',
'$static' => $static,
diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php
index 4340876ea..90e870330 100644
--- a/Zotlabs/Module/Sse_bs.php
+++ b/Zotlabs/Module/Sse_bs.php
@@ -404,7 +404,7 @@ class Sse_bs extends Controller {
foreach($mids as $mid)
$b64mids[] = 'b64.' . base64url_encode($mid);
- $forums[$x]['notify_link'] = (($forums[$x]['private_forum']) ? $forums[$x]['xchan_url'] : z_root() . '/network/?f=&pf=1&unseen=1&cid=' . $forums[$x]['abook_id']);
+ $forums[$x]['notify_link'] = z_root() . '/network/?f=&pf=1&unseen=1&cid=' . $forums[$x]['abook_id'];
$forums[$x]['name'] = $forums[$x]['xchan_name'];
$forums[$x]['addr'] = $forums[$x]['xchan_addr'];
$forums[$x]['url'] = $forums[$x]['xchan_url'];